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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cf56c5f4fd811492b10686aa3349469bbf8d6220 | b286f1df0d10db9b0a3c00d2a26ee953e51354fc | /app/src/main/java/cn/xhl/client/manga/adapter/HomePagerAdapter.java | bbbd969e8ad68c517863f3d354922f7e7e2aa067 | [] | no_license | xiuhaoli/Manga | e8009046350fb225b73fc49322477e258c597a91 | 0453fe1af5213abfb6ecea38d7038376d40382c4 | refs/heads/master | 2021-05-10T16:08:02.942140 | 2018-02-28T01:40:55 | 2018-02-28T01:40:55 | 118,569,723 | 14 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,886 | java | package cn.xhl.client.manga.adapter;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;
import cn.xhl.client.manga.config.IConstants;
import cn.xhl.client.manga.presenter.main.LatestPresenter;
import cn.xhl.client.manga.view.main.fragment.LatestFragment;
/**
* @author Mike on 2017/10/10 0010.
* <p>
* 首页的适配器
*/
public class HomePagerAdapter extends FragmentPagerAdapter {
public HomePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
switch (position) {
case 0:
// 在getItem的时候会先从FragmentManager中取,不会每次都new
LatestFragment latestFragment = new LatestFragment();
Bundle bundle = new Bundle();
bundle.putString("type", IConstants.LATEST);
latestFragment.setArguments(bundle);
new LatestPresenter(latestFragment);
return latestFragment;
case 1:
LatestFragment recommend = new LatestFragment();
Bundle bundle1 = new Bundle();
bundle1.putString("type", IConstants.RECOMMEND);
recommend.setArguments(bundle1);
new LatestPresenter(recommend);
return recommend;
case 2:
LatestFragment rankingFragment = new LatestFragment();
Bundle bundle2 = new Bundle();
bundle2.putString("type", IConstants.RANKING);
rankingFragment.setArguments(bundle2);
new LatestPresenter(rankingFragment);
return rankingFragment;
case 3:
LatestFragment attendFragment = new LatestFragment();
Bundle bundle3 = new Bundle();
bundle3.putString("type",IConstants.ATTENTION);
attendFragment.setArguments(bundle3);
new LatestPresenter(attendFragment);
return attendFragment;
default:
return null;
}
}
@Override
public int getCount() {
return 4;
}
@Override
public CharSequence getPageTitle(int position) {
// tab会从这里取数据作为标题,父类只返回了null,因此要重写
switch (position) {
case 0:
return "Latest";
case 1:
return "Trending";
case 2:
return "Ranking";
case 3:
return "Following";
default:
return super.getPageTitle(position);
}
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
}
}
| [
"[email protected]"
] | |
7913082366488587bfd10db7b799e65ca7458959 | ea04a2cea870b26f2032b54ed3e08986bf74152f | /skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java | 5c45742b6c67e5ebfb08e4767133891542936048 | [
"Apache-2.0"
] | permissive | PatrickCheevers/jclouds | 55aa44538ebe85c6521f8741a1fb4795a5b4bcc5 | 464bca0ec1f4a2826499c891fa6ed796650f9da1 | refs/heads/master | 2021-01-13T10:31:21.466745 | 2010-10-19T22:08:11 | 2010-10-19T22:08:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,017 | java | package org.jclouds.servermanager.compute;
import static org.testng.Assert.assertNotNull;
import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ServerManagerComputeServiceContextBuilderTest {
@Test
public void testCreateContextModule() {
assertNotNull(ServerManagerComputeServiceContextBuilder.createContextModule());
}
@Test
public void testCanBuildDirectly() {
ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder(new Properties())
.buildComputeServiceContext();
context.close();
}
@Test
public void testCanBuildWithComputeService() {
ComputeServiceContext context = ComputeServiceContextFactory
.createStandaloneContext(ServerManagerComputeServiceContextBuilder.createContextModule());
context.close();
}
}
| [
"[email protected]"
] | |
cec920b6710126b7b9ce295745e2186b461fca84 | ee8f5c975ab1a7a8ada7e0d639cb00389a5c6d1d | /src/test/java/com/mavanit/selenium/SmokeTest.java | 4887785f7783b0f5257ae7dd781169af9cd05019 | [] | no_license | Tharini05/newargos | ed5ceddbf70c463680dad3cfe562dd19c5140c22 | f6a843250a1c020e6e069370c5a5a5bbbf3e312b | refs/heads/master | 2021-01-04T21:50:02.761217 | 2020-02-15T19:09:47 | 2020-02-15T19:09:47 | 240,773,161 | 0 | 0 | null | 2020-10-13T19:34:28 | 2020-02-15T19:10:44 | Java | UTF-8 | Java | false | false | 10,243 | java | package com.mavanit.selenium;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.fail;
public class SmokeTest extends Hooks {
@Test
public void searchTest() {
doSearch("puma");
String url = driver.getCurrentUrl();
assertThat(url, endsWith("puma"));
List<WebElement> productWebElements = driver.findElements(By.cssSelector("a[data-test='component-product-card-title']"));
for (WebElement indProduct : productWebElements) {
String actual = indProduct.getText();
assertThat(actual, containsString("Puma"));
}
String actualTitle = driver.findElement(By.className("search-title__term")).getText();
assertThat(actualTitle, is(equalToIgnoringCase("puma")));
driver.findElement(By.id("searchTerm")).sendKeys("puma");
driver.findElement(By.id("searchTerm")).sendKeys(Keys.ENTER);
}
@Test
public void basketTest() throws InterruptedException {
doSearch("nike");
List<WebElement> productWebElements = driver.findElements(By.cssSelector("a[data-test='component-product-card-title']"));
if (productWebElements.size() == 0) {
fail("No Products found with: " + "nike");
}
// TODO: 2020-02-08 this will be converted in future
Random random = new Random();
int randomNumber = random.nextInt(productWebElements.size() - 1);
WebElement selectedElement = productWebElements.get(randomNumber);
String selectedProductName = selectedElement.getText();
selectedElement.click();
addToBasket();
goToBasket();
String actual = getProductInBasket();
assertThat(actual, is(equalToIgnoringCase(selectedProductName)));
}
public void doSearch(String searchTerm) {
driver.findElement(By.id("searchTerm")).sendKeys(searchTerm);
driver.findElement(By.id("searchTerm")).sendKeys(Keys.ENTER);
}
public void addToBasket() {
driver.findElement(By.cssSelector("button[data-test='component-att-button']")).click();
}
public void goToBasket() throws InterruptedException{
Thread.sleep(1500);
driver.findElement(By.cssSelector(".xs-row a[data-test='component-att-button-basket']")).click();
}
public String getProductInBasket(){
return driver.findElement(By.cssSelector(".ProductCard__content__9U9b1.xsHidden.lgFlex .ProductCard__titleLink__1PgaZ")).getText();
}
@Test
public void selectMultiple()throws InterruptedException
{
doSearch("nike");
Thread.sleep(1500);
List<WebElement> productWebElements = driver.findElements(By.cssSelector("a[data-test='component-product-card-title']"));
if (productWebElements.size() == 0) {
fail("No Products found with: " + "nike");
}
// TODO: 2020-02-08 this will be converted in future
Random random = new Random();
int randomNumber = random.nextInt(productWebElements.size() - 1);
WebElement selectedElement = productWebElements.get(randomNumber);
//String selectedProductName = selectedElement.getText();
selectedElement.click();
//Drag and drop selection
Thread.sleep(2500);
WebElement NoOfQuantity=driver.findElement(By.cssSelector(".xs-4--none select[data-test=\"select\"]"));
Select selectedNumber=new Select(NoOfQuantity);
selectedNumber.selectByVisibleText("2");
WebElement valueSelected=selectedNumber.getFirstSelectedOption();
String value=valueSelected.getText();
int noOfProducts=Integer.parseInt(value);
System.out.println("No of Quantity="+noOfProducts);
addToBasket();
Thread.sleep(1500);
goToBasket();
Thread.sleep(2500);
//String actualValue=driver.findElement(By.cssSelector(".ProductCard__price__1vkg0 .ProductCard__productLinePrice__3QC7V")).getText();
String actualValue=driver.findElement(By.cssSelector(".Summary__totalInformation__2hwn3 .Summary__subTotalLabel__2GphY")).getText();
System.out.println("Total value="+actualValue);
double totalValue=(actualValue.contains("£"))?Double.parseDouble(actualValue.replace("£","")):0.0;
System.out.println("Actual Total Amount="+totalValue);
String productsAmount=driver.findElement(By.cssSelector(".ProductCard__unitPrice__rTWTs span[data-e2e=\"product-unit-price\"]")).getText();
System.out.println("Amount of single product"+productsAmount);
double unitPrice=(productsAmount.contains("£"))?Double.parseDouble(productsAmount.replace("£","")):0.0;
System.out.println("Total Amount"+unitPrice);
double expectedResult=resultCalculation(unitPrice,noOfProducts);
System.out.println("Expected result="+expectedResult);
assertThat(totalValue,is(expectedResult));
}
public double resultCalculation(double unitPrice,double noOfProducts)
{
if (noOfProducts!=0)
return unitPrice+resultCalculation(unitPrice,noOfProducts-1);
else
return 0;
}
public void waitTime(int time)
{
driver.manage().timeouts().implicitlyWait(time, TimeUnit.MILLISECONDS);
}
@Test
public void continueShopping() throws InterruptedException,NumberFormatException
{
doSearch("puma");
waitTime(5000);
List<WebElement> productWebElements = driver.findElements(By.cssSelector("a[data-test='component-product-card-title']"));
if (productWebElements.size() == 0) {
fail("No Products found with: " + "nike");
}
Random random = new Random();
int randomNumber = random.nextInt(productWebElements.size() - 1);
WebElement selectedElement = productWebElements.get(randomNumber);
selectedElement.click();
//Drag and drop selection
WebElement NoOfQuantity=driver.findElement(By.cssSelector(".xs-4--none select[data-test=\"select\"]"));
Select selectedNumber=new Select(NoOfQuantity);
selectedNumber.selectByVisibleText("1");
addToBasket();
//Continue shopping
driver.findElement(By.cssSelector("button[data-test=\"component-att-button-continue\"]")).click();
doSearch("nike");
List<WebElement> productWebElements1 = driver.findElements(By.cssSelector("a[data-test='component-product-card-title']"));
if (productWebElements1.size() == 0) {
fail("No Products found with: " + "nike");
}
Random random1 = new Random();
int randomNumber1 = random1.nextInt(productWebElements1.size() - 1);
WebElement selectedElement1 = productWebElements1.get(randomNumber1);
selectedElement1.click();
//Drag and drop selection
WebElement NoOfQuantity1=driver.findElement(By.cssSelector(".xs-4--none select[data-test=\"select\"]"));
Select selectedNumber1=new Select(NoOfQuantity1);
selectedNumber1.selectByVisibleText("1");
addToBasket();
goToBasket();
int noOfProduct;
double productPrice,unitPrice,totalIndProduct;
double grossTotal=0.0;
waitTime(5000);
List<WebElement> productsInBasket=driver.findElements(By.cssSelector(".xs-12--none.md-6--none.lg-7--none.undefined li[data-e2e=\"basket-productcard\"]"));
for (WebElement indiProduct : productsInBasket)
{
String nameOfProduct=indiProduct.findElement(By.cssSelector(".ProductCard__content__9U9b1.xsHidden.lgFlex .ProductCard__titleLink__1PgaZ")).getText();
System.out.println("Name of the product="+nameOfProduct);
//Selection of number of products
WebElement noOfQuantity=indiProduct.findElement(By.cssSelector(".ProductCard__quantityContainer__2gY5E .ProductCard__quantitySelect__2y1R3"));
Select selectedNo=new Select(noOfQuantity);
WebElement valueSelected=selectedNo.getFirstSelectedOption();
String presentValue=valueSelected.getText();
noOfProduct=Integer.parseInt(presentValue);
System.out.println("No of Quantity"+noOfProduct);
//Selection of product price
String productValue=indiProduct.findElement(By.cssSelector(".ProductCard__pricesContainer__dA7SA .ProductCard__price__1vkg0")).getText();
System.out.println("Product value:"+productValue);
productPrice=(productValue.contains("£"))?Double.parseDouble(productValue.replace("£"," ")):0.0;
System.out.println("Products total amount"+productPrice);
//Selection of unit price
if(noOfProduct==1)
{
totalIndProduct=resultCalculation(productPrice,noOfProduct);
}
else
{
String productsUnitAmount=indiProduct.findElement(By.cssSelector(".ProductCard__unitPrice__rTWTs span[data-e2e=\"product-unit-price\"]")).getText();
unitPrice=(productsUnitAmount.contains("£"))?Double.parseDouble(productsUnitAmount.replace("£"," ")):0.0;
System.out.println("Total Amount"+unitPrice);
totalIndProduct=resultCalculation(unitPrice,noOfProduct);
}
grossTotal=grossTotal+totalIndProduct;
}
System.out.println("Gross Total="+grossTotal);
String actualValue=driver.findElement(By.cssSelector(".Summary__totalInformation__2hwn3 .Summary__subTotalLabel__2GphY")).getText();
System.out.println("Total value="+actualValue);
double totalValue=(actualValue.contains("£"))?Double.parseDouble(actualValue.replace("£","")):0.0;
System.out.println("Actual Total Amount="+totalValue);
assertThat(totalValue,is(grossTotal));
}
}
| [
"[email protected]"
] | |
e7f08d1dfa4d20415ca38fa82c18a0f9b72875f5 | b287cbcc7d41f12a198112c4c5f19f6c73d864e4 | /app/src/main/java/com/example/bozhilun/android/bzlmaps/sos/GPSGaoDeUtils.java | bca446aaad1e76123c122a5d9c064107dd526f2e | [
"Apache-2.0"
] | permissive | sengeiou/RaceFitPro | dffc24ee4a70bae7f944f47696ed09bc799e0e83 | 8487da3a9cea4eefed27c727e02fc6786a91b603 | refs/heads/master | 2022-11-16T18:38:02.142577 | 2020-07-08T08:43:17 | 2020-07-08T08:43:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,022 | java | package com.example.bozhilun.android.bzlmaps.sos;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.example.bozhilun.android.Commont;
import com.example.bozhilun.android.MyApp;
import com.example.bozhilun.android.R;
import com.example.bozhilun.android.siswatch.utils.WatchUtils;
import com.suchengkeji.android.w30sblelibrary.utils.SharedPreferencesUtils;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Administrator on 2018/4/17.
* 获取用户的地理位置
*/
public class GPSGaoDeUtils {
private static GPSGaoDeUtils instance;
private Context mContext;
//声明mlocationClient对象
public AMapLocationClient mlocationClient;
//声明mLocationOption对象
public AMapLocationClientOption mLocationOption = null;
private GPSGaoDeUtils(Context context) {
this.mContext = context;
mlocationClient = new AMapLocationClient(mContext);
//初始化定位参数
mLocationOption = new AMapLocationClientOption();
//设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//设置定位间隔,单位毫秒,默认为2000ms
mLocationOption.setInterval(5000);
//设置定位参数
mlocationClient.setLocationOption(mLocationOption);
// 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
// 注意设置合适的定位时间的间隔(最小间隔支持为1000ms),并且在合适时间调用stopLocation()方法来取消定位请求
// 在定位结束后,在合适的生命周期调用onDestroy()方法
// 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
//启动定位
mlocationClient.startLocation();
//设置定位监听
mlocationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//经纬度
double latitude = amapLocation.getLatitude();
double longitude = amapLocation.getLongitude();
//详细地址
String dizhi = amapLocation.getCountry()//国
+ " " + amapLocation.getProvince()//省
+ " " + amapLocation.getCity()//城
+ " " + amapLocation.getDistrict()//区
+ " " + amapLocation.getStreet()//街
+ " " + amapLocation.getStreetNum();//街道门牌号信息
if (WatchUtils.isEmpty(dizhi)) dizhi = amapLocation.getAddress();
//预编的紧急内容
String stringpersonContent = (String) SharedPreferencesUtils.getParam(MyApp.getInstance(), "personContent", "");
if (WatchUtils.isEmpty(stringpersonContent))
stringpersonContent = mContext.getResources().getString(R.string.string_emergency_gelp);
Commont.SENDMESSGE_COUNT++;
Log.e("----------AA", "计算发送次数 " + Commont.SENDMESSGE_COUNT);
if (Commont.SENDMESSGE_COUNT == 1) {
Intent intent_message = new Intent();
intent_message.setAction(Commont.SOS_SENDSMS_MESSAGE);
intent_message.putExtra("msm", stringpersonContent.trim() + " " + latitude + "," + longitude);
Log.e("----------AA", "拿到位置-- - 位置广播已经发送 去发短信 msm");
mContext.sendBroadcast(intent_message);
} else if (Commont.SENDMESSGE_COUNT == 2) {
Intent intent_location = new Intent();
intent_location.setAction(Commont.SOS_SENDSMS_LOCATION);
intent_location.putExtra("gps", dizhi.trim());
Log.e("----------AA", "拿到位置-- - 位置广播已经发送 去发短信 gps");
mContext.sendBroadcast(intent_location);
} else {
stopGPS();
destroyGPS();
}
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
});
}
/**
* 停止定位
*/
void stopGPS() {
if (mlocationClient != null) {
mlocationClient.stopLocation();//停止定位后,本地定位服务并不会被销毁
mlocationClient = null;
}
if (instance != null) instance = null;
}
/**
* 销毁定位
*/
void destroyGPS() {
if (mlocationClient != null) {
mlocationClient.onDestroy();//销毁定位客户端,同时销毁本地定位服务。
mlocationClient = null;
}
}
public static GPSGaoDeUtils getInstance(Context context) {
return new GPSGaoDeUtils(context);
}
} | [
"[email protected]"
] | |
1f5ba7b2ac104d5e6ca098b30367cec26db37e9f | 56072a9cbcf659a377c1bd93472fe74df1549177 | /BridgelabDay2/src/Basic_Square_number/Patt4_Basic_Numb_Star.java | dc09be0b6ed81807606bc898d42ec56a38106580 | [] | no_license | Ravi9038/BridgeLabz- | 83de8fdcd1b17f0d241dd08e35776e76c5beebc9 | 42f3dae8eacfe9d07a0993957347b3bd9b519584 | refs/heads/master | 2021-08-11T06:15:47.831081 | 2021-07-29T06:45:00 | 2021-07-29T06:45:00 | 249,673,446 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 545 | java | package Basic_Square_number;
public class Patt4_Basic_Numb_Star {
public static void main(String[] args) {
int num1 = 1, num2 = 9;
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= 7; j++) {
if(j%2 == 0) {
System.out.print("*");
}else {
if (i == 1 || i == 4) {
System.out.print(num1);
num1++;
}else {
System.out.print(num2);
num2++;
}
}
}
System.out.println();
}
}
}
/**
1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8
*/
| [
"[email protected]"
] | |
52173248c64e33ab4397ec8a95897bd440312eda | a234b2e607c230c30ff2a31831c9f53c642c73d4 | /platforms/android/src/com/yoguin/hola/MainActivity.java | b60f9195c97f50368dca9b7b6619c12bbd98c2bb | [] | no_license | nathaliesicard/yoguin-android | 6e2a87edb9ce249577aae2e2820299bf6b0131bb | 5cb3430fa8b3290c8bd5a80a11568f57a8b09341 | refs/heads/master | 2020-03-30T02:54:59.046680 | 2016-10-07T17:11:44 | 2016-10-07T17:11:44 | 59,971,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,208 | 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 com.yoguin.hola;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
| [
"[email protected]"
] | |
26dca049e35e38ae7637be37e615a16a31a7ae3b | 24e6d49a50faf43b0f7622dd3f6855344201c052 | /stage1/mode1/code/1/DateConvert.java | 27d0ae97c9a3727c07e5950c9eae924f54dbae4d | [] | no_license | lxfgg66/lagou-javawork | c1b25243c20549420bf56ae72d84db19635d6c78 | f2e7e54905cc0c4e627cd8c1442f56c7f41dad5f | refs/heads/master | 2022-12-14T16:06:57.412867 | 2020-09-10T07:38:00 | 2020-09-10T07:38:00 | 294,337,391 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,143 | java | /*
编程实现根据年月日判断为一年中的第几天
*/
import java.util.Scanner;
public class DateConvert {
public static void main(String args[]) {
// 1.提示用户输入年月日
System.out.print("请输入年月日:");
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
int month = sc.nextInt();
int day = sc.nextInt();
// 2.将年月日转换为第几天
// 2.1 校验year是否合法
if(year < 0){
System.out.println("无效日期!");
return;
}
// 2.2 校验day是否合法
switch(month){
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
if(day < 1 || day > 31){
System.out.println("无效日期!");
return;
}
break;
case 4:case 6:case 9:case 11:
if(day < 1 || day > 30){
System.out.println("无效日期!");
return;
}
break;
case 2:
if(year % 4 == 0 && year % 100 != 0){
if(day < 1 || day > 29){
System.out.println("无效日期!");
return;
}
break;
}else{
if(day < 1 || day > 28){
System.out.println("无效日期!");
return;
}
break;
}
}
// 2.3 校验月份是否合法,同时将日期转换为天数
int t = 0; //记录天数
switch(month){
case 1: t = day;break;
case 2: t = 31 + day; break;
case 3: t = 31 + 28 + day;break;
case 4: t = 31 + 28 + 31 + day;break;
case 5: t = 31 + 28 + 31 + 30 + day;break;
case 6: t = 31 + 28 + 31 + 30 + 31 + day;break;
case 7: t = 31 + 28 + 31 + 30 + 31 + 30 + day;break;
case 8: t = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;break;
case 9: t = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;break;
case 10: t = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;break;
case 11: t = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;break;
case 12: t = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;break;
default: System.out.println("无效日期!");return;
}
if(year % 4 == 0 && year % 100 != 0 && month > 2){
t += 1;
}
// 3.输出天数
System.out.println(year + "年" + month + "月" + day + "日是一年的第" + t + "天");
}
} | [
"[email protected]"
] | |
38944c56f3469cdab003e8042a03b7d9c7afbc81 | df9f50141b01b7b224bbaeea7651311881d99219 | /src/aps/loop/java/modelo/ControleCena.java | bf8b4cf541a083a80dff37ba2f9fe881bcbeb4aa | [] | no_license | NatanMalta/APS-LPOO | a3592a739be453ab71624b62360d686d10b82d07 | b96daeec692d7ff17a693fa90158ef09075ace14 | refs/heads/master | 2022-09-08T17:39:38.744218 | 2020-05-30T00:27:57 | 2020-05-30T00:27:57 | 263,749,160 | 0 | 1 | null | 2020-05-26T22:43:27 | 2020-05-13T21:40:51 | Java | UTF-8 | Java | false | false | 483 | java | package aps.loop.java.modelo;
public class ControleCena
{
public Cena cena;
public ControleCena()
{
this.cena = new Cena();
}
public void executaEscolha(int num) throws Exception
{
this.executaEscolha(this.cena.getEscolhas().get(num));
}
public void executaEscolha(Escolha e) throws Exception
{
this.cena.limpar();
String novaCena = this.cena.lerCena(e.getArquivo());
this.cena.montaCena(novaCena);
}
} | [
"[email protected]"
] | |
c161f7225dda35b9f7d1169cc5d07419ea24c663 | b28f58c768a496f151a509388d8b2590e15aaef6 | /src/test/java/cucumber/IsItFriday.java | f2f67e54b0459b51a4e8000c5820d4084cdad0f3 | [] | no_license | kappsegla/Test19 | 77ef0f50c4f486f5a9559b1590cfa374e0c8513a | 9d65d1bfb207e9f75030694bd83667c7d157e432 | refs/heads/master | 2023-07-25T11:35:08.721849 | 2022-02-15T08:32:26 | 2022-02-15T08:32:26 | 224,134,615 | 0 | 1 | null | 2023-07-07T21:57:26 | 2019-11-26T07:58:45 | Java | UTF-8 | Java | false | false | 349 | java | package cucumber;
import java.util.List;
public class IsItFriday {
public static String isItFriday(String today) {
if( today.equals("Friday"))
return "TGIF";
return "Nope";
}
public static long countFridays(List<String> days) {
return days.stream().filter(s -> s.equals("Friday")).count();
}
}
| [
"[email protected]"
] | |
4a8f36d3c6bdc77c9c2c3b6b6c0b57468148b123 | 207be8dcadd7f22df27fe61f46cc2a9fc77bc50d | /src/main/java/com/azarenka/words/service/util/ApplicationUtil.java | 0a58bf0f61ca1922d69587d220292cbdf73ce21a | [] | no_license | AntonAzarenka/words | 8ca21ce587fdec6d556baf29e79efcf14e253977 | 64a66924187760c1a7aa0e3d2dd322902ce82786 | refs/heads/master | 2023-01-11T00:21:13.363595 | 2022-12-27T07:21:18 | 2022-12-27T07:21:18 | 253,557,986 | 0 | 3 | null | 2020-06-09T06:45:01 | 2020-04-06T16:41:37 | Java | UTF-8 | Java | false | false | 601 | java | package com.azarenka.words.service.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents of util methods.
* <p>
* Copyright (C) 2022 [email protected]
* <p>
* Date: 12/26/2022
*
* @author Anton Azarenka
*/
public class ApplicationUtil {
/**
* Returns logger.
*
* @return instance of {@link Logger}
*/
public static Logger getLogger() {
final Throwable t = new Throwable();
t.fillInStackTrace();
final String clazz = t.getStackTrace()[1].getClassName();
return LoggerFactory.getLogger(clazz);
}
}
| [
"[email protected]"
] | |
03f5168318589359506e6c1f4cc36b968ac784f9 | 4f2a55321393f2a15ae37ffbcff4467984c918ff | /Sort/src/com/sort/bucket/BucketSort.java | 7019ceef893d9b69b4d38ea2743ee8120e465ce9 | [] | no_license | FEFJay/myproject | 2a7fcc63ccedcb1d0050f99aeab65c1890c70b1c | 59166889fea1484894352f1692c132d6f93c570b | refs/heads/master | 2021-01-12T00:18:54.131406 | 2017-01-17T03:41:00 | 2017-01-17T03:41:00 | 78,704,111 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,583 | java | package com.sort.bucket;
import com.sort.main.MySort;
public class BucketSort implements MySort{
public void sort(int[] a){
// System.out.println("BucketSort");
if (null == a || a.length < 2) {
return;
}
bucketSort(a);
}
/**************************************
*
* @param 待排序数组
* @author JayLi
* @function 根据数组的最大值max,设定桶的个数(从0到max一共有max+1个),然后根据最低位优先法往桶里面放元素,再按照一定顺序倒出来即可.要求数组元素都是自然数。
*
*
* ***********************************/
private void bucketSort(int[] a ) {
//找到最大的元素
int max = 0;
for (int i : a) {
if (i > max) {
max = i;
}
}
//计数数组,用于计算对应的桶一个有几个元素。注意要排序的元素,就是count数组的下标,这是一一对应的。
// int len = max > a.length ? max : a.length;
int len = max ;
int[] count = new int[len+1];
//开始计数,进行入桶操作
for (int i = 0; i < a.length; i++) {
count[a[i]]++;
}
//进行出桶操作,完成出桶就完成排序
for (int i = 0, k = 0; i < count.length; i++) {
for (; count[i] > 0; count[i]--) {
a[k++] = i; //要排序的元素,就是count数组的下标
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
// int[] a={4,5,45,6,1,7,9,166,88,0,4};
int[] a={1,1,0,2};
new BucketSort().sort(a);
for (int i : a) {
System.out.print(i+" ");
}
}
}
| [
"[email protected]"
] | |
702369887026adb8a85fe55f25fc59f045d29a60 | 723ce9e722d3753b54335438102609f1f0273d2f | /main/java/net/journey/dimension/boil/BiomeGenBoiling.java | ab91bad18f2325868fe2de849de42c73e719e5a4 | [] | no_license | Dizzlepop12/Journey | 72b6ee9bc2f38062cf3b3515ede1243e6591efe3 | c314bbaf411a81e61f0df0fb129037c31c4590d9 | refs/heads/master | 2021-01-11T02:47:17.027290 | 2018-07-03T03:47:54 | 2018-07-03T03:47:54 | 56,901,235 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,695 | java | package net.journey.dimension.boil;
import java.awt.Color;
import java.util.Random;
import net.journey.JourneyBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class BiomeGenBoiling extends BiomeGenBase {
public BiomeGenBoiling(int par1) {
super(par1);
this.setBiomeName("Boiling Point");
this.topBlock = JourneyBlocks.hotBlock.getDefaultState();
this.fillerBlock = JourneyBlocks.hotBlock.getDefaultState();
this.spawnableCreatureList.clear();
this.spawnableMonsterList.clear();
this.spawnableCaveCreatureList.clear();
this.spawnableWaterCreatureList.clear();
rainfall = 0.0F;
setDisableRain();
setColor(0xC40600);
}
/*@Override
public void genTerrainBlocks(World w, Random r, Block[] b, byte[] by, int x, int z, double d) {
double d1 = plantNoise.func_151601_a((double)x * 0.25D, (double)z * 0.25D);
if(d1 > 0.0D) {
int k = x & 15;
int l = z & 15;
int i1 = b.length / 256;
for(int j1 = 255; j1 >= 0; --j1) {
int k1 = (l * 16 + k) * i1 + j1;
if(b[k1] == null || b[k1].getMaterial() != Material.air) {
if (j1 == 62 && b[k1] != Blocks.lava) {
b[k1] = Blocks.lava;
}
break;
}
}
}
this.genBiomeTerrain(w, r, b, by, x, z, d);
}*/
@Override
public int getSkyColorByTemp(float f) {
return Color.getHSBColor(0.0F, 0.0F, 0.0F).getRGB();
}
} | [
"[email protected]"
] | |
2324e8519f940f4b0c815560c5c5a3dfc167c13d | 17242f4d30d7f375d9198cbf447baeda2afc65ce | /springboot-file-server/file-server-v2/src/main/java/com/github/ren/file/model/request/CheckRequest.java | 8998869d939b4034fb16e747ee76a776a2c17d3e | [] | no_license | DorraChen/springboot-file-server | 166852f2d389d98c93432a14f36b1bab8818c13f | 9ddc32ab9716be25c7614b54558dc7dd2ac18ab0 | refs/heads/master | 2023-06-02T21:07:32.892440 | 2021-06-11T11:14:14 | 2021-06-11T11:14:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 359 | java | package com.github.ren.file.model.request;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Description 检测文件参数
* @Author ren
* @Since 1.0
*/
@Data
@ApiModel("检测文件参数")
public class CheckRequest {
@NotBlank(message = "md5不能为空")
private String md5;
}
| [
"[email protected]"
] | |
015a9570cb4098f8e73914ca9387e9f786f1ebf5 | bd81675872ac5b22996f9acbd17175e8f501426f | /app/src/main/java/com/example/firebasenotification/FirebaseMessanging.java | 18c498d83b29c12dfea514472749dcb56e33677f | [] | no_license | arunktaria/FirebaseNotification | 3d80afeffa0be9d1642236fde9ce30a0b4d1d617 | 7488c5224d78e3f8c1e4c5145888edac82802226 | refs/heads/master | 2023-08-14T06:36:55.242992 | 2021-09-21T08:12:29 | 2021-09-21T08:12:29 | 407,485,043 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,246 | java | package com.example.firebasenotification;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class FirebaseMessanging extends FirebaseMessagingService {
Bitmap bitmap;
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.userimg1);
showMessage(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
}
void showMessage(String title, String des) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setLargeIcon(bitmap)
.setContentTitle(title)
.setContentText(des);
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);
managerCompat.notify(100, builder.build());
}
}
| [
"[email protected]"
] | |
2ea92319563328443d95c96a90d8db69a817a7ca | cf4b0851d6e3ba16f3ada1b7b9c7831aa7c9f4bb | /src/java_20190812/MemberDto.java | 7121d944eb93fe1398a494e0a3bb6922bf190fb0 | [] | no_license | sch930214/Java_Fundamental | 37565251063749fa69068dd6a18143be79cec8f7 | 0569d3479e6a3efe8239af4082655122dc399e23 | refs/heads/master | 2020-06-21T17:48:36.406564 | 2019-09-10T11:29:43 | 2019-09-10T11:29:43 | 197,150,967 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 577 | java | package java_20190812;
public class MemberDto {
private int num;
private String name;
private String addr;
public MemberDto(int num, String name, String addr) {
super();
this.num = num;
this.name = name;
this.addr = addr;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}
| [
"KITCOOP@DESKTOP-428VTGC"
] | KITCOOP@DESKTOP-428VTGC |
032b51780130ec91de4690f7b29d7de631477e39 | 47ccba8486449b903e735713af9deb3000c8f12e | /src/com/datapower/schemas/appliance/management/_3/DeviceOperation.java | 1a787955dd273ffb1716500574b3b59137ca3f01 | [] | no_license | secintic/dpManager | 4b37e72ffb5206804244b367c5d06f6e70290309 | f867de70743b6324b261a6e66d589b9169c04822 | refs/heads/master | 2020-03-28T21:08:17.507109 | 2018-09-17T14:02:52 | 2018-09-17T14:02:52 | 149,131,753 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,690 | java |
package com.datapower.schemas.appliance.management._3;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for device-operation.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="device-operation">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="Ping"/>
* <enumeration value="GetToken"/>
* <enumeration value="Reboot"/>
* <enumeration value="SetFirmware"/>
* <enumeration value="Reinitialize"/>
* <enumeration value="SecureBackup"/>
* <enumeration value="SecureRestore"/>
* <enumeration value="WhenDeviceLastChanged"/>
* <enumeration value="Quiesce"/>
* <enumeration value="Unquiesce"/>
* <enumeration value="GetDeviceInfo"/>
* <enumeration value="GetDeviceSettings"/>
* <enumeration value="SetDeviceSettings"/>
* <enumeration value="GetErrorReport"/>
* <enumeration value="Subscribe"/>
* <enumeration value="Unsubscribe"/>
* <enumeration value="GetDomainList"/>
* <enumeration value="GetDomainStatus"/>
* <enumeration value="GetDomainExport"/>
* <enumeration value="SetDomainExport"/>
* <enumeration value="GetDomainConfig"/>
* <enumeration value="SetDomainConfig"/>
* <enumeration value="DeleteDomain"/>
* <enumeration value="StartDomain"/>
* <enumeration value="StopDomain"/>
* <enumeration value="RestartDomain"/>
* <enumeration value="GetCryptoArtifacts"/>
* <enumeration value="SetFile"/>
* <enumeration value="CompareConfig"/>
* <enumeration value="GetLog"/>
* <enumeration value="WAXHNActivate"/>
* <enumeration value="GetServiceListFromExport"/>
* <enumeration value="GetInterDependentServices"/>
* <enumeration value="GetServiceListFromDomain"/>
* <enumeration value="StartService"/>
* <enumeration value="StopService"/>
* <enumeration value="GetReferencedObjects"/>
* <enumeration value="DeleteService"/>
* <enumeration value="DeleteFile"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "device-operation")
@XmlEnum
public enum DeviceOperation {
@XmlEnumValue("Ping")
PING("Ping"),
@XmlEnumValue("GetToken")
GET_TOKEN("GetToken"),
@XmlEnumValue("Reboot")
REBOOT("Reboot"),
@XmlEnumValue("SetFirmware")
SET_FIRMWARE("SetFirmware"),
@XmlEnumValue("Reinitialize")
REINITIALIZE("Reinitialize"),
@XmlEnumValue("SecureBackup")
SECURE_BACKUP("SecureBackup"),
@XmlEnumValue("SecureRestore")
SECURE_RESTORE("SecureRestore"),
@XmlEnumValue("WhenDeviceLastChanged")
WHEN_DEVICE_LAST_CHANGED("WhenDeviceLastChanged"),
@XmlEnumValue("Quiesce")
QUIESCE("Quiesce"),
@XmlEnumValue("Unquiesce")
UNQUIESCE("Unquiesce"),
@XmlEnumValue("GetDeviceInfo")
GET_DEVICE_INFO("GetDeviceInfo"),
@XmlEnumValue("GetDeviceSettings")
GET_DEVICE_SETTINGS("GetDeviceSettings"),
@XmlEnumValue("SetDeviceSettings")
SET_DEVICE_SETTINGS("SetDeviceSettings"),
@XmlEnumValue("GetErrorReport")
GET_ERROR_REPORT("GetErrorReport"),
@XmlEnumValue("Subscribe")
SUBSCRIBE("Subscribe"),
@XmlEnumValue("Unsubscribe")
UNSUBSCRIBE("Unsubscribe"),
@XmlEnumValue("GetDomainList")
GET_DOMAIN_LIST("GetDomainList"),
@XmlEnumValue("GetDomainStatus")
GET_DOMAIN_STATUS("GetDomainStatus"),
@XmlEnumValue("GetDomainExport")
GET_DOMAIN_EXPORT("GetDomainExport"),
@XmlEnumValue("SetDomainExport")
SET_DOMAIN_EXPORT("SetDomainExport"),
@XmlEnumValue("GetDomainConfig")
GET_DOMAIN_CONFIG("GetDomainConfig"),
@XmlEnumValue("SetDomainConfig")
SET_DOMAIN_CONFIG("SetDomainConfig"),
@XmlEnumValue("DeleteDomain")
DELETE_DOMAIN("DeleteDomain"),
@XmlEnumValue("StartDomain")
START_DOMAIN("StartDomain"),
@XmlEnumValue("StopDomain")
STOP_DOMAIN("StopDomain"),
@XmlEnumValue("RestartDomain")
RESTART_DOMAIN("RestartDomain"),
@XmlEnumValue("GetCryptoArtifacts")
GET_CRYPTO_ARTIFACTS("GetCryptoArtifacts"),
@XmlEnumValue("SetFile")
SET_FILE("SetFile"),
@XmlEnumValue("CompareConfig")
COMPARE_CONFIG("CompareConfig"),
@XmlEnumValue("GetLog")
GET_LOG("GetLog"),
@XmlEnumValue("WAXHNActivate")
WAXHN_ACTIVATE("WAXHNActivate"),
@XmlEnumValue("GetServiceListFromExport")
GET_SERVICE_LIST_FROM_EXPORT("GetServiceListFromExport"),
@XmlEnumValue("GetInterDependentServices")
GET_INTER_DEPENDENT_SERVICES("GetInterDependentServices"),
@XmlEnumValue("GetServiceListFromDomain")
GET_SERVICE_LIST_FROM_DOMAIN("GetServiceListFromDomain"),
@XmlEnumValue("StartService")
START_SERVICE("StartService"),
@XmlEnumValue("StopService")
STOP_SERVICE("StopService"),
@XmlEnumValue("GetReferencedObjects")
GET_REFERENCED_OBJECTS("GetReferencedObjects"),
@XmlEnumValue("DeleteService")
DELETE_SERVICE("DeleteService"),
@XmlEnumValue("DeleteFile")
DELETE_FILE("DeleteFile");
private final String value;
DeviceOperation(String v) {
value = v;
}
public String value() {
return value;
}
public static DeviceOperation fromValue(String v) {
for (DeviceOperation c: DeviceOperation.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
| [
"[email protected]"
] | |
81e300ba7c9d75e5a64eda1b532e8fab42fe63cf | 6240dfe893719fe814a462e888f5fa2309b464a8 | /app/src/main/java/com/tdr/yunwei/activity/NewDeviceAddActivity.java | 318840e704fc2b36f837de0c02bd1c40f9cd352c | [] | no_license | KingJA/yunwei | bdf461380069bf62a0af420e894af58bb6e052ab | 8b5e5c351b76ee72857931653354c01eaf5722ea | refs/heads/master | 2020-03-12T14:08:19.930749 | 2018-07-17T05:14:05 | 2018-07-17T05:14:05 | 130,659,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 57,423 | java | package com.tdr.yunwei.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.CoordinateConverter;
import com.google.gson.Gson;
import com.tdr.yunwei.R;
import com.tdr.yunwei.baidumap.BaiDuMapActivity;
import com.tdr.yunwei.baidumap.BaiDuMapDeviceActivity;
import com.tdr.yunwei.bean.DeviceBean;
import com.tdr.yunwei.bean.DeviceBean2;
import com.tdr.yunwei.bean.DictionaryBean;
import com.tdr.yunwei.bean.ParamBean;
import com.tdr.yunwei.util.ActivityUtil;
import com.tdr.yunwei.util.Constants;
import com.tdr.yunwei.util.DBUtils;
import com.tdr.yunwei.util.DeviceInstallUtil;
import com.tdr.yunwei.util.LOG;
import com.tdr.yunwei.util.PhotoUtil;
import com.tdr.yunwei.util.PhotoUtils;
import com.tdr.yunwei.util.SharedUtil;
import com.tdr.yunwei.util.ToastUtil;
import com.tdr.yunwei.util.WebUtil;
import com.tdr.yunwei.util.ZProgressHUD;
import com.tdr.yunwei.util.ZbarUtil;
import com.tdr.yunwei.view.Dialog.DialogUtil;
import com.tdr.yunwei.view.Dialog.NormalListDialog;
import com.zbar.lib.CaptureActivity;
import org.json.JSONException;
import org.json.JSONObject;
import org.xutils.DbManager;
import org.xutils.ex.DbException;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by Administrator on 2017/11/20.
* 纠察网关
*/
@ContentView(R.layout.activity_new_device_add)
public class NewDeviceAddActivity extends Activity implements View.OnClickListener {
private static final String TAG = "NewDeviceAddActivity";
@ViewInject(R.id.image_back)
private ImageView image_back;
@ViewInject(R.id.iv_scan_serial)
private ImageView iv_scan_serial;
@ViewInject(R.id.TV_Title)
private TextView TV_Title;
@ViewInject(R.id.txt_modify)
private TextView txt_modify;
@ViewInject(R.id.et_devicecode)
private EditText et_devicecode;
@ViewInject(R.id.et_deviceName)
private EditText et_deviceName;
@ViewInject(R.id.LL_LastTime)
private LinearLayout LL_LastTime;
@ViewInject(R.id.TV_LastTime)
private TextView TV_LastTime;
@ViewInject(R.id.ll_Device_use)
private LinearLayout ll_Device_use;
@ViewInject(R.id.txt_Device_use)
private TextView txt_Device_use;
@ViewInject(R.id.ll_Station_Type)
private LinearLayout ll_Station_Type;
@ViewInject(R.id.txt_Station_Type)
private TextView txt_Station_Type;
@ViewInject(R.id.txt_devicetype)
private TextView txt_devicetype;
@ViewInject(R.id.et_deviceno)
private EditText et_deviceno;
@ViewInject(R.id.img_photo1)
private ImageView img_photo1;
@ViewInject(R.id.img_photo2)
private ImageView img_photo2;
@ViewInject(R.id.img_photo3)
private ImageView img_photo3;
@ViewInject(R.id.ll_baidu)
private LinearLayout ll_baidu;
@ViewInject(R.id.img_baidu)
private ImageView img_baidu;
@ViewInject(R.id.txt_lng)
private TextView txt_lng;
@ViewInject(R.id.txt_lat)
private TextView txt_lat;
@ViewInject(R.id.et_deviceaddress)
private EditText et_deviceaddress;
@ViewInject(R.id.LL_Type_Visibility)
private LinearLayout LL_Type_Visibility;
@ViewInject(R.id.ll_roadNum)
private LinearLayout ll_roadNum;
@ViewInject(R.id.txt_roadNum)
private TextView txt_roadNum;
@ViewInject(R.id.ll_roadType)
private LinearLayout ll_roadType;
@ViewInject(R.id.txt_roadType)
private TextView txt_roadType;
@ViewInject(R.id.ET_EastRoad)
private EditText ET_EastRoad;
@ViewInject(R.id.ET_SouthRoad)
private EditText ET_SouthRoad;
@ViewInject(R.id.ET_WestRoad)
private EditText ET_WestRoad;
@ViewInject(R.id.ET_NorthRoad)
private EditText ET_NorthRoad;
@ViewInject(R.id.ll_One_Geographic)
private LinearLayout ll_One_Geographic;
@ViewInject(R.id.txt_One_Geographic)
private TextView txt_One_Geographic;
@ViewInject(R.id.et_CentralNum)
private EditText et_CentralNum;
@ViewInject(R.id.ll_area)
private LinearLayout ll_area;
@ViewInject(R.id.txt_area)
private TextView txt_area;
@ViewInject(R.id.ll_pcs)
private LinearLayout ll_pcs;
@ViewInject(R.id.txt_pcs)
private TextView txt_pcs;
@ViewInject(R.id.ll_owner)
private LinearLayout ll_owner;
@ViewInject(R.id.txt_owner)
private TextView txt_owner;
@ViewInject(R.id.txt_repaircompany)
private TextView txt_repaircompany;
@ViewInject(R.id.rg_accesstype)
private RadioGroup rg_accesstype;
@ViewInject(R.id.rb_youxian)
private RadioButton rb_youxian;
@ViewInject(R.id.rb_wuxian)
private RadioButton rb_wuxian;
@ViewInject(R.id.ll_youxian)
private LinearLayout ll_youxian;
@ViewInject(R.id.et_ip)
private EditText et_ip;
@ViewInject(R.id.et_yanma)
private EditText et_yanma;
@ViewInject(R.id.et_wangguan)
private EditText et_wangguan;
@ViewInject(R.id.ll_wuxian)
private LinearLayout ll_wuxian;
@ViewInject(R.id.rg_yunyingshang)
private RadioGroup rg_yunyingshang;
@ViewInject(R.id.rb_yidong)
private RadioButton rb_yidong;
@ViewInject(R.id.rb_liantong)
private RadioButton rb_liantong;
@ViewInject(R.id.rb_dianxin)
private RadioButton rb_dianxin;
@ViewInject(R.id.et_phone)
private EditText et_phone;
@ViewInject(R.id.et_sim)
private EditText et_sim;
@ViewInject(R.id.et_mac)
private EditText et_mac;
@ViewInject(R.id.et_TelegraphPole)
private EditText et_TelegraphPole;
@ViewInject(R.id.et_height)
private EditText et_height;
@ViewInject(R.id.et_txt)
private EditText et_txt;
@ViewInject(R.id.TV_Submit)
private TextView TV_Submit;
@ViewInject(R.id.et_produceNo)
private EditText et_produceNo;
private Activity mActivity;
private DbManager DB;
private ZProgressHUD zProgressHUD;
private Gson mGson;
private DeviceInstallUtil DIU;
private String SystemID;
private String Address;
private String BaiduLAT;
private String BaiduLNG;
private String Photo1ToBase64;
private String Photo2ToBase64;
private String Photo3ToBase64;
private String status;
private DeviceBean2 device;
private Map<String, String> userMap = new HashMap<>();
private Map<String, String> typeMap = new HashMap<>();
private Map<String, String> userMap1 = new HashMap<>();
private Map<String, String> typeMap1 = new HashMap<>();
private boolean isVISIBLE = true;
private String deviceType;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e(TAG, "当前Activity: ");
x.view().inject(this);
initview();
ActivityUtil.AddActivity(mActivity);
status = getIntent().getStringExtra("status");
SystemID = DIU.getSystemID(getIntent().getStringExtra("DeviceType"));
LOG.E("SystemID=" + SystemID);
getUsageList1();
if (status.equals("安装")) {
Add();
}
if (status.equals("详情")) {
Xiangqing();
}
}
private void initview() {
mActivity = this;
mGson = new Gson();
zProgressHUD = new ZProgressHUD(mActivity);
deviceType = getIntent().getStringExtra("DeviceType");
Log.e(TAG, "设备类型: " + deviceType);
DB = x.getDb(DBUtils.getDb());
DIU = new DeviceInstallUtil(mActivity, DB);
image_back.setOnClickListener(this);
ll_Device_use.setOnClickListener(this);
ll_Station_Type.setOnClickListener(this);
iv_scan_serial.setOnClickListener(this);
txt_modify.setOnClickListener(this);
img_photo1.setOnClickListener(this);
img_photo2.setOnClickListener(this);
img_photo3.setOnClickListener(this);
ll_baidu.setOnClickListener(this);
ll_roadNum.setOnClickListener(this);
ll_roadType.setOnClickListener(this);
ll_One_Geographic.setOnClickListener(this);
ll_area.setOnClickListener(this);
ll_pcs.setOnClickListener(this);
ll_owner.setOnClickListener(this);
TV_Submit.setOnClickListener(this);
txt_repaircompany.setText(SharedUtil.getValue(mActivity, "CompanyName"));
rg_accesstype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (rb_youxian.getId() == checkedId) {
ll_wuxian.setVisibility(View.GONE);
ll_youxian.setVisibility(View.VISIBLE);
et_sim.setText("");
et_phone.setText("");
rg_yunyingshang.clearCheck();
}
if (rb_wuxian.getId() == checkedId) {
ll_wuxian.setVisibility(View.VISIBLE);
ll_youxian.setVisibility(View.GONE);
et_ip.setText("");
et_yanma.setText("");
et_wangguan.setText("");
}
}
});
}
private void Add() {
TV_Title.setText("安装设备");
TV_Submit.setText("确认安装");
txt_devicetype.setText(getIntent().getStringExtra("DeviceRemark"));
et_devicecode.setText(getIntent().getStringExtra("DeviceCode"));
txt_modify.setVisibility(View.GONE);
LL_LastTime.setVisibility(View.GONE);
LOG.E("DeviceType=" + getIntent().getStringExtra("DeviceType"));
if (userMap1 != null) {
String use = userMap1.get("101");
if (use != null && use.contains("纠章")) {
txt_Device_use.setText(use);
setVisible(View.VISIBLE);
} else {
setVisible(View.GONE);
}
}
}
private void Xiangqing() {
TV_Title.setText("设备详情");
TV_Submit.setText("返回");
txt_modify.setVisibility(View.VISIBLE);
initData();
}
private void initData() {
device = getIntent().getParcelableExtra("deviceBean");
String pic = getIntent().getStringExtra("pic");
SystemID = DIU.getSystemID(device.getDeviceType());
getListType1();
BaiduLAT = device.getReserve7();
BaiduLNG = device.getReserve8();
et_devicecode.setText(device.getDeviceCode());
txt_devicetype.setText(getIntent().getStringExtra("deviceremark"));
et_deviceno.setText(device.getSerialNumber());
String LNG = device.getLNG();
String LAT = device.getLAT();
Address = device.getAddress();
if ("".equals(LNG)) {
LNG = "0";
}
if ("".equals(LAT)) {
LAT = "0";
}
String lat, lng;
if (!device.getReserve8().equals("") && !device.getReserve7().equals("")) {
lat = device.getReserve8();
lng = device.getReserve7();
} else {
// 将GPS设备采集的原始GPS坐标转换成百度坐标
LatLng ll = new LatLng(Double.parseDouble(LAT), Double.parseDouble(LNG));
CoordinateConverter converter = new CoordinateConverter();
converter.from(CoordinateConverter.CoordType.GPS);
// sourceLatLng待转换坐标
converter.coord(ll);
LatLng desLatLng = converter.convert();
lat = desLatLng.latitude + "";
lng = desLatLng.longitude + "";
}
txt_lat.setText(lat);
txt_lng.setText(lng);
et_deviceaddress.setText(Address);
et_produceNo.setText(device.getReserve13());
txt_roadNum.setText(device.getROADNO());
if (userMap1 != null) {
txt_Device_use.setText(userMap1.get(device.getUsage()));
if (device.getUsage() != null && !device.getUsage().equals("")) {
if (device.getUsage().equals("101")) {
setVisible(View.VISIBLE);
} else {
setVisible(View.GONE);
}
}
}
if (typeMap1 != null) {
txt_Station_Type.setText(typeMap1.get(device.getReserve3()));
}
String roadType = "";
switch (device.getROADTYPE()) {
case "1":
roadType = "大型路口";
break;
case "2":
roadType = "中型路口";
break;
case "3":
roadType = "小型路口";
break;
}
TV_LastTime.setText(device.getReserve10());
txt_roadType.setText(roadType);
ET_EastRoad.setText(device.getEASTROAD_NAME());
ET_SouthRoad.setText(device.getSOUTHROAD_NAME());
ET_WestRoad.setText(device.getWESTROAD_NAME());
ET_NorthRoad.setText(device.getNORTHROAD_NAME());
txt_One_Geographic.setText(device.getDEVICEGROUD_DIRECTION());
et_CentralNum.setText(device.getDEVICEGROUD_ID());
LOG.E("AreaID=" + device.getAreaID());
txt_area.setText(DIU.AreaID2AreaMC(device.getAreaID()));
txt_pcs.setText(DIU.getPCSMC(device.getPCS()));
txt_owner.setText(DIU.getParamValue(device.getOwner(), SystemID));
txt_repaircompany.setText(DIU.getCompanyName(device.getRepairCompany()));
String AccessType = device.getAccessType();
LOG.E("AccessType=" + AccessType);
if (AccessType.equals("1")) {
rb_youxian.setChecked(true);
ll_youxian.setVisibility(View.VISIBLE);
ll_wuxian.setVisibility(View.GONE);
et_ip.setText(device.getIP());
et_yanma.setText(device.getMask());
et_wangguan.setText(device.getGateway());
}
if (AccessType.equals("2")) {
rb_wuxian.setChecked(true);
ll_youxian.setVisibility(View.GONE);
ll_wuxian.setVisibility(View.VISIBLE);
et_sim.setText(device.getSIM());
et_phone.setText(device.getPhone());
String CarrierOperator = device.getCarrierOperator();
LOG.E("CarrierOperator=" + CarrierOperator);
if (CarrierOperator.equals("移动")) {
rb_yidong.setChecked(true);
}
if (CarrierOperator.equals("联通")) {
rb_liantong.setChecked(true);
}
if (CarrierOperator.equals("电信")) {
rb_dianxin.setChecked(true);
}
}
et_mac.setText(device.getReserve4());
et_TelegraphPole.setText(device.getReserve1());
et_height.setText(device.getReserve2());
et_txt.setText(device.getDescription());
if (pic.equals("wu")) {
Photo1ToBase64 = device.getPhoto1();
Photo2ToBase64 = device.getPhoto2();
Photo3ToBase64 = device.getPhoto3();
}
if (pic.equals("you")) {
Photo1ToBase64 = SharedUtil.getValue(mActivity, "Photo1");
Photo2ToBase64 = SharedUtil.getValue(mActivity, "Photo2");
Photo3ToBase64 = SharedUtil.getValue(mActivity, "Photo3");
}
if (!Photo1ToBase64.equals("")) {
Bitmap bm = PhotoUtil.base64toBitmap(Photo1ToBase64);
bm = PhotoUtil.thumbnailBitmap(bm);
img_photo1.setImageBitmap(bm);
}
if (!Photo2ToBase64.equals("")) {
Bitmap bm = PhotoUtil.base64toBitmap(Photo2ToBase64);
bm = PhotoUtil.thumbnailBitmap(bm);
img_photo2.setImageBitmap(bm);
}
if (!Photo3ToBase64.equals("")) {
Bitmap bm = PhotoUtil.base64toBitmap(Photo3ToBase64);
bm = PhotoUtil.thumbnailBitmap(bm);
img_photo3.setImageBitmap(bm);
}
setViewEnabled(false);
}
private void setViewEnabled(boolean key) {
et_devicecode.setEnabled(key);
et_deviceno.setEnabled(key);
et_deviceaddress.setEnabled(key);
ll_Device_use.setEnabled(key);
ll_Station_Type.setEnabled(key);
ll_roadNum.setEnabled(key);
ll_roadType.setEnabled(key);
ET_NorthRoad.setEnabled(key);
ET_WestRoad.setEnabled(key);
ET_SouthRoad.setEnabled(key);
ET_EastRoad.setEnabled(key);
ll_One_Geographic.setEnabled(key);
et_CentralNum.setEnabled(key);
ll_area.setEnabled(key);
ll_pcs.setEnabled(key);
ll_owner.setEnabled(key);
rb_youxian.setEnabled(key);
rb_wuxian.setEnabled(key);
rb_yidong.setEnabled(key);
rb_liantong.setEnabled(key);
rb_dianxin.setEnabled(key);
et_ip.setEnabled(key);
et_yanma.setEnabled(key);
et_wangguan.setEnabled(key);
et_mac.setEnabled(key);
et_phone.setEnabled(key);
et_sim.setEnabled(key);
et_TelegraphPole.setEnabled(key);
et_height.setEnabled(key);
et_txt.setEnabled(key);
}
private static final int REQUEST_SCAN_SERIAL = 10086;
@Override
public void onClick(View v) {
switch (v.getId()) {
default:
break;
case R.id.iv_scan_serial:
CaptureActivity.goSimpleCaptureActivity(NewDeviceAddActivity.this, REQUEST_SCAN_SERIAL);
break;
case R.id.image_back:
finish();
break;
case R.id.ll_Device_use:
DialogUtil.ShowList(mActivity, txt_Device_use, getUsageList(), "设备用途", new NormalListDialog
.NLDListener() {
@Override
public void onSelect(String str) {
LOG.E("ll_Device_use=" + str);
if (str != null && !str.equals("")) {
String DeviceUse = userMap.get(str);
LOG.E("ll_Device_userMap=" + DeviceUse);
if (DeviceUse.equals("101")) {
setVisible(View.VISIBLE);
} else {
setVisible(View.GONE);
}
}
}
});
break;
case R.id.ll_Station_Type:
DialogUtil.ShowList(mActivity, txt_Station_Type, getListType(), "基站类型");
break;
case R.id.txt_modify:
LOG.E("modify=" + txt_modify.getText().toString());
if (txt_modify.getText().toString().equals("修改")) {
txt_modify.setText("取消");
TV_Submit.setText("确认修改");
status = "修改";
// setViewEnabled(true);
setViewEnable();
} else {
txt_modify.setText("修改");
TV_Submit.setText("返回");
status = "详情";
setViewEnabled(false);
initData();
}
break;
case R.id.img_photo1:
if (status.equals("详情")) {
ShowBigPic(mActivity, Photo1ToBase64);
} else {
PhotoUtils.takePicture(mActivity, "photo1.jpg");
}
break;
case R.id.img_photo2:
if (status.equals("详情")) {
ShowBigPic(mActivity, Photo2ToBase64);
} else {
PhotoUtils.takePicture(mActivity, "photo2.jpg");
}
break;
case R.id.img_photo3:
if (status.equals("详情")) {
ShowBigPic(mActivity, Photo3ToBase64);
} else {
PhotoUtils.takePicture(mActivity, "photo3.jpg");
}
break;
case R.id.ll_baidu:
if (status.equals("安装")) {
Intent intent1 = new Intent(mActivity, BaiDuMapActivity.class);
startActivityForResult(intent1, 4);
}
if (status.equals("详情") || status.equals("修改")) {
String lat = txt_lat.getText().toString();
String lng = txt_lng.getText().toString();
String address = et_deviceaddress.getText().toString();
LOG.D("lat=" + lat + " lng=" + lng);
if (lat.equals("") || Double.valueOf(lat) < 0 || lng.equals("") || Double.valueOf(lng) < 0) {
ToastUtil.ErrorOrRight(mActivity, "无法定位", 1);
}
if (!lat.equals("") && Double.valueOf(lat) > 0 && !lng.equals("") && Double.valueOf(lng) > 0) {
Intent intent = new Intent(mActivity, BaiDuMapDeviceActivity.class);
intent.putExtra("status", status);
intent.putExtra("DeviceLAT", lat);
intent.putExtra("DeviceLNG", lng);
intent.putExtra("DeviceAddress", address);
startActivityForResult(intent, 4);
}
}
break;
case R.id.ll_roadNum:
LOG.E("----------路口编号-----------");
List<String> l1 = new ArrayList<>();
for (int i = 1; i <= 15; i++) {
l1.add(i + "");
}
LOG.E("---------------------" + l1.toString());
DialogUtil.ShowList(mActivity, txt_roadNum, l1, "路口编号");
break;
case R.id.ll_roadType:
LOG.E("----------路口类型-----------");
List<String> l2 = new ArrayList<>();
l2.add("大型路口");
l2.add("中型路口");
l2.add("小型路口");
DialogUtil.ShowList(mActivity, txt_roadType, l2, "路口类型");
break;
case R.id.ll_One_Geographic:
List<String> l3 = new ArrayList<>();
l3.add("东");
l3.add("南");
l3.add("西");
l3.add("北");
DialogUtil.ShowList(mActivity, txt_One_Geographic, l3, "1号地埋方向");
break;
case R.id.ll_area:
String LastCity = SharedUtil.getValue(mActivity, "CityName");
if (et_deviceaddress.getText().toString().equals("")) {
ToastUtil.showShort(mActivity, "请先选择设备安装地址(经纬度)");
} else {
DialogUtil.ShowList(mActivity, txt_area, DIU.getAreaList(), LastCity + "区域列表");
txt_pcs.setText("");
}
break;
case R.id.ll_pcs:
String AreaMC = txt_area.getText().toString();
if (AreaMC.equals("")) {
ToastUtil.showShort(mActivity, "请先选择辖区");
} else {
DialogUtil.ShowList(mActivity, txt_pcs, DIU.getPCSList(DIU.getAreaID(AreaMC)), AreaMC + "派出所列表");
}
break;
case R.id.ll_owner:
DialogUtil.ShowList(mActivity, txt_owner, DIU.getOwnerList(SystemID), "产权人");
break;
case R.id.TV_Submit:
String txt = TV_Submit.getText().toString();
if (CheckData()) {
if (txt.equals("确认安装")) {
AddDevice();
}
if (txt.equals("确认修改")) {
ModifyDevice();
}
}
if (txt.equals("返回")) {
ActivityUtil.FinishActivity(mActivity);
}
break;
}
}
private void setViewEnable() {
et_devicecode.setEnabled(false);
et_deviceno.setEnabled(false);
et_deviceaddress.setEnabled(true);
ll_Device_use.setEnabled(true);
ll_Station_Type.setEnabled(true);
ll_roadNum.setEnabled(true);
ll_roadType.setEnabled(true);
ET_NorthRoad.setEnabled(true);
ET_WestRoad.setEnabled(true);
ET_SouthRoad.setEnabled(true);
ET_EastRoad.setEnabled(true);
ll_One_Geographic.setEnabled(true);
et_CentralNum.setEnabled(true);
ll_area.setEnabled(true);
ll_pcs.setEnabled(true);
ll_owner.setEnabled(true);
rb_youxian.setEnabled(true);
rb_wuxian.setEnabled(true);
rb_yidong.setEnabled(true);
rb_liantong.setEnabled(true);
rb_dianxin.setEnabled(true);
et_ip.setEnabled(true);
et_yanma.setEnabled(true);
et_wangguan.setEnabled(true);
et_mac.setEnabled(true);
et_phone.setEnabled(true);
et_sim.setEnabled(true);
et_TelegraphPole.setEnabled(true);
et_height.setEnabled(true);
et_txt.setEnabled(true);
}
private void setVisible(int Visible) {
LL_Type_Visibility.setVisibility(Visible);
if (Visible == View.VISIBLE) {
isVISIBLE = true;
} else {
isVISIBLE = false;
}
}
/**
* 设备用途
*/
private List<String> getUsageList() {
List<String> list3 = null;
try {
list3 = new ArrayList<String>();
userMap = new HashMap<>();
List<DictionaryBean> list = new ArrayList<>();
List<DictionaryBean> L1 = null;
L1 = DB.findAll(DictionaryBean.class);
for (int i = 0; i < L1.size(); i++) {
LOG.D("List_DictionaryName=" + L1.get(i).getDictionaryName());
LOG.D("List_SystemID=" + L1.get(i).getSystemID());
}
for (DictionaryBean dictionaryBean : L1) {
if (dictionaryBean.getDictionaryName().equals("ZD_PURPOSE") && dictionaryBean.getSystemID().equals
(SystemID)) {
list.add(dictionaryBean);
}
}
LOG.D("ZD_PURPOSE " + SystemID);
// list = DB.selector(DictionaryBean.class).where("DictionaryName", "=", "ZD_PURPOSE").and("SystemID",
// "=", SystemID).findAll();
if (list == null) {
LOG.D("设备用途列表为空");
}
LOG.D("设备用途列表 list.size()=" + list.size());
if (list != null && list.size() > 0) {
String DictionaryID = list.get(0).getDictionaryID();
List<ParamBean> list2 = DB.findAll(ParamBean.class);
for (int i = 0; i < list2.size(); i++) {
if (list2.get(i).getDictionaryID().equals(DictionaryID)) {
list3.add(list2.get(i).getParamValue());
userMap.put(list2.get(i).getParamValue(), list2.get(i).getParamCode());
}
}
}
} catch (DbException e) {
LOG.E("设备用途列表异常=" + e.toString());
}
return list3;
}
private List<String> getListType() {
List<String> list3 = new ArrayList<String>();
List<DictionaryBean> list = null;
try {
list = DB.selector(DictionaryBean.class).where("DictionaryName", "=", "ZD_DEVICETYPE").and("SystemID",
"=", SystemID).findAll();
for (int i = 0; i < list.size(); i++) {
LOG.D("List_DictionaryName=" + list.get(i).getDictionaryName());
LOG.D("List_SystemID=" + list.get(i).getSystemID());
}
LOG.D("ZD_DEVICETYPE " + SystemID);
if (list != null && list.size() > 0) {
String DictionaryID = list.get(0).getDictionaryID();
LOG.D("DictionaryID=" + DictionaryID);
typeMap = new HashMap<>();
List<ParamBean> list2 = DB.selector(ParamBean.class).where("DictionaryID", "=", DictionaryID).findAll();
List<ParamBean> list4 = DB.findAll(ParamBean.class);
for (ParamBean paramBean : list4) {
LOG.D("基站类型DictionaryID=" + paramBean.getDictionaryID());
}
LOG.D("基站类型" + list2.size());
if (list2 != null && list2.size() > 0) {
for (int i = 0; i < list2.size(); i++) {
list3.add(list2.get(i).getParamValue());
typeMap.put(list2.get(i).getParamValue(), list2.get(i).getParamCode());
}
}
}
} catch (DbException e) {
e.printStackTrace();
}
return list3;
}
private void getUsageList1() {
List<DictionaryBean> list = null;
try {
list = DB.selector(DictionaryBean.class).where("DictionaryName", "=", "ZD_PURPOSE").and("SystemID", "=",
SystemID).findAll();
LOG.E(SystemID + " 设备用途列表 list。size" + list.size());
if (list != null && list.size() > 0) {
userMap1 = new HashMap<>();
userMap = new HashMap<>();
String DictionaryID = list.get(0).getDictionaryID();
List<ParamBean> list2 = DB.selector(ParamBean.class).where("DictionaryID", "=", DictionaryID).findAll();
LOG.E("设备用途列表 list2。size" + list2.size());
if (list2 != null && list2.size() > 0) {
for (int i = 0; i < list2.size(); i++) {
userMap1.put(list2.get(i).getParamCode(), list2.get(i).getParamValue());
userMap.put(list2.get(i).getParamValue(), list2.get(i).getParamCode());
}
}
LOG.E(userMap1.size() + " 设备用途列表 userMap。size" + userMap.size());
}
} catch (DbException e) {
e.printStackTrace();
}
}
private void getListType1() {
List<DictionaryBean> list = null;
try {
list = DB.selector(DictionaryBean.class).where("DictionaryName", "=", "ZD_DEVICETYPE").and("SystemID",
"=", SystemID).findAll();
if (list != null && list.size() > 0) {
typeMap1 = new HashMap<>();
typeMap = new HashMap<>();
String DictionaryID = list.get(0).getDictionaryID();
List<ParamBean> list2 = DB.selector(ParamBean.class).where("DictionaryID", "=", DictionaryID).findAll();
if (list2 != null && list2.size() > 0) {
for (int i = 0; i < list2.size(); i++) {
typeMap1.put(list2.get(i).getParamCode(), list2.get(i).getParamValue());
typeMap.put(list2.get(i).getParamValue(), list2.get(i).getParamCode());
}
}
}
} catch (DbException e) {
e.printStackTrace();
}
}
public void ShowBigPic(Activity mActivity, String strpic) {
if (strpic.equals("") || strpic == null) {
ToastUtil.ErrorOrRight(mActivity, "无图片地址", 1);
return;
}
final AlertDialog dialog;
LOG.E("ShowBigPicpath=" + strpic);
dialog = new AlertDialog.Builder(mActivity).create();
dialog.show();//必须放在window前
Window window = dialog.getWindow();
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
window.setContentView(R.layout.dialog_img);
ImageView imgView = (ImageView) window.findViewById(R.id.img_open);
imgView.setImageBitmap(PhotoUtil.base64toBitmap(strpic));
imgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}
private Boolean CheckData() {
String devicecode = et_devicecode.getText().toString().trim();
if (devicecode == null || devicecode.equals("")) {
ToastUtil.showShort(mActivity, "请输入设备编号");
return false;
}
if (txt_Device_use.getText().toString().equals("")) {
ToastUtil.showShort(mActivity, "设备用途不能为空");
return true;
}
if (txt_Station_Type.getText().toString().equals("")) {
ToastUtil.showShort(mActivity, "基站类型不能为空");
return true;
}
String devicetype = txt_devicetype.getText().toString().trim();
if (devicetype == null || devicetype.equals("")) {
ToastUtil.showShort(mActivity, "设备类型为空");
return false;
}
if (Photo1ToBase64 == null || Photo1ToBase64.equals("")) {
ToastUtil.showShort(mActivity, "请拍摄基站照片");
return false;
}
if (Photo2ToBase64 == null || Photo2ToBase64.equals("")) {
ToastUtil.showShort(mActivity, "请拍摄进线口照片");
return false;
}
if (Photo3ToBase64 == null || Photo3ToBase64.equals("")) {
ToastUtil.showShort(mActivity, "请拍摄沿街照片");
return false;
}
String lng = txt_lng.getText().toString().trim();
if (lng == null || lng.equals("")) {
ToastUtil.showShort(mActivity, "请选择经度");
return false;
}
String lat = txt_lat.getText().toString().trim();
if (lat == null || lat.equals("")) {
ToastUtil.showShort(mActivity, "请选择纬度");
return false;
}
String deviceaddress = et_deviceaddress.getText().toString().trim();
if (deviceaddress == null || deviceaddress.equals("")) {
ToastUtil.showShort(mActivity, "请输入设备地址");
return false;
}
LOG.E("isVISIBLE=" + isVISIBLE);
if (isVISIBLE) {
String roadNum = txt_roadNum.getText().toString().trim();
if (roadNum == null || roadNum.equals("")) {
ToastUtil.showShort(mActivity, "请选择路口编号");
return false;
}
String roadType = txt_roadType.getText().toString().trim();
if (roadType == null || roadType.equals("")) {
ToastUtil.showShort(mActivity, "请选择路口类型");
return false;
}
String EastRoad = ET_EastRoad.getText().toString().trim();
if (EastRoad == null || EastRoad.equals("")) {
ToastUtil.showShort(mActivity, "请输入东路口名称");
return false;
}
String SouthRoad = ET_SouthRoad.getText().toString().trim();
if (SouthRoad == null || SouthRoad.equals("")) {
ToastUtil.showShort(mActivity, "请输入南路口名称");
return false;
}
String WestRoad = ET_WestRoad.getText().toString().trim();
if (WestRoad == null || WestRoad.equals("")) {
ToastUtil.showShort(mActivity, "请输入西路口名称");
return false;
}
String NorthRoad = ET_NorthRoad.getText().toString().trim();
if (NorthRoad == null || NorthRoad.equals("")) {
ToastUtil.showShort(mActivity, "请输入北路口名称");
return false;
}
String One_Geographic = txt_One_Geographic.getText().toString().trim();
if (One_Geographic == null || One_Geographic.equals("")) {
ToastUtil.showShort(mActivity, "请选择一号地埋方位");
return false;
}
String CentralNum = et_CentralNum.getText().toString().trim();
if (CentralNum == null || CentralNum.equals("")) {
ToastUtil.showShort(mActivity, "请输入中心地埋编号");
return false;
}
}
String area = txt_area.getText().toString().trim();
if (area == null || area.equals("")) {
ToastUtil.showShort(mActivity, "请选择所属辖区");
return false;
}
String pcs = txt_pcs.getText().toString().trim();
if (pcs == null || pcs.equals("")) {
ToastUtil.showShort(mActivity, "请选择所属派出所");
return false;
}
String owner = txt_owner.getText().toString().trim();
if (owner == null || owner.equals("")) {
ToastUtil.showShort(mActivity, "请选择产权人");
return false;
}
String repaircompany = txt_repaircompany.getText().toString().trim();
if (repaircompany == null || repaircompany.equals("")) {
ToastUtil.showShort(mActivity, "运维公司为空");
return false;
}
if (rb_youxian.isChecked()) {
String ip = et_ip.getText().toString().trim();
if (ip == null || ip.equals("")) {
ToastUtil.showShort(mActivity, "请输入设备IP");
return false;
}
}
if (rb_wuxian.isChecked()) {
if (!rb_yidong.isChecked() && !rb_liantong.isChecked() && !rb_dianxin.isChecked()) {
ToastUtil.showShort(mActivity, "请选择运营商");
return false;
}
}
return true;
}
private DeviceBean setdata() {
String CarrierOperator = "";
String AccessType;
if (rb_wuxian.isChecked()) {
AccessType = "2";
switch (rg_yunyingshang.getCheckedRadioButtonId()) {
case R.id.rb_yidong:
CarrierOperator = rb_yidong.getText().toString().trim();
break;
case R.id.rb_liantong:
CarrierOperator = rb_liantong.getText().toString().trim();
break;
case R.id.rb_dianxin:
CarrierOperator = rb_dianxin.getText().toString().trim();
break;
default:
break;
}
} else {
AccessType = "1";
}
String roadType = "";
switch (txt_roadType.getText().toString()) {
case "大型路口":
roadType = "1";
break;
case "中型路口":
roadType = "2";
break;
case "小型路口":
roadType = "3";
break;
default:
break;
}
DeviceBean bean = new DeviceBean();
bean.setDeviceType(getIntent().getStringExtra("DeviceType"));//设备类型
LOG.E("DeviceType=" + bean.getDeviceType());
bean.setDeviceCode(et_devicecode.getText().toString().trim());//设备ID
LOG.E("DeviceCode=" + bean.getDeviceCode());
bean.setSerialNumber(et_deviceno.getText().toString().trim());//序列号
LOG.E("SerialNumber=" + bean.getSerialNumber());
bean.setUsage(userMap.get(txt_Device_use.getText().toString().trim()));//设备用途
LOG.E("Usage=" + bean.getSerialNumber());
bean.setPCS(DIU.getPCS_ID(txt_area.getText().toString().trim(), txt_pcs.getText().toString().trim()));//派出所ID
LOG.E("PCS=" + bean.getPCS());
bean.setLAT(txt_lat.getText().toString().trim());//经度
LOG.E("LAT=" + bean.getLAT());
bean.setLNG(txt_lng.getText().toString().trim());//纬度
LOG.E("LNG=" + bean.getLNG());
bean.setPhotoID1(DIU.getUUID());//照片ID1
LOG.E("PhotoID1=" + bean.getPhotoID1());
bean.setPhotoID2(DIU.getUUID());//照片ID2
LOG.E("PhotoID2=" + bean.getPhotoID2());
bean.setPhotoID3(DIU.getUUID());//照片ID3
LOG.E("PhotoID3=" + bean.getPhotoID3());
bean.setPhoto1(Photo1ToBase64);//照片1
LOG.E(bean.getPhoto1() != null && !bean.getPhoto1().equals("") ? "1有照片" : "1没有照片");
bean.setPhoto2(Photo2ToBase64);//照片2
LOG.E(bean.getPhoto2() != null && !bean.getPhoto2().equals("") ? "2有照片" : "2没有照片");
bean.setPhoto3(Photo3ToBase64);//照片3
LOG.E(bean.getPhoto3() != null && !bean.getPhoto3().equals("") ? "3有照片" : "3没有照片");
bean.setAddress(et_deviceaddress.getText().toString());//安装点位
LOG.E("Address=" + bean.getAddress());
bean.setOwner(DIU.getParamCode(txt_owner.getText().toString().trim()));//产权所有人名称
LOG.E("Owner=" + bean.getOwner());
bean.setRepairCompany(DIU.getCompanyCode(txt_repaircompany.getText().toString().trim()));//运维公司名称
LOG.E("RepairCompany=" + bean.getRepairCompany());
bean.setCarrierOperator(CarrierOperator);//运营商名称
LOG.E("CarrierOperator=" + bean.getCarrierOperator());
bean.setIP(et_ip.getText().toString().trim());//设备IP
LOG.E("IP=" + bean.getIP());
bean.setMask(et_yanma.getText().toString().trim());//子网掩码
LOG.E("Mask=" + bean.getMask());
bean.setGateway(et_wangguan.getText().toString().trim());//网关
LOG.E("Gateway=" + bean.getGateway());
bean.setPhone(et_phone.getText().toString().trim());//SIM卡电话号码
LOG.E("Phone=" + bean.getPhone());
bean.setSIM(et_sim.getText().toString().trim());//设备的SIM卡号
LOG.E("SIM=" + bean.getSIM());
bean.setAccessType(AccessType);//接入方式,(1有线/2无线)
LOG.E("AccessType=" + bean.getAccessType());
bean.setDescription(et_txt.getText().toString());//备注说明
LOG.E("Description=" + bean.getDescription());
bean.setReserve1(et_TelegraphPole.getText().toString().trim());//备用字段1,做电线杆号
LOG.E("Reserve1=" + bean.getReserve1());
bean.setReserve2(et_height.getText().toString().trim());//备用字段2,做安装高度
LOG.E("Reserve2=" + bean.getReserve2());
// bean.setReserve3(DIU.getTypeList(SystemID).get(txt_devicetype.getText().toString().trim()));//备用字段3,做基站类型
bean.setReserve3(typeMap.get(txt_Station_Type.getText().toString().trim()));//备用字段3,基站类型
LOG.E("Station_Type=" + bean.getUsage());
bean.setReserve4(et_mac.getText().toString().trim());//备用字段4,MAC地址
LOG.E("Reserve4=" + bean.getReserve4());
bean.setReserve7(BaiduLNG);//备用字段7,BD_LNG
LOG.E("Reserve7=" + bean.getReserve7());
bean.setReserve8(BaiduLAT);//备用字段8,BD_LAT
LOG.E("Reserve8=" + bean.getReserve8());
bean.setReserve9("3");//备用字段9,数据来源,1GPS 2百度
LOG.E("Reserve9=" + bean.getReserve9());
bean.setReserve10(SharedUtil.getValue(mActivity, "UserName"));//备用字段10,安装人姓名
LOG.E("Reserve10=" + bean.getReserve10());
bean.setReserve11(SharedUtil.getValue(mActivity, "UserPhone"));//备用字段11,安装人员手机号码
LOG.E("Reserve11=" + bean.getReserve11());
bean.setReserve12(et_deviceName.getText().toString());//基站名称(别名)
LOG.E("Reserve12=" + bean.getReserve12());
bean.setReserve13(et_produceNo.getText().toString().trim());//生产序列号
LOG.E("Reserve13 et_produceNo=" +et_produceNo.getText().toString().trim());
if (!isVISIBLE) {
bean.setReserve17("");//路口编号
LOG.E("Reserve17=" + bean.getReserve17());
bean.setReserve18("");//路口类型(1大型路口、2中型路口、3小型路口)
LOG.E("Reserve18=" + bean.getReserve18());
bean.setReserve19("");//东路口名称
LOG.E("Reserve19=" + bean.getReserve19());
bean.setReserve20("");//南路口名称
LOG.E("Reserve20=" + bean.getReserve20());
bean.setReserve21("");//西路口名称
LOG.E("Reserve21=" + bean.getReserve21());
bean.setReserve22("");//北路口名称
LOG.E("Reserve22=" + bean.getReserve22());
bean.setReserve23("");//1号地埋方向(东、南、西、北)
LOG.E("Reserve23=" + bean.getReserve23());
bean.setReserve24("");//中心地埋编号
LOG.E("Reserve24=" + bean.getReserve24());
} else {
bean.setReserve17(txt_roadNum.getText().toString());//路口编号
LOG.E("Reserve17=" + bean.getReserve17());
bean.setReserve18(roadType);//路口类型(1大型路口、2中型路口、3小型路口)
LOG.E("Reserve18=" + bean.getReserve18());
bean.setReserve19(ET_EastRoad.getText().toString());//东路口名称
LOG.E("Reserve19=" + bean.getReserve19());
bean.setReserve20(ET_SouthRoad.getText().toString());//南路口名称
LOG.E("Reserve20=" + bean.getReserve20());
bean.setReserve21(ET_WestRoad.getText().toString());//西路口名称
LOG.E("Reserve21=" + bean.getReserve21());
bean.setReserve22(ET_NorthRoad.getText().toString());//北路口名称
LOG.E("Reserve22=" + bean.getReserve22());
bean.setReserve23(txt_One_Geographic.getText().toString());//1号地埋方向(东、南、西、北)
LOG.E("Reserve23=" + bean.getReserve23());
bean.setReserve24(et_CentralNum.getText().toString());//中心地埋编号
LOG.E("Reserve24=" + bean.getReserve24());
}
if (status.equals("安装")) {
bean.setDeviceID("");//此处应为空(基站ID 2017-2-14)
bean.setAreaID("");//区域ID,接口预留,本次不使用
bean.setXQ("");//辖区分局ID
// bean.setUsage("");//用途
bean.setJWH("");//居委会,接口预留,不使用
bean.setReserve5("");//备用字段5,基站级别
bean.setReserve6("");//备用字段6,位置类型
bean.setReserve13(et_produceNo.getText().toString().trim());//备用字段13
bean.setReserve14("");//备用字段14
bean.setReserve15("");//备用字段15
bean.setReserve16("");//备用字段16
} else if (status.equals("修改")) {
bean.setDeviceID(device.getDeviceID());
bean.setAreaID(device.getAreaID());
bean.setXQ(device.getXQ());
// bean.setUsage(device.getUsage());
bean.setJWH(device.getJWH());
bean.setReserve5(device.getReserve5());
bean.setReserve6(device.getReserve6());
bean.setReserve13(et_produceNo.getText().toString().trim());
bean.setReserve14(device.getReserve14());
bean.setReserve15(device.getReserve15());
bean.setReserve16(device.getReserve16());
}
bean.setReserve25("");
bean.setReserve26("");
bean.setReserve27("");
bean.setReserve28("");
bean.setReserve29("");
bean.setReserve30("");
LOG.E("JWH=" + bean.getJWH());
LOG.E("DeviceID=" + bean.getDeviceID());
LOG.E("AreaID=" + bean.getAreaID());
LOG.E("XQ=" + bean.getXQ());
// LOG.E("Usage=" + bean.getUsage());
LOG.E("Reserve5=" + bean.getReserve5());
LOG.E("Reserve6=" + bean.getReserve6());
LOG.E("Reserve13=" + bean.getReserve13());
LOG.E("Reserve14=" + bean.getReserve14());
LOG.E("Reserve15=" + bean.getReserve15());
LOG.E("Reserve16=" + bean.getReserve16());
return bean;
}
private void AddDevice() {
zProgressHUD = new ZProgressHUD(mActivity);
zProgressHUD.setMessage("正在提交数据请稍后……");
zProgressHUD.show();
String deviceInfo = mGson.toJson(setdata());
LOG.E("New deviceInfo=" + deviceInfo);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("accessToken", SharedUtil.getToken(mActivity));
map.put("deviceInfo", deviceInfo);
map.put("systemID", SystemID);
//ToastUtil.showShort(mActivity,SystemID+"//"+AreaID+"//"+PCS);
WebUtil.getInstance(mActivity).webRequest(Constants.Sys_AddDeviceNew, map, new WebUtil.MyCallback() {
@Override
public void onSuccess(String result) {
zProgressHUD.dismiss();
if (result.equals("-1")) {
return;
}
try {
JSONObject jsonObject = new JSONObject(result);
String ErrorCode = jsonObject.getString("ErrorCode");
String ErrorMsg = jsonObject.getString("ErrorMsg");
if (ErrorCode.equals("0")) {
ToastUtil.ErrorOrRight(mActivity, "设备安装成功!", 2);
ActivityUtil.SaveAddress(mActivity, Address, et_devicecode.getText().toString().trim());
Intent intent = new Intent(mActivity, HomeActivity.class);
startActivity(intent);
ZbarUtil.setDeviceClear();
} else {
ToastUtil.ErrorOrRight(mActivity, "设备安装失败!" + ErrorCode + ErrorMsg, 1);
if (ErrorMsg.contains("已存在")) {
// ll_zbar.setVisibility(View.VISIBLE);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
private void ModifyDevice() {
zProgressHUD = new ZProgressHUD(mActivity);
zProgressHUD.setMessage("正在提交数据请稍后……");
zProgressHUD.show();
String deviceInfo = mGson.toJson(setdata());
LOG.LE("修改数据=" + deviceInfo);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("accessToken", SharedUtil.getToken(mActivity));
map.put("deviceInfo", deviceInfo);
map.put("systemID", SystemID);
WebUtil.getInstance(mActivity).webRequest(Constants.Sys_ModifyDeviceNew, map, new WebUtil.MyCallback() {
@Override
public void onSuccess(String result) {
zProgressHUD.dismiss();
if (result.equals("-1")) {
return;
}
try {
JSONObject jsonObject = new JSONObject(result);
String ErrorCode = jsonObject.getString("ErrorCode");
String ErrorMsg = jsonObject.getString("ErrorMsg");
if (ErrorCode.equals("0")) {
ToastUtil.ErrorOrRight(mActivity, "设备修改成功!", 2);
SharedUtil.setValue(mActivity, "isCodeChange", et_devicecode.getText().toString().trim());
hasResult();
ActivityUtil.FinishActivity(mActivity);
} else {
ToastUtil.ErrorOrRight(mActivity, "设备修改失败!" + ErrorMsg, 1);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
private void hasResult() {
Intent intent = new Intent();
intent.putExtra("result", "1");
setResult(RESULT_OK, intent);
}
private void CheckAddress() {
if (ActivityUtil.CheckAddressRepeated(mActivity, Address)) {
showDialog1("您已使用过 (" + Address + ") 这个地址。");
}
}
private void showDialog1(String content) {
AlertDialog.Builder builder = DialogUtil.getAlertDialogBuilder(this);
builder.setTitle("")
.setMessage(content)
.setPositiveButton("确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
}).setCancelable(false).show();
}
private static final String PRODUCE_NO_TYPE = "1604";
private String produceNo;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_SCAN_SERIAL:
if (resultCode == Activity.RESULT_OK) {
String scanResult = data.getStringExtra("result");
String strZbar = ZbarUtil.DeviceZbar(mActivity, scanResult);
if (TextUtils.isEmpty(strZbar)) {
ToastUtil.ErrorOrRight(mActivity, "请扫描正确的设备二维码。", 1);
} else {
String[] device = strZbar.split(",");
Log.e(TAG, "strZbar: " + strZbar);
if (device[1].equals(PRODUCE_NO_TYPE)) {
produceNo = device[0];
et_produceNo.setText(produceNo);
} else {
ToastUtil.ErrorOrRight(mActivity, "设备类型不匹配", 1);
}
}
}
break;
case PhotoUtils.CAMERA_REQESTCODE:
if (resultCode == RESULT_OK) {
int degree = PhotoUtils.readPictureDegree(PhotoUtils.imageFile.getAbsolutePath());
Bitmap bitmap = PhotoUtils.rotaingImageView(degree, PhotoUtils.getBitmapFromFile(PhotoUtils
.imageFile, 800, 800));
String PhotoNum = PhotoUtils.mPicName.substring(5, 6);
switch (PhotoNum) {
case "1":
img_photo1.setImageBitmap(bitmap);
Photo1ToBase64 = PhotoUtil.bitmapToString(bitmap, mActivity);
break;
case "2":
img_photo2.setImageBitmap(bitmap);
Photo2ToBase64 = PhotoUtil.bitmapToString(bitmap, mActivity);
break;
case "3":
img_photo3.setImageBitmap(bitmap);
Photo3ToBase64 = PhotoUtil.bitmapToString(bitmap, mActivity);
break;
}
}
break;
case 4:
if (resultCode == mActivity.RESULT_OK) {
String LNG = data.getStringExtra("MapLNG");
String LAT = data.getStringExtra("MapLAT");
Address = data.getStringExtra("Address");
BaiduLAT = data.getStringExtra("BaiduMapLAT");
BaiduLNG = data.getStringExtra("BaiduMapLNG");
LOG.D("LNG=" + LNG);
LOG.D("LAT=" + LAT);
LOG.D("Address=" + Address);
LOG.D("BaiduLNG=" + BaiduLNG);
LOG.D("BaiduLAT=" + BaiduLAT);
if (!BaiduLNG.equals("")) {
txt_lng.setText(BaiduLNG);
txt_lat.setText(BaiduLAT);
et_deviceaddress.setText(Address);
CheckAddress();
String Areatxt;
if (Address.length() >= 9) {
Areatxt = Address.substring(6, 9);
} else {
Areatxt = Address;
}
txt_area.setText(DIU.getAreaMC(Areatxt));
txt_pcs.setText("");
img_baidu.setImageResource(R.mipmap.imagelocation_on);
}
}
break;
default:
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
}
| [
"[email protected]"
] | |
d011805373d6fb14d4663d84940915652b3d111a | 579cdb6bae5ab64e2ad5552b03cd45237fd4d157 | /src/main/java/dev/morling/jfrunit/JfrEventTest.java | e931b998947de78a23f337fd4821e3918ef66edf | [
"Apache-2.0"
] | permissive | tbadgu/jfrunit | fc6283e5915e7c273311c3f5b4c7f810aea1f6bc | 17cc0a58660eaad702f941522a841311cc1b2254 | refs/heads/main | 2023-02-25T15:21:03.706027 | 2021-01-15T07:06:52 | 2021-01-15T17:14:34 | 323,638,465 | 0 | 0 | Apache-2.0 | 2020-12-22T13:47:29 | 2020-12-22T13:47:29 | null | UTF-8 | Java | false | false | 998 | java | /**
* Copyright 2020 The JfrUnit 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 dev.morling.jfrunit;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.extension.ExtendWith;
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(JfrEventTestExtension.class)
@Target(ElementType.TYPE)
public @interface JfrEventTest {
}
| [
"[email protected]"
] | |
0d2f56aed931ce1f36a59a0a0a30dd4a166dcbf0 | 805a7d8c455ffc118f155e070c6542276aa5546d | /iTrust/test/edu/ncsu/csc/itrust/unit/action/MyDiagnosisActionTest.java | ffa3bf288da918b36b94b41012089ca6d1fd3ff1 | [] | no_license | therealJacobWu/Medical-Website-Development | bf73cd6ffd21a67e50ae9aa827e226becc914e8f | 0dee82f5d78ba15035974e69a1bc834bbee6dd80 | refs/heads/master | 2022-01-01T20:07:37.837320 | 2021-12-16T20:51:17 | 2021-12-16T20:51:17 | 128,004,641 | 0 | 0 | null | 2021-12-16T20:51:18 | 2018-04-04T03:58:22 | Java | UTF-8 | Java | false | false | 2,489 | java | package edu.ncsu.csc.itrust.unit.action;
import java.util.List;
import junit.framework.TestCase;
import edu.ncsu.csc.itrust.action.MyDiagnosisAction;
import edu.ncsu.csc.itrust.action.MyDiagnosisAction.HCPDiagnosisBeanComparator;
import edu.ncsu.csc.itrust.beans.DiagnosisBean;
import edu.ncsu.csc.itrust.beans.HCPDiagnosisBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator;
import edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory;
public class MyDiagnosisActionTest extends TestCase {
private DAOFactory factory = TestDAOFactory.getTestInstance();
private TestDataGenerator gen = new TestDataGenerator();
private MyDiagnosisAction action;
private HCPDiagnosisBean a;
private HCPDiagnosisBean b;
private HCPDiagnosisBeanComparator hcpdbc;
@Override
protected void setUp() throws Exception {
gen.clearAllTables();
gen.standardData();
gen.loadSQLFile("patient_hcp_visits");
gen.loadSQLFile("hcp_diagnosis_data");
}
public void testGetDiagnoses() throws Exception {
action = new MyDiagnosisAction(factory, 2L);
List<DiagnosisBean> diagnoses = action.getDiagnoses();
assertEquals(11, diagnoses.size());
// further testing should be done in the patientDAO
}
public void testGetHCPByDiagnosis() throws Exception {
action = new MyDiagnosisAction(factory, 1L);
List<HCPDiagnosisBean> diags = action.getHCPByDiagnosis("79.1");
assertEquals(9000000004L, diags.get(0).getHCP());
assertTrue(diags.get(0).getHCPName().equals("Jason Frankenstein"));
assertEquals(2, diags.get(0).getNumPatients());
assertEquals(1, diags.get(0).getMedList().size());
assertEquals(0, diags.get(0).getLabList().size());
assertEquals("3.0", diags.get(0).getVisitSatisfaction());
assertEquals("4.0", diags.get(0).getTreatmentSatisfaction());
}
public void testCompare1() {
a = new HCPDiagnosisBean();
b = new HCPDiagnosisBean();
hcpdbc = new HCPDiagnosisBeanComparator();
a.incNumPatients();
assertEquals(-1, hcpdbc.compare(a, b)); // a > b
}
public void testCompare2() {
a = new HCPDiagnosisBean();
b = new HCPDiagnosisBean();
hcpdbc = new HCPDiagnosisBeanComparator();
b.incNumPatients();
assertEquals(1, hcpdbc.compare(a, b)); // a < b
}
public void testCompare3() {
a = new HCPDiagnosisBean();
b = new HCPDiagnosisBean();
hcpdbc = new HCPDiagnosisBeanComparator();
a.incNumPatients();
b.incNumPatients();
assertEquals(0, hcpdbc.compare(a, b)); // a == b
}
}
| [
"[email protected]"
] | |
fdd1bca6bc0826332ef7caadfd2e651dbadf9872 | ce32decef039a586855c362381003d21d1ab3342 | /modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LocalDateTimeRestVariableConverter.java | 23119622a3ce5ed210ad621033e10b52db63d6b3 | [
"Apache-2.0"
] | permissive | flowable/flowable-engine | fa5fb5c29a453669887bee7874ca6d73fd2663c7 | 7bd4ee8b7374b43dcdd517a26afa14e6806f40e4 | refs/heads/main | 2023-08-31T03:55:26.415399 | 2023-08-29T11:53:55 | 2023-08-29T11:53:55 | 70,780,002 | 7,040 | 2,775 | Apache-2.0 | 2023-09-14T16:51:30 | 2016-10-13T07:21:43 | Java | UTF-8 | Java | false | false | 2,147 | 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 org.flowable.common.rest.variable;
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
/**
* @author Filip Hrisafov
*/
public class LocalDateTimeRestVariableConverter implements RestVariableConverter {
@Override
public String getRestTypeName() {
return "localDateTime";
}
@Override
public Class<?> getVariableType() {
return LocalDateTime.class;
}
@Override
public Object getVariableValue(EngineRestVariable result) {
if (result.getValue() != null) {
if (!(result.getValue() instanceof String)) {
throw new FlowableIllegalArgumentException("Converter can only convert string to localDateTime");
}
try {
return LocalDateTime.parse((String) result.getValue());
} catch (DateTimeParseException e) {
throw new FlowableIllegalArgumentException("The given variable value is not a localDateTime: '" + result.getValue() + "'", e);
}
}
return null;
}
@Override
public void convertVariableValue(Object variableValue, EngineRestVariable result) {
if (variableValue != null) {
if (!(variableValue instanceof LocalDateTime)) {
throw new FlowableIllegalArgumentException("Converter can only convert localDateTime");
}
result.setValue(variableValue.toString());
} else {
result.setValue(null);
}
}
}
| [
"[email protected]"
] | |
d1e6e1af5929fc0985c5bd5ff05d6c7ca49e1d60 | 2ce90c5ac6543b4cb448ce54e8eb8da1142e5658 | /Pilotage_web/src/pilotage/users/management/ModifiyUserAction.java | ff3f3f54ad232ad18380e85f0167698fbe43028c | [] | no_license | aelbarji/pfm-workspaceAG2R | 5c2467094024de9f74dc05da30af2dd34456b86c | a46f05aa2771b2c660f694d1463e602ebc268f1f | refs/heads/master | 2021-01-17T15:20:25.243262 | 2016-06-12T14:26:58 | 2016-06-12T14:26:58 | 49,145,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,155 | java | package pilotage.users.management;
import java.text.MessageFormat;
import java.util.List;
import pilotage.admin.metier.Profil;
import pilotage.database.admin.ProfilDatabaseService;
import pilotage.database.historique.HistoriqueDatabaseService;
import pilotage.database.users.management.UsersDatabaseService;
import pilotage.framework.AbstractAction;
import pilotage.metier.Users;
import pilotage.service.constants.PilotageConstants;
public class ModifiyUserAction extends AbstractAction {
private static final long serialVersionUID = -3616654797068547514L;
private String sort;
private String sens;
private int page;
private int nrPages;
private int nrPerPage;
private Integer selectRow;
private String nom;
private String prenom;
private String login;
private String email;
private Integer profil;
private List<Profil> listProfil;
private Boolean loginChanged;
public Boolean getLoginChanged() {
return loginChanged;
}
public void setLoginChanged(Boolean loginChanged) {
this.loginChanged = loginChanged;
}
public List<Profil> getListProfil() {
return listProfil;
}
public void setListProfil(List<Profil> listProfil) {
this.listProfil = listProfil;
}
public Integer getSelectRow() {
return selectRow;
}
public void setSelectRow(Integer selectRow) {
this.selectRow = selectRow;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getProfil() {
return profil;
}
public void setProfil(Integer profil) {
this.profil = profil;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
public String getSens() {
return sens;
}
public void setSens(String sens) {
this.sens = sens;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getNrPages() {
return nrPages;
}
public void setNrPages(int nrPages) {
this.nrPages = nrPages;
}
public int getNrPerPage() {
return nrPerPage;
}
public void setNrPerPage(int nrPerPage) {
this.nrPerPage = nrPerPage;
}
@Override
protected String executeMetier() {
try {
String historique = "";
Users u = UsersDatabaseService.get(selectRow);
if (!nom.equals(u.getNom())) {
historique += "nom, ";
}
if (!prenom.equals(u.getPrenom())) {
historique += "prenom, ";
}
if (!login.equals(u.getLogin())) {
historique += "login, ";
}
if (!email.equals(u.getEmail())) {
historique += "email, ";
}
if (!profil.equals(u.getStatut())) {
historique += "profil, ";
}
//modification du user
UsersDatabaseService.modify(selectRow, nom, prenom, login, email, profil);
HistoriqueDatabaseService.create(null, MessageFormat.format(getText("historique.users.modification"), new Object[]{login, selectRow, historique}), (Users)session.get(PilotageConstants.USER_LOGGED), PilotageConstants.HISTORIQUE_MODULE_USERS);
info = MessageFormat.format(getText("users.modification.valide"), login);
return OK;
}
catch (Exception e) {
error = getText("error.message.generique") + " : " + e.getMessage();
erreurLogger.error("Modification d'un utilisateur - ", e);
listProfil = ProfilDatabaseService.getAll();
return ERROR;
}
}
@Override
protected boolean validateMetier() {
if(loginChanged && UsersDatabaseService.loginExists(login)){
error = MessageFormat.format(getText("users.creation.login.existe.deja"), login);
login = UsersDatabaseService.get(selectRow).getLogin();
listProfil = ProfilDatabaseService.getAll();
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
eae68954e0aea3a560b1c6e8f4c43140a50cda2f | 5dc6fcf78f9933662223551aa473b59b5b2bc5a4 | /SistemaPWM2018/src/br/edu/udc/sistemas/pwm2018/infra/annotation/Column.java | 71fae89629ca42162d9c5449109bb3b40b318570 | [] | no_license | evertonschuster/SistemaPWM2018 | e65dce16619d616001db1bcbced58103aa70efad | d2effc417110a7d3b3b64e1dc6328a45d5e3cf9d | refs/heads/master | 2020-03-27T20:01:23.914762 | 2018-11-28T20:31:17 | 2018-11-28T20:31:17 | 147,031,725 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 769 | java | package br.edu.udc.sistemas.pwm2018.infra.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author fdami
* Anota��o que faz o mapeamento de um atributo em uma coluna do banco
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {
public String name() default "";
public DataType type() default DataType.STRING;
public int length() default 255;
public boolean orderBy() default false;
public boolean unique() default false;
public boolean nullable() default true;
public boolean insertable() default true;
public boolean updatable() default true;
}
| [
"Ever@DESKTOP-4J1DMOD"
] | Ever@DESKTOP-4J1DMOD |
9d9599afc04dd4d0d77902fe8f2b78d05168c7d2 | b85e31fc32dd5a6763aa13099c155975e875cbb0 | /CS2030/CS2030/LabOneA/src/com/company/Server.java | d98455904bba15e71531c580b24e4818b63dc1de | [] | no_license | daviddl9/schoolwork | 7473c32853a6240e1a4e3679838cb71d4ce86dfa | 8c79b2a2f6596739d997b3e637a325eac275a3ca | refs/heads/master | 2020-04-13T19:14:44.441163 | 2018-12-28T10:13:13 | 2018-12-28T10:13:13 | 163,396,774 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,278 | java | package com.company;
/**
* This class represents a server in the system.
*
* @author David
* @version CS2030 AY17/18 Sem 2 Lab 1b
*/
public class Server {
private Queue queue = new Queue(new Customer[2]);
private boolean isIdle;
public static final double serviceTime = 1.0;
private static int totalNumOfServedCustomers = 0;
private boolean hasQueue = false;
/**
* This constructor takes in the current state of a server and creates a new
* server.
*
* @param isIdle represents the current state of the server. True if the
* server is idle, and false if the server is not idle.
*/
Server(boolean isIdle) {
this.isIdle = isIdle;
}
/**
* This method checks the state of the server.
*
* @return true if the server is idle, false otherwise.
*/
public boolean isIdle() {
return isIdle;
}
/**
* This method returns the service time of a server.
*
* @return service time of the server.
*/
public double getServiceTime() {
return serviceTime;
}
/**
* This method makes a given customer wait, at a given timing.
*
* @param cust represents the customer that has to wait.
* @param time time at which customer starts waiting.
*/
public void makeCustomerWait(Customer cust, double time) {
cust.startWaiting(time);
}
/**
* Returns the total number of customers served by the waiter.
*
* @return total number of customers served by the waiter.
*/
public int getTotalNumOfServedCustomers() {
return totalNumOfServedCustomers;
}
/**
* Checks if a waiter currently has a queue (i.e waiter is currently
* serving a customer and there are customer(s) waiting in line)
*
* @return true if waiter has a queue, false otherwise.
*/
public boolean hasQueue() {
return hasQueue;
}
/**
* Adds a given customer to the queue of the server.
*
* @param c represents the customer to be added into the queue of the waiter.
*/
public void incrementCustomers(Customer c) {
this.queue.addCustomer(c);
}
/**
* This method sets the queue status of the waiter to be true. (i.e
* indicates that the server has a queue)
*/
public void setHasQueue() {
this.hasQueue = true;
}
/**
* This function makes the server serve the customer in his queue.
*
* @param time represents the time of service.
*/
public void serveCustomer(double time) {
this.isIdle = false;
this.queue.serveCust(time);
totalNumOfServedCustomers++;
}
/**
* This function makes the server serve the customer waiting in line after the
* earlier customer leaves.
*
* @param time represents time of service of waiting customer.
*/
public void serveNextCustomer(double time) {
this.isIdle = false;
this.queue.customerLeaves();
this.queue.serveCust(time);
totalNumOfServedCustomers++;
}
/**
* This method sets the state of the server as idle.
*/
public void makeIdle() {
this.isIdle = true;
}
/**
* This method returns the arrival time of the customer waiting in line.
*
* @return arrival time of customer waiting in line.
*/
public double getArrivalTimeOfNextCustomer() {
return this.queue.getFirstCustomerArrivalTime();
}
}
| [
"[email protected]"
] | |
a5739f2b1733252f92f06a1605ab3f0799711d52 | 73b548bca02a4820805804a8c0aed7d5c01f4d4e | /src/network/customevents/player/CoinUpdateEvent.java | 1caf89f305cfb5821d0b1af83b451d735ca1aabf | [] | no_license | CommandCracker8/Minecraft-Bukkit | f7371810e456156a5da52d58b93effc990c3e287 | d6bf83d441e341486bcdc57a36060a8cff4b80cf | refs/heads/master | 2021-09-23T22:20:53.863579 | 2018-09-28T10:51:26 | 2018-09-28T10:51:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 606 | java | package network.customevents.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CoinUpdateEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player = null;
public CoinUpdateEvent(Player player) {
this.player = player;
}
public Player getPlayer() {
return this.player;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}
| [
"[email protected]"
] | |
b3065fbe725928f0eefc22ac1f0f1293cce70d09 | 2cfd95155b3615557ca4f001206026026dc08bce | /src/main/java/shadows/click/ClickMachine.java | 3329f10a8a2da354574af17ece9f32d664ac3a53 | [
"MIT"
] | permissive | Shadows-of-Fire/ClickMachine | 9f2b3b5eb1b0bb219f6729524e75a8431dc7450a | daf3089b7ff5fc674e17e5f7dfd79029b7a061ac | refs/heads/1.18 | 2023-08-17T16:56:09.419825 | 2022-04-07T18:05:36 | 2022-04-07T18:05:36 | 140,522,766 | 16 | 15 | MIT | 2022-05-09T00:51:30 | 2018-07-11T04:47:07 | Java | UTF-8 | Java | false | false | 3,679 | java | package shadows.click;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.ImmutableSet;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import shadows.click.block.AutoClickerBlock;
import shadows.click.block.AutoClickerTile;
import shadows.click.block.gui.AutoClickContainer;
import shadows.click.util.FakePlayerUtil.UsefulFakePlayer;
import shadows.placebo.block_entity.TickingBlockEntityType;
import shadows.placebo.config.Configuration;
import shadows.placebo.container.ContainerUtil;
import shadows.placebo.loot.LootSystem;
import shadows.placebo.recipe.RecipeHelper;
@Mod(ClickMachine.MODID)
public class ClickMachine {
public static final String MODID = "clickmachine";
public static final Logger LOG = LogManager.getLogger(MODID);
public static final RecipeHelper HELPER = new RecipeHelper(MODID);
@ObjectHolder(ClickMachine.MODID + ":auto_clicker")
public static final AutoClickerBlock AUTO_CLICKER = null;
@ObjectHolder(ClickMachine.MODID + ":container")
public static final MenuType<AutoClickContainer> CONTAINER = null;
@ObjectHolder(ClickMachine.MODID + ":tile")
public static final BlockEntityType<AutoClickerTile> TILE = null;
public ClickMachine() {
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGHEST, this::blockJoin);
ClickMachineConfig.init(new Configuration(new File(FMLPaths.CONFIGDIR.get().toFile(), "clickmachine.cfg")));
FMLJavaModLoadingContext.get().getModEventBus().register(this);
}
@SubscribeEvent
public void blocks(Register<Block> e) {
Block b;
e.getRegistry().register(b = new AutoClickerBlock().setRegistryName(MODID, "auto_clicker"));
ForgeRegistries.ITEMS.register(new BlockItem(b, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE)).setRegistryName(b.getRegistryName()));
}
@SubscribeEvent
public void container(Register<MenuType<?>> e) {
e.getRegistry().register(ContainerUtil.makeType(AutoClickContainer::new).setRegistryName(MODID, "container"));
}
@SubscribeEvent
public void tiles(Register<BlockEntityType<?>> e) {
e.getRegistry().register(new TickingBlockEntityType<>(AutoClickerTile::new, ImmutableSet.of(AUTO_CLICKER), false, true).setRegistryName(MODID, "tile"));
}
@SubscribeEvent
public void setup(FMLCommonSetupEvent e) {
Ingredient diorite = Ingredient.of(Items.DIORITE);
HELPER.addShaped(AUTO_CLICKER, 3, 3, diorite, diorite, diorite, diorite, Blocks.CHORUS_FLOWER, diorite, diorite, Blocks.REDSTONE_BLOCK, diorite);
LootSystem.defaultBlockTable(AUTO_CLICKER);
}
public void blockJoin(EntityJoinWorldEvent e) {
if (e.getEntity() instanceof UsefulFakePlayer) e.setCanceled(true);
}
}
| [
"[email protected]"
] | |
5f8cdf3201552a626c90a523bcd83bb461debe5f | 239b35515e39c91eed39885a71aa64a4d3a8e0cb | /hadrumaths/hadrumaths/src/main/java/net/thevpc/scholar/hadrumaths/MatrixVectorSpace.java | e753cda8b967dc13d7ae1ffa3435b85b2eac1700 | [] | no_license | thevpc/scholar-mw | de62e654ae3129dc9b79648aaa4f083d3a81d532 | 76ced260b583f1d1308ba07ed0b54282b4f90842 | refs/heads/master | 2023-05-10T19:37:25.647409 | 2023-05-04T19:10:52 | 2023-05-04T19:10:52 | 72,082,286 | 2 | 1 | null | 2022-09-30T17:22:45 | 2016-10-27T07:24:33 | Java | UTF-8 | Java | false | false | 11,375 | java | package net.thevpc.scholar.hadrumaths;
import net.thevpc.common.util.TypeName;
public class MatrixVectorSpace<T> extends AbstractVectorSpace<Matrix<T>> {
private final TypeName<T> tr;
private final TypeName<Matrix<T>> matrixType;
private final VectorSpace<T> vs;
public MatrixVectorSpace(TypeName<T> itemType, VectorSpace<T> vs) {
this.tr = itemType;
this.vs = vs;
matrixType = new TypeName<>(Matrix.class.getName(), itemType);
}
// @Override
// public <R> R convertTo(Complex value,Class<R> t) {
// if(t.equals(Complex.class)){
// return (R) value;
// }
// if(t.equals(Double.class)){
// return (R) Double.valueOf(value.toDouble());
// }
// if(t.equals(Matrix.class)){
// return (R) Maths.matrix(new Complex[][]{{value}});
// }
// if(t.equals(Matrix.class)){
// return (R) Maths.matrix(new Complex[][]{{value}});
// }
// if(t.equals(Vector.class)){
// return (R) Maths.matrix(new Complex[][]{{value}}).toVector();
// }
// if(t.equals(Vector.class)){
// return (R) Maths.matrix(new Complex[][]{{value}}).toVector();
// }
// throw new ClassCastException();
// }
//
// @Override
// public <R> Complex convertFrom(R value, Class<R> t) {
// if(t.equals(Complex.class)){
// return (Complex) value;
// }
// if(t.equals(Double.class)){
// return (Complex) Complex.valueOf((Double)value);
// }
// if(t.equals(Matrix.class)){
// return (Complex) ((Matrix)value).toComplex();
// }
// if(t.equals(Matrix.class)){
// return (Complex) ((Matrix)value).toComplex();
// }
// if(t.equals(Vector.class)){
// return (Complex) ((Vector)value).toComplex();
// }
// if(t.equals(Vector.class)){
// return (Complex) ((Vector)value).toComplex();
// }
// throw new ClassCastException();
// }
@Override
public TypeName<Matrix<T>> getItemType() {
return matrixType;
}
@Override
public Matrix<T> convert(double d) {
return Maths.matrix(new double[][]{{d}}).to(tr);
}
@Override
public Matrix<T> convert(Complex d) {
return Maths.matrix(new Complex[][]{{d}}).to(tr);
}
@Override
public Matrix<T> convert(Matrix d) {
return d.to(tr);
}
@Override
public Matrix<T> zero() {
return convert(0);
}
@Override
public Matrix<T> one() {
return convert(1);
}
@Override
public Matrix<T> nan() {
return convert(Double.NaN);
}
@Override
public Matrix<T> add(Matrix<T> a, Matrix<T> b) {
return a.add(b);
}
@Override
public RepeatableOp<Matrix<T>> addRepeatableOp() {
return new RepeatableOp<Matrix<T>>() {
Matrix<T> c = null;
@Override
public void append(Matrix<T> item) {
c = new MemMatrix<>(item.getRowCount(), item.getColumnCount(), vs);
c.add(item);
}
@Override
public Matrix<T> eval() {
if (c == null) {
c = new MemMatrix<>(0, 0, vs);
c.set(0, 0, vs.zero());
}
return c;
}
};
}
@Override
public RepeatableOp<Matrix<T>> mulRepeatableOp() {
return new RepeatableOp<Matrix<T>>() {
Matrix<T> c = null;
@Override
public void append(Matrix<T> item) {
c = new MemMatrix<>(item.getRowCount(), item.getColumnCount(), vs);
c.add(item);
}
@Override
public Matrix<T> eval() {
if (c == null) {
c = new MemMatrix<>(0, 0, vs);
c.set(0, 0, vs.one());
}
return c;
}
};
}
@Override
public Matrix<T> minus(Matrix<T> a, Matrix<T> b) {
return a.sub(b);
}
@Override
public Matrix<T> mul(Matrix<T> a, Matrix<T> b) {
return a.mul(b);
}
@Override
public Matrix<T> div(Matrix<T> a, Matrix<T> b) {
return a.div(b);
}
@Override
public Matrix<T> rem(Matrix<T> a, Matrix<T> b) {
return a.rem(b);
}
@Override
public Matrix<T> real(Matrix<T> a) {
return (a.real());
}
@Override
public Matrix<T> imag(Matrix<T> a) {
return (a.imag());
}
@Override
public Matrix<T> abs(Matrix<T> a) {
return (a.abs());
}
@Override
public double absdbl(Matrix<T> a) {
return a.norm();
}
@Override
public double absdblsqr(Matrix<T> a) {
double d = absdbl(a);
return d * d;
}
@Override
public Matrix<T> abssqr(Matrix<T> a) {
return a.abssqr();
}
@Override
public Matrix<T> neg(Matrix<T> complex) {
return complex.neg();
}
@Override
public Matrix<T> conj(Matrix<T> complex) {
return complex.conj();
}
@Override
public Matrix<T> inv(Matrix<T> complex) {
return complex.inv();
}
@Override
public Matrix<T> sin(Matrix<T> complex) {
return complex.sin();
}
@Override
public Matrix<T> cos(Matrix<T> complex) {
return complex.cos();
}
@Override
public Matrix<T> tan(Matrix<T> complex) {
return complex.tan();
}
@Override
public Matrix<T> cotan(Matrix<T> complex) {
return complex.cotan();
}
@Override
public Matrix<T> sinh(Matrix<T> complex) {
return complex.sinh();
}
@Override
public Matrix<T> sincard(Matrix<T> complex) {
return complex.sincard();
}
@Override
public Matrix<T> cosh(Matrix<T> complex) {
return complex.cosh();
}
@Override
public Matrix<T> tanh(Matrix<T> complex) {
return complex.tanh();
}
@Override
public Matrix<T> cotanh(Matrix<T> complex) {
return complex.cotanh();
}
@Override
public Matrix<T> asinh(Matrix<T> complex) {
return complex.asinh();
}
@Override
public Matrix<T> acosh(Matrix<T> complex) {
return complex.acosh();
}
@Override
public Matrix<T> asin(Matrix<T> complex) {
return complex.asinh();
}
@Override
public Matrix<T> acos(Matrix<T> complex) {
return complex.acos();
}
@Override
public Matrix<T> atan(Matrix<T> complex) {
return complex.atan();
}
@Override
public Matrix<T> arg(Matrix<T> complex) {
return complex.arg();
}
@Override
public boolean isZero(Matrix<T> a) {
return a.isZero();
}
@Override
public <R> boolean is(Matrix<T> value, TypeName<R> type) {
return type.equals(tr);
}
@Override
public boolean isComplex(Matrix<T> a) {
return a.isComplex();
}
@Override
public Complex toComplex(Matrix<T> a) {
return a.toComplex();
}
@Override
public Matrix<T> acotan(Matrix<T> complex) {
return complex.acotan();
}
@Override
public Matrix<T> exp(Matrix<T> complex) {
return complex.exp();
}
@Override
public Matrix<T> log(Matrix<T> complex) {
return complex.log();
}
@Override
public Matrix<T> log10(Matrix<T> complex) {
return complex.log10();
}
@Override
public Matrix<T> db(Matrix<T> complex) {
return complex.db();
}
@Override
public Matrix<T> db2(Matrix<T> complex) {
return complex.db2();
}
@Override
public Matrix<T> sqr(Matrix<T> complex) {
return complex.sqr();
}
@Override
public Matrix<T> sqrt(Matrix<T> complex) {
return complex.sqrt();
}
@Override
public Matrix<T> sqrt(Matrix<T> complex, int n) {
return complex.sqrt(n);
}
@Override
public Matrix<T> pow(Matrix<T> a, Matrix<T> b) {
return a.pow(b);
}
@Override
public Matrix<T> pow(Matrix<T> a, double b) {
return a.pow(b);
}
@Override
public Matrix<T> npow(Matrix<T> complex, int n) {
return complex.pow(n);
}
@Override
public Matrix<T> lt(Matrix<T> a, Matrix<T> b) {
int rows = Math.max(a.getRowCount(), b.getRowCount());
int columns = Math.max(a.getColumnCount(), b.getColumnCount());
Matrix<T> m = new MemMatrix<T>(rows, columns, vs);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
m.set(i, j, vs.lt(a.get(i, j), b.get(i, j)));
}
}
return m;
}
@Override
public Matrix<T> lte(Matrix<T> a, Matrix<T> b) {
int rows = Math.max(a.getRowCount(), b.getRowCount());
int columns = Math.max(a.getColumnCount(), b.getColumnCount());
Matrix<T> m = new MemMatrix<T>(rows, columns, vs);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
m.set(i, j, vs.lte(a.get(i, j), b.get(i, j)));
}
}
return m;
}
@Override
public Matrix<T> gt(Matrix<T> a, Matrix<T> b) {
int rows = Math.max(a.getRowCount(), b.getRowCount());
int columns = Math.max(a.getColumnCount(), b.getColumnCount());
Matrix<T> m = new MemMatrix<T>(rows, columns, vs);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
m.set(i, j, vs.gt(a.get(i, j), b.get(i, j)));
}
}
return m;
}
@Override
public Matrix<T> gte(Matrix<T> a, Matrix<T> b) {
int rows = Math.max(a.getRowCount(), b.getRowCount());
int columns = Math.max(a.getColumnCount(), b.getColumnCount());
Matrix<T> m = new MemMatrix<T>(rows, columns, vs);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
m.set(i, j, vs.gte(a.get(i, j), b.get(i, j)));
}
}
return m;
}
@Override
public Matrix<T> eq(Matrix<T> a, Matrix<T> b) {
return a.equals(b) ? one() : zero();
}
@Override
public Matrix<T> ne(Matrix<T> a, Matrix<T> b) {
return (!a.equals(b)) ? one() : zero();
}
@Override
public Matrix<T> not(Matrix<T> a) {
return a.isZero() ? one() : zero();
}
@Override
public Matrix<T> and(Matrix<T> a, Matrix<T> b) {
return (!a.isZero() && !a.isZero()) ? one() : zero();
}
@Override
public Matrix<T> or(Matrix<T> a, Matrix<T> b) {
return (!a.isZero() || !a.isZero()) ? one() : zero();
}
@Override
public Matrix<T> If(Matrix<T> cond, Matrix<T> exp1, Matrix<T> exp2) {
return !cond.isZero() ? exp1 : exp2;
}
@Override
public Matrix<T> parse(String string) {
throw new IllegalArgumentException("Not supported yet");
}
@Override
public Matrix<T> scalarProduct(Matrix<T> a, Matrix<T> b) {
//return hermitian ? a.mul(b) : a.conj().mul(b);
return a.mul(b);
}
@Override
public Matrix<T> setParam(Matrix<T> a, String paramName, Object b) {
return a;
}
}
| [
"[email protected]"
] | |
aaea50c03a3994ced156d4f3c866ab40af5612c4 | ee0299558e891ccf6cef2c1f93de8786cad154fa | /MahasiswaComparator.java | 562fe195be31d90fa522c04d9b912d2e7c937b65 | [] | no_license | rayhansyahli01/myjavacollection | d7bfbc85e3d644d9175654e2dbfea81662767290 | 11ae65b0643862f89ed3ab597429daf77ff0806c | refs/heads/master | 2023-05-28T20:43:48.799240 | 2021-06-07T02:47:27 | 2021-06-07T02:47:27 | 372,731,239 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 840 | java | import java.util.Comparator;
/**
* Write a description of class MahasiswaComparator here.
*
* @author raihan
* @version 5.1
*/
public class MahasiswaComparator implements Comparator<Mahasiswa>
{
// instance variables - replace the example below with your own
/**
* Constructor for objects of class MahasiswaComparator
*/
public MahasiswaComparator()
{
// initialise instance variables
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
@Override
public int compare(Mahasiswa mhs1, Mahasiswa mhs2)
{
// put your code here
//return mhs1.getnimMhs() - mhs2.getnimMhs();
return mhs1.getumurMhs() - mhs2.getumurMhs();
}
} | [
"My [email protected]"
] | |
8dccad8d6ec0374e2064bab08dcfaa4137ad6712 | 9e20645e45cc51e94c345108b7b8a2dd5d33193e | /L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestEnchantItem.java | 418833115c7f4c060e947c607e658b8dc4b2a68e | [] | no_license | Enryu99/L2jMobius-01-11 | 2da23f1c04dcf6e88b770f6dcbd25a80d9162461 | 4683916852a03573b2fe590842f6cac4cc8177b8 | refs/heads/master | 2023-09-01T22:09:52.702058 | 2021-11-02T17:37:29 | 2021-11-02T17:37:29 | 423,405,362 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 22,680 | java | /*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
import org.l2jmobius.gameserver.enums.ItemSkillType;
import org.l2jmobius.gameserver.enums.UserInfoType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.enchant.EnchantResultType;
import org.l2jmobius.gameserver.model.items.enchant.EnchantScroll;
import org.l2jmobius.gameserver.model.items.enchant.EnchantSupportItem;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
import org.l2jmobius.gameserver.network.serverpackets.ExItemAnnounce;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
public class RequestEnchantItem implements IClientIncomingPacket
{
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
private int _objectId;
private int _supportId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_supportId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
if ((request == null) || request.isProcessing())
{
return;
}
request.setEnchantingItem(_objectId);
request.setProcessing(true);
if (!player.isOnline() || client.isDetached())
{
player.removeRequest(request.getClass());
return;
}
if (player.isProcessingTransaction() || player.isInStoreMode())
{
client.sendPacket(SystemMessageId.YOU_CANNOT_ENCHANT_WHILE_OPERATING_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
player.removeRequest(request.getClass());
return;
}
final ItemInstance item = request.getEnchantingItem();
final ItemInstance scroll = request.getEnchantingScroll();
final ItemInstance support = request.getSupportItem();
if ((item == null) || (scroll == null))
{
player.removeRequest(request.getClass());
return;
}
// template for scroll
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
if (scrollTemplate == null)
{
return;
}
// template for support item, if exist
EnchantSupportItem supportTemplate = null;
if (support != null)
{
if (support.getObjectId() != _supportId)
{
player.removeRequest(request.getClass());
return;
}
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
}
// first validation check - also over enchant check
if (!scrollTemplate.isValid(item, supportTemplate) || (Config.DISABLE_OVER_ENCHANTING && ((item.getEnchantLevel() == scrollTemplate.getMaxEnchantLevel()) || (!(item.getItem().getEnchantLimit() == 0) && (item.getEnchantLevel() == item.getItem().getEnchantLimit())))))
{
client.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
return;
}
// fast auto-enchant cheat check
if ((request.getTimestamp() == 0) || ((Chronos.currentTimeMillis() - request.getTimestamp()) < 2000))
{
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " use autoenchant program ", Config.DEFAULT_PUNISH);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
return;
}
// attempting to destroy scroll
if (player.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, player, item) == null)
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
return;
}
// attempting to destroy support if exist
if ((support != null) && (player.getInventory().destroyItem("Enchant", support.getObjectId(), 1, player, item) == null))
{
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
return;
}
final InventoryUpdate iu = new InventoryUpdate();
synchronized (item)
{
// last validation check
if ((item.getOwnerId() != player.getObjectId()) || !item.isEnchantable())
{
client.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
return;
}
final EnchantResultType resultType = scrollTemplate.calculateSuccess(player, item, supportTemplate);
switch (resultType)
{
case ERROR:
{
client.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
break;
}
case SUCCESS:
{
final Item it = item.getItem();
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
if (scrollTemplate.getChance(player, item) > 0)
{
if (supportTemplate != null)
{
item.setEnchantLevel(Math.min(item.getEnchantLevel() + Rnd.get(supportTemplate.getRandomEnchantMin(), supportTemplate.getRandomEnchantMax()), supportTemplate.getMaxEnchantLevel()));
}
else
{
item.setEnchantLevel(Math.min(item.getEnchantLevel() + Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
}
item.updateDatabase();
}
client.sendPacket(new EnchantResult(EnchantResult.SUCCESS, item));
if (Config.LOG_ITEM_ENCHANTS)
{
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
// announce the success
if ((item.getEnchantLevel() >= (item.isArmor() ? Config.MIN_ARMOR_ENCHANT_ANNOUNCE : Config.MIN_WEAPON_ENCHANT_ANNOUNCE)) //
&& (item.getEnchantLevel() <= (item.isArmor() ? Config.MAX_ARMOR_ENCHANT_ANNOUNCE : Config.MAX_WEAPON_ENCHANT_ANNOUNCE)))
{
final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_SUCCESSFULLY_ENCHANTED_A_S2_S3);
sm.addString(player.getName());
sm.addInt(item.getEnchantLevel());
sm.addItemName(item);
player.broadcastPacket(sm);
Broadcast.toAllOnlinePlayers(new ExItemAnnounce(item, player));
final Skill skill = CommonSkill.FIREWORK.getSkill();
if (skill != null)
{
player.broadcastPacket(new MagicSkillUse(player, player, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
}
}
if (item.isEquipped())
{
if (item.isArmor())
{
it.forEachSkill(ItemSkillType.ON_ENCHANT, holder ->
{
// add skills bestowed from +4 armor
if (item.getEnchantLevel() >= holder.getValue())
{
player.addSkill(holder.getSkill(), false);
player.sendSkillList();
}
});
}
player.broadcastUserInfo(); // update user info
}
break;
}
case FAILURE:
{
if (scrollTemplate.isSafe())
{
// safe enchant - remain old value
client.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
client.sendPacket(new EnchantResult(EnchantResult.SAFE_FAIL, item));
if (Config.LOG_ITEM_ENCHANTS)
{
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
else
{
// unequip item on enchant failure to avoid item skills stack
if (item.isEquipped())
{
if (item.getEnchantLevel() > 0)
{
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2_HAS_BEEN_UNEQUIPPED);
sm.addInt(item.getEnchantLevel());
sm.addItemName(item);
client.sendPacket(sm);
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(item);
client.sendPacket(sm);
}
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
{
iu.addModifiedItem(itm);
}
player.sendInventoryUpdate(iu);
player.broadcastUserInfo();
}
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown() || ((supportTemplate != null) && supportTemplate.isDown()) || ((supportTemplate != null) && supportTemplate.isBlessed()))
{
// blessed enchant - enchant value down by 1
if (scrollTemplate.isBlessedDown() || ((supportTemplate != null) && supportTemplate.isDown()))
{
player.sendMessage("The enchant value is decreased by 1.");
item.setEnchantLevel(item.getEnchantLevel() - 1);
}
else // blessed enchant - clear enchant value
{
client.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
item.setEnchantLevel(0);
}
item.updateDatabase();
client.sendPacket(new EnchantResult(EnchantResult.BLESSED_FAIL, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
else
{
// enchant failed, destroy item
if (player.getInventory().destroyItem("Enchant", item, player, null) == null)
{
// unable to destroy item, cheater ?
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from player " + player.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
player.removeRequest(request.getClass());
client.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
if (Config.LOG_ITEM_ENCHANTS)
{
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
return;
}
World.getInstance().removeObject(item);
int count = 0;
if (item.getItem().isCrystallizable())
{
count = Math.max(0, item.getCrystalCount() - ((item.getItem().getCrystalCount() + 1) / 2));
}
ItemInstance crystals = null;
final int crystalId = item.getItem().getCrystalItemId();
if (count > 0)
{
crystals = player.getInventory().addItem("Enchant", crystalId, count, player, item);
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
sm.addItemName(crystals);
sm.addLong(count);
client.sendPacket(sm);
}
if (!Config.FORCE_INVENTORY_UPDATE && (crystals != null))
{
iu.addItem(crystals);
}
if ((crystalId == 0) || (count == 0))
{
client.sendPacket(new EnchantResult(EnchantResult.NO_CRYSTAL, 0, 0));
}
else
{
client.sendPacket(new EnchantResult(EnchantResult.FAIL, crystalId, count));
}
if (Config.LOG_ITEM_ENCHANTS)
{
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
}
break;
}
}
player.sendItemList();
request.setProcessing(false);
player.broadcastUserInfo(UserInfoType.ENCHANTLEVEL);
}
}
}
| [
"MobiusDevelopment@7325c9f8-25fd-504a-9f63-8876acdc129b"
] | MobiusDevelopment@7325c9f8-25fd-504a-9f63-8876acdc129b |
890f602a4f7c9c65c7a70ff6b998ba8f7e7807a3 | 522eb4a57529ef03cc073c90adde1e5199bff0fe | /hermes-rest/src/main/java/com/ctrip/hermes/rest/service/SoaPushCommand.java | 086d9dbf1912292f5425243d06ab746e71bc3a52 | [
"Apache-2.0"
] | permissive | gspandy/hermes-1 | 11dcd2545c42741cbd95d12f3622751512f531f6 | fa80f9626b8fbff91d88d08a262e65a84a39aa14 | refs/heads/master | 2023-08-09T19:36:42.915662 | 2016-01-21T13:18:34 | 2016-01-21T13:18:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | package com.ctrip.hermes.rest.service;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
public class SoaPushCommand extends HystrixCommand<Object> {
protected SoaPushCommand(HystrixCommandGroupKey group) {
super(group);
}
@Override
protected Object run() throws Exception {
// TODO Auto-generated method stub
return null;
}
}
| [
"[email protected]"
] | |
c9620836cefe13f770d81b7eea58b6f51a9ed9b2 | b4ea86f9da7b4da4a170839ca57bd4db8f0e4ce1 | /src/main/java/com/lvpeng/seller/dal/model/GoodsInnerCategory.java | 2a6fff77a2e6a320583cfaec6baccf6ba6e674e4 | [] | no_license | forgotwho/lvpeng_seller_web | 9f735d1c7bd0be12051012dae9a5187d4d443700 | 007041b4f5c19466c856ed2b573bca7529588e7d | refs/heads/master | 2020-03-19T08:14:16.734073 | 2018-06-28T09:20:18 | 2018-06-28T09:20:18 | 136,187,151 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,650 | java | /**
* Copyright 2018 bejson.com
*/
package com.lvpeng.seller.dal.model;
import java.util.Date;
import org.springframework.data.annotation.Id;
/**
* Auto-generated: 2018-06-23 21:50:44
*
* @author bejson.com ([email protected])
* @website http://www.bejson.com/java2pojo/
*/
public class GoodsInnerCategory {
@Id
private int id;
private int pid;
private String name;
private int shopId;
private int seq;
private Date createTime;
private Date updateTime;
private int isDelete;
private int isShow;
private String type;
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setPid(int pid) {
this.pid = pid;
}
public int getPid() {
return pid;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public int getShopId() {
return shopId;
}
public void setSeq(int seq) {
this.seq = seq;
}
public int getSeq() {
return seq;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getCreateTime() {
return createTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
public int getIsDelete() {
return isDelete;
}
public void setIsShow(int isShow) {
this.isShow = isShow;
}
public int getIsShow() {
return isShow;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
} | [
"[email protected]"
] | |
3a756eb5f55a0ddd681ea72f7c9f4de15849bc79 | f9f82a813512ef1b6e6f0dbcc9b33d622c6e66ca | /quiz3no1.java | 0c09e30c65f05cd83582219f60a4004ef69ee93a | [] | no_license | rishabh-parekh/test-java | 0dc83d6e69748b21a09295979d8a667a2793f60b | d3f8eecebb1fda5d69031cd877f0a20403a60145 | refs/heads/master | 2021-01-11T03:08:21.855358 | 2016-11-28T03:11:18 | 2016-11-28T03:11:18 | 71,085,941 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 246 | java | public class quiz3no1 {
public static void main (String [] args)
{
int a = 10;
double b = 10.7;
double c = a + b;
// int d = a + (int)c;
//int d = a + c;
//System.out.println(c + "" + d);
}
}
| [
"[email protected]"
] | |
38c5136b6cc4bbf10d3e5b7154eb1f4daff8b466 | 909a602bd3d1300ca302ce1b9d3946c18a281632 | /src/net/jcip/examples/PrivateLock.java | c27bde3904063b5405f7e69e6d7a31c01544a3d7 | [] | no_license | rohit-sachan/JAVAConcurrency | ff92b87234037c0cabd3a7a9974c32e875674869 | 81a077a29ddb05cf000194d0570259f6d5210206 | refs/heads/master | 2021-01-16T23:22:32.348326 | 2013-08-04T15:27:28 | 2013-08-04T15:27:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 421 | java | package net.jcip.examples;
import net.jcip.annotation.GuardedBy;
/**
* PrivateLock
* <p/>
* Guarding state with a private lock
*
* @author Brian Goetz and Tim Peierls
*/
public class PrivateLock {
private final Object myLock = new Object();
@GuardedBy("myLock") Widget widget;
void someMethod() {
synchronized (myLock) {
// Access or modify the state of widget
}
}
}
| [
"[email protected]"
] | |
98d2ae41e0a64ffb5fd3fd3c572d00b7c4136e14 | a1e49f5edd122b211bace752b5fb1bd5c970696b | /projects/org.springframework.orm/src/test/java/org/springframework/orm/jdo/support/JdoDaoSupportTests.java | 89b3987b1116b41f05e3b906ad1dd670c4a4b569 | [
"Apache-2.0"
] | permissive | savster97/springframework-3.0.5 | 4f86467e2456e5e0652de9f846f0eaefc3214cfa | 34cffc70e25233ed97e2ddd24265ea20f5f88957 | refs/heads/master | 2020-04-26T08:48:34.978350 | 2019-01-22T14:45:38 | 2019-01-22T14:45:38 | 173,434,995 | 0 | 0 | Apache-2.0 | 2019-03-02T10:37:13 | 2019-03-02T10:37:12 | null | UTF-8 | Java | false | false | 2,256 | java | /*
* Copyright 2002-2005 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.orm.jdo.support;
import java.util.ArrayList;
import java.util.List;
import javax.jdo.PersistenceManagerFactory;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.orm.jdo.JdoTemplate;
/**
* @author Juergen Hoeller
* @since 30.07.2003
*/
public class JdoDaoSupportTests extends TestCase {
public void testJdoDaoSupportWithPersistenceManagerFactory() throws Exception {
MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
pmf.getConnectionFactory();
pmfControl.setReturnValue(null, 1);
pmfControl.replay();
final List test = new ArrayList();
JdoDaoSupport dao = new JdoDaoSupport() {
protected void initDao() {
test.add("test");
}
};
dao.setPersistenceManagerFactory(pmf);
dao.afterPropertiesSet();
assertEquals("Correct PersistenceManagerFactory", pmf, dao.getPersistenceManagerFactory());
assertEquals("Correct JdoTemplate", pmf, dao.getJdoTemplate().getPersistenceManagerFactory());
assertEquals("initDao called", test.size(), 1);
pmfControl.verify();
}
public void testJdoDaoSupportWithJdoTemplate() throws Exception {
JdoTemplate template = new JdoTemplate();
final List test = new ArrayList();
JdoDaoSupport dao = new JdoDaoSupport() {
protected void initDao() {
test.add("test");
}
};
dao.setJdoTemplate(template);
dao.afterPropertiesSet();
assertEquals("Correct JdoTemplate", template, dao.getJdoTemplate());
assertEquals("initDao called", test.size(), 1);
}
}
| [
"[email protected]"
] | |
a9f2a02e562201410e59ad45009ecbf70222d232 | a1f49f3d9e354f7d0a8f8837959720f2bcf3b38e | /src/main/java/com/idexcel/cync/los/entity/common/utils/ActivityLog.java | dc25a36a110bd316a584af2a606027cf0439bd13 | [] | no_license | Hrishi29/cync-entity-service | 65dfabaeee46be157ca9afa3396a8612be6fb001 | 980ba671c09a48ef3a0ba474862d31f9d5825668 | refs/heads/master | 2022-12-20T17:41:03.347475 | 2020-10-06T22:41:44 | 2020-10-06T22:41:44 | 301,869,270 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,625 | java | package com.idexcel.cync.los.entity.common.utils;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.LinkedHashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import com.google.gson.Gson;
import com.idexcel.cync.los.entity.common.constants.CoreConstants;
import com.idexcel.cync.los.entity.common.constants.LOSEntityConstants;
import com.idexcel.cync.los.entity.dto.IndividualEntityDto;
public class ActivityLog {
private static final Logger LOG = LoggerFactory.getLogger(ActivityLog.class);
public static String getActivityLog(String entityName, Operation operation, String entityId, String userAction,
Status status, String requestIdentifier, LocalDateTime timestamp) {
Map<String, String> json = new LinkedHashMap<String, String>();
json.put(LOSEntityConstants.APP_NAME, LOSEntityConstants.CYNC_LOS);
json.put(LOSEntityConstants.CLIENT, MDC.get(LOSEntityConstants.CLIENT_NAME_KEY));
json.put(LOSEntityConstants.SERVICE_NAME, LOSEntityConstants.APPLICATION_NAME);
json.put(LOSEntityConstants.RECORD_NAME, entityName);
json.put(LOSEntityConstants.OPERATION, operation.toString());
json.put(LOSEntityConstants.ID, entityId);
json.put(LOSEntityConstants.USER_ACTION, userAction);
json.put(LOSEntityConstants.STATUS, status.toString());
json.put(LOSEntityConstants.REQUESTIDENTIFIER, requestIdentifier);
json.put(LOSEntityConstants.USER_EMAIL, MDC.get(CoreConstants.USER_NAME));
json.put(LOSEntityConstants.TIMESTAMP, timestamp.toString());
String jsonData = null;
try {
jsonData = new Gson().toJson(json, Object.class);
} catch (Exception e) {
LOG.info("Error while printing the activity log {}" + e.getMessage());
}
return jsonData;
}
/**
* Method to convert local time into UTC
*
* @return
*/
public static LocalDateTime localDateTimeInUTC() {
return LocalDateTime.now().atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime();
}
/**
* Method to return IndividualEntity Name
*
* @param individualFinancialEntityDto
* @return
*/
public static String entityName(IndividualEntityDto individualFinancialEntityDto) {
String nameString = null;
if (individualFinancialEntityDto.getMiddleName() == null) {
nameString = individualFinancialEntityDto.getFirstName() + " " + individualFinancialEntityDto.getLastName();
} else {
nameString = individualFinancialEntityDto.getFirstName() + " "
+ individualFinancialEntityDto.getMiddleName() + " " + individualFinancialEntityDto.getLastName();
}
return nameString;
}
}
| [
"[email protected]"
] | |
da5d9740680c163656f1c6c5dc6d7baa03cb8f67 | a7b868c8c81984dbcb17c1acc09c0f0ab8e36c59 | /src/main/java/com/alipay/api/response/AlipayEbppCommunityPropertyCreateResponse.java | 334b161d7d1f72f6eb1bf8dfc9e08ed37d31046c | [
"Apache-2.0"
] | permissive | 1755616537/alipay-sdk-java-all | a7ebd46213f22b866fa3ab20c738335fc42c4043 | 3ff52e7212c762f030302493aadf859a78e3ebf7 | refs/heads/master | 2023-02-26T01:46:16.159565 | 2021-02-02T01:54:36 | 2021-02-02T01:54:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,074 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.domain.ExternalContact;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.ebpp.community.property.create response.
*
* @author auto create
* @since 1.0, 2020-11-17 09:45:13
*/
public class AlipayEbppCommunityPropertyCreateResponse extends AlipayResponse {
private static final long serialVersionUID = 3771949428937286783L;
/**
* 外部联系人
*/
@ApiField("contacts")
private ExternalContact contacts;
/**
* 物业公司名称拼音首字母大写+YYYYMMDD+防重位
*/
@ApiField("property_short_name")
private String propertyShortName;
public void setContacts(ExternalContact contacts) {
this.contacts = contacts;
}
public ExternalContact getContacts( ) {
return this.contacts;
}
public void setPropertyShortName(String propertyShortName) {
this.propertyShortName = propertyShortName;
}
public String getPropertyShortName( ) {
return this.propertyShortName;
}
}
| [
"[email protected]"
] | |
3404e999553a0998a0e207e432a4008ca7e661bc | 2b5aaaf43b5a5b3602e20c948c0f2d58583860ed | /mstar-server-dao/src/main/java/com/wincom/mstar/dao/mapper/BOptimalValueMapper.java | 9c887cd94c4ccad80b11ccfc6acedb19db569678 | [
"Apache-2.0"
] | permissive | xtwxy/cassandra-tests | 2bb2350bf325eba9353d6d632ffe3e4076e213e4 | 346023aad17d37f1d140879b6808092e04d0e1eb | refs/heads/master | 2021-01-19T11:34:27.120908 | 2017-04-17T21:31:12 | 2017-04-17T21:31:12 | 82,253,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,198 | java | package com.wincom.mstar.dao.mapper;
import com.wincom.mstar.domain.BOptimalValue;
import com.wincom.mstar.domain.BOptimalValueExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface BOptimalValueMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int countByExample(BOptimalValueExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int deleteByExample(BOptimalValueExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int insert(BOptimalValue record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int insertSelective(BOptimalValue record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
List<BOptimalValue> selectByExample(BOptimalValueExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int updateByExampleSelective(@Param("record") BOptimalValue record, @Param("example") BOptimalValueExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table nfjd502.dbo.BOptimalValue
*
* @mbggenerated Thu Mar 02 11:23:21 CST 2017
*/
int updateByExample(@Param("record") BOptimalValue record, @Param("example") BOptimalValueExample example);
} | [
"[email protected]"
] | |
bb223a6dd9926d4d0c3f0d3f11ff1b905ec6865a | 4c235e8180ab1a70b77484d7b35b6075ce15d4c5 | /src/main/java/com/cobranca/cobranca/Dao/ITitulo.java | f837dea12704b58c4536c3bc72e42a420cced670 | [
"MIT"
] | permissive | brunocesaromax/CobrancaProjeto | 710ae5f5203de97e0788e320c11aed81d3f324dd | 4ce5fe881e873130470e8d1a4874cc67dfc01139 | refs/heads/master | 2023-03-06T01:43:10.104139 | 2023-02-25T13:06:03 | 2023-02-25T13:06:03 | 121,873,584 | 0 | 0 | MIT | 2022-06-20T23:06:39 | 2018-02-17T16:57:47 | HTML | UTF-8 | Java | false | false | 385 | java | package com.cobranca.cobranca.Dao;
import com.cobranca.cobranca.Model.Titulo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface ITitulo extends JpaRepository<Titulo,Long> {
//Buscar titulos que contenham na descricao o parametro que foi passado como parametro
List<Titulo> findByDescricaoContaining(String descricao);
}
| [
"[email protected]"
] | |
60817abc59e09b7e32eecb8dad3f7e422aad777f | cda9fcaa88ee2c940b5cd7cbb179270e9ceef3f6 | /bpmCommon/src/artifacts/workItemKeyDetails/WorkItemKeyDetails.java | b240488874e8ffe089320b38866e6ce2ecd58af4 | [] | no_license | joper90/bpmLiteSocial | 2cee04dc9b2d704f9767c9be4881bad2b45e5117 | 416dfe224d6a7e0ca17634fb648ba7cc229e7abc | refs/heads/master | 2021-01-17T05:53:40.147704 | 2013-11-12T18:00:44 | 2013-11-12T18:00:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,021 | java |
package artifacts.workItemKeyDetails;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.ektorp.support.CouchDbDocument;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("com.googlecode.jsonschema2pojo")
@JsonPropertyOrder({
"docType",
"processId",
"worked",
"stepId",
"uniqueFormGuid",
"userKey",
"rootKey",
"displayOnly",
"orderList",
"callBackGuid",
"keyFieldDetails"
})
public class WorkItemKeyDetails extends CouchDbDocument{
/**
*
*/
private static final long serialVersionUID = 1L;
@JsonProperty("docType")
private String docType;
@JsonProperty("processId")
private String processId;
@JsonProperty("worked")
private Boolean worked;
@JsonProperty("stepId")
private String stepId;
@JsonProperty("uniqueFormGuid")
private String uniqueFormGuid;
@JsonProperty("userKey")
private String userKey;
@JsonProperty("rootKey")
private String rootKey;
@JsonProperty("displayOnly")
private String displayOnly;
@JsonProperty("orderList")
private String orderList;
@JsonProperty("callBackGuid")
private String callBackGuid;
@JsonProperty("keyFieldDetails")
private List<KeyFieldDetail> keyFieldDetails = new ArrayList<KeyFieldDetail>();
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonProperty("docType")
public String getDocType() {
return docType;
}
@JsonProperty("docType")
public void setDocType(String docType) {
this.docType = docType;
}
@JsonProperty("processId")
public String getProcessId() {
return processId;
}
@JsonProperty("processId")
public void setProcessId(String processId) {
this.processId = processId;
}
@JsonProperty("worked")
public Boolean getWorked() {
return worked;
}
@JsonProperty("worked")
public void setWorked(Boolean worked) {
this.worked = worked;
}
@JsonProperty("stepId")
public String getStepId() {
return stepId;
}
@JsonProperty("stepId")
public void setStepId(String stepId) {
this.stepId = stepId;
}
@JsonProperty("uniqueFormGuid")
public String getUniqueFormGuid() {
return uniqueFormGuid;
}
@JsonProperty("uniqueFormGuid")
public void setUniqueFormGuid(String uniqueFormGuid) {
this.uniqueFormGuid = uniqueFormGuid;
}
@JsonProperty("userKey")
public String getUserKey() {
return userKey;
}
@JsonProperty("userKey")
public void setUserKey(String userKey) {
this.userKey = userKey;
}
@JsonProperty("rootKey")
public String getRootKey() {
return rootKey;
}
@JsonProperty("rootKey")
public void setRootKey(String rootKey) {
this.rootKey = rootKey;
}
@JsonProperty("displayOnly")
public String getDisplayOnly() {
return displayOnly;
}
@JsonProperty("displayOnly")
public void setDisplayOnly(String displayOnly) {
this.displayOnly = displayOnly;
}
@JsonProperty("orderList")
public String getOrderList() {
return orderList;
}
@JsonProperty("orderList")
public void setOrderList(String orderList) {
this.orderList = orderList;
}
@JsonProperty("callBackGuid")
public String getCallBackGuid() {
return callBackGuid;
}
@JsonProperty("callBackGuid")
public void setCallBackGuid(String callBackGuid) {
this.callBackGuid = callBackGuid;
}
@JsonProperty("keyFieldDetails")
public List<KeyFieldDetail> getKeyFieldDetails() {
return keyFieldDetails;
}
@JsonProperty("keyFieldDetails")
public void setKeyFieldDetails(List<KeyFieldDetail> keyFieldDetails) {
this.keyFieldDetails = keyFieldDetails;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object other) {
return EqualsBuilder.reflectionEquals(this, other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperties(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
| [
"[email protected]"
] | |
9224b2cf7482afb3920f0a3da59c4b871f70754e | 3c600892b1a8a7578e09199fee8bacc70d2e5716 | /src/com/yizhao/miniudcu/util/FileUtils/FileMoveUtil.java | acada7ed821bbd45ce3133d65f738119fdad189b | [] | no_license | yizhaocs/MiniUserDataCacheUpdater | 653d23cd3b403cc235b7a8274e4853362df6da28 | 55045d886cebc78f76cb11c5f2690714fce3d80c | refs/heads/master | 2021-03-27T08:55:31.988011 | 2017-05-08T17:48:10 | 2017-05-08T17:48:10 | 87,988,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,975 | java | package com.yizhao.miniudcu.util.FileUtils;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.IOException;
/**
* Created by yzhao on 4/15/17.
*/
public class FileMoveUtil {
private static final Logger logger = Logger.getLogger(FileMoveUtil.class);
/**
* Move file to a directory, overwriting it if necessary.
*
* @param file
* @param toDirectory
* @throws IOException
*/
public static void moveFile(File file, File toDirectory) throws IOException {
moveFile(file, toDirectory, true);
}
/**
* Move file into the given directory.
*
* @param file
* @param toDirectory
* @param overwrite
* @throws IOException
*/
public static void moveFile(File file, File toDirectory, boolean overwrite) throws IOException {
if (!file.exists())
return;
File toFile = new File(toDirectory, file.getName());
doMoveFile(file, toFile, overwrite);
}
public static void doMoveFile(File fromFile, File toFile, boolean overwrite) throws IOException {
if( logger.isDebugEnabled() ){
logger.debug( "START moving file " + fromFile + " to " + toFile );
}
if (toFile.equals(fromFile)) {
if (logger.isDebugEnabled()) {
logger.debug(String
.format("Warning - tried to move a file %s to itself %s - no action taken...",
fromFile, toFile));
}
return;
}
if (toFile.exists() && overwrite && !toFile.delete())
throw new IOException("Could not delete existing file " + toFile + " to overwrite");
if (!fromFile.renameTo(toFile)) {
throw new IOException("Could not move file " + fromFile + " to " + toFile);
}
if( logger.isDebugEnabled() ){
logger.debug( "FINISH moving file " + fromFile + " to " + toFile );
}
}
}
| [
"[email protected]"
] | |
33093dc5865c0488c9e0b806d9107c1c9d7b764d | 1ee4d32c655e6289d8735568ae29ca96e5d51f97 | /src/main/java/I1.java | 80b472c990372c49029c0328823e518712c53815 | [] | no_license | samidala/datastructures-algorithms | 044d9e93aac7cfbb796f596e08c6359c3ba216bf | 2b5b9d965e2a8c7a8b47f7a12c074a6fcc455bc6 | refs/heads/master | 2020-04-16T19:06:55.222388 | 2019-01-15T12:28:33 | 2019-01-15T12:28:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 101 | java | public interface I1 {
default void display(){
System.out.println("display in I1");
}
}
| [
"[email protected]"
] | |
dd15174632f4d9a41bb5224c657352381ec8fb65 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/9/9_0449bd9f672c0008d5f4d326226e59df0e6abb01/mod_MLZ/9_0449bd9f672c0008d5f4d326226e59df0e6abb01_mod_MLZ_s.java | a0353365d72bd0219c4736cad6a05971363acff0 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 979 | java | package net.minecraft.src;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.client.Minecraft;
public class mod_MLZ extends BaseMod
{
public static ItemMCH mch = (ItemMCH)(new ItemMCH(128).setItemName("mch"));
public static Item defenseBeacon = mch; /* Testing */
public static Item miningBeacon = mch; /* Testing */
public void load()
{
this.addRecipes();
ModLoader.addName(mch, "Mind-Control Helmet");
mch.iconIndex = ModLoader.addOverride("/gui/items.png", "/mchelmet.png");
ModLoader.registerEntityID(EntityZombieMC.class, "EntityZombieMC", 123);
}
public void addRecipes()
{
ModLoader.addRecipe(new ItemStack(mch, 1), new Object[] { "R", "H", 'R', Block.torchRedstoneActive, 'H', Item.helmetSteel});
ModLoader.addRecipe(new ItemStack(mch, 64), new Object[] { "D", 'D', Block.dirt } ); /* For testing */
}
public String getVersion()
{
return "1.0";
}
}
| [
"[email protected]"
] | |
9091014144b8c866e16394cfb9b69ce8e7535e70 | c3c424a1c95f94c07ca8a3966085aa64b973696f | /src/main/java/com/springboot/rest/config/PersistenceConfiguration.java | cc5b89cce1469381ffde604a71d2a9cbeb3d2786 | [] | no_license | shanucool/angular_latest | 1ab8d3fdc1277b755ecfa0eaf8ebbedbd7f320cb | 04b8b69a9cd624b43ae685b4da653db966f60b4d | refs/heads/master | 2021-05-13T19:52:23.751434 | 2018-01-10T03:16:00 | 2018-01-10T03:16:00 | 116,901,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 820 | java | package com.springboot.rest.config;
import javax.sql.DataSource;
import org.springframework.boot.autoconfigure.flyway.FlywayDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@Configuration
public class PersistenceConfiguration {
@Bean
@ConfigurationProperties(prefix="spring.datasource")
@Primary
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Bean
@ConfigurationProperties(prefix="datasource.flyway")
@FlywayDataSource
public DataSource flywaydataSource() {
return DataSourceBuilder.create().build();
}
}
| [
"[email protected]"
] | |
4dd9a1d92917c24777018cb1b0756574f75d933e | ec581f0dc6829c4670da43e9b44a27ab6f264402 | /src/test/java/com/ghandreisv/meter/api/dto/MeterReadingDtoFixture.java | 499147f101dd73b9ebff051b9cd34726da48cf21 | [] | no_license | ghandreisv/meter | 8b7d4e3381f4d5accb410282792470ae81de07ef | 2c86ea43328e1ca531078f10effe35d43a05dcda | refs/heads/main | 2023-03-10T11:49:52.129317 | 2021-02-16T06:59:19 | 2021-02-16T06:59:19 | 336,918,700 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,002 | java | package com.ghandreisv.meter.api.dto;
import java.time.LocalDate;
import java.util.UUID;
public class MeterReadingDtoFixture {
public static MeterReadingDto withMeterId() {
MeterReadingDto meterReadingDto = noIds();
meterReadingDto.setMeterId(UUID.randomUUID().toString());
return meterReadingDto;
}
public static MeterReadingDto withAddressId() {
MeterReadingDto meterReadingDto = noIds();
meterReadingDto.setAddressId(UUID.randomUUID().toString());
return meterReadingDto;
}
public static MeterReadingDto withClientId() {
MeterReadingDto meterReadingDto = noIds();
meterReadingDto.setClientId(UUID.randomUUID().toString());
return meterReadingDto;
}
public static MeterReadingDto noIds() {
MeterReadingDto meterReadingDto = new MeterReadingDto();
meterReadingDto.setDate(LocalDate.of(2021, 2, 15));
meterReadingDto.setValue(11L);
return meterReadingDto;
}
}
| [
"[email protected]"
] | |
8738bd6085c863c6b84ab0197dfa4ee20de17448 | 78cb4d1f6718955f3b0c43781ef034f996f55146 | /study/src/main/kotlin/com/bruce/study/algorithm/RemoveDuplicatesJava.java | 8a96ed344fa9acc113f3fbf14029ea1d5fbefc6a | [] | no_license | BruceLql/study | bead939b72edb37322550bb39f8ebe31387c96f9 | 51d8d8078489e1c39ab8a0b12b90803d22f9e363 | refs/heads/master | 2022-11-13T18:42:56.803949 | 2020-06-28T07:32:27 | 2020-06-28T07:32:27 | 273,019,723 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,114 | java | package com.bruce.study.algorithm;
/*
*@ClassName RemoveDuplicatesJava
*@Description TODO
*@Author Bruce
*@Date 2020/6/18 10:20
*@Version 1.0
*/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeSet;
/**
* 删除有序数组中的重复元素,返回最终数组大小?(Java 版本)
* 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。
* 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。
*/
public class RemoveDuplicatesJava {
public int removeDuplicates(int[] arr) {
TreeSet<Integer> set=new TreeSet<Integer>();
for (int i : arr) {
set.add(i);
}
Iterator<Integer> iterator = set.iterator();
ArrayList<Integer> list=new ArrayList<>();
while (iterator.hasNext()){
list.add(iterator.next());
}
for (int i=0;i<list.size();i++) {
arr[i]=list.get(i);
}
return set.size();
}
} | [
"[email protected]"
] | |
cfa09ce1ef2209a88a859bfa3334ecf08c751bb7 | 39bef83f3a903f49344b907870feb10a3302e6e4 | /Android Studio Projects/bf.io.openshop/src/com/google/android/gms/measurement/zzi.java | bace3bea0a655589b6ad82fea602fdf1cf18a8b1 | [] | no_license | Killaker/Android | 456acf38bc79030aff7610f5b7f5c1334a49f334 | 52a1a709a80778ec11b42dfe9dc1a4e755593812 | refs/heads/master | 2021-08-19T06:20:26.551947 | 2017-11-24T22:27:19 | 2017-11-24T22:27:19 | 111,960,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 142 | java | package com.google.android.gms.measurement;
import android.net.*;
public interface zzi
{
void zzb(final zzc p0);
Uri zziA();
}
| [
"[email protected]"
] | |
6164795ced1b298218b12eae19b54774a7105ac8 | 53fe2dbea84f027a36a6ee02b9c3ed12332cf6c4 | /parser/DataTypes.java | d14aec360eceae454811ae34876f0139661a9886 | [
"MIT"
] | permissive | emory-irlab/emu | 352c6cd0b488bf8504e5f7232d0e91fca4b66e70 | 3482ecf2e4d0e45767eaf6123c6533d0c9683956 | refs/heads/master | 2021-03-19T16:58:51.005646 | 2016-12-23T18:26:11 | 2016-12-23T18:26:11 | 77,243,580 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 553 | java | package edu.emu;
public class DataTypes {
public static enum ActionType {
Load, LoadCap, UnLoad, Click, Change, MouseDown, Scroll, MouseMove, MouseOver, MouseOut, MouseUp, LocationChange0, LocationChange1, KeyPress, PageShow, PageHide, Focus, Blur, Resize, TabOpen, TabSelect, TabClose, Fixation;
public static boolean contains(String actionType) {
try {
valueOf(actionType);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
public static enum Version {
v_xx, v_04, v_05, v_06, v_07, v_07c
};
}
| [
"[email protected]"
] | |
f35906837e039688303988d0271554b4bd3c7cd1 | 3d8cc5f983781b9b8604ba18b1079fcae444410d | /src/test/java/org/fasttrack/pages/HomePage.java | d9aff24ba1f97f4f4ad28e4cc14df762fd294644 | [] | no_license | AdrianaCente/SerenityProject | b6839d32e9f10920d9bfec34768c011611cf0d3d | 29b999346431f863f2335e16568ccf478b016a30 | refs/heads/master | 2023-01-21T13:33:13.483218 | 2020-11-25T11:50:50 | 2020-11-25T11:50:50 | 307,463,838 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,564 | java | package org.fasttrack.pages;
import net.serenitybdd.core.annotations.findby.FindBy;
import net.serenitybdd.core.pages.PageObject;
import net.serenitybdd.core.pages.WebElementFacade;
import net.thucydides.core.annotations.DefaultUrl;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import java.util.List;
@DefaultUrl("http://qa4.fasttrackit.org:8008/")
public class HomePage extends PageObject {
@FindBy(xpath = "//li[starts-with(@class,'menu-item')]/a[text()='My account']")
private WebElementFacade accountLink;
@FindBy(xpath = "//li[starts-with(@class,'menu-item')]/a[text()='Shop']")
private WebElementFacade shopLink;
@FindBy(xpath = "//li[starts-with(@class,'menu-item')]/a[text()='Home']")
private WebElementFacade homeLink;
@FindBy(css = "article")
private List<WebElementFacade> articleList;
@FindBy(css = ".header-search-button")
private WebElementFacade searchIcon;
@FindBy(css = "input[title='Search for:']")
private WebElementFacade searchInputField;
@FindBy(css = "#search-2 .search-field")
private WebElementFacade asideSearchInputField;
@FindBy(css = "input[title='Search for:']+input[type='submit']")
private WebElementFacade searchButton;
@FindBy(css = ".fa-shopping-cart")
private WebElementFacade cartIcon;
public void clickMyAccountLink(){
clickOn(accountLink);
}
public void clickSearchIcon(){
clickOn(searchIcon);
}
public void setSearchInputField(String textInput) {
typeInto(searchInputField, textInput);
}
public void setSearchInputFieldAndPressEnter(String textInput) {
asideSearchInputField.sendKeys(textInput + Keys.ENTER);
}
public void clickSearchButton() {
clickOn(searchButton);
}
public void clickCartIcon() {
clickOn(cartIcon);
}
public void clickShopLink() {
clickOn(shopLink);
}
public void clickHomeLink() {
clickOn(homeLink);
}
public void findArticleByTitle(String title) {
for (WebElementFacade item : articleList) {
if (item.findBy(By.cssSelector(".entry-title a")).getText().equals(title)) {
clickOn(item);
break;
}
}
}
public boolean checkAddedPost(String title) {
for (WebElementFacade item : articleList) {
if (item.findBy(By.cssSelector(".entry-title a")).getText().equalsIgnoreCase(title)) {
return true;
}
}
return false;
}
}
| [
"[email protected]"
] | |
0c79992ea5f0fc18b395263040bbf12c7ac1cf64 | dcdb7f883ff49c35ee5e2c405f79679db0a6ae99 | /codex/codex-web/src/main/java/xyz/lionfish/edge/api/endpoint/DeviceController.java | 927ed4103a0f423496dfce648d69c8752bbdc792 | [] | no_license | kevendra/lionfish | 21843af48f7a85d44a8722bd6355ef5f36fc5192 | 661d3f698fb8d8f992ac93b454d4d264fc8dd3df | refs/heads/master | 2021-01-20T20:24:18.257831 | 2016-07-29T10:00:39 | 2016-07-29T10:00:39 | 64,466,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,211 | java | package xyz.lionfish.edge.api.endpoint;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import static xyz.lionfish.edge.api.util.Api.APP_ACTIVATE;
import static xyz.lionfish.edge.api.util.Api.DEVICE;
import static xyz.lionfish.edge.api.util.Api.REGISTRATION;
import javax.annotation.Resource;
import me.parakh.core.api.endpoint.AbstractCommonUtilityController;
import me.parakh.core.api.response.ApiResponse;
import me.parakh.core.dto.common.TokenDto;
import me.parakh.core.service.common.TokenService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* The Activity controller.
*
* @author Kevendra Patidar
*/
@RestController
@RequestMapping(DEVICE)
public class DeviceController extends AbstractCommonUtilityController {
/* ************************************ Static Fields ************************************ */
//private static final Logger LOG = LoggerFactory.getLogger(DeviceController.class);
/* ************************************ Instance Fields ************************************ */
@Resource
private TokenService tokenService;
/* ************************************ Public Methods ************************************ */
// @RequestMapping(value=REGISTRATION, method= GET)
// public ApiResponse pushNotificationRegistration(@RequestParam final String deviceId, @RequestParam final String token){
@RequestMapping(value=REGISTRATION, method= POST)
public ApiResponse pushNotificationRegistration(@RequestBody final TokenDto tokenDto){
tokenService.save(tokenDto);
return this.successResponse(null);
}
/**
* /api/device/app-activate.json?activationCode=xxxxx
*
*/
@RequestMapping(value=APP_ACTIVATE, method= GET)
public ApiResponse pushNotificationRegistration(@RequestParam final Long activationCode){
if(activationCode != 741313l){//432217l 374891l
return this.errorResponse(null, "msg.error.app.activate");
}
return this.successResponse(null);
}
}
| [
"[email protected]"
] | |
b2dadd048b1194938662f9d7250a527caa646bb3 | 9b8eae685cf51f2b598459d7c38ebc1e40da749f | /src/EscribirUTF.java | 253bc7cc072156460ed48406814deb303a21e525 | [] | no_license | Scarnouse/IO | 64e6c732d197824ba0163a345f841a00274ff7e1 | 66725ce3abc9d8fa45b12047b4d9ee59ff212bdb | refs/heads/master | 2016-08-12T13:14:04.853191 | 2016-03-31T08:26:31 | 2016-03-31T08:26:54 | 53,321,865 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 622 | java | import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
public class EscribirUTF {
public static void main(String[] args) {
File outFile = new File("datosSalida/utf.bin");
Random aleatorio = new Random();
try (DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));){
for(int i=0; i<100;i++){
int numero = aleatorio.nextInt(1000000);
out.writeUTF(numero+"");
}
} catch (IOException e) {
System.out.println("Error");
}
}
}
| [
"[email protected]"
] | |
497e280ceb8524736b292a660b316a49dadfc994 | 2ff163f384dfb90548586f0696ecb909ad9015a9 | /persistence/src/main/java/model/model/validators/ComputerValidator.java | 62f1db33fa1486d803fa34bad25a752be60cfbb2 | [
"Apache-2.0"
] | permissive | yegor-novinsky/computer-database | b52286e34c7a26cea75bccced17d45ba14c8b4ab | 9c95c4810ee8054d4a157927778bcced4d10cbb6 | refs/heads/master | 2021-01-13T12:28:04.032681 | 2016-12-21T19:17:05 | 2016-12-21T19:17:05 | 72,603,485 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 546 | java | package model.model.validators;
import java.util.Arrays;
import java.util.List;
/**
* @author yegor
*/
public class ComputerValidator implements EntityValidator {
private final List<String> computerTableFields = Arrays.asList("id", "name", "introduced", "discontinued", "company");
@Override
public boolean hasField(String fieldName) {
return computerTableFields.contains(fieldName);
}
@Override
public boolean hasFields(List<String> fields) {
return computerTableFields.containsAll(fields);
}
}
| [
"[email protected]"
] | |
284a30135b7306b0a7bc57eb324a4769d7710a6e | 1ed0e7930d6027aa893e1ecd4c5bba79484b7c95 | /keiji/source/java/com/tapjoy/TapjoyCacheMap.java | dddce6089f84befa9c7113e6dfd0ff8cc854848a | [] | no_license | AnKoushinist/hikaru-bottakuri-slot | 36f1821e355a76865057a81221ce2c6f873f04e5 | 7ed60c6d53086243002785538076478c82616802 | refs/heads/master | 2021-01-20T05:47:00.966573 | 2017-08-26T06:58:25 | 2017-08-26T06:58:25 | 101,468,394 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,940 | java | package com.tapjoy;
import android.content.Context;
import android.content.SharedPreferences.Editor;
import java.io.File;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.cocos2dx.lib.BuildConfig;
public class TapjoyCacheMap extends ConcurrentHashMap {
private Context a;
private int b = -1;
public TapjoyCacheMap(Context context, int i) {
this.a = context;
this.b = i;
}
private String a() {
long j = -1;
String str = BuildConfig.FLAVOR;
for (Entry entry : entrySet()) {
String str2;
long j2;
long timestampInSeconds = ((TapjoyCachedAssetData) entry.getValue()).getTimestampInSeconds();
if (j == 0 || timestampInSeconds < j) {
str2 = (String) entry.getKey();
j2 = timestampInSeconds;
} else {
str2 = str;
j2 = j;
}
j = j2;
str = str2;
}
return str;
}
public TapjoyCachedAssetData put(String str, TapjoyCachedAssetData tapjoyCachedAssetData) {
TapjoyLog.d("TapjoyCacheMap", "TapjoyCacheMap::put() -- key: " + str + " assetURL: " + tapjoyCachedAssetData.getAssetURL());
if (tapjoyCachedAssetData == null || tapjoyCachedAssetData.getTimeOfDeathInSeconds() <= System.currentTimeMillis() / 1000) {
return null;
}
if (size() == this.b) {
remove(a());
}
Editor edit = this.a.getSharedPreferences(TapjoyConstants.PREF_TAPJOY_CACHE, 0).edit();
edit.putString(tapjoyCachedAssetData.getLocalFilePath(), tapjoyCachedAssetData.toRawJSONString());
edit.commit();
return (TapjoyCachedAssetData) super.put(str, tapjoyCachedAssetData);
}
public TapjoyCachedAssetData remove(Object obj) {
if (!containsKey(obj)) {
return null;
}
Editor edit = this.a.getSharedPreferences(TapjoyConstants.PREF_TAPJOY_CACHE, 0).edit();
edit.remove(((TapjoyCachedAssetData) get(obj)).getLocalFilePath());
edit.commit();
String localFilePath = ((TapjoyCachedAssetData) get(obj)).getLocalFilePath();
if (localFilePath != null && localFilePath.length() > 0) {
TapjoyUtil.deleteFileOrDirectory(new File(localFilePath));
}
TapjoyLog.d("TapjoyCacheMap", "TapjoyCacheMap::remove() -- key: " + obj);
return (TapjoyCachedAssetData) super.remove(obj);
}
public boolean replace(String str, TapjoyCachedAssetData tapjoyCachedAssetData, TapjoyCachedAssetData tapjoyCachedAssetData2) {
throw new UnsupportedOperationException();
}
public TapjoyCachedAssetData replace(String str, TapjoyCachedAssetData tapjoyCachedAssetData) {
throw new UnsupportedOperationException();
}
public void clear() {
throw new UnsupportedOperationException();
}
}
| [
"[email protected]"
] | |
c08d50cb5ca44b91f0a0a291d820bd971d577136 | 7f7c0ee0efc37528e7a9a6c96b240515b751eee1 | /src/main/java/leetcode/Problem1652.java | 004fe99fe1a368530ff76d92cca77fbc2b83fa10 | [
"MIT"
] | permissive | fredyw/leetcode | ac7d95361cf9ada40eedd8925dc29fdf69bbb7c5 | 3dae006f4a38c25834f545e390acebf6794dc28f | refs/heads/master | 2023-09-01T21:29:23.960806 | 2023-08-30T05:45:58 | 2023-08-30T05:45:58 | 28,460,187 | 7 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,464 | java | package leetcode;
/**
* https://leetcode.com/problems/defuse-the-bomb/
*/
public class Problem1652 {
public int[] decrypt(int[] code, int k) {
int[] answer = new int[code.length];
if (k == 0) {
return answer;
}
int[] sums = new int[code.length];
for (int i = 0; i < code.length; i++) {
if (i == 0) {
sums[i] = code[i];
} else {
sums[i] = sums[i - 1] + code[i];
}
}
if (k > 0) {
for (int i = 0; i < code.length; i++) {
int start = i;
int end = (i + k) % code.length;
int val = getValue(sums, start, end);
answer[i] = val;
}
} else {
for (int i = 0; i < code.length; i++) {
int start = (i + k - 1) % code.length;
if (start < 0) {
start = code.length + start;
}
int end = (i - 1) % code.length;
if (end < 0) {
end = code.length + end;
}
int val = getValue(sums, start, end);
answer[i] = val;
}
}
return answer;
}
private static int getValue(int[] sums, int start, int end) {
return end > start ?
sums[end] - sums[start] :
sums[sums.length - 1] - sums[start] + sums[end];
}
}
| [
"[email protected]"
] | |
7c1c4f265394f0282ce914577d36b64bc9f4e95c | 039a8c1f2e3023eb24c1d65e8e28015847affee9 | /WebsiteSlideshowCodeGen.java | d9a3624db7d1ecfc88f191ae33102b7e879d213a | [] | no_license | SabrinaHerrero/acmweb | b689722c969f0e30b81eb5075369df4075cb77c9 | 5d1f12e1ccfde3557f0af1f9b8819adb1690d0f4 | refs/heads/master | 2021-01-01T04:32:11.002011 | 2017-11-02T00:17:31 | 2017-11-02T00:17:31 | 97,190,972 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,251 | java | import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class WebsiteSlideshowCodeGen {
static JFrame numFieldsFrame;
static JTextField numRes;
static int numberOfResources;
static ArrayList<JLabel> labelsArray;
static ArrayList<JTextField> textFieldsArray;
static JLabel status;
static JButton generateCodeButton;
public static void main(String[] args) {
numFieldsWindow();
}
public static void numFieldsWindow() {
numRes = new JTextField();
numFieldsFrame = new JFrame();
numFieldsFrame.setTitle("Number of Slides");
numFieldsFrame.setSize(200, 150);
numFieldsFrame.setResizable(false);
numFieldsFrame.setLocationRelativeTo(null);
numFieldsFrame.getContentPane().add(createViewNFW(numFieldsFrame));
numFieldsFrame.setDefaultCloseOperation(3);
numFieldsFrame.setVisible(true);
}
public static JPanel createViewNFW(JFrame frame) {
JPanel mainPanel = new JPanel();
JLabel label = new JLabel("Number of Slides (30 Max)");
numRes = new JTextField();
JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
submitNumber();
}
});
mainPanel.setLayout(new GridLayout(3, 1, 0, 0));
mainPanel.add(label);
mainPanel.add(numRes);
mainPanel.add(submit);
numRes.setText("");
return mainPanel;
}
public static void submitNumber() {
Scanner sc = new Scanner(numRes.getText());
if (sc.hasNextInt()) {
sc.close();
int number = Integer.parseInt(numRes.getText());
if (number > 0 && number <= 30) {
numberOfResources = number;
numFieldsFrame.setVisible(false);
resourcePathFrame();
numFieldsFrame.dispose();
}
}
else {
sc.close();
}
}
public static void resourcePathFrame() {
JFrame resPathFrame = new JFrame();
resPathFrame.setTitle("Set Resource Paths");
resPathFrame.setSize(600, (numberOfResources*2+2)*35);
resPathFrame.setLocationRelativeTo(null);
JPanel pathsMainPanel = new JPanel();
pathsMainPanel.setLayout(new GridLayout(2*numberOfResources+2, 1, 0, 0));
labelsArray = new ArrayList<JLabel>();
textFieldsArray = new ArrayList<JTextField>();
for (int index = 0; index < numberOfResources; index++) {
JLabel resPathLabel = new JLabel();
resPathLabel.setText("Slide " + (index+1) + " Path :");
labelsArray.add(resPathLabel);
pathsMainPanel.add(resPathLabel);
JTextField resPathField = new JTextField("URL or Path of Resource");
resPathField.setMinimumSize(new Dimension(30, 300));
textFieldsArray.add(resPathField);
pathsMainPanel.add(resPathField);
}
status = new JLabel("Fill in Paths and Press Generate!");
pathsMainPanel.add(status);
generateCodeButton = new JButton("Generate HTML Code and Copy to Clipboard");
generateCodeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String genCode = generateCode();
// JFrame codeFrame = new JFrame();
// codeFrame.setSize(1000, 700);
// JPanel codePanel = new JPanel();
// JTextArea codeArea = new JTextArea();
// codeArea.setText(genCode);
// codeArea.setSize(1000, 700);
// codePanel.add(codeArea);
// codeFrame.getContentPane().add(codePanel);
// codeFrame.setLocationRelativeTo(null);
// codeFrame.setVisible(true);
StringSelection stringSelection = new StringSelection(genCode);
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(stringSelection, null);
}
});
pathsMainPanel.add(generateCodeButton);
resPathFrame.getContentPane().add(pathsMainPanel);
resPathFrame.setVisible(true);
}
public static String generateCode() {
String indent = "\t\t\t";
StringBuilder result = new StringBuilder();
result.append(indent);
result.append("<div class=\"slideshow-container\">\n");
for (int index = 1; index <= numberOfResources; index++) {
result.append(indent);
result.append("\t<div class=\"mySlides fade\">\n");
result.append(indent);
result.append("\t\t<div class=\"numbertext\">" + index + " / " + numberOfResources + "</div>\n");
result.append(indent);
result.append("\t\t<img src=\"");
result.append(textFieldsArray.get(index-1).getText());
result.append("\" class=\"slideshow-images\"/>\n");
result.append(indent);
result.append("\t</div>\n");
}
result.append(indent);
result.append("\t<a class=\"prev\" onclick=\"plusSlides(-1)\">❮</a>\n");
result.append(indent);
result.append("\t<a class=\"next\" onclick=\"plusSlides(1)\">❯</a>\n");
result.append(indent);
result.append("</div>\n");
result.append(indent);
result.append("<div id=\"dots-div\" style=\"text-align:center\">\n");
for (int index = 1; index <= numberOfResources; index++) {
result.append(indent);
result.append("\t<span class=\"dot\" onclick=\"currentSlide(");
result.append(index);
result.append(")\"></span>\n");
}
result.append(indent);
result.append("</div>\n");
return result.toString();
}
}
| [
"[email protected]"
] | |
7dde3045c41ad2e35132f56bc5b8365f1de39ff6 | ac6fe0f82231b44f64451ac3e78513d9392061d8 | /biz/shared/src/main/java/com/xianglin/act/biz/shared/Impl/pop/filter/PopWindowPreFilter.java | 8c919ed10bb98342eed03e5e3571dc388223d6d2 | [] | no_license | heke183/act | 015ef0d0dd57f53afefe41d88f810a9cb0e59b8e | 2378cf1056b672a898a3c7c8fd1e540fd8ee0a42 | refs/heads/master | 2020-04-15T11:00:33.035873 | 2019-01-09T05:46:07 | 2019-01-09T05:46:07 | 164,609,667 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 997 | java | package com.xianglin.act.biz.shared.Impl.pop.filter;
import com.google.common.base.Preconditions;
import com.xianglin.act.biz.shared.annotation.PopTipPreFilter;
import com.xianglin.act.common.dal.model.PopWindow;
import java.util.Date;
import static com.xianglin.act.biz.shared.Impl.PopTipAssembleServiceImpl.RETRUN_TYPE_HOLDER;
/**
* @author Yungyu
* @description Created by Yungyu on 2018/4/12 23:48.
*/
@PopTipPreFilter
public class PopWindowPreFilter extends IPopTipPreFilter<PopWindow> {
@Override
public boolean test(PopWindow popWindow) {
Date now = new Date();
Date showStartTime = popWindow.getShowStartTime();
Date showExpireTime = popWindow.getShowExpireTime();
Preconditions.checkArgument(showStartTime != null, "活动弹窗开始时间不能为空");
Preconditions.checkArgument(showExpireTime != null, "活动弹窗结束时间不能为空");
return showExpireTime.after(now) && showStartTime.before(now);
}
}
| [
"[email protected]"
] | |
f8146d362a9596b3df7f0ef611c6b6c7a3624bc3 | 4a5f24baf286458ddde8658420faf899eb22634b | /aws-java-sdk-comprehend/src/main/java/com/amazonaws/services/comprehend/AmazonComprehendClient.java | 1d60dbb408a46958bdede8829a6bc69c663aaf96 | [
"Apache-2.0"
] | permissive | gopinathrsv/aws-sdk-java | c2876eaf019ac00714724002d91d18fadc4b4a60 | 97b63ab51f2e850d22e545154e40a33601790278 | refs/heads/master | 2021-05-14T17:18:16.335069 | 2017-12-29T19:49:30 | 2017-12-29T19:49:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 42,242 | 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.comprehend;
import org.w3c.dom.*;
import java.net.*;
import java.util.*;
import javax.annotation.Generated;
import org.apache.commons.logging.*;
import com.amazonaws.*;
import com.amazonaws.annotation.SdkInternalApi;
import com.amazonaws.auth.*;
import com.amazonaws.handlers.*;
import com.amazonaws.http.*;
import com.amazonaws.internal.*;
import com.amazonaws.internal.auth.*;
import com.amazonaws.metrics.*;
import com.amazonaws.regions.*;
import com.amazonaws.transform.*;
import com.amazonaws.util.*;
import com.amazonaws.protocol.json.*;
import com.amazonaws.util.AWSRequestMetrics.Field;
import com.amazonaws.annotation.ThreadSafe;
import com.amazonaws.client.AwsSyncClientParams;
import com.amazonaws.services.comprehend.AmazonComprehendClientBuilder;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.comprehend.model.*;
import com.amazonaws.services.comprehend.model.transform.*;
/**
* Client for accessing Amazon Comprehend. All service calls made using this client are blocking, and will not return
* until the service call completes.
* <p>
* <p>
* Amazon Comprehend is an AWS service for gaining insight into the content of documents. Use these actions to determine
* the topics contained in your documents, the topics they discuss, the predominant sentiment expressed in them, the
* predominant language used, and more.
* </p>
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonComprehendClient extends AmazonWebServiceClient implements AmazonComprehend {
/** Provider for AWS credentials. */
private final AWSCredentialsProvider awsCredentialsProvider;
private static final Log log = LogFactory.getLog(AmazonComprehend.class);
/** Default signing name for the service. */
private static final String DEFAULT_SIGNING_NAME = "comprehend";
/** Client configuration factory providing ClientConfigurations tailored to this client */
protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
private static final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory = new com.amazonaws.protocol.json.SdkJsonProtocolFactory(
new JsonClientMetadata()
.withProtocolVersion("1.1")
.withSupportsCbor(false)
.withSupportsIon(false)
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InvalidFilterException").withModeledClass(
com.amazonaws.services.comprehend.model.InvalidFilterException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("BatchSizeLimitExceededException").withModeledClass(
com.amazonaws.services.comprehend.model.BatchSizeLimitExceededException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("JobNotFoundException").withModeledClass(
com.amazonaws.services.comprehend.model.JobNotFoundException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InvalidRequestException").withModeledClass(
com.amazonaws.services.comprehend.model.InvalidRequestException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("TextSizeLimitExceededException").withModeledClass(
com.amazonaws.services.comprehend.model.TextSizeLimitExceededException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("UnsupportedLanguageException").withModeledClass(
com.amazonaws.services.comprehend.model.UnsupportedLanguageException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InternalServerException").withModeledClass(
com.amazonaws.services.comprehend.model.InternalServerException.class))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("TooManyRequestsException").withModeledClass(
com.amazonaws.services.comprehend.model.TooManyRequestsException.class))
.withBaseServiceExceptionClass(com.amazonaws.services.comprehend.model.AmazonComprehendException.class));
public static AmazonComprehendClientBuilder builder() {
return AmazonComprehendClientBuilder.standard();
}
/**
* Constructs a new client to invoke service methods on Amazon Comprehend using the specified parameters.
*
* <p>
* All service calls made using this new client object are blocking, and will not return until the service call
* completes.
*
* @param clientParams
* Object providing client parameters.
*/
AmazonComprehendClient(AwsSyncClientParams clientParams) {
super(clientParams);
this.awsCredentialsProvider = clientParams.getCredentialsProvider();
init();
}
private void init() {
setServiceNameIntern(DEFAULT_SIGNING_NAME);
setEndpointPrefix(ENDPOINT_PREFIX);
// calling this.setEndPoint(...) will also modify the signer accordingly
setEndpoint("comprehend.us-east-1.amazonaws.com");
HandlerChainFactory chainFactory = new HandlerChainFactory();
requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/comprehend/request.handlers"));
requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/comprehend/request.handler2s"));
requestHandler2s.addAll(chainFactory.getGlobalHandlers());
}
/**
* <p>
* Determines the dominant language of the input text for a batch of documents. For a list of languages that Amazon
* Comprehend can detect, see <a href="http://docs.aws.amazon.com/comprehend/latest/dg/how-languages.html">Amazon
* Comprehend Supported Languages</a>.
* </p>
*
* @param batchDetectDominantLanguageRequest
* @return Result of the BatchDetectDominantLanguage operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws BatchSizeLimitExceededException
* The number of documents in the request exceeds the limit of 25. Try your request again with fewer
* documents.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.BatchDetectDominantLanguage
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/BatchDetectDominantLanguage"
* target="_top">AWS API Documentation</a>
*/
@Override
public BatchDetectDominantLanguageResult batchDetectDominantLanguage(BatchDetectDominantLanguageRequest request) {
request = beforeClientExecution(request);
return executeBatchDetectDominantLanguage(request);
}
@SdkInternalApi
final BatchDetectDominantLanguageResult executeBatchDetectDominantLanguage(BatchDetectDominantLanguageRequest batchDetectDominantLanguageRequest) {
ExecutionContext executionContext = createExecutionContext(batchDetectDominantLanguageRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<BatchDetectDominantLanguageRequest> request = null;
Response<BatchDetectDominantLanguageResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new BatchDetectDominantLanguageRequestProtocolMarshaller(protocolFactory).marshall(super
.beforeMarshalling(batchDetectDominantLanguageRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<BatchDetectDominantLanguageResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new BatchDetectDominantLanguageResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Inspects the text of a batch of documents and returns information about them. For more information about
* entities, see <a>how-entities</a>
* </p>
*
* @param batchDetectEntitiesRequest
* @return Result of the BatchDetectEntities operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws BatchSizeLimitExceededException
* The number of documents in the request exceeds the limit of 25. Try your request again with fewer
* documents.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.BatchDetectEntities
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/BatchDetectEntities" target="_top">AWS
* API Documentation</a>
*/
@Override
public BatchDetectEntitiesResult batchDetectEntities(BatchDetectEntitiesRequest request) {
request = beforeClientExecution(request);
return executeBatchDetectEntities(request);
}
@SdkInternalApi
final BatchDetectEntitiesResult executeBatchDetectEntities(BatchDetectEntitiesRequest batchDetectEntitiesRequest) {
ExecutionContext executionContext = createExecutionContext(batchDetectEntitiesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<BatchDetectEntitiesRequest> request = null;
Response<BatchDetectEntitiesResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new BatchDetectEntitiesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(batchDetectEntitiesRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<BatchDetectEntitiesResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new BatchDetectEntitiesResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Detects the key noun phrases found in a batch of documents.
* </p>
*
* @param batchDetectKeyPhrasesRequest
* @return Result of the BatchDetectKeyPhrases operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws BatchSizeLimitExceededException
* The number of documents in the request exceeds the limit of 25. Try your request again with fewer
* documents.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.BatchDetectKeyPhrases
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/BatchDetectKeyPhrases"
* target="_top">AWS API Documentation</a>
*/
@Override
public BatchDetectKeyPhrasesResult batchDetectKeyPhrases(BatchDetectKeyPhrasesRequest request) {
request = beforeClientExecution(request);
return executeBatchDetectKeyPhrases(request);
}
@SdkInternalApi
final BatchDetectKeyPhrasesResult executeBatchDetectKeyPhrases(BatchDetectKeyPhrasesRequest batchDetectKeyPhrasesRequest) {
ExecutionContext executionContext = createExecutionContext(batchDetectKeyPhrasesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<BatchDetectKeyPhrasesRequest> request = null;
Response<BatchDetectKeyPhrasesResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new BatchDetectKeyPhrasesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(batchDetectKeyPhrasesRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<BatchDetectKeyPhrasesResult>> responseHandler = protocolFactory
.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new BatchDetectKeyPhrasesResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Inspects a batch of documents and returns an inference of the prevailing sentiment, <code>POSITIVE</code>,
* <code>NEUTRAL</code>, <code>MIXED</code>, or <code>NEGATIVE</code>, in each one.
* </p>
*
* @param batchDetectSentimentRequest
* @return Result of the BatchDetectSentiment operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws BatchSizeLimitExceededException
* The number of documents in the request exceeds the limit of 25. Try your request again with fewer
* documents.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.BatchDetectSentiment
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/BatchDetectSentiment"
* target="_top">AWS API Documentation</a>
*/
@Override
public BatchDetectSentimentResult batchDetectSentiment(BatchDetectSentimentRequest request) {
request = beforeClientExecution(request);
return executeBatchDetectSentiment(request);
}
@SdkInternalApi
final BatchDetectSentimentResult executeBatchDetectSentiment(BatchDetectSentimentRequest batchDetectSentimentRequest) {
ExecutionContext executionContext = createExecutionContext(batchDetectSentimentRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<BatchDetectSentimentRequest> request = null;
Response<BatchDetectSentimentResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new BatchDetectSentimentRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(batchDetectSentimentRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<BatchDetectSentimentResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new BatchDetectSentimentResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Gets the properties associated with a topic detection job. Use this operation to get the status of a detection
* job.
* </p>
*
* @param describeTopicsDetectionJobRequest
* @return Result of the DescribeTopicsDetectionJob operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws JobNotFoundException
* The specified job was not found. Check the job ID and try again.
* @throws TooManyRequestsException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.DescribeTopicsDetectionJob
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DescribeTopicsDetectionJob"
* target="_top">AWS API Documentation</a>
*/
@Override
public DescribeTopicsDetectionJobResult describeTopicsDetectionJob(DescribeTopicsDetectionJobRequest request) {
request = beforeClientExecution(request);
return executeDescribeTopicsDetectionJob(request);
}
@SdkInternalApi
final DescribeTopicsDetectionJobResult executeDescribeTopicsDetectionJob(DescribeTopicsDetectionJobRequest describeTopicsDetectionJobRequest) {
ExecutionContext executionContext = createExecutionContext(describeTopicsDetectionJobRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<DescribeTopicsDetectionJobRequest> request = null;
Response<DescribeTopicsDetectionJobResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DescribeTopicsDetectionJobRequestProtocolMarshaller(protocolFactory).marshall(super
.beforeMarshalling(describeTopicsDetectionJobRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<DescribeTopicsDetectionJobResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new DescribeTopicsDetectionJobResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Determines the dominant language of the input text. For a list of languages that Amazon Comprehend can detect,
* see <a href="http://docs.aws.amazon.com/comprehend/latest/dg/how-languages.html">Amazon Comprehend Supported
* Languages</a>.
* </p>
*
* @param detectDominantLanguageRequest
* @return Result of the DetectDominantLanguage operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.DetectDominantLanguage
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DetectDominantLanguage"
* target="_top">AWS API Documentation</a>
*/
@Override
public DetectDominantLanguageResult detectDominantLanguage(DetectDominantLanguageRequest request) {
request = beforeClientExecution(request);
return executeDetectDominantLanguage(request);
}
@SdkInternalApi
final DetectDominantLanguageResult executeDetectDominantLanguage(DetectDominantLanguageRequest detectDominantLanguageRequest) {
ExecutionContext executionContext = createExecutionContext(detectDominantLanguageRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<DetectDominantLanguageRequest> request = null;
Response<DetectDominantLanguageResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DetectDominantLanguageRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(detectDominantLanguageRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<DetectDominantLanguageResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new DetectDominantLanguageResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Inspects text for entities, and returns information about them. For more information, about entities, see
* <a>how-entities</a>.
* </p>
*
* @param detectEntitiesRequest
* @return Result of the DetectEntities operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.DetectEntities
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DetectEntities" target="_top">AWS API
* Documentation</a>
*/
@Override
public DetectEntitiesResult detectEntities(DetectEntitiesRequest request) {
request = beforeClientExecution(request);
return executeDetectEntities(request);
}
@SdkInternalApi
final DetectEntitiesResult executeDetectEntities(DetectEntitiesRequest detectEntitiesRequest) {
ExecutionContext executionContext = createExecutionContext(detectEntitiesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<DetectEntitiesRequest> request = null;
Response<DetectEntitiesResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DetectEntitiesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(detectEntitiesRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<DetectEntitiesResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DetectEntitiesResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Detects the key noun phrases found in the text.
* </p>
*
* @param detectKeyPhrasesRequest
* @return Result of the DetectKeyPhrases operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.DetectKeyPhrases
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DetectKeyPhrases" target="_top">AWS
* API Documentation</a>
*/
@Override
public DetectKeyPhrasesResult detectKeyPhrases(DetectKeyPhrasesRequest request) {
request = beforeClientExecution(request);
return executeDetectKeyPhrases(request);
}
@SdkInternalApi
final DetectKeyPhrasesResult executeDetectKeyPhrases(DetectKeyPhrasesRequest detectKeyPhrasesRequest) {
ExecutionContext executionContext = createExecutionContext(detectKeyPhrasesRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<DetectKeyPhrasesRequest> request = null;
Response<DetectKeyPhrasesResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DetectKeyPhrasesRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(detectKeyPhrasesRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<DetectKeyPhrasesResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DetectKeyPhrasesResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Inspects text and returns an inference of the prevailing sentiment (<code>POSITIVE</code>, <code>NEUTRAL</code>,
* <code>MIXED</code>, or <code>NEGATIVE</code>).
* </p>
*
* @param detectSentimentRequest
* @return Result of the DetectSentiment operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TextSizeLimitExceededException
* The size of the input text exceeds the limit. Use a smaller document.
* @throws UnsupportedLanguageException
* Amazon Comprehend can't process the language of the input text. For all APIs except
* <code>DetectDominantLanguage</code>, Amazon Comprehend accepts only English or Spanish text. For the
* <code>DetectDominantLanguage</code> API, Amazon Comprehend detects 100 languages. For a list of
* languages, see <a>how-languages</a>
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.DetectSentiment
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/DetectSentiment" target="_top">AWS API
* Documentation</a>
*/
@Override
public DetectSentimentResult detectSentiment(DetectSentimentRequest request) {
request = beforeClientExecution(request);
return executeDetectSentiment(request);
}
@SdkInternalApi
final DetectSentimentResult executeDetectSentiment(DetectSentimentRequest detectSentimentRequest) {
ExecutionContext executionContext = createExecutionContext(detectSentimentRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<DetectSentimentRequest> request = null;
Response<DetectSentimentResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new DetectSentimentRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(detectSentimentRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<DetectSentimentResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new DetectSentimentResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Gets a list of the topic detection jobs that you have submitted.
* </p>
*
* @param listTopicsDetectionJobsRequest
* @return Result of the ListTopicsDetectionJobs operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TooManyRequestsException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws InvalidFilterException
* The filter specified for the <code>ListTopicDetectionJobs</code> operation is invalid. Specify a
* different filter.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.ListTopicsDetectionJobs
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/ListTopicsDetectionJobs"
* target="_top">AWS API Documentation</a>
*/
@Override
public ListTopicsDetectionJobsResult listTopicsDetectionJobs(ListTopicsDetectionJobsRequest request) {
request = beforeClientExecution(request);
return executeListTopicsDetectionJobs(request);
}
@SdkInternalApi
final ListTopicsDetectionJobsResult executeListTopicsDetectionJobs(ListTopicsDetectionJobsRequest listTopicsDetectionJobsRequest) {
ExecutionContext executionContext = createExecutionContext(listTopicsDetectionJobsRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<ListTopicsDetectionJobsRequest> request = null;
Response<ListTopicsDetectionJobsResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListTopicsDetectionJobsRequestProtocolMarshaller(protocolFactory).marshall(super
.beforeMarshalling(listTopicsDetectionJobsRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<ListTopicsDetectionJobsResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new ListTopicsDetectionJobsResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* <p>
* Starts an asynchronous topic detection job. Use the <code>DescribeTopicDetectionJob</code> operation to track the
* status of a job.
* </p>
*
* @param startTopicsDetectionJobRequest
* @return Result of the StartTopicsDetectionJob operation returned by the service.
* @throws InvalidRequestException
* The request is invalid.
* @throws TooManyRequestsException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @sample AmazonComprehend.StartTopicsDetectionJob
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/StartTopicsDetectionJob"
* target="_top">AWS API Documentation</a>
*/
@Override
public StartTopicsDetectionJobResult startTopicsDetectionJob(StartTopicsDetectionJobRequest request) {
request = beforeClientExecution(request);
return executeStartTopicsDetectionJob(request);
}
@SdkInternalApi
final StartTopicsDetectionJobResult executeStartTopicsDetectionJob(StartTopicsDetectionJobRequest startTopicsDetectionJobRequest) {
ExecutionContext executionContext = createExecutionContext(startTopicsDetectionJobRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request<StartTopicsDetectionJobRequest> request = null;
Response<StartTopicsDetectionJobResult> response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new StartTopicsDetectionJobRequestProtocolMarshaller(protocolFactory).marshall(super
.beforeMarshalling(startTopicsDetectionJobRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler<AmazonWebServiceResponse<StartTopicsDetectionJobResult>> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
new StartTopicsDetectionJobResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* Returns additional metadata for a previously executed successful, request, typically used for debugging issues
* where a service isn't acting as expected. This data isn't considered part of the result data returned by an
* operation, so it's available through this separate, diagnostic interface.
* <p>
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
/**
* Normal invoke with authentication. Credentials are required and may be overriden at the request level.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext) {
executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
return doInvoke(request, responseHandler, executionContext);
}
/**
* Invoke with no authentication. Credentials are not required and any credentials set on the client or request will
* be ignored for this operation.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> anonymousInvoke(Request<Y> request,
HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) {
return doInvoke(request, responseHandler, executionContext);
}
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
ExecutionContext executionContext) {
request.setEndpoint(endpoint);
request.setTimeOffset(timeOffset);
HttpResponseHandler<AmazonServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
@com.amazonaws.annotation.SdkInternalApi
static com.amazonaws.protocol.json.SdkJsonProtocolFactory getProtocolFactory() {
return protocolFactory;
}
}
| [
""
] | |
4029b7f3ac43a7e64fea41a77d351722ec7f3360 | 5f0edc4c3ee63808b94f59f683b1ef97fe8c3f61 | /83.RemoveDuplicatesfromSortedList.java | cf7fbe8662e0595018862479782c194c79ce2a74 | [] | no_license | guangxush/LeetCode | 8f3795949d7b8592bf532f091430db9df7dc2643 | bbea5d8a877afbc6dd32090d2c1aa55e7fd44f2b | refs/heads/master | 2021-06-08T08:56:23.520933 | 2019-10-14T07:01:00 | 2019-10-14T07:01:00 | 104,307,242 | 0 | 2 | null | 2022-08-15T08:19:44 | 2017-09-21T05:53:09 | Java | UTF-8 | Java | false | false | 1,007 | java | package cn.shgx.easy;
/**
* Given a sorted linked list, delete all duplicates such that each element
* appear only once.
* For example,
* Given 1->1->2, return 1->2.
* Given 1->1->2->3->3, return 1->2->3.
*/
//class ListNode{//其他文件中已经定义
// int val;
// ListNode next;
// ListNode(int x){val = x;}
//}
public class RemoveDuplicatesfromSortedList {
public static ListNode deleteDuplicates(ListNode head) {
if(head==null||head.next==null)
return head;
ListNode temp =head;
while(temp.next!=null) {
if(temp.next.val==temp.val) {
temp.next=temp.next.next;
}else{
temp=temp.next;
}
}
return head;
}
public static void main(String[] args) {
ListNode listNode = new ListNode(1);
listNode.next = new ListNode(1);
listNode.next.next = new ListNode(2);
ListNode result = deleteDuplicates(listNode);
System.out.println(result.val);
System.out.println(result.next.val);
}
}
| [
"[email protected]"
] | |
80d3bee8cc88d4b8665abc2cbbaa9d7b59a6a917 | 80b415640deb6f6770e38f247060f8b44ca7e391 | /platform-common/platform-common-core/src/main/java/com/alin/common/core/util/JSONResultUtil.java | 3f9d9181bccd445ab8f6e56a7616d53ecd3a1aff | [] | no_license | singledemon/cloud | 4c681d5268200ee9f30ca37a21517ad535599a1a | 130633321a3e8f32ca07a4739d53d60d3c3973c9 | refs/heads/master | 2022-12-02T06:30:04.951530 | 2020-08-21T06:16:42 | 2020-08-21T06:16:42 | 289,145,250 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,528 | java | package com.alin.common.core.util;
import com.alin.common.core.constant.ExceptionCodeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class JSONResultUtil {
public static final String KEY_CODE = "code";
public static final String KEY_MESSAGE = "msg";
public static final String KEY_DATA = "data";
public static String fillResultString(ExceptionCodeEnum codeEnum) {
return fillResultString(codeEnum.getCode(),codeEnum.getMessage());
}
private static String fillResultString(Integer code, String message) {
return fillResultString(code,message,null);
}
private static String fillResultString(Integer code, String message, Object o) {
Map<String,Object> map = new HashMap<String,Object>();
map.put(KEY_CODE,code);
map.put(KEY_MESSAGE,message);
map.put(KEY_DATA, JSON.toJSONString(o));
return JSONObject.toJSONString(map);
}
public static String fillSuccessResultString(ExceptionCodeEnum codeEnum){
return fileSuccessResultString(codeEnum.getCode(),codeEnum.getMessage());
}
private static String fileSuccessResultString(Integer code, String message) {
return fileSuccessResultString(code,message,null);
}
private static String fileSuccessResultString(Integer code, String message, Object o) {
Map<String,Object> map = new HashMap<String,Object>();
map.put(KEY_CODE, ExceptionCodeEnum.SUCCESS.getCode());
map.put(KEY_MESSAGE, message);
map.put(KEY_DATA, JSON.toJSONString(o));
return JSONObject.toJSONString(map);
}
public static Map<String, Object> fillResult(ExceptionCodeEnum codeEnum) {
return fillResult(codeEnum.getCode(), codeEnum.getMessage());
}
public static Map<String, Object> fillResult(Integer code, String message) {
return fillResult(code, message, null);
}
public static Map<String, Object> fillResult(Integer code, String message, Object data) {
Map<String, Object> map = new HashMap<String,Object>();
map.put(KEY_CODE, code);
map.put(KEY_MESSAGE, message);
map.put(KEY_DATA, JSON.toJSONString(data));
return map;
}
public static Map<String, Object> fillSuccessResult(String message) {
return fillSuccessResult(message, null);
}
public static Map<String, Object> fillSuccessResult(String message, Object o) {
Map<String, Object> map = new HashMap<String,Object>();
map.put(KEY_CODE, ExceptionCodeEnum.SUCCESS.getCode());
map.put(KEY_MESSAGE, message);
map.put(KEY_DATA, JSON.toJSONString(o, SerializerFeature.WRITE_MAP_NULL_FEATURES,SerializerFeature.QuoteFieldNames));
return map;
}
public static Map<String, Object> fillSuccessFormatResult(String message, Object data) {
Map<String, Object> map = new HashMap<String,Object>();
map.put(KEY_CODE, ExceptionCodeEnum.SUCCESS.getCode());
map.put(KEY_MESSAGE, message);
map.put(KEY_DATA, data);
return map;
}
public static String fillErrorResultString(String message) {
Map<String, Object> map = new HashMap<String,Object>();
map.put(KEY_CODE, ExceptionCodeEnum.SERVER_ERROR.getCode());
map.put(KEY_MESSAGE, message);
map.put(KEY_DATA, null);
return JSONObject.toJSONString(map);
}
}
| [
"maqinglin3610"
] | maqinglin3610 |
0bb6c0f62019ae298fd507dfb73c6512191ff043 | 44c91c44a179890a45bd3e03b75172a1d8fba71e | /CassTest/src/main/java/com/examples/dbexample/casstest/Routes.java | 5a8e85aa826980a437eea1749dca5af16c52a0d0 | [] | no_license | hmdesai89/internal_pract | 370f5700b742969a1850ec98834f046d32573ba6 | ff8ee2e9febb47dd36231741ead3f70726ce7a81 | refs/heads/master | 2021-01-20T23:44:21.692998 | 2017-08-30T06:55:29 | 2017-08-30T06:55:29 | 101,848,192 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,210 | java | package com.examples.dbexample.casstest;
import io.netty.handler.codec.http.HttpMethod;
import org.restexpress.RestExpress;
public abstract class Routes
{
public static void define(Configuration config, RestExpress server)
{
// TODO: Your routes here...
server.uri("/samples/uuid/{uuid}.{format}", config.getSampleUuidEntityController())
.method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE)
.name(Constants.Routes.SINGLE_UUID_SAMPLE);
server.uri("/samples/uuid.{format}", config.getSampleUuidEntityController())
.method(HttpMethod.POST)
.name(Constants.Routes.SAMPLE_UUID_COLLECTION);
server.uri("/samples/compound/{key1}/{key2}/{key3}.{format}", config.getSampleCompoundIdentifierEntityController())
.method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE)
.name(Constants.Routes.SINGLE_COMPOUND_SAMPLE);
server.uri("/samples/compound/{key1}/{key2}.{format}", config.getSampleCompoundIdentifierEntityController())
.action("readAll", HttpMethod.GET)
.method(HttpMethod.POST)
.name(Constants.Routes.SAMPLE_COMPOUND_COLLECTION);
// or REGEX matching routes...
// server.regex("/some.regex", config.getRouteController());
}
}
| [
"[email protected]"
] | |
eb9944028e025aa8975ac9b3728bf40bee476b59 | dbb8f8642ca95a2e513c9afae27c7ee18b3ab7d8 | /anchor-bean/src/main/java/org/anchoranalysis/bean/permute/property/PermutePropertySequenceDouble.java | 34a71e43c17d644b99373ed95b38bb51076b6c77 | [
"Apache-2.0",
"MIT"
] | permissive | anchoranalysis/anchor | 19c2a40954515e93da83ddfc99b0ff4a95dc2199 | b3b589e0d76f51b90589893cfc8dfbb5d7753bc9 | refs/heads/master | 2023-07-19T17:38:19.940164 | 2023-07-18T08:33:10 | 2023-07-18T08:33:10 | 240,029,306 | 3 | 0 | MIT | 2023-07-18T08:33:11 | 2020-02-12T14:12:28 | Java | UTF-8 | Java | false | false | 2,736 | java | /*-
* #%L
* anchor-bean
* %%
* Copyright (C) 2010 - 2020 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
package org.anchoranalysis.bean.permute.property;
import java.util.Iterator;
import lombok.Getter;
import lombok.Setter;
import org.anchoranalysis.bean.annotation.BeanField;
/**
* Assigns an arithmetic sequence of doubles, derived by diving an integer sequence by a divider.
*
* <p>Each element to be assigned corresponds to the respective element in the integer-sequence, but
* divided by {@code divisor}.
*
* @author Owen Feehan
*/
public class PermutePropertySequenceDouble extends PermutePropertySequence<Double> {
// START BEAN PROPERTIES
/** What to divide the integer-sequence by. */
@BeanField @Getter @Setter private double divisor = 1.0;
// END BEAN PROPERTIES
@Override
public Iterator<Double> propertyValues() {
return new DoubleRange(sequenceIterator());
}
@Override
public String describePropertyValue(Double value) {
return value.toString();
}
/** The range of {@link Double} values that can be assigned. */
class DoubleRange implements Iterator<Double> {
private Iterator<Integer> itr;
public DoubleRange(Iterator<Integer> integerSequence) {
itr = integerSequence;
}
@Override
public boolean hasNext() {
return itr.hasNext();
}
@Override
public Double next() {
return itr.next() / divisor;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
}
| [
"[email protected]"
] | |
37831040100fe2be58bf2a0e1c4f52ff994e8ab6 | 3d0aaa0e2a7da9ec3b0c4e01c7a831825e75fb3c | /src/main/java/br/com/petz/handler/model/FormErro.java | eeb6c88e76649f97857425b8c8375cde68a72dec | [] | no_license | jsteniors/teste-petz | 985801bd1ec88ffd8c1e75c8ef2507951a17a688 | 06fab16c6e28eed6c46e45b2d628585efb269988 | refs/heads/master | 2023-01-03T01:12:02.034625 | 2020-10-30T20:20:57 | 2020-10-30T20:20:57 | 308,727,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 952 | java | package br.com.petz.handler.model;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.FieldError;
public class FormErro {
private String field;
private String message;
public FormErro(FieldError fieldError, MessageSource messageSource) {
this.field = fieldError.getField();
this.message = messageSource.getMessage(fieldError, LocaleContextHolder.getLocale());
}
public static List<FormErro> convert(List<FieldError> fieldErrors, MessageSource messageSource) {
return fieldErrors.stream().map(e -> new FormErro(e, messageSource)).collect(Collectors.toList());
}
public String getField() {
return field;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return "FormErro [field=" + field + ", message=" + message + "]";
}
}
| [
"[email protected]"
] | |
afae6b77b4dfe44bf920551956b74de015e1cb12 | 7aeb5718068ad7eddbb8a9a981ea9acd5347c4ca | /traveling/src/main/java/nl/noordland19/duong/manager/TravelManager.java | 6f5b55653e1320c2be3b3bc428ad812e8bbbaa96 | [] | no_license | Carlavn84/Traveling | db0dda1d24c9c02941fe7d8b678e55b5ccd9fcaf | 6dd95ad02698b1da0f7d933ed13bbba14c6fe417 | refs/heads/master | 2022-11-27T22:34:30.972231 | 2020-08-05T16:04:18 | 2020-08-05T16:04:18 | 281,728,832 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,117 | java | package nl.noordland19.duong.manager;
import nl.noordland19.duong.model.Country;
import nl.noordland19.duong.repositories.CountryRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TravelManager {
private final CountryRepository countryRepository;
private Logger logger = LoggerFactory.getLogger(TravelManager.class);
@Autowired
public TravelManager(CountryRepository countryRepository) {
this.countryRepository = countryRepository;
logger.debug("Travel Manager Class created");
}
public List<Country> getAllCountries() {
return countryRepository.findAll();
}
public Country getCountryById(final Long id) {
return countryRepository.findById(id).get();
}
public Country saveCountry(Country country) {
return countryRepository.save(country);
}
public void deleteCountryById(final Long id) {
countryRepository.deleteById(id);
}
}
| [
"[email protected]"
] | |
cbaadd50cebd9891d10679209f1ed895df2212e1 | 04d83501ed2b1c49b97d7d2baa29ae47f927369d | /wiki/tags/release-0.7.2/jamwiki-core/src/main/java/org/jamwiki/model/WikiFileVersion.java | 21baca3f72ac0ed4e58b3ced9bbaa62f6df2404c | [] | no_license | Eljah/jamwiki | a207fac211a5d7977d175d26352771f51a4d2560 | 466275bd61bde092e1d0bb9d3c2491fb3b6968a3 | refs/heads/master | 2021-01-10T17:13:14.829006 | 2013-03-20T05:41:42 | 2013-03-20T05:41:42 | 46,241,623 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,511 | java | /**
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the latest version of the GNU Lesser General
* Public License as published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program (LICENSE.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.jamwiki.model;
import java.sql.Timestamp;
import org.apache.commons.lang.StringUtils;
import org.jamwiki.utils.WikiLogger;
/**
* Provides an object representing a version of a file uploaded to the Wiki.
*/
public class WikiFileVersion {
private Integer authorId = null;
private String authorIpAddress = null;
private int fileId = -1;
private long fileSize = -1;
private int fileVersionId = -1;
private String mimeType = WikiFile.UNKNOWN_MIME_TYPE;
private String uploadComment = null;
private Timestamp uploadDate = new Timestamp(System.currentTimeMillis());
private String url = null;
private static final WikiLogger logger = WikiLogger.getLogger(WikiFileVersion.class.getName());
/**
*
*/
public WikiFileVersion() {
}
/**
*
*/
public Integer getAuthorId() {
return this.authorId;
}
/**
*
*/
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
/**
*
*/
public String getAuthorIpAddress() {
return this.authorIpAddress;
}
/**
*
*/
public void setAuthorIpAddress(String authorIpAddress) {
this.authorIpAddress = authorIpAddress;
}
/**
*
*/
public int getFileId() {
return this.fileId;
}
/**
*
*/
public void setFileId(int fileId) {
this.fileId = fileId;
}
/**
*
*/
public long getFileSize() {
return this.fileSize;
}
/**
*
*/
public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}
/**
*
*/
public int getFileVersionId() {
return this.fileVersionId;
}
/**
*
*/
public void setFileVersionId(int fileVersionId) {
this.fileVersionId = fileVersionId;
}
/**
* This method will either return the MIME type set for the file, or a default
* MIME type indicating that the MIME type is unknown. This method will never
* return <code>null</code>.
*/
public String getMimeType() {
return (StringUtils.isBlank(this.mimeType)) ? WikiFile.UNKNOWN_MIME_TYPE : this.mimeType;
}
/**
*
*/
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
/**
*
*/
public String getUploadComment() {
return this.uploadComment;
}
/**
*
*/
public void setUploadComment(String uploadComment) {
this.uploadComment = uploadComment;
}
/**
*
*/
public Timestamp getUploadDate() {
return this.uploadDate;
}
/**
*
*/
public void setUploadDate(Timestamp uploadDate) {
this.uploadDate = uploadDate;
}
/**
*
*/
public String getUrl() {
return this.url;
}
/**
*
*/
public void setUrl(String url) {
this.url = url;
}
} | [
"wrh2@f65b7e76-0091-dd46-87ae-4bc0c949c03e"
] | wrh2@f65b7e76-0091-dd46-87ae-4bc0c949c03e |
4af2bda875d0a9d130178187c662ccb8ddde213c | 438a6d4655abb36234c4505d31b98dc39d7c5857 | /app/src/main/java/com/example/myapplication/util/MiscUtil.java | 24644427c9944b230a9d905151355e3730db5a12 | [] | no_license | tawny1/test | 666d820b58d53c575af46b09175f5d4b01020838 | 9bec6032cef388cf4ea7d34a6f37e14678894a8f | refs/heads/master | 2023-03-18T04:25:57.419116 | 2022-08-29T03:36:24 | 2022-08-29T03:36:24 | 204,408,673 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,969 | java | package com.example.myapplication.util;
import android.content.Context;
import android.graphics.Paint;
import android.view.View;
public class MiscUtil {
/**
* 测量 View
*
* @param measureSpec
* @param defaultSize View 的默认大小
* @return
*/
public static int measure(int measureSpec, int defaultSize) {
int result = defaultSize;
int specMode = View.MeasureSpec.getMode(measureSpec);
int specSize = View.MeasureSpec.getSize(measureSpec);
if (specMode == View.MeasureSpec.EXACTLY) {
result = specSize;
} else if (specMode == View.MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
}
return result;
}
/**
* dip 转换成px
*
* @param dip
* @return
*/
public static int dipToPx(Context context, float dip) {
float density = context.getResources().getDisplayMetrics().density;
return (int) (dip * density + 0.5f * (dip >= 0 ? 1 : -1));
}
/**
* 获取数值精度格式化字符串
*
* @param precision
* @return
*/
public static String getPrecisionFormat(int precision) {
return "%." + precision + "f";
}
/**
* 反转数组
*
* @param arrays
* @param <T>
* @return
*/
public static <T> T[] reverse(T[] arrays) {
if (arrays == null) {
return null;
}
int length = arrays.length;
for (int i = 0; i < length / 2; i++) {
T t = arrays[i];
arrays[i] = arrays[length - i - 1];
arrays[length - i - 1] = t;
}
return arrays;
}
/**
* 测量文字高度
* @param paint
* @return
*/
public static float measureTextHeight(Paint paint) {
Paint.FontMetrics fontMetrics = paint.getFontMetrics();
return (Math.abs(fontMetrics.ascent) - fontMetrics.descent);
}
}
| [
"[email protected]"
] | |
705b4e4bce3b195002af7a550be980d4be49d148 | 93bdc4230cd34a06e90c3b080152529d7d2c9667 | /app/src/main/java/com/example/loric/aacharya/FeeDetails.java | 81e8e13f6f9038a9116161abf1969156780da370 | [] | no_license | srikantloric/Aacharya | 31f617020bd5802dfc612a71971c9ec09d8dfe33 | 65f88692f127e71cc00d7055fee557be44824f77 | refs/heads/master | 2023-02-11T09:47:07.591652 | 2020-11-26T09:06:25 | 2020-11-26T09:06:25 | 306,873,674 | 0 | 0 | null | 2021-01-01T12:19:42 | 2020-10-24T11:58:36 | Java | UTF-8 | Java | false | false | 5,694 | java | package com.example.loric.aacharya;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.loric.aacharya.Adapters.FeeDetailAdapter;
import com.example.loric.aacharya.Models.FeeDetailModel;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class FeeDetails extends AppCompatActivity {
private RecyclerView recyclerView;
private FeeDetailAdapter adapter;
private List<FeeDetailModel> feeDetailModelList = new ArrayList<>();
private FirebaseFirestore firebaseFirestore;
private FirebaseAuth firebaseAuth;
private TextView courseDetail, courseFeeDetail, feePaidTotal, feeDueTotal;
private ImageView backBtn;
private Dialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fee_details);
firebaseFirestore = FirebaseFirestore.getInstance();
firebaseAuth = FirebaseAuth.getInstance();
dialog = new Dialog(this);
dialog.setContentView(R.layout.loading_dialog_layout);
dialog.setCancelable(false);
dialog.show();
recyclerView = findViewById(R.id.rv_fee_detail);
courseFeeDetail = findViewById(R.id.course_fee_detail_tv);
courseDetail = findViewById(R.id.course_detail_tv);
feeDueTotal = findViewById(R.id.fee_due_total);
backBtn = findViewById(R.id.back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
feePaidTotal = findViewById(R.id.feePaidTotal);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
adapter = new FeeDetailAdapter(feeDetailModelList);
recyclerView.setAdapter(adapter);
loadServerData();
}
private void loadServerData() {
firebaseFirestore.collection("USERS").document(firebaseAuth.getCurrentUser().getUid())
.get()
.addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
Long courseFee = task.getResult().getLong("userCourseFee");
String userCourseDetail = task.getResult().getString("userCourseDetail");
courseDetail.setText(userCourseDetail);
courseFeeDetail.setText("Rs." + courseFee);
firebaseFirestore.collection("USERS").document(firebaseAuth.getCurrentUser().getUid())
.collection("PAYMENT_HISTORY")
.orderBy("payment_date", Query.Direction.DESCENDING)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
long feePaid = 0;
for (QueryDocumentSnapshot snapshot : task.getResult()) {
Long payAmount = snapshot.getLong("paid_amount");
Date date = snapshot.getDate("payment_date");
feePaid = feePaid + payAmount;
long dueAmount = (courseFee - payAmount);
feeDetailModelList.add(new FeeDetailModel("Rs. " + payAmount, "Rs. " + dueAmount, date));
}
feeDueTotal.setText("Rs. " + (courseFee - feePaid));
feePaidTotal.setText("Rs. " + feePaid);
adapter.notifyDataSetChanged();
} else {
Toast.makeText(FeeDetails.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
dialog.dismiss();
}
});
} else {
dialog.dismiss();
Toast.makeText(FeeDetails.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
} | [
"[email protected]"
] | |
e546b460b9152019c70edbf1b8512c692a615caa | 02a7774c60742233c7fabf2c2c90feaf46159892 | /src/com/coolweather/app/activity/ChooseAreaActivity.java | b4e036883b4514db0591d28c6bc9e1dba9fb7271 | [
"Apache-2.0"
] | permissive | wo519622/coolweather | 1fc5336896805b73e92aab0feb20a44e59cc207e | 9d9e2ceb256a0c319b8bff76fae637ce54279e3b | refs/heads/master | 2021-01-19T05:46:19.170928 | 2017-08-22T07:57:31 | 2017-08-22T07:57:31 | 100,578,318 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 7,540 | java | package com.coolweather.app.activity;
import java.security.Provider;
import java.util.ArrayList;
import java.util.List;
import com.coolweather.app.R;
import com.coolweather.app.model.City;
import com.coolweather.app.model.CoolWeatherDB;
import com.coolweather.app.model.County;
import com.coolweather.app.model.Province;
import com.coolweather.app.util.HttpCallbackLister;
import com.coolweather.app.util.HttpUtil;
import com.coolweather.app.util.Utility;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class ChooseAreaActivity extends Activity {
public static final int LEVEL_PROVINCE=0;
public static final int LEVEL_CITY=1;
public static final int LEVEL_COUNTY=2;
private ProgressDialog progressDialog;
private TextView titleText;
private ListView listView;
private ArrayAdapter<String> adapter;
private CoolWeatherDB coolWeatherDB;
private List<String> dataList=new ArrayList<String>();
private List<Province> provinceList;//省列表
private List<City> cityList;//省列表
private List<County> countyList;//县列表
private Province selectedProvince;//选中的省份
private City selectedCity;//选中的城市
private int currentLevel;//当前选中的级别
private boolean isFromWeatherActivity;//是否从WeatherActivity中跳转过来。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.choose_area);
isFromWeatherActivity=getIntent().getBooleanExtra("from_weather_activity", false);
SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
//已经选择了城市且不是从WeatherActivity跳转过来,才会直接跳转到WeatherActivity
if (prefs.getBoolean("city_selected", false) && !isFromWeatherActivity ) {
Intent intent=new Intent(this,WeatherActivity.class);
startActivity(intent);
finish();
return;
}
listView=(ListView)findViewById(R.id.list_view);
titleText=(TextView)findViewById(R.id.title_text);
adapter=new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,dataList);
listView.setAdapter(adapter);
coolWeatherDB=CoolWeatherDB.getInstance(this);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int index,
long arg3) {
if (currentLevel==LEVEL_PROVINCE) {
selectedProvince=provinceList.get(index);
queryCities();
}else if (currentLevel==LEVEL_CITY) {
selectedCity=cityList.get(index);
queryCounties();
}else if (currentLevel==LEVEL_COUNTY) {
String countyCode=countyList.get(index).getCountyCode();
Intent intent=new Intent(ChooseAreaActivity.this,WeatherActivity.class);
intent.putExtra("county_code",countyCode);
startActivity(intent);
finish();
}
}
});
queryProvinces();//加载省级数据
}
//查询全国所有的省,优先从数据库查询,如果没有查询到再去服务器上查询。
private void queryProvinces() {
provinceList=coolWeatherDB.loadProvinces();
if (provinceList.size()>0) {
dataList.clear();
for(Province province : provinceList){
dataList.add(province.getProvinceName());
}
adapter.notifyDataSetChanged();
listView.setSelection(0);
titleText.setText("中国");
currentLevel=LEVEL_PROVINCE;
}else {
queryFromServer(null,"province");
}
}
//查询选中省所有的市,优先从数据库查询,如果没有查询到再去服务器上查找
protected void queryCities() {
cityList=coolWeatherDB.loadCities(selectedProvince.getId());
if (cityList.size()>0) {
dataList.clear();
for(City city:cityList){
dataList.add(city.getCityName());
}
adapter.notifyDataSetChanged();
listView.setSelection(0);
titleText.setText(selectedProvince.getProvinceName());
currentLevel=LEVEL_CITY;
}else {
queryFromServer(selectedProvince.getProvinceCode(), "city");
}
}
//查询选中的市内所有县,优先从数据库查询,如果没有查询到再去服务器上查找。
protected void queryCounties() {
countyList=coolWeatherDB.loadCounties(selectedCity.getId());
if (countyList.size()>0) {
dataList.clear();
for(County county:countyList){
dataList.add(county.getCountyName());
}
adapter.notifyDataSetChanged();
listView.setSelection(0);
titleText.setText(selectedCity.getCityName());
currentLevel=LEVEL_COUNTY;
}else {
queryFromServer(selectedCity.getCityCode(), "county");
}
}
//根据传入代号和类型从服务器上查询省市县数据
private void queryFromServer(final String code, final String type) {
String address;
if (!TextUtils.isEmpty(code)) {
address="http://www.weather.com.cn/data/list3/city"+code+".xml";
}else {
address="http://www.weather.com.cn/data/list3/city.xml";
}
showProgressDialog();
HttpUtil.sendHttpRequest(address, new HttpCallbackLister() {
@Override
public void onFinish(String response) {
boolean result=false;
if ("province".equals(type)) {
result=Utility.handleProvincesResponse(coolWeatherDB, response);
}else if ("city".equals(type)) {
result=Utility.handleCitiesResponse(coolWeatherDB, response, selectedProvince.getId());
}else if ("county".equals(type)) {
result=Utility.handleCountiesResponse(coolWeatherDB, response, selectedCity.getId());
}
if (result) {
//通过runONUiThread()方法回到主线程处理逻辑
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressDialog();
if("province".equals(type)){
queryProvinces();
}else if ("city".equals(type)) {
queryCities();
}else if ("county".equals(type)) {
queryCounties();
}
}
});
}
}
@Override
public void onError(Exception e) {
//通过runONUiThread()方法回到主线程处理逻辑
runOnUiThread(new Runnable() {
public void run() {
closeProgressDialog();
Toast.makeText(ChooseAreaActivity.this, "加载失败", Toast.LENGTH_SHORT).show();
}
});
}
});
}
//显示进度对话框
private void showProgressDialog() {
if (progressDialog==null) {
progressDialog=new ProgressDialog(this);
progressDialog.setMessage("正在加载...");
progressDialog.setCanceledOnTouchOutside(false);
}
progressDialog.show();
}
//关闭进度对话框
private void closeProgressDialog() {
if (progressDialog!=null) {
progressDialog.dismiss();
}
}
//捕获back按键,根据当前的级别来判断,此时应该返回市列表、省列表、还是直接退出。
@Override
public void onBackPressed() {
if (currentLevel==LEVEL_COUNTY) {
queryCities();
}else if (currentLevel==LEVEL_CITY) {
queryProvinces();
}else {
if (isFromWeatherActivity) {
Intent intent=new Intent(this,WeatherActivity.class);
startActivity(intent);
}
finish();
}
}
}
| [
"[email protected]"
] | |
1346b45042c49c70e0ac48a56d435df5b2377201 | 4b8ce73fb33fed90a4bf976b7b114176f6d4268e | /chapter_002/src/main/java/ru/job4j/stream/Address.java | 2779e347c87c19406110daade8cabd11e865657b | [] | no_license | shalashkove/job4j | 1d58cf5e17bf1e0c79b96fed158a8f076341ce7e | 12c9b2701c92407432765326f089339c11247ee6 | refs/heads/master | 2021-07-10T02:57:39.245128 | 2020-05-06T17:18:28 | 2020-05-06T17:18:28 | 204,113,660 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,175 | java | package ru.job4j.stream;
import java.util.Objects;
public class Address {
private String city;
private String street;
private int home;
private int apartment;
public String getCity() {
return city;
}
public String getStreet() {
return street;
}
public int getHome() {
return home;
}
public int getApartment() {
return apartment;
}
public Address(String city, String street, int home, int apartment) {
this.city = city;
this.street = street;
this.home = home;
this.apartment = apartment;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Address address = (Address) o;
return home == address.home
&& apartment == address.apartment
&& Objects.equals(city, address.city)
&& Objects.equals(street, address.street);
}
@Override
public int hashCode() {
return Objects.hash(city, street, home, apartment);
}
}
| [
"[email protected]"
] | |
e301389dd5883a704b0803e347e674ce28af0451 | 29150da7db2a4c408fc56c9e237799be47ea8e98 | /src/main/java/kodlamaio/hrms/dataAccess/abstracts/JobPositionDao.java | acd0013c7deb3efc646f41d7c93ea864e3e515c6 | [] | no_license | umurislamoglu/HRMS | c1fede68e3525982d5bc5d617d6c56a6b6e743d6 | 2e59d377ac9d8c4007661668d274aca45562b1d9 | refs/heads/master | 2023-05-08T03:25:15.379419 | 2021-06-02T17:11:06 | 2021-06-02T17:11:06 | 366,750,110 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 450 | java | package kodlamaio.hrms.dataAccess.abstracts;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import kodlamaio.hrms.entities.concretes.JobPositions;
public interface JobPositionDao extends JpaRepository<JobPositions,Integer> {
@Query(value="SELECT id,position FROM jobpositions j WHERE j.position = ?1", nativeQuery = true)
JobPositions findByPosition(String position);
}
| [
"[email protected]"
] | |
a3266265567e364f4cf49edef0df32f042656c4f | ff4b6e6fdc004670ba23f0131cd885f35c393781 | /cst-to-json/src/core/exolab/cst/xml/validators/IdRefsValidator.java | 19e4cfbdeae9bc01f123ce928b7741412aca772c | [] | no_license | gospoduro/java_study_iba | 96b7d3fe4b4a47d89d2dec4c2f6d801e7af32373 | 9acbe031b7169e7f04f19b56c502b1de0f38531a | refs/heads/master | 2020-03-19T12:41:37.738362 | 2018-07-08T13:17:30 | 2018-07-08T13:17:30 | 135,212,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,002 | java | /*
* Copyright 2006 Werner Guttmann
*
* 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 core.exolab.cst.xml.validators;
import core.exolab.cst.xml.TypeValidator;
import core.exolab.cst.xml.ValidationContext;
import core.exolab.cst.xml.ValidationException;
/**
* The IDREFS Validation class.
*
* @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttman</a>
* @version $Revision: 0000 $ $Date: $
*/
public class IdRefsValidator implements TypeValidator {
/** Our IdRefValidator. */
private IdRefValidator _idRefValidator;
/**
* Creates a new IdRefsValidator with no restrictions.
*/
public IdRefsValidator() {
super();
_idRefValidator = new IdRefValidator();
}
/**
* Validates the given Object.
*
* @param object the Object to validate
* @param context the ValidationContext
* @throws ValidationException if the object fails validation.
*/
public void validate(final Object object, final ValidationContext context)
throws ValidationException {
if (object == null) {
String err = "The object of type IDREFS is null!";
throw new ValidationException(err);
}
Object[] objects = (Object[]) object;
for (int i = 0; i < objects.length; i++) {
_idRefValidator.validate(objects[i], context);
}
// validate(value, context);
} //-- validate
}
| [
"GitHub3377734_"
] | GitHub3377734_ |
13f4a9829bd4560a1098f91c909390dc7deab164 | f3416fb3e2f7edd6fb6790362e0abc5e6bb584be | /src/lesson18/task2/ComparatorOfPrice.java | 2e3a7c38c38d2b851d2ddafd989f503ac788a61d | [] | no_license | squirrel3712/Projects | 14cb30e6dc2086deb1986b5ccc475a5c2bfff1bb | 88f3f8f4ef25b316eb4cd5e50fb849f1f7100523 | refs/heads/master | 2020-12-03T00:02:57.388382 | 2017-10-08T19:34:38 | 2017-10-08T19:34:38 | 95,978,788 | 0 | 1 | null | 2017-07-10T17:47:42 | 2017-07-01T17:36:08 | Java | UTF-8 | Java | false | false | 250 | java | package lesson18.task2;
import java.util.Comparator;
public class ComparatorOfPrice implements Comparator<Product> {
@Override
public int compare(Product first, Product second) {
return first.getPrice() - second.getPrice();
}
}
| [
"[email protected]"
] | |
1f66577eb188ffbcff0f55a500033057c6f9d7f8 | 6fcac7722b0247cc3e10c85cf4150857fc2c3876 | /src/Java15/Sort3.java | 3651f0d4d14b994d619bb7e47c30e2e0cbb29c4c | [] | no_license | liyuhuan123/untitled2 | 558967162493ba21ddfc1ae84053b8fbbb2d121e | 910f7bdcb928698f08fa241349419b8f8b4275a3 | refs/heads/master | 2021-04-07T14:20:25.582413 | 2020-04-17T12:37:28 | 2020-04-17T12:37:28 | 248,682,701 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,811 | java | package Java15;
import java.util.Arrays;
public class Sort3 {
public static void shellSort(int[] array){
int gap = array.length / 2;
while(gap > 1){
insertSortGap(array,gap);
gap = gap / 2;
}
insertSortGap(array,1);
}
private static void insertSortGap(int[] array,int gap){
for(int i = gap;i < array.length;i++){
int v = array[i];
int j = i - gap;
for(;j >= 0;j-=gap){
if(array[j] > v){
array[j+gap] = array[j];
}else{
break;
}
}
array[j+gap] = v;
}
}
public static void selectSort(int[] array){
for(int i = 0;i < array.length;i++){
for(int j = i + 1;j < array.length;j++){
if(array[i] > array[j]){
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}
public static void bubbleSort(int[] array){
for(int i = 0;i < array.length;i++){
for(int j = array.length - 1;j > i;j--){
if(array[i] > array[j]){
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}
public static void heapSort(int[] array){
//先建堆
creatHeap(array);
for(int i = 0;i < array.length;i++){
int heapSize = array.length - i;
swap(array,0,heapSize - 1);
heapSize--;
shiftDown(array,heapSize,0);
}
}
private static void creatHeap(int[] array){
for(int i = (array.length - 1 - 1)/2;i >= 0;i--){
shiftDown(array,array.length,i);
}
}
private static void shiftDown(int[] array,int heapSize,int index){
int parent = index;
int child = parent * 2 + 1;
while(child < heapSize){
if(child + 1 < heapSize && array[child+1] > array[child]){
child = child + 1;
}
if(array[parent] < array[child]){
swap(array,child,parent);
}else{
break;
}
parent = child;
child = parent * 2 + 1;
}
}
private static void swap(int[] array,int i,int j){
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
public static void main(String[] args){
int[] array = {9,5,2,3,7,6,8};
//insertSort(array);
//shellSort(array);
//selectSort(array);
//bubbleSort(array);
creatHeap(array);
System.out.println(Arrays.toString(array));
}
}
| [
"[email protected]"
] | |
8ef35fa3d01a1b5658a29cb524e043b514e60b3a | 29e7822137ae1f9c1796c866b1fe4be061a333f2 | /build/maven/src/main/java/io/jshift/kit/build/maven/ImagePullCache.java | 04c257450498364d60a1a186de41468f79e30698 | [
"Apache-2.0"
] | permissive | jshiftio/jshift-kit | e814ad0d45f0366796785410b69ac5f0beeb889a | 4570a42251f61f6bed7755baeb8f61dcf1c5fdd6 | refs/heads/master | 2022-10-22T17:25:23.155306 | 2019-12-20T17:03:58 | 2019-12-20T17:03:58 | 184,569,540 | 5 | 3 | Apache-2.0 | 2022-10-05T03:06:12 | 2019-05-02T11:30:56 | Java | UTF-8 | Java | false | false | 2,017 | java | package io.jshift.kit.build.maven;
import com.google.gson.JsonObject;
import io.jshift.kit.common.JsonFactory;
/**
* Simple interface for a ImagePullCache manager, to load and persist the cache.
*/
public class ImagePullCache {
// Key for the previously used image cache
private static final String CONTEXT_KEY_PREVIOUSLY_PULLED = "CONTEXT_KEY_PREVIOUSLY_PULLED";
private Backend backend;
public ImagePullCache(Backend backend) {
this.backend = backend;
}
public boolean hasAlreadyPulled(String image) {
return load().has(image);
}
public void pulled(String image) {
save(load().add(image));
}
// Store to use for the cached
public interface Backend {
String get(String key);
void put(String key, String value);
}
// ======================================================================================
private ImagePullCacheStore load() {
String pullCacheJson = backend.get(CONTEXT_KEY_PREVIOUSLY_PULLED);
ImagePullCacheStore cache = new ImagePullCacheStore(pullCacheJson);
if (pullCacheJson == null) {
save(cache);
}
return cache;
}
private void save(ImagePullCacheStore cache) {
backend.put(CONTEXT_KEY_PREVIOUSLY_PULLED, cache.toString());
}
/**
* Simple serializable cache for holding image names
*
* @author roland
* @since 20/07/16
*/
class ImagePullCacheStore {
private JsonObject cache;
ImagePullCacheStore(String json) {
cache = json != null ? JsonFactory.newJsonObject(json) : new JsonObject();
}
public boolean has(String imageName) {
return cache.has(imageName);
}
public ImagePullCacheStore add(String image) {
cache.addProperty(image, Boolean.TRUE);
return this;
}
@Override
public String toString() {
return cache.toString();
}
}
}
| [
"[email protected]"
] | |
ee447b2205f707e75d89db4595f627a3078edab1 | 45a758765a72de22af02274b555f7ae36c8abe5d | /Gunjungps/src/Gunjungps/javasocketserver.java | 85b81c2b230560eeb4a85a07a1c930ad557e262c | [] | no_license | dlrjswns/Androidproject1 | 55c06600a21b88fc6896298aac29d0cdd860eb76 | 2f909bfbe6296fa4224915a26079b6ff0c146310 | refs/heads/master | 2020-03-22T16:25:38.711333 | 2018-07-10T12:58:26 | 2018-07-10T12:58:26 | 140,325,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 841 | java | package Gunjungps;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class javasocketserver {
public static void main(String[] args) {
try {
ServerSocket serverSocket=new ServerSocket(5000);
System.out.println("server started:5000");
while(true) {
Socket socket=serverSocket.accept();
ObjectInputStream instream=new ObjectInputStream(socket.getInputStream());
String inStr=instream.readUTF();
System.out.println("inStr from client:"+inStr);
ObjectOutputStream outstream=new ObjectOutputStream(socket.getOutputStream());
outstream.writeUTF(inStr+"from server");
outstream.flush();
}
}
catch(IOException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
989fb82a5a3058084ed25f40cf3187618c60b6c6 | 11385ff57ae1fdef1d85554e063c438f9ec919b7 | /web-job/src/main/java/com/cn/web/job/service/impl/ScheduleJobServiceImpl.java | 44723df08872926c3305ff29f5f52a3792e9b182 | [
"Apache-2.0"
] | permissive | findById/web | eb2cbe5dcc75e8fd110e8c64608594c353b0912c | 7c3878eba135b3e17d2ed26f178eac5cb7a04774 | refs/heads/master | 2021-06-16T20:06:58.346767 | 2021-02-08T03:10:10 | 2021-02-08T03:10:10 | 94,448,537 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,224 | java | package com.cn.web.job.service.impl;
import com.alibaba.fastjson.JSON;
import com.cn.web.job.dao.ScheduleJobDao;
import com.cn.web.job.domain.ScheduleJob;
import com.cn.web.job.service.ScheduleJobService;
import com.cn.web.job.util.ScheduleJobUtils;
import org.quartz.CronExpression;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
@Service(value = "scheduleJobService")
public class ScheduleJobServiceImpl implements ScheduleJobService {
@Resource
ScheduleJobDao scheduleJobDao;
@Autowired
private Scheduler scheduler;
@PostConstruct
public void init() {
List<ScheduleJob> list = this.list();
if (list == null || list.isEmpty()) {
return;
}
for (ScheduleJob item : list) {
System.out.println("schedule job id: " + item.getId() + ", method: " + item.getMethod() + ", cron: " + item.getCron());
try {
Trigger trigger = ScheduleJobUtils.getTrigger(scheduler, item);
if (trigger == null) {
ScheduleJobUtils.createScheduleJob(scheduler, item);
} else {
ScheduleJobUtils.updateScheduleJob(scheduler, item);
}
if (ScheduleJob.JOB_STATE_RUNNING.equals(item.getStatus())) {
ScheduleJobUtils.startScheduleJob(scheduler, item);
}
} catch (SchedulerException e) {
e.printStackTrace();
}
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
}
@Override
public ScheduleJob get(Long id) {
Optional<ScheduleJob> optional = scheduleJobDao.findById(id);
return optional.orElse(null);
}
@Override
@Transactional
public ScheduleJob save(ScheduleJob scheduleJob) {
boolean valid = CronExpression.isValidExpression(scheduleJob.getCron());
if (!valid) {
throw new IllegalArgumentException("无效的Cron表达式");
}
scheduleJob.setStatus(ScheduleJob.JOB_STATE_STANDBY);
scheduleJobDao.save(scheduleJob);
ScheduleJobUtils.createScheduleJob(scheduler, scheduleJob);
return scheduleJob;
}
@Override
@Transactional
public ScheduleJob update(ScheduleJob scheduleJob) {
boolean valid = CronExpression.isValidExpression(scheduleJob.getCron());
if (!valid) {
throw new IllegalArgumentException("无效的Cron表达式");
}
// scheduleJobDao.update(scheduleJob);
scheduleJobDao.save(scheduleJob);
try {
ScheduleJobUtils.updateScheduleJob(scheduler, scheduleJob);
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
return scheduleJob;
}
@Override
@Transactional
public void delete(Long[] ids) {
for (Long id : ids) {
ScheduleJob job = get(id);
try {
ScheduleJobUtils.deleteScheduleJob(scheduler, job);
} catch (SchedulerException e) {
e.printStackTrace();
}
scheduleJobDao.deleteById(id);
}
}
@Override
@Transactional
public void deleteByLogic(Long[] ids) {
for (Long id : ids) {
ScheduleJob job = this.get(id);
if (job != null) {
try {
ScheduleJobUtils.deleteScheduleJob(scheduler, job);
} catch (SchedulerException e) {
e.printStackTrace();
}
job.setDelFlg(ScheduleJob.FLAG_DELETE);
scheduleJobDao.save(job);
}
}
}
@Override
public List<ScheduleJob> list() {
return scheduleJobDao.findAll();
}
@Override
public Page<ScheduleJob> list(int page, int size) {
return scheduleJobDao.findAll(PageRequest.of(page, size, Sort.by("id")));
}
@Override
public Page<ScheduleJob> search(String keywords, int page, int size) {
ScheduleJob item = new ScheduleJob();
// item.setId(keywords);
item.setName(keywords);
item.setGroup(keywords);
item.setMethod(keywords);
item.setRemark(keywords);
ExampleMatcher matcher = ExampleMatcher.matchingAny()
//.withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("group", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("method", ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("remark", ExampleMatcher.GenericPropertyMatchers.contains())
.withIgnorePaths("status", "updateTime", "delFlg");
Example<ScheduleJob> example = Example.of(item, matcher);
return scheduleJobDao.findAll(example, PageRequest.of(page, size, Sort.by("updateTime").descending()));
}
@Override
@Transactional
public void updateBatch(Long[] ids, String state) throws Exception {
for (Long id : ids) {
ScheduleJob job = get(id);
switch (state) {
case ScheduleJob.JOB_STATE_STANDBY: {
ScheduleJobUtils.pauseScheduleJob(scheduler, job);
break;
}
case ScheduleJob.JOB_STATE_RUNNING: {
ScheduleJobUtils.startScheduleJob(scheduler, job);
break;
}
case ScheduleJob.JOB_STATE_PAUSED: {
ScheduleJobUtils.pauseScheduleJob(scheduler, job);
break;
}
case ScheduleJob.JOB_STATE_STOPPED: {
ScheduleJobUtils.pauseScheduleJob(scheduler, job);
break;
}
default:
return;
}
job.setStatus(state);
scheduleJobDao.save(job);
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
}
@Override
@Transactional
public boolean start(Long[] ids) {
for (Long id : ids) {
try {
ScheduleJob job = get(id);
ScheduleJobUtils.startScheduleJob(scheduler, job);
job.setStatus(ScheduleJob.JOB_STATE_RUNNING);
scheduleJobDao.save(job);
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
return true;
}
@Override
@Transactional
public boolean resume(Long[] ids) {
for (Long id : ids) {
try {
ScheduleJob job = get(id);
ScheduleJobUtils.resumeScheduleJob(scheduler, job);
job.setStatus(ScheduleJob.JOB_STATE_RUNNING);
scheduleJobDao.save(job);
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
return true;
}
@Override
@Transactional
public boolean pause(Long[] ids) {
for (Long id : ids) {
try {
ScheduleJob job = get(id);
ScheduleJobUtils.pauseScheduleJob(scheduler, job);
job.setStatus(ScheduleJob.JOB_STATE_PAUSED);
scheduleJobDao.save(job);
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
return true;
}
@Override
@Transactional
public boolean stop(Long[] ids) {
for (Long id : ids) {
try {
ScheduleJob job = get(id);
ScheduleJobUtils.pauseScheduleJob(scheduler, job);
job.setStatus(ScheduleJob.JOB_STATE_STOPPED);
scheduleJobDao.save(job);
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
try {
System.out.println("job: " + JSON.toJSONString(ScheduleJobUtils.getScheduleJob(scheduler)));
System.out.println("running job: " + JSON.toJSONString(ScheduleJobUtils.getRunningJob(scheduler)));
} catch (SchedulerException e) {
e.printStackTrace();
}
return true;
}
}
| [
"[email protected]"
] | |
44ecc697e8fcba1d5f52a18fc42aedbff7cd42a2 | 9b7b7c2862ee705c4efd5491cd389bb144b084b5 | /src/领扣算法/剑指offer/在排序数组中查找数字I/Main.java | b3c5f8da14be273008dbdb66f3f3c1181c8721ee | [] | no_license | g1587613421/arithmetic | 5bf16083df2b9791d6ff09ea4463610184a250cb | 22f99afb5f785eadb8cff57ec09c635dead69d50 | refs/heads/master | 2021-07-10T03:19:08.413358 | 2021-04-02T00:58:25 | 2021-04-02T00:58:25 | 235,080,687 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 789 | java | /*
* Copyright (c) 2021.版权所有高金磊
*/
package 领扣算法.剑指offer.在排序数组中查找数字I;
public class Main {
public int search(int[] nums, int target) {
if (nums.length==0)
return 0;
int le=0,ri=nums.length-1;
int middle=0;
while (le<=ri)
{
middle=le+(ri-le)/2;
if (nums[middle]==target)
break;//查找成功
if (nums[middle]>target)
{
ri=middle-1;
}
else le=middle+1;
}
int count=0;
for (int i = middle; i>=0&&nums[i]==target ; i--)
count++;
for (int i = middle+1; i<nums.length&&nums[i]==target ; i++)
count++;
return count;
}
}
| [
"[email protected]"
] | |
21045f665944bf07cdb9aa3d54fcb60aa23f8f80 | bfc7bb040d43e63d7518eb41b90129ae4afc4b29 | /java-network/src/main/java/com/linkedin/norbert/network/javaapi/ConsistentHashPartitionedLoadBalancerFactory.java | fbd6d363ebbe1bcf097121248727858e9a98b1aa | [
"Apache-2.0"
] | permissive | liliwu/norbert | 7b485fdddc9a11c4ab7b7cedcbaf56277008db1f | 2108fd3bfb4b1b7e857c0744f126fb48bdc6311c | refs/heads/master | 2021-01-17T12:46:04.600042 | 2010-04-01T22:48:40 | 2010-04-01T22:48:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,962 | java | /*
* Copyright 2009-2010 LinkedIn, 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.linkedin.norbert.network.javaapi;
import com.linkedin.norbert.cluster.InvalidClusterException;
import com.linkedin.norbert.cluster.Node;
import java.util.*;
public abstract class ConsistentHashPartitionedLoadBalancerFactory<PartitionedId> implements PartitionedLoadBalancerFactory<PartitionedId> {
public PartitionedLoadBalancer<PartitionedId> newLoadBalancer(Node[] nodes) throws InvalidClusterException {
return new ConsistentHashLoadBalancer(nodes);
}
abstract protected int hashPartitionedId(PartitionedId id);
private class ConsistentHashLoadBalancer implements PartitionedLoadBalancer<PartitionedId> {
private final Map<Integer, List<Node>> nodeMap = new HashMap<Integer, List<Node>>();
private final Random random = new Random();
private ConsistentHashLoadBalancer(Node[] nodes) {
for (Node node : nodes) {
for (int partitionId : node.getPartitions()) {
List<Node> nodeList = nodeMap.get(partitionId);
if (nodeList == null) {
nodeList = new ArrayList<Node>();
nodeMap.put(partitionId, nodeList);
}
nodeList.add(node);
}
}
}
public Node nextNode(PartitionedId partitionedId) {
List<Node> nodes = nodeMap.get(hashPartitionedId(partitionedId));
return nodes.get(random.nextInt(nodes.size()));
}
}
}
| [
"[email protected]"
] | |
967f8a53da4a9de5cd79454037d93f2ec72be90b | 94813b9a019bcfeea2f879ec5b9d52843fc0f156 | /java basics/src/array/Sortinginarray.java | d69e15cad150a50ab94cd8e2ada97eb88444282b | [] | no_license | gvenkatesh4/javabasicsprograms | a687197574989a8a04e06fe52c6f46c42dfdc43d | 95cf04ef6f5f291c8e2fdb0b1bb3025ec41c1675 | refs/heads/master | 2022-10-11T18:01:37.790782 | 2020-06-13T05:09:42 | 2020-06-13T05:09:42 | 271,944,830 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 692 | java | package array;
import java.util.Scanner;
public class Sortinginarray {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("enter the size");
int size = scan.nextInt();
System.out.println("enter the array elements");
int a[] = new int [size];
for(int i=0;i<size;i++)
{
a[i]=scan.nextInt();
}
sorting(a);
}
public static void sorting(int a[]) {
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if(a[i]>a[j]) {
int temp = a[i];
a[i]=a[j];
a[j]=temp;
}
}
System.out.println(a[i]);
}
}
}
| [
"Venkatesh@LAPTOP-4OKHSCA5"
] | Venkatesh@LAPTOP-4OKHSCA5 |
1ddc8f654a2ba0dd9701b17f750af00695cf95ae | 7bab9e9423d08d117bcdd790c9bffc10af82a362 | /src/main/java/com/otx/entities/Route.java | 92afb0b74867b5d5b3a7c9127184a10a498ce2cb | [] | no_license | satnamkhowal/otx_main_webapp | e4fbaeafb1d2607dff5d9a8f2c6be9fdb8fd93f5 | fcd85994c69c1fb3c20b9bf498b448945a33d69d | refs/heads/master | 2022-12-08T15:45:45.029260 | 2020-09-12T09:26:57 | 2020-09-12T09:26:57 | 294,846,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,653 | java | package com.otx.entities;
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 org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.ManyToAny;
@Entity
@Table(name = "routes")
public class Route {
@Id
//@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "route_id")
private Long routeId;
//private int userId;
@ManyToOne
@JoinColumn(name="user_id")
private User user;
@Column(name = "starting_point")
private String startingPoint;
@Column(name="destination")
private String destination;
@Column(name="stops")
private String stops;
public Long getRouteId() {
return routeId;
}
public void setRouteId(Long routeId) {
this.routeId = routeId;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getStartingPoint() {
return startingPoint;
}
public void setStartingPoint(String startingPoint) {
this.startingPoint = startingPoint;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getStops() {
return stops;
}
public void setStops(String stops) {
this.stops = stops;
}
@Override
public String toString() {
return "Route [routeId=" + routeId + ", user=" + user + ", startingPoint=" + startingPoint + ", destination="
+ destination + ", stops=" + stops + "]";
}
}
| [
"[email protected]"
] | |
7a4e9e29cebc855baf7be9d53d213e8f17abdb00 | b4e1ef470c1627bf6cd331d4d28e96e2acdb8ac6 | /Healthbar2/src/com/msquirrel/adapter/MyGridAdapter.java | d0f77be43d6f8e8483e03916d569c717f1652a05 | [] | no_license | XXiaoMei/LifeCalculator | dfeb2c50ba387c21c638cfc55ed2aab7eb0cc836 | 7db3f2effbf48f944eda8ed583b1acaf554d6cb3 | refs/heads/master | 2020-05-17T10:34:35.144116 | 2015-06-08T03:57:58 | 2015-06-08T03:57:58 | 32,931,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,298 | java | package com.msquirrel.adapter;
import java.util.List;
import com.msquirrel.bean.UserImgs;
import com.nostra13.universalimageloader.core.ImageLoader;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
public class MyGridAdapter extends BaseAdapter {
private List<UserImgs> mUI;
private LayoutInflater mLayoutInflater;
public MyGridAdapter(List<UserImgs> ui, Context context) {
mLayoutInflater = LayoutInflater.from(context);
this.mUI = ui;
}
@Override
public int getCount() {
return mUI == null ? 0 : mUI.size();
}
@Override
public String getItem(int position) {
return mUI.get(position).urls;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyGridViewHolder viewHolder;
if (convertView == null) {
viewHolder = new MyGridViewHolder();
} else {
viewHolder = (MyGridViewHolder) convertView.getTag();
}
String url = getItem(position);
ImageLoader.getInstance().displayImage(url, viewHolder.imageView);
return convertView;
}
private static class MyGridViewHolder {
ImageView imageView;
}
}
| [
"[email protected]"
] | |
c5db53f4e51f5cc26c0a2846dd7198079a463132 | 0887c90394c6915aac10b3785dd4e7d600e35c74 | /src/usercenter/externalTask/TaskResponse/DliverSumType.java | b3d695f660b53eed1179a0bd5bf188af75496af5 | [] | no_license | Monkey-mi/outsideeasy | ca34a0ca4e474e13722b9424901170d51d37a805 | 2e171bfd3b649eeefdcaa28adc57a4dac569ec09 | refs/heads/master | 2021-01-21T06:38:48.058165 | 2017-02-27T04:04:50 | 2017-02-27T04:04:50 | 83,262,244 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | package usercenter.externalTask.TaskResponse;
public class DliverSumType {
}
| [
"[email protected]"
] | |
9b430b65519a9d7f2f1a48f780710a8142edb7de | c2bc17ac50f9fe8629362fe2e1da707d0ad44113 | /OlioEsimerki5/TiedostojenKasittely5.java | 714e2d21444d2f33b2d165ead806348234c6637d | [] | no_license | bekshoi/ltdns20 | a1b56d8aa271b7edb921c5ec8209da2746b51cb9 | c338c4fd1f1fe84dce14a5917c07409d0b45ba66 | refs/heads/master | 2023-02-09T07:31:43.431108 | 2020-12-29T07:30:15 | 2020-12-29T07:30:15 | 306,302,237 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,527 | java | /*********************************************
Nimi: TiedostojenKasittely5
Kuvaus: Esimerkki 5: binääritiedostoon kirjoittaminen.
*********************************************/
/* Otetaan mukaan kirjastot, jotka sisältävät tarvittavat valmiit
luokat. */
import java.util.*;
import java.io.*;
// Toteutettava luokka.
public class TiedostojenKasittely5 {
// Pääohjelma, jota kutsutaan ohjelman suorituksen alkaessa.
public static void main(String [ ] args) {
// Esitellään ja alustetaan olio syötteiden lukemista varten.
Scanner lukija;
lukija = new Scanner(System.in);
// Esitellään muuttuja tiedostonimen kysymistä varten.
String tiedostonimi;
// Esitellään muuttujat, jotka haluamme kirjoittaa tiedostoon.
int kokonaisluku = 5;
double liukuluku = 2.5;
// Olio tiedostosta lukemista varten.
ObjectInputStream tiedostolukija = null;
// Yritetään lukea tiedostosta ...
try {
// Pyydetään tiedostonimi käyttäjältä.
System.out.print("Anna tiedostonimi: ");
tiedostonimi = lukija.nextLine();
//Luodaan tarvittavat oliot tiedoston lukua varten ja annetaan luettava tiedosto.
FileOutputStream tiedosto = new FileOutputStream(tiedostonimi);
ObjectOutputStream Tiedostoonkirjoittaja = new ObjectOutputStream(tiedosto);
//Kirjoitetaan data tiedostoon.
Tiedostoonkirjoittaja.writeInt(kokonaisluku);
Tiedostoonkirjoittaja.writeDouble(liukuluku);
// Suljetaan lopuksi tiedostolukjan osoittama tiedosto.
Tiedostoonkirjoittaja.close();
// Ilmoitetaan käyttäjälle, kun päästään tiedoston loppuun.
} catch (EOFException eof) {
System.out.println ("Tiedosto loppui");
}
// Mikäli tiedostoa ei löydy, ilmoitetaan asiasta ja lopetetaan ohjelma.
catch (FileNotFoundException e) {
System.out.println("Tiedostoa ei löytynyt. Lopetan ");
System.exit(1);
}
// Otetaan kiinni syöte- ja tulostevirtoihin liittyvät poikkeukset, tulostetaan ilmoitus ja lopetetaan ohjelma.
catch(IOException e) {
System.out.println(" Syöte- ja tulostevirtojen käsittely epäonnistui. Lopetan.");
System.exit(1);
}
// Otetaan kiinni kaikki muut poikkeukset, tulostetaan yleispätevä ilmoitus ja lopetetaan ohjelma.
catch (Exception e) {
System.out.println(" Jotain meni pieleen. Lopetan.");
System.exit(1);
}
}
} | [
"[email protected]"
] | |
e9c48ba4b1f54e0355f77bf8d0f475b5c4461b6b | 184bd2b79a48c597e1c251651d90f633d7d142ef | /leetcode/30day-challenge-2020-april/src/main/java/week1/single_number/SingleNumberV3.java | f88fae74d9686678c9e2705e6a046f00a277f685 | [
"MIT"
] | permissive | olegkoskin/challenges | dc61f61a9d373bff951e98f4911b46c517973317 | f8e5d87f1b7eb86bf8cd1901904a71b8994ebe0c | refs/heads/master | 2021-11-05T19:58:56.885279 | 2021-11-01T08:25:27 | 2021-11-01T08:45:13 | 252,131,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 571 | java | package week1.single_number;
import java.util.HashMap;
import java.util.Map;
public class SingleNumberV3 {
/**
* Map contain approach.
*
* @param nums nums
* @return single number
*/
public int singleNumber(int[] nums) {
Map<Integer, Integer> hash1 = new HashMap<>(nums.length);
for (int num : nums) {
if (hash1.containsKey(num)) {
hash1.remove(num);
} else {
hash1.put(num, 1);
}
}
return hash1.keySet().iterator().next();
}
}
| [
"[email protected]"
] | |
507eccc81a999537fefe44aaad072c95194ccc49 | a2df6764e9f4350e0d9184efadb6c92c40d40212 | /aliyun-java-sdk-sofa/src/main/java/com/aliyuncs/sofa/transform/v20190815/QueryRmsAlertrulesResponseUnmarshaller.java | 95e756b4351365eb825e7458ea58197ae9e38141 | [
"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 | 6,667 | 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.sofa.transform.v20190815;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.EntitiesItem;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.EntitiesItem.Entity;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.EntitiesItem.Entity.Definition;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.EntitiesItem.Entity.MonitorTarget;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.Meta;
import com.aliyuncs.sofa.model.v20190815.QueryRmsAlertrulesResponse.Response.Meta.Page;
import com.aliyuncs.transform.UnmarshallerContext;
public class QueryRmsAlertrulesResponseUnmarshaller {
public static QueryRmsAlertrulesResponse unmarshall(QueryRmsAlertrulesResponse queryRmsAlertrulesResponse, UnmarshallerContext _ctx) {
queryRmsAlertrulesResponse.setRequestId(_ctx.stringValue("QueryRmsAlertrulesResponse.RequestId"));
queryRmsAlertrulesResponse.setResultCode(_ctx.stringValue("QueryRmsAlertrulesResponse.ResultCode"));
queryRmsAlertrulesResponse.setResultMessage(_ctx.stringValue("QueryRmsAlertrulesResponse.ResultMessage"));
Response response = new Response();
Meta meta = new Meta();
Page page = new Page();
page.setLimit(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Meta.Page.Limit"));
page.setOffset(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Meta.Page.Offset"));
page.setTotalSize(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Meta.Page.TotalSize"));
meta.setPage(page);
response.setMeta(meta);
List<EntitiesItem> entities = new ArrayList<EntitiesItem>();
for (int i = 0; i < _ctx.lengthValue("QueryRmsAlertrulesResponse.Response.Entities.Length"); i++) {
EntitiesItem entitiesItem = new EntitiesItem();
entitiesItem.setLayer(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Layer"));
Entity entity = new Entity();
entity.setAlertLevel(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertLevel"));
entity.setAlertShutEndDateTime(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertShutEndDateTime"));
entity.setAlertShutReason(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertShutReason"));
entity.setAlertShutStartDateTime(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertShutStartDateTime"));
entity.setAlertValidEndTime(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertValidEndTime"));
entity.setAlertValidStartTime(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.AlertValidStartTime"));
entity.setEnabled(_ctx.booleanValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Enabled"));
entity.setId(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Id"));
entity.setRuleType(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.RuleType"));
entity.setSilencePeriodMinute(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.SilencePeriodMinute"));
entity.setState(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.State"));
entity.setUtcCreated(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.UtcCreated"));
entity.setUtcModified(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.UtcModified"));
Definition definition = new Definition();
definition.setMonitorItemType(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.MonitorItemType"));
definition.setMonitorOptionKey(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.MonitorOptionKey"));
definition.setMonitorPort(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.MonitorPort"));
definition.setStatisticalMethod(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.StatisticalMethod"));
definition.setStatisticalPeriod(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.StatisticalPeriod"));
definition.setTriggerCountThreshold(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.TriggerCountThreshold"));
definition.setTriggerOperator(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.TriggerOperator"));
definition.setTriggerValueThreshold(_ctx.longValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.Definition.TriggerValueThreshold"));
entity.setDefinition(definition);
MonitorTarget monitorTarget = new MonitorTarget();
monitorTarget.setMonitorTargetId(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.MonitorTarget.MonitorTargetId"));
monitorTarget.setMonitorTargetName(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.MonitorTarget.MonitorTargetName"));
monitorTarget.setMonitorTargetType(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.MonitorTarget.MonitorTargetType"));
monitorTarget.setTenantId(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.MonitorTarget.TenantId"));
monitorTarget.setWorkspaceId(_ctx.stringValue("QueryRmsAlertrulesResponse.Response.Entities["+ i +"].Entity.MonitorTarget.WorkspaceId"));
entity.setMonitorTarget(monitorTarget);
entitiesItem.setEntity(entity);
entities.add(entitiesItem);
}
response.setEntities(entities);
queryRmsAlertrulesResponse.setResponse(response);
return queryRmsAlertrulesResponse;
}
} | [
"[email protected]"
] | |
890f6c0e205587122ec9d0ca2c487cf3606052ab | e10236f06968808aba67e7117cd6c0d2bc3122bf | /Test2/module1/src/com/xunhuai01/test/Start.java | 0301ecccb5d258fc0344f34282f5635740801e6f | [] | no_license | bingup/Test3 | d02f17ac06cab8fbd74b223872fedd41952641b4 | 5c2fe16f840f24547e472ef89c9d73a0b487c415 | refs/heads/master | 2022-12-07T09:39:31.807204 | 2020-08-27T09:55:08 | 2020-08-27T09:55:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 464 | java | package com.xunhuai01.test;
public class Start {
private String name;
private String sex;
private String content;
public Start(String name, String sex, String content) {
this.name = name;
this.sex = sex;
this.content = content;
}
public void Sing(){
System.out.println(name+"明星唱歌需要100元");
}
public void show(){
System.out.println(name+"明星演戏需要200元");
}
}
| [
"[email protected]"
] | |
8f79a8c2cf5689e4188abc46baeb0112a54e542e | 1be9ce03b27c09183497bf6e7cbea013cbcb0cc5 | /src/main/java/com/universign/universigncs/connector/aop/logging/LoggingAspect.java | fd12d00d1bb1491818efa9ba1d27bcb3db45afe5 | [] | no_license | EricLamore/connector-360 | 6cb00e8aaebbbddfbc658ab6bd99dd7575a5b118 | 9b4e2e1e792eaa58559b97406218f7423740cbf3 | refs/heads/master | 2020-06-26T11:41:45.978864 | 2019-07-30T09:40:59 | 2019-07-30T09:40:59 | 199,622,196 | 0 | 0 | null | 2019-10-30T04:42:50 | 2019-07-30T09:40:44 | Java | UTF-8 | Java | false | false | 3,970 | java | package com.universign.universigncs.connector.aop.logging;
import io.github.jhipster.config.JHipsterConstants;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import java.util.Arrays;
/**
* Aspect for logging execution of service and repository Spring components.
*
* By default, it only runs with the "dev" profile.
*/
@Aspect
public class LoggingAspect {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final Environment env;
public LoggingAspect(Environment env) {
this.env = env;
}
/**
* Pointcut that matches all repositories, services and Web REST endpoints.
*/
@Pointcut("within(@org.springframework.stereotype.Repository *)" +
" || within(@org.springframework.stereotype.Service *)" +
" || within(@org.springframework.web.bind.annotation.RestController *)")
public void springBeanPointcut() {
// Method is empty as this is just a Pointcut, the implementations are in the advices.
}
/**
* Pointcut that matches all Spring beans in the application's main packages.
*/
@Pointcut("within(com.universign.universigncs.connector.repository..*)"+
" || within(com.universign.universigncs.connector.service..*)"+
" || within(com.universign.universigncs.connector.web.rest..*)")
public void applicationPackagePointcut() {
// Method is empty as this is just a Pointcut, the implementations are in the advices.
}
/**
* Advice that logs methods throwing exceptions.
*
* @param joinPoint join point for advice.
* @param e exception.
*/
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);
} else {
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
}
}
/**
* Advice that logs when a method is entered and exited.
*
* @param joinPoint join point for advice.
* @return result.
* @throws Throwable throws {@link IllegalArgumentException}.
*/
@Around("applicationPackagePointcut() && springBeanPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
if (log.isDebugEnabled()) {
log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
}
try {
Object result = joinPoint.proceed();
if (log.isDebugEnabled()) {
log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), result);
}
return result;
} catch (IllegalArgumentException e) {
log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()),
joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
throw e;
}
}
}
| [
"[email protected]"
] | |
9a53244eda4c00300effedfdfed76d5510a65d5d | cec0c2fa585c3f788fc8becf24365e56bce94368 | /net/minecraft/world/entity/ai/behavior/YieldJobSite.java | e9bdb377bd0645a75a5e3be5685a489f3c3d4b96 | [] | no_license | maksym-pasichnyk/Server-1.16.3-Remapped | 358f3c4816cbf41e137947329389edf24e9c6910 | 4d992e2d9d4ada3ecf7cecc039c4aa0083bc461e | refs/heads/master | 2022-12-15T08:54:21.236174 | 2020-09-19T16:13:43 | 2020-09-19T16:13:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,727 | java | /* */ package net.minecraft.world.entity.ai.behavior;
/* */
/* */ import com.google.common.collect.ImmutableMap;
/* */ import java.util.Map;
/* */ import java.util.Optional;
/* */ import net.minecraft.core.BlockPos;
/* */ import net.minecraft.core.GlobalPos;
/* */ import net.minecraft.network.protocol.game.DebugPackets;
/* */ import net.minecraft.server.level.ServerLevel;
/* */ import net.minecraft.world.entity.LivingEntity;
/* */ import net.minecraft.world.entity.ai.memory.MemoryModuleType;
/* */ import net.minecraft.world.entity.ai.memory.MemoryStatus;
/* */ import net.minecraft.world.entity.ai.village.poi.PoiType;
/* */ import net.minecraft.world.entity.npc.Villager;
/* */ import net.minecraft.world.entity.npc.VillagerProfession;
/* */ import net.minecraft.world.level.pathfinder.Path;
/* */
/* */
/* */ public class YieldJobSite
/* */ extends Behavior<Villager>
/* */ {
/* */ private final float speedModifier;
/* */
/* */ public YieldJobSite(float debug1) {
/* 25 */ super((Map<MemoryModuleType<?>, MemoryStatus>)ImmutableMap.of(MemoryModuleType.POTENTIAL_JOB_SITE, MemoryStatus.VALUE_PRESENT, MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LIVING_ENTITIES, MemoryStatus.VALUE_PRESENT));
/* */
/* */
/* */
/* */
/* 30 */ this.speedModifier = debug1;
/* */ }
/* */
/* */
/* */ protected boolean checkExtraStartConditions(ServerLevel debug1, Villager debug2) {
/* 35 */ if (debug2.isBaby()) {
/* 36 */ return false;
/* */ }
/* */
/* 39 */ return (debug2.getVillagerData().getProfession() == VillagerProfession.NONE);
/* */ }
/* */
/* */
/* */ protected void start(ServerLevel debug1, Villager debug2, long debug3) {
/* 44 */ BlockPos debug5 = ((GlobalPos)debug2.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get()).pos();
/* */
/* 46 */ Optional<PoiType> debug6 = debug1.getPoiManager().getType(debug5);
/* 47 */ if (!debug6.isPresent()) {
/* */ return;
/* */ }
/* */
/* 51 */ BehaviorUtils.getNearbyVillagersWithCondition(debug2, debug3 -> nearbyWantsJobsite(debug1.get(), debug3, debug2))
/* 52 */ .findFirst()
/* 53 */ .ifPresent(debug4 -> yieldJobSite(debug1, debug2, debug4, debug3, debug4.getBrain().getMemory(MemoryModuleType.JOB_SITE).isPresent()));
/* */ }
/* */
/* */
/* */ private boolean nearbyWantsJobsite(PoiType debug1, Villager debug2, BlockPos debug3) {
/* 58 */ boolean debug4 = debug2.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).isPresent();
/* 59 */ if (debug4) {
/* 60 */ return false;
/* */ }
/* */
/* 63 */ Optional<GlobalPos> debug5 = debug2.getBrain().getMemory(MemoryModuleType.JOB_SITE);
/* 64 */ VillagerProfession debug6 = debug2.getVillagerData().getProfession();
/* */
/* */
/* 67 */ if (debug2.getVillagerData().getProfession() != VillagerProfession.NONE && debug6.getJobPoiType().getPredicate().test(debug1)) {
/* 68 */ if (!debug5.isPresent()) {
/* 69 */ return canReachPos(debug2, debug3, debug1);
/* */ }
/* 71 */ return ((GlobalPos)debug5.get()).pos().equals(debug3);
/* */ }
/* 73 */ return false;
/* */ }
/* */
/* */ private void yieldJobSite(ServerLevel debug1, Villager debug2, Villager debug3, BlockPos debug4, boolean debug5) {
/* 77 */ eraseMemories(debug2);
/* */
/* 79 */ if (!debug5) {
/* 80 */ BehaviorUtils.setWalkAndLookTargetMemories((LivingEntity)debug3, debug4, this.speedModifier, 1);
/* 81 */ debug3.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(debug1.dimension(), debug4));
/* 82 */ DebugPackets.sendPoiTicketCountPacket(debug1, debug4);
/* */ }
/* */ }
/* */
/* */ private boolean canReachPos(Villager debug1, BlockPos debug2, PoiType debug3) {
/* 87 */ Path debug4 = debug1.getNavigation().createPath(debug2, debug3.getValidRange());
/* 88 */ return (debug4 != null && debug4.canReach());
/* */ }
/* */
/* */ private void eraseMemories(Villager debug1) {
/* 92 */ debug1.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET);
/* 93 */ debug1.getBrain().eraseMemory(MemoryModuleType.LOOK_TARGET);
/* 94 */ debug1.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
/* */ }
/* */ }
/* Location: C:\Users\Josep\Downloads\Decompile Minecraft\deobfuscated.jar!\net\minecraft\world\entity\ai\behavior\YieldJobSite.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/ | [
"[email protected]"
] | |
91c521d5ffd1205a1ad225c598ecb3eeacba47f9 | 5fd63ede3a95609e9abc674bbc05236eadb55603 | /jackpot-core/src/main/java/jackpot/mapper/Mapper.java | ba8acc9655c047c1fc3e7dcd2881c45cc88b82af | [] | no_license | shalecraig/jackpot | 9594472608aef0f038a3101016d7afd297323091 | 268fe03406ea6b3c21ecf5a5e32c045b88b787b3 | refs/heads/master | 2016-09-05T22:11:54.383918 | 2014-10-27T01:46:08 | 2014-10-27T02:35:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 190 | java | package jackpot.mapper;
import java.util.Collection;
public interface Mapper<IN, OUT> {
OUT map(IN in);
OUT[] mapMany(IN[] in);
Collection<OUT> mapMany(Collection<IN> in);
}
| [
"[email protected]"
] | |
a4b9004dd60c5582217db45801920f8d220d4b9d | 5ed068b52f11151fcebe1de131c91541c95ec572 | /src/main/java/org/erpmicroservices/human_resources/endpoint/rest/model/TerminationType.java | 859617105673be1b48df0079f6dc7659bdcaec68 | [] | no_license | ErpMicroServices/human_resources-endpoint-rest | d50868af2a53353c90f2aa487139d4d0d363f97b | 7c00c2bf2cd47b9a0b4198c7cb153f3440f2d1ad | refs/heads/master | 2023-03-14T16:26:34.451534 | 2021-03-29T18:38:07 | 2021-03-29T18:38:07 | 320,842,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 618 | java | package org.erpmicroservices.human_resources.endpoint.rest.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.data.jpa.domain.AbstractPersistable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@Entity
@Data
@ToString
@EqualsAndHashCode(callSuper = true)
public class TerminationType extends AbstractPersistable<UUID> {
@NotBlank
@NotNull
private String description;
@ManyToOne
private TerminationType parent;
}
| [
"[email protected]"
] | |
bad95d9605846e26f9337d3c181dc7a1bc8b5037 | ac351f4124febe2ff50020366ac39c819b7c67e6 | /app/src/androidTest/java/br/com/mtusjt/ciclodevida/ExampleInstrumentedTest.java | 833242c3ff8cb59f00eb5ac090de7803bd639ff0 | [] | no_license | MuriloDeAraujo10/Aula02 | 1f4714419af112498cfc5e4253405e730f823683 | 70fa512388e0b626454a2fbf8cd7402fc0718a9e | refs/heads/master | 2020-03-30T08:49:31.160895 | 2018-10-01T01:13:55 | 2018-10-01T01:13:55 | 150,989,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 751 | java | package br.com.mtusjt.ciclodevida;
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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("br.com.mtusjt.ciclodevida", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
b6cadeda9cc5dc24ba4910da65b530308a54832f | ff9c4633d46346a8b0d02551233f46e0de192fb6 | /java/com/l2jserver/gameserver/CheckDynamicIpAddressTask.java | e646ffb92889c4066dec6a5e21fc952c12a83af1 | [] | no_license | UchihaSV/l2j-sfjp | 98c7cde38a10f7da8547df2f0fb0c3e69b4861fc | 695769ffc6bb3c5dc550dcee1a1b11df8b53028a | refs/heads/master | 2020-04-17T02:07:28.604636 | 2015-04-07T12:44:12 | 2015-04-07T12:44:12 | 166,121,212 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,032 | java | //@formatter:off
package com.l2jserver.gameserver;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.l2jserver.Config;
import com.l2jserver.Config.IPConfigData;
/*
* @auther JOJO
*/
public class CheckDynamicIpAddressTask implements Runnable
{
private static final Logger _log = Logger.getLogger(CheckDynamicIpAddressTask.class.getName());
// Configuration
static final long CHECK_DYNAMIC_IP_ADDRESS_INITIAL = 1800_000L;
static final long CHECK_DYNAMIC_IP_ADDRESS_DELAY = 900_000L;
private static String[] WHAT_IS_MY_IP_URL = {
// "http://api.externalip.net/ip/", // "Website suspended. This website has been suspended as of March 1st 2014."
"http://bot.whatismyipaddress.com",
"http://checkip.dyndns.com/",
"http://checkip.dyndns.org/",
"http://checkmyip.com/",
"http://ip1.dynupdate.no-ip.com:8245/",
"http://ipaddress.com/",
"http://ipecho.net/plain",
"http://myip.dnsomatic.com",
"http://myip.is/",
"http://myip.nt0.biz/",
"http://taruo.net/ip/?",
"http://whatismyipaddress.com/ip-lookup",
"http://whatsmyip.net/",
"http://www.akakagemaru.info/cgi-bin/index.cgi",
"http://www.canyouseeme.org/",
"http://www.cybersyndrome.net/evc.html",
"http://www.findmyipaddress.com/",
"http://www.howtofindmyipaddress.com/",
"http://www.ipchicken.com/",
"http://www.iprivacytools.com/my-ip-address/",
"http://www.my-ip-address.net/",
"http://www.show-ip-addr.com/en/",
"http://www.showmyip.gr/",
"http://www.tracemyip.org/",
"http://www.whereisip.net/",
// "http://www.ugtop.com/spill.shtml",
};
public static boolean isAutoIpConfig;
private static int _index = -1;
private static ScheduledFuture<?> _checkDynamicIpAddressTask;
@Override
public void run()
{
if (com.l2jserver.Config.CHECK_DYNAMIC_IP_ADDRESS_TASK) {{
if (LoginServerThread.getInstance().getServerName() == null)
return;
String ip = whatIsMyIp();
if (ip != null) {
if (ip.equals(IPConfigData.externalIp)) {
_log.fine("Network Config: Current external IP address is '" + ip + "'");
}
else CHANGE: {
_log.warning("Network Config: External IP address was changed '" + ip + "' from '" + IPConfigData.externalIp + "'. Trying to reconnect the Login Server.");
List<String> hosts = Config.GAME_SERVER_HOSTS;
List<String> subnets = Config.GAME_SERVER_SUBNETS;
for (int i = hosts.size(); --i >= 0;) {
if (hosts.get(i).equals(IPConfigData.externalIp) && subnets.get(i).equals("0.0.0.0/0")) {
hosts.set(i, ip);
IPConfigData.externalIp = ip;
System.out.println(toIpConfigXml());
LoginServerThread.getInstance().disconnect();
break CHANGE;
}
}
}
}
}}
}
private String whatIsMyIp()
{
if (com.l2jserver.Config.CHECK_DYNAMIC_IP_ADDRESS_TASK) {{
_index = (_index + 1) % WHAT_IS_MY_IP_URL.length;
String url = WHAT_IS_MY_IP_URL[_index];
_log.info("Network Config: Check external IP address from '" + url + "'");
try {
URL autoIp = new URL(url);
try (BufferedReader in = new BufferedReader(new InputStreamReader(autoIp.openStream()))) {
final Pattern pattern = Pattern.compile("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)");
String temp;
while ((temp = in.readLine()) != null) {
Matcher match = pattern.matcher(temp);
while (match.find())
return match.group();
}
}
catch (IOException e) {
_log.warning("<!>Network Config: " + e.getMessage());
}
}
catch (MalformedURLException e) {
_log.log(Level.WARNING, "", e);
}
}}
return null;
}
public static String toIpConfigXml()
{
final String T = "\t|"; // indent
StringBuilder a = new StringBuilder(), b = new StringBuilder();
List<String> hosts = Config.GAME_SERVER_HOSTS;
List<String> subnets = Config.GAME_SERVER_SUBNETS;
for (int i = 0; i < hosts.size(); ++i) {
String subnet = subnets.get(i), host = hosts.get(i);
if (subnet.equals("0.0.0.0/0"))
a.append(T + "<gameserver address=\"").append(host).append("\">\n");
else
b.append(T + "\t<define subnet=\"").append(subnet).append(" address=\"").append(host).append("\" />\n");
}
return a.append(b).append(T + "</gameserver>").toString();
}
public static void start()
{
if (com.l2jserver.Config.CHECK_DYNAMIC_IP_ADDRESS_TASK) {{
if (isAutoIpConfig)
if (_checkDynamicIpAddressTask == null)
_checkDynamicIpAddressTask = ThreadPoolManager.getInstance().scheduleGeneralWithFixedDelay(
new CheckDynamicIpAddressTask()
, CHECK_DYNAMIC_IP_ADDRESS_INITIAL
, CHECK_DYNAMIC_IP_ADDRESS_DELAY);
}}
}
}
| [
"torikawatukune@7d3f705e-0b0b-4019-9fd5-072e50595f16"
] | torikawatukune@7d3f705e-0b0b-4019-9fd5-072e50595f16 |
5208c67fffe95b892bb8012667bfbfeb5f97751e | 6addc7d9de291fb02cbdcd3d8052cc82663402e3 | /library/src/main/java/com/ytjojo/shadowlayout/shadowdelegate/PathModel.java | d16569690b178b302c31337dd4d4817edf0f16b3 | [
"Apache-2.0",
"MIT"
] | permissive | everyoung09/ShadowLayout | 1753a37e9fd4719625aed7cf9b7f002904c8c60c | e6401eb25a914c4cb6a9f65cf8a31a0e49a96a2f | refs/heads/master | 2020-03-07T17:21:51.757268 | 2018-03-18T14:17:32 | 2018-03-18T14:17:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,905 | java | package com.ytjojo.shadowlayout.shadowdelegate;
import android.content.res.TypedArray;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.view.View;
import com.ytjojo.shadowlayout.R;
import com.ytjojo.shadowlayout.ShadowLayout;
/**
* Created by Administrator on 2017/11/4 0004.
*/
public class PathModel implements ShadowDelegate {
private final static float MIN_RADIUS = 0.1F;
Path mPath;
Path mClipPath;
Path mShadowpath;
Paint mPaint;
ShadowLayout mParent;
float mShadowRadius;
private float mOffsetDy;
private float mOffsetDx;
private Point mControlPoint1;
private Point mControlPoint2;
private int mEndRightY;
private int mStartLeftY;
private float mCoordinatex1;
private float mCoordinatey1;
private float mCoordinatex2;
private float mCoordinatey2;
private float mRatgStartLeftY;
private float mRateEndRightY;
Rect mBoundsRect;
public PathModel(ShadowLayout parent, TypedArray typedArray) {
mParent = parent;
mBoundsRect = new Rect();
mParent.setWillNotDraw(false);
mParent.setClipToPadding(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
mPath = new Path();
mClipPath = new Path();
mShadowpath = new Path();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setDither(true);
mPaint.setStyle(Paint.Style.FILL);
setShadowColor(
typedArray.getColor(
R.styleable.ShadowLayout_sl_shadow_color, Color.BLACK
)
);
setShadowRadius(
typedArray.getDimension(
R.styleable.ShadowLayout_sl_shadow_radius, 25
)
);
mOffsetDx = typedArray.getDimensionPixelSize(
R.styleable.ShadowLayout_sl_shadow_offsetdx, 0
);
mOffsetDy = typedArray.getDimensionPixelSize(
R.styleable.ShadowLayout_sl_shadow_offsetdy, 0
);
mCoordinatex1 = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_coordinatex1,0f);
mCoordinatey1 = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_coordinatey1,1f);
mCoordinatex2 = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_coordinatex2,1f);
mCoordinatey2 = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_coordinatey2,1f);
mRatgStartLeftY = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_startleft_y_rate,0.6f);
mRateEndRightY = typedArray.getFloat(R.styleable.ShadowLayout_shadow_path_endright_y_rate,0.6f);
}
@Override
public void onDraw(Canvas canvas) {
mParent.superdispatchDraw(canvas);
}
@Override
public void onDrawOver(Canvas canvas) {
canvas.save();
// if(Build.VERSION.SDK_INT>=19){
// canvas.clipPath(mPath);
// }else{
// canvas.clipPath(mPath, Region.Op.REPLACE);
// canvas.clipPath(mClipPath, Region.Op.DIFFERENCE);
// }
canvas.clipPath(mPath, Region.Op.REPLACE);
canvas.clipPath(mClipPath, Region.Op.DIFFERENCE);
mPaint.setColor(Color.BLACK);
mShadowpath.set(mClipPath);
mShadowpath.offset(mOffsetDx, mOffsetDy);
canvas.drawPath(mShadowpath, mPaint);
canvas.restore();
}
@Override
public boolean onClipCanvas(Canvas canvas, View child) {
canvas.clipPath(mClipPath);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
child.invalidateOutline();
}
return false;
}
@Override
public void invalidateShadow() {
mParent.postInvalidate();
}
@Override
public void setShadowColor(@ColorInt int color) {
mPaint.setColor(color);
mParent.postInvalidate();
}
@Override
public void onLayout(boolean changed, int left, int top, int right, int bottom) {
mBoundsRect.set(left,top,right,bottom);
mPath.reset();
mShadowpath.reset();
mPath.lineTo(left, top);
mPath.lineTo(right, top);
mPath.lineTo(right, bottom);
mPath.lineTo(left, bottom);
mPath.lineTo(left, top);
if(!useCustom){
mClipPath.reset();
int width = right - left;
int height = bottom - top;
if(mControlPoint1==null){
mControlPoint1 = new Point();
}
if(mControlPoint2==null){
mControlPoint2 = new Point();
}
mControlPoint1.set((int)(mCoordinatex1*width+left),(int)(mCoordinatey1*height+top));
mControlPoint2.set((int)(mCoordinatex2*width+left),(int)(mCoordinatey2*height+top));
mStartLeftY = (int) (mRatgStartLeftY*height+top);
mEndRightY = (int) (mRateEndRightY*height+top);
mClipPath.moveTo(left, top);
mClipPath.lineTo(left, mStartLeftY);
mClipPath.cubicTo(mControlPoint1.x, mControlPoint1.y, mControlPoint2.x, mControlPoint2.y, right,mEndRightY);
mClipPath.lineTo(right, top);
mClipPath.lineTo(left, top);
// if(Build.VERSION.SDK_INT>=19){
// mPath.op(mClipPath, Path.Op.DIFFERENCE);
// }
}
}
public void changeClipPath(){
mClipPath.reset();
if(mBoundsRect.isEmpty()){
return;
}
if(mControlPoint1==null){
mControlPoint1 = new Point();
}
if(mControlPoint2==null){
mControlPoint2 = new Point();
}
mControlPoint1.set((int)(mCoordinatex1*mBoundsRect.width()+mBoundsRect.left),(int)(mCoordinatey1*mBoundsRect.height()+mBoundsRect.top));
mControlPoint2.set((int)(mCoordinatex2*mBoundsRect.width()+mBoundsRect.left),(int)(mCoordinatey2*mBoundsRect.height()+mBoundsRect.top));
mStartLeftY = (int) (mRatgStartLeftY*mBoundsRect.height()+mBoundsRect.top);
mEndRightY = (int) (mRateEndRightY*mBoundsRect.height()+mBoundsRect.top);
mClipPath.moveTo(mBoundsRect.left, mBoundsRect.top);
mClipPath.lineTo(mBoundsRect.left, mStartLeftY);
mClipPath.cubicTo(mControlPoint1.x, mControlPoint1.y, mControlPoint2.x, mControlPoint2.y, mBoundsRect.right,mEndRightY);
mClipPath.lineTo(mBoundsRect.right, mBoundsRect.top);
mClipPath.lineTo(mBoundsRect.left, mBoundsRect.top);
invalidateShadow();
}
@Override
public void onAttachToWindow() {
}
@Override
public void onDetachedFromWindow() {
}
public void setShadowRadius(final float shadowRadius) {
mShadowRadius = Math.max(MIN_RADIUS, shadowRadius);
if (mParent.isInEditMode()) return;
// Set blur filter to paint
mPaint.setMaskFilter(new BlurMaskFilter(mShadowRadius, BlurMaskFilter.Blur.NORMAL));
invalidateShadow();
}
private boolean useCustom;
public void setPath(Path path){
useCustom = true;
this.mClipPath = path;
invalidateShadow();
}
public void setControlPoint1(float xRate,float yRate){
this.mCoordinatex1 =xRate;
this.mCoordinatey1 =yRate;
}
public void setControlPoint2(float xRate,float yRate){
this.mCoordinatex2 =xRate;
this.mCoordinatey2 =yRate;
}
public void setRatgStartLeftY(int ratgStartLeftY) {
this.mRatgStartLeftY = ratgStartLeftY;
}
public void setRateEndRightY(int rateEndRightY) {
this.mRateEndRightY = rateEndRightY;
}
}
| [
"[email protected]"
] | |
5491503b6acc1b82e30a58929796e9d938b2fe08 | fb10774d7a7adb669fb95064fde48051d8496e11 | /source/openapi-sdk-message-1.3.4.20170608-sources/com/yiji/openapi/message/mpay/sdk/MpayIDCardOcrResponse.java | 7ecff46877d827251326b377d6b9962598e863f2 | [] | no_license | jtyjty99999/yiji-nodejs | 9297339138df66590d02b637c76a62e54f0747ca | 0e3e2e66f89bcc2f6de7466b1adf892b2d903d09 | refs/heads/master | 2021-01-22T22:35:31.766945 | 2017-06-25T15:16:36 | 2017-06-25T15:16:36 | 85,558,620 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,961 | java | package com.yiji.openapi.message.mpay.sdk;
import org.hibernate.validator.constraints.NotBlank;
import com.yiji.openapi.sdk.common.annotation.OpenApiField;
import com.yiji.openapi.sdk.common.annotation.OpenApiMessage;
import com.yiji.openapi.sdk.common.enums.ApiMessageType;
import com.yiji.openapi.sdk.common.message.ApiResponse;
/**
* Created by [email protected] on 2016/7/14.
*/
@OpenApiMessage(service = "mpayIDCardOcr", type = ApiMessageType.Response)
public class MpayIDCardOcrResponse extends ApiResponse {
/**
* 身份证号
*/
@NotBlank
@OpenApiField(desc = "身份证号",demo = "5242556784893548147",security = true)
private String certNo;
/**
* 真实姓名
*/
@NotBlank
@OpenApiField(desc = "真实姓名",demo = "张三",security = true)
private String realName;
/**
* 证件有效期
*/
@NotBlank
@OpenApiField(desc = "证件有效期",demo = "2020-12-12",constraint = "如果有效期是长期,则返回“长期”",security = true)
private String licenseValidTime;
/**
* 地址
*/
@NotBlank
@OpenApiField(desc = "地址",demo = "重庆市渝北区黄山大道中段",security = true)
private String address;
public String getCertNo() {
return certNo;
}
public void setCertNo(String certNo) {
this.certNo = certNo;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getLicenseValidTime() {
return licenseValidTime;
}
public void setLicenseValidTime(String licenseValidTime) {
this.licenseValidTime = licenseValidTime;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
| [
"[email protected]"
] | |
b3268940993920fba8592cd9affe266ed823cc15 | 0ac16e9d2c3fd9520208c5aff915b95e52991a03 | /ReportCabinet/src/main/java/com/reportcabinet/dao/ReportCabinetDao.java | 32992d8550a617f39d309aad15445bd5c036e0ea | [] | no_license | heq99/report | 460e8b2e2562eb8f13c2a13c3313eae0f08dd799 | 83fe5105f5814f1967277483a895653231289d5d | refs/heads/master | 2016-09-05T14:08:27.790122 | 2014-01-27T23:41:33 | 2014-01-27T23:41:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 160 | java | package com.reportcabinet.dao;
import com.reportcabinet.domainobjects.ReportCabinet;
public interface ReportCabinetDao extends GenericDao<ReportCabinet> {
}
| [
"[email protected]"
] | |
42a9482babc484b35bfbcd09a4dea99a74181850 | ab596ed989572d8a9d77349f2d7bb7c0cde8c9e3 | /src/main/java/com/luulsolutions/luulpos/web/rest/DiscountResource.java | df97903f15d5dc96ed784b1408716699e7ed0c62 | [
"Apache-2.0"
] | permissive | wassimz/luulpos_backend | 522b0eb7583aef6f688ab1b5671f1c76b8440a7f | f6a6ad528fe48e4e3292e1e337a58c5068644258 | refs/heads/master | 2020-04-15T19:26:04.062839 | 2018-12-30T14:44:11 | 2018-12-30T14:44:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,103 | java | package com.luulsolutions.luulpos.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.luulsolutions.luulpos.service.DiscountService;
import com.luulsolutions.luulpos.web.rest.errors.BadRequestAlertException;
import com.luulsolutions.luulpos.web.rest.util.HeaderUtil;
import com.luulsolutions.luulpos.web.rest.util.PaginationUtil;
import com.luulsolutions.luulpos.service.dto.DiscountDTO;
import com.luulsolutions.luulpos.service.dto.DiscountCriteria;
import com.luulsolutions.luulpos.service.DiscountQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import java.util.stream.StreamSupport;
import static org.elasticsearch.index.query.QueryBuilders.*;
/**
* REST controller for managing Discount.
*/
@RestController
@RequestMapping("/api")
public class DiscountResource {
private final Logger log = LoggerFactory.getLogger(DiscountResource.class);
private static final String ENTITY_NAME = "discount";
private final DiscountService discountService;
private final DiscountQueryService discountQueryService;
public DiscountResource(DiscountService discountService, DiscountQueryService discountQueryService) {
this.discountService = discountService;
this.discountQueryService = discountQueryService;
}
/**
* POST /discounts : Create a new discount.
*
* @param discountDTO the discountDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new discountDTO, or with status 400 (Bad Request) if the discount has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/discounts")
@Timed
public ResponseEntity<DiscountDTO> createDiscount(@Valid @RequestBody DiscountDTO discountDTO) throws URISyntaxException {
log.debug("REST request to save Discount : {}", discountDTO);
if (discountDTO.getId() != null) {
throw new BadRequestAlertException("A new discount cannot already have an ID", ENTITY_NAME, "idexists");
}
DiscountDTO result = discountService.save(discountDTO);
return ResponseEntity.created(new URI("/api/discounts/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /discounts : Updates an existing discount.
*
* @param discountDTO the discountDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated discountDTO,
* or with status 400 (Bad Request) if the discountDTO is not valid,
* or with status 500 (Internal Server Error) if the discountDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/discounts")
@Timed
public ResponseEntity<DiscountDTO> updateDiscount(@Valid @RequestBody DiscountDTO discountDTO) throws URISyntaxException {
log.debug("REST request to update Discount : {}", discountDTO);
if (discountDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
DiscountDTO result = discountService.save(discountDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, discountDTO.getId().toString()))
.body(result);
}
/**
* GET /discounts : get all the discounts.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of discounts in body
*/
@GetMapping("/discounts")
@Timed
public ResponseEntity<List<DiscountDTO>> getAllDiscounts(DiscountCriteria criteria, Pageable pageable) {
log.debug("REST request to get Discounts by criteria: {}", criteria);
Page<DiscountDTO> page = discountQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/discounts");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /discounts/count : count all the discounts.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/discounts/count")
@Timed
public ResponseEntity<Long> countDiscounts(DiscountCriteria criteria) {
log.debug("REST request to count Discounts by criteria: {}", criteria);
return ResponseEntity.ok().body(discountQueryService.countByCriteria(criteria));
}
/**
* GET /discounts/:id : get the "id" discount.
*
* @param id the id of the discountDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the discountDTO, or with status 404 (Not Found)
*/
@GetMapping("/discounts/{id}")
@Timed
public ResponseEntity<DiscountDTO> getDiscount(@PathVariable Long id) {
log.debug("REST request to get Discount : {}", id);
Optional<DiscountDTO> discountDTO = discountService.findOne(id);
return ResponseUtil.wrapOrNotFound(discountDTO);
}
/**
* DELETE /discounts/:id : delete the "id" discount.
*
* @param id the id of the discountDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/discounts/{id}")
@Timed
public ResponseEntity<Void> deleteDiscount(@PathVariable Long id) {
log.debug("REST request to delete Discount : {}", id);
discountService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
/**
* SEARCH /_search/discounts?query=:query : search for the discount corresponding
* to the query.
*
* @param query the query of the discount search
* @param pageable the pagination information
* @return the result of the search
*/
@GetMapping("/_search/discounts")
@Timed
public ResponseEntity<List<DiscountDTO>> searchDiscounts(@RequestParam String query, Pageable pageable) {
log.debug("REST request to search for a page of Discounts for query {}", query);
Page<DiscountDTO> page = discountService.search(query, pageable);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/discounts");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
}
| [
"[email protected]"
] | |
ec31022bfce3df6ee9f82331678baf60e0ccc540 | da50bd71e4d8b0bba2a630a892e55c7f7bd3a4a9 | /src/main/java/mosaic/bregman/output/ObjectsColoc.java | 3df9d8144363da28d22d459b662c1b60a497bcad | [] | no_license | krzysg/MosaicSuite | 6fcd79076827311e299093e60b6c823775283812 | 474e8a79edadcb11b34913d5e45478d1b4e00fed | refs/heads/master | 2021-07-08T02:03:59.766393 | 2021-04-12T15:04:36 | 2021-04-12T15:04:36 | 98,867,509 | 1 | 1 | null | 2021-04-26T18:13:42 | 2017-07-31T08:41:21 | Java | UTF-8 | Java | false | false | 2,952 | java | package mosaic.bregman.output;
import org.apache.commons.lang3.ArrayUtils;
import org.supercsv.cellprocessor.FmtBool;
import org.supercsv.cellprocessor.ParseDouble;
import org.supercsv.cellprocessor.ParseInt;
import org.supercsv.cellprocessor.ift.CellProcessor;
import mosaic.utils.io.csv.CsvColumnConfig;
public class ObjectsColoc extends ImageBase {
protected static final String[] ObjectsColocMap = ArrayUtils.addAll(ImageBaseMap, new String[] { "Id", "ChannelColoc", "Overlap", "AvgColocObjSize", "AvgColocObjIntensity", "ColocImageIntensity", "SingleColoc" });
protected static final CellProcessor[] ObjectsColocProc = ArrayUtils.addAll(ImageBaseProc, new CellProcessor[] { new ParseInt(), new ParseInt(), new ParseDouble(), new ParseDouble(), new ParseDouble(), new ParseDouble(), new FmtBool("true", "false") });
public static final CsvColumnConfig ColumnConfig = new CsvColumnConfig(ObjectsColocMap, ObjectsColocProc);
protected int id;
protected int channelColoc;
protected double overlap;
protected double avgColocObjSize;
protected double avgColocObjIntensity;
protected double colocImageIntensity;
protected boolean singleColoc;
public ObjectsColoc(String aFileName, int f, int c, int i, int cc, double over, double objsi, double objin, double imint, boolean sc) {
setFilename(aFileName);
setFrame(f);
setChannel(c);
setId(i);
setChannelColoc(cc);
setOverlap(over);
setAvgColocObjSize(objsi);
setAvgColocObjIntensity(objin);
setColocImageIntensity(imint);
setSingleColoc(sc);
}
// Auto generated getters/setters
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getChannelColoc() {
return channelColoc;
}
public void setChannelColoc(int channelColoc) {
this.channelColoc = channelColoc;
}
public double getOverlap() {
return overlap;
}
public void setOverlap(double overlap) {
this.overlap = overlap;
}
public double getAvgColocObjSize() {
return avgColocObjSize;
}
public void setAvgColocObjSize(double avgColocObjSize) {
this.avgColocObjSize = avgColocObjSize;
}
public double getAvgColocObjIntensity() {
return avgColocObjIntensity;
}
public void setAvgColocObjIntensity(double avgColocObjIntensity) {
this.avgColocObjIntensity = avgColocObjIntensity;
}
public double getColocImageIntensity() {
return colocImageIntensity;
}
public void setColocImageIntensity(double colocImageIntensity) {
this.colocImageIntensity = colocImageIntensity;
}
public boolean getSingleColoc() {
return singleColoc;
}
public void setSingleColoc(boolean singleColoc) {
this.singleColoc = singleColoc;
}
}
| [
"[email protected]"
] | |
5b683a858b0dec43323d2d6e83bcfe8738bd7f6b | 27f6a988ec638a1db9a59cf271f24bf8f77b9056 | /Code-Hunt-data/users/User045/Sector1-Level6/attempt014-20140920-120431.java | 243699ad5701b8899eee7711294bfcb4ef53090b | [] | no_license | liiabutler/Refazer | 38eaf72ed876b4cfc5f39153956775f2123eed7f | 991d15e05701a0a8582a41bf4cfb857bf6ef47c3 | refs/heads/master | 2021-07-22T06:44:46.453717 | 2017-10-31T01:43:42 | 2017-10-31T01:43:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java |
public class Program {
public static int Puzzle(String s) {
int count=0;
for(int i=0;i<s.length();i++){
if((i>0 && s.charAt(i)==' ' && s.charAt(i-1)!=' ') || (i==0 && s.charAt(i)==' ' && s.charAt(i+1)!=' ')) count++;
}
if(s.charAt(0)!=' ' && s.charAt(1)!=' ') return count+1;
else return count;
}
} | [
"[email protected]"
] | |
98b1ea62ee9c2e6db00ab7e39d98bf0ad0bb2538 | 6e4978da76071211117a8ecbde208553c26a1087 | /Portal/poll/src/classes.jar/atg/portal/gear/poll/taglib/SetGearPollTEI.java | f344cb264e1d7864ce571c5b7a574e9f3e4786eb | [] | no_license | vkscorpio3/ATG_TASK | 3b41df29898447bb4409bf46bc735045ce7d8cc6 | 8751d555c35a968d4d73c9e22d7f56a6c82192e7 | refs/heads/master | 2020-03-08T16:56:40.463816 | 2014-12-12T10:55:01 | 2014-12-12T10:55:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,798 | java | /*<ATGCOPYRIGHT>
* Copyright (C) 2001-2011 Art Technology Group, Inc.
* All Rights Reserved. No use, copying or distribution of this
* work may be made except in accordance with a valid license
* agreement from Art Technology Group. This notice must be
* included on all copies, modifications and derivatives of this
* work.
*
* Art Technology Group (ATG) MAKES NO REPRESENTATIONS OR WARRANTIES
* ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. ATG SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
* MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
* "Dynamo" is a trademark of Art Technology Group, Inc.
</ATGCOPYRIGHT>*/
package atg.portal.gear.poll.taglib;
import javax.servlet.jsp.tagext.*;
/**
*
*
* @author Jeff Banister
* @version $Id: //app/portal/version/10.0.3/poll/src/atg/portal/gear/poll/taglib/SetGearPollTEI.java#2 $$Change: 651448 $
* @updated $DateTime: 2011/06/07 13:55:45 $$Author: rbarbier $
*/
public class SetGearPollTEI extends TagExtraInfo
{
//-------------------------------------
/** Class version string */
public static String CLASS_VERSION = "$Id: //app/portal/version/10.0.3/poll/src/atg/portal/gear/poll/taglib/SetGearPollTEI.java#2 $$Change: 651448 $";
//-------------------------------------
/**
*
*/
public VariableInfo [] getVariableInfo (TagData pData)
{
return new VariableInfo []
{
new VariableInfo(pData.getId (),
"atg.portal.gear.poll.taglib.SetGearPollTag",
true,
VariableInfo.NESTED)
};
}
} // end of class
| [
"[email protected]"
] | |
a5db84678882ab251fa26f6f56bf2fe9bc6ba9ec | 407ee801fb8f48b027a321a9ea8bbc910978d04a | /05_TaskManager/src/main/model/Message.java | bcbdd6f6b83a5897ce82fc8e35af048e76a1de40 | [] | no_license | ssalom/SWE-Aufgaben | 2e924275302c9f898df33d14203dda7842e608fa | fbd5769b58d0331efeaecb98f558b5480d2c0856 | refs/heads/master | 2023-04-13T17:37:08.642340 | 2021-04-23T17:29:01 | 2021-04-23T17:29:01 | 308,053,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 482 | java | package main.model;
public class Message {
private String key;
private String message;
public Message(String key, String message) {
this.key = key;
this.message = message;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| [
"[email protected]"
] | |
26218b49fcba2e7862dda3b65f51cb8eb9011bca | 66006cfda2ce96ed7608a773adec41b56b6b2a07 | /app/src/main/java/com/watbots/tryapi/ui/ListItemView.java | 29f4dc6b42e2cf38edc512e4af3878780ce8bfe6 | [] | no_license | palrahul/TryApi | d7fbebd701233dc9c5ec3fc11748fdb6083a0a1a | d31e5aeae648296eb92c437212e2b15d5ae668e3 | refs/heads/master | 2020-06-19T04:47:47.799505 | 2018-05-04T17:51:14 | 2018-05-04T17:51:14 | 74,919,685 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,927 | java | package com.watbots.tryapi.ui;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.watbots.tryapi.R;
import com.watbots.tryapi.model.Item;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ListItemView extends RelativeLayout {
@BindView(R.id.item_logo)
ImageView itemLogo;
@BindView(R.id.item_name)
TextView itemName;
@BindView(R.id.item_description)
TextView itemDesc;
@BindView(R.id.yelp_stars)
TextView rating;
@BindView(R.id.status)
TextView status;
private final CircleStrokeTransformation avatarTransformation;
private final int descriptionColor;
public ListItemView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.textColorSecondary, outValue, true);
descriptionColor = outValue.data;
// TODO: Make this a singleton.
avatarTransformation =
new CircleStrokeTransformation(context, ContextCompat.getColor(context, R.color.img_stroke), 1);
}
@Override protected void onFinishInflate() {
super.onFinishInflate();
ButterKnife.bind(this);
}
public void bindTo(Item item, Picasso picasso) {
picasso.load(item.cover_img_url)
.placeholder(R.drawable.doordash_def)
.fit()
//.transform(avatarTransformation)
.into(itemLogo);
itemName.setText(item.name);
rating.setText(String.valueOf(item.yelp_rating));
status.setText(String.valueOf(item.status));
itemDesc.setText(item.description);
}
}
| [
"[email protected]"
] | |
96aab48b41de341ac1dc16e8987f13a3501f8345 | 61d45ecdbf54bd52ad52176c7cf84bf6877d29d5 | /microservices/18-circuit-breaker-pattern/borrow-service/src/main/java/lk/buddhi/managementcloud/borrowservice/model/Response.java | 981f8054e52a54886a5fb88f0b49d9535bac7a33 | [] | no_license | buddinisansala/Krish_SE_Training | 7322fd90df448804e9f0ab66958e51e360fc393b | bf3a12b113365de95651d9dceb59e0af0868bdd2 | refs/heads/main | 2023-03-11T03:34:55.535916 | 2021-02-28T12:48:04 | 2021-02-28T12:48:04 | 329,981,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 86 | java | package lk.buddhi.managementcloud.borrowservice.model;
public interface Response {
}
| [
"[email protected]"
] | |
344cbc9ca86a3ce9730abbe05f01fe8ef1ee2eca | aa5f88f05b79e393399d8957913db17ef02739bf | /src/com/capgemini/collection/test/StudentsMapTest.java | d2bf91002c5286387a143dc6ba204a466000c24d | [] | no_license | mrunaltodkar/collection-assignments | 8412f6fd6636450fb71d8b576af7a11d669757fd | ef207be4047fc8b4af8f3158e7020fbdf40412a0 | refs/heads/master | 2020-04-30T09:18:42.041131 | 2019-03-20T13:49:24 | 2019-03-20T13:49:24 | 176,743,374 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,003 | java | package com.capgemini.collection.test;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import org.junit.BeforeClass;
import org.junit.Test;
import com.capgemini.collection.main.StudentsMap;
public class StudentsMapTest {
private static StudentsMap mrunal;
private static StudentsMap aayush;
private static StudentsMap prangshu;
@BeforeClass
public static void setUp() {
mrunal = new StudentsMap("mrunal", 20);
aayush = new StudentsMap("aayush", 15);
prangshu = new StudentsMap("prangshu", 12);
}
@Test
public void testStudentKeyGivesValueOfFruit() {
HashMap<String, String> hashset = new HashMap<>();
hashset.put(mrunal.getStudentName(), "mango");
hashset.put(aayush.getStudentName(), "orange");
hashset.put(prangshu.getStudentName(), "grape");
assertEquals("mango", hashset.get(mrunal.getStudentName()));
assertEquals("orange", hashset.get(aayush.getStudentName()));
assertEquals("grape", hashset.get(prangshu.getStudentName()));
}
} | [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.