blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
132 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
28 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
352
52c6c9d8fca90f5fa580b24da8fa1a3592f51243
a41aecf9653ee34cb5d75ab23459e4d2e1787a8f
/src/android/utils/PrinterSetting.java
92d119227de4f63e1a856d90301d3e118b9e347d
[ "MIT" ]
permissive
andrewphan/cordova-plugin-bixolon-bt-printer
41f93e9fddc58513afb15c9a8be287117699f4db
d970b99187e6d3579e51173649ece5227329cf03
refs/heads/master
2020-03-18T14:09:48.585213
2018-05-29T04:23:35
2018-05-29T04:23:35
134,833,540
0
0
null
null
null
null
UTF-8
Java
false
false
3,023
java
package com.dn.andrewphan.bixolonprinter.utils; import java.util.HashMap; import java.util.Map; /** * Package: com.dn.andrewphan.bixolonprinter.utils * Created by andrew.phan * on 5/24/18 3:17 PM */ public class PrinterSetting { // Action to execute public static final String ACTION_PRINT_TEXT = "printText"; public static final String ACTION_PRINT_1D_BARCODE = "printBarCode"; public static final String ACTION_PRINT_QRCODE = "printQRCode"; public static final String ACTION_GET_STATUS = "getStatus"; public static final String ACTION_CUT_PAPER = "cutPaper"; public static final String ACTION_START_MSR_READER_LISTENER = "startMsrReaderListener"; public static final String ACTION_STOP_MSR_READER_LISTENER = "stopMsrReaderListener"; public static final String ACTION_START_CONNECTION_LISTENER = "startConnectionListener"; public static final String ACTION_RECONNECT = "reconnect"; public static final String ACTION_DISCONNECT = "disconnect"; public static final String ACTION_STOP_CONNECTION_LISTENER = "stopConnectionListener"; // Alignment string public static final String ALIGNMENT_LEFT = "LEFT"; public static final String ALIGNMENT_CENTER = "CENTER"; public static final String ALIGNMENT_RIGHT = "RIGHT"; // Font string public static final String FONT_A = "A"; public static final String FONT_B = "B"; @SuppressWarnings({"serial", "unused"}) public final static Map<String, String> PRODUCT_IDS = new HashMap<String, String>() {{ put("10", "SPP-R200"); put("11", "SPP-R210"); put("18", "SPP-100"); put("22", "SRP-F310"); put("31", "SRP-350II"); put("29", "SRP-350plusII"); put("35", "SRP-F312"); put("36", "SRP-350IIK"); put("40", "SPP-R200II"); put("33", "SPP-R300"); put("41", "SPP-R400"); }}; @SuppressWarnings("serial") public final static Map<String, Integer> MAX_COL = new HashMap<String, Integer>() {{ put("SPP-R200", 0); put("SPP-R210",0); put("SPP-100", 0); put("SRP-F310", 0); put("SRP-350II", 0); put("SRP-350plusII", 0); put("SRP-F312", 0); put("SRP-350IIK", 0); put("SPP-R200II", 0); put("SPP-R300", 48); put("SPP-R400", 69); }}; public static final int STATUS_STEP_GET_STATUS = 0; public static final int STATUS_STEP_GET_BATTERY_STATUS = 1; public static final int STATUS_STEP_GET_PRINTER_ID_FIRMWARE_VERSION = 2; public static final int STATUS_STEP_GET_PRINTER_ID_MANUFACTURER = 3; public static final int STATUS_STEP_GET_PRINTER_ID_PRINTER_MODEL = 4; public static final int STATUS_STEP_GET_PRINTER_ID_CODE_PAGE = 5; public static final int STATUS_STEP_GET_PRINTER_ID_MODEL_ID = 6; public static final int STATUS_STEP_GET_PRINTER_ID_PRODUCT_SERIAL = 7; public static final int STATUS_STEP_GET_PRINTER_ID_TYPE_ID = 8; public static final int STATUS_STEP_COMPLETE = 10; }
[ "an.phan.chau.truong@gmail.com" ]
an.phan.chau.truong@gmail.com
6b7940f6b0dff3b919c4933a76db2fcae08bc3b3
9d470695c72f14714ff5c0a2fe426c627d2cdd2a
/CSCI201L_FinalProject/src/servlets/Login.java
7c40af9d81bf7eebd6943fa9284d502054a1191d
[]
no_license
mtawata/USC_CSCI201L_Final_iMusic
8c81f431a8748b6656ab755614f3b8106c66a750
3ac9d97cb68d022e64ed20df4bb5d20e2353eb2c
refs/heads/master
2020-05-03T21:40:07.091159
2019-04-01T09:22:53
2019-04-01T09:22:53
178,828,089
0
0
null
null
null
null
UTF-8
Java
false
false
727
java
package servlets; import java.sql.ResultSet; import java.sql.SQLException; public class Login { //If the server gets val = 0 public static String login(String username, String userPassword) throws ClassNotFoundException { try { //If user does not exist return "username" ResultSet users = Database.getUsers(username); boolean usersExist = false; while(users.next()) { usersExist = true; break; } if(!usersExist) { return "0,username"; } //If user's password is incorrect return "password" return Database.passwordMatch(username, users, userPassword); } catch (SQLException e) { System.out.println("Error login"); e.printStackTrace(); } return null; } }
[ "tawata@usc.edu" ]
tawata@usc.edu
f8dd370b8552dc4b1a8b55be6e03da95099f7284
44eef90e43fd3ad94f6c820fe502876301bc5d02
/mybatis/src/test/java/org/apache/ibatis/submitted/order_prefix_removed/Person.java
4b392aa0550223d06fe8833060dcf46684a691fa
[]
no_license
chenhonghaovip/spring-framework-master
faafc370433113a25093e22c9927e8886f8a7463
5d56503bacf032d40e00b3075df1650dbb5a743f
refs/heads/master
2023-08-18T15:21:40.161286
2023-08-11T07:22:57
2023-08-11T07:22:57
251,283,524
0
1
null
2022-12-10T06:04:11
2020-03-30T11:24:10
Java
UTF-8
Java
false
false
1,202
java
/** * Copyright 2009-2015 the original author or authors. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.ibatis.submitted.order_prefix_removed; import java.io.Serializable; public class Person implements Serializable { private Integer id; private String firstName; private String lastName; 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 Integer getId() { return id; } public void setId(Integer id) { this.id = id; } }
[ "zhihei.chh@alibaba-inc.com" ]
zhihei.chh@alibaba-inc.com
6a484188732bcf90376aa3adbdad5a7f06e2cc84
2cb0c340f22febb2cac00864babe408c456c7715
/Municipio/src/main/java/com/attozoic/main/repositories/RepositoryRebalancesCount.java
e4621ad08e490b1b2c1f22f111d58a201caaea9e
[]
no_license
kresovic-milos/municipio-server
586945a205e1f7c484f159cea9e327537bd7b01d
87db73f5d72a23ea6df22c517222f28708f082c9
refs/heads/master
2021-01-11T08:13:09.042552
2016-12-28T02:31:22
2016-12-28T02:31:22
69,808,401
0
0
null
null
null
null
UTF-8
Java
false
false
251
java
package com.attozoic.main.repositories; import org.springframework.stereotype.Repository; import com.attozoic.main.model.RebalancesCount; @Repository public interface RepositoryRebalancesCount extends RepositoryEntity<RebalancesCount> { }
[ "ivansrdic@gmail.com" ]
ivansrdic@gmail.com
d2a8244ecdd8e5f4e0af9c6a271fdc39ede1a0c1
ab303954ce9724c83ce7ef0df2920c1103c40364
/oa-organ/src/main/java/com/zhss/oa/App.java
09d31787721a5a8d840982bb09ef6b2204145d6a
[]
no_license
zhanglibin1117/oa-parent
def6b1ac4e1b59c9ce4f7df91f8078161c057942
e39d40618d09cf07737041f5fe4a92f80cd52d6b
refs/heads/master
2021-05-09T13:18:45.206619
2018-01-26T10:05:06
2018-01-26T10:05:06
119,030,766
0
0
null
null
null
null
UTF-8
Java
false
false
187
java
package com.zhss.oa; /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } }
[ "zhss@163.com" ]
zhss@163.com
fa62717bb085da47068a3aa93572daf2108702eb
c93a02daa3ea3d73624db883cad07d8a556d01ba
/src/Interfaces/OrdenCompraCRUD.java
8c3f372ef8e442e0fe328f4d879cbb22edc2ce2b
[]
no_license
Goby026/MrJuerga-Desktop
f7575e258fa66e50b2410becdb00dfed2444e753
9932f8c7f0b27de3007e38ea43438a9f5ed869a9
HEAD
2019-07-31T16:44:32.160174
2018-02-24T21:09:50
2018-02-24T21:09:50
75,757,246
0
0
null
null
null
null
UTF-8
Java
false
false
376
java
package Interfaces; import Modelo.OrdenCompra; import java.util.List; public interface OrdenCompraCRUD { public boolean registrar(OrdenCompra oc) throws Exception; public boolean modificar(OrdenCompra oc) throws Exception; public boolean anular(OrdenCompra oc) throws Exception; public List<OrdenCompra> listar() throws Exception; }
[ "ELMER_03@MRJUERGA_02" ]
ELMER_03@MRJUERGA_02
27046d00ab1b1fc5f0c03ccbb2eca1e545778339
57e0bb6df155a54545d9cee8f645a95f3db58fd2
/src/by/it/tsyhanova/at04/TaskA.java
4cf8b493e6fb2f0df314f9e38e19ecc86ada9c12
[]
no_license
VitaliShchur/AT2019-03-12
a73d3acd955bc08aac6ab609a7d40ad109edd4ef
3297882ea206173ed39bc496dec04431fa957d0d
refs/heads/master
2020-04-30T23:28:19.377985
2019-08-09T14:11:52
2019-08-09T14:11:52
177,144,769
0
0
null
2019-05-15T21:22:32
2019-03-22T13:26:43
Java
UTF-8
Java
false
false
1,847
java
package by.it.tsyhanova.at04; import java.util.Scanner; public class TaskA { // Таблица умножения от 2 до 9 включительно private static void printMulTable(){ for(int i=2;i<10;i++){ for(int j=2;j<10;j++){ System.out.printf("%1d*%1d=%-2d ",i,j,i*j); } System.out.println(); } } static void buildOneDimArray(String line){ //получение массива вещественных чисел из строки класса InOut double[] array=InOut.getArray(line); double start=array[0]; double stop=array[array.length-1]; //распечатка массива по 5 элементов в строке InOut.printArray(array,"V",5); //отсортировать массив Helper.sort(array); //вывести отсортированный массив в 4 колонки InOut.printArray(array,"V",4); //выполнить вычисление новых (после сортировки) индексов первого // и последнего элемента исходного массива и напечатать их for(int i=0;i<array.length;i++){ if(array[i]==start){ System.out.println("Index of first element="+i); break; } } for(int i=0;i<array.length;i++){ if(array[i]==stop){ System.out.println("Index of last element="+i); break; } } System.out.println(); } public static void main(String[] args){ printMulTable(); Scanner scan=new Scanner(System.in); String s=scan.nextLine(); buildOneDimArray(s); } }
[ "tatsianatsyhanova@yahoo.com" ]
tatsianatsyhanova@yahoo.com
063d57a357929082df4a73039c281d946fa15d32
58eac8afa926b5646ca0dce62a9392dd48d4cf32
/workspace_IncLing/Elevator/src/testset/ElevatorTest.java
6798dd28688a862a705cf4afb60991e6d188a5b9
[]
no_license
fischerJF/Community-wide-Dataset-of-Configurable-Systems
71f20635032bbfed959382e98e808e657c5f1ef4
eab5839ec7c6851934d255f3af3904b81a8dd13e
refs/heads/master
2023-07-04T23:04:56.061388
2021-08-17T18:32:53
2021-08-17T18:32:53
236,009,474
3
2
null
2021-08-17T18:33:29
2020-01-24T13:39:55
Java
UTF-8
Java
false
false
11,800
java
package testset; import static org.junit.Assert.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.api.support.membermodification.MemberModifier; import org.powermock.reflect.Whitebox; import static org.mockito.Matchers.anyObject; import elevatorsystem.Elevator; import elevatorsystem.Environment; import elevatorsystem.Person; import elevatorsystem.Elevator.Direction; import elevatorsystem.Elevator.DoorState; import specifications.Configuration; public class ElevatorTest { private Elevator e; private Environment env; private Person p1; private Person p2; private Person p3; private Person p4; @Before public void setUp(){ env = new Environment(5); e=new Elevator(env, 4, false); p1 = new Person("Maria", 60, 1, 2, env); p2= new Person("Paulo", 40, 1, 2, env); p3 = new Person("John", 80, 1, 3, env); p4 = new Person("Pedro", 90, 1, 4, env); } @Test public void testisBlocked() { Environment env = new Environment(5); e = new Elevator(env, 4, false); if (!Configuration.overloaded) { assertFalse(e.isBlocked()); } } @Test public void testEnterElevator() { Environment env = new Environment(5); e = new Elevator(env, 4, false); e.enterElevator(new Person("Paulo", 40, 1, 4, env)); assertTrue(e.floorButtons[4]); } @Test public void testEnterElevatorWeight() { if (Configuration.weight) { e.enterElevator(p1); e.enterElevator(p2); e.enterElevator(p3); e.enterElevator(p4); assertEquals(270, e.weight); } assertTrue(true); } @Test public void testLeaveElevator(){ e.enterElevator(p1); e.enterElevator(p2); e.enterElevator(p3); assertTrue(e.leaveElevator(p1)); assertTrue(e.leaveElevator(p2)); assertTrue(e.leaveElevator(p3)); assertFalse(e.leaveElevator(p4)); } @Test public void testLeaveElevatorForWeight(){ e.enterElevator(p1); e.enterElevator(p2); e.enterElevator(p3); e.enterElevator(p4); e.leaveElevator(p1); e.leaveElevator(p2); e.leaveElevator(p3); e.leaveElevator(p4); if(Configuration.weight){ assertEquals(0, e.weight); } assertTrue(true); } @Test public void testLeaveElevatorForEmpty(){ e.enterElevator(p1); e.enterElevator(p2); e.enterElevator(p3); e.enterElevator(p4); e.leaveElevator(p1); e.leaveElevator(p2); e.leaveElevator(p3); e.leaveElevator(p4); if(Configuration.empty){ for (boolean b : e.floorButtons) { if(b){ assertTrue(false); } } assertTrue(true); } assertTrue(true); } @Test public void isBlockedTest() throws IllegalArgumentException, IllegalAccessException { // Configuration.overloaded=true; if (Configuration.overloaded) { MemberModifier.field(Elevator.class, "blocked").set(e, true); assertTrue(e.isBlocked()); } // Configuration.overloaded=true; if (!Configuration.overloaded) { assertFalse(e.isBlocked()); } } @Test public void enterElevator() { // Configuration.weight=true; if (Configuration.weight) { e.enterElevator(p1); assertEquals(e.weight,60); } // Configuration.weight=false; if (!Configuration.weight) { e=new Elevator(env, 4, false); e.enterElevator(p1); assertEquals(e.weight,0); } } @Test public void leaveElevatorTest1() { e=new Elevator(env, 4, false); assertFalse(e.leaveElevator(p1)); } @Test public void leaveElevatorTest2() { e.enterElevator(p1); // Configuration.weight=false; // Configuration.empty=false; if (!Configuration.weight && !Configuration.empty) { assertTrue(e.leaveElevator(p1)); } } @Test public void leaveElevatorTest3() { // Configuration.weight=true; // Configuration.empty=false; if (Configuration.weight && !Configuration.empty) { e.enterElevator(p1); assertEquals(e.weight,60); assertTrue(e.leaveElevator(p1)); assertEquals(e.weight,0); } } @Test public void leaveElevatorTest4() { e.enterElevator(p1); // Configuration.weight=false; // Configuration.empty=true; if (!Configuration.weight && Configuration.empty) { assertTrue(e.leaveElevator(p1)); for (int i = 0; i < e.floorButtons.length; i++) { if(e.floorButtons[i]) assertTrue(false); } assertTrue(true); } } @Test public void getEnvTest() { assertEquals(e.getEnv(),env); } @Test public void isToString() { System.err.println(e.toString()); assertEquals(e.toString(),"Elevator [_] at 4 heading DOWN weight; 0"); } @Test public void isExecutiveFloor() { assertTrue(e.isExecutiveFloor(4)); assertFalse(e.isExecutiveFloor(3)); } @Test public void isExecutiveFloorCallingTest() { env = new Environment(1); e=new Elevator(env, 0, false); assertFalse(e.isExecutiveFloorCalling()); } @Test public void anyStopRequestedTest() throws Exception { boolean b= (boolean) Whitebox.invokeMethod(e, "anyStopRequested"); assertTrue(b); } @Test public void anyStopRequestedTest2() throws Exception { env = new Environment(0); e=new Elevator(env, 0, false); boolean b= (boolean) Whitebox.invokeMethod(e, "anyStopRequested"); assertFalse(b); } @Test public void isAnyLiftButtonPressed() throws Exception { env = new Environment(0); e=new Elevator(env, 0, false); boolean b= (boolean) Whitebox.invokeMethod(e, "isAnyLiftButtonPressed"); assertFalse(b); } @Test public void isAnyLiftButtonPressed1() throws Exception { env = new Environment(4); e=new Elevator(env, 4, false); e.pressInLiftFloorButton(3); boolean b= (boolean) Whitebox.invokeMethod(e, "isAnyLiftButtonPressed"); assertTrue(b); } @Test public void stopRequestedInDirection() throws Exception { MemberModifier.field(Elevator.class, "currentFloorID").set(e,1); e.pressInLiftFloorButton(1); boolean b= (boolean) Whitebox.invokeMethod(e, "stopRequestedInDirection",Direction.UP,false, false); assertFalse(b); } @Test public void isIdleTest() { e.pressInLiftFloorButton(1); assertFalse(e.isIdle()); } @Test public void timeShiftTest_BlockedTrue() throws IllegalArgumentException, IllegalAccessException { // Configuration.overloaded=true; if (Configuration.overloaded) { MemberModifier.field(Elevator.class, "doors").set(e, DoorState.OPEN); e.weight=200; e.timeShift(); boolean test=(boolean) MemberModifier.field(Elevator.class, "blocked").get(e); assertTrue(test); } } @Test public void timeShiftTest_BlockedFalse() throws IllegalArgumentException, IllegalAccessException { // Configuration.overloaded=true; if (Configuration.overloaded) { MemberModifier.field(Elevator.class, "doors").set(e, DoorState.OPEN); e.weight=10; e.timeShift(); boolean test=(boolean) MemberModifier.field(Elevator.class, "blocked").get(e); assertFalse(test); } } @Test public void timeShiftTest() throws Exception { // Configuration.overloaded=false; // Configuration.executivefloor=false; // Configuration.twothirdsfull=false; if (!Configuration.overloaded) { e.enterElevator(p1); e.enterElevator(p2); e.enterElevator(p3); e.enterElevator(p4); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 2); e.timeShift(); boolean test=(boolean) MemberModifier.field(Person.class, "destinationReached").get(p1); assertTrue(test); e.enterElevator(p2); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 2); e.timeShift(); test=(boolean) MemberModifier.field(Person.class, "destinationReached").get(p2); assertTrue(test); e.enterElevator(p3); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 3); e.timeShift(); test=(boolean) MemberModifier.field(Person.class, "destinationReached").get(p3); assertTrue(test); e.enterElevator(p4); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 4); e.timeShift(); test=(boolean) MemberModifier.field(Person.class, "destinationReached").get(p4); assertTrue(test); } } @Test public void TimeShiftTest() throws IllegalArgumentException, IllegalAccessException{ // Configuration.overloaded=false; // Configuration.executivefloor=true; // Configuration.twothirdsfull=false; if (!Configuration.overloaded && Configuration.executivefloor && !Configuration.overloaded ) { e.enterElevator(p1); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 1); MemberModifier.field(Elevator.class, "executiveFloor").set(e,2); env.getFloor(2).callElevator(); e.timeShift(); Object obj = (Object) MemberModifier.field(Elevator.class, "currentHeading").get(e); assertEquals(obj.toString(), "UP"); } } @Test public void TimeShiftTest_2() throws IllegalArgumentException, IllegalAccessException{ // Configuration.overloaded=false; // Configuration.executivefloor=false; // Configuration.twothirdsfull=true; if (!Configuration.overloaded && !Configuration.executivefloor && Configuration.twothirdsfull ) { e.enterElevator(p1); MemberModifier.field(Elevator.class, "currentFloorID").set(e, 1); MemberModifier.field(Elevator.class, "executiveFloor").set(e,2); // env.getFloor(2).callElevator(); e.weight=1000; e.floorButtons[2]=false; e.timeShift(); Object obj = (Object) MemberModifier.field(Elevator.class, "currentHeading").get(e); assertEquals(obj.toString(), "DOWN"); } } @Test public void anyStopRequestedTest_2() throws Exception { for (int x=0; x<e.floorButtons.length; x++) { e.floorButtons[x]=true; } boolean b= (boolean) Whitebox.invokeMethod(e, "anyStopRequested"); assertTrue(b); } @Test public void stopRequestedInDirection_2() throws Exception { // Configuration.executivefloor=false; // Configuration.twothirdsfull=true; if (!Configuration.executivefloor && Configuration.twothirdsfull) { e.weight=1000; Object obj=null; for (int x=0; x<e.floorButtons.length; x++) { e.floorButtons[x]=true; } boolean b= (boolean) Whitebox.invokeMethod(e, "stopRequestedInDirection",obj, true, true); assertTrue(b); } } @Test public void isBlockedTest2() { // Configuration.overloaded=false; if (!Configuration.overloaded) { assertFalse(e.isBlocked()); } } @Test public void currentHeadingTest() throws IllegalArgumentException, IllegalAccessException { System.err.println(e.getCurrentDirection()); e.getCurrentDirection().reverse(); Object obj = (Object) MemberModifier.field(Elevator.class, "currentHeading").get(e); assertEquals(obj.toString(),"DOWN"); Object test = e.getCurrentDirection(); MemberModifier.field(Elevator.class, "currentHeading").set(e, e.getCurrentDirection().reverse()); System.err.println(e.getCurrentDirection()); assertEquals(e.getCurrentDirection().reverse(),test); } @Test public void getCurrentFloorIDTest() throws IllegalArgumentException, IllegalAccessException { MemberModifier.field(Elevator.class, "currentFloorID").set(e,1); assertEquals(e.getCurrentFloorID(),1); } @Test public void areDoorsOpenTest() throws IllegalArgumentException, IllegalAccessException { MemberModifier.field(Elevator.class, "doors").set(e, DoorState.OPEN); assertTrue(e.areDoorsOpen()); MemberModifier.field(Elevator.class, "doors").set(e, DoorState.CLOSE); assertFalse(e.areDoorsOpen()); } }
[ "fischerbatera@hotmail.com" ]
fischerbatera@hotmail.com
d9bb9407484591af85caca491061cc320efada70
ae0b9a24839983b7b14d1b4821dcd76ea7758e09
/src/NaukaWDomu/Podstawa.java
9a1dfc49a27a24238df702dc8b80dfa4cd2c97bb
[]
no_license
wkempa1990/Brudnopis
d1bef2a04a46e24f24d2838697aaaa17fa11ba16
1ababeb78ab9bd8e63054ee70872e3b18fd45493
refs/heads/master
2020-12-14T12:04:47.913713
2020-01-18T13:56:15
2020-01-18T13:56:15
234,734,171
0
0
null
null
null
null
UTF-8
Java
false
false
1,769
java
package NaukaWDomu; public class Podstawa { public static void main(String[] args) { int a = 10; a += 5; a += 11; a *= 10; System.out.println(a); String txt = "abcdefghijklmno"; System.out.println(txt.length());//length liczy dlugosc ciagu "abcdefghijklmno" String txt2 = "Wojciech"; System.out.println(txt2.toUpperCase());// toUpperCase z duzej litery String imie = "wojciech"; String nazwisko = "kempinski"; String imieInazwisko = (imie + " " + nazwisko); System.out.println(imieInazwisko); String cudzyslow = "nazwa wlasna \"michal\" mozna zapisac tak"; System.out.println(cudzyslow); Math.max(1000, 2000); System.out.println(Math.max(1000, 2000)); Math.min(3, 22); System.out.println(Math.min(3, 22)); Math.sqrt(81);//sqrt pierwiastek z System.out.println(Math.sqrt(81)); int c = 10; int d = 19; System.out.println(c > d); int dzien = 4; switch (dzien) { // int dzien podaje wartosc ze switcha nr 4 case 1: System.out.println("poniedzialek"); break; case 2: System.out.println("wtorek"); break; case 3: System.out.println("sroda"); break; case 4: System.out.println("czwartek"); break; case 5: System.out.println("piatek"); break; case 6: System.out.println("sobota"); break; case 7: System.out.println("niedziela"); break; } } }
[ "wkempinski@outlook.com" ]
wkempinski@outlook.com
0218901d62c21f3d86d644f116c669ca023c85db
9e6be3c136847c31373ad324eb7cced2eecb0cc7
/bootcamp/Expedia.java
3f9379451357f354ac5ddee1c7fa76cbef38af93
[]
no_license
tashnuva/Selenium_bootcamp
b92ef25f58a3737b5337d8be7fb9e44a5cfbb7fa
5d3148e6082ceebf083701dc79aa26b3ef9e3c8f
refs/heads/master
2023-02-06T08:30:43.774256
2020-12-26T20:37:44
2020-12-26T20:37:44
324,626,772
0
0
null
null
null
null
UTF-8
Java
false
false
3,821
java
package bootcamp; import java.util.concurrent.TimeUnit; import org.omg.PortableInterceptor.USER_EXCEPTION; import org.openqa.selenium.By; import org.openqa.selenium.By.ByXPath; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class Expedia { static WebDriver driver; public static void main(String[] argh) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\tasnu\\eclipse-workspace\\Trainingsession\\Drivers\\chromedriver.exe"); driver = new ChromeDriver(); driver.get("https://www.expedia.com/"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//*[@id=\"uitk-tabs-button-container\"]/li[2]/a")).click(); driver.findElement(By.xpath("//*[@id=\"uitk-tabs-button-container\"]/div/li[1]/a/span")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // driver.findElement(By.xpath("//*[@id=\"wizard-flight-tab-roundtrip\"]/div/div[1]/div/div[1]/div/div/div/button")).click(); driver.findElement(By.xpath("//*[@id=\"location-field-leg1-origin-menu\"]/div[1]/button")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.findElement(By.xpath("//*[@id=\"location-field-leg1-origin\"]")).click(); driver.findElement(By.xpath("//*[@id=\"location-field-leg1-origin\"]")).sendKeys("iad"); driver.findElement( By.xpath("//*[@id=\"location-field-leg1-origin-menu\"]/div[2]/ul/li[1]/button/div/div[1]/span/strong")) .click(); driver.findElement(By.xpath("//*[@id=\"location-field-leg1-destination-menu\"]/div[1]/button")).click(); driver.findElement(By.xpath("//*[@id=\"location-field-leg1-destination\"]")).sendKeys("bangladesh"); driver.findElement(By.xpath( "//*[@id=\"location-field-leg1-destination-menu\"]/div[2]/ul/li[1]/button/div/div[1]/span/strong")) .click(); driver.findElement(By.xpath("//*[@id=\"d1-btn\"]")).click(); // driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); Thread.sleep(2000); driver.findElement(By.xpath("(//*[@data-day='27'])[1]")).click(); driver.findElement(By.xpath("(//*[@data-day='27'])[2]")).click(); driver.findElement(By.xpath("(//*[text()='Done'])[2]")).click(); driver.findElement(By.xpath("//button[contains(text(),'Search')]")).click(); Thread.sleep(2000); driver.findElement(By.xpath( "//body/div[@id='app']/div[@id='app-layer-manager']/div[@id='app-layer-base']/div[2]/div[2]/div[1]/section[1]/main[1]/ol[1]/li[1]/div[1]/div[1]/div[1]/button[1]")) .click(); driver.findElement(By.xpath("//button[contains(text(),'Continue')]")).click(); Thread.sleep(2000); driver.findElement(By.xpath( "//body/div[@id='app']/div[@id='app-layer-manager']/div[@id='app-layer-base']/div[2]/div[2]/div[1]/section[1]/main[1]/ol[1]/li[1]/div[1]/div[1]/div[1]/button[1]")) .click(); driver.findElement(By.xpath("//button[contains(text(),'Continue')]")).click(); // Store the current window handle @SuppressWarnings("unused") String winHandleBefore = driver.getWindowHandle(); // Switch to new window opened for (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); } driver.findElement( By.xpath("//*[@id=\"app-layer-base\"]/div/div/div[2]/div/main/section[2]/div[1]/div/div[2]/button")) .click(); Thread.sleep(2000); driver.findElement(By.id("firstname[0]")).sendKeys("tashnuva"); driver.findElement(By.id("lastname[0]")).sendKeys("zaman"); driver.findElement(By.id("phone-number[0]")).sendKeys("123456789"); driver.findElement(By.xpath("//*[@id=\"preferences\"]/form/fieldset/fieldset/div/fieldset[2]/label[2]/span")) .click(); } }
[ "tasnuvactg@yahoo.com" ]
tasnuvactg@yahoo.com
3a509d12625b51e27746577b1ed2d125543272b7
dea04aa4c94afd38796e395b3707d7e98b05b609
/Participant results/P17/Interaction-3/ArrayIntList_ES_0_AlreadyValued_Test.java
9fe23c663b6c4d15358752e0e4198718bd38e544
[]
no_license
PdedP/InterEvo-TR
aaa44ef0a4606061ba4263239bafdf0134bb11a1
77878f3e74ee5de510e37f211e907547674ee602
refs/heads/master
2023-04-11T11:51:37.222629
2023-01-09T17:37:02
2023-01-09T17:37:02
486,658,497
0
0
null
null
null
null
UTF-8
Java
false
false
980
java
/* * This file was automatically generated by EvoSuite * Tue Jan 25 10:35:38 GMT 2022 */ package com.org.apache.commons.collections.primitives; import org.junit.Test; import static org.junit.Assert.*; import com.org.apache.commons.collections.primitives.ArrayIntList; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) public class ArrayIntList_ES_0_AlreadyValued_Test extends ArrayIntList_ES_0_AlreadyValued_Test_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { ArrayIntList arrayIntList0 = new ArrayIntList(); arrayIntList0.add(0, 0); arrayIntList0.add(0); assertEquals(2, arrayIntList0.size()); arrayIntList0.clear(); assertEquals(0, arrayIntList0.size()); } }
[ "pedro@uca.es" ]
pedro@uca.es
378487960e62a2b7fc82f030d090bd0d18adbb50
276df0eab5504f7e0253153175ff8cab0a2705ae
/Engine/org/apache/mahout/matrix/AbstractMatrix.java
4c346006c188000f55c8edda11338426bd04aff3
[]
no_license
ankitgoswami/SuggestionEngine
0b9b56d276e515d1e6ede0f2c5e83ebb8ed30011
9279f47f0aa2df81f21d9150375df2c8418204e7
refs/heads/master
2016-09-05T23:26:16.245404
2012-03-01T10:22:53
2012-03-01T10:22:53
3,546,476
2
2
null
null
null
null
UTF-8
Java
false
false
13,890
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.mahout.matrix; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; /** A few universal implementations of convenience functions */ public abstract class AbstractMatrix implements Matrix { private Map<String, Integer> columnLabelBindings; private Map<String, Integer> rowLabelBindings; @Override public double get(String rowLabel, String columnLabel) throws IndexException, UnboundLabelException { if (columnLabelBindings == null || rowLabelBindings == null) { throw new UnboundLabelException(); } Integer row = rowLabelBindings.get(rowLabel); Integer col = columnLabelBindings.get(columnLabel); if (row == null || col == null) { throw new UnboundLabelException(); } return get(row, col); } @Override public Map<String, Integer> getColumnLabelBindings() { return columnLabelBindings; } @Override public Map<String, Integer> getRowLabelBindings() { return rowLabelBindings; } @Override public void set(String rowLabel, double[] rowData) { if (columnLabelBindings == null) { throw new UnboundLabelException(); } Integer row = rowLabelBindings.get(rowLabel); if (row == null) { throw new UnboundLabelException(); } set(row, rowData); } @Override public void set(String rowLabel, int row, double[] rowData) { if (rowLabelBindings == null) { rowLabelBindings = new HashMap<String, Integer>(); } rowLabelBindings.put(rowLabel, row); set(row, rowData); } @Override public void set(String rowLabel, String columnLabel, double value) throws IndexException, UnboundLabelException { if (columnLabelBindings == null || rowLabelBindings == null) { throw new UnboundLabelException(); } Integer row = rowLabelBindings.get(rowLabel); Integer col = columnLabelBindings.get(columnLabel); if (row == null || col == null) { throw new UnboundLabelException(); } set(row, col, value); } @Override public void set(String rowLabel, String columnLabel, int row, int column, double value) throws IndexException, UnboundLabelException { if (rowLabelBindings == null) { rowLabelBindings = new HashMap<String, Integer>(); } rowLabelBindings.put(rowLabel, row); if (columnLabelBindings == null) { columnLabelBindings = new HashMap<String, Integer>(); } columnLabelBindings.put(columnLabel, column); set(row, column, value); } @Override public void setColumnLabelBindings(Map<String, Integer> bindings) { columnLabelBindings = bindings; } @Override public void setRowLabelBindings(Map<String, Integer> bindings) { rowLabelBindings = bindings; } // index into int[2] for column value public static final int COL = 1; // index into int[2] for row value public static final int ROW = 0; public static Matrix decodeMatrix(String formatString) { Type vectorType = new TypeToken<Vector>() { }.getType(); Type matrixType = new TypeToken<Matrix>() { }.getType(); GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(vectorType, new JsonVectorAdapter()); builder.registerTypeAdapter(matrixType, new JsonMatrixAdapter()); Gson gson = builder.create(); return gson.fromJson(formatString, matrixType); } @Override public String asFormatString() { Type vectorType = new TypeToken<Vector>() { }.getType(); Type matrixType = new TypeToken<Matrix>() { }.getType(); GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(vectorType, new JsonVectorAdapter()); builder.registerTypeAdapter(matrixType, new JsonMatrixAdapter()); Gson gson = builder.create(); return gson.toJson(this, matrixType); } @Override public Matrix assign(double value) { int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { setQuick(row, col, value); } } return this; } @Override public Matrix assign(double[][] values) { int[] c = size(); if (c[ROW] != values.length) { throw new CardinalityException(); } for (int row = 0; row < c[ROW]; row++) { if (c[COL] != values[row].length) { throw new CardinalityException(); } else { for (int col = 0; col < c[COL]; col++) { setQuick(row, col, values[row][col]); } } } return this; } @Override public Matrix assign(Matrix other, BinaryFunction function) { int[] c = size(); int[] o = other.size(); if (c[ROW] != o[ROW] || c[COL] != o[COL]) { throw new CardinalityException(); } for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { setQuick(row, col, function.apply(getQuick(row, col), other.getQuick( row, col))); } } return this; } @Override public Matrix assign(Matrix other) { int[] c = size(); int[] o = other.size(); if (c[ROW] != o[ROW] || c[COL] != o[COL]) { throw new CardinalityException(); } for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { setQuick(row, col, other.getQuick(row, col)); } } return this; } @Override public Matrix assign(UnaryFunction function) { int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { setQuick(row, col, function.apply(getQuick(row, col))); } } return this; } @Override public double determinant() { int[] card = size(); int rowSize = card[ROW]; int columnSize = card[COL]; if (rowSize != columnSize) { throw new CardinalityException(); } if (rowSize == 2) { return getQuick(0, 0) * getQuick(1, 1) - getQuick(0, 1) * getQuick(1, 0); } else { int sign = 1; double ret = 0; for (int i = 0; i < columnSize; i++) { Matrix minor = new DenseMatrix(rowSize - 1, columnSize - 1); for (int j = 1; j < rowSize; j++) { boolean flag = false; /* column offset flag */ for (int k = 0; k < columnSize; k++) { if (k == i) { flag = true; continue; } minor.set(j - 1, flag ? k - 1 : k, getQuick(j, k)); } } ret += getQuick(0, i) * sign * minor.determinant(); sign *= -1; } return ret; } } @Override public Matrix clone() { AbstractMatrix clone; try { clone = (AbstractMatrix) super.clone(); } catch (CloneNotSupportedException cnse) { throw new IllegalStateException(cnse); // can't happen } if (rowLabelBindings != null) { clone.rowLabelBindings = (Map<String, Integer>) ((HashMap<String, Integer>) rowLabelBindings).clone(); } if (columnLabelBindings != null) { clone.columnLabelBindings = (Map<String, Integer>) ((HashMap<String, Integer>) columnLabelBindings).clone(); } return clone; } @Override public Matrix divide(double x) { Matrix result = clone(); int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result.setQuick(row, col, result.getQuick(row, col) / x); } } return result; } @Override public double get(int row, int column) { int[] c = size(); if (row < 0 || column < 0 || row >= c[ROW] || column >= c[COL]) { throw new IndexException(); } return getQuick(row, column); } @Override public Matrix minus(Matrix other) { int[] c = size(); int[] o = other.size(); if (c[ROW] != o[ROW] || c[COL] != o[COL]) { throw new CardinalityException(); } Matrix result = clone(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result.setQuick(row, col, result.getQuick(row, col) - other.getQuick(row, col)); } } return result; } @Override public Matrix plus(double x) { Matrix result = clone(); int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result.setQuick(row, col, result.getQuick(row, col) + x); } } return result; } @Override public Matrix plus(Matrix other) { int[] c = size(); int[] o = other.size(); if (c[ROW] != o[ROW] || c[COL] != o[COL]) { throw new CardinalityException(); } Matrix result = clone(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result.setQuick(row, col, result.getQuick(row, col) + other.getQuick(row, col)); } } return result; } @Override public void set(int row, int column, double value) { int[] c = size(); if (row < 0 || column < 0 || row >= c[ROW] || column >= c[COL]) { throw new IndexException(); } setQuick(row, column, value); } @Override public void set(int row, double[] data) { int[] c = size(); if (c[COL] < data.length) { throw new CardinalityException(); } if ((c[ROW] < row) || (row < 0)) { throw new IndexException(); } for (int i = 0; i < c[COL]; i++) { setQuick(row, i, data[i]); } } @Override public Matrix times(double x) { Matrix result = clone(); int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result.setQuick(row, col, result.getQuick(row, col) * x); } } return result; } @Override public Matrix times(Matrix other) { int[] c = size(); int[] o = other.size(); if (c[COL] != o[ROW]) { throw new CardinalityException(); } Matrix result = like(c[ROW], o[COL]); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < o[COL]; col++) { double sum = 0; for (int k = 0; k < c[COL]; k++) { sum += getQuick(row, k) * other.getQuick(k, col); } result.setQuick(row, col, sum); } } return result; } @Override public Matrix transpose() { int[] card = size(); Matrix result = like(card[COL], card[ROW]); for (int row = 0; row < card[ROW]; row++) { for (int col = 0; col < card[COL]; col++) { result.setQuick(col, row, getQuick(row, col)); } } return result; } @Override public double zSum() { double result = 0; int[] c = size(); for (int row = 0; row < c[ROW]; row++) { for (int col = 0; col < c[COL]; col++) { result += getQuick(row, col); } } return result; } @Override public void readFields(DataInput in) throws IOException { // read the label bindings int colSize = in.readInt(); if (colSize > 0) { columnLabelBindings = new HashMap<String, Integer>(); for (int i = 0; i < colSize; i++) { columnLabelBindings.put(in.readUTF(), in.readInt()); } } int rowSize = in.readInt(); if (rowSize > 0) { rowLabelBindings = new HashMap<String, Integer>(); for (int i = 0; i < rowSize; i++) { rowLabelBindings.put(in.readUTF(), in.readInt()); } } } @Override public void write(DataOutput out) throws IOException { // write the label bindings if (columnLabelBindings == null) { out.writeInt(0); } else { out.writeInt(columnLabelBindings.size()); for (Map.Entry<String, Integer> stringIntegerEntry : columnLabelBindings.entrySet()) { out.writeUTF(stringIntegerEntry.getKey()); out.writeInt(stringIntegerEntry.getValue()); } } if (rowLabelBindings == null) { out.writeInt(0); } else { out.writeInt(rowLabelBindings.size()); for (Map.Entry<String, Integer> stringIntegerEntry : rowLabelBindings.entrySet()) { out.writeUTF(stringIntegerEntry.getKey()); out.writeInt(stringIntegerEntry.getValue()); } } } /** Reads a typed Matrix instance from the input stream */ public static Matrix readMatrix(DataInput in) throws IOException { String matrixClassName = in.readUTF(); Matrix matrix; try { matrix = Class.forName(matrixClassName).asSubclass(Matrix.class) .newInstance(); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } matrix.readFields(in); return matrix; } /** Writes a typed Matrix instance to the output stream */ public static void writeMatrix(DataOutput out, Matrix matrix) throws IOException { out.writeUTF(matrix.getClass().getName()); matrix.write(out); } }
[ "sharadjain.sj@gmail.com" ]
sharadjain.sj@gmail.com
e9dbc45359da94835ac1c02ea337ed00aeecfd6f
a33867248397df65b70bad738d91e095397f7d0f
/src/study/pattern/prototype/PrototypeDeepTest.java
c8dc55b48bfcb7f575bc828284b93f4e9e3840ec
[]
no_license
wangjjjjjjjjj/gupao
a2b8bc2ef7da3b252789632da8ef761efcbfbbe6
84d7cdd27d4042ed6f4751cf16b31f67df045149
refs/heads/master
2020-04-28T00:08:53.218263
2019-03-17T06:18:10
2019-03-17T06:18:10
174,805,271
0
0
null
null
null
null
UTF-8
Java
false
false
569
java
package study.pattern.prototype; import java.util.ArrayList; import java.util.List; public class PrototypeDeepTest { public static void main(String[] args) { PrototypeDeep a = new PrototypeDeep(); a.setA("1"); a.setB("2"); List list = new ArrayList(); list.add("3"); list.add("4"); a.setC(list); PrototypeDeep b = (PrototypeDeep) a.clone(); System.out.println(a.getC() == b.getC()); list.add("5"); System.out.println(a.getC()); System.out.println(b.getC()); } }
[ "390748307@qq.com" ]
390748307@qq.com
5bbe47d998e361b7df04447da4982678d31d0bd6
07b9014f1d74d4ba1e447fb80cb380c5fce529ed
/src/main/java/by/levkovets/usermanagement/domain/UserAccount.java
535a4c253853f61d2a38a9f52296cd0585c55efd
[]
no_license
SergeiLevkovets/user-management
6bef991782aea41753456522b656009a89d9aff5
02f5f5b7756ada8c8716de016dc44fc2ad3e7e61
refs/heads/master
2021-01-06T22:22:36.793369
2020-02-21T08:33:44
2020-02-21T08:33:44
241,499,479
0
0
null
null
null
null
UTF-8
Java
false
false
1,833
java
package by.levkovets.usermanagement.domain; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; import javax.validation.constraints.NotBlank; import java.util.Date; /** * Simple javaBean domain object that represent UserAccount * */ @Entity @Data @AllArgsConstructor @NoArgsConstructor @Table(name = "userAccount") public class UserAccount { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; // @Pattern(regexp = "^[a-zA-Z]+$", message = "Username must contain only latin characters") // @Size(min = 3, max = 16, message = "Username must be 3-16 characters long") // @NotBlank(message = "UserName cannot be empty") @Column(unique = true) private String userName; // @Pattern(regexp = "(?=\\w*(?!\\d)\\w)(?=\\w*\\d)\\w+", message = "Password must have at least one character and at least one number") // @Size(min = 3, max = 16, message = "Password must be 3-16 characters long") @NotBlank(message = "Password cannot be empty") private String password; // @Pattern(regexp = "^[a-zA-Z]+$", message = "firstName must contain only latin characters") // @Size(min = 1, max = 16, message = "firstName must be 3-16 characters long") // @NotBlank(message = "firstName confirmation cannot be empty") private String firstName; // @Pattern(regexp = "^[a-zA-Z]+$", message = "lastName must contain only latin characters") // @Size(min = 1, max = 16, message = "lastName must be 3-16 characters long") // @NotBlank(message = "lastName confirmation cannot be empty") private String lastName; @Enumerated(EnumType.STRING) private Role role; private boolean active; @Column(insertable = false) @Temporal(TemporalType.TIMESTAMP) private Date CreatedAt; }
[ "sergeilevkovets@gmail.com" ]
sergeilevkovets@gmail.com
9ee33fb81ffeb297f026f16d8c3e767b45f63f13
5252a00843c6082d739d7a00142525fff0a2f3e7
/zoeeasy-cloud-platform/zoeeasy-cloud-modules/zoeeasy-cloud-order/zoeeasy-cloud-order-server/src/main/java/com/zoeeasy/cloud/order/service/impl/MessageSendOrderServiceImpl.java
e5d3212a10ced39e0c14a46f739c984d52ae0319
[]
no_license
P79N6A/parking
be8dc0ae6394096ec49faa89521d723425a5c965
6e3ea14312edc7487f725f2df315de989eaabb10
refs/heads/master
2020-05-07T22:07:03.790311
2019-04-12T03:06:26
2019-04-12T03:06:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,187
java
package com.zoeeasy.cloud.order.service.impl; import com.scapegoat.infrastructure.common.utils.StringUtils; import com.scapegoat.infrastructure.core.dto.result.ResultDto; import com.scapegoat.infrastructure.message.RocketMessage; import com.zoeeasy.cloud.core.cst.MessageQueueDefinitions; import com.zoeeasy.cloud.message.MessageSendService; import com.zoeeasy.cloud.message.payload.OrderConfirmCallbackPayload; import com.zoeeasy.cloud.order.message.MessageSendOrderService; import com.zoeeasy.cloud.order.message.dot.request.OrderConfirmCallbackRequestDto; import lombok.extern.log4j.Log4j; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * @author AkeemSuper * @date 2018/12/23 0023 */ @Service("messageSendOrderService") @Log4j public class MessageSendOrderServiceImpl implements MessageSendOrderService { @Autowired private ModelMapper modelMapper; @Autowired private MessageSendService messageSendService; /** * 发送三方账单支付回调消息 * * @param requestDto */ @Override public ResultDto sendOrderConfirmCallbackMessage(OrderConfirmCallbackRequestDto requestDto) { ResultDto resultDto = new ResultDto(); try { if (requestDto != null) { RocketMessage<OrderConfirmCallbackPayload> message = new RocketMessage<>(); message.setDestination(MessageQueueDefinitions.Topic.ORDER_CALL_BACK); message.setSender(MessageQueueDefinitions.Sender.ORDER); message.setMessageId(StringUtils.getUUID()); OrderConfirmCallbackPayload payLoad = modelMapper.map(resultDto, OrderConfirmCallbackPayload.class); message.setPayload(payLoad); messageSendService.sendAndSaveSync(message); resultDto.success(); return resultDto; } resultDto.failed(); } catch (Exception e) { log.error("发送三方账单支付回调消息失败" + e.getMessage()); resultDto.failed(); } return resultDto; } }
[ "xuqinghuo@126.com" ]
xuqinghuo@126.com
6f9afa2c202f179d1d4dfafe74ed71a08d395eb2
ecb449c5c6c40d31911c452d3b351f18a7c436de
/www.csie.ntu.edu.tw/~sylee/courses/dataStructures/code/misc/UsingAVector.java
701b8a71a346d7b9a628fddeac4b4477171c421f
[]
no_license
2892931976/Algorithms-in-Go
166319cd97dc6521a06076f456d6eb14281868db
cbdb38d86282a42f9e0eb43e15f9362584524ffd
refs/heads/master
2023-01-20T18:06:28.345390
2020-05-03T07:55:49
2020-05-03T07:55:49
203,523,554
1
1
null
2022-12-30T01:26:35
2019-08-21T06:44:23
Java
UTF-8
Java
false
false
1,232
java
/** using a Vector */ package misc; import java.util.*; import wrappers.*; public class UsingAVector { public static void main(String [] args) { // define a vector with initial capacity 1 Vector v = new Vector(1); System.out.println("The initial capacity is " + v.capacity()); System.out.println("The initial size is " + v.size()); // add some elements v.addElement(new MyInteger(1)); v.addElement(new MyInteger(2)); v.insertElementAt(new MyInteger(3), 2); v.insertElementAt(new MyInteger(4), 3); v.insertElementAt(new MyInteger(5), 4); System.out.println("The new capacity is " + v.capacity()); System.out.println("The new size is " + v.size()); System.out.println("The vector is " + v); // check out the iterator Enumeration e = v.elements(); while (e.hasMoreElements()) System.out.print(e.nextElement() + " "); System.out.println(); // make a clone Vector w = (Vector) v.clone(); // empty v v.removeAllElements(); // output w System.out.println("The vector is " + w); } }
[ "2892931976@qq.com" ]
2892931976@qq.com
a2ec61f9eceeefd6f843eb039d9e658e17819ccb
4a39ab5ab4bf0914dbeb9f41e49852ff781968c6
/org.entirej.ide.cf.rwt/src/org/entirej/ide/cf/rwt/RWTTabrisClientFrameworkProvider.java
769ea0728726deef4e530d05490abf4fa30f4e76
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
entirej/plugin
2bb1ede5d7c167e2637d391c44bec4ca9feb6d26
c65d49e4d38ef140ae54bed0b76e6e010e1e2d47
refs/heads/develop
2022-12-12T13:41:18.195896
2022-12-06T07:51:11
2022-12-06T07:51:11
14,260,908
1
1
null
2022-12-06T07:51:12
2013-11-09T16:54:57
Java
UTF-8
Java
false
false
9,207
java
/******************************************************************************* * Copyright 2013 CRESOFT AG * * 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. * * Contributors: * CRESOFT AG - initial API and implementation ******************************************************************************/ package org.entirej.ide.cf.rwt; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IAccessRule; import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.entirej.ide.cf.rwt.lib.tabris.RWTCFRuntimeClasspathContainer; import org.entirej.ide.cf.rwt.lib.tabris.RWTCoreRuntimeClasspathContainer; import org.entirej.ide.core.EJCoreLog; import org.entirej.ide.core.cf.CFProjectHelper; import org.entirej.ide.core.cf.EmptyClientFrameworkProvider; import org.entirej.ide.core.spi.ClientFrameworkProvider; public class RWTTabrisClientFrameworkProvider implements ClientFrameworkProvider { private static final String RWT_PROJECT_PROPERTIES_FILE = "/templates/rwt/application_tabris.ejprop"; private static final String RWT_PROJECT_RENDERER_FILE = "/templates/rwt/renderers_tabris.ejprop"; private static final String RWT_APP_LAUNCHER = "/templates/rwt/Configuration.java"; private static final String RWT_WEB_DD = "/templates/rwt/web.tabris.xml"; private static final String RWT_WEB_INDEX = "/templates/rwt/index.html"; public void addEntireJNature(IConfigurationElement configElement, IJavaProject project, IProgressMonitor monitor) { try { CFProjectHelper.verifySourceContainer(project, "src"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), RWT_PROJECT_PROPERTIES_FILE, "src/application.ejprop"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), RWT_PROJECT_RENDERER_FILE, "src/renderers.ejprop"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), RWT_APP_LAUNCHER, "src/org/entirej/ApplicationLauncher.java"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), RWT_WEB_DD, "WebContent/WEB-INF/web.xml"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), RWT_WEB_INDEX, "WebContent/index.html"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), getComponentSource(project), ".settings/org.eclipse.wst.common.component"); CFProjectHelper.addFile(project, EJCFRwtPlugin.getDefault().getBundle(), getFactesSource(project), ".settings/org.eclipse.wst.common.project.facet.core.xml"); IClasspathAttribute[] attributes = getClasspathAttributes(); CFProjectHelper.addEntireJBaseLibraries(project, attributes); CFProjectHelper.addToClasspath(project, JavaCore.newContainerEntry(RWTCFRuntimeClasspathContainer.ID, new IAccessRule[0], attributes, true)); CFProjectHelper.addToClasspath(project, JavaCore.newContainerEntry(RWTCoreRuntimeClasspathContainer.ID, new IAccessRule[0], attributes, true)); CFProjectHelper.addToClasspath(project, JavaCore.newContainerEntry(new Path("org.eclipse.jst.j2ee.internal.web.container"))); CFProjectHelper.addToClasspath(project, JavaCore.newContainerEntry(new Path("org.eclipse.jst.j2ee.internal.module.container"))); addWebNeatures(project); EmptyClientFrameworkProvider.addGeneratorFiles(project, monitor); CFProjectHelper.refreshProject(project, monitor); final IFile file = project.getProject().getFile("src/application.ejprop"); Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, file, true); } catch (PartInitException e) { EJCoreLog.logException(e); } } }); } catch (Exception e) { EJCoreLog.logException(e); } } private byte[] getComponentSource(IJavaProject project) { StringBuilder builder = new StringBuilder(); builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><project-modules id=\"moduleCoreId\" project-version=\"1.5.0\">"); String name = project.getProject().getName(); builder.append(String.format("<wb-module deploy-name=\"%s\">", name)); builder.append("<wb-resource deploy-path=\"/\" source-path=\"/WebContent\" tag=\"defaultRootSource\"/>"); builder.append("<wb-resource deploy-path=\"/WEB-INF/classes\" source-path=\"/src\"/>"); builder.append(String.format(" <property name=\"context-root\" value=\"%s\"/>", name)); builder.append(String.format("<property name=\"java-output-path\" value=\"/%s/bin\"/>", name)); builder.append("</wb-module>"); builder.append("</project-modules>"); return builder.toString().getBytes(); } private byte[] getFactesSource(IJavaProject project) { String option = project.getOption("org.eclipse.jdt.core.compiler.source", true); if (option == null) { option = "1.6";// default } StringBuilder builder = new StringBuilder(); builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.append("<faceted-project>"); builder.append("<fixed facet=\"wst.jsdt.web\"/>"); builder.append(String.format("<installed facet=\"java\" version=\"%s\"/>", option)); builder.append("<installed facet=\"jst.web\" version=\"3.0\"/>"); builder.append("<installed facet=\"wst.jsdt.web\" version=\"1.0\"/>"); builder.append("</faceted-project>"); return builder.toString().getBytes(); } private void addWebNeatures(IJavaProject project) { try { /* * <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> * <nature>org * .eclipse.wst.common.modulecore.ModuleCoreNature</nature> * <nature>org.eclipse.wst.common.project.facet.core.nature</nature> * <nature>org.eclipse.wst.jsdt.core.jsNature</nature> */ IProjectDescription description = project.getProject().getDescription(); String[] natures = description.getNatureIds(); List<String> newNatures = new ArrayList<String>(Arrays.asList(natures)); newNatures.add("org.eclipse.jem.workbench.JavaEMFNature"); newNatures.add("org.eclipse.wst.common.modulecore.ModuleCoreNature"); newNatures.add("org.eclipse.wst.common.project.facet.core.nature"); newNatures.add("org.eclipse.wst.jsdt.core.jsNature"); description.setNatureIds(newNatures.toArray(new String[0])); project.getProject().setDescription(description, null); } catch (CoreException e) { e.printStackTrace(); } } public String getProviderName() { return "Mobile Application Framework (Tabris)"; } public String getProviderId() { return "org.entirej.framework.cf.rwt_tabris"; } public String getDescription() { return "Creates a project adding the Mobile Application Framework (EclipseSource Tabris) and renderers.\nThe application.ejprop file will be pre-configured with references to the Tabris Renderers"; } public IClasspathAttribute[] getClasspathAttributes() { return new IClasspathAttribute[] { new IClasspathAttribute() { public String getValue() { return "/WEB-INF/lib"; } public String getName() { return "org.eclipse.jst.component.dependency"; } } }; } }
[ "theanuradha@gmail.com" ]
theanuradha@gmail.com
cc57d5eaa9c61daa6f93bd7dc40086299cb61adc
be9979211eb748c8301a4c0a75359d4bd2633cfe
/src/per/hss/dao/UserDao.java
4c84890ca0545c3402515b782896250f08f75582
[]
no_license
Hss533/StudentManage
d64c21b1db94d649499f5960e0b5e67f380f14e6
8c51ded1a7ea42bca342962ab1691b0c57a2f383
refs/heads/master
2020-03-11T08:13:23.475750
2018-04-17T09:15:48
2018-04-17T09:15:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,185
java
package per.hss.dao; import per.hss.model.User; import per.hss.util.DbUtil; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.*; public class UserDao { public User login(Connection con, User user) { User resultUser=null; String sql="select * from user where username=? and password=?"; PreparedStatement ptmt=null; try { ptmt=con.prepareStatement(sql); ptmt.setString(1, user.getUserName()); ptmt.setString(2, user.getPassWord()); ResultSet res = ptmt.executeQuery(); if (res.next()) { resultUser = new User(); resultUser.setUserName(res.getString("username")); resultUser.setPassWord(res.getString("password")); } }catch(Exception e) { e.printStackTrace(); } return resultUser; } public static void main(String[] args) { DbUtil dbutil=new DbUtil(); Connection con=dbutil.getConnection(); UserDao userdao=new UserDao(); User user=new User("hss","533533"); } }
[ "1097260937@qq.com" ]
1097260937@qq.com
d7d348b15ba46e1eb33dd5df9e96cfd06a852408
ff0d01db50bf6171fd3dbdcf59d60a519b9c8a0f
/src/main/java/fr/treeptik/centreformation/dao/StagiaireDAO.java
1518f5754250ded83bbb85b251016760debb7784
[]
no_license
ericterrade/CentreFormation
445b7117379479ebef563ac917d3f60f6a78b8a9
56da32c0669372ee72052a50c948272c7412cac9
refs/heads/master
2016-08-11T07:21:14.212043
2015-05-25T16:25:03
2015-05-25T16:25:03
36,240,623
0
0
null
null
null
null
UTF-8
Java
false
false
343
java
package fr.treeptik.centreformation.dao; import java.util.List; import fr.treeptik.centreformation.model.Stagiaire; import fr.treeptik.centreformation.model.StagiaireDTO; import fr.treeptik.centreformation.dao.GenericDAO; public interface StagiaireDAO extends GenericDAO<Stagiaire, Integer>{ List<StagiaireDTO> findAllStagiaireDTO(); }
[ "eric.terrade@gmail.com" ]
eric.terrade@gmail.com
594bcb57332146800410ad9068bffadb416e5e04
91901d20dd99ecbac775a06a355f1d2d1450a407
/core/discoRT/java/edu/wpi/disco/rt/realizer/PrimitiveRealizer.java
6d0cdb900feb2d7f51a3b209240be6eb768f8d9d
[]
no_license
always-on/always
f9571441b8ad4b18c024393a94ce4781ffc25174
75f7a826feeece1d8fa8658326f00e88208fc832
refs/heads/develop
2021-01-01T15:51:04.229895
2015-12-12T17:44:44
2015-12-12T17:44:44
6,750,595
5
0
null
2015-07-02T00:42:25
2012-11-18T19:55:28
C++
UTF-8
Java
false
false
772
java
package edu.wpi.disco.rt.realizer; import edu.wpi.disco.rt.behavior.PrimitiveBehavior; /** * A PrimitiveRealizer's run() method will be called periodically for it to do * something (if needed). Do not hold the thread. A PrimitiveRealizer should not * require preconditions on the state of the Resource, i.e., it should be able * to do its work from any preexisting condition. Any run of run() may be the * last run! You cannot count on it being called again in any way. * * @author Bahador * @param <T> */ public interface PrimitiveRealizer<T extends PrimitiveBehavior> extends Runnable { T getParams (); void shutdown (); void addObserver (PrimitiveRealizerObserver observer); void removeObserver (PrimitiveRealizerObserver observer); }
[ "rich@wpi.edu" ]
rich@wpi.edu
30fe90444cf4076aaff2322ae5700e509927e1d7
1002c14520663a52912a52ce46f8fbd2054221a0
/src/main/java/com/example/employment/repository/EmployeeRepository.java
3b50bd4424afca4e6fd657201daba50b669f07f0
[]
no_license
ChineduVickreg/Employee_management_app
0de2806320f0e94eeac2863f2b9ee6ad30ec2535
b5e00f4064c88473a7e0e476a4489d52fec6f753
refs/heads/master
2023-01-24T07:47:49.258656
2020-12-07T22:40:39
2020-12-07T22:40:39
318,624,655
0
0
null
null
null
null
UTF-8
Java
false
false
294
java
package com.example.employment.repository; import com.example.employment.model.Employee; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface EmployeeRepository extends JpaRepository<Employee, Long> { }
[ "nwachukwuvictorc@gmil.com" ]
nwachukwuvictorc@gmil.com
f91ab786f17e0ebe6007acdb4a77f34bfcf2a061
5e34c548f8bbf67f0eb1325b6c41d0f96dd02003
/dataset/smallest_dedc2a7c_000/mutations/106/smallest_dedc2a7c_000.java
a4a56c92a9fb163524b67a9d3d2b881fbe37fe1e
[]
no_license
mou23/ComFix
380cd09d9d7e8ec9b15fd826709bfd0e78f02abc
ba9de0b6d5ea816eae070a9549912798031b137f
refs/heads/master
2021-07-09T15:13:06.224031
2020-03-10T18:22:56
2020-03-10T18:22:56
196,382,660
1
1
null
2020-10-13T20:15:55
2019-07-11T11:37:17
Java
UTF-8
Java
false
false
2,269
java
package introclassJava; class IntObj { public int value; public IntObj () { } public IntObj (int i) { value = i; } } class FloatObj { public float value; public FloatObj () { } public FloatObj (float i) { value = i; } } class LongObj { public long value; public LongObj () { } public LongObj (long i) { value = i; } } class DoubleObj { public double value; public DoubleObj () { } public DoubleObj (double i) { value = i; } } class CharObj { public char value; public CharObj () { } public CharObj (char i) { value = i; } } public class smallest_dedc2a7c_000 { public java.util.Scanner scanner; public String output = ""; public static void main (String[]args) throws Exception { smallest_dedc2a7c_000 mainClass = new smallest_dedc2a7c_000 (); String output; if (args.length > 0) { mainClass.scanner = new java.util.Scanner (args[0]); } else { mainClass.scanner = new java.util.Scanner (System.in); } mainClass.exec (); System.out.println (mainClass.output); } public void exec () throws Exception { FloatObj a = new FloatObj (), b = new FloatObj (), c = new FloatObj (), d = new FloatObj (); output += (String.format ("Please enter 4 numbers separated by spaces > ")); a.value = scanner.nextFloat (); b.value = scanner.nextFloat (); c.value = scanner.nextFloat (); d.value = scanner.nextFloat (); if ((a.value < b.value) && (a.value < c.value) && (a.value < d.value)) { output += (String.format ("%.0f is the smallest\n", a.value)); } else if ((b.value < a.value) && (a.value) < (c.value) && (b.value < d.value)) { output += (String.format ("%.0f is the smallest\n", b.value)); } else if ((c.value < a.value) && (c.value < b.value) && (c.value < d.value)) { output += (String.format ("%.0f is the smallest\n", c.value)); } else { output += (String.format ("%.0f is the smallest\n", d.value)); } if (true) return;; } }
[ "bsse0731@iit.du.ac.bd" ]
bsse0731@iit.du.ac.bd
e06207b9a66c9fe95fb39ac2a46fe95a59fa96a6
1977757fa8a337e3346795cfb1ceca9ae95b97fb
/src/day44/HouseBuilder.java
b74d401880170f0c1d72c1bf7451bea89d874ff5
[]
no_license
Tarana82/MyFirstProject
fcb3e81c3659e9f846a71c7856fcf4ba914e15ad
6fe9bb5f1d90812f6c2e5ef68ba275435a7cabce
refs/heads/master
2021-02-11T16:22:21.801471
2020-03-03T03:33:39
2020-03-03T03:33:39
244,509,280
0
0
null
null
null
null
UTF-8
Java
false
false
505
java
package day44; public class HouseBuilder { public static void main(String[] args) { CyberHouse.showNeighbourhoodName(); CyberHouse c1 = new CyberHouse("Vintage", 101); c1.showAllInfo(); CyberHouse c2 = new CyberHouse("Classic", 102); c2.showAllInfo(); //System.out.println(CyberHouse.neighbourhoodName ); // How do I get max value of Short System.out.println(Short.MAX_VALUE); System.out.println(Byte.MAX_VALUE); } }
[ "tahmadova1982@gmail.com" ]
tahmadova1982@gmail.com
4c46bc3027069c88b81f985f44c89f061e9ff2f5
16ed72e751dc1393912eb2ef3a830033831862c2
/msi/src/main/java/dk/dma/enav/services/s124/views/ChartAffected.java
3964a6ccf4db24ef44799d91291dc229e84c4a69
[ "Apache-2.0" ]
permissive
maritime-web/Enav-Services
43126ac447e82a03834cb49b283abf27432b6de0
e0329646b924d74b7dc45dd2ca21a6ebdde31d9d
refs/heads/master
2022-12-17T17:39:39.004132
2020-04-20T11:36:38
2020-04-20T11:36:38
50,661,158
1
1
Apache-2.0
2022-12-05T23:33:40
2016-01-29T12:30:32
Java
UTF-8
Java
false
false
939
java
/* Copyright (c) 2011 Danish Maritime Authority. * * 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 dk.dma.enav.services.s124.views; import lombok.Getter; import lombok.Setter; import lombok.ToString; import java.util.Date; @Getter @Setter @ToString public class ChartAffected { private String chartNumber; private Date editionDate; private Date lastNoticeDate; private String publicationAffected; }
[ "steen@lundogbendsen.dk" ]
steen@lundogbendsen.dk
c578661adfe5fccdc754424dc7e5f14ab21b583f
ee8c16c1474e161359f2cb77b0105f9ded8068d1
/webrtc-demo/webrtc-demo-api/src/main/java/dev/onvoid/webrtc/demo/presenter/DesktopCaptureSettingsPresenter.java
7830ab7b2dfcd901638f20cf6b2acc058f7538df
[ "BSD-3-Clause", "LicenseRef-scancode-html5", "DOC", "Apache-2.0" ]
permissive
m-sobieszek/webrtc-java
b46fa47a4e1cd7b8e5992322311562a31eeabdee
406336052da1bc079ca62577a3fc845e22e215c1
refs/heads/master
2022-08-22T12:32:28.509935
2022-06-15T11:47:50
2022-06-15T11:47:50
230,241,997
0
0
Apache-2.0
2019-12-26T10:12:11
2019-12-26T10:12:10
null
UTF-8
Java
false
false
1,266
java
/* * Copyright 2019 Alex Andres * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package dev.onvoid.webrtc.demo.presenter; import dev.onvoid.webrtc.demo.config.Configuration; import dev.onvoid.webrtc.demo.config.DesktopCaptureConfiguration; import dev.onvoid.webrtc.demo.view.DesktopCaptureSettingsView; import javax.inject.Inject; public class DesktopCaptureSettingsPresenter extends Presenter<DesktopCaptureSettingsView> { private final DesktopCaptureConfiguration config; @Inject DesktopCaptureSettingsPresenter(DesktopCaptureSettingsView view, Configuration config) { super(view); this.config = config.getDesktopCaptureConfiguration(); } @Override public void initialize() { view.setFrameRate(config.frameRateProperty()); } }
[ "andres.alex@protonmail.com" ]
andres.alex@protonmail.com
db26b58a4da4429255fa0cc1c70d24a33a582f9b
28c99d6b07a8683bed97c8d2190648d5b9dca757
/src/main/java/io/github/wispoffates/minecraft/tktowns/responses/OutpostModificationResponse.java
c578c5a992a8138be8d59baaf460893a4f828b73
[]
no_license
wispoffates/minecraft.tktowns
b0e0ecc5f347b1d0c497115119f9b2ffedce8595
c68bb14629a865213cbbcaaf2d30fae26882cffa
refs/heads/master
2016-09-06T14:38:49.870049
2015-05-21T03:23:20
2015-05-21T03:23:20
24,813,285
0
0
null
null
null
null
UTF-8
Java
false
false
433
java
package io.github.wispoffates.minecraft.tktowns.responses; import io.github.wispoffates.minecraft.tktowns.api.impl.Outpost; public class OutpostModificationResponse extends GenericModificationResponse { protected Outpost outpost; public OutpostModificationResponse(String message, Outpost outpost, boolean success) { super(message,success); this.outpost = outpost; } public Outpost getOutpost() { return outpost; } }
[ "fayted@gmail.com" ]
fayted@gmail.com
3e71ce6090c7548de8e24f792dc3fd98f3acb10a
2b6f5c78a02805fd7684409c31d3dc3f0a00e81e
/src/main/java/com/shedhack/thread/threadlocal/utility/ThreadLocalUtility.java
6f3fb00a27261b561df7cae30dc6a04231ba4f45
[]
no_license
imamchishty/threadlocal-string-utility
7fccd10b4e0c145261a6a250fe4e29fc1af875d8
657380085516173ad9fc62c3d46d054735f57de1
refs/heads/master
2021-01-10T09:47:30.258404
2016-03-31T11:34:40
2016-03-31T11:34:40
55,134,516
0
1
null
null
null
null
UTF-8
Java
false
false
531
java
package com.shedhack.thread.threadlocal.utility; /** * Utility class simplifies the manner in which ThreadLocal (of String payload types) are stored, accessed and cleared. * * @author imamchishty */ public class ThreadLocalUtility { private static final ThreadLocal<String> local = new ThreadLocal<>(); public static void set(String requestId) { local.set(requestId); } public static String get() { return local.get(); } public static void clear(){ local.remove(); } }
[ "imam.chishty@emc.com" ]
imam.chishty@emc.com
67f79b8df885ace10335e24bad94792d49267161
01b56a5840baddc1eba73940d5ee3e2b98c02006
/app/src/main/java/com/example/discussgo/firstscreen/view/fragments/RegisterFragment.java
f0f0dcb3992875d04a4b876a2ffc3c8c272db620
[]
no_license
Sernrbia/DiscussGo-final
a45608734e0449b25259918acabc6361f3c9c4af
77ad537541f6c84c6d4a7997b305168419d8341d
refs/heads/master
2020-06-28T17:31:53.620503
2019-08-10T00:50:01
2019-08-10T00:50:01
200,297,529
0
0
null
null
null
null
UTF-8
Java
false
false
2,857
java
package com.example.discussgo.firstscreen.view.fragments; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProviders; import com.example.discussgo.R; import com.example.discussgo.addon.Animation; import com.example.discussgo.addon.SharedPreferencesWrapper; import com.example.discussgo.firstscreen.factory.RegisterFactory; import com.example.discussgo.firstscreen.repository.UserRepository; import com.example.discussgo.firstscreen.viewmodel.RegisterVM; public class RegisterFragment extends Fragment { RegisterVM viewmodel; Animation animation; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.register_layout, container, false); final EditText firstName = view.findViewById(R.id.register_editFirstName); final EditText lastName = view.findViewById(R.id.register_editLastName); final EditText username = view.findViewById(R.id.register_editUsername); final EditText password = view.findViewById(R.id.register_editPassword); final EditText confirmPassword = view.findViewById(R.id.register_editConfirmPassword); SharedPreferencesWrapper wrapper = SharedPreferencesWrapper.getInstance(); UserRepository repository = UserRepository.getInstance(wrapper); RegisterFactory factory = new RegisterFactory(repository); viewmodel = ViewModelProviders.of(this, factory).get(RegisterVM.class); viewmodel.getCheckFields().observe(RegisterFragment.this, s -> { //animation.stopAnimation(); if (s.contains("username")) { username.setError(s); } else if(s.contains("password")) { password.setError(s); } else if(s.contains("first name")) { firstName.setError(s); } else if(s.contains("last name")) { lastName.setError(s); } else if(s.contains("confirm password")) { confirmPassword.setError(s); } else { password.setText(""); confirmPassword.setText(""); password.setError(s); confirmPassword.setError(s); } }); Button btnRegister = view.findViewById(R.id.register_btnRegister); btnRegister.setOnClickListener(view1 -> { viewmodel.checkFields(firstName.getText().toString(), lastName.getText().toString(), username.getText().toString(), password.getText().toString(), confirmPassword.getText().toString()); }); return view; } }
[ "dejan.randjelovic.016@gmail.com" ]
dejan.randjelovic.016@gmail.com
458ee11c6d16fb00dd91d70a8705d59b8460ae01
20867edd60d647d3dc983bb4599ab55f7a417823
/app/src/main/java/app/roque/moviesfeed/http/MoviesApiService.java
ea3644089be3ec55bb953c496888d4f883218026
[]
no_license
kevingroque/Movies-Feed-Mvp-Dagger2-RxJava-Retrofit
3fc72a9bd289dac5f1d449ceb689596047852df9
d860ab06a2403870feda7c356dc75dc47aa22ff9
refs/heads/master
2020-08-05T03:41:25.823211
2019-10-02T15:50:25
2019-10-02T15:50:25
212,380,903
0
0
null
null
null
null
UTF-8
Java
false
false
362
java
package app.roque.moviesfeed.http; import app.roque.moviesfeed.http.apiModel.TopMoviesRated; import io.reactivex.Observable; import retrofit2.http.GET; import retrofit2.http.Query; public interface MoviesApiService { @GET("top_rated") Observable<TopMoviesRated> getTopMoviesRated(/*@Query("api_key") String api_key,*/ @Query("page") Integer page); }
[ "keving.roque.huich@gmail.com" ]
keving.roque.huich@gmail.com
f5aec46499213d4bc4eff0edb8ec37aa6d256146
dbd5cc67713c20cea78040615dc19a2a9c4d9fcb
/src/main/java/com/spotify/client/demo/model/Example.java
ea6ffb4cf2e0f1b2b7325dc0b93dbb0d5ef75d11
[]
no_license
adamcze4/SpringBoot_Spotify_Client_with_MongoDB
e812cf9bd1849de0083e74cc012c9fa3e80aacde
8e4b68d90cb8276b7dc581fa26a5327b8c5e28be
refs/heads/master
2022-10-08T02:03:00.844976
2020-06-10T11:08:17
2020-06-10T11:08:17
271,253,575
0
0
null
null
null
null
UTF-8
Java
false
false
1,151
java
package com.spotify.client.demo.model; import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "tracks" }) public class Example { @JsonProperty("tracks") private Tracks tracks; @JsonIgnore private Map<String, Object> additionalProperties = new HashMap<String, Object>(); @JsonProperty("tracks") public Tracks getTracks() { return tracks; } @JsonProperty("tracks") public void setTracks(Tracks tracks) { this.tracks = tracks; } @JsonAnyGetter public Map<String, Object> getAdditionalProperties() { return this.additionalProperties; } @JsonAnySetter public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } }
[ "adamcze4@gmail.com" ]
adamcze4@gmail.com
10cb8ac82c16c6bf9ad174d1a571f1d7648c97b7
487cf95b2537c14c205fd55f5aa16b19bd4d0c69
/src/main/java/net/shopxx/template/directive/PaginationDirective.java
58bf801a36203d80c098e5946372607a711e51fa
[]
no_license
heyewei/mall1
1953d777fc7a0a59037e7e819b732c05f77957b0
01b5b49289757a10bbb5d3dea25b114762a2c783
refs/heads/develop
2021-07-10T17:58:08.819438
2017-10-13T02:06:36
2017-10-13T02:06:36
107,208,648
1
1
null
2017-10-17T02:38:49
2017-10-17T02:38:49
null
UTF-8
Java
false
false
5,320
java
/* * Copyright 2005-2017 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package net.shopxx.template.directive; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.stereotype.Component; import freemarker.core.Environment; import freemarker.template.TemplateDirectiveBody; import freemarker.template.TemplateException; import freemarker.template.TemplateModel; import net.shopxx.util.FreeMarkerUtils; /** * 模板指令 - 分页 * * @author SHOP++ Team * @version 5.0.3 */ @Component public class PaginationDirective extends BaseDirective { /** * "模式"参数名称 */ private static final String PATTERN_PARAMETER_NAME = "pattern"; /** * "页码"参数名称 */ private static final String PAGE_NUMBER_PARAMETER_NAME = "pageNumber"; /** * "总页数"参数名称 */ private static final String TOTAL_PAGES_PARAMETER_NAME = "totalPages"; /** * "中间段页码数"参数名称 */ private static final String SEGMENT_COUNT_PARAMETER_NAME = "segmentCount"; /** * "模式"变量名称 */ private static final String PATTERN_VARIABLE_NAME = "pattern"; /** * "页码"变量名称 */ private static final String PAGE_NUMBER_VARIABLE_NAME = "pageNumber"; /** * "总页数"变量名称 */ private static final String PAGE_COUNT_VARIABLE_NAME = "totalPages"; /** * "中间段页码数"变量名称 */ private static final String SEGMENT_COUNT_VARIABLE_NAME = "segmentCount"; /** * "是否存在上一页"变量名称 */ private static final String HAS_PREVIOUS_VARIABLE_NAME = "hasPrevious"; /** * "是否存在下一页"变量名称 */ private static final String HAS_NEXT_VARIABLE_NAME = "hasNext"; /** * "是否为首页"变量名称 */ private static final String IS_FIRST_VARIABLE_NAME = "isFirst"; /** * "是否为末页"变量名称 */ private static final String IS_LAST_VARIABLE_NAME = "isLast"; /** * "上一页页码"变量名称 */ private static final String PREVIOUS_PAGE_NUMBER_VARIABLE_NAME = "previousPageNumber"; /** * "下一页页码"变量名称 */ private static final String NEXT_PAGE_NUMBER_VARIABLE_NAME = "nextPageNumber"; /** * "首页页码"变量名称 */ private static final String FIRST_PAGE_NUMBER_VARIABLE_NAME = "firstPageNumber"; /** * "末页页码"变量名称 */ private static final String LAST_PAGE_NUMBER_VARIABLE_NAME = "lastPageNumber"; /** * "中间段页码"变量名称 */ private static final String SEGMENT_VARIABLE_NAME = "segment"; /** * 执行 * * @param env * 环境变量 * @param params * 参数 * @param loopVars * 循环变量 * @param body * 模板内容 */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String pattern = FreeMarkerUtils.getParameter(PATTERN_PARAMETER_NAME, String.class, params); Integer pageNumber = FreeMarkerUtils.getParameter(PAGE_NUMBER_PARAMETER_NAME, Integer.class, params); Integer totalPages = FreeMarkerUtils.getParameter(TOTAL_PAGES_PARAMETER_NAME, Integer.class, params); Integer segmentCount = FreeMarkerUtils.getParameter(SEGMENT_COUNT_PARAMETER_NAME, Integer.class, params); if (pageNumber == null || pageNumber < 1) { pageNumber = 1; } if (totalPages == null || totalPages < 1) { totalPages = 1; } if (segmentCount == null || segmentCount < 1) { segmentCount = 5; } boolean hasPrevious = pageNumber > 1; boolean hasNext = pageNumber < totalPages; boolean isFirst = pageNumber == 1; boolean isLast = pageNumber.equals(totalPages); int previousPageNumber = pageNumber - 1; int nextPageNumber = pageNumber + 1; int firstPageNumber = 1; int lastPageNumber = totalPages; int startSegmentPageNumber = pageNumber - (int) Math.floor((segmentCount - 1) / 2D); int endSegmentPageNumber = pageNumber + (int) Math.ceil((segmentCount - 1) / 2D); if (startSegmentPageNumber < 1) { startSegmentPageNumber = 1; } if (endSegmentPageNumber > totalPages) { endSegmentPageNumber = totalPages; } List<Integer> segment = new ArrayList<>(); for (int i = startSegmentPageNumber; i <= endSegmentPageNumber; i++) { segment.add(i); } Map<String, Object> variables = new HashMap<>(); variables.put(PATTERN_VARIABLE_NAME, pattern); variables.put(PAGE_NUMBER_VARIABLE_NAME, pageNumber); variables.put(PAGE_COUNT_VARIABLE_NAME, totalPages); variables.put(SEGMENT_COUNT_VARIABLE_NAME, segmentCount); variables.put(HAS_PREVIOUS_VARIABLE_NAME, hasPrevious); variables.put(HAS_NEXT_VARIABLE_NAME, hasNext); variables.put(IS_FIRST_VARIABLE_NAME, isFirst); variables.put(IS_LAST_VARIABLE_NAME, isLast); variables.put(PREVIOUS_PAGE_NUMBER_VARIABLE_NAME, previousPageNumber); variables.put(NEXT_PAGE_NUMBER_VARIABLE_NAME, nextPageNumber); variables.put(FIRST_PAGE_NUMBER_VARIABLE_NAME, firstPageNumber); variables.put(LAST_PAGE_NUMBER_VARIABLE_NAME, lastPageNumber); variables.put(SEGMENT_VARIABLE_NAME, segment); setLocalVariables(variables, env, body); } }
[ "121323188@qq.com" ]
121323188@qq.com
371bbc17cad5d1541196439ab6c39f84243a43f5
b347249be3422c10d43b027bce87be7c37031325
/ModuloPagamento2/src/com/up/pagamento/endpoint/PagamentoEndPointImpl.java
41a6fca7a5bcae726c4b541c647e7b5cecedf91a
[]
no_license
lucaswamser/ecommerce
dc1b3613f0790713a14862ce2c23a8cc145c752d
a0f392fc29fc42ed5d7cc4d8f2a49a2adc3b1613
refs/heads/master
2021-01-20T18:16:26.155035
2016-11-19T17:56:21
2016-11-19T17:56:21
61,677,260
0
0
null
null
null
null
UTF-8
Java
false
false
796
java
package com.up.pagamento.endpoint; import javax.jws.WebMethod; import javax.jws.WebService; import com.up.pagamento.dao.PagamentoDaoImpl; import com.up.pagamento.domain.Pagamento; import com.up.pagamento.services.PagamentoService; import com.up.pagamento.services.PagamentoServiceImpl; @WebService(endpointInterface = "com.up.pagamento.endpoint.PagamentoEndPoint") public class PagamentoEndPointImpl implements PagamentoEndPoint { private PagamentoService pagamentoService; public PagamentoEndPointImpl() { super(); this.pagamentoService = new PagamentoServiceImpl(new PagamentoDaoImpl()); } @WebMethod @Override public Boolean pagar(Pagamento pagamento) { System.out.println("modulo de pagamento recebeu a requisição"); return pagamentoService.pagar(pagamento); } }
[ "lucas@lucas-Aspire-E1-571" ]
lucas@lucas-Aspire-E1-571
8b39b144ffd70b91184167885e83fefbf176ecc9
815c18b4fa82e2ef7a15b661eb93bab8085b2257
/cxx-checks/src/test/java/org/sonar/cxx/checks/LineRegularExpressionCheckTest.java
a30af45a4643e980156302f35c8dc2ba68b97d2d
[]
no_license
FrontEndART/sonar-cxx
12b2ae22ad0bb802acade321a7c7e5e8654f8765
65b76a9db7851f90bded2cf71be6701b5b6c1c78
refs/heads/master
2021-01-16T20:34:52.236232
2016-06-10T08:26:21
2016-06-10T09:39:31
60,832,193
0
0
null
2016-06-10T07:51:49
2016-06-10T07:51:49
null
UTF-8
Java
false
false
4,097
java
/* * Sonar C++ Plugin (Community) * Copyright (C) 2011 Waleri Enns and CONTACT Software GmbH * sonarqube@googlegroups.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ package org.sonar.cxx.checks; import java.io.File; import org.junit.Test; import org.sonar.cxx.CxxAstScanner; import org.sonar.squidbridge.api.SourceFile; import org.sonar.squidbridge.checks.CheckMessagesVerifier; public class LineRegularExpressionCheckTest { @Test public void lineRegExWithoutFilePattern() { LineRegularExpressionCheck check = new LineRegularExpressionCheck(); check.regularExpression = "stdafx\\.h"; check.message = "Found 'stdafx.h' in line!"; SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/LineRegEx.cc"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next().atLine(2).withMessage(check.message) .next().atLine(3).withMessage(check.message) .noMore(); } @Test public void lineRegExInvertWithoutFilePattern() { LineRegularExpressionCheck check = new LineRegularExpressionCheck(); check.regularExpression = "//.*"; check.invertRegularExpression = true; check.message = "Found no comment in the line!"; SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/LineRegExInvert.cc"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next().atLine(3).withMessage(check.message) .noMore(); } @Test public void lineRegExWithFilePattern1() { LineRegularExpressionCheck check = new LineRegularExpressionCheck(); check.matchFilePattern = "/**/*.cc"; // all files with .cc file extension check.regularExpression = "#include\\s+\"stdafx\\.h\""; check.message = "Found '#include \"stdafx.h\"' in line in a .cc file!"; SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/LineRegEx.cc"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next().atLine(2).withMessage(check.message) .next().atLine(3).withMessage(check.message) .noMore(); } @Test public void lineRegExWithFilePatternInvert() { LineRegularExpressionCheck check = new LineRegularExpressionCheck(); check.matchFilePattern = "/**/*.xx"; // all files with not .xx file extension check.invertFilePattern = true; check.regularExpression = "#include\\s+\"stdafx\\.h\""; check.message = "Found '#include \"stdafx.h\"' in line in a not .xx file!"; SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/LineRegEx.cc"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .next().atLine(2).withMessage(check.message) .next().atLine(3).withMessage(check.message) .noMore(); } @Test public void lineRegExWithFilePattern2() { LineRegularExpressionCheck check = new LineRegularExpressionCheck(); check.matchFilePattern = "/**/*.xx"; // all files with .xx file extension check.regularExpression = "#include\\s+\"stdafx\\.h\""; check.message = "Found '#include \"stdafx.h\"' in line in a .xx file!"; SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/LineRegEx.cc"), check); CheckMessagesVerifier.verify(file.getCheckMessages()) .noMore(); } }
[ "guenter.wirth@etas.com" ]
guenter.wirth@etas.com
3c9ba1f190bb80b05efa2b9a1edb7c742054de3b
d16ff20568c9c82dd9f821332cdffdeab01b97b3
/code/src/org/bits/jcr/actors/Developer.java
e3422d3bccccbd5d3869cad4c46a4503633860cd
[]
no_license
shubbansal27/ReviewIt
b4966df019b5ddf6e96c7bd0ca795c8af1da29dd
a6585cef727227e20f3a79222caddb4e7cefc8fa
refs/heads/main
2023-03-07T04:05:54.359383
2021-02-25T17:25:48
2021-02-25T17:25:48
342,323,445
0
0
null
null
null
null
UTF-8
Java
false
false
443
java
package org.bits.jcr.actors; import java.io.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Developer extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
[ "shubansa@cisco.com" ]
shubansa@cisco.com
ee5b32ffaa27afd07ac4d98aa6b74eee20680a6c
1680bc3a99e275962dff0f094f83bd987205959b
/CitasMedicas/src/java/pe/com/citasmedicas/dao/MedicoDao.java
9ca2e4d29b006f6b46210ff62207f2e267411d0a
[]
no_license
richardtrujillo/dewcitamedica
a0e4d482be73bd9c676fe847e5c4eb87c29f8ad4
6830c74f2aa85d5a32b9c82c324ad33019acf532
refs/heads/master
2021-01-10T05:12:27.129443
2010-04-10T20:25:41
2010-04-10T20:25:41
36,374,320
0
0
null
null
null
null
UTF-8
Java
false
false
1,005
java
package pe.com.citasmedicas.dao; import java.util.List; import pe.com.citasmedicas.model.Especialidad; import pe.com.citasmedicas.model.Medico; /** * Esta clase contiene los métodos a ser implementados por las clases de persistencia * @author dew - Grupo 04 */ public interface MedicoDao { /** * Obtiene un médico por su id * @param medicoId identificador del medico * @return Medico datos del medico */ Medico getMedicoPorId(Integer medicoId); /** * Obtiene todas los médicos de una especialidad específica * @param especialidad datos de la especialidad * @return List<Medico> lista de medicos encontrados */ List<Medico> getMedicosPorEspecialidad(Especialidad especialidad); /** * Obtiene todas los médicos de una especialidad específica * @param especialidadId identificador de la especialidad * @return List<Medico> lista de medicos */ List<Medico> getMedicosPorEspecialidad(Integer especialidadId); }
[ "kielsaenz@82247850-1900-11df-85bb-b9a83fee2cb1" ]
kielsaenz@82247850-1900-11df-85bb-b9a83fee2cb1
f5a0db0820f5679070bc5cc6e8ab59f87a1c2127
f8d41d7bab69c60ca335f32e11d7b6fbff24d698
/java/src/test/java/com/thoughtworks/refactoring/pullUpConstructorBody/ManagerTest.java
3a43f2598f16abb7f6e3ec9f2f46d2c1d9a832b3
[ "MIT" ]
permissive
sheltonsuen/refactoring
872f6bdb972f5283ff5ac0c0a59949c1817d03ee
48dbe45f031bb490a1104b0e6090e7b1f395188f
refs/heads/master
2020-04-01T10:30:51.669443
2018-10-25T13:58:09
2018-10-25T13:58:09
153,120,759
0
0
MIT
2018-10-15T13:46:13
2018-10-15T13:46:12
null
UTF-8
Java
false
false
372
java
package com.thoughtworks.refactoring.pullUpConstructorBody; import org.junit.Test; import static org.junit.Assert.assertEquals; public class ManagerTest { @Test public void descriptionOfManager() throws Exception { Manager manager = new Manager("manager", "b", 1); assertEquals(manager.description(), "name: manager, id: b, grade: 1"); } }
[ "634725546@qq.com" ]
634725546@qq.com
0dcb99eeb6dede5b37a831771978e591bcd0fd78
adceea293c35e411803ecd7426aff098def5a8b0
/Lesson2/Classwork/For1.java
525a0b4b29cbeabb8198405a739a1d7dd9e6d91a
[]
no_license
polosbl/Java
0e36314780e006df2c2b75266e0f8165539740ea
2a8d481f964c0fa15bf5afa2dbaf2076cab898ef
refs/heads/master
2023-03-31T22:53:35.406994
2021-04-08T19:01:10
2021-04-08T19:01:10
346,018,621
0
0
null
null
null
null
UTF-8
Java
false
false
263
java
package Lesson2.Classwork; public class For1 { public static void main(String[] args) { // Выведите на экран все числа от 20 до 1 for (int i = 20; i > 0; i--) { System.out.println(i); } } }
[ "a.gordeichik@invento.by" ]
a.gordeichik@invento.by
c66e6f6a8fecb6ae42115083ddb60d49ef1d739f
a40089046c5ec8397c8bf8c50619a8927ab3fe3f
/workspace/spring-boot-data-jpa/src/main/java/com/curso/springboot/jpa/models/entity/UserEntity.java
858d850c94c1a7d21c217242b24675c12172c089
[]
no_license
junglans/curso-spring
7024af19cbe26b2bb256f572c6879d33448ec1e9
bf1e37d2304bcffacf2639e4faf3ccaf2dbb11f7
refs/heads/master
2021-07-13T06:41:42.244989
2019-03-13T13:24:31
2019-03-13T13:24:31
149,016,372
0
0
null
null
null
null
UTF-8
Java
false
false
3,609
java
package com.curso.springboot.jpa.models.entity; import java.io.Serializable; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.ConstraintMode; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name = "USERS") public class UserEntity implements Serializable { /** * */ private static final long serialVersionUID = 2939196117275458845L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(unique = true, insertable=true, updatable=true, nullable=false, length = 30) private String username; @Column(insertable=true, updatable=true, nullable=false, length = 60) private String password; @Column(insertable=true, updatable=true, nullable=false) private Boolean enabled; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name="USER_ROLE", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), foreignKey = @ForeignKey(ConstraintMode.CONSTRAINT) ) private List<RoleEntity> roles; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } public List<RoleEntity> getRoles() { return roles; } public void setRoles(List<RoleEntity> roles) { this.roles = roles; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((enabled == null) ? 0 : enabled.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((password == null) ? 0 : password.hashCode()); result = prime * result + ((roles == null) ? 0 : roles.hashCode()); result = prime * result + ((username == null) ? 0 : username.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; UserEntity other = (UserEntity) obj; if (enabled == null) { if (other.enabled != null) return false; } else if (!enabled.equals(other.enabled)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (password == null) { if (other.password != null) return false; } else if (!password.equals(other.password)) return false; if (roles == null) { if (other.roles != null) return false; } else if (!roles.equals(other.roles)) return false; if (username == null) { if (other.username != null) return false; } else if (!username.equals(other.username)) return false; return true; } @Override public String toString() { return "UserEntity [id=" + id + ", username=" + username + ", password=" + password + ", enabled=" + enabled + ", roles=" + roles + "]"; } }
[ "jf.jimenez@mnemo.com" ]
jf.jimenez@mnemo.com
a45de9cace1f2270725d19c1be0b51ff001d1bb4
8214f05bbbbd65837c197e64bdb6bf31cd95d538
/src/main/java/cn/baby_p2p/demo/service/UserService.java
419736e0fdaa524b114d5f7bf84955e67c2a33a6
[]
no_license
babyp2pT240/baby_p2pxm
60885ac640167e12980462378891fea76b0fb265
da519027251a6f3866e7c42b00a4dea0e1b63f99
refs/heads/master
2022-07-09T04:34:46.962574
2020-03-02T03:26:56
2020-03-02T03:26:56
242,270,515
0
0
null
2022-06-21T02:50:39
2020-02-22T03:03:55
JavaScript
UTF-8
Java
false
false
4,640
java
package cn.baby_p2p.demo.service; import cn.baby_p2p.demo.dao.TBankCardRepository; import cn.baby_p2p.demo.dao.TUserAccountRepository; import cn.baby_p2p.demo.dao.TUserInfoRepository; import cn.baby_p2p.demo.dao.TUserWalletRepository; import cn.baby_p2p.demo.pojo.TBankCard; import cn.baby_p2p.demo.pojo.TUserAccount; import cn.baby_p2p.demo.pojo.TUserInfo; import cn.baby_p2p.demo.pojo.TUserWallet; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; @Service public class UserService { @Resource private TUserAccountRepository tUserAccountRepository; @Resource private TUserInfoRepository tUserInfoRepository; @Resource private TUserWalletRepository tUserWalletRepository; @Resource private TBankCardRepository tBankCardRepository; public TUserAccount login(String username){ TUserAccount tUserAccount = new TUserAccount(); tUserAccount.setLastLoginTime(new Date()); QueryWrapper<TUserAccount> queryWrapper = new QueryWrapper<TUserAccount>(); queryWrapper.like("username",username); List<TUserAccount> tUserAccountList = tUserAccountRepository.selectList(queryWrapper); int result = tUserAccountRepository.update(tUserAccount,queryWrapper); if (result>0){ return tUserAccountList.get(0); } if(tUserAccountList.size()==0){ return null; }else { return tUserAccountList.get(0); } } public boolean register(String id,String username,String password){ TUserAccount tUserAccount = new TUserAccount(); TUserInfo tUserInfo = new TUserInfo(); TUserWallet tUserWallet = new TUserWallet(); boolean faly = false; tUserAccount.setId(id); tUserAccount.setUsername(username); tUserAccount.setPassword(password); tUserAccount.setAccountStatus(1); tUserAccount.setAccountType(1); tUserAccount.setCreateTime(new Date()); tUserInfo.setAccountId(id); tUserInfo.setCreateTime(new Date()); tUserWallet.setAccountId(id); tUserWallet.setCreateTime(new Date()); tUserInfo.setAvatar("nobody.jpg"); int result1 = tUserAccountRepository.insert(tUserAccount); int result2 = tUserInfoRepository.insert(tUserInfo); int result3 = tUserWalletRepository.insert(tUserWallet); if (result1>0&&result2>0&&result3>0){ faly = true; } return faly; } public TUserInfo getTUserInfo(String id){ QueryWrapper<TUserInfo> queryWrapper = new QueryWrapper<TUserInfo>(); queryWrapper.like("account_id",id); List<TUserInfo> tUserInfoList = tUserInfoRepository.selectList(queryWrapper); return tUserInfoList.get(0); } public TUserWallet getTUserWallet(String id){ QueryWrapper<TUserWallet> queryWrapper = new QueryWrapper<TUserWallet>(); queryWrapper.like("account_id",id); List<TUserWallet> tUserWalletList = tUserWalletRepository.selectList(queryWrapper); return tUserWalletList.get(0); } public TBankCard getTBankCard(String id){ QueryWrapper<TBankCard> queryWrapper = new QueryWrapper<TBankCard>(); queryWrapper.like("user_id",id); List<TBankCard> tBankCardList = tBankCardRepository.selectList(queryWrapper); if (tBankCardList.size()==0){ return null; }else { return tBankCardList.get(0); } } public boolean addTBankCard(TBankCard tBankCard){ boolean faly = false; int result = tBankCardRepository.insert(tBankCard); if (result>0){ faly = true; } return faly; } public boolean updateUserinfo(TUserInfo tUserInfo){ boolean faly = false; QueryWrapper<TUserInfo> queryWrapper = new QueryWrapper<TUserInfo>(); queryWrapper.like("account_id",tUserInfo.getAccountId()); int result = tUserInfoRepository.update(tUserInfo,queryWrapper); if (result>0){ faly = true; } return faly; } public boolean updateUserAccount(TUserAccount tUserAccount){ boolean faly = false; QueryWrapper<TUserAccount> queryWrapper = new QueryWrapper<TUserAccount>(); queryWrapper.like("id",tUserAccount.getId()); int result = tUserAccountRepository.update(tUserAccount,queryWrapper); if (result>0){ faly = true; } return faly; } }
[ "a1198957762@163.com" ]
a1198957762@163.com
415b76a2687ef75bd54ee3f946dee59b95ac9ac7
cc9925d381bb8dda2e89fbd2c50be9eaf7df70bc
/app/src/com/trovebox/android/app/ui/adapter/MultiSelectTagsAdapter.java
54d3d3b09066dca107989438fc978d329b26a7cf
[ "Apache-2.0" ]
permissive
photo/mobile-android
91e5ad5d93c6482dfaf00b0c8c59d58a314d9b87
24d1d105629403ec6fc19aa1f3cb4aa45c80d391
refs/heads/master
2021-01-15T22:29:16.633557
2020-10-01T07:04:11
2020-10-01T07:04:11
2,031,128
29
23
Apache-2.0
2020-10-01T07:04:12
2011-07-11T15:49:24
Java
UTF-8
Java
false
false
4,087
java
package com.trovebox.android.app.ui.adapter; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import com.trovebox.android.app.Preferences; import com.trovebox.android.app.R; import com.trovebox.android.app.TroveboxApplication; import com.trovebox.android.app.model.utils.TagUtils; import com.trovebox.android.app.util.compare.ToStringComparator; import com.trovebox.android.common.model.Tag; import com.trovebox.android.common.net.ITroveboxApi; import com.trovebox.android.common.net.TagsResponse; import com.trovebox.android.common.net.TroveboxResponseUtils; import com.trovebox.android.common.ui.adapter.EndlessAdapter; import com.trovebox.android.common.util.GuiUtils; import com.trovebox.android.common.util.LoadingControl; /** * @author Eugene Popovich */ public abstract class MultiSelectTagsAdapter extends EndlessAdapter<Tag> implements OnCheckedChangeListener { static final String TAG = MultiSelectTagsAdapter.class.getSimpleName(); private final ITroveboxApi mTroveboxApi; protected Set<String> checkedTags = new HashSet<String>(); private LoadingControl loadingControl; public MultiSelectTagsAdapter(LoadingControl loadingControl) { super(Integer.MAX_VALUE); this.loadingControl = loadingControl; mTroveboxApi = Preferences.getApi(TroveboxApplication.getContext()); loadFirstPage(); } @Override public long getItemId(int position) { return ((Tag) getItem(position)).getTag().hashCode(); } public void initTagCheckbox(Tag tag, CheckBox checkBox) { checkBox.setText(tag.getTag()); checkBox.setOnCheckedChangeListener(null); checkBox.setChecked(isChecked(tag.getTag())); checkBox.setOnCheckedChangeListener(this); } @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { String text = (String) buttonView.getText(); if (isChecked) checkedTags.add(text); else checkedTags.remove(text); } @Override public LoadResponse loadItems(int page) { if (GuiUtils.checkLoggedInAndOnline()) { try { TagsResponse response = mTroveboxApi.getTags(); if (TroveboxResponseUtils.checkResponseValid(response)) { List<Tag> tags = response.getTags(); if (tags != null) { Collections.sort(tags, new ToStringComparator()); } return new LoadResponse(tags, false); } } catch (Exception e) { GuiUtils.error(TAG, R.string.errorCouldNotLoadNextTagsInList, e); } } return new LoadResponse(null, false); } @Override protected void onStartLoading() { if(loadingControl != null) { loadingControl.startLoading(); } } @Override protected void onStoppedLoading() { if(loadingControl != null) { loadingControl.stopLoading(); } } public String getSelectedTags() { StringBuffer buf = new StringBuffer(""); if (checkedTags.size() > 0) { List<String> sortedTags = new ArrayList<String>(checkedTags); Collections.sort(sortedTags, new ToStringComparator()); buf.append(TagUtils.getTagsString(sortedTags)); } return buf.toString(); } protected boolean isChecked(String tag) { if (tag == null) { return false; } return checkedTags.contains(tag); } }
[ "httpdispatch@gmail.com" ]
httpdispatch@gmail.com
91875a7caa82d02d983d5196df3de1fdafbfc234
da62f2ca68ea688d45611bb745a86ae76b409348
/containerkit/instrument/client/src/main/java/org/apache/excalibur/instrument/client/InstrumentManagerTreeModel.java
b8b0943f7c3e1394d952a6c94a7ed5ebf17d368a
[ "Apache-2.0" ]
permissive
eva-xuyen/excalibur
34dbf26dbd6e615dd9f04ced77580e5751a45401
4b5bcb6c21d998ddea41b0e3ebdbb2c1f8662c54
refs/heads/master
2021-01-23T03:04:14.441013
2015-03-26T02:45:49
2015-03-26T02:45:49
32,907,024
1
2
null
null
null
null
UTF-8
Java
false
false
41,337
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. * * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.excalibur.instrument.client; import java.util.ArrayList; import java.util.HashMap; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import org.apache.avalon.framework.logger.AbstractLogEnabled; /** * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> */ class InstrumentManagerTreeModel extends AbstractLogEnabled implements InstrumentManagerConnectionListener, TreeModel { private final InstrumentManagerConnection m_connection; /** The state version of the last client. */ private int m_lastClientStateVersion; private boolean m_lastConnected = false; private DefaultMutableTreeNode m_root; private ArrayList m_listeners = new ArrayList(); private TreeModelListener[] m_listenerArray; private HashMap m_elementMap = new HashMap(); private HashMap m_leasedSampleMap = new HashMap(); private DefaultMutableTreeNode[] m_leasedSampleArray; /*--------------------------------------------------------------- * Constructors *-------------------------------------------------------------*/ InstrumentManagerTreeModel( InstrumentManagerConnection connection ) { m_connection = connection; m_root = new DefaultMutableTreeNode( "Root" ); } /*--------------------------------------------------------------- * InstrumentManagerConnectionListener Methods *-------------------------------------------------------------*/ /** * Called when the connection is opened. May be called more than once if * the connection to the InstrumentManager is reopened. * * @param connection Connection which was opened. */ public void opened( InstrumentManagerConnection connection ) { getLogger().debug( "InstrumentManagerTreeModel.opened(" + connection + ")" ); refreshModel(); } /** * Called when the connection is closed. May be called more than once if * the connection to the InstrumentManager is reopened. * * @param connection Connection which was closed. */ public void closed( InstrumentManagerConnection connection ) { getLogger().debug( "InstrumentManagerTreeModel.closed(" + connection + ")" ); refreshModel(); } /** * Called when the connection is deleted. All references should be removed. * * @param connection Connection which was deleted. */ public void deleted( InstrumentManagerConnection connection ) { getLogger().debug( "InstrumentManagerTreeModel.deleted(" + connection + ")" ); refreshModel(); } /*--------------------------------------------------------------- * TreeModel Methods *-------------------------------------------------------------*/ /** * Returns the root of the tree. Returns null only if the tree has * no nodes. * * @return the root of the tree */ public Object getRoot() { return m_root; } /** * Returns the child of <I>parent</I> at index <I>index</I> in the parent's * child array. <I>parent</I> must be a node previously obtained from * this data source. This should not return null if <i>index</i> * is a valid index for <i>parent</i> (that is <i>index</i> >= 0 && * <i>index</i> < getChildCount(<i>parent</i>)). * * @param parent a node in the tree, obtained from this data source * @return the child of <I>parent</I> at index <I>index</I> */ public Object getChild( Object parent, int index ) { //getLogger.debug("InstrumentManagerTreeModel.getChild(" + parent + ", " + index + ")"); if ( parent instanceof DefaultMutableTreeNode ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent; return node.getChildAt( index ); } else { return "---"; } } /** * Returns the number of children of <I>parent</I>. Returns 0 if the node * is a leaf or if it has no children. <I>parent</I> must be a node * previously obtained from this data source. * * @param parent a node in the tree, obtained from this data source * @return the number of children of the node <I>parent</I> */ public int getChildCount( Object parent ) { //getLogger.debug("InstrumentManagerTreeModel.getChildCount(" + parent + ")"); if ( parent instanceof DefaultMutableTreeNode ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent; return node.getChildCount(); } else { return 0; } } /** * Returns true if <I>node</I> is a leaf. It is possible for this method * to return false even if <I>node</I> has no children. A directory in a * filesystem, for example, may contain no files; the node representing * the directory is not a leaf, but it also has no children. * * @param node a node in the tree, obtained from this data source * @return true if <I>node</I> is a leaf */ public boolean isLeaf( Object node ) { //getLogger.debug("InstrumentManagerTreeModel.isLeaf(" + node + ")"); if ( node == m_root ) { // The root must always return false so that trees that do not // show their root node will display correctly. return false; } else if ( node instanceof DefaultMutableTreeNode ) { DefaultMutableTreeNode inode = (DefaultMutableTreeNode)node; return inode.isLeaf(); } else { return true; } } /** * Messaged when the user has altered the value for the item identified * by <I>path</I> to <I>newValue</I>. If <I>newValue</I> signifies * a truly new value the model should post a treeNodesChanged * event. * * @param path path to the node that the user has altered. * @param newValue the new value from the TreeCellEditor. */ public void valueForPathChanged( TreePath path, Object newValue ) { //getLogger.debug( "InstrumentManagerTreeModel.valueForPathChanged(" + path + // ", " + newValue + ")" ); } /** * Returns the index of child in parent. */ public int getIndexOfChild( Object parent, Object child ) { //getLogger.debug("InstrumentManagerTreeModel.getIndexOfChild(" + parent + ", " + child + ")"); if ( parent instanceof DefaultMutableTreeNode ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent; return node.getIndex( (DefaultMutableTreeNode)child ); } else { return 0; } } /** * Adds a listener for the TreeModelEvent posted after the tree changes. * * @param listener the listener to add */ public void addTreeModelListener( TreeModelListener listener ) { //getLogger.debug("InstrumentManagerTreeModel.addTreeModelListener(" + listener + ")"); synchronized(this) { m_listeners.add( listener ); m_listenerArray = null; } } /** * Removes a listener previously added with <B>addTreeModelListener()</B>. * * @param listener the listener to remove */ public void removeTreeModelListener( TreeModelListener listener ) { //getLogger.debug("InstrumentManagerTreeModel.removeTreeModelListener(" + listener + ")"); synchronized(this) { m_listeners.remove( listener ); m_listenerArray = null; } } /*--------------------------------------------------------------- * Methods *-------------------------------------------------------------*/ /** * Returns an optimized array of the registered TreeModelListeners. * * @return An array of the registered TreeModelListeners */ private TreeModelListener[] getListeners() { TreeModelListener[] listeners = m_listenerArray; if ( listeners == null ) { synchronized(this) { m_listenerArray = new TreeModelListener[ m_listeners.size() ]; m_listeners.toArray( m_listenerArray ); listeners = m_listenerArray; } } return listeners; } private void fireTreeNodesChanged( TreeModelEvent event ) { TreeModelListener[] listeners = getListeners(); for ( int i = 0; i < listeners.length; i++ ) { listeners[i].treeNodesChanged( event ); } } private void fireTreeNodesInserted( TreeModelEvent event ) { TreeModelListener[] listeners = getListeners(); for ( int i = 0; i < listeners.length; i++ ) { listeners[i].treeNodesInserted( event ); } } private void fireTreeNodesRemoved( TreeModelEvent event ) { TreeModelListener[] listeners = getListeners(); for ( int i = 0; i < listeners.length; i++ ) { listeners[i].treeNodesRemoved( event ); } } private void fireTreeStructureChanged( TreeModelEvent event ) { TreeModelListener[] listeners = getListeners(); for ( int i = 0; i < listeners.length; i++ ) { listeners[i].treeStructureChanged( event ); } } /** * Returns a TreeNode for an Instrumentable given its name. * * @param name Name of the Instrumentable. * * @return The named TreeNode. */ public DefaultMutableTreeNode getInstrumentableTreeNode( String name ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)m_elementMap.get( name ); if ( node != null ) { Object element = node.getUserObject(); if ( element instanceof InstrumentableNodeData ) { return node; } } return null; } /** * Returns a TreeNode for an Instrument given its name. * * @param name Name of the Instrument. * * @return The named TreeNode. */ public DefaultMutableTreeNode getInstrumentTreeNode( String name ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)m_elementMap.get( name ); if ( node != null ) { Object element = node.getUserObject(); if ( element instanceof InstrumentNodeData ) { return node; } } return null; } /** * Returns a TreeNode for an InstrumentSample given its name. * * @param name Name of the InstrumentSample. * * @return The named TreeNode. */ public DefaultMutableTreeNode getInstrumentSampleTreeNode( String name ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)m_elementMap.get( name ); if ( node != null ) { Object element = node.getUserObject(); if ( element instanceof InstrumentSampleNodeData ) { return node; } } return null; } /** * Returns an optimized array of TreeNodes representing the leased * instrument samples in this tree model. * * @return An array of TreeNodes for the leased instrument samples * in the TreeModel. */ private DefaultMutableTreeNode[] getLeasedSampleArray() { DefaultMutableTreeNode[] leasedSampleArray = m_leasedSampleArray; if ( leasedSampleArray == null ) { synchronized(this) { m_leasedSampleArray = new DefaultMutableTreeNode[ m_leasedSampleMap.size() ]; m_leasedSampleMap.values().toArray( m_leasedSampleArray ); leasedSampleArray = m_leasedSampleArray; } } return leasedSampleArray; } /** * Once a minute, all of the leased samples should be updated. This is * necessary to get the latest expiration times in case other processes * are also updating the leases. * Called from InstrumentManagerConnection.handleLeasedSamples. */ void renewAllSampleLeases() { DefaultMutableTreeNode[] leasedSampleArray = getLeasedSampleArray(); for ( int i = 0; i < leasedSampleArray.length; i++ ) { // Extract the NodeData from the TreeNode InstrumentSampleNodeData sampleNodeData = (InstrumentSampleNodeData)leasedSampleArray[i].getUserObject(); InstrumentSampleData sample = sampleNodeData.getData(); updateInstrumentSample( sample ); } } /** * Remove any instrument samples whose current leases have expired. */ void purgeExpiredSamples() { DefaultMutableTreeNode[] leasedSampleArray = getLeasedSampleArray(); for ( int i = 0; i < leasedSampleArray.length; i++ ) { // Extract the NodeData from the TreeNode InstrumentSampleNodeData sampleNodeData = (InstrumentSampleNodeData)leasedSampleArray[i].getUserObject(); //System.out.println(" check: " + sampleNodeData + " remaining " + // ( sampleNodeData.getRemainingLeaseTime() / 1000 ) + " seconds." ); if ( sampleNodeData.getRemainingLeaseTime() < 0 ) { // Update the Instrument containing the sample. DefaultMutableTreeNode instrumentTreeNode = (DefaultMutableTreeNode)leasedSampleArray[i].getParent(); InstrumentData instrumentData = ((InstrumentNodeData)instrumentTreeNode.getUserObject()).getData(); updateInstrument( instrumentData, instrumentTreeNode, -1 /*Force update*/ ); } } } /** * Refreshes the entire Tree Model with the latest information from the server. * This should be called whenever a refresh is needed, or whenever the status * of the connection to the server changes. */ void refreshModel() { // Is the connection open or not? if ( m_connection.isConnected() != m_lastConnected ) { m_root.removeAllChildren(); m_elementMap.clear(); m_leasedSampleMap.clear(); m_leasedSampleArray = null; m_lastClientStateVersion = -1; fireTreeStructureChanged( new TreeModelEvent( this, m_root.getPath() ) ); } if ( m_connection.isConnected() ) { // Need to update the child nodes. (Root Instrumentables) updateInstrumentManagerData( m_connection.getInstrumentManager(), m_root, m_lastClientStateVersion ); } m_lastConnected = m_connection.isConnected(); } /** * Called to update the local view of the InstrumentManagerData in the TreeeModel. * * @param manager The InstrumentManagerData to use for the update. * @param roorTreeNode The TreeNode representing the client. * @param oldStateVersion The state version at the time of the last update. */ private void updateInstrumentManagerData( InstrumentManagerData manager, DefaultMutableTreeNode rootTreeNode, int oldStateVersion ) { int stateVersion = manager.getStateVersion(); if ( stateVersion == oldStateVersion ) { // Already up to date. return; } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "update manager(" + manager.getName() + ") " + "state new=" + stateVersion + ", old=" + oldStateVersion ); } // The latest Instrumentables will be in the correct order. InstrumentableData[] instrumentables = manager.getInstrumentables(); int i; for ( i = 0; i < instrumentables.length; i++ ) { InstrumentableData instrumentable = instrumentables[i]; int oldInstrumentableStateVersion = -1; DefaultMutableTreeNode newChild = null; int childCount = rootTreeNode.getChildCount(); if ( i < childCount ) { int cmp; do { DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)rootTreeNode.getChildAt( i ); cmp = ((InstrumentableNodeData)oldChild.getUserObject()).getDescription(). compareTo( instrumentable.getDescription() ); if ( cmp == 0 ) { // This is the same object. InstrumentableNodeData nodeData = (InstrumentableNodeData)oldChild.getUserObject(); oldInstrumentableStateVersion = nodeData.getStateVersion(); if ( nodeData.update() ) { // The contents of the node changed. fireTreeNodesChanged( new TreeModelEvent( this, rootTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); } newChild = oldChild; // Node already in the elementMap } else if ( cmp > 0 ) { // Need to insert a new node. newChild = new DefaultMutableTreeNode( new InstrumentableNodeData( instrumentable ), true ); rootTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, rootTreeNode.getPath(),new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentableNodeData)newChild.getUserObject()). getName(), newChild ); } else if ( cmp < 0 ) { // Need to remove an old node. rootTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, rootTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentableNodeData)oldChild.getUserObject()). getName() ); } } while ( cmp < 0 ); } else { // Append the new descriptor newChild = new DefaultMutableTreeNode( new InstrumentableNodeData( instrumentable ), true ); rootTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, rootTreeNode.getPath(), new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentableNodeData)newChild.getUserObject()). getName(), newChild ); } updateInstrumentable( instrumentable, newChild, oldInstrumentableStateVersion ); } // Remove any remaining old nodes while ( i < rootTreeNode.getChildCount() ) { // Need to remove an old node. DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)rootTreeNode.getChildAt( i ); rootTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, rootTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentableNodeData)oldChild.getUserObject()). getName() ); } m_lastClientStateVersion = stateVersion; } /** * @param instrumentableData The Instrumentable to update. * @param instrumentableTreeNode The tree node of the Instrumentable to * update. * @param oldStateVersion The state version at the time of the last update. */ private void updateInstrumentable( InstrumentableData instrumentableData, DefaultMutableTreeNode instrumentableTreeNode, int oldStateVersion ) { int stateVersion = instrumentableData.getStateVersion(); if ( stateVersion == oldStateVersion ) { // Already up to date. return; } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "update instrumentable(" + instrumentableData.getName() + ") " + "state new=" + stateVersion + ", old=" + oldStateVersion ); } // The latest Instrumentables will be in the correct order. InstrumentableData[] childInstrumentables = instrumentableData.getInstrumentables(); //System.out.println("Model.updateInstumentable() " + instrumentableData.getName() + " " + childInstrumentables.length); int i; for ( i = 0; i < childInstrumentables.length; i++ ) { InstrumentableData childInstrumentable = childInstrumentables[i]; int oldInstrumentableStateVersion = -1; //System.out.println(" " + childInstrumentable.getName() ); DefaultMutableTreeNode newChild = null; int childCount = instrumentableTreeNode.getChildCount(); if ( i < childCount ) { int cmp; do { DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentableTreeNode.getChildAt( i ); if ( oldChild.getUserObject() instanceof InstrumentableNodeData ) { cmp = ((InstrumentableNodeData)oldChild.getUserObject()).getDescription(). compareTo( childInstrumentable.getDescription() ); } else { // Always put Instrumentables before any other nodes. cmp = 1; } if ( cmp == 0 ) { // This is the same object. InstrumentableNodeData nodeData = (InstrumentableNodeData)oldChild.getUserObject(); oldInstrumentableStateVersion = nodeData.getStateVersion(); if ( nodeData.update() ) { // The contents of the node changed. fireTreeNodesChanged( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); } newChild = oldChild; // Node already in the elementMap } else if ( cmp > 0 ) { // Need to insert a new node. newChild = new DefaultMutableTreeNode( new InstrumentableNodeData( childInstrumentable ), true ); instrumentableTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentableTreeNode.getPath(),new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentableNodeData)newChild.getUserObject()). getName(), newChild ); } else if ( cmp < 0 ) { // Need to remove an old node. instrumentableTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentableNodeData)oldChild.getUserObject()). getName() ); } } while ( cmp < 0 ); } else { // Append the new descriptor newChild = new DefaultMutableTreeNode( new InstrumentableNodeData( childInstrumentable ), true ); instrumentableTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentableNodeData)newChild.getUserObject()). getName(), newChild ); } updateInstrumentable( childInstrumentable, newChild, oldInstrumentableStateVersion ); } // Remove any remaining old Instrumentable nodes while ( i < instrumentableTreeNode.getChildCount() ) { // Need to remove an old node. DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentableTreeNode.getChildAt( i ); if ( !( oldChild.getUserObject() instanceof InstrumentableNodeData ) ) { break; } instrumentableTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentableNodeData)oldChild.getUserObject()). getName() ); } // The latest Instruments will be in the correct order. InstrumentData[] instruments = instrumentableData.getInstruments(); for ( i = childInstrumentables.length; i < instruments.length + childInstrumentables.length; i++ ) { InstrumentData instrument = instruments[i - childInstrumentables.length]; int oldInstrumentStateVersion = -1; //System.out.println(" " + instrument.getName() ); DefaultMutableTreeNode newChild = null; int childCount = instrumentableTreeNode.getChildCount(); if ( i < childCount ) { int cmp; do { DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentableTreeNode.getChildAt( i ); if ( oldChild.getUserObject() instanceof InstrumentNodeData ) { cmp = ((InstrumentNodeData)oldChild.getUserObject()).getDescription(). compareTo( instrument.getDescription() ); } else { // Always put Instrumentables before any other nodes. cmp = 1; } if ( cmp == 0 ) { // This is the same object. InstrumentNodeData nodeData = (InstrumentNodeData)oldChild.getUserObject(); oldInstrumentStateVersion = nodeData.getStateVersion(); if ( nodeData.update() ) { // The contents of the node changed. fireTreeNodesChanged( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); } newChild = oldChild; // Node already in the elementMap } else if ( cmp > 0 ) { // Need to insert a new node. newChild = new DefaultMutableTreeNode( new InstrumentNodeData( instrument, m_connection ), true ); instrumentableTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentableTreeNode.getPath(),new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentNodeData)newChild.getUserObject()). getName(), newChild ); } else if ( cmp < 0 ) { // Need to remove an old node. instrumentableTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentNodeData)oldChild.getUserObject()). getName() ); } } while ( cmp < 0 ); } else { // Append the new descriptor newChild = new DefaultMutableTreeNode( new InstrumentNodeData( instrument, m_connection ), true ); instrumentableTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap m_elementMap.put( ((InstrumentNodeData)newChild.getUserObject()). getName(), newChild ); } updateInstrument( instrument, newChild, oldInstrumentStateVersion ); } // Remove any remaining old Instrument nodes while ( i < instrumentableTreeNode.getChildCount() ) { // Need to remove an old node. DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentableTreeNode.getChildAt( i ); instrumentableTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentableTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap m_elementMap.remove( ((InstrumentNodeData)oldChild.getUserObject()). getName() ); } } /** * @param instrumentData The Instrument to update. */ void updateInstrument( InstrumentData instrumentData ) { // Find the tree node. DefaultMutableTreeNode instrumentTreeNode = getInstrumentTreeNode( instrumentData.getName() ); if ( instrumentTreeNode != null ) { updateInstrument( instrumentData, instrumentTreeNode, -1 /* Force update */ ); } } /** * @param instrumentData The Instrument to update. * @param instrumentTreeNode The tree node of the Instrument to update. */ void updateInstrument( InstrumentData instrumentData, DefaultMutableTreeNode instrumentTreeNode, int oldStateVersion ) { int stateVersion = instrumentData.getStateVersion(); if ( stateVersion == oldStateVersion ) { // Already up to date. return; } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "update instrument(" + instrumentData.getName() + ") " + "state new=" + stateVersion + ", old=" + oldStateVersion ); } // The latest Instrument Samples will be in the correct order. InstrumentSampleData[] samples = instrumentData.getInstrumentSamples(); //System.out.println("Model.updateInstument() " + instrumentDescriptor.getName() + " " + descriptors.length); int i; for ( i = 0; i < samples.length; i++ ) { InstrumentSampleData sample = samples[i]; //System.out.println(" " + sample.getName() ); DefaultMutableTreeNode newChild = null; int childCount = instrumentTreeNode.getChildCount(); if ( i < childCount ) { int cmp; do { // Old child will always be a sample DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentTreeNode.getChildAt( i ); cmp = ((InstrumentSampleNodeData)oldChild.getUserObject()). getDescription().compareTo( sample.getDescription() ); if ( cmp == 0 ) { // This is the same object. if ( ((InstrumentSampleNodeData)oldChild.getUserObject()).update() ) { // The contents of the node changed. fireTreeNodesChanged( new TreeModelEvent( this, instrumentTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); } newChild = oldChild; // Node already in the elementMap } else if ( cmp > 0 ) { // Need to insert a new node. newChild = new DefaultMutableTreeNode( new InstrumentSampleNodeData( instrumentData.getName(), sample, m_connection ), true ); instrumentTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentTreeNode.getPath(),new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap InstrumentSampleNodeData newNodeData = (InstrumentSampleNodeData)newChild.getUserObject(); String sampleName = newNodeData.getName(); m_elementMap.put( sampleName, newChild ); if ( newNodeData.isLeased() ) { m_leasedSampleMap.put( sampleName, newChild ); m_leasedSampleArray = null; } // Make sure that the maintained flag is set correctly MaintainedSampleLease lease = m_connection.getMaintainedSampleLease( sampleName ); if ( lease != null ) { newNodeData.setLeaseDuration( lease.getLeaseDuration() ); } } else if ( cmp < 0 ) { // Need to remove an old node. instrumentTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap InstrumentSampleNodeData oldNodeData = (InstrumentSampleNodeData)oldChild.getUserObject(); String sampleName = oldNodeData.getName(); m_elementMap.remove( sampleName ); if ( oldNodeData.isLeased() ) { m_leasedSampleMap.remove( sampleName ); m_leasedSampleArray = null; } } } while ( cmp < 0 ); } else { // Append the new descriptor newChild = new DefaultMutableTreeNode( new InstrumentSampleNodeData( instrumentData.getName(), sample, m_connection ), true ); instrumentTreeNode.insert( newChild, i ); fireTreeNodesInserted( new TreeModelEvent( this, instrumentTreeNode.getPath(), new int[] { i }, new Object[] { newChild } ) ); // Add the new node to the elementMap InstrumentSampleNodeData newNodeData = (InstrumentSampleNodeData)newChild.getUserObject(); String sampleName = newNodeData.getName(); m_elementMap.put( sampleName, newChild ); if ( newNodeData.isLeased() ) { m_leasedSampleMap.put( sampleName, newChild ); m_leasedSampleArray = null; } // Make sure that the maintained flag is set correctly MaintainedSampleLease lease = m_connection.getMaintainedSampleLease( sampleName ); if ( lease != null ) { newNodeData.setLeaseDuration( lease.getLeaseDuration() ); } } } // Remove any remaining old Instrument Sample nodes while ( i < instrumentTreeNode.getChildCount() ) { // Need to remove an old node. DefaultMutableTreeNode oldChild = (DefaultMutableTreeNode)instrumentTreeNode.getChildAt( i ); instrumentTreeNode.remove( i ); fireTreeNodesRemoved( new TreeModelEvent( this, instrumentTreeNode.getPath(), new int[] { i }, new Object[] { oldChild } ) ); // Remove the old node from the elementMap InstrumentSampleNodeData oldNodeData = (InstrumentSampleNodeData)oldChild.getUserObject(); String sampleName = oldNodeData.getName(); m_elementMap.remove( sampleName ); if ( oldNodeData.isLeased() ) { m_leasedSampleMap.remove( sampleName ); m_leasedSampleArray = null; } } } /** * @param sampleData The Instrument Sample to update. */ void updateInstrumentSample( InstrumentSampleData sampleData ) { // Find the tree node. DefaultMutableTreeNode sampleTreeNode = getInstrumentSampleTreeNode( sampleData.getName() ); if ( sampleTreeNode != null ) { updateInstrumentSample( sampleData, sampleTreeNode ); } } /** * @param sampleData The Instrument Sample to update. * @param sampleTreeNode The tree node of the Instrument Sample to update. */ void updateInstrumentSample( InstrumentSampleData sampleData, DefaultMutableTreeNode sampleTreeNode ) { // An update here should always lead to an event being fired. ((InstrumentSampleNodeData)sampleTreeNode.getUserObject()).update(); // The contents of the node changed. fireTreeNodesChanged( new TreeModelEvent( this, sampleTreeNode.getPath(), new int[ 0 ], new Object[ 0 ] ) ); } }
[ "root@mycompany.com" ]
root@mycompany.com
735b5e108a68a6b5f21d61605c87c9ef97e06a22
bb7f8a1b64fdeb1d374022c0d24e975178cbf4c7
/uikit/src/com/netease/nim/uikit/team/activity/AdvancedTeamInfoActivity.java
c57264bda9e3496651086b4bf53a0e1e0c9de624
[]
no_license
er-rousy/meet-andoid
09c746c8c1b0e8ea82745616866efea333f9e76b
bd4e5b36be2c67360240ba7852ad9299b2759cd9
refs/heads/master
2022-03-30T04:09:32.832225
2020-01-08T01:24:17
2020-01-08T01:24:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
54,918
java
package com.netease.nim.uikit.team.activity; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.AbsListView; import android.widget.TextView; import android.widget.Toast; import com.netease.nim.uikit.NimUIKit; import com.netease.nim.uikit.R; import com.netease.nim.uikit.cache.SimpleCallback; import com.netease.nim.uikit.cache.TeamDataCache; import com.netease.nim.uikit.common.activity.UI; import com.netease.nim.uikit.common.adapter.TAdapterDelegate; import com.netease.nim.uikit.common.adapter.TViewHolder; import com.netease.nim.uikit.common.media.picker.PickImageHelper; import com.netease.nim.uikit.common.ui.dialog.DialogMaker; import com.netease.nim.uikit.common.ui.dialog.MenuDialog; import com.netease.nim.uikit.common.ui.imageview.HeadImageView; import com.netease.nim.uikit.common.util.log.LogUtil; import com.netease.nim.uikit.common.util.sys.TimeUtil; import com.netease.nim.uikit.contact.core.item.ContactIdFilter; import com.netease.nim.uikit.contact_selector.activity.ContactSelectActivity; import com.netease.nim.uikit.model.ToolBarOptions; import com.netease.nim.uikit.session.actions.PickImageAction; import com.netease.nim.uikit.team.adapter.TeamMemberAdapter; import com.netease.nim.uikit.team.adapter.TeamMemberAdapter.TeamMemberItem; import com.netease.nim.uikit.team.helper.AnnouncementHelper; import com.netease.nim.uikit.team.helper.TeamHelper; import com.netease.nim.uikit.team.model.Announcement; import com.netease.nim.uikit.team.ui.TeamInfoGridView; import com.netease.nim.uikit.team.viewholder.TeamMemberHolder; import com.netease.nim.uikit.uinfo.UserInfoHelper; import com.netease.nim.uikit.uinfo.UserInfoObservable; import com.netease.nimlib.sdk.AbortableFuture; import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.RequestCallback; import com.netease.nimlib.sdk.RequestCallbackWrapper; import com.netease.nimlib.sdk.ResponseCode; import com.netease.nimlib.sdk.nos.NosService; import com.netease.nimlib.sdk.team.TeamService; import com.netease.nimlib.sdk.team.constant.TeamBeInviteModeEnum; import com.netease.nimlib.sdk.team.constant.TeamFieldEnum; import com.netease.nimlib.sdk.team.constant.TeamInviteModeEnum; import com.netease.nimlib.sdk.team.constant.TeamMemberType; import com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum; import com.netease.nimlib.sdk.team.constant.TeamUpdateModeEnum; import com.netease.nimlib.sdk.team.constant.VerifyTypeEnum; import com.netease.nimlib.sdk.team.model.Team; import com.netease.nimlib.sdk.team.model.TeamMember; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 高级群群资料页 * Created by huangjun on 2015/3/17. */ public class AdvancedTeamInfoActivity extends UI implements TAdapterDelegate, TeamMemberAdapter.AddMemberCallback, TeamMemberHolder.TeamMemberHolderEventListener { private static final int REQUEST_CODE_TRANSFER = 101; private static final int REQUEST_CODE_MEMBER_LIST = 102; private static final int REQUEST_CODE_CONTACT_SELECT = 103; private static final int REQUEST_PICK_ICON = 104; private static final int ICON_TIME_OUT = 30000; // constant private static final String TAG = "RegularTeamInfoActivity"; private static final String EXTRA_ID = "EXTRA_ID"; public static final String RESULT_EXTRA_REASON = "RESULT_EXTRA_REASON"; public static final String RESULT_EXTRA_REASON_QUIT = "RESULT_EXTRA_REASON_QUIT"; public static final String RESULT_EXTRA_REASON_DISMISS = "RESULT_EXTRA_REASON_DISMISS"; private static final int TEAM_MEMBERS_SHOW_LIMIT = 5; // data private TeamMemberAdapter adapter; private String teamId; private Team team; private String creator; private List<String> memberAccounts; private List<TeamMember> members; private List<TeamMemberAdapter.TeamMemberItem> dataSource; private MenuDialog dialog; private MenuDialog authenDialog; private MenuDialog inviteDialog; private MenuDialog teamInfoUpdateDialog; private MenuDialog teamInviteeDialog; private MenuDialog teamNotifyDialog; private List<String> managerList; private UserInfoObservable.UserInfoObserver userInfoObserver; private AbortableFuture<String> uploadFuture; // view private View headerLayout; private HeadImageView teamHeadImage; private TextView teamNameText; private TextView teamIdText; private TextView teamCreateTimeText; private TextView teamBusinessCard; // 我的群名片 private View layoutMime; private View layoutTeamMember; private TeamInfoGridView gridView; private View layoutTeamName; private View layoutTeamIntroduce; private View layoutTeamAnnouncement; private View layoutTeamExtension; private View layoutAuthentication; private View layoutNotificationConfig; // 邀请他人权限 private View layoutInvite; private TextView inviteText; // 群资料修改权限 private View layoutInfoUpdate; private TextView infoUpdateText; // 被邀请人身份验证权限 private View layoutInviteeAuthen; private TextView inviteeAutenText; private TextView memberCountText; private TextView introduceEdit; private TextView announcementEdit; private TextView extensionTextView; private TextView authenticationText; private TextView notificationConfigText; // state private boolean isSelfAdmin = false; private boolean isSelfManager = false; public static void start(Context context, String tid) { Intent intent = new Intent(); intent.putExtra(EXTRA_ID, tid); intent.setClass(context, AdvancedTeamInfoActivity.class); context.startActivity(intent); } /** * ************************ TAdapterDelegate ************************** */ @Override public int getViewTypeCount() { return 1; } @Override public Class<? extends TViewHolder> viewHolderAtPosition(int position) { return TeamMemberHolder.class; } @Override public boolean enabled(int position) { return false; } /** * ***************************** Life cycle ***************************** */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nim_advanced_team_info_activity); ToolBarOptions options = new ToolBarOptions(); setToolBar(R.id.toolbar, options); parseIntentData(); findViews(); initActionbar(); initAdapter(); loadTeamInfo(); requestMembers(); registerObservers(true); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { return; } switch (requestCode) { case REQUEST_CODE_CONTACT_SELECT: final ArrayList<String> selected = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA); if (selected != null && !selected.isEmpty()) { inviteMembers(selected); } break; case REQUEST_CODE_TRANSFER: final ArrayList<String> target = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA); if (target != null && !target.isEmpty()) { transferTeam(target.get(0)); } break; case AdvancedTeamNicknameActivity.REQ_CODE_TEAM_NAME: setBusinessCard(data.getStringExtra(AdvancedTeamNicknameActivity.EXTRA_NAME)); break; case AdvancedTeamMemberInfoActivity.REQ_CODE_REMOVE_MEMBER: boolean isSetAdmin = data.getBooleanExtra(AdvancedTeamMemberInfoActivity.EXTRA_ISADMIN, false); boolean isRemoveMember = data.getBooleanExtra(AdvancedTeamMemberInfoActivity.EXTRA_ISREMOVE, false); String account = data.getStringExtra(EXTRA_ID); refreshAdmin(isSetAdmin, account); if (isRemoveMember) { removeMember(account); } break; case REQUEST_CODE_MEMBER_LIST: boolean isMemberChange = data.getBooleanExtra(AdvancedTeamMemberActivity.EXTRA_DATA, false); if (isMemberChange) { requestMembers(); } break; case REQUEST_PICK_ICON: String path = data.getStringExtra(com.netease.nim.uikit.session.constant.Extras.EXTRA_FILE_PATH); updateTeamIcon(path); break; default: break; } } @Override protected void onDestroy() { if (dialog != null) { dialog.dismiss(); } if (authenDialog != null) { authenDialog.dismiss(); } registerObservers(false); super.onDestroy(); } private void parseIntentData() { teamId = getIntent().getStringExtra(EXTRA_ID); } private void findViews() { headerLayout = findViewById(R.id.team_info_header); headerLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showSelector(R.string.set_head_image, REQUEST_PICK_ICON); } }); teamHeadImage = (HeadImageView) findViewById(R.id.team_head_image); teamNameText = (TextView) findViewById(R.id.team_name); teamIdText = (TextView) findViewById(R.id.team_id); teamCreateTimeText = (TextView) findViewById(R.id.team_create_time); layoutMime = findViewById(R.id.team_mime_layout); ((TextView) layoutMime.findViewById(R.id.item_title)).setText(R.string.my_team_card); teamBusinessCard = (TextView) layoutMime.findViewById(R.id.item_detail); layoutMime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AdvancedTeamNicknameActivity.start(AdvancedTeamInfoActivity.this, teamBusinessCard.getText().toString()); } }); layoutTeamMember = findViewById(R.id.team_memeber_layout); ((TextView) layoutTeamMember.findViewById(R.id.item_title)).setText(R.string.team_member); memberCountText = (TextView) layoutTeamMember.findViewById(R.id.item_detail); gridView = (TeamInfoGridView) findViewById(R.id.team_member_grid_view); layoutTeamMember.setVisibility(View.GONE); gridView.setVisibility(View.GONE); memberCountText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AdvancedTeamMemberActivity.startActivityForResult(AdvancedTeamInfoActivity.this, teamId, REQUEST_CODE_MEMBER_LIST); } }); layoutTeamName = findViewById(R.id.team_name_layout); ((TextView) layoutTeamName.findViewById(R.id.item_title)).setText(R.string.team_name); layoutTeamName.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TeamPropertySettingActivity.start(AdvancedTeamInfoActivity.this, teamId, TeamFieldEnum.Name, team.getName()); } }); layoutTeamIntroduce = findViewById(R.id.team_introduce_layout); ((TextView) layoutTeamIntroduce.findViewById(R.id.item_title)).setText(R.string.team_introduce); introduceEdit = ((TextView) layoutTeamIntroduce.findViewById(R.id.item_detail)); introduceEdit.setHint(R.string.team_introduce_hint); layoutTeamIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TeamPropertySettingActivity.start(AdvancedTeamInfoActivity.this, teamId, TeamFieldEnum.Introduce, team.getIntroduce()); } }); layoutTeamAnnouncement = findViewById(R.id.team_announcement_layout); ((TextView) layoutTeamAnnouncement.findViewById(R.id.item_title)).setText(R.string.team_annourcement); announcementEdit = ((TextView) layoutTeamAnnouncement.findViewById(R.id.item_detail)); announcementEdit.setHint(R.string.team_announce_hint); layoutTeamAnnouncement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AdvancedTeamAnnounceActivity.start(AdvancedTeamInfoActivity.this, teamId); } }); layoutTeamExtension = findViewById(R.id.team_extension_layout); ((TextView) layoutTeamExtension.findViewById(R.id.item_title)).setText(R.string.team_extension); extensionTextView = ((TextView) layoutTeamExtension.findViewById(R.id.item_detail)); extensionTextView.setHint(R.string.team_extension_hint); layoutTeamExtension.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TeamPropertySettingActivity.start(AdvancedTeamInfoActivity.this, teamId, TeamFieldEnum.Extension, team.getExtension()); } }); // 群消息提醒设置 initNotify(); // 身份验证 findLayoutAuthentication(); // 邀请他人权限 findLayoutInvite(); // 群资料修改权限 findLayoutInfoUpdate(); // 被邀请人身份验证 findLayoutInviteeAuthen(); } /** * 打开图片选择器 */ private void showSelector(int titleId, final int requestCode) { PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption(); option.titleResId = titleId; option.multiSelect = false; option.crop = true; option.cropOutputImageWidth = 720; option.cropOutputImageHeight = 720; PickImageHelper.pickImage(AdvancedTeamInfoActivity.this, requestCode, option); } /** * 群消息提醒设置 */ private void initNotify() { layoutNotificationConfig = findViewById(R.id.team_notification_config_layout); ((TextView) layoutNotificationConfig.findViewById(R.id.item_title)).setText(R.string.team_notification_config); notificationConfigText = (TextView) layoutNotificationConfig.findViewById(R.id.item_detail); layoutNotificationConfig.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTeamNotifyMenu(); } }); } /** * 身份验证布局初始化 */ private void findLayoutAuthentication() { layoutAuthentication = findViewById(R.id.team_authentication_layout); layoutAuthentication.setVisibility(View.GONE); ((TextView) layoutAuthentication.findViewById(R.id.item_title)).setText(R.string.team_authentication); authenticationText = ((TextView) layoutAuthentication.findViewById(R.id.item_detail)); layoutAuthentication.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTeamAuthenMenu(); } }); } /** * 邀请他人权限布局初始化 */ private void findLayoutInvite() { layoutInvite = findViewById(R.id.team_invite_layout); layoutInvite.setVisibility(View.GONE); ((TextView) layoutInvite.findViewById(R.id.item_title)).setText(R.string.team_invite); inviteText = ((TextView) layoutInvite.findViewById(R.id.item_detail)); layoutInvite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTeamInviteMenu(); } }); } /** * 群资料修改权限布局初始化 */ private void findLayoutInfoUpdate() { layoutInfoUpdate = findViewById(R.id.team_info_update_layout); layoutInfoUpdate.setVisibility(View.GONE); ((TextView) layoutInfoUpdate.findViewById(R.id.item_title)).setText(R.string.team_info_update); infoUpdateText = ((TextView) layoutInfoUpdate.findViewById(R.id.item_detail)); layoutInfoUpdate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTeamInfoUpdateMenu(); } }); } /** * 被邀请人身份验证布局初始化 */ private void findLayoutInviteeAuthen() { layoutInviteeAuthen = findViewById(R.id.team_invitee_authen_layout); layoutInviteeAuthen.setVisibility(View.GONE); ((TextView) layoutInviteeAuthen.findViewById(R.id.item_title)).setText(R.string.team_invitee_authentication); inviteeAutenText = ((TextView) layoutInviteeAuthen.findViewById(R.id.item_detail)); layoutInviteeAuthen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTeamInviteeAuthenMenu(); } }); } private void initActionbar() { TextView toolbarView = findView(R.id.action_bar_right_clickable_textview); toolbarView.setText(R.string.menu); toolbarView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showRegularTeamMenu(); } }); } private void initAdapter() { memberAccounts = new ArrayList<>(); members = new ArrayList<>(); dataSource = new ArrayList<>(); managerList = new ArrayList<>(); adapter = new TeamMemberAdapter(this, dataSource, this, null, this); adapter.setEventListener(this); gridView.setSelector(R.color.transparent); gridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == 0) { adapter.notifyDataSetChanged(); } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); gridView.setAdapter(adapter); } /** * 初始化群组基本信息 */ private void loadTeamInfo() { Team t = TeamDataCache.getInstance().getTeamById(teamId); if (t != null) { updateTeamInfo(t); } else { TeamDataCache.getInstance().fetchTeamById(teamId, new SimpleCallback<Team>() { @Override public void onResult(boolean success, Team result) { if (success && result != null) { updateTeamInfo(result); } else { onGetTeamInfoFailed(); } } }); } } private void onGetTeamInfoFailed() { Toast.makeText(this, getString(R.string.team_not_exist), Toast.LENGTH_SHORT).show(); finish(); } /** * 更新群信息 * * @param t */ private void updateTeamInfo(final Team t) { this.team = t; if (team == null) { Toast.makeText(this, getString(R.string.team_not_exist), Toast.LENGTH_SHORT).show(); finish(); return; } else { creator = team.getCreator(); if (creator.equals(NimUIKit.getAccount())) { isSelfAdmin = true; } setTitle(team.getName()); } teamHeadImage.loadTeamIconByTeam(team); teamNameText.setText(team.getName()); teamIdText.setText(team.getId()); teamCreateTimeText.setText(TimeUtil.getTimeShowString(team.getCreateTime(), true)); ((TextView) layoutTeamName.findViewById(R.id.item_detail)).setText(team.getName()); introduceEdit.setText(team.getIntroduce()); extensionTextView.setText(team.getExtension()); notificationConfigText.setText(team.mute() ? "关闭" : "开启"); memberCountText.setText(String.format("共%d人", team.getMemberCount())); setAnnouncement(team.getAnnouncement()); setAuthenticationText(team.getVerifyType()); updateInviteText(team.getTeamInviteMode()); updateInfoUpateText(team.getTeamUpdateMode()); updateBeInvitedText(team.getTeamBeInviteMode()); } /** * 更新群成员信息 * * @param m */ private void updateTeamMember(final List<TeamMember> m) { if (m != null && m.isEmpty()) { return; } updateTeamBusinessCard(m); addTeamMembers(m, true); } /** * 更新我的群名片 * * @param m */ private void updateTeamBusinessCard(List<TeamMember> m) { for (TeamMember teamMember : m) { if (teamMember != null && teamMember.getAccount().equals(NimUIKit.getAccount())) { teamBusinessCard.setText(teamMember.getTeamNick() != null ? teamMember.getTeamNick() : ""); } } } /** * 添加群成员到列表 * * @param m 群成员列表 * @param clear 是否清除 */ private void addTeamMembers(final List<TeamMember> m, boolean clear) { if (m == null || m.isEmpty()) { return; } isSelfManager = false; isSelfAdmin = false; if (clear) { this.members.clear(); this.memberAccounts.clear(); } // add if (this.members.isEmpty()) { this.members.addAll(m); } else { for (TeamMember tm : m) { if (!this.memberAccounts.contains(tm.getAccount())) { this.members.add(tm); } } } // sort Collections.sort(this.members, TeamHelper.teamMemberComparator); // accounts, manager, creator this.memberAccounts.clear(); this.managerList.clear(); for (TeamMember tm : members) { if (tm == null) { continue; } if (tm.getType() == TeamMemberType.Manager) { managerList.add(tm.getAccount()); } if (tm.getAccount().equals(NimUIKit.getAccount())) { if (tm.getType() == TeamMemberType.Manager) { isSelfManager = true; } else if (tm.getType() == TeamMemberType.Owner) { isSelfAdmin = true; creator = NimUIKit.getAccount(); } } this.memberAccounts.add(tm.getAccount()); } updateAuthenView(); updateTeamMemberDataSource(); } /** * 更新身份验证是否显示 */ private void updateAuthenView() { if (isSelfAdmin || isSelfManager) { layoutAuthentication.setVisibility(View.VISIBLE); layoutInvite.setVisibility(View.VISIBLE); layoutInfoUpdate.setVisibility(View.VISIBLE); layoutInviteeAuthen.setVisibility(View.VISIBLE); announcementEdit.setHint(R.string.without_content); } else { layoutAuthentication.setVisibility(View.GONE); layoutInvite.setVisibility(View.GONE); layoutInfoUpdate.setVisibility(View.GONE); layoutInviteeAuthen.setVisibility(View.GONE); introduceEdit.setHint(R.string.without_content); announcementEdit.setHint(R.string.without_content); } } /** * 更新成员信息 */ private void updateTeamMemberDataSource() { if (members.size() > 0) { gridView.setVisibility(View.VISIBLE); layoutTeamMember.setVisibility(View.VISIBLE); } else { gridView.setVisibility(View.GONE); layoutTeamMember.setVisibility(View.GONE); return; } dataSource.clear(); // add item if (team.getTeamInviteMode() == TeamInviteModeEnum.All || isSelfAdmin || isSelfManager) { dataSource.add(new TeamMemberAdapter.TeamMemberItem(TeamMemberAdapter.TeamMemberItemTag.ADD, null, null, null)); } // member item int count = 0; String identity = null; for (String account : memberAccounts) { int limit = TEAM_MEMBERS_SHOW_LIMIT; if (team.getTeamInviteMode() == TeamInviteModeEnum.All || isSelfAdmin || isSelfManager) { limit = TEAM_MEMBERS_SHOW_LIMIT - 1; } if (count < limit) { identity = getIdentity(account); dataSource.add(new TeamMemberAdapter.TeamMemberItem(TeamMemberAdapter.TeamMemberItemTag .NORMAL, teamId, account, identity)); } count++; } // refresh adapter.notifyDataSetChanged(); memberCountText.setText(String.format("共%d人", count)); } private String getIdentity(String account) { String identity; if (creator.equals(account)) { identity = TeamMemberHolder.OWNER; } else if (managerList.contains(account)) { identity = TeamMemberHolder.ADMIN; } else { identity = null; } return identity; } /** * *************************** 加载&变更数据源 ******************************** */ private void requestMembers() { TeamDataCache.getInstance().fetchTeamMemberList(teamId, new SimpleCallback<List<TeamMember>>() { @Override public void onResult(boolean success, List<TeamMember> members) { if (success && members != null && !members.isEmpty()) { updateTeamMember(members); } } }); } /** * ************************** 群信息变更监听 ************************** */ /** * 注册群信息更新监听 * * @param register */ private void registerObservers(boolean register) { if (register) { TeamDataCache.getInstance().registerTeamMemberDataChangedObserver(teamMemberObserver); TeamDataCache.getInstance().registerTeamDataChangedObserver(teamDataObserver); } else { TeamDataCache.getInstance().unregisterTeamMemberDataChangedObserver(teamMemberObserver); TeamDataCache.getInstance().unregisterTeamDataChangedObserver(teamDataObserver); } registerUserInfoChangedObserver(register); } TeamDataCache.TeamMemberDataChangedObserver teamMemberObserver = new TeamDataCache.TeamMemberDataChangedObserver() { @Override public void onUpdateTeamMember(List<TeamMember> m) { for (TeamMember mm : m) { for (TeamMember member : members) { if (mm.getAccount().equals(member.getAccount())) { members.set(members.indexOf(member), mm); break; } } } addTeamMembers(m, false); } @Override public void onRemoveTeamMember(List<TeamMember> members) { for (TeamMember member : members) { removeMember(member.getAccount()); } } }; TeamDataCache.TeamDataChangedObserver teamDataObserver = new TeamDataCache.TeamDataChangedObserver() { @Override public void onUpdateTeams(List<Team> teams) { for (Team team : teams) { if (team.getId().equals(teamId)) { updateTeamInfo(team); updateTeamMemberDataSource(); break; } } } @Override public void onRemoveTeam(Team team) { if (team.getId().equals(teamId)) { AdvancedTeamInfoActivity.this.team = team; finish(); } } }; /** * ******************************* Action ********************************* */ /** * 从联系人选择器发起邀请成员 */ @Override public void onAddMember() { ContactSelectActivity.Option option = TeamHelper.getContactSelectOption(memberAccounts); NimUIKit.startContactSelect(AdvancedTeamInfoActivity.this, option, REQUEST_CODE_CONTACT_SELECT); } /** * 从联系人选择器选择群转移对象 */ private void onTransferTeam() { if (memberAccounts.size() <= 1) { Toast.makeText(AdvancedTeamInfoActivity.this, R.string.team_transfer_without_member, Toast.LENGTH_SHORT) .show(); return; } ContactSelectActivity.Option option = new ContactSelectActivity.Option(); option.title = "选择群转移的对象"; option.type = ContactSelectActivity.ContactSelectType.TEAM_MEMBER; option.teamId = teamId; option.multi = false; option.maxSelectNum = 1; ArrayList<String> includeAccounts = new ArrayList<>(); includeAccounts.addAll(memberAccounts); option.itemFilter = new ContactIdFilter(includeAccounts, false); NimUIKit.startContactSelect(this, option, REQUEST_CODE_TRANSFER); dialog.dismiss(); } /** * 邀请群成员 * * @param accounts 邀请帐号 */ private void inviteMembers(ArrayList<String> accounts) { NIMClient.getService(TeamService.class).addMembers(teamId, accounts).setCallback(new RequestCallback<List<String>>() { @Override public void onSuccess(List<String> failedAccounts) { if (failedAccounts == null || failedAccounts.isEmpty()) { Toast.makeText(AdvancedTeamInfoActivity.this, "添加群成员成功", Toast.LENGTH_SHORT).show(); } else { TeamHelper.onMemberTeamNumOverrun(failedAccounts, AdvancedTeamInfoActivity.this); } } @Override public void onFailed(int code) { if (code == ResponseCode.RES_TEAM_INVITE_SUCCESS) { Toast.makeText(AdvancedTeamInfoActivity.this, R.string.team_invite_members_success, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AdvancedTeamInfoActivity.this, "invite members failed, code=" + code, Toast.LENGTH_SHORT).show(); Log.e(TAG, "invite members failed, code=" + code); } } @Override public void onException(Throwable exception) { } }); } private void showTeamNotifyMenu() { if (teamNotifyDialog == null) { List<String> btnNames = TeamHelper.createNotifyMenuStrings(); int type = team.getMessageNotifyType().getValue(); teamNotifyDialog = new MenuDialog(AdvancedTeamInfoActivity.this, btnNames, type, 3, new MenuDialog .MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { teamNotifyDialog.dismiss(); TeamMessageNotifyTypeEnum type = TeamHelper.getNotifyType(name); if (type == null) { return; } DialogMaker.showProgressDialog(AdvancedTeamInfoActivity.this, getString(R.string.empty), true); NIMClient.getService(TeamService.class).muteTeam(teamId, type).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); updateTeamNotifyText(team.getMessageNotifyType()); } @Override public void onFailed(int code) { DialogMaker.dismissProgressDialog(); teamNotifyDialog.undoLastSelect(); Log.d(TAG, "muteTeam failed code:" + code); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } }); } teamNotifyDialog.show(); } /** * 转让群 * * @param account 转让的帐号 */ private void transferTeam(final String account) { TeamMember member = TeamDataCache.getInstance().getTeamMember(teamId, account); if (member == null) { Toast.makeText(AdvancedTeamInfoActivity.this, "成员不存在", Toast.LENGTH_SHORT).show(); return; } if (member.isMute()) { Toast.makeText(AdvancedTeamInfoActivity.this, "该成员已被禁言,请先取消禁言", Toast.LENGTH_LONG).show(); return; } NIMClient.getService(TeamService.class).transferTeam(teamId, account, false) .setCallback(new RequestCallback<List<TeamMember>>() { @Override public void onSuccess(List<TeamMember> members) { creator = account; updateTeamMember(TeamDataCache.getInstance().getTeamMemberList(teamId)); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.team_transfer_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { Toast.makeText(AdvancedTeamInfoActivity.this, R.string.team_transfer_failed, Toast.LENGTH_SHORT).show(); Log.e(TAG, "team transfer failed, code=" + code); } @Override public void onException(Throwable exception) { } }); } /** * 非群主退出群 */ private void quitTeam() { DialogMaker.showProgressDialog(this, getString(R.string.empty), true); NIMClient.getService(TeamService.class).quitTeam(teamId).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.quit_team_success, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_OK, new Intent().putExtra(RESULT_EXTRA_REASON, RESULT_EXTRA_REASON_QUIT)); finish(); } @Override public void onFailed(int code) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.quit_team_failed, Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * 群主解散群(直接退出) */ private void dismissTeam() { DialogMaker.showProgressDialog(this, getString(R.string.empty), true); NIMClient.getService(TeamService.class).dismissTeam(teamId).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); setResult(Activity.RESULT_OK, new Intent().putExtra(RESULT_EXTRA_REASON, RESULT_EXTRA_REASON_DISMISS)); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.dismiss_team_success, Toast.LENGTH_SHORT).show(); finish(); } @Override public void onFailed(int code) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.dismiss_team_failed, Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * ******************************* Event ********************************* */ /** * 显示菜单 */ private void showRegularTeamMenu() { List<String> btnNames = new ArrayList<>(); if (isSelfAdmin) { btnNames.add(getString(R.string.dismiss_team)); btnNames.add(getString(R.string.transfer_team)); btnNames.add(getString(R.string.cancel)); } else { btnNames.add(getString(R.string.quit_team)); btnNames.add(getString(R.string.cancel)); } dialog = new MenuDialog(this, btnNames, new MenuDialog.MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { if (name.equals(getString(R.string.quit_team))) { quitTeam(); } else if (name.equals(getString(R.string.dismiss_team))) { dismissTeam(); } else if (name.equals(getString(R.string.transfer_team))) { onTransferTeam(); } dialog.dismiss(); } }); dialog.show(); } /** * 显示验证菜单 */ private void showTeamAuthenMenu() { if (authenDialog == null) { List<String> btnNames = TeamHelper.createAuthenMenuStrings(); int type = team.getVerifyType().getValue(); authenDialog = new MenuDialog(AdvancedTeamInfoActivity.this, btnNames, type, 3, new MenuDialog .MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { authenDialog.dismiss(); if (name.equals(getString(R.string.cancel))) { return; // 取消不处理 } VerifyTypeEnum type = TeamHelper.getVerifyTypeEnum(name); if (type != null) { setAuthen(type); } } }); } authenDialog.show(); } /** * 显示邀请他人权限菜单 */ private void showTeamInviteMenu() { if (inviteDialog == null) { List<String> btnNames = TeamHelper.createInviteMenuStrings(); int type = team.getTeamInviteMode().getValue(); inviteDialog = new MenuDialog(AdvancedTeamInfoActivity.this, btnNames, type, 2, new MenuDialog .MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { inviteDialog.dismiss(); if (name.equals(getString(R.string.cancel))) { return; // 取消不处理 } TeamInviteModeEnum type = TeamHelper.getInviteModeEnum(name); if (type != null) { updateInviteMode(type); } } }); } inviteDialog.show(); } // 显示群资料修改权限菜单 private void showTeamInfoUpdateMenu() { if (teamInfoUpdateDialog == null) { List<String> btnNames = TeamHelper.createTeamInfoUpdateMenuStrings(); int type = team.getTeamUpdateMode().getValue(); teamInfoUpdateDialog = new MenuDialog(AdvancedTeamInfoActivity.this, btnNames, type, 2, new MenuDialog .MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { teamInfoUpdateDialog.dismiss(); if (name.equals(getString(R.string.cancel))) { return; // 取消不处理 } TeamUpdateModeEnum type = TeamHelper.getUpdateModeEnum(name); if (type != null) { updateInfoUpdateMode(type); } } }); } teamInfoUpdateDialog.show(); } // 显示被邀请人身份验证菜单 private void showTeamInviteeAuthenMenu() { if (teamInviteeDialog == null) { List<String> btnNames = TeamHelper.createTeamInviteeAuthenMenuStrings(); int type = team.getTeamBeInviteMode().getValue(); teamInviteeDialog = new MenuDialog(AdvancedTeamInfoActivity.this, btnNames, type, 2, new MenuDialog .MenuDialogOnButtonClickListener() { @Override public void onButtonClick(String name) { teamInviteeDialog.dismiss(); if (name.equals(getString(R.string.cancel))) { return; // 取消不处理 } TeamBeInviteModeEnum type = TeamHelper.getBeInvitedModeEnum(name); if (type != null) { updateBeInvitedMode(type); } } }); } teamInviteeDialog.show(); } /** * 设置我的名片 * * @param nickname 群昵称 */ private void setBusinessCard(final String nickname) { DialogMaker.showProgressDialog(this, getString(R.string.empty), true); NIMClient.getService(TeamService.class).updateMemberNick(teamId, NimUIKit.getAccount(), nickname).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); teamBusinessCard.setText(nickname); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } @Override public void onHeadImageViewClick(String account) { // 打开群成员信息详细页面 AdvancedTeamMemberInfoActivity.startActivityForResult(AdvancedTeamInfoActivity.this, account, teamId); } /** * 设置群公告 * * @param announcement 群公告 */ private void setAnnouncement(String announcement) { Announcement a = AnnouncementHelper.getLastAnnouncement(teamId, announcement); if (a == null) { announcementEdit.setText(""); } else { announcementEdit.setText(a.getTitle()); } } /** * 设置验证模式 * * @param type 验证类型 */ private void setAuthen(final VerifyTypeEnum type) { DialogMaker.showProgressDialog(this, getString(R.string.empty)); NIMClient.getService(TeamService.class).updateTeam(teamId, TeamFieldEnum.VerifyType, type).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); setAuthenticationText(type); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { authenDialog.undoLastSelect(); // 撤销选择 DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * 设置验证模式detail显示 * * @param type 验证类型 */ private void setAuthenticationText(VerifyTypeEnum type) { authenticationText.setText(TeamHelper.getVerifyString(type)); } private void updateTeamNotifyText(TeamMessageNotifyTypeEnum typeEnum) { if (typeEnum == TeamMessageNotifyTypeEnum.All) { notificationConfigText.setText(getString(R.string.team_notify_all)); } else if (typeEnum == TeamMessageNotifyTypeEnum.Manager) { notificationConfigText.setText(getString(R.string.team_notify_manager)); } else if (typeEnum == TeamMessageNotifyTypeEnum.Mute) { notificationConfigText.setText(getString(R.string.team_notify_mute)); } } /** * 更新邀请他人权限 * @param type 邀请他人类型 */ private void updateInviteMode(final TeamInviteModeEnum type) { DialogMaker.showProgressDialog(this, getString(R.string.empty)); NIMClient.getService(TeamService.class).updateTeam(teamId, TeamFieldEnum.InviteMode, type).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); updateInviteText(type); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { inviteDialog.undoLastSelect(); // 撤销选择 DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * 更新邀请他人detail显示 * @param type 邀请他人类型 */ private void updateInviteText(TeamInviteModeEnum type) { inviteText.setText(TeamHelper.getInviteModeString(type)); } /** * 更新群资料修改权限 * @param type 群资料修改类型 */ private void updateInfoUpdateMode(final TeamUpdateModeEnum type) { DialogMaker.showProgressDialog(this, getString(R.string.empty)); NIMClient.getService(TeamService.class).updateTeam(teamId, TeamFieldEnum.TeamUpdateMode, type).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); updateInfoUpateText(type); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { teamInfoUpdateDialog.undoLastSelect(); // 撤销选择 DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * 更新群资料修改detail显示 * @param type 群资料修改类型 */ private void updateInfoUpateText(TeamUpdateModeEnum type) { infoUpdateText.setText(TeamHelper.getInfoUpdateModeString(type)); } /** * 更新被邀请人权限 * @param type 被邀请人类型 */ private void updateBeInvitedMode(final TeamBeInviteModeEnum type) { DialogMaker.showProgressDialog(this, getString(R.string.empty)); NIMClient.getService(TeamService.class).updateTeam(teamId, TeamFieldEnum.BeInviteMode, type).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); updateBeInvitedText(type); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); } @Override public void onFailed(int code) { teamInviteeDialog.undoLastSelect(); // 撤销选择 DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); } /** * 更新被邀请人detail显示 * @param type 被邀请人类型 */ private void updateBeInvitedText(TeamBeInviteModeEnum type) { inviteeAutenText.setText(TeamHelper.getBeInvitedModeString(type)); } /** * 移除群成员成功后,删除列表中的群成员 * * @param account 被删除成员帐号 */ private void removeMember(String account) { if (TextUtils.isEmpty(account)) { return; } memberAccounts.remove(account); for (TeamMember m : members) { if (m.getAccount().equals(account)) { members.remove(m); break; } } memberCountText.setText(String.format("共%d人", members.size())); for (TeamMemberItem item : dataSource) { if (item.getAccount() != null && item.getAccount().equals(account)) { dataSource.remove(item); break; } } adapter.notifyDataSetChanged(); } /** * 是否设置了管理员刷新界面 * * @param isSetAdmin * @param account */ private void refreshAdmin(boolean isSetAdmin, String account) { if (isSetAdmin) { if (managerList.contains(account)) { return; } managerList.add(account); updateTeamMemberDataSource(); } else { if (managerList.contains(account)) { managerList.remove(account); updateTeamMemberDataSource(); } } } private void registerUserInfoChangedObserver(boolean register) { if (register) { if (userInfoObserver == null) { userInfoObserver = new UserInfoObservable.UserInfoObserver() { @Override public void onUserInfoChanged(List<String> accounts) { adapter.notifyDataSetChanged(); } }; } UserInfoHelper.registerObserver(userInfoObserver); } else { UserInfoHelper.unregisterObserver(userInfoObserver); } } /** * 更新头像 */ private void updateTeamIcon(final String path) { if (TextUtils.isEmpty(path)) { return; } File file = new File(path); if (file == null) { return; } DialogMaker.showProgressDialog(this, null, null, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { cancelUpload(R.string.team_update_cancel); } }).setCanceledOnTouchOutside(true); LogUtil.i(TAG, "start upload icon, local file path=" + file.getAbsolutePath()); new Handler().postDelayed(outimeTask, ICON_TIME_OUT); uploadFuture = NIMClient.getService(NosService.class).upload(file, PickImageAction.MIME_JPEG); uploadFuture.setCallback(new RequestCallbackWrapper<String>() { @Override public void onResult(int code, String url, Throwable exception) { if (code == ResponseCode.RES_SUCCESS && !TextUtils.isEmpty(url)) { LogUtil.i(TAG, "upload icon success, url =" + url); NIMClient.getService(TeamService.class).updateTeam(teamId, TeamFieldEnum.ICON, url).setCallback(new RequestCallback<Void>() { @Override public void onSuccess(Void param) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show(); onUpdateDone(); } @Override public void onFailed(int code) { DialogMaker.dismissProgressDialog(); Toast.makeText(AdvancedTeamInfoActivity.this, String.format(getString(R.string.update_failed), code), Toast.LENGTH_SHORT).show(); } @Override public void onException(Throwable exception) { DialogMaker.dismissProgressDialog(); } }); // 更新资料 } else { Toast.makeText(AdvancedTeamInfoActivity.this, R.string.team_update_failed, Toast .LENGTH_SHORT).show(); onUpdateDone(); } } }); } private void cancelUpload(int resId) { if (uploadFuture != null) { uploadFuture.abort(); Toast.makeText(AdvancedTeamInfoActivity.this, resId, Toast.LENGTH_SHORT).show(); onUpdateDone(); } } private Runnable outimeTask = new Runnable() { @Override public void run() { cancelUpload(R.string.team_update_failed); } }; private void onUpdateDone() { uploadFuture = null; DialogMaker.dismissProgressDialog(); } }
[ "http://192.168.0.254:3000/Fred/meet-andoid.git" ]
http://192.168.0.254:3000/Fred/meet-andoid.git
54080a4f2d42f5f0b458c11e89c48148e285b921
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/8/8_aff5236124995d294779dfd68b47b8e5164fefb2/ASListener/8_aff5236124995d294779dfd68b47b8e5164fefb2_ASListener_t.java
187e1458936b09c8167ab139db24e6ccfb944240
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
36,793
java
package com.turt2live.antishare; import java.io.BufferedWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.block.Furnace; import org.bukkit.block.Jukebox; import org.bukkit.entity.Boat; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Minecart; import org.bukkit.entity.Painting; import org.bukkit.entity.Player; import org.bukkit.entity.PoweredMinecart; import org.bukkit.entity.Projectile; import org.bukkit.entity.StorageMinecart; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.Vehicle; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.ExpBottleEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.inventory.ItemStack; import com.turt2live.antishare.notification.Alert.AlertTrigger; import com.turt2live.antishare.notification.Alert.AlertType; import com.turt2live.antishare.permissions.PermissionNodes; import com.turt2live.antishare.regions.ASRegion; import com.turt2live.antishare.storage.PerWorldConfig; import com.turt2live.antishare.storage.PerWorldConfig.ListType; /** * The core listener - Listens to all events needed by AntiShare and handles them * * @author turt2live */ public class ASListener implements Listener { private AntiShare plugin = AntiShare.instance; private ConcurrentHashMap<World, PerWorldConfig> config = new ConcurrentHashMap<World, PerWorldConfig>(); /** * Creates a new Listener */ public ASListener(){ reload(); } /** * Reloads lists */ public void reload(){ config.clear(); for(World world : Bukkit.getWorlds()){ config.put(world, new PerWorldConfig(world)); } } /** * Prints out each world to the writer * * @param out the writer * @throws IOException for internal handling */ public void print(BufferedWriter out) throws IOException{ for(World world : config.keySet()){ out.write("## WORLD: " + world.getName() + " \r\n"); config.get(world).print(out); } } // ################# World Load @EventHandler public void onWorldLoad(WorldLoadEvent event){ World world = event.getWorld(); config.put(world, new PerWorldConfig(world)); } // ################# World Unload @EventHandler public void onWorldUnload(WorldUnloadEvent event){ World world = event.getWorld(); config.remove(world); } // ################# Block Break @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event){ Player player = event.getPlayer(); Block block = event.getBlock(); AlertType type = AlertType.ILLEGAL; boolean special = false; boolean region = false; Boolean drops = null; AlertType specialType = AlertType.LEGAL; String blockGM = "Unknown"; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_BLOCK_BREAK, block.getWorld())){ type = AlertType.LEGAL; } if(!config.get(block.getWorld()).isBlocked(block.getType(), ListType.BLOCK_BREAK)){ type = AlertType.LEGAL; } // Check creative/survival blocks if(!plugin.getPermissions().has(player, PermissionNodes.FREE_PLACE)){ GameMode blockGamemode = plugin.getBlockManager().getType(block); if(blockGamemode != null){ special = true; blockGM = blockGamemode.name().toLowerCase(); String oGM = blockGM.equalsIgnoreCase("creative") ? "survival" : "creative"; if(player.getGameMode() != blockGamemode){ boolean deny = plugin.getConfig().getBoolean("settings." + oGM + "-breaking-" + blockGM + "-blocks.deny"); drops = plugin.getConfig().getBoolean("settings." + oGM + "-breaking-" + blockGM + "-blocks.block-drops"); if(deny){ specialType = AlertType.ILLEGAL; } } } } // Check regions if(!plugin.getPermissions().has(player, PermissionNodes.REGION_BREAK)){ ASRegion playerRegion = plugin.getRegionManager().getRegion(player.getLocation()); ASRegion blockRegion = plugin.getRegionManager().getRegion(block.getLocation()); if(playerRegion != blockRegion){ special = true; region = true; specialType = AlertType.ILLEGAL; } } // Handle event if(type == AlertType.ILLEGAL || specialType == AlertType.ILLEGAL){ event.setCancelled(true); }else{ plugin.getBlockManager().removeBlock(block); } // Handle drops if(drops != null){ if(drops){ if(event.isCancelled()){ plugin.getBlockManager().removeBlock(block); block.breakNaturally(); } }else{ plugin.getBlockManager().removeBlock(block); block.setType(Material.AIR); } } // Alert if(special){ if(region){ if(specialType == AlertType.ILLEGAL){ String specialMessage = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (specialType == AlertType.ILLEGAL ? " tried to break " : " broke ") + (specialType == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " ") + ChatColor.WHITE + " in a region."; String specialPlayerMessage = ChatColor.RED + "You cannot break blocks that are not in your region"; plugin.getAlerts().alert(specialMessage, player, specialPlayerMessage, specialType, AlertTrigger.BLOCK_BREAK); } }else{ String specialMessage = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (specialType == AlertType.ILLEGAL ? " tried to break the " + blockGM + " block " : " broke the " + blockGM + " block ") + (specialType == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " "); String specialPlayerMessage = plugin.getMessage("blocked-action." + blockGM + "-block-break"); plugin.getAlerts().alert(specialMessage, player, specialPlayerMessage, specialType, (blockGM.equalsIgnoreCase("creative") ? AlertTrigger.CREATIVE_BLOCK : AlertTrigger.SURVIVAL_BLOCK)); } }else{ String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to break " : " broke ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " "); String playerMessage = plugin.getMessage("blocked-action.break-block"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.BLOCK_BREAK); } // Check for 'attached' blocks and internal inventories if(player.getGameMode() == GameMode.CREATIVE && !plugin.getPermissions().has(player, PermissionNodes.BREAK_ANYTHING)){ // Check inventories if(config.get(block.getWorld()).clearBlockInventoryOnBreak()){ if(block.getState() instanceof Chest){ Chest state = (Chest) block.getState(); state.getBlockInventory().clear(); }else if(block.getState() instanceof Jukebox){ Jukebox state = (Jukebox) block.getState(); state.setPlaying(null); }else if(block.getState() instanceof Furnace){ Furnace state = (Furnace) block.getState(); state.getInventory().clear(); } } // Check for attached blocks if(config.get(block.getWorld()).removeAttachedBlocksOnBreak()){ for(BlockFace face : BlockFace.values()){ Block rel = block.getRelative(face); if(ASUtils.isDroppedOnBreak(rel, block)){ plugin.getBlockManager().removeBlock(rel); rel.setType(Material.AIR); } } } } } // ################# Block Place @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event){ Player player = event.getPlayer(); Block block = event.getBlock(); AlertType type = AlertType.ILLEGAL; boolean region = false; // Sanity check if(block.getType() == Material.AIR){ return; } // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_BLOCK_PLACE, block.getWorld())){ type = AlertType.LEGAL; } if(!config.get(block.getWorld()).isBlocked(block.getType(), ListType.BLOCK_PLACE)){ type = AlertType.LEGAL; } if(!plugin.getPermissions().has(player, PermissionNodes.REGION_PLACE)){ ASRegion playerRegion = plugin.getRegionManager().getRegion(player.getLocation()); ASRegion blockRegion = plugin.getRegionManager().getRegion(block.getLocation()); if(playerRegion != blockRegion){ type = AlertType.ILLEGAL; region = true; } } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); }else{ // Handle block place for tracker if(!plugin.getPermissions().has(player, PermissionNodes.FREE_PLACE)){ plugin.getBlockManager().addBlock(player.getGameMode(), block); } } // Alert if(region){ if(type == AlertType.ILLEGAL){ String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to place " : " placed ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " ") + ChatColor.WHITE + " in a region."; String playerMessage = ChatColor.RED + "You cannot place blocks in another region!"; plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.BLOCK_PLACE); } }else{ String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to place " : " placed ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " "); String playerMessage = plugin.getMessage("blocked-action.place-block"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.BLOCK_PLACE); } } // ################# Player Interact Block @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInteract(PlayerInteractEvent event){ Player player = event.getPlayer(); Block block = event.getClickedBlock(); Action action = event.getAction(); AlertType type = AlertType.LEGAL; String message = "no message"; String playerMessage = "no message"; AlertTrigger trigger = AlertTrigger.RIGHT_CLICK; // Check for AntiShare tool if(plugin.getPermissions().has(player, PermissionNodes.TOOL_USE) && player.getItemInHand() != null && (action == Action.RIGHT_CLICK_BLOCK || action == Action.LEFT_CLICK_BLOCK)){ if(player.getItemInHand().getType() == AntiShare.ANTISHARE_TOOL){ String blockname = block.getType().name().replaceAll("_", " ").toLowerCase(); String gamemode = (plugin.getBlockManager().getType(block) != null ? plugin.getBlockManager().getType(block).name() : "natural").toLowerCase(); ASUtils.sendToPlayer(player, "That " + ChatColor.YELLOW + blockname + ChatColor.WHITE + " is a " + ChatColor.YELLOW + gamemode + ChatColor.WHITE + " block."); // Cancel and stop the check event.setCancelled(true); return; } } // Right click list if(action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK){ // Check if they should be blocked if(config.get(block.getWorld()).isBlocked(block.getType(), ListType.RIGHT_CLICK)){ type = AlertType.ILLEGAL; } if(!plugin.isBlocked(player, PermissionNodes.ALLOW_RIGHT_CLICK, block.getWorld())){ type = AlertType.LEGAL; } // Set messages message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to right click " : " right clicked ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " "); playerMessage = plugin.getMessage("blocked-action.right-click"); } // If this event is triggered as legal from the right click, check use lists if(type == AlertType.LEGAL){ if(config.get(block.getWorld()).isBlocked(block.getType(), ListType.USE)){ type = AlertType.ILLEGAL; } // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_USE, block.getWorld())){ type = AlertType.LEGAL; } // Set messages message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to right click " : " right clicked ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + block.getType().name().replace("_", " "); playerMessage = plugin.getMessage("blocked-action.right-click"); } // If the event is triggered as legal from the use lists, check the player's item in hand if(type == AlertType.LEGAL && action == Action.RIGHT_CLICK_BLOCK && player.getItemInHand() != null){ // Check if they should be blocked if(config.get(player.getWorld()).isBlocked(player.getItemInHand().getType(), ListType.USE)){ type = AlertType.ILLEGAL; } if(!plugin.isBlocked(player, PermissionNodes.ALLOW_USE, player.getWorld())){ type = AlertType.LEGAL; } // Set messages message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to use " : " used ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + player.getItemInHand().getType().name().replace("_", " "); playerMessage = plugin.getMessage("blocked-action.use-item"); trigger = AlertTrigger.USE_ITEM; } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert (with sanity check) if(type != AlertType.LEGAL){ plugin.getAlerts().alert(message, player, playerMessage, type, trigger); } } // ################# Player Interact Entity @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInteractEntity(PlayerInteractEntityEvent event){ Player player = event.getPlayer(); AlertType type = AlertType.ILLEGAL; // Convert entity -> item ID Material item = Material.AIR; if(event.getRightClicked() instanceof StorageMinecart){ item = Material.STORAGE_MINECART; }else if(event.getRightClicked() instanceof PoweredMinecart){ item = Material.POWERED_MINECART; }else if(event.getRightClicked() instanceof Boat){ item = Material.BOAT; }else if(event.getRightClicked() instanceof Minecart){ item = Material.MINECART; }else if(event.getRightClicked() instanceof Painting){ item = Material.PAINTING; } // If the entity is not found, ignore the event if(item == Material.AIR){ return; } // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_RIGHT_CLICK, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(item, ListType.RIGHT_CLICK)){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to right click " : " right clicked ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + item.name(); String playerMessage = plugin.getMessage("blocked-action.right-click"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.RIGHT_CLICK); } // ################# Cart Death Check @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onCartDeath(VehicleDestroyEvent event){ Entity attacker = event.getAttacker(); Vehicle potentialCart = event.getVehicle(); // Sanity checks if(attacker == null || !(potentialCart instanceof StorageMinecart)){ return; } if(!(attacker instanceof Player)){ return; } // Setup Player player = (Player) attacker; StorageMinecart cart = (StorageMinecart) potentialCart; // Check internal inventories if(player.getGameMode() == GameMode.CREATIVE && !plugin.getPermissions().has(player, PermissionNodes.BREAK_ANYTHING)){ // Check inventories if(config.get(player.getWorld()).clearBlockInventoryOnBreak()){ cart.getInventory().clear(); } } } // ################# Egg Check @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEggThrow(PlayerEggThrowEvent event){ Player player = event.getPlayer(); AlertType type = AlertType.ILLEGAL; Material item = Material.EGG; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_USE, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(item, ListType.USE)){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ event.setHatching(false); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to use " : " used ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + item.name(); String playerMessage = plugin.getMessage("blocked-action.use-item"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.USE_ITEM); } // ################# Experience Bottle Check @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onExpBottle(ExpBottleEvent event){ ThrownExpBottle bottle = event.getEntity(); LivingEntity shooter = bottle.getShooter(); AlertType type = AlertType.ILLEGAL; Material item = Material.EXP_BOTTLE; // Sanity Check if(!(shooter instanceof Player)){ return; } // Setup Player player = (Player) shooter; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_USE, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(item, ListType.USE)){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ event.setExperience(0); event.setShowEffect(false); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to use " : " used ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + item.name(); String playerMessage = plugin.getMessage("blocked-action.use-item"); if(type == AlertType.ILLEGAL){ // We don't want to show legal events because of spam plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.USE_ITEM); } } // ################# Drop Item @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDrop(PlayerDropItemEvent event){ Player player = event.getPlayer(); Item item = event.getItemDrop(); ItemStack itemStack = item.getItemStack(); AlertType type = AlertType.ILLEGAL; boolean region = false; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_DROP, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(itemStack.getType(), ListType.DROP)){ type = AlertType.LEGAL; } // Region Check if(plugin.getRegionManager().getRegion(player.getLocation()) != plugin.getRegionManager().getRegion(item.getLocation()) && type == AlertType.LEGAL){ if(!plugin.getPermissions().has(player, PermissionNodes.REGION_THROW)){ type = AlertType.ILLEGAL; region = true; } } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to throw " : " threw ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + itemStack.getType().name().replace("_", " "); String playerMessage = plugin.getMessage("blocked-action.drop-item"); if(region){ message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to throw " : " threw ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + itemStack.getType().name().replace("_", " ") + ChatColor.WHITE + " into a region."; playerMessage = ChatColor.RED + "You cannot throw items into another region!"; } plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.ITEM_DROP); } // ################# Pickup Item @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPickup(PlayerPickupItemEvent event){ Player player = event.getPlayer(); Item item = event.getItem(); ItemStack itemStack = item.getItemStack(); AlertType type = AlertType.ILLEGAL; boolean region = false; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_PICKUP, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(itemStack.getType(), ListType.PICKUP)){ type = AlertType.LEGAL; } // Region Check if(plugin.getRegionManager().getRegion(player.getLocation()) != plugin.getRegionManager().getRegion(item.getLocation()) && type == AlertType.LEGAL){ if(!plugin.getPermissions().has(player, PermissionNodes.REGION_PICKUP)){ type = AlertType.ILLEGAL; region = true; } } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to pickup " : " picked up ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + itemStack.getType().name().replace("_", " "); String playerMessage = plugin.getMessage("blocked-action.pickup-item"); if(region){ message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to pickup " : " picked up ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + itemStack.getType().name().replace("_", " ") + ChatColor.WHITE + " from a region."; playerMessage = ChatColor.RED + "You cannot pickup items from another region!"; } plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.ITEM_PICKUP); } // ################# Player Death @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onDeath(PlayerDeathEvent event){ Player player = event.getEntity(); List<ItemStack> drops = event.getDrops(); AlertType type = AlertType.ILLEGAL; int illegalItems = 0; // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_DEATH, player.getWorld())){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ List<ItemStack> remove = new ArrayList<ItemStack>(); for(ItemStack item : drops){ if(config.get(player.getWorld()).isBlocked(item.getType(), ListType.DEATH)){ illegalItems++; remove.add(item); } } // Remove items for(ItemStack item : remove){ drops.remove(item); } } // Determine new status if(illegalItems == 0){ type = AlertType.LEGAL; } // Alert String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + " died with " + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + illegalItems + " illegal item(s)."; String playerMessage = plugin.getMessage("blocked-action.die-with-item"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.PLAYER_DEATH); } // ################# Player Command @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onCommand(PlayerCommandPreprocessEvent event){ Player player = event.getPlayer(); String command = event.getMessage().toLowerCase(); AlertType type = AlertType.ILLEGAL; // Game Mode command GameModeCommand.onPlayerCommand(event); if(event.isCancelled()){ return; } // Check if they should be blocked if(!plugin.isBlocked(player, PermissionNodes.ALLOW_PICKUP, player.getWorld())){ type = AlertType.LEGAL; } if(!config.get(player.getWorld()).isBlocked(command, ListType.COMMAND)){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert (with sanity check) String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to use the command " : " used the command ") + (type == AlertType.ILLEGAL ? ChatColor.RED : ChatColor.GREEN) + command; String playerMessage = plugin.getMessage("blocked-action.command"); plugin.getAlerts().alert(message, player, playerMessage, type, AlertTrigger.COMMAND); } // ################# Player Move @EventHandler (ignoreCancelled = true) public void onMove(PlayerMoveEvent event){ Player player = event.getPlayer(); ASRegion currentRegion = plugin.getRegionManager().getRegion(event.getFrom()); ASRegion toRegion = plugin.getRegionManager().getRegion(event.getTo()); // Check world split config.get(player.getWorld()).checkSplit(player); // Check regions if(currentRegion != toRegion){ if(currentRegion != null){ currentRegion.alertExit(player); } if(toRegion != null){ toRegion.alertEntry(player); } } } // ################# Player Game Mode Change @EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onGameModeChange(PlayerGameModeChangeEvent event){ Player player = event.getPlayer(); GameMode from = player.getGameMode(); GameMode to = event.getNewGameMode(); boolean ignore = true; boolean checkRegion = true; // Check to see if we should even bother if(!plugin.getConfig().getBoolean("handled-actions.gamemode-inventories")){ return; } // Tag check if(player.hasMetadata("antishare-regionleave")){ player.removeMetadata("antishare-regionleave", plugin); checkRegion = false; } // Region Check if(!plugin.getPermissions().has(player, PermissionNodes.REGION_ROAM) && checkRegion){ ASRegion region = plugin.getRegionManager().getRegion(player.getLocation()); if(region != null){ ASUtils.sendToPlayer(player, ChatColor.RED + "You are in a region and therefore cannot change Game Mode"); event.setCancelled(true); return; } } // Check temp if(plugin.getInventoryManager().isInTemporary(player)){ plugin.getInventoryManager().removeFromTemporary(player); } if(!plugin.getPermissions().has(player, PermissionNodes.NO_SWAP)){ // Save from switch (from){ case CREATIVE: plugin.getInventoryManager().saveCreativeInventory(player, player.getWorld()); break; case SURVIVAL: plugin.getInventoryManager().saveSurvivalInventory(player, player.getWorld()); break; } // Set to switch (to){ case CREATIVE: plugin.getInventoryManager().getCreativeInventory(player, player.getWorld()).setTo(player); break; case SURVIVAL: plugin.getInventoryManager().getSurvivalInventory(player, player.getWorld()).setTo(player); break; } // For alerts ignore = false; } // Alerts String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + " changed to Game Mode " + ChatColor.YELLOW + to.name(); String playerMessage = ignore ? "no message" : "Your inventory has been changed to " + ChatColor.YELLOW + to.name(); plugin.getAlerts().alert(message, player, playerMessage, AlertType.GENERAL, AlertTrigger.GENERAL); } // ################# Player Combat @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onCombat(EntityDamageByEntityEvent event){ DamageCause cause = event.getCause(); Entity attacker = event.getDamager(); Entity target = event.getEntity(); AlertType type = AlertType.ILLEGAL; boolean playerCombat = false; Player playerAttacker = null; // Check case switch (cause){ case ENTITY_ATTACK: // attacker = entity if(attacker instanceof Player){ playerAttacker = (Player) attacker; }else{ return; } break; case PROJECTILE: // attacker = Projectile Projectile projectile = (Projectile) attacker; LivingEntity shooter = projectile.getShooter(); if(shooter instanceof Player){ playerAttacker = (Player) shooter; }else{ return; } break; default: return; } // Determine if we are hitting a mob or not, and whether it is legal if(target instanceof Player){ // target = Player playerCombat = true; if(!plugin.isBlocked(playerAttacker, PermissionNodes.ALLOW_COMBAT_PLAYERS, playerAttacker.getWorld())){ type = AlertType.LEGAL; } }else{ // target = other entity if(!plugin.isBlocked(playerAttacker, PermissionNodes.ALLOW_COMBAT_MOBS, playerAttacker.getWorld())){ type = AlertType.LEGAL; } } // Check if we need to continue based on settings if(playerCombat){ if(!plugin.getConfig().getBoolean("blocked-actions.combat-against-players")){ return; } }else{ if(!plugin.getConfig().getBoolean("blocked-actions.combat-against-mobs")){ return; } } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } // Alert String message = "no message"; String playerMessage = "no message"; AlertTrigger trigger = AlertTrigger.HIT_MOB; if(playerCombat){ String playerName = ((Player) target).getName(); message = ChatColor.YELLOW + playerAttacker.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to hit " + ChatColor.RED : " hit " + ChatColor.GREEN) + playerName; playerMessage = plugin.getMessage("blocked-action.hit-player"); trigger = AlertTrigger.HIT_PLAYER; }else{ String targetName = target.getClass().getName().replace("Craft", "").replace("org.bukkit.craftbukkit.entity.", "").trim(); message = ChatColor.YELLOW + playerAttacker.getName() + ChatColor.WHITE + (type == AlertType.ILLEGAL ? " tried to hit a " + ChatColor.RED : " hit a " + ChatColor.GREEN) + targetName; playerMessage = plugin.getMessage("blocked-action.hit-mob"); } plugin.getAlerts().alert(message, playerAttacker, playerMessage, type, trigger); } // ################# Entity Target @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event){ Entity target = event.getTarget(); Player playerTarget = null; AlertType type = AlertType.ILLEGAL; // Check target if(target instanceof Player){ playerTarget = (Player) target; }else{ return; } // Check permissions if(!plugin.isBlocked(playerTarget, PermissionNodes.ALLOW_COMBAT_MOBS, playerTarget.getWorld())){ type = AlertType.LEGAL; } // Handle event if(type == AlertType.ILLEGAL){ event.setCancelled(true); } } // ################# Piston Move (Extend) @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event){ for(Block block : event.getBlocks()){ // Check for block type GameMode type = plugin.getBlockManager().getType(block); // Sanity if(type == null){ continue; } // Setup Location oldLocation = block.getLocation(); Location newLocation = block.getRelative(event.getDirection()).getLocation(); // Move plugin.getBlockManager().moveBlock(oldLocation, newLocation); } } // ################# Piston Move (Retract) @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event){ if(!event.isSticky()){ // Only handle moving blocks return; } Block block = event.getBlock().getRelative(event.getDirection()).getRelative(event.getDirection()); // Check for block type GameMode type = plugin.getBlockManager().getType(block); // Sanity if(type == null){ return; } // Setup Location oldLocation = block.getLocation(); Location newLocation = block.getRelative(event.getDirection().getOppositeFace()).getLocation(); // Move plugin.getBlockManager().moveBlock(oldLocation, newLocation); } // ################# Player Join @EventHandler (ignoreCancelled = true) public void onJoin(PlayerJoinEvent event){ Player player = event.getPlayer(); // Tell the inventory manager to prepare this player plugin.getInventoryManager().loadPlayer(player); // Check region ASRegion region = plugin.getRegionManager().getRegion(player.getLocation()); if(region != null){ region.alertSilentEntry(player); // Sets inventory and Game Mode // This must be done because when the inventory manager releases // a player it resets the inventory to "non-temp" } } // ################# Player Quit @EventHandler (ignoreCancelled = true) public void onQuit(PlayerQuitEvent event){ Player player = event.getPlayer(); // Tell the inventory manager to release this player plugin.getInventoryManager().releasePlayer(player); } // ################# Player Kicked @EventHandler (ignoreCancelled = true) public void onKick(PlayerKickEvent event){ Player player = event.getPlayer(); // Tell the inventory manager to release this player plugin.getInventoryManager().releasePlayer(player); } // ################# Player World Change @EventHandler (priority = EventPriority.LOWEST, ignoreCancelled = true) public void onWorldChange(PlayerChangedWorldEvent event){ Player player = event.getPlayer(); World to = player.getWorld(); World from = event.getFrom(); boolean ignore = true; // Check to see if we should even bother checking if(!plugin.getConfig().getBoolean("handled-actions.world-transfers")){ return; } // Check temp if(plugin.getInventoryManager().isInTemporary(player)){ plugin.getInventoryManager().removeFromTemporary(player); } // Inventory check if(!plugin.getPermissions().has(player, PermissionNodes.NO_SWAP)){ // Save from switch (player.getGameMode()){ case CREATIVE: plugin.getInventoryManager().saveCreativeInventory(player, from); break; case SURVIVAL: plugin.getInventoryManager().saveSurvivalInventory(player, from); break; } // Set to switch (player.getGameMode()){ case CREATIVE: plugin.getInventoryManager().getCreativeInventory(player, to).setTo(player); break; case SURVIVAL: plugin.getInventoryManager().getSurvivalInventory(player, to).setTo(player); break; } // For alerts ignore = false; } // Alerts String message = ChatColor.YELLOW + player.getName() + ChatColor.WHITE + " changed to world " + ChatColor.YELLOW + to.getName(); String playerMessage = ignore ? "no message" : "Your inventory has been changed to " + ChatColor.YELLOW + to.getName(); plugin.getAlerts().alert(message, player, playerMessage, AlertType.GENERAL, AlertTrigger.GENERAL); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
2e5196d50bf4730a7d6be1ebbd5bb305ec657ebd
0706c4e0c89edd499ad0a885958421252d3fc2cc
/EmployeeImportance.java
7c465047419d8b29288b8857bf4ff57737bc422f
[]
no_license
leonngai/LeetCode-Questions
42d70f4b77914758cb620db3e6f872ae17560ab8
1ec409094601a6f74a2718e72d851c8a30e9ce18
refs/heads/master
2021-06-23T03:50:07.249584
2021-01-20T05:29:29
2021-01-20T05:29:29
176,599,413
0
0
null
null
null
null
UTF-8
Java
false
false
1,486
java
/* // Employee info class Employee { // It's the unique id of each node; // unique id of this employee public int id; // the importance value of this employee public int importance; // the id of direct subordinates public List<Integer> subordinates; }; */ class Solution { /* Things we need to do: 1. Traverse through the list of employees and add each employee into a hashmap with the id as key and reference of employee as value 2. While traversing the list if the employee id matches the id that we are looking for, add to the Queue 3. Perform a breadth first search of the matched employee, adding each employees subordinates into the Queue until it return empty Time Complexity: O(N) Space Complexity: O(N) */ public int getImportance(List<Employee> employees, int id) { int ans = 0; HashMap<Integer, Employee> hash = new HashMap<>(); Queue<Employee> q = new LinkedList<>(); for (Employee employee : employees) { hash.put(employee.id, employee); if (id == employee.id) q.add(employee); } while(!q.isEmpty()) { Employee temp = q.poll(); ans += temp.importance; for (int subordinateID : temp.subordinates) q.add(hash.get(subordinateID)); } return ans; } }
[ "ngai@synopsys.com" ]
ngai@synopsys.com
b45a4cd67a41419a91d30b62132583c4d94860a1
9c90b9d63b8e9d3dc1d7c3bd9be9b555d75211aa
/src/main/java/se/inera/fmu/domain/model/eavrop/note/Note.java
37c7d3fbcac40faed796d74305271517f6ca432c
[]
no_license
qwazer/fmu
bc2228893a348f1d12e32be9a9ea93ccb14b8809
1bdd65b289484303532c9b126899253f61a82bde
refs/heads/master
2020-12-26T04:37:49.051002
2014-10-03T07:56:27
2014-10-03T07:56:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,080
java
package se.inera.fmu.domain.model.eavrop.note; import java.io.Serializable; import java.util.UUID; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import lombok.ToString; import se.inera.fmu.domain.shared.AbstractBaseEntity; import se.inera.fmu.domain.shared.ValueObject; @Entity @Table(name = "T_NOTE") @ToString public class Note extends AbstractBaseEntity implements ValueObject<Note>, Serializable { // ~ Instance fields ================================================================================================ // database primary key @Id @Column(name = "ID", updatable = false, nullable = false) private String id; @Column(name = "TEXT") private String text; // TODO: Maybe add party if not reachable from audit created by and also if // notes from bestallare should be represented with this entity // ~ Constructors =================================================================================================== Note() { // Needed by Hibernate } public Note(String text) { this.id = UUID.randomUUID().toString(); setText(text); } // ~ Property Methods =============================================================================================== private void setText(String text) { this.text = text; } public String getText() { return this.text; } // ~ Other Methods ================================================================================================== /** * @param object to compare * @return True if they have the same value * @see #sameValueAs(Note) */ @Override public boolean equals(final Object object) { if (this == object) return true; if (object == null || getClass() != object.getClass()) return false; final Note other = (Note) object; return sameValueAs(other); } /** * @return Hash code of id. */ @Override public int hashCode() { return this.id.hashCode(); } @Override public boolean sameValueAs(Note other) { return other != null && this.id.equals(other.id); } }
[ "rickard.hjortling@r2m.se" ]
rickard.hjortling@r2m.se
8993921a20bd56270ae09507ce6cec77e2129953
3a01702ca03c11917da22bff39d7d9acbe0aa302
/src/main/java/com/ceeses/dao/mapper/LnskfsxMapper.java
3f9806542e63e727e79ad136ce6bcb7b209d6a6f
[]
no_license
collegeApply/ceeses
b36bbd2c74b22aa13abfeca1bc85663240b0afbc
c43a02f3506c6354a6fedb4a72a5be2af7fe53d9
refs/heads/master
2021-01-23T16:19:28.271686
2017-06-29T16:56:24
2017-06-29T16:56:24
93,291,605
0
0
null
null
null
null
UTF-8
Java
false
false
224
java
package com.ceeses.dao.mapper; import com.ceeses.model.Lnskfsx; import java.util.List; /** * Created by zhaoshan on 2017/6/4. */ public interface LnskfsxMapper { public List<Lnskfsx> queryLnskfsx(Integer year); }
[ "15572760238@163.com" ]
15572760238@163.com
2000868d6f45ab4051ea11a43d3d786131d18ba1
35b49d6ff547ef5062c83471da9f5183d86fde1b
/src/main/java/com/company/AlgorithmFactory.java
5725bac068deb2074359f5bfea3c55f6f8519856
[]
no_license
FernandoES/Master-thesis
26bf6a13dab2d0c362c9c15abd8710c6ed1a900c
b64a762fadc053526fbf191126771e232223a1e9
refs/heads/master
2020-03-30T10:13:32.165006
2018-12-01T23:20:41
2018-12-01T23:20:41
151,082,526
0
0
null
null
null
null
UTF-8
Java
false
false
1,644
java
package com.company; import java.lang.reflect.*; import java.util.*; import com.company.algorithms.*; public class AlgorithmFactory { public Algorithm getAlgorithm(String algorithmName, int numberOfGroups){ Algorithm algorithm = selectAlgorithm(algorithmName); algorithm.NUMBER_OF_GROUPS = numberOfGroups; return algorithm; } public static String[] availableAlgorithms = {"KMeansInternal","KMeansExternal","KMeansWeka","RandomCentersClustering", "RandomMembersClustering","RandomMembersClustering","ExpectationMaximization","CobwebAlgorithm","Hierarchical"}; private static Algorithm selectAlgorithm(String algorithmName) { Map<String, String> availableArrays = new HashMap<String, String>(); for (int i = 0; i <availableAlgorithms.length ; i++) { availableArrays.put(availableAlgorithms[i].toLowerCase() , availableAlgorithms[i]); } return getAlgorithmByName(availableArrays.get(algorithmName.toLowerCase())); } private static Algorithm getAlgorithmByName(String objectName){ try { String constructorWithPackage = "com.company.algorithms." + objectName; Class algorithmName = Class.forName(constructorWithPackage); Constructor constructor = algorithmName.getConstructor(); Algorithm algorithm = (Algorithm) constructor.newInstance(); return algorithm; } catch(Exception e){ System.out.println("Creation of class went wrong"); e.printStackTrace(); System.exit(1); return null; } } }
[ "fernan_1989@hotmail.com" ]
fernan_1989@hotmail.com
afe7889ffd523aaa1037fae49ff3f0ce09d56295
45d401809e5272a4605ab77fc5af28c279e01b95
/src/main/java/com/msdn/generator/service/FreemarkerService.java
46b2d99856d80b60bba06ef8d5e4698c77a5b1b9
[]
no_license
fmy1993/mybatisgenerator
721ae0c661eb99e5e044cc0788869dc3e8103785
b22404deaae7fdd38ba9f0ae08ba5c3f62b04730
refs/heads/master
2023-04-19T14:15:40.021681
2021-05-15T02:28:29
2021-05-15T02:28:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,511
java
package com.msdn.generator.service; import com.msdn.generator.entity.Config; import com.msdn.generator.entity.GenerateParameter; import com.msdn.generator.utils.StringUtils; import freemarker.cache.CacheStorage; import freemarker.cache.TemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.Map; /** * 使用FreeMarker 根据设定好的文件模板来生成相关文件 */ @Service public class FreemarkerService { private static final Logger logger = LoggerFactory.getLogger(FreemarkerService.class); @Autowired private Configuration configuration; /** * 输出文件模板 * * @param templateName resources 文件夹下的模板名,比如说model.ftl,是生成实体类的模块 * @param dataModel 表名,字段名等内容集合 * @param filePath 输出文件名,包括路径 * @param generateParameter * @throws Exception */ public void write(String templateName, Map<String, Object> dataModel, String filePath, GenerateParameter generateParameter) throws Exception { // FTL(freemarker templete language)模板的文件名称 Template template = configuration.getTemplate(dataModel.get("type") + File.separator + templateName + ".ftl"); File file; // 判断是不是多表,如果是,则按照表名生成各自的文件夹目录 if (generateParameter.isFlat()) { file = new File(Config.OutputPath + File.separator + dataModel.get("tempId") + File.separator + filePath); } else { file = new File(Config.OutputPath + File.separator + dataModel.get("tempId") + File.separator + dataModel.get("tableName") + File.separator + filePath); } if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } FileOutputStream fileOutputStream = new FileOutputStream(file); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8); template.process(dataModel, outputStreamWriter); fileOutputStream.flush(); fileOutputStream.close(); } }
[ "hkyy521@163.com" ]
hkyy521@163.com
b4e0bda611d2f9e5054de590f39e8dd802067dc4
36ec7e118a084c076ed911d69025766ace468ae5
/kodilla-hibernate/src/main/java/com/kodilla/hibernate/invoice/dao/ProductDao.java
b960e7bc4aa3717ea2630b34084f68d5562137ea
[]
no_license
andrzejsplewinski/Kodilla-Course
8a23815461d38c0d901fa165e9a5155be40ec7c2
08bb5c471948b2940f6e1a5d9185e578d6b0b294
refs/heads/master
2023-03-29T04:42:44.691089
2020-01-11T14:54:39
2020-01-11T14:54:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
353
java
package com.kodilla.hibernate.invoice.dao; import com.kodilla.hibernate.invoice.Product; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import javax.transaction.Transactional; @Transactional @Repository public interface ProductDao extends CrudRepository<Product, Integer> { }
[ "andrzej.splewinski@gmail.com" ]
andrzej.splewinski@gmail.com
cb52ff6cbfb7209deddf266004ac125af3bd5f23
fc435f02a7fe09497f722ca0fce77d16dcbd0dc6
/src/by/it/kudelich/lesson05/TaskB2.java
aac59fa7d8851dca96d02281d5bfcee696a7cf98
[]
no_license
DaryaLoban/cs2018-01-08
28b1f5c9301c3b1d0f6ad50393d9334f8b6215a6
4d3e626861d9ed3f00c8e48afd4272e379a3344c
refs/heads/master
2021-05-13T20:49:34.129814
2018-01-21T23:05:11
2018-01-21T23:05:11
116,920,507
0
0
null
2018-01-10T06:58:55
2018-01-10T06:58:55
null
UTF-8
Java
false
false
1,501
java
package by.it.kudelich.lesson05; /* Один большой массив и два маленьких 1. Создать массив m на 20 целых чисел. 2. Ввести в него значения с клавиатуры. 3. Создать два массива a и b на 10 целых чисел каждый. 4. Скопировать большой массив в два маленьких: половину чисел в первый маленький, вторую половину во второй маленький. 5. Вывести массивы a и b на экран командами: System.out.println("a="+Arrays.toString(a)); System.out.println("b="+Arrays.toString(b)); Например, для такого ввода 1 2 3 4 5 6 7 8 9 10 11 22 33 44 55 66 77 88 99 0 ожидается такой вывод: a=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] b=[11, 22, 33, 44, 55, 66, 77, 88, 99, 0] */ import java.util.Arrays; import java.util.Scanner; public class TaskB2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] m = new int[20]; for (int i = 0; i < m.length; i++) { m[i] = sc.nextInt(); } int[] a = new int[10]; int[] b = new int[10]; System.arraycopy(m, 0, a, 0, 10); System.arraycopy(m, 10, b, 0, 10); System.out.println("a="+Arrays.toString(a)); System.out.println("b="+ Arrays.toString(b)); } }
[ "kudeliches@gmail.com" ]
kudeliches@gmail.com
88ea78c807bde06fa3ef734008c17dd3f3160f27
b249461bae017c99c0723ebd8c163977d2ed442d
/src/main/java/com/handsetdetection/cache/NoCache.java
d9d7ccf2500bd03710b4f1e97e80fba9c223f495
[ "MIT" ]
permissive
HandsetDetection/detection-apikit-java
d9916b8ed99475756a56f27ce3705dd8a3fa7929
a5b6d0fb29c94d2fe123967e452ca4851cfe9fb1
refs/heads/master
2020-04-06T03:47:04.631585
2017-10-10T06:44:07
2017-10-10T06:44:07
95,067,096
1
1
null
2017-10-10T06:44:08
2017-06-22T02:40:00
Java
UTF-8
Java
false
false
2,027
java
/* * Copyright (c) 2017, Richard Uren <richard@teleport.com.au> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package com.handsetdetection.cache; import com.fasterxml.jackson.core.type.TypeReference; /** * */ public class NoCache implements Cache { final String name = "none"; public NoCache() { } @Override public Object get(String key, TypeReference ref) { return null; } @Override public boolean set(String key, Object data, int ttl) { return true; } @Override public boolean del(String key) { return true; } @Override public boolean flush() { return true; } @Override public String getName() { return this.name; } }
[ "thdls55@users.noreply.github.com" ]
thdls55@users.noreply.github.com
2f876e3cfec33b3ddc36940386e7bb304abc97e0
fc105a83971ff483bc0ca7eb65be519912ee8a0a
/Milestone2ClassesObjects/src/main/java/PersonCodeAlong/Person.java
cd7b6caf27ac9e3d43fb3f5d4bd8a4547160787e
[]
no_license
NarishSingh/SG2-Java-OOP
9db64113683f5ca8614fbbce1023393c4d6fd196
cce0d49c8fab2cbe0aff950b674d77c49e798968
refs/heads/master
2023-04-08T11:36:07.923534
2020-05-17T20:35:27
2020-05-17T20:35:27
255,391,704
1
0
null
null
null
null
UTF-8
Java
false
false
1,083
java
package PersonCodeAlong; public class Person { /*fields*/ private String name; private int age; private Address home; //uses address class /*ctors*/ /* public Person() { //default } */ public Person(String name, int age, Address home) { this.name = name; setAge(age); //we can use out setters in constructors to ensure proper field entry this.home = home; } /*getter/setter*/ public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public final void setAge(int age) { // finals makes this a constant method and stops the overridable method warning if (age > 0 && age < 120) { this.age = age; } else { throw new IllegalArgumentException("Invalid age."); } } /*behaviors*/ @Override public String toString() { return "Person{" + "name=" + name + ", age=" + age + ", home=" + home + '}'; } }
[ "narish.singh786@gmail.com" ]
narish.singh786@gmail.com
e7a8fb4778c23889e63ba7412782da045fce8c32
e6fff39054fc394395d38c5bcd4c3275b3bbdef5
/VisionPlusX/src/com/sv/visionplus/transaction/grn/GrnForm.java
85217eda7263156e9c3969e8670e610fbd65df06
[]
no_license
supervisiontec/Specs-Shop---Vision-Plus
0ea7111046d49b9631a9e574137822f429e95de4
5a76f10dba14d0befeb6a06f67c6a984b552684a
refs/heads/master
2023-03-06T09:40:48.508328
2021-02-17T19:50:54
2021-02-17T19:50:54
107,935,028
0
0
null
null
null
null
UTF-8
Java
false
false
754
java
package com.sv.visionplus.transaction.grn; import com.sv.visionplus.base.AbstractObjectCreator; import com.sv.visionplus.base.transaction.AbstractTransactionForm; import com.sv.visionplus.base.transaction.AbstractTransactionFormService; import com.sv.visionplus.transaction.grn.model.GrnMix; public class GrnForm extends AbstractTransactionForm<GrnMix> { private PCGrn grn; public GrnForm() {} protected AbstractTransactionFormService<GrnMix> getTransactionFormService() { return new GrnService(); } protected AbstractObjectCreator<GrnMix> getObjectCreator() { grn = new PCGrn(this); return grn; } public void doSave() { super.doSave(); if (grn != null) { grn.resetFields(); } } }
[ "chamara.kaza@gmail.com" ]
chamara.kaza@gmail.com
0febef08e3200fcc3e7c33bda0faeb12bbbd1395
eff9d1e6ce4032c7a2618cf8b40922401f3d1ce0
/ls-java-core/src/main/java/com/ls/lishuai/aqs/MutextDemo.java
e0cb8ff8e881324d4534dbab22397eaf32957046
[]
no_license
lishuai2016/all
67d8ff5db911ca5c38b249172d3dcbf4234d49d7
aa7d6774611c21e126e628268a6abd020138974f
refs/heads/master
2022-12-09T11:03:08.571479
2019-08-18T16:38:41
2019-08-18T16:38:44
200,311,974
5
4
null
2022-11-16T07:57:51
2019-08-03T00:08:21
Java
UTF-8
Java
false
false
621
java
package com.ls.lishuai.aqs; /** * @Author: lishuai * @CreateDate: 2018/8/3 17:18 */ public class MutextDemo { private static Mutex mutex = new Mutex(); public static void main(String[] args) { for (int i = 0; i < 10; i++) { Thread thread = new Thread(() -> { mutex.lock(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } finally { mutex.unlock(); } }); thread.start(); } } }
[ "1830473670@qq.com" ]
1830473670@qq.com
646ea779dc5373a3eae1a8cd724cfc9943c1eb96
2689a96a27b7d77bec4ba486baa9db8687645873
/HelloWorld/app/src/test/java/com/ceva/helloworld/ExampleUnitTest.java
1a97061cf06559e6585dd6a41a4673969b235b44
[]
no_license
barcvilla/android-studio-3
6b15ed1393989899253e78d38af53b7d22b869fb
9e4fac40d3ba118a85d61cc9f9ca0269b6672ac8
refs/heads/master
2020-03-10T10:01:25.098001
2018-05-25T21:10:08
2018-05-25T21:10:08
129,324,223
0
0
null
null
null
null
UTF-8
Java
false
false
380
java
package com.ceva.helloworld; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
[ "barcvilla@gmail.com" ]
barcvilla@gmail.com
4702560385d8c9624dcfd23324b514b68dd50e0c
3b91ed788572b6d5ac4db1bee814a74560603578
/com/tencent/mm/plugin/gallery/ui/ImagePreviewUI$17.java
030c09a3abb5f0ac3abc219610fccc17a3a65c6a
[]
no_license
linsir6/WeChat_java
a1deee3035b555fb35a423f367eb5e3e58a17cb0
32e52b88c012051100315af6751111bfb6697a29
refs/heads/master
2020-05-31T05:40:17.161282
2018-08-28T02:07:02
2018-08-28T02:07:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
504
java
package com.tencent.mm.plugin.gallery.ui; import com.tencent.mm.plugin.gallery.model.m; import com.tencent.mm.plugin.gallery.model.m.a; class ImagePreviewUI$17 implements a { final /* synthetic */ ImagePreviewUI jEa; ImagePreviewUI$17(ImagePreviewUI imagePreviewUI) { this.jEa = imagePreviewUI; } public final void a(m mVar) { if (mVar.position == ImagePreviewUI.g(this.jEa).intValue()) { ImagePreviewUI.a(this.jEa, mVar.path, mVar.jBs); } } }
[ "707194831@qq.com" ]
707194831@qq.com
b34918ac783e749871bb35465638365b3e38e53f
1e8f616605bb5af4890a25875119eaa8bb847d69
/src/com/class31/TestParent.java
2d1c44341478325b7af52378e805e5f126231da6
[]
no_license
hasansinan17/BatchVJavaClasses
418743f42627cf8a99f09477135ba026a1578a1e
4e4de21841c43829865dbb44a3ad3929adf4925a
refs/heads/master
2020-09-04T21:06:45.945960
2020-02-04T22:00:03
2020-02-04T22:00:03
219,891,902
0
0
null
null
null
null
UTF-8
Java
false
false
133
java
package com.class31; public class TestParent { public static void main(String[] args) { Parent p=new Child(); p.hello(); } }
[ "hsinangh@gmail.com" ]
hsinangh@gmail.com
8d2a9dbc6623db17ac01a89a5c7294ba79560a78
162fe280496f033542297df6a2b41292644262ee
/fresh-fruits-goods-service/src/main/java/com/fresh/fruits/service/impl/ItemServiceImpl.java
394c034789ffecf7487b0ec1d67ce8d1f43b3e75
[]
no_license
AJ990716/fresh-fruits
fc6e807f6d95d7785b0bf11ead899738c05925a7
d4716a35c5975c5aaf3adae452409aabb7d0e7ad
refs/heads/master
2023-06-17T09:35:29.879796
2021-07-22T04:15:17
2021-07-22T04:15:17
388,309,612
0
0
null
null
null
null
UTF-8
Java
false
false
545
java
package com.fresh.fruits.service.impl; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fresh.fruits.dao.ItemDao; import com.fresh.fruits.pojo.ItemEntity; import com.fresh.fruits.service.ItemService; @Service("itemService") public class ItemServiceImpl extends ServiceImpl<ItemDao, ItemEntity> implements ItemService { }
[ "319067125@qq.com" ]
319067125@qq.com
fa292b2b6fb8738b30c8a6fcbe96929b972f9e49
461acdfede26ba5e0c53e47c54f36155c3b34cee
/Java_22_FileSampleData/src/com/biz/files/service/NameService.java
211e51315fdf39c000c2a129edad58ef0b02665b
[]
no_license
qussoa/20191002
dc5e13a0a7e35079aeb4a028c919cd8c310b5caf
2843d602c09a49ff0980af79743fdf49b1295def
refs/heads/master
2020-08-04T21:17:58.279045
2019-11-04T07:42:55
2019-11-04T07:42:55
212,282,154
0
0
null
null
null
null
UTF-8
Java
false
false
255
java
package com.biz.files.service; public interface NameService { public void readNameList(String nameFile) throws Exception; public void readFamList(String famFile) throws Exception; public void writeNameFile(String korNameFile) throws Exception; }
[ "qussoa@naver.com" ]
qussoa@naver.com
50e7cd99f4f8f71b94b73dc626ac814c1db899fd
584ccf5c7bbf0185c3cede2d30ec309d40af4a14
/java/exercicios/src/Out7/MaiorInteiro.java
69f239f98c1c176d6ff29184089e7cfbfa14bacb
[]
no_license
WashingtonPSantos/turma11java
53fe4433b503a4626b24906d7f491d19de244098
8f2845a828955c855a51db7ab79937b7eb1b365b
refs/heads/master
2023-01-09T02:55:12.179821
2020-11-08T23:15:31
2020-11-08T23:15:31
298,044,432
0
0
null
null
null
null
WINDOWS-1252
Java
false
false
1,001
java
package Out7; import java.util.Scanner; public class MaiorInteiro { public static void main(String[] args) { // 1- Faça um programa que receba três inteiros e diga qual deles é o maior. Scanner leia = new Scanner(System.in); int a,b,c; System.out.print("Digite o valor de a: "); a = leia.nextInt(); System.out.print("Digite o valor de b: "); b = leia.nextInt(); System.out.print("Digite o valor de c: "); c= leia.nextInt(); //System.out.println("O valor de a é: "+a+". O valor de b é: "+b+". O valor de c é:"+c); if (a>=b){ //System.out.println("a é maior que b"); if (a>=c) { System.out.println(" a é o maior"); } } if (b>=a){ //System.out.println("a é maior que b"); if (b>=c) { System.out.println(" b é o maior"); } } if (c>=a){ //System.out.println("a é maior que b"); if (c>=b) { System.out.println(" c é o maior"); } } else { System.out.println(" A,b e C são iguais"); } } }
[ "washington_pereira@hotmail.com" ]
washington_pereira@hotmail.com
04bdd37b97ff9b6e44a1b712bb838c9ed6a9b07f
c3e183b9b3ff1a511c6182893d70aaa352c167f0
/src/main/java/com/m2m/domain/TagTrainSampleWithBLOBs.java
cd3faf0b2b0899b80610d1227d414d386a0adaae
[]
no_license
hushunjian/rest
a47a6e00b038eb5fb635ec4362ff0b6a5a92813b
15b49ada2725bdba17a92986ed8372a0d56ef748
refs/heads/master
2021-05-04T12:33:54.762619
2018-02-05T11:37:10
2018-02-05T11:37:10
120,258,667
0
0
null
null
null
null
UTF-8
Java
false
false
2,031
java
package com.m2m.domain; public class TagTrainSampleWithBLOBs extends TagTrainSample { /** * This field was generated by MyBatis Generator. * This field corresponds to the database column tag_train_sample.summary * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ private String summary; /** * This field was generated by MyBatis Generator. * This field corresponds to the database column tag_train_sample.keywords * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ private String keywords; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column tag_train_sample.summary * * @return the value of tag_train_sample.summary * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ public String getSummary() { return summary; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column tag_train_sample.summary * * @param summary the value for tag_train_sample.summary * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ public void setSummary(String summary) { this.summary = summary == null ? null : summary.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column tag_train_sample.keywords * * @return the value of tag_train_sample.keywords * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ public String getKeywords() { return keywords; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column tag_train_sample.keywords * * @param keywords the value for tag_train_sample.keywords * * @mbggenerated Thu Jan 11 17:51:54 CST 2018 */ public void setKeywords(String keywords) { this.keywords = keywords == null ? null : keywords.trim(); } }
[ "hushunjian950420@163.com" ]
hushunjian950420@163.com
7a7c1d8b793c04a33854a4f939e6c7d80ee0eb97
ce07325c9ad45b771849ebb6d82ad1b0c1bf677d
/src/libro/cap02/excepciones/Aplicacion.java
eead9efc24fd529de953e38909e79ca11067845f
[]
no_license
abrahan0108/JavaAFondo
88c45d1fe19b7e9315c26e9c531e476f8cb9f74f
886770013843196766a6790dd693f600090909ec
refs/heads/master
2020-06-22T19:14:24.119764
2019-07-19T14:26:20
2019-07-19T14:26:20
197,785,473
0
0
null
null
null
null
UTF-8
Java
false
false
1,161
java
package libro.cap02.excepciones; import java.util.ResourceBundle; public class Aplicacion { public Usuario login(String usrname, String password) throws ErrorFisicoException { try { // Se lee el archivo de propiedades que debe estar ubicado en el // package root ResourceBundle rb = ResourceBundle.getBundle("usuario"); // leemos el valor de la propiedad usrname String usr = rb.getString("usrname"); // leemos el valor de la propiedad password String pwd = rb.getString("password"); // Se define una variable de retorno Usuario u = null; //si coinciden los datos proporcionados con los leidos if(usr.equals(usrname) && pwd.equals(password)) { //intancio y seteo todos los datos u = new Usuario(); u.setUsuario(usr); u.setPassword(pwd); u.setNombre(rb.getString("nombre")); u.setEmail(rb.getString("email")); } // retorno la instancia o null si no entró al if return u; }catch (Exception e) { // Cualquier error "salgo por excepcion" throw new RuntimeException("Error verificando datos", e); } } }
[ "f8abrahan@gmail.com" ]
f8abrahan@gmail.com
b39c86080f3fa89bb0661db8149e3795e6390e5b
958aa7834f07b09862eda5e73b4465e64294fb38
/src/main/java/com/sun/structure/FixedCapacityStackOfString.java
ed09c071f296cca788879c3d5a5d916044d0e946
[]
no_license
sunwnehongl/Algorithms
12e6ba58a24ffb5879adba00783f711c4adc481e
b1d3d83ed9e1da999c75492abdbd88bf5ede99a6
refs/heads/master
2022-06-27T04:32:00.993215
2022-06-18T15:31:41
2022-06-18T15:31:41
148,800,547
0
0
null
2020-10-13T14:01:15
2018-09-14T14:33:41
Java
GB18030
Java
false
false
1,050
java
package com.sun.structure; /** * @Auther: swh * @Date: 2019/6/10 23:07 * @Description: 固定容量的字符串栈的实现 */ public class FixedCapacityStackOfString { // 栈实现用来存放栈内容的字符串数组 private String [] items; // 栈当前的大小,也是下一个栈顶值得下标 private int size; /*** * 固定容量字符串栈的构造器,只有一个参数为固定栈的容量 * @param initCapacity 栈的容量 */ public FixedCapacityStackOfString(int initCapacity) { if (initCapacity > 0) { items = new String[initCapacity]; }else{ throw new IllegalArgumentException("Illegal Capacity: "+initCapacity); } } /*** * 栈的push方法,向栈顶添加一个字符串 * @param item 向栈顶添加的字符串 */ public void push(String item) { items[size++] = item; } public String pop() { return items[--size]; } public int size() { return size; } }
[ "30740977+sunwnehongl@users.noreply.github.com" ]
30740977+sunwnehongl@users.noreply.github.com
5b2462a91c851b6f46c4028c2309c17d556d961d
eae7d9e7ba55065dfa63c25a4721122648c794cd
/EX_ReprDados/src/EX_01/TCPcliente.java
8f15e278ac57d3ac7aa206a3a9c8ecb0f5e998f3
[]
no_license
matheussguerra/SistemasDistribuidosListas
f89d20d4f30376dc36ccef95ba2f45accaa58206
6a2116358879643a1b493bda3d0f27d21557481f
refs/heads/master
2021-07-23T20:36:57.358997
2017-11-05T03:00:54
2017-11-05T03:00:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,063
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 EX_01; /** * * @author guerra */ /** * TCPClient: Cliente para conexao TCP * Descrição: Envia uma informacao ao servidor e finaliza a conexao */ import java.net.*; import java.io.*; import java.util.ArrayList; /** * * @author rodrigo */ public class TCPcliente { public static void main (String args[]) { Compromisso a,b; Socket s; ObjectOutputStream objOut; try { System.out.println ("Criando instâncias da classe Pessoa ...\n"); a = new Compromisso ("Entregar lista 3 de SD", "29/09/2017", "13:00"); b = new Compromisso("Entrgar lista de análise", "03/10/2017", "13:00"); System.out.println ("Conectando ao servidor ...\n"); s = new Socket ("localhost",6666); System.out.println ("Criando objetos de leitura/escrita ...\n"); objOut = new ObjectOutputStream (s.getOutputStream()); System.out.println ("Enviando objetos serializados ...\n"); objOut.writeObject(a); objOut.writeObject(b); objOut.flush(); DataOutputStream out =new DataOutputStream( s.getOutputStream()); System.out.println("Solicitando listagem..."); out.writeUTF("listar"); ObjectInputStream objIn = new ObjectInputStream (s.getInputStream()); ArrayList<Compromisso> lista = (ArrayList<Compromisso>) objIn.readObject(); System.out.println("Listando:\n"+ lista.get(0).toString() + "\n" + lista.get(1).toString()); System.out.println ("Finalizado."); } catch (Exception e) { System.out.println(e); } //catch } //main }
[ "guerramatheus2@gmail.com" ]
guerramatheus2@gmail.com
c76e0f2f478d22d37efd811a62748394f91e81c9
6930feb27097f713cfb9d113aa384ce5bbb5dba7
/src/main/java/com/crud/tasks/TasksApplication.java
25bba3f766543977ffcf9f89de1bb5ac31ebbb4e
[]
no_license
DawidBadura/SpringWeb-
a215385a0ead3fb6aee45c894936a7e941db1c59
1cc9b7838570b00b51cf7bcd11c633fe91806083
refs/heads/master
2023-03-22T03:36:36.416802
2021-03-16T21:38:35
2021-03-16T21:38:35
277,657,750
0
0
null
null
null
null
UTF-8
Java
false
false
519
java
package com.crud.tasks; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class TasksApplication/* extends SpringBootServletInitializer*/ { /* @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(TasksApplication.class); }*/ public static void main(String[] args) { SpringApplication.run(TasksApplication.class, args); } }
[ "dawid.badurakrk@gmail.com" ]
dawid.badurakrk@gmail.com
e5f4c56be80cb83ba81c8f42dd50fc6524ec4678
599fd53841c8c3e25c2801108ff356f8cc2a2cab
/M101J/src/main/java/com/home/mongodb/m101j/crud/FindTest.java
583206e694b67d347f14139b4944179b7bff002c
[]
no_license
DineshPatri/MongoDB
d485274a9746ad0ca3878007626afc849b9b83eb
cb94dcf6faafb825261256057022221dfed9223d
refs/heads/master
2020-04-08T07:08:07.115403
2018-12-09T18:09:14
2018-12-09T18:09:14
159,128,207
0
0
null
2018-12-09T18:09:15
2018-11-26T07:28:49
null
UTF-8
Java
false
false
2,234
java
/* * Copyright 2015 MongoDB, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.home.mongodb.m101j.crud; import com.mongodb.MongoClient; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import com.mongodb.client.MongoDatabase; import org.bson.Document; import javax.print.Doc; import java.util.ArrayList; import java.util.List; import java.util.Random; import static com.home.mongodb.m101j.util.Helpers.printJson; public class FindTest { public static void main(String[] args) { MongoClient client = new MongoClient(); MongoDatabase database = client.getDatabase("course"); MongoCollection<Document> collection = database.getCollection("findTest"); collection.drop(); // insert 10 documents for (int i = 0; i < 10; i++) { collection.insertOne(new Document("x", i)); } System.out.println("Find one:"); Document first = collection.find().first(); printJson(first); System.out.println("Find all with into: "); List<Document> all = collection.find().into(new ArrayList<Document>()); for (Document cur : all) { printJson(cur); } System.out.println("Find all with iteration: "); try(MongoCursor<Document> cursor = collection.find().iterator();){//need to close the cursor, to avoid memory leaks when exceptions occur while (cursor.hasNext()) { Document cur = cursor.next(); printJson(cur); } } System.out.println("Count:"); long count = collection.countDocuments();//count() is deprecated; System.out.println(count); } }
[ "DP052402@cerner.net" ]
DP052402@cerner.net
9d3d3c658798809ef66df404533e0947bd7b9e44
7b40d383ff3c5d51c6bebf4d327c3c564eb81801
/src/android/support/v4/view/ViewGroupCompat$ViewGroupCompatJellybeanMR2Impl.java
0192c5520186ed186a5cd330ce1fc2382dc721ef
[]
no_license
reverseengineeringer/com.yik.yak
d5de3a0aea7763b43fd5e735d34759f956667990
76717e41dab0b179aa27f423fc559bbfb70e5311
refs/heads/master
2021-01-20T09:41:04.877038
2015-07-16T16:44:44
2015-07-16T16:44:44
38,577,543
2
0
null
null
null
null
UTF-8
Java
false
false
629
java
package android.support.v4.view; import android.view.ViewGroup; class ViewGroupCompat$ViewGroupCompatJellybeanMR2Impl extends ViewGroupCompat.ViewGroupCompatIcsImpl { public int getLayoutMode(ViewGroup paramViewGroup) { return ViewGroupCompatJellybeanMR2.getLayoutMode(paramViewGroup); } public void setLayoutMode(ViewGroup paramViewGroup, int paramInt) { ViewGroupCompatJellybeanMR2.setLayoutMode(paramViewGroup, paramInt); } } /* Location: * Qualified Name: android.support.v4.view.ViewGroupCompat.ViewGroupCompatJellybeanMR2Impl * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */
[ "reverseengineeringer@hackeradmin.com" ]
reverseengineeringer@hackeradmin.com
2236bfe54f0dd5ab2cc771887e8cf59c6f922490
a375989d20ba4a68672f4eea6659bc6a7861e568
/HackVG/app/src/main/java/com/hackvg/android/di/modules/DomainModule.java
a9b66281eeac07d329c1313ffbaf10d8d0652d62
[ "Apache-2.0" ]
permissive
gooYangFeng/Material-Movies
cf765c62812279304d11640a8c1f94b85fc2548e
0ebdd973148ca235abe061871fe9486deecd2c48
refs/heads/master
2020-05-23T10:10:45.012404
2015-11-26T10:12:39
2015-11-26T10:12:39
36,914,425
0
1
null
2015-06-05T05:49:08
2015-06-05T05:49:08
null
UTF-8
Java
false
false
1,019
java
/* * Copyright (C) 2015 Saúl Molinero. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hackvg.android.di.modules; import com.hackvg.model.rest.RestMovieSource; import com.squareup.otto.Bus; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; @Module public class DomainModule { @Provides @Singleton Bus provideBus () { return new Bus(); } @Provides @Singleton RestMovieSource provideDataSource (Bus bus) { return new RestMovieSource(bus); } }
[ "saulmm2@gmail.com" ]
saulmm2@gmail.com
24c17799879d6d2dede6b02eeb410e58348c4069
eb349e08462a1363237054d3bf522ac9c68a8238
/src/FizzBuzz.java
914e21f8e3eb262c917474d59b50c5aa4562da34
[]
no_license
Miss-qi/week_2nd
67a38ba28cf948ba1121fc07a7af9c8c26d4216f
9e5d86ecf878f41a93f565358c0c1e63335851aa
refs/heads/master
2021-01-01T05:54:23.731992
2017-07-15T07:48:09
2017-07-15T07:48:09
97,300,591
0
0
null
null
null
null
UTF-8
Java
false
false
518
java
public class FizzBuzz { public static void main(String[] args) { fizzBuzz(); } public static void fizzBuzz() { for (int i = 1; i <= 15; i++) { if (i % 3 == 0 && i % 5 == 0) { System.out.println("FizzBuzz"); } else if (i % 3 == 0) { System.out.println("Fizz"); } else if (i % 5 == 0) { System.out.println("Buzz"); } else { System.out.println(i); } } } }
[ "1370322806@qq.com" ]
1370322806@qq.com
c48d3d2ecdc0f8a17e0b9ca000807854dde6bff1
e43b47beb5e1d79637ccc2b6ae92977b659ec338
/app/src/main/java/com/imyyq/rvshowtime/ExampleFragment.java
647738a8827814f9a7c5e45319e91ee73d131a9d
[]
no_license
imyyq-star/RvShowTimeLib
fbff12716938f35343e9b8445266eef215cad645
22b03bcac800ae449ffca69a6b4ad864059291b4
refs/heads/master
2022-08-01T22:12:59.753016
2020-05-20T09:00:35
2020-05-20T09:00:35
265,505,749
2
0
null
null
null
null
UTF-8
Java
false
false
1,089
java
package com.imyyq.rvshowtime; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.imyyq.rvshowtime.databinding.FragmentExampleBinding; import com.imyyq.showtime.RvShowTimeInterface; public class ExampleFragment extends Fragment implements RvShowTimeInterface { private FragmentExampleBinding binding; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentExampleBinding.inflate(inflater); return binding.getRoot(); } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.i("ExampleFragment", "commonLog - onActivityCreated: "+getFragmentManager()); RvUtil.initRv(getFragmentManager(), this, binding.rv); } }
[ "imyyq.star@gmail.com" ]
imyyq.star@gmail.com
703fe0b0a0d5bc7e7b8011f07241f756b38c36c8
95ee120f82dddd550af025a760f496fbdc4ec099
/src/com/javarush/test/level27/lesson15/big01/statistic/StatisticEventManager.java
214a99858fdbdc999bfe69cd6ade91b1e5c3d9de
[]
no_license
vsprog/JavaRushHomeWork
863ce30d48b28e468fa9a60b5747893ba82fe468
faadfb3a28d3adbd892577e3ff5efa1aa6fe7e87
refs/heads/master
2021-06-10T13:17:24.199933
2017-01-23T05:51:13
2017-01-23T05:51:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,701
java
package com.javarush.test.level27.lesson15.big01.statistic; import com.javarush.test.level27.lesson15.big01.kitchen.Cook; import com.javarush.test.level27.lesson15.big01.statistic.event.CookedOrderEventDataRow; import com.javarush.test.level27.lesson15.big01.statistic.event.EventDataRow; import com.javarush.test.level27.lesson15.big01.statistic.event.EventType; import com.javarush.test.level27.lesson15.big01.statistic.event.VideoSelectedEventDataRow; import java.util.*; public class StatisticEventManager { private static final StatisticEventManager ourInstance = new StatisticEventManager(); private StatisticStorage storage = new StatisticStorage(); public static StatisticEventManager getInstance() { return ourInstance; } private StatisticEventManager() { } public void register(EventDataRow data) { storage.put(data); } private static class StatisticStorage { private Map<EventType, List<EventDataRow>> eventMapStorage = new HashMap<>(); private StatisticStorage() { for (EventType eventType : EventType.values()) { eventMapStorage.put(eventType, new ArrayList<EventDataRow>()); } } private void put(EventDataRow data) { eventMapStorage.get(data.getType()).add(data); } private List<EventDataRow> getEvents(EventType eventType) { return eventMapStorage.get(eventType); } } private static final int[] TIME_FIELDS = { Calendar.HOUR_OF_DAY, Calendar.HOUR, Calendar.AM_PM, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND }; public TreeMap<Date, Long> getAdvertisementRevenueAgregatedByDay() { TreeMap<Date, Long> result = new TreeMap<>(); for (EventDataRow eventDataRow : storage.getEvents(EventType.SELECTED_VIDEOS)) { VideoSelectedEventDataRow vEventDataRow = (VideoSelectedEventDataRow) eventDataRow; GregorianCalendar gDate = new GregorianCalendar(); gDate.setTime(vEventDataRow.getDate()); for(int i : TIME_FIELDS) gDate.clear(i); Date date = gDate.getTime(); Long dayRevenue = result.get(date) ; if (dayRevenue == null) dayRevenue = Long.valueOf(0); result.put(date, dayRevenue + vEventDataRow.getAmount()); } return result; } public TreeMap<Date, HashMap<String, Integer>> getCookWorkloadingAgregatedByDay() { TreeMap<Date, HashMap<String, Integer>> result = new TreeMap<>(); for (EventDataRow eventDataRow : storage.getEvents(EventType.COOKED_ORDER)) { CookedOrderEventDataRow cookDataRow = (CookedOrderEventDataRow) eventDataRow; GregorianCalendar gDate = new GregorianCalendar(); gDate.setTime(cookDataRow.getDate()); for(int i : TIME_FIELDS) gDate.clear(i); Date date = gDate.getTime(); HashMap<String, Integer> cooksNameWorkDuration = result.get(date); if (cooksNameWorkDuration == null) { cooksNameWorkDuration = new HashMap<>(); result.put(date, cooksNameWorkDuration); } String cookName = cookDataRow.getCookName(); Integer cookWorkDuration = cooksNameWorkDuration.get(cookName); if (cookWorkDuration == null) cookWorkDuration = Integer.valueOf(0); cooksNameWorkDuration.put(cookName, cookWorkDuration + cookDataRow.getTime()); } return result; } }
[ "chmolekula@gmail.com" ]
chmolekula@gmail.com
33df97ed6a4893e516208f0f1e24405787b9834d
ea2917b369d3bf693b0e475e8aecc22a2acf959a
/src/java/controle/UsuarioWS.java
8684b46d6343d8ca88e6bc8af2b412fa774ddb8c
[]
no_license
renataeb/TCC
16730b391363966880243791e2c883a6c750f167
5cc1d92b9b987e2b9a439c9cdc337d8b822e5e73
refs/heads/master
2020-08-10T21:11:53.767688
2019-10-11T11:48:37
2019-10-11T11:48:37
214,421,598
0
0
null
null
null
null
UTF-8
Java
false
false
6,331
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 controle; import dao.AdminDAO; import dao.UsuarioDAO; import java.io.IOException; import java.io.PrintWriter; import java.security.NoSuchAlgorithmException; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import modelo.Usuario; import util.Criptografia; /** * * @author Aluno */ @WebServlet(name = "UsuarioWS", urlPatterns = {"/controle/UsuarioWS"}) public class UsuarioWS extends HttpServlet { private UsuarioDAO dao; private Usuario obj; private String pagina; private String acao; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { acao = request.getParameter("acao"); List<Usuario> lista = null; String id; switch(String.valueOf(acao)){ case "del": id = request.getParameter("id"); dao = new UsuarioDAO(); pagina = "index.jsp"; obj = dao.buscarPorChavePrimaria(Long.parseLong(id)); Usuario usu_sessao = (Usuario)request.getSession().getAttribute("usuario"); if(usu_sessao.getId()==Long.parseLong(id)){ lista = dao.listar(); request.setAttribute("lista", lista); request.setAttribute("msg", "Você não pode excluir o Usuario que esta logado."); }else{ Boolean deucerto = dao.excluir(obj); if(deucerto){ lista = dao.listar(); request.setAttribute("lista", lista); request.setAttribute("msg", "Excluído com sucesso"); } else{ request.setAttribute("msg", "Erro ao excluir"); } } break; case "edit": id = request.getParameter("id"); dao = new UsuarioDAO(); Usuario obj = dao.buscarPorChavePrimaria(Long.parseLong(id)); request.setAttribute("obj", obj); pagina = "edita.jsp"; break; case "sair": request.getSession().setAttribute("usuario",new Usuario()); request.setAttribute("msg", "Você se deslogou com sucesso!"); pagina = "../login/login.jsp"; break; default: dao = new UsuarioDAO(); if (request.getParameter("filtro") != null) { try { lista = dao.listar(request.getParameter("filtro")); } catch (Exception ex) { Logger.getLogger(AdminWS.class.getName()).log(Level.SEVERE, null, ex); } } else { lista = dao.listar(); } //pra onde deve ser redirecionada a página pagina = "index.jsp"; //passar a listagem para a página request.setAttribute("lista", lista); break; } RequestDispatcher destino = request.getRequestDispatcher(pagina); destino.forward(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String msg; request.setCharacterEncoding("UTF-8"); //verificar campos obrigatórios if(request.getParameter("txtNome") == null){ msg = "Campos obrigatórios não informados"; } else{ dao = new UsuarioDAO(); obj = new Usuario(); //preencho o objeto com o que vem do post Boolean deucerto; if(request.getParameter("txtId")!= null){ obj = dao.buscarPorChavePrimaria(Long.parseLong(request.getParameter("txtId"))); obj.setNome(request.getParameter("txtNome")); obj.setEmail(request.getParameter("txtEmail")); try { obj.setSenha(Criptografia.convertPasswordToMD5(request.getParameter("txtSenha"))); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(UsuarioWS.class.getName()).log(Level.SEVERE, null, ex); } deucerto = dao.alterar(obj); pagina="edita.jsp"; } else{ obj.setNome(request.getParameter("txtNome")); obj.setEmail(request.getParameter("txtEmail")); try { String criptografia = Criptografia.convertPasswordToMD5(request.getParameter("txtSenha")); obj.setSenha(criptografia); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(UsuarioWS.class.getName()).log(Level.SEVERE, null, ex); } deucerto = dao.incluir(obj); pagina="../usuario/add.jsp"; } if(deucerto){ msg = "Operação realizada com sucesso"; } else{ msg = "Erro ao realizar a operação"; } } dao.fecharConexao(); request.setAttribute("msg", msg); RequestDispatcher destino = request.getRequestDispatcher(pagina); destino.forward(request, response); } }
[ "Aluno@NTI-HP" ]
Aluno@NTI-HP
7ccc3319e8c37f888dba1269b02b86f8bc4e6464
15c5eadf6c6a4d3fa5bf5eb66f22e1cabd49df2c
/WeChatApp/WeChatApp/src/main/java/com/jisu/WeChatApp/pojo/MemberProhi.java
282ad74fab2223fb89d5dfd2b07546b0135625e4
[]
no_license
RunzhiH/WeChatApp
8eb168f94526fa87d6563e5a55e4a297234476b2
40f40bcfb588305a8923ce86085499c78a2835c7
refs/heads/master
2021-07-02T16:02:35.120383
2020-10-19T07:16:20
2020-10-19T07:16:20
186,799,624
0
0
null
2020-10-19T07:16:22
2019-05-15T09:59:34
JavaScript
UTF-8
Java
false
false
5,579
java
package com.jisu.WeChatApp.pojo; import java.util.Date; public class MemberProhi { /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.member_prohi_id * @mbg.generated */ private String memberProhiId; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.prohi_status * @mbg.generated */ private Integer prohiStatus; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.prohi_type * @mbg.generated */ private Integer prohiType; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.member_no * @mbg.generated */ private String memberNo; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.member_type * @mbg.generated */ private Integer memberType; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.prohi_time * @mbg.generated */ private Integer prohiTime; /** * This field was generated by MyBatis Generator. This field corresponds to the database column member_prohi.create_time * @mbg.generated */ private Date createTime; /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.member_prohi_id * @return the value of member_prohi.member_prohi_id * @mbg.generated */ public String getMemberProhiId() { return memberProhiId; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.member_prohi_id * @param memberProhiId the value for member_prohi.member_prohi_id * @mbg.generated */ public void setMemberProhiId(String memberProhiId) { this.memberProhiId = memberProhiId == null ? null : memberProhiId.trim(); } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.prohi_status * @return the value of member_prohi.prohi_status * @mbg.generated */ public Integer getProhiStatus() { return prohiStatus; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.prohi_status * @param prohiStatus the value for member_prohi.prohi_status * @mbg.generated */ public void setProhiStatus(Integer prohiStatus) { this.prohiStatus = prohiStatus; } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.prohi_type * @return the value of member_prohi.prohi_type * @mbg.generated */ public Integer getProhiType() { return prohiType; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.prohi_type * @param prohiType the value for member_prohi.prohi_type * @mbg.generated */ public void setProhiType(Integer prohiType) { this.prohiType = prohiType; } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.member_no * @return the value of member_prohi.member_no * @mbg.generated */ public String getMemberNo() { return memberNo; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.member_no * @param memberNo the value for member_prohi.member_no * @mbg.generated */ public void setMemberNo(String memberNo) { this.memberNo = memberNo == null ? null : memberNo.trim(); } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.member_type * @return the value of member_prohi.member_type * @mbg.generated */ public Integer getMemberType() { return memberType; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.member_type * @param memberType the value for member_prohi.member_type * @mbg.generated */ public void setMemberType(Integer memberType) { this.memberType = memberType; } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.prohi_time * @return the value of member_prohi.prohi_time * @mbg.generated */ public Integer getProhiTime() { return prohiTime; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.prohi_time * @param prohiTime the value for member_prohi.prohi_time * @mbg.generated */ public void setProhiTime(Integer prohiTime) { this.prohiTime = prohiTime; } /** * This method was generated by MyBatis Generator. This method returns the value of the database column member_prohi.create_time * @return the value of member_prohi.create_time * @mbg.generated */ public Date getCreateTime() { return createTime; } /** * This method was generated by MyBatis Generator. This method sets the value of the database column member_prohi.create_time * @param createTime the value for member_prohi.create_time * @mbg.generated */ public void setCreateTime(Date createTime) { this.createTime = createTime; } }
[ "hongrunzhi@126.com" ]
hongrunzhi@126.com
c5915e9025d2e7b7c9cffa1ebb2b2d40514477ca
929557608e958cf7628b9e0bad8ac937c1ba7cd8
/src/main/java/hudson/plugins/analysis/core/AntBuilderCheck.java
92ba5ccf1b8d264283df4c90c024f5247ad6699a
[ "MIT" ]
permissive
loelala/analysis-core-plugin
2d56d3ac2bfc65f6d93bbfe259ac4e78ea741557
13edc435dae4ac8a8ee274011fc7216a1e51c88c
refs/heads/master
2021-04-15T19:00:54.583925
2018-03-12T09:55:29
2018-03-12T09:55:29
126,339,983
0
0
MIT
2018-04-23T09:43:59
2018-03-22T13:32:40
Java
UTF-8
Java
false
false
1,071
java
package hudson.plugins.analysis.core; import hudson.model.AbstractBuild; import hudson.model.Project; import hudson.tasks.Builder; import hudson.tasks.Ant; /** * Verifies if the build is an {@link Ant} task. * * @author Ulli Hafner */ public final class AntBuilderCheck { /** * Returns whether the current build uses ant. * * @param build * the current build * @return <code>true</code> if the current build uses ant, * <code>false</code> otherwise */ public static boolean isAntBuild(final AbstractBuild<?, ?> build) { if (build.getProject() instanceof Project) { Project<?, ?> project = (Project<?, ?>)build.getProject(); for (Builder builder : project.getBuilders()) { if (builder instanceof Ant) { return true; } } } return false; } /** * Creates a new instance of {@link AntBuilderCheck}. */ private AntBuilderCheck() { // prevent instantiation } }
[ "ullrich.hafner@gmail.com" ]
ullrich.hafner@gmail.com
4c46f34019c1a4a38744e00a85ecfd1115c022a0
7fe906aa8eebb9fb61a7bdc9ca1edf9989d28dc5
/egg-facade/src/main/java/com/egg/manager/persistence/em/user/db/mysql/mapper/EmUserRoleMapper.java
09eebb53773a562baf5dcf009cec62fa5f854002
[ "Apache-2.0" ]
permissive
lanlandetiankong/egg_manager
aad0f304233665ed87cb47c2c86945000d0b4997
868b3d74f1a94d303ef39ea1bd8171ab405c96b9
refs/heads/master
2022-09-11T05:06:40.576855
2021-02-03T13:48:48
2021-02-03T13:48:48
208,092,096
0
1
Apache-2.0
2022-09-01T23:13:00
2019-09-12T16:10:14
Java
UTF-8
Java
false
false
2,034
java
package com.egg.manager.persistence.em.user.db.mysql.mapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.egg.manager.persistence.commons.base.constant.db.mysql.EggMpSqlConst; import com.egg.manager.persistence.commons.base.query.pagination.antdv.AntdvSortMap; import com.egg.manager.persistence.commons.base.query.pagination.antdv.QueryFieldArr; import com.egg.manager.persistence.em.user.db.mysql.entity.EmUserAccountEntity; import com.egg.manager.persistence.em.user.db.mysql.entity.EmUserRoleEntity; import com.egg.manager.persistence.em.user.pojo.dto.EmUserRoleDto; import com.egg.manager.persistence.exchange.db.mysql.mapper.MyEggMapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @author zhoucj * @description * @date 2020/10/20 */ public interface EmUserRoleMapper extends MyEggMapper<EmUserRoleEntity> { /** * [分页搜索查询] - 用户角色 * @param page * @param queryFieldArr * @param sortMap * @return */ List<EmUserRoleDto> selectQueryPage(Page<EmUserRoleDto> page, @Param(EggMpSqlConst.PARAMOF_QUERY_FIELD_LIST) QueryFieldArr queryFieldArr, @Param(EggMpSqlConst.PARAMOF_SORT_MAP) AntdvSortMap sortMap); /** * 取得用户拥有的所有角色id集合 * @param userAccountId * @param filterEnable 是否只查询状态为可用的 * @return */ List<String> findAllRoleIdByUserAccountId(@Param(EggMpSqlConst.PARAMOF_USER_ACCOUNT_ID) String userAccountId, @Param("filterEnable") boolean filterEnable); /** * 根据用户id 修改指定角色关联 的可用状态 * @param userAccountId * @param roleIdList * @param stateVal * @param loginUser * @return */ int batchUpdateStateByUserAccountId(@Param(EggMpSqlConst.PARAMOF_USER_ACCOUNT_ID) String userAccountId, @Param("roleIdList") List<String> roleIdList, @Param("stateVal") Short stateVal , @Param(EggMpSqlConst.PARAMOF_LOGIN_USER) EmUserAccountEntity loginUser); }
[ "695605813@qq.com" ]
695605813@qq.com
bf9a9cd5b63f5e33da6e3f32972714394f1302ca
fe5b610f0ded630462e9f98806edc7b24dcc2ef0
/Downloads/AyoKeMasjid_v0.3_apkpure.com_source_from_JADX/com/google/android/gms/ads/formats/NativeAdOptions.java
b1ab5cd3983f4f867cebc8bb7ba876679e52ba7b
[]
no_license
rayga/n4rut0
328303f0adcb28140b05c0a18e54abecf21ef778
e1f706aeb6085ee3752cb92187bf339c6dfddef0
refs/heads/master
2020-12-25T15:18:25.346886
2016-08-29T22:51:25
2016-08-29T22:51:25
66,826,428
1
0
null
null
null
null
UTF-8
Java
false
false
1,585
java
package com.google.android.gms.ads.formats; public final class NativeAdOptions { public static final int ORIENTATION_ANY = 0; public static final int ORIENTATION_LANDSCAPE = 2; public static final int ORIENTATION_PORTRAIT = 1; private final boolean zznV; private final int zznW; private final boolean zznX; public static final class Builder { private boolean zznV; private int zznW; private boolean zznX; public Builder() { this.zznV = false; this.zznW = NativeAdOptions.ORIENTATION_ANY; this.zznX = false; } public NativeAdOptions build() { return new NativeAdOptions(); } public Builder setImageOrientation(int orientation) { this.zznW = orientation; return this; } public Builder setRequestMultipleImages(boolean shouldRequestMultipleImages) { this.zznX = shouldRequestMultipleImages; return this; } public Builder setReturnUrlsForImageAssets(boolean shouldReturnUrls) { this.zznV = shouldReturnUrls; return this; } } private NativeAdOptions(Builder builder) { this.zznV = builder.zznV; this.zznW = builder.zznW; this.zznX = builder.zznX; } public int getImageOrientation() { return this.zznW; } public boolean shouldRequestMultipleImages() { return this.zznX; } public boolean shouldReturnUrlsForImageAssets() { return this.zznV; } }
[ "arga@lahardi.com" ]
arga@lahardi.com
ec90176b3fae803e113e47777ed965b7838d7be4
27f31c3ef8fbd6ff4463cafc92768d6ee2b2900d
/Infothek_tmj/src/li/tmj/db/sql/DBConnect.java
bf544bb1657ac1a5f5e25a5b5e2c2c3af4f5939f
[]
no_license
tmjGit/Infothek
a1002b121ce8eefe2128732e238e59aed2157224
20c1df10f2421a2ccc8da599deb2a943a971449d
refs/heads/master
2020-04-07T10:57:26.104334
2018-11-20T00:36:07
2018-11-20T00:36:07
158,306,908
0
0
null
null
null
null
UTF-8
Java
false
false
2,930
java
//package li.tmj.db.sql; // //import java.sql.Connection; //import java.sql.DriverManager; //import java.sql.SQLException; //import li.tmj.app.Application; //import li.tmj.db.exception.DBConnectException; //import org.pmw.tinylog.Logger; // ////public final class DBConnect {//Singleton //public final class DBConnect { // private static DBConnect instance = null; // private Connection con;// TODO con.close // private static String dbname=Application.confMainGet("dbname"); // // private DBConnect() { // try { // Class.forName( "com.mysql.jdbc.Driver" ).newInstance();///!!!!Tomcat // con = DriverManager.getConnection( Application.confMainGet("url")+Application.confMainGet("db"), // Application.confMainGet("usr"), // Application.confMainGet("pwd") // ); // } catch (SQLException | InstantiationException | IllegalAccessException | ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public static DBConnect getInstance(){ // if(instance == null){ // instance = new DBConnect(); // } // return instance; // } // // public Connection getConnection(){ // return con; // } // // public static String getDbname(){ // return dbname; // } //} // //// private static Connection connection; //// //// private DBConnect() throws DBConnectException { //// Logger.trace("connect..."); //// // Falls die Connection außerhalb geschlossen wird, kann sie aufgrund des Singleton nicht mehr geöffnet werden. //// connect( createUrl(),Application.confMainGet("dbname"),Application.confMainGet("user"),Application.confMainGet("password") ); //// } //// //// public static String createUrl() { //// Logger.trace("createUrl..."); //// return Application.confMainGet("driver") + ":" + Application.confMainGet("protocol") + "://" + Application.confMainGet("host") //// + (Application.confMainGet("port").equals("") ? "" : ":" + Application.confMainGet("port")) +"/"; //// } //// //// private static void connect(String url, String db, String user, String password) throws DBConnectException { //// Logger.trace("url={}, db={}, user={}, password={}",url,db,user,password); //// try { ////// con = DriverManager.getConnection( url +"", user, password ); //// con = DriverManager.getConnection( url + db, user, password ); ////// Logger.debug("con={}",con); //// } catch (SQLException e) { //// // TODO error log //// throw new DBConnectException(e.getMessage()); // e.printStackTrace(); //// } //// } //// //// public static DBConnect getInstance() throws DBConnectException{ //// Logger.trace("getInstance: instance={}",instance); //// if(instance == null){ //// instance = new DBConnect(); //// } //// return instance; //// } //// //// public static Connection getConnection(){ //// Logger.trace("getConnection: connection={}", connection); //// if(null==connection) { //// connect(url, db, user, password); //// } //// return connection; //// } ////}
[ "git@tmj.li" ]
git@tmj.li
834caf5b59149f49be1986adee7b20407b3ed40d
d4850e773872f333b78f3056b52b12c501a4ce5e
/myapp/src/main/java/com/rockgarden/myapp/uitl/FeedContextMenu.java
b9ab45b57c220faf0bcfc9463a938107cbc0f1cd
[]
no_license
rockgarden/MyCard
0c359aa3611c16a6384cf3f6705f955dd42508a0
526de6b66a1b9c0ef4d4a3b596bc3fcd74eef898
refs/heads/master
2020-12-14T03:56:53.702161
2016-07-29T05:59:26
2016-07-29T05:59:26
46,687,989
0
2
null
null
null
null
UTF-8
Java
false
false
2,511
java
package com.rockgarden.myapp.uitl; import android.content.Context; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.LinearLayout; import butterknife.ButterKnife; import butterknife.OnClick; import com.litesuits.common.utils.AndroidUtil; import com.rockgarden.myapp.R; /** * Created by froger_mcs on 15.12.14. */ public class FeedContextMenu extends LinearLayout { private static final int CONTEXT_MENU_WIDTH = AndroidUtil.dpToPx(240); private int feedItem = -1; private OnFeedContextMenuItemClickListener onItemClickListener; public FeedContextMenu(Context context) { super(context); init(); } private void init() { LayoutInflater.from(getContext()).inflate(R.layout.view_context_menu, this, true); setBackgroundResource(R.drawable.bg_container_shadow); setOrientation(VERTICAL); setLayoutParams(new LayoutParams(CONTEXT_MENU_WIDTH, ViewGroup.LayoutParams.WRAP_CONTENT)); } public void bindToItem(int feedItem) { this.feedItem = feedItem; } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); ButterKnife.bind(this); } public void dismiss() { ((ViewGroup) getParent()).removeView(FeedContextMenu.this); } @OnClick(R.id.btnReport) public void onReportClick() { if (onItemClickListener != null) { onItemClickListener.onReportClick(feedItem); } } @OnClick(R.id.btnSharePhoto) public void onSharePhotoClick() { if (onItemClickListener != null) { onItemClickListener.onSharePhotoClick(feedItem); } } @OnClick(R.id.btnCopyShareUrl) public void onCopyShareUrlClick() { if (onItemClickListener != null) { onItemClickListener.onCopyShareUrlClick(feedItem); } } @OnClick(R.id.btnCancel) public void onCancelClick() { if (onItemClickListener != null) { onItemClickListener.onCancelClick(feedItem); } } public void setOnFeedMenuItemClickListener(OnFeedContextMenuItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public interface OnFeedContextMenuItemClickListener { public void onReportClick(int feedItem); public void onSharePhotoClick(int feedItem); public void onCopyShareUrlClick(int feedItem); public void onCancelClick(int feedItem); } }
[ "rockwk@msn.com" ]
rockwk@msn.com
80ed64a9d74a8f6192832e944fd01e83588f1867
b31ea99b7ba411618e9a066ba0904c90373eaa39
/app/src/main/java/com/example/myapplication/MainActivity.java
06fe151a5b86c2c34e254978fe81ef6221dd8eb1
[]
no_license
rushil-thareja/DIS-PROJECT
ad55a55a4f1c1b4b74577ba50a66e60a28ee6b08
ff3a9768247a536407f5a9aa102ad71b59f43f55
refs/heads/master
2023-01-24T07:13:07.293148
2020-11-22T08:20:14
2020-11-22T08:20:14
314,793,049
0
0
null
null
null
null
UTF-8
Java
false
false
5,657
java
//package com.example.myapplication; // //import androidx.appcompat.app.AppCompatActivity; // //import android.os.Bundle; //import android.view.MotionEvent; //import android.widget.Toast; // //import com.google.ar.core.Anchor; //import com.google.ar.core.HitResult; //import com.google.ar.core.Plane; //import com.google.ar.sceneform.AnchorNode; //import com.google.ar.sceneform.rendering.Material; //import com.google.ar.sceneform.rendering.ModelRenderable; //import com.google.ar.sceneform.ux.ArFragment; //import com.google.ar.sceneform.ux.BaseArFragment; //import com.google.ar.sceneform.ux.TransformableNode; // //public class MainActivity extends AppCompatActivity { // private ArFragment arFragment; // private ModelRenderable modelRenderable; // // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); // arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.fragment); // setUpModel(); // setUpPlane(); // } // private void setUpModel(){ // ModelRenderable.builder() // .setSource(this,R.raw.hamburger) // .build() // .thenAccept(renderable->modelRenderable = renderable) // .exceptionally(throwable -> { // Toast.makeText(MainActivity.this,"not loaded",Toast.LENGTH_LONG).show(); // return(null); // }); // // } // private void setUpPlane(){ // arFragment.setOnTapArPlaneListener(new BaseArFragment.OnTapArPlaneListener() { // @Override // public void onTapPlane(HitResult hitResult, Plane plane, MotionEvent motionEvent) { // Anchor anchor = hitResult.createAnchor(); // AnchorNode anchorNode = new AnchorNode(anchor); // anchorNode.setParent(arFragment.getArSceneView().getScene()); // createModel(anchorNode); // } // }); // } // private void createModel(AnchorNode anchorNode){ // TransformableNode node = new TransformableNode(arFragment.getTransformationSystem()); // node.setParent(anchorNode); // node.setRenderable(modelRenderable); // node.select(); // } //} package com.example.myapplication; import android.net.Uri; import android.os.Bundle; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import com.google.android.gms.tasks.OnSuccessListener; import com.google.ar.sceneform.AnchorNode; import com.google.ar.sceneform.assets.RenderableSource; import com.google.ar.sceneform.math.Vector3; import com.google.ar.sceneform.rendering.ModelRenderable; import com.google.ar.sceneform.ux.ArFragment; import com.google.firebase.FirebaseApp; import com.google.firebase.storage.FileDownloadTask; import com.google.firebase.storage.FirebaseStorage; import com.google.firebase.storage.StorageReference; import java.io.File; import java.io.IOException; public class MainActivity extends AppCompatActivity { private String choose_dish; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //call the getIntent() getstring methods here to get string from calling activity then enter that into choose_dish choose_dish = "dish"; FirebaseApp.initializeApp(this); FirebaseStorage storage = FirebaseStorage.getInstance(); String path = "restaurant/"+choose_dish+"/out.glb"; StorageReference modelRef = storage.getReference().child(path); ArFragment arFragment = (ArFragment) getSupportFragmentManager() .findFragmentById(R.id.arFragment); findViewById(R.id.downloadBtn) .setOnClickListener(v -> { try { File file = File.createTempFile("out", "glb"); modelRef.getFile(file).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() { @Override public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { buildModel(file); } }); } catch (IOException e) { e.printStackTrace(); } }); arFragment.setOnTapArPlaneListener((hitResult, plane, motionEvent) -> { AnchorNode anchorNode = new AnchorNode(hitResult.createAnchor()); anchorNode.setRenderable(renderable); Vector3 vector3 = new Vector3(0.1f,0.1f,0.1f); anchorNode.setLocalScale(vector3); arFragment.getArSceneView().getScene().addChild(anchorNode); }); } private ModelRenderable renderable; private void buildModel(File file) { RenderableSource renderableSource = RenderableSource .builder() .setSource(this, Uri.parse(file.getPath()), RenderableSource.SourceType.GLB) .setRecenterMode(RenderableSource.RecenterMode.ROOT) .build(); ModelRenderable .builder() .setSource(this, renderableSource) .setRegistryId(file.getPath()) .build() .thenAccept(modelRenderable -> { Toast.makeText(this, "Model built", Toast.LENGTH_SHORT).show();; renderable = modelRenderable; }); } }
[ "rushilthareja@gmail.com" ]
rushilthareja@gmail.com
eb86f262747e523138f34cff4d9c20def06b79c9
5e6abc6bca67514b4889137d1517ecdefcf9683a
/Client/src/main/java/com/runescape/scene/graphic/TextureLoader667.java
fea45c96a8c35f069c28fab8eace128d068fca10
[]
no_license
dginovker/RS-2009-317
88e6d773d6fd6814b28bdb469f6855616c71fc26
9d285c186656ace48c2c67cc9e4fb4aeb84411a4
refs/heads/master
2022-12-22T18:47:47.487468
2019-09-20T21:24:34
2019-09-20T21:24:34
208,949,111
2
2
null
2022-12-15T23:55:43
2019-09-17T03:15:17
Java
UTF-8
Java
false
false
6,152
java
package com.runescape.scene.graphic; import com.runescape.cache.def.TextureDefinition; import com.runescape.cache.texture.Texture; import com.runescape.net.requester.ResourceProvider; public class TextureLoader667 { public static int[] textureLastUsed; public static int textureGetCount; private static int loadedTextureCount; private static int textureTexelPoolPointer; private static int[][] texelArrayPool; private static int[][] texelCache; private static float brightness = 1.0F; public static void initTextures(int count, ResourceProvider resourceProvider) { Texture.init(count, resourceProvider); loadedTextureCount = count; textureLastUsed = new int[count]; texelCache = new int[count][]; } public static void clearTextureCache() { texelArrayPool = null; for (int i = 0; i < loadedTextureCount; i++) { texelCache[i] = null; } } public static void resetTextures() { if (texelArrayPool == null) { textureTexelPoolPointer = 50;//was parameter texelArrayPool = new int[textureTexelPoolPointer][0x10000]; for (int k = 0; k < loadedTextureCount; k++) { texelCache[k] = null; } } } public static void resetTexture(int textureId) { if (texelCache[textureId] == null) { return; } texelArrayPool[textureTexelPoolPointer++] = texelCache[textureId]; texelCache[textureId] = null; } public static int[] getTexturePixels(int textureId) { if (textureId == 0) { textureId = 24; } Texture texture = Texture.get(textureId); if (texture == null) { return null; } textureLastUsed[textureId] = textureGetCount++; if (texelCache[textureId] != null) { return texelCache[textureId]; } int[] texels; //Start of mem management code if (textureTexelPoolPointer > 0) { //Freed texture data arrays available texels = texelArrayPool[--textureTexelPoolPointer]; texelArrayPool[textureTexelPoolPointer] = null; } else { //No freed texture data arrays available, recycle least used texture's array int lastUsed = 0; int target = -1; for (int i = 0; i < loadedTextureCount; i++) { if (texelCache[i] != null && (textureLastUsed[i] < lastUsed || target == -1)) { lastUsed = textureLastUsed[i]; target = i; } } texels = texelCache[target]; texelCache[target] = null; } texelCache[textureId] = texels; //End of mem management code if (texture.width == 64) { for (int y = 0; y < 128; y++) { for (int x = 0; x < 128; x++) { texels[x + (y << 7)] = texture.getPixel((x >> 1) + ((y >> 1) << 6)); } } } else { for (int texelPtr = 0; texelPtr < 16384; texelPtr++) { texels[texelPtr] = texture.getPixel(texelPtr); } } TextureDefinition def = textureId >= 0 && textureId < TextureDefinition.textures.length ? TextureDefinition.textures[textureId] : null; int blendType = def != null ? def.anInt1226 : 0; if (blendType != 1 && blendType != 2) { blendType = 0; } for (int texelPtr = 0; texelPtr < 16384; texelPtr++) { int texel = texels[texelPtr]; int alpha; if (blendType == 2) { alpha = texel >>> 24; } else if (blendType == 1) { alpha = texel != 0 ? 0xff : 0; } else { alpha = texel >>> 24; if (def != null && !def.aBoolean1223) { alpha /= 5; } } texel &= 0xffffff; if (textureId == 1 || textureId == 24) { texel = adjustBrightnessLinear(texel, 190);//379 } else { texel = adjustBrightnessLinear(texel, 179); } if (textureId == 1 || textureId == 24) { // texel = adjustBrightness(texel, 0.90093F); } else { texel = adjustBrightness(texel, brightness); } texel &= 0xf8f8ff; texels[texelPtr] = texel | (alpha << 24); texels[16384 + texelPtr] = ((texel - (texel >>> 3)) & 0xf8f8ff) | (alpha << 24); texels[32768 + texelPtr] = ((texel - (texel >>> 2)) & 0xf8f8ff) | (alpha << 24); texels[49152 + texelPtr] = ((texel - (texel >>> 3) - (texel >>> 3)) & 0xf8f8ff) | (alpha << 24); } return texels; } private static int adjustBrightness(int rgb, float brightness) { return ((int) ((float) Math.pow((double) ((float) (rgb >>> 16) / 256.0F), (double) brightness) * 256.0F) << 16) | ((int) ((float) Math.pow((double) ((float) ((rgb >>> 8) & 0xff) / 256.0F), (double) brightness) * 256.0F) << 8) | (int) ((float) Math.pow((double) ((float) (rgb & 0xff) / 256.0F), (double) brightness) * 256.0F); } private static int adjustBrightnessLinear(int rgb, int factor) { return ((((rgb >>> 16) * factor) & 0xff00) << 8) | ((((rgb >>> 8) & 0xff) * factor) & 0xff00) | (((rgb & 0xff) * factor) >> 8); } public static void calculateTexturePalette(double brightness) { for (int textureId = 0; textureId != loadedTextureCount; ++textureId) { resetTexture(textureId); } } public static void clear() { texelArrayPool = null; texelCache = null; textureLastUsed = null; brightness = 1.0F; } public boolean isValid() { return texelArrayPool != null && texelCache != null; } }
[ "dcress01@uoguelph.ca" ]
dcress01@uoguelph.ca
2f7ff3089d506b448bb81c720d462df714e51373
6193f2aab2b5aba0fcf24c4876cdcb6f19a1be88
/hgzb/src/private/nc/bs/pub/action/N_ZB07_WRITE.java
eda68e833b5297af9a1b3e5b277efe1966f3838b
[]
no_license
uwitec/nc-wandashan
60b5cac6d1837e8e1e4f9fbb1cc3d9959f55992c
98d9a19dc4eb278fa8aa15f120eb6ebd95e35300
refs/heads/master
2016-09-06T12:15:04.634079
2011-11-05T02:29:15
2011-11-05T02:29:15
41,097,642
0
0
null
null
null
null
GB18030
Java
false
false
2,237
java
package nc.bs.pub.action; import java.util.Hashtable; import nc.bs.pub.compiler.AbstractCompiler2; import nc.vo.pub.AggregatedValueObject; import nc.vo.pub.BusinessException; import nc.vo.pub.compiler.PfParameterVO; import nc.vo.trade.pub.HYBillVO; import nc.vo.uap.pf.PFBusinessException; public class N_ZB07_WRITE extends AbstractCompiler2 { private java.util.Hashtable m_methodReturnHas=new java.util.Hashtable(); private Hashtable m_keyHas=null; /** * * 分量调整单保存 * */ public N_ZB07_WRITE() { super(); } /* * 备注:平台编写规则类 * 接口执行类 */ public Object runComClass(PfParameterVO vo) throws BusinessException { try{ super.m_tmpVo=vo; try { super.m_tmpVo = vo; Object retObj = null; AggregatedValueObject billvo = getVo(); Object o = getUserObj(); if(billvo == null){ throw new BusinessException("传入数据为空"); } HYBillVO biddingvo = (HYBillVO)billvo; //只是执行了保存操作 retObj = runClass("nc.bs.zb.pub.HYBillSave", "saveBill","nc.vo.pub.AggregatedValueObject:01", vo, m_keyHas, m_methodReturnHas); return retObj; } catch (Exception ex) { if (ex instanceof BusinessException) throw (BusinessException) ex; else throw new PFBusinessException(ex.getMessage(), ex); } } catch (Exception ex) { if (ex instanceof BusinessException) throw (BusinessException) ex; else throw new PFBusinessException(ex.getMessage(), ex); } } /* * 备注:平台编写原始脚本 */ public String getCodeRemark(){ return null; } // return " try {\n super.m_tmpVo = vo;\n Object retObj = null;\n // 保存即提交\n retObj = runClass(\"nc.bs.gt.pub.HYBillSave\", \"saveBill\",\"nc.vo.pub.AggregatedValueObject:01\", vo, m_keyHas, m_methodReturnHas);\n return retObj;\n } catch (Exception ex) {\n if (ex instanceof BusinessException)\n throw (BusinessException) ex;\n else\n throw new PFBusinessException(ex.getMessage(), ex);\n }\n";} /* * 备注:设置脚本变量的HAS */ private void setParameter(String key,Object val) { if (m_keyHas==null){ m_keyHas=new Hashtable(); } if (val!=null) { m_keyHas.put(key,val); } } }
[ "liuyushi_alice@163.com" ]
liuyushi_alice@163.com
315fb3c628eb71c3692100d7b576c89b05d9ca55
cfcbe9f1d135278d2e682b2e5a75f9aefbf79e69
/java/src/com/caleb/java/juc/ThreadUnsafeExample.java
ec5b47ed70454fcc91fbc374d4db6b3c211d7c4f
[ "Apache-2.0" ]
permissive
huayo65001/JavaDemo
6ba6c19ff50bcbcd1c820e7a77fbaa3bf72ad476
95f4ef8d041e02f6f59bdcf00c2c356127b1c95a
refs/heads/main
2023-09-01T14:30:41.094083
2021-10-24T03:33:00
2021-10-24T03:33:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,037
java
package com.caleb.java.juc; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * @author:hanzhigang * @Date : 2021/3/1 2:49 PM */ public class ThreadUnsafeExample { public static void main(String[] args) throws InterruptedException { final int threadSize = 1000; ThreadErrorTest example = new ThreadErrorTest(); final CountDownLatch countDownLatch = new CountDownLatch(threadSize); ExecutorService executorService = Executors.newCachedThreadPool(); for (int i = 0; i < threadSize; i++) { executorService.execute(() -> { example.add(); countDownLatch.countDown(); }); } countDownLatch.await(); executorService.shutdown(); System.out.println(example.getCnt()); } } class ThreadErrorTest{ private int cnt = 0; public void add(){ cnt++; } public int getCnt() { return cnt; } }
[ "zhigang_han0521@163.com" ]
zhigang_han0521@163.com
a5bd463bb5c90d30e3d2fcf4918fe0238497b68b
e3e054fc775c012b698ac3ae160183d6b4069c44
/app/src/main/java/com/example/sampah_ku/Dashboard.java
8060e0f8cdb0efba0a609a13feda8c34b092c53a
[]
no_license
denaldipf/Sampah-Ku
1be08bd748c1e8453caafc37391dcba75ac7d4d7
d13cf201d32eb8eb186159c71cb2d2c5124626cc
refs/heads/master
2023-05-03T00:47:01.013339
2021-05-22T16:44:48
2021-05-22T16:44:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
336
java
package com.example.sampah_ku; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class Dashboard extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); } }
[ "78007781+dzulfiqar12@users.noreply.github.com" ]
78007781+dzulfiqar12@users.noreply.github.com
3cc4519ae82a9ddbacfd2a793d90738f0a668c87
6baf22fbb88f13b0f5527efd0b983a2b00fad824
/src/ArrayedStructures/ArrayedStack.java
ad65aa8effcca1f8abc6a32e0eca61e53a2a2f9c
[]
no_license
drahsansaleem/DataStructures-ADT
c3b19387f55f59f3d828f54f1675bd99db1d8878
029ce909f55c88646f650d4f09a379b87a320be0
refs/heads/main
2023-09-03T02:49:39.118817
2021-03-25T09:56:49
2021-03-25T09:56:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,367
java
package ArrayedStructures; import AbstractDataTypes.ArrayedStructure; import AbstractDataTypes.DataStructure; import AbstractDataTypes.Stack; import util.StructureIterator; import java.util.List; @SuppressWarnings({"unchecked", "CStyleArrayDeclaration", "unused"}) public class ArrayedStack<T> implements Stack<T>, DataStructure, ArrayedStructure<T> { private int size; T[] stack; int top = 0; public ArrayedStack() { stack = (T[]) new Object[1]; } public void clear() { stack = (T[]) new Object[1]; } @Override public StructureIterator<T> toIterator() { return new StructureIterator<>() { @Override public T next() { return null; } @Override public boolean hasNext() { return false; } }; } @Override public List<T> toJavaList() { return null; } public ArrayedStack(int size) { this.size = size; stack = (T[]) new Object[size]; } public void push(T data) { if (size() == size) { expand(); } stack[top] = data; top++; } private void expand() { int length = size(); T newStack[] = (T[]) new Object[size * 2]; System.arraycopy(stack, 0, newStack, 0, length); stack = newStack; size *= 2; } public T pop() { if (isEmpty()) { throw new RuntimeException("ArrayedStack is empty!"); } else { top--; T data = stack[top]; stack[top] = null; shrink(); return data; } } private void shrink() { int length = size(); if (length <= (size / 2) / 2) size = size / 2; T newStack[] = (T[]) new Object[size]; System.arraycopy(stack, 0, newStack, 0, size); stack = newStack; } public T peek() { T data; data = stack[top - 1]; return data; } public void display() { for (Object t : stack) { System.out.println(t); } } public int size() { return top; } public boolean isEmpty() { return top <= 0; } @Override public boolean isFull() { return top==stack.length; } }
[ "Osadkovski" ]
Osadkovski
eaac8a8ecdad12af5ff22c2e87fa3f128271b1bc
3efa417c5668b2e7d1c377c41d976ed31fd26fdc
/src/br/com/mind5/masterData/paymentStatus/info/Paymenus.java
2eab75dda6b0003abb3af5ece0e1b5911f3b2e39
[]
no_license
grazianiborcai/Agenda_WS
4b2656716cc49a413636933665d6ad8b821394ef
e8815a951f76d498eb3379394a54d2aa1655f779
refs/heads/master
2023-05-24T19:39:22.215816
2023-05-15T15:15:15
2023-05-15T15:15:15
109,902,084
0
0
null
2022-06-29T19:44:56
2017-11-07T23:14:21
Java
UTF-8
Java
false
false
322
java
package br.com.mind5.masterData.paymentStatus.info; public enum Paymenus { ACCEPTED("ACCEPTED"), REFUSED("REFUSED"), WAITING("WAITING"); private final String codStatus; private Paymenus(String cod) { codStatus = cod; } public String getCodStatus() { return codStatus; } }
[ "mmaciel@mind5.com" ]
mmaciel@mind5.com
429ae0f2c0baa2968fd791fe207c869db9961c6a
37761230cff9d8ebb731074020f6d4a52dc41ee1
/app/src/main/java/com/example/tps900/tps900/activity/TicketVerificationActivity.java
e78f0a26a6ff2ba02873d169afb4994ca95b0de1
[]
no_license
lihuaizhan/FengNing
fb828b07a323a901e0764a7dab2cadbf5e8779d3
8f7a3da71da63030a4adccc835679bfed84ce050
refs/heads/master
2020-03-22T23:44:21.125668
2018-07-13T09:21:21
2018-07-13T09:21:21
140,826,025
0
0
null
null
null
null
UTF-8
Java
false
false
35,238
java
package com.example.tps900.tps900.activity; import android.app.ProgressDialog; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Message; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.TextView; import android.widget.Toast; import com.alibaba.fastjson.JSON; import com.example.tps900.tps900.Bean.ConsumeTicketsBean; import com.example.tps900.tps900.Bean.GetOverifByEcodeBean; import com.example.tps900.tps900.Bean.GetTicketCode; import com.example.tps900.tps900.Bean.GetUpadateTicketBean; import com.example.tps900.tps900.Bean.TicketPrintBean; import com.example.tps900.tps900.R; import com.example.tps900.tps900.Utlis.Constant; import com.example.tps900.tps900.Utlis.OtherUtils; import com.example.tps900.tps900.Utlis.ThreadPoolUtils; import com.example.tps900.tps900.Utlis.TpsN900PrintUtils; import com.example.tps900.tps900.Webservice.GsWebServiceUtils; import com.godfery.Utils.ToastUtils; import com.godfery.keyboard.KeyboardUtil; import com.godfery.pay.HttpUtils; import com.godfery.Zxing.CaptureActivity; import java.util.Timer; import java.util.TimerTask; import static com.example.tps900.tps900.Utlis.Dailog.ErrDialog2; import static com.example.tps900.tps900.Utlis.OtherUtils.Bitmap2Bytes; import static com.example.tps900.tps900.Utlis.OtherUtils.getTime; import static com.example.tps900.tps900.Utlis.OtherUtils.sendMessageInfo; import static com.example.tps900.tps900.Webservice.GsWebServiceUtils.ConsumeTickets; import static com.example.tps900.tps900.Webservice.GsWebServiceUtils.GetOverifByEcode; import static com.godfery.keyboard.CustomEditLintener.EditListener; /** * 项目名称:TPS900 * 类名称: * 类描述: * 创建人:zxh * 创建时间:2017/4/17 13:24 * 修改人:zxh * 修改时间:2017/4/17 13:24 * 修改备注: * * @author zxh */ public class TicketVerificationActivity extends BaseActivity implements BaseActivity.CardCodeInterface { //扫描 private final int Scanning = 1; //线上核销 private final int Onlineverification = 2; //线下核销 private final int Offlineverification = 3; //通用失败 private final int Failed = 4; //清空 private final int Emptied = 5; //更新入园次数 private final int UpdataText = 6; TextView ticketName; TextView startTime; LinearLayout ticketLvBacket; TextView endTime; TextView ticketPersonNum; EditText practicalPersonNum; RadioButton ticketConfirm; RadioButton ticketCancel; ImageView ticketImgDelete; TextView ticketState; TextView ticketType; EditText ticketEtTicketCode; ImageView ticketImgDeleteCode; Button ticketQueryTicket; Button ticketBtnBor; Button ticketBtnComit; private Timer mTimer; private GetTicketCode getTicketCode; private GetUpadateTicketBean getUpadateTicketBean; //二维码,门票名称,开始日期,结束日期,可入景区数,可入人数 private String barcode, getTicketName, startDateTime, inParkTime, endDateTime, personNum; private String barcode2 = ""; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { //扫描 case Scanning: Intent intent = new Intent(TicketVerificationActivity.this, CaptureActivity.class); startActivityForResult(intent, 100); break; //线下核销 case Offlineverification: Ticket_H(barcode2, Integer.valueOf(practicalPersonNum.getText().toString())); timerTask(); break; //线上核销 case Onlineverification: ConTickets(barcode, practicalPersonNum.getText().toString().trim()); timerTask(); break; //通用失败原因 case Failed: String msgInfo = msg.obj.toString(); ErrDialog2(TicketVerificationActivity.this, msgInfo, ""); timerTask(); break; case Emptied://清除数据 ticketName.setText(""); ticketState.setText(""); startTime.setText(""); endTime.setText(""); ticketPersonNum.setText(""); practicalPersonNum.setText(""); ticketType.setText(""); ticketEtTicketCode.setText(""); yearCode_img_lv.setVisibility(View.GONE); break; case UpdataText: practicalPersonNum.setText(inParkTime); break; default: break; } } }; private String TAG = "TicketVerActivity"; private GetOverifByEcodeBean getobe; private ProgressDialog progressDialog; //通用错误 private String msgErr; private ConsumeTicketsBean ticketsBean; private byte[] buff = new byte[125 * 250]; private ImageView yearImage; private Drawable drawable; private Bitmap bitmap; private BitmapDrawable drawable2; private LinearLayout yearCode_img_lv; private Button ticket_btn_code; private String type = ""; /** * 设置布局 * * @return */ @Override public int getLayoutId() { return R.layout.activity_ticket_verification; } /** * @author zxh * created at 2017/6/7 15:56 * 方法名: initView * 方法说明: 初始化操作 */ @Override public void initView() { setCardInterface(this); startTime = (TextView) findViewById(R.id.start_time); endTime = (TextView) findViewById(R.id.end_time); ticketPersonNum = (TextView) findViewById(R.id.ticket_personNum); practicalPersonNum = (EditText) findViewById(R.id.practical_personNum); ticketConfirm = (RadioButton) findViewById(R.id.ticket_confirm); ticketCancel = (RadioButton) findViewById(R.id.ticket_cancel); ticketImgDelete = (ImageView) findViewById(R.id.ticket_img_delete); ticketState = (TextView) findViewById(R.id.ticket_State); ticketType = (TextView) findViewById(R.id.ticket_type); ticketEtTicketCode = (EditText) findViewById(R.id.ticket_et_ticketCode); ticketImgDeleteCode = (ImageView) findViewById(R.id.ticket_img_deleteCode); ticketQueryTicket = (Button) findViewById(R.id.ticket_QueryTicket); ticket_btn_code = (Button) findViewById(R.id.ticket_btn_code); ticketBtnBor = (Button) findViewById(R.id.ticket_btn_bor); ticketBtnComit = (Button) findViewById(R.id.ticket_btn_comit); ticketName = (TextView) findViewById(R.id.ticket_name); ticketLvBacket = (LinearLayout) findViewById(R.id.ticket_lv_back);// yearCode_img_lv = (LinearLayout) findViewById(R.id.yearCode_img_lv);//yearCode_img_lv progressDialog = new ProgressDialog(TicketVerificationActivity.this); yearImage = (ImageView) findViewById(R.id.ticket_img_web); drawable = getResources().getDrawable(R.mipmap.touxiangyonghu_03); bitmap = OtherUtils.drawableToBitmap(drawable); drawable2 = new BitmapDrawable(bitmap); yearImage.setBackground(drawable2); yearCode_img_lv.setVisibility(View.GONE); } /** * @author zxh * created at 2017/6/7 16:15 * 方法名: initData * 方法说明: 一些数据操作 */ @Override public void initData() { EditListener(practicalPersonNum); EditListener(ticketEtTicketCode); practicalPersonNum.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { practicalPersonNum.setHint(""); ticketEtTicketCode.setHint("请输入门票串码"); new KeyboardUtil(getApplicationContext(), TicketVerificationActivity.this, practicalPersonNum, R.id.schemas_key_keyboard_view).showKeyboard(); } }); ticketEtTicketCode.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { ticketEtTicketCode.setHint(""); practicalPersonNum.setHint("请输入园次数"); new KeyboardUtil(getApplicationContext(), TicketVerificationActivity.this, ticketEtTicketCode, R.id.schemas_key_keyboard_view).showKeyboard(); } }); practicalPersonNum.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String ticketNum = s.toString().trim(); String state = ticketState.getText().toString().trim(); if (!TextUtils.isEmpty(ticketNum) && TextUtils.isEmpty(state) && Integer.valueOf(inParkTime) != 0) { if (Integer.valueOf(ticketNum) > Integer.valueOf(inParkTime) || Integer.valueOf(ticketNum) == 0) { ToastUtils.show(TicketVerificationActivity.this, "请输入正确入园次数"); sendMessageInfo(handler, UpdataText); } } } }); ticketQueryTicket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendMessageInfo(handler,Emptied); String ticketCode = ticketEtTicketCode.getText().toString().trim(); Log.e("门票串码---1", ticketCode + ""); if (TextUtils.isEmpty(ticketCode)) { ToastUtils.show(TicketVerificationActivity.this, "请输入门票串码"); } else { barcode = ticketCode; btn_QueryticketInfo(barcode); } } }); } public void onClick(View view) { int id = view.getId(); if (id == R.id.ticket_et_ticketCode) { ticketEtTicketCode.setHint(""); practicalPersonNum.setHint("请输入园次数"); new KeyboardUtil(getApplicationContext(), TicketVerificationActivity.this, ticketEtTicketCode, R.id.schemas_key_keyboard_view).showKeyboard(); } else if (id == R.id.practical_personNum) { practicalPersonNum.setHint(""); ticketEtTicketCode.setHint("请输入门票串码"); new KeyboardUtil(getApplicationContext(), TicketVerificationActivity.this, practicalPersonNum, R.id.schemas_key_keyboard_view).showKeyboard(); } else if (id == R.id.ticket_img_delete) { practicalPersonNum.setText(""); } else if (id == R.id.ticket_img_deleteCode) { ticketEtTicketCode.setText(""); } else if (id == R.id.ticket_QueryTicket) { String ticketCode = ticketEtTicketCode.getText().toString().trim(); Log.e("门票串码---1", ticketCode + ""); if (TextUtils.isEmpty(ticketCode)) { ToastUtils.show(this, "请输入门票串码"); } else { barcode = ticketCode; btn_QueryticketInfo(barcode); } } else if (id == R.id.ticket_btn_bor) { sendMessageInfo(handler, Scanning); } else if (id == R.id.ticket_btn_comit) { ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { btn_comit(); } }); } else if (id == R.id.ticket_lv_back) { TicketVerificationActivity.this.startActivity(new Intent(this, MainActivity.class)); finish(); } else if (id == R.id.ticket_img_web) { if (getTicketCode.MEMBER_PHOTO != null) { bitmap = OtherUtils.stringtoBitmap(getTicketCode.MEMBER_PHOTO); buff = Bitmap2Bytes(bitmap); Intent intent = new Intent(TicketVerificationActivity.this, ImgShowActivity.class); intent.putExtra("bitmap", buff); TicketVerificationActivity.this.startActivity(intent); }else { drawable = getResources().getDrawable(R.mipmap.touxiangyonghu_03); bitmap = OtherUtils.drawableToBitmap(drawable); buff = Bitmap2Bytes(bitmap); Intent intent = new Intent(TicketVerificationActivity.this, ImgShowActivity.class); intent.putExtra("bitmap", buff); TicketVerificationActivity.this.startActivity(intent); } } else if (id == R.id.ticket_btn_code) { HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { DeviceN900(TicketVerificationActivity.this); } }); } } /** * @author zxh * created at 2017/6/7 15:54 * 方法名: Ticket_Verifi 线下门票查询 * 方法说明: 传入二维码 查看当前票是否有效 * "TICKET" */ public void Ticket_Verifi(final String barcode, String Type) { String GetTicketCheck = GsWebServiceUtils.GetTicketCheck(barcode, Type); HttpUtils.exitProgressDialog(progressDialog); Log.e("GetTicketCheck门票信息", GetTicketCheck); if (GetTicketCheck.equals("err")) { sendMessageInfo(handler, Failed, "请求数据失败,请检查网络或者检查配置"); } else { getTicketCode = JSON.parseObject(GetTicketCheck, GetTicketCode.class); if (getTicketCode.FLAG && getTicketCode.TICKETNAME != null) { runOnUiThread(new Runnable() { @Override public void run() { inParkTime = String.valueOf(getTicketCode.getINPARKTIME()); barcode2 = getTicketCode.getBARCODE(); getTicketName = getTicketCode.getTICKETNAME(); startDateTime = getTicketCode.getSTARTDATETIME(); endDateTime = getTicketCode.getENDDATETIME(); ticketName.setText(getTicketName); startTime.setText(startDateTime); ticketType.setText("线下票"); endTime.setText(endDateTime); ticketPersonNum.setText(String.valueOf(getTicketCode.getINPARKTIME())); practicalPersonNum.setText(String.valueOf(getTicketCode.getINPARKTIME())); Log.e("barcode", barcode); if (getTicketCode.MEMBER_PHOTO == null || TextUtils.isEmpty(getTicketCode.MEMBER_PHOTO)) { drawable = getResources().getDrawable(R.mipmap.touxiangyonghu_03); bitmap = OtherUtils.drawableToBitmap(drawable); drawable2 = new BitmapDrawable(bitmap); yearImage.setBackground(drawable2); } else { yearCode_img_lv.setVisibility(View.VISIBLE); bitmap = OtherUtils.stringtoBitmap(getTicketCode.MEMBER_PHOTO); drawable2 = new BitmapDrawable(bitmap); yearImage.setBackground(drawable2); } //可入人数为1并且为有效票 if (1 == getTicketCode.INPARKTIME && "有效票".equals(getTicketCode.SHOWMSG)) { HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { Ticket_H(barcode2, Integer.valueOf(practicalPersonNum.getText().toString())); } }); } else if (getTicketCode.INPARKTIME > 1) { ticketState.setText("未核销"); ticketState.setTextColor(Color.BLACK); } else if (0 == getTicketCode.INPARKTIME) { ticketState.setText(getTicketCode.SHOWMSG); ticketState.setTextColor(Color.RED); timerTask(); } } }); } else { //线下查询票失败 sendMessageInfo(handler, Failed, getTicketCode.SHOWMSG + "\n查询票信息失败"); } } } /** * @author zxh * created at 2017/6/7 15:54 * 方法名: Ticket_H 线下核销 * 方法说明: 传入二维码 和 入园人数进行核销 */ public void Ticket_H(final String barcode, final int count) { ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { String ticket_H = GsWebServiceUtils.GetUpdateTicket(barcode, count, "TICKET"); HttpUtils.exitProgressDialog(progressDialog); Log.e("ticket_H门票信息", ticket_H); if (ticket_H.equals("err")) { sendMessageInfo(handler, Failed, "请求数据失败,请检查网络或者检查配置"); } else { getUpadateTicketBean = JSON.parseObject(ticket_H, GetUpadateTicketBean.class); if (getUpadateTicketBean.FLAG) { ThreadPoolUtils.runTaskInUIThread(new Runnable() { @Override public void run() { ticketName.setText(getTicketName); ticketState.setText("已核销"); ticketState.setTextColor(Color.RED); startTime.setText(startDateTime); endTime.setText(endDateTime); ticketPersonNum.setText(inParkTime); practicalPersonNum.setText(String.valueOf(getUpadateTicketBean.DATA)); ticketType.setText("线下票"); String time = getTime(); TpsN900PrintUtils.TpsN900Print_ticket(TicketVerificationActivity.this,"门票核销", "\n门票名称:" + getTicketCode.getTICKETNAME() + "\n门票价格:" + getTicketCode.getTICKETPRICE() + "元" + "\n入园开始日期:" + getTicketCode.getSTARTDATETIME() + "\n入园结束日期:" + getTicketCode.getENDDATETIME() + "\n门票核销日期:" + time + "\n可入园次数:" + getTicketCode.getINPARKTIME() + "次" + "\n实际入园次数:" + count + "\n门票二维码:" , barcode, "温馨提示:此票只作为核销凭证,不可视为报销凭证"); Constant.TicketPintList.clear(); Constant.TicketPintList.add(new TicketPrintBean( time, getTicketCode.getTICKETNAME(), getTicketCode.getTICKETPRICE(), String.valueOf(getTicketCode.getINPARKTIME()), String.valueOf(count), getTicketCode.getSTARTDATETIME(), getTicketCode.getENDDATETIME(),barcode)); if (ticketState.getText().toString().equals("已核销")) { timerTask(); } else if (ticketState.getText().toString().equals("核销失败")) { timerTask(); } } }); } else { ThreadPoolUtils.runTaskInUIThread(new Runnable() { @Override public void run() { ticketState.setText("核销失败"); ticketState.setTextColor(Color.RED); } }); //核销失败 sendMessageInfo(handler, Failed, "核销失败" + getUpadateTicketBean.MSG + "\n请检查网络或者检查配置"); } } } }); } /** * @author zxh * created at 2017/6/7 15:53 * 方法名: GetOByEcode 大平台门票查询 * 方法说明: */ public void GetOByEcode(final String Ecode, final String OrderNo) { try { String f00001409 = GetOverifByEcode(Ecode, OrderNo); Log.e("线上查询信息", f00001409); HttpUtils.exitProgressDialog(progressDialog); if (TextUtils.isEmpty(f00001409) || f00001409.equals("err")) { sendMessageInfo(handler, Failed, "请求数据失败,请检查网络或者检查配置"); } else if (!TextUtils.isEmpty(f00001409) && !f00001409.equals("err")) { getobe = JSON.parseObject(f00001409, GetOverifByEcodeBean.class); if (getobe.Success && getobe.Data != null) { ThreadPoolUtils.runTaskInUIThread(new Runnable() { @Override public void run() { Log.e(TAG, getobe.Message + "正确"); barcode2 = Ecode; inParkTime = getobe.Data.ProductCount; ticketName.setText(getobe.Data.ProductName); startTime.setText(getobe.Data.PlayStartDate); endTime.setText(getobe.Data.PlayEndDate); ticketPersonNum.setText(getobe.Data.ProductCount); practicalPersonNum.setText(getobe.Data.ProductCount); ticketEtTicketCode.setText(Ecode); ticketType.setText("线上票"); if (inParkTime.equals("1")) { HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { ConTickets(Ecode, inParkTime); } }); } else { ticketState.setText("未核销"); ticketState.setTextColor(Color.BLACK); } } }); } else { //线上查询失败 sendMessageInfo(handler, Failed, getobe.Message + "\n查询票信息失败"); } } } catch (Exception e) { } } /** * @author zxh * created at 2017/6/7 15:53 * 方法名: ConTickets 大平台门票核销 * 方法说明: 传入二维码和人数进行核销 */ public void ConTickets(final String ECode, final String VerifNum) { ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { try { String consumeTickets = ConsumeTickets(ECode, VerifNum); HttpUtils.exitProgressDialog(progressDialog); if (!TextUtils.isEmpty(consumeTickets)) { if (consumeTickets.equals("err")) { //网络原因或者接口中断 sendMessageInfo(handler, Failed, "请求数据失败,请检查网络或者检查配置"); } else { ticketsBean = JSON.parseObject(consumeTickets, ConsumeTicketsBean.class); if (ticketsBean.Success) { Log.e(TAG, ticketsBean.Message + "正确"); ThreadPoolUtils.runTaskInUIThread(new Runnable() { @Override public void run() { ticketType.setText("线上票"); ticketState.setText("已核销"); ticketState.setTextColor(Color.RED); String time = getTime(); TpsN900PrintUtils.TpsN900Print_ticket(TicketVerificationActivity.this,"门票核销", "\n门票名称:" + getobe.Data.ProductName + "\n门票价格:" + getobe.Data.PrintPrice + "元" + "\n入园开始日期:" + getobe.Data.PlayStartDate + "\n入园结束日期:" + getobe.Data.PlayEndDate + "\n门票核销日期:" + time + "\n可入园次数:" + getobe.Data.ProductCount + "次" + "\n实际入园次数:" + VerifNum + "\n门票二维码:" , ECode, "温馨提示:此票只作为核销凭证,不可视为报销凭证"); Constant.TicketPintList.clear(); Constant.TicketPintList.add(new TicketPrintBean( time, getobe.Data.ProductName, getobe.Data.PrintPrice, getobe.Data.ProductCount, VerifNum, getobe.Data.PlayStartDate, getobe.Data.PlayEndDate,barcode)); if (ticketState.getText().toString().equals("已核销")) { timerTask(); } else if (ticketState.getText().toString().equals("核销失败")) { timerTask(); } } }); } else { Log.e(TAG, "失败了" + ticketsBean.Message); //核销失败 sendMessageInfo(handler, Failed, ticketsBean.Message + "\n核销失败"); } } } Log.e(TAG, "核销信息" + consumeTickets); } catch (Exception e) { } } }); } /** * @author zxh * created at 2017/6/7 15:52 * 方法名: 扫描核销方法 * 方法说明: 扫描到结果进行查询核销 */ @Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { if (data != null) { barcode = data.getStringExtra("result"); if (!TextUtils.isEmpty(barcode)) { btn_QueryticketInfo(barcode); } return; } else { Toast.makeText(TicketVerificationActivity.this, "扫描结果为空", Toast.LENGTH_LONG).show(); } } /** * @author zxh * created at 2017/6/7 15:50 * 方法名: timerTask * 方法说明: 定时消除字体 */ private void timerTask() { if (mTimer != null) { mTimer.cancel();// 退出之前的mTimer } mTimer = new Timer(); TimerTask timerTask01 = new TimerTask() { @Override public void run() { //清空页面 sendMessageInfo(handler, Emptied); } }; mTimer.schedule(timerTask01, 3000); } //提交数据 public void btn_comit() { TicketVerificationActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (TextUtils.isEmpty(ticketState.getText().toString().trim())) { ToastUtils.show(TicketVerificationActivity.this, "请先扫描门票"); return; } else if (ticketState.getText().toString().trim().equals("已核销")) { ToastUtils.show(TicketVerificationActivity.this, "请先扫描门票"); return; } else { String ticketNum = practicalPersonNum.getText().toString().trim(); if (TextUtils.isEmpty(ticketNum)) { ToastUtils.show(TicketVerificationActivity.this, "请输入入园次数"); practicalPersonNum.setText(inParkTime); } else if (Integer.valueOf(ticketNum) > Integer.valueOf(inParkTime) || Integer.valueOf(ticketNum) == 0) { ToastUtils.show(TicketVerificationActivity.this, "请输入正确入园次数"); practicalPersonNum.setText(inParkTime); } else { if (barcode.length() >= 24) { runOnUiThread(new Runnable() { @Override public void run() { HttpUtils.showProgressDialog(progressDialog); } }); //线下核销 sendMessageInfo(handler, Offlineverification); } else if (barcode.length() < 24 && barcode.length() > 10) { runOnUiThread(new Runnable() { @Override public void run() { HttpUtils.showProgressDialog(progressDialog); } }); //线上核销 sendMessageInfo(handler, Onlineverification); } else if (barcode.length() < 24 && barcode.length() <= 10) {//线下票 runOnUiThread(new Runnable() { @Override public void run() { HttpUtils.showProgressDialog(progressDialog); } }); //线下核销 sendMessageInfo(handler, Offlineverification); } } } } }); } /** * 根据串码判断是线上票还是线下票 * * @param barcode */ public void btn_QueryticketInfo(final String barcode) { //根据主页面传递过来的二维码判断是否是有效票 if (!TextUtils.isEmpty(barcode)) { if (barcode.length() >= 24) {//大于24位的就是线下票 HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { Ticket_Verifi(barcode, "TICKET"); } }); } else if (barcode.length() < 24 && barcode.length() > 10) {//小于24位的就是线上票 HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { GetOByEcode(barcode, ""); if (ticketState.getText().toString().equals("已核销")) { timerTask(); } else if (ticketState.getText().toString().equals("核销失败")) { timerTask(); } } }); } else if (barcode.length() < 24 && barcode.length() <= 10) {//线下票 HttpUtils.showProgressDialog(progressDialog); ThreadPoolUtils.runTaskInThread(new Runnable() { @Override public void run() { Ticket_Verifi(barcode, "MEMBER"); } }); } } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { openActivityAndCloseThis(MainActivity.class); return true; } return super.onKeyDown(keyCode, event); } /** * 读取卡号成功回调 * * @param cardNo 返回卡号 */ @Override public void onReadCardOk(String cardNo) { HttpUtils.exitProgressDialog(progressDialog); barcode = cardNo; btn_QueryticketInfo(cardNo); } }
[ "2381343538@qq.com" ]
2381343538@qq.com
47edb9c2901bb14dd00ad8e7e5cc014519b5d903
2675014ce51aa2be088c1c3d4126153ea3bdcf94
/aws-java-sdk-kinesis/src/main/java/com/amazonaws/services/kinesisanalytics/model/transform/AddApplicationInputRequestMarshaller.java
4be78a8a0f089e2cd794e145e7f34ec49064d6dc
[ "Apache-2.0" ]
permissive
erbrito/aws-java-sdk
7b621cae16c470dfe26b917781cb00f5c6a0de4e
853b7e82d708465aca43c6013ab1221ce4d50852
refs/heads/master
2021-01-25T05:50:39.073013
2017-02-02T03:58:41
2017-02-02T03:58:41
80,691,444
1
0
null
null
null
null
UTF-8
Java
false
false
3,441
java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.kinesisanalytics.model.transform; import java.io.ByteArrayInputStream; import javax.annotation.Generated; import com.amazonaws.SdkClientException; import com.amazonaws.Request; import com.amazonaws.DefaultRequest; import com.amazonaws.http.HttpMethodName; import com.amazonaws.services.kinesisanalytics.model.*; import com.amazonaws.transform.Marshaller; import com.amazonaws.protocol.json.*; /** * AddApplicationInputRequest Marshaller */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AddApplicationInputRequestMarshaller implements Marshaller<Request<AddApplicationInputRequest>, AddApplicationInputRequest> { private final SdkJsonMarshallerFactory protocolFactory; public AddApplicationInputRequestMarshaller(SdkJsonMarshallerFactory protocolFactory) { this.protocolFactory = protocolFactory; } public Request<AddApplicationInputRequest> marshall(AddApplicationInputRequest addApplicationInputRequest) { if (addApplicationInputRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<AddApplicationInputRequest> request = new DefaultRequest<AddApplicationInputRequest>(addApplicationInputRequest, "AmazonKinesisAnalytics"); request.addHeader("X-Amz-Target", "KinesisAnalytics_20150814.AddApplicationInput"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (addApplicationInputRequest.getApplicationName() != null) { jsonGenerator.writeFieldName("ApplicationName").writeValue(addApplicationInputRequest.getApplicationName()); } if (addApplicationInputRequest.getCurrentApplicationVersionId() != null) { jsonGenerator.writeFieldName("CurrentApplicationVersionId").writeValue(addApplicationInputRequest.getCurrentApplicationVersionId()); } if (addApplicationInputRequest.getInput() != null) { jsonGenerator.writeFieldName("Input"); InputJsonMarshaller.getInstance().marshall(addApplicationInputRequest.getInput(), jsonGenerator); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", protocolFactory.getContentType()); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; } }
[ "" ]
88881ebcbbc75b23d1ec614cdf89be1b1f047a6b
3093a2393cc807425404613120ca6f7eabdc61e5
/transaction-demo/src/main/java/com/anhe/pojo/v23mypackage/UploadDocumentReferenceDetail.java
f20d602fe8b6429ce2bc9ae9944b620adf6584c2
[]
no_license
tangyongshuang/practice-parent
928e1505f48bd84a4f8e7eaa28c0e08e617c4d38
ef74210f74f84722ee1220e8f11c9e3614dc98a7
refs/heads/master
2022-06-23T23:34:20.343807
2019-06-19T08:16:47
2019-06-19T08:16:47
190,373,049
0
0
null
2022-06-17T03:25:50
2019-06-05T10:13:58
Java
UTF-8
Java
false
false
6,499
java
package com.anhe.pojo.v23mypackage; import java.math.BigInteger; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; /** * <p>UploadDocumentReferenceDetail complex type的 Java 类。 * * <p>以下模式片段指定包含在此类中的预期内容。 * * <pre> * &lt;complexType name="UploadDocumentReferenceDetail"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="LineNumber" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" minOccurs="0"/> * &lt;element name="CustomerReference" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;element name="Description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;element name="DocumentProducer" type="{http://fedex.com/ws/ship/v23}UploadDocumentProducerType" minOccurs="0"/> * &lt;element name="DocumentType" type="{http://fedex.com/ws/ship/v23}UploadDocumentType" minOccurs="0"/> * &lt;element name="DocumentId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;element name="DocumentIdProducer" type="{http://fedex.com/ws/ship/v23}UploadDocumentIdProducer" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "UploadDocumentReferenceDetail", namespace = "http://fedex.com/ws/ship/v23", propOrder = { "lineNumber", "customerReference", "description", "documentProducer", "documentType", "documentId", "documentIdProducer" }) public class UploadDocumentReferenceDetail { @XmlElement(name = "LineNumber", namespace = "http://fedex.com/ws/ship/v23") @XmlSchemaType(name = "nonNegativeInteger") protected BigInteger lineNumber; @XmlElement(name = "CustomerReference", namespace = "http://fedex.com/ws/ship/v23") protected String customerReference; @XmlElement(name = "Description", namespace = "http://fedex.com/ws/ship/v23") protected String description; @XmlElement(name = "DocumentProducer", namespace = "http://fedex.com/ws/ship/v23") @XmlSchemaType(name = "string") protected UploadDocumentProducerType documentProducer; @XmlElement(name = "DocumentType", namespace = "http://fedex.com/ws/ship/v23") @XmlSchemaType(name = "string") protected UploadDocumentType documentType; @XmlElement(name = "DocumentId", namespace = "http://fedex.com/ws/ship/v23") protected String documentId; @XmlElement(name = "DocumentIdProducer", namespace = "http://fedex.com/ws/ship/v23") @XmlSchemaType(name = "string") protected UploadDocumentIdProducer documentIdProducer; /** * 获取lineNumber属性的值。 * * @return * possible object is * {@link BigInteger } * */ public BigInteger getLineNumber() { return lineNumber; } /** * 设置lineNumber属性的值。 * * @param value * allowed object is * {@link BigInteger } * */ public void setLineNumber(BigInteger value) { this.lineNumber = value; } /** * 获取customerReference属性的值。 * * @return * possible object is * {@link String } * */ public String getCustomerReference() { return customerReference; } /** * 设置customerReference属性的值。 * * @param value * allowed object is * {@link String } * */ public void setCustomerReference(String value) { this.customerReference = value; } /** * 获取description属性的值。 * * @return * possible object is * {@link String } * */ public String getDescription() { return description; } /** * 设置description属性的值。 * * @param value * allowed object is * {@link String } * */ public void setDescription(String value) { this.description = value; } /** * 获取documentProducer属性的值。 * * @return * possible object is * {@link UploadDocumentProducerType } * */ public UploadDocumentProducerType getDocumentProducer() { return documentProducer; } /** * 设置documentProducer属性的值。 * * @param value * allowed object is * {@link UploadDocumentProducerType } * */ public void setDocumentProducer(UploadDocumentProducerType value) { this.documentProducer = value; } /** * 获取documentType属性的值。 * * @return * possible object is * {@link UploadDocumentType } * */ public UploadDocumentType getDocumentType() { return documentType; } /** * 设置documentType属性的值。 * * @param value * allowed object is * {@link UploadDocumentType } * */ public void setDocumentType(UploadDocumentType value) { this.documentType = value; } /** * 获取documentId属性的值。 * * @return * possible object is * {@link String } * */ public String getDocumentId() { return documentId; } /** * 设置documentId属性的值。 * * @param value * allowed object is * {@link String } * */ public void setDocumentId(String value) { this.documentId = value; } /** * 获取documentIdProducer属性的值。 * * @return * possible object is * {@link UploadDocumentIdProducer } * */ public UploadDocumentIdProducer getDocumentIdProducer() { return documentIdProducer; } /** * 设置documentIdProducer属性的值。 * * @param value * allowed object is * {@link UploadDocumentIdProducer } * */ public void setDocumentIdProducer(UploadDocumentIdProducer value) { this.documentIdProducer = value; } }
[ "albert.tang@circle.us" ]
albert.tang@circle.us
0c414f5e084642120d12612decc7448b82c0f7ce
d1195c8554762cba6a7a5aaa801ca25b31080858
/src/main/java/com/poly/service/ReportService.java
d1704a3d11927112cd53738b32e68b2a31bdd716
[]
no_license
GoalShop/GoalShop-1
b8b556a7e1678d4a0f1866b8448e3e0ce7b47a79
643e0da373061cd42f60db3624e8bda5821fbad1
refs/heads/main
2023-08-19T19:17:41.616706
2021-10-30T08:07:36
2021-10-30T08:07:36
413,252,706
0
0
null
null
null
null
UTF-8
Java
false
false
508
java
package com.poly.service; import java.util.Date; import java.util.List; import com.poly.entity.ReportCategory; import com.poly.entity.ReportProductbyDay; import com.poly.entity.ReportTrademark; public interface ReportService { List<ReportCategory> getReportCategory() ; List<ReportProductbyDay> getReportProductbyDaynoMinMax(); List<ReportProductbyDay> getReportProductbyDayMinMax(Date minday , Date maxday); List<ReportCategory> revenueByMonth(); List<ReportTrademark> getReportTrademark(); }
[ "91859987+GoalShop@users.noreply.github.com" ]
91859987+GoalShop@users.noreply.github.com
648bdbdedd5ef99edc0b897781893af29ef7c105
8e6883fb124e1a42ae786488bf13b8caf5fa9df9
/project/backend/src/main/java/ru/otus/project/service/BatchServiceImpl.java
c5593a7c62872de542aac843e63551fa79867be6
[]
no_license
zubata/2019-09-otus-spring-Zubkov
cedf4eb0ab2f69a7e0460d51a6cbfd8ae219fc7f
58c671320a117ab3c79d4d47fee9170e90a4240f
refs/heads/master
2022-12-04T13:12:01.650907
2020-06-15T22:56:07
2020-06-15T22:56:07
207,668,675
0
0
null
2019-09-11T07:45:24
2019-09-10T21:44:48
Java
UTF-8
Java
false
false
3,376
java
package ru.otus.project.service; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.JobOperator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import ru.otus.project.batch.StepProducerConfig; import ru.otus.project.batch.StepVineConfig; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Optional; @Service public class BatchServiceImpl implements BatchService { private final JobLauncher jobLauncher; private final JobOperator jobOperator; private final StepProducerConfig stepProducer; private final StepVineConfig stepVine; private final List<Job> jobs; private List<JobExecution> jobExecutionList; private final Logger log; private final String folderpath; @Autowired public BatchServiceImpl(JobLauncher jobLauncher, JobOperator jobOperator, StepProducerConfig stepProducer, StepVineConfig stepVine, List<Job> jobs, @Value("${batch.file.path}") String folderpath) { this.jobLauncher = jobLauncher; this.jobOperator = jobOperator; this.stepProducer = stepProducer; this.stepVine = stepVine; this.jobs = jobs; jobExecutionList = new ArrayList<>(); log = LoggerFactory.getLogger("BatchService"); this.folderpath = folderpath; } @Override public File saveToCsv(String jobName) { setFileName(folderpath); Optional<Job> job = jobs.stream().filter(s -> s.getName().equals(jobName)).findFirst(); if (job.isPresent()) { try { if (checkJob(jobName, "COMPLETED") != -1) { jobOperator.startNextInstance(jobName); } else { jobExecutionList.add(jobLauncher.run(job.get(), new JobParameters())); } return new File(folderpath + (jobName.equals("vineJob") ? "/Vine.csv" : "/Producer.csv")); } catch (Exception e) { log.error(e.toString()); e.printStackTrace(); } } else { log.info(String.format("Job для %s не найдена", jobName)); } return null; } @Override public void restartJob(String jobName) { long jobId = checkJob(jobName, "FAILED"); try { jobOperator.restart(jobId); } catch (Exception e) { e.printStackTrace(); } } private long checkJob(String jobName, String status) { for (JobExecution je : jobExecutionList) { String tempJobName = je.getJobInstance().getJobName(); String tempStatus = je.getStatus().name(); if (tempJobName.equals(jobName) && tempStatus.equals(status)) { return je.getJobId(); } } return -1; } private void setFileName(String filePath) { stepVine.setResource(filePath + "/Vine.csv"); stepProducer.setResource(filePath + "/Producer.csv"); } }
[ "ozubkov@neoflex.ru" ]
ozubkov@neoflex.ru
898cf46ab51ad8197afbfd76dfb521c52411373e
3582978b7a13f90ae9e9b42dff3775fa92e4f920
/src/main/java/com/mrs/marketsurveys/dto/UserDTO.java
e911d4feab98d31fdd697ce1db2c7605d2d2a93f
[]
no_license
arharg/marketsurveys
4c352c6922247baf11813f1f588bdc809c80b02b
a5ceef8a62d895be2de2e2edbd987761223c8733
refs/heads/master
2022-03-05T02:29:37.822337
2018-08-01T06:05:22
2018-08-01T06:05:22
212,514,913
0
0
null
null
null
null
UTF-8
Java
false
false
142
java
package com.mrs.marketsurveys.dto; import lombok.Data; public @Data class UserDTO { private String username; private String password; }
[ "hardoyaroa@gmail.com" ]
hardoyaroa@gmail.com
6254716c471b7dbfd5de186336d5af6c15a546dc
687c566d7be328cb5db50ed1109bf1400cb3e5fb
/spring-boot-hbase/src/main/java/com/newtouch/work/common/JsonResult.java
029308bf7454865aa35fac84d7ce0819cffd63bf
[]
no_license
yepengfei2020/springboot-study
0e3ca335a561574e18e3b40f4b6150263ae820c9
b41a5f7601b7a5162cd9b01677b1703e050648f0
refs/heads/master
2023-04-14T05:41:26.816104
2021-04-15T08:30:11
2021-04-15T08:30:11
285,528,803
0
0
null
null
null
null
UTF-8
Java
false
false
462
java
package com.newtouch.work.common; import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; /** * @program: JsonResult * @description: 格式化回参 * @author: yepengfei * @create: 2021/3/19、9:46 * @Version 1.0 **/ @Data @AllArgsConstructor public class JsonResult<T> implements Serializable { private boolean status; // 状态码 private String message; // 提示信息 private T result; // 返回结果 }
[ "811721443@qq.com" ]
811721443@qq.com
e339a3650ee481011b7e616e5dcbc277c051b619
e1ba03ea9a4f7f5b8727db9a415879eb399a206a
/code/android_day0701_homework/src/com/example/android_day0701_venn_homework/fragment/MessageFragment.java
9280a14dca1d797d0de47246a1b604112e53c990
[]
no_license
LloydFinch/MyAndroidCode
65f66ed64a331ca104a8bbdbda41076ef94f1f26
5bee5179d4eaf4f378a6974806ad9b73d4106d12
refs/heads/master
2021-06-20T21:20:38.809106
2017-08-13T02:20:36
2017-08-13T02:20:36
39,632,624
2
0
null
null
null
null
UTF-8
Java
false
false
2,354
java
package com.example.android_day0701_venn_homework.fragment; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; import android.widget.TextView; import com.example.android_day0701_venn_homework.Adapter.MessageAdapter; import com.example.android_day0701_venn_homework.R; import com.example.android_day0701_venn_homework.contactsTool.ContactsTool; import com.example.android_day0701_venn_homework.entity.Message; import java.util.List; /** * project:com.example.android_day0701_venn_homework.fragment * user:VennUser * date:2015/7/2 */ public class MessageFragment extends Fragment implements AdapterView.OnItemClickListener { private static Context context; private MenuInflater menuInflater; private ListView listView; private MessageAdapter adapter; private List<Message> messageList; public void MessageFragment() { } public static void getContext(Context con) { context = con; } public void onAttach(Activity activity) { super.onAttach(activity); menuInflater = activity.getMenuInflater(); } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_message, container, false); listView = (ListView) view.findViewById(R.id.list_message); messageList= ContactsTool.getMessage(context); adapter = new MessageAdapter(context, messageList); listView.setAdapter(adapter); listView.setOnItemClickListener(this); return view; } public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView textView2 = (TextView) view.findViewById(R.id.text_time); String time = textView2.getText().toString(); MesDetailFragment.getContext(context); MesDetailFragment.getMessage(messageList.get(position).getContent(), time); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.fraglayout, new MesDetailFragment()); transaction.commit(); } }
[ "870289738@qq.com" ]
870289738@qq.com
d137a87a53509a320374f16d76b0fdd9ab226161
4aa90348abcb2119011728dc067afd501f275374
/app/src/main/java/com/tencent/mm/plugin/game/gamewebview/ui/d$17.java
3c53963a6450f96ee415761b573d17b3ae898858
[]
no_license
jambestwick/HackWechat
0d4ceb2d79ccddb45004ca667e9a6a984a80f0f6
6a34899c8bfd50d19e5a5ec36a58218598172a6b
refs/heads/master
2022-01-27T12:48:43.446804
2021-12-29T10:36:30
2021-12-29T10:36:30
249,366,791
0
0
null
2020-03-23T07:48:32
2020-03-23T07:48:32
null
UTF-8
Java
false
false
455
java
package com.tencent.mm.plugin.game.gamewebview.ui; class d$17 implements Runnable { final /* synthetic */ String iTF; final /* synthetic */ String iXg; final /* synthetic */ d mZC; d$17(d dVar, String str, String str2) { this.mZC = dVar; this.iXg = str; this.iTF = str2; } public final void run() { if (d.n(this.mZC) != null) { d.n(this.mZC).cJ(this.iXg, this.iTF); } } }
[ "malin.myemail@163.com" ]
malin.myemail@163.com
9f4628b342dca107994401b94d265df3cd7b5794
bdefe06b209dc7dbf8844ecb86d636a33a5d6337
/erx-00d198182586de6f5c556aad995383d13c79bd5f/erx.git/eRX-Model/src/com/walgreens/pharmacy/rules/ResultType.java
2e8a4273163df9d2b3520ca4d46f0a0a2eeb894c
[]
no_license
tanickel/eRx
e0758713834a00ce8a55f053839d1c0ae95b6e4a
432281c1c9f0e790c75dde0cfb2946ce94ff1dfc
refs/heads/master
2021-01-22T23:48:56.938872
2014-09-07T13:38:43
2014-09-07T13:38:43
null
0
0
null
null
null
null
UTF-8
Java
false
false
378
java
package com.walgreens.pharmacy.rules; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlType; @XmlType(name = "ResultType") @XmlEnum public enum ResultType { COMPLETE, MANUAL, IN_PROGRESS; public String value() { return name(); } public static ResultType fromValue(String v) { return valueOf(v); } }
[ "tanickel@us.ibm.com" ]
tanickel@us.ibm.com
a33535641cee7a60a54b985d8c661bdc6eb1df80
ef5fc1ca0ba16a8e365aa9b493ad46ae27b2ee64
/core/src/org/academiadecodigo/hexaltistas/persistence/dao/UserDao.java
64cb8112d600dcb3176f8a47abb79cc07410a77d
[]
no_license
gui-pinto/Echo
5a842922fcb6844170d73de292f544acf57813de
6762bc97d58f282bc42c2f49adb7fb9daca505bb
refs/heads/master
2020-03-15T00:31:13.440584
2018-04-06T11:58:20
2018-04-06T11:58:20
131,870,881
1
0
null
2018-05-02T15:30:45
2018-05-02T15:30:44
null
UTF-8
Java
false
false
1,895
java
package org.academiadecodigo.hexaltistas.persistence.dao; import org.academiadecodigo.hexaltistas.model.User; import org.academiadecodigo.hexaltistas.persistence.TransactionException; import org.academiadecodigo.hexaltistas.persistence.jpa.JpaSessionManager; import org.hibernate.HibernateException; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import java.util.List; public class UserDao { private JpaSessionManager sm; private User user; public List<User> findAll() { try { EntityManager em = sm.getCurrentSession(); CriteriaQuery<User> criteriaQuery = em.getCriteriaBuilder().createQuery(User.class); Root<User> root = criteriaQuery.from(User.class); return em.createQuery(criteriaQuery).getResultList(); // Using JPQL // return em.createQuery( "from " + modelType.getSimpleName(), modelType).getResultList(); } catch (HibernateException ex) { throw new TransactionException(ex); } } public User findById(Integer id) { try { EntityManager em = sm.getCurrentSession(); return em.find(User.class, id); } catch (HibernateException ex) { throw new TransactionException(ex); } } public User saveOrUpdate(User user) { try { EntityManager em = sm.getCurrentSession(); return em.merge(user); } catch (HibernateException ex) { throw new TransactionException(ex); } } public void delete(Integer id) { try { EntityManager em = sm.getCurrentSession(); em.remove(em.find(User.class, id)); } catch (HibernateException ex) { throw new TransactionException(ex); } } }
[ "ncardosolol@gmail.com" ]
ncardosolol@gmail.com
2ec80f512ab41e99253d0c8e06e9faef9aac3497
1ef8371658b59f617395869bad526d87611fca60
/OpenCL_Demo/src/main/java/org/openpixi/pixi/physics/solver/relativistic/LeapFrogRelativistic.java
1716477da5b189601d8e3ff7907005c6e9b958e5
[]
no_license
PetcuAlexandru/OpenCL_Demo
8f0f0f7ab225c932c9e3488477743bbca636e08d
6389d6c1cb4ee8df616b9d2be2c3e6fdfc4372fe
refs/heads/master
2020-04-14T15:40:12.051133
2013-05-01T22:18:55
2013-05-01T22:18:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,148
java
/* * OpenPixi - Open Particle-In-Cell (PIC) Simulator * Copyright (C) 2012 OpenPixi.org * * 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 2 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openpixi.pixi.physics.solver.relativistic; import org.openpixi.pixi.physics.*; import org.openpixi.pixi.physics.force.Force; import org.openpixi.pixi.physics.solver.Solver; /**This class represents the LeapFrog algorithm and the equations that are used one can be find here: * http://phycomp.technion.ac.il/~david/thesis/node34.html * and also here: * http://www.artcompsci.org/vol_1/v1_web/node34.html#leapfrog-step2 */ public class LeapFrogRelativistic implements Solver{ RelativisticVelocity relvelocity; public LeapFrogRelativistic(double c) { relvelocity = new RelativisticVelocity(c); } /** * LeapFrog algorithm. The damping is implemented with an linear error O(dt). * Warning: the velocity is stored half a time step ahead of the position. * @param p before the update: x(t), u(t+dt/2), a(t); * after the update: x(t+dt), u(t+3*dt/2), a(t+dt) * u(t) is the relativistic momentum */ public void step(Particle p, Force f, double dt) { double gamma = relvelocity.calculateGamma(p); // x(t+dt) = x(t) + c(t+dt/2) * dt / gamma p.setX(p.getX() + p.getVx() * dt / gamma); p.setY(p.getY() + p.getVy() * dt / gamma); // a(t+dt) = F(u(t+dt/2), x(t+dt)) / m // WARNING: Force is evaluated at two different times t+dt/2 and t+dt! p.setAx(f.getForceX(p) / p.getMass()); p.setAy(f.getForceY(p) / p.getMass()); // u(t+3*dt/2) = u(t+dt/2) + a(t+dt)*dt p.setVx(p.getVx() + p.getAx() * dt); p.setVy(p.getVy() + p.getAy() * dt); } /** * prepare method for bringing the velocity in the desired half step * @param p before the update: v(t); * after the update: v(t+dt/2) */ public void prepare(Particle p, Force f, double dt) { //a(t) = F(v(t), x(t)) / m p.setAx(f.getForceX(p) / p.getMass()); p.setAy(f.getForceY(p) / p.getMass()); //v(t + dt / 2) = v(t) + a(t)*dt / 2 p.setVx(p.getVx() + p.getAx() * dt); p.setVy(p.getVy() + p.getAy() * dt); } /** * complete method for bringing the velocity in the desired half step * @param p before the update: v(t+dt/2); * after the update: v(t) */ public void complete(Particle p, Force f, double dt) { //v(t) = v(t + dt / 2) - a(t)*dt / 2 p.setVx(p.getVx() - p.getAx() * dt); p.setVy(p.getVy() - p.getAy() * dt); } }
[ "alexandru3007@yahoo.com" ]
alexandru3007@yahoo.com
34ab05454da8da38990e77d189296e88732aa5cd
3d1669572512486a20f829795a4d4585c8e3c88c
/kodilla-patterns2/src/test/java/com/kodilla/patterns2/observer/homework/HomeworkTestSuite.java
72a1ae941887045c5ecab0bbea6a86f97c7310f3
[]
no_license
xmarcel99/kodilla-course
53b889bc58688b644e0b7427a5aa9094b2b86598
0b98643a46dfbc7f76618ae3b2d104534b0106de
refs/heads/master
2020-04-28T15:37:59.330807
2019-09-06T07:11:02
2019-09-06T07:11:02
175,382,070
0
0
null
null
null
null
UTF-8
Java
false
false
942
java
package com.kodilla.patterns2.observer.homework; import org.junit.Assert; import org.junit.Test; public class HomeworkTestSuite { @Test public void testUpdate() { //Given Teacher lincolnBurrows = new Teacher("Lincoln Borrows"); Teacher johnSmith = new Teacher("John Smitch"); Homework michaelScofield = new Homework("Michael Scofield",lincolnBurrows); Homework saraTencredi = new Homework("Sara Tencredi",lincolnBurrows); Homework walterWhite = new Homework("Walter White",johnSmith); //When michaelScofield.addTask("Create first Rest Api Controller"); michaelScofield.addTask("Sending request to diffrent server"); saraTencredi.addTask("For loop"); walterWhite.addTask("AOP - what is it ? "); //Then Assert.assertEquals(3,lincolnBurrows.getUpdateCounter()); Assert.assertEquals(1,johnSmith.getUpdateCounter()); } }
[ "sensiss99@gmail.com" ]
sensiss99@gmail.com
a98af63f00bbaab44ae7901564c46878a5695f17
66a603509064e876e30c1351dae1e9d35f2b21cc
/spring-core-4.0/org/springframework/core/io/ClassPathResource.java
1c700739b4e0fbead448f81675c4685e233f838e
[ "Apache-2.0" ]
permissive
leogoing/spring_jeesite
4e6d2fc96a028da38058f0c6b6fb13a56f930d0c
c2dc3da3925f089ead933685942dbdb689f14d4b
refs/heads/master
2021-01-21T14:40:13.977630
2016-09-10T14:29:23
2016-09-10T14:29:23
56,330,057
0
0
null
null
null
null
UTF-8
Java
false
false
8,760
java
/* * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.core.io; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** * 类路径资源<p> * {@link Resource} implementation for class path resources. * Uses either a given ClassLoader or a given Class for loading resources. * * <p>Supports resolution as {@code java.io.File} if the class path * resource resides in the file system, but not for resources in a JAR. * Always supports resolution as URL. * * @author Juergen Hoeller * @author Sam Brannen * @since 28.12.2003 * @see ClassLoader#getResourceAsStream(String) * @see Class#getResourceAsStream(String) */ public class ClassPathResource extends AbstractFileResolvingResource { private final String path; private ClassLoader classLoader; private Class<?> clazz; /** * Create a new {@code ClassPathResource} for {@code ClassLoader} usage. * A leading slash will be removed, as the ClassLoader resource access * methods will not accept it. * <p>The thread context class loader will be used for * loading the resource. * @param path the absolute path within the class path * @see java.lang.ClassLoader#getResourceAsStream(String) * @see org.springframework.util.ClassUtils#getDefaultClassLoader() */ public ClassPathResource(String path) { this(path, (ClassLoader) null); } /** * Create a new {@code ClassPathResource} for {@code ClassLoader} usage. * A leading slash will be removed, as the ClassLoader resource access * methods will not accept it. * @param path the absolute path within the classpath * @param classLoader the class loader to load the resource with, * or {@code null} for the thread context class loader * @see ClassLoader#getResourceAsStream(String) */ public ClassPathResource(String path, ClassLoader classLoader) { Assert.notNull(path, "Path must not be null"); String pathToUse = StringUtils.cleanPath(path); if (pathToUse.startsWith("/")) { pathToUse = pathToUse.substring(1); } this.path = pathToUse; this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader()); } /** * Create a new {@code ClassPathResource} for {@code Class} usage. * The path can be relative to the given class, or absolute within * the classpath via a leading slash. * @param path relative or absolute path within the class path * @param clazz the class to load resources with * @see java.lang.Class#getResourceAsStream */ public ClassPathResource(String path, Class<?> clazz) { Assert.notNull(path, "Path must not be null"); this.path = StringUtils.cleanPath(path); this.clazz = clazz; } /** * Create a new {@code ClassPathResource} with optional {@code ClassLoader} * and {@code Class}. Only for internal usage. * @param path relative or absolute path within the classpath * @param classLoader the class loader to load the resource with, if any * @param clazz the class to load resources with, if any */ protected ClassPathResource(String path, ClassLoader classLoader, Class<?> clazz) { this.path = StringUtils.cleanPath(path); this.classLoader = classLoader; this.clazz = clazz; } /** * 获取资源路径(无法重写)<p> * Return the path for this resource (as resource path within the class path). */ public final String getPath() { return this.path; } /** * 获取类加载器,为空则获取该类Class对象的类加载器(无法重写)<p> * Return the ClassLoader that this resource will be obtained from. */ public final ClassLoader getClassLoader() { return (this.clazz != null ? this.clazz.getClassLoader() : this.classLoader); } /** * 根据path属性判断URL资源是否存在与classes目录下<p> * This implementation checks for the resolution of a resource URL. * @see java.lang.ClassLoader#getResource(String) * @see java.lang.Class#getResource(String) */ @Override public boolean exists() { return (resolveURL() != null); } /** * 返回classes目录下的path属性标明的文件资源作为URL返回<p> * Resolves a URL for the underlying class path resource. * @return the resolved URL, or {@code null} if not resolvable */ protected URL resolveURL() { if (this.clazz != null) { return this.clazz.getResource(this.path);//返回classes目录下的path文件路径资源 } else if (this.classLoader != null) { return this.classLoader.getResource(this.path);//此时需要path为完成带包名的路径 } else { return ClassLoader.getSystemResource(this.path); } } /** * 返回classes目录下的path属性标明的文件资源转为URL再打开一个连接到这个URL用于读取并返回这个InputStream的连接<p> * This implementation opens an InputStream for the given class path resource. * @see java.lang.ClassLoader#getResourceAsStream(String) * @see java.lang.Class#getResourceAsStream(String) */ @Override public InputStream getInputStream() throws IOException { InputStream is; if (this.clazz != null) { is = this.clazz.getResourceAsStream(this.path); } else if (this.classLoader != null) { is = this.classLoader.getResourceAsStream(this.path); } else { is = ClassLoader.getSystemResourceAsStream(this.path); } if (is == null) { throw new FileNotFoundException(getDescription() + " cannot be opened because it does not exist"); } return is; } /** * 获取类路径下的资源URL<p> * This implementation returns a URL for the underlying class path resource, * if available. * @see java.lang.ClassLoader#getResource(String) * @see java.lang.Class#getResource(String) */ @Override public URL getURL() throws IOException { URL url = resolveURL(); if (url == null) { throw new FileNotFoundException(getDescription() + " cannot be resolved to URL because it does not exist"); } return url; } /** * 在当前资源路径的父级文件夹下并拼接传入路径字符串创建相同资源对象<p> * This implementation creates a ClassPathResource, applying the given path * relative to the path of the underlying resource of this descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new ClassPathResource(pathToUse, this.classLoader, this.clazz); } /** * 获取path属性文件名<p> * This implementation returns the name of the file that this class path * resource refers to. * @see org.springframework.util.StringUtils#getFilename(String) */ @Override public String getFilename() { return StringUtils.getFilename(this.path); } /** * 资源路径描述<p> * This implementation returns a description that includes the class path location. */ @Override public String getDescription() { StringBuilder builder = new StringBuilder("class path resource ["); String pathToUse = path; if (this.clazz != null && !pathToUse.startsWith("/")) { builder.append(ClassUtils.classPackageAsResourcePath(this.clazz)); builder.append('/'); } if (pathToUse.startsWith("/")) { pathToUse = pathToUse.substring(1); } builder.append(pathToUse); builder.append(']'); return builder.toString(); } /** * This implementation compares the underlying class path locations. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof ClassPathResource) { ClassPathResource otherRes = (ClassPathResource) obj; return (this.path.equals(otherRes.path) && ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) && ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz)); } return false; } /** * This implementation returns the hash code of the underlying * class path location. */ @Override public int hashCode() { return this.path.hashCode(); } }
[ "81391276@qq.com" ]
81391276@qq.com
d6e7548391a3b22189eb3f419b3a0137a5a1d134
a33aac97878b2cb15677be26e308cbc46e2862d2
/data/libgdx/Touchpad_setResetOnTouchUp.java
9a45e80fd7d0efbd0b9dcdbda4765101290dffe0
[]
no_license
GabeOchieng/ggnn.tensorflow
f5d7d0bca52258336fc12c9de6ae38223f28f786
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
refs/heads/master
2022-05-30T11:17:42.278048
2020-05-02T11:33:31
2020-05-02T11:33:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
159
java
/** * @param reset Whether to reset the knob to the center on touch up. */ public void setResetOnTouchUp(boolean reset) { this.resetOnTouchUp = reset; }
[ "bdqnghi@gmail.com" ]
bdqnghi@gmail.com