blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
380b395cfc4a269ffee6d033da6d4bbb859606d6 | f0749246184688d8af2b309a29be8ae32c5d04ee | /src/main/java/genepi/imputationserver/util/GenomicTools.java | df8746c1e8cf4ca4c3bd488a02319b52e8d2ccfb | [] | no_license | cfuchsberger/imputationserver | 71f75520139aef400b4b822271b624f3f89bc4d8 | 554ad0797bba5687c4cce7b842da23836a617e40 | refs/heads/master | 2021-01-15T10:51:37.115708 | 2016-05-12T18:37:27 | 2016-05-12T18:37:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,325 | java | package genepi.imputationserver.util;
import genepi.imputationserver.steps.qc.QualityControlMapper;
import genepi.io.legend.LegendEntry;
import org.broadinstitute.variant.variantcontext.VariantContext;
public class GenomicTools {
public static boolean isValid(String allele) {
return allele.toUpperCase().equals("A")
|| allele.toUpperCase().equals("C")
|| allele.toUpperCase().equals("G")
|| allele.toUpperCase().equals("T");
}
public static boolean match(VariantContext snp, LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
if (studyRef == legendRef && studyAlt == legendAlt) {
return true;
}
return false;
}
/**
* it's only a match if chiSquare is under 300. This means there is no
* switch
**/
public static boolean matchChiSquare(VariantContext snp,
LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
if (studyRef == legendRef && studyAlt == legendAlt) {
return chiSquare(snp, refEntry, false).getChisq() <= 300;
}
return false;
}
public static boolean alleleSwitch(VariantContext snp, LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
// all simple cases
if (studyRef == legendAlt && studyAlt == legendRef) {
return true;
}
return false;
}
public static boolean alleleSwitchChiSquare(VariantContext snp,
LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
String studyGenotype = new StringBuilder().append(studyRef)
.append(studyAlt).toString();
String referenceGenotype = new StringBuilder().append(legendRef)
.append(legendAlt).toString();
if ((studyGenotype.equals("AT") || studyGenotype.equals("TA"))
&& (referenceGenotype.equals("AT") || referenceGenotype
.equals("TA"))) {
return chiSquare(snp, refEntry, false).getChisq() > 300;
} else if ((studyGenotype.equals("CG") || studyGenotype.equals("GC"))
&& (referenceGenotype.equals("CG") || referenceGenotype
.equals("GC"))) {
return chiSquare(snp, refEntry, false).getChisq() > 300;
}
// all other cases
else if (studyRef == legendAlt && studyAlt == legendRef) {
return true;
}
return false;
}
public static boolean strandSwap(char studyRef, char studyAlt,
char legendRef, char legendAlt) {
String studyGenotype = new StringBuilder().append(studyRef)
.append(studyAlt).toString();
String referenceGenotype = new StringBuilder().append(legendRef)
.append(legendAlt).toString();
if (studyGenotype.equals("AC")) {
return referenceGenotype.equals("TG");
} else if (studyGenotype.equals("CA")) {
return referenceGenotype.equals("GT");
} else if (studyGenotype.equals("AG")) {
return referenceGenotype.equals("TC");
} else if (studyGenotype.equals("GA")) {
return referenceGenotype.equals("CT");
} else if (studyGenotype.equals("TG")) {
return referenceGenotype.equals("AC");
} else if (studyGenotype.equals("GT")) {
return referenceGenotype.equals("CA");
} else if (studyGenotype.equals("CT")) {
return referenceGenotype.equals("GA");
} else if (studyGenotype.equals("TC")) {
return referenceGenotype.equals("AG");
}
return false;
}
public static boolean complicatedGenotypes(VariantContext snp,
LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
String studyGenotype = new StringBuilder().append(studyRef)
.append(studyAlt).toString();
String referenceGenotype = new StringBuilder().append(legendRef)
.append(legendAlt).toString();
if ((studyGenotype.equals("AT") || studyGenotype.equals("TA"))
&& (referenceGenotype.equals("AT") || referenceGenotype
.equals("TA"))) {
return true;
} else if ((studyGenotype.equals("CG") || studyGenotype.equals("GC"))
&& (referenceGenotype.equals("CG") || referenceGenotype
.equals("GC"))) {
return true;
}
return false;
}
public static boolean complicatedGenotypesChiSquare(VariantContext snp,
LegendEntry refEntry) {
char studyRef = snp.getReference().getBaseString().charAt(0);
char studyAlt = snp.getAltAlleleWithHighestAlleleCount()
.getBaseString().charAt(0);
char legendRef = refEntry.getAlleleA();
char legendAlt = refEntry.getAlleleB();
String studyGenotype = new StringBuilder().append(studyRef)
.append(studyAlt).toString();
String referenceGenotype = new StringBuilder().append(legendRef)
.append(legendAlt).toString();
if ((studyGenotype.equals("AT") || studyGenotype.equals("TA"))
&& (referenceGenotype.equals("AT") || referenceGenotype
.equals("TA"))) {
return chiSquare(snp, refEntry, false).getChisq() <= 300;
} else if ((studyGenotype.equals("CG") || studyGenotype.equals("GC"))
&& (referenceGenotype.equals("CG") || referenceGenotype
.equals("GC"))) {
return chiSquare(snp, refEntry, false).getChisq() <= 300;
}
return false;
}
public static boolean strandSwapAndAlleleSwitch(char studyRef,
char studyAlt, char legendRef, char legendAlt) {
String studyGenotype = new StringBuilder().append(studyRef)
.append(studyAlt).toString();
String referenceGenotype = new StringBuilder().append(legendRef)
.append(legendAlt).toString();
if (studyGenotype.equals("AC")) {
return referenceGenotype.equals("GT");
} else if (studyGenotype.equals("CA")) {
return referenceGenotype.equals("TG");
} else if (studyGenotype.equals("AG")) {
return referenceGenotype.equals("CT");
} else if (studyGenotype.equals("GA")) {
return referenceGenotype.equals("TC");
} else if (studyGenotype.equals("TG")) {
return referenceGenotype.equals("CA");
} else if (studyGenotype.equals("GT")) {
return referenceGenotype.equals("AC");
} else if (studyGenotype.equals("CT")) {
return referenceGenotype.equals("AG");
} else if (studyGenotype.equals("TC")) {
return referenceGenotype.equals("GA");
}
return false;
}
public static ChiSquareObject chiSquare(VariantContext snp,
LegendEntry refSnp, boolean strandSwap) {
// calculate allele frequency
double chisq = 0;
int refN = getPanelSize(QualityControlMapper.PANEL_ID);
double refA = refSnp.getFrequencyA();
double refB = refSnp.getFrequencyB();
int majorAlleleCount;
int minorAlleleCount;
if (!strandSwap) {
majorAlleleCount = snp.getHomRefCount();
minorAlleleCount = snp.getHomVarCount();
} else {
majorAlleleCount = snp.getHomVarCount();
minorAlleleCount = snp.getHomRefCount();
}
int countRef = snp.getHetCount() + majorAlleleCount * 2;
int countAlt = snp.getHetCount() + minorAlleleCount * 2;
double p = countRef / (double) (countRef + countAlt);
double q = countAlt / (double) (countRef + countAlt);
double studyN = (snp.getNSamples() - snp.getNoCallCount()) * 2;
double totalQ = q * studyN + refB * refN;
double expectedQ = totalQ / (studyN + refN) * studyN;
double deltaQ = q * studyN - expectedQ;
chisq += (Math.pow(deltaQ, 2) / expectedQ)
+ (Math.pow(deltaQ, 2) / (totalQ - expectedQ));
double totalP = p * studyN + refA * refN;
double expectedP = totalP / (studyN + refN) * studyN;
double deltaP = p * studyN - expectedP;
chisq += (Math.pow(deltaP, 2) / expectedP)
+ (Math.pow(deltaP, 2) / (totalP - expectedP));
return new ChiSquareObject(chisq, p, q);
}
public static int getPanelSize(String panelId) {
switch (panelId) {
case "phase1":
return 1092;
case "phase3":
return 2535;
case "hrc":
return 32611;
case "hapmap2":
return 1301;
case "caapa":
return 883;
default:
return 1092;
}
}
public static int getPopSize(String pop) {
switch (pop) {
case "eur":
return 11418;
case "afr":
return 17469;
case "asn":
case "sas":
case "eas":
return 14269;
default:
return 15000;
}
}
public static boolean alleleMismatch(char studyRef, char studyAlt,
char referenceRef, char referenceAlt) {
return studyRef != referenceRef || studyAlt != referenceAlt;
}
}
| [
"[email protected]"
] | |
fecbc774a9e171f22f16f235c958b213844b448f | 47fb243836c3a1709f6abc2a6f0bf7467e1eeafc | /src/main/java/com/youndevice/app/bootstrap/ApplicationReadyEventHandlerService.java | 81c2454edc5649c7a94cdffd27236f573c816fbd | [] | no_license | youndevice/main-ynd-app | d401b0f540ce4e5f3653ebd3c0bf0515a7cfaec7 | 80785050001322b5a571f294b782859cabab1ae5 | refs/heads/master | 2020-07-22T05:21:58.507682 | 2019-09-21T14:52:37 | 2019-09-21T14:52:37 | 207,085,576 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,580 | java | package com.youndevice.app.bootstrap;
import com.youndevice.app.domain.Appliance;
import com.youndevice.app.domain.Device;
import com.youndevice.app.domain.Role;
import com.youndevice.app.domain.User;
import com.youndevice.app.enums.DeviceType;
import com.youndevice.app.enums.RoleType;
import com.youndevice.app.service.repo.RoleRepoService;
import com.youndevice.app.service.repo.UserRepoService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Component
public class ApplicationReadyEventHandlerService implements ApplicationListener<ApplicationReadyEvent> {
Log log = LogFactory.getLog(ApplicationReadyEventHandlerService.class);
@Value("${skip.bootstrap:false}")
Boolean skipBootstrap;
@Autowired
UserRepoService userRepoService;
@Autowired
RoleRepoService roleRepoService;
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
// skipBootstrap = true;
if (skipBootstrap) {
log.info("Bootstrap skipped as config property 'skip.bootstrap' is set to true");
} else {
createTestRole();
createUserTestData();
}
}
private void createUserTestData() {
List<User> userList = new ArrayList<>();
String testEmailId = null;
createAdminUser();
for (int i = 1; i <= 5; i++) {
testEmailId = "email" + i + "@testmail.com";
if (userRepoService.countUserByEmailId(testEmailId) < 1) {
User user = new User("firstName", "lastName", testEmailId, new BCryptPasswordEncoder().encode("igdefault"));
user.setDevices(createTestDevices(i, user));
HashSet<Role> roleSet = new HashSet<Role>();
roleSet.add(roleRepoService.findRoleByAuthority(RoleType.ROLE_USER.name()));
user.setRoles(roleSet);
userList.add(user);
}
}
userRepoService.save(userList);
}
private void createAdminUser() {
log.info("Admin user created");
String emailId = "[email protected]";
if (userRepoService.countUserByEmailId(emailId) < 1) {
User adminUser = new User("firstName", "lastName", emailId, new BCryptPasswordEncoder().encode("admin"));
HashSet<Role> roleSet = new HashSet<Role>();
roleSet.add(roleRepoService.findRoleByAuthority(RoleType.ROLE_ADMIN.name()));
adminUser.setRoles(roleSet);
userRepoService.save(adminUser);
}
}
private Set<Device> createTestDevices(Integer noOfDevices, User user) {
Set<Device> devices = new HashSet<>(noOfDevices);
for (Integer count = 0; count < noOfDevices; count++) {
Device device = new Device();
device.setDeviceType(DeviceType.TYPE_1);
device.setUserFriendlyName("User Friendly name for Device");
device.setAppliances(createTestAppliances(count, device));
device.setUser(user);
devices.add(device);
}
return devices;
}
private Set<Appliance> createTestAppliances(Integer noOfAppliances, Device device) {
Set<Appliance> appliances = new HashSet<>(noOfAppliances);
for (Integer count = 0; count < noOfAppliances; count++) {
Appliance appliance = new Appliance();
appliance.setWebStatus("1");
appliance.setUserFriendlyName("User Friendly name for Appliance- ");
appliances.add(appliance);
appliance.setDevice(device);
}
return appliances;
}
private void createTestRole() {
if (roleRepoService.countRoleByAuthority(RoleType.ROLE_ADMIN.name()) < 1) {
Role role1 = new Role();
role1.setAuthority(RoleType.ROLE_ADMIN.name());
roleRepoService.save(role1);
}
if (roleRepoService.countRoleByAuthority(RoleType.ROLE_USER.name()) < 1) {
Role role2 = new Role();
role2.setAuthority(RoleType.ROLE_USER.name());
roleRepoService.save(role2);
}
}
}
| [
"[email protected]"
] | |
0d9431b4429b981a0b0b02196b26ee7854960261 | 8d86599c933ef1f52b6a980871207d54b4417cf9 | /Modul3/11.MVC/Thuc_hanh/src/controller/CustomerServlet.java | 9ba1221d0c4befb01c74d57d9b040871e75fe068 | [] | no_license | vphuc0601/C0920G1-Nguyen-Van-Phuc | 38b4e13c817588fd629c133165d8d9df069f6be7 | 71a3a6f89bd745779b20e31fdfcef029ce6547dc | refs/heads/master | 2023-04-23T22:31:58.472256 | 2021-05-07T09:26:32 | 2021-05-07T09:26:32 | 295,303,727 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,278 | java | package controller;
import model.Customer;
import service.CustomersService;
import service.CustomersServiceImpl;
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 java.io.IOException;
import java.util.List;
@WebServlet(name = "CustomerServlet", urlPatterns = {"","/customer"})
public class CustomerServlet extends HttpServlet {
private CustomersService service = new CustomersServiceImpl();
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter("action");
if (action == null) {
action = "";
}
switch (action) {
case "create":
showCreateForm(request,response);
break;
case "edit":
break;
case "delete":
break;
case "view":
break;
default:
listCustomers(request,response);
break;
}
}
private void listCustomers(HttpServletRequest request, HttpServletResponse response) {
List<Customer> customers = service.findAll();
request.setAttribute("customers", customers);
RequestDispatcher dispatcher = request.getRequestDispatcher("customer/list.jsp");
try {
dispatcher.forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void showCreateForm(HttpServletRequest request, HttpServletResponse response){
RequestDispatcher dispatcher=request.getRequestDispatcher("customer/create.jsp");
try {
dispatcher.forward(request,response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} | [
"[email protected]"
] | |
16d118fa277e528dea77b6d25cb708d0b54ba543 | d4a9ef8bcbb8ab77a4327fb11b78db16658588d2 | /TestExercise/src/utl/Grades.java | 0593c51f79302cdcf9524262801f581499022b01 | [] | no_license | KwokShing/Java | 431e83bba016305df77f5a98b1b6193ba30246fc | 266172d07b18cb0a9e9172f55f8f5fae77833d04 | refs/heads/master | 2016-09-11T13:05:36.816186 | 2016-01-13T05:17:28 | 2016-01-13T05:17:28 | 22,006,841 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 517 | java | package utl;
public class Grades {
public static String Grade(int exam, int course) {
String result = "null";
long average;
average = Math.round((exam + course) / 2);
if ((exam < 0) || (exam > 100) || (course < 0) || (course > 100))
result = "Marks out of range";
else {
if ((exam < 50) || (course < 50)) {
result = "Fail";
} else if (exam < 60) {
result = "Pass,C";
} else if (average >= 70) {
result = "Pass,A";
} else {
result = "Pass,B";
}
}
return result;
}
}
| [
"[email protected]"
] | |
c3f3718babb863699ae1d47c390734e7f61f4f5f | d437c3d5c18105c891de75e17ff1a16044b660fa | /src/main/java/com/kharchenko/university/model/Subject.java | f90ade612d89fb7642792a81b0f027faf46421c0 | [] | no_license | OlessiaKharchenko/university | bc25d61c2fec72acf63a8bd1918702b7fdfeb13c | 0f628fc80d376a13ee634c684a78e0688a535e1d | refs/heads/main | 2023-06-02T15:56:30.891453 | 2021-06-16T18:48:23 | 2021-06-16T18:48:23 | 370,108,213 | 0 | 0 | null | 2021-06-16T18:48:23 | 2021-05-23T16:56:38 | Java | UTF-8 | Java | false | false | 280 | java | package com.kharchenko.university.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Subject {
private Integer id;
private String name;
private String description;
} | [
"[email protected]"
] | |
3709229c52d4bdcbccc6c1a7902029d1c9f07eb1 | 56c5f8fdf5a2c6d99b9e7bf4f5025852f83f249e | /src/com/marocgeo/als/utils/GpsTrackerLatLng.java | 5e8f08b00ae3a6a267c58a25461f5d47eeb642e7 | [] | no_license | karouani/DoliDroidALS | d8e8e759f63cf7e3a5dde3a9e888653bb44235de | aa61d95ce1c1b29f62ecab1a1922f9e576ea528b | refs/heads/master | 2021-03-12T23:43:16.723768 | 2015-07-28T10:50:00 | 2015-07-28T10:50:00 | 39,825,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,161 | java | package com.marocgeo.als.utils;
import android.app.Activity;
import android.content.Context;
import android.location.LocationManager;
import com.google.android.gms.location.LocationListener;
import com.marocgeo.als.models.GpsTracker;
public class GpsTrackerLatLng extends Activity{
private GpsTracker gps;
public GpsTrackerLatLng() {
gps = new GpsTracker();
}
public GpsTracker getGps(){
LocationManager mlocManager=null;
android.location.LocationListener mlocListener;
mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
if (mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
if(MyLocationListener.latitude>0)
{
gps.setLangitude(""+MyLocationListener.longitude);
gps.setLatitude(""+MyLocationListener.latitude);
}
else
{
gps.setLangitude(""+0);
gps.setLatitude(""+0);
}
}
return gps;
}
}
| [
"[email protected]"
] | |
f75d712147f45a1f198ce7b98e547f051bed952a | 17fcfd39f6d9ea9943fb5d73077694256b23c744 | /Ex1/Part1/app/src/test/java/com/example/tuanle/retrofitexample/ExampleUnitTest.java | 2730dbe6f2c4e0e027e11ed23f458c0eae77e463 | [] | no_license | boyluv/mobile_application_development | c15de655934495b3a8f411979f06396017db0ad9 | 996944d6e1643ae770a95f041feb83a7efd487f3 | refs/heads/master | 2021-04-06T09:26:25.424558 | 2018-04-20T06:11:38 | 2018-04-20T06:11:38 | 124,719,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package com.example.tuanle.retrofitexample;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
0df5850231c45f3a7e0b061e1212aff5045404d2 | d50b6ac201e8898560ae6c2c59dfd0371ca1fd88 | /app/src/main/java/com/example/readshare/Activity/ui/main/TracabiliteAdapter.java | 0b736d58ac873bada8701ec0dd74abf21c7eee52 | [] | no_license | widadWatawi/ReadShare | 8d94159f2284698c1036537b8a4860b5ab753dfa | e10f456abcf31001fb726579a8fae90a5e849d28 | refs/heads/master | 2020-09-20T13:27:00.365971 | 2020-01-06T17:52:50 | 2020-01-06T17:52:50 | 224,495,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,661 | java | package com.example.readshare.Activity.ui.main;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.example.readshare.R;
public class TracabiliteAdapter extends RecyclerView.Adapter<TracabiliteAdapter.ViewHolder>{
private ListTracabilite[] listTracabilite;
// RecyclerView recyclerView;
public TracabiliteAdapter(ListTracabilite[] listTracabilites) {
this.listTracabilite=listTracabilites;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem= layoutInflater.inflate(R.layout.liste_tracabilite, parent, false);
ViewHolder viewHolder = new ViewHolder(listItem);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final ListTracabilite myList = listTracabilite[position];
holder.distuser.setText(listTracabilite[position].getDistance());
holder.imageuser.setImageResource(listTracabilite[position].getImg());
}
@Override
public int getItemCount() {
return listTracabilite.length;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public ImageView imageuser;
public TextView distuser;
public ViewHolder(View itemView) {
super(itemView);
this.imageuser = (ImageView) itemView.findViewById(R.id.imageuser);
this.distuser = (TextView) itemView.findViewById(R.id.distanceUser);
}
}
}
| [
"[email protected]"
] | |
ecf5fc9e3d0e35b555252fb9f5d661b0ad1f39c7 | 9f8154fac4127beb39e15ad8235a25cbea68de6c | /app/src/main/java/jgg/com/jdemo/view/CustmView4.java | 75f22a8ecf27088a397fe691528612fe93e57ba0 | [] | no_license | 345127607/JDemo | 5558f572e478395ea1d8a802e9b350e5ca1afcec | e4a2371188c1a745bec96aabd396d3a7675b5fd2 | refs/heads/master | 2020-03-22T06:50:25.362511 | 2018-08-08T01:25:50 | 2018-08-08T01:25:50 | 139,661,534 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,578 | java | package jgg.com.jdemo.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class CustmView4 extends View {
public CustmView4(Context context) {
super(context);
}
public CustmView4(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public CustmView4(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public CustmView4(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
Paint paint =new Paint(Paint.ANTI_ALIAS_FLAG);
Path path = new Path();
{
// 使用 path 对图形进行描述(这段描述代码不必看懂)
path.addArc(200, 200, 400, 400, -225, 225);
path.arcTo(400, 200, 600, 400, -180, 225, false);
path.lineTo(400, 542);
path.close();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
/*
心形
*/
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL);
canvas.drawPath(path,paint);
}
}
| [
"[email protected]"
] | |
16fef2ba4515a6b48cffc42234d430f05cac1add | c89b21232f0c7737237a5e56f041eb0043f3cd88 | /library/src/main/java/me/donnie/adapter/BaseAdapter.java | eb21c5860023f01f72ea929f2d2c936915f2ed78 | [] | no_license | donniesky/BaseAdapter | 1b6abb086d570da8e0eb8a7f070a432833611b2b | 5ffc8d5858f3a5779f89c21a04ae64c5b80bb32f | refs/heads/master | 2020-12-02T21:23:01.006478 | 2018-07-03T03:12:31 | 2018-07-03T03:12:31 | 96,305,192 | 1 | 1 | null | 2017-07-06T06:39:40 | 2017-07-05T10:00:32 | Java | UTF-8 | Java | false | false | 3,706 | java | package me.donnie.adapter;
import android.support.annotation.IntRange;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author donnieSky
* @created_at 2017/7/5.
* @description
*/
public abstract class BaseAdapter<T, VH extends BaseViewHolder> extends RecyclerView.Adapter<VH> {
protected List<T> mData;
protected int mLayoutResId;
protected OnItemClickListener mOnItemClickListener;
@NonNull
public List<T> getData() {
return mData;
}
public void setData(@Nullable List<T> data) {
this.mData = data == null ? new ArrayList<T>() : data;
notifyDataSetChanged();
}
public void addData(@IntRange(from = 0) int position, @NonNull Collection<? extends T> newData) {
mData.addAll(position, newData);
notifyItemRangeInserted(position, newData.size());
compatibilityDataSizeChanged(newData.size());
}
public void addData(@NonNull Collection<? extends T> newData) {
mData.addAll(newData);
notifyItemRangeInserted(mData.size() - newData.size(), newData.size());
compatibilityDataSizeChanged(newData.size());
}
public void replaceData(@NonNull Collection<? extends T> data) {
mData.clear();
mData.addAll(data);
notifyDataSetChanged();
}
private void compatibilityDataSizeChanged(int size) {
final int dataSize = mData == null ? 0 : mData.size();
if (dataSize == size) {
notifyDataSetChanged();
}
}
@Nullable
public T getItem(@IntRange(from = 0) int position) {
if (position < mData.size()) {
return mData.get(position);
} else {
return null;
}
}
public BaseAdapter(@Nullable List<T> data) {
this(0, data);
}
public BaseAdapter(@LayoutRes int layoutResId) {
this(layoutResId, null);
}
public BaseAdapter(@LayoutRes int layoutResId, @Nullable List<T> data) {
this.mData = data == null ? new ArrayList<T>() : data;
if (layoutResId != 0) {
this.mLayoutResId = layoutResId;
}
}
@Override
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
BaseViewHolder holder = BaseViewHolder.createViewHolder(parent.getContext(), parent, mLayoutResId);
setListener(parent, holder, viewType);
return (VH) holder;
}
@Override
public void onBindViewHolder(VH holder, int position) {
convert(holder, mData.get(position), position);
}
@Override
public int getItemCount() {
return mData.size();
}
protected abstract void convert(VH holder, T t, int position);
protected void setListener(final ViewGroup parent, final BaseViewHolder viewHolder, int viewType) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnItemClickListener != null) {
int position = viewHolder.getAdapterPosition();
mOnItemClickListener.onItemClick(v, viewHolder, position);
}
}
});
}
public interface OnItemClickListener {
void onItemClick(View view, BaseViewHolder holder, int position);
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
}
| [
"[email protected]"
] | |
146a28ae1c75388e202a93e87c19bd30ac7541c4 | 0c98cf3f64a72ceb4987f23936979d587183e269 | /services/sms/src/main/java/com/huaweicloud/sdk/sms/v3/model/DeleteTaskResponse.java | caa63b90e4c57ca88eeda068ddf77a1cdf22b1a5 | [
"Apache-2.0"
] | permissive | cwray01/huaweicloud-sdk-java-v3 | 765d08e4b6dfcd88c2654bdbf5eb2dd9db19f2ef | 01b5a3b4ea96f8770a2eaa882b244930e5fd03e7 | refs/heads/master | 2023-07-17T10:31:20.119625 | 2021-08-31T11:38:37 | 2021-08-31T11:38:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 722 | java | package com.huaweicloud.sdk.sms.v3.model;
import com.huaweicloud.sdk.core.SdkResponse;
import java.util.Objects;
/** Response Object */
public class DeleteTaskResponse extends SdkResponse {
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode() {
return Objects.hash();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeleteTaskResponse {\n");
sb.append("}");
return sb.toString();
}
}
| [
"[email protected]"
] | |
9b36a1d2beaa58594b1541816d0e70dc37f30135 | 2093c2f8c79ea54b69834580cbdee2933cd7db26 | /project_h6t2b/src/main/persistence/Writable.java | 43f3570b0aec88e5398cc0de7fd3de56789b431c | [] | no_license | mayjang/Hydropathy_Plot | d6723a8f6f22833be5228873a7066a3a142caf1b | af7407eeae9856fbb17405308d3558e11122d08e | refs/heads/main | 2023-06-18T08:29:33.164981 | 2021-06-29T07:13:42 | 2021-06-29T07:13:42 | 370,842,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 227 | java | package persistence;
import org.json.JSONObject;
//Citation: https://github.students.cs.ubc.ca/CPSC210/JsonSerializationDemo
public interface Writable {
// EFFECTS: returns this as JSON object
JSONObject toJson();
}
| [
"[email protected]"
] | |
d8f93a98d59d14100f31d5b9f290b37aa0d8aa16 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/30/30_4d242db502b5b96fc3d5ddbbe7066577c202d078/GatewayLoopActivityBuilder/30_4d242db502b5b96fc3d5ddbbe7066577c202d078_GatewayLoopActivityBuilder_s.java | b54c19cb2afbfe0fc16f381a532e3a4f00a66f56 | [] | 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 | 3,409 | java | /**
* Approved for Public Release: 10-4800. Distribution Unlimited.
* Copyright 2011 The MITRE Corporation,
* 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.wiredwidgets.cow.server.transform.v2;
import org.apache.log4j.Logger;
import org.wiredwidgets.cow.server.api.model.v2.Loop;
/**
* A Loop is implemented as an Activity followed by a Task in which a decision is made
* This requires multiple lastNode instances
* @author JKRANES
*/
public class GatewayLoopActivityBuilder extends ActivityBuilderImpl<Loop> {
private static Logger log = Logger.getLogger(GatewayLoopActivityBuilder.class);
public GatewayLoopActivityBuilder(ProcessContext context, Loop loop, ActivityBuilderFactory factory) {
super(context, loop, factory);
}
@Override
public void build() {
Loop source = getActivity();
// start with a converging gateway
NodeBuilder convergingGatewayBuilder = this.createNodeBuilder(getContext(), source, NodeType.CONVERGING_EXCLUSIVE_GATEWAY);
convergingGatewayBuilder.build(this);
setLinkTarget(convergingGatewayBuilder);
ActivityBuilder activityBuilder = createActivityBuilder(source.getActivity().getValue());
activityBuilder.build(this);
convergingGatewayBuilder.link(activityBuilder);
// Following the Activity we insert a Task for making a decision
// whether to repeat the Activity or continue
// ActivityBuilder loopTaskBuilder = createActivityBuilder(source.getLoopTask());
NodeBuilder loopTaskBuilder = createNodeBuilder(getContext(), source, NodeType.LOOP_TASK);
loopTaskBuilder.build(this);
// Use a named transition for the continue path
// This name should be used in the UI
// NOTE: this MUST go after the build() call
loopTaskBuilder.setLinkTransitionName(source.getDoneName());
activityBuilder.link(loopTaskBuilder);
// following the task we have a diverging gateway
NodeBuilder divergingGatewayBuilder = this.createNodeBuilder(getContext(), source, NodeType.DIVERGING_EXCLUSIVE_GATEWAY);
// a bit of a hack to inject the name of the decision variable into the gateway builder
divergingGatewayBuilder.setBuildProperty("decisionVar", loopTaskBuilder.getBuildProperty("decisionVar"));
divergingGatewayBuilder.build(this);
loopTaskBuilder.link(divergingGatewayBuilder);
// Link the diverging gateway back to the converging gateway
// TODO: figure out how to express named transitions in BPMN20
// should be used in the UI
divergingGatewayBuilder.link(convergingGatewayBuilder, source.getRepeatName());
setLinkSource(divergingGatewayBuilder);
}
}
| [
"[email protected]"
] | |
6058775cb1f8352a04d4e5d35c48a59b5ca3367f | 0bc3bc1abe8c0949ca09b9661e0c0fd6e106bee2 | /AndroidStudioProjects/VIVO/AndroidStudioProjects/GlobalSearchDemo/app/src/main/java/com/vivo/globalsearchdemo/model/SearchModel.java | 241d3b8599389b2e74bb4e837216b16d9c3b6ea8 | [] | no_license | x554536080/GlobalSearchDemo | d39e54fe192afa31c06c683e761181124bfe4665 | 67cd6158e2eb78b87e1edd3f9649783ad12c1428 | refs/heads/master | 2020-04-08T04:35:22.987072 | 2018-12-13T08:52:16 | 2018-12-13T08:52:19 | 159,023,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 105 | java | package com.vivo.globalsearchdemo.model;
public interface SearchModel {
void doSearch(String input);
}
| [
"[email protected]"
] | |
65b395d18afb55f2d2cfce9788b37adf960b3e57 | 256f4bed8d8f42560a168364056acf47893ddc2c | /bin/custom/merchandisefulfilmentprocess/testsrc/org/merchandise/fulfilmentprocess/test/actions/consignmentfulfilment/AllowShipment.java | de27e0f3fd2af3e435358fe39a7461cd2ed55658 | [] | no_license | marty-friedman/e-commerce | 87d5b4226c9a06ca6020bf87c738e6590c071e3f | 5c56f40d240f848e234f430ce904d4483ffe8117 | refs/heads/master | 2021-09-20T13:55:37.744933 | 2018-08-10T03:51:06 | 2018-08-10T03:51:06 | 142,566,237 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 557 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
*
* This software is the confidential and proprietary information of SAP
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with SAP.
*/
package org.merchandise.fulfilmentprocess.test.actions.consignmentfulfilment;
public class AllowShipment extends AbstractTestConsActionTemp
{
// Empty
}
| [
"[email protected]"
] | |
bf710b5049ac59e6c9ac534f22611d865cca83d0 | 373cb1aa9b227313e9f696965b885941a9e5a195 | /Series2/src/Series2.java | f91560cf0e92d37e35ae9620abcbc24145c8399e | [] | no_license | atanbhardwaj/BasicJavaPrograms | 8d579379b7ef23e3a8e98e63a1c8c653714d5ebc | 47a52fe144e50ef1ad179ed2e4c6145590aa9879 | refs/heads/master | 2023-02-06T22:22:54.083094 | 2021-01-01T17:48:23 | 2021-01-01T17:48:23 | 326,027,458 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 972 | java | import java.util.Scanner;
public class Series2 {
public static void main(String st[])
{
Scanner x = new Scanner(System.in);
int n,ch;
System.out.print("Press 1 for S=1/22+1/33+1/44...upto n terms \nPress 2 for S=1/1!+22/2!+33/3!+...upto n terms");
System.out.print("\nEnter the value of n:");
n=x.nextInt();
System.out.print("Enter your choice ");
ch=x.nextInt();
switch(ch)
{
case 1:
S1 s1=new S1();
s1.input(n);
break;
case 2:
S2 s2=new S2();
s2.input(n);
break;
}
x.close();
}
}
class S1{
double sum=0.0;
int i;
void input(int n)
{
for(i=2;i<=(n+1);i++)
{
sum+=(1/(double)(11*i));
}
System.out.print("The sum is: "+sum);
}
}
class S2{
double sum=0.0;
int i,f;
void input(int n)
{
if(n==1)
sum=1;
else
{
sum=1;
for(i=2;i<=n;i++)
sum+=(11*i)/(double)(in(i));
}
System.out.print("Sum is "+sum);
}
int in(int k)
{
f=1;
while(k!=0)
{
f*=k;
k--;
}
return f;
}
}
| [
"[email protected]"
] | |
abc2a618d5d37e50ef024d0fd63791734620ffc1 | d2e4af8b4876edcb49f1b7cdfaf3074363edb285 | /src/com/xu/observer/WeatherData.java | 953ee672011699a87d18edca606d5ab7725fe5c1 | [] | no_license | xuhewei/design_partten | ad415ab239cdf4ef27a9b8d71ef86209560581f7 | 51df17f89b9266c0bcaa5f87e7bfe47e5f4d1fd8 | refs/heads/master | 2021-09-09T19:33:28.709489 | 2018-03-19T08:57:03 | 2018-03-19T08:57:03 | 125,020,353 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | package com.xu.observer;
public class WeatherData {
private float mTemperatrue;
private float mPressure;
private float mHumidity;
private CurrentConditions mCurrentConditions;
public WeatherData(CurrentConditions mCurrentConditions)
{
this. mCurrentConditions= mCurrentConditions;
}
public float getTemperature()
{
return mTemperatrue;
}
public float getPressure()
{
return mPressure;
}
public float getHumidity()
{
return mHumidity;
}
public void dataChange()
{
mCurrentConditions.update(getTemperature(), getPressure(), getHumidity());
}
public void setData(float mTemperature,float mPressure,float mHumidity)
{
this.mTemperatrue=mTemperature;
this.mPressure=mPressure;
this.mHumidity=mHumidity;
dataChange();
}
}
| [
"[email protected]"
] | |
35adf8561f35ca7b8bae028d7d0a417aa355deb3 | 90f68055a914df0839f5dd92cae3a5863a630040 | /OTPService/src/main/java/com/phatlt/OTPService/model/APIResponse.java | f3c4b8dc3c7a1c4f94b2bfd7932a9cafce3a1c8d | [] | no_license | AntonyLe23/nab-challenge | 04f3305171b2fec29e8b9b19f22c4f1de69a0807 | 154a89982db973ef9183c7c6e3f2b3fe4f8138ac | refs/heads/master | 2023-02-22T00:26:28.033230 | 2021-01-22T07:56:20 | 2021-01-22T07:56:20 | 329,576,656 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | package com.phatlt.OTPService.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@AllArgsConstructor
public class APIResponse implements Serializable {
private int codeStatus;
private String messageStatus;
private Object data;
}
| [
"[email protected]"
] | |
90a7c58d86317afed42514f1b80a934baeeb0ef5 | 5f9ad033fbd9131b712bc0f188fde4e4753aefaf | /src/test/java/com/the/dark/side/crew/fejsbuk/FejsbukApplicationTests.java | 0b00f9e11997b7080b5c1d00fb1989dfd2aa37b4 | [] | no_license | TheDarkSideCrew/fejs-buk | ba712c583e0b35a26d03f3da9e203a28e16f26ab | b76e3af36e7883ea3d91b9bd1cdf1175487ed0f6 | refs/heads/master | 2023-03-18T01:24:05.498893 | 2021-03-12T17:50:30 | 2021-03-12T17:50:30 | 321,744,003 | 0 | 0 | null | 2021-03-12T17:50:33 | 2020-12-15T17:43:51 | Java | UTF-8 | Java | false | false | 223 | java | package com.the.dark.side.crew.fejsbuk;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class FejsbukApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
e07e7eebe7b81d5da25edbd7fbd54b827dc1c44c | 3fe8e5db53dc425afdb24303f2f6926cade14f04 | /user/ezt_hall/src/main/java/com/eztcn/user/hall/model/UpLoadAvatarResponse.java | cf334289dbf359e651b7effdebd6e02a4a92f042 | [] | no_license | llorch19/ezt_user_code | 087a9474a301d8d8fef7bd1172d6c836373c2faf | ee82f4bfbbd14c81976be1275dcd4fc49f6b1753 | refs/heads/master | 2021-06-01T09:40:19.437831 | 2016-08-10T02:33:35 | 2016-08-10T02:33:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,202 | java | package com.eztcn.user.hall.model;
/**
* @Author: lizhipeng
* @Data: 16/6/25 下午6:03
* @Description:
*/
public class UpLoadAvatarResponse {
/**
* data : http://images.eztcn.com.cn/images/patient/eztcn2.0/7BA88A782515F9E7B78ACAD1A6C0E5A6.jpeg
* detailMsg : 数据修改成功!
* flag : true
* msg : 数据修改成功!
* number : 2002
*/
private String data;
private String detailMsg;
private boolean flag;
private String msg;
private String number;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getDetailMsg() {
return detailMsg;
}
public void setDetailMsg(String detailMsg) {
this.detailMsg = detailMsg;
}
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
| [
"[email protected]"
] | |
0c4480d79b5c8eea36fbed915564a6dbdb38bfb0 | 956d0dfe725a50cdfea6059c0483289b7c507842 | /app/src/main/java/com/uav/autodebit/vo/StatusVO.java | 0784b3155b19c14b85d636534d510b9c02f461cd | [] | no_license | anku1207/AutoDebit-Android_Hundi_07-11-2020 | c0e9778aae219b8eebb2f7c7299d24e1fd40b787 | e03d14719b0eaa625656040951f4fcd1b0c5205d | refs/heads/master | 2023-03-13T00:55:49.505761 | 2021-02-25T07:23:54 | 2021-02-25T07:23:54 | 310,817,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 819 | java | package com.uav.autodebit.vo;
public class StatusVO extends BaseVO {
public static Integer ACTIVE=1;
public static Integer INACTIVE=2;
public static Integer CREATED=3;
public static Integer COMPLETED=4;
public static Integer INITIATIED=5;
public static Integer FAIELD=6;
public static Integer SUCCESSFULL=7;
public static Integer PENDING=8;
private Integer statusId;
private String statusName;
public StatusVO() {
}
public Integer getStatusId() {
return statusId;
}
public StatusVO setStatusId(Integer statusId) {
this.statusId = statusId;
return null;
}
public String getStatusName() {
return statusName;
}
public void setStatusName(String statusName) {
this.statusName = statusName;
}
}
| [
"[email protected]"
] | |
057d9879637b0645a7f996c0928891622897998e | 2c55167b086b19933d5a28e03c9d210dc26caf4c | /commercetools-sdk-base/src/main/java/io/sphere/sdk/annotations/NotOSGiCompatible.java | ec7f02c4dd36b6dd5e8e8fc6826db98f9dcca95e | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | commercetools/commercetools-jvm-sdk | 02a1b6162aff245dce35a2e17b41c5fc8481cf33 | 9268215185628611ad12502cb9c844e8b65c2944 | refs/heads/master | 2023-08-31T20:04:34.331396 | 2023-08-11T07:43:29 | 2023-08-11T07:43:29 | 20,855,247 | 46 | 50 | NOASSERTION | 2023-08-11T09:27:43 | 2014-06-15T12:46:24 | Java | UTF-8 | Java | false | false | 418 | java | package io.sphere.sdk.annotations;
import java.lang.annotation.*;
/**
* This annotation marks the classes that are selected to run outside an OSGi container
* either for latency reason or for dependency issue ...,the runner used in that case
* is {@link org.junit.runners.BlockJUnit4ClassRunner}
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Target(ElementType.TYPE)
public @interface NotOSGiCompatible {
}
| [
"[email protected]"
] | |
ab494328e881e6c81b9d9d7abae7a15109b2ba16 | ac7e6719811aa3ade91c3c2f878ffa5617da1f02 | /java_basic/kadai/kadai/BookUse.java | 77688da69b269f69d66f5176e4b5c0441431451f | [] | no_license | sakiko-senba/JavaBasic | cc5c0103b95cb40d9c6da4daed21fadf1f8a2f12 | fc6701c804f1c50df52f2131a9907c2e2e7b54b9 | refs/heads/main | 2023-08-29T13:53:14.993780 | 2021-10-25T02:40:12 | 2021-10-25T02:40:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 496 | java | package kadai;
public class BookUse {
public static void main(String[] args) {
Book1 booka = new Book1();
booka.setBook("3月のライオン");
booka.disp();
System.out.println();
Book1 bookb = new Book1();
bookb.setBook("銀の匙","荒川弘");
bookb.disp();
System.out.println();
Book1 bookc = new Book1();
bookc.setBook("海街iary","吉田秋生",1000);
bookc.disp();
System.out.println();
}
}
| [
"[email protected]"
] | |
72aa5303f0af3df1f4d92224343632ca7d340fdf | a00326c0e2fc8944112589cd2ad638b278f058b9 | /src/main/java/000/132/163/CWE191_Integer_Underflow__int_random_sub_13.java | a7704f9ba953038ef27a3fc36ce5234c3f9cc52a | [] | no_license | Lanhbao/Static-Testing-for-Juliet-Test-Suite | 6fd3f62713be7a084260eafa9ab221b1b9833be6 | b095b11c7cb6d4a5bb2b76181e35d6ee00e96e68 | refs/heads/master | 2020-08-24T13:34:04.004149 | 2019-10-25T09:26:00 | 2019-10-25T09:26:00 | 216,822,684 | 0 | 1 | null | 2019-11-08T09:51:54 | 2019-10-22T13:37:13 | Java | UTF-8 | Java | false | false | 5,898 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE191_Integer_Underflow__int_random_sub_13.java
Label Definition File: CWE191_Integer_Underflow__int.label.xml
Template File: sources-sinks-13.tmpl.java
*/
/*
* @description
* CWE: 191 Integer Underflow
* BadSource: random Set data to a random value
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks: sub
* GoodSink: Ensure there will not be an underflow before subtracting 1 from data
* BadSink : Subtract 1 from data, which can cause an Underflow
* Flow Variant: 13 Control flow: if(IO.STATIC_FINAL_FIVE==5) and if(IO.STATIC_FINAL_FIVE!=5)
*
* */
import java.security.SecureRandom;
public class CWE191_Integer_Underflow__int_random_sub_13 extends AbstractTestCase
{
public void bad() throws Throwable
{
int data;
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: Set data to a random value */
data = (new SecureRandom()).nextInt();
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run
* but ensure data is inititialized before the Sink to avoid compiler errors */
data = 0;
}
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: if data == Integer.MIN_VALUE, this will overflow */
int result = (int)(data - 1);
IO.writeLine("result: " + result);
}
}
/* goodG2B1() - use goodsource and badsink by changing first IO.STATIC_FINAL_FIVE==5 to IO.STATIC_FINAL_FIVE!=5 */
private void goodG2B1() throws Throwable
{
int data;
if (IO.STATIC_FINAL_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run
* but ensure data is inititialized before the Sink to avoid compiler errors */
data = 0;
}
else
{
/* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
data = 2;
}
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: if data == Integer.MIN_VALUE, this will overflow */
int result = (int)(data - 1);
IO.writeLine("result: " + result);
}
}
/* goodG2B2() - use goodsource and badsink by reversing statements in first if */
private void goodG2B2() throws Throwable
{
int data;
if (IO.STATIC_FINAL_FIVE==5)
{
/* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
data = 2;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run
* but ensure data is inititialized before the Sink to avoid compiler errors */
data = 0;
}
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: if data == Integer.MIN_VALUE, this will overflow */
int result = (int)(data - 1);
IO.writeLine("result: " + result);
}
}
/* goodB2G1() - use badsource and goodsink by changing second IO.STATIC_FINAL_FIVE==5 to IO.STATIC_FINAL_FIVE!=5 */
private void goodB2G1() throws Throwable
{
int data;
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: Set data to a random value */
data = (new SecureRandom()).nextInt();
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run
* but ensure data is inititialized before the Sink to avoid compiler errors */
data = 0;
}
if (IO.STATIC_FINAL_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
IO.writeLine("Benign, fixed string");
}
else
{
/* FIX: Add a check to prevent an overflow from occurring */
if (data > Integer.MIN_VALUE)
{
int result = (int)(data - 1);
IO.writeLine("result: " + result);
}
else
{
IO.writeLine("data value is too small to perform subtraction.");
}
}
}
/* goodB2G2() - use badsource and goodsink by reversing statements in second if */
private void goodB2G2() throws Throwable
{
int data;
if (IO.STATIC_FINAL_FIVE==5)
{
/* POTENTIAL FLAW: Set data to a random value */
data = (new SecureRandom()).nextInt();
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run
* but ensure data is inititialized before the Sink to avoid compiler errors */
data = 0;
}
if (IO.STATIC_FINAL_FIVE==5)
{
/* FIX: Add a check to prevent an overflow from occurring */
if (data > Integer.MIN_VALUE)
{
int result = (int)(data - 1);
IO.writeLine("result: " + result);
}
else
{
IO.writeLine("data value is too small to perform subtraction.");
}
}
}
public void good() throws Throwable
{
goodG2B1();
goodG2B2();
goodB2G1();
goodB2G2();
}
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"[email protected]"
] | |
c5deb5819b0fd36ddbb264cbf9e054ad86cc44fa | c0645a2ad02123de03a7fc039858cf219f4b21f7 | /src/main/java/com/mmall/service/impl/UserServiceImpl.java | 22a47fe3e77c85ec58f6fe59f8c88b996665011d | [] | no_license | ChungYikHawn/happyMall | 1408394df7b774b5808c51d8021c662cc3a10940 | 4503bfcbab8820c62ddb250393293be8535e1ce6 | refs/heads/main | 2023-02-08T22:22:52.718041 | 2020-12-30T06:59:26 | 2020-12-30T06:59:26 | 319,195,311 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,308 | java | package com.mmall.service.impl;
import com.mmall.common.Const;
import com.mmall.common.ServerResponse;
import com.mmall.common.TokenCache;
import com.mmall.dao.UserDao;
import com.mmall.pojo.User;
import com.mmall.service.IUserService;
import com.mmall.util.MD5Util;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
@Service("iUserService")
public class UserServiceImpl implements IUserService {
@Autowired
private UserDao userDao;
@Override
public ServerResponse<User> login(String username, String password) {
int resultCount = userDao.checkUsername(username);
if (resultCount == 0) {
return ServerResponse.createByErrorMessage("用户名不存在");
}
//密码登录MD5
String md5Password = MD5Util.MD5EncodeUtf8(password);
User user = userDao.selectLogin(username, md5Password);
if (user == null) {
return ServerResponse.createByErrorMessage("密码错误");
}
user.setPassword(StringUtils.EMPTY);
return ServerResponse.createBySuccess("登录成功", user);
}
@Override
public ServerResponse<String> register(User user) {
ServerResponse validResponse = this.checkValid(user.getUsername(), Const.USERNAME);
if (!validResponse.isSuccess()) {
return validResponse;
}
validResponse = this.checkValid(user.getEmail(), Const.EMAIL);
if (!validResponse.isSuccess()) {
return validResponse;
}
user.setRole(Const.Role.ROLE_CUSTOMER);
//MD5加密
user.setPassword(MD5Util.MD5EncodeUtf8(user.getPassword()));
int resultCount = userDao.insert(user);
if (resultCount == 0) {
return ServerResponse.createByErrorMessage("注册失败");
}
return ServerResponse.createBySuccess("注册成功");
}
@Override
public ServerResponse<String> checkValid(String str, String type) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(type)) {
//开始校验
if (Const.USERNAME.equals(type)) {
int resultCount = userDao.checkUsername(str);
if (resultCount > 0) {
return ServerResponse.createByErrorMessage("用户名已存在");
}
}
if (Const.EMAIL.equals(type)) {
int resultCount = userDao.checkEmail(str);
if (resultCount > 0) {
return ServerResponse.createByErrorMessage("email已存在");
}
}
} else {
return ServerResponse.createByErrorMessage("参数错误");
}
return ServerResponse.createBySuccessMessage("校验成功");
}
@Override
public ServerResponse selectQuestion(String username) {
ServerResponse<String> validResponse = this.checkValid(username, Const.USERNAME);
if (validResponse.isSuccess()) {
return ServerResponse.createByErrorMessage("用户不存在");
}
String question = userDao.selectQuestionByUsername(username);
if (StringUtils.isNotBlank(question)) {
return ServerResponse.createBySuccess(question);
}
return ServerResponse.createByErrorMessage("找回密码的问题是空");
}
public ServerResponse<String> checkAnswer(String username, String question, String answer) {
int resultCount = userDao.checkAnswer(username, question, answer);
if (resultCount > 0) {
String forgetToken = UUID.randomUUID().toString();
TokenCache.setKey(TokenCache.TOKEN_PREFIX + username, forgetToken);
return ServerResponse.createBySuccess(forgetToken);
}
return ServerResponse.createByErrorMessage("问题答案错误");
}
@Override
public ServerResponse<String> forgetResetPassword(String username, String passwordNew, String forgetToken) {
if (StringUtils.isBlank(forgetToken)) {
return ServerResponse.createByErrorMessage("参数错误,token需要传递");
}
ServerResponse validResponse = this.checkValid(username, Const.USERNAME);
if (validResponse.isSuccess()) {
return ServerResponse.createByErrorMessage("用户名不存在");
}
String token = TokenCache.getKey(TokenCache.TOKEN_PREFIX + username);
if (StringUtils.isBlank(token)) {
return ServerResponse.createByErrorMessage("token无效或者已过期");
}
if (StringUtils.equals(token, forgetToken)) {
String md5Password = MD5Util.MD5EncodeUtf8(passwordNew);
int rowCount = userDao.updatePasswordByUsername(username, md5Password);
if (rowCount > 0) {
return ServerResponse.createBySuccessMessage("修改密码成功");
}
} else {
return ServerResponse.createByErrorMessage("Token错误,请重新获取重置密码的token");
}
return ServerResponse.createByErrorMessage("修改密码失败");
}
@Override
public ServerResponse<String> resetPassword(String passwordOld, String passwordNew, User user) {
int resultCount=userDao.checkPassword(MD5Util.MD5EncodeUtf8(passwordOld),user.getId());
if (resultCount==0) return ServerResponse.createByErrorMessage("旧密码错误");
user.setPassword(MD5Util.MD5EncodeUtf8(passwordNew));
int i = userDao.updateByPrimaryKeySelective(user);
if (i>0){
return ServerResponse.createBySuccessMessage("密码更新成功");
}
return ServerResponse.createByErrorMessage("密码更新失败");
}
public ServerResponse<User> updateInformation(User user){
int resultCount= userDao.checkEmailByUserId(user.getId(),user.getEmail());
if (resultCount>0){
return ServerResponse.createByErrorMessage("email已存在,请更换emial再尝试更新");
}
User updateUser=new User();
updateUser.setId(user.getId());
updateUser.setEmail(user.getEmail());
updateUser.setPhone(user.getPhone());
updateUser.setQuestion(user.getQuestion());
updateUser.setAnswer(user.getAnswer());
int updateCount = userDao.updateByPrimaryKeySelective(updateUser);
if(updateCount > 0){
return ServerResponse.createBySuccess("更新个人信息成功",updateUser);
}
return ServerResponse.createByErrorMessage("更新个人信息失败");
}
@Override
public ServerResponse<User> getInformation(Integer userId) {
User user = userDao.selectByPrimaryKey(userId);
if(user == null){
return ServerResponse.createByErrorMessage("找不到当前用户");
}
user.setPassword(org.apache.commons.lang3.StringUtils.EMPTY);
return ServerResponse.createBySuccess(user);
}
public ServerResponse checkAdminRole(User user){
if(user != null && user.getRole().intValue() == Const.Role.ROLE_ADMIN){
return ServerResponse.createBySuccess();
}
return ServerResponse.createByError();
}
}
| [
"[email protected]"
] | |
2cdc393e84597fadd46fb3238df9150f4df37f7e | 0aabae7d26fcdca07439756d2a2ade3dd37daf17 | /app/src/main/java/com/ismail/gads/ui/MainActivity.java | dc89e712906d7466d302b563eef83a88c1d8048e | [] | no_license | Mohamedismail77/GadsProject | 23b46da89d9ccf6b095fb623636b323fbd0ef9ac | 639e1aaa19741b7d3ecf02ce86c9fa0f487a01f4 | refs/heads/master | 2022-12-11T13:35:53.266809 | 2020-09-11T09:21:36 | 2020-09-11T09:21:36 | 294,650,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 928 | java | package com.ismail.gads.ui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import android.os.Bundle;
import com.ismail.gads.GADsProject;
import com.ismail.gads.R;
import com.ismail.gads.databinding.ActivityMainBinding;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GADsProject gaDsProject = new ViewModelProvider(this).get(GADsProject.class);
ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
activityMainBinding.setLifecycleOwner(this);
getLifecycle().addObserver(gaDsProject);
}
} | [
"[email protected]"
] | |
64b761d88836f791758ac58cd1122145df29f070 | d16e2e6f22ca16be7a1fc07e2c89000ddb1622ab | /src/main/java/com/mbugajski/springrevision/SpringRevisionApplication.java | 9e5443566d09468e7d66a83d884c404413b7a035 | [] | no_license | MBugajski/spring-revision | 42383e309578ceabaea96b1e596303495420766f | bf4b0dba0c85fd1e259904ddcb7386f7244c6ae7 | refs/heads/master | 2023-02-18T08:53:54.108184 | 2021-01-21T22:44:09 | 2021-01-21T22:44:09 | 317,052,362 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 349 | java | package com.mbugajski.springrevision;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringRevisionApplication {
public static void main(String[] args) {
SpringApplication.run(SpringRevisionApplication.class, args);
}
}
| [
"“[email protected]"
] | |
e29b194869c00bd0cdab6c5a555c7019a74e0b55 | b95c26cdbfedb089900ccc43e486c37b940044f5 | /ProgramacionOOMichelleZhanay/src/conversor/deci.java | a1e3097906342b3834145fb0e3e3592f5486c4ff | [] | no_license | Michelle-Zhanay-1994/Proyecto | 46eb302070cb1fb9f6a9a8a29b181fddd87b7fcc | 0a8fa29c84e6245dc8c8188c7a21e9b75b6c832d | refs/heads/master | 2022-11-29T23:14:08.671801 | 2019-09-03T13:41:07 | 2019-09-03T13:42:05 | 287,618,452 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 380 | 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 conversor;
/**
*
* @author Usuario
*/
public class deci extends Conversor {
public double CalcularM_deci(double cant3){
conv=cant3*10;
return (conv);
}
}
| [
"LENOVO@LAPTOP-39EC5ES9"
] | LENOVO@LAPTOP-39EC5ES9 |
88683417fcbc504cac16ed641ca389fdf783b485 | 6bd632f9cf06534226644c35e99ae28ee2f6c45f | /app/src/main/java/com/example/rxflight/network/ApiService.java | e4f06bbe2670f4fb9f701d1a32a03e0ab10f3b1d | [] | no_license | virendersran01/RxFlight | f6db8bf508b2f96e82471936a801080467dcc02c | 518da35517772fa16d393c9f604f2af13c53dfb5 | refs/heads/master | 2020-09-19T02:04:06.041952 | 2019-11-26T07:51:47 | 2019-11-26T07:51:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 566 | java | package com.example.rxflight.network;
import com.example.rxflight.network.model.Price;
import com.example.rxflight.network.model.Ticket;
import java.util.List;
import io.reactivex.Single;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface ApiService {
@GET("airline-tickets.php")
Single<List<Ticket>> searchTickets(@Query("from") String from, @Query("to") String to);
@GET("airline-tickets-price.php")
Single<Price> getPrice(@Query("flight_number") String flightNumber, @Query("from") String from, @Query("to") String to);
}
| [
"[email protected]"
] | |
4cf0901e67c39d1e2e6ac7b1bbce14fb95738728 | 0736b64c91d1cf872ca9f191ca45a34d625c3705 | /flickrgallery/src/com/flickrgallery/activity/TitleFragment.java | 3aeb6f17f08791f6b53643f6957f05f93396301a | [] | no_license | udand/Flickr_Gallary | 06efebece5a4936042afba3645c91b8730ade5f5 | 9d4460e9470ee07d9c1059d932eb7cda78a7e21d | refs/heads/master | 2021-05-30T17:05:10.342809 | 2014-08-04T03:34:15 | 2014-08-04T03:34:15 | 21,713,032 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 8,181 | java | package com.flickrgallery.activity;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.flickrgallery.data.Data;
import com.flickrgallery.data.Photo;
import com.flickrgallery.observer.Observer;
import com.flickrgallery.request.GetList;
import com.flickrgallery.request.GetPhotos;
import com.flickrgallery.util.Util;
import com.google.gson.Gson;
public class TitleFragment extends Fragment implements Observer {
private GridView gridView;
private Data result = null;
private ImageAdapter imageAdapter;
private ProgressBar progressBar;
private LinkedHashSet<String> filePaths = new LinkedHashSet<String>();
private File file;
private boolean mDualPane;
private int index = 0;
private int length = 0;
private GetPhotos getPhotos;
public static String Url = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.activity_main, container, false);
gridView = (GridView) view.findViewById(R.id.gridView1);
progressBar = (ProgressBar) view.findViewById(R.id.progressBar1);
progressBar.setVisibility(View.GONE);
// Util.Url set when user search for photo using keyword.
if (Util.URL == null) {
File file = new File(Util.DIR_PATH);
if (file.exists())
for (File file2 : file.listFiles()) {
file2.delete();
}
File file1 = new File(Util.DIR_PATH_FULL_IMAGE);
if (file1.exists())
for (File file2 : file1.listFiles()) {
file2.delete();
}
Url = Util.LIST_URL + Util.METHOD_GET_PHOTOS + "&" + Util.API_KEY
+ "&format=json&nojsoncallback=1";
} else {
Url = Util.URL; // here for search feature activity.
}
// Get the list of the data to download the photos.
GetList getList = new GetList();
getList.registerObserver(this);
getList.execute(Url);
int displayWidth = getResources().getDisplayMetrics().widthPixels;
int imageWidth = displayWidth / 3;
gridView.setColumnWidth(imageWidth);
gridView.setStretchMode(GridView.NO_STRETCH);
imageAdapter = new ImageAdapter(getActivity());
gridView.setAdapter(imageAdapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Photo photo = (Photo) view.getTag();
if (mDualPane) {
DetailFragment details = (DetailFragment) getFragmentManager()
.findFragmentById(R.id.details1);
details = DetailFragment.newInstance(index);
Bundle bundle = new Bundle();
bundle.putString("id", photo.id);
bundle.putString("farm", photo.farm);
bundle.putString("server", photo.server);
bundle.putString("secret", photo.secret);
bundle.putString("title", photo.title);
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
ft.remove(details);
details.setArguments(bundle);
ft.replace(R.id.details1, details);
ft.addToBackStack(null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
// }
} else {
Intent intent = new Intent(getActivity(),
ImageDetailActivity.class);
Bundle bundle = new Bundle();
bundle.putString("id", photo.id);
bundle.putString("farm", photo.farm);
bundle.putString("server", photo.server);
bundle.putString("secret", photo.secret);
bundle.putString("title", photo.title);
intent.putExtra("key", bundle);
startActivity(intent);
}
}
});
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View detailsFrame = getActivity().findViewById(R.id.details1);
mDualPane = detailsFrame != null
&& detailsFrame.getVisibility() == View.VISIBLE;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
}
@Override
public void update(String string) {
if (!string.equalsIgnoreCase("DOWNLOAD_COMPLETE")) {
Gson gson = new Gson();
result = gson.fromJson(string, Data.class);
length = result.photosResult.photosList.size();
if (Url.contains("search")) {
getPhotos = new GetPhotos(Util.DIR_PATH_SEARCH_IMAGE);
} else {
getPhotos = new GetPhotos(Util.DIR_PATH);
}
getPhotos.registerObserver(this);
getPhotos.execute(result);
} else if (string.equals("DOWNLOAD_COMPLETE")) {
if (Url.contains("search")) {
file = new File(Util.DIR_PATH_SEARCH_IMAGE);
} else {
file = new File(Util.DIR_PATH);
}
for (File files : file.listFiles()) {
synchronized (filePaths) {
filePaths.add(files.getAbsolutePath());
}
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
imageAdapter.notifyDataSetChanged();
}
});
}
}
/**
* ImageAdapter sets the bitmap from the files to gridview imageview.
*
* @author Umang
*/
public class ImageAdapter extends BaseAdapter {
public Context context;
public ImageAdapter(Context context) {
this.context = context;
}
@Override
public int getCount() {
return length;
}
@Override
public java.lang.Object getItem(int position) {
return result.photosResult.photosList.get(position);
}
@Override
public long getItemId(int arg0) {
return 0;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
ImageView imageView = null;
if (view != null) {
imageView = (ImageView) view;
imageView.setImageDrawable(getResources().getDrawable(
R.drawable.ic_launcher));
imageView.setTag(null);
} else {
imageView = new ImageView(context);
imageView.setImageDrawable(getResources().getDrawable(
R.drawable.ic_launcher));
int diplaySize = getResources().getDisplayMetrics().widthPixels;
int imageWidth = diplaySize / 3;
imageView.setLayoutParams(new GridView.LayoutParams(imageWidth,
imageWidth));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setTag(null);
}
synchronized (filePaths) {
if (filePaths != null && filePaths.size() > position) {
Bitmap bitmap = BitmapFactory.decodeFile(filePaths
.toArray()[position].toString());
imageView.setTag(null);
String[] str = filePaths.toArray()[position].toString()
.split("/");
imageView.setTag(getPhoto(str[str.length - 1],
result.photosResult.photosList));
imageView.setImageBitmap(bitmap);
}
}
return imageView;
}
}
/**
* Find the details for the clicked photo in gridview.
* @param id
* - photo id
* @param arrayList
* - list of the photos
* @return - @Photo object
*/
private Photo getPhoto(String id, ArrayList<Photo> arrayList) {
for (Photo photo : arrayList) {
if (photo.id.equalsIgnoreCase(id)) {
return photo;
}
}
return null;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
} | [
"[email protected]"
] | |
219f7fb22e0166df9d142e862d0b742e01359e69 | b2854b4c00a0faf27cbe7655e89db8c3591418c9 | /material-elements/java/com/zeoflow/material/elements/transformation/FabTransformationBehavior.java | dc4c655432b9bf37bba8b091ed9c8c5c3d1f8645 | [
"Apache-2.0"
] | permissive | pittayabuakhaw/material-elements | 1eddc95416944198a6aa34b913192735e48375dc | 28519b2375177afff39d64b9b816c40392f074bb | refs/heads/main | 2023-04-30T13:22:55.906142 | 2021-04-23T17:42:04 | 2021-04-23T17:42:04 | 363,487,347 | 0 | 0 | Apache-2.0 | 2021-05-01T19:24:55 | 2021-05-01T19:07:03 | null | UTF-8 | Java | false | false | 28,979 | java | /*
* Copyright 2020 ZeoFlow
*
* 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.zeoflow.material.elements.transformation;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.Gravity;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.CallSuper;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.ViewCompat;
import com.zeoflow.material.elements.R;
import com.zeoflow.material.elements.animation.AnimatorSetCompat;
import com.zeoflow.material.elements.animation.ArgbEvaluatorCompat;
import com.zeoflow.material.elements.animation.ChildrenAlphaProperty;
import com.zeoflow.material.elements.animation.DrawableAlphaProperty;
import com.zeoflow.material.elements.animation.MotionSpec;
import com.zeoflow.material.elements.animation.MotionTiming;
import com.zeoflow.material.elements.animation.Positioning;
import com.zeoflow.material.elements.circularreveal.CircularRevealCompat;
import com.zeoflow.material.elements.circularreveal.CircularRevealHelper;
import com.zeoflow.material.elements.circularreveal.CircularRevealWidget;
import com.zeoflow.material.elements.circularreveal.CircularRevealWidget.CircularRevealScrimColorProperty;
import com.zeoflow.material.elements.circularreveal.CircularRevealWidget.RevealInfo;
import com.zeoflow.material.elements.floatingactionbutton.FloatingActionButton;
import com.zeoflow.material.elements.math.MathUtils;
import com.zeoflow.material.elements.transition.MaterialContainerTransform;
import java.util.ArrayList;
import java.util.List;
import static com.zeoflow.material.elements.animation.AnimationUtils.lerp;
/**
* Abstract base behavior for any non-scrim view that should appear when a {@link
* FloatingActionButton} is {@link FloatingActionButton#setExpanded(boolean)} expanded}.
*
* @deprecated Use {@link MaterialContainerTransform}
* instead.
*/
@Deprecated
public abstract class FabTransformationBehavior extends ExpandableTransformationBehavior
{
private final Rect tmpRect = new Rect();
private final RectF tmpRectF1 = new RectF();
private final RectF tmpRectF2 = new RectF();
private final int[] tmpArray = new int[2];
// The original translation of the dependency. Used to translate the dependency back to its
// original position.
private float dependencyOriginalTranslationX;
private float dependencyOriginalTranslationY;
public FabTransformationBehavior()
{
}
public FabTransformationBehavior(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@Override
@CallSuper
public boolean layoutDependsOn(
@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency)
{
if (child.getVisibility() == View.GONE)
{
throw new IllegalStateException(
"This behavior cannot be attached to a GONE view. Set the view to INVISIBLE instead.");
}
if (dependency instanceof FloatingActionButton)
{
int expandedComponentIdHint =
((FloatingActionButton) dependency).getExpandedComponentIdHint();
return expandedComponentIdHint == 0 || expandedComponentIdHint == child.getId();
}
return false;
}
@Override
@CallSuper
public void onAttachedToLayoutParams(@NonNull CoordinatorLayout.LayoutParams lp)
{
if (lp.dodgeInsetEdges == Gravity.NO_GRAVITY)
{
// If the developer hasn't set dodgeInsetEdges, lets set it to BOTTOM so that
// we dodge any Snackbars, matching FAB's behavior.
lp.dodgeInsetEdges = Gravity.BOTTOM;
}
}
@NonNull
@Override
protected AnimatorSet onCreateExpandedStateChangeAnimation(
@NonNull final View dependency,
@NonNull final View child,
final boolean expanded,
boolean isAnimating)
{
FabTransformationSpec spec = onCreateMotionSpec(child.getContext(), expanded);
if (expanded)
{
dependencyOriginalTranslationX = dependency.getTranslationX();
dependencyOriginalTranslationY = dependency.getTranslationY();
}
List<Animator> animations = new ArrayList<>();
List<AnimatorListener> listeners = new ArrayList<>();
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
{
createElevationAnimation(
dependency, child, expanded, isAnimating, spec, animations, listeners);
}
RectF childBounds = tmpRectF1;
createTranslationAnimation(
dependency, child, expanded, isAnimating, spec, animations, listeners, childBounds);
float childWidth = childBounds.width();
float childHeight = childBounds.height();
createDependencyTranslationAnimation(dependency, child, expanded, spec, animations);
createIconFadeAnimation(dependency, child, expanded, isAnimating, spec, animations, listeners);
createExpansionAnimation(
dependency,
child,
expanded,
isAnimating,
spec,
childWidth,
childHeight,
animations,
listeners);
createColorAnimation(dependency, child, expanded, isAnimating, spec, animations, listeners);
createChildrenFadeAnimation(
dependency, child, expanded, isAnimating, spec, animations, listeners);
AnimatorSet set = new AnimatorSet();
AnimatorSetCompat.playTogether(set, animations);
set.addListener(
new AnimatorListenerAdapter()
{
@Override
public void onAnimationStart(Animator animation)
{
if (expanded)
{
child.setVisibility(View.VISIBLE);
// A bug exists in 4.4.4 where setVisibility() did not invalidate the view.
dependency.setAlpha(0f);
dependency.setVisibility(View.INVISIBLE);
}
}
@Override
public void onAnimationEnd(Animator animation)
{
if (!expanded)
{
child.setVisibility(View.INVISIBLE);
// A bug exists in 4.4.4 where setVisibility() did not invalidate the view.
dependency.setAlpha(1f);
dependency.setVisibility(View.VISIBLE);
}
}
});
for (int i = 0, count = listeners.size(); i < count; i++)
{
set.addListener(listeners.get(i));
}
return set;
}
protected abstract FabTransformationSpec onCreateMotionSpec(Context context, boolean expanded);
@TargetApi(VERSION_CODES.LOLLIPOP)
private void createElevationAnimation(
View dependency,
@NonNull View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations,
List<AnimatorListener> unusedListeners)
{
float translationZ = ViewCompat.getElevation(child) - ViewCompat.getElevation(dependency);
Animator animator;
if (expanded)
{
if (!currentlyAnimating)
{
child.setTranslationZ(-translationZ);
}
animator = ObjectAnimator.ofFloat(child, View.TRANSLATION_Z, 0f);
} else
{
animator = ObjectAnimator.ofFloat(child, View.TRANSLATION_Z, -translationZ);
}
MotionTiming timing = spec.timings.getTiming("elevation");
timing.apply(animator);
animations.add(animator);
}
private void createDependencyTranslationAnimation(
@NonNull View dependency,
@NonNull View child,
boolean expanded,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations)
{
float translationX = calculateTranslationX(dependency, child, spec.positioning);
float translationY = calculateTranslationY(dependency, child, spec.positioning);
ValueAnimator translationXAnimator;
ValueAnimator translationYAnimator;
Pair<MotionTiming, MotionTiming> motionTiming =
calculateMotionTiming(translationX, translationY, expanded, spec);
MotionTiming translationXTiming = motionTiming.first;
MotionTiming translationYTiming = motionTiming.second;
translationXAnimator =
ObjectAnimator.ofFloat(
dependency,
View.TRANSLATION_X,
expanded ? translationX : dependencyOriginalTranslationX);
translationYAnimator =
ObjectAnimator.ofFloat(
dependency,
View.TRANSLATION_Y,
expanded ? translationY : dependencyOriginalTranslationY);
translationXTiming.apply(translationXAnimator);
translationYTiming.apply(translationYAnimator);
animations.add(translationXAnimator);
animations.add(translationYAnimator);
}
private void createTranslationAnimation(
@NonNull View dependency,
@NonNull View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations,
List<AnimatorListener> unusedListeners,
@NonNull RectF childBounds)
{
float translationX = calculateTranslationX(dependency, child, spec.positioning);
float translationY = calculateTranslationY(dependency, child, spec.positioning);
ValueAnimator translationXAnimator;
ValueAnimator translationYAnimator;
Pair<MotionTiming, MotionTiming> motionTiming =
calculateMotionTiming(translationX, translationY, expanded, spec);
MotionTiming translationXTiming = motionTiming.first;
MotionTiming translationYTiming = motionTiming.second;
if (expanded)
{
if (!currentlyAnimating)
{
child.setTranslationX(-translationX);
child.setTranslationY(-translationY);
}
translationXAnimator = ObjectAnimator.ofFloat(child, View.TRANSLATION_X, 0f);
translationYAnimator = ObjectAnimator.ofFloat(child, View.TRANSLATION_Y, 0f);
calculateChildVisibleBoundsAtEndOfExpansion(
child,
spec,
translationXTiming,
translationYTiming,
-translationX,
-translationY,
0f,
0f,
childBounds);
} else
{
translationXAnimator = ObjectAnimator.ofFloat(child, View.TRANSLATION_X, -translationX);
translationYAnimator = ObjectAnimator.ofFloat(child, View.TRANSLATION_Y, -translationY);
}
translationXTiming.apply(translationXAnimator);
translationYTiming.apply(translationYAnimator);
animations.add(translationXAnimator);
animations.add(translationYAnimator);
}
private void createIconFadeAnimation(
View dependency,
final View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations,
@NonNull List<AnimatorListener> listeners)
{
if (!(child instanceof CircularRevealWidget) || !(dependency instanceof ImageView))
{
return;
}
final CircularRevealWidget circularRevealChild = (CircularRevealWidget) child;
ImageView dependencyImageView = (ImageView) dependency;
final Drawable icon = dependencyImageView.getDrawable();
if (icon == null)
{
return;
}
icon.mutate();
ObjectAnimator animator;
if (expanded)
{
if (!currentlyAnimating)
{
icon.setAlpha(0xFF);
}
animator = ObjectAnimator.ofInt(icon, DrawableAlphaProperty.DRAWABLE_ALPHA_COMPAT, 0x00);
} else
{
animator = ObjectAnimator.ofInt(icon, DrawableAlphaProperty.DRAWABLE_ALPHA_COMPAT, 0xFF);
}
// icon.setCallback() is not expected to be called and
// child.verifyDrawable() is not expected to be implemented.
animator.addUpdateListener(
new AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
child.invalidate();
}
});
MotionTiming timing = spec.timings.getTiming("iconFade");
timing.apply(animator);
animations.add(animator);
listeners.add(
new AnimatorListenerAdapter()
{
@Override
public void onAnimationStart(Animator animation)
{
circularRevealChild.setCircularRevealOverlayDrawable(icon);
}
@Override
public void onAnimationEnd(Animator animation)
{
circularRevealChild.setCircularRevealOverlayDrawable(null);
}
});
}
private void createExpansionAnimation(
@NonNull View dependency,
View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
float childWidth,
float childHeight,
@NonNull List<Animator> animations,
@NonNull List<AnimatorListener> listeners)
{
if (!(child instanceof CircularRevealWidget))
{
return;
}
final CircularRevealWidget circularRevealChild = (CircularRevealWidget) child;
float revealCenterX = calculateRevealCenterX(dependency, child, spec.positioning);
float revealCenterY = calculateRevealCenterY(dependency, child, spec.positioning);
((FloatingActionButton) dependency).getContentRect(tmpRect);
float dependencyRadius = tmpRect.width() / 2f;
Animator animator;
MotionTiming timing = spec.timings.getTiming("expansion");
if (expanded)
{
if (!currentlyAnimating)
{
circularRevealChild.setRevealInfo(
new RevealInfo(revealCenterX, revealCenterY, dependencyRadius));
}
float fromRadius =
currentlyAnimating ? circularRevealChild.getRevealInfo().radius : dependencyRadius;
float toRadius =
MathUtils.distanceToFurthestCorner(
revealCenterX, revealCenterY, 0, 0, childWidth, childHeight);
animator =
CircularRevealCompat.createCircularReveal(
circularRevealChild, revealCenterX, revealCenterY, toRadius);
animator.addListener(
new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
// After toRadius has been reached, jump to no circular clip. This shouldn't result in
// a visual difference, because toRadius has been calculated precisely to avoid it.
RevealInfo revealInfo = circularRevealChild.getRevealInfo();
revealInfo.radius = RevealInfo.INVALID_RADIUS;
circularRevealChild.setRevealInfo(revealInfo);
}
});
createPreFillRadialExpansion(
child,
timing.getDelay(),
(int) revealCenterX,
(int) revealCenterY,
fromRadius,
animations);
// No need to post fill. In all cases, circular reveal radius is removed.
} else
{
float fromRadius = circularRevealChild.getRevealInfo().radius;
float toRadius = dependencyRadius;
animator =
CircularRevealCompat.createCircularReveal(
circularRevealChild, revealCenterX, revealCenterY, toRadius);
createPreFillRadialExpansion(
child,
timing.getDelay(),
(int) revealCenterX,
(int) revealCenterY,
fromRadius,
animations);
createPostFillRadialExpansion(
child,
timing.getDelay(),
timing.getDuration(),
spec.timings.getTotalDuration(),
(int) revealCenterX,
(int) revealCenterY,
toRadius,
animations);
}
timing.apply(animator);
animations.add(animator);
listeners.add(CircularRevealCompat.createCircularRevealListener(circularRevealChild));
}
private void createColorAnimation(
@NonNull View dependency,
View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations,
List<AnimatorListener> unusedListeners)
{
if (!(child instanceof CircularRevealWidget))
{
return;
}
CircularRevealWidget circularRevealChild = (CircularRevealWidget) child;
@ColorInt int tint = getBackgroundTint(dependency);
@ColorInt int transparent = tint & 0x00FFFFFF;
ObjectAnimator animator;
if (expanded)
{
if (!currentlyAnimating)
{
circularRevealChild.setCircularRevealScrimColor(tint);
}
animator =
ObjectAnimator.ofInt(
circularRevealChild,
CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR,
transparent);
} else
{
animator =
ObjectAnimator.ofInt(
circularRevealChild,
CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR,
tint);
}
animator.setEvaluator(ArgbEvaluatorCompat.getInstance());
MotionTiming timing = spec.timings.getTiming("color");
timing.apply(animator);
animations.add(animator);
}
private void createChildrenFadeAnimation(
View unusedDependency,
View child,
boolean expanded,
boolean currentlyAnimating,
@NonNull FabTransformationSpec spec,
@NonNull List<Animator> animations,
List<AnimatorListener> unusedListeners)
{
if (!(child instanceof ViewGroup))
{
return;
}
if (child instanceof CircularRevealWidget
&& CircularRevealHelper.STRATEGY == CircularRevealHelper.BITMAP_SHADER)
{
// Bitmap shader strategy animates a static snapshot of the child.
return;
}
ViewGroup childContentContainer = calculateChildContentContainer(child);
if (childContentContainer == null)
{
return;
}
Animator animator;
if (expanded)
{
if (!currentlyAnimating)
{
ChildrenAlphaProperty.CHILDREN_ALPHA.set(childContentContainer, 0f);
}
animator =
ObjectAnimator.ofFloat(childContentContainer, ChildrenAlphaProperty.CHILDREN_ALPHA, 1f);
} else
{
animator =
ObjectAnimator.ofFloat(childContentContainer, ChildrenAlphaProperty.CHILDREN_ALPHA, 0f);
}
MotionTiming timing = spec.timings.getTiming("contentFade");
timing.apply(animator);
animations.add(animator);
}
@NonNull
private Pair<MotionTiming, MotionTiming> calculateMotionTiming(
float translationX,
float translationY,
boolean expanded,
@NonNull FabTransformationSpec spec)
{
MotionTiming translationXTiming;
MotionTiming translationYTiming;
if (translationX == 0 || translationY == 0)
{
// Horizontal or vertical motion.
translationXTiming = spec.timings.getTiming("translationXLinear");
translationYTiming = spec.timings.getTiming("translationYLinear");
} else if ((expanded && translationY < 0) || (!expanded && translationY > 0))
{
// Upwards motion.
translationXTiming = spec.timings.getTiming("translationXCurveUpwards");
translationYTiming = spec.timings.getTiming("translationYCurveUpwards");
} else
{
// Downwards motion.
translationXTiming = spec.timings.getTiming("translationXCurveDownwards");
translationYTiming = spec.timings.getTiming("translationYCurveDownwards");
}
return new Pair<>(translationXTiming, translationYTiming);
}
private float calculateTranslationX(
@NonNull View dependency, @NonNull View child, @NonNull Positioning positioning)
{
RectF dependencyBounds = tmpRectF1;
RectF childBounds = tmpRectF2;
calculateDependencyWindowBounds(dependency, dependencyBounds);
calculateWindowBounds(child, childBounds);
float translationX = 0f;
switch (positioning.gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
{
case Gravity.LEFT:
translationX = childBounds.left - dependencyBounds.left;
break;
case Gravity.CENTER_HORIZONTAL:
translationX = childBounds.centerX() - dependencyBounds.centerX();
break;
case Gravity.RIGHT:
translationX = childBounds.right - dependencyBounds.right;
break;
default:
break;
}
translationX += positioning.xAdjustment;
return translationX;
}
private float calculateTranslationY(
@NonNull View dependency, @NonNull View child, @NonNull Positioning positioning)
{
RectF dependencyBounds = tmpRectF1;
RectF childBounds = tmpRectF2;
calculateDependencyWindowBounds(dependency, dependencyBounds);
calculateWindowBounds(child, childBounds);
float translationY = 0f;
switch (positioning.gravity & Gravity.VERTICAL_GRAVITY_MASK)
{
case Gravity.TOP:
translationY = childBounds.top - dependencyBounds.top;
break;
case Gravity.CENTER_VERTICAL:
translationY = childBounds.centerY() - dependencyBounds.centerY();
break;
case Gravity.BOTTOM:
translationY = childBounds.bottom - dependencyBounds.bottom;
break;
default:
break;
}
translationY += positioning.yAdjustment;
return translationY;
}
private void calculateWindowBounds(@NonNull View view, RectF rect)
{
RectF windowBounds = rect;
windowBounds.set(0, 0, view.getWidth(), view.getHeight());
int[] windowLocation = tmpArray;
view.getLocationInWindow(windowLocation);
windowBounds.offsetTo(windowLocation[0], windowLocation[1]);
// We specifically want to take into account the transformations of all parents only.
// The idea is that only this transformation should modify the translation of the views itself.
windowBounds.offset((int) -view.getTranslationX(), (int) -view.getTranslationY());
}
private void calculateDependencyWindowBounds(@NonNull View view, @NonNull RectF rect)
{
calculateWindowBounds(view, rect);
rect.offset(dependencyOriginalTranslationX, dependencyOriginalTranslationY);
}
private float calculateRevealCenterX(
@NonNull View dependency, @NonNull View child, @NonNull Positioning positioning)
{
RectF dependencyBounds = tmpRectF1;
RectF childBounds = tmpRectF2;
calculateDependencyWindowBounds(dependency, dependencyBounds);
calculateWindowBounds(child, childBounds);
float translationX = calculateTranslationX(dependency, child, positioning);
childBounds.offset(-translationX, 0);
return dependencyBounds.centerX() - childBounds.left;
}
private float calculateRevealCenterY(
@NonNull View dependency, @NonNull View child, @NonNull Positioning positioning)
{
RectF dependencyBounds = tmpRectF1;
RectF childBounds = tmpRectF2;
calculateDependencyWindowBounds(dependency, dependencyBounds);
calculateWindowBounds(child, childBounds);
float translationY = calculateTranslationY(dependency, child, positioning);
childBounds.offset(0, -translationY);
return dependencyBounds.centerY() - childBounds.top;
}
private void calculateChildVisibleBoundsAtEndOfExpansion(
@NonNull View child,
@NonNull FabTransformationSpec spec,
@NonNull MotionTiming translationXTiming,
@NonNull MotionTiming translationYTiming,
float fromX,
float fromY,
float toX,
float toY,
@NonNull RectF childBounds)
{
float translationX =
calculateValueOfAnimationAtEndOfExpansion(spec, translationXTiming, fromX, toX);
float translationY =
calculateValueOfAnimationAtEndOfExpansion(spec, translationYTiming, fromY, toY);
// Calculate the window bounds.
Rect window = tmpRect;
child.getWindowVisibleDisplayFrame(window);
RectF windowF = tmpRectF1;
windowF.set(window);
// Calculate the visible bounds of the child given its translation and window bounds.
RectF childVisibleBounds = tmpRectF2;
calculateWindowBounds(child, childVisibleBounds);
childVisibleBounds.offset(translationX, translationY);
childVisibleBounds.intersect(windowF);
childBounds.set(childVisibleBounds);
}
private float calculateValueOfAnimationAtEndOfExpansion(
@NonNull FabTransformationSpec spec, @NonNull MotionTiming timing, float from, float to)
{
long delay = timing.getDelay();
long duration = timing.getDuration();
// Calculate at what time in the translation animation does the expansion animation end.
MotionTiming expansionTiming = spec.timings.getTiming("expansion");
long expansionEnd = expansionTiming.getDelay() + expansionTiming.getDuration();
// Adjust one frame (16.6ms) for Android's draw pipeline.
// A value set at frame N will be drawn at frame N+1.
expansionEnd += 17;
float fraction = (float) (expansionEnd - delay) / duration;
// Calculate the exact value of the animation at that time.
fraction = timing.getInterpolator().getInterpolation(fraction);
return lerp(from, to, fraction);
}
/**
* Given the a child, return the ViewGroup whose children we want to fade.
*/
@Nullable
private ViewGroup calculateChildContentContainer(@NonNull View view)
{
// 1. If an explicitly tagged view exists, use that as the child content container.
View childContentContainer = view.findViewById(R.id.mtrl_child_content_container);
if (childContentContainer != null)
{
return toViewGroupOrNull(childContentContainer);
}
// 2. If the view is a wrapper container, use its child as the child content container.
if (view instanceof TransformationChildLayout || view instanceof TransformationChildCard)
{
childContentContainer = ((ViewGroup) view).getChildAt(0);
return toViewGroupOrNull(childContentContainer);
}
// 3. Use the view itself as the child content container.
return toViewGroupOrNull(view);
}
@Nullable
private ViewGroup toViewGroupOrNull(View view)
{
if (view instanceof ViewGroup)
{
return (ViewGroup) view;
} else
{
return null;
}
}
private int getBackgroundTint(@NonNull View view)
{
ColorStateList tintList = ViewCompat.getBackgroundTintList(view);
if (tintList != null)
{
return tintList.getColorForState(view.getDrawableState(), tintList.getDefaultColor());
} else
{
return Color.TRANSPARENT;
}
}
/**
* Adds pre radial expansion animator.
*/
private void createPreFillRadialExpansion(
View child,
long delay,
int revealCenterX,
int revealCenterY,
float fromRadius,
@NonNull List<Animator> animations)
{
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
{
// No setter for circular reveal in L+.
if (delay > 0)
{
Animator animator =
ViewAnimationUtils.createCircularReveal(
child, revealCenterX, revealCenterY, fromRadius, fromRadius);
animator.setStartDelay(0);
animator.setDuration(delay);
animations.add(animator);
}
}
}
/**
* Adds post radial expansion animator.
*/
private void createPostFillRadialExpansion(
View child,
long delay,
long duration,
long totalDuration,
int revealCenterX,
int revealCenterY,
float toRadius,
@NonNull List<Animator> animations)
{
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
{
// Circular reveal in L+ doesn't stick around.
if (delay + duration < totalDuration)
{
Animator animator =
ViewAnimationUtils.createCircularReveal(
child, revealCenterX, revealCenterY, toRadius, toRadius);
animator.setStartDelay(delay + duration);
animator.setDuration(totalDuration - (delay + duration));
animations.add(animator);
}
}
}
/**
* Motion spec for a FAB transformation.
*/
protected static class FabTransformationSpec
{
@Nullable
public MotionSpec timings;
public Positioning positioning;
}
}
| [
"[email protected]"
] | |
6d628ec725f60d9d2bbec44533132f803c8d31b2 | 7c7108c3f9882b27b642ba4c85540d7201f6c278 | /app/src/main/java/com/tarek/vaccins/model/Plan.java | 14d33b6b14526b434311f9e562c094d030675579 | [] | no_license | TAREK199/VacDz_Android_App | 2940fa423b31fea726303bfeb6907cae0e3cdd85 | 4820db9324d08c70e6b586deae283087cfc78b21 | refs/heads/master | 2022-04-01T17:32:59.457479 | 2019-07-05T14:33:19 | 2019-07-05T14:33:19 | 231,661,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,113 | java | package com.tarek.vaccins.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Plan {
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("jour")
@Expose
private Integer jour;
@SerializedName("vaccin")
@Expose
private String vaccin;
@SerializedName("polyclinique")
@Expose
private String polyclinique;
public Plan(int jour, String vaccin) {
this.jour = jour ;
this.vaccin = vaccin ;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getJour() {
return jour;
}
public void setJour(Integer jour) {
this.jour = jour;
}
public String getVaccin() {
return vaccin;
}
public void setVaccin(String vaccin) {
this.vaccin = vaccin;
}
public String getPolyclinique() {
return polyclinique;
}
public void setPolyclinique(String polyclinique) {
this.polyclinique = polyclinique;
}
}
| [
"[email protected]"
] | |
f9fa615afffa55f59c4d884eec2d69ff95479780 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_a396d15834ecb391527c4446c417fef2053f471c/NavigationTable/8_a396d15834ecb391527c4446c417fef2053f471c_NavigationTable_t.java | 90ae5b54d60ec365e96ab3bc57651c0997ce2f52 | [] | 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 | 10,460 | java | // Copyright (C) 2009 The Android Open Source Project
//
// 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.google.gerrit.client.ui;
import com.google.gerrit.client.Gerrit;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwtexpui.globalkey.client.GlobalKey;
import com.google.gwtexpui.globalkey.client.KeyCommand;
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
import com.google.gwtexpui.safehtml.client.SafeHtml;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
public abstract class NavigationTable<RowItem> extends FancyFlexTable<RowItem> {
protected class MyFlexTable extends FancyFlexTable.MyFlexTable {
public MyFlexTable() {
sinkEvents(Event.ONDBLCLICK | Event.ONCLICK);
}
@Override
public void onBrowserEvent(final Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONCLICK: {
// Find out which cell was actually clicked.
final Element td = getEventTargetCell(event);
if (td == null) {
break;
}
final int row = rowOf(td);
if (getRowItem(row) != null) {
onCellSingleClick(rowOf(td), columnOf(td));
return;
}
break;
}
case Event.ONDBLCLICK: {
// Find out which cell was actually clicked.
Element td = getEventTargetCell(event);
if (td == null) {
return;
}
onCellDoubleClick(rowOf(td), columnOf(td));
return;
}
}
super.onBrowserEvent(event);
}
}
@SuppressWarnings("serial")
private static final LinkedHashMap<String, Object> savedPositions =
new LinkedHashMap<String, Object>(10, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Entry<String, Object> eldest) {
return size() >= 20;
}
};
private final Image pointer;
protected final KeyCommandSet keysNavigation;
protected final KeyCommandSet keysAction;
private HandlerRegistration regNavigation;
private HandlerRegistration regAction;
private int currentRow = -1;
private String saveId;
private boolean computedScrollType;
private ScrollPanel parentScrollPanel;
protected NavigationTable(String itemHelpName) {
this();
keysNavigation.add(new PrevKeyCommand(0, 'k', Util.M.helpListPrev(itemHelpName)));
keysNavigation.add(new NextKeyCommand(0, 'j', Util.M.helpListNext(itemHelpName)));
keysNavigation.add(new OpenKeyCommand(0, 'o', Util.M.helpListOpen(itemHelpName)));
keysNavigation.add(new OpenKeyCommand(0, KeyCodes.KEY_ENTER,
Util.M.helpListOpen(itemHelpName)));
}
protected NavigationTable() {
pointer = new Image(Gerrit.RESOURCES.arrowRight());
keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
}
protected abstract void onOpenRow(int row);
protected abstract Object getRowItemKey(RowItem item);
private void onUp() {
for (int row = currentRow - 1; row >= 0; row--) {
if (getRowItem(row) != null) {
movePointerTo(row);
break;
}
}
}
private void onDown() {
final int max = table.getRowCount();
for (int row = currentRow + 1; row < max; row++) {
if (getRowItem(row) != null) {
movePointerTo(row);
break;
}
}
}
private void onOpen() {
if (0 <= currentRow && currentRow < table.getRowCount()) {
if (getRowItem(currentRow) != null) {
onOpenRow(currentRow);
}
}
}
/** Invoked when the user double clicks on a table cell. */
protected void onCellDoubleClick(int row, int column) {
onOpenRow(row);
}
/** Invoked when the user clicks on a table cell. */
protected void onCellSingleClick(int row, int column) {
movePointerTo(row);
}
protected int getCurrentRow() {
return currentRow;
}
protected void ensurePointerVisible() {
final int max = table.getRowCount();
int row = currentRow;
final int init = row;
if (row < 0) {
row = 0;
} else if (max <= row) {
row = max - 1;
}
final CellFormatter fmt = table.getCellFormatter();
final int sTop = Document.get().getScrollTop();
final int sEnd = sTop + Document.get().getClientHeight();
while (0 <= row && row < max) {
final Element cur = DOM.getParent(fmt.getElement(row, C_ARROW));
final int cTop = cur.getAbsoluteTop();
final int cEnd = cTop + cur.getOffsetHeight();
if (cEnd < sTop) {
row++;
} else if (sEnd < cTop) {
row--;
} else {
break;
}
}
if (init != row) {
movePointerTo(row, false);
}
}
protected void movePointerTo(final int newRow) {
movePointerTo(newRow, true);
}
protected void movePointerTo(final int newRow, final boolean scroll) {
final CellFormatter fmt = table.getCellFormatter();
final boolean clear = 0 <= currentRow && currentRow < table.getRowCount();
if (clear) {
final Element tr = DOM.getParent(fmt.getElement(currentRow, C_ARROW));
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().activeRow(), false);
}
if (0 <= newRow && newRow < table.getRowCount()
&& getRowItem(newRow) != null) {
table.setWidget(newRow, C_ARROW, pointer);
final Element tr = DOM.getParent(fmt.getElement(newRow, C_ARROW));
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().activeRow(), true);
if (scroll) {
scrollIntoView(tr);
}
} else if (clear) {
table.setWidget(currentRow, C_ARROW, null);
pointer.removeFromParent();
}
currentRow = newRow;
}
protected void scrollIntoView(final Element tr) {
if (!computedScrollType) {
parentScrollPanel = null;
Widget w = getParent();
while (w != null) {
if (w instanceof ScrollPanel) {
parentScrollPanel = (ScrollPanel) w;
break;
}
w = w.getParent();
}
computedScrollType = true;
}
if (parentScrollPanel != null) {
parentScrollPanel.ensureVisible(new UIObject() {
{
setElement(tr);
}
});
} else {
tr.scrollIntoView();
}
}
protected void movePointerTo(final Object oldId) {
final int row = findRow(oldId);
if (0 <= row) {
movePointerTo(row);
}
}
protected int findRow(final Object oldId) {
if (oldId != null) {
final int max = table.getRowCount();
for (int row = 0; row < max; row++) {
final RowItem c = getRowItem(row);
if (c != null && oldId.equals(getRowItemKey(c))) {
return row;
}
}
}
return -1;
}
@Override
public void resetHtml(SafeHtml body) {
currentRow = -1;
super.resetHtml(body);
}
public void finishDisplay() {
if (currentRow >= table.getRowCount()) {
currentRow = -1;
}
if (saveId != null) {
movePointerTo(savedPositions.get(saveId));
}
if (currentRow < 0) {
onDown();
}
}
public void setSavePointerId(final String id) {
saveId = id;
}
public void setRegisterKeys(final boolean on) {
if (on && isAttached()) {
if (regNavigation == null) {
regNavigation = GlobalKey.add(this, keysNavigation);
}
if (regAction == null) {
regAction = GlobalKey.add(this, keysAction);
}
} else {
if (regNavigation != null) {
regNavigation.removeHandler();
regNavigation = null;
}
if (regAction != null) {
regAction.removeHandler();
regAction = null;
}
}
}
@Override
protected void onLoad() {
computedScrollType = false;
parentScrollPanel = null;
}
@Override
protected void onUnload() {
setRegisterKeys(false);
if (saveId != null && currentRow >= 0) {
final RowItem c = getRowItem(currentRow);
if (c != null) {
savedPositions.put(saveId, getRowItemKey(c));
}
}
computedScrollType = false;
parentScrollPanel = null;
super.onUnload();
}
@Override
protected MyFlexTable createFlexTable() {
return new MyFlexTable();
}
public class PrevKeyCommand extends KeyCommand {
public PrevKeyCommand(int mask, char key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
ensurePointerVisible();
onUp();
}
}
public class NextKeyCommand extends KeyCommand {
public NextKeyCommand(int mask, char key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
ensurePointerVisible();
onDown();
}
}
public class OpenKeyCommand extends KeyCommand {
public OpenKeyCommand(int mask, int key, String help) {
super(mask, key, help);
}
@Override
public void onKeyPress(final KeyPressEvent event) {
ensurePointerVisible();
onOpen();
}
}
}
| [
"[email protected]"
] | |
3564d6af0f2becbded81a3d2b0487f1e4c4d5aa0 | 737c667bb50030cf9f9b3d834f86eb2e711d46fd | /app/src/main/java/com/mudrichenko/evgeniy/flickrtestproject/ui/launcher/LauncherActivity.java | 60c7361d68625bb2b240700b80d0bd24bbf69984 | [] | no_license | 001loop/Flickr_test_project | 16b3f0ca3807a9f67a484a65cf4d97f06ae12876 | 2711f45bbd5d1878c73dcccc0ac2acb9de0c922b | refs/heads/master | 2020-05-25T17:21:48.777165 | 2019-10-24T18:10:15 | 2019-10-24T18:10:15 | 187,907,139 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,886 | java | package com.mudrichenko.evgeniy.flickrtestproject.ui.launcher;
import android.content.Intent;
import android.os.Bundle;
import com.arellomobile.mvp.MvpAppCompatActivity;
import com.arellomobile.mvp.presenter.InjectPresenter;
import com.mudrichenko.evgeniy.flickrtestproject.App;
import com.mudrichenko.evgeniy.flickrtestproject.R;
import com.mudrichenko.evgeniy.flickrtestproject.ui.auth.AuthActivity;
import com.mudrichenko.evgeniy.flickrtestproject.ui.main.MainActivity;
import com.mudrichenko.evgeniy.flickrtestproject.utils.PrefUtils;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import javax.inject.Inject;
public class LauncherActivity extends MvpAppCompatActivity implements LauncherView {
@InjectPresenter
LauncherPresenter mLauncherPresenter;
@Inject
PrefUtils mPrefUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
//
App.Companion.getAppComponent().inject(this);
Logger.addLogAdapter(new AndroidLogAdapter());
boolean isAuthTokenCorrect = true;
String authToken = mPrefUtils.getAuthToken();
Logger.i("authToken null = " + (authToken==null));
Logger.i("authToken = " + authToken);
if (authToken == null) {
isAuthTokenCorrect = false;
} else if (authToken.equals("")) {
isAuthTokenCorrect = false;
}
if (!isAuthTokenCorrect) {
startAuthActivity();
} else {
startMainActivity();
}
}
private void startMainActivity() {
startActivity(new Intent(this, MainActivity.class));
finish();
}
private void startAuthActivity() {
startActivity(new Intent(this, AuthActivity.class));
finish();
}
}
| [
"[email protected]"
] | |
27b4f4a4bd53f417ea5b1610b3b0f0092a57a438 | 174f7ee970692cd71a54529620f779b061ef966a | /src/main/java/org/knowhowlab/osgi/monitoradmin/job/MonitoringJobVisitor.java | 4b1161c8d7277d7807a50324137d1b680a80cb6d | [
"Apache-2.0"
] | permissive | knowhowlab/org.knowhowlab.osgi.monitoradmin | 5730f91456444933f092224798bd292db43a48d9 | c593bc6889dfa229de19235e1d6b3b765de05e5a | refs/heads/master | 2021-07-04T00:19:16.068067 | 2019-08-21T10:15:35 | 2019-08-21T10:15:35 | 51,601,433 | 0 | 3 | Apache-2.0 | 2021-06-07T16:32:39 | 2016-02-12T16:38:43 | Java | UTF-8 | Java | false | false | 1,716 | java | /*
* Copyright (c) 2009-2016 Dmytro Pishchukhin (http://knowhowlab.org)
*
* 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.knowhowlab.osgi.monitoradmin.job;
import org.osgi.service.monitor.StatusVariable;
/**
* Interface to access some internal MonitorAdminImpl from Jobs
*
* @author dmytro.pishchukhin
*/
public interface MonitoringJobVisitor {
/**
* Get status variable by path
*
* @param path path
* @return StatusVariable by path
*
* @throws IllegalArgumentException path is invalid
* @throws SecurityException some problems with security permissions
* @see org.osgi.service.monitor.Monitorable#getStatusVariable(String)
*/
StatusVariable getStatusVariable(String path) throws IllegalArgumentException, SecurityException;
/**
* Cancel Monitoring job
* @param job job
*/
void cancelJob(AbstractMonitoringJob job);
/**
* Fire event with given parameters
* @param monitorableId monitorable id
* @param statusVariable StatusVariable value
* @param initiator initiator
*/
void fireEvent(String monitorableId, StatusVariable statusVariable, String initiator);
}
| [
"[email protected]"
] | |
d362ad782b759bc37da256fe6e26625cd90e553a | 9200fdf9540b35d1f64b793ab3717d0f73bd3fbe | /src/main/cz/kucera/services/currency/rate/ExchangeRateService.java | dd3b1ef3a9e489b038d6a4481067fee3fdc87f51 | [] | no_license | kuceraf/ExchangeRatesProject | 5d6b68b2ff08c074b5d2cde08f706510a975258b | 4b53e048f135d35e79b1bb3f1d452e86b80c645f | refs/heads/master | 2021-01-18T21:29:20.129947 | 2015-05-24T12:56:37 | 2015-05-24T12:56:37 | 35,365,299 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 283 | java | package main.cz.kucera.services.currency.rate;
import main.cz.kucera.parser.exchangereate.ExchangeRateMap;
/**
* Created by Filip on 18. 4. 2015.
*/
public interface ExchangeRateService {
ExchangeRateMap getExchangeRatesAll();
ExchangeRateMap getExchangeRatesByDate();
}
| [
"[email protected]"
] | |
d747b8cdd7d54a6516dda897456a8acef94742d9 | 88212d606d353e9584249cd8fd0cba83af546290 | /Jax-rs/src/main/java/i/jaxrscms/Loader.java | 38338b94f60879fb5ac3cbffa600cdba29185cea | [] | no_license | AlexAasen/SpringData-JaxRs | 68ecb81fb7960d3379a8f969399d22f6f988b96c | a1eff54bf7f552b35ee60a770d7ba339576103f6 | refs/heads/master | 2020-12-01T08:34:04.183405 | 2016-09-05T21:34:28 | 2016-09-05T21:34:28 | 67,449,311 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 356 | java | package i.jaxrscms;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/*")
public class Loader extends Application {
@PostConstruct
public void init() {
// initialization
}
@PreDestroy
public void destroy() {
// clean up
}
}
| [
"[email protected]"
] | |
79188e0de0f8e408f65a570606e20859a0e4a280 | 8152a5253515c028f3e28d4b628b6892ce4e1108 | /src/main/java/com/yzxie/rockcat/protocol/Protocol.java | 6d9560ef9745a9c61c16f71f3b71ad346c07db3a | [] | no_license | yzxie/rockcat | ef6e121884324044f3ad5ba242d148fb5dc7447b | 5d45cd6dfc4e82a1be3509258ab53a690075f833 | refs/heads/master | 2020-04-15T09:30:21.391978 | 2019-01-08T04:12:02 | 2019-01-08T04:12:02 | 164,552,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 136 | java | package com.yzxie.rockcat.protocol;
/**
* @author xieyizun
* @date 8/1/2019 12:11
* @description:
*/
public interface Protocol {
}
| [
"[email protected]"
] | |
4be608eb19148e8cf45f20bd12cd5e4a29661c2a | 028cbe18b4e5c347f664c592cbc7f56729b74060 | /external/modules/asm/3.1/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterUnitTest.java | 3afe0b3a8369051c6278033115f815e1eca0d25c | [
"BSD-3-Clause"
] | permissive | dmatej/Glassfish-SVN-Patched | 8d355ff753b23a9a1bd9d7475fa4b2cfd3b40f9e | 269e29ba90db6d9c38271f7acd2affcacf2416f1 | refs/heads/master | 2021-05-28T12:55:06.267463 | 2014-11-11T04:21:44 | 2014-11-11T04:21:44 | 23,610,469 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 49,799 | java | /***
* ASM tests
* Copyright (c) 2002-2005 France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.objectweb.asm.commons;
import junit.framework.TestCase;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.util.TraceMethodVisitor;
/**
* JsrInlinerTest
*
* @author Eugene Kuleshov, Niko Matsakis, Eric Bruneton
*/
public class JSRInlinerAdapterUnitTest extends TestCase {
private JSRInlinerAdapter jsr;
private MethodNode exp;
private MethodVisitor current;
protected void setUp() throws Exception {
super.setUp();
jsr = new JSRInlinerAdapter(null, 0, "m", "()V", null, null) {
public void visitEnd() {
System.err.println("started w/ method:" + name);
TraceMethodVisitor mv = new TraceMethodVisitor();
for (int i = 0; i < instructions.size(); ++i) {
instructions.get(i).accept(mv);
System.err.print(Integer.toString(i + 100000).substring(1));
System.err.print(" : " + mv.text.get(i));
}
super.visitEnd();
System.err.println("finished w/ method:" + name);
}
};
exp = new MethodNode(0, "m", "()V", null, null);
}
private void setCurrent(final MethodVisitor cv) {
this.current = cv;
}
private void ICONST_0() {
this.current.visitInsn(Opcodes.ICONST_0);
}
private void ISTORE(final int var) {
this.current.visitVarInsn(Opcodes.ISTORE, var);
}
private void ALOAD(final int var) {
this.current.visitVarInsn(Opcodes.ALOAD, var);
}
private void ILOAD(final int var) {
this.current.visitVarInsn(Opcodes.ILOAD, var);
}
private void ASTORE(final int var) {
this.current.visitVarInsn(Opcodes.ASTORE, var);
}
private void RET(final int var) {
this.current.visitVarInsn(Opcodes.RET, var);
}
private void ATHROW() {
this.current.visitInsn(Opcodes.ATHROW);
}
private void ACONST_NULL() {
this.current.visitInsn(Opcodes.ACONST_NULL);
}
private void RETURN() {
this.current.visitInsn(Opcodes.RETURN);
}
private void LABEL(final Label l) {
this.current.visitLabel(l);
}
private void IINC(final int var, final int amnt) {
this.current.visitIincInsn(var, amnt);
}
private void GOTO(final Label l) {
this.current.visitJumpInsn(Opcodes.GOTO, l);
}
private void JSR(final Label l) {
this.current.visitJumpInsn(Opcodes.JSR, l);
}
private void IFNONNULL(final Label l) {
this.current.visitJumpInsn(Opcodes.IFNONNULL, l);
}
private void IFNE(final Label l) {
this.current.visitJumpInsn(Opcodes.IFNE, l);
}
private void TRYCATCH(
final Label start,
final Label end,
final Label handler)
{
this.current.visitTryCatchBlock(start, end, handler, null);
}
private void LINE(final int line, final Label start) {
this.current.visitLineNumber(line, start);
}
private void LOCALVAR(
final String name,
final String desc,
final int index,
final Label start,
final Label end)
{
this.current.visitLocalVariable(name, desc, null, start, end, index);
}
private void END(final int maxStack, final int maxLocals) {
this.current.visitMaxs(maxStack, maxLocals);
this.current.visitEnd();
ClassWriter cw = new ClassWriter(0);
cw.visit(Opcodes.V1_1,
Opcodes.ACC_PUBLIC,
"C",
null,
"java/lang/Object",
null);
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC,
"<init>",
"()V",
null,
null);
mv.visitCode();
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
"java/lang/Object",
"<init>",
"()V");
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
((MethodNode) this.current).accept(cw);
cw.visitEnd();
byte[] b = cw.toByteArray();
try {
TestClassLoader loader = new TestClassLoader();
Class c = loader.defineClass("C", b);
c.newInstance();
} catch (Throwable t) {
fail(t.getMessage());
}
this.current = null;
}
static class TestClassLoader extends ClassLoader {
public Class defineClass(final String name, final byte[] b) {
return defineClass(name, b, 0, b.length);
}
}
/**
* Tests a method which has the most basic <code>try{}finally</code> form
* imaginable:
*
* <pre>
* public void a() {
* int a = 0;
* try {
* a++;
* } finally {
* a--;
* }
* }
* </pre>
*/
public void testBasic() {
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
/* L0: body of try block */
LABEL(L0);
IINC(1, 1);
GOTO(L1);
/* L2: exception handler */
LABEL(L2);
ASTORE(3);
JSR(L3);
ALOAD(3);
ATHROW();
/* L3: subroutine */
LABEL(L3);
ASTORE(2);
IINC(1, -1);
RET(2);
/* L1: non-exceptional exit from try block */
LABEL(L1);
JSR(L3);
LABEL(L4); // L4
RETURN();
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L4, L2);
END(1, 4);
}
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3_1a = new Label();
Label L3_1b = new Label();
Label L3_2a = new Label();
Label L3_2b = new Label();
Label L4 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// L0: try/catch block
LABEL(L0);
IINC(1, 1);
GOTO(L1);
// L2: Exception handler:
LABEL(L2);
ASTORE(3);
ACONST_NULL();
GOTO(L3_1a);
LABEL(L3_1b); // L3_1b;
ALOAD(3);
ATHROW();
// L1: On non-exceptional exit, try block leads here:
LABEL(L1);
ACONST_NULL();
GOTO(L3_2a);
LABEL(L3_2b); // L3_2b
LABEL(L4); // L4
RETURN();
// L3_1a: First instantiation of subroutine:
LABEL(L3_1a);
ASTORE(2);
IINC(1, -1);
GOTO(L3_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L3_2a: Second instantiation of subroutine:
LABEL(L3_2a);
ASTORE(2);
IINC(1, -1);
GOTO(L3_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L4, L2);
END(1, 4);
}
assertEquals(exp, jsr);
}
/**
* Tests a method which has an if/else-if w/in the finally clause:
*
* <pre>
* public void a() {
* int a = 0;
* try {
* a++;
* } finally {
* if (a == 0)
* a+=2;
* else
* a+=3;
* }
* }
* </pre>
*/
public void testIfElseInFinally() {
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
Label L5 = new Label();
Label L6 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
/* L0: body of try block */
LABEL(L0);
IINC(1, 1);
GOTO(L1);
/* L2: exception handler */
LABEL(L2);
ASTORE(3);
JSR(L3);
ALOAD(3);
ATHROW();
/* L3: subroutine */
LABEL(L3);
ASTORE(2);
ILOAD(1);
IFNE(L4);
IINC(1, 2);
GOTO(L5);
LABEL(L4); // L4: a != 0
IINC(1, 3);
LABEL(L5); // L5: common exit
RET(2);
/* L1: non-exceptional exit from try block */
LABEL(L1);
JSR(L3);
LABEL(L6); // L6 is used in the TRYCATCH below
RETURN();
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L6, L2);
END(1, 4);
}
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3_1a = new Label();
Label L3_1b = new Label();
Label L3_2a = new Label();
Label L3_2b = new Label();
Label L4_1 = new Label();
Label L4_2 = new Label();
Label L5_1 = new Label();
Label L5_2 = new Label();
Label L6 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// L0: try/catch block
LABEL(L0);
IINC(1, 1);
GOTO(L1);
// L2: Exception handler:
LABEL(L2);
ASTORE(3);
ACONST_NULL();
GOTO(L3_1a);
LABEL(L3_1b); // L3_1b;
ALOAD(3);
ATHROW();
// L1: On non-exceptional exit, try block leads here:
LABEL(L1);
ACONST_NULL();
GOTO(L3_2a);
LABEL(L3_2b); // L3_2b
LABEL(L6); // L6
RETURN();
// L3_1a: First instantiation of subroutine:
LABEL(L3_1a);
ASTORE(2);
ILOAD(1);
IFNE(L4_1);
IINC(1, 2);
GOTO(L5_1);
LABEL(L4_1); // L4_1: a != 0
IINC(1, 3);
LABEL(L5_1); // L5_1: common exit
GOTO(L3_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L3_2a: First instantiation of subroutine:
LABEL(L3_2a);
ASTORE(2);
ILOAD(1);
IFNE(L4_2);
IINC(1, 2);
GOTO(L5_2);
LABEL(L4_2); // L4_2: a != 0
IINC(1, 3);
LABEL(L5_2); // L5_2: common exit
GOTO(L3_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L6, L2);
END(1, 4);
}
assertEquals(exp, jsr);
}
/**
* Tests a simple nested finally:
*
* <pre>
* public void a1() {
* int a = 0;
* try {
* a += 1;
* } finally {
* try {
* a += 2;
* } finally {
* a += 3;
* }
* }
* }
* </pre>
*/
public void testSimpleNestedFinally() {
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
Label L5 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// L0: Body of try block:
LABEL(L0);
IINC(1, 1);
JSR(L3);
GOTO(L1);
// L2: First exception handler:
LABEL(L2);
JSR(L3);
ATHROW();
// L3: First subroutine:
LABEL(L3);
ASTORE(2);
IINC(1, 2);
JSR(L4);
RET(2);
// L5: Second exception handler:
LABEL(L5);
JSR(L4);
ATHROW();
// L4: Second subroutine:
LABEL(L4);
ASTORE(3);
IINC(1, 3);
RET(3);
// L1: On normal exit, try block jumps here:
LABEL(L1);
RETURN();
TRYCATCH(L0, L2, L2);
TRYCATCH(L3, L5, L5);
END(2, 6);
}
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3_1a = new Label();
Label L3_1b = new Label();
Label L3_2a = new Label();
Label L3_2b = new Label();
Label L4_1a = new Label();
Label L4_1b = new Label();
Label L4_2a = new Label();
Label L4_2b = new Label();
Label L4_3a = new Label();
Label L4_3b = new Label();
Label L4_4a = new Label();
Label L4_4b = new Label();
Label L5_1 = new Label();
Label L5_2 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// L0: Body of try block:
LABEL(L0);
IINC(1, 1);
ACONST_NULL();
GOTO(L3_1a);
LABEL(L3_1b); // L3_1b
GOTO(L1);
// L2: First exception handler:
LABEL(L2);
ACONST_NULL();
GOTO(L3_2a);
LABEL(L3_2b); // L3_2b
ATHROW();
// L1: On normal exit, try block jumps here:
LABEL(L1);
RETURN();
// L3_1a: First instantiation of first subroutine:
LABEL(L3_1a);
ASTORE(2);
IINC(1, 2);
ACONST_NULL();
GOTO(L4_1a);
LABEL(L4_1b); // L4_1b
GOTO(L3_1b);
LABEL(L5_1); // L5_1
ACONST_NULL();
GOTO(L4_2a);
LABEL(L4_2b); // L4_2b
ATHROW();
LABEL(new Label()); // extra label emitted due to impl quirks
// L3_2a: Second instantiation of first subroutine:
LABEL(L3_2a);
ASTORE(2);
IINC(1, 2);
ACONST_NULL();
GOTO(L4_3a);
LABEL(L4_3b); // L4_3b
GOTO(L3_2b);
LABEL(L5_2); // L5_2
ACONST_NULL();
GOTO(L4_4a);
LABEL(L4_4b); // L4_4b
ATHROW();
LABEL(new Label()); // extra label emitted due to impl quirks
// L4_1a: First instantiation of second subroutine:
LABEL(L4_1a);
ASTORE(3);
IINC(1, 3);
GOTO(L4_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L4_2a: Second instantiation of second subroutine:
LABEL(L4_2a);
ASTORE(3);
IINC(1, 3);
GOTO(L4_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L4_3a: Third instantiation of second subroutine:
LABEL(L4_3a);
ASTORE(3);
IINC(1, 3);
GOTO(L4_3b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L4_4a: Fourth instantiation of second subroutine:
LABEL(L4_4a);
ASTORE(3);
IINC(1, 3);
GOTO(L4_4b);
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(L0, L2, L2);
TRYCATCH(L3_1a, L5_1, L5_1);
TRYCATCH(L3_2a, L5_2, L5_2);
END(2, 6);
}
assertEquals(exp, jsr);
}
/**
* This tests a subroutine which has no ret statement, but ends in a
* "return" instead.
*
* We structure this as a try/finally with a break in the finally. Because
* the while loop is infinite, it's clear from the byte code that the only
* path which reaches the RETURN instruction is through the subroutine.
*
* <pre>
* public void a1() {
* int a = 0;
* while (true) {
* try {
* a += 1;
* } finally {
* a += 2;
* break;
* }
* }
* }
* </pre>
*/
public void testSubroutineWithNoRet() {
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// L0: while loop header/try block
LABEL(L0);
IINC(1, 1);
JSR(L1);
GOTO(L2);
// L3: implicit catch block
LABEL(L3);
ASTORE(2);
JSR(L1);
ALOAD(2);
ATHROW();
// L1: subroutine ...
LABEL(L1);
ASTORE(3);
IINC(1, 2);
GOTO(L4); // ...not that it does not return!
// L2: end of the loop... goes back to the top!
LABEL(L2);
GOTO(L0);
// L4:
LABEL(L4);
RETURN();
TRYCATCH(L0, L3, L3);
END(1, 4);
}
{
Label L0 = new Label();
Label L1_1a = new Label();
Label L1_1b = new Label();
Label L1_2a = new Label();
Label L1_2b = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4_1 = new Label();
Label L4_2 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// L0: while loop header/try block
LABEL(L0);
IINC(1, 1);
ACONST_NULL();
GOTO(L1_1a);
LABEL(L1_1b); // L1_1b
GOTO(L2);
// L3: implicit catch block
LABEL(L3);
ASTORE(2);
ACONST_NULL();
GOTO(L1_2a);
LABEL(L1_2b); // L1_2b
ALOAD(2);
ATHROW();
// L2: end of the loop... goes back to the top!
LABEL(L2);
GOTO(L0);
LABEL(new Label()); // extra label emitted due to impl quirks
// L1_1a: first instantiation of subroutine ...
LABEL(L1_1a);
ASTORE(3);
IINC(1, 2);
GOTO(L4_1); // ...not that it does not return!
LABEL(L4_1);
RETURN();
// L1_2a: second instantiation of subroutine ...
LABEL(L1_2a);
ASTORE(3);
IINC(1, 2);
GOTO(L4_2); // ...not that it does not return!
LABEL(L4_2);
RETURN();
TRYCATCH(L0, L3, L3);
END(1, 4);
}
assertEquals(exp, jsr);
}
/**
* This tests a subroutine which has no ret statement, but ends in a
* "return" instead.
*
* <pre>
* JSR L0
* L0:
* ASTORE 0
* RETURN
* </pre>
*/
public void testSubroutineWithNoRet2() {
{
Label L0 = new Label();
setCurrent(jsr);
JSR(L0);
LABEL(L0);
ASTORE(0);
RETURN();
END(1, 1);
}
{
Label L0_1a = new Label();
Label L0_1b = new Label();
setCurrent(exp);
ACONST_NULL();
GOTO(L0_1a);
LABEL(L0_1b);
// L0_1a: First instantiation of subroutine:
LABEL(L0_1a);
ASTORE(0);
RETURN();
LABEL(new Label()); // extra label emitted due to impl quirks
END(1, 1);
}
assertEquals(exp, jsr);
}
/**
* This tests a subroutine which has no ret statement, but instead exits
* implicitely by branching to code which is not part of the subroutine.
* (Sadly, this is legal)
*
* We structure this as a try/finally in a loop with a break in the finally.
* The loop is not trivially infinite, so the RETURN statement is reachable
* both from the JSR subroutine and from the main entry point.
*
* <pre>
* public void a1() {
* int a = 0;
* while (null == null) {
* try {
* a += 1;
* } finally {
* a += 2;
* break;
* }
* }
* }
* </pre>
*/
public void testImplicitExit() {
{
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
Label L5 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// L5: while loop header
LABEL(L5);
ACONST_NULL();
IFNONNULL(L4);
// L0: try block
LABEL(L0);
IINC(1, 1);
JSR(L1);
GOTO(L2);
// L3: implicit catch block
LABEL(L3);
ASTORE(2);
JSR(L1);
ALOAD(2);
ATHROW();
// L1: subroutine ...
LABEL(L1);
ASTORE(3);
IINC(1, 2);
GOTO(L4); // ...not that it does not return!
// L2: end of the loop... goes back to the top!
LABEL(L2);
GOTO(L0);
// L4:
LABEL(L4);
RETURN();
TRYCATCH(L0, L3, L3);
END(1, 4);
}
{
Label L0 = new Label();
Label L1_1a = new Label();
Label L1_1b = new Label();
Label L1_2a = new Label();
Label L1_2b = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
Label L5 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// L5: while loop header
LABEL(L5);
ACONST_NULL();
IFNONNULL(L4);
// L0: while loop header/try block
LABEL(L0);
IINC(1, 1);
ACONST_NULL();
GOTO(L1_1a);
LABEL(L1_1b); // L1_1b
GOTO(L2);
// L3: implicit catch block
LABEL(L3);
ASTORE(2);
ACONST_NULL();
GOTO(L1_2a);
LABEL(L1_2b); // L1_2b
ALOAD(2);
ATHROW();
// L2: end of the loop... goes back to the top!
LABEL(L2);
GOTO(L0);
// L4: exit, not part of subroutine
// Note that the two subroutine instantiations branch here
LABEL(L4);
RETURN();
// L1_1a: first instantiation of subroutine ...
LABEL(L1_1a);
ASTORE(3);
IINC(1, 2);
GOTO(L4); // ...note that it does not return!
LABEL(new Label()); // extra label emitted due to impl quirks
// L1_2a: second instantiation of subroutine ...
LABEL(L1_2a);
ASTORE(3);
IINC(1, 2);
GOTO(L4); // ...note that it does not return!
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(L0, L3, L3);
END(1, 4);
}
assertEquals(exp, jsr);
}
/**
* Tests a nested try/finally with implicit exit from one subroutine to the
* other subroutine. Equivalent to the following java code:
*
* <pre>
* void m(boolean b) {
* try {
* return;
* } finally {
* while (b) {
* try {
* return;
* } finally {
* // NOTE --- this break avoids the second return above (weird)
* if (b) break;
* }
* }
* }
* }
* </pre>
*
* This example is from the paper, "Subroutine Inlining and Bytecode
* Abstraction to Simplify Static and Dynamic Analysis" by Cyrille Artho and
* Armin Biere.
*/
public void testImplicitExitToAnotherSubroutine() {
{
Label T1 = new Label();
Label C1 = new Label();
Label S1 = new Label();
Label L = new Label();
Label C2 = new Label();
Label S2 = new Label();
Label W = new Label();
Label X = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// T1: first try:
LABEL(T1);
JSR(S1);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
JSR(S1);
ALOAD(e1);
ATHROW();
// S1: first finally handler
LABEL(S1);
ASTORE(r1);
GOTO(W);
// L: body of while loop, also second try
LABEL(L);
JSR(S2);
RETURN();
// C2: exception handler for second try
LABEL(C2);
ASTORE(e2);
JSR(S2);
ALOAD(e2);
ATHROW();
// S2: second finally handler
LABEL(S2);
ASTORE(r2);
ILOAD(b);
IFNE(X);
RET(r2);
// W: test for the while loop
LABEL(W);
ILOAD(b);
IFNE(L); // falls through to X
// X: exit from finally{} block
LABEL(X);
RET(r1);
TRYCATCH(T1, C1, C1);
TRYCATCH(L, C2, C2);
END(1, 6);
}
{
Label T1 = new Label();
Label C1 = new Label();
Label S1_1a = new Label();
Label S1_1b = new Label();
Label S1_2a = new Label();
Label S1_2b = new Label();
Label L_1 = new Label();
Label L_2 = new Label();
Label C2_1 = new Label();
Label C2_2 = new Label();
Label S2_1_1a = new Label();
Label S2_1_1b = new Label();
Label S2_1_2a = new Label();
Label S2_1_2b = new Label();
Label S2_2_1a = new Label();
Label S2_2_1b = new Label();
Label S2_2_2a = new Label();
Label S2_2_2b = new Label();
Label W_1 = new Label();
Label W_2 = new Label();
Label X_1 = new Label();
Label X_2 = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(exp);
// --- Main Subroutine ---
ICONST_0();
ISTORE(1);
// T1: first try:
LABEL(T1);
ACONST_NULL();
GOTO(S1_1a);
LABEL(S1_1b);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
ACONST_NULL();
GOTO(S1_2a);
LABEL(S1_2b);
ALOAD(e1);
ATHROW();
LABEL(new Label()); // extra label emitted due to impl quirks
// --- First instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_1a);
ASTORE(r1);
GOTO(W_1);
// L_1: body of while loop, also second try
LABEL(L_1);
ACONST_NULL();
GOTO(S2_1_1a);
LABEL(S2_1_1b);
RETURN();
// C2_1: exception handler for second try
LABEL(C2_1);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_1_2a);
LABEL(S2_1_2b);
ALOAD(e2);
ATHROW();
// W_1: test for the while loop
LABEL(W_1);
ILOAD(b);
IFNE(L_1); // falls through to X_1
// X_1: exit from finally{} block
LABEL(X_1);
GOTO(S1_1b);
// --- Second instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_2a);
ASTORE(r1);
GOTO(W_2);
// L_2: body of while loop, also second try
LABEL(L_2);
ACONST_NULL();
GOTO(S2_2_1a);
LABEL(S2_2_1b);
RETURN();
// C2_2: exception handler for second try
LABEL(C2_2);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_2_2a);
LABEL(S2_2_2b);
ALOAD(e2);
ATHROW();
// W_2: test for the while loop
LABEL(W_2);
ILOAD(b);
IFNE(L_2); // falls through to X_2
// X_2: exit from finally{} block
LABEL(X_2);
GOTO(S1_2b);
// --- Second subroutine's 4 instantiations ---
// S2_1_1a:
LABEL(S2_1_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_1_2a:
LABEL(S2_1_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_2_1a:
LABEL(S2_2_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_2_2a:
LABEL(S2_2_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(T1, C1, C1);
TRYCATCH(L_1, C2_1, C2_1); // duplicated try/finally for each...
TRYCATCH(L_2, C2_2, C2_2); // ...instantiation of first sub
END(1, 6);
}
assertEquals(exp, jsr);
}
/**
* This tests two subroutines, neither of which exit. Instead, they both
* branch to a common set of code which returns from the method. This code
* is not reachable except through these subroutines, and since they do not
* invoke each other, it must be copied into both of them.
*
* I don't believe this can be represented in Java.
*/
public void testCommonCodeWhichMustBeDuplicated() {
{
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// Invoke the two subroutines, each twice:
JSR(L1);
JSR(L1);
JSR(L2);
JSR(L2);
RETURN();
// L1: subroutine 1
LABEL(L1);
IINC(1, 1);
GOTO(L3); // ...note that it does not return!
// L2: subroutine 2
LABEL(L2);
IINC(1, 2);
GOTO(L3); // ...note that it does not return!
// L3: common code to both subroutines: exit method
LABEL(L3);
RETURN();
END(1, 2);
}
{
Label L1_1a = new Label();
Label L1_1b = new Label();
Label L1_2a = new Label();
Label L1_2b = new Label();
Label L2_1a = new Label();
Label L2_1b = new Label();
Label L2_2a = new Label();
Label L2_2b = new Label();
Label L3_1 = new Label();
Label L3_2 = new Label();
Label L3_3 = new Label();
Label L3_4 = new Label();
setCurrent(exp);
ICONST_0();
ISTORE(1);
// Invoke the two subroutines, each twice:
ACONST_NULL();
GOTO(L1_1a);
LABEL(L1_1b);
ACONST_NULL();
GOTO(L1_2a);
LABEL(L1_2b);
ACONST_NULL();
GOTO(L2_1a);
LABEL(L2_1b);
ACONST_NULL();
GOTO(L2_2a);
LABEL(L2_2b);
RETURN();
LABEL(new Label()); // extra label emitted due to impl quirks
// L1_1a: instantiation 1 of subroutine 1
LABEL(L1_1a);
IINC(1, 1);
GOTO(L3_1); // ...note that it does not return!
LABEL(L3_1);
RETURN();
// L1_2a: instantiation 2 of subroutine 1
LABEL(L1_2a);
IINC(1, 1);
GOTO(L3_2); // ...note that it does not return!
LABEL(L3_2);
RETURN();
// L2_1a: instantiation 1 of subroutine 2
LABEL(L2_1a);
IINC(1, 2);
GOTO(L3_3); // ...note that it does not return!
LABEL(L3_3);
RETURN();
// L2_2a: instantiation 2 of subroutine 2
LABEL(L2_2a);
IINC(1, 2);
GOTO(L3_4); // ...note that it does not return!
LABEL(L3_4);
RETURN();
END(1, 2);
}
assertEquals(exp, jsr);
}
/**
* This tests a simple subroutine where the control flow jumps back and
* forth between the subroutine and the caller.
*
* This would not normally be produced by a java compiler.
*/
public void testInterleavedCode() {
{
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// Invoke the subroutine, each twice:
JSR(L1);
GOTO(L2);
// L1: subroutine 1
LABEL(L1);
ASTORE(2);
IINC(1, 1);
GOTO(L3);
// L2: second part of main subroutine
LABEL(L2);
IINC(1, 2);
GOTO(L4);
// L3: second part of subroutine 1
LABEL(L3);
IINC(1, 4);
RET(2);
// L4: third part of main subroutine
LABEL(L4);
JSR(L1);
RETURN();
END(1, 3);
}
{
Label L1_1a = new Label();
Label L1_1b = new Label();
Label L1_2a = new Label();
Label L1_2b = new Label();
Label L2 = new Label();
Label L3_1 = new Label();
Label L3_2 = new Label();
Label L4 = new Label();
setCurrent(exp);
// Main routine:
ICONST_0();
ISTORE(1);
ACONST_NULL();
GOTO(L1_1a);
LABEL(L1_1b);
GOTO(L2);
LABEL(L2);
IINC(1, 2);
GOTO(L4);
LABEL(L4);
ACONST_NULL();
GOTO(L1_2a);
LABEL(L1_2b);
RETURN();
// L1_1: instantiation #1
LABEL(L1_1a);
ASTORE(2);
IINC(1, 1);
GOTO(L3_1);
LABEL(L3_1);
IINC(1, 4);
GOTO(L1_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// L1_2: instantiation #2
LABEL(L1_2a);
ASTORE(2);
IINC(1, 1);
GOTO(L3_2);
LABEL(L3_2);
IINC(1, 4);
GOTO(L1_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
END(1, 3);
}
assertEquals(exp, jsr);
}
/**
* Tests a nested try/finally with implicit exit from one subroutine to the
* other subroutine, and with a surrounding try/catch thrown in the mix.
* Equivalent to the following java code:
*
* <pre>
* void m(int b) {
* try {
* try {
* return;
* } finally {
* while (b) {
* try {
* return;
* } finally {
* // NOTE --- this break avoids the second return above (weird)
* if (b) break;
* }
* }
* }
* } catch (Exception e) {
* b += 3;
* return;
* }
* }
* </pre>
*/
public void testImplicitExitInTryCatch() {
{
Label T1 = new Label();
Label C1 = new Label();
Label S1 = new Label();
Label L = new Label();
Label C2 = new Label();
Label S2 = new Label();
Label W = new Label();
Label X = new Label();
Label OT = new Label();
Label OC = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// OT: outermost try
LABEL(OT);
// T1: first try:
LABEL(T1);
JSR(S1);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
JSR(S1);
ALOAD(e1);
ATHROW();
// S1: first finally handler
LABEL(S1);
ASTORE(r1);
GOTO(W);
// L: body of while loop, also second try
LABEL(L);
JSR(S2);
RETURN();
// C2: exception handler for second try
LABEL(C2);
ASTORE(e2);
JSR(S2);
ALOAD(e2);
ATHROW();
// S2: second finally handler
LABEL(S2);
ASTORE(r2);
ILOAD(b);
IFNE(X);
RET(r2);
// W: test for the while loop
LABEL(W);
ILOAD(b);
IFNE(L); // falls through to X
// X: exit from finally{} block
LABEL(X);
RET(r1);
// OC: outermost catch
LABEL(OC);
IINC(b, 3);
RETURN();
TRYCATCH(T1, C1, C1);
TRYCATCH(L, C2, C2);
TRYCATCH(OT, OC, OC);
END(1, 6);
}
{
Label T1 = new Label();
Label C1 = new Label();
Label S1_1a = new Label();
Label S1_1b = new Label();
Label S1_2a = new Label();
Label S1_2b = new Label();
Label L_1 = new Label();
Label L_2 = new Label();
Label C2_1 = new Label();
Label C2_2 = new Label();
Label S2_1_1a = new Label();
Label S2_1_1b = new Label();
Label S2_1_2a = new Label();
Label S2_1_2b = new Label();
Label S2_2_1a = new Label();
Label S2_2_1b = new Label();
Label S2_2_2a = new Label();
Label S2_2_2b = new Label();
Label W_1 = new Label();
Label W_2 = new Label();
Label X_1 = new Label();
Label X_2 = new Label();
Label OT_1 = S1_1a;
Label OT_2 = S1_2a;
Label OT_1_1 = S2_1_1a;
Label OT_1_2 = S2_1_2a;
Label OT_2_1 = S2_2_1a;
Label OT_2_2 = S2_2_2a;
Label OC = new Label();
Label OC_1 = new Label();
Label OC_2 = new Label();
Label OC_1_1 = new Label();
Label OC_1_2 = new Label();
Label OC_2_1 = new Label();
Label OC_2_2 = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(exp);
// --- Main Subroutine ---
ICONST_0();
ISTORE(1);
// T1: outermost try / first try:
LABEL(T1);
ACONST_NULL();
GOTO(S1_1a);
LABEL(S1_1b);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
ACONST_NULL();
GOTO(S1_2a);
LABEL(S1_2b);
ALOAD(e1);
ATHROW();
// OC: Outermost catch
LABEL(OC);
IINC(b, 3);
RETURN();
// --- First instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_1a);
ASTORE(r1);
GOTO(W_1);
// L_1: body of while loop, also second try
LABEL(L_1);
ACONST_NULL();
GOTO(S2_1_1a);
LABEL(S2_1_1b);
RETURN();
// C2_1: exception handler for second try
LABEL(C2_1);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_1_2a);
LABEL(S2_1_2b);
ALOAD(e2);
ATHROW();
// W_1: test for the while loop
LABEL(W_1);
ILOAD(b);
IFNE(L_1); // falls through to X_1
// X_1: exit from finally{} block
LABEL(X_1);
GOTO(S1_1b);
LABEL(OC_1);
// --- Second instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_2a);
ASTORE(r1);
GOTO(W_2);
// L_2: body of while loop, also second try
LABEL(L_2);
ACONST_NULL();
GOTO(S2_2_1a);
LABEL(S2_2_1b);
RETURN();
// C2_2: exception handler for second try
LABEL(C2_2);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_2_2a);
LABEL(S2_2_2b);
ALOAD(e2);
ATHROW();
// W_2: test for the while loop
LABEL(W_2);
ILOAD(b);
IFNE(L_2); // falls through to X_2
// X_2: exit from finally{} block
LABEL(X_2);
GOTO(S1_2b);
LABEL(OC_2);
// --- Second subroutine's 4 instantiations ---
// S2_1_1a:
LABEL(S2_1_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_1b);
LABEL(OC_1_1);
// S2_1_2a:
LABEL(S2_1_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_2b);
LABEL(OC_1_2);
// S2_2_1a:
LABEL(S2_2_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_1b);
LABEL(OC_2_1);
// S2_2_2a:
LABEL(S2_2_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_2b);
LABEL(OC_2_2);
// main subroutine handlers:
TRYCATCH(T1, C1, C1);
TRYCATCH(T1, OC, OC);
// first instance of first sub try/catch handlers:
TRYCATCH(L_1, C2_1, C2_1);
TRYCATCH(OT_1, OC_1, OC); // note: reuses handler code from main
// sub
// second instance of first sub try/catch handlers:
TRYCATCH(L_2, C2_2, C2_2);
TRYCATCH(OT_2, OC_2, OC);
// all 4 instances of second sub:
TRYCATCH(OT_1_1, OC_1_1, OC);
TRYCATCH(OT_1_2, OC_1_2, OC);
TRYCATCH(OT_2_1, OC_2_1, OC);
TRYCATCH(OT_2_2, OC_2_2, OC);
END(1, 6);
}
assertEquals(exp, jsr);
}
/**
* Tests a method which has line numbers and local variable declarations.
*
* <pre>
* public void a() {
* 1 int a = 0;
* 2 try {
* 3 a++;
* 4 } finally {
* 5 a--;
* 6 }
* }
* LV "a" from 1 to 6
* </pre>
*/
public void testBasicLineNumberAndLocalVars() {
{
Label LM1 = new Label();
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3 = new Label();
Label L4 = new Label();
setCurrent(jsr);
LABEL(LM1);
LINE(1, LM1);
ICONST_0();
ISTORE(1);
/* L0: body of try block */
LABEL(L0);
LINE(3, L0);
IINC(1, 1);
GOTO(L1);
/* L2: exception handler */
LABEL(L2);
ASTORE(3);
JSR(L3);
ALOAD(3);
ATHROW();
/* L3: subroutine */
LABEL(L3);
LINE(5, L3);
ASTORE(2);
IINC(1, -1);
RET(2);
/* L1: non-exceptional exit from try block */
LABEL(L1);
JSR(L3);
LABEL(L4); // L4
RETURN();
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L4, L2);
LOCALVAR("a", "I", 1, LM1, L4);
END(1, 4);
}
{
Label LM1 = new Label();
Label L0 = new Label();
Label L1 = new Label();
Label L2 = new Label();
Label L3_1a = new Label();
Label L3_1b = new Label();
Label L3_1c = new Label();
Label L3_2a = new Label();
Label L3_2b = new Label();
Label L3_2c = new Label();
Label L4 = new Label();
setCurrent(exp);
LABEL(LM1);
LINE(1, LM1);
ICONST_0();
ISTORE(1);
// L0: try/catch block
LABEL(L0);
LINE(3, L0);
IINC(1, 1);
GOTO(L1);
// L2: Exception handler:
LABEL(L2);
ASTORE(3);
ACONST_NULL();
GOTO(L3_1a);
LABEL(L3_1b); // L3_1b;
ALOAD(3);
ATHROW();
// L1: On non-exceptional exit, try block leads here:
LABEL(L1);
ACONST_NULL();
GOTO(L3_2a);
LABEL(L3_2b); // L3_2b
LABEL(L4); // L4
RETURN();
// L3_1a: First instantiation of subroutine:
LABEL(L3_1a);
LINE(5, L3_1a);
ASTORE(2);
IINC(1, -1);
GOTO(L3_1b);
LABEL(L3_1c);
// L3_2a: Second instantiation of subroutine:
LABEL(L3_2a);
LINE(5, L3_2a);
ASTORE(2);
IINC(1, -1);
GOTO(L3_2b);
LABEL(L3_2c);
TRYCATCH(L0, L2, L2);
TRYCATCH(L1, L4, L2);
LOCALVAR("a", "I", 1, LM1, L4);
LOCALVAR("a", "I", 1, L3_1a, L3_1c);
LOCALVAR("a", "I", 1, L3_2a, L3_2c);
END(1, 4);
}
assertEquals(exp, jsr);
}
public void assertEquals(final MethodNode exp, final MethodNode actual) {
String textexp = getText(exp);
String textact = getText(actual);
System.err.println("Expected=" + textexp);
System.err.println("Actual=" + textact);
assertEquals(textexp, textact);
}
private String getText(final MethodNode mn) {
TraceMethodVisitor tmv = new TraceMethodVisitor(null);
mn.accept(tmv);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < tmv.text.size(); i++) {
sb.append(tmv.text.get(i));
}
return sb.toString();
}
}
| [
"vivekp@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5"
] | vivekp@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5 |
19812d7c5002745597ec0f935335cb0f105fbb33 | 2d76e26665f9b5fdf9794752f72d6ff99401f6b7 | /mp01/src/main/java/com/aiguigu/mp/mapper/EmployeeMapper.java | 08ed654a874b41f91d79f3036b1a416614b3ec6b | [] | no_license | GalileoPushpin/JekinsDemo | 5ff33843ea1d64a0f2bfd5477ed8771f41d1fafa | 5b1cde653feaf79d634e904d2a1928b762edd000 | refs/heads/master | 2020-04-29T17:16:46.141853 | 2019-03-21T09:38:53 | 2019-03-21T09:38:53 | 176,292,204 | 1 | 0 | null | 2019-03-21T06:12:57 | 2019-03-18T13:28:37 | null | UTF-8 | Java | false | false | 283 | java | package com.aiguigu.mp.mapper;
import com.aiguigu.mp.beans.Employee;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* MP
* 继承BaseMapper
* 泛型:对应的实体类
* @author Administrator
*
*/
public interface EmployeeMapper extends BaseMapper<Employee>{
//
}
| [
"[email protected]"
] | |
1dfa48e91370f5ae4367623fc5406038b4919d0f | 35d53041fb01f222c86f3121bf5045923ea688b4 | /base/src/main/java/org/xillium/base/model/TextResources.java | 3969fb78dc28d6e81d13767216a82805e7bb0923 | [
"Apache-2.0"
] | permissive | brianwhu/xillium | b9c0c6ba46280882aee56ffc8fda651063d9bea1 | a50985f741ba91bd24f6f4ae6ae43168b5550e21 | refs/heads/master | 2023-08-14T15:58:35.348548 | 2020-01-30T20:24:06 | 2020-01-30T20:24:06 | 4,109,644 | 0 | 1 | Apache-2.0 | 2022-07-11T21:04:41 | 2012-04-23T04:34:39 | Java | UTF-8 | Java | false | false | 516 | java | package org.xillium.base.model;
import java.util.*;
/**
* A collection of TextResource objects registered under unique names.
*/
public class TextResources {
public static Map<String, String> map;
private final String _name;
public TextResources(String namespace) {
_name = namespace;
}
public void addTextResource(TextResource resource) {
if (map == null) {
map = new HashMap<>();
}
map.put(_name + '/' + resource.name, resource.text);
}
}
| [
"[email protected]"
] | |
274082eac5ce00d5b2d55fc17df7495b54d451ea | 0314ec6b45d526ef1530d4cb21544832c4e0ffff | /src/main/java/dice/Main.java | 7524c92f916f3d8b0e5fa855eaf30324e4a5e0c3 | [] | no_license | willlowery/antlr-intro-dice-notation | 0772283be253c0a9b30a62b9f7a7af52fa21767e | 8d8a0fd19fb715786f274f279048c4d8274d59d8 | refs/heads/master | 2021-01-25T06:56:08.512422 | 2017-02-16T22:53:37 | 2017-02-16T22:53:37 | 80,672,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 439 | java | package dice;
import dice.sm.DieExpressionFactory;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
String roll = "6d6";
System.out.printf("Roll [%s] %d%n", roll, eval(roll));
}
private static Integer eval(String toParse) throws IOException {
return new Reader_Final(new DieExpressionFactory(new DieRoller())).run(toParse).eval();
}
}
| [
"[email protected]"
] | |
ac40e5779b7490bd17c55f1f4deddb3550d0cff4 | f6899a2cf1c10a724632bbb2ccffb7283c77a5ff | /hibernate-core/5.2.15/src/main/java/org/hibernate/type/ManyToOneType.java | d44b8baf4fa333f7eba8c560de5d204097e1d91e | [] | no_license | Appdynamics/OSS | a8903058e29f4783e34119a4d87639f508a63692 | 1e112f8854a25b3ecf337cad6eccf7c85e732525 | refs/heads/master | 2023-07-22T03:34:54.770481 | 2021-10-28T07:01:57 | 2021-10-28T07:01:57 | 19,390,624 | 2 | 13 | null | 2023-07-08T02:26:33 | 2014-05-02T22:42:20 | null | UTF-8 | Java | false | false | 9,571 | java | /*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.type;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.engine.internal.ForeignKeys;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.entity.EntityPersister;
/**
* A many-to-one association to an entity.
*
* @author Gavin King
*/
public class ManyToOneType extends EntityType {
private final boolean ignoreNotFound;
private boolean isLogicalOneToOne;
/**
* Creates a many-to-one association type with the given referenced entity.
*
* @param scope The scope for this instance.
* @param referencedEntityName The name iof the referenced entity
*/
public ManyToOneType(TypeFactory.TypeScope scope, String referencedEntityName) {
this( scope, referencedEntityName, false );
}
/**
* Creates a many-to-one association type with the given referenced entity and the
* given laziness characteristic
*
* @param scope The scope for this instance.
* @param referencedEntityName The name iof the referenced entity
* @param lazy Should the association be handled lazily
*/
public ManyToOneType(TypeFactory.TypeScope scope, String referencedEntityName, boolean lazy) {
this( scope, referencedEntityName, true, null, lazy, true, false, false );
}
/**
* @deprecated Use {@link #ManyToOneType(TypeFactory.TypeScope, String, boolean, String, boolean, boolean, boolean, boolean ) } instead.
*/
@Deprecated
public ManyToOneType(
TypeFactory.TypeScope scope,
String referencedEntityName,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean isEmbeddedInXML,
boolean ignoreNotFound,
boolean isLogicalOneToOne) {
this( scope, referencedEntityName, uniqueKeyPropertyName == null, uniqueKeyPropertyName, lazy, unwrapProxy, ignoreNotFound, isLogicalOneToOne );
}
public ManyToOneType(
TypeFactory.TypeScope scope,
String referencedEntityName,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
boolean ignoreNotFound,
boolean isLogicalOneToOne) {
super( scope, referencedEntityName, referenceToPrimaryKey, uniqueKeyPropertyName, !lazy, unwrapProxy );
this.ignoreNotFound = ignoreNotFound;
this.isLogicalOneToOne = isLogicalOneToOne;
}
public ManyToOneType(ManyToOneType original, String superTypeEntityName) {
super( original, superTypeEntityName );
this.ignoreNotFound = original.ignoreNotFound;
this.isLogicalOneToOne = original.isLogicalOneToOne;
}
@Override
protected boolean isNullable() {
return ignoreNotFound;
}
@Override
public boolean isAlwaysDirtyChecked() {
// always need to dirty-check, even when non-updateable;
// this ensures that when the association is updated,
// the entity containing this association will be updated
// in the cache
return true;
}
@Override
public boolean isOneToOne() {
return false;
}
@Override
public boolean isLogicalOneToOne() {
return isLogicalOneToOne;
}
@Override
public int getColumnSpan(Mapping mapping) throws MappingException {
return requireIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
}
@Override
public int[] sqlTypes(Mapping mapping) throws MappingException {
return requireIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
}
@Override
public Size[] dictatedSizes(Mapping mapping) throws MappingException {
return requireIdentifierOrUniqueKeyType( mapping ).dictatedSizes( mapping );
}
@Override
public Size[] defaultSizes(Mapping mapping) throws MappingException {
return requireIdentifierOrUniqueKeyType( mapping ).defaultSizes( mapping );
}
@Override
public ForeignKeyDirection getForeignKeyDirection() {
return ForeignKeyDirection.FROM_PARENT;
}
@Override
public Object hydrate(
ResultSet rs,
String[] names,
SharedSessionContractImplementor session,
Object owner) throws HibernateException, SQLException {
// return the (fully resolved) identifier value, but do not resolve
// to the actual referenced entity instance
// NOTE: the owner of the association is not really the owner of the id!
// First hydrate the ID to check if it is null.
// Don't bother resolving the ID if hydratedKeyState[i] is null.
// Implementation note: if id is a composite ID, then resolving a null value will
// result in instantiating an empty composite if AvailableSettings#CREATE_EMPTY_COMPOSITES_ENABLED
// is true. By not resolving a null value for a composite ID, we avoid the overhead of instantiating
// an empty composite, checking if it is equivalent to null (it should be), then ultimately throwing
// out the empty value.
final Object hydratedId = getIdentifierOrUniqueKeyType( session.getFactory() )
.hydrate( rs, names, session, null );
final Serializable id;
if ( hydratedId != null ) {
id = (Serializable) getIdentifierOrUniqueKeyType( session.getFactory() )
.resolve( hydratedId, session, null );
}
else {
id = null;
}
scheduleBatchLoadIfNeeded( id, session );
return id;
}
/**
* Register the entity as batch loadable, if enabled
*/
@SuppressWarnings({ "JavaDoc" })
private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException {
//cannot batch fetch by unique key (property-ref associations)
if ( uniqueKeyPropertyName == null && id != null ) {
final EntityPersister persister = getAssociatedEntityPersister( session.getFactory() );
if ( persister.isBatchLoadable() ) {
final EntityKey entityKey = session.generateEntityKey( id, persister );
if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey );
}
}
}
}
@Override
public boolean useLHSPrimaryKey() {
return false;
}
@Override
public boolean isModified(
Object old,
Object current,
boolean[] checkable,
SharedSessionContractImplementor session) throws HibernateException {
if ( current == null ) {
return old!=null;
}
if ( old == null ) {
// we already know current is not null...
return true;
}
// the ids are fully resolved, so compare them with isDirty(), not isModified()
return getIdentifierOrUniqueKeyType( session.getFactory() )
.isDirty( old, getIdentifier( current, session ), session );
}
@Override
public Serializable disassemble(
Object value,
SharedSessionContractImplementor session,
Object owner) throws HibernateException {
if ( value == null ) {
return null;
}
else {
// cache the actual id of the object, not the value of the
// property-ref, which might not be initialized
Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved(
getAssociatedEntityName(),
value,
session
);
if ( id == null ) {
throw new AssertionFailure(
"cannot cache a reference to an object with a null id: " +
getAssociatedEntityName()
);
}
return getIdentifierType( session ).disassemble( id, session, owner );
}
}
@Override
public Object assemble(
Serializable oid,
SharedSessionContractImplementor session,
Object owner) throws HibernateException {
//TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object)
Serializable id = assembleId( oid, session );
if ( id == null ) {
return null;
}
else {
return resolveIdentifier( id, session );
}
}
private Serializable assembleId(Serializable oid, SharedSessionContractImplementor session) {
//the owner of the association is not the owner of the id
return ( Serializable ) getIdentifierType( session ).assemble( oid, session, null );
}
@Override
public void beforeAssemble(Serializable oid, SharedSessionContractImplementor session) {
scheduleBatchLoadIfNeeded( assembleId( oid, session ), session );
}
@Override
public boolean[] toColumnNullness(Object value, Mapping mapping) {
boolean[] result = new boolean[ getColumnSpan( mapping ) ];
if ( value != null ) {
Arrays.fill( result, true );
}
return result;
}
@Override
public boolean isDirty(
Object old,
Object current,
SharedSessionContractImplementor session) throws HibernateException {
if ( isSame( old, current ) ) {
return false;
}
Object oldid = getIdentifier( old, session );
Object newid = getIdentifier( current, session );
return getIdentifierType( session ).isDirty( oldid, newid, session );
}
@Override
public boolean isDirty(
Object old,
Object current,
boolean[] checkable,
SharedSessionContractImplementor session) throws HibernateException {
if ( isAlwaysDirtyChecked() ) {
return isDirty( old, current, session );
}
else {
if ( isSame( old, current ) ) {
return false;
}
Object oldid = getIdentifier( old, session );
Object newid = getIdentifier( current, session );
return getIdentifierType( session ).isDirty( oldid, newid, checkable, session );
}
}
}
| [
"[email protected]"
] | |
b885df9abe0d4a8997b414049e516801ed7fd473 | 0803259ff60f66cf5d0fe42b7e0ece6a70689a8d | /AP CSA HW/src/ashwin/manur/APCSA/hw/Chapter2/HelloGui/HelloGraphics.java | f87e0a1a12dbf5609e0635efeb5e92212280eb31 | [] | no_license | MeepManur383/Source-Code | 714f0843297b8969f5203b8ed016958ddd8db9f4 | 685583abf9ce95723a5805076f4c2f65876bf8d9 | refs/heads/master | 2020-04-24T20:22:13.373816 | 2019-06-09T21:08:53 | 2019-06-09T21:08:53 | 172,240,831 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,287 | java | package ashwin.manur.APCSA.hw.Chapter2.HelloGui;
// This program displays simple graphics
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class HelloGraphics extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g); // Call JPanel's paintComponent method
// to paint the background
g.setColor(Color.RED);
// Draw a 150 by 45 rectangle with the upper-left
// corner at x = 20, y = 40:
g.drawRect(20, 40, 150, 45);
g.setColor(Color.BLUE);
// Draw a string of text starting at x = 55, y = 65:
g.drawString("Hello, Graphics!", 55, 65);
}
public static void main(String[] args)
{
JFrame window = new JFrame("Graphics Demo");
// Set this window's location and size:
// upper-left corner at 300, 300; width 200, height 150
window.setBounds(300, 300, 200, 150);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
HelloGraphics panel = new HelloGraphics();
panel.setBackground(Color.WHITE); // the default color is light gray
Container c = window.getContentPane();
c.add(panel);
window.setVisible(true);
}
}
| [
"[email protected]"
] | |
0ff9137e3bfc7130f6fb6e25b66f8185d3538e6c | bacd2beb8d5f9c3d19e6219d24c5d8dc73245d08 | /library/src/main/java/com/fanchen/zxing/camera/CameraConfigurationManager.java | 0e492cb7945143a2f6ffd26e2595e77fe23b9d25 | [] | no_license | nino9012/Imui | aa5a3d1037835dcb1d63b0d62cb9872ab32057a1 | 0750fa0f68fdb3ed637065c77ab40e70b015ca84 | refs/heads/master | 2022-12-06T00:11:24.866824 | 2020-08-25T01:59:11 | 2020-08-25T01:59:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,212 | java | /*
* Copyright (C) 2010 ZXing 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 com.fanchen.zxing.camera;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.hardware.Camera;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import com.fanchen.zxing.camera.open.CameraFacing;
import com.fanchen.zxing.camera.open.OpenCamera;
/**
* A class which deals with reading, parsing, and setting the camera parameters which are used to
* configure the camera hardware.
*/
@SuppressWarnings("deprecation") // camera APIs
final class CameraConfigurationManager {
private static final String TAG = "CameraConfiguration";
private final Context context;
private int cwNeededRotation;
private int cwRotationFromDisplayToCamera;
private Point screenResolution;
private Point cameraResolution;
private Point bestPreviewSize;
private Point previewSizeOnScreen;
CameraConfigurationManager(Context context) {
this.context = context;
}
/**
* Reads, one time, values from the camera that are needed by the app.
*/
public void initFromCameraParameters(OpenCamera camera) {
Camera.Parameters parameters = camera.getCamera().getParameters();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
int displayRotation = display.getRotation();
int cwRotationFromNaturalToDisplay;
switch (displayRotation) {
case Surface.ROTATION_0:
cwRotationFromNaturalToDisplay = 0;
break;
case Surface.ROTATION_90:
cwRotationFromNaturalToDisplay = 90;
break;
case Surface.ROTATION_180:
cwRotationFromNaturalToDisplay = 180;
break;
case Surface.ROTATION_270:
cwRotationFromNaturalToDisplay = 270;
break;
default:
// Have seen this return incorrect values like -90
if (displayRotation % 90 == 0) {
cwRotationFromNaturalToDisplay = (360 + displayRotation) % 360;
} else {
throw new IllegalArgumentException("Bad rotation: " + displayRotation);
}
}
Log.i(TAG, "Display at: " + cwRotationFromNaturalToDisplay);
int cwRotationFromNaturalToCamera = camera.getOrientation();
Log.i(TAG, "Camera at: " + cwRotationFromNaturalToCamera);
// Still not 100% sure about this. But acts like we need to flip this:
if (camera.getFacing() == CameraFacing.FRONT) {
cwRotationFromNaturalToCamera = (360 - cwRotationFromNaturalToCamera) % 360;
Log.i(TAG, "Front camera overriden to: " + cwRotationFromNaturalToCamera);
}
cwRotationFromDisplayToCamera =
(360 + cwRotationFromNaturalToCamera - cwRotationFromNaturalToDisplay) % 360;
Log.i(TAG, "Final display orientation: " + cwRotationFromDisplayToCamera);
if (camera.getFacing() == CameraFacing.FRONT) {
Log.i(TAG, "Compensating rotation for front camera");
cwNeededRotation = (360 - cwRotationFromDisplayToCamera) % 360;
} else {
cwNeededRotation = cwRotationFromDisplayToCamera;
}
Log.i(TAG, "Clockwise rotation from display to camera: " + cwNeededRotation);
Point theScreenResolution = new Point();
display.getSize(theScreenResolution);
screenResolution = theScreenResolution;
Log.i(TAG, ">>>>>>>Screen resolution in current orientation: " + screenResolution);
cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, ">>>>>>>Camera resolution: " + cameraResolution);
bestPreviewSize = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolution);
Log.i(TAG, ">>>>>>>Best available preview size: " + bestPreviewSize);
boolean isScreenPortrait = screenResolution.x < screenResolution.y;
boolean isPreviewSizePortrait = bestPreviewSize.x < bestPreviewSize.y;
if (isScreenPortrait == isPreviewSizePortrait) {
previewSizeOnScreen = bestPreviewSize;
} else {
previewSizeOnScreen = new Point(bestPreviewSize.y, bestPreviewSize.x);
}
Log.i(TAG, ">>>>>>>Preview size on screen: " + previewSizeOnScreen);
}
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private Point getDisplaySize(final Display display) {
final Point point = new Point();
try {
display.getSize(point);
} catch (NoSuchMethodError ignore) {
point.x = display.getWidth();
point.y = display.getHeight();
}
return point;
}
void setDesiredCameraParameters(OpenCamera camera, boolean safeMode) {
Camera theCamera = camera.getCamera();
Camera.Parameters parameters = theCamera.getParameters();
if (parameters == null) {
Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration.");
return;
}
Log.i(TAG, "Initial camera parameters: " + parameters.flatten());
if (safeMode) {
Log.w(TAG, "In camera config safe mode -- most settings will not be honored");
}
parameters.setPreviewSize(bestPreviewSize.x, bestPreviewSize.y);
theCamera.setParameters(parameters);
theCamera.setDisplayOrientation(cwRotationFromDisplayToCamera);
Camera.Parameters afterParameters = theCamera.getParameters();
Camera.Size afterSize = afterParameters.getPreviewSize();
if (afterSize != null && (bestPreviewSize.x != afterSize.width || bestPreviewSize.y != afterSize.height)) {
Log.w(TAG, "Camera said it supported preview size " + bestPreviewSize.x + 'x' + bestPreviewSize.y +
", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height);
bestPreviewSize.x = afterSize.width;
bestPreviewSize.y = afterSize.height;
}
}
Point getBestPreviewSize() {
return bestPreviewSize;
}
Point getPreviewSizeOnScreen() {
return previewSizeOnScreen;
}
Point getCameraResolution() {
return cameraResolution;
}
Point getScreenResolution() {
return screenResolution;
}
int getCWNeededRotation() {
return cwNeededRotation;
}
boolean getTorchState(Camera camera) {
if (camera != null) {
Camera.Parameters parameters = camera.getParameters();
if (parameters != null) {
String flashMode = parameters.getFlashMode();
return flashMode != null &&
(Camera.Parameters.FLASH_MODE_ON.equals(flashMode) ||
Camera.Parameters.FLASH_MODE_TORCH.equals(flashMode));
}
}
return false;
}
}
| [
"[email protected]"
] | |
75fd23c9605b18e3d4710368aadc37c4fc0ae867 | b9a17e089dbfdd8d2b519593232aec2003c54e02 | /com/comcast/test/app/testCases/userManagement/userRegistration/UserRegistrationTestCasesForCreditCardDetails/UserRegWithNoPINCode/RegisterToXidioApplicationWithNoPinCode.java | 3ecc55ab3451ee98713d908db18072a77a012e7a | [] | no_license | sandeeptiku2012/ComcastNewFW | a7f6146b6a0fb0161a413b29eebd6102c08cb5c8 | 30620b76c8181360934d1de735aa65f2dcdb12d0 | refs/heads/master | 2021-01-19T15:33:33.511448 | 2013-07-10T14:51:25 | 2013-07-10T14:51:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,869 | java | package comcast.test.app.testCases.userManagement.userRegistration.UserRegistrationTestCasesForCreditCardDetails.UserRegWithNoPINCode;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.By;
import comcast.test.config.configServices.DataServiceProperties;
import comcast.test.config.configServices.utils.BaseTest;
import comcast.test.app.common.userManagement.userRegistration.common.UserRegistrationFunction;
import comcast.test.app.common.userManagement.userRegistration.common.UserRegistrationValidationFuncitons;
/** Class Name: RegisterToXidioApplicationWithNoPinCode
* Description: This test case is for user registration to comcast application
* without entering pin code
* **/
public class RegisterToXidioApplicationWithNoPinCode extends BaseTest{
UserRegistrationFunction useRegFun=new UserRegistrationFunction();
UserRegistrationValidationFuncitons userRegVal=new UserRegistrationValidationFuncitons();
@Test
public void testRegisterToXidioApplicationWithNoPincode() throws Exception {
driver.get(DataServiceProperties.APPURL);
Thread.sleep(sleepTime);
driver.findElement(By.linkText("Register")).click();
Thread.sleep(sleepTime);
//This method is used to enter registration fields details
useRegFun.RegistrationDetails(driver);
driver.findElement(By.name("terms_conditions")).click();
driver.findElement(By.linkText("Next")).click();
Thread.sleep(sleepTime);
//This method is used to verify that Pin code is mandatory field
userRegVal.ValidatePinCodeMandatoryField(driver);
Thread.sleep(sleepTime);
driver.findElement(By.linkText("Next")).click();
assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*Create-pin code is required[\\s\\S]*$"));
}
}
| [
"[email protected]"
] | |
96422dea1d390623afe61abc7d29f6958029c1dd | eaecaa951bc07dc583e17541c21ea7382c057695 | /app/src/main/java/com/techmighty/rupeeexchangeprocess/ContentFragment.java | a9002cb5703eb3844e15a878cf3b045564b751cc | [] | no_license | variaankitb/RupeeExchangeProcess | 791b2e2f8226b0081847c844ec33ab7779745a17 | 0e52974b048e347518a0f159bcebd1cddfb013d5 | refs/heads/master | 2021-06-07T20:18:32.035440 | 2016-11-10T17:07:24 | 2016-11-10T17:07:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,404 | java | package com.techmighty.rupeeexchangeprocess;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by avaria on 09/11/16.
*/
public class ContentFragment extends Fragment {
public ContentFragment() {
}
public static Fragment newInstance(String title, int position) {
Bundle args = new Bundle();
args.putString("title", title);
args.putInt("position", position);
ContentFragment fragment = new ContentFragment();
fragment.setArguments(args);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_content, container, false);
initRecyclerView(view);
return view;
}
private void initRecyclerView(View view) {
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.content_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(new ContentAdapter(getActivity()));
}
}
| [
"[email protected]"
] | |
43084b1d5ccfb524a1a0008fc46375bf0eb650e8 | 0c9e245c8cac1b0553c5450983243e313b081dd8 | /src/main/java/file_randomaccessfile/TestFile.java | 3fae0cf0b9ab706f3735d1c1cb202b97850bbe01 | [] | no_license | simonZ0919/JSD1902_SE | 4ac92ccbc7b08ab2597260fcad7e0090fab25b54 | b9053e1d70959e4fc4bcdadb65726f49a6d592e4 | refs/heads/master | 2021-08-17T19:40:10.112036 | 2019-06-09T12:47:02 | 2019-06-09T12:47:02 | 191,005,623 | 0 | 0 | null | 2020-06-06T05:53:46 | 2019-06-09T12:47:59 | Java | UTF-8 | Java | false | false | 1,421 | java | package file_randomaccessfile;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
public class TestFile {
public static void main(String[] args) throws IOException {
/**
* file properties: getname(), length, canRead, isHidden....
*/
File file1=new File("./test.txt");
System.out.println("name:"+file1.getName()+
"\tlength:"+file1.length());
System.out.println("readable:"+file1.canRead()+"\twritable:"+
file1.canWrite()+"\thidden:"+file1.isHidden());
/**
* createNewFile(), delete
*/
File file2=new File("./NewFile.txt");
file2.createNewFile();
file2.delete();
// recursively delete folder
File dir1=new File("./New Folder");
deleteAll(dir1);
// file filter, lambda expression
File dir2=new File(".");
File[] subdir2=dir2.listFiles((file)->
(file).getName().startsWith("."));
for (File file : subdir2) {
System.out.println(file.getName());
}
}
/*
* mkdir(): current folder; mkdirs(): create parent folder also
* delete(): empty folder only
* isFile(), isDirectory(), exist()
* listFiles(); list all subfilee in File[]
*/
public static void deleteAll(File f) {
if (f.isDirectory()) {
File[] subs=f.listFiles();
for (int i = 0; i < subs.length; i++) {
deleteAll(subs[i]);
subs[i].delete();// iteration
}
}
f.delete();
return;
}
}
| [
"simon"
] | simon |
04ad32a15d281beed137f9a81e9af12f3cd2ff9e | 17e8438486cb3e3073966ca2c14956d3ba9209ea | /dso/tags/2.2.1-stable/code/base/common/tests.base/com/tc/config/schema/test/SpringApplicationConfigBuilderImpl.java | 83963a807fea684f37aba13425b8d30d5fad067e | [] | no_license | sirinath/Terracotta | fedfc2c4f0f06c990f94b8b6c3b9c93293334345 | 00a7662b9cf530dfdb43f2dd821fa559e998c892 | refs/heads/master | 2021-01-23T05:41:52.414211 | 2015-07-02T15:21:54 | 2015-07-02T15:21:54 | 38,613,711 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,775 | java | /*
* All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
*/
package com.tc.config.schema.test;
import com.tc.config.schema.builder.SpringApplicationConfigBuilder;
import com.tc.config.schema.builder.SpringApplicationContextConfigBuilder;
import java.util.Collections;
public class SpringApplicationConfigBuilderImpl extends BaseConfigBuilder implements SpringApplicationConfigBuilder {
private String name;
protected SpringApplicationConfigBuilderImpl() {
super(4, new String[] { "application-contexts" });
}
public static SpringApplicationConfigBuilderImpl newMinimalInstance() {
SpringApplicationConfigBuilderImpl result = new SpringApplicationConfigBuilderImpl();
result.setApplicationContexts(new SpringApplicationContextConfigBuilder[] { SpringApplicationContextConfigBuilderImpl.newMinimalInstance() });
return result;
}
public String toString() {
return openElement("jee-application", Collections.singletonMap("name", name))
+ openElement("application-contexts")
+ propertyAsString("application-contexts")
+ closeElement("application-contexts")
+ closeElement("jee-application");
}
public SpringApplicationContextConfigBuilder[] getApplicationContexts() {
if (isSet("application-contexts")) return (SpringApplicationContextConfigBuilder[]) ((SelfTaggingArray) getRawProperty("application-contexts"))
.values();
else return null;
}
public void setApplicationContexts(SpringApplicationContextConfigBuilder[] applications) {
setProperty("application-contexts", selfTaggingArray(applications));
}
public void setName(String name) {
this.name = name;
}
}
| [
"jvoegele@7fc7bbf3-cf45-46d4-be06-341739edd864"
] | jvoegele@7fc7bbf3-cf45-46d4-be06-341739edd864 |
f364c058ae1e9846506cdc249760c30bf48731bd | fe42eac3d625fb8bb0ec4e5c9027e582cf00e176 | /mneg-infra/mneg-infra-seguridad/src/test/java/test/mx/mneg/infra/seguridad/util/SeguridadUtilTest.java | 2258205961fedd583c830750c7ab754af1c329cd | [] | no_license | alex-pi/plataforma-spring-mnegocio | 94925c6e748e18e820e549bb5f6c87f17f31691a | b85f4b15be09f49c83dcb38ee274b2b743319934 | refs/heads/master | 2021-01-22T01:58:02.080683 | 2012-11-19T05:12:18 | 2012-11-19T05:12:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 464 | java | package test.mx.mneg.infra.seguridad.util;
import org.junit.Assert;
import org.junit.Test;
import test.mx.mneg.infra.seguridad.SeguridadBaseTest;
import com.mx.mneg.infra.modelo.UsuarioSeguridad;
import com.mx.mneg.infra.utils.seguridad.SeguridadUtil;
public class SeguridadUtilTest extends SeguridadBaseTest {
@Test
public void getUsuarioActualTest(){
UsuarioSeguridad usuario = SeguridadUtil.getUsuarioActual();
Assert.assertNotNull(usuario);
}
}
| [
"[email protected]"
] | |
e5de2572733ec27709c0b05d1646937f80f03501 | 9cf7f6b8108a0927b4a6c429c6d8d64552288838 | /ql_hs/app/src/main/java/com/example/administrator/ql_hs/hocsinh.java | 3667f9ebb4e0c12872abf5cbcba81a9c798ca95e | [] | no_license | tuanhuy333/Android | afce425c361a99eee401616281f1ffc8d597c38e | fe21981c180e81c71f29f10025ea94669e108382 | refs/heads/master | 2020-12-01T17:20:01.038476 | 2020-07-10T00:40:33 | 2020-07-10T00:40:33 | 230,707,242 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 870 | java | package com.example.administrator.ql_hs;
import java.io.Serializable;
public class hocsinh implements Serializable {
private int id;
private String ten;
private String lop;
private float diem;
public hocsinh(int id, String ten, String lop, float diem) {
this.id = id;
this.ten = ten;
this.lop = lop;
this.diem = diem;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTen() {
return ten;
}
public void setTen(String ten) {
this.ten = ten;
}
public String getLop() {
return lop;
}
public void setLop(String lop) {
this.lop = lop;
}
public float getDiem() {
return diem;
}
public void setDiem(float diem) {
this.diem = diem;
}
}
| [
"[email protected]"
] | |
d45e196040e05b11204ba8fd4217ae764bf1bbbf | fe12be554f4a0595c6832f6b5b6e9f0f706a0721 | /src/main/java/bammerbom/ultimatecore/bukkit/commands/CmdDelwarp.java | 1b42d994dc9da94d5ab6cf3a9086b91a1b26b02c | [] | no_license | UnfixableExploit/UltimateCore | 9150cb5ca8b3e9e6b5356b53ad575bc14b0fb8e9 | 71022cb421e6393eb2bfb2edbf980f939f727f56 | refs/heads/master | 2020-12-25T20:42:22.533579 | 2015-12-05T17:18:47 | 2015-12-05T17:18:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,664 | java | /*
* This file is part of UltimateCore, licensed under the MIT License (MIT).
*
* Copyright (c) Bammerbom
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package bammerbom.ultimatecore.bukkit.commands;
import bammerbom.ultimatecore.bukkit.UltimateCommand;
import bammerbom.ultimatecore.bukkit.api.UC;
import bammerbom.ultimatecore.bukkit.r;
import bammerbom.ultimatecore.bukkit.resources.utils.StringUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
import java.util.List;
public class CmdDelwarp implements UltimateCommand {
@Override
public String getName() {
return "delwarp";
}
@Override
public String getPermission() {
return "uc.delwarp";
}
@Override
public List<String> getAliases() {
return Arrays.asList("remwarp", "removewarp");
}
@Override
public void run(final CommandSender cs, String label, String[] args) {
if (!r.perm(cs, "uc.delwarp", false, true)) {
return;
}
if (!r.checkArgs(args, 0)) {
r.sendMes(cs, "delwarpUsage");
return;
}
if (!StringUtil.containsIgnoreCase(UC.getServer().getWarpNames(), args[0])) {
r.sendMes(cs, "warpNotExist", "%Warp", args[0]);
return;
}
UC.getServer().removeWarp(args[0]);
r.sendMes(cs, "delwarpMessage", "%Warp", args[0]);
}
@Override
public List<String> onTabComplete(CommandSender cs, Command cmd, String alias, String[] args, String curs, Integer curn) {
return UC.getServer().getWarpNames();
}
}
| [
"[email protected]"
] | |
a05e1989d7a6e57403879a1e23038b40e486cd6e | 25fe97be9ab07f6583aa1548433db99ef8aaaf3d | /src/com/example/batterymeasure/BatteryService.java | 9f391b16db627391930a634203ebf9bde497fd75 | [] | no_license | wzWang1991/AndroidBattery | 4c7231e4dfc85a7184b26822728a6ce1e4f60d86 | 20393d95aed94482b844f1819aaf38e83eb80160 | refs/heads/master | 2020-04-09T05:24:13.751240 | 2013-12-03T04:06:56 | 2013-12-03T04:06:56 | 12,939,145 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,881 | java | package com.example.batterymeasure;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import android.app.AlertDialog;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.text.format.DateFormat;
import android.widget.TextView;
public class BatteryService extends Service {
public static final String TAG = "BatteryServiceTAG";
private int level;
private int scale;
private BatteryInfoBroadcastReceiver receiver = new BatteryInfoBroadcastReceiver(){
public void onReceive(Context context, Intent intent){
level = intent.getIntExtra("level", 0);
scale = intent.getIntExtra("scale", 100);
sendBatteryConsumption(level,scale);
}
};
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
//set filter for broadcast, only receive ACTION_BATTERY_CHANGED
@Override
public void onStart(Intent intent, int startID){
IntentFilter batteryReceiveFilter = new IntentFilter();
batteryReceiveFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(receiver, batteryReceiveFilter);
}
public void onDestroy(){
sendBatteryConsumption(level,scale);
unregisterReceiver(receiver);
}
private void sendBatteryConsumption(int level, int scale) {
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date nowTime = new Date();
String nowTimeString = df.format(nowTime);
Intent ittmp = new Intent();
ittmp.setAction("android.intent.action.battery");
ittmp.putExtra("BATTERY_COMSUMPTION_TIME", nowTimeString);
ittmp.putExtra("BATTERY_COMSUMPTION_LEVEL", level);
ittmp.putExtra("BATTERY_COMSUMPTION_SCALE", scale);
sendBroadcast(ittmp);
}
}
| [
"[email protected]"
] | |
cd752bc62b48618db41eb2b7a54cd3b4df0e696c | 68c8f743c31322dfd5c9a56ca0089a646fbcb86b | /src/com/secondhand/fragment/FragmentMessage.java | 5811e5406970a8c1f95e11dcec49c94d2f4beaaf | [] | no_license | CapLuo/SecondHandMarket | aa5ffd27bbd7defd5e3087d12180bd4c7de5316d | 466aeec917dba25ffde791c76d07d08815081811 | refs/heads/master | 2016-09-05T22:13:00.945644 | 2015-05-05T08:23:24 | 2015-05-05T08:23:24 | 31,377,132 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 684 | java | package com.secondhand.fragment;
import com.secondhand.market.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragmentMessage extends Fragment {
private View mContentView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (mContentView == null) {
mContentView = inflater.inflate(R.layout.fragment_message,
container, false);
}
if (mContentView.getParent() != null) {
((ViewGroup) mContentView.getParent()).removeView(mContentView);
}
return mContentView;
}
}
| [
"[email protected]"
] | |
31b9b2e842ee7fcfa5432e7c27a8c2ec79ee697f | da509de2632c4720eb51ef928e07e86bd8974e1a | /bizamo-services/src/test/java/com/e3/bizamo/services/tomcat/NameDouble.java | 482f656649dfc94b3eb2c87712410784481a1d3a | [] | no_license | evgenycherny/bizamo | 9f6d3f085094e937269dc8b3231c831fe7b6261b | 65f0de94e011789e87bee24d6a7b7a111b28b2f2 | refs/heads/master | 2016-08-11T06:52:01.013707 | 2015-10-24T20:07:08 | 2015-10-24T20:07:08 | 44,881,017 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 274 | java | package com.e3.bizamo.services.tomcat;
import java.util.Enumeration;
import javax.naming.CompositeName;
public class NameDouble extends CompositeName {
private static final long serialVersionUID = 1L;
public NameDouble(Enumeration<String> comps) {
super(comps);
}
}
| [
"[email protected]"
] | |
bbbab178a6bfc65346415b09e91f03f815345628 | a924c03aeb11ebdbf7548fe63132ee9544b230e5 | /app/src/main/java/com/support/android/ukenya/Message.java | f5890dd957df5a8745cd9bcb1c4432d2e60b0ace | [
"Apache-2.0"
] | permissive | jeffandeko/ukenya | be6d86b422de9b57857673f82fce85364cdf66f0 | a722c863c106724202f41b42ae84d0855b362686 | refs/heads/master | 2021-01-24T23:58:00.135314 | 2018-03-05T17:54:37 | 2018-03-05T17:54:37 | 123,285,433 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 615 | java | package com.support.android.ukenya;
/**
* Created by Nyeri Baptist on 2/26/2018.
*/
public class Message {
private String content, username;
public Message() {
}
public Message(String content, String username) {
this.content = content;
this.username = username;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
| [
"[email protected]"
] | |
22b9f6c127e843d07a01e87a18dbbc6f46c93cc3 | 1cdcb223dc1b6320fbfd69752d3477d8f9c564ce | /MPP_Project/src/view/LibrarianHomepage.java | 10d3391dff1f16719c4e4effe48804ecdae76183 | [] | no_license | AvenashKumar92/MPP_Project | 19d4937141b86454d5d682749c51fd219038780c | 8979730ebe149c4bf73847ef50a9a4421090f2b8 | refs/heads/master | 2020-03-25T08:53:57.325791 | 2018-08-05T18:36:21 | 2018-08-05T18:36:21 | 143,636,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 535 | java | package view;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class LibrarianHomepage extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/view/LibrarianHomepage.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
| [
"[email protected]"
] | |
9134f5b206a1b20e33bded40c649ea936f4f785a | 76d569f42ce4b0ff0f00bd1972564bb80e5a19a5 | /src/edu/fjut/fundsys/exception/ClientException.java | 0a0063e0c7b7db13f11879619082b2552cb6b321 | [] | no_license | tianyuyzip/FundTradingSys | 03c713bf369c3b34bce86dc39e63b3162236dc51 | 30698966a7eb6fa66478d9aee5cc53572c55275e | refs/heads/master | 2021-07-01T04:15:55.648502 | 2017-09-22T05:58:46 | 2017-09-22T05:58:46 | 104,343,077 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 1,003 | java | /**
*
*/
package edu.fjut.fundsys.exception;
/**
* @author ÌïÓî
*
*/
public class ClientException extends RuntimeException {
/**
*
*/
public ClientException() {
// TODO Auto-generated constructor stub
}
/**
* @param message
*/
public ClientException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
/**
* @param cause
*/
public ClientException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
/**
* @param message
* @param cause
*/
public ClientException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
/**
* @param message
* @param cause
* @param enableSuppression
* @param writableStackTrace
*/
public ClientException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
// TODO Auto-generated constructor stub
}
}
| [
"[email protected]"
] | |
ddb24971089e14fc21668c652ada82c4392d3b63 | e1817d23fd89d57e0f31927202d2a4732328e129 | /reliable-messaging-service/src/main/java/com/honghao/cloud/message/client/hystrix/OrderFallbackFactory.java | ec99e05d9149d6a1f0751fb11c8a7056bc4d80f1 | [] | no_license | chenhonghaovip/spring-project | d25b20a42af6eb9fe61f266a8fa410ddba929ada | 38a18e96c60a0b7dd89dded1ea65586be11c03b1 | refs/heads/master | 2022-07-02T22:55:38.479939 | 2020-12-22T01:46:29 | 2020-12-22T01:46:29 | 197,159,775 | 0 | 0 | null | 2022-06-21T04:05:41 | 2019-07-16T09:08:25 | Java | UTF-8 | Java | false | false | 716 | java | package com.honghao.cloud.message.client.hystrix;
import com.honghao.cloud.basic.common.base.BaseResponse;
import com.honghao.cloud.message.client.OrderClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 熔断降级配置
*
* @author chenhonghao
* @date 2019-07-31 13:24
*/
@Slf4j
@Component
public class OrderFallbackFactory implements FallbackFactory<OrderClient> {
@Override
public OrderClient create(Throwable cause) {
return new OrderClient() {
@Override
public BaseResponse queryStatus(long msgId) {
return BaseResponse.error();
}
};
}
}
| [
"[email protected]"
] | |
737d3812141807a913965a09526b1b2927f2622a | 5102f47e6c26ea57c33187066c5354588c8d908f | /app/src/main/java/com/winwang/wanandroid/http/RetrofitCache.java | 11110cc60ca9cb840a51c1314b47b85a333b5445 | [] | no_license | WinWang/wanAndroid | df2e73e779aa21f3fed993933adb4c676b4982f9 | 369eb79150a5d276e86e7909118567d455c208b6 | refs/heads/master | 2022-11-15T16:05:03.258641 | 2022-11-01T14:49:09 | 2022-11-01T14:49:09 | 141,439,743 | 20 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,326 | java | package com.winwang.wanandroid.http;
import android.content.Context;
import android.text.TextUtils;
import cn.droidlover.xdroidmvp.cache.DiskCache;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.FlowableEmitter;
import io.reactivex.FlowableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by helin on 2016/11/10 10:41.
*/
public class RetrofitCache {
/**
* @param cacheKey 缓存的Key
* @param fromNetwork
* @param isSave 是否缓存
* @return
*/
public static Flowable<String> load(final Context context,
final String cacheKey,
Flowable<String> fromNetwork,
boolean isSave
) {
Flowable<String> fromCache = Flowable.create(new FlowableOnSubscribe<String>() {
@Override
public void subscribe(FlowableEmitter<String> e) throws Exception {
String cacheString = DiskCache.getInstance(context).get(cacheKey);
if (!TextUtils.isEmpty(cacheString)) {
e.onNext(cacheString);
e.onComplete();
} else {
e.onComplete();
}
}
}, BackpressureStrategy.BUFFER
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
//强制刷新
if (!isSave) {
return fromNetwork;
} else {
// return Observable.concat(fromCache, fromNetwork).takeFirst();
Flowable<String> stringObservable = Flowable.concat(fromCache, fromNetwork);
return stringObservable;
}
}
}
| [
"[email protected]"
] | |
2a245c7575b1e27b06c63c25c4de7c97edee13c3 | 31f609157ae46137cf96ce49e217ce7ae0008b1e | /bin/ext-commerce/commercefacades/src/de/hybris/platform/commercefacades/voucher/impl/DefaultVoucherFacade.java | 5d369e2624478d0c63b23b97237d4ca3a012ba26 | [] | no_license | natakolesnikova/hybrisCustomization | 91d56e964f96373781f91f4e2e7ca417297e1aad | b6f18503d406b65924c21eb6a414eb70d16d878c | refs/heads/master | 2020-05-23T07:16:39.311703 | 2019-05-15T15:08:38 | 2019-05-15T15:08:38 | 186,672,599 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,985 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
*
* This software is the confidential and proprietary information of SAP
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with SAP.
*/
package de.hybris.platform.commercefacades.voucher.impl;
import de.hybris.platform.commercefacades.voucher.VoucherFacade;
import de.hybris.platform.commercefacades.voucher.data.VoucherData;
import de.hybris.platform.commercefacades.voucher.exceptions.VoucherOperationException;
import de.hybris.platform.core.model.order.CartModel;
import de.hybris.platform.jalo.order.price.JaloPriceFactoryException;
import de.hybris.platform.order.CartService;
import de.hybris.platform.servicelayer.dto.converter.Converter;
import de.hybris.platform.voucher.VoucherModelService;
import de.hybris.platform.voucher.VoucherService;
import de.hybris.platform.voucher.model.VoucherModel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
/**
* Default implementation of {@link VoucherFacade}.
*/
public class DefaultVoucherFacade implements VoucherFacade
{
private static final Logger LOG = Logger.getLogger(DefaultVoucherFacade.class);
private VoucherService voucherService;
private VoucherModelService voucherModelService;
private CartService cartService;
private Converter<VoucherModel, VoucherData> voucherConverter;
@Override
public boolean checkVoucherCode(final String voucherCode)
{
if (StringUtils.isBlank(voucherCode))
{
return false;
}
final VoucherModel voucher = getVoucherService().getVoucher(voucherCode);
if (voucher == null)
{
return false;
}
return checkVoucherCanBeRedeemed(voucher, voucherCode);
}
@Override
public VoucherData getVoucher(final String voucherCode) throws VoucherOperationException
{
validateVoucherCodeParameter(voucherCode);
return getVoucherConverter().convert(getVoucherModel(voucherCode));
}
protected void validateVoucherCodeParameter(final String voucherCode)
{
if (StringUtils.isBlank(voucherCode))
{
throw new IllegalArgumentException("Parameter voucherCode must not be empty");
}
}
protected boolean isVoucherCodeValid(final String voucherCode)
{
final VoucherModel voucher = getVoucherService().getVoucher(voucherCode);
if (voucher == null)
{
return false;
}
return true;
}
protected boolean checkVoucherCanBeRedeemed(final VoucherModel voucher, final String voucherCode)
{
return getVoucherModelService().isApplicable(voucher, getCartService().getSessionCart())
&& getVoucherModelService().isReservable(voucher, voucherCode, getCartService().getSessionCart());
}
@Override
public void applyVoucher(final String voucherCode) throws VoucherOperationException
{
validateVoucherCodeParameter(voucherCode);
if (!isVoucherCodeValid(voucherCode))
{
throw new VoucherOperationException("Voucher not found: " + voucherCode);
}
final CartModel cartModel = getCartService().getSessionCart();
final VoucherModel voucher = getVoucherModel(voucherCode);
synchronized (cartModel)
{
if (!checkVoucherCanBeRedeemed(voucher, voucherCode))
{
throw new VoucherOperationException("Voucher cannot be redeemed: " + voucherCode);
}
else
{
try
{
if (!getVoucherService().redeemVoucher(voucherCode, cartModel))
{
throw new VoucherOperationException("Error while applying voucher: " + voucherCode);
}
//Important! Checking cart, if total amount <0, release this voucher
checkCartAfterApply(voucherCode, voucher);
return;
}
catch (final JaloPriceFactoryException e)
{
throw new VoucherOperationException("Error while applying voucher: " + voucherCode, e);
}
}
}
}
@Override
public void releaseVoucher(final String voucherCode) throws VoucherOperationException
{
validateVoucherCodeParameter(voucherCode);
final CartModel cartModel = getCartService().getSessionCart();
final VoucherModel voucher = getVoucherModel(voucherCode);
if (voucher != null && cartModel != null)
{
try
{
getVoucherService().releaseVoucher(voucherCode, cartModel);
return;
}
catch (final JaloPriceFactoryException e)
{
throw new VoucherOperationException("Couldn't release voucher: " + voucherCode, e);
}
}
}
@Override
public List<VoucherData> getVouchersForCart()
{
if (!getCartService().hasSessionCart())
{
return Collections.emptyList();
}
final CartModel cartModel = getCartService().getSessionCart();
if (cartModel != null)
{
final List<VoucherData> vouchersData = new ArrayList<VoucherData>();
final Collection<String> voucherCodes = getVoucherService().getAppliedVoucherCodes(cartModel);
for (final String code : voucherCodes)
{
try
{
vouchersData.add(getSingleVouchersByCode(code));
}
catch (final VoucherOperationException e)
{
// nothing
LOG.debug("Couldn't get data for voucher: " + code, e);
}
}
return vouchersData;
}
return Collections.emptyList();
}
/**
* Voucher cannot be redeemed Getting single voucher
*
* @param voucherCode
* @return VoucherData
*/
protected VoucherData getSingleVouchersByCode(final String voucherCode) throws VoucherOperationException
{
final VoucherModel voucherModel = getVoucherModel(voucherCode);
final VoucherData voucherData = getVoucherConverter().convert(voucherModel);
if (voucherCode.length() > 3)
{
//Serial voucher
voucherData.setVoucherCode(voucherCode);
}
return voucherData;
}
protected VoucherModel getVoucherModel(final String voucherCode) throws VoucherOperationException
{
final VoucherModel voucher = getVoucherService().getVoucher(voucherCode);
if (voucher == null)
{
throw new VoucherOperationException("Voucher not found: " + voucherCode);
}
return voucher;
}
/**
* Checking state of cart after redeem last voucher
*
* @param lastVoucherCode
*/
protected void checkCartAfterApply(final String lastVoucherCode, final VoucherModel lastVoucher)
throws VoucherOperationException
{
final CartModel cartModel = getCartService().getSessionCart();
//Total amount in cart updated with delay... Calculating value of voucher regarding to order
final double cartTotal = cartModel.getTotalPrice().doubleValue();
final double voucherValue = lastVoucher.getValue().doubleValue();
final double voucherCalcValue = (lastVoucher.getAbsolute().equals(Boolean.TRUE)) ? voucherValue
: (cartTotal * voucherValue) / 100;
if (cartModel.getTotalPrice().doubleValue() - voucherCalcValue < 0)
{
releaseVoucher(lastVoucherCode);
//Throw exception with specific information
throw new VoucherOperationException("Voucher " + lastVoucherCode + " cannot be redeemed: total price exceeded");
}
}
public VoucherService getVoucherService()
{
return voucherService;
}
@Required
public void setVoucherService(final VoucherService voucherService)
{
this.voucherService = voucherService;
}
public VoucherModelService getVoucherModelService()
{
return voucherModelService;
}
@Required
public void setVoucherModelService(final VoucherModelService voucherModelService)
{
this.voucherModelService = voucherModelService;
}
public CartService getCartService()
{
return cartService;
}
@Required
public void setCartService(final CartService cartService)
{
this.cartService = cartService;
}
public Converter<VoucherModel, VoucherData> getVoucherConverter()
{
return voucherConverter;
}
@Required
public void setVoucherConverter(final Converter<VoucherModel, VoucherData> voucherConverter)
{
this.voucherConverter = voucherConverter;
}
}
| [
"[email protected]"
] | |
b936f61e46f52a970e220ebec013f9f59d363f2e | a38f1e804a41b846c1f9dc4698e90822c89e26b4 | /src/me/lordusan/Dice.java | a33ac271519edaab72fe3fd8deb2c2b536ddefe0 | [] | no_license | jsutaria/Dice-Plugin-Minecraft | 3db24b7e2105248ca8bd39d4c71c5bfbc4b98d36 | c7ec7ec55d66ba5a66c6378b4913ea00bc11412b | refs/heads/master | 2021-01-10T09:26:21.220776 | 2016-03-06T02:24:32 | 2016-03-06T02:24:32 | 53,233,576 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,196 | java | package me.lordusan;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Dice extends JavaPlugin {
Random rand = new Random();
public void onEnable() {
}
@Override
public void onDisable() {
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("dice") && sender instanceof Player) {
Player player = (Player) sender;
if (sender.hasPermission("dice.allow")) {
if (args.length > 0) {
try
{
// the String to int conversion happens here
int num = Integer.parseInt(args[0].trim());
if (num > 100 || num < 2) {
sender.sendMessage(ChatColor.GRAY + "(" + ChatColor.BLUE + "Dice" + ChatColor.GRAY + ") " + ChatColor.LIGHT_PURPLE +
"Error: you can only have a dice from 2 - 100 sides");
}
else {
try {
player.addAttachment(this, "essentials.chat.color", true);
player.chat(ChatColor.LIGHT_PURPLE + "rolled a " + ChatColor.BLUE +
Integer.toString(rand.nextInt(num) + 1) + ChatColor.LIGHT_PURPLE + " on a " +
ChatColor.BLUE + args[0] + ChatColor.LIGHT_PURPLE + " sided dice");
player.addAttachment(this, "essentials.chat.color", false);
}
catch (Exception ex) {
ex.printStackTrace();
}
finally {player.addAttachment(this, "essentials.chat.color", false);}
}
}
catch (NumberFormatException nfe)
{
System.out.println("NumberFormatException: " + nfe.getMessage());
sender.sendMessage(ChatColor.GRAY + "(" + ChatColor.BLUE + "Dice" + ChatColor.GRAY + ") " + ChatColor.LIGHT_PURPLE +
"Error: we dont support non-number dice");
}
}
else {
sender.sendMessage(ChatColor.GRAY + "(" + ChatColor.BLUE + "Dice" + ChatColor.GRAY + ") " + ChatColor.LIGHT_PURPLE +
"Error: usage /dice <number>");
}
}
}
return true;
}
}
| [
"[email protected]"
] | |
f16da1af472cb8aa97df03810d0e698513c31c44 | 446e27c64b09d03480e3031ea866500a79623dc3 | /src/TestPoint.java | 7d31c9e43efa02818b05c064f2a400b76e37f12c | [
"MIT"
] | permissive | git-ning/thinking-in-java | a4c5831de7c5f218b53442797670d1f08e38312f | c3d6e873d0fce33a7e733af2ee24108e1c403eb4 | refs/heads/master | 2020-03-17T05:18:30.872217 | 2018-08-31T01:54:07 | 2018-08-31T01:54:07 | 133,310,850 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 888 | java | /**
* 计算三维空间的点到原点/空间中任意两点之间的距离
* @author ning
* @date 2018/03/23
*/
class Point {
double x, y, z;
//构造方法
Point(double x1, double y1, double z1) {
x = x1;
y = y1;
z = z1;
}
public void setX(double x1) {
x = x1;
}
public void setY(double y1) {
y = y1;
}
public void setZ(double z1) {
z = z1;
}
public double getDistance(Point p) {
return (x - p.x) * (x - p.x) + (y - p.y)*(y - p.y) + (z - p.z)*(z - p.z);
}
}
public class TestPoint {
public static void main(String[] args) {
Point point = new Point(1.0, 2.0, 3.0);
Point point1 = new Point(0.0, 0.0, 0.0);
System.out.println(point.getDistance(point1));
point.setX(2.0);
System.out.println(point.getDistance(point1));
}
}
| [
"[email protected]"
] | |
601670885afe6eaa1cf08176002e972123ea7154 | 3852db4b581b359898d30acf2f57a4c17e9001a9 | /dice-server/src/main/java/com/bihell/dice/service/AuthApiService.java | c38807730c00ffb5ffddf4073c9341c6f65351ab | [
"MIT"
] | permissive | HowChuang/Dice | 56e6aea3458be4c02ba503cd8a0522d59ea376c9 | c36c508f5d7cd812a898b6192977d6cfa15b50fd | refs/heads/master | 2020-12-14T20:47:19.711321 | 2020-01-16T11:00:06 | 2020-01-16T11:00:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 388 | java | package com.bihell.dice.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bihell.dice.model.domain.AuthApi;
import com.bihell.dice.model.params.QueryParam;
/**
* @author haseochen
*/
public interface AuthApiService {
/**
* 增加 api
* @param authApi
* @return
*/
void add(AuthApi authApi);
AuthApi update(AuthApi authApi);
}
| [
"[email protected]"
] | |
0f7fa47a83d888113b958daace555cbb7152fcae | 09daa3887c373e23b150e170cb68650c913fb8ed | /src/main/java/com/lyc/concurrency/HttpFilter.java | 438ede687fce4c122fe312c317ab57e0d495bb1d | [] | no_license | liyaochu/Concurrency | 42503bcdb91d47cba49f0e5513ce211cb981419b | ad8dc4a244e7d3ed80a008207b9f2ae9a51bcbc4 | refs/heads/master | 2020-04-17T03:46:08.848885 | 2019-01-26T08:31:26 | 2019-01-26T08:31:26 | 166,199,556 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 961 | java | package com.lyc.concurrency;
import com.lyc.concurrency.example.threadlocal.RequestHolder;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* @Auther: Jhon Li
* @Date: 2018/12/10 21:19
* @Description:
*/
@Slf4j
public class HttpFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
log.info("do filter,{}, {}" ,Thread.currentThread().getId(),request.getServletPath());
RequestHolder.add(Thread.currentThread().getId());
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
}
}
| [
"[email protected]"
] | |
e89bdc58f611797aa275d962ff59d1da5713fbe5 | bd867538718f93e4576c097798d3008b87804b92 | /react_book/TotoList/android/app/src/main/java/com/totolist/MainApplication.java | c724b5cc5e1e29d877459cb080e13c0f0c1688f9 | [] | no_license | seungjinhan/react_native_study | c33dbffe0bb7495769a71470250f7e8c8e16551e | 6c3091b620ae9e9446423e14892b6222c0a88d65 | refs/heads/master | 2023-01-09T01:14:07.278051 | 2020-02-21T12:54:16 | 2020-02-21T12:54:16 | 238,958,951 | 0 | 0 | null | 2023-01-05T07:24:49 | 2020-02-07T15:36:10 | TypeScript | UTF-8 | Java | false | false | 2,275 | java | package com.totolist;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
185b7133b3139f1e061a1d09734902914588dc34 | 2352a68af42217acb7aca075455ae572d474c4dc | /pinyougou-pojo/src/main/java/entity/Result.java | 98f408f9126e75889512617961561f9c4da6eaa7 | [] | no_license | liyili123/gtb | 95be5f71eda6073f5748f2becfe0b23d87be3566 | 98ce97b67506710af9ded67d82a84418e8381f8d | refs/heads/master | 2022-12-22T11:51:18.803513 | 2020-06-01T14:02:23 | 2020-06-01T14:02:23 | 213,006,625 | 1 | 0 | null | 2022-12-16T07:17:37 | 2019-10-05T13:44:29 | JavaScript | UTF-8 | Java | false | false | 549 | java | package entity;
import java.io.Serializable;
public class Result implements Serializable {
private String message;//返回信息
private boolean success;//是否成功
public Result(String message, boolean success) {
super();
this.message = message;
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}
| [
"[email protected]"
] | |
16ce70793f44302a2d06cf203187fb27d7cce218 | 1ef3d5154e6e1d249bee202c111ce528f64dba47 | /tests/org/miradi/migrations/TestMigrationTo26.java | b96de27441db8c3a23a3077a74fe0ec05fe5a457 | [] | no_license | Blychro/miradi-client | bcab8e6d845213582028799a553a879315a8664a | 4a1cc521d2eda7b2f0e51ad9011d649302bda857 | refs/heads/master | 2022-01-22T20:02:42.043641 | 2019-07-17T08:49:32 | 2019-07-17T08:49:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,768 | java | /*
Copyright 2005-2018, Foundations of Success, Bethesda, Maryland
on behalf of the Conservation Measures Partnership ("CMP").
Material developed between 2005-2013 is jointly copyright by Beneficent Technology, Inc. ("The Benetech Initiative"), Palo Alto, California.
This file is part of Miradi
Miradi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3,
as published by the Free Software Foundation.
Miradi 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 Miradi. If not, see <http://www.gnu.org/licenses/>.
*/
package org.miradi.migrations;
import org.miradi.ids.BaseId;
import org.miradi.ids.IdList;
import org.miradi.migrations.forward.MigrationTo26;
import org.miradi.objecthelpers.ORef;
import org.miradi.objecthelpers.ORefList;
import org.miradi.objecthelpers.ObjectType;
import org.miradi.objects.Strategy;
import org.miradi.objects.Task;
import org.miradi.project.Project;
import org.miradi.schemas.TaskSchema;
import static org.miradi.objects.Strategy.TAG_ACTIVITY_IDS;
public class TestMigrationTo26 extends AbstractTestMigration
{
public TestMigrationTo26(String name)
{
super(name);
}
public void testChildTasksMovedByForwardMigration() throws Exception
{
Strategy strategy = getProject().createStrategy();
Task activity = getProject().createTask(strategy);
Task childTask = getProject().createTask(activity);
Task grandchildTask = getProject().createTask(childTask);
assertEquals(strategy.getActivityRefs(), new ORefList(activity.getRef()));
assertEquals(activity.getChildTaskRefs(), new ORefList(childTask.getRef()));
assertEquals(childTask.getChildTaskRefs(), new ORefList(grandchildTask.getRef()));
RawProject rawProject = reverseMigrate(new VersionRange(MigrationTo26.VERSION_TO));
migrateProject(rawProject, new VersionRange(Project.VERSION_HIGH));
RawPool strategyPool = rawProject.getRawPoolForType(ObjectType.STRATEGY);
assertNotNull(strategyPool);
assertEquals(strategyPool.keySet().size(), 1);
RawObject rawStrategy = strategyPool.get(strategyPool.keySet().toArray()[0]);
assertNotNull(rawStrategy);
assertTrue(rawStrategy.containsKey(TAG_ACTIVITY_IDS));
IdList activityIdList = new IdList(TaskSchema.getObjectType(), rawStrategy.get(TAG_ACTIVITY_IDS));
assertEquals(activityIdList, new IdList(activity));
RawPool taskPool = rawProject.getRawPoolForType(ObjectType.TASK);
assertNotNull(taskPool);
assertEquals(taskPool.keySet().size(), 3);
for(ORef taskRef : taskPool.keySet())
{
RawObject rawTask = taskPool.get(taskRef);
BaseId taskId = taskRef.getObjectId();
if (taskId.equals(activity.getId()))
{
IdList childTaskIdList = new IdList(TaskSchema.getObjectType(), rawTask.get(MigrationTo26.TAG_SUBTASK_IDS));
assertEquals(childTaskIdList, new IdList(ObjectType.TASK, new BaseId[]{childTask.getId(), grandchildTask.getId()}));
}
if (taskId.equals(childTask.getId()))
{
IdList grandchildTaskIdList = new IdList(TaskSchema.getObjectType(), rawTask.get(MigrationTo26.TAG_SUBTASK_IDS));
assertEquals(grandchildTaskIdList, new IdList(ObjectType.TASK, new BaseId[]{}));
}
if (taskId.equals(grandchildTask.getId()))
{
assertFalse(rawTask.containsKey(MigrationTo26.TAG_SUBTASK_IDS));
}
}
}
public void testChildTasksNotMovedByReverseMigration() throws Exception
{
Strategy strategy = getProject().createStrategy();
Task activity = getProject().createTask(strategy);
Task childTask = getProject().createTask(activity);
Task grandchildTask = getProject().createTask(childTask);
assertEquals(strategy.getActivityRefs(), new ORefList(activity.getRef()));
assertEquals(activity.getChildTaskRefs(), new ORefList(childTask.getRef()));
assertEquals(childTask.getChildTaskRefs(), new ORefList(grandchildTask.getRef()));
RawProject rawProject = reverseMigrate(new VersionRange(MigrationTo26.VERSION_TO));
RawPool strategyPool = rawProject.getRawPoolForType(ObjectType.STRATEGY);
assertNotNull(strategyPool);
assertEquals(strategyPool.keySet().size(), 1);
RawObject rawStrategy = strategyPool.get(strategyPool.keySet().toArray()[0]);
assertNotNull(rawStrategy);
assertTrue(rawStrategy.containsKey(TAG_ACTIVITY_IDS));
IdList activityIdList = new IdList(TaskSchema.getObjectType(), rawStrategy.get(TAG_ACTIVITY_IDS));
assertEquals(activityIdList, new IdList(activity));
RawPool taskPool = rawProject.getRawPoolForType(ObjectType.TASK);
assertNotNull(taskPool);
assertEquals(taskPool.keySet().size(), 3);
for(ORef taskRef : taskPool.keySet())
{
RawObject rawTask = taskPool.get(taskRef);
BaseId taskId = taskRef.getObjectId();
if (taskId.equals(activity.getId()))
{
IdList childTaskIdList = new IdList(TaskSchema.getObjectType(), rawTask.get(MigrationTo26.TAG_SUBTASK_IDS));
assertEquals(childTaskIdList, new IdList(ObjectType.TASK, new BaseId[]{childTask.getId()}));
}
if (taskId.equals(childTask.getId()))
{
IdList grandchildTaskIdList = new IdList(TaskSchema.getObjectType(), rawTask.get(MigrationTo26.TAG_SUBTASK_IDS));
assertEquals(grandchildTaskIdList, new IdList(ObjectType.TASK, new BaseId[]{grandchildTask.getId()}));
}
if (taskId.equals(grandchildTask.getId()))
{
assertFalse(rawTask.containsKey(MigrationTo26.TAG_SUBTASK_IDS));
}
}
}
@Override
protected int getFromVersion()
{
return MigrationTo26.VERSION_FROM;
}
@Override
protected int getToVersion()
{
return MigrationTo26.VERSION_TO;
}
}
| [
"[email protected]"
] | |
9e17f3ca2d205bb8b4c26f5a9de0ca8f6f509b59 | bcdbfbec231b76d60ee0da4f46835f53f9588f2e | /Hello World/src/HelloWorld.java | 53a4f23effb3b2d38e44131ee5a5dfedf0d082f4 | [] | no_license | Aortz/CZ2002 | 68dbcb102044a12e04c426c86ecc631cb942cc60 | bdd07c020d3e9000c842cfd33e4ac5c83f857e60 | refs/heads/master | 2023-08-25T02:51:32.207379 | 2021-10-11T15:30:20 | 2021-10-11T15:30:20 | 415,968,227 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 701 | java | public class HelloWorld {
public static void main(String[] args) {
int result = 1+2; // result should be 3
// this is a comment
System.out.println("1 + 2 = " + result);
result++;
System.out.println(result%3);
double first = 20.00d;
double second = 80.00d;
double third = (first+second)*100.00d;
double fourth = third % 40.00d;
boolean isNoRemainder = (fourth == 0)? true : false;
System.out.println("isNoRemainder = " + isNoRemainder);
if(isNoRemainder) {
System.out.println("No Remainder");
}
else{
System.out.println("Got some remainder");
}
}
}
| [
"[email protected]"
] | |
b55e6d8f3150fd591ec918a5bf3cc2ba5075f8ff | 33694bd693c6a3985a7194b5b20017791432dc61 | /3 java file scraped.java | 0f22cba62b37dcae2454a067d393a762ab672c80 | [] | no_license | heros1sport/SimpleJavaPrograms | 083d4b70a00dfdb13f3569ba8ad4225b5d3571b6 | 702482815ad854032b2f5e2391783d63205a63c3 | refs/heads/main | 2023-01-09T23:57:37.523109 | 2020-11-15T11:20:46 | 2020-11-15T11:20:46 | 313,014,100 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 652 | java | import java.util.Scanner;
public class Count_One
{
public static void main(String[] args)
{
int n, m, count = 0;
String x = "";
Scanner s = new Scanner(System.in);
System.out.print("Enter the Decimal Number:");
n = s.nextInt();
while(n > 0)
{
int a = n % 2;
x = a + x;
n = n / 2;
}
int l = x.length();
for(int i = 0; i < l; i++)
{
if(x.charAt(i) == '1')
{
count++;
}
}
System.out.println("No. of 1's are:"+count);
}
}
| [
"[email protected]"
] | |
c0461bfbc2c5e861a518c585e9a25c1e3a728007 | 4f8132a0096046eeb91da006e8757f975ce68f27 | /sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/HiveAuthzBindingHookV2.java | febe133642d3d2314367ab422572de3b7d456d38 | [
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"MIT"
] | permissive | sundapeng/incubator-sentry | f015e1b2bbc63831b2a135e22ca8c30c6e8ff9ad | 866de365d29e219b261b56fbebdedae47cff52c8 | refs/heads/hive_plugin_v2_dp | 2021-01-21T02:37:49.714174 | 2015-11-24T02:20:45 | 2015-11-24T02:20:45 | 39,749,330 | 0 | 0 | null | 2016-02-22T03:07:33 | 2015-07-27T01:37:28 | Java | UTF-8 | Java | false | false | 7,799 | 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.sentry.binding.hive.v2;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.util.List;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.exec.DDLTask;
import org.apache.hadoop.hive.ql.exec.SentryFilterDDLTask;
import org.apache.hadoop.hive.ql.exec.Task;
import org.apache.hadoop.hive.ql.metadata.AuthorizationException;
import org.apache.hadoop.hive.ql.parse.ASTNode;
import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
import org.apache.hadoop.hive.ql.parse.HiveParser;
import org.apache.hadoop.hive.ql.parse.HiveSemanticAnalyzerHookContext;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.plan.DDLWork;
import org.apache.hadoop.hive.ql.plan.HiveOperation;
import org.apache.hadoop.hive.ql.session.SessionState;
import org.apache.sentry.binding.hive.HiveAuthzBindingHook;
import org.apache.sentry.binding.hive.authz.HiveAuthzBinding;
import org.apache.sentry.binding.hive.authz.HiveAuthzPrivileges;
import org.apache.sentry.binding.hive.authz.HiveAuthzPrivilegesMap;
import org.apache.sentry.binding.hive.conf.HiveAuthzConf;
import org.apache.sentry.core.common.Subject;
import org.apache.sentry.core.model.db.Database;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HiveAuthzBindingHookV2 extends HiveAuthzBindingHook {
private static final Logger LOG = LoggerFactory
.getLogger(HiveAuthzBindingHookV2.class);
private final HiveAuthzBinding hiveAuthzBinding;
private final HiveAuthzConf authzConf;
public HiveAuthzBindingHookV2() throws Exception {
SessionState session = SessionState.get();
if(session == null) {
throw new IllegalStateException("Session has not been started");
}
HiveConf hiveConf = session.getConf();
if(hiveConf == null) {
throw new IllegalStateException("Session HiveConf is null");
}
authzConf = loadAuthzConf(hiveConf);
hiveAuthzBinding = new HiveAuthzBinding(hiveConf, authzConf);
}
public static HiveAuthzConf loadAuthzConf(HiveConf hiveConf) {
boolean depreicatedConfigFile = false;
HiveAuthzConf newAuthzConf = null;
String hiveAuthzConf = hiveConf.get(HiveAuthzConf.HIVE_SENTRY_CONF_URL);
if(hiveAuthzConf == null || (hiveAuthzConf = hiveAuthzConf.trim()).isEmpty()) {
hiveAuthzConf = hiveConf.get(HiveAuthzConf.HIVE_ACCESS_CONF_URL);
depreicatedConfigFile = true;
}
if(hiveAuthzConf == null || (hiveAuthzConf = hiveAuthzConf.trim()).isEmpty()) {
throw new IllegalArgumentException("Configuration key " + HiveAuthzConf.HIVE_SENTRY_CONF_URL
+ " value '" + hiveAuthzConf + "' is invalid.");
}
try {
newAuthzConf = new HiveAuthzConf(new URL(hiveAuthzConf));
} catch (MalformedURLException e) {
if (depreicatedConfigFile) {
throw new IllegalArgumentException("Configuration key " + HiveAuthzConf.HIVE_ACCESS_CONF_URL
+ " specifies a malformed URL '" + hiveAuthzConf + "'", e);
} else {
throw new IllegalArgumentException("Configuration key " + HiveAuthzConf.HIVE_SENTRY_CONF_URL
+ " specifies a malformed URL '" + hiveAuthzConf + "'", e);
}
}
return newAuthzConf;
}
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
switch (ast.getToken().getType()) {
// Hive parser doesn't capture the database name in output entity, so we store it here for now
case HiveParser.TOK_CREATEFUNCTION:
String udfClassName = BaseSemanticAnalyzer.unescapeSQLString(ast.getChild(1).getText());
try {
CodeSource udfSrc = Class.forName(udfClassName).getProtectionDomain().getCodeSource();
if (udfSrc == null) {
throw new SemanticException("Could not resolve the jar for UDF class " + udfClassName);
}
String udfJar = udfSrc.getLocation().getPath();
if (udfJar == null || udfJar.isEmpty()) {
throw new SemanticException("Could not find the jar for UDF class " + udfClassName +
"to validate privileges");
}
udfURI = parseURI(udfSrc.getLocation().toString(), true);
} catch (ClassNotFoundException e) {
throw new SemanticException("Error retrieving udf class", e);
}
// create/drop function is allowed with any database
currDB = Database.ALL;
break;
case HiveParser.TOK_DROPFUNCTION:
// create/drop function is allowed with any database
currDB = Database.ALL;
break;
}
return ast;
}
/**
* Post analyze hook that invokes hive auth bindings
*/
@Override
public void postAnalyze(HiveSemanticAnalyzerHookContext context,
List<Task<? extends Serializable>> rootTasks) throws SemanticException {
HiveOperation stmtOperation = getCurrentHiveStmtOp();
Subject subject = new Subject(context.getUserName());
for (int i = 0; i < rootTasks.size(); i++) {
Task<? extends Serializable> task = rootTasks.get(i);
if (task instanceof DDLTask) {
SentryFilterDDLTask filterTask =
new SentryFilterDDLTask(hiveAuthzBinding, subject, stmtOperation);
filterTask.setWork((DDLWork)task.getWork());
rootTasks.set(i, filterTask);
}
}
HiveAuthzPrivileges stmtAuthObject = HiveAuthzPrivilegesMap.getHiveAuthzPrivileges(stmtOperation);
if (stmtOperation.equals(HiveOperation.CREATEFUNCTION)
|| stmtOperation.equals(HiveOperation.DROPFUNCTION)) {
try {
if (stmtAuthObject == null) {
// We don't handle authorizing this statement
return;
}
authorizeWithHiveBindings(context, stmtAuthObject, stmtOperation);
} catch (AuthorizationException e) {
executeOnFailureHooks(context, stmtOperation, e);
String permsRequired = "";
for (String perm : hiveAuthzBinding.getLastQueryPrivilegeErrors()) {
permsRequired += perm + ";";
}
SessionState.get().getConf().set(HiveAuthzConf.HIVE_SENTRY_AUTH_ERRORS, permsRequired);
String msgForLog =
HiveAuthzConf.HIVE_SENTRY_PRIVILEGE_ERROR_MESSAGE
+ "\n Required privileges for this query: " + permsRequired;
String msgForConsole =
HiveAuthzConf.HIVE_SENTRY_PRIVILEGE_ERROR_MESSAGE + "\n " + e.getMessage();
// AuthorizationException is not a real exception, use the info level to record this.
LOG.info(msgForLog);
throw new SemanticException(msgForConsole, e);
} finally {
hiveAuthzBinding.close();
}
}
}
private HiveOperation getCurrentHiveStmtOp() {
SessionState sessState = SessionState.get();
if (sessState == null) {
LOG.warn("SessionState is null");
return null;
}
return sessState.getHiveOperation();
}
}
| [
"[email protected]"
] | |
b43a0aaedfd6ef7cbf4c5c44305d2a61f1d4ef3e | ab4624141cc69c5b7627ed543a086241c4169ab2 | /src/main/java/com/jc/admin/dao/DictionaryMapper.java | 8ac774a9cd74cb88571966c9a9fd69f1c9d996fc | [] | no_license | jiachong1106/jcyun | 5ecca977d701170e4d7362421e864c1ac72cf9f3 | 64d10e05c89fb03d269e6785fbdd1ca6a408aadc | refs/heads/master | 2022-12-27T20:34:39.689119 | 2020-03-21T07:40:48 | 2020-03-21T07:40:48 | 247,887,797 | 0 | 0 | null | 2020-03-18T01:40:26 | 2020-03-17T05:35:19 | null | UTF-8 | Java | false | false | 911 | java | package com.jc.admin.dao;
import com.jc.admin.bean.Dictionary;
import com.jc.admin.bean.DictionaryExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DictionaryMapper {
long countByExample(DictionaryExample example);
int deleteByExample(DictionaryExample example);
int deleteByPrimaryKey(Integer id);
int insert(Dictionary record);
int insertSelective(Dictionary record);
List<Dictionary> selectByExample(DictionaryExample example);
Dictionary selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") Dictionary record, @Param("example") DictionaryExample example);
int updateByExample(@Param("record") Dictionary record, @Param("example") DictionaryExample example);
int updateByPrimaryKeySelective(Dictionary record);
int updateByPrimaryKey(Dictionary record);
} | [
"PC@DESKTOP-CNFJG5K"
] | PC@DESKTOP-CNFJG5K |
3b12ede2922b9ac73494eb4f4560f9e7a51ecb69 | 1f63dde39fcc5f8be29f2acb947c41f1b6f1683e | /Boss2D/addon/webrtc-jumpingyang001_for_boss/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java | dea84ca22686792246f177b5f68ad302207b2dcf | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webm",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | koobonil/Boss2D | 09ca948823e0df5a5a53b64a10033c4f3665483a | e5eb355b57228a701495f2660f137bd05628c202 | refs/heads/master | 2022-10-20T09:02:51.341143 | 2019-07-18T02:13:44 | 2019-07-18T02:13:44 | 105,999,368 | 7 | 2 | MIT | 2022-10-04T23:31:12 | 2017-10-06T11:57:07 | C++ | UTF-8 | Java | false | false | 16,047 | java | /*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc.voiceengine;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.os.Build;
import java.util.Timer;
import java.util.TimerTask;
import javax.annotation.Nullable;
import org.webrtc.ContextUtils;
import org.webrtc.Logging;
// WebRtcAudioManager handles tasks that uses android.media.AudioManager.
// At construction, storeAudioParameters() is called and it retrieves
// fundamental audio parameters like native sample rate and number of channels.
// The result is then provided to the caller by nativeCacheAudioParameters().
// It is also possible to call init() to set up the audio environment for best
// possible "VoIP performance". All settings done in init() are reverted by
// dispose(). This class can also be used without calling init() if the user
// prefers to set up the audio environment separately. However, it is
// recommended to always use AudioManager.MODE_IN_COMMUNICATION.
public class WebRtcAudioManager {
private static final boolean DEBUG = false;
private static final String TAG = "WebRtcAudioManager";
// TODO(bugs.webrtc.org/8914): disabled by default until AAudio support has
// been completed. Goal is to always return false on Android O MR1 and higher.
private static final boolean blacklistDeviceForAAudioUsage = true;
// Use mono as default for both audio directions.
private static boolean useStereoOutput = false;
private static boolean useStereoInput = false;
private static boolean blacklistDeviceForOpenSLESUsage = false;
private static boolean blacklistDeviceForOpenSLESUsageIsOverridden = false;
// Call this method to override the default list of blacklisted devices
// specified in WebRtcAudioUtils.BLACKLISTED_OPEN_SL_ES_MODELS.
// Allows an app to take control over which devices to exclude from using
// the OpenSL ES audio output path
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized void setBlacklistDeviceForOpenSLESUsage(boolean enable) {
blacklistDeviceForOpenSLESUsageIsOverridden = true;
blacklistDeviceForOpenSLESUsage = enable;
}
// Call these methods to override the default mono audio modes for the specified direction(s)
// (input and/or output).
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized void setStereoOutput(boolean enable) {
Logging.w(TAG, "Overriding default output behavior: setStereoOutput(" + enable + ')');
useStereoOutput = enable;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized void setStereoInput(boolean enable) {
Logging.w(TAG, "Overriding default input behavior: setStereoInput(" + enable + ')');
useStereoInput = enable;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized boolean getStereoOutput() {
return useStereoOutput;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public static synchronized boolean getStereoInput() {
return useStereoInput;
}
// Default audio data format is PCM 16 bit per sample.
// Guaranteed to be supported by all devices.
private static final int BITS_PER_SAMPLE = 16;
private static final int DEFAULT_FRAME_PER_BUFFER = 256;
// Private utility class that periodically checks and logs the volume level
// of the audio stream that is currently controlled by the volume control.
// A timer triggers logs once every 30 seconds and the timer's associated
// thread is named "WebRtcVolumeLevelLoggerThread".
private static class VolumeLogger {
private static final String THREAD_NAME = "WebRtcVolumeLevelLoggerThread";
private static final int TIMER_PERIOD_IN_SECONDS = 30;
private final AudioManager audioManager;
private @Nullable Timer timer;
public VolumeLogger(AudioManager audioManager) {
this.audioManager = audioManager;
}
public void start() {
timer = new Timer(THREAD_NAME);
timer.schedule(new LogVolumeTask(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING),
audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL)),
0, TIMER_PERIOD_IN_SECONDS * 1000);
}
private class LogVolumeTask extends TimerTask {
private final int maxRingVolume;
private final int maxVoiceCallVolume;
LogVolumeTask(int maxRingVolume, int maxVoiceCallVolume) {
this.maxRingVolume = maxRingVolume;
this.maxVoiceCallVolume = maxVoiceCallVolume;
}
@Override
public void run() {
final int mode = audioManager.getMode();
if (mode == AudioManager.MODE_RINGTONE) {
Logging.d(TAG, "STREAM_RING stream volume: "
+ audioManager.getStreamVolume(AudioManager.STREAM_RING) + " (max="
+ maxRingVolume + ")");
} else if (mode == AudioManager.MODE_IN_COMMUNICATION) {
Logging.d(TAG, "VOICE_CALL stream volume: "
+ audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL) + " (max="
+ maxVoiceCallVolume + ")");
}
}
}
private void stop() {
if (timer != null) {
timer.cancel();
timer = null;
}
}
}
private final long nativeAudioManager;
private final AudioManager audioManager;
private boolean initialized = false;
private int nativeSampleRate;
private int nativeChannels;
private boolean hardwareAEC;
private boolean hardwareAGC;
private boolean hardwareNS;
private boolean lowLatencyOutput;
private boolean lowLatencyInput;
private boolean proAudio;
private boolean aAudio;
private int sampleRate;
private int outputChannels;
private int inputChannels;
private int outputBufferSize;
private int inputBufferSize;
private final VolumeLogger volumeLogger;
WebRtcAudioManager(long nativeAudioManager) {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
this.nativeAudioManager = nativeAudioManager;
audioManager =
(AudioManager) ContextUtils.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG);
}
volumeLogger = new VolumeLogger(audioManager);
storeAudioParameters();
nativeCacheAudioParameters(sampleRate, outputChannels, inputChannels, hardwareAEC, hardwareAGC,
hardwareNS, lowLatencyOutput, lowLatencyInput, proAudio, aAudio, outputBufferSize,
inputBufferSize, nativeAudioManager);
WebRtcAudioUtils.logAudioState(TAG);
}
private boolean init() {
Logging.d(TAG, "init" + WebRtcAudioUtils.getThreadInfo());
if (initialized) {
return true;
}
Logging.d(TAG, "audio mode is: "
+ WebRtcAudioUtils.modeToString(audioManager.getMode()));
initialized = true;
volumeLogger.start();
return true;
}
private void dispose() {
Logging.d(TAG, "dispose" + WebRtcAudioUtils.getThreadInfo());
if (!initialized) {
return;
}
volumeLogger.stop();
}
private boolean isCommunicationModeEnabled() {
return (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION);
}
private boolean isDeviceBlacklistedForOpenSLESUsage() {
boolean blacklisted = blacklistDeviceForOpenSLESUsageIsOverridden
? blacklistDeviceForOpenSLESUsage
: WebRtcAudioUtils.deviceIsBlacklistedForOpenSLESUsage();
if (blacklisted) {
Logging.d(TAG, Build.MODEL + " is blacklisted for OpenSL ES usage!");
}
return blacklisted;
}
private void storeAudioParameters() {
outputChannels = getStereoOutput() ? 2 : 1;
inputChannels = getStereoInput() ? 2 : 1;
sampleRate = getNativeOutputSampleRate();
hardwareAEC = isAcousticEchoCancelerSupported();
// TODO(henrika): use of hardware AGC is no longer supported. Currently
// hardcoded to false. To be removed.
hardwareAGC = false;
hardwareNS = isNoiseSuppressorSupported();
lowLatencyOutput = isLowLatencyOutputSupported();
lowLatencyInput = isLowLatencyInputSupported();
proAudio = isProAudioSupported();
aAudio = isAAudioSupported();
outputBufferSize = lowLatencyOutput ? getLowLatencyOutputFramesPerBuffer()
: getMinOutputFrameSize(sampleRate, outputChannels);
inputBufferSize = lowLatencyInput ? getLowLatencyInputFramesPerBuffer()
: getMinInputFrameSize(sampleRate, inputChannels);
}
// Gets the current earpiece state.
private boolean hasEarpiece() {
return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TELEPHONY);
}
// Returns true if low-latency audio output is supported.
private boolean isLowLatencyOutputSupported() {
return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_AUDIO_LOW_LATENCY);
}
// Returns true if low-latency audio input is supported.
// TODO(henrika): remove the hardcoded false return value when OpenSL ES
// input performance has been evaluated and tested more.
public boolean isLowLatencyInputSupported() {
// TODO(henrika): investigate if some sort of device list is needed here
// as well. The NDK doc states that: "As of API level 21, lower latency
// audio input is supported on select devices. To take advantage of this
// feature, first confirm that lower latency output is available".
return WebRtcAudioUtils.runningOnLollipopOrHigher() && isLowLatencyOutputSupported();
}
// Returns true if the device has professional audio level of functionality
// and therefore supports the lowest possible round-trip latency.
@TargetApi(23)
private boolean isProAudioSupported() {
return WebRtcAudioUtils.runningOnMarshmallowOrHigher()
&& ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_AUDIO_PRO);
}
// AAudio is supported on Androio Oreo MR1 (API 27) and higher.
// TODO(bugs.webrtc.org/8914): currently disabled by default.
private boolean isAAudioSupported() {
if (blacklistDeviceForAAudioUsage) {
Logging.w(TAG, "AAudio support is currently disabled on all devices!");
}
return !blacklistDeviceForAAudioUsage && WebRtcAudioUtils.runningOnOreoMR1OrHigher();
}
// Returns the native output sample rate for this device's output stream.
private int getNativeOutputSampleRate() {
// Override this if we're running on an old emulator image which only
// supports 8 kHz and doesn't support PROPERTY_OUTPUT_SAMPLE_RATE.
if (WebRtcAudioUtils.runningOnEmulator()) {
Logging.d(TAG, "Running emulator, overriding sample rate to 8 kHz.");
return 8000;
}
// Default can be overriden by WebRtcAudioUtils.setDefaultSampleRateHz().
// If so, use that value and return here.
if (WebRtcAudioUtils.isDefaultSampleRateOverridden()) {
Logging.d(TAG, "Default sample rate is overriden to "
+ WebRtcAudioUtils.getDefaultSampleRateHz() + " Hz");
return WebRtcAudioUtils.getDefaultSampleRateHz();
}
// No overrides available. Deliver best possible estimate based on default
// Android AudioManager APIs.
final int sampleRateHz;
if (WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) {
sampleRateHz = getSampleRateOnJellyBeanMR10OrHigher();
} else {
sampleRateHz = WebRtcAudioUtils.getDefaultSampleRateHz();
}
Logging.d(TAG, "Sample rate is set to " + sampleRateHz + " Hz");
return sampleRateHz;
}
@TargetApi(17)
private int getSampleRateOnJellyBeanMR10OrHigher() {
String sampleRateString = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
return (sampleRateString == null) ? WebRtcAudioUtils.getDefaultSampleRateHz()
: Integer.parseInt(sampleRateString);
}
// Returns the native output buffer size for low-latency output streams.
@TargetApi(17)
private int getLowLatencyOutputFramesPerBuffer() {
assertTrue(isLowLatencyOutputSupported());
if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) {
return DEFAULT_FRAME_PER_BUFFER;
}
String framesPerBuffer =
audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
return framesPerBuffer == null ? DEFAULT_FRAME_PER_BUFFER : Integer.parseInt(framesPerBuffer);
}
// Returns true if the device supports an audio effect (AEC or NS).
// Four conditions must be fulfilled if functions are to return true:
// 1) the platform must support the built-in (HW) effect,
// 2) explicit use (override) of a WebRTC based version must not be set,
// 3) the device must not be blacklisted for use of the effect, and
// 4) the UUID of the effect must be approved (some UUIDs can be excluded).
private static boolean isAcousticEchoCancelerSupported() {
return WebRtcAudioEffects.canUseAcousticEchoCanceler();
}
private static boolean isNoiseSuppressorSupported() {
return WebRtcAudioEffects.canUseNoiseSuppressor();
}
// Returns the minimum output buffer size for Java based audio (AudioTrack).
// This size can also be used for OpenSL ES implementations on devices that
// lacks support of low-latency output.
private static int getMinOutputFrameSize(int sampleRateInHz, int numChannels) {
final int bytesPerFrame = numChannels * (BITS_PER_SAMPLE / 8);
final int channelConfig =
(numChannels == 1 ? AudioFormat.CHANNEL_OUT_MONO : AudioFormat.CHANNEL_OUT_STEREO);
return AudioTrack.getMinBufferSize(
sampleRateInHz, channelConfig, AudioFormat.ENCODING_PCM_16BIT)
/ bytesPerFrame;
}
// Returns the native input buffer size for input streams.
private int getLowLatencyInputFramesPerBuffer() {
assertTrue(isLowLatencyInputSupported());
return getLowLatencyOutputFramesPerBuffer();
}
// Returns the minimum input buffer size for Java based audio (AudioRecord).
// This size can calso be used for OpenSL ES implementations on devices that
// lacks support of low-latency input.
private static int getMinInputFrameSize(int sampleRateInHz, int numChannels) {
final int bytesPerFrame = numChannels * (BITS_PER_SAMPLE / 8);
final int channelConfig =
(numChannels == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO);
return AudioRecord.getMinBufferSize(
sampleRateInHz, channelConfig, AudioFormat.ENCODING_PCM_16BIT)
/ bytesPerFrame;
}
// Helper method which throws an exception when an assertion has failed.
private static void assertTrue(boolean condition) {
if (!condition) {
throw new AssertionError("Expected condition to be true");
}
}
private native void nativeCacheAudioParameters(int sampleRate, int outputChannels,
int inputChannels, boolean hardwareAEC, boolean hardwareAGC, boolean hardwareNS,
boolean lowLatencyOutput, boolean lowLatencyInput, boolean proAudio, boolean aAudio,
int outputBufferSize, int inputBufferSize, long nativeAudioManager);
}
| [
"[email protected]"
] | |
c9b9ef768329953e54358f71058d0ea27a778ce3 | ffa0407a1196ae2b17a8ae7c02ea58a3f357456b | /app/src/main/java/com/example/abhishek/rideon/callback/DefaultCallback.java | b2f11c7895db2fead63ea0a9ba28941529c1d868 | [] | no_license | abhis9031/RideOn | 924a649929dd72317fadb796d0255e491884822f | 2f87f0f149f9da61a3810402483366208dfedfed | refs/heads/master | 2021-01-10T14:49:44.962847 | 2016-02-27T04:53:11 | 2016-02-27T04:53:11 | 51,543,489 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,196 | java | package com.example.abhishek.rideon.callback;
import android.app.ProgressDialog;
import android.content.Context;
import android.widget.Toast;
import com.backendless.async.callback.BackendlessCallback;
import com.backendless.exceptions.BackendlessFault;
/**
* Created by Abhishek on 31-01-2016.
*/
public class DefaultCallback<T> extends BackendlessCallback<T>
{
private Context context;
private ProgressDialog progressDialog;
public DefaultCallback( Context context )
{
this.context = context;
progressDialog = ProgressDialog.show( context, "", "Loading...", true );
}
public DefaultCallback( Context context, String message )
{
this.context = context;
progressDialog = ProgressDialog.show( context, "", message, true );
}
@Override
public void handleResponse( T response )
{
progressDialog.cancel();
}
@Override
public void handleFault( BackendlessFault fault )
{
progressDialog.cancel();
Toast.makeText(context, fault.getMessage(), Toast.LENGTH_LONG).show();
}
}
| [
"[email protected]"
] | |
83704789f1b9d9a99bde89b332213f551a14b493 | 5153fec29ba9518244d4605116428ef4ff59cb63 | /src/perfect/db/BDBConfig.java | aa078187d5c3dc8e57b7d06d6b1f65fcd17e42a4 | [] | no_license | stallboy/perfect | 507c5756ea8db0653186de8c25b8326cc99eae29 | 0ab70dd801f251322542fb6a69883667b84096cf | refs/heads/master | 2020-04-30T06:27:25.453436 | 2017-09-13T06:17:20 | 2017-09-13T06:17:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,846 | java | package perfect.db;
import com.sleepycat.je.Durability;
public final class BDBConfig {
private String envRoot;
private long cacheSize;
private Durability envDurability;
private Durability txnDurability;
private String backupRoot;
private int incrementalBackupInterval;
private int fullBackupInterval;
public BDBConfig() {
this.envRoot = "_database_";
this.cacheSize = 0;
this.envDurability = Durability.COMMIT_NO_SYNC;
this.txnDurability = Durability.COMMIT_NO_SYNC;
this.backupRoot = this.envRoot + "/" + "backup";
this.incrementalBackupInterval = 1800;
this.fullBackupInterval = 86400;
}
public final String getEnvRoot() {
return envRoot;
}
public final void setEnvRoot(String envRoot) {
this.envRoot = envRoot;
}
public final String getBackupRoot() {
return backupRoot;
}
public final void setBackupRoot(String backupRoot) {
this.backupRoot = backupRoot;
}
public final int getIncrementalBackupInterval() {
return incrementalBackupInterval;
}
public final void setIncrementalBackupInterval(int incrementalBackupInterval) {
this.incrementalBackupInterval = incrementalBackupInterval;
}
public final int getFullBackupInterval() {
return fullBackupInterval;
}
public final void setFullBackupInterval(int fullBackupInterval) {
this.fullBackupInterval = fullBackupInterval;
}
public final long getCacheSize() {
return cacheSize;
}
public final void setCacheSize(long cacheSize) {
this.cacheSize = cacheSize;
}
public final Durability getEnvDurability() {
return envDurability;
}
public final void setEnvDurability(Durability durability) {
this.envDurability = durability;
}
public final Durability getTxnDurability() {
return txnDurability;
}
public final void setTxnDurability(Durability txnDurability) {
this.txnDurability = txnDurability;
}
}
| [
"[email protected]"
] | |
1ee6c776fc8b4fa6c2d76e0d14cca9f50cd8738d | 441ed345bd9fe2c80ffb44b0397f14454d85ba21 | /spring-boot-demo/src/test/java/com/chunfen/wx/BootTest.java | dd69455f0cfcb6f199cdc9b13ef27d54c25c56cc | [] | no_license | ariesandx/chunfenwx | 8d6e4ca819e8a844b52fbf86c0c553dca56335d2 | e5d784f4760b43c2c65367bba44f49b52f0ed2c0 | refs/heads/master | 2022-07-22T12:36:07.834573 | 2019-10-11T02:37:51 | 2019-10-11T02:37:51 | 195,645,761 | 0 | 0 | null | 2022-06-21T01:25:08 | 2019-07-07T12:00:14 | Java | UTF-8 | Java | false | false | 2,424 | java | package com.chunfen.wx;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chunfen.wx.domain.User;
import com.chunfen.wx.domain.UserMapper;
import com.chunfen.wx.mq.sender.HelloSender;
import com.chunfen.wx.mq.sender.TopicSender;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
/**
* Created by xi.w on 2019/5/1.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class BootTest {
@Autowired
private UserMapper userMapper;
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test
public void selectList() throws Exception{
QueryWrapper<User> query = Wrappers.query(new User());
query.like("name", "tom");
List<User> users = userMapper.selectList(query);
System.out.println(OBJECT_MAPPER.writeValueAsString(users));
}
@Test
public void insertList() throws Exception{
User user = new User();
user.setId(1);
user.setName("tom_早");
int insert = userMapper.insert(user);
System.out.println(insert);
}
@Test
public void getAllList() throws Exception{
QueryWrapper<User> query = Wrappers.query(new User());
query.like("user_name", "tom");
System.out.println(OBJECT_MAPPER.writeValueAsString(userMapper.getAll(query)));
}
@Test
public void deleteList() throws Exception{
QueryWrapper<User> query = Wrappers.query(new User());
query.like("user_name", "tom");
System.out.println(OBJECT_MAPPER.writeValueAsString(userMapper.delete(query)));
}
@Test
public void getOneList() throws Exception{
System.out.println(OBJECT_MAPPER.writeValueAsString(userMapper.getOne(3)));
}
@Autowired
private HelloSender helloSender;
@Autowired
private TopicSender topicSender;
@Test
public void hello() throws Exception {
helloSender.send();
}
@Test
public void topicSender() throws Exception {
// for(int i=0; i<100; i++){
// topicSender.send();
// }
Thread.sleep(10 * 1000);
}
}
| [
"[email protected]"
] | |
be14402a64a41b4efaeeedd8084639d4afaafc1d | 226560d54418df7ddb2b64f5add91056668a4cbf | /src/main/java/crimson/application/repository/CartRepository.java | 992430166b5e26ef78e6090ecc42157644a34348 | [] | no_license | ebinezerp/crimson | 938df76f0ac25d0d7ca45d4f83b7797d94021ddb | afbe0736a7233599675d63b4e22a37172e30b965 | refs/heads/master | 2021-06-13T01:46:38.593740 | 2019-08-14T10:47:22 | 2019-08-14T10:47:22 | 182,284,668 | 0 | 2 | null | 2021-04-26T19:00:07 | 2019-04-19T15:21:03 | CSS | UTF-8 | Java | false | false | 441 | java | package crimson.application.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import crimson.application.model.Cart;
import crimson.application.model.User;
public interface CartRepository extends JpaRepository<Cart, Long>{
public Cart findCartByUser(User user);
@Query("select c.quantity from Cart c where c.user=:user")
public Long cartCount(User user);
}
| [
"[email protected]"
] | |
544f7afbb9c07f7e02a862c8cc7f97009c9b024f | e406e6cb1253843399ef616a4b0e562f7cc7707b | /test/model/gamemodes/PointBuilderTest.java | d4ce31c6c4c6e8011a698b23eaa4f66e950a84b6 | [] | no_license | apapadoi/BuzzQuizWorld | a909fce33b6e85efeaa1eb83e9694813b4cb7e84 | 66e704f0ed40bb928a1827a168285c187b52f520 | refs/heads/master | 2023-05-27T02:35:54.633560 | 2021-01-15T20:04:52 | 2021-01-15T20:04:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,888 | java | package model.gamemodes;
import controller.FrontController;
import controller.requests.*;
import javafx.embed.swing.JFXPanel;
import model.Model;
import model.fileHandler.FileHandler;
import model.gamemodes.factories.GamemodeFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import view.gui.GUI;
import view.gui.GameplayFrame;
import view.gui.SelectionFrameUI;
import view.gui.UI;
import java.awt.*;
import view.gui.SelectionFrameUI;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class PointBuilderTest {
private PointBuilder pointBuilder;
@BeforeEach
void setUp() {
new JFXPanel();
FrontController.getInstance().setView(new GameplayFrame() {
@Override
public Dimension getSize() {
return new Dimension(150,150);
}
@Override
public UI getPreQuestionFrame() {
return new GUI() {
@Override
public Dimension getSize() {
return new Dimension(150,150);
}
@Override
public void dispose() {
super.dispose();
}
};
}
});
pointBuilder = new PointBuilder();
FileHandler fileHandler = new FileHandler(new ArrayList<>(),
Paths.get("test/resources/data/questions/textQuestions/textQuestions.txt"),
Paths.get("test/resources/data/questions/imagedQuestions/imagedQuestions.txt"));
FrontController.getInstance().setFileHandler(fileHandler);
FrontController.getInstance().dispatchRequest(new SetGamemodeFactoryRequest(
new GamemodeFactory() {
@Override
public Gamemodable getRandomGamemode() {
return pointBuilder;
}
@Override
public void clearGamemodeData() {
}
}
));
FrontController.getInstance().dispatchRequest(new LoadRequest());
FrontController.getInstance().dispatchRequest(new ClearDataRequest());
SelectionFrameUI selectionFrame = new SelectionFrameUI() {
@Override
public int getNumOfRoundsChoice() {
return 1;
}
@Override
public List<String> getUsernames() {
return new ArrayList<>(List.of("testUsername"));
}
};
FrontController.getInstance().dispatchRequest(new AddUsernamesRequest(selectionFrame));
FrontController.getInstance().dispatchRequest(new AddNumOfRoundsRequest(selectionFrame));
FrontController.getInstance().dispatchRequest(new SetMaximumPlayersRequest(1));
FrontController.getInstance().dispatchRequest(new UpdateDataRequest(-1,
-1,0));
}
@Test
void getDescription() {
assertEquals("Each player that answers correctly earns 1000 points.",
pointBuilder.getDescription());
}
@Test
void hasPreQuestionPhase() {
assertFalse(pointBuilder.hasPreQuestionPhase());
}
@Test
void hasTimer() {
assertFalse(pointBuilder.hasTimer());
}
@Test
void testToString() {
assertEquals("Point Builder", pointBuilder.toString());
}
/**
* Test case if the player answers correct and then wrong, while he already has points.
*/
@Test
void answerActions() {
int correctAnswerIndex = Model.getInstance().getRound(0).getQuestions().get(0).getAnswers().
indexOf(Model.getInstance().getRound(0).getQuestions().
get(0).getCorrectAnswer());
Model.getInstance().getPlayers().get(0).setScore(500);
FrontController.getInstance().dispatchRequest(new UpdateDataRequest(0, correctAnswerIndex, 1000));
assertEquals(1500, Model.getInstance().getPlayers().get(0).getScore());
correctAnswerIndex = Model.getInstance().getRound(0).getQuestions().get(1).getAnswers().
indexOf(Model.getInstance().getRound(0).getQuestions().
get(1).getCorrectAnswer());
int wrongAnswerIndex;
if (correctAnswerIndex == 0)
wrongAnswerIndex = correctAnswerIndex + 1;
else
wrongAnswerIndex = correctAnswerIndex - 1;
FrontController.getInstance().dispatchRequest(new UpdateDataRequest(0,wrongAnswerIndex,1500));
assertEquals(1500, Model.getInstance().getPlayers().get(0).getScore());
}
/**
* Test case if the player answers wrong and then correct, while he has no previous points.
*/
@Test
void answerActions1() {
int correctAnswerIndex = Model.getInstance().getRound(0).getQuestions().get(0).getAnswers().
indexOf(Model.getInstance().getRound(0).getQuestions().
get(0).getCorrectAnswer());
int wrongAnswerIndex;
if (correctAnswerIndex == 0)
wrongAnswerIndex = correctAnswerIndex + 1;
else
wrongAnswerIndex = correctAnswerIndex - 1;
FrontController.getInstance().dispatchRequest(new UpdateDataRequest(0, wrongAnswerIndex, 1000));
assertEquals(0, Model.getInstance().getPlayers().get(0).getScore());
correctAnswerIndex = Model.getInstance().getRound(0).getQuestions().get(1).getAnswers().
indexOf(Model.getInstance().getRound(0).getQuestions().
get(1).getCorrectAnswer());
FrontController.getInstance().dispatchRequest(new UpdateDataRequest(0,correctAnswerIndex,1500));
assertEquals(1000, Model.getInstance().getPlayers().get(0).getScore());
}
} | [
"[email protected]"
] | |
36c47a98082cb427de985aa3fe50c8bce817796c | 7df9e78d0cb05a6ebf394f16f3c4fc9e39c5a8e3 | /app/src/main/java/com/example/assigndeliveryperson/MainActivity.java | dd8719a36599bdc8b4f093dcea5aa1de21d04349 | [] | no_license | tchankamie/AssignDeliveryPerson | c9d01a4cf9feacff62a76b5297de25d6371bd1a5 | 00ce549452cba78f154c708c90ccb013b1882b84 | refs/heads/master | 2020-06-29T17:35:00.369067 | 2019-08-05T04:12:20 | 2019-08-05T04:12:20 | 200,580,453 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 827 | java | package com.example.assigndeliveryperson;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClickbutton1(View view){
Intent intent = new Intent(this, AssignOrder.class);
startActivity(intent);
}
public void onClickbutton2(View view){
Intent intent = new Intent(this,AssignOrder.class);
startActivity(intent);
}
public void onClickbutton3(View view){
Intent intent = new Intent(this,AssignOrder.class);
startActivity(intent);
}
}
| [
"[email protected]"
] | |
c48acdc0ccda9ec0fecc36d8c387212cfee1177b | 87d0cc373afae0903882060c3b32c277f5bbaba7 | /src/main/java/cz/nlfnorm/quasar/dto/EvaluatedEacCode.java | f9a29721cf0f4fbbdf2f1beb2672943c9ea43af9 | [] | no_license | chomman/cpr | 55ada67f6beeaeea630e15365983e743a2e4742e | cb082dfc5cd81f6480e005f3c4544e6198064c00 | refs/heads/master | 2016-09-05T12:30:41.189957 | 2014-08-20T18:28:01 | 2014-08-20T18:28:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 455 | java | package cz.nlfnorm.quasar.dto;
import cz.nlfnorm.quasar.entities.AuditorEacCode;
public class EvaluatedEacCode extends EvaludatedCode{
private AuditorEacCode auditorEacCode;
public EvaluatedEacCode(final AuditorEacCode code){
this.auditorEacCode = code;
}
public AuditorEacCode getAuditorEacCode() {
return auditorEacCode;
}
public void setAuditorEacCode(AuditorEacCode auditorEacCode) {
this.auditorEacCode = auditorEacCode;
}
}
| [
"[email protected]"
] | |
eaa2eac8af597970569f3b800a5d4d543a3721d3 | 002140e0ea60a9fcfac9fc07f60bb3e9dc49ab67 | /src/main/java/net/ibizsys/paas/core/IDEDataQuery.java | aed424e5e526eec4896fbe17d4595de953e24037 | [] | no_license | devibizsys/saibz5_all | ecacc91122920b8133c2cff3c2779c0ee0381211 | 87c44490511253b5b34cd778623f9b6a705cb97c | refs/heads/master | 2021-01-01T16:15:17.146300 | 2017-07-20T07:52:21 | 2017-07-20T07:52:21 | 97,795,014 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 538 | java | package net.ibizsys.paas.core;
/**
* 实体数据查询接口
*
* @author lionlau
*
*/
public interface IDEDataQuery extends IDataEntityObject {
/**
* 初始化
*
* @param iDataEntity
* @throws Exception
*/
void init(IDataEntity iDataEntity) throws Exception;
/**
* 获取实体数据库代码
*
* @param strDBType
* @return
* @throws Exception
*/
IDEDataQueryCode getDEDataQueryCode(String strDBType) throws Exception;
/**
* 是否为默认查询
*
* @return
*/
boolean isDefaultMode();
}
| [
"[email protected]"
] | |
2a6d538ab1a98c1245505b119bb8b3c4e2040417 | 1220159472ed475d59187d0f845474020dc1bb25 | /src/main/java/com/imove/AutoTest/lib/DateLib.java | b1104557ead92b14c00a7d9da207173ed8f39b5d | [] | no_license | fxlysm/apitest | a9283eb57ceb928c71fa2a9b0797b747e6106a76 | 9e27c46964452631ec7e9e8aff4a0480ee62bc43 | refs/heads/master | 2020-03-29T04:56:55.013214 | 2018-09-20T05:59:42 | 2018-09-20T05:59:42 | 149,557,262 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,324 | java | package com.imove.AutoTest.lib;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateLib {
/**
* 将'yyyyMMddHHmmss' 转成 yyyy-mm-dd hh:mm:ss
*
* @param source
* @return
*/
public static String format(String source) throws Exception {
int sourcelength=14;
if (source != null && source.length() == sourcelength) {
return source.substring(0, 4) + "-" + source.substring(4, 6) + "-"
+ source.substring(6, 8) + " " + source.substring(8, 10)
+ ":" + source.substring(10, 12) + ":"
+ source.substring(12, 14);
} else {
throw new Exception("传入的字符为" + source
+ "不能正常转化为yyyy-mm-dd hh:mm:ss形式");
}
}
/**
* 将'yyyy-MM-dd'转成'yyyyMMdd'
*
* @param source
* @return
*/
public static String format1(String source) {
return source.substring(0, 4) + source.substring(5, 7)
+ source.substring(8, 10);
}
public static String format2(String source) {
return source.substring(2, 4) + source.substring(5, 7)
+ source.substring(8, 10);
}
/**
* 取昨天的时间,并以format的形式返回
*
* @return
* @throws Exception
*/
public static String ydFormat(String format) {
String tar;
Calendar c = Calendar.getInstance();
int date = c.get(Calendar.DATE);
date--;
c.set(Calendar.DATE, date);
Date yesDay = new Date(c.getTimeInMillis());
tar = (new SimpleDateFormat(format)).format(yesDay);
return tar;
}
/**
* 取前天日期,并以format传入的形式返回
*
* @param format
* @return
*/
public static String beforYdFormat(String format) {
String tar;
Calendar c = Calendar.getInstance();
int date = c.get(Calendar.DATE);
date = date - 2;
c.set(Calendar.DATE, date);
Date yesDay = new Date(c.getTimeInMillis());
tar = (new SimpleDateFormat(format)).format(yesDay);
return tar;
}
/**
* 取前N天日期,并以format传入的形式返回
*
* @param format
* @return
*/
public static String beforNdFormat(String format, int n) {
String tar;
Calendar c = Calendar.getInstance();
int date = c.get(Calendar.DATE);
date = date - n;
c.set(Calendar.DATE, date);
Date yesDay = new Date(c.getTimeInMillis());
tar = (new SimpleDateFormat(format)).format(yesDay);
return tar;
}
/**
* 取某一天第二天的日期
*
* @param yd
* @param format
* @return
* @throws Exception
*/
public static String toFormat(String yd, String format) throws Exception {
yd = yd.replaceAll("-", "");
String ad;
SimpleDateFormat sf = new SimpleDateFormat();
sf.applyPattern(format);
java.util.Date yDate = sf.parse(yd);
// -1表示前一天,+1表示后一天,依次类推
long myTime = (yDate.getTime() / 1000) + 1 * 60 * 60 * 24;
yDate.setTime(myTime * 1000);
ad = sf.format(yDate);
return ad;
}
public static String today(String format) {
java.util.Date date = new java.util.Date();
String tar = new SimpleDateFormat(format).format(date);
return tar;
}
public static String tomorrow(String today, String format) throws Exception {
String ad;
SimpleDateFormat sf = new SimpleDateFormat();
sf.applyPattern(format);
java.util.Date yDate = sf.parse(today);
// -1表示前一天,+1表示后一天,依次类推
long myTime = (yDate.getTime() / 1000) + 1 * 60 * 60 * 24;
yDate.setTime(myTime * 1000);
ad = sf.format(yDate);
return ad;
}
/**
* 获得某个月的第一天
*
* @param date
* @return
*
*/
public static java.util.Date firstDayOfMonth(java.util.Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, 1);
return c.getTime();
}
/**
* 获得某周的一天
*
* @param date
* @return
*
*/
public static String weekday(String date) {
java.util.Date nowDate = java.sql.Date.valueOf(date);
java.text.SimpleDateFormat bartDateFormat = new java.text.SimpleDateFormat(
"EEE");
String week = bartDateFormat.format(nowDate).trim();
return week;
}
/**
* 比较时间
*
* @param DATE1
* 开始时间
* @param DATE2
* @return
*/
public static int compareDate(String date1, String date2) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
java.util.Date dt1 = df.parse(date1);
java.util.Date dt2 = df.parse(date2);
if (dt1.getTime() >= dt2.getTime()) {
//System.out.println("以第【1】个时间为准");
return 1;
}
//System.out.println("以第【2】个时间为准");
return 2;
} catch (Exception exception) {
exception.printStackTrace();
}
return 0;
}
/**
* 计算入参日期到今天的间隔天数
* @param beforedate
* @return
* @throws ParseException
*/
public static int getDays(String beforedatestr) throws ParseException {
if(null==beforedatestr){
return 0;
}
String todaystr = DateLib.today("yyyy-MM-dd"); //第二个日期
//算两个日期间隔多少天
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date today = format.parse(todaystr);
Date beforedate = format.parse(beforedatestr);
int days = (int) ((today.getTime() - beforedate.getTime()) / (1000*3600*24));
return days;
}
public static void main(String[] args) {
}
}
| [
"[email protected]"
] | |
a9daab3069a37a8361ddabc9d875dad5b72562b6 | 38af5b79171a1e1e4d100cc1c7196551826deb82 | /SQliteDB/src/com/example/sqlitedb/DBHack.java | ad7cea0cb1f2aa9943d753d676be54c53d68fd41 | [] | no_license | azam20104u/Android-Class | 980f4311d47d4bd593453152808633a642b51e70 | 47fe16a91cf8c81bb8b2918c3e008943538597b4 | refs/heads/master | 2020-04-10T08:09:28.360433 | 2019-04-29T08:08:23 | 2019-04-29T08:08:23 | 160,898,772 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,569 | java | package com.example.sqlitedb;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHack extends SQLiteOpenHelper{
public DBHack(Context context) {
super(context, "mydb.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table contact(id integer primary key autoincrement,name text,phone long unique)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
db.execSQL("drop table if exists contact");
onCreate(db);
}
public Long saveData(String name,long phone){
SQLiteDatabase db=getWritableDatabase();
ContentValues values=new ContentValues();
values.put("name", name);
values.put("phone", phone);
Long row=db.insert("contact", null, values);
return row;
}
public Cursor viewAll(){
SQLiteDatabase db=getWritableDatabase();
Cursor cursor=db.rawQuery("select* from contact",null);
return cursor;
}
public void updateContact(Contacts contact) {
SQLiteDatabase db=getWritableDatabase();
ContentValues values=new ContentValues();
values.put("name", contact.getName());
values.put("phone", contact.getPhone());
db.update("contact", values, "id=?", new String[]{String.valueOf(contact.getId())});
}
public void deleteContact(String tid) {
SQLiteDatabase db=getWritableDatabase();
db.delete("contact", "id=?", new String[]{tid});
}
}
| [
"macbook@macbook-Lenovo-B40-80"
] | macbook@macbook-Lenovo-B40-80 |
7f6e0a3931353cc9c7a98e51cd1a5771b3f181c8 | 8f0ae91a5055ac51733b9c0c4694c89fa7466635 | /mycloud-configdeptclient8001/src/main/java/com/gpw/springcloud/controller/DeptController.java | 36f1dd2e9185dee56e2e5aa5e08cd2c65379c48d | [
"MIT"
] | permissive | gpw1126/microservice | aa683250072a6301c7cc3fbf132effc234b0df7e | 4c487f594569873ebd24ce0d2a9b1992ce9676af | refs/heads/master | 2022-06-22T04:16:26.554728 | 2019-06-12T13:11:08 | 2019-06-12T13:11:08 | 191,164,639 | 0 | 0 | MIT | 2020-07-01T23:24:37 | 2019-06-10T12:33:35 | Java | UTF-8 | Java | false | false | 928 | java | package com.gpw.springcloud.controller;
import com.gpw.springcloud.entities.Dept;
import com.gpw.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author: Gpw
* @Date: 2019/6/7
* @Description: com.gpw.springcloud.controller
* @Version: 1.0
*/
@RestController
public class DeptController {
@Autowired
DeptService service;
@RequestMapping(value="/dept/add",method= RequestMethod.POST)
public boolean add(@RequestBody Dept dept)
{
return service.add(dept);
}
@RequestMapping(value="/dept/get/{id}",method=RequestMethod.GET)
public Dept get(@PathVariable("id") Long id)
{
return service.get(id);
}
@RequestMapping(value="/dept/list",method=RequestMethod.GET)
public List<Dept> list()
{
return service.list();
}
}
| [
"[email protected]"
] | |
3139a856dd419933c4a3305255af6db5a54592cf | 828a4351e3741b3f3371ee2f84ac271c88cba2d3 | /LabA14/src/Rolling.java | e94673ca86bdd011a89bdaaf6a1546ee78b85a09 | [] | no_license | pdkainth/APCSA | 973e52d3fdd60f773c150408fb1c12f8335229b7 | cea72e9fbdfd6a720a48e8b1c6eb272f6af22fe3 | refs/heads/master | 2020-03-29T10:21:05.449289 | 2019-04-14T18:05:53 | 2019-04-14T18:05:53 | 149,800,838 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,629 | java | import java.util.*;
/**
*
* @author Prabhdeep Kainth
* period # 4
*/
public class Rolling {
Random rand;
/**
* constructor to initilize the random number
* generator
* @param s - seed for the random number generator
*/
public Rolling(int s)
{
rand = new Random(s);//makes new number generator
}
/**
* Method to simulate a dice roll
* @return an integer between 1 and 6
*/
private int roll()
{
//Your code goes here
return rand.nextInt(6) + 1;
}
/**
* Roll the dice three times and count the
* number of tries it took to get all three
* different rolls. In the end print a message
* displaying the number of tries
*/
public void play() {
//Your code goes here
int count = 1;
boolean same = true;
while(same) {
int first = roll();
int second = roll();
int third = roll();
System.out.println(first + " " + second + " " + third);
if(first != second && second != third && first != third) {
System.out.println("Rolled " + count + " times before all the rolls were different");
same = false;
} else {
count++;
}
}
}
/**
* Answer to question 3 goes here
* when loop ends, this will be true
*
* (first == second) || (second == third) || (first == third)
*
* negation will be !(first == second) || (second == third) || (first == third)
* and after using demorgans law, it becomes,
* first != second && second != third && first != third
*/
} | [
"[email protected]"
] | |
a5f64ea4ff5170ca424a4bce8d8e697134a29000 | 0b778b573b3eaaefe92953e29bbe6da0088e636d | /src/main/java/com/tsystems/tshop/domain/User.java | 53c75d0cdbc3776b7f25bfa1c331c61711ea8d82 | [] | no_license | leriil/tjavaschool | 4d953ebaa577d04229659cce688acffa94d30e91 | 2f1227a47e7be92eaa6f7d9a71e4f38269cba815 | refs/heads/master | 2020-03-29T02:10:44.954129 | 2018-12-08T18:16:55 | 2018-12-08T18:16:55 | 149,423,775 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,106 | java | package com.tsystems.tshop.domain;
import com.tsystems.tshop.domain.util.LocalDateConverter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@Entity
@Table(name = "user")
@SqlResultSetMapping(
name = "userTopMapping",
classes = @ConstructorResult(
targetClass = UserTop.class,
columns = {
@ColumnResult(name = "userId", type = Long.class),
@ColumnResult(name = "name"),
@ColumnResult(name = "surname"),
@ColumnResult(name = "email"),
@ColumnResult(name = "moneySpent", type = BigDecimal.class)
}))
public class User implements UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long userId;
@ManyToMany(cascade = {
CascadeType.PERSIST,
CascadeType.MERGE,
})
@JoinTable(name = "user_role",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "role_id")
)
private Set<Role> roles = new HashSet<>();
@ManyToOne
@JoinColumn(name = "address_id")
private Address address = new Address();
@Column(name = "login", nullable = false, unique = true, updatable = false)
@Pattern(regexp = "^[a-zA-Z0-9]{2,15}$", message = "Your username contains invalid characters or is too short.")
private String login;
@Column(name = "password", unique = true, nullable = false)
private String password;
@Column(name = "confirm_password", nullable = false)
private String confirmPassword;
@Pattern(regexp = "^[A-Z][a-z]+$", message = "Your name contains invalid characters.")
@Column(name = "name", nullable = false)
private String name;
@Pattern(regexp = "^[A-Z][a-z]+$", message = "Your surname contains invalid characters.")
@Column(name = "surname", nullable = false)
private String surname;
@Past(message = "It has to be a past date.")
@Column(name = "birth_date")
@Convert(converter = LocalDateConverter.class)
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate birthDate;
@NotBlank(message = "example: [email protected]")
@Column(name = "email", nullable = false, unique = true)
private String email;
public User() {
}
public User(String login, String password) {
this.login = login;
this.password = password;
}
public User(String login, String password, String name, String surname, String email) {
this.login = login;
this.password = password;
this.name = name;
this.surname = surname;
this.email = email;
}
public User(String login, String password, List<GrantedAuthority> roles) {
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Set<Role> roles = this.getRoles();
List<String> privileges = new ArrayList<>();
for (Role role : roles) {
privileges.add(role.getName());
}
return privileges.stream()
.map(SimpleGrantedAuthority::new).collect(Collectors.toList());
}
@Override
public String getUsername() {
return login;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getConfirmPassword() {
return confirmPassword;
}
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public LocalDate getBirthDate() {
return birthDate;
}
public void setBirthDate(LocalDate birthDate) {
this.birthDate = birthDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
@Override
public String toString() {
return "User{" +
"userId=" + userId +
", roles=" + roles +
", address=" + address +
", login='" + login + '\'' +
", password='" + password + '\'' +
", name='" + name + '\'' +
", surname='" + surname + '\'' +
", birthDate=" + birthDate +
", email='" + email + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
32a9b3bf572624665a5eefa36c5dca4361396680 | 6aa0a9a0333c9aeb5b0cbaa000122ee7d597be55 | /app/src/main/java/com/john/jmusicstore/ui/RegisterActivity.java | f3c70c8466860773eeb85b092e487f99d8b9e6b0 | [] | no_license | JohnhoJ1/JMusicStore | 6d043545d0d35cdf42b9484796b951c7ed02693c | b66674f5a95ecbb6053248d2a3861ba362dc1791 | refs/heads/master | 2021-01-13T21:52:10.609636 | 2020-02-23T13:31:00 | 2020-02-23T13:31:00 | 242,506,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,420 | java | package com.john.jmusicstore.ui;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.john.jmusicstore.MainActivity;
import com.john.jmusicstore.R;
import com.john.jmusicstore.api.UserAPI;
import com.john.jmusicstore.model.User;
import com.john.jmusicstore.server_response.SignUpResponse;
import com.john.jmusicstore.url.URL;
import java.util.Random;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RegisterActivity extends AppCompatActivity {
private TextView login_text;
private EditText etName, etEmail, etPhoneNumber, etSMSCode, etPasswordRegister;
private Button btnSendSMS, btnSignUp;
Random r = new Random();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getSupportActionBar().hide();
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_register);
etSMSCode = findViewById(R.id.etSMSCode);
etPhoneNumber = findViewById(R.id.etPhoneNumber);
etName = findViewById(R.id.etName);
etEmail = findViewById(R.id.etEmail);
etPasswordRegister = findViewById(R.id.etPasswordRegister);
btnSendSMS = findViewById(R.id.btnSendSMS);
btnSignUp = findViewById(R.id.btnSignUp);
login_text = findViewById(R.id.login_text);
btnSendSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (TextUtils.isEmpty(etPhoneNumber.getText().toString())){
etPhoneNumber.setError("Enter Phone Number");
return;
}
final int random = (int)(Math.random() * 9999 + 0000);
etSMSCode.postDelayed(new Runnable() {
@Override
public void run() {
etSMSCode.setText(Integer.toString(random));
}
}, 3000);
}
});
login_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
startActivity(intent);
}
});
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phone = etPhoneNumber.getText().toString();
String password = etPasswordRegister.getText().toString();
String name = etName.getText().toString();
String email = etEmail.getText().toString();
User users = new User(name, email, password, phone);
UserAPI usersAPI = URL.getInstance().create(UserAPI.class);
Call<SignUpResponse> signUpCall = usersAPI.registerUser(users);
signUpCall.enqueue(new Callback<SignUpResponse>() {
@Override
public void onResponse(Call<SignUpResponse> call, Response<SignUpResponse> response) {
if (!response.isSuccessful()) {
Toast.makeText(RegisterActivity.this, "Code " + response.code(), Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(RegisterActivity.this, "Successfully Registered", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
startActivity(intent);
}
@Override
public void onFailure(Call<SignUpResponse> call, Throwable t) {
Toast.makeText(RegisterActivity.this, "Register Unsuccessful" + t.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
}
}
| [
"email [at] [email protected]"
] | email [at] [email protected] |
93c42e882f9c57de8bf104fda0afab83ae6f7956 | 3eae40691a6cd509c9c07e03c9d4654441497ea2 | /src/infpp/Fish.java | 0a14c674ffd72f3082b414ba33ae0663e082d70c | [] | no_license | Hope1282/oceanLife | 33594063c560de654fdbe322b58e01af7d6b902a | 440aecf394d36d909cf37fa5255407d383f54393 | refs/heads/master | 2021-01-19T15:33:09.329286 | 2014-10-13T07:05:57 | 2014-10-13T07:05:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,350 | java | package infpp;
public class Fish extends OceanObject {
/**Bewegung in x-Richtung invertieren*/
private boolean invX = false;
/**Bewegung in y-Richtung invertieren*/
private boolean invY = false;
/**Erbt Konstruktoren von Oceanobject*/
public Fish() {
}
public Fish(int[] position, String name, String object) {
super(position, name, object);
}
public Fish(int x, int y, String name, String object) {
super(x, y, name, object);
}
/**Dreht um, wenn er an eine Wand stoesst*/
public void swim() {
if(super.getPosition()[0] == Ocean.getInstance().getWidth()-71){
invX = true;
} else if(super.getPosition()[0] == 0){
invX = false;
}
if(super.getPosition()[1] == Ocean.getInstance().getDepth()-71){
invY = true;
} else if(super.getPosition()[1] == 0){
invY = false;
}
if(invX){
super.getPosition()[0]-=1;
} else {
super.getPosition()[0]+=1;
}
if(invY){
super.getPosition()[1]-=1;
} else {
super.getPosition()[1]+=1;
}
}
/**Bewegt Fish immer nur um einen pixel weiter, um zu verhindern,
* dass er z.B. den Rand des Ocean ueberspringt*/
public void move() {
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
this.swim();
}
}
| [
"[email protected]"
] | |
c980b985cfa4348519f1a23afc7b55edfec48f34 | 02dc2110c96a8b1b2294fdfa86d28cb93937e9a0 | /src/main/java/com/example/muza10k/services/SongServiceImpl.java | fa0e19dcdb757633a819a69054c0901d818b2f09 | [] | no_license | CWAN1ACZEK/MuzyczkaV3 | e6fb8b15ff17f3005d1859a6fbeb9b259f76d693 | fd6f510a0929a711f3b859ea04702103f11fa9be | refs/heads/main | 2023-03-06T13:22:31.955718 | 2021-02-20T17:12:22 | 2021-02-20T17:12:22 | 340,705,367 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,999 | java | package com.example.muza10k.services;
import com.example.muza10k.api.domain.SongDTO;
import com.example.muza10k.api.mapper.SongMapper;
import com.example.muza10k.repositories.SongRepository;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SongServiceImpl implements SongService{
SongRepository songRepository;
SongMapper songMapper;
public SongServiceImpl(SongRepository songRepository, SongMapper songMapper) {
this.songRepository = songRepository;
this.songMapper = songMapper;
}
@Override
public List<SongDTO> getAllSongs() {
return songRepository.getAllSongs()
.stream()
.map(songMapper::songToSongDTO)
.collect(Collectors.toList());
}
@Override
public SongDTO getSongById(Long id) {
return songMapper.songToSongDTO(songRepository.findById(id).get());
}
@Override
public List<SongDTO> getSongByTitle(String title) {
return songRepository.getAllSongs()
.stream()
.map(songMapper::songToSongDTO)
.collect(Collectors.toList());
}
@Override
public List<SongDTO> getSongByIsmn(String ismn) {
return songRepository.getAllSongs()
.stream()
.map(songMapper::songToSongDTO)
.collect(Collectors.toList());
}
@Override
public List<SongDTO> getSongByYear(String year) {
return songRepository.getAllSongs()
.stream()
.map(songMapper::songToSongDTO)
.collect(Collectors.toList());
}
@Override
public List<SongDTO> getSongByGenre(String genre) {
return songRepository.getAllSongs()
.stream()
.map(songMapper::songToSongDTO)
.collect(Collectors.toList());
}
}
| [
"[email protected]"
] | |
26cc99b76727797b6c635532964d945461ca12b9 | 28a4e0b601b556a2ad17652f5ea2b6e35b77b61d | /src/main/java/shanghai/shu/config/Protocol.java | 9e10276f6034b5e17a9455be24abd85d1107453a | [] | no_license | jacob12122/SimpleDuubo | d7dbb52475da1cd87b8e5f92ea1cb537473f527f | 8f49dee46432d24f1a481b4a8d899d08e3f8fb0d | refs/heads/master | 2023-01-13T11:45:18.700012 | 2020-11-20T07:33:35 | 2020-11-20T07:33:35 | 314,479,451 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,488 | java | package shanghai.shu.config;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import shanghai.shu.remoting.netty.server.NettyServer;
public class Protocol extends BaseConfigBean implements ApplicationContextAware,ApplicationListener<ContextRefreshedEvent> {
private static final long serialVersionUID = 7082032188443659845L;
private String name;
private String host;
private String port;
private String contextpath;
private String threads;
private String serialize;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getContextpath() {
return contextpath;
}
public void setContextpath(String contextPath) {
this.contextpath = contextPath;
}
public String getThreads() {
return threads;
}
public void setThreads(String threads) {
this.threads = threads;
}
public String getSerialize() {
return serialize;
}
public void setSerialize(String serialize) {
this.serialize = serialize;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContextHolder.setApplicationContext(applicationContext);
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (!ContextRefreshedEvent.class.getName().equals(event.getClass().getName())){
return;
}
final Protocol protocol=this;
if ("netty".equals(name)){
new Thread(new Runnable() {
@Override
public void run() {
try {
NettyServer.start(protocol);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
}
}
| [
"[email protected]"
] | |
79ec25346bd06444cb17c0458983626a9f3099ba | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/1/1_61cb9a1016d9ab6d6c28c65c757de473f28e3b5e/InsertBatchAction/1_61cb9a1016d9ab6d6c28c65c757de473f28e3b5e_InsertBatchAction_t.java | e7363dc26cd62a72bfe06298e82376f296aacf4b | [] | 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 | 1,371 | java | package org.javasimon.testapp;
import org.javasimon.testapp.test.Action;
import org.javasimon.testapp.model.Tuple;
import org.javasimon.testapp.model.Tuples;
import org.javasimon.testapp.model.TupleDAO;
import org.javasimon.Split;
import org.javasimon.SimonManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;
/**
* Class InsertBatchAction.
*
* @author Radovan Sninsky
* @since 2.0
*/
public class InsertBatchAction implements Action {
private static final int COUNT = 28;
private Connection conn;
/**
* Insert batch action constructor.
*
* @param conn SQL connection
*/
public InsertBatchAction(Connection conn) {
this.conn = conn;
}
/**
* Inserts batch.
*
* @param runno run number
*/
public void perform(int runno) {
Split split = SimonManager.getStopwatch("org.javasimon.testapp.action.insertbatch").start();
System.out.println("Run: " + runno + ", InsertBatchAction [count: " + COUNT + "]");
List<Tuple> list = new ArrayList<Tuple>(COUNT);
for (Tuple t : new Tuples(COUNT)) {
list.add(t);
}
try {
new TupleDAO(conn, "tuple").save(list);
} catch (SQLException e) {
System.err.println(e.getMessage());
}
split.stop();
}
}
| [
"[email protected]"
] | |
039e6448b654f0c0b0b0c18ad9190d8bf6c1fe4b | 72c6e5bf7e0145d3e10fc983f801abafa9d77e0c | /src/main/java/ru/inbox/savinov_vu/core/scheduler/resetGuest/ResetGuestJob.java | 4845cfdc6ca0f50e22da854a6d0b2c6af360067a | [] | no_license | savinovvu/reg-exp | 76d7c66942e5a424e2709079b738fbc6ffb605db | 5191c9708830851bfecb13d3f268dd84f8370a32 | refs/heads/master | 2023-03-09T15:51:34.888190 | 2022-04-01T08:10:06 | 2022-04-01T08:10:06 | 130,526,896 | 1 | 0 | null | 2023-03-03T03:15:51 | 2018-04-22T01:59:30 | Java | UTF-8 | Java | false | false | 493 | java | package ru.inbox.savinov_vu.core.scheduler.resetGuest;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
@RequiredArgsConstructor
public class ResetGuestJob {
@Resource
private final ResetGuestService resetGuestService;
@Scheduled(cron = "${scheduler.cron.guest-reset}")
public void invoke() {
resetGuestService.resetGuest();
}
}
| [
"[email protected]"
] | |
a6fba63c0a7619d7ab0305395b6c78632c215538 | 3c293c8d912fc862958bfce1e6cf7b783e5f7225 | /src/khosro/views/RankPage.java | 7068f430cce873f69a0111f9cfe854aa953911f4 | [] | no_license | khosravi-am/plants-vs-zombie | d1e3f89bcde98a0c6a99cb25a482c2dfe48324dd | f02fd2d60caafc854e14a7691b62f34019f17b61 | refs/heads/master | 2023-05-02T23:41:44.756642 | 2021-02-03T19:01:19 | 2021-02-03T19:01:19 | 328,310,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,245 | java | package khosro.views;
import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class RankPage extends JFrame implements MouseListener, MouseMotionListener {
/**
* Invoked when the mouse button has been clicked (pressed
* and released) on a component.
*
* @param e the event to be processed
*/
@Override
public void mouseClicked(MouseEvent e) {
}
/**
* Invoked when a mouse button has been pressed on a component.
*
* @param e the event to be processed
*/
@Override
public void mousePressed(MouseEvent e) {
}
/**
* Invoked when a mouse button has been released on a component.
*
* @param e the event to be processed
*/
@Override
public void mouseReleased(MouseEvent e) {
}
/**
* Invoked when the mouse enters a component.
*
* @param e the event to be processed
*/
@Override
public void mouseEntered(MouseEvent e) {
}
/**
* Invoked when the mouse exits a component.
*
* @param e the event to be processed
*/
@Override
public void mouseExited(MouseEvent e) {
}
/**
* Invoked when a mouse button is pressed on a component and then
* dragged. {@code MOUSE_DRAGGED} events will continue to be
* delivered to the component where the drag originated until the
* mouse button is released (regardless of whether the mouse position
* is within the bounds of the component).
* <p>
* Due to platform-dependent Drag&Drop implementations,
* {@code MOUSE_DRAGGED} events may not be delivered during a native
* Drag&Drop operation.
*
* @param e the event to be processed
*/
@Override
public void mouseDragged(MouseEvent e) {
}
/**
* Invoked when the mouse cursor has been moved onto a component
* but no buttons have been pushed.
*
* @param e the event to be processed
*/
@Override
public void mouseMoved(MouseEvent e) {
}
public void render() {
}
}
| [
"[email protected]"
] | |
d5992885d7e5c61706fe20e16c0d18a092da0e23 | 7461b52f428467c37ff51b84c6751c7e1b481c71 | /src/Frame1.java | 81aef73d497013abe6a20ca42e5fea3854710e3f | [] | no_license | miftah789/modul7 | 8558f2a6d057b3a0c3941ab71d5360b913b1f790 | 0ff671988202bf84f7328900341f8f1b3f9ed46c | refs/heads/master | 2020-07-18T04:59:00.424534 | 2016-11-16T13:52:01 | 2016-11-16T13:52:01 | 73,923,452 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,671 | 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.
*/
/**
*
* @author Asus
*/
public class Frame1 extends javax.swing.JFrame {
/**
* Creates new form Frame1
*/
public Frame1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
Jurusan = new javax.swing.ButtonGroup();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
Nama = new javax.swing.JTextField();
Absen = new javax.swing.JTextField();
Alamat = new javax.swing.JTextField();
rpl = new javax.swing.JRadioButton();
tkj = new javax.swing.JRadioButton();
Kelas = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 102, 102));
jLabel2.setText("Nama");
getContentPane().add(jLabel2);
jLabel2.setBounds(60, 50, 80, 30);
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 102, 102));
jLabel3.setText("Absen");
getContentPane().add(jLabel3);
jLabel3.setBounds(60, 90, 80, 30);
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(0, 102, 102));
jLabel4.setText("Kelas");
getContentPane().add(jLabel4);
jLabel4.setBounds(60, 130, 80, 30);
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel5.setForeground(new java.awt.Color(0, 102, 102));
jLabel5.setText("Jurusan");
getContentPane().add(jLabel5);
jLabel5.setBounds(60, 160, 80, 30);
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel6.setForeground(new java.awt.Color(0, 102, 102));
jLabel6.setText("Alamat");
getContentPane().add(jLabel6);
jLabel6.setBounds(60, 204, 80, 20);
Nama.setBackground(new java.awt.Color(204, 255, 204));
Nama.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Nama.setForeground(new java.awt.Color(0, 102, 102));
Nama.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NamaActionPerformed(evt);
}
});
getContentPane().add(Nama);
Nama.setBounds(140, 50, 150, 30);
Absen.setBackground(new java.awt.Color(204, 255, 204));
Absen.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Absen.setForeground(new java.awt.Color(0, 102, 102));
Absen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AbsenActionPerformed(evt);
}
});
getContentPane().add(Absen);
Absen.setBounds(140, 90, 150, 30);
Alamat.setBackground(new java.awt.Color(204, 255, 204));
Alamat.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Alamat.setForeground(new java.awt.Color(0, 102, 102));
Alamat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AlamatActionPerformed(evt);
}
});
getContentPane().add(Alamat);
Alamat.setBounds(140, 200, 150, 30);
rpl.setBackground(new java.awt.Color(204, 255, 204));
Jurusan.add(rpl);
rpl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
rpl.setForeground(new java.awt.Color(0, 102, 102));
rpl.setText("RPL");
rpl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rplActionPerformed(evt);
}
});
getContentPane().add(rpl);
rpl.setBounds(140, 170, 60, 25);
tkj.setBackground(new java.awt.Color(204, 255, 204));
Jurusan.add(tkj);
tkj.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
tkj.setForeground(new java.awt.Color(0, 102, 102));
tkj.setText("TKJ");
getContentPane().add(tkj);
tkj.setBounds(220, 170, 70, 25);
Kelas.setBackground(new java.awt.Color(204, 255, 204));
Kelas.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Kelas.setForeground(new java.awt.Color(0, 102, 102));
Kelas.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
KelasActionPerformed(evt);
}
});
getContentPane().add(Kelas);
Kelas.setBounds(140, 130, 150, 30);
jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 102, 102));
jButton1.setText("Exit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(210, 250, 90, 30);
jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton2.setForeground(new java.awt.Color(0, 102, 102));
jButton2.setText("Send");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(110, 250, 90, 30);
jPanel1.setBackground(new java.awt.Color(204, 255, 204));
jPanel1.setLayout(null);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(0, 102, 102));
jLabel1.setText("BIODATA");
jPanel1.add(jLabel1);
jLabel1.setBounds(180, 4, 110, 30);
jLabel7.setIcon(new javax.swing.ImageIcon("D:\\shizuka.png")); // NOI18N
jPanel1.add(jLabel7);
jLabel7.setBounds(320, 50, 130, 120);
getContentPane().add(jPanel1);
jPanel1.setBounds(0, 0, 460, 300);
setBounds(0, 0, 475, 338);
}// </editor-fold>//GEN-END:initComponents
private void NamaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NamaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_NamaActionPerformed
private void AbsenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AbsenActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_AbsenActionPerformed
private void AlamatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AlamatActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_AlamatActionPerformed
private void rplActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rplActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_rplActionPerformed
private void KelasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_KelasActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_KelasActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
String nama = Nama.getText();
String absen = Absen.getText();
String kelas = Kelas.getText();
String jurusan;
String alamat = Alamat.getText();
if(rpl.isSelected())
jurusan = "RPL";
else if(tkj.isSelected())
jurusan = "TKJ";
else
jurusan = " ";
new Frame2(nama, absen, kelas, jurusan, alamat).setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
dispose();
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Frame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Frame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Frame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Frame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frame1().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField Absen;
private javax.swing.JTextField Alamat;
private javax.swing.ButtonGroup Jurusan;
private javax.swing.JTextField Kelas;
private javax.swing.JTextField Nama;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JRadioButton rpl;
private javax.swing.JRadioButton tkj;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
d0cd51c628cd863dfbf4fbe4c155cd38f74e5799 | 9daf83e02ad3fc504f57932cb3f6ffe132d862ec | /lib/client/src/main/java/net/i2p/client/DomainServerSocket.java | fca062d17b47f4b9298e866afee6830ac085e2f9 | [
"LicenseRef-scancode-infineon-free",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | i2p/i2p.android.base | 2374ea3363d217b9fd9061f4f3e89038ebc72634 | 41ca3fe527cc0d28a2d1902b78d796f4001c423c | refs/heads/master | 2023-07-23T19:46:10.283475 | 2023-07-05T22:18:32 | 2023-07-05T22:18:32 | 11,885,610 | 104 | 47 | NOASSERTION | 2023-06-15T17:30:33 | 2013-08-04T21:50:12 | Java | UTF-8 | Java | false | false | 3,809 | java | package net.i2p.client;
import android.net.LocalServerSocket;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.nio.channels.ServerSocketChannel;
/**
* Bridge to LocalServerSocket.
* <p/>
* accept() returns a real Socket (a DomainSocket).
* <p/>
* DomainServerSockets are always bound.
* You may not create an unbound DomainServerSocket.
* Create this through the DomainSocketFactory.
*
* @author str4d
* @since 0.9.14
*/
class DomainServerSocket extends ServerSocket {
private final LocalServerSocket mLocalServerSocket;
private final DomainSocketFactory mDomainSocketFactory;
private volatile boolean mClosed;
/**
* @throws IOException
*/
public DomainServerSocket(String name, DomainSocketFactory domainSocketFactory) throws IOException {
this(new LocalServerSocket(name), domainSocketFactory);
}
/**
* Used for testing.
*
* @throws IOException
*/
DomainServerSocket(LocalServerSocket localServerSocket, DomainSocketFactory domainSocketFactory) throws IOException {
mLocalServerSocket = localServerSocket;
mDomainSocketFactory = domainSocketFactory;
}
/**
* @throws IOException
*/
@Override
public Socket accept() throws IOException {
return mDomainSocketFactory.createSocket(mLocalServerSocket.accept());
}
/**
* @throws UnsupportedOperationException always
*/
@Override
public void bind(SocketAddress endpoint) {
throw new UnsupportedOperationException();
}
/**
* @throws UnsupportedOperationException always
*/
@Override
public void bind(SocketAddress endpoint, int backlog) {
throw new UnsupportedOperationException();
}
/**
* @throws IOException
*/
@Override
public void close() throws IOException {
mLocalServerSocket.close();
mClosed = true;
}
/**
* @return null always
*/
@Override
public ServerSocketChannel getChannel() {
return null;
}
/**
* @return null always
*/
@Override
public InetAddress getInetAddress() {
return null;
}
/**
* @return -1 always
*/
@Override
public int getLocalPort() {
return -1;
}
/**
* @return null always
*/
@Override
public SocketAddress getLocalSocketAddress() {
return null;
}
/**
* @throws UnsupportedOperationException always
*/
@Override
public int getReceiveBufferSize() {
throw new UnsupportedOperationException();
}
/**
* @return false always
*/
@Override
public boolean getReuseAddress() {
return false;
}
/**
* @throws UnsupportedOperationException always
*/
@Override
public int getSoTimeout() {
throw new UnsupportedOperationException();
}
/**
* @return true always
*/
@Override
public boolean isBound() {
return true;
}
@Override
public boolean isClosed() {
return mClosed;
}
/**
* Does nothing.
*/
@Override
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
}
/**
* Does nothing.
*/
@Override
public void setReceiveBufferSize(int size) {
}
/**
* Does nothing.
*/
@Override
public void setReuseAddress(boolean on) {
}
/**
* Does nothing.
*/
@Override
public void setSoTimeout(int timeout) throws SocketException {
}
@Override
public String toString() {
return mLocalServerSocket.toString();
}
}
| [
"[email protected]"
] | |
3bd34b662fc0c741bc13ad5714939adeaa4b2c6e | a39543d6df647d0590e4944497c285e199e51a36 | /task4/src/main/java/PersonTask/FileOps.java | 48fb33c530d463449c16c9ef4eb5d54a83cd1119 | [] | no_license | DmPerepechko/JD2-Course | f27bb2392a50fcf792a6e2b124028e03932ea509 | febb9d9258108413010b9ad1994e646183640ceb | refs/heads/master | 2023-08-19T05:30:22.354869 | 2021-10-04T15:55:54 | 2021-10-04T15:55:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,018 | java | package PersonTask;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class FileOps implements Writable {
static final String FILE = "TaskTest.txt";
@Override
public void write(List<Person> list) {
try (ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(FILE))) {
for (Person person : list) {
output.writeObject(person);
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public List read() {
List<Person> list = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(FILE);
ObjectInputStream input = new ObjectInputStream(fis)) {
while (fis.available() > 0) {
Person person = (Person) input.readObject();
list.add(person);
}
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return list;
}
}
| [
"[email protected]"
] | |
b98b8193b9285912b0bff0a8774a90a12e8f3f0e | 7afd20edbed4e378a8d576a3a18ae2a59df96e47 | /app/src/main/java/com/xiaowei/android/wht/ui/TransferTreatmentFragment.java | e48fe6ae04563b592e2468117dbf49deafeb549d | [] | no_license | fsh596847/wht | 343a23b591ad38ab88b9fc616dff086a8d0015eb | 69e4583e46133975ae3e64454e48f16d55e919e7 | refs/heads/master | 2020-12-24T06:43:12.686968 | 2017-01-13T05:42:26 | 2017-01-13T05:42:26 | 73,458,730 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,929 | java | package com.xiaowei.android.wht.ui;
import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.xiaowei.android.wht.R;
import com.xiaowei.android.wht.SpData;
import com.xiaowei.android.wht.beans.Patient;
import com.xiaowei.android.wht.model.HttpResult;
import com.xiaowei.android.wht.service.DataService;
import com.xiaowei.android.wht.utils.mLog;
import com.xiaowei.android.wht.utis.HlpUtils;
import com.xiaowei.android.wht.utis.SyncImageLoaderListview;
import com.xiaowei.android.wht.utis.SyncImageLoaderListview.OnImageLoadListener;
import com.xiaowei.android.wht.utis.Utils;
import com.xiaowei.android.wht.views.CircularImage;
public class TransferTreatmentFragment extends Fragment {
private ListView listView;
private List<Patient> listPatient;
private MyPatientAdapter patientAdapter;
private int state;
private String areaid;
//分页刷新
private int p;
private int page;
private boolean success;//是否更新成功
private boolean isQuery;//是否正在更新
private boolean isFinish;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_transfer_treatment, container, false);
p = 1;
page = 15;
success = true;
isQuery = true;
isFinish = false;
listPatient = new ArrayList<Patient>();
init(view);
return view;
}
private void init(View view) {
listView = (ListView) view.findViewById(R.id.listview_transfer_treatment);
patientAdapter = new MyPatientAdapter(getActivity(), listView);
listView.setAdapter(patientAdapter);
queryDoctorReferral(-1, null,false);
patientAdapter.setOnImageLoadListener(new OnImageLoadListener() {
@Override
public void onImageLoad(Integer t, Drawable drawable, CircularImage ivHead,Integer index) {
listPatient.get(t).setDrawable(drawable);
}
@Override
public void onError(Integer t) {
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
startActivityForResult(new Intent(getActivity(), PatientStateActivity.class)
.putExtra("Patient", listPatient.get(arg2)), PatientStateActivity.resultCode_stateChange);
getActivity().overridePendingTransition(R.anim.in_right,0);
}
});
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (firstVisibleItem != 0 && !isFinish) {
//判断可视Item是否能在当前页面完全显示
if (visibleItemCount+firstVisibleItem == totalItemCount) {
if(success && isQuery){
p+=1;
queryDoctorReferral(state, areaid,false);
}
}
}
}
});
}
public void queryDoctorReferral(final int state, final String areaid,final boolean isOut){
if(isOut){
p = 1;
page = 15;
isFinish = false;
listPatient.clear();
}
isQuery = false;
this.state = state;
this.areaid = areaid;
reload("正在努力加载……");
new Thread(new Runnable() {
@Override
public void run() {
try {
SpData spData = new SpData(getActivity());
String s = DataService.queryDoctorReferral(getActivity(), state, spData.getStringValue(SpData.keyId, null)
, spData.getStringValue(SpData.keyPhoneUser, null), areaid,null,null,p,page);
mLog.d("http", "s:"+s);
if (!isDestroy && !HlpUtils.isEmpty(s)){
HttpResult hr = JSON.parseObject(s,HttpResult.class);
if (hr != null){
if (hr.isSuccess()){
success = true;
if(!isDestroy){
if(hr.getTotalpage()==p){
isFinish = true;
}
/*if(listPatient == null){
listPatient = JSON.parseArray(hr.getData().toString(), Patient.class);
}
else{*/
List<Patient> list = JSON.parseArray(hr.getData().toString(), Patient.class);
listPatient.addAll(list);
/*}*/
getActivity().runOnUiThread(new Runnable(){
@Override
public void run() {
patientAdapter.setList(listPatient);
}
});
}
}else{
if(p==1){
if(listPatient != null){
listPatient.clear();
}
getActivity().runOnUiThread(new Runnable(){
@Override
public void run() {
patientAdapter.setList(listPatient);
}
});
}
}
}else{
success = false;
}
}else{
}
}catch (Exception he) {
he.printStackTrace();
}
closeLoadingDialog();
isQuery = true;
}
}).start();
}
private void reload(String text){
if (loadingDialog == null){
loadingDialog = Utils.createLoadingDialog(getActivity(), text);
}
if (!loadingDialog.isShowing()){
loadingDialog.show();
}
}
private Dialog loadingDialog = null;
private void closeLoadingDialog() {
if(null != loadingDialog) {
loadingDialog.dismiss();
loadingDialog = null;
}
}
boolean isDestroy = false;
@Override
public void onStart() {
super.onStart();
isFinish = false;
isDestroy = false;
}
@Override
public void onDestroy() {
super.onDestroy();
isFinish = true;
isDestroy = true;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (resultCode) {
case PatientStateActivity.resultCode_stateChange:
queryDoctorReferral(state, areaid,true);
break;
}
}
private class MyPatientAdapter extends BaseAdapter {
@SuppressLint("HandlerLeak")
Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
notifyDataSetChanged();
break;
default:
break;
}
};};
List<Patient> listPatient = new ArrayList<Patient>();
ListView mListView;
private Drawable[] drawables;
private LayoutInflater mInflater = null;
private Context mContext;
SyncImageLoaderListview.OnImageLoadListener mImageLoadListener;
private MyPatientAdapter(Context context, ListView lvPatient)
{
this.mInflater = LayoutInflater.from(context);
mContext = context;
mListView = lvPatient;
mListView.setOnScrollListener(onScrollListener);
}
private void setList(List<Patient> list)
{
if(list!=null){
if(list.size()>0){
drawables = new Drawable[list.size()];
}
this.listPatient = list;
notifyDataSetChanged();
}
}
private void setOnImageLoadListener(SyncImageLoaderListview.OnImageLoadListener mImageLoadListener){
this.mImageLoadListener = mImageLoadListener;
}
@Override
public int getCount() {
return listPatient.size();
}
@Override
public Object getItem(int arg0) {
return listPatient.get(arg0);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup arg2) {
ViewHolder holder;
if(convertView == null)
{
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_my_patient, null);
holder.ivHead = (CircularImage) convertView.findViewById(R.id.iv_item_my_patient_headphoto);
holder.tvName = (TextView) convertView.findViewById(R.id.tv_my_patient_name);
holder.tvIllnessname = (TextView) convertView.findViewById(R.id.tv_my_patient_illnessname);
holder.tvPatientdesc = (TextView) convertView.findViewById(R.id.tv_my_patient_patientdesc);
holder.tvInfo = (TextView) convertView.findViewById(R.id.tv_my_patient_info);
holder.tvState = (TextView) convertView.findViewById(R.id.tv_my_patient_state);
holder.tvDate = (TextView) convertView.findViewById(R.id.tv_my_patient_date);
convertView.setTag(holder);
}else
{
holder = (ViewHolder)convertView.getTag();
}
if(getCount()>0)
{
Patient expert = listPatient.get(position);
String name = expert.getPatientname();
if(name != null){
holder.tvName.setText(name);
}
else {
holder.tvName.setText("");
}
String illnessname = expert.getIllnessname();
if(illnessname != null){
holder.tvIllnessname.setText("疾病名称:"+illnessname);
}
else {
holder.tvIllnessname.setText("");
}
String patientdesc = expert.getPatientdesc();
if(patientdesc != null){
holder.tvPatientdesc.setText("病情描述:"+patientdesc);
}
else {
holder.tvPatientdesc.setText("");
}
String acceptdoctorname = expert.getAcceptdoctorname();
if(acceptdoctorname == null || "null".equals(acceptdoctorname)){
acceptdoctorname = "无";
holder.tvInfo.setTextColor(Color.GRAY);
}
holder.tvInfo.setText("专家:"+acceptdoctorname);
String booking = expert.getBookingDayMonth();
String state = "";
switch (expert.getState()) {
case 5:
state = "未响应";
holder.tvState.setTextColor(Color.parseColor("#f44e06"));
holder.tvDate.setVisibility(View.GONE);
break;
case 4:
state = "已拒绝";
holder.tvState.setTextColor(Color.parseColor("#f44e06"));
holder.tvDate.setVisibility(View.GONE);
break;
case 0:
state = "待接诊";
holder.tvState.setTextColor(Color.parseColor("#ee5775"));
holder.tvDate.setVisibility(View.GONE);
break;
case 1:
state = "待预约";
holder.tvState.setTextColor(Color.parseColor("#199BFC"));
holder.tvDate.setVisibility(View.GONE);
break;
case 2:
state = "已预约";
holder.tvState.setTextColor(Color.parseColor("#199BFC"));
if(booking != null){
holder.tvDate.setText(booking);
holder.tvDate.setTextColor(Color.WHITE);
holder.tvDate.setBackgroundColor(Color.parseColor("#199BFC"));
holder.tvDate.setVisibility(View.VISIBLE);
}else{
holder.tvDate.setVisibility(View.GONE);
}
break;
case 3:
state = "已完成";
holder.tvState.setTextColor(Color.GRAY);
if(booking != null){
holder.tvDate.setText(booking);
holder.tvDate.setTextColor(Color.parseColor("#cccccc"));
holder.tvDate.setBackgroundColor(Color.parseColor("#f7f7f7"));
holder.tvDate.setVisibility(View.VISIBLE);
}else{
holder.tvDate.setVisibility(View.GONE);
}
break;
}
holder.tvState.setText(state);
//Drawable d = syncImageLoader.getSoftReferenceDrawable(expert.getHeadimg());
Drawable d = drawables[position];
if(d != null){
holder.ivHead.setImageDrawable(d);
}
else{
holder.ivHead.setImageResource(R.drawable.ic_head);
syncImageLoader.loadImage(mContext,position,expert.getHeadimg(),imageLoadListener,holder.ivHead,0);
}
}
return convertView;
}
SyncImageLoaderListview.OnImageLoadListener imageLoadListener = new SyncImageLoaderListview.OnImageLoadListener(){
@Override
public void onImageLoad(Integer t, Drawable drawable,CircularImage view,Integer index) {
//View view = mListView.getChildAt(t);
if(view != null){
//CircularImage v = (CircularImage) view.findViewById(R.id.iv_item_my_patient_headphoto);
//v.setImageDrawable(drawable);
handler.sendEmptyMessage(0);
//view.setImageDrawable(drawable);
drawables[t] = drawable;
//mLog.d("http", "imageLoadListener onImageLoad view != null");
}
if(mImageLoadListener != null){
mImageLoadListener.onImageLoad(t, drawable, view, 0);
}
}
@Override
public void onError(Integer t) {
}
};
SyncImageLoaderListview syncImageLoader = new SyncImageLoaderListview();
public void loadImage(){
int start = mListView.getFirstVisiblePosition();
int end =mListView.getLastVisiblePosition();
if(end >= getCount()){
end = getCount() -1;
}
syncImageLoader.setLoadLimit(start, end);
syncImageLoader.unlock();
}
AbsListView.OnScrollListener onScrollListener = new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
case AbsListView.OnScrollListener.SCROLL_STATE_FLING:
syncImageLoader.lock();
break;
case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
loadImage();
break;
case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
syncImageLoader.lock();
break;
default:
break;
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}
};
class ViewHolder
{
private CircularImage ivHead;
private TextView tvName;
private TextView tvIllnessname;
private TextView tvPatientdesc;
private TextView tvInfo;
private TextView tvState;
private TextView tvDate;
}
}
}
| [
"[email protected]"
] | |
956a069015c2b5ba6dc5d28ce1f5436fae0d3f02 | a132731ad6ee9cec47691b8a6167d67de7535b45 | /src/main/java/com/mb/model/rental/RentalStatus.java | feedff227a542ae6c5dd66642f23a1b9bf2b87eb | [
"MIT"
] | permissive | srfunksensei/video-rental-store | 923c911b1321f24df34c3bbea516ce36584909c1 | f481c9081689e619b7eecbb939f425bf851e4e08 | refs/heads/master | 2021-08-16T13:11:13.707381 | 2021-07-27T12:30:49 | 2021-07-27T12:30:49 | 174,097,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 77 | java | package com.mb.model.rental;
public enum RentalStatus {
RENTED, RETURNED
}
| [
"[email protected]"
] | |
d83da79ee2a820fd71bf0a8a42d5644e9c439df8 | edf21ca5a0b2b06a13f4f30a97e3a698a870f5d2 | /app/src/main/java/com/golaspico/vanhyori/prov_hv3/CommunicatorTabb.java | 70257f3d5227e68c0a7692486a8fa36a33e96f58 | [] | no_license | AizenIlang/PROVHv3 | 417f219ca21a8c0abc13b6622a6346ac0421b259 | 1c2d3276113c29087f39178df1b1ffcb2dbb3c86 | refs/heads/master | 2020-03-31T05:05:12.511666 | 2019-02-05T19:46:42 | 2019-02-05T19:46:42 | 151,932,450 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 143 | java | package com.golaspico.vanhyori.prov_hv3;
import modules.Doctor;
interface CommunicatorTabb {
public void changeDoctor(Doctor doctor);
}
| [
"[email protected]"
] | |
968510f8af4bdffd8fcc06d7da127c4824b8b6f3 | cacf9f692ac35c14f6af7510bc19fa40ca65dc8d | /Pedidos/Logica/src/main/Java/InterfazLogica/VerEstadoPedidoLocal.java | c4d8c78f9652bf86d1e4b239ddf43497dec92dd7 | [] | no_license | SantiagoCaroprese/Arquitectura-de-software | faf21a2a7be9a8cdb0255b8882f3cd848c642697 | 89faf81fd63128bb4df00b72ffa31151b6ddd636 | refs/heads/main | 2023-05-13T14:05:47.855446 | 2021-06-03T20:11:49 | 2021-06-03T20:11:49 | 345,441,737 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 136 | java | package InterfazLogica;
import javax.ejb.Local;
@Local
public interface VerEstadoPedidoLocal {
String execute(String idPedido);
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.