blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2
values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 7 5.41M | extension stringclasses 11
values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f8bc0bb7593c127aeb4263d31ef4e5785ecfee50 | 1869c93d3e8af29202bc479e18957c21eb467d0e | /test/level03/lesson12/home02/Solution.java | a5a47c32d8b0807785f6f84c4351352db0cee216 | [] | no_license | Demonian/JavaRush | 9682e2f85f8bf3b8bbb8b230a6f276589cf937f6 | de75c9f6aba82946dcf4e3c2f680b019c7b2a111 | refs/heads/master | 2020-12-24T16:07:39.104600 | 2016-03-10T14:37:43 | 2016-03-10T14:37:43 | 24,858,101 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 598 | java | package com.javarush.test.level03.lesson12.home02;
/* Я не хочу изучать Java, я хочу большую зарплату
Вывести на экран десять раз надпись «Я не хочу изучать Java, я хочу большую зарплату»
*/
public class Solution
{
public static void main(String[] args)
{
//Напишите тут ваш код
int i;
for( i = 0; i < 10; i++){
System.out.println("Я не хочу изучать Java, я хочу большую зарплату");
}
}
}
| [
"for.reg@ukr.net"
] | for.reg@ukr.net |
caf2c8c6e967b88495dadd8072aba8e8b8585443 | 23ecb5f26687fb071d79839d5613f18054fdb4e9 | /Q22.java | 589cb6f53e21a3f0f6c488eea755a439e1855b66 | [] | no_license | ro-patil/Array | 01950c42ec6b56a78c73914f597f35d69e168605 | 866954d3181ef1188f2d4387395f11065daaff54 | refs/heads/main | 2023-08-15T12:38:06.896863 | 2021-10-09T13:17:10 | 2021-10-09T13:17:10 | 415,313,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 553 | java | package HomeWork;
public class Q22 {
public static void main(String[] args)
{
int [][] a= {{1,2,3},
{1,2,3},
{1,2,3}};
int [][] b= {{1,2,3},
{1,2,3},
{1,2,3}};
int [][] c=new int[a.length][a.length];
for (int i = 0; i < c.length; i++)
{
for (int j = 0; j < c[i].length; j++)
{
c[i][j]=a[i][j]-b[i][j];
}
}
for (int i = 0; i < c.length; i++)
{
for (int j = 0; j < c[i].length; j++)
{
System.out.print(c[i][j]+" ");
}
System.out.println();
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
cd6fd3e566518a0fff38fe79b8db1ce82dc97c69 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/ui/chatting/v$o.java | 69af6c2bb2062aeaa8a91106cd032e9a874360ff | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 494 | java | package com.tencent.mm.ui.chatting;
import com.tencent.mm.storage.cc;
public final class v$o
{
cc hTm;
String hgk;
String nSg;
public v$o(String paramString1, cc paramcc, String paramString2)
{
this.nSg = paramString1;
this.hTm = paramcc;
this.hgk = paramString2;
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes4.jar
* Qualified Name: com.tencent.mm.ui.chatting.v.o
* JD-Core Version: 0.7.0.1
*/ | [
"98632993+tsuzcx@users.noreply.github.com"
] | 98632993+tsuzcx@users.noreply.github.com |
ddf6678e595fd0fc89249bb4c8253b3e2f4bff75 | 82b64e1a541036ae840322a8cd735d32b3885d1b | /src/Presenter/ItemPresenter.java | 04cbe2abed36013fd9468d63f5599093c56b2bdd | [] | no_license | chojnacki-marcin/Console-MVP | d6bd787f724fee3b7dd1a6090fa0d21ad4330374 | 2b2a6345046c1d516b931d6740a48ea7866a5d25 | refs/heads/master | 2020-04-27T14:06:01.665659 | 2019-05-22T18:09:15 | 2019-05-22T18:09:15 | 174,396,369 | 0 | 0 | null | 2019-05-22T18:09:16 | 2019-03-07T18:10:20 | Java | UTF-8 | Java | false | false | 1,289 | java | package Presenter;
import Model.Item;
import DAL.ItemDAO;
import Views.ItemView;
import java.util.Optional;
public class ItemPresenter {
private final ItemDAO itemDAO;
private ItemView itemView;
public ItemPresenter(ItemDAO itemDAO) {
this.itemDAO = itemDAO;
}
public void addItem(String name, long shoppingListId){
Item item = new Item(name, shoppingListId);
if(!itemDAO.add(item)){
itemView.displayCreateErrorMessage();
}
}
public void modifyItem(long itemId, String name) {
Optional<Item> itemOptional = itemDAO.findById(itemId);
if (itemOptional.isPresent()) {
Item item = itemOptional.get();
item.setName(name);
itemDAO.update(item);
} else {
itemView.displayModifyErrorMessage();
}
}
public void deleteItem(long id){
if(!itemDAO.delete(id)){
itemView.displayDeleteErrorMessage();
}
}
public void setItemView(ItemView itemView) {
this.itemView = itemView;
}
public void getItems(long shoppingListId) {
var items = itemDAO.findAllByShoppingListId(shoppingListId);
items.forEach(item -> itemView.displayItem(item.getId(), item.getName()));
}
}
| [
"chojnacki8@gmail.com"
] | chojnacki8@gmail.com |
abbb3b2b2e2681f8617331abe3ce0e0db3ec60b0 | af86ca45a5c0b9b6471ffa51db548f75da8cf128 | /onesignal/src/main/java/com/onesignal/BadgeCountUpdater.java | e8c0fcf7e4fea24c8b62127292cd162ef0721615 | [] | no_license | MHKalantarian/Simple-Ads-Initializer | fb0f2f23ea0cac83ee79ecf80e282e66fbf9bc49 | 5ffe8b9cd7e9ba53084a588016757fc68cba90d6 | refs/heads/master | 2020-05-23T22:27:37.915874 | 2019-05-16T07:19:06 | 2019-05-16T07:19:06 | 186,974,089 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,118 | java | /**
* Modified MIT License
* <p>
* Copyright 2017 OneSignal
* <p>
* 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:
* <p>
* 1. The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 2. All copies of substantial portions of the Software may only be used in connection
* with services provided by OneSignal.
* <p>
* 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.
*/
package com.onesignal;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import com.onesignal.OneSignalDbContract.NotificationTable;
import com.onesignal.shortcutbadger.ShortcutBadger;
import androidx.annotation.RequiresApi;
import static com.onesignal.NotificationLimitManager.MAX_NUMBER_OF_NOTIFICATIONS_STR;
class BadgeCountUpdater {
// Cache for manifest setting.
private static int badgesEnabled = -1;
private static boolean areBadgeSettingsEnabled(Context context) {
if (badgesEnabled != -1)
return (badgesEnabled == 1);
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
if (bundle != null) {
String defaultStr = bundle.getString("com.onesignal.BadgeCount");
badgesEnabled = "DISABLE".equals(defaultStr) ? 0 : 1;
} else
badgesEnabled = 1;
} catch (Throwable t) {
badgesEnabled = 0;
OneSignal.Log(OneSignal.LOG_LEVEL.ERROR, "Error reading meta-data tag 'com.onesignal.BadgeCount'. Disabling badge setting.", t);
}
return (badgesEnabled == 1);
}
private static boolean areBadgesEnabled(Context context) {
return areBadgeSettingsEnabled(context) && OSUtils.areNotificationsEnabled(context);
}
static void update(SQLiteDatabase readableDb, Context context) {
if (!areBadgesEnabled(context))
return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
updateStandard(context);
else
updateFallback(readableDb, context);
}
@RequiresApi(api = Build.VERSION_CODES.M)
private static void updateStandard(Context context) {
NotificationManager notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
StatusBarNotification[] activeNotifs = notifManager.getActiveNotifications();
int runningCount = 0;
for (StatusBarNotification activeNotif : activeNotifs) {
if (NotificationLimitManager.isGroupSummary(activeNotif))
continue;
runningCount++;
}
updateCount(runningCount, context);
}
private static void updateFallback(SQLiteDatabase readableDb, Context context) {
Cursor cursor = readableDb.query(
NotificationTable.TABLE_NAME,
null,
NotificationTable.recentUninteractedWithNotificationsWhere().toString(),
null, // Where args
null, // group by
null, // filter by row groups
null, // sort order, new to old
MAX_NUMBER_OF_NOTIFICATIONS_STR
);
int notificationCount = cursor.getCount();
cursor.close();
updateCount(notificationCount, context);
}
static void updateCount(int count, Context context) {
if (!areBadgeSettingsEnabled(context))
return;
// Can throw if badges are not support on the device.
// Or app does not have a default launch Activity.
try {
ShortcutBadger.applyCountOrThrow(context, count);
} catch (Throwable t) {
}
}
}
| [
"Mhkalantarian@gmail.com"
] | Mhkalantarian@gmail.com |
a40cedbc7d4f233c8ca189158f45044912c4415f | bc7a985f914be1660d25d25938ebd5dae1488de7 | /ChooseYourOwnAdventure_v01/app/src/main/java/com/example/palmdigital/chooseyourownadventure_v01/ToiletActivity.java | b128a5beb8bcd1f0683e862349a750796f02e0c9 | [] | no_license | 91091038/AndroidStudioProjects | 56776d3c6462ce9e52616aa9864719fe2bd99cf6 | 836347b0b6cf2d00cf5b9c423c3169242c452fc2 | refs/heads/master | 2020-03-08T04:58:27.074725 | 2018-06-05T16:47:24 | 2018-06-05T16:47:24 | 127,935,728 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,089 | java | package com.example.palmdigital.chooseyourownadventure_v01;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class ToiletActivity extends AppCompatActivity implements View.OnClickListener {
Button buttonLeftYes;
Button buttonRightHeckYes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_toilet);
buttonLeftYes = findViewById(R.id.buttonLeftYes);
buttonRightHeckYes = findViewById(R.id.buttonRightHeckYes);
buttonLeftYes.setOnClickListener(this);
buttonRightHeckYes.setOnClickListener(this);
}
public void onClick (View view)
{
if(view.getId() == R.id.buttonLeftYes)
{
Intent i = new Intent (this, YesActivity.class);
startActivity(i);
} else
{
Intent i = new Intent (this, YesActivity.class);
startActivity(i);
}
}
}
| [
"91091038@mvusd.net"
] | 91091038@mvusd.net |
430a67b95d6de7ce97dba342833150a3794c8639 | ed3cb95dcc590e98d09117ea0b4768df18e8f99e | /project_1_3/src/f/f/h/Calc_1_3_5573.java | 1b75e5b0ecaa3f21e9a9d5b4221cd72c18aea0db | [] | no_license | chalstrick/bigRepo1 | ac7fd5785d475b3c38f1328e370ba9a85a751cff | dad1852eef66fcec200df10083959c674fdcc55d | refs/heads/master | 2016-08-11T17:59:16.079541 | 2015-12-18T14:26:49 | 2015-12-18T14:26:49 | 48,244,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 131 | java | package f.f.h;
public class Calc_1_3_5573 {
/** @return the sum of a and b */
public int add(int a, int b) {
return a+b;
}
}
| [
"christian.halstrick@sap.com"
] | christian.halstrick@sap.com |
f7847aa24735f5bcd764fdcf039945ace4b377d6 | 4a111ab38dcffc6da9bb5245024d01514260ca87 | /Netbeans/day13_0115_HN/src/ex1/PriorityExample.java | 5fb7666bdf3edd00351adeeb88f1a48d09a19735 | [] | no_license | hanna531/HANNA_GitHub | 70fb3725a2fd7fd4f5ba0b1d4f05666ce565c0de | 60db87d476d2d2085ad110d5afcbec229f5e76f7 | refs/heads/master | 2020-04-16T00:57:38.934999 | 2019-01-21T08:51:22 | 2019-01-21T08:51:22 | 165,156,355 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 824 | java | package ex1;
// 여러 스레드가 하나의 일/목적을 위해 실행되는 것 = 동시성 (p588)
// 여러 스레드가 다른 일을 실행하는 것 = 병렬성
public class PriorityExample {
//스레드 우선순위 테스트를 위해서 10개 생성한 코드
// 확률적으로 10이 먼저 실행될 경우가 많다 (하지만 순위가 낮아질 수 있따)
public static void main(String[] args) {
for(int i=1; i<=10; i++){
//우선순위 1~10까지임. 1이 가장 낮은 값
Thread thread =new CalcThread("thread: "+i);
if(i != 10){
thread.setPriority(Thread.MIN_PRIORITY); // 1
} else{
thread.setPriority(Thread.MAX_PRIORITY); // 10 가장 높음
}
thread.start();
}
}
}
| [
"hanna531@naver.com"
] | hanna531@naver.com |
eae5bfb9047820e0cd9fbbbece91a1500a623469 | d3d03ab16f063862788e3d6c8cbe75f0c5b16a3c | /comp261_a2_yun/src/myCode/Restriction.java | a51690ef76fdbce0bd70bbee083129b5dd271eae | [] | no_license | Yun-K/comp261A2 | 031219451550a5503d265b88bc9e98728f9592fb | be97e5f4aca898129ea203241c6936634e445039 | refs/heads/main | 2023-04-06T21:34:00.597787 | 2021-04-15T18:45:36 | 2021-04-15T18:45:36 | 358,352,854 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,642 | java | package myCode;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import code.Node;
import code.Road;
/***
* Description: <br/>
* My restriction class for parsing the restrictions.tab file to the java object.
*
* @author Yun Zhou 300442776
* @version
*/
public class Restriction {
int nodeID_1, roadID_1, nodeID, roadID_2, nodeID_2;
static List<Restriction> allRestrictions = new ArrayList<Restriction>();
/**
* A constructor. It construct a new instance of Restriction.
*
* @param nodeID_1
* @param roadID_1
* @param nodeID
* @param roadID_2
* @param nodeID_2
*/
public Restriction(int nodeID_1, int roadID_1, int nodeID, int roadID_2, int nodeID_2) {
this.nodeID_1 = nodeID_1;
this.roadID_1 = roadID_1;
this.nodeID = nodeID;
this.roadID_2 = roadID_2;
this.nodeID_2 = nodeID_2;
}
public static List<Restriction> parseRestrictions(File restrictionFile) {
if (restrictionFile == null) {
return null;
}
allRestrictions = new ArrayList<Restriction>();
try {
// make a reader
BufferedReader br = new BufferedReader(new FileReader(restrictionFile));
String line = br.readLine();// jump the first line
// read in each line of the file
while ((line = br.readLine()) != null) {
// tokenise the line by splitting it at the tabs.
String[] tokens = line.split("[\t]+");
// process the tokens
int tnodeID_1 = asInt(tokens[0]);
int troadID_1 = asInt(tokens[1]);
int tnodeID = asInt(tokens[2]);
int troadID_2 = asInt(tokens[3]);
int tnodeID_2 = asInt(tokens[4]);
allRestrictions
.add(new Restriction(tnodeID_1, troadID_1, tnodeID, troadID_2, tnodeID_2));
}
br.close();
} catch (IOException e) {
throw new RuntimeException("file reading failed.");
}
return allRestrictions;
}
private static int asInt(String str) {
return Integer.parseInt(str);
}
private static double asDouble(String str) {
return Double.parseDouble(str);
}
// Node nodeID_1() {
//
//
//
//
// }
//
// Road roadID_1() {
// }
//
// Node nodeID() {
// }
//
// Road roadID_2() {
// }
//
// Node nodeID_2() {
// }
}
| [
"zhouyun@ecs.vuw.ac.nz"
] | zhouyun@ecs.vuw.ac.nz |
7ad10bca70fb799be87803f17efd71574a50d418 | 5139dbb167c360e87d66ecc0b42a1e288e424f67 | /src/main/java/com/wps/microservicesspringboot/breweries/ServletInitializer.java | c44fc7bc822de838494d4be3eb1903f0382eb382 | [] | no_license | wagnerpsantos/microservices-breweries | 0f1234ad6c62a2ee241778f7295757125e80b58b | c86753eef7d393590b38ec6174896b7444ee9c7e | refs/heads/main | 2023-04-18T19:57:11.233740 | 2021-05-07T01:01:56 | 2021-05-07T01:01:56 | 365,066,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 434 | java | package com.wps.microservicesspringboot.breweries;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BreweriesApplication.class);
}
}
| [
"CIANDT\\wpereira@lnb017506cps.ciandt.global"
] | CIANDT\wpereira@lnb017506cps.ciandt.global |
70a49c6c70fcfa062a860d34bad5980406060e48 | 42fd92414ad5bc6d01a201f996d77b11b18b36b0 | /common/src/main/java/com/serenegiant/glutils/es2/GLHelper.java | 4c7b652394dffcd3a6551b47ad292cb9ce890dea | [
"Apache-2.0"
] | permissive | wangruoyudev/libcommon | fe4689d1cd6cb437cf137d3dd14b86f804c06942 | 216f21ef6d3ddc9b8d33464d73d49e6789e209c9 | refs/heads/master | 2020-12-04T17:58:52.446146 | 2019-12-17T20:46:28 | 2019-12-17T20:46:28 | 231,860,088 | 1 | 0 | Apache-2.0 | 2020-01-05T03:04:53 | 2020-01-05T03:04:53 | null | UTF-8 | Java | false | false | 17,373 | java | package com.serenegiant.glutils.es2;
/*
* libcommon
* utility/helper classes for myself
*
* Copyright (c) 2014-2019 saki t_saki@serenegiant.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import androidx.annotation.NonNull;
import android.util.Log;
import com.serenegiant.glutils.ShaderConst;
import com.serenegiant.utils.AssetsHelper;
import com.serenegiant.system.BuildCheck;
import com.serenegiant.system.Stacktrace;
import java.io.IOException;
import java.nio.FloatBuffer;
import static com.serenegiant.utils.BufferHelper.SIZEOF_FLOAT_BYTES;
/**
* OpenGL|ES2/3用のヘルパークラス
*/
public final class GLHelper {
private static final boolean DEBUG = false; // FIXME 実働時はfalseにすること
private static final String TAG = GLHelper.class.getSimpleName();
private GLHelper() {
// インスタンス化をエラーにするためにデフォルトコンストラクタをprivateに
}
/**
* OpenGL|ESのエラーをチェックしてlogCatに出力する
* @param op
*/
public static void checkGlError(final String op) {
final int error = GLES20.glGetError();
if (error != GLES20.GL_NO_ERROR) {
final String msg = op + ": glError 0x" + Integer.toHexString(error);
Log.e(TAG, msg);
Stacktrace.print();
// if (DEBUG) {
// throw new RuntimeException(msg);
// }
}
}
/**
* テクスチャ名を生成, クランプ方法はGL_CLAMP_TO_EDGE
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param texUnit テクスチャユニット, GL_TEXTURE0...GL_TEXTURE31
* @param filterParam テクスチャの補完方法を指定, min/mag共に同じ値になる, GL_LINEARとかGL_NEAREST
* @return
*/
public static int initTex(final int texTarget, final int texUnit, final int filterParam) {
return initTex(texTarget, GLES20.GL_TEXTURE0,
filterParam, filterParam, GLES20.GL_CLAMP_TO_EDGE);
}
/**
* テクスチャ名を生成(GL_TEXTURE0のみ)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param texUnit テクスチャユニット, GL_TEXTURE0...GL_TEXTURE31
* @param minFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param magFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param wrap テクスチャのクランプ方法, GL_CLAMP_TO_EDGE等
* @return
*/
public static int initTex(final int texTarget, final int texUnit,
final int minFilter, final int magFilter, final int wrap) {
if (DEBUG) Log.v(TAG, "initTex:target=" + texTarget);
final int[] tex = new int[1];
GLES20.glActiveTexture(texUnit);
GLES20.glGenTextures(1, tex, 0);
GLES20.glBindTexture(texTarget, tex[0]);
GLES20.glTexParameteri(texTarget, GLES20.GL_TEXTURE_WRAP_S, wrap);
GLES20.glTexParameteri(texTarget, GLES20.GL_TEXTURE_WRAP_T, wrap);
GLES20.glTexParameteri(texTarget, GLES20.GL_TEXTURE_MIN_FILTER, minFilter);
GLES20.glTexParameteri(texTarget, GLES20.GL_TEXTURE_MAG_FILTER, magFilter);
Log.d(TAG, "initTex:texId=" + tex[0]);
return tex[0];
}
/**
* テクスチャ名配列を生成(前から順にGL_TEXTURE0, GL_TEXTURE1, ...), クランプ方法はGL_CLAMP_TO_EDGE
* @param n 生成するテキスチャ名の数, 最大で32個(GL_MAX_TEXTURE_IMAGE_UNITS以下)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param filterParam テクスチャの補完方法を指定, min/mag共に同じ値になる, GL_LINEARとかGL_NEAREST
* @return
*/
public static int[] initTexes(final int n,
final int texTarget, final int filterParam) {
return initTexes(new int[n], texTarget,
filterParam, filterParam, GLES20.GL_CLAMP_TO_EDGE);
}
/**
* テクスチャ名配列を生成(前から順にGL_TEXTURE0, GL_TEXTURE1, ...), クランプ方法はGL_CLAMP_TO_EDGE
* @param texIds テクスチャ名配列, 最大で32個(GL_MAX_TEXTURE_IMAGE_UNITS以下)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param filterParam テクスチャの補完方法を指定, min/mag共に同じ値になる, GL_LINEARとかGL_NEAREST
* @return
*/
public static int[] initTexes(@NonNull final int[] texIds,
final int texTarget, final int filterParam) {
return initTexes(texIds, texTarget,
filterParam, filterParam, GLES20.GL_CLAMP_TO_EDGE);
}
/**
* テクスチャ名配列を生成(前から順にGL_TEXTURE0, GL_TEXTURE1, ...)
* @param n 生成するテキスチャ名の数, 最大32
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param minFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param magFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param wrap テクスチャのクランプ方法, GL_CLAMP_TO_EDGE等
* @return
*/
public static int[] initTexes(final int n,
final int texTarget, final int minFilter, final int magFilter, final int wrap) {
return initTexes(new int[n], texTarget, minFilter, magFilter, wrap);
}
/**
* テクスチャ名配列を生成(前から順にGL_TEXTURE0, GL_TEXTURE1, ...)
* @param texIds テクスチャ名配列, 最大で32個(GL_MAX_TEXTURE_IMAGE_UNITS以下)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param minFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param magFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param wrap テクスチャのクランプ方法, GL_CLAMP_TO_EDGE等
* @return
*/
public static int[] initTexes(@NonNull final int[] texIds,
final int texTarget, final int minFilter, final int magFilter, final int wrap) {
int[] textureUnits = new int[1];
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, textureUnits, 0);
Log.v(TAG, "GL_MAX_TEXTURE_IMAGE_UNITS=" + textureUnits[0]);
final int n = texIds.length > textureUnits[0]
? textureUnits[0] : texIds.length;
for (int i = 0; i < n; i++) {
texIds[i] = GLHelper.initTex(texTarget, ShaderConst.TEX_NUMBERS_ES2[i],
minFilter, magFilter, wrap);
}
return texIds;
}
/**
* テクスチャ名配列を生成(こっちは全部同じテクスチャユニット)
* @param n 最大で32個(GL_MAX_TEXTURE_IMAGE_UNITS以下)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param texUnit テクスチャユニット
* @param minFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param magFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param wrap テクスチャのクランプ方法, GL_CLAMP_TO_EDGE等
* @return
*/
public static int[] initTexes(final int n,
final int texTarget, final int texUnit,
final int minFilter, final int magFilter, final int wrap) {
return initTexes(new int[n], texTarget, texUnit,
minFilter, magFilter, wrap);
}
/**
* テクスチャ名配列を生成(こっちは全部同じテクスチャユニット), クランプ方法はGL_CLAMP_TO_EDGE
* @param texIds 最大で32個(GL_MAX_TEXTURE_IMAGE_UNITS以下)
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param texUnit テクスチャユニット
* @param filterParam テクスチャの補完方法を指定, min/mag共に同じ値になる, GL_LINEARとかGL_NEAREST
* @return
*/
public static int[] initTexes(@NonNull final int[] texIds,
final int texTarget, final int texUnit, final int filterParam) {
return initTexes(texIds, texTarget, texUnit,
filterParam, filterParam, GLES20.GL_CLAMP_TO_EDGE);
}
/**
* テクスチャ名配列を生成(こっちは全部同じテクスチャユニット)
* @param texIds テクスチャ名配列
* @param texTarget テクスチャのタイプ, GL_TEXTURE_EXTERNAL_OESかGL_TEXTURE_2D
* @param texUnit テクスチャユニット
* @param minFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param magFilter テクスチャの補間方法を指定, GL_LINEARとかGL_NEAREST
* @param wrap テクスチャのクランプ方法, GL_CLAMP_TO_EDGE等
* @return
*/
public static int[] initTexes(@NonNull final int[] texIds,
final int texTarget, final int texUnit,
final int minFilter, final int magFilter, final int wrap) {
int[] textureUnits = new int[1];
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_IMAGE_UNITS, textureUnits, 0);
final int n = texIds.length > textureUnits[0]
? textureUnits[0] : texIds.length;
for (int i = 0; i < n; i++) {
texIds[i] = GLHelper.initTex(texTarget, texUnit,
minFilter, magFilter, wrap);
}
return texIds;
}
/**
* delete specific texture
*/
public static void deleteTex(final int hTex) {
if (DEBUG) Log.v(TAG, "deleteTex:");
final int[] tex = new int[] {hTex};
GLES20.glDeleteTextures(1, tex, 0);
}
/**
* delete specific texture
*/
public static void deleteTex(@NonNull final int[] tex) {
if (DEBUG) Log.v(TAG, "deleteTex:");
GLES20.glDeleteTextures(tex.length, tex, 0);
}
public static int loadTextureFromResource(final Context context, final int resId) {
return loadTextureFromResource(context, resId, null);
}
@SuppressLint("NewApi")
public static int loadTextureFromResource(final Context context, final int resId, final Resources.Theme theme) {
if (DEBUG) Log.v(TAG, "loadTextureFromResource:");
// Create an empty, mutable bitmap
final Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_8888);
// get a canvas to paint over the bitmap
final Canvas canvas = new Canvas(bitmap);
canvas.drawARGB(0,0,255,0);
// get a background image from resources
// note the image format must match the bitmap format
final Drawable background;
if (BuildCheck.isAndroid5()) {
background = context.getResources().getDrawable(resId, theme);
} else {
background = context.getResources().getDrawable(resId);
}
background.setBounds(0, 0, 256, 256);
background.draw(canvas); // draw the background to our bitmap
final int[] textures = new int[1];
//Generate one texture pointer...
GLES20.glGenTextures(1, textures, 0);
//...and makeCurrent it to our array
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
//Create Nearest Filtered Texture
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
//Different possible texture parameters, e.g. GLES20.GL_CLAMP_TO_EDGE
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);
//Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
//Clean up
bitmap.recycle();
return textures[0];
}
public static int createTextureWithTextContent(@NonNull final String text) {
return createTextureWithTextContent(text, GLES20.GL_TEXTURE0);
}
public static int createTextureWithTextContent(@NonNull final String text, final int texUnit) {
if (DEBUG) Log.v(TAG, "createTextureWithTextContent:");
// Create an empty, mutable bitmap
final Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_8888);
// get a canvas to paint over the bitmap
final Canvas canvas = new Canvas(bitmap);
canvas.drawARGB(0,0,255,0);
// Draw the text
final Paint textPaint = new Paint();
textPaint.setTextSize(32);
textPaint.setAntiAlias(true);
textPaint.setARGB(0xff, 0xff, 0xff, 0xff);
// draw the text centered
canvas.drawText(text, 16, 112, textPaint);
final int texture = initTex(GLES20.GL_TEXTURE_2D,
texUnit, GLES20.GL_NEAREST, GLES20.GL_LINEAR, GLES20.GL_REPEAT);
// Alpha blending
// GLES20.glEnable(GLES20.GL_BLEND);
// GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
// Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
// Clean up
bitmap.recycle();
return texture;
}
/**
* load, compile and link shader from Assets files
* @param context
* @param vss_asset source file name in Assets of vertex shader
* @param fss_asset source file name in Assets of fragment shader
* @return
*/
public static int loadShader(@NonNull final Context context,
final String vss_asset, final String fss_asset) {
int program;
try {
final String vss = AssetsHelper.loadString(context.getAssets(), vss_asset);
final String fss = AssetsHelper.loadString(context.getAssets(), vss_asset);
program = loadShader(vss, fss);
} catch (final IOException e) {
program = 0;
}
return program;
}
/**
* load, compile and link shader
* @param vss source of vertex shader
* @param fss source of fragment shader
* @return
*/
public static int loadShader(final String vss, final String fss) {
if (DEBUG) Log.v(TAG, "loadShader:");
final int[] compiled = new int[1];
// 頂点シェーダーをコンパイル
final int vs = loadShader(GLES20.GL_VERTEX_SHADER, vss);
if (vs == 0) {
Log.d(TAG, "loadShader:failed to compile vertex shader,\n" + vss);
return 0;
}
// フラグメントシェーダーをコンパイル
int fs = loadShader(GLES20.GL_FRAGMENT_SHADER, fss);
if (fs == 0) {
Log.d(TAG, "loadShader:failed to compile fragment shader,\n" + fss);
return 0;
}
// リンク
final int program = GLES20.glCreateProgram();
checkGlError("glCreateProgram");
if (program == 0) {
Log.e(TAG, "Could not create program");
}
GLES20.glAttachShader(program, vs);
checkGlError("glAttachShader");
GLES20.glAttachShader(program, fs);
checkGlError("glAttachShader");
GLES20.glLinkProgram(program);
final int[] linkStatus = new int[1];
GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
if (linkStatus[0] != GLES20.GL_TRUE) {
Log.e(TAG, "Could not link program: ");
Log.e(TAG, GLES20.glGetProgramInfoLog(program));
GLES20.glDeleteProgram(program);
return 0;
}
return program;
}
/**
* Compiles the provided shader source.
*
* @return A handle to the shader, or 0 on failure.
*/
public static int loadShader(final int shaderType, final String source) {
int shader = GLES20.glCreateShader(shaderType);
checkGlError("glCreateShader type=" + shaderType);
GLES20.glShaderSource(shader, source);
GLES20.glCompileShader(shader);
final int[] compiled = new int[1];
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
if (compiled[0] == 0) {
Log.e(TAG, "Could not compile shader " + shaderType + ":");
Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader));
GLES20.glDeleteShader(shader);
shader = 0;
}
return shader;
}
/**
* Checks to see if the location we obtained is valid. GLES returns -1 if a label
* could not be found, but does not set the GL error.
* <p>
* Throws a RuntimeException if the location is invalid.
*/
public static void checkLocation(final int location, final String label) {
if (location < 0) {
throw new RuntimeException("Unable to locate '" + label + "' in program");
}
}
/**
* バッファーオブジェクトを生成&データをセットしてバッファー名を返す
* @param target GL_ARRAY_BUFFERまたはGL_ELEMENT_ARRAY_BUFFER
* @param data
* @param usage GL_STATIC_DRAW, GL_STREAM_DRAW, GL_DYNAMIC_DRAW
* @return
*/
public static int createBuffer(final int target, @NonNull final FloatBuffer data, final int usage) {
final int[] ids = new int[1];
GLES20.glGenBuffers(1, ids, 0);
checkGlError("glGenBuffers");
GLES20.glBindBuffer(target, ids[0]);
checkGlError("glBindBuffer");
GLES20.glBufferData(target, SIZEOF_FLOAT_BYTES * data.limit(), data, usage);
checkGlError("glBufferData");
GLES20.glBindBuffer(target, 0);
return ids[0];
}
/**
* バッファーオブジェクトを破棄する
* @param bufId
*/
public static void deleteBuffer(final int bufId) {
deleteBuffer(new int[] {bufId});
}
/**
* バッファーオブジェクトを破棄する
* @param bufIds
*/
public static void deleteBuffer(@NonNull final int[] bufIds) {
GLES20.glDeleteBuffers(bufIds.length, bufIds, 0);
}
}
| [
"saki4510t@gmail.com"
] | saki4510t@gmail.com |
dbf02088896613322c81176dcd30424933891070 | e5b2137b7221e6c4fd049359f95e3a59dd0bc78d | /AutoTestUI-master/src/main/java/com/zhaopin/uitest/util/HttpHelper.java | 3008a152714f530cd8bc8b01e74613206818f7eb | [] | no_license | xie592/AutoTest | 9c19225e1df24055938ba221f28e619429fb5de2 | 8ff3ec9673742811d51cf4bd1a8996031ec50e66 | refs/heads/master | 2020-03-21T01:49:27.456949 | 2018-07-25T07:31:16 | 2018-07-25T07:31:16 | 137,964,754 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,686 | java | package com.zhaopin.uitest.util;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
public class HttpHelper {
public static synchronized boolean URLisAvailable(String url){
boolean flag = false;
int counts = 0;
while (counts < 3) {
int state = -1;
try {
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
state = con.getResponseCode();
if (state == 200) {
System.out.println("URL is available: "+url);
flag = true;
break;
}
}catch (Exception e) {
counts++;
System.out.println("URL不可用,第" + counts + "次链接" + url + "为"+state);
continue;
}
}
return flag;
}
public static synchronized boolean URLisAvailable(List<String> url){
boolean flag = true;
int counts = 0;
if (url == null || url.size() <= 0) {
flag = false;
System.out.println("链接数组为空");
}
for(int i=0;i<url.size();i++){
if(url.get(i).equalsIgnoreCase(null)){
System.out.println(url.get(i)+"为空链接");
flag = false;
}
while (counts < 3) {
int state = -1;
try {
HttpURLConnection con = (HttpURLConnection) new URL(url.get(i)).openConnection();
state = con.getResponseCode();
if (state == 200) {
System.out.println("URL is available: "+url.get(i));
break;
}
}catch (Exception e) {
counts++;
System.out.println("URL不可用,第"+ counts + "次链接" + url.get(i) + "为"+state);
flag=false;
continue;
}
}
}
return flag;
}
}
| [
"642964636@qq.com"
] | 642964636@qq.com |
f020ba420e84b9e1d1b1dc0aaef21c43fce5be2f | 9c61ad1094164027a96648436ff1f7b783ddc0e6 | /demo_transferdata/src/main/java/transferdata/SendRedirectPage.java | f2eeb1c93b60161e39f321fe709f94018e48b2c4 | [] | no_license | codehero-cn/javaee.basic | 0d56fddae980620c6e0df6890714f06041f68098 | 8483955113edb4218f9059b947b68f00633454a1 | refs/heads/master | 2020-04-07T01:52:16.778673 | 2019-07-20T14:40:35 | 2019-07-24T01:33:27 | 157,955,538 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,016 | java | package javaee.basic.transferdata;
import java.io.IOException;
//import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
*数据传递方法:使用跳转时带上数据
*/
@WebServlet(name="SendRedirectPage",urlPatterns={"/transferdata/SendRedirectPage"})
public class SendRedirectPage extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html charset=utf-8");
resp.setCharacterEncoding("utf-8");
//PrintWriter out = resp.getWriter();
//跳转到下一个页面[servlet提供了两种:Sendredirct转向 forward转发]
//sendRedirect的url应该这样写 /web应用名/servlet的url
resp.sendRedirect("http://localhost?secodeusername=2name&secoondpassword=2password");
}
}
| [
"1823887177@qq.com"
] | 1823887177@qq.com |
ed9d053e2e867eca8006ffbfb6e345d18cb53597 | 4cc705a819a33ce49e6e9569c60bd6019d58ba10 | /src/main/java/com/webapps2015/entity/Person.java | 13d07d2abce15d1dc67951c95566cecfb70723d9 | [] | no_license | JavaAdore/charity | fcff732a32429627fa17a1dfae1b730e14943e35 | 2564c92248f4b962fac66a573aefdccb23be40f5 | refs/heads/master | 2016-08-12T20:35:57.434370 | 2016-02-23T16:44:31 | 2016-02-23T16:44:31 | 52,382,772 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,495 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.webapps2015.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
/**
*
* @author dar27
*/
@Entity
public class Person extends SystemUser implements Serializable{
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "postal_code")
private String postalCode;
@Column(name = "address")
private String address;
@Column(name = "city")
private String city;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
| [
"mahmoud.eltaieb@gmail.com"
] | mahmoud.eltaieb@gmail.com |
ce80702fad12980616219d9b3bbf54b0d61d5168 | 288574a9ebfaf6a66ec224f04e30021c49ab527b | /src/hacer/Divicion0.java | 8732e558f07a654c7cbf26d9a88702a1ffc993d6 | [] | no_license | grishnackh666/Divicion-por-cero | 301dac3abbf0e39324006a7099ccbd4bf2dbcb98 | 791e325661e90214ef6f797acb8b81353f8433d6 | refs/heads/master | 2020-05-20T18:08:22.644423 | 2019-05-09T01:06:33 | 2019-05-09T01:06:33 | 185,701,229 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 471 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hacer;
public class Divicion0 extends Exception{
public Divicion0(String el_numero_no_puede_ser_0) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
| [
"kvnpolo97@gmail.com"
] | kvnpolo97@gmail.com |
3be77c0ee9a512f9668dd29b115b9e250462270a | 1588a90cfac6a0905a118c2e5cdad999088b3efc | /app/src/main/java/com/example/app/actionitem/MainActivity.java | 972ad51d487ae70b0261bacc75be667bb859faa4 | [] | no_license | GMuthuraja/ActionItem | 5893d23f49e2a5d6cca958898119d0a62677d9f2 | 0f6b6cfdc33d58784d351c627875ddb04caf1471 | refs/heads/master | 2020-04-01T09:49:28.061643 | 2018-10-15T10:04:39 | 2018-10-15T10:04:39 | 153,091,130 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,755 | java | package com.example.app.actionitem;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar bar = getSupportActionBar();
bar.setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
int selectedItem = item.getItemId();
switch (selectedItem){
case android.R.id.home:
Toast.makeText(MainActivity.this, "You clicked back button!", Toast.LENGTH_LONG).show();
break;
case R.id.icon1:
Toast.makeText(MainActivity.this, "You just clicked Email!", Toast.LENGTH_LONG).show();
break;
case R.id.icon2:
Toast.makeText(MainActivity.this, "You just clicked Camera!", Toast.LENGTH_LONG).show();
break;
case R.id.icon3:
Toast.makeText(MainActivity.this, "You just clicked Info!", Toast.LENGTH_LONG).show();
break;
case R.id.icon4:
Toast.makeText(MainActivity.this, "You just clicked Add!", Toast.LENGTH_LONG).show();
break;
}
return true;
}
}
| [
"muthuraja.g@newgendigital.com"
] | muthuraja.g@newgendigital.com |
1f3a3dca024eabf3957bb1f9c72c612ca8836c62 | abf0bd529444218e384a7f8fade69c4428a4f37f | /game-decay/src/main/java/com/zerulus/game/entity/Enemy.java | 962252dbb4a648c4549b32167813d4b2ceac8e59 | [
"MIT"
] | permissive | NatetheGrate06/yt-java-game | b9a70b660ec34f215a4814b1dd7d90209f3e6519 | 5847673be400e5b16f32d77fdb494355be9978e0 | refs/heads/master | 2020-12-29T08:54:14.796043 | 2020-02-05T19:46:26 | 2020-02-05T19:46:26 | 238,544,914 | 1 | 0 | MIT | 2020-02-05T20:44:50 | 2020-02-05T20:44:49 | null | UTF-8 | Java | false | false | 4,740 | java | package com.zerulus.game.entity;
import com.zerulus.game.graphics.SpriteSheet;
import com.zerulus.game.util.Camera;
import com.zerulus.game.math.AABB;
import com.zerulus.game.math.Vector2f;
import java.util.ArrayList;
import java.awt.Graphics2D;
import java.awt.Color;
public abstract class Enemy extends Entity {
protected AABB sense;
protected int r_sense;
protected AABB attackrange;
protected int r_attackrange;
private Camera cam;
protected int xOffset;
protected int yOffset;
protected ArrayList<GameObject> collisions;
public Enemy(Camera cam, SpriteSheet sprite, Vector2f origin, int size) {
super(sprite, origin, size);
this.cam = cam;
bounds.setWidth(size / 2);
bounds.setHeight(size / 2 - yOffset);
bounds.setXOffset(size / 2 - xOffset);
bounds.setYOffset(size / 2 + yOffset);
sense = new AABB(new Vector2f(origin.x + size / 2 - r_sense / 2, origin.y + size / 2 - r_sense / 2), r_sense);
attackrange = new AABB(new Vector2f(origin.x + bounds.getXOffset() + bounds.getWidth() / 2 - r_attackrange / 2 , origin.y + bounds.getYOffset() + bounds.getHeight() / 2 - r_attackrange / 2 ), r_attackrange);
}
public void chase(Player player) {
AABB playerBounds = player.getBounds();
if (sense.colCircleBox(playerBounds) && !attackrange.colCircleBox(playerBounds)) {
if (pos.y > player.pos.y + 1) {
up = true;
} else {
up = false;
}
if (pos.y < player.pos.y - 1) {
down = true;
} else {
down = false;
}
if (pos.x > player.pos.x + 1) {
left = true;
} else {
left = false;
}
if (pos.x < player.pos.x - 1) {
right = true;
} else {
right = false;
}
} else {
up = false;
down = false;
left = false;
right = false;
}
}
public void update(Player player, double time) {
if(cam.getBounds().collides(this.bounds)) {
super.update(time);
chase(player);
move();
if(teleported) {
teleported = false;
bounds.setWidth(size / 2);
bounds.setHeight(size / 2 - yOffset);
bounds.setXOffset(size / 2 - xOffset);
bounds.setYOffset(size / 2 + yOffset);
hitBounds = new AABB(pos, size, size);
hitBounds.setXOffset(size / 2);
sense = new AABB(new Vector2f(pos.x + size / 2 - r_sense / 2, pos.y + size / 2 - r_sense / 2), r_sense);
attackrange = new AABB(new Vector2f(pos.x + bounds.getXOffset() + bounds.getWidth() / 2 - r_attackrange / 2 , pos.y + bounds.getYOffset() + bounds.getHeight() / 2 - r_attackrange / 2 ), r_attackrange);
}
if(attackrange.colCircleBox(player.getBounds()) && !isInvincible) {
attack = true;
player.setHealth(player.getHealth() - damage, 5f * getDirection(), currentDirection == UP || currentDirection == DOWN);
} else {
attack = false;
}
if (!fallen) {
if (!tc.collisionTile(dx, 0)) {
sense.getPos().x += dx;
attackrange.getPos().x += dx;
pos.x += dx;
}
if (!tc.collisionTile(0, dy)) {
sense.getPos().y += dy;
attackrange.getPos().y += dy;
pos.y += dy;
}
} else {
if(ani.hasPlayedOnce()) {
die = true;
}
}
}
}
@Override
public void render(Graphics2D g) {
if(cam.getBounds().collides(this.bounds)) {
//if(isInvincible)
if(useRight && left) {
g.drawImage(ani.getImage().image, (int) (pos.getWorldVar().x) + size, (int) (pos.getWorldVar().y), -size, size, null);
} else {
g.drawImage(ani.getImage().image, (int) (pos.getWorldVar().x), (int) (pos.getWorldVar().y), size, size, null);
}
// Health Bar UI
g.setColor(Color.red);
g.fillRect((int) (pos.getWorldVar().x + bounds.getXOffset()), (int) (pos.getWorldVar().y - 5), 24, 5);
g.setColor(Color.green);
g.fillRect((int) (pos.getWorldVar().x + bounds.getXOffset()), (int) (pos.getWorldVar().y - 5), (int) (24 * healthpercent), 5);
}
}
} | [
"danielrcastro10@gmail.com"
] | danielrcastro10@gmail.com |
7eacde5c9b2bfb89a76245c2a3e2c8a1739ab925 | 1a830a22f60e7e15fea935e4aecaa48e0b7d0940 | /src/com/coralc/inspectbox/AccueilActivity.java | 0725a104f539dd0c7c3a83111f5f505f81d54ba0 | [] | no_license | coralc/InspectBoxMobile-Auto_Sycnch- | cefb2050e1e56f97c3fc53c3a9b0ef9916ec4ae5 | a1a4b72c57df6b9e25e2c8a7acb9440a9aba79ac | refs/heads/master | 2021-04-09T13:04:18.199670 | 2018-03-18T01:12:30 | 2018-03-18T01:12:30 | 125,681,722 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 9,256 | java | package com.coralc.inspectbox;
import java.util.List;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import com.coralc.inspectbox.database.DatabaseHelper;
import com.coralc.inspectbox.database.Parametrage;
import com.coralc.inspectbox.database.Utilisateur;
import com.coralc.inspectbox.sync.IAsyncTaskCallback;
import com.coralc.inspectbox.sync.SyncTask;
import com.coralc.inspectbox.R;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;
public class AccueilActivity extends OrmLiteBaseActivity<DatabaseHelper> implements IAsyncTaskCallback {
// Widgets
private ImageButton btnInspection;
private ImageButton btnParam;
private ImageButton btnExit;
private ImageButton btnSync;
final private static int DIALOG_LOGIN = 1;
final private static int DIALOG_EXIT = 2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.homepage);
// Initalisation des widgets
btnInspection = (ImageButton) findViewById(R.id.btnInspection);
btnParam = (ImageButton) findViewById(R.id.btnParam);
btnExit = (ImageButton) findViewById(R.id.btnExit);
btnSync = (ImageButton) findViewById(R.id.btnSync);
// Binding des évènements
btnExit.setOnClickListener(new OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
showDialog(DIALOG_EXIT);
}
});
btnInspection.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
List<Utilisateur> users = getHelper().getUtilisateurDao().queryForAll();
if (users.size()>0)
{
Intent intent = new Intent(AccueilActivity.this, LoginActivity.class);
startActivity(intent);
}
else
Toast.makeText(AccueilActivity.this, getText(R.string.nodata), Toast.LENGTH_LONG)
.show();
}
});
btnParam.setOnClickListener(new OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
showDialog(DIALOG_LOGIN);
}
});
btnSync.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (isOnline())
{
List<Utilisateur> users = getHelper().getUtilisateurDao().queryForAll();
if (users.size()>0)
{// enfin on lance la synchronisation :
// on créer un nouveau fragment
TaskFragment taskFragment = new TaskFragment();
taskFragment.setTitle(getText(R.string.app_name).toString());
taskFragment.setText(getText(R.string.syncencours).toString());
// on lui assigne une tâche
taskFragment.setTask(new SyncTask(getHelper(), true, false,false));
// affiche le fragment qui lance la tache associée
taskFragment.show(getFragmentManager(), "TaskFragmentTag");
}
else
Toast.makeText(AccueilActivity.this, getText(R.string.nodata), Toast.LENGTH_LONG)
.show();
}
else
{
Toast.makeText(AccueilActivity.this, getText(R.string.nocx), Toast.LENGTH_LONG)
.show();
}
}
});
}
@Override
public void onTaskComplete(int result) {
if (result < 0) {
Toast.makeText(this, this.getText(R.string.synccanceled), Toast.LENGTH_LONG).show();
} else if (result == 100) {
Toast.makeText(this, this.getText(R.string.synccomplete), Toast.LENGTH_LONG).show();
} else if (result == 0) {
Toast.makeText(this, this.getText(R.string.mdperrone), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, this.getText(R.string.erreursync), Toast.LENGTH_LONG).show();
}
}
@Override
protected Dialog onCreateDialog(int id) {
AlertDialog dialogDetails = null;
switch (id) {
case DIALOG_LOGIN:
LayoutInflater inflater = LayoutInflater.from(this);
View dialogview = inflater.inflate(R.layout.dialog_mdp, null);
AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
dialogbuilder.setTitle(getText(R.string.cltmdps));
dialogbuilder.setView(dialogview);
dialogDetails = dialogbuilder.create();
break;
case DIALOG_EXIT:
LayoutInflater inflater2 = LayoutInflater.from(this);
View dialogview2 = inflater2.inflate(R.layout.dialog_exit, null);
AlertDialog.Builder dialogbuilder2 = new AlertDialog.Builder(this);
dialogbuilder2.setTitle(getText(R.string.cltmdps));
dialogbuilder2.setView(dialogview2);
dialogDetails = dialogbuilder2.create();
break;
}
return dialogDetails;
}
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case DIALOG_LOGIN:
final AlertDialog alertDialog = (AlertDialog) dialog;
Button loginbutton = (Button) alertDialog
.findViewById(R.id.btn_savepassp);
Button cancelbutton = (Button) alertDialog
.findViewById(R.id.btn_cancelpassp);
final EditText pass1 = (EditText) alertDialog
.findViewById(R.id.passeditt);
loginbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Parametrage param = getHelper().getParametrageDao().queryForId(1);
if (param.getPasseappli()!=null)
{
if (param.getPasseappli().equals(pass1.getText().toString()))
{
Intent intent = new Intent(AccueilActivity.this, ParametrageActivity.class);
startActivity(intent);
}
else
{
Toast.makeText(AccueilActivity.this, getText(R.string.wrongpass), Toast.LENGTH_LONG)
.show();
}
}
alertDialog.dismiss();
pass1.setText("");
}
});
cancelbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
pass1.setText("");
}
});
break;
case DIALOG_EXIT:
final AlertDialog alertDialog2 = (AlertDialog) dialog;
Button loginbutton2 = (Button) alertDialog2
.findViewById(R.id.btn_saveexit);
Button cancelbutton2 = (Button) alertDialog2
.findViewById(R.id.btn_cancelexit);
final EditText passexit = (EditText) alertDialog2
.findViewById(R.id.exitedit);
loginbutton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Parametrage param = getHelper().getParametrageDao().queryForId(1);
if (param.getPasseappli()!=null)
{
if (param.getPasseappli().equals(passexit.getText().toString()))
{
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else
{
Toast.makeText(AccueilActivity.this, getText(R.string.wrongpass), Toast.LENGTH_LONG)
.show();
}
}
passexit.setText("");
alertDialog2.dismiss();
}
});
cancelbutton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog2.dismiss();
passexit.setText("");
}
});
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.version, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
PackageInfo pInfo;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
MenuItem profileMenuItem = menu.findItem(R.id.menu_version);
if(profileMenuItem != null) {
profileMenuItem.setTitle("V "+version);
}
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return super.onPrepareOptionsMenu(menu);
}
public boolean isOnline() {
ConnectivityManager cm =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();
}
}
| [
"maurice.dierick@gmail.com"
] | maurice.dierick@gmail.com |
f9b475332475679f5ffe338488542d210c8f9440 | 72e84026142ce90ae798a61134b19bbfcf084833 | /app/src/main/java/com/example/factoryrec/selector/view/SquareFrameLayout.java | b82a8b68219dae0f5090d966e296c3bfbfaa5c41 | [] | no_license | cc-open/FactoryRec | ab1753aaddc782521fe303b13747a2af6eccf90f | 782a220380e9baa7d949af973cc2effd3c168159 | refs/heads/main | 2023-04-30T05:52:03.261166 | 2021-05-28T09:43:34 | 2021-05-28T09:43:34 | 352,646,516 | 0 | 0 | null | 2021-05-28T09:43:35 | 2021-03-29T13:06:20 | Java | UTF-8 | Java | false | false | 1,683 | java | /** ************************************************************************/
/* */
/* Copyright (c) 2016 YULONG Company */
/* 宇龙计算机通信科技(深圳)有限公司 版权所有 2015 */
/* */
/* PROPRIETARY RIGHTS of YULONG Company are involved in the */
/* subject matter of this material. All manufacturing, reproduction, use, */
/* and sales rights pertaining to this subject matter are governed by the */
/* license agreement. The recipient of this software implicitly accepts */
/* the terms of the license. */
/* 本软件文档资料是宇龙公司的资产,任何人士阅读和使用本资料必须获得 */
/* 相应的书面授权,承担保密责任和接受相应的法律约束. */
/* */
/** ************************************************************************/
package com.example.factoryrec.selector.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* SquareFrameLayout
*
* @author yangcheng
*/
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
super(context);
}
public SquareFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
}
}
| [
"15151860920@163.com"
] | 15151860920@163.com |
45414b6ccfd56159c0f4bd4029725da10e998f07 | 44341807367eb3e262e70d27ce21fef23fe6ac8c | /app/src/test/java/felixserrano/example/org/grabadora/ExampleUnitTest.java | c0cc062c801c9ddf81486c0c0e7eccc9a59fa46a | [] | no_license | xerkoss/felixserrano_Grabadora | 9012e4074c368e464ebdb96cb43d4e741f4ee340 | 88927b3541d6bd6151cafef51254e7ca16d70c40 | refs/heads/master | 2021-01-11T19:20:14.124556 | 2017-01-18T16:09:54 | 2017-01-18T16:09:54 | 79,357,692 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package felixserrano.example.org.grabadora;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"el-xuko-1989@hotmail.com"
] | el-xuko-1989@hotmail.com |
aa078f764cccaabd301e381752f8fd38a4bdf521 | 22395fd543755e9c638551a60bf00fb682ecaa71 | /prj/disldroid/src-analysis/ch/usi/dag/bc/analysis/BC2Analysis.java | dba68ffed8dcc4a4b390390947ae869051e6ac4c | [
"Apache-2.0"
] | permissive | andrewpedia/disl-android | e9274c234295f6431b4310049ec1c98a93ddf43f | 393f9ee82750dede78f7ab4a9524d6055bf2fbe9 | refs/heads/master | 2022-02-13T15:30:32.929508 | 2017-04-01T08:48:57 | 2017-04-01T08:48:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,855 | java | package ch.usi.dag.bc.analysis;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import ch.usi.dag.disldroidreserver.remoteanalysis.RemoteAnalysis;
import ch.usi.dag.disldroidreserver.shadow.Context;
import ch.usi.dag.disldroidreserver.shadow.Forkable;
import ch.usi.dag.disldroidreserver.shadow.ShadowObject;
import ch.usi.dag.disldroidreserver.shadow.ShadowString;
public class BC2Analysis extends RemoteAnalysis implements Forkable {
public static class ContextStatistic {
ConcurrentHashMap <String, ClassStatistic> classStatistics = new ConcurrentHashMap <String, ClassStatistic> ();
public ClassStatistic getClassStatistic (
final String className, final int totalEdge) {
ClassStatistic classStatistic;
if ((classStatistic = classStatistics.get (className)) == null) {
final ClassStatistic temp = new ClassStatistic (totalEdge);
if ((classStatistic = classStatistics.putIfAbsent (className, temp)) == null) {
classStatistic = temp;
}
}
return classStatistic;
}
@Override
public ContextStatistic clone () {
final ContextStatistic contextStatistic = new ContextStatistic ();
for (final String className : classStatistics.keySet ()) {
contextStatistic.classStatistics.put (
className, classStatistics.get (className).clone ());
}
return contextStatistic;
}
}
public static class ClassStatistic {
ConcurrentHashMap <String, boolean []> methodStatistics = new ConcurrentHashMap <String, boolean []> ();
int totalEdge;
// for dumping data
int coveredEdge = 0;
// for dumping data
int coveredMethod = 0;
public ClassStatistic (final int totalEdge) {
this.totalEdge = totalEdge;
}
public boolean [] getMethodStatistic (final String methodID, final int size) {
boolean [] methodStatistic;
if ((methodStatistic = methodStatistics.get (methodID)) == null) {
final boolean [] temp = new boolean [size];
if ((methodStatistic = methodStatistics.putIfAbsent (methodID, temp)) == null) {
methodStatistic = temp;
}
}
return methodStatistic;
}
@Override
public ClassStatistic clone () {
final ClassStatistic classStatistic = new ClassStatistic (totalEdge);
for (final String methodName : methodStatistics.keySet ()) {
final boolean [] methodStatistic = methodStatistics.get (methodName);
classStatistic.methodStatistics.put (
methodName,
Arrays.copyOf (methodStatistic, methodStatistic.length));
}
return classStatistic;
}
}
ConcurrentHashMap <Context, ContextStatistic> contextStatistics = new ConcurrentHashMap <Context, ContextStatistic> ();
private String getClassName (final String methodName) {
final String methodNameWithoutDesc = methodName.substring (
0, methodName.lastIndexOf ('('));
return methodNameWithoutDesc.substring (
0, methodNameWithoutDesc.lastIndexOf ('.'));
}
public void sendMeta (
final ShadowString className, final ShadowString methodID, final int total,
final int local, final Context context) {
ContextStatistic contextStatistic;
if ((contextStatistic = contextStatistics.get (context)) == null) {
final ContextStatistic temp = new ContextStatistic ();
if ((contextStatistic = contextStatistics.putIfAbsent (context, temp)) == null) {
contextStatistic = temp;
}
}
// Create entry
contextStatistic.getClassStatistic (
getClassName (methodID.toString ()), total).getMethodStatistic (
methodID.toString (), local);
}
public void commitBranch (
final ShadowString methodID, final int index, final Context context) {
ContextStatistic contextStatistic;
if ((contextStatistic = contextStatistics.get (context)) == null) {
final ContextStatistic temp = new ContextStatistic ();
if ((contextStatistic = contextStatistics.putIfAbsent (context, temp)) == null) {
contextStatistic = temp;
}
}
if (contextStatistic != null) {
final ClassStatistic classStatistic = contextStatistic.classStatistics.get (getClassName (methodID.toString ()));
if (classStatistic != null) {
final boolean [] methodStatistic = classStatistic.methodStatistics.get (methodID.toString ());
if (methodStatistic != null) {
methodStatistic [index] = true;
}
}
}
}
public void printResult () {
}
@Override
public void atExit (final Context context) {
final ContextStatistic contextStatistic = contextStatistics.get (context);
if (contextStatistic == null) {
return;
}
for (final ClassStatistic classStatistic : contextStatistic.classStatistics.values ()) {
for (final boolean [] methodStatistic : classStatistic.methodStatistics.values ()) {
classStatistic.coveredMethod++;
for (final boolean flag : methodStatistic) {
if (flag) {
classStatistic.coveredEdge++;
}
}
}
}
System.out.println ("############### Classes ###############");
for (final String className : contextStatistic.classStatistics.keySet ()) {
final ClassStatistic classStatistic = contextStatistic.classStatistics.get (className);
System.out.printf (
"PROCESS-%d: %s %.2f %d %d %d\n",
context.pid (),
className,
classStatistic.totalEdge == 0
? Float.NaN
: (((float) classStatistic.coveredEdge) / classStatistic.totalEdge),
classStatistic.totalEdge, classStatistic.coveredMethod,
classStatistic.coveredEdge);
}
}
@Override
public void objectFree (final Context context, final ShadowObject netRef) {
}
@Override
public void onFork (final Context parent, final Context child) {
final ContextStatistic parentStatistic = contextStatistics.get (parent);
if (parentStatistic != null) {
contextStatistics.put (child, parentStatistic.clone ());
}
}
}
| [
"sunhaiyangsjtu@gmail.com"
] | sunhaiyangsjtu@gmail.com |
d707bbbf6b05a5e4bac5c388451f7ec44c744dc6 | 5c49481ba36d92370fdabe8e0bbe0f3fb9a6ccc5 | /description/src/ru/diman/swing/table/renderers/ColumnRendererFactory.java | 11d9b98a8bd35081bead7d46bdbe63a5b35b2673 | [] | no_license | empyrosx/unicons | 05aa58078ba9ccef5f3b99ad32c65e02d436a717 | 162ea3a7ec49c1699c36a90431369d3c8b7493d6 | refs/heads/master | 2021-01-19T13:03:56.177373 | 2017-08-19T20:28:11 | 2017-08-19T20:28:11 | 100,818,760 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,371 | java | package ru.diman.swing.table.renderers;
import ru.diman.swing.table.*;
import ru.diman.swing.table.renderers.NumberRenderer;
import ru.diman.swing.table.renderers.MultiRowRenderer;
import ru.diman.swing.table.renderers.DecimalRenderer;
import ru.diman.swing.table.renderers.PickListRenderer;
import ru.diman.swing.table.editors.PickList;
import ru.diman.description.Column;
import ru.diman.description.column.types.ValueType;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import ru.diman.description.column.types.AutoSize;
/**
* Фабрика создания декораторов для колонки
* @author Димитрий
*
*/
public class ColumnRendererFactory {
/**
* Создание соответствующего декоратора для колонки
* @param column
* @return
*/
public static TableCellRenderer createRenderer(Column column) {
// выпадающий список
if (!column.getPickList().isEmpty()) {
PickList pickList = new PickList(column.getPickList(), column.getValueType() == ValueType.INTEGER);
return new ColumnRendererAdapter(new PickListRenderer(pickList));
}
// суммы
if (column.getValueType() == ValueType.FLOAT) {
return new ColumnRendererAdapter(new DecimalRenderer());
}
// отформатированное значение (строковые и целые поля
if (!column.getTextFormat().isEmpty()) {
// получаем формат
String textFormat = column.getTextFormat();
if ((textFormat.indexOf('.') > 0) || (column.getValueType() == ValueType.STRING)) {
// с точками
return new ColumnRendererAdapter(new TextFormatRenderer(column.getTextFormat()));
} else {
// целые без '.'
return new ColumnRendererAdapter(new NumberRenderer(textFormat));
}
}
/*
if (column.getAliasName().equalsIgnoreCase("note")){
return new MultiRowRenderer(column);
}*/
if (column.getAutoSize().equals(AutoSize.AUTO_HEIGHT)){
return new MultiRowRenderer(column);
}
return new DefaultTableCellRenderer();
}
}
| [
"empyrosx@gmail.com"
] | empyrosx@gmail.com |
43f0e208bd330a9a3ee0375da3f9042e4595a899 | 619ed52f083b96587480ba287e99062dd2e17f04 | /src/si/fri/rgti/tank/APhysicsModelStatic.java | 46c37e615788c5467f1c401941e1128a0019d4b1 | [
"MIT"
] | permissive | jenzy/Little-Tank-That-Could | 1162112f57e20355f155621693f136d4cd9b56c9 | 12c63c8862778fc3e2729fe736be8ccf0745a498 | refs/heads/master | 2020-04-16T15:51:46.676178 | 2019-01-14T19:27:35 | 2019-01-14T19:27:35 | 165,716,983 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,141 | java | package si.fri.rgti.tank;
import javax.vecmath.Vector3f;
import si.fri.rgti.tank.ModelLoader.Model;
import com.bulletphysics.dynamics.DynamicsWorld;
/**
* A model that doesn't move (except up and down ~ gravity)
* This solution kinda sucks, but jBullet isn't a complete port of Bullet, so it
* doesn't have the .setLinearFactor method to restrict movement, so I resorted
* to assigning static objects a massive mass so that they can't be moved.
* @author Jani
*/
public abstract class APhysicsModelStatic extends APhysicsModel {
public APhysicsModelStatic(Vector3f position, Vector3f size,
DynamicsWorld physicsWorld, ModelConstructionInfo info,
String modelFile) {
super(position, size, physicsWorld, info, modelFile);
rigidBody.setMassProps(constructionInfo.mass, new Vector3f(0,0,0));
rigidBody.setAngularFactor(0f);
}
public APhysicsModelStatic(Vector3f position, Vector3f size, DynamicsWorld physicsWorld, ModelConstructionInfo info, Model m) {
super(position, size, physicsWorld, info, m);
rigidBody.setMassProps(constructionInfo.mass, new Vector3f(0,0,0));
rigidBody.setAngularFactor(0f);
}
}
| [
"bevk.jani@gmail.com"
] | bevk.jani@gmail.com |
ecb04e8ecd3c8cb664b250c33ac753d33d1aa889 | babaf4c8bcc2edf41e1ee9bf05068af656f23cd0 | /retrolambda/src/main/java/net/orfjackal/retrolambda/RemoveDefaultMethods.java | 95a477821db253598858d858ec8152f1b5932bbf | [
"Apache-2.0"
] | permissive | Arneball/retrolambda | 4cc450430ab342cb3339dc4911e466e13cf8976b | 23cfe1b9dca6a28a2e31bf66726d237f8f5eae20 | refs/heads/master | 2021-01-16T20:29:45.315128 | 2014-09-05T17:35:05 | 2014-09-05T17:35:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,093 | java | // Copyright © 2013-2014 Esko Luontola <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0
package net.orfjackal.retrolambda;
import org.objectweb.asm.*;
import static org.objectweb.asm.Opcodes.*;
public class RemoveDefaultMethods extends ClassVisitor {
private boolean isInterface;
public RemoveDefaultMethods(ClassVisitor next) {
super(ASM5, next);
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
isInterface = Flags.hasFlag(access, ACC_INTERFACE);
super.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (isInterface && !Flags.hasFlag(access, ACC_ABSTRACT)) {
return null;
} else {
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
}
| [
"esko.luontola@gmail.com"
] | esko.luontola@gmail.com |
bb5422d3289cd8643c2886b91daa1ab50e23fdc8 | cd4802766531a9ccf0fb54ca4b8ea4ddc15e31b5 | /java/com/l2jmobius/loginserver/network/mmocore/NioNetStringBuffer.java | 77230a9940f555728fbf764203661543a568f018 | [] | no_license | singto53/underground | 8933179b0d72418f4b9dc483a8f8998ef5268e3e | 94264f5168165f0b17cc040955d4afd0ba436557 | refs/heads/master | 2021-01-13T10:30:20.094599 | 2016-12-11T20:32:47 | 2016-12-11T20:32:47 | 76,455,182 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,386 | 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 com.l2jmobius.loginserver.network.mmocore;
import java.nio.BufferOverflowException;
/**
* @author Forsaiken
*/
public final class NioNetStringBuffer
{
private final char[] _buf;
private final int _size;
private int _len;
public NioNetStringBuffer(int size)
{
_buf = new char[size];
_size = size;
_len = 0;
}
public final void clear()
{
_len = 0;
}
public final void append(char c)
{
if (_len < _size)
{
_buf[_len++] = c;
}
else
{
throw new BufferOverflowException();
}
}
@Override
public final String toString()
{
return new String(_buf, 0, _len);
}
}
| [
"MobiusDev@7325c9f8-25fd-504a-9f63-8876acdc129b"
] | MobiusDev@7325c9f8-25fd-504a-9f63-8876acdc129b |
519ce5513f7a47cebccf648f8aac35d1ef239104 | 1d432895a968be7159444ba9c447b3c3080b336c | /app/src/main/java/com/example/android/bookstore/BookCursorAdapter.java | e19eb5b7faa7e4b7b2f0de69caee4300e7a5f517 | [] | no_license | Narinder19/BookStore2 | b63f28100276568ef3c4f17ac52b3862bad63167 | d8d136c832ccfb083ad382734818f0dccd5605e0 | refs/heads/master | 2020-03-28T00:35:20.077452 | 2018-09-06T01:34:21 | 2018-09-06T01:34:21 | 147,430,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,111 | java | package com.example.android.bookstore;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.example.android.bookstore.data.BookContract.BookEntry;
public class BookCursorAdapter extends CursorAdapter {
public BookCursorAdapter(Context context, Cursor c) {
super(context, c, 0);
}
@Override
public View newView(final Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
}
@Override
public void bindView(View view, final Context context, Cursor cursor) {
int position = cursor.getPosition();
TextView textViewBookName = view.findViewById(R.id.book_name);
TextView textViewBookPrice = view.findViewById(R.id.book_price);
TextView textViewBookQuantity = view.findViewById(R.id.book_quantity);
Button saleButton = view.findViewById(R.id.book_sale_button);
if (position % 2 == 0) {
view.setBackgroundColor(context.getResources().getColor(R.color.light_row_background));
} else {
view.setBackgroundColor(context.getResources().getColor(R.color.book_icon_background));
}
final int bookId = cursor.getInt(cursor.getColumnIndexOrThrow(BookEntry._ID));
final String bookName = cursor.getString(cursor.getColumnIndexOrThrow(BookEntry.COLUMN_BOOK_NAME));
String bookPrice = cursor.getString(cursor.getColumnIndexOrThrow(BookEntry.COLUMN_BOOK_PRICE));
final String bookQuantity = cursor.getString(cursor.getColumnIndexOrThrow(BookEntry.COLUMN_BOOK_QUANTITY));
textViewBookName.setText(bookName);
textViewBookPrice.setText(context.getString(R.string.currency_symbol, bookPrice));
textViewBookQuantity.setText(context.getString(R.string.quantity_string, bookQuantity));
saleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Reduce the quantity by one when Sale button is pressed
int quantity = Integer.parseInt(bookQuantity) - 1;
ContentValues values = new ContentValues();
values.put(BookEntry.COLUMN_BOOK_QUANTITY, quantity);
Uri updateUri = ContentUris.withAppendedId(BookEntry.CONTENT_URI, bookId);
context.getContentResolver().update(updateUri, values, null, null);
Toast.makeText(context, "Sold one " + bookName , Toast.LENGTH_SHORT).show();
}
});
if (Integer.parseInt(bookQuantity) > 0) {
saleButton.setVisibility(View.VISIBLE);
} else {
//Hide sale button when quantity is 0
saleButton.setVisibility(View.GONE);
}
}
}
| [
"ngupta@columbiacountyga.gov"
] | ngupta@columbiacountyga.gov |
b69c445075b5702696dfad7268c956b1489ea7f8 | 4118738bfad220f38b98243a4070fdd3171ca8e4 | /src/test/java/com/w2a/listeners/CustomListeners.java | 59c472247c05a0fc528ab2961b4095dbd9d0886f | [] | no_license | RoshAutomation/DataDrivenTesting | 636d3c03eee711b9459acdc2a6b7ecbac723c54b | 126665834db5762d91a5c797922c55f223ce9bde | refs/heads/master | 2020-03-27T03:03:24.491825 | 2018-08-23T14:23:54 | 2018-08-23T14:23:54 | 145,836,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,894 | java | package com.w2a.listeners;
import java.io.IOException;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.SkipException;
import com.relevantcodes.extentreports.LogStatus;
import com.w2a.base.TestBase;
import com.w2a.utilities.TestUtil;
public class CustomListeners extends TestBase implements ITestListener{
public void onTestStart(ITestResult result) {
;
test=rep.startTest(result.getName().toUpperCase());
//runmodes - Y
}
public void onTestSuccess(ITestResult result) {
test.log(LogStatus.PASS, result.getName().toUpperCase()+" PASS");
rep.endTest(test);
rep.flush();
}
public void onTestFailure(ITestResult result) {
System.setProperty("org.uncommons.reportng.escape-output", "false");
try {
TestUtil.takeScreenshotAtEndOfTest();
} catch (IOException e) {
e.printStackTrace();
}
test.log(LogStatus.FAIL,result.getName().toUpperCase()+ " Failed with exception : "+result.getThrowable());
test.log(LogStatus.FAIL,test.addScreenCapture(TestUtil.screenshotName));
Reporter.log("Capturing Screenshot");
Reporter.log("<a target=\"blank\" href="+TestUtil.screenshotName+">Screenshot</a>");
Reporter.log("<br>");
Reporter.log("<a target=\"blank\" href="+TestUtil.screenshotName+"><img src="+TestUtil.screenshotName+" height=200 width=200></img></a>");
rep.endTest(test);
rep.flush();
}
public void onTestSkipped(ITestResult result) {
test.log(LogStatus.SKIP, result.getName().toUpperCase()+" Skipped the Test Case");
rep.endTest(test);
rep.flush();
}
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
}
public void onStart(ITestContext context) {
// TODO Auto-generated method stub
}
public void onFinish(ITestContext context) {
// TODO Auto-generated method stub
}
}
| [
"roshankg96@gmail.com"
] | roshankg96@gmail.com |
b64da3b092f3d53b8707dc9ae892403afaef5b56 | 2ded1aa3b59c5c1998009dc143f8ad89db6a486a | /sdfs/src/main/java/sdfs/sdfs/Policy.java | 8e8e0858c2a3320e48bd3cac4d192202b11904a3 | [] | no_license | kelseyfrancis/sdfs | 44984223b31cede4ba028e78d1a4de4c098dfd56 | e7852358b05efac931ec723ac265e02175afce7e | refs/heads/master | 2021-01-10T21:03:50.153089 | 2013-04-27T02:58:44 | 2013-04-27T02:58:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,295 | java | package sdfs.sdfs;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import org.joda.time.Instant;
import sdfs.CN;
class Policy {
final Config x;
Policy(Config x) {
this.x = x;
}
PrincipalRights principalRights(CN cn) {
try {
return new PrincipalRights(x.getConfig(cn.name));
} catch (Exception e) {
return new PrincipalRights(ConfigFactory.empty());
}
}
Policy grantOwner(CN cn) {
return new Policy(
x.withValue(
cn.name,
principalRights(cn).setOwner(true).x.root()
)
);
}
Policy delegate(CN from, CN to, Right right, Instant expiration, Instant now) {
PrincipalRights fromRights = principalRights(from);
if (!fromRights.mayGrant(right, now)) {
throw new AccessControlException();
}
Instant fromExpiration = fromRights.getExpiration(right);
if (fromExpiration != null && fromExpiration.isBefore(expiration)) {
expiration = fromExpiration;
}
return new Policy(
x.withValue(
to.name,
principalRights(to).delegate(right, expiration).x.root()
)
);
}
}
| [
"ch.martin@gmail.com"
] | ch.martin@gmail.com |
e34804b92871353726507ded4ca58140f292bcdc | b71f41cb5a4fc0a7ca4bb940d04a49b1800f3a7c | /src/d30_10_18/Eleven_six.java | 26561430f42fbba8f711a6bca8389d813183724c | [] | no_license | sainsh/classromm | 52108184ed6844c7a616b1be4b56eaf8b30021e0 | 84780722a7692f9b4e2a7a9d3d5102b1c5e9c059 | refs/heads/master | 2020-04-03T14:57:02.855319 | 2018-11-06T07:41:07 | 2018-11-06T07:41:07 | 155,343,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 469 | java | package d30_10_18;
import javafx.scene.shape.Circle;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Eleven_six {
public static void main(String[] args) {
List<Object> list = new ArrayList<>();
list.add(new Loan());
list.add(new Date());
list.add("random text");
list.add(new Circle());
for(Object o:list){
System.out.println(o.toString());
}
}
}
| [
"kfsainsh@gmail.com"
] | kfsainsh@gmail.com |
9d34832877e766ba7b78513c1656ecdf07c8bdee | 92691b49bc6294a41094f0ffd6b694023c0e5cb3 | /Java/Core_Java/12_OverLoading/mainclass1.java | cb4edbf934d7c404655c4567f9ff9d9b6d693132 | [] | no_license | hardodehack/Java | 673b5d2a09e32e50f67d67310f52a0bc6c1042a3 | 5e26c0eeb418fb1ed950a9d690b5b98be3a11b7d | refs/heads/master | 2021-01-14T14:16:08.154651 | 2016-01-16T19:07:42 | 2016-01-16T19:07:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 340 | java | class hardik
{
static void h1(int arg)
{
int a1=arg;
System.out.println("h1 running"+a1);
}
static void h1(double arg)
{
double d1 = arg;
System.out.println("h1 doble running"+d1);
}
}
class mainclass1
{
public static void main(String[] args)
{
hardik.h1(25.25);
//System.out.println("Hello World!");
}
}
| [
"hnpatel6787@gmail.com"
] | hnpatel6787@gmail.com |
2e9258be35ea6ccd8613a135595f40e0008a6220 | 92234b40626160cd7cd65916229fc918b48e959e | /3.JavaMultithreading/src/com/javarush/task/task21/task2106/Solution.java | 5a0f9203d9dd9c14d41df353d1c0db401a32b695 | [] | no_license | evoyager/JavaRushTasks | 3c2394e978832be0e5709155d68c6b42a986cff1 | e3c43648f322790c16c415bd8c42266e99d35058 | refs/heads/master | 2020-04-20T08:56:59.789305 | 2019-05-28T19:47:54 | 2019-05-28T19:47:54 | 168,753,799 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,819 | java | package com.javarush.task.task21.task2106;
import java.util.Date;
/*
Ошибка в equals/hashCode
*/
public class Solution {
private int anInt;
private String string;
private double aDouble;
private Date date;
private Solution solution;
public Solution(int anInt, String string, double aDouble, Date date, Solution solution) {
this.anInt = anInt;
this.string = string;
this.aDouble = aDouble;
this.date = date;
this.solution = solution;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Solution)) return false;
if (o == null || getClass() != o.getClass()) {
return false;
}
Solution solution1 = (Solution) o;
if (anInt != solution1.anInt) return false;
if (string != null ? !string.equals(solution1.string) : solution1.string != null) return false;
if (Double.compare(solution1.aDouble, aDouble) != 0) return false;
if (date != null ? !date.equals(solution1.date) : solution1.date != null) return false;
if (solution != null ? !solution.equals(solution1.solution) : solution1.solution != null) return false;
return true;
}
@Override
public int hashCode() {
int result = 7;
long temp;
result = 31 * result + anInt;
result = 31 * result + (solution == null ? 0: string.hashCode());
temp = aDouble != +0.0d ? Double.doubleToLongBits(aDouble) : 0L;
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (date == null ? 0: date.hashCode());
result = 31 * result + (solution != null ? solution.hashCode() : 0);
return result;
}
public static void main(String[] args) {
}
}
| [
"igusar@corelogic.com"
] | igusar@corelogic.com |
b0b75597ed14200b2f6c71dabab6e5d8a5f81f8c | 21e8581ae7007f1ca03a4240346dc0b7a6c680f5 | /app/src/main/java/com/manuelrojas/geomusic/data/repository/datasource/db/TrackDao.java | 481a7a2d97f594c7da85c4a26808489937247862 | [] | no_license | leuamrojas/GeoMusic | 834839a68cb0cc8687a0558cc9d7414c38b36482 | 37eaca6e5db7a4b0ead097bd658fa513aa4615b6 | refs/heads/master | 2020-08-30T17:12:54.732556 | 2019-11-05T19:06:48 | 2019-11-05T19:06:48 | 218,441,070 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 968 | java | package com.manuelrojas.geomusic.data.repository.datasource.db;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import com.manuelrojas.geomusic.data.entity.TrackEntity;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Observable;
@Dao
public interface TrackDao extends BaseDao<TrackEntity> {
@Query(value = "SELECT * FROM track")
// Observable<List<TrackEntity>> getAllTracks();
List<TrackEntity> getAllTracks();
@Query(value = "SELECT * FROM track WHERE id = :trackId")
Observable<TrackEntity> getTrackById(String trackId);
@Query(value = "SELECT * FROM track WHERE artist_id = :artistId")
Observable<List<TrackEntity>> getTrackByArtist(String artistId);
@Insert(onConflict = OnConflictStrategy.REPLACE)
long insertReplace(TrackEntity trackEntity);
@Query("DELETE FROM track")
Completable deleteAllTracks();
}
| [
"leuamrojas@hotmail.com"
] | leuamrojas@hotmail.com |
c7c642ae12f928ade4f3883cd5461d168bc3a78d | f72971fbab14458776400d240216442d8a46cbe1 | /modules/common/src/main/java/wsimport/lib/sabre/bfm/POSType.java | 2eefd0e742d656e743a8df01587780cc11b746fe | [] | no_license | hamzzy/Amadeus-Sabre-Java-Multi-GDS-SDK | cea5ee9f3be520bfbf509d5207adcc7c0f4ec4b8 | a21e706c17b85d99e1ef573f66c88efa9e2918fe | refs/heads/master | 2022-11-05T16:49:24.067050 | 2020-06-28T03:59:13 | 2020-06-28T03:59:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,824 | java |
package wsimport.lib.sabre.bfm;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.*;
/**
* Point of Sale (POS) is the details identifying the party or connection channel making the request.
*
* <p>Java class for POS_Type complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="POS_Type">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Source" type="{http://www.opentravel.org/OTA/2003/05}SourceType" maxOccurs="5"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "POS_Type", propOrder = {
"source"
})
@XmlSeeAlso({OTAAirLowFareSearchRQ.class})
public class POSType {
@XmlElement(name = "Source", required = true)
protected List<SourceType> source;
/**
* Gets the value of the source property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the source property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSource().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link SourceType }
*
*
*/
public List<SourceType> getSource() {
if (source == null) {
source = new ArrayList<SourceType>();
}
return this.source;
}
}
| [
"info@brakket.tech"
] | info@brakket.tech |
69d7bff064ec48a4a48213c019918075b0cf1b28 | 0943c01b59f4d8bbab045d83adae0b015e935cba | /old/src/main/java/hat/bemo/measure/set/MeasureController.java | e913041bdec3ba637abcceadddc48e8cb4c11fa8 | [
"Apache-2.0"
] | permissive | 18271261642/RingmiiHX | c31c4609e6d126d12107c5f6aabaf4959659f308 | 3f1f840a1727cdf3ee39bc1b8d8aca4d2c3ebfcb | refs/heads/master | 2021-06-28T10:28:58.649906 | 2020-08-16T02:27:28 | 2020-08-16T02:27:28 | 230,220,762 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 11,596 | java | package hat.bemo.measure.set;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
import org.apache.http.NameValuePair;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;
import hat.bemo.APIupload.Controller;
import hat.bemo.BlueTooth.blegatt.api.ChangeDateFormat;
import hat.bemo.MyApplication;
import hat.bemo.measure.setting_db.MeasureDAO;
import hat.bemo.measure.setting_db.VO_BG_DATA;
import hat.bemo.measure.setting_db.VO_BO_DATA;
import hat.bemo.measure.setting_db.VO_BP_DATA;
import hat.bemo.measure.setting_db.VO_BW_DATA;
import hat.bemo.measure.setting_db.VO_Temp_DATA;
public class MeasureController {
public final static String HTTP = "http://";
public final static String SERVER_HOST_0x36 = "/APP/GcareUploadBloodPressureData.html";
public final static String SERVER_HOST_0x37 = "/APP/GcareUploadBloodSugarData.html";
public final static String SERVER_HOST_0x38 = "/APP/GcareUploadBloodOxygenData.html";
public final static String SERVER_HOST_0x39 = "/APP/GcareUploadWeightData.html";
public final static String SERVER_HOST_0x3A = "/APP/GcareUploadTemperatureData.html";
public final static String type_0x36 = "0x36";
public final static String type_0x37 = "0x37";
public final static String type_0x38 = "0x38";
public final static String type_0x39 = "0x39";
public final static String type_0x3A = "0x3A";
private static String CreateDate;
private static String TimeStamp;
private static MeasureDAO dao;
private List<NameValuePair> ValuePair;
private MeasureFieldName fn;
private String DataJosn;
private String DataHash;
private MeasureJsonFormat json;
private String URL;
private String TYPE;
private static VO_BP_DATA vobpdata;
private static VO_BG_DATA vobgdata;
private static VO_BO_DATA vobodata;
private static VO_BW_DATA vobwdata;
private static VO_Temp_DATA votempdata;
public static Context context;
private TelephonyManager telephonyManager;
public static String IMEI;
private String Gkey = "AAAAAAAAZZZZZZZZZZZZ999999999";
private String GkeyId = "1";
private static ArrayList<VO_BP_DATA> vo_801203;
private static ArrayList<VO_BG_DATA> vo_801204;
private static ArrayList<VO_BO_DATA> vo_801205;
private static ArrayList<VO_BW_DATA> vo_801206;
private static ArrayList<VO_Temp_DATA> vo_801207;
@SuppressWarnings("static-access")
public void LoData(final Context context, String type) {
this.context = context;
dao = new MeasureDAO();
CreateDate = ChangeDateFormat.CreateDate();
TimeStamp = ChangeDateFormat.TimeStamp();
telephonyManager = (TelephonyManager)context.getSystemService(context.TELEPHONY_SERVICE);
IMEI = telephonyManager.getDeviceId();
if (json == null)
json = new MeasureJsonFormat();
if (fn == null)
fn = new MeasureFieldName();
ESettings_type mSetting_type = ESettings_type.ByStr(type);
switch (mSetting_type) {
case type_0x36:
vo_801203 = dao.Get_BP_MeasurementRecord(context);
if (vo_801203 != null) {
for (int i = 0; i < vo_801203.size(); i++) {
vobpdata = vo_801203.get(i);
}
DataJosn = json.jsonformat(type_0x36,
vobpdata.getAccount(),
vobpdata.getAFIB(),
vobpdata.getAM(),
vobpdata.getARR(),
vobpdata.getBS_TIME(),
ChangeDateFormat.CreateDate(),
vobpdata.getDATA_TYPE(),
vobpdata.getDIAGNOSTIC_MODE(),
vobpdata.getHIGH_PRESSURE(),
vobpdata.getLOW_PRESSURE(),
vobpdata.getMODEL(),
vobpdata.getPLUS(),
vobpdata.getPM(),
vobpdata.getRES(),
vobpdata.getUSUAL_MODE(),
vobpdata.getYEAR());
URL = HTTP+ Controller.Check_IP()+SERVER_HOST_0x36;
TYPE = type_0x36;
DataHash = encrypt(Gkey, TimeStamp, DataJosn);
ValuePair = fn.NameValuePair(DataHash, GkeyId, TimeStamp, DataJosn);
PostData();
Log.e(TYPE, "上傳血壓記錄");
}
else{
Log.e(TYPE, "血壓記錄上傳完畢");
}
break;
case type_0x37:
vo_801204 = dao.Get_BG_MeasurementRecord(context);
if (vo_801204 != null) {
for (int i = 0; i < vo_801204.size(); i++) {
vobgdata = vo_801204.get(i);
}
// new
DataJosn = json.jsonformat(type_0x37,
vobgdata.getAccount(),
// "799999999999999",
vobgdata.getUnit(),
vobgdata.getGlu(),
vobgdata.getBsTime(),
vobgdata.getHemoglobin(),
vobgdata.getBloodFlowVelocity());
// old
// DataJosn = json.jsonformat(type_0x37,
// vobgdata.getAccount(),
// vobgdata.getUnit(),
// vobgdata.getGlu(),
// ChangeDateFormat.CreateDate(),
// "1",
// ChangeDateFormat.CreateDate());
URL = HTTP+Controller.Check_IP()+SERVER_HOST_0x37;
TYPE = type_0x37;
DataHash = encrypt(Gkey, TimeStamp, DataJosn);
ValuePair = fn.NameValuePair(DataHash, GkeyId, TimeStamp, DataJosn);
PostData();
Log.e(TYPE, "上傳血糖記錄");
}
else{
Log.e(TYPE, "血糖記錄上傳完畢");
}
break;
case type_0x38:
vo_801205 = dao.Get_BO_MeasurementRecord(context);
if (vo_801205 != null) {
for (int i = 0; i < vo_801205.size(); i++) {
vobodata = vo_801205.get(i);
}
DataJosn = json.jsonformat(type_0x38,
vobodata.getAccount(),
vobodata.getOXY_TIME(),
vobodata.getOXY_COUNT(),
vobodata.getPLUS(),
vobodata.getSPO2(),
ChangeDateFormat.CreateDate());
URL = HTTP+Controller.Check_IP()+SERVER_HOST_0x38;
TYPE = type_0x38;
DataHash = encrypt(Gkey, TimeStamp, DataJosn);
ValuePair = fn.NameValuePair(DataHash, GkeyId, TimeStamp, DataJosn);
PostData();
Log.e(TYPE, "上傳血氧記錄");
}
else{
Log.e(TYPE, "血氧記錄上傳完畢");
}
break;
case type_0x39:
vo_801206 = dao.Get_BW_MeasurementRecord(context);
if (vo_801206 != null) {
for (int i = 0; i < vo_801206.size(); i++) {
vobwdata = vo_801206.get(i);
}
DataJosn = json.jsonformat(type_0x39,
vobwdata.getAccount(),
vobwdata.getBFTime(),
vobwdata.getHeight(),
vobwdata.getSex(),
vobwdata.getUnit(),
vobwdata.getBw(),
vobwdata.getBmi(),
vobwdata.getRecycle(),
vobwdata.getOrganFat(),
vobwdata.getBone(),
vobwdata.getBirthYear(),
vobwdata.getBirthMonth(),
vobwdata.getBirthDay(),
vobwdata.getAge(),
vobwdata.getMuscle(),
vobwdata.getResister(),
vobwdata.getAqua(),
ChangeDateFormat.CreateDate());
URL = HTTP+Controller.Check_IP()+SERVER_HOST_0x39;
TYPE = type_0x39;
DataHash = encrypt(Gkey, TimeStamp, DataJosn);
ValuePair = fn.NameValuePair(DataHash, GkeyId, TimeStamp, DataJosn);
PostData();
Log.e(TYPE, "上傳體重記錄");
}
else{
Log.e(TYPE, "體重記錄上傳完畢");
}
break;
case type_0x3A:
vo_801207 = dao.Get_TEMP_MeasurementRecord(context);
if (vo_801207 != null) {
for (int i = 0; i < vo_801207.size(); i++) {
votempdata = vo_801207.get(i);
}
DataJosn = json.jsonformat(type_0x3A,
votempdata.getAccount(),
votempdata.getBS_TIME(),
votempdata.getTYPE_T(),
votempdata.getUINT(),
votempdata.getTEMP(),
ChangeDateFormat.CreateDate());
URL = HTTP+Controller.Check_IP()+SERVER_HOST_0x3A;
TYPE = type_0x3A;
DataHash = encrypt(Gkey, TimeStamp, DataJosn);
ValuePair = fn.NameValuePair(DataHash, GkeyId, TimeStamp, DataJosn);
PostData();
Log.e(TYPE, "上傳耳溫記錄");
}
else{
Log.e(TYPE, "耳溫記錄上傳完畢");
}
break;
}
}
public static void delete0x36(){
for (int i = 0; i < vo_801203.size(); i++) {
vobpdata = vo_801203.get(i);
}
vo_801203.clear();
MyApplication.cro.LoData(MyApplication.context, MeasureController.type_0x36);
}
public static void delete0x37(){
for (int i = 0; i < vo_801204.size(); i++) {
vobgdata = vo_801204.get(i);
}
vo_801204.clear();
MyApplication.cro.LoData(MyApplication.context, MeasureController.type_0x37);
}
public static void delete0x38(){
for (int i = 0; i < vo_801205.size(); i++) {
vobodata = vo_801205.get(i);
}
vo_801205.clear();
MyApplication.cro.LoData(MyApplication.context, MeasureController.type_0x38);
}
public static void delete0x39(){
for (int i = 0; i < vo_801206.size(); i++) {
vobwdata = vo_801206.get(i);
}
vo_801206.clear();
MyApplication.cro.LoData(MyApplication.context, MeasureController.type_0x39);
}
public static void delete0x3A(){
for (int i = 0; i < vo_801207.size(); i++) {
votempdata = vo_801207.get(i);
}
vo_801207.clear();
MyApplication.cro.LoData(MyApplication.context, MeasureController.type_0x3A);
}
private void PostData() {
new Thread() {
public void run() {
try {
Log.e("URL", URL);
new MeasureHttpPostData(URL, TYPE, ValuePair, context);
ValuePair = null;
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
public static String encrypt(String account, String pwd, String timeStamp){
//String timeStamp = getTimesgetTimes(); //加密還不需%20取代空格
String dataStructure = account + pwd + timeStamp;
Log.e("dataStructure", dataStructure);
MessageDigest shaCode = null;
try {
shaCode = MessageDigest.getInstance("SHA-256");
shaCode.update(dataStructure.getBytes());
//System.out.println("dataStructure="+dataStructure);
}
catch(Exception e) {
e.printStackTrace();
return "";
}
return byte2Hex(shaCode.digest());
}
public static String encrypt2(String account){
//String timeStamp = getTimesgetTimes(); //加密還不需%20取代空格
MessageDigest shaCode = null;
try {
shaCode = MessageDigest.getInstance("SHA-256");
shaCode.update(account.getBytes());
//System.out.println("dataStructure="+dataStructure);
}
catch(Exception e) {
e.printStackTrace();
return "";
}
return byte2Hex(shaCode.digest());
}
private static String byte2Hex(byte[] data) {
String hexString = "";
String stmp = "";
for(int i = 0; i < data.length; i++) {
stmp = Integer.toHexString(data[i] & 0XFF);
if(stmp.length() == 1) {
hexString = hexString + "0" + stmp;
}
else {
hexString = hexString + stmp;
}
}
return hexString.toUpperCase();
}
public enum ESettings_type {
type_0x36("0x36"),
type_0x37("0x37"),
type_0x38("0x38"),
type_0x39("0x39"),
type_0x3A("0x3A"),
type_err ("");
private String type;
ESettings_type(String str){
this.type = str;
}
public static ESettings_type ByStr(final String val)
{
for (ESettings_type type : ESettings_type.values())
{
if (type.type.equals(val))
{
return type;
}
}
return type_err; //Never return null
}
}
} | [
"runningmaggot@163.com"
] | runningmaggot@163.com |
3293cf0ea6c19f83567d4fb5d06a2332691c0983 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/thinkaurelius--titan/76469e0497df2c3790bbe3bdfeb7f4fd790646a7/after/TitanBlueprintsGraph.java | a9c2af8932779a4b37de355d76f3180f9658ce2f | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,009 | java | package com.thinkaurelius.titan.graphdb.blueprints;
import com.thinkaurelius.titan.core.*;
import com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration;
import com.thinkaurelius.titan.graphdb.database.StandardTitanGraph;
import com.thinkaurelius.titan.graphdb.util.ExceptionFactory;
import com.tinkerpop.blueprints.*;
import com.tinkerpop.blueprints.Parameter;
import com.tinkerpop.blueprints.util.StringFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* Blueprints specific implementation for {@link TitanGraph}.
* Handles thread-bound transactions.
*
* @author Matthias Broecheler (me@matthiasb.com)
*/
public abstract class TitanBlueprintsGraph implements TitanGraph {
private static final Logger log =
LoggerFactory.getLogger(TitanBlueprintsGraph.class);
// ########## TRANSACTION HANDLING ###########################
private ThreadLocal<TitanBlueprintsTransaction> txs = new ThreadLocal<TitanBlueprintsTransaction>() {
protected TitanBlueprintsTransaction initialValue() {
return null;
}
};
/**
* ThreadLocal transactions used behind the scenes in
* {@link TransactionalGraph} methods. Transactions started through
* {@code ThreadedTransactionalGraph#newTransaction()} aren't included in
* this map. Contrary to the javadoc comment above
* {@code ThreadedTransactionalGraph#newTransaction()}, the caller is
* responsible for holding references to and committing or rolling back any
* transactions started through
* {@code ThreadedTransactionalGraph#newTransaction()}.
*/
private final Map<TitanBlueprintsTransaction, Boolean> openTx =
new ConcurrentHashMap<TitanBlueprintsTransaction, Boolean>();
@Override
public void commit() {
TitanTransaction tx = txs.get();
if (tx != null && tx.isOpen()) {
try {
tx.commit();
} finally {
txs.remove();
openTx.remove(tx);
log.debug("Committed thread-bound transaction {}", tx);
}
}
}
@Override
public void rollback() {
TitanTransaction tx = txs.get();
if (tx != null && tx.isOpen()) {
try {
tx.rollback();
} finally {
txs.remove();
openTx.remove(tx);
log.debug("Rolled back thread-bound transaction {}", tx);
}
}
}
@Override
@Deprecated
public void stopTransaction(Conclusion conclusion) {
switch (conclusion) {
case SUCCESS:
commit();
break;
case FAILURE:
rollback();
break;
default:
throw new IllegalArgumentException("Unrecognized conclusion: " + conclusion);
}
}
public abstract TitanTransaction newThreadBoundTransaction();
private TitanBlueprintsTransaction getAutoStartTx() {
if (txs == null) ExceptionFactory.graphShutdown();
TitanBlueprintsTransaction tx = txs.get();
if (tx == null) {
tx = (TitanBlueprintsTransaction) newThreadBoundTransaction();
txs.set(tx);
openTx.put(tx, Boolean.TRUE);
log.debug("Created new thread-bound transaction {}", tx);
}
return tx;
}
public TitanTransaction getCurrentThreadTx() {
return getAutoStartTx();
}
@Override
public synchronized void shutdown() {
for (TitanTransaction tx : openTx.keySet()) {
tx.commit();
}
openTx.clear();
txs = null;
}
@Override
public String toString() {
GraphDatabaseConfiguration config = ((StandardTitanGraph) this).getConfiguration();
return "titangraph" + StringFactory.L_BRACKET +
config.getBackendDescription() + StringFactory.R_BRACKET;
// return StringFactory.graphString(this,config.getBackendDescription());
}
// ########## INDEX HANDLING ###########################
@Override
public <T extends Element> void dropKeyIndex(String key, Class<T> elementClass) {
throw new UnsupportedOperationException("Key indexes cannot be dropped");
}
@Override
public <T extends Element> void createKeyIndex(String key, Class<T> elementClass, final Parameter... indexParameters) {
getAutoStartTx().createKeyIndex(key, elementClass);
}
@Override
public <T extends Element> Set<String> getIndexedKeys(Class<T> elementClass) {
return getAutoStartTx().getIndexedKeys(elementClass);
}
// ########## TRANSACTIONAL FORWARDING ###########################
@Override
public TitanVertex addVertex(Object id) {
return getAutoStartTx().addVertex(id);
}
@Override
public TitanVertex getVertex(Object id) {
return getAutoStartTx().getVertex(id);
}
@Override
public void removeVertex(Vertex vertex) {
getAutoStartTx().removeVertex(vertex);
}
@Override
public Iterable<Vertex> getVertices() {
return getAutoStartTx().getVertices();
}
@Override
public KeyMaker makeKey(String name) {
return getAutoStartTx().makeKey(name);
}
@Override
public LabelMaker makeLabel(String name) {
return getAutoStartTx().makeLabel(name);
}
@Override
public TitanGraphQuery query() {
return getAutoStartTx().query();
}
@Override
public TitanIndexQuery indexQuery(String indexName, String query) {
return getAutoStartTx().indexQuery(indexName,query);
}
@Override
public TitanMultiVertexQuery multiQuery(TitanVertex... vertices) {
return getAutoStartTx().multiQuery(vertices);
}
@Override
public TitanMultiVertexQuery multiQuery(Collection<TitanVertex> vertices) {
return getAutoStartTx().multiQuery(vertices);
}
@Override
public TitanType getType(String name) {
return getAutoStartTx().getType(name);
}
@Override
public Iterable<Vertex> getVertices(String key, Object value) {
return getAutoStartTx().getVertices(key, value);
}
@Override
public TitanEdge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label) {
return getAutoStartTx().addEdge(id, outVertex, inVertex, label);
}
@Override
public TitanEdge getEdge(Object id) {
return getAutoStartTx().getEdge(id);
}
@Override
public void removeEdge(Edge edge) {
getAutoStartTx().removeEdge(edge);
}
@Override
public Iterable<Edge> getEdges() {
return getAutoStartTx().getEdges();
}
@Override
public Iterable<Edge> getEdges(String key, Object value) {
return getAutoStartTx().getEdges(key, value);
}
} | [
"fraczwojciech@gmail.com"
] | fraczwojciech@gmail.com |
9ac0bd05cd6dd500e93d4b718040bedb7ef88afa | e456ff29a294401a05ecad61908918747468f4c8 | /climbing-consumer/src/main/java/com/nicolasboueme/climbing/consumer/contract/dao/UserDao.java | 21775090e2d8b55264d996ab5f4ceade2d6146a9 | [] | no_license | nboueme/climbing-community | 083af40f49717f89e6107f5bb977529043253fbc | 6c28c71a83580ae7cc4eae8b613fd7b023cebd39 | refs/heads/master | 2021-03-27T15:10:12.353845 | 2017-12-19T10:57:01 | 2017-12-19T10:57:01 | 110,672,702 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 356 | java | package com.nicolasboueme.climbing.consumer.contract.dao;
import com.nicolasboueme.climbing.model.entity.UserAccount;
public interface UserDao {
void addUser(UserAccount user);
UserAccount getUser(UserAccount user);
void deleteUserPicture(UserAccount user);
void updateUser(UserAccount user);
void deleteUser(UserAccount user);
}
| [
"nicolasboueme@gmail.com"
] | nicolasboueme@gmail.com |
b50ff096797fe21c20d6ba79e9f942cfaf91b980 | cd3744f4bd7c12f4b3b475d36c37d553bb156aa1 | /REST/src/main/java/com/example/demo/model/student.java | 3992871353d9692a281fb9eda341110b3c15e46e | [] | no_license | FarzeenAlam/RestWithPostMan | 9515ed06b4b1553b827fcdc306ecd9b5c1047134 | 1d29acd249614f8605ce6e7e99c2fa8592dbcfb5 | refs/heads/main | 2023-01-21T10:56:00.022920 | 2020-12-03T10:24:03 | 2020-12-03T10:24:03 | 318,154,246 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 873 | java | package com.example.demo.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class student
{
@Id
@GeneratedValue
@Column(name="Std_Id")
private int Id;
@Column(name="Name")
private String Name;
@Column(name="Position")
private String Position;
public student() {
}
public int getId() {
return Id;
}
public void setId(int id) {
Id = id;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getPosition() {
return Position;
}
public void setPosition(String position) {
Position = position;
}
@Override
public String toString() {
return "student [Id=" + Id + ", Name=" + Name + ", Position=" + Position + "]";
}
}
| [
"noreply@github.com"
] | noreply@github.com |
dccb73e99f770009e7d6a2d2a9ab94d6d3e3c1ce | f3ffe3c8d3ca7d46451198fdcff7124ac9d27e51 | /sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/TasksClientImpl.java | b711bda43ef4d5dcf899593719dc4e041f5a335c | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-or-later",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-generic-cla"
] | permissive | pmakani/azure-sdk-for-java | 7f0a0e3832a66f53eeb3ee09a4fe08a0033c9faf | 6b259d1ea07342ceeccd89615348f8e0db02d4c6 | refs/heads/master | 2022-12-24T05:44:30.317176 | 2020-09-29T07:53:49 | 2020-09-29T07:53:49 | 299,564,055 | 1 | 0 | MIT | 2020-09-29T09:12:59 | 2020-09-29T09:12:58 | null | UTF-8 | Java | false | false | 79,046 | java | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.containerregistry.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.containerregistry.fluent.TasksClient;
import com.azure.resourcemanager.containerregistry.fluent.models.TaskInner;
import com.azure.resourcemanager.containerregistry.models.TaskListResult;
import com.azure.resourcemanager.containerregistry.models.TaskUpdateParameters;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in TasksClient. */
public final class TasksClientImpl implements TasksClient {
private final ClientLogger logger = new ClientLogger(TasksClientImpl.class);
/** The proxy service used to perform REST calls. */
private final TasksService service;
/** The service client containing this operation class. */
private final ContainerRegistryManagementClientImpl client;
/**
* Initializes an instance of TasksClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
TasksClientImpl(ContainerRegistryManagementClientImpl client) {
this.service = RestProxy.create(TasksService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for ContainerRegistryManagementClientTasks to be used by the proxy
* service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "ContainerRegistryMan")
private interface TasksService {
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<TaskListResult>> list(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks/{taskName}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<TaskInner>> get(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
@PathParam("taskName") String taskName,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Put(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks/{taskName}")
@ExpectedResponses({200, 201})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> create(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
@PathParam("taskName") String taskName,
@BodyParam("application/json") TaskInner taskCreateParameters,
Context context);
@Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
@Delete(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks/{taskName}")
@ExpectedResponses({200, 202, 204})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> delete(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
@PathParam("taskName") String taskName,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Patch(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks/{taskName}")
@ExpectedResponses({200, 201})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> update(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
@PathParam("taskName") String taskName,
@BodyParam("application/json") TaskUpdateParameters taskUpdateParameters,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry"
+ "/registries/{registryName}/tasks/{taskName}/listDetails")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<TaskInner>> getDetails(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("registryName") String registryName,
@QueryParam("api-version") String apiVersion,
@PathParam("taskName") String taskName,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<TaskListResult>> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<TaskInner>> listSinglePageAsync(String resourceGroupName, String registryName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.list(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
context))
.<PagedResponse<TaskInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<TaskInner>> listSinglePageAsync(
String resourceGroupName, String registryName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.list(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<TaskInner> listAsync(String resourceGroupName, String registryName) {
return new PagedFlux<>(
() -> listSinglePageAsync(resourceGroupName, registryName), nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<TaskInner> listAsync(String resourceGroupName, String registryName, Context context) {
return new PagedFlux<>(
() -> listSinglePageAsync(resourceGroupName, registryName, context),
nextLink -> listNextSinglePageAsync(nextLink, context));
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<TaskInner> list(String resourceGroupName, String registryName) {
return new PagedIterable<>(listAsync(resourceGroupName, registryName));
}
/**
* Lists all the tasks for a specified container registry.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<TaskInner> list(String resourceGroupName, String registryName, Context context) {
return new PagedIterable<>(listAsync(resourceGroupName, registryName, context));
}
/**
* Get the properties of a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the properties of a specified task.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<TaskInner>> getWithResponseAsync(
String resourceGroupName, String registryName, String taskName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.get(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the properties of a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the properties of a specified task.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<TaskInner>> getWithResponseAsync(
String resourceGroupName, String registryName, String taskName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.get(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context);
}
/**
* Get the properties of a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the properties of a specified task.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<TaskInner> getAsync(String resourceGroupName, String registryName, String taskName) {
return getWithResponseAsync(resourceGroupName, registryName, taskName)
.flatMap(
(Response<TaskInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Get the properties of a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the properties of a specified task.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner get(String resourceGroupName, String registryName, String taskName) {
return getAsync(resourceGroupName, registryName, taskName).block();
}
/**
* Get the properties of a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the properties of a specified task.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<TaskInner> getWithResponse(
String resourceGroupName, String registryName, String taskName, Context context) {
return getWithResponseAsync(resourceGroupName, registryName, taskName, context).block();
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
if (taskCreateParameters == null) {
return Mono
.error(new IllegalArgumentException("Parameter taskCreateParameters is required and cannot be null."));
} else {
taskCreateParameters.validate();
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.create(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
taskCreateParameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskInner taskCreateParameters,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
if (taskCreateParameters == null) {
return Mono
.error(new IllegalArgumentException("Parameter taskCreateParameters is required and cannot be null."));
} else {
taskCreateParameters.validate();
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.create(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
taskCreateParameters,
context);
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PollerFlux<PollResult<TaskInner>, TaskInner> beginCreateAsync(
String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
Mono<Response<Flux<ByteBuffer>>> mono =
createWithResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters);
return this
.client
.<TaskInner, TaskInner>getLroResult(
mono, this.client.getHttpPipeline(), TaskInner.class, TaskInner.class, Context.NONE);
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private PollerFlux<PollResult<TaskInner>, TaskInner> beginCreateAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskInner taskCreateParameters,
Context context) {
context = this.client.mergeContext(context);
Mono<Response<Flux<ByteBuffer>>> mono =
createWithResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters, context);
return this
.client
.<TaskInner, TaskInner>getLroResult(
mono, this.client.getHttpPipeline(), TaskInner.class, TaskInner.class, context);
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<TaskInner>, TaskInner> beginCreate(
String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
return beginCreateAsync(resourceGroupName, registryName, taskName, taskCreateParameters).getSyncPoller();
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<TaskInner>, TaskInner> beginCreate(
String resourceGroupName,
String registryName,
String taskName,
TaskInner taskCreateParameters,
Context context) {
return beginCreateAsync(resourceGroupName, registryName, taskName, taskCreateParameters, context)
.getSyncPoller();
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<TaskInner> createAsync(
String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
return beginCreateAsync(resourceGroupName, registryName, taskName, taskCreateParameters)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<TaskInner> createAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskInner taskCreateParameters,
Context context) {
return beginCreateAsync(resourceGroupName, registryName, taskName, taskCreateParameters, context)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner create(
String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
return createAsync(resourceGroupName, registryName, taskName, taskCreateParameters).block();
}
/**
* Creates a task for a container registry with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskCreateParameters The task that has the ARM resource and task properties. The task will have all
* information to schedule a run against it.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner create(
String resourceGroupName,
String registryName,
String taskName,
TaskInner taskCreateParameters,
Context context) {
return createAsync(resourceGroupName, registryName, taskName, taskCreateParameters, context).block();
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
String resourceGroupName, String registryName, String taskName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.delete(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
String resourceGroupName, String registryName, String taskName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.delete(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context);
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
String resourceGroupName, String registryName, String taskName) {
Mono<Response<Flux<ByteBuffer>>> mono = deleteWithResponseAsync(resourceGroupName, registryName, taskName);
return this
.client
.<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, Context.NONE);
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
String resourceGroupName, String registryName, String taskName, Context context) {
context = this.client.mergeContext(context);
Mono<Response<Flux<ByteBuffer>>> mono =
deleteWithResponseAsync(resourceGroupName, registryName, taskName, context);
return this
.client
.<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<Void>, Void> beginDelete(
String resourceGroupName, String registryName, String taskName) {
return beginDeleteAsync(resourceGroupName, registryName, taskName).getSyncPoller();
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<Void>, Void> beginDelete(
String resourceGroupName, String registryName, String taskName, Context context) {
return beginDeleteAsync(resourceGroupName, registryName, taskName, context).getSyncPoller();
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteAsync(String resourceGroupName, String registryName, String taskName) {
return beginDeleteAsync(resourceGroupName, registryName, taskName)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Void> deleteAsync(String resourceGroupName, String registryName, String taskName, Context context) {
return beginDeleteAsync(resourceGroupName, registryName, taskName, context)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void delete(String resourceGroupName, String registryName, String taskName) {
deleteAsync(resourceGroupName, registryName, taskName).block();
}
/**
* Deletes a specified task.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void delete(String resourceGroupName, String registryName, String taskName, Context context) {
deleteAsync(resourceGroupName, registryName, taskName, context).block();
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
String resourceGroupName, String registryName, String taskName, TaskUpdateParameters taskUpdateParameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
if (taskUpdateParameters == null) {
return Mono
.error(new IllegalArgumentException("Parameter taskUpdateParameters is required and cannot be null."));
} else {
taskUpdateParameters.validate();
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.update(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
taskUpdateParameters,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskUpdateParameters taskUpdateParameters,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
if (taskUpdateParameters == null) {
return Mono
.error(new IllegalArgumentException("Parameter taskUpdateParameters is required and cannot be null."));
} else {
taskUpdateParameters.validate();
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.update(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
taskUpdateParameters,
context);
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PollerFlux<PollResult<TaskInner>, TaskInner> beginUpdateAsync(
String resourceGroupName, String registryName, String taskName, TaskUpdateParameters taskUpdateParameters) {
Mono<Response<Flux<ByteBuffer>>> mono =
updateWithResponseAsync(resourceGroupName, registryName, taskName, taskUpdateParameters);
return this
.client
.<TaskInner, TaskInner>getLroResult(
mono, this.client.getHttpPipeline(), TaskInner.class, TaskInner.class, Context.NONE);
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private PollerFlux<PollResult<TaskInner>, TaskInner> beginUpdateAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskUpdateParameters taskUpdateParameters,
Context context) {
context = this.client.mergeContext(context);
Mono<Response<Flux<ByteBuffer>>> mono =
updateWithResponseAsync(resourceGroupName, registryName, taskName, taskUpdateParameters, context);
return this
.client
.<TaskInner, TaskInner>getLroResult(
mono, this.client.getHttpPipeline(), TaskInner.class, TaskInner.class, context);
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<TaskInner>, TaskInner> beginUpdate(
String resourceGroupName, String registryName, String taskName, TaskUpdateParameters taskUpdateParameters) {
return beginUpdateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters).getSyncPoller();
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SyncPoller<PollResult<TaskInner>, TaskInner> beginUpdate(
String resourceGroupName,
String registryName,
String taskName,
TaskUpdateParameters taskUpdateParameters,
Context context) {
return beginUpdateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters, context)
.getSyncPoller();
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<TaskInner> updateAsync(
String resourceGroupName, String registryName, String taskName, TaskUpdateParameters taskUpdateParameters) {
return beginUpdateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<TaskInner> updateAsync(
String resourceGroupName,
String registryName,
String taskName,
TaskUpdateParameters taskUpdateParameters,
Context context) {
return beginUpdateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters, context)
.last()
.flatMap(this.client::getLroFinalResultOrError);
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner update(
String resourceGroupName, String registryName, String taskName, TaskUpdateParameters taskUpdateParameters) {
return updateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters).block();
}
/**
* Updates a task with the specified parameters.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param taskUpdateParameters The parameters for updating a task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner update(
String resourceGroupName,
String registryName,
String taskName,
TaskUpdateParameters taskUpdateParameters,
Context context) {
return updateAsync(resourceGroupName, registryName, taskName, taskUpdateParameters, context).block();
}
/**
* Returns a task with extended information that includes all secrets.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<TaskInner>> getDetailsWithResponseAsync(
String resourceGroupName, String registryName, String taskName) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
return FluxUtil
.withContext(
context ->
service
.getDetails(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Returns a task with extended information that includes all secrets.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<TaskInner>> getDetailsWithResponseAsync(
String resourceGroupName, String registryName, String taskName, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (resourceGroupName == null) {
return Mono
.error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
}
if (registryName == null) {
return Mono.error(new IllegalArgumentException("Parameter registryName is required and cannot be null."));
}
if (taskName == null) {
return Mono.error(new IllegalArgumentException("Parameter taskName is required and cannot be null."));
}
final String apiVersion = "2018-09-01";
context = this.client.mergeContext(context);
return service
.getDetails(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
resourceGroupName,
registryName,
apiVersion,
taskName,
context);
}
/**
* Returns a task with extended information that includes all secrets.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<TaskInner> getDetailsAsync(String resourceGroupName, String registryName, String taskName) {
return getDetailsWithResponseAsync(resourceGroupName, registryName, taskName)
.flatMap(
(Response<TaskInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Returns a task with extended information that includes all secrets.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TaskInner getDetails(String resourceGroupName, String registryName, String taskName) {
return getDetailsAsync(resourceGroupName, registryName, taskName).block();
}
/**
* Returns a task with extended information that includes all secrets.
*
* @param resourceGroupName The name of the resource group to which the container registry belongs.
* @param registryName The name of the container registry.
* @param taskName The name of the container registry task.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the task that has the ARM resource and task properties.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<TaskInner> getDetailsWithResponse(
String resourceGroupName, String registryName, String taskName, Context context) {
return getDetailsWithResponseAsync(resourceGroupName, registryName, taskName, context).block();
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<TaskInner>> listNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listNext(nextLink, context))
.<PagedResponse<TaskInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the collection of tasks.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<TaskInner>> listNextSinglePageAsync(String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listNext(nextLink, context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
}
| [
"noreply@github.com"
] | noreply@github.com |
ede610b966b382c0ae004ec93bb9a9392b994648 | 94382c7d0f1011faa1426f1a1d51567074bda440 | /src/main/java/com/exadel/model/entity/ParticipationStatus.java | 44b19bddcd97c42b4ad410e7132237a01a5ee644 | [] | no_license | TrainingGroup2/trainings | a86f9646309b72d9a45d39f4c25914bb6c1ab4bf | 19c990474de19450056146af9cedb286246a317d | refs/heads/master | 2020-05-07T08:09:41.821381 | 2015-08-11T08:51:35 | 2015-08-11T08:54:49 | 38,815,003 | 0 | 6 | null | 2015-08-11T14:19:25 | 2015-07-09T10:52:44 | Java | UTF-8 | Java | false | false | 96 | java | package com.exadel.model.entity;
public enum ParticipationStatus {
MEMBER, RESERVE, NONE
}
| [
"jpalaznik@gmail.com"
] | jpalaznik@gmail.com |
b47754f5c29b1e980f13114b85c0a05a0300d5c1 | f8c98b082e14027677ee7c185058ba0b2d1072d0 | /rosjava/Arquitectura_Hibrida/src/main/java/planificador/gestorPlanes/Accion.java | 2ac01414d83fe9bd0cfb457d7c81f15b864a3c5b | [] | no_license | WayWingsDev/SIMUL_DSA | 62514848ba4701d8f68d2a12774021c32af3e243 | 311181557d0ef622417c7450d397d3515aebf9da | refs/heads/master | 2020-12-29T03:19:20.625741 | 2014-08-28T21:55:53 | 2014-08-29T01:03:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,240 | java | package planificador.gestorPlanes;
import java.util.LinkedList;
/**
* Clase que representa una operacion del concepto clasico de
* planificacion. A partir de unos predicados que indican las
* precondiciones, ejecutando esta accion se llega a cambiar el
* modelo del mundo con otros predicados que indican las
* postcondiciones.
*
* @author Jose Luis Diaz Cebrian
* @version 1.0
*
*/
public class Accion {
/**
* Identificador unico de la accion dentro del dominio del planificador.
*/
private String nombre;
/**
* Serie de elementos que, junto con el nombre, definen la accion.
*/
private Elemento[] elementos;
/**
* Lista de predicados que definen las precondiciones de la accion para que
* pueda llevarse a cabo.
*/
private LinkedList<Predicado> precondiciones;
/**
* Lista de predicados que es preciso borrar del estado del modelo del mundo
* tras realizar la accion.
*/
private LinkedList<Predicado> borrados;
/**
* Lista de predicados que es necesario incluir en el estado del modelo del
* mundo tras realizar la accion.
*/
private LinkedList<Predicado> anyadidos;
/**
* Inicializa por defecto con los atributos a null.
*/
public Accion(){}
/**
* Constructor por defecto para la libreria de acciones. NO USAR PARA CREAR
* ACCIONES PARA EL PLANIFICADOR.
*/
public Accion(String nom){
this.nombre = nom;
}
/**
* Inicializa la accion, asignandole un nombre y los elementos que la definen.
* Posteriormente se debe asignar la lista de precondiciones y postcondiciones.
*
* @param nom El identificador (nombre) de la accion
* @param elem El array de elementos que definen la accion
*/
public Accion(String nom, Elemento[] elem){
this.nombre = nom;
this.elementos = new Elemento[elem.length];
for(int i=0; i<this.elementos.length; i++)
this.elementos[i] = elem[i];
this.precondiciones = new LinkedList<Predicado>();
this.borrados = new LinkedList<Predicado>();
this.anyadidos = new LinkedList<Predicado>();
}
/**
* Devuelve el identificador unico (nombre) de la accion.
*
* @return El nombre de la accion
*/
public String getNombre() {
return this.nombre;
}
/**
* Devuelve la serie de elementos que definen la accion.
*
* @return El array de elementos de la accion
*/
public Elemento[] getElementos(){
return this.elementos;
}
/**
* Devuelve la lista de predicados que forman las precondiciones de la accion.
*
* @return La lista de precondiciones
*/
public LinkedList<Predicado> getPrecondiciones(){
return this.precondiciones;
}
/**
* Devuelve la lista de predicados que forman las postcondiciones de borrado
* de la accion.
*
* @return La lista de borrados
*/
public LinkedList<Predicado> getBorrados(){
return this.borrados;
}
/**
* Devuelve la lista de predicados que forman las postcondiciones de inclusion
* de la accion.
*
* @return La lista de anadidos
*/
public LinkedList<Predicado> getAnyadidos(){
return this.anyadidos;
}
/**
* Asigna un nuevo identificador (nombre) a la accion.
*
* @param nombre El nuevo nombre de la accion
*/
public void SetNombre(String nombre){
this.nombre = nombre;
}
/**
* Asigna una lista de elementos a la definicion de la accion.
*
* @param elem El array de elementos que definen la accion
*/
public void setElementos(Elemento[] elem){
this.elementos = new Elemento[elem.length];
for(int i=0; i<this.elementos.length; i++)
this.elementos[i] = elem[i];
}
/**
* Incluye un nuevo predicado a la lista de precondiciones de la accion.
*
* @param pred El predicado a anadir a la lista
*/
public void anyadirPrecondicion(Predicado pred){
this.precondiciones.add(pred);
}
/**
* Incluye un nuevo predicaado a la lista de postcondiciones de borrado
* de la accion.
*
* @param pred El predicado a anadir a la lista
*/
public void anyadirBorrado(Predicado pred){
this.borrados.add(pred);
}
/**
* Incluye un nuevo predicado a la lista de postcondiciones de inclusion
* de la accion.
*
* @param pred El predicado a anadir a la lista
*/
public void anyadirAnyadido(Predicado pred){
this.anyadidos.add(pred);
}
}
| [
"ariel.vernaza@admios-sa.com"
] | ariel.vernaza@admios-sa.com |
aec94a841b61bd70a1a69449b87fe767385f4671 | 8ca516e6c62178b2a1a71990d4c2f174acb70dda | /CallRecorder/CallRecorder-master/app/src/main/java/com/jlcsoftware/callrecorder/SettingsActivity.java | e02f51d52aec26b7471541a46ab916a658f8a5bc | [
"LicenseRef-scancode-warranty-disclaimer",
"CC-BY-3.0"
] | permissive | DanyaProgrammer666/Callv2 | 48e6b4177df10bb21262084bc9d8e4d4302075c9 | 57829d712e9237652e8ec63ff244de75818cfd67 | refs/heads/master | 2020-03-09T07:07:20.931807 | 2018-04-25T21:56:12 | 2018-04-25T21:56:12 | 128,657,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,823 | java | package com.jlcsoftware.callrecorder;
import android.content.Context;
import android.os.Bundle;
import android.os.StatFs;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import com.jlcsoftware.database.CallLog;
import com.jlcsoftware.database.Database;
import com.jlcsoftware.receivers.MyAlarmReceiver;
import com.jlcsoftware.services.CleanupService;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Not your classic Android Settings Activity, since
* we are only supporting a very limited range of options and PreferenceActivity is essentially deprecated
* and all the Fragment stuff is over-kill
*
* a new PreferencesFragment based Activity is overkill and the old PreferenceActivity never made much sense anyway
*/
public class SettingsActivity extends AppCompatActivity {
class MyArrayAdapter<T> extends ArrayAdapter<T> {
ArrayList<Integer> icons;
public MyArrayAdapter(Context context, List objects, ArrayList<Integer> icons) {
super(context, android.R.layout.simple_spinner_item, objects);
this.icons = icons;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
((TextView) view).setCompoundDrawablesWithIntrinsicBounds(icons.get(position), 0, 0, 0);
return view;
}
}
@Override
public void onStop() {
final AppPreferences.OlderThan olderThan = AppPreferences.getInstance(this).getOlderThan();
if (olderThan != AppPreferences.OlderThan.NEVER) {
MyAlarmReceiver.setAlarm(SettingsActivity.this);
} else {
MyAlarmReceiver.cancleAlarm(SettingsActivity.this);
}
super.onStop();
}
AppPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
preferences = AppPreferences.getInstance(this);
CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox);
checkBox.setChecked(preferences.isRecordingIncomingEnabled());
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
preferences.setRecordingIncomingEnabled(isChecked);
}
});
checkBox = (CheckBox) findViewById(R.id.checkBox2);
checkBox.setChecked(preferences.isRecordingOutgoingEnabled());
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
preferences.setRecordingOutgoingEnabled(isChecked);
}
});
File[] externalFilesDirs = new ContextCompat().getExternalFilesDirs(this, null);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
List<String> list = new ArrayList<String>();
ArrayList<Integer> icons = new ArrayList<>();
File filesDir = getFilesDir();
list.add(filesDir.getAbsolutePath());
icons.add(R.drawable.ic_folder_black_24dp);
for (File file : externalFilesDirs) {
list.add(file.getAbsolutePath());
icons.add(R.drawable.ic_cards_black_24);
}
final MyArrayAdapter<String> dataAdapter = new MyArrayAdapter<String>(this, list, icons);
spinner.setAdapter(dataAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String path = dataAdapter.getItem(position);
calcFreeSpace(path);
AppPreferences.getInstance(getApplicationContext()).setFilesDirectory(path);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
String path = AppPreferences.getInstance(getApplicationContext()).getFilesDirectory().getAbsolutePath();
spinner.setSelection(dataAdapter.getPosition(path.replace("/calls/", "")));
//calcFreeSpace(path);
// Now, count the recordings
ArrayList<CallLog> allCalls = Database.getInstance(getApplicationContext()).getAllCalls();
TextView textView = (TextView) findViewById(R.id.textView4);
String str = textView.getText().toString();
str = String.format(str, allCalls.size());
textView.setText(Html.fromHtml(str));
// Get the length of each file...
long length = 0;
for (CallLog call : allCalls) {
File file = new File(call.getPathToRecording());
length += file.length();
}
textView = (TextView) findViewById(R.id.textView5);
str = textView.getText().toString();
str = String.format(str, length / 1024);
textView.setText(Html.fromHtml(str));
spinner = (Spinner) findViewById(R.id.spinner2);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// Obviously <string-array name="pref_frequencies"> MUST be in the same order as AppPreferences.OlderThan enum
final AppPreferences.OlderThan olderThan = AppPreferences.OlderThan.values()[position];
AppPreferences.getInstance(getApplicationContext()).setOlderThan(olderThan);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinner.setSelection(AppPreferences.getInstance(getApplicationContext()).getOlderThan().ordinal());
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CleanupService.sartCleaning(SettingsActivity.this);
}
});
}
private void calcFreeSpace(String path) {
// http://stackoverflow.com/questions/3394765/how-to-check-available-space-on-android-device-on-mini-sd-card
StatFs stat = new StatFs(path);
long bytesTotal = 0;
long bytesAvailable = 0;
float megAvailable = 0;
long megTotalAvailable = 0;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
bytesTotal = (long) stat.getBlockSizeLong() * (long) stat.getBlockCountLong();
bytesAvailable = (long) stat.getBlockSizeLong() * (long) stat.getAvailableBlocksLong();
} else {
bytesTotal = (long) stat.getBlockSize() * (long) stat.getBlockCount();
bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
}
megAvailable = bytesAvailable / 1048576;
megTotalAvailable = bytesTotal / 1048576;
// Free Space
TextView textView = (TextView) findViewById(R.id.textView6);
String str = getString(R.string.pref_folder_total_folder_size);
str = String.format(str, megAvailable);
textView.setText(Html.fromHtml(str));
}
}
| [
"viperpoison@mail.ru"
] | viperpoison@mail.ru |
e79d15b6cedff0be45759d830ed086880c2732a4 | 76e79889fdac1f99c8ca60d02ead18f8a482303d | /src/com/jdp/logic/model/Fruit.java | 4558ba41c06ea25570c1147f429ed4155a6c53c2 | [] | no_license | jdpluta/TddWithJUnit | 0bc60600eef15189146c207b5a520c5b33dd9e02 | 82e9c235b068752931a9f4e9051c75560b0050fd | refs/heads/master | 2020-04-23T13:53:52.576043 | 2019-02-18T04:15:29 | 2019-02-18T04:15:29 | 171,213,195 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 805 | java | package com.jdp.logic.model;
import java.util.Objects;
public class Fruit {
public Fruit(String name, int qty) {
this.name = name;
this.qty = qty;
}
private String name;
private int qty;
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
// Test equal, override equals() and hashCode()
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Fruit fruit = (Fruit) o;
return qty == fruit.qty && Objects.equals(name, fruit.name);
}
@Override
public int hashCode() {
return Objects.hash(name, qty);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
322a8f8b108e374d12801d8fe91e97f4afb43757 | b0b4f5d7dd63329b9112e86d52bd46bba75e303c | /src/main/java/com/lj/gps/frame/config/WebAppRootContext.java | bec8d3fa8aad912ddcd834e92163b2edf9072aea | [
"MIT"
] | permissive | liimin/gps | 255166f36bc880a45f52c7af2145437d2d7152f8 | 5de0bd5c928fe97818006db4aed0c0ebb4ae4358 | refs/heads/master | 2020-03-07T14:49:39.233471 | 2018-04-18T13:50:04 | 2018-04-18T13:50:04 | 127,536,794 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 945 | java | package com.lj.gps.frame.config;
import com.lj.gps.frame.common.Constants;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.util.WebAppRootListener;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
/**
* Description 类描述:WebAppRootListener
* <p>
* Created by IntelliJ IDEA.<br/>
* User: liuyf<br/>
* Date: 2018/2/12<br/>
* Time: 10:11<br/>
*/
@Configuration
public class WebAppRootContext implements ServletContextInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(WebAppRootListener.class);
servletContext.setInitParameter(
//这里是注入参数的名称
Constants.CONTEXT_PATH_KEY,
Constants.CONTEXT_PATH_VALUE
);
}
}
| [
"17653212@qq.com"
] | 17653212@qq.com |
0499c1410f642f834fc4cdc7c24664743ab019f0 | 19d47922eab52cbcdd5ac49d901bb68a95c7502f | /Suli/inheritancemethods/src/main/java/inheritancemethods/bankaccount/DebitAccount.java | 79579a913f45a7efd429c8531b2708aea9e9402d | [] | no_license | Gergely1987/degeFiles | 73d87ca4327a14834eb4f454844d964034ebab9e | 1615163f5915f140f5efb2727a3c2c874e768b20 | refs/heads/master | 2021-05-02T12:09:09.946595 | 2019-04-03T07:44:40 | 2019-04-03T07:44:40 | 120,736,840 | 0 | 1 | null | 2018-02-10T02:24:06 | 2018-02-08T09:01:46 | Java | UTF-8 | Java | false | false | 983 | java | package inheritancemethods.bankaccount;
public class DebitAccount {
String accountNumber;
long balance;
double COST = 3.0;
static final long MIN_COST = 200;
public DebitAccount(String accountNumber, long balance) {
this.accountNumber = accountNumber;
this.balance = balance;
}
public DebitAccount() {
}
public final long costOfTransaction(long amount) {
if (amount * COST / 100 > MIN_COST) {
return (long) (amount * COST / 100);
} else return MIN_COST;
}
public boolean transaction(long amount) {
if (balance >= amount + costOfTransaction(amount)) {
balance -= (amount + costOfTransaction(amount));
return true;
}
return false;
}
public void balanceToZero() {
balance = 0;
}
public String getAccountNumber() {
return accountNumber;
}
public long getBalance() {
return balance;
}
}
| [
"decsicsgergely@gmail.com"
] | decsicsgergely@gmail.com |
b1ca5f20979e0a0b10eb5ce5c7ffe40920f0a63d | 9cdcba2987fb02319aaf1f79a79fe1c18b861693 | /src/code/CheckResults.java | 4173e59db669e871ab2b683ab715f8c87b2310e4 | [] | no_license | fstoqnov/GDP14 | d009b7191b8e24679b667898dc234b487a924315 | bc3af976daf5abae436af1abe32b2164ce99523f | refs/heads/master | 2020-05-09T10:48:07.527198 | 2019-01-30T13:41:38 | 2019-01-30T13:41:38 | 181,057,402 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 472 | java | package code;
//Class temporarily storing basic metrics from a test.
public class CheckResults {
public Boolean overallPass;
public Integer totalPassed;
public Integer totalFailed;
public CheckResults() {
this.overallPass = true;
this.totalPassed = 0;
this.totalFailed = 0;
}
public void insertResult(boolean newTest) {
this.overallPass = this.overallPass && newTest;
if (newTest) {
this.totalPassed++;
}
else {
this.totalFailed++;
}
}
}
| [
"mfw1g15@soton.ac.uk"
] | mfw1g15@soton.ac.uk |
57bd2870d08528c0ab7ab46cef9b25ebd708f46f | 0b370920b2a571391a4882576b5997f55af72a98 | /oca/Set1_8.java | 59627e180b2124abadd9e173891941ca64f8f860 | [] | no_license | shindemayuri853/OCA | 9ac186beaddb745cfcfe479db7e2c6adb32aafb0 | 82badb7fdcd8bd64c49b3c292c07c6d5bd4bc2b2 | refs/heads/master | 2022-11-10T00:06:04.706940 | 2020-06-23T13:49:26 | 2020-06-23T13:49:26 | 274,412,667 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 438 | java | package com.capgemini.oca;
public class Set1_8 {
public static void main(String[] args) {
int numbers []= {12,13,14,14,16,17,18};
int [] keys = findMax(numbers);
}
//static int findMax (int[] numbers){
//int [] keys = new int [3];
//return keys;
//}
static int [] findMax(int [] max) {
int[] keys = new int [3];
return keys;
}
// public int [] findMax(int [] numbers) {
// int[] keys = new int [3];
// return keys;
// }
}
| [
"shindemayuri853@gmail.com"
] | shindemayuri853@gmail.com |
1a16a9bf2bde551eb6eadb28cd18cdb87b34f3b0 | b21409ad77c81b9a2d271883a7a12e49441f7f51 | /src/main/java/com/zrz/pattern/proxy/FuYuJie.java | cae54753c271fcb66fc956624d80eb7c5485fe19 | [] | no_license | zhouruizhong/pattern | 8e616181d0d33a801ee9ef09c81c0bc0c53fdbae | fb61698c6dcd0b060141f70f1b5cbde26df9c10d | refs/heads/master | 2023-01-07T20:06:29.358558 | 2020-11-05T09:06:57 | 2020-11-05T09:06:57 | 310,243,674 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 324 | java | package com.zrz.pattern.proxy;
/**
* 人事
* @author 周瑞忠
*/
public class FuYuJie implements Reception {
@Override
public void reception(String name) {
System.out.println("接待");
}
@Override
public void recruit(String content) {
System.out.println("发布招聘");
}
}
| [
"528441592@qq.com"
] | 528441592@qq.com |
37a7439e36956376b5c5d42b40d4fd6b346bd774 | a399b787c68b65da51732276bf878c3608346c29 | /src/main/java/com/github/rnewson/couchdb/lucene/DocumentConverter.java | 80b08eca10a364152243503355bc0fa5cab95448 | [
"Apache-2.0"
] | permissive | sakrafd/couchdb-lucene | 9cb77358f9f3f8dde5447cf4d4263ab4ddf94bb4 | 682a26bdee17cdddb5b528b919e45d7c0012923e | refs/heads/master | 2020-12-25T01:19:09.167366 | 2010-01-08T16:07:06 | 2010-01-08T16:07:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,779 | java | package com.github.rnewson.couchdb.lucene;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.lucene.document.Document;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.NativeArray;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Undefined;
import com.github.rnewson.couchdb.lucene.couchdb.Database;
import com.github.rnewson.couchdb.rhino.JSLog;
import com.github.rnewson.couchdb.rhino.JsonToRhinoConverter;
import com.github.rnewson.couchdb.rhino.RhinoDocument;
public final class DocumentConverter {
private static final Document[] NO_DOCUMENTS = new Document[0];
private static final Logger LOG = Logger.getLogger(DocumentConverter.class);
private final Context context;
private final Function viewFun;
private final ScriptableObject scope;
public DocumentConverter(final Context context, final String functionName, final String function) throws IOException {
this.context = context;
scope = context.initStandardObjects();
// Allow custom document helper class.
try {
ScriptableObject.defineClass(scope, RhinoDocument.class);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
// Add a log object
ScriptableObject.putProperty(scope, "log", new JSLog());
// Compile user-specified function
viewFun = context.compileFunction(scope, trim(function), functionName, 0, null);
}
public Document[] convert(final JSONObject doc, final JSONObject defaults, final Database database) throws IOException {
final Object result;
final ScriptableObject scriptableObject = JsonToRhinoConverter.convertObject(doc);
try {
result = viewFun.call(context, scope, null, new Object[] { scriptableObject });
} catch (final JavaScriptException e) {
LOG.warn(doc + " caused exception during conversion.", e);
return NO_DOCUMENTS;
}
if (result == null || result instanceof Undefined) {
return NO_DOCUMENTS;
}
if (result instanceof RhinoDocument) {
final RhinoDocument rhinoDocument = (RhinoDocument) result;
final Document document = rhinoDocument.toDocument(doc.getString("_id"), defaults, database);
return new Document[] { document };
}
if (result instanceof NativeArray) {
final NativeArray nativeArray = (NativeArray) result;
final Document[] arrayResult = new Document[(int) nativeArray.getLength()];
for (int i = 0; i < (int) nativeArray.getLength(); i++) {
if (nativeArray.get(i, null) instanceof RhinoDocument) {
final RhinoDocument rhinoDocument = (RhinoDocument) nativeArray.get(i, null);
final Document document = rhinoDocument.toDocument(doc.getString("_id"), defaults, database);
arrayResult[i] = document;
}
}
return arrayResult;
}
return null;
}
private String trim(final String fun) {
String result = fun;
result = StringUtils.trim(result);
result = StringUtils.removeStart(result, "\"");
result = StringUtils.removeEnd(result, "\"");
return result;
}
}
| [
"robert.newson@gmail.com"
] | robert.newson@gmail.com |
995d50333303ff1b26fc9f04caf8c1c637a9916a | b4a07fa86eda736e9bf15053682b6beaf5eaf75c | /app/src/main/java/com/nuppin/company/Loja/produto/FrListaProdutosLoja.java | 4715f80813865c86648e463f9fd1e667a7535cc2 | [] | no_license | rodrigodascenzio/marketplace_business_app | dc0993d503c6a4d086a32d64dcdbc5061eb3a690 | 875b5148aaab8a08769431e98de808a33369c968 | refs/heads/main | 2023-01-06T03:41:04.549422 | 2020-11-04T14:15:35 | 2020-11-04T14:15:35 | 310,023,162 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,352 | java | package com.nuppin.company.Loja.produto;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.AsyncTaskLoader;
import androidx.loader.content.Loader;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.airbnb.lottie.LottieAnimationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.google.gson.Gson;
import com.nuppin.company.Util.AppConstants;
import com.nuppin.company.Util.UtilShaPre;
import com.nuppin.company.connection.ConnectApi;
import com.nuppin.company.Loja.produto.Alimentos.RvAlimentosAdapter;
import com.nuppin.company.model.Company;
import com.nuppin.company.model.Product;
import com.nuppin.company.R;
import com.nuppin.company.Util.Util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.toptas.fancyshowcase.FancyShowCaseView;
import me.toptas.fancyshowcase.listener.DismissListener;
public class FrListaProdutosLoja extends Fragment implements
LoaderManager.LoaderCallbacks<List<Product>>,
RvProdutosAdapterLoja.RvProdutosLojaOnClickListener,
RvAlimentosAdapter.RvProdutosOnClickListener {
private RvProdutosAdapterLoja adapter;
private RecyclerView mRecyclerView;
private Company company;
private LoaderManager loaderManager;
private static final String EXTRA_COMPANY = "COMPANY";
private List<Product> data;
private LottieAnimationView dots;
private LinearLayout linearEmpty;
private ConstraintLayout errorLayout;
private FloatingActionButton fabError, fab;
private TextView iconCollection;
private CardView progress;
private FancyShowCaseView fancyShowCaseView1;
private FancyShowCaseView fancyShowCaseView2;
private DismissListener listener = new DismissListener() {
@Override
public void onDismiss(String s) {
chainTutorial();
}
@Override
public void onSkipped(String s) {
}
};
private void chainCreatedTutorial() {
if (fancyShowCaseView1 == null) {
fancyShowCaseView1 = new FancyShowCaseView.Builder(requireActivity())
.focusOn(fab)
.delay(500)
.title(getString(R.string.unique_tutorial_lista_produto_fab_string))
.showOnce(getString(R.string.unique_tutorial_lista_produto_fab))
.backgroundColor(getResources().getColor(R.color.primary_light))
.enableAutoTextPosition()
.closeOnTouch(true)
.dismissListener(listener)
.build();
}
if (fancyShowCaseView2 == null) {
fancyShowCaseView2 = new FancyShowCaseView.Builder(requireActivity())
.focusOn(iconCollection)
.title(getString(R.string.unique_tutorial_lista_produto_icon_collection_string))
.backgroundColor(getResources().getColor(R.color.primary_light))
.enableAutoTextPosition()
.showOnce(getString(R.string.unique_tutorial_lista_produto_icon_collection))
.dismissListener(listener)
.closeOnTouch(true)
.build();
}
}
private void chainTutorial() {
if (!fancyShowCaseView1.isShownBefore()) {
fancyShowCaseView1.show();
return;
}
if (!fancyShowCaseView2.isShownBefore()) {
fancyShowCaseView2.show();
return;
}
}
private RvAlimentosAdapter alimentosAdapter;
public static FrListaProdutosLoja novaInstancia(Company company) {
Bundle parametros = new Bundle();
parametros.putParcelable(EXTRA_COMPANY, company);
FrListaProdutosLoja fragment = new FrListaProdutosLoja();
fragment.setArguments(parametros);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null && getArguments().containsKey(EXTRA_COMPANY)) {
company = getArguments().getParcelable(EXTRA_COMPANY);
}
loaderManager = LoaderManager.getInstance(this);
}
@Override
public void onPause() {
super.onPause();
loaderManager.destroyLoader(0);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fr_list_product, container, false);
progress = view.findViewById(R.id.progress);
dots = view.findViewById(R.id.dots);
linearEmpty = view.findViewById(R.id.linearEmpty);
errorLayout = view.findViewById(R.id.error_layout);
fabError = view.findViewById(R.id.fabError);
fabError.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dots.setVisibility(View.VISIBLE);
errorLayout.setVisibility(View.GONE);
loaderManager.restartLoader(0, null, FrListaProdutosLoja.this);
}
});
Toolbar toolbar = view.findViewById(R.id.toolbar_top);
Util.setaToolbar(this, R.string.produtos_toolbar, toolbar, getActivity(), false, 0);
fab = view.findViewById(R.id.fab);
fab.hide();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getActivity() instanceof FrListaProdutosLoja.ToActivity) {
FrListaProdutosLoja.ToActivity listener = (FrListaProdutosLoja.ToActivity) getActivity();
listener.ListaProdutosBottom(R.id.fab, company);
}
}
});
iconCollection = view.findViewById(R.id.fab2);
iconCollection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getActivity() instanceof FrListaProdutosLoja.ToActivity) {
FrListaProdutosLoja.ToActivity listener = (FrListaProdutosLoja.ToActivity) getActivity();
listener.ListaProdutosBottom(R.id.fab2, company);
}
}
});
mRecyclerView = view.findViewById(R.id.recyclerview_products);
if (company.getCategory_company_id().equals("1")) {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false);
mRecyclerView.setLayoutManager(linearLayoutManager);
alimentosAdapter = new RvAlimentosAdapter(this, requireActivity());
mRecyclerView.setAdapter(alimentosAdapter);
} else {
GridLayoutManager gridLayoutManager;
if (getResources().getBoolean(R.bool.isTablet10)) {
gridLayoutManager = new GridLayoutManager(getActivity(), 3);
} else {
gridLayoutManager = new GridLayoutManager(getActivity(), 2);
}
mRecyclerView.setLayoutManager(gridLayoutManager);
adapter = new RvProdutosAdapterLoja(this,requireActivity());
mRecyclerView.setAdapter(adapter);
}
loaderManager.restartLoader(0, null, this);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
itemTouchHelper.attachToRecyclerView(mRecyclerView);
chainCreatedTutorial();
return view;
}
@NonNull
@Override
public Loader<List<Product>> onCreateLoader(int id, Bundle args) {
if (id == 0) {
return new ProductsLoader(getActivity(), company.getCompany_id(), data);
} else {
return new UpdateProductPosition(getActivity(), data);
}
}
@Override
public void onLoadFinished(@NonNull Loader<List<Product>> loader, List<Product> data) {
dots.setVisibility(View.GONE);
progress.setVisibility(View.GONE);
if (data != null) {
fab.show();
chainTutorial();
this.data = data;
if (loader.getId() == 0) {
if (data.size() > 0) {
mRecyclerView.setVisibility(View.VISIBLE);
linearEmpty.setVisibility(View.GONE);
if (company.getCategory_company_id().equals("1")) {
alimentosAdapter.setProducts(data);
} else {
adapter.setProducts(data);
}
} else {
mRecyclerView.setVisibility(View.GONE);
linearEmpty.setVisibility(View.VISIBLE);
}
}
errorLayout.setVisibility(View.GONE);
} else {
errorLayout.setVisibility(View.VISIBLE);
}
if (loader.getId() != 0) {
if (loader.getId() == 1) {
loaderManager.restartLoader(0, null, this);
}
loaderManager.destroyLoader(loader.getId());
}
}
@Override
public void onLoaderReset(@NonNull Loader<List<Product>> loader) {
}
ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.START | ItemTouchHelper.END, 0) {
private boolean mOrderChanged;
@Override
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
int fromPosition = viewHolder.getAdapterPosition();
int toPosition = target.getAdapterPosition();
Collections.swap(data, fromPosition, toPosition);
if (recyclerView.getAdapter() != null) {
recyclerView.getAdapter().notifyItemMoved(fromPosition, toPosition);
}
mOrderChanged = true;
return false;
}
@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
}
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
if (actionState == ItemTouchHelper.ACTION_STATE_IDLE && mOrderChanged) {
progress.setVisibility(View.VISIBLE);
for (int i = 0; i < data.size(); i++) {
data.get(i).setPosition(i);
}
loaderManager.restartLoader(1, null, FrListaProdutosLoja.this);
mOrderChanged = false;
}
}
};
@Override
public void onClick(Product product) {
Activity activity = getActivity();
if (activity instanceof RvProdutosAdapterLoja.RvProdutosLojaOnClickListener) {
RvProdutosAdapterLoja.RvProdutosLojaOnClickListener listener =
(RvProdutosAdapterLoja.RvProdutosLojaOnClickListener) activity;
listener.onClick(product);
}
}
private static class ProductsLoader extends AsyncTaskLoader<List<Product>> {
String storeId;
Context ctx;
List<Product> data;
ProductsLoader(Context context, String storeId, List<Product> data) {
super(context);
ctx = context;
this.storeId = storeId;
this.data = data;
}
@Override
protected void onStartLoading() {
if (data != null && !data.isEmpty()) {
deliverResult(data);
forceLoad();
} else {
forceLoad();
}
}
@Override
public List<Product> loadInBackground() {
Gson gson = new Gson();
try {
Product[] products = gson.fromJson(ConnectApi.GET(ConnectApi.PRODUCT_COMPANY + "/" + storeId, getContext()), Product[].class);
return new ArrayList<>(Arrays.asList(products));
} catch (Exception e) {
FirebaseCrashlytics.getInstance().log(UtilShaPre.getDefaultsString(AppConstants.USER_ID, getContext()));
FirebaseCrashlytics.getInstance().recordException(e);
return null;
}
}
}
private static class UpdateProductPosition extends AsyncTaskLoader<List<Product>> {
Context ctx;
List<Product> product;
UpdateProductPosition(Context context, List<Product> product) {
super(context);
ctx = context;
this.product = product;
}
@Override
protected void onStartLoading() {
forceLoad();
}
@Override
public List<Product> loadInBackground() {
try {
Gson gson = new Gson();
return new ArrayList<>(Arrays.asList(gson.fromJson(ConnectApi.PATCH(product, ConnectApi.PRODUCT_POSITION, getContext()), Product[].class)));
} catch (Exception e) {
FirebaseCrashlytics.getInstance().log(UtilShaPre.getDefaultsString(AppConstants.USER_ID, getContext()));
FirebaseCrashlytics.getInstance().recordException(e);
return null;
}
}
}
public interface ToActivity {
void ListaProdutosBottom(int id, Company company);
}
}
| [
"rodrigodascenzio@gmail.com"
] | rodrigodascenzio@gmail.com |
2f388528250035283e1b0dbbafd548ee053b8ef1 | 6be3f3ecd85f33a5d4eb547acc36513758dea4d4 | /src/com/example/demo/files/DeleteFile.java | 7c7320b8369d164b4c1cd468cc8aff2788d03eaf | [] | no_license | jeena-augustine/Java-Progarms | b0e7a1d93fb9e2a75691992bd359c862ce9a2c44 | 7ece0f488a17e9b40daefffa606015fb60ced651 | refs/heads/master | 2023-06-26T01:30:41.223474 | 2021-07-29T11:58:01 | 2021-07-29T11:58:01 | 390,708,392 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 399 | java | package com.example.demo.files;
import java.io.File;
class DeleteFile {
public static void main(String[] args) {
File f0 = new File("D:\\FileOperationExample.txt");
if (f0.delete()) {
System.out.println(f0.getName()+ " file is deleted successfully.");
} else {
System.out.println("Unexpected error found in deletion of the file.");
}
}
}
| [
"anila.augustine96@gmail.com"
] | anila.augustine96@gmail.com |
1ebc7431999d6e5ef395dacaf3e53f4a8d8451be | 7308e279b3ab6cd45f2f7097c52f5434d9cff58b | /CountDownWebApp/src/main/java/util/Util.java | f75179e8d72c1af625afead3899077ce91274c56 | [] | no_license | Nolyurn/CountDownWebApp | 9d20f217e657ebbc400ff9928dc1d98308954134 | 8b5841eb1cfb24072f78111adc39a9a10916d5c8 | refs/heads/master | 2020-07-05T15:14:38.252690 | 2016-11-18T13:15:59 | 2016-11-18T13:15:59 | 74,113,269 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,944 | java | package util;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
public class Util {
//Permet d'obtenir un cookie contenu dans request
public static String getCookieValue( HttpServletRequest request, String nom ) {
javax.servlet.http.Cookie[] cookies = request.getCookies();
if ( cookies != null ) {
for ( javax.servlet.http.Cookie cookie : cookies ) {
if ( cookie != null && nom.equals( cookie.getName() ) ) {
return cookie.getValue();
}
}
}
return null;
}
//Modifie la valeur d'un cookie contenu dans request
public static void setCookieValue( HttpServletRequest request, String nom, String value) {
javax.servlet.http.Cookie[] cookies = request.getCookies();
if ( cookies != null ) {
for ( javax.servlet.http.Cookie cookie : cookies ) {
if ( cookie != null && nom.equals( cookie.getName() ) ) {
cookie.setValue(value);
}
}
}
}
public static String diff(String date) throws ParseException{
//Les dates sont au format anglais
DateFormat d = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT, new Locale("EN","en"));
Date d1 = new Date();
long diff = d.parse(date).getTime() - d1.getTime();
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000) % 24;
long diffDays = diff / (24 * 60 * 60 * 1000);
String res = "";
if(diffDays>0){
res += diffDays+" day(s) ";
}
if(diffHours>0){
res += diffHours+" hour(s) ";
}
if(diffMinutes>0){
res += diffMinutes+" minute(s) ";
}
if(diffSeconds>0){
res += diffSeconds+" seconde(s) ";
}
return (res.equals(""))?"Finished : "+date:res;
}
} | [
"gatient76@gmail.com"
] | gatient76@gmail.com |
13cc6107ad8f3e302cb71e1d6e512a645a781c26 | 83843869c0b16ebf0e1a13d07242a4b37a9aaf36 | /Command/src/commands/off/StereoOffCommand.java | 9b271e4f4d207b9cbd576e2c2d43593bfd438270 | [] | no_license | igor-korotenko/Patterns | ea8ad8aaf2b61ec2d2e3b3cc9d551cc2f10faaae | 0a71ffa3d3a797e2b41a94fe14925a9fab25b832 | refs/heads/master | 2021-01-20T02:47:58.911594 | 2013-11-07T09:52:07 | 2013-11-07T09:52:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | package commands.off;
import commands.Command;
import devices.Stereo;
/**
* Created by Igor Korotenko on 11/7/13.
*/
public class StereoOffCommand implements Command {
private Stereo stereo;
public StereoOffCommand(Stereo stereo) {
this.stereo = stereo;
}
@Override
public void execute() {
stereo.off();
}
@Override
public void undo() {
stereo.on();
}
}
| [
"igor_kor@hbb-it.com"
] | igor_kor@hbb-it.com |
b2cfbcfe4042ba7bf49985b4411e5a618e93efb2 | 39499a16d726c0d7757b0937fe0daa9037cb1429 | /src/main/java/com/domain/BookAuthor.java | a7672b5042a9f1a8683de9b304b8940f482a2830 | [] | no_license | 7043mcgeep/mscs5800finalproject | 0a3f2a3907edcb710529aa7796766ebd77082c8e | cdd66630e1c49ba356ddd31bfd42f206c6997b16 | refs/heads/master | 2020-04-08T13:21:02.859032 | 2018-12-03T15:22:04 | 2018-12-03T15:22:04 | 159,387,256 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 658 | java | package com.domain;
import java.math.BigDecimal;
public class BookAuthor {
private BigDecimal bookid;
private String authorname;
public BookAuthor(BigDecimal bookid, String authorname) {
super();
this.bookid = bookid;
this.authorname = authorname;
}
public BigDecimal getBookid() {
return bookid;
}
public void setBookid(BigDecimal bookid) {
this.bookid = bookid;
}
public String getAuthorname() {
return authorname;
}
public void setAuthorname(String authorname) {
this.authorname = authorname;
}
@Override
public String toString() {
return "BookAuthor [bookid=" + bookid + ", authorname=" + authorname + "]";
}
}
| [
"patmc@PATRICKGTX1080"
] | patmc@PATRICKGTX1080 |
1746d24921d66146d08a53ece72a617954fc2bc7 | 42f6af6b2e5b365a729519e9fdce809a0c12fa82 | /Java/org/sikuli/ide/z_notused/sikuli_test/ProgressBar.java | b3dccd4cf1b30ee3c06441fae274333b3c09479f | [] | no_license | kitty5209/SikuliX-IDE | c941c791d9c6748f0a9ace49789f70757f2fb769 | e68044c5bed990dd76b00d609ffba5cd847f8c36 | refs/heads/master | 2021-01-01T06:45:37.618971 | 2013-06-10T13:02:41 | 2013-06-10T13:02:41 | 11,020,267 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 848 | java | /*
* Copyright 2010-2011, Sikuli.org
* Released under the MIT License.
*
*/
package org.sikuli.ide.z_notused.sikuli_test;
import java.awt.Color;
import javax.swing.JProgressBar;
/**
* A progress bar showing the green/red status
*/
class ProgressBar extends JProgressBar {
boolean fError= false;
public ProgressBar() {
super();
setForeground(getStatusColor());
}
protected Color getStatusColor() {
if (fError)
return Color.red;
return Color.green;
}
public void reset() {
fError= false;
updateBarColor();
setValue(0);
}
public void start(int total) {
setMaximum(total);
reset();
}
public void step(int value, boolean successful) {
setValue(value);
if (!fError && !successful) {
fError= true;
updateBarColor();
}
}
protected void updateBarColor() {
setForeground(getStatusColor());
}
}
| [
"rmhdevelop@me.com"
] | rmhdevelop@me.com |
86a307021f8716e030d59f12e70333deeb5e54a2 | 6db7967087c50e6a9af013db22520670863f98a9 | /src/main/java/com/perso/vasp/config/JacksonConfiguration.java | ecb98d089624ef76fb805cecc731f7ce0cf72844 | [] | no_license | TheNeptuneZ/vasp-spring-angular | 1b1444ded54612ec5c359bf8046b3086680b360d | 74a84d1a83dd943d2d0d582fbc593eed3844867a | refs/heads/master | 2023-01-06T23:22:01.591408 | 2020-11-06T14:51:33 | 2020-11-06T14:51:33 | 310,625,162 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,387 | java | package com.perso.vasp.config;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zalando.problem.ProblemModule;
import org.zalando.problem.violations.ConstraintViolationProblemModule;
@Configuration
public class JacksonConfiguration {
/**
* Support for Java date and time API.
* @return the corresponding Jackson module.
*/
@Bean
public JavaTimeModule javaTimeModule() {
return new JavaTimeModule();
}
@Bean
public Jdk8Module jdk8TimeModule() {
return new Jdk8Module();
}
/*
* Support for Hibernate types in Jackson.
*/
@Bean
public Hibernate5Module hibernate5Module() {
return new Hibernate5Module();
}
/*
* Module for serialization/deserialization of RFC7807 Problem.
*/
@Bean
public ProblemModule problemModule() {
return new ProblemModule();
}
/*
* Module for serialization/deserialization of ConstraintViolationProblem.
*/
@Bean
public ConstraintViolationProblemModule constraintViolationProblemModule() {
return new ConstraintViolationProblemModule();
}
}
| [
"jhipster-bot@jhipster.tech"
] | jhipster-bot@jhipster.tech |
9f71512b14b6f167a7b9f30a67b211e94cb56354 | 406db909a31831fca1fd99784f6d824d018fde4a | /i18N/com/example/i18N/localeEx/LocaleEx.java | 6f25cb287415f756fb575ffbdd031eec9b1d279b | [] | no_license | satykrishna/SCJP | 4dc92755abade92dc090b9e70b19582f1219f2bd | 5d1b55bca1782fdcdc4290231897f7a3615b2e54 | refs/heads/master | 2021-05-04T07:37:56.421118 | 2016-10-12T20:52:29 | 2016-10-12T20:52:29 | 70,665,668 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,037 | java | package com.example.i18N.localeEx;
import java.util.Locale;
public class LocaleEx {
public static void main(String[] args) {
Locale locale = new Locale("English");
Locale l2 = new Locale("Hindi", "India");
l2 = Locale.ENGLISH;
l2 = Locale.KOREAN;
System.out.println(Locale.getDefault());
System.out.println(Locale.getDefault().getDisplayCountry());
System.out.println(Locale.getDefault().getDisplayLanguage());
Locale.setDefault(Locale.GERMAN);
System.out.println(Locale.getDefault().getDisplayCountry());
System.out.println(Locale.getDefault().getDisplayLanguage());
for (String lang : Locale.getISOLanguages()) {
System.out.println(lang);
}
for (String country : Locale.getISOCountries()) {
System.out.println(country);
}
l2 = new Locale("PUNJAB", "INDIA");
Locale.setDefault(l2);
System.out.println(l2.getLanguage());
for (Locale l : Locale.getAvailableLocales()) {
System.out.println(l.getDisplayLanguage() + " .... " + l.getDisplayCountry());
}
}
}
| [
"satykrishna@gmail.com"
] | satykrishna@gmail.com |
5de3adcc07755e6125387a474750a8b02c3f58b6 | 5c1eeb2035342330f947b6c8aa8d57399b83b5ee | /app/helpers/validator/exceptions/MinLengthValidation.java | b365c50d4108b055e6da5d936c70981f6f275787 | [] | no_license | xavi-reloaded/play-sagas | 30734d6028c5d146a402e2f86645aba7d4fae57b | d6350b21e3bc28399d3a4733cc428715b34ed44c | refs/heads/master | 2020-04-08T19:46:10.139887 | 2018-11-29T19:55:50 | 2018-11-29T19:55:50 | 159,670,344 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package helpers.validator.exceptions;
import java.text.MessageFormat;
public class MinLengthValidation extends BaseValidation {
private static final String MINIMUM_CHARACTERS = "Minimum {0} characters";
public MinLengthValidation(String field, Integer minCharacters) {
super(ErrorValidationCodes.WRONG_MIN_LENGTH, field, MinLengthValidation.buildMessage(minCharacters), new Object[]{minCharacters});
}
public static String buildMessage(Integer minCharacters) {
return MessageFormat.format(MINIMUM_CHARACTERS, minCharacters);
}
}
| [
"xavi.hidalgo.fernandez@gmail.com"
] | xavi.hidalgo.fernandez@gmail.com |
3c27f3dd250611d14bdb329907adfaa17d8ed386 | 5b46ef8a4cb3b16da30975c06a8aa760bb578539 | /PreBuild/Android/src/org/openaphid/internal/Diagnostic.java | 392dfda549449669fac125ba9079e8f977cb8b43 | [
"Apache-2.0"
] | permissive | dumganhar/Runtime | 8cba8c27208cc0899bbcb7c7bb14fa11c98cf91c | 51df604f4256c9b2746d81e34120332de435134a | refs/heads/master | 2021-01-24T02:06:02.128202 | 2012-06-27T13:59:25 | 2012-06-27T13:59:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,825 | java | /*
Copyright 2012 Aphid Mobile
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.openaphid.internal;
import org.openaphid.internal.utils.AphidLog;
import org.openaphid.internal.utils.UI;
import android.graphics.Color;
import android.widget.TextView;
import android.widget.Toast;
public class Diagnostic {
private Diagnostic() {
}
public static final int INFO_COLOR = Color.TRANSPARENT;
public static void error(String message) {
error(message, true);
}
public static void error(String message, boolean logInConsole) {
if (message != null) {
if (logInConsole)
AphidLog.e("(OpenAphid Diagnostic) Error, " + message);
if (AppDelegate.isDevelopMode())
displayNotification(Color.RED, message, false);
}
}
public static void warn(String message) {
warn(message, true);
}
public static void warn(String message, boolean logInConsole) {
if (message != null) {
if (logInConsole)
AphidLog.w("(OpenAphid Diagnostic) Warning, " + message);
if (AppDelegate.isDevelopMode())
displayNotification(Color.BLUE, message, false);
}
}
public static void info(String message) {
info(message, true);
}
public static void info(String message, boolean logInConsole) {
if (message != null) {
if (logInConsole)
AphidLog.i("(OpenAphid Diagnostic) Info, " + message);
if (AppDelegate.isDevelopMode())
displayNotification(INFO_COLOR, message, true);
}
}
public static void displayNotification(final int color, final String message, final boolean shortTimeout) {
if (UI.isMainThread())
doDisplayNotification(color, message, shortTimeout);
else
AppDelegate.getHandler().post(new Runnable() {
public void run() {
doDisplayNotification(color, message, shortTimeout);
}
});
}
public static void doDisplayNotification(int color, String message, boolean shortTimeout) {
if (color == INFO_COLOR)
Toast.makeText(AppDelegate.getApplicationContext(), message,
shortTimeout ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
else {
TextView tv = new TextView(AppDelegate.getApplicationContext());
tv.setText(message);
tv.setBackgroundColor(color);
Toast toast = new Toast(AppDelegate.getApplicationContext());
toast.setView(tv);
toast.setDuration(shortTimeout ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG);
toast.show();
}
}
}
| [
"openaphid@gmail.com"
] | openaphid@gmail.com |
881eb8cb25a996a2a1c0fa2dbf28a15afbc4014c | 19fbd92d331f5fd7003685632e9a9c389380c6ca | /app/src/main/java/com/test/locationtest/BaseActivity.java | 5c403a4604060f1877298b3d6d26fafe05311420 | [
"Apache-2.0"
] | permissive | caibinglong1987/Location | ff7fc56489feac3f3e5a33ff09140b5e3d81720a | 4534704159a3e86254fe5f5f82853a4211e393ab | refs/heads/master | 2020-12-23T20:13:32.748503 | 2017-05-27T05:27:09 | 2017-05-27T05:27:09 | 92,572,944 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,958 | java | package com.test.locationtest;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
/**
* Created by caibinglong
* on 2017/5/22.
*/
public class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case HXApp.PERMISSION_REQ_ID_RECORD_AUDIO: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
checkSelfPermission(Manifest.permission.CAMERA, HXApp.PERMISSION_REQ_ID_CAMERA);
} else {
finish();
}
break;
}
case HXApp.PERMISSION_REQ_ID_CAMERA: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, HXApp.PERMISSION_REQ_ID_WRITE_EXTERNAL_STORAGE);
} else {
finish();
}
break;
}
case HXApp.PERMISSION_REQ_ID_WRITE_EXTERNAL_STORAGE: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
finish();
}
break;
}
}
}
public boolean checkSelfPermission(String permission, int requestCode) {
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{permission}, requestCode);
return false;
}
return true;
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (isFinishing()) {
return;
}
checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION, HXApp.PERMISSION_LOCATION);
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M)) {
// so far we do not use OnRequestPermissionsResultCallback
}
}
}, 500);
}
}
| [
"caibinglong1987@gmail.com"
] | caibinglong1987@gmail.com |
10bdc5cb3169d02b05e5cd0787c2ce0c41b8f359 | 195271058391ded619d292f17ce141686bc2c0d7 | /AccountModuleService/src/main/java/com/pbs/accs/dao/AccountDAO.java | 4b721b8134d92b733c29923e64b7516e53c1365a | [] | no_license | PravalikaJakka/Sprint-2 | 8a91304affc1a7ed75c85ed482638d5bb4b69fe1 | b83484d92dcef3270fa1d761e11260fdeeb67bda | refs/heads/master | 2022-06-09T07:14:01.919592 | 2020-05-10T12:09:14 | 2020-05-10T12:09:14 | 257,577,258 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 262 | java | package com.pbs.accs.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.pbs.accs.dto.Account;
@Repository
public interface AccountDAO extends JpaRepository<Account,Long>
{
}
| [
"noreply@github.com"
] | noreply@github.com |
79bc390e902417836c8c9107ddd316b1810bf702 | fad4630b5adfe9128d576021a514f705302729c8 | /me/ka1/vulcan/clickgui/buttons/ModeComponent.java | fac045df238fe8dc93a4eba3e4dde71352d75268 | [] | no_license | XeonLyfe/TuxHack-1.2-Decompiled-Remapped | d8046b6d6ee8d6b05bfeb6f0db1855e656f6f766 | 9c9a8b7b2298199abfd50573764c2e39eefb2382 | refs/heads/main | 2023-04-27T17:59:01.870020 | 2021-05-17T22:26:15 | 2021-05-17T22:26:15 | 374,810,207 | 1 | 0 | null | 2021-06-07T21:57:08 | 2021-06-07T21:57:08 | null | UTF-8 | Java | false | false | 3,161 | java | //Deobfuscated with https://github.com/PetoPetko/Minecraft-Deobfuscator3000 using mappings "1.12 stable mappings"!
//
// Decompiled by Procyon v0.5.36
//
package me.ka1.vulcan.clickgui.buttons;
import me.ka1.vulcan.util.font.FontUtils;
import com.mojang.realmsclient.gui.ChatFormatting;
import me.ka1.vulcan.module.ModuleManager;
import net.minecraft.client.gui.Gui;
import java.awt.Color;
import me.ka1.vulcan.module.modules.client.ClickGuiModule;
import me.ka1.vulcan.module.Module;
import me.ka1.vulcan.setting.Setting;
import me.ka1.vulcan.clickgui.Buttons;
import me.ka1.vulcan.clickgui.Component;
public class ModeComponent extends Component
{
private boolean hovered;
private final Buttons parent;
private final Setting.Mode set;
private int offset;
private int x;
private int y;
private final Module mod;
private int modeIndex;
public ModeComponent(final Setting.Mode set, final Buttons button, final Module mod, final int offset) {
this.set = set;
this.parent = button;
this.mod = mod;
this.x = button.parent.getX() + button.parent.getWidth();
this.y = button.parent.getY() + button.offset;
this.offset = offset;
this.modeIndex = 0;
}
@Override
public void setOff(final int newOff) {
this.offset = newOff;
}
@Override
public void renderComponent() {
Gui.drawRect(this.parent.parent.getX(), this.parent.parent.getY() + this.offset + 1, this.parent.parent.getX() + this.parent.parent.getWidth(), this.parent.parent.getY() + this.offset + 16, this.hovered ? new Color(0, 0, 0, ClickGuiModule.opacity.getValue() - 50).darker().darker().getRGB() : new Color(0, 0, 0, ClickGuiModule.opacity.getValue() - 50).getRGB());
Gui.drawRect(this.parent.parent.getX(), this.parent.parent.getY() + this.offset, this.parent.parent.getX() + this.parent.parent.getWidth(), this.parent.parent.getY() + this.offset + 1, new Color(0, 0, 0, ClickGuiModule.opacity.getValue() - 50).getRGB());
FontUtils.drawStringWithShadow(ModuleManager.isModuleEnabled("CustomFont"), this.set.getName() + " " + ChatFormatting.GRAY + this.set.getValue(), this.parent.parent.getX() + 2, this.parent.parent.getY() + this.offset + 4, -1);
}
@Override
public void updateComponent(final int mouseX, final int mouseY) {
this.hovered = this.isMouseOnButton(mouseX, mouseY);
this.y = this.parent.parent.getY() + this.offset;
this.x = this.parent.parent.getX();
}
@Override
public void mouseClicked(final int mouseX, final int mouseY, final int button) {
if (this.isMouseOnButton(mouseX, mouseY) && button == 0 && this.parent.open) {
final int maxIndex = this.set.getModes().size() - 1;
++this.modeIndex;
if (this.modeIndex > maxIndex) {
this.modeIndex = 0;
}
this.set.setValue(this.set.getModes().get(this.modeIndex));
}
}
public boolean isMouseOnButton(final int x, final int y) {
return x > this.x && x < this.x + 88 && y > this.y && y < this.y + 16;
}
}
| [
"hqrion@gmail.com"
] | hqrion@gmail.com |
11c1a9b122ba96b2acb98f41d2f684dcbe5bad0b | 23bd0b2922d7b807fa5fa42c4576682310087caa | /ExceptionExamples/src/example1/App.java | 0045df51ca643b10a7f9097f4d25d62813da7ada | [] | no_license | hellupp/JavaCourse-Summer2021 | 85a585ab110bf0cb63e955b0bcf3f32dd934f8e4 | c1aa4951610ac5937c8af5aa5476c2a8a6dd1adb | refs/heads/main | 2023-06-25T05:09:39.346594 | 2021-07-26T12:45:37 | 2021-07-26T12:45:37 | 379,834,123 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,479 | java | package example1;
public class App {
public static void main(String[] args) {
System.err.println("#1.in");
f(); // создаем фрейм, помещаем в стек, передаем в него управление
System.err.println("#1.out"); // вернулись и работаем
}
public static void f() {
System.err.println(". #2.in");
g(); // создаем фрейм, помещаем в стек, передаем в него управление
System.err.println(". #2.out"); // вернулись и работаем
}
public static void g() {
System.err.println(". . #3.in");
try {
h(); // создаем фрейм, помещаем в стек, передаем в него управление
} catch (Error e) { // "перехватили" "летящее" исключение
System.err.println(". . #3.CATCH"); // и работаем
}
System.err.println(". . #3.out"); // работаем дальше
}
public static void h() {
System.err.println(". . . #4.in");
if (true) {
System.err.println(". . . #4.THROW");
throw new Error(); // выходим со всей пачки фреймов ("раскрутка стека") по 'throw'
}
System.err.println(". . . #4.out"); // ПРОПУСТИЛИ!
}
}
| [
"77292360+hellupp@users.noreply.github.com"
] | 77292360+hellupp@users.noreply.github.com |
ae65d3c658e7318dcf16e165a1dc5783a9147df8 | 2b095a305124ec3e68d96f4aa0296075013576eb | /app/src/main/java/io/github/osaigbovo/remotejobs/widget/FavoriteJobWidgetService.java | 5b8393a1470d551a5b6e6a4a5fdca942138ca5ca | [] | no_license | Osaigbovo/Remote-Jobs | a0d2c8a2546e5688bd8ef5165535d807b3859da5 | 8e815971844086464b122f7dd825ef0ca37d6538 | refs/heads/master | 2020-06-01T18:37:50.380733 | 2020-05-14T00:14:55 | 2020-05-14T00:14:55 | 190,886,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 675 | java | package io.github.osaigbovo.remotejobs.widget;
import android.content.Intent;
import android.widget.RemoteViewsService;
import javax.inject.Inject;
import dagger.android.AndroidInjection;
import io.github.osaigbovo.remotejobs.data.repository.JobRepository;
public class FavoriteJobWidgetService extends RemoteViewsService {
@Inject
JobRepository jobRepository;
@Override
public void onCreate() {
AndroidInjection.inject(this);
super.onCreate();
}
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
return new FavoriteRemoteViewsFactory(this.getApplicationContext(), intent, jobRepository);
}
} | [
"odiase.osaigbovo@gmail.com"
] | odiase.osaigbovo@gmail.com |
2d26f94002b49d4db58cbdc8a5b283a936330564 | ec633723dc88a36f1be935d77661021fe5fca184 | /src/test/Main.java | 08685839db49c6a6742537e9eb0bae8205b1fbdd | [] | no_license | Qccbz/FriedBeans | fbdec8ca7f7dad44fcd72605c84289bffe2c7d30 | 67dc47236353f9756afbef06c97496927cc679d5 | refs/heads/master | 2021-01-20T19:21:28.693521 | 2016-07-21T09:53:39 | 2016-07-21T09:53:39 | 63,857,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,262 | java | package test;
import java.io.File;
import algorithm.InterviewBeans;
import algorithm.Josephus;
import file.FileUtils;
public class Main {
public static void main(String[] args) {
Main instance = new Main();
// instance.testFileCopy();
// instance.testJosephus();
instance.testInterviewBeans();
}
private void testFileCopy() {
String srcFilePath = new StringBuilder("D:").append(File.separator).append("android_tools")
.append(File.separator).append("NDK-r10e.rar").toString();
String desFilePath = new StringBuilder("E:").append(File.separator).append("copy_NDK-r10e.rar").toString();
long begin = System.currentTimeMillis();
System.out.println("copy begin: " + begin);
if (FileUtils.copy(srcFilePath, desFilePath)) {
System.out.println("copy end: " + (System.currentTimeMillis() - begin));
System.out.println("copy file success!");
} else {
}
}
private void testJosephus() {
int[] input = { 3, 1, 2, 4, 55, 6, 8, 787, 96, 41, 44, 25, 0, 32 };
int[] output = Josephus.getArray(input, 7);
if (output != null) {
for (int i : output) {
System.out.println(i);
}
} else {
System.out.println("Josephus result null");
}
}
private void testInterviewBeans() {
InterviewBeans.ropeProblem();
}
}
| [
"1020755361@qq.com"
] | 1020755361@qq.com |
4cec17fa5332c2fd1c1608fc3b50b6a33327626b | 6735f59611fdfbf0e6ff304ee3793797cb6b4b1b | /cnplay/cnplay.platform/src/main/java/cc/cnplay/platform/dao/UserDao.java | c90a16edacc1df03177b5c80bb9e2fdc0e74ad2a | [] | no_license | xsvg/xsvg | 5905ba7414ff7825da5d30883d3b54e37d5dcb62 | 78cc9bd8a49532b5b45b38c8705a993b573ef438 | refs/heads/master | 2020-05-22T11:02:30.777303 | 2019-05-16T11:51:54 | 2019-05-16T11:51:54 | 13,596,353 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,283 | java | package cc.cnplay.platform.dao;
import java.util.List;
import cc.cnplay.core.dao.GenericDao;
import cc.cnplay.core.vo.DataGrid;
import cc.cnplay.platform.domain.Role;
import cc.cnplay.platform.domain.RoleRight;
import cc.cnplay.platform.domain.User;
import cc.cnplay.platform.domain.UserEmpower;
import cc.cnplay.platform.domain.UserFinger;
import cc.cnplay.platform.domain.UserRight;
import cc.cnplay.platform.domain.UserRole;
public interface UserDao extends GenericDao<User, String>
{
User getByUsername(String username);
boolean isRoot(String userid);
List<UserEmpower> findToUserEmpowers(String userId);
List<UserRole> findUserRoles(String userId);
List<UserRight> findUserRights(String userId);
List<UserFinger> findUserFingerByUserid(String userId);
List<RoleRight> findRoleRightByRoleId(String roleId);
List<UserRole> findUserRoles(Role role);
DataGrid<User> findList(String userId, String name, String levelCode, String orgId, int pageNum, int pageSize);
void removeNotOrgUserRole(String roleId, String orgId);
User getByMobile(String mobile);
List<User> findUserByRightId(String rightId, String orgId);
boolean findUserHasRight(String rightId, String userId);
List<User> findList(String userId, String name, String levelCode, String orgId);
} | [
"peixere@qq.com"
] | peixere@qq.com |
856ac178e6a381565a13f65c58fd8f45cc06af1c | 22a2969059a73116164f59da05f6c5bd99e70c00 | /2250/Main.java | b5970040f04e36aea534de0f38ce426e9ffb987a | [] | no_license | RumbleKAT/AlgorithmStudy | 9216adb59c16daf2232a87c53044cf022b18ea6b | 6c93c61195f182232843b4920fba04cf6393fbb7 | refs/heads/master | 2023-08-31T03:51:43.713460 | 2023-08-29T12:49:07 | 2023-08-29T12:49:07 | 182,794,211 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,034 | java | import java.util.*;
import java.io.*;
class Main{
static int N;
static int[] levelMin;
static int[] levelMax;
static int maxLevel = 0;
static int point = 1;
static int rootIndex = 0;
static Map<Integer, Node> nodeMap;
public static void main(String [] args) throws Exception{
System.setIn(new FileInputStream("./sample.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer token = new StringTokenizer(br.readLine());
N = Integer.parseInt(token.nextToken());
levelMin = new int[N+1];
levelMax = new int[N+1];
for(int i=1;i<=N;i++){
levelMin[i] = N;
levelMax[i] = 0;
}
nodeMap = new HashMap<>();
for(int i=1;i<=N;i++){
token = new StringTokenizer(br.readLine());
int data = Integer.parseInt(token.nextToken());
int left = Integer.parseInt(token.nextToken());
int right = Integer.parseInt(token.nextToken());
Node currentNode = nodeMap.getOrDefault(data, new Node(data));
nodeMap.put(data, currentNode);
if (left != -1) {
Node leftNode = nodeMap.getOrDefault(left, new Node(left));
currentNode.left = leftNode;
nodeMap.put(left, leftNode);
}
if (right != -1) {
Node rightNode = nodeMap.getOrDefault(right, new Node(right));
currentNode.right = rightNode;
nodeMap.put(right, rightNode);
}
if(left != -1) nodeMap.get(left).parent = data;
if(right != -1) nodeMap.get(right).parent = data;
}
for(int i = 1; i<=N; i++) {
if(nodeMap.get(i).parent == -1) {
rootIndex = i;
break;
}
}
inOrder(rootIndex,1);
int answerLevel = 1;
int answerWidth = levelMax[1] - levelMin[1] + 1;
for (int i = 2; i<= maxLevel; i++) {
int width = levelMax[i] - levelMin[i] + 1;
if(answerWidth < width) {
answerLevel = i;
answerWidth = width;
}
}
System.out.println(answerLevel + " " + answerWidth);
}
public static void inOrder(int rootIndex, int level) {
Node root = nodeMap.get(rootIndex);
if(maxLevel < level) maxLevel = level;
if(root.left != null && root.left.data != -1) {
inOrder(root.left.data, level + 1);
}
levelMin[level] = Math.min(levelMin[level], point);
levelMax[level] = point;
point++;
if(root.right != null && root.right.data != -1) {
inOrder(root.right.data, level + 1);
}
}
}
class Node {
int parent;
int data;
Node left, right;
public Node(int data) {
this.parent = -1;
this.data = data;
this.left = null;
this.right = null;
}
}
| [
"reki318@naver.com"
] | reki318@naver.com |
06dd992f0cf38597ef39f203a08c096560ddb358 | e556d18d23a064528ff82aa2c7b5f2c0e07d19af | /src/main/java/com/hr/zh/mapper/HumanFileDigMapper.java | edcd24e117a76ada90d7bc3a2530ba622c0626e0 | [] | no_license | HRCIHR/hr | ce60df73cc66341737254c43603c6ff5dc47b5c6 | 6b482223251898b8762152d010c4f538fecd4464 | refs/heads/master | 2022-12-27T05:05:00.535822 | 2020-04-06T14:13:14 | 2020-04-06T14:13:14 | 248,937,882 | 0 | 0 | null | 2022-12-16T09:44:35 | 2020-03-21T08:45:27 | CSS | UTF-8 | Java | false | false | 320 | java | package com.hr.zh.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.hr.entity.HumanFile;
@Repository
public interface HumanFileDigMapper {
Integer saveHumanFileDig(@Param("sql") String value, @Param("humanFile") HumanFile humanFile);
}
| [
"656771561@163.com"
] | 656771561@163.com |
4f3af907b67b81f4986c37ea7d020c1e439a9bdd | c0e9dcbc51f88004940b3a5e162ea438c6119690 | /WebApplication3/src/java/com/controller/controller_to_save_information.java | 093135fd9ca08ed99b6cdfc67cad3938b0b230d7 | [] | no_license | loki3789/time_tracking_application | c323ef12e9d7fa08e99f4fe36542d8ec0c24ce47 | 098ebaf662e4c077e58a032ca9e1277b871bc74e | refs/heads/master | 2020-04-09T13:46:41.323598 | 2018-12-04T16:08:35 | 2018-12-04T16:08:35 | 160,380,708 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,121 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author lokesh
*/
public class controller_to_save_information extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String time = request.getParameter("time_elapsed");
String category = request.getParameter("category");
String work = request.getParameter("working_on");
int total_seconds = Integer.parseInt(time) / 10;
int hours = (total_seconds / 3600);
int minutes = ((total_seconds / 60) % 60);
int seconds = total_seconds % 60;
String time_format = hours + ":" + minutes + ":" + seconds;
String date = (new java.util.Date()).toLocaleString();
String date1=date.substring(0,12);
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jspdb", "root", "root");
PreparedStatement psmt = con.prepareStatement("insert into time_information(working_on,category,time,date) values(?,?,?,?)");
psmt.setString(1, work);
psmt.setString(2, category);
psmt.setString(3, time_format);
psmt.setString(4, date1);
int s = psmt.executeUpdate();
if (s > 0) {
response.sendRedirect("index.jsp");
}
con.close();
psmt.close();
} catch (Exception ex) {
out.println(ex);
}
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"noreply@github.com"
] | noreply@github.com |
9798b5de2db0cc63b28b2f35950befa2a0e54c0b | 89cf021fa54ca40aba607e861833272e11703194 | /app/src/main/java/com/eddelacruz/wishmaker/FriendFragments/FriendListDisplay.java | b01ff6a4ec6c2a3e47b67bf23d94a1908d196407 | [] | no_license | edthecreator/Wish_Maker | 2965527ba2b115c1de9ec8c114677a4f29b7faa9 | 1e11b85c8aa550b94a6d64eaf0c51176e1b4109e | refs/heads/master | 2022-12-01T21:40:01.837931 | 2020-08-14T05:55:46 | 2020-08-14T05:55:46 | 276,554,957 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,749 | java | package com.eddelacruz.wishmaker.FriendFragments;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.eddelacruz.wishmaker.Adapters.ListsAdapter;
import com.eddelacruz.wishmaker.LoadingFragments.LoadingFragment;
import com.eddelacruz.wishmaker.Managers.TransactionNameAndFragmentTag;
import com.eddelacruz.wishmaker.Models.Lists;
import com.eddelacruz.wishmaker.R;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import de.hdodenhof.circleimageview.CircleImageView;
public class FriendListDisplay extends Fragment implements View.OnClickListener {
private static String TAG = "FRIENDS LIST DISPLAY";
private TextView friendName;
private CircleImageView friend_profile;
private ImageView backArrow;
private ListsAdapter listsAdapter;
private RecyclerView recyclerView;
private String uid = "";
private String url = "";
private String name = "";
private Query query;
private Lists lists;
boolean noMorePulls = false;
private ArrayList<Lists> listsArrayList = new ArrayList<>();
public FriendListDisplay() {
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.friends_list_display_fragment, container, false);
try {
Bundle extras = this.getArguments();
uid = extras.getString("uid", "");
name = extras.getString("name", "");
url = extras.getString("url", "");
} catch (NullPointerException e) {
e.printStackTrace();
}
setUpLoading();
setUpListeners(root);
return root;
}
private void setUpListeners(View rootview) {
recyclerView = rootview.findViewById(R.id.listsRecyclerView);
friend_profile = rootview.findViewById(R.id.friendImage);
friendName = rootview.findViewById(R.id.friendTextView);
backArrow = rootview.findViewById(R.id.backArrow);
backArrow.setOnClickListener(this);
initializeData();
firebasecall();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.backArrow:
try {
getFragmentManager().popBackStack(TransactionNameAndFragmentTag.FriendsListDisplay,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (NullPointerException e) {
e.printStackTrace();
}
break;
default:
break;
}
}
private void initializeData() {
try {
friendName.setText(name);
if( URLUtil.isValidUrl(url)) {
Glide.with(friend_profile.getContext()).load(Uri.parse(url)).centerCrop().into(friend_profile);
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
private void firebasecall() {
try {
query = FirebaseDatabase.getInstance().getReference().child("wishlist")
.child(uid).orderByChild("name").limitToFirst(7);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
lists = (new Lists(userSnapshot.child("image").getValue(String.class), userSnapshot.child("name").getValue(String.class), userSnapshot.child("created_at").getValue(Long.class)));
listsArrayList.add(lists);
}
if(listsArrayList.size() < 7) {
noMorePulls = true;
}
setupAdapter(listsArrayList);
removeLoading();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
} catch (com.google.firebase.database.DatabaseException e) {
e.printStackTrace();
removeLoading();
}
}
public void setupAdapter(ArrayList<Lists> list) {
listsAdapter = new ListsAdapter(this.getContext(), list);
recyclerView.setLayoutManager((RecyclerView.LayoutManager) new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false));
listsAdapter.setOnItemClickListener(new ListsAdapter.onRecyclerViewItemClickListener() {
@Override
public void onItemClickListener(View v, int position, String list_name) {
try {
Bundle data = new Bundle();
data.putString("uid", uid);
data.putString("name", list_name);
data.putString("url", url);
GiftFriendsListDisplay giftFriendsListDisplay = new GiftFriendsListDisplay();
giftFriendsListDisplay.setArguments(data);
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.add(R.id.root_frame, giftFriendsListDisplay, TransactionNameAndFragmentTag.GiftsFriendsListDisplay);
fragmentTransaction.addToBackStack(TransactionNameAndFragmentTag.GiftsFriendsListDisplay);
fragmentTransaction.commitAllowingStateLoss();
} catch (NullPointerException e) {
e.printStackTrace();
}
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (!recyclerView.canScrollVertically(1) && newState==RecyclerView.SCROLL_STATE_IDLE) {
anotherPull();
Log.d("-----","end");
}
}
});
recyclerView.setAdapter(listsAdapter);
}
private void anotherPull(){
try {
final int listsOldSize = listsArrayList.size() - 1;
Query AnotherQuery = FirebaseDatabase.getInstance().getReference().child("wishlist")
.child(uid).orderByChild("name").startAt(listsArrayList.get(listsArrayList.size() - 1).getName()).limitToFirst(7);
AnotherQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
lists = (new Lists(userSnapshot.child("image").getValue(String.class), userSnapshot.child("name").getValue(String.class), userSnapshot.child("created_at").getValue(Long.class)));
listsArrayList.add(lists);
}
if(listsArrayList.size() % 7 != 0 || dataSnapshot.getChildrenCount() == 0L) {
noMorePulls = true;
}
if(dataSnapshot.getChildrenCount() != 0L) {
listsArrayList.remove(listsOldSize);
}
listsAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
} catch (com.google.firebase.database.DatabaseException e) {
e.printStackTrace();
removeLoading();
}
}
private void setUpLoading() {
try {
LoadingFragment loadingFragment = new LoadingFragment();
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.add(R.id.root_frame, loadingFragment, TransactionNameAndFragmentTag.LoadingFragment);
fragmentTransaction.addToBackStack(TransactionNameAndFragmentTag.LoadingFragment);
fragmentTransaction.commitAllowingStateLoss();
} catch (NullPointerException e) {
e.printStackTrace();
}
}
private void removeLoading() {
try {
getFragmentManager().popBackStack(TransactionNameAndFragmentTag.LoadingFragment,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
}
| [
"lordblacksheep13@gmail.com"
] | lordblacksheep13@gmail.com |
03a2b8dd0ea5cc4fbb5c6b65b25255804b15d3e7 | 4059bf35a52aee18f5d0448e347c3a2ce86794ef | /tools-server/src/main/java/com/rbinnovative/tools/model/dto/CategoryDTO.java | b3cdd51c0fa8f6ff982e74451b7fd8401a570777 | [] | no_license | bataragaradu/tool-rental-architecture-tools | f6274f9ae2f8df8c564552542fce6e5366e6b899 | 32c61d3e1448a14f24c4eeedf0b915f35c3fe181 | refs/heads/main | 2023-06-04T22:36:37.294883 | 2021-06-28T20:57:15 | 2021-06-28T20:57:15 | 330,211,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 647 | java | package com.rbinnovative.tools.model.dto;
public class CategoryDTO {
private int id;
private String name;
private String description;
public int getId() {
return id;
}
public CategoryDTO setId(int id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public CategoryDTO setName(String name) {
this.name = name;
return this;
}
public String getDescription() {
return description;
}
public CategoryDTO setDescription(String description) {
this.description = description;
return this;
}
}
| [
"bataragaradu@gmail.com"
] | bataragaradu@gmail.com |
d15d79f267013e2bb36c7d3c0488f964d016c624 | 992a8227f6ab1f23c69bcc2ec3ebaa9a70fb507e | /prompt-jdbc-skeleton/src/main/java/org/academiadecodigo/tailormoons/controller/AbstractController.java | 4b0474482e96a63e775e488f7a7e568b1afd2750 | [] | no_license | gorthaur-source/Academy | 475964eb6d1263d21f5f0e7843aa2403db51c29c | 212782ef3653bf197e94b6592c9670c2827d7e43 | refs/heads/main | 2023-01-23T07:26:21.506565 | 2020-11-25T17:46:26 | 2020-11-25T17:46:26 | 303,529,932 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 541 | java | package org.academiadecodigo.tailormoons.controller;
import org.academiadecodigo.tailormoons.service.UserService;
import org.academiadecodigo.tailormoons.view.View;
public abstract class AbstractController implements Controller {
protected UserService userService;
protected View view;
@Override
public void init() {
view.show();
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public void setView(View view) {
this.view = view;
}
}
| [
"codecadet@enigma.local"
] | codecadet@enigma.local |
0af5c66dfeab3b4f2c5512cb4c8bbdfb17d4f947 | 6601bd6d2b098d81fefef3825e453e227c46d051 | /src/test/java/upc/opendinghall/project/start/StartApplicationTests.java | 912be0e25d796af5b842a114ca15ef7c06af8e3a | [
"MIT"
] | permissive | liliangbin/Open-Dining-Hall | c70917df1304e1f40600bdd351d56f84e7490378 | eca8b0a83ee38659b7cb642d2da6b00fdf450ca1 | refs/heads/master | 2021-04-06T09:26:14.359653 | 2018-03-09T02:26:09 | 2018-03-09T02:26:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package upc.opendinghall.project.start;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class StartApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"2286824491@qq.com"
] | 2286824491@qq.com |
09919fc30aa3c32f2802919b1c9cfc2d9a141317 | c130a094e04eb448201ca2ab8ed4fe56cd1d80bc | /samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApi.java | 847cc88474b899407f1869462ba5cdd6820e0b65 | [
"Apache-2.0"
] | permissive | janweinschenker/openapi-generator | 83fb57f9a5a94e548e9353cbf289f4b4172a724e | 2d927a738b1758c2213464e10985ee5124a091c6 | refs/heads/master | 2022-02-01T17:22:05.604745 | 2022-01-19T10:43:39 | 2022-01-19T10:43:39 | 221,860,152 | 1 | 0 | Apache-2.0 | 2019-11-15T06:36:25 | 2019-11-15T06:36:24 | null | UTF-8 | Java | false | false | 2,689 | java | /**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0-SNAPSHOT).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.api;
import org.openapitools.model.Client;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.http.codec.multipart.Part;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "another-fake", description = "the another-fake API")
public interface AnotherFakeApi {
default AnotherFakeApiDelegate getDelegate() {
return new AnotherFakeApiDelegate() {};
}
/**
* PATCH /another-fake/dummy : To test special tags
* To test special tags and operation ID starting with number
*
* @param body client model (required)
* @return successful operation (status code 200)
*/
@Operation(
operationId = "call123testSpecialTags",
summary = "To test special tags",
tags = { "$another-fake?" },
responses = {
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Client.class)))
}
)
@RequestMapping(
method = RequestMethod.PATCH,
value = "/another-fake/dummy",
produces = { "application/json" },
consumes = { "application/json" }
)
default Mono<ResponseEntity<Client>> call123testSpecialTags(
@Parameter(name = "body", description = "client model", required = true, schema = @Schema(description = "")) @Valid @RequestBody Mono<Client> body,
@Parameter(hidden = true) final ServerWebExchange exchange
) {
return getDelegate().call123testSpecialTags(body, exchange);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
7437cc0609a574f3381c87951502c55a7e39f275 | 14a0a00546034e78b0f968ac1a3087d33d5e60e7 | /src/com/company/encoders/Decoder.java | 4666f7c863a31aed4ccb5d93f023ece1979c30f4 | [] | no_license | TheNinjaRahul/LLDGPS | 642d23796b5d419dad5da3d5a8546d006858187c | 0ad0f8169d92804faf2b0e1f3a7ba3596aa78c6b | refs/heads/main | 2023-03-04T23:09:31.312411 | 2021-02-17T14:13:42 | 2021-02-17T14:13:42 | 339,742,964 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 701 | java | package com.company.encoders;
import com.company.Entiry.DataPacket;
import com.company.Entiry.LoginData;
import com.company.Exception.DecoderException;
/**
* The interface Decoder.
*/
public interface Decoder {
/**
* Login decode login data.
*
* @param input the input
* @return the login data
* @throws DecoderException the decoder exception
*/
public LoginData loginDecode(String input) throws DecoderException;
/**
* Data decode data packet.
*
* @param input the input
* @return the data packet
* @throws DecoderException the decoder exception
*/
public DataPacket dataDecode(String input) throws DecoderException;
}
| [
"chudasama.rahul.r@gmail.com"
] | chudasama.rahul.r@gmail.com |
8fd567ceb231f6870640018e27b14b41b9595da9 | d29235b1b696f16a0f7d890af3752a797e12fabf | /src/main/java/com/movie/search/integration/themoviedb/Genre.java | 03dc0519b7584e3182e2d23220a538c24fd81475 | [] | no_license | gabrieldsguilherme/movie-search | 2575f6eadc2a4f54b545fa6c1d47bfaccfaed021 | 3f9fb58c26362aa3fbe42ba1ca7413b07277e12a | refs/heads/master | 2020-03-17T08:15:35.193746 | 2018-05-17T23:52:36 | 2018-05-17T23:52:36 | 133,431,232 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,066 | java | package com.movie.search.integration.themoviedb;
public enum Genre {
Action(28) {
@Override
public Boolean isCompatibleWithTemperature(Long temperature) {
return temperature.compareTo(40L) > 0;
}
},
Comedy(35) {
@Override
public Boolean isCompatibleWithTemperature(Long temperature) {
return temperature.compareTo(36L) >= 0 && temperature.compareTo(40L) <= 0;
}
},
Animation(16) {
@Override
public Boolean isCompatibleWithTemperature(Long temperature) {
return temperature.compareTo(20L) >= 0 && temperature.compareTo(35L) <= 0;
}
},
Mystery(9648) {
@Override
public Boolean isCompatibleWithTemperature(Long temperature) {
return temperature.compareTo(0L) >= 0 && temperature.compareTo(19L) <= 0;
}
},
Documentary(99) {
@Override
public Boolean isCompatibleWithTemperature(Long temperature) {
return temperature.compareTo(0L) < 0;
}
};
private int id;
Genre(int id) {
this.id = id;
}
public int getId() {
return id;
}
public abstract Boolean isCompatibleWithTemperature(Long temperature);
}
| [
"gabrieldsguilherme@gmail.com"
] | gabrieldsguilherme@gmail.com |
8fbb3616192239ca763c956faee30f0a77f94cfe | b382dee8460e7e7904cf407f821acbfaa5c99390 | /src/main/java/com/primary/string/ReplaceChar.java | 82f91f150575244062429132162c449123d93a87 | [] | no_license | guozhongdong/leetcode | 4ddc00d2f89234e551c1733666c2284defc18f25 | ecafb5a578fd22284430034717633e48607e15d4 | refs/heads/master | 2021-06-08T10:42:11.884201 | 2021-04-08T13:24:00 | 2021-04-08T13:24:00 | 134,811,159 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,050 | java | package com.primary.string;
/**
* @author gzd
* @create 2018-06-24 21:12
* @desc: 提交一个工具类,替换一个字符
**/
public class ReplaceChar {
public static void main(String[] args){
String s = new ReplaceChar().replaceSpecialChar("and cust.label > 12.00");
System.out.println(s);
}
public String replaceSpecialChar(String str){
if (str == null){
return null;
}
String result = null ;
char[] charArray = str.toCharArray();
int len = charArray.length;
for (int i = 0; i < len; i++) {
if (charArray[i] == '.' && i+1 < len){
if (Character.isDigit(charArray[i-1]) && Character.isDigit(charArray[i-1])){
charArray[i] = '#';
}else{
charArray[i] = '*';
}
}
}
result = new String(charArray);
result = result.replaceAll("#",".").replaceAll("\\*","__");
return result;
}
}
| [
"guozhongdong@bonc.com.cn"
] | guozhongdong@bonc.com.cn |
b5a5742d46587e564c034296c542088d0b39568c | cfd7738b86e1fa17b71a2a79721108ceaba633ff | /src/main/java/com/searchcentric/tool/gis/model/config/GroupsConfig.java | 25592d7f904ac0fffa15a32b9483e796876fa539 | [] | no_license | undwood/tool-postgis | e15f4377fd1d85b2997b091d4c86a36ba2ab99b5 | c2846e6467eb59be44da4560b72211ad215c6e23 | refs/heads/master | 2020-07-04T09:28:58.541206 | 2016-09-08T07:02:24 | 2016-09-08T07:02:24 | 67,677,087 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,999 | java | package com.searchcentric.tool.gis.model.config;
/**
* Created by undwood on 11.08.16.
*/
public class GroupsConfig {
public String field;
public String field_alias;
public String sub_field;
public String sub_field_alias;
public String inner;
public String inner_alias;
public String outer;
public String outer_alias;
public String order;
public String order_alias;
public String getField_alias() {
return field_alias;
}
public void setField_alias(String field_alias) {
this.field_alias = field_alias;
}
public String getSub_field_alias() {
return sub_field_alias;
}
public void setSub_field_alias(String sub_field_alias) {
this.sub_field_alias = sub_field_alias;
}
public String getInner_alias() {
return inner_alias;
}
public void setInner_alias(String inner_alias) {
this.inner_alias = inner_alias;
}
public String getOuter_alias() {
return outer_alias;
}
public void setOuter_alias(String outer_alias) {
this.outer_alias = outer_alias;
}
public String getOrder_alias() {
return order_alias;
}
public void setOrder_alias(String order_alias) {
this.order_alias = order_alias;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getSub_field() {
return sub_field;
}
public void setSub_field(String sub_field) {
this.sub_field = sub_field;
}
public String getInner() {
return inner;
}
public void setInner(String inner) {
this.inner = inner;
}
public String getOuter() {
return outer;
}
public void setOuter(String outer) {
this.outer = outer;
}
}
| [
"pwd4external"
] | pwd4external |
c074f84dbf36281414572a3a7b47224f80a3784e | 5bc96221c6f2207a8212c6687f578d358be562c8 | /src/test/java/com/dkunert/exampleclient/ProducentTest.java | bb1ce05504e335f6bda47c0c37cb4aa0719cee9a | [] | no_license | Enofod/exampleclient | 667a12463d7ac0fe01d979018f98d5a8be5a1794 | 01b4b6500665d4af1689849762d7946f02df08ec | refs/heads/master | 2021-07-12T17:01:13.118071 | 2017-10-01T21:25:41 | 2017-10-01T21:25:41 | 105,193,973 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,216 | java | package com.dkunert.exampleclient;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.stubrunner.StubFinder;
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@AutoConfigureStubRunner()
public class ProducentTest {
@Autowired
private StubFinder stubFinder;
@Test
public void checkStub() {
String stubUrl = stubFinder.findStubUrl("com.dkunert", "exampleproducent").toString();
System.out.println(stubUrl);
List<String> tallPeople = Arrays.asList(new RestTemplate().getForObject(stubUrl + "/people/tall", String[].class));
Assertions.assertThat(tallPeople.size()).isEqualTo(2);
tallPeople.forEach(System.out::println);
}
}
| [
"enofod@gmail.com"
] | enofod@gmail.com |
0215f8feb7c582cf991c863a4725e5ed002ec64a | 3a857e6649468b11c3d43960a0643fb3ea567a87 | /app/src/main/java/com/huizhou/receptionbooking/common/TreeNodeType.java | fdfb23efa830fc64ddcc8ba55a9130c1c9f53ad9 | [] | no_license | Manu15f/Android_ReceptionBooking | 24cd3d4000df1d37cdae2bcb3723c5341948d39e | dc26cee387d9d1658611729333c36ab136e497ff | refs/heads/master | 2023-03-17T21:47:17.511026 | 2018-01-19T14:11:28 | 2018-01-19T14:11:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 358 | java | package com.huizhou.receptionbooking.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Administrator on 2017/12/22.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TreeNodeType
{
}
| [
"lyshyhuangli@126.com"
] | lyshyhuangli@126.com |
5a8b05796db11940d66175322ab79c499f01246e | 9607d56b27a701ba07181c52b7880421b1dc6ead | /HelloWorld/src/im/chap13/sec06/exam01_generic_wildcard/Student.java | e6338702d646cb25bf007ab5d58e545fc6438261 | [] | no_license | minsk-sku/Hello | f3531de7ebac74169d9a7c00983cfd75c8cc1efb | 21bc283693496916af9da4208dc96faea96a10b3 | refs/heads/master | 2020-07-23T09:16:20.118970 | 2019-10-23T07:55:40 | 2019-10-23T07:55:40 | 207,510,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 146 | java | package im.chap13.sec06.exam01_generic_wildcard;
public class Student extends Person {
public Student(String name) {
super(name);
}
}
| [
"User@YD03-01"
] | User@YD03-01 |
3f3f76006e84ecfc0f91e44222ef7a8122406fc7 | a307bd6319532a82feb3bf7c4321bd9b2a512f03 | /00.BashSoft - Refactored OOP Advanced/src/main/bg/softuni/staticData/ExceptionMessages.java | 9008511abead6b6679db6f497c7177fb3c6256b5 | [] | no_license | CarlitoBG/JavaOOP-Advanced | d8e6471223bbc7243ae37d22dac2a420318bd3d0 | e9da95e1c12df1e2155308e75d40d870cbc6045b | refs/heads/master | 2020-04-08T09:16:59.012470 | 2018-11-26T18:55:25 | 2018-11-26T18:55:25 | 159,216,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,352 | java | package main.bg.softuni.staticData;
public class ExceptionMessages {
public static final String DATA_ALREADY_INITIALIZED = "Data is already initialized.";
public static final String DATA_NOT_INITIALIZED = "Data is not initialized.";
public static final String NON_EXISTING_COURSE = "SoftUniCourse does not exist.";
public static final String NON_EXISTING_STUDENT = "SoftUniStudent does not exist.";
public static final String CANNOT_ACCESS_FILE = "Cannot access file.";
public static final String INVALID_OUTPUT_LENGTH = "Actual and expected files are with different length.";
public static final String INVALID_FILTER = "Invalid filter.";
public static final String INVALID_COMPARISON_QUERY =
"The comparison query you want, does not exist in the context of the current program!";
public static final String INVALID_TAKE_COMMAND = "The take command expected does not match the format wanted!";
public static final String INVALID_TAKE_QUANTITY_PARAMETER =
"The quantity you are trying to take is an invalid parameter!";
public static final String INVALID_NUMBER_OF_SCORES =
"The number of scores for the given course is greater than the possible.";
public static final String INVALID_SCORE = "The number for the score you've entered is not in the range of 0 - 100";
} | [
"dimitrov.dians@gmail.com"
] | dimitrov.dians@gmail.com |
8688331eaeaa66a05ade37bbbe0a1ea9789b4020 | 871ce247c8561ae154942a6461867793d5a8c845 | /src/servlets/BuyServlet.java | 514e0018babff303b5a0f87edd6fb8056c27c934 | [] | no_license | Dezypher/SecurdeMP | 59c90d0abdaf85b8d4eca35cdc9207dfa88c2837 | e020cdd9eab7ad3cc6b580aeb0aec0a628d3f9e7 | refs/heads/master | 2020-04-06T07:07:39.562185 | 2016-08-29T02:36:07 | 2016-08-29T02:36:07 | 64,363,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,600 | java | package servlets;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import database.DBHelper;
import models.Account;
import models.LogGenerator;
import models.PurchaseLog;
import models.SaleLog;
import security.CreditCard;
/**
* Servlet implementation class IncreaseSaleServlet
*/
@WebServlet("/Buy")
public class BuyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public BuyServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
String productID = request.getParameter("productid");
String ccnumber = request.getParameter("ccnumber");
String cvc = request.getParameter("cvc");
String expdate = request.getParameter("expdate");
String price = request.getParameter("price");
float fPrice = 0;
try {
fPrice = Float.parseFloat(price);
} catch (NumberFormatException ex) {
ex.printStackTrace();
}
Cookie ck[] = request.getCookies();
String user = "";
for(int i = 0; i < ck.length; i++) {
if(ck[i].getName().equals("user")){
user = ck[i].getValue();
}
}
if(ccnumber.length() == 16 && CreditCard.CheckCreditCardValidity(ccnumber)) {
if(CreditCard.CheckCreditCardLimit(ccnumber, fPrice)) {
try {
int prodID = Integer.parseInt(productID);
SaleLog log = LogGenerator.generateSaleLog("", prodID, DBHelper.getAccountID(user), fPrice);
PurchaseLog pLog = LogGenerator.generatePurchaseLog(user, prodID, DBHelper.getAccountID(user), fPrice);
DBHelper.increaseSales(prodID, 1);
DBHelper.createSaleLog(log);
DBHelper.createPurchaseLog(pLog);
RequestDispatcher rs = request.getRequestDispatcher("buyproduct.jsp?productid=" + productID);
request.setAttribute("errorMessage", "Transaction Successful!");
rs.forward(request, response);
} catch (NumberFormatException ex) {
request.setAttribute("errorMessage", "Something went horribly wrong.");
}
} else {
System.out.println("Product price is more than your credit card limit!");
request.setAttribute("errorMessage", "Product price is more than your credit card limit!");
RequestDispatcher rs = request.getRequestDispatcher("buyproduct.jsp?productid=" + productID);
rs.forward(request, response);
}
} else {
System.out.println("CCNumber invalid!");
request.setAttribute("errorMessage", "Invalid Credit Card Number!");
RequestDispatcher rs = request.getRequestDispatcher("buyproduct.jsp?productid=" + productID);
rs.forward(request, response);
}
}
}
| [
"Solomon@Solomons-MacBook-Pro.local"
] | Solomon@Solomons-MacBook-Pro.local |
72bb33243622211417cd7e19e7b3a7ffa6f6d7bf | 437c055096b0ffb8bb673c4f5b373719b648c08f | /lc-df-ftp-remote-synchronizer/src/test/java/com/lc/df/ftp/sync/batch/FTPBatchConfigurationTest.java | b15251fac4ea6a961e6b88aed851b85441579861 | [] | no_license | Jone14/df-poc | 1702d6e2ac62859d4ca244ef1453d03552709342 | 37987db4f7b6fe688b845008d63b974c2307e969 | refs/heads/master | 2021-06-21T22:13:07.866171 | 2017-08-16T07:00:12 | 2017-08-16T07:00:12 | 100,457,140 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,629 | java | package com.lc.df.ftp.sync.batch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.job.builder.FlowJobBuilder;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.job.builder.JobFlowBuilder;
import org.springframework.batch.core.step.builder.SimpleStepBuilder;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.builder.TaskletStepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.core.step.tasklet.TaskletStep;
import org.springframework.boot.test.context.SpringBootTest;
import com.lc.df.ftp.sync.batch.FTPBatchConfiguration;
@RunWith(MockitoJUnitRunner.class)
@SpringBootTest(classes = FTPBatchConfiguration.class)
public class FTPBatchConfigurationTest {
@Mock
public JobBuilderFactory jobBuilderFactory;
@Mock
public StepBuilderFactory stepBuilderFactory;
@InjectMocks
FTPBatchConfiguration config;
@Mock
private JobBuilder jobBuilder;
@Mock
private JobFlowBuilder jobFlowBuilder;
@Mock
private StepBuilder stepBuilder;
@Mock
private SimpleStepBuilder<Object, Object> simpleStepBuilder;
@Mock
private FlowJobBuilder flowBuilder;
@Mock
private Job job;
@Mock
private Tasklet tasklet;
@Mock
private TaskletStepBuilder taskletStepBuilder;
@Mock
private TaskletStep taskletStep;
@Test
public void testFtpSycJob() {
Mockito.when(jobBuilderFactory.get(Mockito.anyString())).thenReturn(jobBuilder);
Mockito.when(jobBuilder.incrementer(Mockito.anyObject())).thenReturn(jobBuilder);
Mockito.when(jobBuilder.listener(Mockito.anyObject())).thenReturn(jobBuilder);
Mockito.when(jobBuilder.flow(Mockito.anyObject())).thenReturn(jobFlowBuilder);
Mockito.when(stepBuilderFactory.get(Mockito.anyString())).thenReturn(stepBuilder);
Mockito.when(stepBuilder.tasklet(Mockito.anyObject())).thenReturn(taskletStepBuilder);
Mockito.when(taskletStepBuilder.build()).thenReturn(taskletStep);
Mockito.when(jobFlowBuilder.end()).thenReturn(flowBuilder);
Mockito.when(flowBuilder.build()).thenReturn(job);
Assert.assertEquals(job,config.ftpSycJob());
}
}
| [
"jonej@DESKTOP-L0HBF9T"
] | jonej@DESKTOP-L0HBF9T |
b15524351d6281c3fa70a89fd7d9c1a255ddb7e5 | e9324eecb5bfab9ec143bec78e65e1378783c326 | /app/src/main/java/com/example/wilsona/correctmathgame/MainActivity.java | 30bed232b426967367486fec8850f4885abc27d3 | [] | no_license | anotherrose/CorrectMathGame | 74aabb3f8095f473a5f2b4e7acaf554f5a36fc24 | 83ac734c772a6089080237de259c834f69cd8880 | refs/heads/master | 2021-01-09T06:52:18.689261 | 2017-02-27T17:30:53 | 2017-02-27T17:30:53 | 81,112,364 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,267 | java | package com.example.wilsona.correctmathgame;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import java.io.IOException;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Handler myHandler;
long startTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
startTime = System.currentTimeMillis();
myHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
long seconds = ((System.currentTimeMillis() - startTime)) / 1000;
Log.i("info", "Seconds = " + seconds);
myHandler.sendEmptyMessageDelayed(0, 1000);
}
};
myHandler.sendEmptyMessageDelayed(0,0);
Log.i("info", "does this run?");
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
Button play = (Button) findViewById(R.id.btnPlay);
play.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent i =new Intent(this, GameActivity.class);
startActivity(i);
}
}
| [
"andrewmwilson98@gmail.com"
] | andrewmwilson98@gmail.com |
4a889065c831ad47d768430f8d084bdac770828f | 196e4f594da1c7a28f45d0e1c21622e23e5f1504 | /OAWeb/test/xiao/oa/util/QueryHelperTest.java | 0b8a5d92c676eee14135f0a1f9c38449e6d71315 | [] | no_license | qinghongyou/oa | ff579166e6c2b5a4ee22eac61fa457250461563d | dc23157edf474f41adc7a4a519527f5d4e4a3f02 | refs/heads/master | 2021-07-22T21:30:40.655331 | 2017-11-01T17:24:24 | 2017-11-01T17:24:24 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,844 | java | package xiao.oa.util;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import xiao.oa.domain.Forum;
import xiao.oa.domain.PageBean;
import xiao.oa.domain.Topic;
import com.opensymphony.xwork2.ActionContext;
public class QueryHelperTest {
/**
* 0 表示全部主题<br>
* 1 表示全部精华贴
*/
private int viewType = 1;
/**
* 0 表示默认排序(所有置顶帖在前面,并按最后更新时间降序排列)<br>
* 1 表示只按最后更新时间排序<br>
* 2 表示只按主题发表时间排序<br>
* 3 表示只按回复数量排序
*/
private int orderBy = 0;
/**
* true表示升序<br>
* false表示降序
*/
private boolean asc = false;
private Forum forum = new Forum();
@Test
public void testQueryHelper() {
QueryHelper queryHelper = new QueryHelper(Topic.class, "t")//
.addWhereCondition("t.forum=?", forum)//
.addWhereCondition((viewType == 1), "t.type=?", Topic.TYPE_BEST) // 1 表示只看精华帖
.addOrderByProperty((orderBy == 1), "t.lastUpdateTime", asc) // 1 表示只按最后更新时间排序
.addOrderByProperty((orderBy == 2), "t.postTime", asc) // 表示只按主题发表时间排序
.addOrderByProperty((orderBy == 3), "t.replyCount", asc) // 表示只按回复数量排序
.addOrderByProperty((orderBy == 0), "(CASE t.type WHEN 2 THEN 2 ELSE 0 END)", false)//
.addOrderByProperty((orderBy == 0), "t.lastUpdateTime", false); // 0 表示默认排序(所有置顶帖在前面,并按最后更新时间降序排列)
String listHql = queryHelper.getQueryListHql();
String countHql = queryHelper.getQueryCountHql();
List<Object> parameters = queryHelper.getParameters();
System.out.println(listHql);
System.out.println(countHql);
System.out.println(parameters);
}
}
| [
"2635178623@qq.com"
] | 2635178623@qq.com |
eb9c3495238301263400056b962d8d801667bd15 | e9a27127d2efb90c4b0d692dd6bddf4631717f5a | /server/src/main/java/cloud/server/ServerStarter.java | 9aa5959907692f6322fb01c3236ad9bcee07a0b2 | [] | no_license | OlegRykov/galusenitsa_box | bc3372b3f0441bb309298aa70b14da1840aa0703 | 14c8cd479e9f13b36c0e46c7ca3ea3c666482041 | refs/heads/master | 2023-04-30T22:37:21.902697 | 2021-05-13T11:47:58 | 2021-05-13T11:47:58 | 356,904,563 | 0 | 0 | null | 2021-05-13T11:50:41 | 2021-04-11T15:26:00 | Java | UTF-8 | Java | false | false | 193 | java | package cloud.server;
import cloud.server.factory.Factory;
public class ServerStarter {
public static void main(String[] args) {
Factory.getServerService().startServer();
}
}
| [
"olegrikov@ya.ru"
] | olegrikov@ya.ru |
b784d48bf45c993df930e753f1111e6e34a6cf8b | d0994997c7f6a3d6552220d8d396b9ff1fd5b715 | /xsl781/src/main/java/org/xsl781/db/annotation/PrimaryKey.java | 23f38d285850227e1ffa946026634d45bc0a1817 | [
"MIT"
] | permissive | liqimoon/xiubit-android | 65ab6f1a56b9f89e86530401f07a8cf16c6c2efd | 5723b5a8187a14909f605605b42fb3e7a8c3d768 | refs/heads/master | 2020-06-28T09:40:01.876486 | 2018-09-21T05:50:49 | 2018-09-21T05:50:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,088 | java | package org.xsl781.db.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 主键,这是一个模型里必须有的,是对象的唯一标识。
* 没有主键将会报错,一个表只有一个主关键字,它有两种类型:
* 1.主键值自定义,适用于已有唯一ID的对象。
* 2.主键值系统定义,适用于没有唯一ID的对象,将使用递增的数字作为值賦予它。
*
*
* @date 2013-6-2下午7:01:47
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface PrimaryKey {
AssignType value();
/**
* @author MaTianyu
* @date 2014-08-16
*/
enum AssignType {
/**
* 主键值自己来指定。
*/
BY_MYSELF,
/**
* 主键值由系统分配,系统将使用自动递增整数赋值给主键。
* 系统将从1开始递增分配,每次在上一条最大ID上+1 。
*/
AUTO_INCREMENT
}
}
| [
"694208570@qq.com"
] | 694208570@qq.com |
bfec6fbe44810d0efc4878105c75d7d608e96124 | e4c3bdf2af574c948c9ffef4342670789d601e2f | /src/main/java/fr/sywoo/hub/utils/PlayerUtils.java | 0418d5521d994df8f37fc4092855df3360cf5d63 | [] | no_license | Sywoo-Dev/Squiden-Hub | 8c7e72df46d088a7a73c9a3b56141f2db30ef07d | 606cfd65e4b71b8df3d1783099f9ff97daae495d | refs/heads/master | 2022-11-21T05:34:22.290385 | 2020-07-13T00:38:30 | 2020-07-13T00:38:30 | 279,173,744 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 960 | java | package fr.sywoo.hub.utils;
import de.dytanic.cloudnet.driver.CloudNetDriver;
import de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot;
import de.dytanic.cloudnet.ext.bridge.ServiceInfoSnapshotUtil;
public class PlayerUtils {
@SuppressWarnings("deprecation")
public static int getGamePlayer(String str){
int i = 0;
try{i = CloudNetDriver.getInstance().getCloudServiceProvider().getStartedCloudServices().stream()
.filter(service -> service.getServiceId().getName().startsWith(str + "-")).mapToInt(serviceInfoSnapshot -> ServiceInfoSnapshotUtil.getPlayers(serviceInfoSnapshot).size()).sum();
}catch(Exception e) {
return 0;
}
return i;
}
@SuppressWarnings("deprecation")
public static int getPlayers(ServiceInfoSnapshot service){
int server = 0;
if(ServiceInfoSnapshotUtil.getPlayers(service) == null){
return server;
} else {
server += ServiceInfoSnapshotUtil.getPlayers(service).size();
}
return server;
}
}
| [
"contact@lenglet.pro"
] | contact@lenglet.pro |
9d87d9eb0f88c28be175985e4136b658cdf1d8d3 | 3f8b44a44418c7853859ccc55b0da31c7a263bdd | /src/com/github/leetcode/medium/SubsetsII_90.java | 8850601679c7ccfbc574f4480902cbe23591d0be | [] | no_license | WOSHICAIXIANFENG/LeetCode_Training | 41a2751327f459f9496f0d9c7dcc6f62cde4caba | 53def92a5c83a2f27c9d3f9f48357f0082c1d652 | refs/heads/master | 2021-01-17T13:04:40.839941 | 2019-06-29T15:59:31 | 2019-06-29T15:59:31 | 62,431,187 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,079 | java | package com.github.leetcode.medium;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SubsetsII_90 {
public static void main(String[] args) {
SubsetsII_90 obj = new SubsetsII_90();
int[] a1 = {1, 2, 2};
System.out.println("Cai Test = " + obj.subsetsWithDup(a1));
}
// 1 ms, faster than 100.00%
// Approach 1: DFS --- Backtracking
// TC: O(n*2^n)
// SC: O(k*n) --- k is the len of subsets, n is the len of each combination
public List<List<Integer>> subsetsWithDup(int[] nums) {
List<List<Integer>> res = new ArrayList<>();
Arrays.sort(nums);
helper(nums,0, new ArrayList<>(), res);
return res;
}
private void helper(int[] nums, int s, List<Integer> sub, List<List<Integer>> res) {
res.add(new ArrayList<>(sub));
for (int i= s; i < nums.length; i++) {
if (i > s && nums[i] == nums[i - 1]) continue;
sub.add(nums[i]);
helper(nums, i + 1, sub, res);
sub.remove(sub.size() - 1);
}
return;
}
}
| [
"samuel.cai@ceosoftcenters.com"
] | samuel.cai@ceosoftcenters.com |
954f2a91850f0328f88e24f0a26694be99804bb2 | 5837edf7ef64492dd918dfb42ab7338cd2e817bc | /mango-consumer/src/main/java/com/levy/mango/consumer/controller/MangoProducerService.java | 83576212265088d6c8b817e649c85bc9cb6d78d8 | [] | no_license | develop4j/mango | 83d77b53f980e0f0e73f8cbe94b19e88b7b4d3c3 | 2c86b01173d8f116272cd3059be86053a077fc69 | refs/heads/master | 2021-04-14T08:33:41.039124 | 2020-12-06T09:12:37 | 2020-12-06T09:12:37 | 249,219,221 | 0 | 0 | null | 2020-07-25T03:07:10 | 2020-03-22T16:01:26 | Java | UTF-8 | Java | false | false | 365 | java | package com.levy.mango.consumer.controller;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
@FeignClient(name = "mango-producer",fallback = MangoProducerHystrix.class) //要调用的服务名
public interface MangoProducerService {
@RequestMapping("/hello")
public String hello();
}
| [
"18846453394@163.com"
] | 18846453394@163.com |
d800f7e3245de19cb7896e01d53e516766ec0b8d | 0cffd43208c01c61b0583d28a8dcf63ffd76d7dd | /src/main/java/github/sunkeun/webboard/controller/UserController.java | bdbd0da8e79bb032cd0784e3818d3106ea220d63 | [] | no_license | jsmlov2/WebBoard | 44f872d0b2bf36ed6accfafbb34864cd9294d559 | c4d66fa8aa61ba2c88a097c3ba332d1b3825f769 | refs/heads/master | 2020-04-05T04:08:34.974714 | 2019-01-11T12:45:57 | 2019-01-11T12:45:57 | 156,539,173 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,375 | java | package github.sunkeun.webboard.controller;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import github.sunkeun.webboard.dto.Member;
import github.sunkeun.webboard.service.UserService;
@Controller
public class UserController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@Inject
UserService userService ;
@RequestMapping(value="/join", method=RequestMethod.GET)
public String login() {
return "/join"; //join.jsp
}
@RequestMapping(value="/join", method=RequestMethod.POST)
public String insertMember(@RequestParam String id, @RequestParam String pw,
@RequestParam String name, @RequestParam String address, @RequestParam String eMail ) {
System.out.println("%s %s %S %S %S"+id+pw+name+address+eMail);
Member m = new Member();
m.setId(id);
m.setPw(pw);
m.setName(name);
m.setAddress(address);
m.seteMail(eMail);
userService.insertMember(m);
return "/confirmLogin"; //confirmLogin
/*
return {success: false, cause:DUP_ID}
*/
}
@RequestMapping(value="/joinAsync", method=RequestMethod.POST)
@ResponseBody // return 타입이 아니라, jsp를 찾는게 아니고 나를 호출한 곳으로 데이터 넘김 res로
public String insertMemberAsync(@RequestParam String id, @RequestParam String pw,
@RequestParam String name, @RequestParam String address, @RequestParam String eMail ) {
System.out.println("%s %s %S %S %S"+id+pw+name+address+eMail);
Member m = new Member();
m.setId(id);
m.setPw(pw);
m.setName(name);
m.setAddress(address);
m.seteMail(eMail);
try {
userService.insertMember(m);
return "{\"success\": true}";
} catch ( Exception e) {
return "{\"success\": false, \"cause\":\"DUP_ID\"}";
}
//return "/confirmLogin";
//{ "success" : true , "id" : ddddd}
/*
return {success: false, cause:DUP_ID}
*/
}
@RequestMapping(value="/login", method=RequestMethod.GET)
public String doLogin() {
return "/confirmLogin";
}
@RequestMapping(value="/doLogin", method=RequestMethod.POST)
public String doLogin(@RequestParam String id, @RequestParam String pw, HttpSession session) {
Member m = userService.login(id,pw);
System.out.println("login user: " + m);
if(m!=null) {
session.setAttribute("Member", m);
// 302
// location /xxxx/list
//return "/list"; // <- list.jsp
return "redirect:/list"; // http://localhost:8080/webboard/list (브라우저 재요청)
}else {
session.setAttribute("error", "LOOGIN_ERR");
return "redirect:/login";
}
}
@RequestMapping(value="/doLoginAsyn", method=RequestMethod.POST)
@ResponseBody
public Object doLoginAsync(@RequestParam String id, @RequestParam String pw, HttpSession session) throws JsonProcessingException {
Member m = userService.login(id,pw);
// ObjectMapper om = new ObjectMapper();
System.out.println("login user: " + m);
Map<String, Object> res = new HashMap<>();
if(m!=null) {
session.setAttribute("Member", m);
res.put("success", true);
res.put("id", "dddddd");
//return "{\"success\": true, \"id\": \"dddddd\" }"; //?? dddd 이게 뭐지:::
}else {
res.put("success", false);
res.put("cause", "FAIL");
// return "{\"success\": false, \"id\": null }";
}
// return om.writeValueAsString(res);
return res;
}
@RequestMapping(value="/logout", method=RequestMethod.GET)
public String logout(HttpSession session) {
if(session != null) {
session.removeAttribute("Member");
session.invalidate();
}
return "redirect:/list";
}
}
| [
"조선근@DESKTOP-CEQQROI"
] | 조선근@DESKTOP-CEQQROI |
1152783619cd4bac02ae4721584bebe2e60d786f | 226f44ef19abad4e37a648c8fbd496b66499cdd4 | /src/com/luv2code/springdemo/SetterDemoApp.java | 5f75821de59c29f41ddbbf86c834a42c0f4d3139 | [] | no_license | AlexLekkas90/spring-demo-one | 2ed3b5bac78f14da21833607363218444be7d01d | c9a092cc9f95395845a94ddd378c37973b26ccb1 | refs/heads/master | 2021-05-10T13:20:52.577644 | 2018-01-26T12:00:29 | 2018-01-26T12:00:29 | 118,471,502 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 983 | java | package com.luv2code.springdemo;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SetterDemoApp {
public static void main(String[] args) {
//load the spring configuration file
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//retrieve bean from spring container
CricketCoach theCoach = context.getBean("myCricketCoach", CricketCoach.class);
Coach gamingCoach = context.getBean("myGamingCoach", Coach.class);
//call methods on the bean
System.out.println(theCoach.getDailyWorkout());
System.out.println(theCoach.getDailyFortune());
//call new methods to get literal values
System.out.println(theCoach.getEmailAddress());
System.out.println(theCoach.getTeam());
//call gaming coach methods
System.out.println(gamingCoach.getDailyWorkout());
System.out.println(gamingCoach.getRandomFortune());
//close the context
context.close();
}
}
| [
"alexander.lekkas@insurethebox.com"
] | alexander.lekkas@insurethebox.com |
b8115744065e9e7662347c207bba1391cc483033 | bb6b070a4104698792f39b857ac3b74a694b74a8 | /src/main/java/net/haesleinhuepf/clij/CLIJ.java | 6fd40fba0659fb77d21ea7be3acbd03ced0c343a | [] | no_license | psteinb/clij-1 | 2099ab08195c5f471182e4c61a3dc946b0d14e60 | 484f267879fdb54d890b30bfe39479e5fd66a629 | refs/heads/master | 2020-04-14T20:28:23.803478 | 2019-01-03T20:00:25 | 2019-01-03T20:00:25 | 164,094,952 | 1 | 0 | null | 2019-01-04T10:42:22 | 2019-01-04T10:42:21 | null | UTF-8 | Java | false | false | 11,261 | java | package net.haesleinhuepf.clij;
import clearcl.*;
import clearcl.backend.ClearCLBackendInterface;
import clearcl.backend.ClearCLBackends;
import clearcl.backend.jocl.ClearCLBackendJOCL;
import clearcl.enums.*;
import clearcl.util.ElapsedTime;
import coremem.enums.NativeTypeEnum;
import ij.IJ;
import ij.ImagePlus;
import ij.plugin.Duplicator;
import net.haesleinhuepf.clij.converters.CLIJConverterPlugin;
import net.haesleinhuepf.clij.converters.CLIJConverterService;
import net.haesleinhuepf.clij.utilities.CLInfo;
import net.haesleinhuepf.clij.utilities.CLKernelExecutor;
import net.imglib2.RandomAccessibleInterval;
import org.scijava.Context;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* CLIJ is an entry point for ImageJ/OpenCL compatibility.
* Simply create an instance using the SingleTon implementation:
* <p>
* clij = CLIJ.getInstance();
* <p>
* Alternatively, you can get an instance associated to a particular
* OpenCL device by handing over its name to the constructor
* <p>
* clji = new CLIJ("geforce");
* <p>
* To get a list of available devices, call
* CLIJ.getAvailableDevices() to learn more about these devices,
* call CLIJ.clinfo();
* <p>
* <p>
* Author: Robert Haase (http://haesleinhuepf.net) at MPI CBG (http://mpi-cbg.de)
* February 2018
*/
public class CLIJ {
static {
forwardStdErr();
};
private static CLIJ sInstance = null;
protected ClearCLContext mClearCLContext;
private ClearCLDevice mClearCLDevice;
private ClearCL mClearCL;
private CLKernelExecutor
mCLKernelExecutor = null;
public static boolean debug = false;
@Deprecated
public CLIJ(int deviceIndex) {
ClearCLBackendInterface
lClearCLBackend = new ClearCLBackendJOCL();
mClearCL = new ClearCL(lClearCLBackend);
ArrayList<ClearCLDevice> allDevices = mClearCL.getAllDevices();
if (debug) {
for (int i = 0; i < allDevices.size(); i++) {
System.out.println(allDevices.get(i).getName());
}
}
mClearCLDevice = allDevices.get(deviceIndex);
if (debug) {
System.out.println("Using OpenCL device: " + mClearCLDevice.getName());
}
mClearCLContext = mClearCLDevice.createContext();
resetStdErrForwarding();
}
/**
* Deprecated: use getInstance(String) instead
*
* @param pDeviceNameMustContain device name
*/
@Deprecated
public CLIJ(String pDeviceNameMustContain) {
ClearCLBackendInterface
lClearCLBackend = new ClearCLBackendJOCL();
mClearCL = new ClearCL(lClearCLBackend);
if (pDeviceNameMustContain == null || pDeviceNameMustContain.length() == 0) {
mClearCLDevice = null;
} else {
mClearCLDevice = mClearCL.getDeviceByName(pDeviceNameMustContain);
}
if (mClearCLDevice == null) {
if (debug) {
System.out.println("No GPU name specified. Using first GPU device found.");
}
for (ClearCLDevice device : mClearCL.getAllDevices()) {
if (!device.getName().contains("CPU")) {
mClearCLDevice = device;
}
}
}
if (mClearCLDevice == null) {
if (debug) {
System.out.println("Warning: GPU device determination failed. Retrying using first device found.");
}
mClearCLDevice = mClearCL.getAllDevices().get(0);
}
if (debug) {
System.out.println("Using OpenCL device: " + mClearCLDevice.getName());
}
mClearCLContext = mClearCLDevice.createContext();
resetStdErrForwarding();
}
public static CLIJ getInstance() {
return getInstance(null);
}
public static CLIJ getInstance(String pDeviceNameMustContain) {
if (sInstance == null) {
sInstance = new CLIJ(pDeviceNameMustContain);
} else {
if (pDeviceNameMustContain != null && sInstance.getClearCLContext().getDevice().getName().compareTo(pDeviceNameMustContain) != 0) {
// switch device requested
if (debug) {
System.out.println("Switching CL device! New: " + pDeviceNameMustContain);
}
sInstance.close();
sInstance = null;
sInstance = new CLIJ(pDeviceNameMustContain);
}
}
return sInstance;
}
public static String clinfo() {
return CLInfo.clinfo();
}
public static ArrayList<String> getAvailableDeviceNames() {
ArrayList<String> lResultList = new ArrayList<>();
ClearCLBackendInterface lClearCLBackend = ClearCLBackends.getBestBackend();
ClearCL lClearCL = new ClearCL(lClearCLBackend);
for (ClearCLDevice lDevice : lClearCL.getAllDevices()) {
lResultList.add(lDevice.getName());
}
return lResultList;
}
public boolean execute(String pProgramFilename,
String pKernelname,
Map<String, Object> pParameterMap) {
return execute(Object.class, pProgramFilename, pKernelname, pParameterMap);
}
public boolean execute(Class pAnchorClass,
String pProgramFilename,
String pKernelname,
Map<String, Object> pParameterMap) {
return execute(pAnchorClass, pProgramFilename, pKernelname, null, pParameterMap);
}
public boolean execute(Class pAnchorClass,
String pProgramFilename,
String pKernelname,
long[] pGlobalsizes,
Map<String, Object> pParameterMap) {
final boolean[] result = new boolean[1];
if (debug) {
for (String key : pParameterMap.keySet()) {
System.out.println(key + " = " + pParameterMap.get(key));
}
}
ElapsedTime.measure("kernel + build " + pKernelname, () -> {
if (mCLKernelExecutor == null) {
try {
mCLKernelExecutor = new CLKernelExecutor(mClearCLContext,
pAnchorClass,
pProgramFilename,
pKernelname,
pGlobalsizes);
} catch (IOException e) {
e.printStackTrace();
result[0] = false;
return;
}
} else {
mCLKernelExecutor.setProgramFilename(pProgramFilename);
mCLKernelExecutor.setKernelName(pKernelname);
mCLKernelExecutor.setAnchorClass(pAnchorClass);
mCLKernelExecutor.setParameterMap(pParameterMap);
mCLKernelExecutor.setGlobalSizes(pGlobalsizes);
}
mCLKernelExecutor.setParameterMap(pParameterMap);
result[0] = mCLKernelExecutor.enqueue(true);
});
return result[0];
}
public void dispose() {
mClearCLContext.close();
converterService = null;
if (sInstance == this) {
sInstance = null;
}
}
public ClearCLContext getClearCLContext() {
return mClearCLContext;
}
public Map<String, Object> parameters(Object... pParameterList) {
Map<String, Object> lResultMap = new HashMap<String, Object>();
for (int i = 0; i < pParameterList.length; i += 2) {
lResultMap.put((String) pParameterList[i], pParameterList[i + 1]);
}
return lResultMap;
}
public ClearCLImage createCLImage(ClearCLImage pInputImage) {
return mClearCLContext.createImage(pInputImage);
}
public ClearCLImage createCLImage(long[] dimensions, ImageChannelDataType pImageChannelType) {
return mClearCLContext.createImage(HostAccessType.ReadWrite,
KernelAccessType.ReadWrite,
ImageChannelOrder.R,
pImageChannelType,
dimensions);
}
public ClearCLBuffer createCLBuffer(ClearCLBuffer inputCL) {
return createCLBuffer(inputCL.getDimensions(), inputCL.getNativeType());
}
public ClearCLBuffer createCLBuffer(long[] dimensions, NativeTypeEnum pNativeType) {
return mClearCLContext.createBuffer(
MemAllocMode.Best,
HostAccessType.ReadWrite,
KernelAccessType.ReadWrite,
1L,
pNativeType,
dimensions
);
}
public void show(RandomAccessibleInterval input, String title) {
show(convert(input, ImagePlus.class), title);
}
public void show(ClearCLImage input, String title) {
show(convert(input, ImagePlus.class), title);
}
public void show(ClearCLBuffer input, String title) {
show(convert(input, ImagePlus.class), title);
}
public void show(ImagePlus input, String title) {
ImagePlus imp = new Duplicator().run(input);
imp.setTitle(title);
imp.setZ(imp.getNSlices() / 2);
imp.setC(imp.getNChannels() / 2);
IJ.run(imp, "Enhance Contrast", "saturated=0.35");
if (imp.getNChannels() > 1 && imp.getNSlices() == 1) {
IJ.run(imp, "Properties...", "channels=1 slices=" + imp.getNChannels() + " frames=1 unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000");
}
imp.show();
}
public boolean close() {
mClearCLContext.close();
mClearCLContext.getDevice().close();
if (sInstance == this) {
sInstance = null;
}
return true;
}
private CLIJConverterService converterService = null;
public void setConverterService(CLIJConverterService converterService) {
this.converterService = converterService;
}
public <S, T> T convert(S source, Class<T> targetClass) {
if (targetClass.isAssignableFrom(source.getClass())) {
return (T) source;
}
if (converterService == null) {
converterService = new Context(CLIJConverterService.class).service(CLIJConverterService.class);
//new ImageJ().getContext().service(CLIJConverterService.class);
}
CLIJConverterPlugin<S, T> converter = (CLIJConverterPlugin<S, T>) converterService.getConverter(source.getClass(), targetClass);
return converter.convert(source);
}
private static PrintStream stdErrStreamBackup;
private static void forwardStdErr() {
// forwarding stdErr temporarily is necessary to prevent a window popping up with error message from BridJ.
// The library runs even though BridJ throws that error.
stdErrStreamBackup = System.err;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setErr(new PrintStream(baos));
}
private static void resetStdErrForwarding() {
System.setErr(stdErrStreamBackup);
}
}
| [
"rhaase@mpi-cbg.de"
] | rhaase@mpi-cbg.de |
c3fe0a9aa61090cc51d2a49c3e6197bf39e06872 | 967094bcf08d70da6d62c2b10ca11032a6f475bf | /app/src/main/java/com/anad/mobile/post/Activity/RegisterCode.java | 21619e3e7e1fcf6914526653f71be4916a5167d0 | [] | no_license | sarbarekati/Post_androidApplication | 72d3a40d07db24caa1754d84c6acf1f89247f1b6 | 6cfef2290e8064de5a3ea98b03c36fcc6f08e57b | refs/heads/master | 2021-03-24T16:27:23.994464 | 2019-05-25T10:28:21 | 2019-05-25T10:28:21 | 247,542,136 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,487 | java | package com.anad.mobile.post.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.anad.mobile.post.Models.LoginModel;
import com.anad.mobile.post.R;
import com.anad.mobile.post.Storage.PostSharedPreferences;
import com.anad.mobile.post.Utils.Constants;
import com.anad.mobile.post.Utils.SingletonApi;
import com.anad.mobile.post.Utils.Util;
public class RegisterCode extends AppCompatActivity {
private EditText edtRegisterCode;
Button btnAcceptRegisterCode;
private TextView txtWrongRegisterCode;
private PostSharedPreferences postSharedPreferences;
TextView txtTitle;
Util util;
SingletonApi api;
private String URL = Constants.URL_LOGIN;
private String USER_NAME;
private String PASSWORD;
private String REGISTER_CODE;
private static final String TAG = "RegisterCode";
private com.victor.loading.rotate.RotateLoading rotateLoading;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_register_code);
util = Util.getInstance();
postSharedPreferences = new PostSharedPreferences(this);
api = SingletonApi.getInstance(this);
setUpViews();
}
private void setUpViews() {
rotateLoading = findViewById(R.id.Register_Code_rotate_loading);
edtRegisterCode = findViewById(R.id.Register_Code_edt_registerCode);
btnAcceptRegisterCode = findViewById(R.id.RegisterCode_btn_accept);
txtWrongRegisterCode = findViewById(R.id.Register_txt_wrong_registerCode);
txtTitle = findViewById(R.id.Register_Code_txt_title);
setUpFont();
btnAcceptRegisterCode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
REGISTER_CODE = edtRegisterCode.getText().toString();
if (REGISTER_CODE.equals(""))
util.showToast(RegisterCode.this, "لطفا کد چهار رقمی را وارد نمایید.");
else {
LoginModel loginModel = new LoginModel();
rotateLoading.start();
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
USER_NAME = bundle.getString("USER_NAME");
PASSWORD = bundle.getString("PASSWORD");
loginModel.setUsername(USER_NAME);
loginModel.setPassword(PASSWORD);
loginModel.setRegCode(REGISTER_CODE);
}
api.checkLogin(URL, loginModel, new SingletonApi.CanLogin() {
@Override
public void onResponseBack(boolean canLogin) {
if (canLogin) {
rotateLoading.stop();
postSharedPreferences.setRegisterCode(REGISTER_CODE);
postSharedPreferences.setPrefUserName(USER_NAME);
postSharedPreferences.setPrefPassword(PASSWORD);
postSharedPreferences.setKeyOpenActivity(Constants.KEY);
postSharedPreferences.setBase64Encode(Util.EncryptUsernamePassword(USER_NAME,PASSWORD));
startActivity(new Intent(RegisterCode.this, MainActivity.class));
finish();
} else {
rotateLoading.stop();
util.showToast(RegisterCode.this, getString(R.string.Log_in_failed));
}
}
});
}
}
});
}
private void setUpFont() {
util.setTypeFaceLight(txtWrongRegisterCode, this);
util.setTypeFaceEdt(edtRegisterCode, this);
util.setTypeFaceButton(btnAcceptRegisterCode, this);
util.setTypeFace(txtTitle, this);
}
}
| [
"elias.mohammady91@gmail.com"
] | elias.mohammady91@gmail.com |
f774db3573252db41243f0f5dab284ca533aaf84 | 7eb84d9c47de1784d2c3045a2647da63c33e5b00 | /app/src/main/java/com/duces/mtginfo/CardsFragment.java | 84142e421e2f6965e606ac4d94a16f7954568350 | [] | no_license | Duces/MTGInfo | ade650460af32343fa69b49976403826c2fd0e27 | 5202ffaccdb7f125b740cb4e1c6c3a05117845bb | refs/heads/master | 2020-06-04T05:39:29.392489 | 2015-01-06T04:27:42 | 2015-01-06T04:27:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,747 | java | package com.duces.mtginfo;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
/**
* Created by David Doose on 12/14/2014.
*/
public class CardsFragment extends Fragment{
ViewPager pager;
String url;
int setcount, savedpos;
ArrayList<Card> mCardArrayList;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_cards,container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
pager = (ViewPager) view.findViewById(R.id.pager);
if (savedInstanceState!=null){
mCardArrayList = savedInstanceState.getParcelableArrayList("cards");
savedpos = savedInstanceState.getInt("pos");
CardPagerAdapter adapter = new CardPagerAdapter(getFragmentManager(), mCardArrayList, mCardArrayList.size());
pager.setAdapter(adapter);
pager.setPageTransformer(true, new DepthPageTransformer());
pager.setCurrentItem(savedpos);
}else{
url = getActivity().getIntent().getStringExtra("set");
mCardArrayList = new ArrayList<Card>();
new ParseCardListHTMLTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "");
}
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onSaveInstanceState(Bundle outState) {
int pos = pager.getCurrentItem();
outState.putInt("pos", pos);
outState.putParcelableArrayList("cards", mCardArrayList);
super.onSaveInstanceState(outState);
}
private class ParseCardListHTMLTask extends AsyncTask<String,Void,String> {
@Override
protected String doInBackground(String... params) {
String total = "";
try {
Document doc = Jsoup.connect(url).get();
Elements tables = doc.select("table");
Elements td = tables.get(2).select("td");
total = td.get(2).text().substring(0, td.get(2).text().indexOf("c"));
Elements cardsdata = tables.get(3).select("tr");
cardsdata.remove(0);
for (Element e:cardsdata){
Elements carddata = e.select("td");
Card card = new Card();
card.setNum(carddata.get(0).text());
card.setName(carddata.get(1).text());
card.setUrl(carddata.get(1).select("a[href]").get(0).attr("href"));
String cardurlword = card.getUrl().substring(card.getUrl().indexOf("/"), card.getUrl().indexOf("/", 1)).replace("/", "");
card.setCardimgurl(getResources().getString(R.string.img_url)+cardurlword);
card.setType(carddata.get(2).text());
card.setMana(carddata.get(3).text());
card.setRarity(carddata.get(4).text());
mCardArrayList.add(card);
}
} catch (IOException e) {
Log.v("TAG", "parsing exception: " + e.toString());
e.printStackTrace();
}
return total;
}
@Override
protected void onPostExecute(String s) {
CardPagerAdapter adapter = new CardPagerAdapter(getFragmentManager(), mCardArrayList, mCardArrayList.size());
pager.setPageTransformer(true, new DepthPageTransformer());
pager.setAdapter(adapter);
// super.onPostExecute(s);
}
}
// private AlertDialog.Builder filterDialog(){
// AlertDialog.Builder adb = new AlertDialog.Builder(this);
// View v = getLayoutInflater().inflate(R.layout.dialog_filter, null);
// final CheckBox redcb = (CheckBox) v.findViewById(R.id.red_cb);
// final CheckBox bluecb = (CheckBox) v.findViewById(R.id.blue_cb);
// final CheckBox greencb = (CheckBox) v.findViewById(R.id.green_cb);
// final CheckBox blackcb = (CheckBox) v.findViewById(R.id.black_cb);
// final CheckBox whitecb = (CheckBox) v.findViewById(R.id.white_cb);
// final CheckBox colorlesscb = (CheckBox) v.findViewById(R.id.colorless_cb);
// final CheckBox creaturecb = (CheckBox) v.findViewById(R.id.creaturecb);
// final CheckBox enchantcb = (CheckBox) v.findViewById(R.id.enchantcb);
// final CheckBox instantcb = (CheckBox) v.findViewById(R.id.instantcb);
// final CheckBox sorcerycb = (CheckBox) v.findViewById(R.id.sorcerycb);
// final CheckBox planescb = (CheckBox) v.findViewById(R.id.planeswalkercb);
// final CheckBox artifactcb = (CheckBox) v.findViewById(R.id.artifactcb);
// adb.setView(v);
// adb.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// ArrayList<String> colors = new ArrayList<String>();
// ArrayList<String> types = new ArrayList<String>();
// if (redcb.isChecked()){
// colors.add("R");
// }
// if (bluecb.isChecked()){
// colors.add("U");
// }
// if (greencb.isChecked()){
// colors.add("G");
// }
// if (blackcb.isChecked()){
// colors.add("B");
// }
// if (whitecb.isChecked()){
// colors.add("W");
// }
// if (colorlesscb.isChecked()){
// colors.add("C");
// }
// if (creaturecb.isChecked()){
// types.add("Creature");
// }
// if (enchantcb.isChecked()){
// types.add("Enchantment");
// }
// if (instantcb.isChecked()){
// types.add("Instant");
// }
// if (sorcerycb.isChecked()){
// types.add("Sorcery");
// }
// if (planescb.isChecked()){
// types.add("Planeswalker");
// }
// if (artifactcb.isChecked()){
// types.add("Artifact");
// }
//
// filterCards(colors, types);
//
//
// dialog.dismiss();
// }
// });
// adb.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
// });
//
//
// return adb;
// }
// private void filterCards(ArrayList<String> filtercolors, ArrayList<String> filtertypes){
// ArrayList<Card> filteredcolors = new ArrayList<Card>();
// filteredcards = new ArrayList<Card>();
// if (filtercolors.size()>0 || filtertypes.size()>0){
// if (filtercolors.size()>0) {
// for (Card c : mCardArrayList) {
// for (String s : filtercolors) {
// if (c.getMana().contains(s)) {
// filteredcolors.add(c);
// } else if (s.equals("C")) {
// if (!(c.getMana().contains("W") || c.getMana().contains("U") || c.getMana().contains("B") || c.getMana().contains("R") || c.getMana().contains("G"))) {
// filteredcolors.add(c);
// }
// }
// }
// }
// }
// if (filtertypes.size()>0 && filtercolors.size()>0) {
// for (Card a : filteredcolors) {
// for (String t : filtertypes) {
// if (a.getType().contains(t)) {
// filteredcards.add(a);
// }
// }
// }
// }else if (filtertypes.size()>0){
// for (Card a : mCardArrayList) {
// for (String t : filtertypes) {
// if (a.getType().contains(t)) {
// filteredcards.add(a);
// }
// }
// }
// }
// if (filtertypes.size()==0){
// filteredcards.addAll(filteredcolors);
// }
// CardPagerAdapter filteredadapter = new CardPagerAdapter(getFragmentManager(), filteredcards, filteredcards.size());
// pager.setAdapter(filteredadapter);
// filtered = true;
// }else{
// CardPagerAdapter adapter = new CardPagerAdapter(getFragmentManager(), mCardArrayList, setcount);
// pager.setAdapter(adapter);
// filtered = false;
// }
//
// }
private class CardPagerAdapter extends FragmentStatePagerAdapter {
ArrayList<Card> cards;
int count;
public CardPagerAdapter(FragmentManager fm, ArrayList<Card> cards, int count) {
super(fm);
this.cards = cards;
this.count = count;
}
@Override
public Fragment getItem(int i) {
String currentcardimgurl = cards.get(i).getCardimgurl() + "/" + cards.get(i).getNum() + ".jpg";
String rulings = cards.get(i).getRulings();
String cardurl = "http://www.magiccards.info"+cards.get(i).getUrl();
return CardFragment.newInstance(currentcardimgurl, rulings, cardurl);
}
@Override
public int getCount() {
return count;
}
}
public class DepthPageTransformer implements ViewPager.PageTransformer {
private static final float MIN_SCALE = 0.75f;
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
// Use the default slide transition when moving to the left page
view.setAlpha(1);
view.setTranslationX(0);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) { // (0,1]
// Fade the page out.
view.setAlpha(1 - position);
// Counteract the default slide transition
view.setTranslationX(pageWidth * -position);
// Scale the page down (between MIN_SCALE and 1)
float scaleFactor = MIN_SCALE
+ (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
}
}
| [
"Duces2ii@gmail.com"
] | Duces2ii@gmail.com |
1afc4135cf1b2de811b6ec648b58a9deef91722f | 573afb6df6eb238d59463677e5a1765b0927f5f7 | /src/main/java/org/lab/mars/onem2m/server/upgrade/DataTreeV1.java | bb3189d31241a8d153797256b1083ba9262b8dc6 | [] | no_license | yaoalong/GraduationProject | d0ec0011f394388d1c6222e35fdb35cdf786d630 | 537a4caf50652983414665a362ac3b612b637086 | refs/heads/master | 2021-01-10T01:12:59.217132 | 2016-02-23T04:33:52 | 2016-02-23T04:33:52 | 48,848,104 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 20,798 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lab.mars.onem2m.server.upgrade;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.lab.mars.onem2m.KeeperException;
import org.lab.mars.onem2m.KeeperException.Code;
import org.lab.mars.onem2m.KeeperException.NoNodeException;
import org.lab.mars.onem2m.Watcher;
import org.lab.mars.onem2m.Watcher.Event;
import org.lab.mars.onem2m.Watcher.Event.EventType;
import org.lab.mars.onem2m.ZooDefs.OpCode;
import org.lab.mars.onem2m.data.ACL;
import org.lab.mars.onem2m.data.Stat;
import org.lab.mars.onem2m.data.StatPersistedV1;
import org.lab.mars.onem2m.jute.InputArchive;
import org.lab.mars.onem2m.jute.OutputArchive;
import org.lab.mars.onem2m.jute.Record;
import org.lab.mars.onem2m.server.WatchManager;
import org.lab.mars.onem2m.txn.CreateTxn;
import org.lab.mars.onem2m.txn.DeleteTxn;
import org.lab.mars.onem2m.txn.ErrorTxn;
import org.lab.mars.onem2m.txn.SetACLTxn;
import org.lab.mars.onem2m.txn.SetDataTxn;
import org.lab.mars.onem2m.txn.TxnHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class maintains the tree data structure. It doesn't have any networking
* or client connection code in it so that it can be tested in a stand alone
* way.
* <p>
* The tree maintains two parallel data structures: a hashtable that maps from
* full paths to DataNodes and a tree of DataNodes. All accesses to a path is
* through the hashtable. The tree is traversed only when serializing to disk.
*/
public class DataTreeV1 {
private static final Logger LOG = LoggerFactory.getLogger(DataTreeV1.class);
/**
* This hashtable provides a fast lookup to the datanodes. The tree is the
* source of truth and is where all the locking occurs
*/
private ConcurrentHashMap<String, DataNodeV1> nodes = new ConcurrentHashMap<String, DataNodeV1>();
private WatchManager dataWatches = new WatchManager();
private WatchManager childWatches = new WatchManager();
/**
* This hashtable lists the paths of the ephemeral nodes of a session.
*/
private Map<Long, HashSet<String>> ephemerals = new ConcurrentHashMap<Long, HashSet<String>>();
/**
* return the ephemerals for this tree
*
* @return the ephemerals for this tree
*/
public Map<Long, HashSet<String>> getEphemeralsMap() {
return this.ephemerals;
}
public void setEphemeralsMap(Map<Long, HashSet<String>> ephemerals) {
this.ephemerals = ephemerals;
}
@SuppressWarnings("unchecked")
public HashSet<String> getEphemerals(long sessionId) {
HashSet<String> retv = ephemerals.get(sessionId);
if (retv == null) {
return new HashSet<String>();
}
HashSet<String> cloned = null;
synchronized (retv) {
cloned = (HashSet<String>) retv.clone();
}
return cloned;
}
public Collection<Long> getSessions() {
return ephemerals.keySet();
}
public DataNodeV1 getNode(String path) {
return nodes.get(path);
}
/**
* This is a pointer to the root of the DataTree. It is the source of truth,
* but we usually use the nodes hashmap to find nodes in the tree.
*/
private DataNodeV1 root = new DataNodeV1(null, new byte[0], null,
new StatPersistedV1());
public DataTreeV1() {
/* Rather than fight it, let root have an alias */
nodes.put("", root);
nodes.put("/", root);
}
static public void copyStatPersisted(StatPersistedV1 from,
StatPersistedV1 to) {
to.setAversion(from.getAversion());
to.setCtime(from.getCtime());
to.setCversion(from.getCversion());
to.setCzxid(from.getCzxid());
to.setMtime(from.getMtime());
to.setMzxid(from.getMzxid());
to.setVersion(from.getVersion());
to.setEphemeralOwner(from.getEphemeralOwner());
}
static public void copyStat(Stat from, Stat to) {
to.setAversion(from.getAversion());
to.setCtime(from.getCtime());
to.setCversion(from.getCversion());
to.setCzxid(from.getCzxid());
to.setMtime(from.getMtime());
to.setMzxid(from.getMzxid());
to.setVersion(from.getVersion());
to.setEphemeralOwner(from.getEphemeralOwner());
to.setDataLength(from.getDataLength());
to.setNumChildren(from.getNumChildren());
}
// public void remooveInterest(String path, Watcher nw) {
// DataNode n = nodes.get(path);
// if (n == null) {
// synchronized (nonExistentWatches) {
// HashSet<Watcher> list = nonExistentWatches.get(path);
// if (list != null) {
// list.remove(nw);
// }
// }
// }
// synchronized (n) {
// n.dataWatchers.remove(nw);
// n.childWatchers.remove(nw);
// }
// }
/**
* @param path
* @param data
* @param acl
* @param ephemeralOwner
* the session id that owns this node. -1 indicates this is not
* an ephemeral node.
* @param zxid
* @param time
* @return the patch of the created node
* @throws KeeperException
*/
public String createNode(String path, byte data[], List<ACL> acl,
long ephemeralOwner, long zxid, long time)
throws KeeperException.NoNodeException,
KeeperException.NodeExistsException {
int lastSlash = path.lastIndexOf('/');
String parentName = path.substring(0, lastSlash);
String childName = path.substring(lastSlash + 1);
StatPersistedV1 stat = new StatPersistedV1();
stat.setCtime(time);
stat.setMtime(time);
stat.setCzxid(zxid);
stat.setMzxid(zxid);
stat.setVersion(0);
stat.setAversion(0);
stat.setEphemeralOwner(ephemeralOwner);
DataNodeV1 parent = nodes.get(parentName);
if (parent == null) {
throw new KeeperException.NoNodeException();
}
synchronized (parent) {
if (parent.children.contains(childName)) {
throw new KeeperException.NodeExistsException();
}
int cver = parent.stat.getCversion();
cver++;
parent.stat.setCversion(cver);
DataNodeV1 child = new DataNodeV1(parent, data, acl, stat);
parent.children.add(childName);
nodes.put(path, child);
if (ephemeralOwner != 0) {
HashSet<String> list = ephemerals.get(ephemeralOwner);
if (list == null) {
list = new HashSet<String>();
ephemerals.put(ephemeralOwner, list);
}
synchronized (list) {
list.add(path);
}
}
}
dataWatches.triggerWatch(path, Event.EventType.NodeCreated);
childWatches.triggerWatch(parentName.equals("") ? "/" : parentName,
Event.EventType.NodeChildrenChanged);
return path;
}
public void deleteNode(String path) throws KeeperException.NoNodeException {
int lastSlash = path.lastIndexOf('/');
String parentName = path.substring(0, lastSlash);
String childName = path.substring(lastSlash + 1);
DataNodeV1 node = nodes.get(path);
if (node == null) {
throw new KeeperException.NoNodeException();
}
nodes.remove(path);
DataNodeV1 parent = nodes.get(parentName);
if (parent == null) {
throw new KeeperException.NoNodeException();
}
synchronized (parent) {
parent.children.remove(childName);
parent.stat.setCversion(parent.stat.getCversion() + 1);
long eowner = node.stat.getEphemeralOwner();
if (eowner != 0) {
HashSet<String> nodes = ephemerals.get(eowner);
if (nodes != null) {
synchronized (nodes) {
nodes.remove(path);
}
}
}
node.parent = null;
}
Set<Watcher> processed = dataWatches.triggerWatch(path,
EventType.NodeDeleted);
childWatches.triggerWatch(path, EventType.NodeDeleted, processed);
childWatches.triggerWatch(parentName.equals("") ? "/" : parentName,
EventType.NodeChildrenChanged);
}
public Stat setData(String path, byte data[], int version, long zxid,
long time) throws KeeperException.NoNodeException {
Stat s = new Stat();
DataNodeV1 n = nodes.get(path);
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
n.data = data;
n.stat.setMtime(time);
n.stat.setMzxid(zxid);
n.stat.setVersion(version);
n.copyStat(s);
}
dataWatches.triggerWatch(path, EventType.NodeDataChanged);
return s;
}
public byte[] getData(String path, Stat stat, Watcher watcher)
throws KeeperException.NoNodeException {
DataNodeV1 n = nodes.get(path);
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
n.copyStat(stat);
if (watcher != null) {
dataWatches.addWatch(path, watcher);
}
return n.data;
}
}
public Stat statNode(String path, Watcher watcher)
throws KeeperException.NoNodeException {
Stat stat = new Stat();
DataNodeV1 n = nodes.get(path);
if (watcher != null) {
dataWatches.addWatch(path, watcher);
}
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
n.copyStat(stat);
return stat;
}
}
public ArrayList<String> getChildren(String path, Stat stat, Watcher watcher)
throws KeeperException.NoNodeException {
DataNodeV1 n = nodes.get(path);
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
ArrayList<String> children = new ArrayList<String>();
children.addAll(n.children);
if (watcher != null) {
childWatches.addWatch(path, watcher);
}
return children;
}
}
public Stat setACL(String path, List<ACL> acl, int version)
throws KeeperException.NoNodeException {
Stat stat = new Stat();
DataNodeV1 n = nodes.get(path);
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
n.stat.setAversion(version);
n.acl = acl;
n.copyStat(stat);
return stat;
}
}
public List<ACL> getACL(String path, Stat stat)
throws KeeperException.NoNodeException {
DataNodeV1 n = nodes.get(path);
if (n == null) {
throw new KeeperException.NoNodeException();
}
synchronized (n) {
n.copyStat(stat);
return new ArrayList<ACL>(n.acl);
}
}
static public class ProcessTxnResult {
public long clientId;
public int cxid;
public long zxid;
public int err;
public int type;
public String path;
public Stat stat;
/**
* Equality is defined as the clientId and the cxid being the same. This
* allows us to use hash tables to track completion of transactions.
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (o instanceof ProcessTxnResult) {
ProcessTxnResult other = (ProcessTxnResult) o;
return other.clientId == clientId && other.cxid == cxid;
}
return false;
}
/**
* See equals() to find the rational for how this hashcode is generated.
*
* @see ProcessTxnResult#equals(Object)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return (int) ((clientId ^ cxid) % Integer.MAX_VALUE);
}
}
public volatile long lastProcessedZxid = 0;
public ProcessTxnResult processTxn(TxnHeader header, Record txn) {
ProcessTxnResult rc = new ProcessTxnResult();
String debug = "";
try {
rc.clientId = header.getClientId();
rc.cxid = header.getCxid();
rc.zxid = header.getZxid();
rc.type = header.getType();
rc.err = 0;
if (rc.zxid > lastProcessedZxid) {
lastProcessedZxid = rc.zxid;
}
switch (header.getType()) {
case OpCode.create:
CreateTxn createTxn = (CreateTxn) txn;
debug = "Create transaction for " + createTxn.getPath();
createNode(createTxn.getPath(), createTxn.getData(),
createTxn.getAcl(),
createTxn.getEphemeral() ? header.getClientId() : 0,
header.getZxid(), header.getTime());
rc.path = createTxn.getPath();
break;
case OpCode.delete:
DeleteTxn deleteTxn = (DeleteTxn) txn;
debug = "Delete transaction for " + deleteTxn.getPath();
deleteNode(deleteTxn.getPath());
break;
case OpCode.setData:
SetDataTxn setDataTxn = (SetDataTxn) txn;
debug = "Set data for transaction for " + setDataTxn.getPath();
rc.stat = setData(setDataTxn.getPath(), setDataTxn.getData(),
setDataTxn.getVersion(), header.getZxid(),
header.getTime());
break;
case OpCode.setACL:
SetACLTxn setACLTxn = (SetACLTxn) txn;
debug = "Set ACL for transaction for " + setACLTxn.getPath();
rc.stat = setACL(setACLTxn.getPath(), setACLTxn.getAcl(),
setACLTxn.getVersion());
break;
case OpCode.closeSession:
killSession(header.getClientId());
break;
case OpCode.error:
ErrorTxn errTxn = (ErrorTxn) txn;
rc.err = errTxn.getErr();
break;
}
} catch (KeeperException e) {
// These are expected errors since we take a lazy snapshot
if (initialized
|| (e.code() != Code.NONODE && e.code() != Code.NODEEXISTS)) {
LOG.warn("Failed:" + debug, e);
}
}
return rc;
}
void killSession(long session) {
// the list is already removed from the ephemerals
// so we do not have to worry about synchronyzing on
// the list. This is only called from FinalRequestProcessor
// so there is no need for synchornization. The list is not
// changed here. Only create and delete change the list which
// are again called from FinalRequestProcessor in sequence.
HashSet<String> list = ephemerals.remove(session);
if (list != null) {
for (String path : list) {
try {
deleteNode(path);
if (LOG.isDebugEnabled()) {
LOG.debug("Deleting ephemeral node " + path
+ " for session 0x" + Long.toHexString(session));
}
} catch (NoNodeException e) {
LOG.warn("Ignoring NoNodeException for path " + path
+ " while removing ephemeral for dead session 0x"
+ Long.toHexString(session));
}
}
}
}
/**
* this method uses a stringbuilder to create a new path for children. This
* is faster than string appends ( str1 + str2).
*
* @param oa
* OutputArchive to write to.
* @param path
* a string builder.
* @throws IOException
* @throws InterruptedException
*/
void serializeNode(OutputArchive oa, StringBuilder path)
throws IOException, InterruptedException {
String pathString = path.toString();
DataNodeV1 node = getNode(pathString);
if (node == null) {
return;
}
String children[] = null;
synchronized (node) {
scount++;
oa.writeString(pathString, "path");
oa.writeRecord(node, "node");
children = node.children.toArray(new String[node.children.size()]);
}
path.append('/');
int off = path.length();
if (children != null) {
for (String child : children) {
// since this is single buffer being resused
// we need
// to truncate the previous bytes of string.
path.delete(off, Integer.MAX_VALUE);
path.append(child);
serializeNode(oa, path);
}
}
}
int scount;
public boolean initialized = false;
public void serialize(OutputArchive oa, String tag) throws IOException,
InterruptedException {
scount = 0;
serializeNode(oa, new StringBuilder(""));
// / marks end of stream
// we need to check if clear had been called in between the snapshot.
if (root != null) {
oa.writeString("/", "path");
}
}
public void deserialize(InputArchive ia, String tag) throws IOException {
nodes.clear();
String path = ia.readString("path");
while (!path.equals("/")) {
DataNodeV1 node = new DataNodeV1();
ia.readRecord(node, "node");
nodes.put(path, node);
int lastSlash = path.lastIndexOf('/');
if (lastSlash == -1) {
root = node;
} else {
String parentPath = path.substring(0, lastSlash);
node.parent = nodes.get(parentPath);
node.parent.children.add(path.substring(lastSlash + 1));
long eowner = node.stat.getEphemeralOwner();
if (eowner != 0) {
HashSet<String> list = ephemerals.get(eowner);
if (list == null) {
list = new HashSet<String>();
ephemerals.put(eowner, list);
}
list.add(path);
}
}
path = ia.readString("path");
}
nodes.put("/", root);
}
public String dumpEphemerals() {
Set<Long> keys = ephemerals.keySet();
StringBuilder sb = new StringBuilder("Sessions with Ephemerals ("
+ keys.size() + "):\n");
for (long k : keys) {
sb.append("0x" + Long.toHexString(k));
sb.append(":\n");
HashSet<String> tmp = ephemerals.get(k);
synchronized (tmp) {
for (String path : tmp) {
sb.append("\t" + path + "\n");
}
}
}
return sb.toString();
}
public void removeCnxn(Watcher watcher) {
dataWatches.removeWatcher(watcher);
childWatches.removeWatcher(watcher);
}
public void clear() {
root = null;
nodes.clear();
ephemerals.clear();
// dataWatches = null;
// childWatches = null;
}
}
| [
"sishimei@163.com"
] | sishimei@163.com |
53fb176aa995255578f7d48b706aabb0609d53a9 | a54a4058152685f507e02e3e9f6ad422ff5df751 | /embedded-jetty-example/src/main/java/com/jason/embedded_jetty/MyResource.java | b2d9ee684fc6dbcd8e84ffb0ca62c060431e5e3d | [
"Apache-2.0"
] | permissive | jasonbwtan/code-snippets | 7a3366b2d61a47144c9eef48a3db64a7d87ede4b | b753a27373918f63b0c19731817428edff034d4e | refs/heads/master | 2021-01-21T12:40:09.506796 | 2016-03-24T10:55:26 | 2016-03-24T10:55:26 | 37,095,326 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,594 | java | package com.jason.embedded_jetty;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.Date;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* Root resource (exposed at "myresource" path)
*/
@Path("api")
public class MyResource {
/**
* Method handling HTTP GET requests. The returned object will be sent to
* the client as "text/plain" media type.
*
* @return String that will be returned as a text/plain response.
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Hello, Jersey-Rest-Heroku (space)!";
}
// @GET
// @Path("/getreport")
// @Produces("text/plain")
// public Response getReport() throws IOException {
// Date date = new Date();
// SimpleDateFormat sdf = new SimpleDateFormat("YYYY_MM_dd");
// String dateString = sdf.format(date);
//// File file = new File("foo.txt");
//// FileOutputStream out = new FileOutputStream(file);
//// byte[] data = {1, 2, 3, 4, 5};
//// out.write(data);
//// out.close();
// PrintWriter writer = new PrintWriter("foo.txt", "UTF-8");
// writer.println("The first line");
// writer.println("The second line");
// writer.close();
// File file = new File("foo.txt");
//
// ResponseBuilder response = Response.ok((Object) file);
// response.header("Content-Disposition",
// "attachment; filename=\"space_report_"+dateString+".txt\"");
// return response.build();
//
// }
}
| [
"jasonbwtan@hotmail.com"
] | jasonbwtan@hotmail.com |
b977f4f4359471768bddb856bdd7e82e654eea03 | 33a40d1cd5e52c9ec96514c68d5384505d9f0202 | /achilles-cql/src/test/java/info/archinnov/achilles/table/CQLTableValidatorTest.java | cdd93ef444bce1080b26f1d51de8b026c541e2c0 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | mboudraa/Achilles | 87271fc1c8a141aac8dca1b540d1dcd1beb7c472 | 80d1ee7baa04e11fad17eff152175dcda5c816bc | refs/heads/master | 2021-01-20T11:50:10.246889 | 2013-09-03T20:32:17 | 2013-09-03T20:32:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,157 | java | package info.archinnov.achilles.table;
import static info.archinnov.achilles.counter.AchillesCounter.*;
import static info.archinnov.achilles.entity.metadata.PropertyType.*;
import static org.mockito.Mockito.*;
import info.archinnov.achilles.entity.metadata.EntityMeta;
import info.archinnov.achilles.entity.metadata.PropertyMeta;
import info.archinnov.achilles.test.builders.PropertyMetaTestBuilder;
import info.archinnov.achilles.test.mapping.entity.UserBean;
import info.archinnov.achilles.test.parser.entity.CompoundKey;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ColumnMetadata;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.TableMetadata;
import com.google.common.collect.ImmutableMap;
/**
* CQLTableValidatorTest
*
* @author DuyHai DOAN
*
*/
@RunWith(MockitoJUnitRunner.class)
public class CQLTableValidatorTest {
private CQLTableValidator validator;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Cluster cluster;
@Mock
private TableMetadata tableMetadata;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ColumnMetadata columnMetadata;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ColumnMetadata columnMetadataForField;
private String keyspaceName = "keyspace";
private EntityMeta entityMeta;
@Before
public void setUp()
{
validator = new CQLTableValidator(cluster, keyspaceName);
entityMeta = new EntityMeta();
}
@Test
public void should_validate_id_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
PropertyMeta nameMeta = PropertyMetaTestBuilder
.completeBean(Void.class, String.class)
.field("name")
.type(SIMPLE)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(nameMeta));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("name")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.text());
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_embedded_id_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.valueClass(CompoundKey.class)
.compNames("userId", "name")
.compClasses(Long.class, String.class)
.type(EMBEDDED_ID)
.build();
PropertyMeta nameMeta = PropertyMetaTestBuilder
.completeBean(Void.class, String.class)
.field("string")
.type(SIMPLE)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(nameMeta));
when(tableMetadata.getName()).thenReturn("table");
ColumnMetadata userIdMetadata = mock(ColumnMetadata.class);
when(tableMetadata.getColumn("userid")).thenReturn(userIdMetadata);
when(userIdMetadata.getType()).thenReturn(DataType.bigint());
ColumnMetadata nameMetadata = mock(ColumnMetadata.class);
when(tableMetadata.getColumn("name")).thenReturn(nameMetadata);
when(nameMetadata.getType()).thenReturn(DataType.text());
when(tableMetadata.getColumn("string")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.text());
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_simple_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, String.class)
.field("name")
.type(SIMPLE)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("name")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.text());
validator.validateForEntity(entityMeta, tableMetadata);
pm = PropertyMetaTestBuilder.
completeBean(Void.class, String.class)
.field("name")
.type(LAZY_SIMPLE)
.build();
entityMeta.setPropertyMetas(ImmutableMap.of("name", pm));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_join_simple_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
EntityMeta joinMeta = new EntityMeta();
joinMeta.setIdMeta(idMeta);
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, UserBean.class)
.field("user")
.type(JOIN_SIMPLE)
.joinMeta(joinMeta)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("user")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.bigint());
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_list_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, String.class)
.field("friends")
.type(LIST)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("friends")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.list(DataType.text()));
validator.validateForEntity(entityMeta, tableMetadata);
pm = PropertyMetaTestBuilder.
completeBean(Void.class, String.class)
.field("friends")
.type(LAZY_LIST)
.build();
entityMeta.setPropertyMetas(ImmutableMap.of("friends", pm));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_join_list_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
EntityMeta joinMeta = new EntityMeta();
joinMeta.setIdMeta(idMeta);
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, UserBean.class)
.field("friends")
.joinMeta(joinMeta)
.type(JOIN_LIST)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("friends")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.list(DataType.bigint()));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_set_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, String.class)
.field("followers")
.type(SET)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("followers")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.set(DataType.text()));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_join_set_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
EntityMeta joinMeta = new EntityMeta();
joinMeta.setIdMeta(idMeta);
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Void.class, UserBean.class)
.field("followers")
.type(JOIN_SET)
.joinMeta(joinMeta)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("followers")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.set(DataType.bigint()));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_map_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Integer.class, String.class)
.field("preferences")
.type(MAP)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("preferences")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.map(DataType.cint(), DataType.text()));
validator.validateForEntity(entityMeta, tableMetadata);
pm = PropertyMetaTestBuilder.
completeBean(Integer.class, String.class)
.field("preferences")
.type(LAZY_MAP)
.build();
entityMeta.setPropertyMetas(ImmutableMap.of("preferences", pm));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_join_map_field_for_entity() throws Exception
{
PropertyMeta idMeta = PropertyMetaTestBuilder
.completeBean(Void.class, Long.class)
.field("id")
.type(ID)
.build();
EntityMeta joinMeta = new EntityMeta();
joinMeta.setIdMeta(idMeta);
PropertyMeta pm = PropertyMetaTestBuilder.
completeBean(Integer.class, String.class)
.field("preferences")
.type(JOIN_MAP)
.joinMeta(joinMeta)
.build();
entityMeta.setIdMeta(idMeta);
entityMeta.setAllMetasExceptIdMeta(Arrays.asList(pm));
when(tableMetadata.getName()).thenReturn("table");
when(tableMetadata.getColumn("id")).thenReturn(columnMetadata);
when(columnMetadata.getType()).thenReturn(DataType.bigint());
when(tableMetadata.getColumn("preferences")).thenReturn(columnMetadataForField);
when(columnMetadataForField.getType()).thenReturn(DataType.map(DataType.cint(), DataType.bigint()));
validator.validateForEntity(entityMeta, tableMetadata);
}
@Test
public void should_validate_achilles_counter() throws Exception
{
KeyspaceMetadata keyspaceMeta = mock(KeyspaceMetadata.class);
when(cluster.getMetadata().getKeyspace(keyspaceName)).thenReturn(keyspaceMeta);
when(keyspaceMeta.getTable(CQL_COUNTER_TABLE)).thenReturn(tableMetadata);
ColumnMetadata fqcnColumnMeta = mock(ColumnMetadata.class);
when(tableMetadata.getColumn(CQL_COUNTER_FQCN)).thenReturn(fqcnColumnMeta);
ColumnMetadata pkColumnMeta = mock(ColumnMetadata.class);
when(tableMetadata.getColumn(CQL_COUNTER_PRIMARY_KEY)).thenReturn(pkColumnMeta);
ColumnMetadata propertyColumnMeta = mock(ColumnMetadata.class);
when(tableMetadata.getColumn(CQL_COUNTER_PROPERTY_NAME)).thenReturn(propertyColumnMeta);
ColumnMetadata counterColumnMeta = mock(ColumnMetadata.class);
when(tableMetadata.getColumn(CQL_COUNTER_VALUE)).thenReturn(counterColumnMeta);
when(fqcnColumnMeta.getType()).thenReturn(DataType.text());
when(pkColumnMeta.getType()).thenReturn(DataType.text());
when(propertyColumnMeta.getType()).thenReturn(DataType.text());
when(counterColumnMeta.getType()).thenReturn(DataType.counter());
validator.validateAchillesCounter();
}
}
| [
"doanduyhai@gmail.com"
] | doanduyhai@gmail.com |
4e2231dbc283ad1865f09f5b3dd3e271be9c5399 | 273becbf8b6ca4490bc910d52f52e5eeaec40039 | /image/src/main/java/com/project/image/files/tiff/Tiff.java | 41e824c310345835f41a770a71b1e24f59f2565b | [] | no_license | wlgh2626/ImageProcessor | 93b8e0ab191a7a20ef44edf413d7a4ebd436347b | 6aac47f1ca8c4cd1d379ec8564ab92ea1c7ccce9 | refs/heads/main | 2023-07-23T22:16:05.689811 | 2021-09-08T20:43:11 | 2021-09-08T20:43:11 | 362,288,578 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,597 | java | package com.project.image.files.tiff;
import java.util.ArrayList;
import java.util.Arrays;
import com.project.image.files.tiff.header.Header;
import com.project.image.files.tiff.ifd.ImageFileDirectory;
import com.project.image.files.tiff.ifd.Tags.TagName;
import com.project.image.files.tiff.image.Image;
public class Tiff {
public static final String TIFF_DIRECTORY = System.getProperty("user.dir") + "/tiff";
private Header header;
private ArrayList<Image> imageList = new ArrayList<Image>();
private ArrayList<ImageFileDirectory> ifdList = new ArrayList<ImageFileDirectory>();
private final byte[] data;
public Tiff(byte[] data) throws Exception {
this.data = data;
header = new Header(Arrays.copyOfRange(data, 0, 8));
int currentOffset = header.getOffset();
ImageFileDirectory currentIFD;
Image currentImage;
do {
currentIFD = new ImageFileDirectory(data, currentOffset, header.getBufferReader());
currentImage = new Image.Builder(data)
.length(currentIFD.tagToValue(TagName.IMAGE_LENGTH).get(0))
.width(currentIFD.tagToValue(TagName.IMAGE_WIDTH).get(0))
.byteCounts(currentIFD.tagToValue(TagName.STRIP_BYTE_COUNTS))
.offsets(currentIFD.tagToValue(TagName.STRIPS_OFF_SETS))
.build();
ifdList.add(currentIFD);
imageList.add(currentImage);
currentOffset = currentIFD.getNextOffset();
} while (currentOffset != 0);
}
public Header getHeader() {
return header;
}
public ArrayList<ImageFileDirectory> getIFDList() {
return ifdList;
}
public ArrayList<Image> getImageList() {
return imageList;
}
}
| [
"wlgh2626@hotmail.com"
] | wlgh2626@hotmail.com |
7eefcca08893b8714992a57707cd2ee86daf07ba | e832a56e691822fa7335c5a209dfa536f7b3ee2b | /app/src/main/java/com/example/abdel/egyptguide/TabsActivity.java | f07eca113267c004c6801656ca86e69d6a03893f | [] | no_license | Abdelaty/Egypt-Guide | 1eee61731c672cd4f3cf19a4fb8e548a0fc37719 | 9bb3f453209e3a9649816db4e43c0c14c401f630 | refs/heads/master | 2020-03-14T18:34:46.713869 | 2018-05-05T06:41:23 | 2018-05-05T06:41:23 | 129,339,353 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,778 | java | package com.example.abdel.egyptguide;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class TabsActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabs);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabs);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_tabs, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (getArguments().getInt(ARG_SECTION_NUMBER) == 1) {
View rootView = inflater.inflate(R.layout.fragment_cairo_tower_about, container, false);
return rootView;
} else if (getArguments().getInt(ARG_SECTION_NUMBER) == 2) {
View rootView = inflater.inflate(R.layout.fragment_cairo_tower_videos, container, false);
return rootView;
} else {
View rootView = inflater.inflate(R.layout.fragment_tabs, container, false);
TextView textView = rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
}
}
| [
"Abdelaty.mohammedmagdi@gmail.com"
] | Abdelaty.mohammedmagdi@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.