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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7c60e74827250f1e912365b1e9f5a5c829b042b6 | 1ba7c8166bf70bc19559fb36da53142df2b8abd4 | /MegaHibernateTest/src/main/java/manytomany/User.java | 39126658859ed59bc436a10f3de13f96f6024d22 | [] | no_license | zm-dksg/AC_Exercises | a2b5417d6dc6f7c6c4740367e5fa81f2348ff82c | d51957d78557d894aeaaf46d039ba3aa2db7f707 | refs/heads/main | 2023-07-04T10:57:13.524150 | 2021-08-13T10:39:59 | 2021-08-13T10:39:59 | 390,671,546 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 867 | java | package manytomany;
import javax.persistence.*;
import java.util.LinkedList;
import java.util.List;
@Entity
@Table(name = "user")
public class User {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
private Integer userID;
private String username;
@ManyToMany(fetch = FetchType.EAGER)
private List<Chat> chatList;
public User() {
chatList = new LinkedList<>();
}
public void addChat(Chat chat) {
chatList.add(chat);
}
public Integer getUserID() {
return userID;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public List<Chat> getChatList() {
return chatList;
}
public void setChatList(List<Chat> chatList) {
this.chatList = chatList;
}
}
| [
"[email protected]"
] | |
031cdd7756a1b3b1f90303d0e7a5409ae86cac9a | 2c4bd981bb3e94655040fcbb840250461aa430e7 | /vibes-selection/src/test/java/be/unamur/transitionsystem/test/selection/JaccardDissimilarityComputorTest.java | 49a689908f21f690a59b5379bf58f4bb79a318cc | [
"MIT"
] | permissive | SEDB/vibes | f3cc10d5d935d385e9e7eb5bbb50fa585b87dbfd | 4c62f7a7c4b77f290be1d654b1d9908726bc9e31 | refs/heads/master | 2020-03-15T12:33:13.599542 | 2018-02-06T10:58:16 | 2018-02-06T10:58:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,712 | 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 be.unamur.transitionsystem.test.selection;
import java.util.Set;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import static be.unamur.transitionsystem.test.selection.TestUtils.*;
import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Xavier Devroey - [email protected]
*/
public class JaccardDissimilarityComputorTest {
private static final Logger logger = LoggerFactory.getLogger(JaccardDissimilarityComputorTest.class);
@Rule
public TestRule watcher = new TestWatcher() {
@Override
protected void starting(Description description) {
logger.info(String.format("Starting test: %s()...",
description.getMethodName()));
}
;
};
@Test
public void testGetDistanceNoIntersect() {
JaccardDissimilarityComputor<Set<Character>> dist = new JaccardDissimilarityComputor();
String str1 = "abc";
String str2 = "def";
double expected = 0.0;
assertThat(dist.getDistance(toSet(str1), toSet(str2)), equalTo(expected));
}
@Test
public void testGetDistanceIntersect() {
JaccardDissimilarityComputor<Set<Character>> dist = new JaccardDissimilarityComputor();
String str1 = "abcde";
String str2 = "def";
double expected = 2.0 / 6.0;
assertThat(dist.getDistance(toSet(str1), toSet(str2)), equalTo(expected));
}
@Test
public void testGetDistanceSame() {
JaccardDissimilarityComputor<Set<Character>> dist = new JaccardDissimilarityComputor();
String str = "abcde";
double expected = 1.0;
assertThat(dist.getDistance(toSet(str), toSet(str)), equalTo(expected));
}
@Test
public void testGetDistanceEmpty() {
JaccardDissimilarityComputor<Set<Character>> dist = new JaccardDissimilarityComputor();
String str = "";
double expected = 1.0;
assertThat(dist.getDistance(toSet(str), toSet(str)), equalTo(expected));
}
@Test
public void testGetDistanceOneEmpty() {
JaccardDissimilarityComputor<Set<Character>> dist = new JaccardDissimilarityComputor();
String str1 = "";
String str2 = "abcdef";
double expected = 0.0;
assertThat(dist.getDistance(toSet(str1), toSet(str2)), equalTo(expected));
}
} | [
"[email protected]"
] | |
794ee1b2649914d97b1afc5aa10abc0185e6f0bd | 905bf27f9f2800fd9572940ed5b30e402b943d44 | /src/module-info.java | c931d0416dce3084da14e1469c035314274c05ab | [] | no_license | tajirhas9/CodeIT | b829b034bf09ae19322efa23aab677636aa278e4 | 446dcdfda5f8308a88c3c654a35316e2d98b3949 | refs/heads/master | 2020-04-17T12:44:02.407709 | 2019-01-19T20:36:26 | 2019-01-19T20:36:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 112 | java | /**
*
*/
/**
* @author tajir
*
*/
module SampleProject {
requires java.desktop;
requires java.logging;
} | [
"[email protected]"
] | |
431e084b63354060a80a6040acb1f5d410ede1f9 | c890e2c73323267f4d23c3020dcaeb7d89830e66 | /app/src/main/java/com/vijayelectronics/utils/ValidateInputs.java | 30f298f4f35cd26c344ffadc4db254b13ece4f73 | [] | no_license | KarthikDigit/VijayElectronics | 07d841ba62b1bbca3fdebffd734a77302bd73e38 | b3852bffa212e3ec01c1434e2f414b00391a0574 | refs/heads/master | 2022-05-29T22:07:48.729717 | 2020-04-30T07:04:10 | 2020-04-30T07:04:10 | 260,137,591 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,991 | java | package com.vijayelectronics.utils;
import android.text.TextUtils;
import android.util.Patterns;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* ValidateInputs class has different static methods, to validate different types of user Inputs
**/
public class ValidateInputs {
private static String blockCharacters = "[$&+~;=\\\\?|/'<>^*%!-]";
//*********** Validate Email Address ********//
public static boolean isValidEmail(String email) {
return !TextUtils.isEmpty(email) && Patterns.EMAIL_ADDRESS.matcher(email).matches();
}
//*********** Validate Name Input ********//
public static boolean isValidName(String name) {
String regExpn = "^([a-zA-Z ]{1,24})+$";
if (name.equalsIgnoreCase(""))
return false;
CharSequence inputStr = name;
Pattern pattern = Pattern.compile(blockCharacters, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return !pattern.matcher(inputStr).find();
}
//*********** Validate User Login ********//
public static boolean isValidLogin(String login) {
String regExpn = "^([a-zA-Z]{4,24})?([a-zA-Z][a-zA-Z0-9_]{4,24})$";
CharSequence inputStr = login;
Pattern pattern = Pattern.compile(regExpn, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return matcher.matches();
}
//*********** Validate Password Input ********//
public static boolean isValidPassword(String password) {
String regExpn = "^[a-z0-9_$@.!%*?&]{6,24}$";
CharSequence inputStr = password;
Pattern pattern = Pattern.compile(regExpn, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return matcher.matches();
}
//*********** Validate Phone Number********//
public static boolean isValidPhoneNo(String phoneNo) {
return !TextUtils.isEmpty(phoneNo) && Patterns.PHONE.matcher(phoneNo).matches();
}
//*********** Validate Number Input ********//
public static boolean isValidNumber(String number) {
String regExpn = "^[0-9]{1,24}$";
CharSequence inputStr = number;
Pattern pattern = Pattern.compile(regExpn, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return matcher.matches();
}
//*********** Validate Any Input ********//
public static boolean isValidInput(String input) {
String regExpn = "(.*?)?((?:[a-z][a-z]+))";
if (input.equalsIgnoreCase(""))
return false;
CharSequence inputStr = input;
Pattern pattern = Pattern.compile(blockCharacters, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return !pattern.matcher(inputStr).find();
}
//*********** Validate Any Input ********//
public static boolean isIfValidInput(String input) {
CharSequence inputStr = input;
Pattern pattern = Pattern.compile(blockCharacters, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return !pattern.matcher(inputStr).find();
}
//*********** Validate Search Query ********//
public static boolean isValidSearchQuery(String query) {
String regExpn = "^([a-zA-Z]{1,24})?([a-zA-Z][a-zA-Z0-9_]{1,24})$";
CharSequence inputStr = query;
Pattern pattern = Pattern.compile(regExpn, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
return matcher.matches();
}
}
| [
"[email protected]"
] | |
84c680947c21d0d99c5498f905364fa4c45da9b0 | 5b8337c39cea735e3817ee6f6e6e4a0115c7487c | /sources/com/pierfrancescosoffritti/androidyoutubeplayer/BuildConfig.java | 0c13c441b8319b9be6ac7860279d416b704f8ebf | [] | no_license | karthik990/G_Farm_Application | 0a096d334b33800e7d8b4b4c850c45b8b005ccb1 | 53d1cc82199f23517af599f5329aa4289067f4aa | refs/heads/master | 2022-12-05T06:48:10.513509 | 2020-08-10T14:46:48 | 2020-08-10T14:46:48 | 286,496,946 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 439 | java | package com.pierfrancescosoffritti.androidyoutubeplayer;
public final class BuildConfig {
public static final String APPLICATION_ID = "com.pierfrancescosoffritti.androidyoutubeplayer";
public static final String BUILD_TYPE = "release";
public static final boolean DEBUG = false;
public static final String FLAVOR = "";
public static final int VERSION_CODE = 8;
public static final String VERSION_NAME = "8.0.1";
}
| [
"[email protected]"
] | |
e3b6df1125f029a0c221b44286de269120b023b8 | 7af715232453498777f0092640477db024805f61 | /RandomWarriors/app/src/main/java/geekybytes/randomwarriors/MainActivity.java | 045aff560e12c2493de0b962b31d62158871d9c0 | [] | no_license | Barbarian-JD/RandomWarriors | 7ae1e1122fc3fbd995ae0443023d9bb9b3323ccc | 3cbba6c2f467bf4e2dd8ba460a4d420bd7190e21 | refs/heads/master | 2021-05-02T13:08:29.820246 | 2015-07-21T22:05:15 | 2015-07-21T22:05:15 | 36,541,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,799 | java | package geekybytes.randomwarriors;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.widget.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import geekybytes.randomwarriors.R;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.plus.Plus;
import com.google.android.gms.plus.model.people.Person;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
public class MainActivity extends Activity implements OnClickListener, ConnectionCallbacks, OnConnectionFailedListener {
private static final int RC_SIGN_IN = 0;
private ProgressBar progress;
// Google client to communicate with Google
private static GoogleApiClient mGoogleApiClient;
private boolean mIntentInProgress;
private boolean signedInUser;
private ConnectionResult mConnectionResult;
private SignInButton signinButton;
// private ImageView image;
// private TextView username,
private TextView emailLabel;
private static LinearLayout profileFrame, signinFrame;
private int logged=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logged = getIntent().getIntExtra("loggedout",0);
signinButton = (SignInButton) findViewById(R.id.signin);
signinButton.setOnClickListener(this);
progress = (ProgressBar) findViewById(R.id.progressbar);
//image = (ImageView) findViewById(R.id.image);
// username = (TextView) findViewById(R.id.username);
emailLabel = (TextView) findViewById(R.id.email);
profileFrame = (LinearLayout) findViewById(R.id.profileFrame);
signinFrame = (LinearLayout) findViewById(R.id.signinFrame);
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API, Plus.PlusOptions.builder().build()).addScope(Plus.SCOPE_PLUS_LOGIN).build();
}
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
private void resolveSignInError() {
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
} catch (SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
return;
}
if (!mIntentInProgress) {
// store mConnectionResult
mConnectionResult = result;
if (signedInUser) {
resolveSignInError();
}
}
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
switch (requestCode) {
case RC_SIGN_IN:
if (responseCode == RESULT_OK) {
signedInUser = false;
}
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
break;
}
}
@Override
public void onConnected(Bundle arg0) {
signedInUser = false;
if(logged==1)
Toast.makeText(this, "Logged out", Toast.LENGTH_SHORT).show();
else {
Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show();
}
getProfileInformation();
}
private void updateProfile(boolean isSignedIn, String email) {
if (isSignedIn) {
if(logged==0)
{
signinFrame.setVisibility(View.GONE);
//profileFrame.setVisibility(View.VISIBLE);
new check_user_signup(email, "http://randomwarriors.byethost7.com/userTest.php").execute(null, null, null);
// ihome.putExtra("pname",pname);
// ihome.putExtra("picurl",picurl);
}
else
{
/*signinFrame.setVisibility(View.GONE);
profileFrame.setVisibility(View.VISIBLE);
logged=0;*/
if (mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();}
signinFrame.setVisibility(View.VISIBLE);
//profileFrame.setVisibility(View.GONE);
isSignedIn=false;
logged=0;
}
} else {
if (mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
//mGoogleApiClient.disconnect();
//mGoogleApiClient.connect();
}
signinFrame.setVisibility(View.VISIBLE);
profileFrame.setVisibility(View.GONE);
}
}
class check_user_signup extends AsyncTask<String, String, String> {
public boolean running = true;
HttpResponse response;
private InputStream is;
String host, email;
public check_user_signup(String email, String host) {
this.email = email;
this.host = host;
}
@Override
protected void onPreExecute() {
progress.setVisibility(View.VISIBLE);
}
@Override
protected void onCancelled() {
running = false;
}
@Override
protected String doInBackground(String... params) {
ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(new BasicNameValuePair("email", email));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(host);
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");
try {
if (running) {
httppost.setEntity(new UrlEncodedFormEntity(list));
// Execute HTTP Post Request
response = httpclient.execute(httppost);
if (response != null) {
is = response.getEntity().getContent();
}
}
} catch (Exception e) {
System.out.println(e);
// TODO Auto-generated catch block
}
return null;
}
@Override
protected void onPostExecute(String Result) {
if (running) {
Reader reader = new InputStreamReader(is);
int status = 0;
String message = "";
try {
JsonParser parser = new JsonParser();
JsonObject data = parser.parse(reader).getAsJsonObject();
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
Type Integer = new TypeToken<Integer>() {}.getType();
Type String = new TypeToken<String>() {}.getType();
if (running) {
status = gson.fromJson(data.get("success"), Integer); //EDIT THIS LINE FOR WHICH DATA NEEDED FROM JSON
message = gson.fromJson(data.get("message"), String);
}
} catch (Exception e) {
e.printStackTrace();
}
SharedPreferences saved_values = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = saved_values.edit();
editor.putString("email", email);
editor.apply();
Intent ihome = new Intent(getApplicationContext(), HomeActivity.class);
ihome.putExtra("email",email);
ihome.putExtra("signup_status", status);
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
startActivity(ihome);
finish();
}
progress.setVisibility(View.GONE);
}
}
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
//Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
//String personName = currentPerson.getDisplayName();
//String personPhotoUrl = currentPerson.getImage().getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
//username.setText(personName);
emailLabel.setText(email);
//new LoadProfileImage(image).execute(personPhotoUrl);
// update profile frame with new info about Google Account
// profile
//updateProfile(true,personName,personPhotoUrl,email);
updateProfile(true, email);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onConnectionSuspended(int cause) {
mGoogleApiClient.connect();
updateProfile(false,"null");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.signin:
googlePlusLogin();
break;
}
}
public void signIn(View v) {
googlePlusLogin();
}
public void logout(View v) {
googlePlusLogout();
}
private void googlePlusLogin() {
if (!mGoogleApiClient.isConnecting()) {
signedInUser = true;
resolveSignInError();
}
}
private void googlePlusLogout() {
if (mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
updateProfile(false,"null");
}
}
// download Google Account profile image, to complete profile
/*private class LoadProfileImage extends AsyncTask<String, Void, Bitmap> {
ImageView downloadedImage;
public LoadProfileImage(ImageView image) {
this.downloadedImage = image;
}
protected Bitmap doInBackground(String... urls) {
String url = urls[0];
Bitmap icon = null;
try {
InputStream in = new java.net.URL(url).openStream();
icon = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return icon;
}
protected void onPostExecute(Bitmap result) {
downloadedImage.setImageBitmap(result);
}
}*/
} | [
"[email protected]"
] | |
1156dc94101bc560c7d808a390d02315a26cd604 | a97da6edc24ddd7e6d020781e09b1f929525bd0a | /src/javaProject/Rectangle.java | e49a5068b84a191780d2968f2619f8d286a6b893 | [] | no_license | sechae0528/javaProject2 | dd97e8cb6d82a20d553d142f15eb13207d999efe | 14495d71a932c568165d54f2c26a57f64ab7cfdf | refs/heads/master | 2020-03-09T16:44:07.015723 | 2018-04-26T07:36:29 | 2018-04-26T07:36:29 | 128,892,619 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 280 | java | package javaProject;
public class Rectangle {
int width; //필드 ==> public을 생략하면 default (public이 더 큰 범위)
int height;
int getArea(){
return width*height;
}
public Rectangle(){
}
public Rectangle(int a, int b){
width = a;
height = b;
}
}
| [
"[email protected]"
] | |
b06537858c13bfc03f59e10afba82675f8dea8b6 | 1d6f626cb42f06d6180ef88fababc9c4269f1133 | /reference-test/src/test/java/au/org/consumerdatastandards/conformance/transactions/ListTransactionsTest.java | 600e4590e849b22c09d15b26d5431d24d072fc9e | [
"MIT"
] | permissive | darkedges/java-artefacts | 4ea573851a2b8cca279db97a0765e4860fe1c805 | 2caf60bc8889f3633172582386d77ccc9f303cc4 | refs/heads/master | 2021-01-06T03:38:05.131236 | 2020-02-03T04:50:58 | 2020-02-03T04:50:58 | 241,213,471 | 0 | 0 | MIT | 2020-02-17T21:39:35 | 2020-02-17T21:39:34 | null | UTF-8 | Java | false | false | 1,783 | java | package au.org.consumerdatastandards.conformance.transactions;
import net.serenitybdd.junit.runners.SerenityParameterizedRunner;
import net.thucydides.junit.annotations.UseTestDataFrom;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SerenityParameterizedRunner.class)
@UseTestDataFrom("testdata/banking-transactions-api-params.csv")
public class ListTransactionsTest extends TransactionsAPITestBase {
private String accountId;
private String oldestTime;
private String newestTime;
private String minAmount;
private String maxAmount;
private String text;
private Integer page;
private Integer pageSize;
@Test
public void listTransactions() {
if (StringUtils.isBlank(steps.getApiBasePath())) {
return;
}
steps.getTransactions(accountId, oldestTime, newestTime, minAmount, maxAmount, text, page, pageSize);
steps.validateGetTransactionsResponse(accountId, oldestTime, newestTime, minAmount, maxAmount, text, page, pageSize);
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public void setOldestTime(String oldestTime) {
this.oldestTime = oldestTime;
}
public void setNewestTime(String newestTime) {
this.newestTime = newestTime;
}
public void setMinAmount(String minAmount) {
this.minAmount = minAmount;
}
public void setMaxAmount(String maxAmount) {
this.maxAmount = maxAmount;
}
public void setText(String text) {
this.text = text;
}
public void setPage(Integer page) {
this.page = page;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
| [
"[email protected]"
] | |
012f3faf53c149de42ea56cf5dd48e3c23969221 | 45e84ca3e622947af8cb5c46e1c3774bedc4c19a | /app/src/main/java/com/ruijia/qrdemo/function/ZbarOpenAct.java | c32197ba90490ada8f0efa220d3cd815f89527d5 | [] | no_license | 66668/FastQrDemo | 3703e551040ec540ca08bb7c7c1a0a810a6b5289 | 2a7c1b68a3353f9d37310761d7b36e988316f7bf | refs/heads/master | 2020-04-08T19:10:34.827933 | 2019-09-10T10:06:15 | 2019-09-10T10:06:15 | 159,643,453 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 19,223 | java | package com.ruijia.qrdemo.function;
import android.Manifest;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.hardware.Camera;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.ruijia.qrdemo.R;
import com.ruijia.qrdemo.persmission.PermissionHelper;
import com.ruijia.qrdemo.persmission.PermissionInterface;
import com.ruijia.qrdemo.utils.CodeUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import cn.qqtheme.framework.picker.FilePicker;
import lib.ruijia.zbar.ZBarView;
import lib.ruijia.zbar.qrcodecore.BarcodeType;
import lib.ruijia.zbar.qrcodecore.QRCodeView;
/**
* zbar识别方式 开路识别 后置摄像头
* <p>
* 开路:只负责发送,或只负责识别,通过标记位决定 数据是否发送或结束。
* <p>
* 闭路:接收端:识别完一条数据,返回二维码告知更新数据,等待识别新数据。
* 发送端:触发按钮,发送二维码数据,发送端等待识别端的二维码(返回 更新数据的通知),接收后再发送新数据
* <p>
* 读取txt文件
* https://github.com/journeyapps/zxing-android-embedded
* 使用功能:持续识别+前置摄像头+margin
*/
public class ZbarOpenAct extends AppCompatActivity implements View.OnClickListener, QRCodeView.Delegate {
//权限相关
private String[] permissionArray;
PermissionHelper permissionHelper;
//控件
private ZBarView mZBarView; //zbar
private ImageView img_result;
private Button btn_select, btn_show;
//相机
int cameraId = Camera.CameraInfo.CAMERA_FACING_FRONT;//
// int cameraId = Camera.CameraInfo.CAMERA_FACING_BACK;//
//生成二维码使用
private int size = 400;//200就够了,再大也没用
//test数据
private List<String> orgDatas = new ArrayList<>();//发送数据
private List<String> receiveDatas = new ArrayList<>();//接收数据,用于保存到txt中
private int receiveLength = 0;//发送端传过来的数据长度,用于比较接收端数据是否有缺失。
private File saveFile;//识别内容保存到txt中
//操作流程控制
private long totalSize;//接收文件大小
private Handler handler;
private String lastText;
private long startTime;//发送开始时间
private long overTime;//接收结束时间
private long receiveTime;//摄像头一直识别,记录识别时间使用,如果识别时间超过MAX_TIME,自动结束识别流程
private static final long TIME_SIZE = 1000;//转s单位
private static final long PSOTDELAY_TIME = 800;//发送间隔时间
private int sendTimes = 0;//发送次数,一次发送,到下一次再发送,为一次,
//=====================================识别流程控制==========================================
/**
* zbar极限速度 140ms--200ms。
*/
//QRCodeView.Delegate
@Override
public void onScanQRCodeSuccess(String resultStr) {
Log.d("SJY", "扫描结果为:" + resultStr);
mZBarView.startSpot(); // 延迟0.1秒后开始识别
//结果相同不处理
if (TextUtils.isEmpty(resultStr) || resultStr.equals(lastText)) {
Log.d("SJY", "重复扫描");
if (resultStr != null && resultStr.contains("识别完了")) {
showBitmap("识别完了");
if (orgDatas == null || orgDatas.size() <= 0) {//接收端识别
handOver(true);
} else {
handOver(false);
}
return;
}
return;
}
//
final String result = resultStr;
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("SJY", "识别速度=" + (System.currentTimeMillis() - receiveTime)+"--长度="+result.length());
receiveTime = System.currentTimeMillis();
//显示扫描str结果
lastText = result;
//判断发送端/接收端
if (orgDatas == null || orgDatas.size() <= 0) {//接收端识别
vibrate();
if (result.contains("listSize=")) {//开路识别标记,数据开始识别的地方:listSize=12
String[] arr = result.split("=");
receiveLength = Integer.parseInt(arr[1]);//获取数据大小
//接收端时间统计--开始
startTime = System.currentTimeMillis();
receiveTime = System.currentTimeMillis();
} else {
totalSize += result.length();
Log.d("SJY", "size=" + result.length() + "--total=" + totalSize);
receiveDatas.add(result);//保存接收数据,
}
} else {//发送端识别
Log.d("SJY", "我是发送端,zBarOpenAct时,不识别数据");
}
}
});
}
//QRCodeView.Delegate
@Override
public void onScanQRCodeOpenCameraError() {
Log.e("SJY", "QRCodeView.Delegate--ScanQRCodeOpenCameraError()");
}
/**
* 发送二维码
*/
private void startShow() {
//发送端时间统计
startTime = System.currentTimeMillis();
receiveTime = System.currentTimeMillis();
sendTimes = 0;
handler.postDelayed(sendtask, 3000);
}
Runnable sendtask = new Runnable() {
@Override
public void run() {
if (sendTimes < orgDatas.size()) {
showBitmap(orgDatas.get(sendTimes));
sendTimes++;
handler.postDelayed(this, PSOTDELAY_TIME);
} else {
showBitmap("识别完了");
handOver(false);
}
}
};
/**
* 异常或正常结束,都走这一步,结束识别,但是识别端不会关闭二维码预览,只会清空数据,等待再次识别新数据
*
* @param isReceive true 接收端
*/
private void handOver(boolean isReceive) {
overTime = System.currentTimeMillis();
//统计结果
StringBuffer buffer = new StringBuffer();
long time = (overTime - startTime);
if (isReceive) {
Log.i("SJY", "接收端统计:总耗时 = " + time + "ms");
Log.i("SJY", "发送数据长度=" + receiveLength + "---接收实际长度=" + receiveDatas.size() + "--数据大小" + totalSize + "B");
if (receiveDatas != null && receiveDatas.size() > 0) {
for (String str : receiveDatas) {
buffer.append(str).append("\n");
}
}
} else {
buffer.append("发送端统计:总耗时 = " + time + "ms").append("\n")
.append("发送list.size=" + orgDatas.size() + "次").append("\n")
.append("发送次数 = " + sendTimes + "次");
Log.d("SJY", buffer.toString());
}
}
/**
* 重新初始化流程控制参数
*/
private void initParams() {
startTime = 0;
overTime = 0;
receiveTime = 0;
sendTimes = 0;
receiveDatas = new ArrayList<>();
orgDatas = new ArrayList<>();
btn_show.setVisibility(View.GONE);
saveFile = null;
img_result.setBackground(ContextCompat.getDrawable(this, R.mipmap.ic_launcher));
}
//=====================================复写==========================================
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_zbar_open);
initView();
//必要权限
permissionArray = new String[]{
Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
};
toStartPermission();
}
/**
* 初始化控件
*/
private void initView() {
//控件
btn_select = findViewById(R.id.btn_select);
btn_show = findViewById(R.id.btn_show);
btn_show.setVisibility(View.GONE);
btn_show.setOnClickListener(this);
btn_select.setOnClickListener(this);
//zbar
mZBarView = (ZBarView) findViewById(R.id.zbarview);
mZBarView.setDelegate(this);
//
img_result = (ImageView) findViewById(R.id.barcodePreview);
img_result.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//点击图片重新唤醒
if (mZBarView != null) {
mZBarView.startSpotAndShowRect(); // 显示扫描框,并且延迟0.1秒后开始识别
}
initParams();
}
});
//设置宽高
size = 400;
//保存识别内容-->根目录/save.txt
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "save.txt";
saveFile = new File(path);
if (saveFile != null) {
saveFile.delete();
}
saveFile = new File(path);
handler = new Handler();
}
private void vibrate() {
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
vibrator.vibrate(200);
}
/**
* 开始识别(其实布局绑定就已经识别,此处设置识别样式)
*/
private void startPreview() {
//前置摄像头(不加显示后置)
mZBarView.startCamera(); // 打开后置摄像头开始预览,但是并未开始识别
mZBarView.setType(BarcodeType.ONLY_QR_CODE, null); // 只识别 QR_CODE
mZBarView.getScanBoxView().setOnlyDecodeScanBoxArea(true); // 仅识别扫描框中的码
// mZBarView.startCamera(cameraId); // 打开前置摄像头开始预览,但是并未开始识别
mZBarView.startSpotAndShowRect(); // 显示扫描框,并且延迟0.1秒后开始识别
}
@Override
protected void onStart() {
super.onStart();
if (mZBarView != null) {
mZBarView.startCamera(); // 打开后置摄像头开始预览,但是并未开始识别
mZBarView.getScanBoxView().setOnlyDecodeScanBoxArea(true); // 仅识别扫描框中的码
mZBarView.setType(BarcodeType.ONLY_QR_CODE, null); // 只识别 QR_CODE
// mZBarView.startCamera(cameraId); // 打开前置摄像头开始预览,但是并未开始识别
mZBarView.startSpotAndShowRect(); // 显示扫描框,并且延迟0.1秒后开始识别
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_select:
//文件选择器
FilePicker picker = new FilePicker(this, FilePicker.FILE);
picker.setShowHideDir(false);
picker.setRootPath(Environment.getExternalStorageDirectory().getAbsolutePath());
picker.setAllowExtensions(new String[]{".txt"});
picker.setFileIcon(getResources().getDrawable(android.R.drawable.ic_menu_agenda));
picker.setFolderIcon(getResources().getDrawable(android.R.drawable.ic_menu_upload_you_tube));
//picker.setArrowIcon(getResources().getDrawable(android.R.drawable.arrow_down_float));
picker.setOnFilePickListener(new FilePicker.OnFilePickListener() {
@Override
public void onFilePicked(String currentPath) {
Log.d("SJY", "currentPath=" + currentPath);
initParams();
if (!TextUtils.isEmpty(currentPath)) {
getRealFile(currentPath);
}
}
});
picker.show();
break;
case R.id.btn_show:
//显示二维码
startShow();
break;
}
}
@Override
protected void onResume() {
super.onResume();
if (mZBarView != null) {
//前置摄像头(不加显示后置)
mZBarView.startCamera(); // 打开后置摄像头开始预览,但是并未开始识别
mZBarView.setType(BarcodeType.ONLY_QR_CODE, null); // 只识别 QR_CODE
mZBarView.getScanBoxView().setOnlyDecodeScanBoxArea(true); // 仅识别扫描框中的码
// mZBarView.startCamera(cameraId); // 打开前置摄像头开始预览,但是并未开始识别
mZBarView.startSpotAndShowRect(); // 显示扫描框,并且延迟0.1秒后开始识别
}
}
@Override
protected void onPause() {
super.onPause();
if (mZBarView != null) {
mZBarView.stopCamera(); // 关闭摄像头预览,并且隐藏扫描框
}
}
@Override
protected void onStop() {
mZBarView.stopCamera(); // 关闭摄像头预览,并且隐藏扫描框
super.onStop();
}
@Override
protected void onDestroy() {
mZBarView.onDestroy(); // 销毁二维码扫描控件
handler.removeCallbacks(sendtask);
super.onDestroy();
}
private void toStartPermission() {
permissionHelper = new PermissionHelper(this, new PermissionInterface() {
@Override
public int getPermissionsRequestCode() {
//设置权限请求requestCode,只有不跟onRequestPermissionsResult方法中的其他请求码冲突即可。
return 10002;
}
@Override
public String[] getPermissions() {
//设置该界面所需的全部权限
return permissionArray;
}
@Override
public void requestPermissionsSuccess() {
//权限请求用户已经全部允许
startPreview();
}
@Override
public void requestPermissionsFail() {
}
});
//发起调用:
permissionHelper.requestPermissions();
}
//权限回调处理
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (permissionHelper.requestPermissionsResult(requestCode, permissions, grantResults)) {
//权限请求已处理,不用再处理
return;
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
//=====================================private处理==========================================
/**
* 将绝对路径转成文件
*
* @param absolutePath
*/
private void getRealFile(String absolutePath) {
File file = new File(absolutePath);
if (file == null || !file.exists()) {
Toast.makeText(this, "没有txt文件", Toast.LENGTH_SHORT).show();
} else {
btn_show.setVisibility(View.VISIBLE);
initData(file);
}
}
/**
* 创建并显示
*
* @param content 不为空
* @return
*/
private void showBitmap(final String content) {
new AsyncTask<Void, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Void... voids) {
return CodeUtils.createByMultiFormatWriter(content, size);
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null) {
img_result.setImageBitmap(bitmap);
} else {
Log.e("SJY", "生成英文二维码失败");
Toast.makeText(ZbarOpenAct.this, "生成英文二维码失败", Toast.LENGTH_SHORT).show();
}
}
}.execute();
}
/**
* 创建数据
* <p>
* 将txt转成List<String>
*
* @param file
*/
@SuppressLint("StaticFieldLeak")
private void initData(final File file) {
//
if (!file.getName().contains("txt")) {
Toast.makeText(this, file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
return;
}
//
orgDatas = new ArrayList<>();
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... voids) {
String linStr;
try {
//1
FileInputStream inputStream = new FileInputStream(file);
long length = file.length();
Log.d("SJY", "文件大小=" + length + "B");
InputStreamReader inputReader = new InputStreamReader(inputStream, "utf-8");
BufferedReader buffReader = new BufferedReader(inputReader);
//2
while ((linStr = buffReader.readLine()) != null) {//读一行
orgDatas.add(linStr);
}
int size = orgDatas.size();
//添加标记位 首尾各一个
orgDatas.add(0, "listSize=" + size);//首位标记
orgDatas.add("识别完了");//尾标记
//打印 可删除
StringBuffer buffer = new StringBuffer();
for (String str : orgDatas) {
buffer.append(str).append("\n");
}
Log.d("SJY", "+orgDatas.size()=" + orgDatas.size() + "--str=" + buffer.toString());
//
inputStream.close();
inputReader.close();
buffReader.close();
return null;
} catch (Exception e) {
e.printStackTrace();
String s = "无法生成原始数据,无法转成二维码";
return s;
}
}
@Override
protected void onPostExecute(String s) {
if (s != null) {
Toast.makeText(ZbarOpenAct.this, s, Toast.LENGTH_SHORT).show();
btn_show.setVisibility(View.GONE);
return;
}
Log.d("SJY", "---orgDatas.size()=" + orgDatas.size());
btn_show.setVisibility(View.VISIBLE);
}
}.execute();
}
}
| [
"[email protected]"
] | |
d82f73ec360b492485074086f46c893d5270c628 | 009e01c42bb8c52c49e1fd7805617b2c11e234d0 | /src/cardgame/Card.java | 38bfc9f369547de17541e38546a6b3ea972f8963 | [] | no_license | RyanLadley/CardGame | 12237887771f212325f50a3f5a1a3731ac80564f | c9eaf56198b78b7978db950345e469d894b0b8e4 | refs/heads/master | 2021-01-10T15:28:57.040881 | 2016-01-17T02:15:15 | 2016-01-17T02:15:15 | 49,761,329 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,840 | java | package cardgame;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
public class Card {
private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private static int screenWidth = screenSize.width,
screenHeight = screenSize.height;
static int defaultWidth = screenWidth /12, defaultHeight = screenHeight/5;
BufferedImage CardImage;
int x, y, holdY, width, height, rotationAngle = 0, imageNumber;
boolean inPlay, rotate = false, darkSide, inHand = true, hideHand = false , discarded = false;
public Card(BufferedImage image, int x,int y,int width,int height, boolean Inplay, boolean Dark, int Image){
CardImage = image;
this.x = x;
this.y= y;
this.width = width;
this.height = height;
inPlay = Inplay;
darkSide = Dark;
imageNumber = Image;
}
public Card(){
//Only Used in Load
}
public static void changeScreenSize(int newWidth, int newHeight){
screenWidth = newWidth;
screenHeight = newHeight;
defaultWidth = newWidth /12;
defaultHeight = newHeight/5;
}
public BufferedImage getImage(){
return CardImage;
}
public void changeImage(BufferedImage NewImage){
CardImage = NewImage;
}
public void setImageNumber(int Number){
imageNumber = Number;
}
public int getImageNumber(){
return imageNumber;
}
public int getX(){
return x;
}
public void setX(int NewX){
x= NewX;
}
public int getY(){
return y;
}
public void setY(int NewY){
y= NewY;
}
public int getWidth(){
return width;
}
public void expandWidth(){
if(width*2 <= defaultWidth*2){
width = 5*width/2;
}
}
public void returnDefaultWidth(){
width = defaultWidth;
}
public void changeWidthBy(int n, int m){
width = n*width/m;
}
public int getHeight(){
return height;
}
public void expandHeight(){
if(height*2 <= defaultHeight*2){
holdY = y;
y -= 2*height/3;
height= 5*height/2;
if(y+height > screenHeight){
y = screenHeight - height-10;
}
}
}
public void returnDefaultHeight(){
if(height != defaultHeight){
y=holdY;
height = defaultHeight;
}
}
public void trueDefaultHeight(){
height = defaultHeight;
}
public void changeHeightBy(int n, int m){
height = n*height/m;
}
public void enlargeCard(){
expandWidth();
expandHeight();
}
public void returnDefaultSize(){
returnDefaultHeight();
returnDefaultWidth();
}
public boolean isInPlay(){
return inPlay;
}
public void changeInPlay(boolean Status){
inPlay = Status;
}
public boolean isRotated(){
return rotate;
}
public void rotateCard(boolean Answer){
rotate = Answer;
}
public int getRotation(){
return rotationAngle;
}
public void setRotationAngle(int Angle){
rotationAngle = Angle;
}
public void increaseRotation(){
if(rotationAngle == 270){
rotationAngle = 0;
}
else{
rotationAngle += 90;
}
}
public void changeDarkSide(boolean Value){
darkSide = Value;
}
public boolean isDarkSide(){
return darkSide;
}
public boolean isInHand(){
return inHand;
}
public void changeHandStatus(boolean Status){
inHand = Status;
}
public boolean isHandHidden(){
return hideHand;
}
public boolean isDiscarded(){
return discarded;
}
public void changeDiscarded(boolean Status){
discarded = Status;
}
public void changeHiddenHand(boolean Status){
hideHand = Status;
}
//This Method preforms checks if point, notably a mouse point, is over card
//Returns True If it does
public boolean isIntsersecting(Point mousePoint){
if( mousePoint.getX() >= x &&mousePoint.getX() <= x+width
&&mousePoint.getY() >= y &&mousePoint.getY() <=y+height){
return true;
}
else{
return false;
}
}
public String saveProperties(){
return x +"\n"+ y + "\n"+ rotationAngle +"\n"+ imageNumber+"\n"+inPlay+"\n"+rotate +"\n"+ darkSide+"\n"+ inHand +"\n"+ hideHand;
}
}
| [
"[email protected]"
] | |
8d837309a18b991f4c54dd647dec8f246786730b | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/yauaa/learning/2188/ParseUserAgentFunction.java | d1a3155f0f4f75c6c21e492739bbf60d7ab82b3c | [] | no_license | ASSERT-KTH/synthetic-checkstyle-error-dataset | 40e8d1e0a7ebe7f7711def96a390891a6922f7bd | 40c057e1669584bfc6fecf789b5b2854660222f3 | refs/heads/master | 2023-03-18T12:50:55.410343 | 2019-01-25T09:54:39 | 2019-01-25T09:54:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,088 | java | /*
* Yet Another UserAgent Analyzer
* Copyright (C) 2013-2018 Niels Basjes
*
* 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
*
* https://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 nl.basjes.parse.useragent.drill;
import io.netty.buffer.DrillBuf;
import org.apache.drill.exec.expr.DrillSimpleFunc;
import org.apache.drill.exec.expr.annotations.FunctionTemplate;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.annotations.Workspace;
import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
import org.apache.drill.exec.vector.complex.writer.BaseWriter;
import javax.inject.Inject;
@FunctionTemplate(
name = "parse_user_agent",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL
)
public class ParseUserAgentFunction implements DrillSimpleFunc {
@Param
NullableVarCharHolder input;
@Output
BaseWriter.ComplexWriter outWriter;
@Inject
DrillBuf outBuffer;
@Workspace
nl.basjes.parse
.useragent.UserAgentAnalyzer uaa;
@Workspace
java.util.List<String> allFields;
public void setup() {
uaa = nl.basjes.parse.useragent.drill.UserAgentAnalyzerPreLoader.getInstance();
allFields = uaa.getAllPossibleFieldNamesSorted();
}
public void eval() {
org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter queryMapWriter = outWriter.rootAsMap();
if (input.buffer == null) {
return;
}
String userAgentString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer);
if (userAgentString.isEmpty() || userAgentString.equals("null")) {
userAgentString = "";
}
nl.basjes.parse.useragent.UserAgent agent = uaa.parse(userAgentString);
for (String fieldName: agent.getAvailableFieldNamesSorted()) {
org.apache.drill.exec.expr.holders.VarCharHolder rowHolder = new org.apache.drill.exec.expr.holders.VarCharHolder();
String field = agent.getValue(fieldName);
if (field == null) {
field = "Unknown";
}
byte[] rowStringBytes = field.getBytes();
outBuffer.reallocIfNeeded(rowStringBytes.length);
outBuffer.setBytes(0, rowStringBytes);
rowHolder.start = 0;
rowHolder.end = rowStringBytes.length;
rowHolder.buffer = outBuffer;
queryMapWriter.varChar(fieldName).write(rowHolder);
}
}
}
| [
"[email protected]"
] | |
c5896227089231402f915b9b8213ee697bf7e45c | 6726185f48dfafa9254841c36813f0006dfa6f30 | /CollectionsFramework/src/main/java/pers/ztf/gather/dao/hsqldb/impl/StudentDaoHsqlImpl.java | 38e808cfe76ce1b220e37ed59ea0629c60b04a60 | [] | no_license | EnTaroAdunZ/StudentManagementSystem | a5650abfe0882f87d561533b4b5bb9a6e8287ca7 | 24a5d0a7142dbdf251451aae7e651cb492da04d2 | refs/heads/master | 2021-07-21T23:16:22.325288 | 2017-11-01T11:36:42 | 2017-11-01T11:36:42 | 109,123,307 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,200 | java | package main.java.pers.ztf.gather.dao.hsqldb.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import main.java.pers.ztf.gather.dao.hsqldb.StudentDaoHsql;
import main.java.pers.ztf.gather.po.Student;
public class StudentDaoHsqlImpl implements StudentDaoHsql{
// static Connection connection=null;
// static Statement stmt=null;;
String TABLE_NAME = "student";
String Create_FIELDS = "(id varchar(254),name varchar(254))";
String INSERT_SQL = "insert into "+TABLE_NAME+" values(?,?)" ;
String SELECT_SQL = "select * from "+TABLE_NAME ;
String SELECT_WITHID=" where id=?";
public void createStudentData() {
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
}
try(Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
Statement stmt = connection.createStatement();)
{
String sql1 = "create table IF NOT EXISTS "+TABLE_NAME+Create_FIELDS;
stmt.executeUpdate(sql1);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void insertStudents(List<Student> students) {
try {
createStudentData();
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
}
try(Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
PreparedStatement ps = connection.prepareStatement(INSERT_SQL);)
{
for(Student student:students) {
ps.setString(1, student.getId());
ps.setString(2, student.getName());
ps.execute();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public List<Student> selectStudents() {
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
}
List<Student> students=new ArrayList<>();
try(Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
Statement state = connection.createStatement();)
{
ResultSet resultSet=state.executeQuery(SELECT_SQL);
while(resultSet.next()) {
students.add(new Student(resultSet.getString(1), resultSet.getString(2)));
}
} catch (Exception e) {
e.printStackTrace();
}
return students;
}
@Override
public void insertStudent(Student student) {
try {
createStudentData();
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
}
try(Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
PreparedStatement ps = connection.prepareStatement(INSERT_SQL);)
{
ps.setString(1, student.getId());
ps.setString(2, student.getName());
ps.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public Student selectById(String id) {
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
}
Student student=null;
try(Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
PreparedStatement state = connection.prepareStatement(SELECT_SQL+SELECT_WITHID);)
{
state.setString(1, id);
ResultSet resultSet=state.executeQuery();
if(resultSet.next()) {
student=new Student(id, resultSet.getString(2));
}
} catch (Exception e) {
e.printStackTrace();
}
return student;
}
// public static void main(String[] args) {
// StudentDaoHsqlImpl studentDaoHsqlImpl=new StudentDaoHsqlImpl();
// studentDaoHsqlImpl.createStudentData();
// List<Student> list=new ArrayList<>();
// list.add(new Student("443", "233"));
// list.add(new Student("44", "3433"));
// studentDaoHsqlImpl.insertStudent(list);
//
//
// List<Student> list2=studentDaoHsqlImpl.selectStudents();
// for(Student stuent:list2) {
// System.out.println(stuent);
// }
//
// }
}
| [
"[email protected]"
] | |
88885efa6297403e4158a1cef65ff5a68fa2a492 | ad80e9f6f6476cc2d7e83fa56075b3264cc05a96 | /ATM dan Rekening/Rekening.java | e99a9f7ac076c9dc0e537d7bf720c637bc6bb85a | [] | no_license | risnandym/pboDRIVERCLASS-and-INHERITENCE | d3834d3ce8797149828d1523737bc2fdb5894940 | a78f2985c90b9bc924711375a63785e81989761b | refs/heads/master | 2020-05-22T11:47:58.768386 | 2019-05-13T02:25:45 | 2019-05-13T02:25:45 | 186,331,227 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | public class Rekening{
private String nama, alamat, tgllahir;
private int norek;
public void setNama(String nama){
this.nama=nama;
}
public String getNama(){
return this.nama;
}
public void setAlamat(String alamat){
this.alamat=alamat;
}
public String getAlamat(){
return this.alamat;
}
public void setTgllahir(String tgllahir){
this.tgllahir=tgllahir;
}
public String getTgllahir(){
return this.tgllahir;
}
public void setNorek(int norek){
this.norek=norek;
}
public int getNorek(){
return this.norek;
}
} | [
"[email protected]"
] | |
61e225232379874a02bbc551a9efa1d634fb93be | c99e60b5c28db9c0e6f2ff5685fca177d79a4e59 | /app/src/main/java/com/yahoo/americancurry/petpeeve/activities/PinnedListFragment.java | 43d68fde4d6ca5579c199f1524c5d0f537af5064 | [] | no_license | americanCurry/PetPeeve | 58bb91b3d3abacd625b60786be05f7a122da9190 | a040191371c1cbde162c739ca6a1b9efabd9aa37 | refs/heads/master | 2020-04-07T15:30:31.297322 | 2015-02-26T23:47:46 | 2015-02-26T23:47:46 | 31,046,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,013 | java | package com.yahoo.americancurry.petpeeve.activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by rakeshch on 2/25/15.
*/
public class PinnedListFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return super.onCreateView(inflater,container,savedInstanceState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize data which are not view related
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// After activity is done loading
}
@Override
public void onDestroy() {
super.onDestroy();
}
}
| [
"[email protected]"
] | |
4d7557f77b5077ce0aac81e55c0d14a89059ea36 | 7f9a50f02d486b35085c417218df5980d4fa9b3f | /spring-boot-dataprocessor/src/main/java/com/valten/support/FtpDownloadRunner.java | 66eaa158dbd82bdd0ab5e1b10e35d1d4539f2739 | [] | no_license | ichoukou/spring-boot | 0ac2b43c45f8cb45ba31bc917052833745eb1aab | 0823336847746886796ba8f15473de6329c08e38 | refs/heads/master | 2023-04-11T13:04:26.535624 | 2020-07-14T04:32:04 | 2020-07-14T04:32:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,273 | java | package com.valten.support;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.ModelCamelContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult;
/**
* 继承Application接口后项目启动时会按照执行顺序执行run方法
* 通过设置Order的value来指定执行的顺序
*
* @author huangyuanli
* @className FtpDownloadListener
* @package com.valten.listener
* @date 2020/7/12 10:58
**/
@Component
@Order(value = 1)
public class FtpDownloadRunner implements ApplicationRunner {
@Autowired
private FtpDownloadRoute ftpDownloadRoute;
@Override
public void run(ApplicationArguments args) throws Exception {
// 这是camel上下文对象,整个路由的驱动全靠它了。
ModelCamelContext camelContext = new DefaultCamelContext();
// 启动route
camelContext.start();
// 将我们的路由处理加入到上下文中
camelContext.addRoutes(ftpDownloadRoute);
}
}
| [
"[email protected]"
] | |
1f7f8b2e4417e88b74e6087eb2e2d5c1a5f117b1 | 87901d9fd3279eb58211befa5357553d123cfe0c | /bin/ext-commerce/commercefacades/testsrc/de/hybris/platform/commercefacades/order/converters/populator/ZoneDeliveryModePopulatorTest.java | 38460dcfa9d1f1ba66f0bb24f602a850e2ba2b6a | [] | no_license | prafullnagane/learning | 4d120b801222cbb0d7cc1cc329193575b1194537 | 02b46a0396cca808f4b29cd53088d2df31f43ea0 | refs/heads/master | 2020-03-27T23:04:17.390207 | 2014-02-27T06:19:49 | 2014-02-27T06:19:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,092 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2000-2013 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("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 hybris.
*
*
*/
package de.hybris.platform.commercefacades.order.converters.populator;
import de.hybris.bootstrap.annotations.UnitTest;
import de.hybris.platform.commercefacades.order.data.ZoneDeliveryModeData;
import de.hybris.platform.commerceservices.util.ConverterFactory;
import de.hybris.platform.converters.impl.AbstractPopulatingConverter;
import de.hybris.platform.deliveryzone.model.ZoneDeliveryModeModel;
import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@UnitTest
public class ZoneDeliveryModePopulatorTest
{
private AbstractPopulatingConverter<ZoneDeliveryModeModel, ZoneDeliveryModeData> zoneDeliveryModeConverter =
new ConverterFactory<ZoneDeliveryModeModel, ZoneDeliveryModeData, ZoneDeliveryModePopulator>().create(ZoneDeliveryModeData.class, new ZoneDeliveryModePopulator());
@Before
public void setUp()
{
//Do Nothing
}
@Test
public void testConvert()
{
final ZoneDeliveryModeModel zoneDeliveryModeModel = mock(ZoneDeliveryModeModel.class);
given(zoneDeliveryModeModel.getCode()).willReturn("code");
given(zoneDeliveryModeModel.getName()).willReturn("name");
given(zoneDeliveryModeModel.getDescription()).willReturn("desc");
final ZoneDeliveryModeData zoneDeliveryModeData = zoneDeliveryModeConverter.convert(zoneDeliveryModeModel);
Assert.assertEquals("code", zoneDeliveryModeData.getCode());
Assert.assertEquals("name", zoneDeliveryModeData.getName());
Assert.assertEquals("desc", zoneDeliveryModeData.getDescription());
}
@Test(expected = IllegalArgumentException.class)
public void testConvertNull()
{
zoneDeliveryModeConverter.convert(null);
}
}
| [
"admin1@neev31.(none)"
] | admin1@neev31.(none) |
07d2e3238ad7191e4b688d8c9d483d7a52db7440 | cf679b9e626e7fee2ea10f03743e42c04a1cb504 | /src/myproject/Canteen.java | 3731544501abb7b4a93a47618a0e70ef42a8c90d | [] | no_license | rajveermehra/myproject | df6b5b1bf44c2e24a9e08c2e4f27ead8d3ddde31 | 1913737ce54ec4e141f88e27ef58b25557f52427 | refs/heads/master | 2020-04-28T23:31:27.982760 | 2019-08-17T15:39:15 | 2019-08-17T15:39:15 | 175,657,884 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,678 | 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 myproject;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
*
* @author Rajveermehra
*/
@Entity
@Table(name = "canteen", catalog = "mess", schema = "")
@NamedQueries({
@NamedQuery(name = "Canteen.findAll", query = "SELECT c FROM Canteen c"),
@NamedQuery(name = "Canteen.findByItemid", query = "SELECT c FROM Canteen c WHERE c.itemid = :itemid"),
@NamedQuery(name = "Canteen.findByAccountno", query = "SELECT c FROM Canteen c WHERE c.accountno = :accountno"),
@NamedQuery(name = "Canteen.findByItem", query = "SELECT c FROM Canteen c WHERE c.item = :item"),
@NamedQuery(name = "Canteen.findByPrize", query = "SELECT c FROM Canteen c WHERE c.prize = :prize"),
@NamedQuery(name = "Canteen.findByDay", query = "SELECT c FROM Canteen c WHERE c.day = :day")})
public class Canteen implements Serializable {
@Transient
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "Itemid")
private Integer itemid;
@Basic(optional = false)
@Column(name = "Accountno")
private String accountno;
@Basic(optional = false)
@Column(name = "Item")
private String item;
@Basic(optional = false)
@Column(name = "Prize")
private String prize;
@Basic(optional = false)
@Column(name = "Day")
private String day;
public Canteen() {
}
public Canteen(Integer itemid) {
this.itemid = itemid;
}
public Canteen(Integer itemid, String accountno, String item, String prize, String day) {
this.itemid = itemid;
this.accountno = accountno;
this.item = item;
this.prize = prize;
this.day = day;
}
public Integer getItemid() {
return itemid;
}
public void setItemid(Integer itemid) {
Integer oldItemid = this.itemid;
this.itemid = itemid;
changeSupport.firePropertyChange("itemid", oldItemid, itemid);
}
public String getAccountno() {
return accountno;
}
public void setAccountno(String accountno) {
String oldAccountno = this.accountno;
this.accountno = accountno;
changeSupport.firePropertyChange("accountno", oldAccountno, accountno);
}
public String getItem() {
return item;
}
public void setItem(String item) {
String oldItem = this.item;
this.item = item;
changeSupport.firePropertyChange("item", oldItem, item);
}
public String getPrize() {
return prize;
}
public void setPrize(String prize) {
String oldPrize = this.prize;
this.prize = prize;
changeSupport.firePropertyChange("prize", oldPrize, prize);
}
public String getDay() {
return day;
}
public void setDay(String day) {
String oldDay = this.day;
this.day = day;
changeSupport.firePropertyChange("day", oldDay, day);
}
@Override
public int hashCode() {
int hash = 0;
hash += (itemid != null ? itemid.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Canteen)) {
return false;
}
Canteen other = (Canteen) object;
if ((this.itemid == null && other.itemid != null) || (this.itemid != null && !this.itemid.equals(other.itemid))) {
return false;
}
return true;
}
@Override
public String toString() {
return "myproject.Canteen[ itemid=" + itemid + " ]";
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(listener);
}
}
| [
"[email protected]"
] | |
c294d296154b9f740d0695bfea35bd1c6818a760 | 05ad3485ec08799dfd1bfe854fc4857a742d6a5f | /src/main/java/com/bridgelabz/Maximum.java | 521f966e607f8b5d465197a16728dc97de36161b | [] | no_license | mvinchankar/Generics | d8b60310eb0db4cea6221bd2effd1456a9a7d068 | ff54b6b227096c5da6faed7b2b8d49c874c67b5d | refs/heads/master | 2020-09-21T00:40:15.471602 | 2019-11-29T06:02:46 | 2019-11-29T06:02:46 | 224,630,848 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 947 | java | package com.bridgelabz;
public class Maximum<T extends Comparable> {
private T maximumT;
private T maximumU;
private T maximumV;
public Maximum(T maximumT, T maximumU, T maximumV) {
this.maximumT = maximumT;
this.maximumU = maximumU;
this.maximumV = maximumV;
}
public static <T extends Comparable> T testMax(T maximumT, T maximumU, T maximumV) {
T maximum = maximumT;
if (maximumU.compareTo(maximum) > 0) {
maximum = maximumU;
}
if (maximumV.compareTo(maximum) > 0) {
maximum = maximumV;
}
printMax(maximum);
return maximum;
}
public <T> T testMax() {
T maxElememt = (T) testMax(this.maximumT, this.maximumU, this.maximumV);
printMax(maxElememt);
return maxElememt;
}
private static <T> void printMax(T maximumValue) {
System.out.println(maximumValue);
}
}
| [
"[email protected]"
] | |
f1aca25f18be49ba3aa866c00d16226c06de15bb | 9f30fbae8035c2fc1cb681855db1bc32964ffbd4 | /Java/lujing/task3/src/main/java/lujing/controller/StudentController.java | 1840138377cb3d79076f8d38d460d5b592eaba89 | [] | no_license | IT-xzy/Task | f2d309cbea962bec628df7be967ac335fd358b15 | 4f72d55b8c9247064b7c15db172fd68415492c48 | refs/heads/master | 2022-12-23T04:53:59.410971 | 2019-06-20T21:14:15 | 2019-06-20T21:14:15 | 126,955,174 | 18 | 395 | null | 2022-12-16T12:17:21 | 2018-03-27T08:34:32 | null | UTF-8 | Java | false | false | 2,765 | java | package lujing.controller;
import java.util.List;
import org.aspectj.apache.bcel.classfile.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import lujing.pojo.StudentCustom;
import lujing.pojo.StudentQueryVo;
import lujing.service.StudentService;
@Controller
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentService studentService;
//跳转到新增页面
@RequestMapping(value = "/newpage", method = RequestMethod.GET)
public String addstudent(Model model,StudentCustom studentCustom) {
studentCustom = studentService.findStudentById((long)218547);
model.addAttribute("studentCustom", studentCustom);
return "addstudent";
}
// 提交新增学生信息,value是url地址,设置request的方法
@RequestMapping(value = "/studentOne", method = RequestMethod.POST)
public String addStudentSubmit(StudentCustom studentCustom) {
studentService.addStudent(studentCustom);
return "redirect:studentslist";
}
// 显示所有学生列表
@RequestMapping(value = "/studentslist", method = RequestMethod.GET)
public ModelAndView queryStudent() {
ModelAndView modelAndView = new ModelAndView();
List<StudentCustom> studentlist = studentService.findStudentList(null);
modelAndView.addObject("studentlist", studentlist);
// 将模型数据填充到视图,逻辑视图名
modelAndView.setViewName("studentlist");
return modelAndView;
}
// 点击修改按钮,跳转到修改页面,并查询id对应的学生信息填充到表单中
@RequestMapping(value = "/{id}",method=RequestMethod.GET)
public String editstudent(Model model, @PathVariable("id") Long id) {
StudentCustom studentCustom = studentService.findStudentById(id);
model.addAttribute("student", studentCustom);
// 返回字符串类型,字符串为jsp页面的逻辑视图名
return "editstudent";
}
//修改提交
@RequestMapping(value="/{id}" ,method=RequestMethod.PUT)
public String editStudentSubmit(@PathVariable("id") Long id,StudentCustom studentCustom){
studentService.updateStudent(id, studentCustom);
return "redirect:studentslist";
}
// 删除按钮,执行删除学生方法
@RequestMapping(value = "/{id}",method=RequestMethod.DELETE)
public String deleteStudent(@PathVariable("id") Long id) {
studentService.deleteStudent(id);
return "redirect:studentslist";
}
}
| [
"[email protected]"
] | |
391b1e42efb24883b795f1dd01c5759beee4aa70 | d7bfc70001e92362029909cc7d4b3a2b5a785a6d | /src/main/java/sr/dac/utils/CountdownDive.java | b833b101fe1d3a164555ab508b204a7438508448 | [] | no_license | banicola/DAC | bcde094fa6354676ec3e46b3d03072516b9bcc3f | c36154e05eea46556875f5cd36ba3c774d6d80ec | refs/heads/master | 2022-12-16T05:14:56.138643 | 2020-09-11T19:07:08 | 2020-09-11T19:07:08 | 265,835,061 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,518 | java | package sr.dac.utils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import sr.dac.events.StartGame;
import sr.dac.main.Arena;
import sr.dac.main.Main;
import sr.dac.menus.ScoreboardDAC;
public class CountdownDive implements Runnable {
Arena a;
Player diver;
int timeToJump;
public CountdownDive(Player p, Arena arena){
a = arena;
diver = p;
timeToJump = Main.getPlugin().getConfig().getInt("timeForJump");
}
@Override
public void run() {
ScoreboardDAC.setScoreboardPlayingDAC(diver,timeToJump);
if(timeToJump== Main.getPlugin().getConfig().getInt("timeForJump")){
diver.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.f.getString("name") + " " + Main.f.getString("game.jumpCountdownStart").replace("%time%", ""+timeToJump)));
} else if(timeToJump==5 || (timeToJump<=3&&timeToJump>0)){
diver.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.f.getString("name") + " " + Main.f.getString("game.jumpCountdown").replace("%time%", ""+timeToJump)));
} else if(timeToJump==0){
diver.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.f.getString("name") + " " + Main.f.getString("game.jumpCountdownEnd")));
try {
a.setPlayerLives(diver, -1);
diver.teleport(a.getLobbyLocation());
} catch (NullPointerException ignore){}
StartGame.nextDiver(a);
}
timeToJump--;
}
}
| [
"[email protected]"
] | |
d4f33b9b876b0295eb43fce7419fbfda2537edc7 | ef161f26d1dac1de7bd879ce85cd7381003dbd46 | /DreamHouse/build/generated-sources/ap-source-output/cl/starlabs/modelo/Propiedad_.java | 4328b02d9e16d8be64806c685925a4256781b73f | [] | no_license | xqb91/DreamHouse | d217729a706af4882c66f4cad8514b53426c66b5 | 38da738da1807d5ca5deb31c09354a1917935b07 | refs/heads/master | 2016-09-13T00:43:16.552861 | 2016-05-29T00:19:08 | 2016-05-29T00:19:08 | 59,068,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,837 | java | package cl.starlabs.modelo;
import cl.starlabs.modelo.Agenda;
import cl.starlabs.modelo.Arriendo;
import cl.starlabs.modelo.Comision;
import cl.starlabs.modelo.Empleado;
import cl.starlabs.modelo.Historialbusqueda;
import cl.starlabs.modelo.Propietario;
import cl.starlabs.modelo.Tipopropiedades;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.Generated;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2016-05-27T04:52:56")
@StaticMetamodel(Propiedad.class)
public class Propiedad_ {
public static volatile SingularAttribute<Propiedad, Tipopropiedades> tipo;
public static volatile CollectionAttribute<Propiedad, Agenda> agendaCollection;
public static volatile CollectionAttribute<Propiedad, Comision> comisionCollection;
public static volatile SingularAttribute<Propiedad, String> calle;
public static volatile SingularAttribute<Propiedad, Empleado> numempleado;
public static volatile SingularAttribute<Propiedad, BigInteger> hab;
public static volatile SingularAttribute<Propiedad, BigInteger> ciudad;
public static volatile SingularAttribute<Propiedad, Propietario> numpropietario;
public static volatile CollectionAttribute<Propiedad, Arriendo> arriendoCollection;
public static volatile SingularAttribute<Propiedad, BigDecimal> numpropiedad;
public static volatile CollectionAttribute<Propiedad, Historialbusqueda> historialbusquedaCollection;
public static volatile SingularAttribute<Propiedad, Double> renta;
public static volatile SingularAttribute<Propiedad, String> codigopostal;
public static volatile SingularAttribute<Propiedad, Character> disponible;
} | [
"[email protected]"
] | |
0f4bdf09a08dabce2a6fb72f1efc1283f872a1eb | 151a55c9c497cf8750b23fc80328b8f45463382f | /src/test/java/com/thetimes/MyStepdefs.java | 85ef8ef02972d790de7bd2d54e01a857879ed00d | [] | no_license | keshashivam/BDDHomework3 | efd2703cbd616217c9f8a62537c51b13e487cbb0 | a144c5b3743ee6506969400c607f339957cfb019 | refs/heads/master | 2021-01-20T03:25:22.956046 | 2017-04-27T00:43:31 | 2017-04-27T00:43:31 | 89,539,320 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,773 | java | package com.thetimes;
import cucumber.api.PendingException;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.junit.Assert;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
/**
* Created by user on 4/27/2017.
*/
public class MyStepdefs {
WebDriver driver;
@Given("^user is on home page$")
public void userIsOnHomePage()
{
driver= new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get("https://www.thetimes.co.uk");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@When("^user Click on Subscripe the times services$")
public void userClickOnSubscripeTheTimesServices()
{
Alert alert=driver.switchTo().alert();
driver.findElement(By.className("CookieMessage-button")).click();
driver.findElement(By.linkText("Subscribe")).click();
}
@And("^user select digital pack for (\\d+) weeks$")
public void userSelectDigitalPackForWeeks(int arg0)
{
driver.findElement(By.linkText("View all Subscriptions")).click();
driver.findElement(By.linkText("Digital Packs")).click();
driver.findElement(By.xpath("(//a[contains(text(),'Viewfulldetails')])[2]")).click();
}
@Then("^user should get digital services subscriptin for (\\d+) weeks$")
public void userShouldGetDigitalServicesSubscriptinForWeeks(int arg0)
{
Assert.assertEquals(driver.findElement(By.cssSelector("div.productName")).getText(),"The Digital Pack");
}
}
| [
"[email protected]"
] | |
2ee5633020e3d2b8089b18f189c395590ef42aa5 | a335ca17558ed4f77a85e6497cf7b7c4130140cd | /1DV607/src/BlackJack/Model/rules/BasicHitStrategy.java | 81e0fd0000babd1f76c0adfccdd0cfb0d2492316 | [] | no_license | RonaZong/Lecture | 4f12ad02e368e7c447448916c0edec8241b96b21 | d357fdf7e3f5a612c673918607e9d0e7a6ce640b | refs/heads/master | 2022-12-31T15:24:05.440593 | 2020-10-22T15:07:33 | 2020-10-22T15:07:33 | 259,694,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 262 | java | package BlackJack.Model.rules;
import BlackJack.Model.Player;
public class BasicHitStrategy implements IHitStrategy {
private final int g_hitLimit = 17;
public boolean DoHit(Player a_dealer) {
return a_dealer.CalcScore() < g_hitLimit;
}
}
| [
"[email protected]"
] | |
626a7e8d8555463f1de5ab641721ed70f23d06fa | c7b468a87cf9bc2ad748fc3bb0281abbf698026b | /tests/WriteReviewScreenTest.java | df2957651513d8ce2716aa000a1a0a9c226ba3e5 | [] | no_license | JackDavidson/CourseConfessions | db8c772d9f6aee84d09db830659f697d2de2f427 | 616dc901b2c92a8d7ea42c8ba30b5621a9149ab3 | refs/heads/master | 2020-04-05T19:03:38.527256 | 2015-06-07T20:46:27 | 2015-06-07T20:46:27 | 34,018,775 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,458 | java | package com.bitsplease.courseconfessions.test;
import activities.writeReview.WriteReviewScreen;
import activities.main.MainMenu;
import android.content.Intent;
import android.test.*;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class WriteReviewScreenTest extends ActivityInstrumentationTestCase2<WriteReviewScreen>
{
private WriteReviewScreen WriteReviewScreenTester;
private EditText reviewText;
private Button submit;
public WriteReviewScreenTest() {
super(WriteReviewScreen.class);
}
protected void setUp() throws Exception {
super.setUp();
//for the main menu
WriteReviewScreenTester = getActivity();
reviewText = (EditText) WriteReviewScreenTester.getReviewText().getEditText();
submit = (Button) WriteReviewScreenTester.getSubmitButton();
}
public void testPreconditions() {
assertNotNull("Write Review Screen is null",WriteReviewScreenTester);
assertNotNull("EditText is null",reviewText);
assertNotNull("Submit button is null",submit);
}
@UiThreadTest
public void testRequestingFocus()
{
assertTrue(reviewText.requestFocus());
assertTrue(reviewText.hasFocus());
}
@UiThreadTest
public void testEditText() {
reviewText.requestFocus();
reviewText.setText("testing writing a review");
assertEquals("the text in the username field is incorrect.",
"testing writing a review", reviewText.getText().toString());
}
}
| [
"[email protected]"
] | |
dfff2a33cfb309a3b6f381d81d6d26b37835485d | 09171166d8be8e35a4b6dbde8beacd27460dabbb | /lib/src/main/java/com/dyh/common/lib/weigit/picker/entity/Province.java | 0596db93a47edaf05f83dc53f2e31bfb1fd6fda4 | [
"ICU"
] | permissive | dongyonghui/CommonLib | d51c99f15258e54344fed6dfdacc0c3aa0c08017 | a57fb995898644bb7b4bcd259417aca1e11944c9 | refs/heads/master | 2021-07-20T06:58:19.536087 | 2021-01-11T09:05:26 | 2021-01-11T09:05:26 | 233,981,794 | 12 | 2 | null | null | null | null | UTF-8 | Java | false | false | 783 | java | package com.dyh.common.lib.weigit.picker.entity;
import java.util.ArrayList;
import java.util.List;
/**
* 省份
* <br/>
* Author:李玉江[QQ:1032694760]
* DateTime:2016-10-15 19:06
* Builder:Android Studio
*/
public class Province extends Area implements LinkageFirst<City> {
private List<City> cities = new ArrayList<>();
public Province() {
super();
}
public Province(String areaName) {
super(areaName);
}
public Province(String areaId, String areaName) {
super(areaId, areaName);
}
public List<City> getCities() {
return cities;
}
public void setCities(List<City> cities) {
this.cities = cities;
}
@Override
public List<City> getSeconds() {
return cities;
}
} | [
"[email protected]"
] | |
d8d473e0527ba91c2a1f25537b25ac39a12a74a1 | 6bc32c1d5fcf4a9129a0af775a5d12f0f4af8c37 | /DA104G6/src/com/product/model/ProductDAO_interface.java | 6562da9a20e3bc724339e3f25743b324c987cc66 | [] | no_license | Boss-Lin/DA104G6 | 0c3b96ecabbfd0b82d667fe539b4304d7cc26056 | 3bed0208a43777c048523f0a7435b6b5bfe30451 | refs/heads/main | 2023-09-02T13:41:50.403857 | 2021-11-08T01:34:40 | 2021-11-08T01:34:40 | 416,858,200 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 548 | java | package com.product.model;
import java.util.*;
public interface ProductDAO_interface {
public void insert(ProductVO productVO);
public void update(ProductVO productVO);
public void delete(String pro_no);
public ProductVO findByPrimaryKey(String pro_no);
public List<ProductVO> findByCategory(String category_no);
public List<ProductVO> getAll();
public List<ProductVO> findByCompositeQuery(String product, String category_no);
public List<ProductVO> getStatus(Integer status);
public void updateScore(ProductVO productVO);
}
| [
"[email protected]"
] | |
3da4cea4e5d6338f7867a4cc675951f8dc51db20 | 0ea271177f5c42920ac53cd7f01f053dba5c14e4 | /5.3.5/sources/io/fabric/sdk/android/services/persistence/PreferenceStore.java | 67bf398daf58d87eb5cc29c777480cf2197eb2a0 | [] | no_license | alireza-ebrahimi/telegram-talaeii | 367a81a77f9bc447e729b2ca339f9512a4c2860e | 68a67e6f104ab8a0888e63c605e8bbad12c4a20e | refs/heads/master | 2020-03-21T13:44:29.008002 | 2018-12-09T10:30:29 | 2018-12-09T10:30:29 | 138,622,926 | 12 | 1 | null | null | null | null | UTF-8 | Java | false | false | 265 | java | package io.fabric.sdk.android.services.persistence;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public interface PreferenceStore {
Editor edit();
SharedPreferences get();
boolean save(Editor editor);
}
| [
"[email protected]"
] | |
21462713f930046e87729f0745cf190eaad29034 | 69a4f2d51ebeea36c4d8192e25cfb5f3f77bef5e | /methods/Method_22620.java | c27e977c243ac510d34b8b7b28282df5752a7e01 | [] | no_license | P79N6A/icse_20_user_study | 5b9c42c6384502fdc9588430899f257761f1f506 | 8a3676bc96059ea2c4f6d209016f5088a5628f3c | refs/heads/master | 2020-06-24T08:25:22.606717 | 2019-07-25T15:31:16 | 2019-07-25T15:31:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 848 | java | /**
* Set the default L & F. While I enjoy the bounty of the sixteen possible exception types that this UIManager method might throw, I feel that in just this one particular case, I'm being spoiled by those engineers at Sun, those Masters of the Abstractionverse. So instead, I'll pretend that I'm not offered eleven dozen ways to report to the user exactly what went wrong, and I'll bundle them all into a single catch-all "Exception". Because in the end, all I really care about is whether things worked or not. And even then, I don't care.
* @throws Exception Just like I said.
*/
public void setLookAndFeel() throws Exception {
String laf=Preferences.get("editor.laf");
if (laf == null || laf.length() == 0) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
else {
UIManager.setLookAndFeel(laf);
}
}
| [
"[email protected]"
] | |
d2bbec65f7e78712676bbb4edc6ebe5baefaa8c1 | 527125672cfa1e88e794f413aaae51ea63cf6739 | /t7_calculadorTodo/src/main/java/com/estadisticas/entities/ValuesArray.java | b4bc6494b54bb82ed56c692b28a43a3bee79cd26 | [] | no_license | cirodiaz/Entregas | 0b314386a0007c009f4814bbbc2856f17521a571 | 8f304e9ddb9008113963f4b44cb8cd89e03d0b88 | refs/heads/master | 2021-01-20T14:49:43.777776 | 2017-05-04T04:39:39 | 2017-05-04T04:39:39 | 82,776,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,707 | java | package com.estadisticas.entities;
/**
* @author Ciro Diaz
* Programa calculador todos los datos para psp 2.1
* Version: 1.0
* Creado: 02/05/2017
* ultima modificacion: 03/05/2017
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;
import org.apache.commons.math3.stat.regression.SimpleRegression;
public class ValuesArray {
//margen de error para los calculos de integrales
private double errorMargin = 0.000000001;
/**
* Toma un arreglo de n pares de valores, y establece los rangos entre VS, S, M, L, VL
* @param valueList
* @return average
*/
public LinkedList<ValueLabel> setRanges(LinkedList<ValueLabel> valueList){
LinkedList<ValueLabel> logarithmList = new LinkedList<ValueLabel>();
LinkedList<ValueLabel> resultList = new LinkedList<ValueLabel>();
for (int i=0;i<valueList.size();i++) {
ValueLabel currVal = new ValueLabel("",0);
//Se hace una lista con los valores de logaritmo natural de cada par de valores
currVal.setLabel(valueList.get(i).getLabel());
currVal.setValue(computeNaturalLogarithm(valueList.get(i).getValue()));
logarithmList.add(currVal);
}
Float avg = (float) computeAverage(logarithmList);
Float stdDev = (float) computeStdDeviation(logarithmList);
for(int i=-2;i<=2;i++){
ValueLabel currVal = new ValueLabel("",0);
float logRange = avg + i*stdDev;
switch (i) {
case -2:
currVal.setLabel(Range.VERY_SMALL.toString());
break;
case -1:
currVal.setLabel(Range.SMALL.toString());
break;
case 0:
currVal.setLabel(Range.MEDIUM.toString());
break;
case 1:
currVal.setLabel(Range.LARGE.toString());
break;
case 2:
currVal.setLabel(Range.VERY_LARGE.toString());
break;
default:
break;
}
currVal.setValue((float)Math.pow(Math.E, logRange));
resultList.add(currVal);
}
return resultList;
}
/**
* Toma un arreglo de n pares de valores, y calcula el promedio para ellos
* @param valuePairs
* @return average
*/
public Float computeNaturalLogarithm(float value){
Float naturalLog = (float) Math.log(value);
return naturalLog;
}
/**
* Toma un arreglo de n pares de valores, y calcula el promedio para ellos
* @param valuePairs
* @return average
*/
public Float computeAverage(LinkedList<ValueLabel> valueList){
Float avg = (float) 0;
Float totalSum = (float) 0;
for (int i=0;i<valueList.size();i++) {
totalSum +=valueList.get(i).getValue();
}
avg = totalSum/valueList.size();
return avg;
}
/**
* Toma un arreglo de n pares de valores, y calcula la desviaci�n est�ndar para ellos
* @param valuePairs
* @return stdDev
*/
public Float computeStdDeviation(LinkedList<ValueLabel> list){
Float stdDev = (float) 0;
Float avg = computeAverage(list);
Float variance = (float) 0;
for(int i=0;i<list.size();i++){
variance=(float) (variance + Math.pow((list.get(i).getValue()-avg), 2));
}
stdDev = (float) Math.sqrt(variance/(list.size()-1));
return stdDev;
}
/**
* Metodo de legado del programa 1; se toman los valores desde un archivo, y se insertan a una variable Value
* @param fileName
* @return list values
* @throws FileNotFoundException
*/
public LinkedList<Value> readFromFile (String fileName) throws FileNotFoundException{
//Se lee el archivo que se encuentra en la ruta ingresada, o se cargan los valores por defecto.
FileInputStream fileStream = new FileInputStream(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream));
//Si no se encuentran valores en el archivo, la lista retorna vacia (null)
LinkedList<Value> list = new LinkedList<Value>();
String values;
try {
values = reader.readLine();
while(values !=null){
if(!values.isEmpty()){
StringTokenizer parts= new StringTokenizer(values,";");
Value currVal = new Value(0,0);
//Cada linea del archivo sera un par de valores label, value para cargar a la lista
if(parts.hasMoreTokens()){
currVal.setxValue(Float.parseFloat(parts.nextToken()));
currVal.setyValue(Float.parseFloat(parts.nextToken()));
}
list.add(currVal);
values=reader.readLine();
}
}
} catch (Exception e) {
// Agarra cualquier excepci�n
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
// Necesario para poder cerrar el reader.
e.printStackTrace();
}
}
return list;
}
//Adiciones al codigo de la clase:
/**
* Toma un arreglo de n pares de valores, y calcula la regresion lineal para ellos
* @param valuePairs
* @return
*/
public LinearRegression computeLinearRegression(LinkedList<Value> valuePairs){
LinearRegression regressionResult = new LinearRegression(0, 0);
SimpleRegression regression = new SimpleRegression();
//Usando la librería Apache Commons, se calcula la regresión lineal de los valores que se ingresen a este método.
for(int i=0;i<valuePairs.size();i++){
Value currVal = valuePairs.get(i);
regression.addData(currVal.getxValue(), currVal.getyValue());
}
regressionResult.setBeta0(regression.getIntercept());
regressionResult.setBeta1(regression.getSlope());
return regressionResult;
}
public double[] computeCorrelation(LinkedList<Value> valuePairs){
SimpleRegression regression = new SimpleRegression();
for(int i=0;i<valuePairs.size();i++){
Value currVal = valuePairs.get(i);
regression.addData(currVal.getxValue(), currVal.getyValue());
}
double[] correlation = {regression.getR(),regression.getRSquare()};
return correlation;
}
/**
* Calcula una estimacion mejorada, con base en la regresion lineal calculada para los valores de entrada
* @param regression
* @param estimation
* @return
*/
public double computeImprovedEstimation(LinearRegression regression,double estimation){
//Si la estimacion no se puede hacer correctamente, el valor sera de cero. Se entiende que una estimacion no puede ser de cero.
double improvedEstimation = 0;
improvedEstimation = regression.getBeta0()+regression.getBeta1()*estimation;
return improvedEstimation;
}
/**
* Calcula la significancia de un conjunto de valores para encontrar si son validos para hacer estimacion
* @param valuePairs
* @return significance
*/
public double computeSignificance(LinkedList<Value> valuePairs){
//Se hacen integracion de la probabilidad desde 0 hasta x (hallado previamente) y con el restante se encuentra 1-2*p, que es la significancia
SimpsonsRuleIntegrator integrator = new SimpsonsRuleIntegrator(errorMargin);
int dataPoints = valuePairs.size();
double[] correlation = this.computeCorrelation(valuePairs);
double r = correlation[0];
double rSquare = correlation[1];
double x = (Math.abs(r)*Math.sqrt(dataPoints-2))/Math.sqrt((1-rSquare));
double probability = integrator.computeFullSimpsons(x, dataPoints-2, 10);
//la significancia es el area bajo la curva que resta desde x hasta el final de la campana de datos.
return 1-2*probability;
}
/**
* Calcula lo minimo y lo maximo que se espera se demore un desarrollo, basado en valores historicos
* @param valuePairs
* @return predictionInterval (double[])
*/
public double[] computePredictionInterval(LinkedList<Value> valuePairs, double expectedX){
//Se hace calculo del rango superior e inferior de prediccion, basado en valores historicos.
LinearRegression regression = this.computeLinearRegression(valuePairs);
int dataPoints = valuePairs.size() - 2;
//primero, se calcula la desviacion estandar, como parte de los valores para hallar el intervalo de prediccion
double linearSum = 0;
for(int i = 1; i <=valuePairs.size();i++ ){
double currVal = valuePairs.get(i-1).getyValue() - regression.getBeta0() - regression.getBeta1()*valuePairs.get(i-1).getxValue();
linearSum += Math.pow(currVal, 2);
}
double variance = (linearSum/dataPoints);
double stdDev = Math.sqrt(variance);
//luego, se calcula la prediccion mejorada
double impPred = computeImprovedEstimation(regression, expectedX);
//se calcula el numerador de la division de la formula de rango:
double avgX = 0;
for(int i=0;i<valuePairs.size();i++){
avgX+=valuePairs.get(i).getxValue();
}
avgX=avgX/valuePairs.size();
double numeratorFlat = expectedX - avgX;
double numerator = Math.pow(numeratorFlat,2);
// ahora el denominador
double denominator = 0;
for(int i = 1;i<=valuePairs.size();i++){
double denSumFlat = valuePairs.get(i-1).getxValue() - avgX;
denominator+= Math.pow(denSumFlat,2);
}
// se halla todo lo que esta dentro de la raiz:
double rootedResult = (double)1 + ((double)1/valuePairs.size())+(numerator/denominator);
//se calcula el valor de x para p = 0.35 y los grados de libertad de dataPoints
XValuesCalculator xValCalc = new XValuesCalculator();
double tResult = xValCalc.computeXValueForP(0.35, dataPoints);
//Se calculan el rango y los valores superior e inferior, y se retornan como un arreglo de tres valores, respectivamente
double [] predictionInterval = {0,0,0};
//el rango
predictionInterval[0] = tResult*stdDev*Math.sqrt(rootedResult);
//el intervalo de prediccion superior
predictionInterval[1] = impPred + predictionInterval[0];
//el intervalo de prediccion inferior
predictionInterval[2] = impPred - predictionInterval[0];
return predictionInterval;
}
}
| [
"[email protected]"
] | |
e04ecbfc01a8dcaea6efacd521be4c0a709058bb | 3376507f08c28d1626f6f2dc87feeb2831fa0a1d | /app/src/main/java/edu/virginia/cs/cs4720/uvabucketlist/BucketListActivity.java | ddc9de842db90f1e1471fc5349e81366df230695 | [] | no_license | PatidarParth/CS4720--Android | bcad5e9162d67be2c58a764f66657844bd9b9811 | 39ce9e7038db068112c9f71bbc5a3437aa647c59 | refs/heads/master | 2021-06-22T20:33:39.844739 | 2017-09-04T17:42:21 | 2017-09-04T17:42:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,793 | java | package edu.virginia.cs.cs4720.uvabucketlist;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class BucketListActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bucket_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.addItem);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String popup = "Add an item to your BucketList";
Snackbar.make(view, popup, Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
BucketItem[] data = new BucketItem[]{
new BucketItem("Finish MileStone 1", "9-04-2017"),
new BucketItem("Streak the Lawn", "09-05-2017"),
new BucketItem("Eat Roots", "09-08-2017"),
new BucketItem("Get an A in CS4720", "12-15-2017")
};
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
BucketListAdapter adapter = new BucketListAdapter(data);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
}
}
| [
"[email protected]"
] | |
58884161e13d99a4917f1ab21bb8b0349fb0c62f | c91604ad90e0abca181d9138896ea99ec398eb9a | /store/src/test/java/cn/tedu/store/service/GoodsServiceTests.java | cd99c6a9ba896725a81242ea38f31ef59b5334f9 | [] | no_license | Hannah-reset/commerce | 76ab8f7363a14f2d4034ada4bf46e7acc30e85dd | 68ab6d5fe07389395ebbcd0ebcb6b7533beac89d | refs/heads/master | 2022-04-12T02:37:34.710839 | 2020-04-05T05:18:12 | 2020-04-05T05:18:12 | 252,925,068 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 804 | java | package cn.tedu.store.service;
import java.util.List;
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 cn.tedu.store.entity.Goods;
@RunWith(SpringRunner.class)
@SpringBootTest
public class GoodsServiceTests {
@Autowired
private IGoodsService service;
@Test
public void getHotList() {
List<Goods> list = service.getHotList();
System.err.println("BEGIN:");
for (Goods item : list) {
System.err.println(item);
}
System.err.println("END.");
}
@Test
public void getById() {
Long id = 10000042L;
Goods result = service.getById(id);
System.err.println(result);
}
}
| [
"[email protected]"
] | |
4de93dcd6d4e97ecbba559b7284b94e9e57dd66b | 644d84071154a2c9467fcd365f6dafdf90a06c67 | /app/src/main/java/com/example/sharencare/ui/OnGoingTripDetails.java | efb33900192062177ff402201b935a405c8467e8 | [] | no_license | dpk196/ShareNcare | 47b7ac967c0b4ee56f067f25770a1b3509138e2a | 169ba2da546969c98aa544ce38aa093b912a4305 | refs/heads/master | 2022-12-16T09:35:36.283595 | 2020-09-05T12:40:39 | 2020-09-05T12:40:39 | 176,232,779 | 0 | 1 | null | 2020-09-05T12:40:41 | 2019-03-18T08:03:53 | Java | UTF-8 | Java | false | false | 7,644 | java | package com.example.sharencare.ui;
import android.location.Address;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.example.sharencare.Models.TripDetail;
import com.example.sharencare.R;
import com.example.sharencare.utils.StaticPoolClass;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.internal.PolylineEncoding;
import com.google.maps.model.DirectionsResult;
import com.google.maps.model.DirectionsRoute;
import java.util.ArrayList;
import java.util.List;
public class OnGoingTripDetails extends AppCompatActivity implements OnMapReadyCallback {
private static final String TAG = "OnGoingTripDetails";
private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey";
private MapView mMapView;
private GoogleMap mMap;
private TripDetail trip=StaticPoolClass.tripDetails;
private TextView tripDistance,tripDuration,tripFare;
private MarkerOptions markerSource;
private MarkerOptions markerDestination;
public static com.google.maps.model.LatLng startPoint;
public static com.google.maps.model.LatLng endPoint;
private LatLngBounds mLatLngBounds;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_on_going_trip_details);
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
mMapView = findViewById(R.id.on_going_trip_details_map);
mMapView.onCreate(mapViewBundle);
mMapView.getMapAsync(this);
try{
tripDistance=findViewById(R.id.trip_distance_tripDetialsDriver);
tripDuration=findViewById(R.id.trip_duration_tripDetialsDriver);
tripFare=findViewById(R.id.max_fare_value);
tripDistance.setText(StaticPoolClass.tripDetails.getTrip_distance());
tripDuration.setText(StaticPoolClass.tripDetails.getTrip_duration());
tripFare.setText("Rs"+" "+ StaticPoolClass.fare);
}catch(NullPointerException e){
Log.d(TAG, "onCreate: "+e.getMessage());
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap=googleMap;
getStartingEndingCoordinate(StaticPoolClass.directionsResultDriver);
setMapMarker();
setCameraView();
addPolylinesToMap(StaticPoolClass.directionsResultDriver);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Bundle mapViewBundle = outState.getBundle(MAPVIEW_BUNDLE_KEY);
if (mapViewBundle == null) {
mapViewBundle = new Bundle();
outState.putBundle(MAPVIEW_BUNDLE_KEY, mapViewBundle);
}
mMapView.onSaveInstanceState(mapViewBundle);
}
private void addPolylinesToMap(final DirectionsResult result) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Log.d(TAG, "run: result routes: " + result.routes.length);
for (DirectionsRoute route : result.routes) {
Log.d(TAG, "run: leg: " + route.legs[0].toString());
List<com.google.maps.model.LatLng> decodedPath = PolylineEncoding.decode(route.overviewPolyline.getEncodedPath());
List<LatLng> newDecodedPath = new ArrayList<>();
// This loops through all the LatLng coordinates of ONE polyline.
for (com.google.maps.model.LatLng latLng : decodedPath) {
// Log.d(TAG, "run: latlng: " + latLng.toString());
newDecodedPath.add(new LatLng(
latLng.lat,
latLng.lng));
}
Polyline polyline = mMap.addPolyline(new PolylineOptions().addAll(newDecodedPath));
polyline.setColor(ContextCompat.getColor(getApplicationContext(), R.color.blue1));
polyline.setClickable(true);
break;
}
}
});
}
private void getStartingEndingCoordinate(final DirectionsResult result) {
for (DirectionsRoute route : result.routes) {
startPoint = route.legs[0].endLocation;
endPoint = route.legs[0].startLocation;
Log.d(TAG, "getStartingEndingCoordinate:Start:" + startPoint.toString());
Log.d(TAG, "getStartingEndingCoordinate: End:" + endPoint.toString());
Log.d(TAG, "getStartingEndingCoordinate: Start Adress and startLocation" + route.legs[0].startAddress + " location:" + route.legs[0].startLocation.toString());
Log.d(TAG, "getStartingEndingCoordinate: End: Adress and startLocation " + route.legs[0].endAddress + " location:" + route.legs[0].endLocation.toString());
double bottomBoundary = startPoint.lat - 0.1;
double leftBoundary = startPoint.lng - 0.1;
double topBoundary = endPoint.lat + 0.1;
double rightBoundary = endPoint.lng + 0.1;
mLatLngBounds = new LatLngBounds(new LatLng(bottomBoundary, leftBoundary), new LatLng(topBoundary, rightBoundary));
LatLng latlng_src = new LatLng(startPoint.lat, startPoint.lng);
LatLng latLng_dtn = new LatLng(endPoint.lat, endPoint.lng);
markerSource = new MarkerOptions().position(latlng_src).title(StaticPoolClass.tripDetails.getTrip_destination());
markerDestination = new MarkerOptions().position(latLng_dtn).title(StaticPoolClass.tripDetails.getTrip_source());
break;
}
}
private void setCameraView() {
//total view of the map
try {
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(mLatLngBounds, 10));
}
});
} catch (Exception e) {
Log.d(TAG, "setCameraView: " + e.getMessage());
}
}
@Override
protected void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onPause() {
mMapView.onPause();
super.onPause();
}
@Override
protected void onDestroy() {
mMapView.onDestroy();
super.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
private void setMapMarker() {
mMap.addMarker(markerDestination);
mMap.addMarker(markerSource);
}
}
| [
"[email protected]"
] | |
4f4d5ce1643e18ffadf8e8764908de6df4d74225 | 1a7e5e94d27520bf8ae371fa55ddc3313e3aa00a | /app/src/main/java/com/example/she_is_a_girl/Models/ModelChat.java | ba197fed02e1905e97d4ebe42d4293ca53fe7fe9 | [] | no_license | Ariful0007/She_IS_a_girl | 76c72e8d3bff588dec0ae721fbefa9527ff89e03 | f7af8cefdee6656156af46dce111b7d582eddf82 | refs/heads/master | 2023-01-02T11:43:30.647504 | 2020-10-20T06:15:36 | 2020-10-20T06:15:36 | 305,605,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | package com.example.she_is_a_girl.Models;
public class ModelChat {
String message,sender,reciver,time;
boolean isSeen;
public ModelChat() {
}
public ModelChat(String message, String sender, String reciver, String time, boolean isSeen) {
this.message = message;
this.sender = sender;
this.reciver = reciver;
this.time = time;
this.isSeen = isSeen;
}
public String getMessage() {
return message;
}
public String getSender() {
return sender;
}
public String getReciver() {
return reciver;
}
public String getTime() {
return time;
}
public boolean isSeen() {
return isSeen;
}
}
| [
"[email protected]"
] | |
0504dc070a85470c735a9ce3674d604b290ceaa2 | 6d01d0b0ed45a318ca3f4eb1baa215cbe458139e | /programprocessor/experiment-dataset/TrainingData/51CTO-java1200221/MR/077/src/FrameShowException.java | 9fb359341a1ec9ab052d0605b6c1f22a4ccef05d | [] | no_license | yangyixiaof/gitcrawler | 83444de5de1e0e0eb1cb2f1e2f39309f10b52eb5 | f07f0525bcb33c054820cf27e9ff73aa591ed3e0 | refs/heads/master | 2022-09-16T20:07:56.380308 | 2020-04-12T17:03:02 | 2020-04-12T17:03:02 | 46,218,938 | 0 | 1 | null | 2022-09-01T22:36:18 | 2015-11-15T13:36:48 | Java | GB18030 | Java | false | false | 3,644 | java | import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
public class FrameShowException extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JTextArea textArea;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FrameShowException frame = new FrameShowException();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public FrameShowException() {
setTitle("\u663E\u793A\u5F02\u5E38\u4FE1\u606F");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 253);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel label = new JLabel(
"\u8BF7\u8F93\u5165\u975E\u6570\u5B57\u5B57\u7B26\u4E32\uFF0C\u67E5\u770B\u8F6C\u6362\u4E3A\u6570\u5B57\u65F6\u53D1\u751F\u7684\u5F02\u5E38\u3002");
label.setBounds(10, 10, 414, 15);
contentPane.add(label);
textField = new JTextField();
textField.setBounds(10, 32, 248, 21);
contentPane.add(textField);
textField.setColumns(10);
JButton btninteger = new JButton(
"\u8F6C\u6362\u4E3AInteger\u7C7B\u578B");
btninteger.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
do_btninteger_actionPerformed(e);
}
});
btninteger.setBounds(268, 31, 156, 23);
contentPane.add(btninteger);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setOpaque(false);
scrollPane.setBounds(10, 63, 414, 142);
contentPane.add(scrollPane);
textArea = new JTextArea();
textArea.setText("\u4FE1\u606F\u63D0\u793A\u6846");
textArea.setEditable(false);
scrollPane.setViewportView(textArea);
}
protected void do_btninteger_actionPerformed(ActionEvent e) {
// 创建字节数组输出流
ByteArrayOutputStream stream = new ByteArrayOutputStream();
System.setErr(new PrintStream(stream));// 重定向err输出流
String numStr = textField.getText();// 获取用户输入
try {
Integer value = Integer.valueOf(numStr);// 字符串转整数
} catch (NumberFormatException e1) {
e1.printStackTrace();// 输出错误异常信息
}
String info = stream.toString();// 获取字节输出流的字符串
if (info.isEmpty()) {// 显示正常转换的提示信息
textArea.setText("字符串到Integer的转换没有发生异常。");
} else {// 显示出现异常的提示信息与异常
textArea.setText("错错啦!转换过程中出现了如下异常错误:\n" + info);
}
}
} | [
"yyx@ubuntu"
] | yyx@ubuntu |
f9c4960f455b35ac2d00bf88ebbb24ddfb1cbdd8 | 6082617095733f812176af96d92c6ced1c0ab5e9 | /app/src/androidTest/java/com/qdxiaogutou/eye/ApplicationTest.java | e50d9f6e9861c2c0ab48cb46634dc0799f2366f4 | [] | no_license | IceSeaOnly/SmsMailerBoss | 7de3847a1271a69acf795d9d5ce6be89173bc2b4 | 2a00f04c29c496a27bda7cf295d32ed1b07c521d | refs/heads/master | 2021-01-11T15:26:49.636287 | 2017-02-27T13:44:30 | 2017-02-27T13:44:30 | 80,343,652 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.qdxiaogutou.eye;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"[email protected]"
] | |
82091357178a2bb29065e0a15c0bdb125eda6539 | d1472e3d30868b6184d9a9ea8c8228d4b89d7910 | /Projeto para cadastrar os produtos da loja preço bom - Vetor e POO/src/projeto/para/cadastrar/os/produtos/da/loja/preço/bom/vetor/e/poo/ProjetoParaCadastrarOsProdutosDaLojaPreçoBomVetorEPOO.java | 20ef93047d80f9ffb60d8a45c612e8ab031d29b5 | [] | no_license | ViniLopes87/Projetos-Unicap-Java | 17ec12e55f167dec72f6cb776efcb3bd686daccc | 1178d63e736fed3e99f1c011e7f6a30a234da0e2 | refs/heads/master | 2023-01-03T19:17:33.747267 | 2020-10-29T20:51:59 | 2020-10-29T20:51:59 | 308,178,729 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,740 | java | package projeto.para.cadastrar.os.produtos.da.loja.preço.bom.vetor.e.poo;
import java.util.Scanner;
public class ProjetoParaCadastrarOsProdutosDaLojaPreçoBomVetorEPOO {
public static void MenuAlt(){
System.out.println("Escolha uma operação: ");
System.out.println("1- Aumento");
System.out.println("2- Desconto");
}
public static void Menu(){
System.out.println("Escolha uma operação:");
System.out.println("0 - Para sair");
System.out.println("1 - Cadastrar um novo produto");
System.out.println("2 - Exibir os dados de todos os produtos da loja");
System.out.println("3 - Exibir os dados de todos os produtos de um dado fornecedor");
System.out.println("4 - Alterar o preço de um produto");
System.out.println("5 - Atualizar o estoque de um produto");
System.out.println("6 - Realizar a venda de um produto");
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int CONT = 100;
String C,D,F;
double V,Percen;
int OP,QE;
Loja L = new Loja(CONT);
Produto P;
System.out.println("Seja bem vindo a loja Preço Bom!");
do{
Menu();
System.out.print("Opção: ");
OP = input.nextInt(); input.nextLine();
switch(OP){
case 0: break;
case 1: System.out.print("Informe o código do produto: ");
C = input.nextLine();
P = new Produto(C);
System.out.print("Informe a definição do produto: ");
D = input.nextLine();
P.setD(D);
System.out.print("Informe a fornecedora do produto: ");
F = input.nextLine();
P.setF(F);
System.out.print("Informe o preço do produto: ");
V = input.nextDouble();
while(V <= 0){
System.out.println("Preço inválido");
System.out.print("Informe o preço do produto que seja maior que 0: ");
V = input.nextDouble();
}
P.setP(V);
System.out.print("Informe a quantidade do produto no estoque: ");
QE = input.nextInt(); input.nextLine();
while(QE < 0){
System.out.println("Quantidade inválida");
System.out.print("Informe a quantidade do produto no estoque que se maior ou igual a 0: ");
QE = input.nextInt(); input.nextLine();
}
P.setQE(QE);
L.Cadastrar(P);
break;
case 2: L.Exibirtodos();
break;
case 3: System.out.print("Informe o nome do fornecedor a ser procurado: ");
F = input.nextLine();
L.ExibirFornecedor(F);
break;
case 4: System.out.print("Informe o código do produto a ser alterado o preço: ");
C = input.nextLine();
System.out.print("Informe o percentual de alteração: ");
Percen = input.nextDouble();
while(Percen <= 0){
System.out.println("Percentual inválido");
System.out.print("Informe o percentual de alteração que seja maior que 0: ");
Percen = input.nextDouble();
}
MenuAlt();
System.out.print("Opção: ");
OP = input.nextInt();
while(OP != 1 && OP != 2){
System.out.println("Opção inválida");
System.out.print("Opção com 1 ou 2: ");
OP = input.nextInt();
}
L.AlterarPreco(C,Percen,OP);
break;
case 5: System.out.print("Informe o código do produto: ");
C = input.nextLine();
System.out.print("Informe quanto deve ser acrescido no estoque do produto: ");
QE = input.nextInt();
while(QE < 0){
System.out.println("Quantidade inválida");
System.out.print("Informe a quantidade do produto que se maior ou igual a 0: ");
QE = input.nextInt(); input.nextLine();
}
L.AlterarQuantidade(C,QE);
break;
case 6: System.out.print("Informe o código do produto que será vendido: ");
C = input.nextLine();
System.out.print("Informe a quantidade à ser vendida: ");
QE = input.nextInt();
while(QE < 0){
System.out.println("Quantidade inválida");
System.out.print("Informe a quantidade do produto que se maior ou igual a 0: ");
QE = input.nextInt(); input.nextLine();
}
L.Venda(C,QE);
break;
default: System.out.println("Opção inválida");
break;
}
}while(OP != 0);
}
} | [
"[email protected]"
] | |
865f6ba57db3fd3c24858c5f89b0dcadccdac5c4 | 4465f98568447abc2566e39194c12afa3a67b65f | /src/main/java/lc/common/util/SpecialBucketHandler.java | 943e4e25c09de674f3be3f9e27d3787d6374ff8d | [] | no_license | irgusite/LanteaCraft | 1d3b331f832083ed35e27c7b2ec0e8ddee463785 | 596e088dfd759f07c4aee145a676fcb336a60b47 | refs/heads/master | 2020-12-27T08:20:30.487360 | 2014-10-11T03:46:40 | 2014-10-11T03:46:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,273 | java | package lc.common.util;
import java.util.HashMap;
import java.util.Map.Entry;
import lc.common.base.LCBlock;
import lc.common.base.LCItemBucket;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
/**
* SpecialBucketHandler handles Forge onBucketFill from {@link ItemBucket}.
*
* @author AfterLifeLochie
*
*/
public class SpecialBucketHandler {
/**
* Map of all Block to LCItemBucket mappings.
*/
private static HashMap<Block, LCItemBucket> buckets = new HashMap<Block, LCItemBucket>();
/**
* Register a new mapping of {@link Block} type blockOf with an
* {@link LCItemBucket} itemResult.
*
* @param blockOf
* The fluid host block type.
* @param itemResult
* The resulting LCItemBucket when the host block is collected in
* a bucket.
*/
public static void registerBucketMapping(LCBlock blockOf, LCItemBucket itemResult) {
buckets.put(blockOf, itemResult);
}
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Result.ALLOW);
}
/**
* Attempts to fill a bucket from the source described.
*
* @param world
* The world object.
* @param pos
* The position of the fluid source block.
* @return The resulting ItemStack from collecting the target fluid in a
* bucket, or null if the fluid cannot be collected with an
* {@link LCItemBucket} registered with the handler.
*/
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
for (Entry<Block, LCItemBucket> results : buckets.entrySet())
if (block.equals(results.getKey())) {
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockById(0));
return new ItemStack(results.getValue());
}
return null;
}
}
| [
"[email protected]"
] | |
9361cfb30b37072e85ad273756d219abb2949131 | f71fa6de9509036c590a845c0560aebf8e1630fb | /src/main/java/serendip/sturts/thymeleaf/struts2_thymeleaf_sampleapp/actions/RegisterListAction.java | dffa640b382122d9bb0b5fc20511e1967b495b3d | [] | no_license | A-pZ/struts2-thymeleaf3-sampleapp | 47dd4f41d8cda3ab26c68aa936637ccf2674d8bd | eef0e50c5791f8c3d8a7ab3bfc6c5a742809a620 | refs/heads/development | 2023-06-29T04:11:23.809988 | 2022-09-10T06:54:31 | 2022-09-10T06:54:31 | 61,311,400 | 1 | 0 | null | 2023-06-14T20:17:11 | 2016-06-16T17:02:47 | HTML | UTF-8 | Java | false | false | 1,346 | java | package serendip.sturts.thymeleaf.struts2_thymeleaf_sampleapp.actions;
import java.util.List;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.Element;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import serendip.sturts.thymeleaf.struts2_thymeleaf_sampleapp.model.ProductService;
import serendip.sturts.thymeleaf.struts2_thymeleaf_sampleapp.model.SampleProduct;
/**
* <code>Set welcome message.</code>
*/
@Namespace("/")
@ParentPackage("struts-thymeleaf")
@Results(
{@Result(name=ActionSupport.SUCCESS,type="thymeleaf",location="listInput"),
@Result(name=ActionSupport.INPUT,type="thymeleaf",location="listInput")}
)
@Log4j2
public class RegisterListAction extends ActionSupport {
@Action("registerList")
public String execute() throws Exception {
log.info("- register:{}" , products);
return SUCCESS;
}
@Getter @Setter
//@Element(value=serendip.sturts.thymeleaf.struts2_thymeleaf_sampleapp.model.SampleProduct.class)
List<SampleProduct> products;
}
| [
"[email protected]"
] | |
8c5f00e72b2a6fd719c9641ebcedcae98cde484d | fda1ee633e8dbaae791da9a5e6c747c4d3cf50df | /faceye-hadoop-manager/src/main/java/com/faceye/component/hadoop/service/stock/mapreduce/DailyDataKeyComparator.java | 2632e44ac77b20abb6e915839c99fea47b53607e | [] | no_license | haipenge/faceye-hadoop | 4670fbd55f1cd63bbeb0e962c3851cef3426b48a | 1dff867c820eee16da408ec4d91a089f2a1b0e1b | refs/heads/master | 2021-01-22T02:17:17.733570 | 2018-04-02T13:08:08 | 2018-04-02T13:08:08 | 92,345,654 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 743 | java | package com.faceye.component.hadoop.service.stock.mapreduce;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class DailyDataKeyComparator extends WritableComparator {
public DailyDataKeyComparator() {
super(DailyDataKey.class, true);
}
public int compare(WritableComparable combinationKeyOne, WritableComparable combinationKeyOther) {
int res = 0;
DailyDataKey key1 = (DailyDataKey) combinationKeyOne;
DailyDataKey key2 = (DailyDataKey) combinationKeyOther;
// res=key1.getDate().compareTo(key2.getDate());
// return res;
res = key1.getStockId().compareTo(key2.getStockId());
if (res == 0) {
res = key2.getDate().compareTo(key1.getDate());
}
return res;
}
}
| [
"[email protected]"
] | |
6855420c7662a9b592a456000bbb644d2b8950b5 | d47fbb83005f4d7c8fa5bf8d41bcdd8d4627d82e | /Question1/src/Question1.java | e51041fa0daf91f738b7a6e1181f55b5b926ce3e | [] | no_license | karenrojas1994/yearup | d3bb2527f80922b1b2cba77bd9616e73f70feefe | cc8d700d646df16414775882ee461a06ef89e1d2 | refs/heads/master | 2021-03-12T21:47:42.657591 | 2016-01-12T18:04:51 | 2016-01-12T18:04:51 | 42,728,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 401 | java | public boolean answerCell(boolean isMorning, boolean isMom, boolean isAsleep)
{
boolean answerCell = true;
if (!isAsleep)
{
if (isMorning)
{
if (!isMom)
{
answerCell =false;
}
}
}
else
{
answerCell = false;
}
}
| [
"[email protected]"
] | |
2622de6d4fdec1b0bbd633aba6d81e530572a965 | 3c9a3770e21b032b10f128f5c82e95600daf7fdb | /src/main/java/io/github/ititus/commons/math/expression/Expression.java | 3721b53cd88389e8768f96551713040824892820 | [
"MIT"
] | permissive | iTitus/commons | fcfdde28741693a25d5aedd7cd39583e48f0f825 | 5cf41dc4570bc2a0f8d37c6d0ab2f7d3c2a5136a | refs/heads/main | 2023-08-05T09:36:22.550572 | 2023-07-24T21:20:07 | 2023-07-24T21:20:07 | 217,306,753 | 0 | 2 | MIT | 2023-09-04T18:53:28 | 2019-10-24T13:31:34 | Java | UTF-8 | Java | false | false | 476 | java | package io.github.ititus.commons.math.expression;
import io.github.ititus.commons.math.number.BigComplex;
public abstract class Expression {
public abstract BigComplex evaluate(ComplexEvaluationContext ctx);
protected abstract String toString(boolean inner);
@Override
public final String toString() {
return toString(false);
}
@Override
public abstract boolean equals(Object o);
@Override
public abstract int hashCode();
}
| [
"[email protected]"
] | |
a423d4ebaa8e87eedd3b2354c7e99696b55254b2 | bceba483c2d1831f0262931b7fc72d5c75954e18 | /src/qubed/corelogicextensions/ADDRESSESEXTENSION.java | 55605b726172bb1e4a4aaf4fef752e138746de0e | [] | no_license | Nigel-Qubed/credit-services | 6e2acfdb936ab831a986fabeb6cefa74f03c672c | 21402c6d4328c93387fd8baf0efd8972442d2174 | refs/heads/master | 2022-12-01T02:36:57.495363 | 2020-08-10T17:26:07 | 2020-08-10T17:26:07 | 285,552,565 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,451 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.08.05 at 04:53:09 AM CAT
//
package qubed.corelogicextensions;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ADDRESSES_EXTENSION complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="ADDRESSES_EXTENSION">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="MISMO" type="{http://www.mismo.org/residential/2009/schemas}MISMO_BASE" minOccurs="0"/>
* <element name="OTHER" type="{http://www.mismo.org/residential/2009/schemas}OTHER_BASE" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ADDRESSES_EXTENSION", propOrder = {
"mismo",
"other"
})
public class ADDRESSESEXTENSION {
@XmlElement(name = "MISMO")
protected MISMOBASE mismo;
@XmlElement(name = "OTHER")
protected OTHERBASE other;
/**
* Gets the value of the mismo property.
*
* @return
* possible object is
* {@link MISMOBASE }
*
*/
public MISMOBASE getMISMO() {
return mismo;
}
/**
* Sets the value of the mismo property.
*
* @param value
* allowed object is
* {@link MISMOBASE }
*
*/
public void setMISMO(MISMOBASE value) {
this.mismo = value;
}
/**
* Gets the value of the other property.
*
* @return
* possible object is
* {@link OTHERBASE }
*
*/
public OTHERBASE getOTHER() {
return other;
}
/**
* Sets the value of the other property.
*
* @param value
* allowed object is
* {@link OTHERBASE }
*
*/
public void setOTHER(OTHERBASE value) {
this.other = value;
}
}
| [
"[email protected]"
] | |
f3ebaa42e8a9dc647fb265582b725485f12b47d0 | 39bdbc9f61a2b3be983778962e2eb7a3401d366b | /src/main/java/seedu/address/commands/Command.java | b269c56d05d6993113c9b70d56f2fb7b28802160 | [
"MIT"
] | permissive | m133225/addressbook-level4 | bbaba631bb438ce674cf6300a1a3c6b08c378d44 | 1d7fdb018dd66cea77b9242a6c079bef4aea4bea | refs/heads/master | 2021-01-16T19:21:49.298432 | 2016-08-29T08:39:42 | 2016-08-29T08:45:48 | 66,449,199 | 0 | 0 | null | 2016-08-24T09:08:08 | 2016-08-24T09:08:08 | null | UTF-8 | Java | false | false | 1,287 | java | package seedu.address.commands;
import seedu.address.commons.Messages;
import seedu.address.model.ModelManager;
import seedu.address.model.person.ReadOnlyPerson;
import java.util.List;
/**
* Represents a command with hidden internal logic and the ability to be executed.
*/
public abstract class Command {
protected ModelManager modelManager;
/**
* Constructs a feedback message to summarise an operation that displayed a listing of persons.
*
* @param personsDisplayed used to generate summary
* @return summary message for persons displayed
*/
public static String getMessageForPersonListShownSummary(List<? extends ReadOnlyPerson> personsDisplayed) {
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, personsDisplayed.size());
}
/**
* Executes the command and returns the result message.
*
* @return feedback message of the operation result for display
*/
public abstract CommandResult execute();
/**
* Provides any needed dependencies to the command.
* Commands making use of any of these should override this method to gain
* access to the dependencies.
*/
public void setData(ModelManager modelManager) {
this.modelManager = modelManager;
}
}
| [
"[email protected]"
] | |
84045ea3ec638a0977d03db64745cd4dfc2f022b | e2cb2f624de130a8393e837eaa000f64b3266e58 | /src/baekjoon/backtracking/Num15649.java | d8370826e4315225bae4438bf19d90d1e2b59af8 | [] | no_license | thkim9373/AlgorithmCode | 566d8c19d675220f20e85842e7033841b145db8a | ae0fecfd09b7a20497b45bac955ec5d28ff73651 | refs/heads/master | 2020-11-28T09:18:23.605884 | 2020-03-28T14:56:24 | 2020-03-28T14:56:24 | 229,768,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,486 | java | package baekjoon.backtracking;
import java.io.*;
import java.util.StringTokenizer;
// N과 M (1)
// https://www.acmicpc.net/problem/15649
public class Num15649 {
private static StringBuilder builder = new StringBuilder();
private static int n, m;
private static boolean[] visited;
private static int[] result;
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
n = Integer.parseInt(tokenizer.nextToken());
m = Integer.parseInt(tokenizer.nextToken());
visited = new boolean[n];
result = new int[m];
getCombination(0);
writer.write(builder.toString());
reader.close();
writer.close();
}
private static void getCombination(int apply) {
if (apply < m) {
for (int i = 0; i < n; i++) {
if (!visited[i]) {
visited[i] = true;
result[apply] = i;
getCombination(apply + 1);
visited[i] = false;
}
}
} else if (apply == m) {
for (int value : result) {
builder.append(value + 1).append(" ");
}
builder.append("\n");
}
}
}
| [
"[email protected]"
] | |
d6e73ed7bfb352f0a4b76a13dc37b76479e9145d | 242b226b764876e476634a10e9541b3e18b80639 | /app/src/main/java/com/example/user/musicapp/Song.java | 3916a8a4ba3199a477e618f94a00f7045c516cc3 | [] | no_license | anionos/MusicApp | 48b89233c7bfdd792b45faedab4a0971bc7e7102 | ee8c7898b3b05c9244d5553df8996fc54fbbfb82 | refs/heads/master | 2020-03-28T12:27:52.442156 | 2018-09-13T13:25:29 | 2018-09-13T13:25:29 | 148,301,156 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,348 | java | package com.example.user.musicapp;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
/**
* Created by user on 8/31/2018.
*/
@Parcel
public class Song {
/**
* {@link Song} represents a vocabulary word that the user wants to learn.
* It contains a default translation and a Miwok translation for that word.
*/
public String mArtistName;
/**
* Miwok translation for the word
*/
public String mSongName;
public int mImageResourceId;
public int mAudioResourceId;
@ParcelConstructor
public Song() {
}
public Song(String artistName, String songName, int imageResourceId, int audioResourceId) {
mArtistName = artistName;
mSongName = songName;
mImageResourceId = imageResourceId;
mAudioResourceId = audioResourceId;
}
/**
* Get the default translation of the word.
*/
public String getArtistName() {
return mArtistName;
}
/**
* Get the Miwok translation of the word.
*/
public String getSongName() {
return mSongName;
}
/**
* Get the the image Id.
*/
public int getmImageResourceId() {
return mImageResourceId;
}
/**
* Get the audio id.
*/
public int getmAudioResourceId() {
return mAudioResourceId;
}
}
| [
"[email protected]"
] | |
47179fe39e78f5df257d2c1aefa580d77101d682 | 3ebf99be9df3844afccd753a01d5d13273e1f701 | /bukkit-plugins/WebSocket/src/main/java/com/github/minesquad/bukkit/websocket/errors/ChannelNotFoundErrorResponse.java | 16179be683559c1ede71660067a51298c96cd8ca | [] | no_license | minesquad/bukkitws | 28fbfab411d3416c8e3732177ce67e56bbaec640 | 7f60ef7035174445c3f0aebbc884baf5beab40bc | refs/heads/master | 2020-03-08T05:42:51.461680 | 2018-04-05T11:44:24 | 2018-04-05T11:44:24 | 127,954,514 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 492 | java | package com.github.minesquad.bukkit.websocket.errors;
import com.google.gson.JsonObject;
public class ChannelNotFoundErrorResponse extends ErrorResponse {
private String channel;
public ChannelNotFoundErrorResponse(String channel) {
this.channel = channel;
}
@Override
public JsonObject getMessage() {
JsonObject message = new JsonObject();
message.addProperty("error", "Channel `" + channel + "` not found");
return message;
}
}
| [
"[email protected]"
] | |
08414c83b470d2f72fc3c9a9f45ffbb874304cc7 | 6486a9a669a674de8992ea4ba803ac55180a4a87 | /src/main/java/se/swejug/squads/beans/Group.java | f8c1b8f634cb6e277ca7a73cd76132f43cc48662 | [] | no_license | swejug/squads | e50f769894412a2d334217eddafda62c8661f079 | 21056d88627b1b09b0f849ff3ea618c5c8dcd7c8 | refs/heads/master | 2021-01-01T17:48:12.263336 | 2013-02-20T22:45:15 | 2013-02-20T22:45:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 73 | java | package se.swejug.squads.beans;
public class Group extends Content {
}
| [
"[email protected]"
] | |
59a9b2fb319d27e78a9a50dc1c11bc8879413ba1 | 41db913e9df0d55af2c3ed47f61e4d4659e81d38 | /src/main/java/cn/ccb/pattern/creational/abstractfactory/JavaVideo.java | e4a706547f46c3a46e8fb5de3e2aa65cd862bd58 | [] | no_license | 2568808909/desgin_pattern | 522df720066b8e3c8d4a00b7aff762a45f1a8cb6 | 9bb56e1a77cd8e94fc851c44bdd9d64ddda17e7d | refs/heads/master | 2020-07-26T09:06:32.255446 | 2020-06-21T13:05:50 | 2020-06-21T13:05:50 | 208,598,592 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 175 | java | package cn.ccb.pattern.creational.abstractfactory;
public class JavaVideo extends Video {
public void produce() {
System.out.println("录制java视频");
}
}
| [
"[email protected]"
] | |
4c0b1d1119f8a43cb953520b4621996427c8f7e0 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /devops-20210625/src/main/java/com/aliyun/devops20210625/models/ListHostGroupsResponse.java | 9de596b0e50e1a88981a194cc437e6fe9b2539bd | [
"Apache-2.0"
] | permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 1,360 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.devops20210625.models;
import com.aliyun.tea.*;
public class ListHostGroupsResponse extends TeaModel {
@NameInMap("headers")
@Validation(required = true)
public java.util.Map<String, String> headers;
@NameInMap("statusCode")
@Validation(required = true)
public Integer statusCode;
@NameInMap("body")
@Validation(required = true)
public ListHostGroupsResponseBody body;
public static ListHostGroupsResponse build(java.util.Map<String, ?> map) throws Exception {
ListHostGroupsResponse self = new ListHostGroupsResponse();
return TeaModel.build(map, self);
}
public ListHostGroupsResponse setHeaders(java.util.Map<String, String> headers) {
this.headers = headers;
return this;
}
public java.util.Map<String, String> getHeaders() {
return this.headers;
}
public ListHostGroupsResponse setStatusCode(Integer statusCode) {
this.statusCode = statusCode;
return this;
}
public Integer getStatusCode() {
return this.statusCode;
}
public ListHostGroupsResponse setBody(ListHostGroupsResponseBody body) {
this.body = body;
return this;
}
public ListHostGroupsResponseBody getBody() {
return this.body;
}
}
| [
"[email protected]"
] | |
e8067902dee037f4d5fa427c0211647af634f678 | 81fe6bf5282d7a60fda43863815e62113e6d4ea8 | /algoritmo6/src/main/java/br/ufg/inf/es/construcao/algoritmo6/Algoritmo6.java | c13e112c2fccf5cce1e029a53c8799a108c1cb48 | [] | no_license | erickriger/CS2015-Algoritmos | 22a3c02136c8c7848cb8bf8ca31b0e80cfb7cdf7 | 895e520f830267d3a39701687f770dccb556ad37 | refs/heads/master | 2021-01-10T12:37:16.685360 | 2015-11-13T01:09:19 | 2015-11-13T01:09:19 | 45,276,011 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,274 | java | package br.ufg.inf.es.construcao.algoritmo6;
import br.ufg.inf.es.construcao.algoritmo4.Algoritmo4;
/**
* Potenciacao atraves de soma.
*
* @author eric
*/
public class Algoritmo6 {
/**
* Calcula a potencia atraves da utilizacao do metodo produto, do
* Algoritmo4. O metodo produto, por sua vez, utiliza somas para realizar a
* multiplicacao. Sendo assim, a potenciacao e calculada, indiretamente,
* atraves de soma.
*
* @param base Base, deve ser maior que zero.
* @param expoente Expoente, deve ser maior ou igual a um.
* @return O resultado da potenciacao.
* @throws IllegalArgumentException Se algum dos parametros for invalido.
* @see Algoritmo4
*/
public static int potenciaSoma(int base, int expoente) {
if (base <= 0) {
throw new IllegalArgumentException("A base deve ser "
+ "maior que zero.");
}
if (expoente < 1) {
throw new IllegalArgumentException("O expoente deve ser "
+ "maior ou igual a 1.");
}
int i = 1;
int produto = base;
while (i < expoente) {
produto = Algoritmo4.produto(produto, base);
i++;
}
return produto;
}
}
| [
"[email protected]"
] | |
b23e001037ecd2082a89f2c335ee46f55619301c | e54bb34b9ecd2841082f99d679ec36818a7bb5b0 | /MindlinerClassLib/src/com/mindliner/contentfilter/evaluator/ConfidentialityEvaluator.java | f459631fe5c5a0ec3c753ec0e59c17e80136faaf | [] | no_license | mindliner/mindliner | 6e4f2c16349c59aaf54351e47c6bc23451700711 | 92b3daefb002e77c9922ead62c24b9b41b62a12f | refs/heads/master | 2021-03-27T14:28:37.040304 | 2018-02-28T09:27:38 | 2018-02-28T09:27:38 | 123,269,905 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,109 | java | /*
* ConfidentialityEvaluator.java
*
* Created on 19.06.2007, 21:58:36
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.mindliner.contentfilter.evaluator;
import com.mindliner.categories.mlsConfidentiality;
import com.mindliner.contentfilter.ObjectEvaluator;
import com.mindliner.entities.mlsObject;
import com.mindliner.entities.mlsUser;
import java.io.Serializable;
import java.util.Map;
/**
* This class evaluates objects based on their confidentiality settings.
*
* @author Marius Messerli
*/
public class ConfidentialityEvaluator implements ObjectEvaluator, Serializable {
private Map<Integer, mlsConfidentiality> highestAllowedConfidentiality;
private mlsUser currentUser = null;
/**
*
* @param highestAllowedConfidentiality A map with clients ids as keys and
* confidentialities as values to ensure that no objects with higher confi
* are found
* @param u The user for which the objects are to be filtered
*/
public ConfidentialityEvaluator(Map<Integer, mlsConfidentiality> highestAllowedConfidentiality, mlsUser u) {
this.highestAllowedConfidentiality = highestAllowedConfidentiality;
currentUser = u;
}
@Override
public boolean passesEvaluation(mlsObject o) {
if (o == null) {
return false;
}
// if we have a cap for the object's client then check, otherwise let pass
mlsConfidentiality maxConf = highestAllowedConfidentiality == null ? null : highestAllowedConfidentiality.get(o.getClient().getId());
if (maxConf == null) {
maxConf = currentUser.getMaxConfidentiality(o.getClient());
}
if (maxConf == null) {
throw new IllegalStateException("ConfidentialityEvaluator: Cannot determine confidentiality ceiling.");
}
return maxConf.compareTo(o.getConfidentiality()) >= 0;
}
@Override
public boolean isMultipleInstancesAllowed() {
return false;
}
private static final long serialVersionUID = 19640205L;
}
| [
"[email protected]"
] | |
5b7ba91f8b467cb6847b7904ceedec3d6c9685a9 | eca1e4b3e62a3dcf6e1ca8c633783b394c7b92c8 | /src/main/com/priyakshi/sumitchallenge/factorial/Main.java | 5c9dbd3fb691dee7715e53fd869863175ac55e77 | [] | no_license | erpriyakshi/JavaLearning2020_Basic | 33578cc5bda7152a6709e55b2f16fb2b19b69650 | 98115f2a602e4e683fd6bd05a8e905a60ab3bfe5 | refs/heads/master | 2023-01-02T10:45:14.232872 | 2020-09-21T17:54:22 | 2020-09-21T17:54:22 | 269,474,811 | 0 | 0 | null | 2020-06-12T19:52:49 | 2020-06-04T22:05:06 | Java | UTF-8 | Java | false | false | 671 | java | package com.priyakshi.sumitchallenge.factorial;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
FindFactorial findFactorial = new FindFactorial();
Scanner scanner = new Scanner(System.in);
// loop
System.out.println("Enter Number");
boolean isHasNext = scanner.hasNext();
if(isHasNext){
int number = scanner.nextInt();
double factorial = findFactorial.findFactorial(number);
System.out.println("Factorial is "+ factorial);
}
// Factorial is 2.6525285981219103E32 - Read about E in given representation and teach sumit
}
}
| [
"[email protected]"
] | |
e751d7b2a7367a1620fcd657b7ecde1e9c7d5b51 | 45308e2235fb26e92a0f137df56de98af7e131d5 | /src/proxy/Ebook.java | 6af72af109ef7f3c5eb8dd3771fcf1f3d57aacbf | [] | no_license | nguyenphucthienan/ultimate-design-patterns | 1e8900084eb81dd27ace1297cbd387b310d45d76 | e5029cc087ea2644d0865329330a4593d82d681d | refs/heads/master | 2022-11-07T09:21:13.047946 | 2020-06-19T16:14:38 | 2020-06-19T16:14:38 | 273,383,936 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 88 | java | package proxy;
public interface Ebook {
void show();
String getFileName();
}
| [
"[email protected]"
] | |
3141598dd5279f98ebb54159d9a9b4cc773d0069 | 37aa8c4b8328d9587aa4b06c481b624156bc6766 | /src/main/java/com/ifmo/epampractice/service/QuestionsService.java | d8792f9abc4da627bb8cc1e44f2af0b123e04a79 | [
"MIT"
] | permissive | java-practice-spb-2020/epam-ifmo-java-practice-2020-1 | 365be6bb9a2f030518c48cb9be78d5755a9e02a8 | 99ad42cd8b03b26d2312793520d969eeb9f6bad6 | refs/heads/develop | 2020-12-29T07:47:33.699914 | 2020-02-27T15:36:48 | 2020-02-27T15:36:48 | 238,520,775 | 0 | 2 | null | 2020-02-28T11:31:25 | 2020-02-05T18:32:28 | Java | UTF-8 | Java | false | false | 2,866 | java | package com.ifmo.epampractice.service;
import com.ifmo.epampractice.dao.QuestionsDAO;
import com.ifmo.epampractice.entity.Questions;
import java.util.List;
public class QuestionsService {
private static final QuestionsDAO QUESTIONS_DAO = new QuestionsDAO();
private static final TestsService TESTS_SERVICE = new TestsService();
private static final AnswersService ANSWERS_SERVICE = new AnswersService();
public Questions addObject(final Questions question) {
if (TESTS_SERVICE.ifTestObjectExist(question.getTestId())) {
System.err.println("This test doesn't exist");
throw new IllegalArgumentException("This object doesn't exist");
}
return QUESTIONS_DAO.addObject(question);
}
public List<Questions> getAll() {
return QUESTIONS_DAO.getAll();
}
public List<Questions> getQuestionsListByTestId(final int testId) {
List<Questions> questionsList;
if (TESTS_SERVICE.ifTestObjectExist(testId)) {
System.err.println("This test doesn't exist");
throw new IllegalArgumentException("This object doesn't exist");
}
questionsList = QUESTIONS_DAO.getQuestionsListByTestId(testId);
return questionsList;
}
public Questions getById(final int questionId) {
return QUESTIONS_DAO.getById(questionId).orElseThrow(() ->
new IllegalArgumentException("This object doesn't exist"));
}
public void updateByObject(final Questions question) {
if (TESTS_SERVICE.ifTestObjectExist(question.getTestId())) {
System.err.println("This test doesn't exist");
throw new IllegalArgumentException("This object doesn't exist");
}
QUESTIONS_DAO.updateByObject(question);
}
public void removeById(final int questionId) {
QUESTIONS_DAO.getById(questionId).orElseThrow(() ->
new IllegalArgumentException("This object doesn't exist"));
QUESTIONS_DAO.removeById(questionId);
}
public List<Questions> getQuestionsWithAnswersListByTestId(final int testId) {
List<Questions> questionsList;
Questions question = new Questions();
if (TESTS_SERVICE.ifTestObjectExist(question.getTestId())) {
System.err.println("This test doesn't exist");
throw new IllegalArgumentException("This object doesn't exist");
}
questionsList = QUESTIONS_DAO.getQuestionsListByTestId(testId);
for (Questions quest : questionsList) {
quest.setAnswersList(ANSWERS_SERVICE.getAnswersListByQuestionId(quest.getTestId()));
}
return questionsList;
}
public Boolean ifQuestionObjectExist(final int id) {
if (QUESTIONS_DAO.getById(id).isPresent()) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
}
| [
"A970b71c94d"
] | A970b71c94d |
002673b05e5a240eda54569a5d19008cc99e0639 | b34654bd96750be62556ed368ef4db1043521ff2 | /cockpit_facade_util/branches/bugr_r3/src/java/tests/com/topcoder/service/util/UnitTests.java | 3f99a7fab617b2f8f87d916e3ec5fb747ed3f2ba | [] | no_license | topcoder-platform/tcs-cronos | 81fed1e4f19ef60cdc5e5632084695d67275c415 | c4ad087bb56bdaa19f9890e6580fcc5a3121b6c6 | refs/heads/master | 2023-08-03T22:21:52.216762 | 2019-03-19T08:53:31 | 2019-03-19T08:53:31 | 89,589,444 | 0 | 1 | null | 2019-03-19T08:53:32 | 2017-04-27T11:19:01 | null | UTF-8 | Java | false | false | 683 | java | /*
* Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.service.util;
import com.topcoder.service.util.gameplan.SoftwareProjectDataTests;
import com.topcoder.service.util.gameplan.StudioProjectDataTests;
import com.topcoder.service.util.gameplan.TCDirectProjectGamePlanDataTests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* <p>This test case aggregates all Unit test cases.</p>
*
* @author FireIce
* @version 1.0
*/
@RunWith(Suite.class)
@Suite.SuiteClasses(
{SoftwareProjectDataTests.class, StudioProjectDataTests.class, TCDirectProjectGamePlanDataTests.class })
public class UnitTests {
} | [
"mashannon168@fb370eea-3af6-4597-97f7-f7400a59c12a"
] | mashannon168@fb370eea-3af6-4597-97f7-f7400a59c12a |
081fe1a9738419fd967cba64ff7486df7779fd1b | 8692972314994b8923b6f12b7ae9e76b30a36391 | /memory_managment/ClassesList/src/Class156.java | e66a77d432e33723cdbfe3f70dab93cfb7e23055 | [] | no_license | Petrash-Samoilenka/2017W-D2D3-ST-Petrash-Samoilenka | d2cd65c1d10bec3c4d1b69b124d4f0aeef1d7308 | 214fbb3682ef6714514af86cc9eaca62f02993e1 | refs/heads/master | 2020-05-27T15:04:52.163194 | 2017-06-16T14:19:38 | 2017-06-16T14:19:38 | 82,560,968 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,746 | java | public class Class156 extends Class1 {
private String _s1;
private String _s2;
private String _s3;
private String _s4;
private String _s5;
private String _s6;
private String _s7;
private String _s8;
public Class156() {
}
public void getValue1(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue2(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue3(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue4(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue5(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue6(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue7(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue8(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue9(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue10(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue11(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue12(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue13(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue14(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue15(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue16(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue17(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue18(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue19(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
public void getValue20(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8) {
_s1 = s1;
_s2 = s2;
_s3 = s3;
_s4 = s4;
}
}
| [
"[email protected]"
] | |
57a73ae310ce593e1e2a854e3ebc36012236ac98 | ffb4c0111c2b3a0f1342103fa829630c504f7cfa | /ContatosBD/src/Principal.java | ed4186d0d52be035e83a379d4fceb12e577813eb | [] | no_license | JaySobreiro/JavaBasicoBSI | 8dff2f88b96fe6ab4ff0efb3342278e8814cf5ae | e5e6198616db581c73cf625e358e23c6d7b41a08 | refs/heads/master | 2020-04-04T00:09:19.214435 | 2018-11-07T23:01:16 | 2018-11-07T23:01:16 | 155,641,788 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 5,372 | java | import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;
public class Principal {
public static void main(String[] args) throws SQLException {
/* teste de conexão
Connection conn = new ConnectionFactory().getConnection();
System.out.println("Conectado com sucesso!\n");
conn.close();*/
int op, op2, op3;
Scanner leitor = new Scanner(System.in);
ContatoDAO dao = new ContatoDAO();
int id;
Contato busca;
do {
System.out.println("\n-----CONTATOS-----");
System.out.println("1) Cadastrar");
System.out.println("2) Listar todos");
System.out.println("3) Buscar");
System.out.println("4) Excluir");
System.out.println("5) Alterar");
System.out.println("0) Sair");
System.out.print("Informe uma opção: ");
op = leitor.nextInt();
switch (op) {
case 1: // cadastro
leitor.nextLine();
Contato c = new Contato();
System.out.println("\nNovo Contato:");
System.out.print("Nome: ");
c.setNome(leitor.nextLine());
System.out.print("Fone: ");
c.setFone(leitor.nextLine());
System.out.print("E-mail: ");
c.setEmail(leitor.nextLine());
dao.cadastrarContato(c);
System.out.println("\nContato cadastrado com sucesso!");
break;
case 2: // listagem
ArrayList<Contato> listaContatos = dao.getContatos();
if(listaContatos.isEmpty()) {
System.out.println("\nAtenção: não há contatos cadastrados!");
}else {
System.out.print("\nContatos Cadastrados:");
for(Contato temp : listaContatos) {
System.out.println("\n" + temp.toString());
}
}
break;
case 3: // buscar contato
System.out.print("\nInforme o ID do contato que deseja encontrar: ");
id = leitor.nextInt();
busca = dao.getContato(id);
if(busca == null) {
System.out.println("\nNão foi encontrado contato com este id...");
}else {
System.out.println("\nContato localizado:");
System.out.println(busca.toString());
}
break;
case 4: // deletar
System.out.print("\nInforme o ID do contato que deseja excluir: ");
id = leitor.nextInt();
busca = dao.getContato(id);
if(busca == null) { // o contato não existe
System.out.println("\nNão foi encontrado contato com este id...");
}else { // o contato existe
// exibe contato
System.out.println("\nContato localizado: ");
System.out.println(busca.toString());
System.out.println("\nDeseja excluir este contato?");
System.out.println("1) Sim");
System.out.println("2) Não");
System.out.print("Sua opção: ");
op2 = leitor.nextInt();
while(op2 != 1 && op2 != 2) {
System.out.println("\nOpção invlálida");
System.out.println("\nDeseja excluir este contato?");
System.out.println("1) Sim");
System.out.println("2) Não");
System.out.print("Sua opção: ");
op2 = leitor.nextInt();
}
if(op2 == 1) {
dao.deletarContato(id);
System.out.println("\nContato nº " + id +" excluido com sucesso!");
}
}
break;
case 5: // alterar
System.out.print("\nInforme o ID do contato que deseja atualizar: ");
id = leitor.nextInt();
busca = dao.getContato(id);
if(busca == null) { // o contato não existe
System.out.println("\nNão foi encontrado contato com este id...");
}else { // o contato existe
System.out.println("Contato localizado: ");
System.out.println(busca.toString() + "\n");
System.out.println("\n--- Menu de Alteração ---");
System.out.println("Informe o campo que deseja atualizar:");
System.out.println("1) Nome");
System.out.println("2) Fone");
System.out.println("3) E-mail");
System.out.println("0) Voltar ao menu principal");
System.out.print("Sua opção: ");
op3 = leitor.nextInt();
while(op3 < 0 || op3 > 3) {
System.out.println("\nOpção invlálida");
System.out.println("\n--- Menu de Alteração ---");
System.out.println("Informe o campo que deseja atualizar:");
System.out.println("1) Nome");
System.out.println("2) Fone");
System.out.println("3) E-mail");
System.out.println("0) Voltar ao menu principal");
System.out.print("Sua opção: ");
op3 = leitor.nextInt();
}
leitor.nextLine();
if(op3 == 1) {
System.out.println("\nNovo nome: ");
busca.setNome(leitor.nextLine());
}else if(op3 == 2) {
System.out.println("\nNovo telefone: ");
busca.setFone(leitor.nextLine());
}else if(op3 == 3){
System.out.println("\nNovo e-mail: ");
busca.setEmail(leitor.nextLine());
}
if(op3 != 0)
{
dao.updateContato(busca, op3);
System.out.println("\nContato alterado com sucesso!");
}
}
break;
case 0: // sair
System.out.println("\nO sistema foi finalizado...");
break;
default:
System.out.println("\nATENÇÃO: opção inválida!");
break;
}
System.out.println();
} while (op != 0);
}
}
| [
"[email protected]"
] | |
636f91d5d8a9fe39b8f24f84f00ffffee3c26430 | 84d756df14b35360d9b73da376a5595353ddff18 | /src/by/it/kleban/lesson05/TaskA1.java | 3151861113762787b6be39c3e00e211c89e2a712 | [] | no_license | userpvt/cs2018-06-19 | 877f406773abe93ca85ce54f8babdeb49df872b3 | dedb0f582e807f1eca2cd0f917e4203bbc7f14ef | refs/heads/master | 2020-03-26T09:05:17.935310 | 2018-07-02T12:08:35 | 2018-07-02T12:08:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 986 | java | package by.it.kleban.lesson05;
/* Массив из чисел в обратном порядке
1. Создать массив на 10 чисел.
2. Ввести с клавиатуры 10 целых чисел и записать их в массив.
3. Расположить элементы массива в обратном порядке.
4. Вывести результат на экран, каждое значение выводить с новой строки.
Например, для такого ввода
1 2 3 4 5 6 7 8 9 0
вывод ожидается такой
0
9
8
7
6
5
4
3
2
1
*/
import java.util.Scanner;
public class TaskA1 {
public static void main (String [] arg) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[10];
for (int i = arr.length-1; i >=0 ; i--)
{
arr[i] = sc.nextInt();
}
for (int element : arr) {
System.out.println(element);
}
}
}
| [
"[email protected]"
] | |
5fdb8cb7874a5025037de27a7aaa74e58130d650 | dbc266fb819b334bb5cf24064fb152eaa35c87b6 | /app/src/main/java/com/praktikum/prak5_mvp_room/database/dao/PersonDao.java | 21a23ea87c87b8a859333a2a5555caedf102aa1c | [] | no_license | fitra-jibjaya/PrakMobileP3 | d7a9f5fc0bcb2c1c34607c210538f16591dda587 | d576e38d26f86aa3e963aa7c28a6905adfdbbca7 | refs/heads/master | 2023-03-29T21:39:32.226765 | 2021-04-02T09:55:40 | 2021-04-02T09:55:40 | 353,977,430 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 844 | java | package com.praktikum.prak5_mvp_room.database.dao;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import com.praktikum.prak5_mvp_room.database.entity.Person;
import java.util.List;
@Dao
public interface PersonDao {
// Di interface ini berisi query-query untuk mengakses entitas yang telah kita isi sebelumnya
// Ini adalah query-query yang otomatis tersedia dari library dari room database
@Insert
void insertPerson(Person person);
@Update
void update(Person person);
@Delete
void delete(Person person);
// Ini adalah query manual yang kita definisikan sendiri
@Query("SELECT * FROM person")
List<Person> getAll();
@Query("SELECT * FROM person WHERE id=:id")
Person finPerson(long id);
}
| [
"[email protected]"
] | |
a2eefb94abad7197475caca92c69f0013350f9a4 | 67579cb19807229c216849627f9ea4a643f4cb19 | /Lectures/jpasec2/src/edu/neu/cs5200/ide/jpa/simple/StudentDAO.java | c16c26cad0814e64ec0f377887abd088d36293eb | [] | no_license | viveks91/Restaurant-reservation | 3a9b3d4c765e5845df62efe58a94ca6e50825265 | fee93fe022155f48ae582fda71ff547436dd6a7c | refs/heads/master | 2016-09-06T11:56:07.815619 | 2014-12-12T01:00:39 | 2014-12-12T01:00:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,062 | java | package edu.neu.cs5200.ide.jpa.simple;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class StudentDAO {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpasec2");
EntityManager em = null;
public StudentDAO() {
em = factory.createEntityManager();
}
public Student createStudent(Student student) {
em.getTransaction().begin();
em.persist(student);
em.getTransaction().commit();
return student;
}
public Student findById(int id) {
em.getTransaction().begin();
Student student = em.find(Student.class, id);
em.getTransaction().commit();
return student;
}
// public Student findByName(String name) {
public List<Student> findByName(String name) {
em.getTransaction().begin();
Query q = em.createQuery("select s from Student s where s.name = :name");
q.setParameter("name", name);
// Student student = (Student) q.getSingleResult();
List<Student> students = q.getResultList();
em.getTransaction().commit();
// return student;
return students;
}
public List<Student> findByNameUsingNamedQuery(String name) {
em.getTransaction().begin();
Query q = em.createNamedQuery("Student.findStudentById");
q.setParameter("name", name);
List<Student> students = q.getResultList();
em.getTransaction().commit();
return students;
}
public List<Student> findAll() {
em.getTransaction().begin();
Query q = em.createNamedQuery("Student.findAll");
List<Student> students = q.getResultList();
em.getTransaction().commit();
return students;
}
public void removeStudentById(int id) {
em.getTransaction().begin();
Student student = em.find(Student.class, id);
em.remove(student);
em.getTransaction().commit();
}
public Student updateStudentNameById(int id, String newName) {
em.getTransaction().begin();
Student student = em.find(Student.class, id);
student.setName(newName);
em.merge(student);
em.getTransaction().commit();
return student;
}
public static void main(String[] args) {
StudentDAO dao = new StudentDAO();
Student s1 = new Student(321, "Dan", new Date());
s1 = dao.createStudent(s1);
System.out.println(s1.getId());
Student s2 = dao.findById(1);
System.out.println(s2);
Student s3 = dao.updateStudentNameById(1, "Greg");
System.out.println(s3);
Student sa = new Student(321, "Greg", new Date());
Student sb = new Student(321, "Greg", new Date());
Student sc = new Student(321, "Charlie", new Date());
Student sd = new Student(321, "Stephen", new Date());
dao.createStudent(sa);
dao.createStudent(sb);
dao.createStudent(sc);
dao.createStudent(sd);
// Student s4 = dao.findByName("Greg");
// List<Student> s4 = dao.findByName("Greg");
List<Student> s4 = dao.findByNameUsingNamedQuery("Greg");
System.out.println(s4);
List<Student> all = dao.findAll();
System.out.println(all);
// dao.removeStudentById(1);
}
}
| [
"[email protected]"
] | |
39864829e8672a911303113436eeae9725c31fb8 | 7c31053c98962d5405b5be629f528c03d12fc256 | /common/net/minecraftforge/inventory/IStackFilter.java | 4c2983ed0c97056e01c0a7ac494f16528d2899a0 | [] | no_license | immibis/MinecraftForge | 6f950179617f5f38eea907263160a0f5658c724c | ab7f9bef46b9709472bd338115860688bcc48da1 | refs/heads/master | 2021-01-17T22:33:26.947373 | 2013-02-26T09:29:08 | 2013-02-26T09:29:08 | 8,178,403 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 625 | java | package net.minecraftforge.inventory;
import net.minecraft.item.ItemStack;
public interface IStackFilter {
/**
* Returns true if the given item matches this filter. The stack size is
* ignored.
*
* @param item
* The item to match.
* @return True if the item matches the filter.
*/
boolean matchesItem(ItemStack item);
/**
* A default filter that matches any item.
*/
static final IStackFilter MATCH_ANY = new IStackFilter() {
@Override
public boolean matchesItem(ItemStack item)
{
return true;
}
};
}
| [
"[email protected]"
] | |
a6e573d619b49a6c82637d1399527d1eb6d5ccce | b0c1f026f03afdd511e97cba0d7eddd156cbe846 | /CIT360-Portfolio/src/JUnitTests/JUnitTests.java | 79a24470d41fd45a0f54307bd100cd9967cbb3a8 | [] | no_license | hodges-olan/CIT360-Portfolio | 7666ffc41a6615b992b0aad6bb9619e04bf3c551 | 70f42136296892479965168aa832cb7bd927b5bc | refs/heads/master | 2021-01-09T20:53:11.147594 | 2017-11-30T21:46:16 | 2017-11-30T21:46:16 | 58,292,326 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,227 | java | package JUnitTests;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author co075oh
*/
public class JUnitTests {
public JUnitTests() {
}
public static void main(String[] args) {
testReduceHealthNormal();
}
/**
* Test of reduceHealthNormal method, of class BattleControl.
*/
@Test
public static void testReduceHealthNormal() {
System.out.println("\nreduceHealthNormal");
// Declare variables
double result, weapon, strength, armor, expResult;
BattleControl instance = new BattleControl();
/********************************
* Test Case #1
*/
// Declare test input and expected output
weapon = 8.0;
strength = 4.0;
armor = 20.0;
expResult = 12.0;
// Execute and Verify function
System.out.println("\tTest case #1");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #2
*/
// Declare test input and expected output
weapon = -1.0;
strength = 10.0;
armor = 10.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #2");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #3
*/
// Declare test input and expected output
weapon = 10.0;
strength = -1.0;
armor = 5.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #3");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #4
*/
// Declare test input and expected output
weapon = 4.0;
strength = 6.0;
armor = -1.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #4");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #5
*/
// Declare test input and expected output
weapon = 0.0;
strength = 12.0;
armor = 7.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #5");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #6
*/
// Declare test input and expected output
weapon = 9.0;
strength = 0.0;
armor = 3.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #6");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #7
*/
// Declare test input and expected output
weapon = 3.0;
strength = 2.0;
armor = 0.0;
expResult = -1.0;
// Execute and Verify function
System.out.println("\tTest case #7");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #8
*/
// Declare test input and expected output
weapon = 1.0;
strength = 8.0;
armor = 2.0;
expResult = 6.0;
// Execute and Verify function
System.out.println("\tTest case #8");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #9
*/
// Declare test input and expected output
weapon = 11.0;
strength = 1.0;
armor = 7.0;
expResult = 4.0;
// Execute and Verify function
System.out.println("\tTest case #9");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Test Case #10
*/
// Declare test input and expected output
weapon = 10.0;
strength = 8.0;
armor = 1.0;
expResult = 79.0;
// Execute and Verify function
System.out.println("\tTest case #10");
result = instance.reduceHealthNormal(weapon, strength, armor);
assertNotNull(result);
assertEquals(expResult, result, 0.0);
/********************************
* Additional Test Cases
*/
// Below are examples of other test cases found on the following URL
// https://github.com/junit-team/junit4/wiki/Assertions
// This will be true as the byte array will be identical between the two using the same input of "trial"
System.out.println("\tTest case - assertArrayEquals");
byte[] expected = "trial".getBytes();
byte[] actual = "trial".getBytes();
assertArrayEquals(expected, actual);
// This will be true, since it is being handed the boolean value of false
System.out.println("\tTest case - assertFalse");
assertFalse(false);
// These will not be the same as they are different instantiations of the class Object
System.out.println("\tTest case - assertNotSame");
assertNotSame(new Object(), new Object());
// This will be true, since it is being handed no value at all
System.out.println("\tTest case - assertNull");
assertNull(null);
// This will be true since you are comparing the exact same object to itself.
System.out.println("\tTest case - assertSame");
Integer aNumber = 768;
assertSame(aNumber, aNumber);
// This will be true, since it is being handed the boolean value of true
System.out.println("\tTest case - assertTrue");
assertTrue(true);
}
private static class BattleControl {
public BattleControl() {
}
private double reduceHealthNormal(double weapon, double strength, double armor) {
// Declare variables
double damage;
// Validation Checks
if(weapon <= 0 || strength <= 0 || armor <= 0) {
return -1.0;
}
// Calculate damage
damage = (weapon * strength) - armor;
// Return values
return Math.round(damage);
}
}
}
| [
"[email protected]"
] | |
ecb1e4001ca78ed9cbec8501109552ebc569c057 | 10378c580b62125a184f74f595d2c37be90a5769 | /org/apache/commons/lang3/concurrent/ConcurrentUtils.java | 97185d17a6ff075a1a147f4a5e22d0a6fb20e833 | [] | no_license | ClientPlayground/Melon-Client | 4299d7f3e8f2446ae9f225c0d7fcc770d4d48ecb | afc9b11493e15745b78dec1c2b62bb9e01573c3d | refs/heads/beta-v2 | 2023-04-05T20:17:00.521159 | 2021-03-14T19:13:31 | 2021-03-14T19:13:31 | 347,509,882 | 33 | 19 | null | 2021-03-14T19:13:32 | 2021-03-14T00:27:40 | null | UTF-8 | Java | false | false | 3,414 | java | package org.apache.commons.lang3.concurrent;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
public class ConcurrentUtils {
public static ConcurrentException extractCause(ExecutionException ex) {
if (ex == null || ex.getCause() == null)
return null;
throwCause(ex);
return new ConcurrentException(ex.getMessage(), ex.getCause());
}
public static ConcurrentRuntimeException extractCauseUnchecked(ExecutionException ex) {
if (ex == null || ex.getCause() == null)
return null;
throwCause(ex);
return new ConcurrentRuntimeException(ex.getMessage(), ex.getCause());
}
public static void handleCause(ExecutionException ex) throws ConcurrentException {
ConcurrentException cex = extractCause(ex);
if (cex != null)
throw cex;
}
public static void handleCauseUnchecked(ExecutionException ex) {
ConcurrentRuntimeException crex = extractCauseUnchecked(ex);
if (crex != null)
throw crex;
}
static Throwable checkedException(Throwable ex) {
if (ex != null && !(ex instanceof RuntimeException) && !(ex instanceof Error))
return ex;
throw new IllegalArgumentException("Not a checked exception: " + ex);
}
private static void throwCause(ExecutionException ex) {
if (ex.getCause() instanceof RuntimeException)
throw (RuntimeException)ex.getCause();
if (ex.getCause() instanceof Error)
throw (Error)ex.getCause();
}
public static <T> T initialize(ConcurrentInitializer<T> initializer) throws ConcurrentException {
return (initializer != null) ? initializer.get() : null;
}
public static <T> T initializeUnchecked(ConcurrentInitializer<T> initializer) {
try {
return initialize(initializer);
} catch (ConcurrentException cex) {
throw new ConcurrentRuntimeException(cex.getCause());
}
}
public static <K, V> V putIfAbsent(ConcurrentMap<K, V> map, K key, V value) {
if (map == null)
return null;
V result = map.putIfAbsent(key, value);
return (result != null) ? result : value;
}
public static <K, V> V createIfAbsent(ConcurrentMap<K, V> map, K key, ConcurrentInitializer<V> init) throws ConcurrentException {
if (map == null || init == null)
return null;
V value = map.get(key);
if (value == null)
return putIfAbsent(map, key, init.get());
return value;
}
public static <K, V> V createIfAbsentUnchecked(ConcurrentMap<K, V> map, K key, ConcurrentInitializer<V> init) {
try {
return createIfAbsent(map, key, init);
} catch (ConcurrentException cex) {
throw new ConcurrentRuntimeException(cex.getCause());
}
}
public static <T> Future<T> constantFuture(T value) {
return new ConstantFuture<T>(value);
}
static final class ConstantFuture<T> implements Future<T> {
private final T value;
ConstantFuture(T value) {
this.value = value;
}
public boolean isDone() {
return true;
}
public T get() {
return this.value;
}
public T get(long timeout, TimeUnit unit) {
return this.value;
}
public boolean isCancelled() {
return false;
}
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
}
}
| [
"[email protected]"
] | |
7b907e3d2654471b8e5742fc6db67c08f1b2c760 | 26f04b87f6db47e918641f4b4751f5a63cf7d60e | /MyMDApp/src/com/example/activities/DiaryListActivity.java | 3f00e3fba67ead479160c958edfe2229564c0d7a | [] | no_license | mengxiankui/MyMDApp | fc32ba63df3c8f6ef4f075029a115b1cf15a2c00 | ec0ad0a808548b433dc9989e0aa0a6fcf7990814 | refs/heads/master | 2021-01-19T03:41:18.797437 | 2017-08-24T09:21:33 | 2017-08-24T09:21:33 | 49,555,542 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,616 | java | package com.example.activities;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.example.mymdapp.R;
import com.example.util.Consts.DiaryConst;
import com.example.util.TimeUtil;
import com.mxk.baseapplication.LBaseActivity;
public class DiaryListActivity extends LBaseActivity implements LoaderCallbacks<Cursor>{
@Bind(R.id.diary_list)
ListView listDiary;
@Bind(R.id.btn_create_new)
Button btnCreate;
MyCursorAdapter mAdapter;
@Override
public int getContentView() {
// TODO Auto-generated method stub
return R.layout.activity_diary_list;
}
@Override
public void setToolBar(Toolbar mToolbar) {
// TODO Auto-generated method stub
mToolbar.setTitle("日记本");
}
@Override
public void onAfterOnCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
ButterKnife.bind(this);
setupToolBar();
init();
initAction();
}
private void initAction() {
// TODO Auto-generated method stub
listDiary.setOnItemLongClickListener(new OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id)
{
// TODO Auto-generated method stub
Intent intent = new Intent(DiaryListActivity.this, DiaryActivity.class);
Bundle bundle = new Bundle();
Cursor cursor = (Cursor) parent.getAdapter().getItem(position);
bundle.putString(DiaryConst.TID,
cursor.getString(cursor.getColumnIndex(DiaryConst.TID)));
bundle.putString(DiaryConst.TITLE,
cursor.getString(cursor.getColumnIndex(DiaryConst.TITLE)));
bundle.putString(DiaryConst.CONTENT,
cursor.getString(cursor.getColumnIndex(DiaryConst.CONTENT)));
bundle.putString(DiaryConst.DIARY_TYPE, DiaryConst.TYPE_EDIT);
intent.putExtras(bundle);
startActivity(intent);
return true;
}
});
btnCreate.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent = new Intent(DiaryListActivity.this, DiaryActivity.class);
Bundle bundle = new Bundle();
bundle.putString(DiaryConst.DIARY_TYPE, DiaryConst.TYPE_NEW);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
private void init() {
// TODO Auto-generated method stub
mAdapter = new MyCursorAdapter(this, null);
listDiary.setAdapter(mAdapter);
getLoaderManager().initLoader(0, null, this);
}
private void setupToolBar() {
// TODO Auto-generated method stub
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getToolBar().setNavigationOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
onBackPressed();
}
});
}
public class MyCursorAdapter extends CursorAdapter
{
public MyCursorAdapter(Context context, Cursor c)
{
super(context, c);
// TODO Auto-generated constructor stub
}
public MyCursorAdapter(Context context, Cursor c, boolean autoRequery)
{
super(context, c, autoRequery);
// TODO Auto-generated constructor stub
}
public MyCursorAdapter(Context context, Cursor c, int flags)
{
super(context, c, flags);
// TODO Auto-generated constructor stub
}
@Override
public View newView(Context context, final Cursor cursor, ViewGroup parent)
{
// TODO Auto-generated method stub
View view = LayoutInflater.from(DiaryListActivity.this).inflate(
R.layout.diary_listitem, null);
ViewHolder holder = new ViewHolder();
holder.txtTitle = (TextView) view.findViewById(R.id.title);
holder.txtDate = (TextView) view.findViewById(R.id.date);
holder.btnDelete = (Button) view.findViewById(R.id.delete);
view.setTag(holder);
bindView(view, context, cursor);
return view;
}
@Override
public void bindView(View view, Context context, final Cursor cursor)
{
// TODO Auto-generated method stub
ViewHolder holder = (ViewHolder) view.getTag();
String strTitle = cursor.getString(cursor.getColumnIndex(DiaryConst.TITLE));
if (TextUtils.isEmpty(strTitle))
{
holder.txtTitle.setText("未命名");
}
else
{
holder.txtTitle.setText(strTitle);
}
Long lmilliseconds = cursor.getLong(cursor.getColumnIndex(DiaryConst.DATE));
holder.txtDate.setText(TimeUtil.getDateFormat(lmilliseconds));
final long lId = cursor.getLong(cursor.getColumnIndex(DiaryConst.TID));
holder.btnDelete.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
new AlertDialog.Builder(DiaryListActivity.this)
.setMessage(R.string.alert_delete)
.setPositiveButton("确定",
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
DiaryListActivity.this.getContentResolver().delete(
ContentUris.withAppendedId(
DiaryConst.CONTENT_URI, lId),
null, null);
}
})
.setNegativeButton("取消",
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
}
}).create().show();
}
});
}
}
public class ViewHolder
{
private TextView txtTitle;
private TextView txtDate;
private Button btnDelete;
}
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args)
{
// TODO Auto-generated method stub
return new CursorLoader(this, DiaryConst.CONTENT_URI, null, null, null,
DiaryConst.ORDER_DATE_DESC);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data)
{
// TODO Auto-generated method stub
mAdapter.swapCursor(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader)
{
// TODO Auto-generated method stub
mAdapter.swapCursor(null);
}
}
| [
"[email protected]"
] | |
0ebeff87c5cdbc479aaaa59c3bd11029a15e8d25 | 4817a306c3b76af1ccb3cd33f2dfe78c4085dc25 | /src/main/java/com/lyl/concurrency/ConcurrencyApplication.java | 7f911f4bdd5e3e72b8ef99f6e1c61585b4b33b49 | [] | no_license | LYL41011/java-concurrency-learning | 36c0206e08f977ea4d40848b118bbbc21d9cb35a | c8ec72d63e7830ecb57fa9eefe5effd0376a1537 | refs/heads/master | 2022-10-18T20:44:11.197037 | 2020-06-06T10:13:54 | 2020-06-06T10:13:54 | 262,068,409 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,040 | java | package com.lyl.concurrency;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@SpringBootApplication
public class ConcurrencyApplication extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplication.run(ConcurrencyApplication.class, args);
}
@Bean
public FilterRegistrationBean httpFilter() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(new HttpFilter());
registrationBean.addUrlPatterns("/threadLocal/*");
return registrationBean;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HttpInterceptor()).addPathPatterns("/**");
}
}
| [
"[email protected]"
] | |
dea4ab3babe46052957750e0be47eb721b47eb22 | f78d8109f433faf0016da10506b12c7f70e00952 | /src/main/java/com/base/MultipleDataSource.java | 25212948f92ce53d1a85b76df5a6b34898b087b1 | [] | no_license | gaoqiongxie/order | 1d4abeb04c2def25ce18c20c320f834664c520b8 | 0d4b527202c36d98f2b9ba1a591741236628cc4d | refs/heads/master | 2020-12-15T05:21:49.030736 | 2020-07-22T03:01:14 | 2020-07-22T03:01:14 | 235,005,472 | 0 | 0 | null | 2020-01-20T05:18:42 | 2020-01-20T02:43:50 | Java | UTF-8 | Java | false | false | 801 | java | package com.base;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
/**
* 多数据源配置类
*
* @author xiegaoqiong
*
*/
public class MultipleDataSource extends AbstractRoutingDataSource {
private static final ThreadLocal<String> dataSourceHolder = new ThreadLocal<String>();
/**
* 设置数据源
* @param dataSource 数据源名称
*/
public static void setDataSource(String dataSource) {
dataSourceHolder.set(dataSource);
}
/**
* 获取数据源
* @return
*/
public static String getDatasource() {
return dataSourceHolder.get();
}
/**
* 清除数据源
*/
public static void clearDataSource() {
dataSourceHolder.remove();
}
@Override
protected Object determineCurrentLookupKey() {
return dataSourceHolder.get();
}
}
| [
"[email protected]"
] | |
4ac35a8ddec362987943bda4d8fc19d34e70e3d8 | eeffa8e086068b3b1986b220a1a158de902a7ac1 | /app/src/main/java/com/kunminx/puremusic/ui/page/adapter/PlaylistAdapter.java | 1db86eccc3307f81d38c5d4e488746127effe5f3 | [
"Apache-2.0"
] | permissive | yangyugee/Jetpack-MVVM-Best-Practice | cc81a41c7122ac7302c95948aeb58c556172cf36 | 6b69074580a920aca6e5abb5b0e4c1363d76455c | refs/heads/master | 2023-07-07T08:57:15.101098 | 2020-07-18T17:25:36 | 2020-07-18T17:25:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,902 | java | /*
* Copyright 2018-2020 KunMinX
*
* 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.kunminx.puremusic.ui.page.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.recyclerview.widget.RecyclerView;
import com.kunminx.architecture.ui.adapter.SimpleDataBindingAdapter;
import com.kunminx.puremusic.R;
import com.kunminx.puremusic.data.bean.TestAlbum;
import com.kunminx.puremusic.databinding.AdapterPlayItemBinding;
import com.kunminx.puremusic.player.PlayerManager;
/**
* Create by KunMinX at 20/4/19
*/
public class PlaylistAdapter extends SimpleDataBindingAdapter<TestAlbum.TestMusic, AdapterPlayItemBinding> {
public PlaylistAdapter(Context context) {
super(context, R.layout.adapter_play_item, DiffUtils.getInstance().getTestMusicItemCallback());
setOnItemClickListener(((item, position) -> {
PlayerManager.getInstance().playAudio(position);
}));
}
@Override
protected void onBindItem(AdapterPlayItemBinding binding, TestAlbum.TestMusic item, RecyclerView.ViewHolder holder) {
binding.setAlbum(item);
int currentIndex = PlayerManager.getInstance().getAlbumIndex();
binding.ivPlayStatus.setColor(currentIndex == holder.getAdapterPosition()
? binding.getRoot().getContext().getResources().getColor(R.color.gray) : Color.TRANSPARENT);
}
}
| [
"[email protected]"
] | |
2e1fde25d356870e34924729f5bbfee69a07eae4 | df5b2dbb1466417322a108d27a625b9673861eed | /src/java/service/FurnitureentityFacadeREST.java | a8cce0e99bcfd5bd7ec8aa1bded366e26c843986 | [] | no_license | IS3102-07/IS3102_MobileWS | f35a75fbfa4fc707c7e4f51824b4b2fbc63403bb | 0dc30e377a210a1f6e80873f7298f16d8f8e8baf | refs/heads/master | 2021-01-01T06:33:49.893639 | 2015-03-27T04:14:18 | 2015-03-27T04:14:18 | 25,724,331 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,226 | 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 service;
import Entity.Furnitureentity;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
/**
*
* @author Jason
*/
@Stateless
@Path("entity.furnitureentity")
public class FurnitureentityFacadeREST extends AbstractFacade<Furnitureentity> {
@PersistenceContext(unitName = "WebService_MobilePU")
private EntityManager em;
public FurnitureentityFacadeREST() {
super(Furnitureentity.class);
}
@POST
@Override
@Consumes({"application/xml", "application/json"})
public void create(Furnitureentity entity) {
super.create(entity);
}
@PUT
@Path("{id}")
@Consumes({"application/xml", "application/json"})
public void edit(@PathParam("id") Long id, Furnitureentity entity) {
super.edit(entity);
}
@DELETE
@Path("{id}")
public void remove(@PathParam("id") Long id) {
super.remove(super.find(id));
}
@GET
@Path("{id}")
@Produces({"application/xml", "application/json"})
public Furnitureentity find(@PathParam("id") Long id) {
return super.find(id);
}
@GET
@Override
@Produces({"application/xml", "application/json"})
public List<Furnitureentity> findAll() {
return super.findAll();
}
@GET
@Path("{from}/{to}")
@Produces({"application/xml", "application/json"})
public List<Furnitureentity> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
return super.findRange(new int[]{from, to});
}
@GET
@Path("count")
@Produces("text/plain")
public String countREST() {
return String.valueOf(super.count());
}
@Override
protected EntityManager getEntityManager() {
return em;
}
}
| [
"[email protected]"
] | |
f29b086d795aa9bee42ba7927ee7cbd7810f1220 | d6c9d1ebf547854c4340d06bf99dc52468c66942 | /src/OfficeHours/_05_13_2020/InstanceTest.java | af8ab4fa184466809f84617ced246e50acaeb79d | [] | no_license | Jmossman14/Spring2020B18_Java | 68d706c9df7f6173e3f58c645ef0263a615364c8 | 223b0d21e1dca6d5a15f27362039df99f5b55c1c | refs/heads/master | 2022-08-16T01:56:45.727008 | 2020-06-22T17:01:18 | 2020-06-22T17:01:18 | 257,957,842 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 692 | java | package OfficeHours._05_13_2020;
public class InstanceTest {
public static void main(String[] args) {
/*
Each object has its OWN copy of the instance variable
MUST assign each object to the instance variable or else it will output NULL
*/
//create an object to test the functions of Instances class:
Instances obj1 = new Instances();
obj1.name = "Judy"; // calls the String Name
obj1.printName();
Instances obj2 = new Instances();
// since there are 2 objects, MUST assign obj2 to String name
obj2.name = "Keora";
obj2.printName();
// ===========================================================
}
}
| [
"[email protected]"
] | |
9772966df58d5b31810448ae0075b1467be77041 | 5ce98124cef0f4d70d6afb628554154e2dd85224 | /src/main/java/it/arlanis/reply/models/Campaign.java | 137abc893de86e31f0987fd05e2ce8d54a561e60 | [] | no_license | onofujoHawk/vodafone-bonifica-catalogue | e8f0deb303b6a53e219c5343f245e7879ac3f065 | 346f87dfc09a9e46c301adfe0f9bc2dac156ae09 | refs/heads/master | 2021-01-01T16:54:33.483627 | 2017-07-27T15:24:09 | 2017-07-27T15:24:09 | 97,951,480 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,708 | java | package it.arlanis.reply.models;
import it.arlanis.reply.models.enums.CampaignState;
import it.arlanis.reply.models.enums.CampaignType;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Entity
@Table(name = "campaign")
public class Campaign extends AbstractEagleCatalogueObject implements Serializable {
public static final String CODE_PREFIX = "camp-";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "campaign_id")
private Long campaignId;
public Long getId() {
return campaignId;
}
@Column(name = "code", unique = true)
private String code;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Column(name = "type")
@Enumerated(value = EnumType.STRING)
private CampaignType type;
@Column(name = "state")
@Enumerated(value = EnumType.STRING)
private CampaignState state;
@ManyToMany
@JoinTable(name = "campaign_channel_relation", joinColumns = @JoinColumn(name = "campaign", referencedColumnName = "campaign_id"), inverseJoinColumns = @JoinColumn(name = "channel", referencedColumnName = "channel_id"))
private List<Channel> channels = new ArrayList<Channel>();
@OneToMany(mappedBy = "campaign")
private List<EnabledUser> enabledUsers = new ArrayList<EnabledUser>();
@Column(name = "convergenza")
private Boolean convergenza;
@Column(name = "start_date")
private Date startDate;
@Column(name = "end_date")
private Date endDate;
@OneToMany(mappedBy = "campaign")
@Column(nullable = true)
private List<OfferInCampaign> offersInCampaign = new ArrayList<OfferInCampaign>();
public Long getCampaignId() {
return campaignId;
}
public void setCampaignId(Long campaignId) {
this.campaignId = campaignId;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public CampaignType getType() {
return type;
}
public void setType(CampaignType type) {
this.type = type;
}
public List<Channel> getChannels() {
return channels;
}
public void setChannel(List<Channel> channels) {
this.channels = channels;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
if (endDate == null) {
this.endDate = null;
return;
}
Calendar date = Calendar.getInstance();
date.setTime(endDate);
date.set(Calendar.HOUR_OF_DAY, 23);
date.set(Calendar.MINUTE, 59);
date.set(Calendar.SECOND, 59);
this.endDate = date.getTime();
}
public List<OfferInCampaign> getOffersInCampaign() {
return offersInCampaign;
}
public void setOffersInCampaign(List<OfferInCampaign> offersInCampaign) {
this.offersInCampaign = offersInCampaign;
}
public Boolean getConvergenza() {
return convergenza;
}
public void setConvergenza(Boolean convergenza) {
this.convergenza = convergenza;
}
public CampaignState getState() {
return state;
}
public void setState(CampaignState state) {
this.state = state;
}
public List<EnabledUser> getEnabledUsers() {
return enabledUsers;
}
public void setEnabledUsers(List<EnabledUser> enabledUsers) {
this.enabledUsers = enabledUsers;
}
public void setChannels(List<Channel> channels) {
this.channels = channels;
}
}
| [
"[email protected]"
] | |
1177fff63249c44226cd3c73cc98c37c0c9b630f | ca030864a3a1c24be6b9d1802c2353da4ca0d441 | /classes2.dex_source_from_JADX/com/facebook/photos/creativeediting/swipeable/prompt/FramePromptProvider.java | d9efe65eeb31fd79e238f7dd867ec34774f33bdb | [] | no_license | pxson001/facebook-app | 87aa51e29195eeaae69adeb30219547f83a5b7b1 | 640630f078980f9818049625ebc42569c67c69f7 | refs/heads/master | 2020-04-07T20:36:45.758523 | 2018-03-07T09:04:57 | 2018-03-07T09:04:57 | 124,208,458 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package com.facebook.photos.creativeediting.swipeable.prompt;
import com.facebook.inject.AbstractAssistedProvider;
/* compiled from: mobile_data */
public class FramePromptProvider extends AbstractAssistedProvider<FramePrompt> {
}
| [
"[email protected]"
] | |
b674ad588354196bbb1bc089bae341af53f44d90 | b96be200dd0d18838d61be34bee0030f0df18c2c | /app/src/main/java/com/magicwind/android/fitness_club/Activity/search.java | 77d4702ece57ed285786f5215cff058b2bccbc8c | [] | no_license | OldAAAA/android-second-homework | ce801448c993416186523733ca515e9dace102f0 | 153bb03b97c063d9244b965d5ed404f6e52faed4 | refs/heads/master | 2020-04-06T12:38:40.223918 | 2018-11-14T05:39:02 | 2018-11-14T05:39:02 | 157,463,953 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 630 | java | package com.magicwind.android.fitness_club.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.magicwind.android.fitness_club.R;
public class search extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
getSupportActionBar().hide();
}
public void searchResult(View view){
Intent intent = new Intent(this,allCourse.class);
startActivity(intent);
}
}
| [
"[email protected]"
] | |
b96bdc635502674b61b2849e19871557dff319b2 | 2f662133b388bd8992c4ed8d04ad77f0290d3970 | /src/main/java/migu/algorithm/study/search/BinarySearchLoop.java | 8a7b7ee108e75e7ce8001f946d32e563d1a34c33 | [] | no_license | tinajeong/dsjava | d050f060f180245354e65eef4c4a789e8e93ea3a | aa2c48765f00fb1d6afe076f673798cb80461683 | refs/heads/master | 2022-07-28T13:35:47.860741 | 2020-05-18T08:45:56 | 2020-05-18T08:45:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 908 | java | package migu.algorithm.study.search;
import migu.algorithm.study.util.PrintArray;
public class BinarySearchLoop {
int[] arr;
public BinarySearchLoop() {
}
public BinarySearchLoop(int[] arr) {
this.arr = arr;
}
public boolean binarySearch(int target) {
new PrintArray().printArray(arr);
int first = 0;
int last = arr.length - 1;
int cnt = 0;
while (first <= last) {
int mid = (first + last) / 2;
cnt++;
if (arr[mid] > target) {
last = mid - 1;
} else if (arr[mid] < target) {
first = mid + 1;
} else {
return true;
}
}
System.out.println(cnt);
return false;
}
public int[] getArr() {
return arr;
}
public void setArr(int[] arr) {
this.arr = arr;
}
}
| [
"[email protected]"
] | |
1b7ed63ceb3327bef7986a58026323b85a5f3b11 | 5f9d7c5ab2e42a92336019bc86dccb8520c746f5 | /src/Unit17/SimplePicture.java | c27ae95112cebba595913cc440a51c34c91f391c | [] | no_license | jsgharib/Unit17 | 0fa8858f7930365bd0cbac8aa3baffc1f9c29cdd | 7ef4193d0ee6d976be7c62d05b2340ed2135593d | refs/heads/master | 2020-05-19T02:36:20.150494 | 2019-05-03T16:01:32 | 2019-05-03T16:01:32 | 184,783,818 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 24,023 | java | package Unit17;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import java.awt.*;
import java.io.*;
import java.awt.geom.*;
/**
* A class that represents a simple picture. A simple picture may have an
* associated file name and a title. A simple picture has pixels, width, and
* height. A simple picture uses a BufferedImage to hold the pixels. You can
* show a simple picture in a PictureFrame (a JFrame). You can also explore a
* simple picture.
*
* @author Barb Ericson [email protected]
*/
public class SimplePicture implements DigitalPicture {
/////////////////////// Fields /////////////////////////
/**
* the file name associated with the simple picture
*/
private String fileName;
/**
* the title of the simple picture
*/
private String title;
/**
* buffered image to hold pixels for the simple picture
*/
private BufferedImage bufferedImage;
/**
* frame used to display the simple picture
*/
private PictureFrame pictureFrame;
/**
* extension for this file (jpg or bmp)
*/
private String extension;
/////////////////////// Constructors /////////////////////////
/**
* A Constructor that takes no arguments. It creates a picture with a width
* of 200 and a height of 100 that is all white. A no-argument constructor
* must be given in order for a class to be able to be subclassed. By
* default all subclasses will implicitly call this in their parent's
* no-argument constructor unless a different call to super() is explicitly
* made as the first line of code in a constructor.
*/
public SimplePicture() {
this(200, 100);
}
/**
* A Constructor that takes a file name and uses the file to create a
* picture
*
* @param fileName the file name to use in creating the picture
*/
public SimplePicture(String fileName) {
// load the picture into the buffered image
load("src/images/" + fileName);
}
/**
* A constructor that takes the width and height desired for a picture and
* creates a buffered image of that size. This constructor doesn't show the
* picture. The pixels will all be white.
*
* @param width the desired width
* @param height the desired height
*/
public SimplePicture(int width, int height) {
bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
title = "None";
fileName = "None";
extension = "jpg";
setAllPixelsToAColor(Color.white);
}
/**
* A constructor that takes the width and height desired for a picture and
* creates a buffered image of that size. It also takes the color to use for
* the background of the picture.
*
* @param width the desired width
* @param height the desired height
* @param theColor the background color for the picture
*/
public SimplePicture(int width, int height, Color theColor) {
this(width, height);
setAllPixelsToAColor(theColor);
}
/**
* A Constructor that takes a picture to copy information from
*
* @param copyPicture the picture to copy from
*/
public SimplePicture(SimplePicture copyPicture) {
if (copyPicture.fileName != null) {
this.fileName = new String(copyPicture.fileName);
this.extension = copyPicture.extension;
}
if (copyPicture.title != null) {
this.title = new String(copyPicture.title);
}
if (copyPicture.bufferedImage != null) {
this.bufferedImage = new BufferedImage(copyPicture.getWidth(),
copyPicture.getHeight(), BufferedImage.TYPE_INT_RGB);
this.copyPicture(copyPicture);
}
}
/**
* A constructor that takes a buffered image
*
* @param image the buffered image
*/
public SimplePicture(BufferedImage image) {
this.bufferedImage = image;
title = "None";
fileName = "None";
extension = "jpg";
}
////////////////////////// Methods //////////////////////////////////
/**
* Method to get the extension for this picture
*
* @return the extension (jpg, bmp, giff, etc)
*/
public String getExtension() {
return extension;
}
/**
* Method that will copy all of the passed source picture into the current
* picture object
*
* @param sourcePicture the picture object to copy
*/
public void copyPicture(SimplePicture sourcePicture) {
Pixel sourcePixel = null;
Pixel targetPixel = null;
// loop through the columns
for (int sourceX = 0, targetX = 0;
sourceX < sourcePicture.getWidth()
&& targetX < this.getWidth();
sourceX++, targetX++) {
// loop through the rows
for (int sourceY = 0, targetY = 0;
sourceY < sourcePicture.getHeight()
&& targetY < this.getHeight();
sourceY++, targetY++) {
sourcePixel = sourcePicture.getPixel(sourceX, sourceY);
targetPixel = this.getPixel(targetX, targetY);
targetPixel.setColor(sourcePixel.getColor());
}
}
}
/**
* Method to set the color in the picture to the passed color
*
* @param color the color to set to
*/
public void setAllPixelsToAColor(Color color) {
// loop through all x
for (int x = 0; x < this.getWidth(); x++) {
// loop through all y
for (int y = 0; y < this.getHeight(); y++) {
getPixel(x, y).setColor(color);
}
}
}
/**
* Method to get the buffered image
*
* @return the buffered image
*/
public BufferedImage getBufferedImage() {
return bufferedImage;
}
/**
* Method to get a graphics object for this picture to use to draw on
*
* @return a graphics object to use for drawing
*/
public Graphics getGraphics() {
return bufferedImage.getGraphics();
}
/**
* Method to get a Graphics2D object for this picture which can be used to
* do 2D drawing on the picture
*/
public Graphics2D createGraphics() {
return bufferedImage.createGraphics();
}
/**
* Method to get the file name associated with the picture
*
* @return the file name associated with the picture
*/
public String getFileName() {
return fileName;
}
/**
* Method to set the file name
*
* @param name the full pathname of the file
*/
public void setFileName(String name) {
fileName = name;
}
/**
* Method to get the title of the picture
*
* @return the title of the picture
*/
public String getTitle() {
return title;
}
/**
* Method to set the title for the picture
*
* @param title the title to use for the picture
*/
public void setTitle(String title) {
this.title = title;
if (pictureFrame != null) {
pictureFrame.setTitle(title);
}
}
/**
* Method to get the width of the picture in pixels
*
* @return the width of the picture in pixels
*/
public int getWidth() {
return bufferedImage.getWidth();
}
/**
* Method to get the height of the picture in pixels
*
* @return the height of the picture in pixels
*/
public int getHeight() {
return bufferedImage.getHeight();
}
/**
* Method to get the picture frame for the picture
*
* @return the picture frame associated with this picture (it may be null)
*/
public PictureFrame getPictureFrame() {
return pictureFrame;
}
/**
* Method to set the picture frame for this picture
*
* @param pictureFrame the picture frame to use
*/
public void setPictureFrame(PictureFrame pictureFrame) {
// set this picture object's picture frame to the passed one
this.pictureFrame = pictureFrame;
}
/**
* Method to get an image from the picture
*
* @return the buffered image since it is an image
*/
public Image getImage() {
return bufferedImage;
}
/**
* Method to return the pixel value as an int for the given x and y location
*
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @return the pixel value as an integer (alpha, red, green, blue)
*/
public int getBasicPixel(int x, int y) {
return bufferedImage.getRGB(x, y);
}
/**
* Method to set the value of a pixel in the picture from an int
*
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @param rgb the new rgb value of the pixel (alpha, red, green, blue)
*/
public void setBasicPixel(int x, int y, int rgb) {
bufferedImage.setRGB(x, y, rgb);
}
/**
* Method to get a pixel object for the given x and y location
*
* @param x the x location of the pixel in the picture
* @param y the y location of the pixel in the picture
* @return a Pixel object for this location
*/
public Pixel getPixel(int x, int y) {
// create the pixel object for this picture and the given x and y location
Pixel pixel = new Pixel(this, x, y);
return pixel;
}
/**
* Method to get a one-dimensional array of Pixels for this simple picture
*
* @return a one-dimensional array of Pixel objects starting with y=0 to
* y=height-1 and x=0 to x=width-1.
*/
public Pixel[] getPixels() {
int width = getWidth();
int height = getHeight();
Pixel[] pixelArray = new Pixel[width * height];
// loop through height rows from top to bottom
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
pixelArray[row * width + col] = new Pixel(this, col, row);
}
}
return pixelArray;
}
/**
* Method to get a two-dimensional array of Pixels for this simple picture
*
* @return a two-dimensional array of Pixel objects in row-major order.
*/
public Pixel[][] getPixels2D() {
int width = getWidth();
int height = getHeight();
Pixel[][] pixelArray = new Pixel[height][width];
// loop through height rows from top to bottom
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
pixelArray[row][col] = new Pixel(this, col, row);
}
}
return pixelArray;
}
/**
* Method to load the buffered image with the passed image
*
* @param image the image to use
*/
public void load(Image image) {
// get a graphics context to use to draw on the buffered image
Graphics2D graphics2d = bufferedImage.createGraphics();
// draw the image on the buffered image starting at 0,0
graphics2d.drawImage(image, 0, 0, null);
// show the new image
show();
}
/**
* Method to show the picture in a picture frame
*/
public void show() {
// if there is a current picture frame then use it
if (pictureFrame != null) {
pictureFrame.updateImageAndShowIt();
} // else create a new picture frame with this picture
else {
pictureFrame = new PictureFrame(this);
}
}
/**
* Method to hide the picture display
*/
public void hide() {
if (pictureFrame != null) {
pictureFrame.setVisible(false);
}
}
/**
* Method to make this picture visible or not
*
* @param flag true if you want it visible else false
*/
public void setVisible(boolean flag) {
if (flag) {
this.show();
} else {
this.hide();
}
}
/**
* Method to open a picture explorer on a copy (in memory) of this simple
* picture
*/
public void explore() {
// create a copy of the current picture and explore it
new PictureExplorer(new SimplePicture(this));
}
/**
* Method to force the picture to repaint itself. This is very useful after
* you have changed the pixels in a picture and you want to see the change.
*/
public void repaint() {
// if there is a picture frame tell it to repaint
if (pictureFrame != null) {
pictureFrame.repaint();
} // else create a new picture frame
else {
pictureFrame = new PictureFrame(this);
}
}
/**
* Method to load the picture from the passed file name
*
* @param fileName the file name to use to load the picture from
* @throws IOException if the picture isn't found
*/
public void loadOrFail(String fileName) throws IOException {
// set the current picture's file name
this.fileName = fileName;
// set the extension
int posDot = fileName.indexOf('.');
if (posDot >= 0) {
this.extension = fileName.substring(posDot + 1);
}
// if the current title is null use the file name
if (title == null) {
title = fileName;
}
File file = new File(this.fileName);
if (!file.canRead()) {
// try adding the media path
file = new File(FileChooser.getMediaPath(this.fileName));
if (!file.canRead()) {
throw new IOException(this.fileName
+ " could not be opened. Check that you specified the path");
}
}
bufferedImage = ImageIO.read(file);
}
/**
* Method to read the contents of the picture from a filename without
* throwing errors
*
* @param fileName the name of the file to write the picture to
* @return true if success else false
*/
public boolean load(String fileName) {
try {
this.loadOrFail(fileName);
return true;
} catch (Exception ex) {
System.out.println("There was an error trying to open " + fileName);
bufferedImage = new BufferedImage(600, 200,
BufferedImage.TYPE_INT_RGB);
addMessage("Couldn't load " + fileName, 5, 100);
return false;
}
}
/**
* Method to load the picture from the passed file name this just calls
* load(fileName) and is for name compatibility
*
* @param fileName the file name to use to load the picture from
* @return true if success else false
*/
public boolean loadImage(String fileName) {
return load(fileName);
}
/**
* Method to draw a message as a string on the buffered image
*
* @param message the message to draw on the buffered image
* @param xPos the x coordinate of the leftmost point of the string
* @param yPos the y coordinate of the bottom of the string
*/
public void addMessage(String message, int xPos, int yPos) {
// get a graphics context to use to draw on the buffered image
Graphics2D graphics2d = bufferedImage.createGraphics();
// set the color to white
graphics2d.setPaint(Color.white);
// set the font to Helvetica bold style and size 16
graphics2d.setFont(new Font("Helvetica", Font.BOLD, 16));
// draw the message
graphics2d.drawString(message, xPos, yPos);
}
/**
* Method to draw a string at the given location on the picture
*
* @param text the text to draw
* @param xPos the left x for the text
* @param yPos the top y for the text
*/
public void drawString(String text, int xPos, int yPos) {
addMessage(text, xPos, yPos);
}
/**
* Method to create a new picture by scaling the current picture by the
* given x and y factors
*
* @param xFactor the amount to scale in x
* @param yFactor the amount to scale in y
* @return the resulting picture
*/
public Picture scale(double xFactor, double yFactor) {
// set up the scale transform
AffineTransform scaleTransform = new AffineTransform();
scaleTransform.scale(xFactor, yFactor);
// create a new picture object that is the right size
Picture result = new Picture((int) (getWidth() * xFactor),
(int) (getHeight() * yFactor));
// get the graphics 2d object to draw on the result
Graphics graphics = result.getGraphics();
Graphics2D g2 = (Graphics2D) graphics;
// draw the current image onto the result image scaled
g2.drawImage(this.getImage(), scaleTransform, null);
return result;
}
/**
* Method to create a new picture of the passed width. The aspect ratio of
* the width and height will stay the same.
*
* @param width the desired width
* @return the resulting picture
*/
public Picture getPictureWithWidth(int width) {
// set up the scale transform
double xFactor = (double) width / this.getWidth();
Picture result = scale(xFactor, xFactor);
return result;
}
/**
* Method to create a new picture of the passed height. The aspect ratio of
* the width and height will stay the same.
*
* @param height the desired height
* @return the resulting picture
*/
public Picture getPictureWithHeight(int height) {
// set up the scale transform
double yFactor = (double) height / this.getHeight();
Picture result = scale(yFactor, yFactor);
return result;
}
/**
* Method to load a picture from a file name and show it in a picture frame
*
* @param fileName the file name to load the picture from
* @return true if success else false
*/
public boolean loadPictureAndShowIt(String fileName) {
boolean result = true; // the default is that it worked
// try to load the picture into the buffered image from the file name
result = load(fileName);
// show the picture in a picture frame
show();
return result;
}
/**
* Method to write the contents of the picture to a file with the passed
* name
*
* @param fileName the name of the file to write the picture to
*/
public void writeOrFail(String fileName) throws IOException {
String extension = this.extension; // the default is current
// create the file object
File file = new File(fileName);
File fileLoc = file.getParentFile(); // directory name
// if there is no parent directory use the current media dir
if (fileLoc == null) {
fileName = FileChooser.getMediaPath(fileName);
file = new File(fileName);
fileLoc = file.getParentFile();
}
// check that you can write to the directory
if (!fileLoc.canWrite()) {
throw new IOException(fileName
+ " could not be opened. Check to see if you can write to the directory.");
}
// get the extension
int posDot = fileName.indexOf('.');
if (posDot >= 0) {
extension = fileName.substring(posDot + 1);
}
// write the contents of the buffered image to the file
ImageIO.write(bufferedImage, extension, file);
}
/**
* Method to write the contents of the picture to a file with the passed
* name without throwing errors
*
* @param fileName the name of the file to write the picture to
* @return true if success else false
*/
public boolean write(String fileName) {
try {
this.writeOrFail(fileName);
return true;
} catch (Exception ex) {
System.out.println("There was an error trying to write " + fileName);
ex.printStackTrace();
return false;
}
}
/**
* Method to get the directory for the media
*
* @param fileName the base file name to use
* @return the full path name by appending the file name to the media
* directory
*/
public static String getMediaPath(String fileName) {
return FileChooser.getMediaPath(fileName);
}
/**
* Method to get the coordinates of the enclosing rectangle after this
* transformation is applied to the current picture
*
* @return the enclosing rectangle
*/
public Rectangle2D getTransformEnclosingRect(AffineTransform trans) {
int width = getWidth();
int height = getHeight();
double maxX = width - 1;
double maxY = height - 1;
double minX, minY;
Point2D.Double p1 = new Point2D.Double(0, 0);
Point2D.Double p2 = new Point2D.Double(maxX, 0);
Point2D.Double p3 = new Point2D.Double(maxX, maxY);
Point2D.Double p4 = new Point2D.Double(0, maxY);
Point2D.Double result = new Point2D.Double(0, 0);
Rectangle2D.Double rect = null;
// get the new points and min x and y and max x and y
trans.deltaTransform(p1, result);
minX = result.getX();
maxX = result.getX();
minY = result.getY();
maxY = result.getY();
trans.deltaTransform(p2, result);
minX = Math.min(minX, result.getX());
maxX = Math.max(maxX, result.getX());
minY = Math.min(minY, result.getY());
maxY = Math.max(maxY, result.getY());
trans.deltaTransform(p3, result);
minX = Math.min(minX, result.getX());
maxX = Math.max(maxX, result.getX());
minY = Math.min(minY, result.getY());
maxY = Math.max(maxY, result.getY());
trans.deltaTransform(p4, result);
minX = Math.min(minX, result.getX());
maxX = Math.max(maxX, result.getX());
minY = Math.min(minY, result.getY());
maxY = Math.max(maxY, result.getY());
// create the bounding rectangle to return
rect = new Rectangle2D.Double(minX, minY, maxX - minX + 1, maxY - minY + 1);
return rect;
}
/**
* Method to get the coordinates of the enclosing rectangle after this
* transformation is applied to the current picture
*
* @return the enclosing rectangle
*/
public Rectangle2D getTranslationEnclosingRect(AffineTransform trans) {
return getTransformEnclosingRect(trans);
}
/**
* Method to return a string with information about this picture
*
* @return a string with information about the picture
*/
public String toString() {
String output = "Simple Picture, filename " + fileName
+ " height " + getHeight() + " width " + getWidth();
return output;
}
} // end of SimplePicture class
| [
"[email protected]"
] | |
8d7bd7975aea40352672d89578924a68daa75997 | 8a0ae0b08c884d2749c2e49968454953df4773cd | /viikko5/Ohtu-NhlStatistics3/src/test/java/ohtuesimerkki/StaticsticsTest.java | 22a46ec955c28803497bddbb66d4659eab809e59 | [] | no_license | artokaik/ohtu-harkat | 7821777d8b84f2c252bdcbd1f43126c87aff6eb9 | 872e5b5bf53a607f4401f173ac609ea9e43e24c3 | refs/heads/master | 2021-01-10T21:37:39.737410 | 2013-04-28T10:46:32 | 2013-04-28T10:46:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,566 | java | package ohtuesimerkki;
import java.util.ArrayList;
import java.util.List;
import org.junit.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
public class StaticsticsTest {
Statistics stats;
@Before
public void setUp() {
PlayerReader reader = mock(PlayerReader.class);
ArrayList<Player> players = new ArrayList<Player>();
players.add(new Player("Semenko", "EDM", 4, 12));
players.add(new Player("Lemieux", "PIT", 45, 54));
players.add(new Player("Kurri", "EDM", 37, 53));
players.add(new Player("Yzerman", "DET", 42, 56));
players.add(new Player("Gretzky", "EDM", 35, 89));
when(reader.getPlayers()).thenReturn(players);
stats = new Statistics(reader);
}
@Test
public void playerFound() {
Player p = stats.search("Lemieux");
assertEquals("PIT", p.getTeam());
assertEquals(45, p.getGoals());
assertEquals(54, p.getAssists());
assertEquals(45 + 54, p.getPoints());
}
@Test
public void teamMembersFound() {
List<Player> players = stats.team("EDM");
assertEquals(3, players.size());
for (Player player : players) {
assertEquals("EDM", player.getTeam());
}
}
@Test
public void topScorersFound() {
List<Player> players = stats.topScorers(2);
assertEquals(3, players.size());
assertEquals("Gretzky", players.get(0).getName());
assertEquals("Lemieux", players.get(1).getName());
}
}
| [
"[email protected]"
] | |
18bf16aea150369ba9dbebbe6f22302517048be9 | 3e64790f1183845f71b1376e7243197581df7b7d | /src/main/java/ee/bcs/koolitus/muisikratt2/spring_app/config/JpaConfiguration.java | b84bb6dbaa6303c2ca643ed28d85449780ffbcde | [] | no_license | Merilis/pd | 9cff4316faebe6fa53ea2ab8f91aa601319c20c2 | 126d43f4686544b7d96925646f6e2e8a83676dfd | refs/heads/master | 2021-04-12T12:24:36.524203 | 2018-03-24T19:32:36 | 2018-03-24T19:32:36 | 126,633,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,263 | java | package ee.bcs.koolitus.muisikratt2.spring_app.config;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaDialect;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableJpaRepositories(basePackages = {"ee.bcs.koolitus.muisikratt2.spring_app.repository"})
@EnableTransactionManagement
public class JpaConfiguration {
@Value("${spring.jpa.hibernate.ddl-auto:none}")
private String ddlAuto;
@Value("${spring.jpa.show-sql:false}")
private String showSql;
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setDataSource(dataSource);
entityManagerFactory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
entityManagerFactory.setPackagesToScan("ee.bcs.koolitus.muisikratt2.spring_app.entity");
entityManagerFactory.setJpaPropertyMap(hibernateJpaProperties());
return entityManagerFactory;
}
private Map<String, ?> hibernateJpaProperties() {
Map<String, String> properties = new HashMap<>();
properties.put("hibernate.hbm2ddl.auto", ddlAuto);
properties.put("hibernate.show_sql", showSql);
properties.put("hibernate.connection.charSet", "UTF-8");
return properties;
}
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
jpaTransactionManager.setEntityManagerFactory(emf);
return jpaTransactionManager;
}
}
| [
"[email protected]"
] | |
da671a8a1323aef7a4dee5e856d073f0d841a1f4 | ea8004509d2b3729303101a69b6a543bc39b9b79 | /ProjectFrontend/src/main/java/com/niit/fileinput/FileInput.java | 21d3d0c94e72d992919b41480a2e8c93a9db12b6 | [] | no_license | HemaR92/Shopping1 | 554c69833690aac67224354385e5a38447b509a0 | 9c31c2090cfec7bccd4b6e6ac49e548d0128d391 | refs/heads/master | 2021-09-03T04:40:33.534081 | 2018-01-05T16:26:41 | 2018-01-05T16:26:41 | 116,404,508 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,071 | java | package com.niit.fileinput;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.springframework.web.multipart.MultipartFile;
public class FileInput {
public static void upload(String path,MultipartFile file,String fileName)
{
if(!file.isEmpty()){
InputStream inputStream =null;
OutputStream outputStream =null;
if(file.getSize()>0)
{
try
{
inputStream=file.getInputStream();
outputStream=new FileOutputStream(path+fileName);
System.out.println("5");
int readBytes =0;
System.out.println("5");
byte[] buffer =new byte[1024];
System.out.println("5");
while((readBytes = inputStream.read(buffer,0,1024))!= -1){
outputStream.write(buffer,0, readBytes);
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally {
try{
outputStream.close();
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}
| [
"[email protected]"
] | |
3b85cf0667538011ecadbd4000b99a0d9d172603 | 705975f9965eabaa7f81663d25b19b3df20dce6e | /app/src/main/java/com/framgia/forder/screen/searchpage/SearchContainerFragment.java | 89cc86a6ff80e15b76fae1bbc64421a1e8294dcb | [] | no_license | tranminhtri911/android_forder_01 | 27fe0d494f268f966e5ac677fb9ffb74e21bce16 | 1e9f1d82e2bd9a2fa4842f92ff6ff706111c9e10 | refs/heads/logic_order | 2021-01-19T21:28:48.629701 | 2017-04-26T01:33:30 | 2017-04-26T03:29:49 | 82,506,327 | 0 | 0 | null | 2017-06-22T01:39:14 | 2017-02-20T02:04:21 | Java | UTF-8 | Java | false | false | 3,866 | java | package com.framgia.forder.screen.searchpage;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import com.framgia.forder.R;
import com.framgia.forder.data.source.DomainRepository;
import com.framgia.forder.data.source.SearchRepository;
import com.framgia.forder.data.source.local.DomainLocalDataSource;
import com.framgia.forder.data.source.local.UserLocalDataSource;
import com.framgia.forder.data.source.local.sharedprf.SharedPrefsApi;
import com.framgia.forder.data.source.local.sharedprf.SharedPrefsImpl;
import com.framgia.forder.data.source.remote.DomainRemoteDataSource;
import com.framgia.forder.data.source.remote.SearchRemoteDataSource;
import com.framgia.forder.data.source.remote.api.service.FOrderServiceClient;
import com.framgia.forder.databinding.FragmentSearchContainerBinding;
/**
* FragmentSearchContainer Screen.
*/
public class SearchContainerFragment extends Fragment implements SearchView.OnQueryTextListener {
private SearchContainerContract.ViewModel mViewModel;
private FragmentSearchContainerBinding mBinding;
public static SearchContainerFragment newInstance() {
return new SearchContainerFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
SearchContainerAdapter adapter =
new SearchContainerAdapter(getActivity(), getChildFragmentManager());
mViewModel = new SearchContainerViewModel(adapter);
SearchRepository searchRepository =
new SearchRepository(new SearchRemoteDataSource(FOrderServiceClient.getInstance()));
SharedPrefsApi prefsApi = new SharedPrefsImpl(getActivity().getApplicationContext());
DomainRepository domainRepository =
new DomainRepository(new DomainRemoteDataSource(FOrderServiceClient.getInstance()),
new DomainLocalDataSource(prefsApi, new UserLocalDataSource(prefsApi)));
SearchContainerContract.Presenter presenter =
new SearchContainerPresenter(mViewModel, searchRepository, domainRepository);
mViewModel.setPresenter(presenter);
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_search_container, container,
false);
mBinding.setViewModel((SearchContainerViewModel) mViewModel);
setUpView();
return mBinding.getRoot();
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
getActivity().getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) item.getActionView();
searchView.setIconified(false);
searchView.getBaselineAlignedChildIndex();
searchView.setOnQueryTextListener(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
private void setUpView() {
setHasOptionsMenu(true);
((AppCompatActivity) getActivity()).setSupportActionBar(mBinding.toolbar);
((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
}
@Override
public boolean onQueryTextSubmit(String query) {
mViewModel.onClickSearch(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
}
| [
"[email protected]"
] | |
94328a863beef0a2a6e8bb765af57e86c583978c | 4cebe0d2407e5737a99d67c99ab84ca093f11cff | /src/multithread/chapter6/demo04DCLofLasySingleton/Run.java | 94782ebb5923aa6a3baddd72715ca9a4b10c3bef | [] | no_license | MoXiaogui0301/MultiThread-Program | 049be7ca7084955cb2a2372bf5acb3e9584f4086 | 1492e1add980342fbbcc2aed7866efca119998c9 | refs/heads/master | 2020-04-28T00:14:37.871448 | 2019-04-02T04:20:04 | 2019-04-02T04:20:04 | 174,808,187 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 531 | java | package multithread.chapter6.demo04DCLofLasySingleton;
/**
* P270
* DCL(双检查锁机制)实现多线程环境中的延迟加载单例设计模式
* 在同步代码块(创建对象)之前进行两次非空判断
*
* Result:
* 438618715
* 438618715
* 438618715
*
*/
public class Run {
public static void main(String[] args) {
MyThread th1 = new MyThread();
MyThread th2 = new MyThread();
MyThread th3 = new MyThread();
th1.start();
th2.start();
th3.start();
}
}
| [
"[email protected]"
] | |
2f29ebe463aeb0be37bacc0476213363fa255066 | e4172e79f17efdee764f558d34959fdc909f219b | /src/main/java/com/person/model/response/PersonResponse.java | ea7546ebfcc41f67452a0c008b87738fcdf613ef | [] | no_license | rubens-tersi/person | dc02ffc1d603b468a945c0a190808b953540f4df | 0f02f8fd7e080ec6f8d9eb3a49aee0d67ee3fd02 | refs/heads/master | 2022-12-03T18:01:16.047318 | 2020-08-10T14:37:39 | 2020-08-10T14:37:39 | 286,479,423 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,571 | java | package com.person.model.response;
import java.time.LocalDate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.person.model.Person;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@JsonInclude(Include.NON_EMPTY)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PersonResponse {
@JsonIgnore
private Person person;
@ApiModelProperty(value = "Person's autogenerated Id.")
public String getId() {
return person.getId();
}
@ApiModelProperty(value = "Person's associated document number, following type pattern.")
public String getDocumentNumber() {
return person.getDocumentNumber();
}
@ApiModelProperty(value = "Person's complete name.")
public String getFullName() {
return person.getFullName();
}
@ApiModelProperty(value = "Person's social name.")
public String getSocialName() {
return person.getSocialName();
}
@ApiModelProperty(value = "Person's gender.")
public String getGender() {
return person.getGender();
}
@ApiModelProperty(value = "Person's birth date.")
public LocalDate getBirthDate() {
return person.getBirthDate();
}
@ApiModelProperty(value = "Person's associated e-mail address.")
public String getEmail() {
return person.getEmail();
}
}
| [
"[email protected]"
] | |
e36be0b7a4725ac5d47a541362ad8f310ad09d10 | ed28460c5d24053259ab189978f97f34411dfc89 | /Software Engineering/Java Fundamentals/Java OOP Advanced/Lab/BashSoft/src/main/bg/softuni/io/commands/MakeDirectoryCommand.java | f69b83c7ad56a528fc3cab405bb88178768b0cd2 | [] | no_license | Dimulski/SoftUni | 6410fa10ba770c237bac617205c86ce25c5ec8f4 | 7954b842cfe0d6f915b42702997c0b4b60ddecbc | refs/heads/master | 2023-01-24T20:42:12.017296 | 2020-01-05T08:40:14 | 2020-01-05T08:40:14 | 48,689,592 | 2 | 1 | null | 2023-01-12T07:09:45 | 2015-12-28T11:33:32 | Java | UTF-8 | Java | false | false | 767 | java | package main.bg.softuni.io.commands;
import main.bg.softuni.annotations.Alias;
import main.bg.softuni.annotations.Inject;
import main.bg.softuni.contracts.DirectoryManager;
import main.bg.softuni.exceptions.InvalidInputException;
@Alias("mkdir")
public class MakeDirectoryCommand extends Command {
@Inject
private DirectoryManager ioManager;
public MakeDirectoryCommand(String input,String[] data) {
super(input, data);
}
@Override
public void execute() throws Exception {
String[] data = this.getData();
if (data.length != 2) {
throw new InvalidInputException(this.getInput());
}
String folderName = data[1];
this.ioManager.createDirectoryInCurrentFolder(folderName);
}
}
| [
"[email protected]"
] | |
bc70092269c40704ff3c4967c4c049ca28d8efbe | 858b82f813bde7b25b2ba571ff71faa05e2b3409 | /src/main/java/com/wcf/mobile/usage/model/CellPhone.java | 1c2011761679bee527a1078974e7dce1959d03cc | [] | no_license | manicpromod/usage | 0ec528d4cfb0977db91b1653849b2d0ccce174bc | 03a8cb574f804af5ccc7f5ac18167e7155719809 | refs/heads/master | 2022-03-14T07:32:39.353006 | 2019-09-16T13:51:01 | 2019-09-16T13:51:01 | 208,166,144 | 0 | 0 | null | 2022-01-21T23:29:48 | 2019-09-12T23:58:28 | Java | UTF-8 | Java | false | false | 407 | java | package com.wcf.mobile.usage.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by pmanickam on 9/10/2019 at 9:25 AM
*/
@NoArgsConstructor
@AllArgsConstructor
public class CellPhone {
private int employeeId;
private String employeeName;
private String purchaseDate;
private String model;
}
| [
"[email protected]"
] | |
06c94ac46e5ec904699f9d6d1eb9e63f42cf8520 | d312683783d10be97252a316cfa2b3397e67b134 | /src/main/java/com/example/lx/imageutils/utils/Utils.java | ae828724a4e087f7c3f3b80c463911016490da3b | [] | no_license | liaoxinlxw/AndroidStudioProject | a07560f749e95b564ac301da5761104f4afc9edd | 68a790b4e696fa16238104a9adc2bf86679d9fc6 | refs/heads/master | 2020-06-14T00:00:03.340616 | 2016-12-05T15:34:34 | 2016-12-05T15:34:34 | 75,542,145 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,961 | java | package com.example.lx.imageutils.utils;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.text.DecimalFormat;
/**
* Created by Administrator on 2016/12/3.
*/
public class Utils {
public static void choseImage(Activity activity){
Intent intent = new Intent();
/* 开启Pictures画面Type设定为image */
intent.setType("image/*");
/* 使用Intent.ACTION_GET_CONTENT这个Action */
intent.setAction(Intent.ACTION_GET_CONTENT);
/* 取得相片后返回本画面 */
activity.startActivityForResult(intent, 1);
}
/**
* 获取指定文件大小
* @param uri
* @return
* @throws Exception
*/
public static long getFileSize(Context context, Uri uri) {
InputStream input = null;
int size = 0;
try {
input = context.getContentResolver().openInputStream(uri);
size = input.available();
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
return size;
}
public static String getFileSizeString(Context context, Uri uri) {
return getDataSize(getFileSize(context, uri));
}
/**
* 返回byte的数据大小对应的文本
*
* @param size
* @return
*/
public static String getDataSize(long size) {
if (size < 0) {
size = 0;
}
DecimalFormat formater = new DecimalFormat("####.00");
if (size < 1024) {
return size + "bytes";
} else if (size < 1024 * 1024) {
float kbsize = size / 1024f;
return formater.format(kbsize) + "KB";
} else if (size < 1024 * 1024 * 1024) {
float mbsize = size / 1024f / 1024f;
return formater.format(mbsize) + "MB";
} else if (size < 1024 * 1024 * 1024 * 1024) {
float gbsize = size / 1024f / 1024f / 1024f;
return formater.format(gbsize) + "GB";
} else {
return "size: error";
}
}
public static Bitmap getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
//此时返回bm为空
Bitmap bitmap = BitmapFactory.decodeFile(srcPath,newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f;//这里设置高度为800f
float ww = 480f;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
}
public static Bitmap compressImage(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
int options = 100;
//循环判断如果压缩后图片是否大于100kb,大于继续压缩
while ( baos.toByteArray().length / 1024>50) {
//重置baos即清空baos
baos.reset();
//这里压缩options%,把压缩后的数据存放到baos中
image.compress(Bitmap.CompressFormat.JPEG, options, baos);
options -= 10;//每次都减少10
}
//把压缩后的数据baos存放到ByteArrayInputStream中
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
//把ByteArrayInputStream数据生成图片
File f = new File("/sdcard/lx", "resize_"+System.currentTimeMillis()+".jpg");
if(!f.getParentFile().exists()){
f.getParentFile().mkdirs();
}
if (f.exists()) {
f.delete();
}
try {
FileOutputStream out = new FileOutputStream(f);
out.write(baos.toByteArray());
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);
return bitmap;
}
/** 保存方法 */
public void saveBitmap(Bitmap bm) {
File f = new File("/sdcard/lx", "resize_"+System.currentTimeMillis()+".jpg");
if(!f.getParentFile().exists()){
f.getParentFile().mkdirs();
}
if (f.exists()) {
f.delete();
}
try {
FileOutputStream out = new FileOutputStream(f);
bm.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Bitmap comp(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
//判断如果图片大于1M,进行压缩避免在生成图片
//(BitmapFactory.decodeStream)时溢出
if( baos.toByteArray().length / 1024>1024) {
baos.reset();//重置baos即清空baos
//这里压缩50%,把压缩后的数据存放到baos中
image.compress(Bitmap.CompressFormat.JPEG, 50, baos);
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
//开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f;//这里设置高度为800f
float ww = 480f;//这里设置宽度为480f
//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1;//be=1表示不缩放
if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;//设置缩放比例
//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
isBm = new ByteArrayInputStream(baos.toByteArray());
bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
}
public static long getBitmapSize(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
InputStream isBm = new ByteArrayInputStream(baos.toByteArray());
int size = 0;
try {
size = isBm.available();
} catch (IOException e) {
e.printStackTrace();
}
return size;
}
}
| [
"[email protected]"
] | |
08c5e1e6e369fc189320ddf82f1c1bfa64ac1742 | 98e2dd89a590f1018070317d820bf61715f86cdf | /BT2/app/src/main/java/com/example/bt2/fragmentxml/FragmentCreateActivity.java | bb518b76ccf165dfe6883e1fadcb8d08e7b0a86e | [] | no_license | VuIt96/BT-Android | c2e9da1f00fb21c23a1f213bf46ae2f135e460e0 | a80a40366b3bb44e3b48ac70dc4bcead7371ef8b | refs/heads/master | 2020-06-30T22:36:29.448371 | 2019-09-03T01:42:55 | 2019-09-03T01:42:55 | 200,969,749 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,160 | java | package com.example.bt2.fragmentxml;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import com.example.bt2.R;
public class FragmentCreateActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment_create);
}
public void AddFrag(View view) {
Fragment fragment = null;
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
switch (view.getId()) {
case R.id.btFragA:
fragment = new FragmentOne();
break;
case R.id.btFragAddB:
fragment = new FragmentTwo();
break;
}
//fragmentTransaction.add(R.id.Framelayout, fragment);
fragmentTransaction.replace(R.id.Framelayout, fragment);
fragmentTransaction.commit();
}
}
| [
"[email protected]"
] | |
aec817c3798698704608fdb7cc86df499ca4957b | 2d2d7bbb72758e6f4824f897b551ff022754119f | /TesteIntegral.java | 2ba6693cff67ee7c85014c6b0a74b14a5e3916a8 | [] | no_license | gustavobr44/mnu_integracao_interpolacao | 5895748038b87011e7929cda1acde74c21eb96d2 | 5a29c726177d75941111f7e7cd8dbdc6d62aea1c | refs/heads/master | 2020-04-09T21:49:53.522858 | 2018-12-06T03:30:57 | 2018-12-06T03:30:57 | 160,613,554 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,053 | java | package teste;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import integracao.*;
public class TesteIntegral {
private static NumberFormat formatador;
public static void main(String[] args) {
CalculoIntegral integ = new CalculoIntegral();
formatador = new DecimalFormat("0.0000"); // Sem "E00" no final da formatação
// Slide1
//double b = 7;
//double a = 1;
//Funcao y = (x) -> {
// return 1 / x;
//};
// Slide2
// double[] xi = { 1, 1.5, 2, 2.5, 3 };
// Funcao y = (x) -> {
// return x * x * x * Math.log(x);
// };
int m = 4;
double b = Math.PI/2;
double a = 0;
double h = (b - a)/m;
double[] xi = {a, a+h, a+2*h, a+3*h, b};
Funcao y = (x) -> {
return Math.cos(x);
};
long start = System.nanoTime();
double result = integ.integ38(b, a, y);
long end = System.nanoTime();
System.out.println("F(x) =");
System.out.println(formatador.format(result));
System.out.println("\nT =");
System.out.println(end - start);
}
}
| [
"[email protected]"
] | |
62bafc6678b68680f17555ad0efbda3f5b0a5252 | 88cfbdc25670de1fba59c029d96acb3abf9900e6 | /JavaLectures/src/Week8_ogrenci/Ogr.java | b814fa56e28e7bcbc74e51ab016b6bfff3352522 | [] | no_license | hakankocaknyc/JavaLectures | e6c6754280ed6d4e1a4294df798db95e51369085 | 940b5c9a1ea45d47bd9b6a157549d1a57c1e9571 | refs/heads/master | 2022-12-05T05:10:13.468985 | 2020-08-22T17:36:43 | 2020-08-22T17:36:43 | 286,625,020 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 487 | java | package Week8_ogrenci;
public abstract class Ogr {
private String isim;
private int no;
public Ogr(String isim, int no) {
super();
this.isim = isim;
this.no = no;
}
public abstract void bolumSoyle();
public void adsoyle(){
System.out.println(" Adim : " + isim);
}
public String getIsim() {
return isim;
}
public void setIsim(String isim) {
this.isim = isim;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
}
| [
"[email protected]"
] | |
1077888f34c88fdb55f17ccb6d758b2d1549e280 | a332b8f86db4c87c6306c5a00e409a278ab95260 | /src/main/java/com/example/dao/UserDaoDB.java | e7e73000960d809fed3c13710482b0d74fdbb9e6 | [] | no_license | PotatoLover1/Project0Bank | 2c4e5b0073f78794d1ce613cb3e7072d7f326fce | 604c7eabc9b581c74b90c4b7c052e72eccc68121 | refs/heads/main | 2023-06-19T22:35:15.911653 | 2021-07-21T14:00:26 | 2021-07-21T14:00:26 | 388,134,585 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,004 | java | package com.example.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.example.models.User;
import com.example.utils.ConnectionUtil;
public class UserDaoDB implements UserDao{
ConnectionUtil conUtil = ConnectionUtil.getConnectionUtil();
@Override
public List<User> getAllUsers() {
List<User> userList = new ArrayList<User>();
try {
Connection con = conUtil.getConnection();
String sql = "SELECT * FROM users";
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
while(rs.next()) {
userList.add(new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6),rs.getString(7)));
}
return userList;
}catch(SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public User getUserByUsername(String username) {
User user = new User();
try {
Connection con = conUtil.getConnection();
String sql = "SELECT * FROM users WHERE users.username = '"+ username +"'";
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
while(rs.next()) {
user.setId(rs.getInt(1));
user.setFirstName(rs.getString(2));
user.setLastName(rs.getString(3));
user.setEmail(rs.getString(4));
user.setUsername(rs.getString(5));
user.setPassword(rs.getString(6));
}
}catch(SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public void createUser(User u) throws SQLException {
Connection con = conUtil.getConnection();
String sql = "INSERT INTO users(first_name, last_name, email, username, password) values"
+ "(?,?,?,?,?)";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, u.getFirstName());
ps.setString(2, u.getLastName());
ps.setString(3, u.getEmail());
ps.setString(4, u.getUsername());
ps.setString(5, u.getPassword());
ps.execute();
}
@Override
public void updateUser(User u) {
try {
Connection con = conUtil.getConnection();
String sql = "UPDATE users SET first_name = ?, last_name = ?, email = ?, username = ?, password = ? "
+ " WHERE users.id = ?";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, u.getFirstName());
ps.setString(2, u.getLastName());
ps.setString(3, u.getEmail());
ps.setString(4, u.getUsername());
ps.setString(5, u.getPassword());
ps.setInt(6, u.getId());
ps.execute();
} catch(SQLException e) {
e.printStackTrace();
}
}
@Override
public void deleteUser(User u) {
try {
Connection con = conUtil.getConnection();
String sql = "DELETE FROM users WHERE users.id = ?";
PreparedStatement ps = con.prepareStatement(sql);
ps.setInt(1, u.getId());
ps.execute();
} catch(SQLException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
9b9999f855608ccd622d1878ea5acaf67e4a2db7 | 35e5dc561b69b8014fb579d5cd671aa646ad5605 | /serv/src/main/java/at/tugraz/sss/serv/datatype/par/SSEntitiesSharedWithUsersPar.java | 8dbbaf54d3ed4d477a9f5fc4dc7bfb049d6a9e95 | [
"Apache-2.0"
] | permissive | learning-layers/SocialSemanticServer | 6a36e426586b6e73e0328a0d38b3a790417b8752 | 4d9402e11275b0cbbcb858f4c83d3ada165f3b91 | refs/heads/master | 2020-04-05T18:57:33.012817 | 2016-08-22T09:24:50 | 2016-08-22T09:24:50 | 17,632,122 | 6 | 4 | null | 2015-10-15T07:40:03 | 2014-03-11T13:54:18 | Java | UTF-8 | Java | false | false | 1,557 | java | /**
* Code contributed to the Learning Layers project
* http://www.learning-layers.eu
* Development is partly funded by the FP7 Programme of the European Commission under
* Grant Agreement FP7-ICT-318209.
* Copyright (c) 2015, Graz University of Technology - KTI (Knowledge Technologies Institute).
* For a list of contributors see the AUTHORS file at the top-level directory of this distribution.
*
* 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 at.tugraz.sss.serv.datatype.par;
import at.tugraz.sss.serv.datatype.*;
import at.tugraz.sss.serv.datatype.*;
public class SSEntitiesSharedWithUsersPar {
public SSUri user = null;
public SSEntity circle = null;
public boolean withUserRestriction = true;
public SSEntitiesSharedWithUsersPar(
final SSUri user,
final SSEntity circle,
final boolean withUserRestriction){
this.user = user;
this.circle = circle;
this.withUserRestriction = withUserRestriction;
}
}
| [
"[email protected]"
] | |
f822f3b648d05d9392c327309ec3bbf8c76451e7 | 0e5a8876c6196fcc79f4ff09f6b1715f64d873d0 | /fun-system/src/main/java/com/fun/system/service/impl/SysRoleServiceImpl.java | f60b861fc7ac2c950dc184ab9d22afc49ad7ef38 | [] | no_license | mrdjun/funboot-multi | d2a9de6d519bbf29e1188c602fa502cb69bfda73 | 9d8ef6be1cc0e0f63c74403737e41c4a0a920af0 | refs/heads/master | 2023-01-19T22:01:36.213283 | 2020-11-30T02:58:39 | 2020-11-30T02:58:39 | 306,553,975 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,685 | java | package com.fun.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.fun.common.annotation.DataScope;
import com.fun.common.constant.UserConstants;
import com.fun.common.core.text.Convert;
import com.fun.common.exception.BusinessException;
import com.fun.common.utils.StringUtils;
import com.fun.common.utils.spring.SpringUtils;
import com.fun.system.domain.SysRole;
import com.fun.system.domain.SysRoleDept;
import com.fun.system.domain.SysRoleMenu;
import com.fun.system.domain.SysUserRole;
import com.fun.system.mapper.SysRoleDeptMapper;
import com.fun.system.mapper.SysRoleMapper;
import com.fun.system.mapper.SysRoleMenuMapper;
import com.fun.system.mapper.SysUserRoleMapper;
import com.fun.system.service.ISysRoleService;
/**
* 角色 业务层处理
*
* @author mrdjun
*/
@Service
public class SysRoleServiceImpl implements ISysRoleService {
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysRoleMenuMapper roleMenuMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
@Autowired
private SysRoleDeptMapper roleDeptMapper;
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope(deptAlias = "d")
public List<SysRole> selectRoleList(SysRole role) {
return roleMapper.selectRoleList(role);
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRoleKeys(Long userId) {
List<SysRole> perms = roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (SysRole perm : perms) {
if (StringUtils.isNotNull(perm)) {
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 角色列表
*/
@Override
public List<SysRole> selectRolesByUserId(Long userId) {
List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId);
List<SysRole> roles = selectRoleAll();
for (SysRole role : roles) {
for (SysRole userRole : userRoles) {
if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
role.setFlag(true);
break;
}
}
}
return roles;
}
/**
* 查询所有角色
*
* @return 角色列表
*/
@Override
public List<SysRole> selectRoleAll() {
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
}
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public SysRole selectRoleById(Long roleId) {
return roleMapper.selectRoleById(roleId);
}
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public boolean deleteRoleById(Long roleId) {
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
}
/**
* 批量删除角色信息
*
* @param ids 需要删除的数据ID
* @throws Exception
*/
@Override
public int deleteRoleByIds(String ids) throws BusinessException {
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
return roleMapper.deleteRoleByIds(roleIds);
}
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int insertRole(SysRole role) {
// 新增角色信息
roleMapper.insertRole(role);
return insertRoleMenu(role);
}
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int updateRole(SysRole role) {
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
return insertRoleMenu(role);
}
/**
* 修改数据权限信息
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int authDataScope(SysRole role) {
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
// 新增角色和部门信息(数据权限)
return insertRoleDept(role);
}
/**
* 新增角色菜单信息
*
* @param role 角色对象
*/
public int insertRoleMenu(SysRole role) {
int rows = 1;
// 新增用户与角色管理
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
for (Long menuId : role.getMenuIds()) {
SysRoleMenu rm = new SysRoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0) {
rows = roleMenuMapper.batchRoleMenu(list);
}
return rows;
}
/**
* 新增角色部门信息(数据权限)
*
* @param role 角色对象
*/
public int insertRoleDept(SysRole role) {
int rows = 1;
// 新增角色与部门(数据权限)管理
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
for (Long deptId : role.getDeptIds()) {
SysRoleDept rd = new SysRoleDept();
rd.setRoleId(role.getRoleId());
rd.setDeptId(deptId);
list.add(rd);
}
if (list.size() > 0) {
rows = roleDeptMapper.batchRoleDept(list);
}
return rows;
}
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(SysRole role) {
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.ROLE_NAME_NOT_UNIQUE;
}
return UserConstants.ROLE_NAME_UNIQUE;
}
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleKeyUnique(SysRole role) {
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.ROLE_KEY_NOT_UNIQUE;
}
return UserConstants.ROLE_KEY_UNIQUE;
}
/**
* 校验角色是否允许操作
*
* @param role 角色信息
*/
@Override
public void checkRoleAllowed(SysRole role) {
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
throw new BusinessException("不允许操作超级管理员角色");
}
}
/**
* 通过角色ID查询角色使用数量
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int countUserRoleByRoleId(Long roleId) {
return userRoleMapper.countUserRoleByRoleId(roleId);
}
/**
* 角色状态修改
*
* @param role 角色信息
* @return 结果
*/
@Override
public int changeStatus(SysRole role) {
return roleMapper.updateRole(role);
}
/**
* 取消授权用户角色
*
* @param userRole 用户和角色关联信息
* @return 结果
*/
@Override
public int deleteAuthUser(SysUserRole userRole) {
return userRoleMapper.deleteUserRoleInfo(userRole);
}
/**
* 批量取消授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要删除的用户数据ID
* @return 结果
*/
@Override
public int deleteAuthUsers(Long roleId, String userIds) {
return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds));
}
/**
* 批量选择授权用户角色
*
* @param roleId 角色ID
* @param userIds 需要删除的用户数据ID
* @return 结果
*/
@Override
public int insertAuthUsers(Long roleId, String userIds) {
Long[] users = Convert.toLongArray(userIds);
// 新增用户与角色管理
List<SysUserRole> list = new ArrayList<SysUserRole>();
for (Long userId : users) {
SysUserRole ur = new SysUserRole();
ur.setUserId(userId);
ur.setRoleId(roleId);
list.add(ur);
}
return userRoleMapper.batchUserRole(list);
}
}
| [
"[email protected]"
] | |
7f4e0c2f98fdfd523846c0167ef7ef500cdd0e4b | 38f204775b93bd8a96b6e6563f56c1cb30441911 | /app/src/main/java/com/example/win8_user/fruitnum/Main7Activity.java | 3b5eaaaf963cda084decfd72f7052b647c76ef9f | [] | no_license | ViviYiWen/Fruitnum | 9bc4018d14cee04478fcbf0191731f738e116fea | 8bacc0c77d13cfb0eca099958ac8984a4b75b811 | refs/heads/master | 2023-03-01T18:08:13.974672 | 2021-02-15T12:29:59 | 2021-02-15T12:29:59 | 339,047,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,337 | java | package com.example.win8_user.fruitnum;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Main7Activity extends AppCompatActivity {
// int num1 =1, num2=2, num3=3, result=0;
TextView t2;
TextView t1;
int result=0;
int num1 = (int)(Math.random()*10);//隨機出4個數字
int num2 = (int)(Math.random()*10);
int num3 = (int)(Math.random()*10);
int num4 = (int)(Math.random()*10);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main7);
findView();//抓使用者姓名
Bundle bundle = this.getIntent().getExtras();
String s = bundle.getString("input");
t1.setText(s);
while(num2==num1) num2 = (int)(Math.random()*10);
while(num3==num2 || num3==num1) num3= (int)(Math.random()*10);
while(num4==num2 || num4==num1||num4==num3) num4= (int)(Math.random()*10);
ShowDialog(num1,num2,num3,num4);
Button sure = (Button)findViewById(R.id.sure);
ImageButton mon = (ImageButton)findViewById(R.id.money);
sure.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
result = Result(num1,num2,num3,num4);
if(result==1){
findView();//抓使用者姓名
t2 = (TextView) findViewById(R.id.mon);
int upToDbCoin = 0; //要update至DB的金幣數量
String flag = "N"; //是否更新DB資料
DBHelper dbHelper = new DBHelper(Main7Activity.this);
SQLiteDatabase db=dbHelper.getWritableDatabase();
Cursor cs = db.query("Player",null,"_PLAYERNAME=?",new String[]{t1.getText().toString()},null,null,null); //search玩家資料
if(cs!=null && cs.getCount() >= 1){ //有查詢到資料(比對金幣數)
int rowNum = cs.getCount(); //比數
if(rowNum!=0){
cs.moveToFirst(); //指標移至第一筆
String coin = cs.getString(2); //取得該玩家金幣數
if(coin!=null && coin!=""){
int coinDb = Integer.parseInt(coin); //玩家金幣數(db資料)
int uiCoin = Integer.parseInt(t2.getText().toString()); //UI剩餘金幣數
if(uiCoin>coinDb){ //剩餘金幣數大於原本資料庫金幣數->則update至資料庫中,否則不更新資料
upToDbCoin = uiCoin;
flag = "Y";
}else{
upToDbCoin = coinDb;
flag = "N";
}
}
}
}
if(flag=="Y"){
ContentValues values = new ContentValues();
values.put("_COIN", Integer.toString(upToDbCoin));
db.update("Player", values, "_PLAYERNAME = ?", new String[] {t1.getText().toString()}); //更新玩家剩餘金幣數
}
//ContentValues values = new ContentValues();
//values.put("_COIN", t2.getText().toString());
//db.update("Player", values, "_PLAYERNAME = ?", new String[] {t1.getText().toString()}); //更新玩家剩餘金幣數
db.close();
dbHelper.close();
Intent intent=new Intent();
intent.setClass(Main7Activity.this,Main5Activity.class);
startActivity(intent);
Main7Activity.this.finish();
}
}
});
mon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView hints = (TextView)findViewById(R.id.hints);
TextView mon = (TextView)findViewById(R.id.mon);
LinearLayout layout = (LinearLayout) findViewById(R.id.app);
int mons=Integer.parseInt(mon.getText().toString());
mons=mons-60;
int ask = (int)(Math.random()*4);//select index number
if(ask==0){
int n=num1;
hints.setText("第一個數字為:"+Integer.toString(n));
mon.setText(Integer.toString(mons));
layout.setVisibility(View.VISIBLE);
}
if(ask==1){
int n=num2;
hints.setText("第二個數字為:"+Integer.toString(n));
mon.setText(Integer.toString(mons));
layout.setVisibility(View.VISIBLE);
}
if(ask==2){
int n=num3;
hints.setText("第三個數字為:"+Integer.toString(n));
mon.setText(Integer.toString(mons));
layout.setVisibility(View.VISIBLE);
}
if(ask==3){
int n=num4;
hints.setText("第四個數字為:"+Integer.toString(n));
mon.setText(Integer.toString(mons));
layout.setVisibility(View.VISIBLE);
}
}
});
}
public void findView(){
t1=(TextView)findViewById(R.id.textView5);
}
//@Override
public int Result(int num1, int num2, int num3,int num4){
int grape=0, apple=0;
EditText ed1 = (EditText)findViewById(R.id.editText2);
EditText ed2 = (EditText)findViewById(R.id.editText3);
EditText ed3 = (EditText)findViewById(R.id.editText4);
EditText ed4 = (EditText)findViewById(R.id.editText5);
String re1, re2;
TextView A = (TextView)findViewById(R.id.apple);
TextView G = (TextView)findViewById(R.id.grape);
int a = Integer.parseInt(ed1.getText().toString());
int b = Integer.parseInt(ed2.getText().toString());
int c = Integer.parseInt(ed3.getText().toString());
int d = Integer.parseInt(ed4.getText().toString());
grape=0;
apple=0;
if(a==num1 && b==num2 && c==num3 && d==num4)
return 1;
if(a==num2 || a==num3 || a==num4) grape++;
if(b==num1 || b==num3 || b==num4) grape++;
if(c==num2 || c==num1 || c==num4) grape++;
if(d==num1 || d==num2 || d==num3) grape++;
if(a==num1) apple++;
if(b==num2) apple++;
if(c==num3) apple++;
if(d==num4) apple++;
re1 = Integer.toString(apple);
re2 = Integer.toString(grape);
A.setText(re1);
G.setText(re2);
ed1 = (EditText)findViewById(R.id.editText2);
ed2 = (EditText)findViewById(R.id.editText3);
ed3 = (EditText)findViewById(R.id.editText4);
ed4 = (EditText)findViewById(R.id.editText5);
a = Integer.parseInt(ed1.getText().toString());
b = Integer.parseInt(ed2.getText().toString());
c = Integer.parseInt(ed3.getText().toString());
d = Integer.parseInt(ed4.getText().toString());
return 0;
}
public void ShowDialog(int num1, int num2, int num3,int num4){
AlertDialog.Builder builder = new AlertDialog.Builder(Main7Activity.this);
builder.setTitle("Answer");
builder.setMessage(Integer.toString(num1)+Integer.toString(num2)+Integer.toString(num3)+Integer.toString(num4));
//builder.setPositiveButton("OK",builder.show());
builder.show();
}
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
} | [
"[email protected]"
] | |
0b893ed4c1589c1d5cbcdb8cc7368aaab22947df | d9bbcfae6bb5437b68a2667c00172b816616b825 | /app/src/main/java/com/example/grzesiek/myapplication/DayTab.java | 2432afcc3dd7d61b8cf8a76708e17be02af6e3fa | [] | no_license | sarayutt/where-is-my-time | f466d6401f97bd97ab1d54a792aa0c7c008d38d8 | d3c0debf4670939be5cbf45f7cc0d700b65053f6 | refs/heads/master | 2021-04-06T05:29:25.173945 | 2016-03-02T06:07:37 | 2016-03-02T06:07:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 753 | java | package com.example.grzesiek.myapplication;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
/**
* Created by grzesiek on 25.02.16.
*/
public class DayTab extends Fragment {
public DayTab() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.tab_1, container, false);
}
}
| [
"[email protected]"
] | |
832d3733dfa1e88cd4abe8fdf7e9d2deeb7eae1e | 0e3ddb7a7053e0c77fc2d49314e4bb652b1f6cf8 | /src/main/java/com/wsicong/enroll/controller/IndexController.java | 784d91a36ec17b210243f9f49077d483deec885e | [] | no_license | wsicong/GraduationProject | 1d15ec6db501978d8ed50794c8eccbcf54dcfae3 | e04a666342edd25320199c4aee833128a2972e5e | refs/heads/master | 2020-05-01T15:01:11.158882 | 2019-05-03T17:20:31 | 2019-05-03T17:20:31 | 177,535,726 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,261 | java | package com.wsicong.enroll.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.UnsupportedEncodingException;
@Controller
@RequestMapping("/")
public class IndexController {
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
@RequestMapping("/index")
public String index() {
logger.debug("-------------index------------");
return "index";
}
@RequestMapping("/home")
public String toHome() {
logger.debug("===111-------------home------------");
return "home";
}
@RequestMapping("/login")
public String toLogin() {
logger.debug("===111-------------login------------");
return "login";
}
@RequestMapping("/userLogin")
public String touserLogin() {
logger.debug("===111-------------login------------");
return "userLogin";
}
@RequestMapping("/userRegister")
public String touserRegister() {
logger.debug("===111-------------login------------");
return "userRegister";
}
@RequestMapping("/{page}")
public String toPage(@PathVariable("page") String page) {
logger.debug("-------------toindex------------" + page);
return page;
}
public static void main(String[] args) {
// 年月日文件夹
/*SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String basedir = sdf.format(new Date());
System.out.println(basedir);*/
// å¶ç»§å
/*
* String str=RPCMD5.TwoMD5("_ja2011mi_"+"1");
*
* System.out.println("str=="+str); å¯ç±ä½ çç¬ 3个èçè
* wkkçå¯å¯
*/
String uniqueFlag = "";
try {
uniqueFlag = new String("çç".getBytes("ISO-8859-1"),
"UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("uniqueFlag==" + uniqueFlag);
}
}
| [
"[email protected]"
] | |
a5a9efa5b71b38d2cdfad398e0f45c921026c52a | 6482753b5eb6357e7fe70e3057195e91682db323 | /io/netty/util/Timeout.java | 4005a32bd0263e0df43bb1c1b70ba323763d60e0 | [] | no_license | TheShermanTanker/Server-1.16.3 | 45cf9996afa4cd4d8963f8fd0588ae4ee9dca93c | 48cc08cb94c3094ebddb6ccfb4ea25538492bebf | refs/heads/master | 2022-12-19T02:20:01.786819 | 2020-09-18T21:29:40 | 2020-09-18T21:29:40 | 296,730,962 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 188 | java | package io.netty.util;
public interface Timeout {
Timer timer();
TimerTask task();
boolean isExpired();
boolean isCancelled();
boolean cancel();
}
| [
"[email protected]"
] | |
078df9cc7c4427c8194503c57036d6792d0ee850 | ea9e540609817b577aa6411113eea1e451500fe9 | /src/main/java/com/s3corp/domain/Employee.java | e935acd25ddb4544bb2e18a1976f527e67774cff | [] | no_license | nvtrai/sonarTest | 73dddbc0056576cd79022944182b990ef80a5b28 | 4372e025317343c6b21c69e56c22179ef707a862 | refs/heads/master | 2020-03-12T12:49:46.531582 | 2018-04-23T02:14:48 | 2018-04-23T02:14:48 | 130,627,547 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,150 | java | package com.s3corp.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "S3CORP.employee")
public class Employee implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long id;
@Column(name = "EMP_NAME")
private String empName;
@Column(name = "EMP_HIRE_DATE")
private Date empHireDate;
@Column(name = "EMP_SALARY")
private Double empSalary;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public Date getEmpHireDate() {
return empHireDate;
}
public void setEmpHireDate(Date empHireDate) {
this.empHireDate = empHireDate;
}
public Double getEmpSalary() {
return empSalary;
}
public void setEmpSalary(Double empSalary) {
this.empSalary = empSalary;
}
} | [
"[email protected]"
] | |
ae59181c66b901f45083bb25a77b977324c36b76 | e03dff4bd73617652e9cbb6f38988366a302f367 | /src/main/java/com/netease/shijin/yitao/dao/ItemDao.java | ef04a9effea09137ddd3d3900afedb56ea2c1462 | [] | no_license | orangedy/yitao | 7fdf3d61f86e4ff68d4535518e7cac42dea648e0 | 4e76fdabc5c585b29a8f3b04e0b5258ca8047975 | refs/heads/master | 2020-12-24T17:44:51.295682 | 2014-07-23T17:03:54 | 2014-07-23T17:03:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 603 | java | package com.netease.shijin.yitao.dao;
import java.util.List;
import com.netease.shijin.yitao.bean.ItemBean;
import com.netease.shijin.yitao.bean.ItemDetailBean;
import com.netease.shijin.yitao.bean.QueryBean;
public interface ItemDao {
List<ItemBean> queryItem(QueryBean query);
ItemDetailBean getItemDetial(String itemID);
boolean addItem(ItemDetailBean itemDetail);
List<ItemBean> getMyItem(String userID, int page, int count);
boolean offShelve(String userID, String itemID);
List<ItemBean> searchItem(String keyword, int start, int count);
}
| [
"[email protected]"
] | |
f62df9fb65a766cd5e0bcbc93e8b4e92e08c2c2c | f299f68321ed3e070a4ad2f0a28affa117c740dd | /src/main/java/com/mdv/corefinance/beans/Installment.java | 6291d8dcfc30caf3c593abf618bc9bed6f9a447a | [] | no_license | maxmcold/core-finance | 140a449c3dadd6d57dbe8fbae43bc53b443f39a2 | 35efa7da2272c99baeb0dddbd75c8d5c59a77b3b | refs/heads/master | 2020-04-28T21:43:21.878110 | 2019-07-16T10:32:31 | 2019-07-16T10:32:31 | 175,592,363 | 0 | 0 | null | 2019-07-14T07:41:11 | 2019-03-14T09:43:48 | Java | UTF-8 | Java | false | false | 125 | java | package com.mdv.corefinance.beans;
public class Installment {
private Double principal;
private Double interest;
}
| [
"[email protected]"
] | |
08ca900ad228ec2093f29660a499508f1039226e | 53362770a6df5fbba4a1af259c2c28688c43f86d | /Project 3/src/StoreManager.java | 2dfb20643c265ccf1bb2c4f6ffff71eb1a8a6fd2 | [] | no_license | NewStrangerC/Project-3 | 92c2754e73fbfad68d4385c3b516ea0c25c7b79b | 3cd39dabc943a3b04377b55757ea59164e950f1d | refs/heads/master | 2020-11-24T10:24:47.578017 | 2019-12-15T00:12:10 | 2019-12-15T00:12:10 | 228,106,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,928 | java | import javax.swing.*;
public class StoreManager {
public static String dbms = "SQLite";
public static String path = "/Users/shenchuang/Desktop/Assignment4/data/store.db";
IDataAdapter dataAdapter = null;
private static StoreManager instance = null;
public static StoreManager getInstance() {
if (instance == null) {
instance = new StoreManager(dbms, path);
}
return instance;
}
private StoreManager(String dbms, String dbfile) {
if (dbms.equals("Oracle"))
dataAdapter = new OracleDataAdapter();
else
if (dbms.equals("SQLite"))
dataAdapter = new SQLiteDataAdapter();
else
if (dbms.equals("Network"))
dataAdapter = new NetworkDataAdapter();
dataAdapter.connect(dbfile);
}
public IDataAdapter getDataAdapter() {
return dataAdapter;
}
public void setDataAdapter(IDataAdapter a) {
dataAdapter = a;
}
public void run() {
LoginUI ui = new LoginUI();
ui.view.setVisible(true);
}
public static void main(String[] args) {
System.out.println("Hello class!");
if (args.length > 0) { // having runtime arguments
dbms = args[0];
if (args.length == 1) { // do not have 2nd arguments for dbfile
if (dbms.equals("SQLite")) {
JFileChooser fc = new JFileChooser();
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
path = fc.getSelectedFile().getAbsolutePath();
}
else
path = JOptionPane.showInputDialog("Enter address of database server as host:port");
}
else
path = args[1];
}
StoreManager.getInstance().run();
}
}
| [
"[email protected]"
] | |
28d280687907a740a729f75d1e1ddd11aebecfc7 | 831629a9f25b840a61eb17ec37f05ff19bbc5bac | /yun-authority-core/src/main/java/com/yun/authority/core/exception/NotSafeException.java | b588973bdcc6e1f5712a8bb1657dbd4d96ac5a44 | [] | no_license | kaiyun1206/yun-authority | 8c3f825be637bb4804f2722a1fd50c6ba267cc83 | e1c20643f0a32f272d8353365ea0b5261dd222d1 | refs/heads/master | 2023-07-12T05:28:55.077736 | 2021-08-13T03:23:59 | 2021-08-13T03:23:59 | 395,507,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 588 | java | package com.yun.authority.core.exception;
import com.yun.footstone.common.exception.BaseException;
/**
* <p>
* 会话未能通过二级认证
* </p>
*
* @author sunkaiyun
* @version 1.0
* @date 2021-08-10 16:54
*/
public class NotSafeException extends BaseException {
private static final long serialVersionUID = -3876712198628139570L;
/** 异常提示语 */
public static final String BE_MESSAGE = "二级认证失败";
/**
* 一个异常:代表会话未通过二级认证
*/
public NotSafeException() {
super(BE_MESSAGE);
}
}
| [
"[email protected]"
] | |
788884536b56d4cd3979f9f798cc3426c653e7b7 | 67ec60c810cdd63eab37d54056a56f8094026065 | /app/src/com/d2cmall/buyer/bean/PhotoDirectory.java | 3a0161ac8796c188e08f9a3ee37a9b0a0fd2dfcb | [] | no_license | sinbara0813/fashion | 2e2ef73dd99c71f2bebe0fc984d449dc67d5c4c5 | 4127db4963b0633cc3ea806851441bc0e08e6345 | refs/heads/master | 2020-08-18T04:43:25.753009 | 2019-10-25T02:28:47 | 2019-10-25T02:28:47 | 215,748,112 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,032 | java | package com.d2cmall.buyer.bean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by donglua on 15/6/28.
*/
public class PhotoDirectory {
private int id;
private String coverPath;
private String name;
private long dateAdded;
private List<Photo> photos = new ArrayList<>();
private boolean selected = false;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PhotoDirectory)) return false;
PhotoDirectory directory = (PhotoDirectory) o;
return id == directory.getId();
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCoverPath() {
return coverPath;
}
public void setCoverPath(String coverPath) {
this.coverPath = coverPath;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getDateAdded() {
return dateAdded;
}
public void setDateAdded(long dateAdded) {
this.dateAdded = dateAdded;
}
public List<Photo> getPhotos() {
return photos;
}
public void setPhotos(List<Photo> photos) {
if (photos == null) return;
for (int i = 0, j = 0, num = photos.size(); i < num; i++) {
Photo p = photos.get(j);
if (p == null) {
photos.remove(j);
} else {
j++;
}
}
this.photos = photos;
}
public List<String> getPhotoPaths() {
List<String> paths = new ArrayList<>(photos.size());
for (Photo photo : photos) {
paths.add(photo.getPath());
}
return paths;
}
public void addPhoto(Photo photo) {
photos.add(photo);
}
}
| [
"[email protected]"
] | |
0eef3183769e7645b0c5051779aaf73cd15a498f | ed3cb95dcc590e98d09117ea0b4768df18e8f99e | /project_1_1/src/j/j/i/Calc_1_1_9984.java | 65d54e6f67755e59677617bde064b54e4acce9f5 | [] | no_license | chalstrick/bigRepo1 | ac7fd5785d475b3c38f1328e370ba9a85a751cff | dad1852eef66fcec200df10083959c674fdcc55d | refs/heads/master | 2016-08-11T17:59:16.079541 | 2015-12-18T14:26:49 | 2015-12-18T14:26:49 | 48,244,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 131 | java | package j.j.i;
public class Calc_1_1_9984 {
/** @return the sum of a and b */
public int add(int a, int b) {
return a+b;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.