blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2 values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 131 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 9.45M | extension stringclasses 32 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c0bcfbb8f452dbd4894fd957aefdfba06a45d4b2 | e49497f1a4c3cc142e16c68090ff232e87e306c3 | /app/src/main/java/com/mc/phonelive/custom/MyRelativeLayout1.java | 79ab167d1d184cc9a6a2eb804e63fa461397a1b9 | [] | no_license | woshihfh0123/miaocha_gz | 2fb03bf1d98d9e838e72315e846825b29b9d09f4 | 0b427a97c4663bee4698495f88b1d58e78be05d0 | refs/heads/main | 2023-01-02T07:02:51.180903 | 2020-10-25T09:58:07 | 2020-10-25T09:58:07 | 307,067,453 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,325 | java | package com.mc.phonelive.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import com.mc.phonelive.R;
/**
* Created by cxf on 2018/10/7.
*/
public class MyRelativeLayout1 extends RelativeLayout {
private int mWidth;
private int mHeight;
private Paint mPaint;
private int mRadius;
private int mBgColor;
private int mInnerWidth;
private int mInnerHeight;
private int mInnerRadius;
private int mInnerX;
private int mInnerY;
private int mLineMargin;
private int mLineMarginTop;
private int mLineHeight;
public MyRelativeLayout1(Context context) {
this(context, null);
}
public MyRelativeLayout1(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MyRelativeLayout1(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyRelativeLayout1);
mRadius = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_radius, 0);
mBgColor = ta.getColor(R.styleable.MyRelativeLayout1_mrl_bg_color, Color.BLACK);
mInnerWidth = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_inner_w, 0);
mInnerHeight = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_inner_h, 0);
mInnerRadius = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_inner_r, 0);
mInnerX = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_inner_x, 0);
mInnerY = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_inner_y, 0);
mLineMargin = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_line_m, 0);
mLineMarginTop = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_line_mt, 0);
mLineHeight = (int) ta.getDimension(R.styleable.MyRelativeLayout1_mrl_line_h, 0);
ta.recycle();
init();
}
private void init() {
mPaint = new Paint();
mPaint.setDither(true);
mPaint.setAntiAlias(true);
mPaint.setColor(mBgColor);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w;
mHeight = h;
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
Path path1 = new Path();
path1.addRoundRect(new RectF(0, 0, mWidth, mHeight), mRadius, mRadius, Path.Direction.CW);
Path path2 = new Path();
path2.addRoundRect(new RectF(mInnerX, mInnerY, mInnerX + mInnerWidth, mInnerY + mInnerHeight), mInnerRadius, mInnerRadius, Path.Direction.CW);
Path path3 = new Path();
int lineY = mInnerY + mInnerHeight + mLineMarginTop;
path3.addRect(mLineMargin, lineY, mWidth - mLineMargin, lineY + mLineHeight, Path.Direction.CW);
path1.op(path2, Path.Op.DIFFERENCE);
path1.op(path3, Path.Op.DIFFERENCE);
canvas.drawPath(path1, mPaint);
}
}
| [
"529395283@qq.com"
] | 529395283@qq.com |
7ba120e72ecb89b9359a0cac22b67f9297cc8bd9 | 39bea7023605a4ef9c72f3a42871dba0ad4cb4c7 | /Bush.java | c31eb3312cfd4708c4563a035df0644f74634b12 | [] | no_license | rohildshah/car-dodge-game | 52272173daefe97afef1adc1c6bb3156fbc013ac | 43cc1f9b43e2871371996ebbf2d9d0ccab10a6ea | refs/heads/master | 2020-04-24T05:27:40.457037 | 2019-02-21T04:34:12 | 2019-02-21T04:34:12 | 171,735,338 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 658 | java | import processing.core.PApplet;
class Bush {
private float x;
private float y;
PApplet canvas;
private float speed = 7;
public Bush(PApplet np, float nx, float ny) {
x = nx;
y = ny;
canvas = np;
}
@SuppressWarnings("static-access")
public void display() {
canvas.fill(39, 150, 15);
canvas.rectMode(canvas.CENTER);
canvas.stroke(39,150,15);
canvas.rect(x, y, 10, 50);
canvas.rect(x-10, y+5, 15, 10);
canvas.rect(x+10, y+5, 15, 10);
canvas.rect(x-17, y, 10, 20);
canvas.rect(x+17, y-4, 10, 28);
}
public void move() {
x = x-speed;
if (x<-100) {
x = 550;
y = canvas.random(0,250);
}
}
} | [
"noreply@github.com"
] | rohildshah.noreply@github.com |
053ebd45630a71482637ed0064c620c3d3a1ada3 | 0e6dc405aaa78d976aaba993c5f85a8f21c98f5e | /src/com/brindavancollege/videosurveillance/PrefSettings.java | 402faddffb715d117e3c1e062d8d3f47f2119166 | [] | no_license | saurabh030892/VideoSurveillance | e0eba5406eaf9b2db5f7028a1f396793674f0014 | f9ffdc62d08125348ce6dcd9210fa23a6ec1212f | refs/heads/master | 2021-01-20T06:36:06.884571 | 2014-06-11T13:40:48 | 2014-06-11T13:40:48 | 20,726,113 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,783 | java | package com.brindavancollege.videosurveillance;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.SwitchPreference;
import android.telephony.gsm.SmsManager;
import android.widget.Toast;
import android.preference.Preference.OnPreferenceClickListener;
public class PrefSettings extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
setUpReferences();
setGallery();
}
private void setUpReferences(){
SwitchPreference smsAlertPreference =(SwitchPreference) findPreference("smsAlert");
Boolean curValue1=smsAlertPreference.getSharedPreferences().getBoolean("smsAlert", false);
smsAlertPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference arg0, Object arg1) {
// TODO Auto-generated method stub
Boolean curValue = (Boolean)arg1;
Toast.makeText(PrefSettings.this, "sms alert "+curValue, Toast.LENGTH_SHORT).show();
if(curValue==true){
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
long[] pattern = {0,500 } ;
v.vibrate(pattern,-1) ;
}
else
{
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
long[] pattern = {0,500 } ;
v.vibrate(pattern,-1) ;
}
return true;
}
});
}
private void setGallery(){
Preference imagePreference = (Preference) findPreference("image");
imagePreference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
public boolean onPreferenceClick(Preference preference){
Toast.makeText(PrefSettings.this,"starting settings....",Toast.LENGTH_SHORT).show();
startActivity(new Intent(PrefSettings.this,ImageActivity.class)) ;
return true;
}
});
Preference videoPreference = (Preference) findPreference("video");
videoPreference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
public boolean onPreferenceClick(Preference preference){
Toast.makeText(PrefSettings.this,"starting settings....",Toast.LENGTH_SHORT).show();
startActivity(new Intent(PrefSettings.this,VideoActivity.class)) ;
return true;
}
});
}
}
| [
"saurabhsingh030892@gmail.com"
] | saurabhsingh030892@gmail.com |
21bf7222d97ef0f3a6bf6e1a68e2d684241467ec | 7916ef9e1c46b44e79cf6075dbd063ff3f79909d | /app/src/main/java/com/example/user/beaconapplication/BeaconApplication.java | ac81181320113f62fc0a0f95137e500371ebb1f1 | [] | no_license | playerlove1/BeaconApplication | 9165f3d8d8601256799a6fe43257914d7d658b62 | d4689a342ef1d6eab52d81093f1180b9b51182f5 | refs/heads/master | 2021-01-23T07:20:27.655283 | 2015-08-14T08:40:07 | 2015-08-14T08:40:07 | 40,703,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,799 | java | package com.example.user.beaconapplication;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.powersave.BackgroundPowerSaver;
import org.altbeacon.beacon.startup.RegionBootstrap;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Iterator;
/**
* Created by user on 2015/8/14.
*/
public class BeaconApplication extends Application implements BeaconConsumer {
private static final String TAG = BeaconApplication.class.getSimpleName();
private RegionBootstrap regionBootstrap;
private BackgroundPowerSaver backgroundPowerSaver;
private boolean haveDetectedBeaconsSinceBoot = false;
private Context CurrentForegroundActivity=null;
private BeaconManager beaconManager;
private patient p;
@Override
public void onTerminate() {
beaconManager.unbind(this);
super.onTerminate();
}
public void onCreate() {
super.onCreate();
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);
beaconManager.setBackgroundBetweenScanPeriod(10000);
Log.d(TAG, "setting up background monitoring for power saving");
// wake up the app when a beacon is seen
backgroundPowerSaver = new BackgroundPowerSaver(this);
}
public void setp(patient p1) {
this.p = p1;
}
public void setMonitoringActivity(Context context) {
this.CurrentForegroundActivity = context;
}
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if(beacons.size()>0) //有抓到beacon
{
Iterator<Beacon> iterator=beacons.iterator(); //走訪beacon collection\
Beacon nearstBeacon=beacons.iterator().next();// 預設第一個為 為距離最近的beacon
Double nearstDistance=nearstBeacon.getDistance(); //預設最近距離 為第一個beacon的距離
while(iterator.hasNext()) //走訪beacon 的collection
{
Beacon next=iterator.next();
int result=compareDistance(nearstDistance,next.getDistance());
switch (result)
{
case 0: //距離一樣
break;
case 1://next較近
nearstBeacon=next;
nearstDistance=next.getDistance();
break;
case 2://原來較近
break;
}
}
Log.d("距離",Double.toString(nearstDistance));
switch (checkContex())
{
case 0: //main
Log.d("目前context", null);
break;
case 1: //patient
if(nearstDistance.intValue()>2)
p.stopthis();
break;
case 2:
if(nearstDistance.intValue()<1)
CheckBeaconId(nearstBeacon.getId2().toInt());
break;
}
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
// 自訂判斷距離的function
private int compareDistance(double currentNearst,double next) {
int result = 0;
BigDecimal d_c = new BigDecimal(currentNearst);
BigDecimal d_n = new BigDecimal(next);
if (d_c.compareTo(d_n) == 0) //下個beacon與目前的beacon距離相等
{
result = 0;
} else if (d_c.compareTo(d_n) > 0) //下個beacon與目前最近的beacon 相比 下個beacon的距離較近
{
result = 1;
} else if (d_c.compareTo(d_n) < 0) //目前beacon的距離仍為最短
{
result = 2;
}
return result;
}
//依據beaconid 傳入對應的參數
private void CheckBeaconId(int bid)
{
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(this, patient.class);
Bundle bundle = new Bundle();
switch (bid)
{
case 1:
bundle.putString("bid", "1");//傳遞Double
intent.putExtras(bundle);
startActivity(intent);
break;
case 3:
bundle.putString("bid", "3");//傳遞Double
intent.putExtras(bundle);
startActivity(intent);
break;
}
}
//確認目前在哪個activity
private int checkContex()
{
int result=0;
if( CurrentForegroundActivity instanceof MainActivity)
{
result=2;
}
else if(CurrentForegroundActivity instanceof patient){
result=1;
}
return result;
}
//缺認距離
}
| [
"kos83611@gmail.com"
] | kos83611@gmail.com |
ce721791c71345bc7530486d2fd54580b838e1c7 | d1e8200dab7d2bca417068d8488e3287a36b0e23 | /hw6/src/cscie160/hw6/ATMImplementation.java | b70695871e6889266901828c6dc94c2aaddd4969 | [] | no_license | bret-blackford/harvard-hw6 | 03588ca80c325d9e3de4d718b8eb1a69b928ca81 | fffc92e15809c18faa77634124c5fe911afe3a38 | refs/heads/master | 2016-09-06T02:26:32.326335 | 2011-12-13T20:58:33 | 2011-12-13T20:58:33 | 32,187,459 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,260 | java | package cscie160.hw6;
/** {@code ATMImplementation} This class implements the ATM interface.
*
* @author M. Bret Blackford (20849347)
* @version 2.0
* @since November 12, 2011
*/
public class ATMImplementation implements ATM {
private Account account;
/** Default contructore which creates an Account object
*/
public ATMImplementation() {
super();
System.out.println(DateUtils.now() + " <<>> constructing ATMImplementation()");
account = new Account();
}
/**Will attempt to deposit amount passed in to the single account
* @param amount
* @throws cscie.hw6.ATMException
*/
public void deposit(float amount) throws ATMException {
System.out.println(DateUtils.now() + "in ATMImplementation.depoist()");
Float balance = account.getBalance();
balance += amount;
account.setBalance(balance);
System.out.println(DateUtils.now() + "in ATMImplementation.depoist() adding " + balance.toString());
}
/**Attempts to withdraw funds from the Account object. If withdraw request exceeds current existing balance then an error message will be displayed by the server (but processing with the client continues).
* @param amount
* @throws cscie.hw6.ATMException
*/
public void withdraw(float amount) throws ATMException {
System.out.println(DateUtils.now() + "in ATMImplementation.withdraw()");
Float balance = account.getBalance();
if (amount > balance) {
String msg = "\n <*><*><*> withdraw request greater than account balance <*><*><*> \n";
System.out.println(msg);
//throw new ATMException(msg);
} else {
balance -= amount;
account.setBalance(balance);
System.out.println(DateUtils.now() + "in ATMImplementation.withdraw() reducing balance to " + balance.toString());
}
}
/**Returns the current balance in the Account object
* @return
* @throws cscie.hw6.ATMException
*/
public Float getBalance() throws ATMException {
Float balance = account.getBalance();
System.out.println(DateUtils.now() + "in ATMImplementation.getBalance() returning " + balance.toString());
return balance;
}
}
| [
"bret_blackford@yahoo.com@e9cda58d-beed-7086-01ab-d7e0a2bbf2a1"
] | bret_blackford@yahoo.com@e9cda58d-beed-7086-01ab-d7e0a2bbf2a1 |
e6c82250b38d2f88220f8b6952804ea7c3599c80 | fd8d851e69c797cc16a29d80f485c881b2b90929 | /CoreJava/src/com/hare/krsna/CompImpl.java | 0ad124c2d8468b557af5eb48d5977639f721b6d5 | [] | no_license | sundararamansa76/JavaProjects | 6a552081a8b42792a181ba7e57d55152defe0c53 | 38053842dbc371679aa436304fe76d36d9a9286a | refs/heads/master | 2020-11-29T20:43:48.461603 | 2020-01-24T09:34:38 | 2020-01-24T09:34:38 | 230,211,373 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 672 | java | package com.hare.krsna;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
class comparAsc implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
// TODO Auto-generated method stub
return Integer.compare(o1.length(), o2.length());
}
}
public class CompImpl {
List<String> arrList = new ArrayList<String>(List.of("Krsna", "Radhe", "Balarama", "Acyuta"));
public List<String> returnSorted(){
Collections.sort(this.arrList, new comparAsc());
return this.arrList;
}
public List<String> normalSort() {
Collections.sort(this.arrList);
return this.arrList;
}
}
| [
"sundararamansa76@gmail.com"
] | sundararamansa76@gmail.com |
6d34547da30d099db3553cd380a654a6c56d39eb | 65aa389e4b9b3345eec595ed7d030740ddd9d482 | /app/src/main/java/me/vanessahlyan/parstagram/CreateFragment.java | a6539e2c92205be4f3188408b5a71e991a0ac429 | [
"Apache-2.0"
] | permissive | vanessahlyan/parstagram | 348087feb059f14b425471cbb7706c4293cacd27 | 5360549d8d0145f63e57fbc353c36ea4fc90e6a8 | refs/heads/master | 2020-03-22T18:56:43.141806 | 2018-07-16T06:48:40 | 2018-07-16T06:48:40 | 140,493,198 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,675 | java | package me.vanessahlyan.parstagram;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseUser;
import com.parse.SaveCallback;
import java.io.ByteArrayOutputStream;
import java.io.File;
import butterknife.BindView;
import butterknife.ButterKnife;
import me.vanessahlyan.parstagram.model.Post;
public class CreateFragment extends Fragment {
@BindView(R.id.etDescription) EditText descriptionInput;
@BindView(R.id.tvUsername) TextView username;
@BindView(R.id.ivPreview) ImageView preview;
@BindView(R.id.btnPost) Button postButton;
@BindView(R.id.btnTakePhoto) Button takePhotoButton;
@BindView(R.id.btnUploadPhoto) Button uploadPhotoButton;
@BindView(R.id.pbLoadingCreate) ProgressBar createProgressBar;
File photoFile;
Bitmap photoBitmap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_create, parent, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
postButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
createProgressBar.setVisibility(ProgressBar.VISIBLE);
final String description = descriptionInput.getText().toString();
final ParseUser user = ParseUser.getCurrentUser();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photoBitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
final ParseFile parseFile = new ParseFile(bytes.toByteArray());
parseFile.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
createPost(description, parseFile, user);
Toast.makeText(getActivity(), "Created post", Toast.LENGTH_LONG).show();
createProgressBar.setVisibility(ProgressBar.INVISIBLE);
//HomeActivity activity = (HomeActivity) getActivity();
//activity.goToHome();
}
else {
Toast.makeText(getActivity(), "cannot create post", Toast.LENGTH_LONG).show();
}
}
});
}
});
takePhotoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HomeActivity activity = (HomeActivity) getActivity();
activity.launchCamera();
}
});
uploadPhotoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HomeActivity activity = (HomeActivity) getActivity();
activity.launchPhotos();
}
});
}
private void createPost(String description, ParseFile imageFile, ParseUser user) {
final Post newPost = new Post();
newPost.setDescription(description);
newPost.setImage(imageFile);
newPost.setUser(user);
newPost.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("HomeActivity", "Create post success");
} else {
e.printStackTrace();
}
}
});
}
// method that takes a string file path
public void processImageString(String uri) {
Bitmap takenImage = BitmapFactory.decodeFile(uri);
photoFile = new File(uri);
Glide.with(getActivity()).load(takenImage).into(preview);
}
public void processImageBitmap(Bitmap takenImage, Uri uri) {
photoBitmap = takenImage;
Glide.with(getActivity()).load(takenImage).into(preview);
}
}
| [
"vanessahlyan@fb.com"
] | vanessahlyan@fb.com |
384e04da85bee16588b6b2cf63384cfe46b09417 | 1472f3c54bc38a4c190e7953300b9cd973459b52 | /stream1/src/stream/expression/Multiplication.java | fed2e723d3c9892ae44db6fd37f4555af6cc4a80 | [] | no_license | seongyun-ko/DataStreamingEngine | 2bf4651fcb70cffbad231f4fc5724f062879fdce | 9edcff92bb69f1096c6c54e38775898f9fcdebe2 | refs/heads/master | 2021-04-26T11:41:30.827816 | 2014-08-04T15:04:13 | 2014-08-04T15:04:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,120 | java | package stream.expression;
/**
* A Multipliction represents a binary mulitplication operation.
*
* @author Jeong-Hyon Hwang (jhh@cs.albany.edu)
*/
public class Multiplication extends BinaryOperation {
/**
* Constructs a Multiplication.
*
* @param left
* the left child.
* @param right
* the right child.
*/
public Multiplication(Node left, Node right) {
super(left, right);
}
@Override
public Object evaluate() throws UnboundVariableException {
Object l = object2num(left.evaluate());
Object r = object2num(right.evaluate());
if (l instanceof Integer && r instanceof Integer)
return ((Integer) l).intValue() * ((Integer) r).intValue();
else if (l instanceof Integer && r instanceof Double)
return ((Integer) l).intValue() * ((Double) r).doubleValue();
else if (l instanceof Double && r instanceof Integer)
return ((Double) l).doubleValue() * ((Integer) r).intValue();
else if (l instanceof Double && r instanceof Double)
return ((Double) l).doubleValue() * ((Double) r).doubleValue();
else
throw new UnsupportedOperationException();
}
}
| [
"Seongyun@postech.ac.kr"
] | Seongyun@postech.ac.kr |
f1c6bfc4a3378404c6b9a31c7488032ffc10dd1a | 090059dd34683958fe66caa622739650f40c162b | /app/src/main/java/com/example/android/tourguideapp/BucharestFragment.java | ae4103a61eef34671ca173d76972aa1af05eac80 | [] | no_license | KajcsaErno/TourGuideApp | d1a8f1454331ada246937c79ea7ec2ddf87522a8 | 1b879738f54bd4f2901780a68df667f71e70f1e5 | refs/heads/master | 2023-04-06T01:19:39.513025 | 2021-04-03T13:09:46 | 2021-04-03T13:09:46 | 112,117,931 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,867 | java | package com.example.android.tourguideapp;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
public class BucharestFragment extends Fragment {
public BucharestFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.attraction_list, container, false);
// Create a list of attractions
final ArrayList<Attraction> attractions = new ArrayList<>();
attractions.add(new Attraction(getResources().getString(R.string.bucharest_attraction_name_1), getResources().getString(R.string.bucharest_attraction_phone_1), getResources().getString(R.string.bucharest_attraction_website_1), getResources().getString(R.string.bucharest_attraction_address_1), R.drawable.b1));
attractions.add(new Attraction(getResources().getString(R.string.bucharest_attraction_name_2), getResources().getString(R.string.bucharest_attraction_phone_2), getResources().getString(R.string.bucharest_attraction_website_2), getResources().getString(R.string.bucharest_attraction_address_2), R.drawable.b2));
attractions.add(new Attraction(getResources().getString(R.string.bucharest_attraction_name_3), getResources().getString(R.string.bucharest_attraction_phone_3), getResources().getString(R.string.bucharest_attraction_website_3), getResources().getString(R.string.bucharest_attraction_address_3), R.drawable.b3));
attractions.add(new Attraction(getResources().getString(R.string.bucharest_attraction_name_4), getResources().getString(R.string.bucharest_attraction_phone_4), getResources().getString(R.string.bucharest_attraction_website_4), getResources().getString(R.string.bucharest_attraction_address_4), R.drawable.b4));
attractions.add(new Attraction(getResources().getString(R.string.bucharest_attraction_name_5), getResources().getString(R.string.bucharest_attraction_phone_5), getResources().getString(R.string.bucharest_attraction_website_5), getResources().getString(R.string.bucharest_attraction_address_5), R.drawable.b5));
AttractionAdapter adapter = new AttractionAdapter(getActivity(), attractions);
ListView listView = rootView.findViewById(R.id.list);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
Intent websiteIntent = new Intent(Intent.ACTION_VIEW);
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Attraction attraction = attractions.get(position);
String url = attraction.getAttractionWebsite();
websiteIntent.setData(Uri.parse(url));
startActivity(websiteIntent);
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long l) {
Attraction attraction = attractions.get(position);
Uri gmmIntentUri = Uri.parse(getResources().getString(R.string.locationUri) + attraction.getAttractionName());
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
return true;
}
});
return rootView;
}
}
| [
"31850356+KajcsaErno@users.noreply.github.com"
] | 31850356+KajcsaErno@users.noreply.github.com |
38d9bddbba389f8e48908918c32b5dad4d7d842c | a663593e5099e60bbf7c4a56c5b8669d76079cd9 | /app/src/main/java/com/xinspace/csevent/data/biz/SupplyUserInfoBiz.java | 7249f558d97a9c61b3fbe5c217527a5e584d5121 | [] | no_license | cuijiehui/doubao | 52fabe5ffe37a76ffd7fd9c335f4e01bc60934c6 | 91f1e3b068eaa2294165b831c695723f0d996a2b | refs/heads/master | 2020-03-17T21:01:41.469553 | 2018-05-18T10:29:33 | 2018-05-18T10:29:33 | 133,939,816 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,071 | java | package com.xinspace.csevent.data.biz;
import android.content.Context;
import android.text.TextUtils;
import com.xinspace.csevent.app.CoresunApp;
import com.xinspace.csevent.data.entity.Params;
import com.xinspace.csevent.myinterface.HttpRequestListener;
import com.xinspace.csevent.app.AppConfig;
import com.xinspace.csevent.util.HttpUtil;
import com.xinspace.csevent.ui.activity.SupplyUserInfoActivity;
import java.util.ArrayList;
import java.util.List;
/**
* 第三方登陆补充个人资料
*/
public class SupplyUserInfoBiz {
public static void supplyInfo(Context context,String name,String sex){
try{
String url=AppConfig.SUPPLY_USER_INFO_URL;
HttpUtil http=new HttpUtil();
http.setOnHttpRequestFinishListener((SupplyUserInfoActivity) context);
List<Params> list=new ArrayList<>();
list.add(new Params("uid", CoresunApp.USER_ID));
list.add(new Params("sex", sex));
list.add(new Params("nickname", name));
http.sendPost(url,list);
}catch (Exception e){
e.printStackTrace();
}
}
public static void supplyInfo2(Context context,String name,String tel , HttpRequestListener listener){
try{
String url=AppConfig.SUPPLY_USER_INFO_URL;
HttpUtil http=new HttpUtil();
http.setOnHttpRequestFinishListener(listener);
List<Params> list=new ArrayList<>();
list.add(new Params("uid", CoresunApp.USER_ID));
list.add(new Params("sex", "1"));
list.add(new Params("nickname", name));
list.add(new Params("birthday", "0000-00-00"));
list.add(new Params("salary", "3000"));
list.add(new Params("email", ""));
list.add(new Params("interest", ""));
list.add(new Params("tel", tel));
http.sendPost(url,list);
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 修改昵称 真实姓名 手机号
*
* @param listener
*/
public static void supplyInfo3(String openid , String nickname , String realname , String avatar, HttpRequestListener listener){
try{
String url=AppConfig.Edit_Info;
HttpUtil http=new HttpUtil();
http.setOnHttpRequestFinishListener(listener);
List<Params> list=new ArrayList<>();
list.add(new Params("openid", openid));
if (!TextUtils.isEmpty(nickname)){
list.add(new Params("nickname", nickname));
}
if (!TextUtils.isEmpty(nickname)){
list.add(new Params("nickname", nickname));
}
if (!TextUtils.isEmpty(realname)){
list.add(new Params("realname", realname));
}
if (!TextUtils.isEmpty(avatar)){
list.add(new Params("avatar", avatar));
}
http.sendPost(url,list);
}catch (Exception e){
e.printStackTrace();
}
}
}
| [
"714888928@qq.com"
] | 714888928@qq.com |
ab92a18923586fe1f91c6abb4c90c30256c4ab74 | d51e5fe6232fb269de47a55dd776cebcf58b0183 | /Sew Projekt/src/net/coderodde/robohand/RobohandApp.java | 3bf3b8c9abc15306ea640d2196a322692796c428 | [] | no_license | indrit11/Indrit | 949e9074252bc13dd5db2c0ef0da31d44b0aea46 | 96f0cf5f5bd550aace0a7f41fd4699aedb4ed7e5 | refs/heads/master | 2021-01-24T07:27:28.070907 | 2017-06-04T20:55:03 | 2017-06-04T20:55:03 | 93,345,479 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,818 | java | package net.coderodde.robohand;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* This class implements the GUI for dealing with a robohand.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (Apr 17, 2016)
*/
public class RobohandApp extends JFrame {
/**
* The width of this frame in pixels.
*/
private static final int FRAME_WIDTH = 800;
/**
* The height of this frame in pixels.
*/
private static final int FRAME_HEIGHT = 600;
private final JPanel panel = new JPanel();
private Canvas myCanvas;
public RobohandApp() {
super("Robohand 1.6");
constructCanvas();
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout());
panel.add(myCanvas, BorderLayout.CENTER);
myCanvas.setBackground(Color.BLACK);
setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setResizable(false);
centerOut();
setVisible(true);
}
private void constructCanvas() {
List<Client> vectorList = new ArrayList<>();
float length = 30.0f;
float angle = 0.0f;
Client[] vectors = new Client[] {
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
new Client(length, angle),
};
vectors[0].addChildVector(vectors[1]);
vectors[0].addChildVector(vectors[2]);
vectors[1].addChildVector(vectors[3]);
vectors[1].addChildVector(vectors[4]);
vectors[2].addChildVector(vectors[5]);
vectors[2].addChildVector(vectors[6]);
vectors[6].addChildVector(vectors[7]);
vectorList.addAll(Arrays.asList(vectors));
myCanvas = new Server(vectorList);
}
private void centerOut() {
final int currentWidth = getWidth();
final int currentHeight = getHeight();
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width - currentWidth) / 2,
(screen.height - currentHeight) / 2);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(() -> {
RobohandApp app = new RobohandApp();
});
}
}
| [
"indmus12@htl-shkoder.com"
] | indmus12@htl-shkoder.com |
5952c2f8cba26b136874fc4711feff1f7cf33896 | 311bae7c3c67aa30d308ff7221eb9c8e0ca70c30 | /app/src/main/java/com/example/myapplication/bean/Feed.java | 312afafd087b0f141e78b5594139bcce58e085d8 | [] | no_license | las1374236892/mini_Tik_Tok | eda0a50d616760dc72fe09c9583bbcb917aa227c | d8a70a2fbc9b1cc57b8388b8e2fd7a77f8d2d333 | refs/heads/master | 2020-06-12T23:53:16.201065 | 2019-07-09T09:28:14 | 2019-07-09T09:28:14 | 194,466,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,551 | java | package com.example.myapplication.bean;
/**
* @author Xavier.S
* @date 2019.01.20 14:18
*/
public class Feed {
// TODO-C2 (1) Implement your Feed Bean here according to the response json
// {
// "student_id":"2220186666",
// "user_name":"doudou",
// "image_url":"https://sf6-hscdn-tos.pstatp
// .com/obj/developer-baas/baas/tt7217xbo2wz3cem41/9c6bbc2aa5355504_1560563154279
// .jpg",
// "_id":"5d044dd222e26f0024157401",
// "video_url":"https://lf1-hscdn-tos.pstatp
// .com/obj/developer-baas/baas/tt7217xbo2wz3cem41/a8efa55c5c22de69_1560563154288
// .mp4",
// "createdAt":"2019-06-15T01:45:54.368Z",
// "updatedAt":"2019-06-15T01:45:54.368Z",
// }
// ...
// ],
private String student_id;
private String user_name;
private String image_url;
private String _id;
private String video_url;
private String createdAt;
private String updatedAt;
public String getStudent_id() {
return student_id;
}
public String get_id() {
return _id;
}
public String getCreatedAt() {
return createdAt;
}
public String getImage_url() {
return image_url;
}
public String getUpdatedAt() {
return updatedAt;
}
public String getUser_name() {
return user_name;
}
public String getVideo_url() {
return video_url;
}
}
| [
"oncwnuDY9bH2yOJIIE_QdgR5Rrdo@git.weixin.qq.com"
] | oncwnuDY9bH2yOJIIE_QdgR5Rrdo@git.weixin.qq.com |
d0749b16d26a56ad1ea28568e286b1de4ba699d5 | 27444e958b652076568e59eafc83ae5a582e6646 | /src/main/java/spring/example/SpringDI/SpellChecker.java | 1afde9d713ae8763d6931860ad17063eec8ea0fd | [] | no_license | SuiteLHY/SuiteLHY | 6484b0234ffa59fbcd577530a4bbb75c960e6470 | f9a747d412c0247db132c0d6c36bb0b4adc6d441 | refs/heads/master | 2020-09-21T12:43:05.841304 | 2020-06-27T14:55:35 | 2020-06-27T14:55:35 | 224,792,570 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 256 | java | package spring.example.SpringDI;
public class SpellChecker {
public SpellChecker() {
System.out.println("Inside SpellChecker constructor");
}
public void checkSpelling() {
System.out.println("Inside checkSpelling");
}
}
| [
"a471486944@gmail.com"
] | a471486944@gmail.com |
ba4e5f71b6723622331cbdb658996e4bc012d687 | aead137a44a9da5bf4035cf3b067d201f95a1f5d | /Ryt/app/src/main/java/com/yxh/ryt/util/utils/GlideCircleTransform.java | 7af5e15f8330ca26b1e8a9170ce8bbf32a6fc76f | [
"MIT"
] | permissive | yangzhenjie0/rongyicast | d3cab6d447b14ae1b709f6f3e9f1d9d4e8dcfa6d | 14876fe3c4ced021fc5f589030f33921e1e0130a | refs/heads/master | 2020-07-10T16:23:23.554852 | 2016-09-07T02:59:06 | 2016-09-07T02:59:11 | 67,566,161 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,692 | java | package com.yxh.ryt.util.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
/**
* Created by yiw on 2016/6/6.
*/
public class GlideCircleTransform extends BitmapTransformation {
public GlideCircleTransform(Context context){
super(context);
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
@Override
public String getId() {
return getClass().getName();
}
}
| [
"jie0122"
] | jie0122 |
3e738a25e69af70749fe7514a3fdcab84bf011f7 | 88492884598e90d5af140958b71cde76b51d36aa | /ExampleByBong/FirstApp/app/src/main/java/nhnnext/org/gingeraebi/firstapp/Person.java | 657a322aed40f58d9e22bba09c2f3ba267fc5867 | [] | no_license | JaeBongLee/cadi | c32cdbf98c7aeaf8acfe463af990158ae0a3b953 | 3da060100485b66fa8ef5f521c5cf9264ed86f4e | refs/heads/master | 2021-01-10T16:31:11.991846 | 2016-03-11T16:23:02 | 2016-03-11T16:23:02 | 51,635,667 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 652 | java | package nhnnext.org.gingeraebi.firstapp;
/**
* Created by JaeWon on 2016-02-18.
*/
public class Person {
private int age;
private String address;
private String name;
private String phoneNum;
public Person(int age, String address, String name, String phoneNum) {
this.age = age;
this.address = address;
this.name = name;
this.phoneNum = phoneNum;
}
public int getAge() {
return age;
}
public String getAddress() {
return address;
}
public String getName() {
return name;
}
public String getPhoneNum() {
return phoneNum;
}
}
| [
"ljb0484@gmail.com"
] | ljb0484@gmail.com |
d519c8eb65d906d3224e332b36cd34fb778c17b1 | 20e63c8a85f84cdd0a776bcdce2a7ad5053798f8 | /app/src/main/java/com/kylejw/vsms/vsms/VoipMsApi/Exchanges/SendSms.java | c1cb45775df982a6c8cb64cc02a43cae1e50e8ab | [] | no_license | kylejw1/vsms | 8915cf51b4fb7430e2bcc67757c924a24650da87 | f3ea808108128f3b040fc65a6d0ed912ea44bb17 | refs/heads/master | 2016-09-11T02:18:11.896763 | 2015-04-27T21:16:43 | 2015-04-27T21:16:43 | 30,577,537 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,677 | java | package com.kylejw.vsms.vsms.VoipMsApi.Exchanges;
import android.content.Context;
import com.kylejw.vsms.vsms.VoipMsApi.VoipMsRequest;
import com.kylejw.vsms.vsms.VoipMsApi.VoipMsResponse;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Calendar;
/**
* Created by Kyle on 12/18/2014.
*/
public class SendSms extends VoipMsRequest<SendSms.SendSmsResponse> {
public class SendSmsResponse extends VoipMsResponse {
private String id;
public String getId() {
return id;
}
public void setId(String sms) {
this.id = sms;
}
}
@VoipMsParameter(name = "did", required = true)
String fromDid;
@VoipMsParameter(name = "dst", required = true)
String toDid;
@VoipMsParameter(name = "message", required = true)
private String message;
public void setMessage(String message) {
if (message.length() > 160) {
// TODO: Split and send two messages!
message = message.substring(0,159);
}
this.message = message;
}
public SendSms(String fromDid, String toDid, String message) {
super("sendSMS", true);
this.fromDid = fromDid;
this.toDid = toDid;
setMessage(message);
}
@Override
protected SendSmsResponse buildResult(JSONObject jsonResponse) {
SendSmsResponse resp = new SendSmsResponse();
try {
resp.setStatus(jsonResponse.getString("status"));
} catch (JSONException ex) {}
try {
resp.setId(jsonResponse.getString("sms"));
} catch (JSONException ex) {}
return resp;
}
}
| [
"kylejw1@gmail.com"
] | kylejw1@gmail.com |
e1e61204f657961c56fa296c0e127fecd672979f | e52dec34258ddb877c58b1fe4ba1fa64da4efc52 | /src/main/java/pl/edu/wszib/wallet/dao/impl/UserDAOImpl.java | 9ffe42b71dd77c3f6bc631d1c2090ba9253efd70 | [] | no_license | karollb/WalletAplication | 8a3ee79d56d4f6a9235fcda1d12a1d274c4c9b92 | ade29ff1465646750e4fe6bf0f3ab235ea2f55ab | refs/heads/master | 2023-06-29T18:04:23.411441 | 2021-07-27T13:47:30 | 2021-07-27T13:47:30 | 389,985,254 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,091 | java | package pl.edu.wszib.wallet.dao.impl;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import pl.edu.wszib.wallet.dao.IUserDAO;
import pl.edu.wszib.wallet.model.User;
import javax.persistence.NoResultException;
@Repository
public class UserDAOImpl implements IUserDAO {
private final SessionFactory sessionFactory;
@Autowired
public UserDAOImpl(final SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public void addNewUser(final User user) {
Session session = this.sessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
session.save(user);
tx.commit();
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
} finally {
session.close();
}
}
@Override
public User getUserById(final Long id) {
Session session = this.sessionFactory.openSession();
Query<User> query = session.createQuery("FROM pl.edu.wszib.wallet.model.User WHERE id = :id");
query.setParameter("id", id);
User result = null;
try {
result = query.getSingleResult();
} catch (NoResultException e) {
e.printStackTrace();
}
session.close();
return result;
}
@Override
public User getUserByLogin(final String login) {
Session session = this.sessionFactory.openSession();
Query<User> query = session.createQuery("FROM pl.edu.wszib.wallet.model.User WHERE login = :login");
query.setParameter("login", login);
User result = null;
try {
result = query.getSingleResult();
} catch (NoResultException e) {
e.printStackTrace();
}
session.close();
return result;
}
}
| [
"73835249+karollb@users.noreply.github.com"
] | 73835249+karollb@users.noreply.github.com |
c5af7da533906d796db3fb1b7899f564f2d6152c | 11d57e8b31c3f77e03177d6f6cd2b2587dbe9a2a | /app/src/main/java/com/qyoub/speedtest/GetSpeedTestHostsHandler.java | 2536e585692eeb1e7720b10f34408d850495a9ff | [] | no_license | ayoub97-developper/speed-test | f2ffe56fc8fc7d94892622b0c9f0bf1be26d17f0 | a5b07f97d3c1e73974369c32e64aebb1d9b5748d | refs/heads/master | 2022-11-29T23:16:55.152319 | 2020-08-21T15:56:44 | 2020-08-21T15:56:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,842 | java | package com.qyoub.speedtest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class GetSpeedTestHostsHandler extends Thread {
HashMap<Integer, String> mapKey = new HashMap<>();
HashMap<Integer, List<String>> mapValue = new HashMap<>();
double selfLat = 0.0;
double selfLon = 0.0;
boolean finished = false;
public HashMap<Integer, String> getMapKey() {
return mapKey;
}
public HashMap<Integer, List<String>> getMapValue() {
return mapValue;
}
public double getSelfLat() {
return selfLat;
}
public double getSelfLon() {
return selfLon;
}
public boolean isFinished() {
return finished;
}
@Override
public void run() {
//Get latitude, longitude
try {
URL url = new URL("https://www.speedtest.net/speedtest-config.php");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
int code = urlConnection.getResponseCode();
if (code == 200) {
BufferedReader br = new BufferedReader(
new InputStreamReader(
urlConnection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (!line.contains("isp=")) {
continue;
}
selfLat = Double.parseDouble(line.split("lat=\"")[1].split(" ")[0].replace("\"", ""));
selfLon = Double.parseDouble(line.split("lon=\"")[1].split(" ")[0].replace("\"", ""));
break;
}
br.close();
}
} catch (Exception ex) {
ex.printStackTrace();
return;
}
String uploadAddress = "";
String name = "";
String country = "";
String cc = "";
String sponsor = "";
String lat = "";
String lon = "";
String host = "";
//Best server
int count = 0;
try {
URL url = new URL("https://www.speedtest.net/speedtest-servers-static.php");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
int code = urlConnection.getResponseCode();
if (code == 200) {
BufferedReader br = new BufferedReader(
new InputStreamReader(
urlConnection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.contains("<server url")) {
uploadAddress = line.split("server url=\"")[1].split("\"")[0];
lat = line.split("lat=\"")[1].split("\"")[0];
lon = line.split("lon=\"")[1].split("\"")[0];
name = line.split("name=\"")[1].split("\"")[0];
country = line.split("country=\"")[1].split("\"")[0];
cc = line.split("cc=\"")[1].split("\"")[0];
sponsor = line.split("sponsor=\"")[1].split("\"")[0];
host = line.split("host=\"")[1].split("\"")[0];
List<String> ls = Arrays.asList(lat, lon, name, country, cc, sponsor, host);
mapKey.put(count, uploadAddress);
mapValue.put(count, ls);
count++;
}
}
br.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
finished = true;
}
} | [
"ayoub.chehlafi@yosobox.com"
] | ayoub.chehlafi@yosobox.com |
baf5850c426dca174586edbaa27e2e9ec8225b9b | a6f12fc5a796c02ec64fa3edc1e77def2828e32e | /Junior3/src/zz/karma/JuniorEdit/CS/K_TestRun.java | dc656cb5274550bfda9800695435d37cb333dd2d | [] | no_license | jixingrui/java | 94b7a599175e572b6f4ef73686ecebfc21e165e2 | 347680e37a363ebf3b5d79e38718416de5f787f0 | refs/heads/master | 2021-06-27T15:12:16.180217 | 2017-09-19T18:59:56 | 2017-09-19T18:59:56 | 104,111,505 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 432 | java | package zz.karma.JuniorEdit.CS;
import azura.karma.run.Karma;
import azura.karma.run.KarmaReaderA;
import azura.karma.def.KarmaSpace;
/**
*@note empty
*/
public class K_TestRun extends KarmaReaderA {
public static final int type = 65371461;
public K_TestRun(KarmaSpace space) {
super(space, type , 65371616);
}
@Override
public void fromKarma(Karma karma) {
}
@Override
public Karma toKarma() {
return karma;
}
} | [
"jixingrui@foxmail.com"
] | jixingrui@foxmail.com |
f0c9fc2ce4ef4d196402836e354d3eb3b74a716e | a4a74b69f5a7fa76d6a11b33141833f4fb750b1e | /code/core_java/src/main/java/com/liuhs/bio/server/ServerSocketDemo.java | 756547c8af4806f8853d5b5b08d3caa236101db2 | [] | no_license | liuhs4444/core_java | 8b07ca0f2aaa6cc9065d53cae9b3d428933ae555 | 92251e59e97d7dddbea226fdb604122a6fc48d2c | refs/heads/master | 2021-06-25T14:17:09.642239 | 2020-03-12T00:51:26 | 2020-03-12T00:51:26 | 119,043,665 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,303 | java | package com.liuhs.bio.server;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class ServerSocketDemo {
public static void main(String[] args) {
try {
// create server socket
ServerSocket serverSocket = new ServerSocket(9999);
// 接受客户端请求
// 此方法默认是阻塞的,当有新的请求来时,此方法会被唤醒
Socket accept = serverSocket.accept();
// 获取输入输出流:用来和客户端进行数据交互
InputStream inputStream = accept.getInputStream();
OutputStream outputStream = accept.getOutputStream();
// 对原始输入流进行包装
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
// 对原始输出流进行包装
PrintWriter printWriter = new PrintWriter(outputStream);
// 读取客户端传递的参数
String clientMsg = bufferedReader.readLine();
System.out.println("server : client send msg ==> " + clientMsg);
// 给客户端的响应
/*printWriter.print("success");
printWriter.flush();*/
} catch (Exception e) {
}
}
}
| [
"liuhs4444@163.com"
] | liuhs4444@163.com |
7d2b0afd1318824f6bac449d52f905811c566038 | 0b8c97c07f8d9f8a1c4c3e52d411b4bac8754ee5 | /app/src/main/java/skating_schedule/Month.java | e6b4b4b9f77baf47df1d03d93ea3e64eb07ef694 | [] | no_license | msysmilu/skatetimePublicVersion | 7c49f23392345d44e79242eee462c460b1782aa0 | 3459ebe15adc728057896fa4a5422ae454c8de79 | refs/heads/master | 2020-03-18T20:05:56.069600 | 2018-05-28T18:36:24 | 2018-05-28T18:36:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 314 | java |
package skating_schedule;
import java.util.List;
public class Month{
private List day;
private String id;
public List getDay(){
return this.day;
}
public void setDay(List day){
this.day = day;
}
public String getId(){
return this.id;
}
public void setId(String id){
this.id = id;
}
}
| [
"emil.ferent@gmail.com"
] | emil.ferent@gmail.com |
198a057559c70e76e03449e547af835823bd112f | 6520c2299aeaa18db3cd115197cfa4189c9bc375 | /src/esocial-esquemas/src/main/java/br/jus/tst/esocial/esquemas/eventos/monit/PGPDataType.java | f27b95c93e355d6e5aeb407a93d1a584c94c1d57 | [] | no_license | PauloTeixeiraF/esocial | 64e2966e0073cd40e6292d4d4a8234d7139d9912 | 49c4e14fb6c4f23e537d9928cf5d1ca4b51a8ed8 | refs/heads/master | 2020-04-20T16:07:10.916308 | 2019-02-01T17:15:46 | 2019-02-01T17:15:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,998 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// 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: 2019.01.09 at 02:26:37 PM BRST
//
package br.jus.tst.esocial.esquemas.eventos.monit;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlType;
import org.w3c.dom.Element;
/**
* <p>Java class for PGPDataType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="PGPDataType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <choice>
* <sequence>
* <element name="PGPKeyID" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
* <element name="PGPKeyPacket" type="{http://www.w3.org/2001/XMLSchema}base64Binary" minOccurs="0"/>
* <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* <sequence>
* <element name="PGPKeyPacket" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
* <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </choice>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PGPDataType", propOrder = {
"content"
})
public class PGPDataType {
@XmlElementRefs({
@XmlElementRef(name = "PGPKeyPacket", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class, required = false),
@XmlElementRef(name = "PGPKeyID", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class, required = false)
})
@XmlAnyElement(lax = true)
protected List<Object> content;
/**
* Gets the rest of the content model.
*
* <p>
* You are getting this "catch-all" property because of the following reason:
* The field name "PGPKeyPacket" is used by two different parts of a schema. See:
* line 220 of file:/home/guilherme/Development/ESOCIAL-JT/github/exemplos/esocial-esquemas/src/main/resources/xsd/eventos/v02_05/xmldsig-core-schema.xsd
* line 215 of file:/home/guilherme/Development/ESOCIAL-JT/github/exemplos/esocial-esquemas/src/main/resources/xsd/eventos/v02_05/xmldsig-core-schema.xsd
* <p>
* To get rid of this property, apply a property customization to one
* of both of the following declarations to change their names:
* Gets the value of the content property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link byte[]}{@code >}
* {@link Element }
* {@link Object }
* {@link JAXBElement }{@code <}{@link byte[]}{@code >}
*
*
*/
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
| [
"guilherme@eti41149.rede.tst"
] | guilherme@eti41149.rede.tst |
7ad9b713ac61eff87ae6ff7623b628eb4d4fecdc | fc6a148bf5783c2219b027364837d3fc1df9e113 | /app/src/test/java/com/example/rajatjain/health/ExampleUnitTest.java | fa7dd6e4e0e2ab7382b486c0c4f1677a916b22a0 | [] | no_license | dakshjain/DietPlanner | 5c9cd63c07cb695a0c39aa3a14c82138f4d9e2ab | d2b140df82476b1c55e3a2f53fd952a8e715bc8d | refs/heads/master | 2021-01-22T04:48:27.611270 | 2017-02-10T15:31:35 | 2017-02-10T15:31:35 | 81,578,577 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 406 | java | package com.example.rajatjain.health;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"rajatjain@DJs-Macbook.local"
] | rajatjain@DJs-Macbook.local |
d3c9f7975d463b368a86775c4902c3ade16adf17 | 10620383d0c16822e02d956ba5959182140e35a9 | /src/Authorization.java | 31a40c7f9bc9439f258c63fb0367cc55ef836120 | [] | no_license | gangji-v4780/mySEJavaProject | b076c763577b5bcdfbd13f30c9657096afc8fd30 | ff82935f96ab902b6ebe715a75545b9cee26f64a | refs/heads/master | 2022-11-19T07:04:00.218709 | 2020-07-20T05:44:23 | 2020-07-20T05:44:23 | 281,024,659 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 33 | java |
public class Authorization {
}
| [
"vandana.gangji@outlook.com"
] | vandana.gangji@outlook.com |
7a390916d53f51d31d83904bf802a4e3ab7f0e33 | f0d25d83176909b18b9989e6fe34c414590c3599 | /app/src/main/java/com/subao/common/intf/XunyouTokenStateListener.java | 77bdb743f1e87e47a077cfc2d35e666a025b0211 | [] | no_license | lycfr/lq | e8dd702263e6565486bea92f05cd93e45ef8defc | 123914e7c0d45956184dc908e87f63870e46aa2e | refs/heads/master | 2022-04-07T18:16:31.660038 | 2020-02-23T03:09:18 | 2020-02-23T03:09:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 111 | java | package com.subao.common.intf;
public interface XunyouTokenStateListener {
void onXunyouTokenInvalid();
}
| [
"quyenlm.vn@gmail.com"
] | quyenlm.vn@gmail.com |
8c44c0cd4febd01c47c6717201fae00680fb35ab | bdc1e84147f0a290ca3718e75011ba237bc16062 | /src/main/java/com/theoryinpractise/halbuilder5/RepresentationException.java | 41105ccb73aacd5909c3ab8fc38cda6743f6a65c | [
"Apache-2.0"
] | permissive | HalBuilder/halbuilder-core | cbcea8e7d73c10138d96f6583dcdfa1b7e6fc383 | 73a277d844ec9616722f655dc34f8174b06b1327 | refs/heads/develop | 2022-11-30T01:39:01.819215 | 2018-07-23T01:07:48 | 2018-07-23T01:07:48 | 5,325,484 | 17 | 9 | null | 2022-11-16T10:47:45 | 2012-08-07T08:33:35 | Java | UTF-8 | Java | false | false | 375 | java | package com.theoryinpractise.halbuilder5;
public class RepresentationException extends RuntimeException {
public RepresentationException(String message) {
super(message);
}
public RepresentationException(Throwable throwable) {
super(throwable);
}
public RepresentationException(String message, Throwable throwable) {
super(message, throwable);
}
}
| [
"mark@talios.com"
] | mark@talios.com |
134d6655005c18693e7eb1243c9a8c639fa2afd9 | 6f99419227f57b51f593ec85cd0b47df561d1bec | /src/medstore/SupplierUpdate.java | c94d64d527dbcd92c393c4d6acbd58fb91c09cb6 | [] | no_license | dipu641298/MedStore | 7daa8f7c48ff0fc905d9429da7bb1229fd900009 | 701ce016adf46703c8475d375706cb1b45a294b1 | refs/heads/master | 2020-05-16T13:08:52.038034 | 2019-04-23T17:43:19 | 2019-04-23T17:43:19 | 183,066,315 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 14,913 | 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 medstore;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
/**
*
* @author dipu
*/
public class SupplierUpdate extends javax.swing.JFrame {
/**
* Creates new form SupplierUpdate
*/
public SupplierUpdate() {
initComponents();
txtid.setText("");
txtname.setText("");
txtcntact.setText("");
txtcompany.setText("");
txtdue.setText("");
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
txtid = new javax.swing.JTextField();
btnSub = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtname = new javax.swing.JTextField();
txtcompany = new javax.swing.JTextField();
txtcntact = new javax.swing.JTextField();
txtdue = new javax.swing.JTextField();
btnsave = new javax.swing.JButton();
btnback = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("ID");
txtid.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtidActionPerformed(evt);
}
});
btnSub.setText("Submit");
btnSub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubActionPerformed(evt);
}
});
jLabel2.setText("Name");
jLabel3.setText("Company");
jLabel4.setText("Contact");
jLabel5.setText("Due");
txtname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtnameActionPerformed(evt);
}
});
txtcompany.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcompanyActionPerformed(evt);
}
});
txtcntact.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcntactActionPerformed(evt);
}
});
txtdue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtdueActionPerformed(evt);
}
});
btnsave.setText("Save");
btnsave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsaveActionPerformed(evt);
}
});
btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtcompany, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcntact, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtdue, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(19, 19, 19))
.addGroup(layout.createSequentialGroup()
.addGap(33, 33, 33)
.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(btnSub)))
.addGap(225, 225, 225)
.addComponent(btnback, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(134, 134, 134)
.addComponent(btnsave)))
.addContainerGap(283, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnSub)
.addComponent(jLabel1)
.addComponent(btnback))
.addGap(51, 51, 51)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtcompany, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(41, 41, 41)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(txtcntact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtdue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(66, 66, 66)
.addComponent(btnsave)
.addContainerGap(145, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void txtidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtidActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtidActionPerformed
private void btnSubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubActionPerformed
// TODO add your handling code here:
String sid = txtid.getText().trim();
int int_sid = Integer.parseInt(sid);
String n="",c="",cm="",d="";
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=db;integratedSecurity=true");
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(" select * from supplier where id = '"+int_sid+"'");
ResultSetMetaData rsmetadata= rs.getMetaData();
int col = rsmetadata.getColumnCount();
while(rs.next()){
n = rs.getString(2);
cm = rs.getString(3);
c = rs.getString(4);
d = rs.getString(5);
}
}catch(Exception e){
e.printStackTrace();
}
txtname.setText(n);
txtcompany.setText(cm);
txtcntact.setText(c);
txtdue.setText(d);
}//GEN-LAST:event_btnSubActionPerformed
private void txtnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtnameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtnameActionPerformed
private void txtcompanyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcompanyActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcompanyActionPerformed
private void txtcntactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcntactActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcntactActionPerformed
private void txtdueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtdueActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtdueActionPerformed
private void btnsaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsaveActionPerformed
// TODO add your handling code here:
String sid = txtid.getText().trim();
int int_sid = Integer.parseInt(sid);
String n="",c="",cm="",d="";
n = txtname.getText().trim();
c = txtcntact.getText().trim();
cm = txtcompany.getText().trim();
d = txtdue.getText().trim();
int int_d = Integer.parseInt(d);
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=db;integratedSecurity=true");
Statement statement = connection.createStatement();
statement.executeQuery(" update supplier set names = '"+n+"', company = '"+cm+"', contact = '"+c+"', due = '"+int_d+"' where id = '"+int_sid+"' ");
}catch(Exception e){
e.printStackTrace();
}
}//GEN-LAST:event_btnsaveActionPerformed
private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbackActionPerformed
// TODO add your handling code here:
new SupplierList().setVisible(true);
this.setVisible(false);
}//GEN-LAST:event_btnbackActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SupplierUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SupplierUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SupplierUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SupplierUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SupplierUpdate().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnSub;
private javax.swing.JButton btnback;
private javax.swing.JButton btnsave;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField txtcntact;
private javax.swing.JTextField txtcompany;
private javax.swing.JTextField txtdue;
private javax.swing.JTextField txtid;
private javax.swing.JTextField txtname;
// End of variables declaration//GEN-END:variables
}
| [
"rahman641298@gmail.com"
] | rahman641298@gmail.com |
0960265c7f33a9d4a6e6766afa548496a93485a2 | 8e68adecb57b1d15a21e8b1baa672ac0e2a2bf13 | /rating-persistence-mongo-adapter/src/main/java/de/itemis/bonn/rating/persistence/mongo/MongoRatingRepository.java | 1a0e40529a66b4405fdb8489b4974d7d889d5f4f | [] | no_license | eilensm/microservices | 16de38e8ba9efeebd4e8b5dcf6bc1abb9b4b7f8a | 35d0b5d6c74d346dffe010eaf6075d964371fbcd | refs/heads/master | 2020-03-19T13:46:53.456993 | 2019-04-04T15:33:59 | 2019-04-04T15:33:59 | 136,594,836 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 275 | java | package de.itemis.bonn.rating.persistence.mongo;
import de.itemis.bonn.rating.persistence.mongo.model.RatingEntity;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface MongoRatingRepository extends MongoRepository<RatingEntity, String> {
}
| [
"m.eilens@gmx.de"
] | m.eilens@gmx.de |
bf23e8997131330b516d09e6fa1d504a7ef221e9 | decef85341214de0514c3e87c17999cdc8c1ca37 | /myapplication/src/androidTest/java/com/seniorzhai/myapplication/ApplicationTest.java | 4ba0f1bec916342129cb6e0d3b475a4d86e3d4d9 | [] | no_license | SeniorZhai/XposedDemo | 14f79fc56f6c205131532569af6276e3409430a9 | f6299f9e9b6118e81f1cd4b4d55bdcd5e599076b | refs/heads/master | 2021-01-10T15:36:55.479538 | 2016-02-19T07:46:40 | 2016-02-19T07:46:40 | 52,070,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 359 | java | package com.seniorzhai.myapplication;
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);
}
} | [
"370985116@qq.com"
] | 370985116@qq.com |
2d2b3e66013fa84f7cea6a931e9498112e21ab37 | c9e3ecbb0055fc9871bca18b78f9605ce02177e7 | /testprojects/src/java/org/pantsbuild/testproject/shadingdep/Dependency.java | 8a2c7a40ac587bad6e70b3cad5f3b80994effb3c | [
"Apache-2.0"
] | permissive | foursquare/pants | 2349434a8f1882adf8136e87772d3c13152898c2 | f0627cfa6ab05fc9a10686a499d1fb1d6ebdb68b | refs/heads/1.7.0+fsX | 2023-07-19T23:51:41.257372 | 2021-02-12T13:11:16 | 2021-02-15T08:28:37 | 24,210,090 | 1 | 1 | Apache-2.0 | 2023-07-11T08:41:59 | 2014-09-19T00:28:00 | Python | UTF-8 | Java | false | false | 357 | java | // Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
package org.pantsbuild.testproject.shadingdep;
/**
* Used to test shading support in tests/python/pants_test/java/jar/test_shader_integration.py
*/
public class Dependency {
public static void main(String[] args) {}
}
| [
"gmalmquist@squareup.com"
] | gmalmquist@squareup.com |
5c92fc8d52d1be67f15cabdca098787da9232dc3 | 0f774102160ee584740bb2403e9b21fe127f0c4d | /src/cs414/a4/rjh2h/test/TicketTest.java | 5fd8c3819104bb06ed53b858e1ccdfba51f3e24a | [] | no_license | ThatsRichApps/cs414a4 | 19e725e9e248b6817f25a816c4606e175ccb8aca | 0b80b841453a1bc74790d715cf55db8deb435beb | refs/heads/master | 2021-01-01T18:54:19.074515 | 2014-10-30T01:00:22 | 2014-10-30T01:00:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,603 | java | package cs414.a4.rjh2h.test;
import static org.junit.Assert.*;
import java.math.BigDecimal;
import java.util.Date;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cs414.a4.rjh2h.Ticket;
import cs414.a4.rjh2h.Vehicle;
public class TicketTest extends Ticket {
private Ticket testTicket1;
private Ticket testTicket2;
@Before
public void setUp() throws Exception {
testTicket1 = new Ticket();
BigDecimal rate = new BigDecimal("2.00");
int ticketNumber = 123;
testTicket2 = new Ticket(ticketNumber, rate);
}
@After
public void tearDown() throws Exception {
}
@Test
public void testTicket1() {
assertEquals("Ticket [999999]", testTicket1.toString());
}
@Test
public void testTicket2() {
assertEquals("Ticket [123]", testTicket2.toString());
}
@Test
public void testGetTicketNumber() {
assertEquals(123, testTicket2.getTicketNumber());
}
@Test
public void testGetTimeIn() {
Date timeNow = new Date();
Ticket testTicket3 = new Ticket();
Date timeIn = testTicket3.getTimeIn();
double timeDifference = timeIn.getTime() - timeNow.getTime();
assertTrue(timeDifference < 100);
}
@Test
public void testGetRate() {
BigDecimal rate = new BigDecimal("2.00");
assertEquals(rate, testTicket2.getRate());
}
@Test
public void testSetRate() {
BigDecimal newRate = new BigDecimal("3.25");
testTicket2.setRate(newRate);
assertEquals(newRate, testTicket2.getRate());
}
@Test
public void testGetVehicle() {
Vehicle vehicle = testTicket2.getVehicle();
assertEquals("Vehicle", vehicle.toString());
}
}
| [
"rich@thatsrichapps.com"
] | rich@thatsrichapps.com |
3a9b7effa98f7528e8516e07e6f4054a0f6af452 | 6ec35840d919900b70cddc4d19a31d6acd8edbac | /src/test/java/com/jaidenmeiden/ereservationspringjava/EReservationSpringJavaApplicationTests.java | f5c2628035f8d9c29f3aeafa948f821d262c4786 | [] | no_license | jaidenmeiden/e-reservation-spring-java | c16613e240cdc6a4ca2ff6a9ebd22d17b56b8c7b | e74b4d62e09e8d2c80ac9380a1cde113da40fc93 | refs/heads/master | 2020-12-09T09:38:42.335578 | 2019-06-02T03:37:17 | 2019-06-02T03:37:17 | 233,265,015 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package com.jaidenmeiden.ereservationspringjava;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class EReservationSpringJavaApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"jailander49@hotmail.com"
] | jailander49@hotmail.com |
8e81effc31ee26048c1338bc612540dd05b9ba78 | 886f4afc7813840e3f7a841742d1a02528e9206e | /src/main/java/com/design/principles/demo4/after/Waterproof.java | 596b1751076c0160bc5a52ead74210b327f11a7a | [] | no_license | JuniorACMer/design-pattern | 007172b1e69f1d7b6635cc1581763aad55237109 | a25e2a72d8b3cab844532b7d669c915b08bd62ea | refs/heads/master | 2023-06-29T17:17:20.499257 | 2021-07-29T03:19:59 | 2021-07-29T03:19:59 | 390,627,441 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package com.design.principles.demo4.after;
/**
* @version v1.0
* @ClassName: Waterproof
* @Description: 防水接口
* @Author: 黑马程序员
*/
public interface Waterproof {
void waterproof();
}
| [
"luzhiqin@inspur.com"
] | luzhiqin@inspur.com |
0cf876842fe04a5f91c26829a77b94459699e427 | f2c183116f8c8eb9e13e7885b6fff369c2810a8c | /src/main/java/ru/alexeylisyutenko/cormen/chapter8/CountingSortInPlace2.java | 28e987a97f4a15d9a8a8198960cd3e85b4f3844f | [] | no_license | alexeylisyutenko/cormen-book | 1837257533a2e8be95ef425fe4b3451c3f565dad | 18de0ecfcb357233248a7f4c6ddd1534c1c27cd9 | refs/heads/master | 2021-06-29T15:33:16.010808 | 2020-11-01T23:29:47 | 2020-11-01T23:29:47 | 170,585,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,270 | java | package ru.alexeylisyutenko.cormen.chapter8;
import java.util.Arrays;
@SuppressWarnings("Duplicates")
public class CountingSortInPlace2 {
/**
* Counting sort implementation that sorts n numbers each is in [0..k] interval.
* <p>This implementation of the counting sort sorts in place.</p>
*
* @param array sorting array
* @param k max number
* @return sorted array
*/
public static void sort(int[] array, int k) {
if (k < 0) {
throw new IllegalArgumentException("Incorrect k value: " + k);
}
if (array.length < 2) {
return;
}
// Initialize counts.
int[] counts = new int[k + 1];
Arrays.fill(counts, 0);
// counts[i] contains number of elements i.
for (int i = 0; i < array.length; i++) {
if (array[i] < 0 || array[i] > k) {
throw new IllegalArgumentException(String.format("Incorrect input array value array[%d] == %d", i, array[i]));
}
counts[array[i]]++;
}
//
int p = 0;
for (int i = 0; i <= k; i++) {
for (int j = 0; j < counts[i]; j++) {
array[p] = i;
p++;
}
}
}
}
| [
"alis@icbcom.ru"
] | alis@icbcom.ru |
5d97e870241d4302c04fca02d9b3ac8e08848c74 | 9a1730db5fe545f5d8967eeb80c3bc5c3bafd492 | /src/Model/ThongKeTonModel.java | fb5ae9af6d5bbb7966e0cbd0449f91c916f613f0 | [] | no_license | NortonBen/QuanLyKho_java | 5d9a2264f65d458e656d0d8ace4d66436bbc7850 | 2ac81a83cb82fa24bc397393e64c8d010dc5fb8d | refs/heads/master | 2021-06-15T17:01:23.882305 | 2017-01-13T09:56:44 | 2017-01-13T09:56:44 | 78,837,111 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,425 | 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 Model;
import Libary.DataManager;
import java.sql.ResultSet;
/**
*
* @author Thanh Huyen
*/
public class ThongKeTonModel extends Model {
@Override
public void init() {
setTable("thongketon");
}
@Override
public ResultSet getData() {
ResultSet data = null;
data = getQuery("select * from "+table);
return data;
}
@Override
public boolean insert(DataManager data) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean update(DataManager data) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean delete(DataManager data) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ResultSet Thongke(String data) {
ResultSet rs = null;
String str = "select * from `thongketon` where DATE_SUB(NgayNhap,MONTH) = '"+data+"'";
rs = getQuery(str);
return rs;
}
}
| [
"ben@joomexp.com"
] | ben@joomexp.com |
ef963b023ed4d13fc901703f062b37e8759ba3ee | 66d485e0a78f06d4df215b809795b6320cbeacc2 | /App7/App7.Android/obj/Debug/81/android/src/mono/MonoPackageManager.java | 6c55953153c436e50dd04a362439c7f36ce2acbf | [] | no_license | ishrakland/Xamarine_FSM | b4b99b03261cbd5b24df09be0bf1b39a94ba8318 | 15eea619b605416af2115ee86dddb870436c83c1 | refs/heads/master | 2020-06-03T22:38:46.335400 | 2019-05-21T13:42:57 | 2019-05-21T13:42:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,588 | java | package mono;
import java.io.*;
import java.lang.String;
import java.util.Locale;
import java.util.HashSet;
import java.util.zip.*;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.res.AssetManager;
import android.util.Log;
import mono.android.Runtime;
public class MonoPackageManager {
static Object lock = new Object ();
static boolean initialized;
static android.content.Context Context;
public static void LoadApplication (Context context, ApplicationInfo runtimePackage, String[] apks)
{
synchronized (lock) {
if (context instanceof android.app.Application) {
Context = context;
}
if (!initialized) {
android.content.IntentFilter timezoneChangedFilter = new android.content.IntentFilter (
android.content.Intent.ACTION_TIMEZONE_CHANGED
);
context.registerReceiver (new mono.android.app.NotifyTimeZoneChanges (), timezoneChangedFilter);
System.loadLibrary("monodroid");
Locale locale = Locale.getDefault ();
String language = locale.getLanguage () + "-" + locale.getCountry ();
String filesDir = context.getFilesDir ().getAbsolutePath ();
String cacheDir = context.getCacheDir ().getAbsolutePath ();
String dataDir = getNativeLibraryPath (context);
ClassLoader loader = context.getClassLoader ();
java.io.File external0 = android.os.Environment.getExternalStorageDirectory ();
String externalDir = new java.io.File (
external0,
"Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath ();
String externalLegacyDir = new java.io.File (
external0,
"../legacy/Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath ();
Runtime.init (
language,
apks,
getNativeLibraryPath (runtimePackage),
new String[]{
filesDir,
cacheDir,
dataDir,
},
loader,
new String[] {
externalDir,
externalLegacyDir
},
MonoPackageManager_Resources.Assemblies,
context.getPackageName ());
mono.android.app.ApplicationRegistration.registerApplications ();
initialized = true;
}
}
}
public static void setContext (Context context)
{
// Ignore; vestigial
}
static String getNativeLibraryPath (Context context)
{
return getNativeLibraryPath (context.getApplicationInfo ());
}
static String getNativeLibraryPath (ApplicationInfo ainfo)
{
if (android.os.Build.VERSION.SDK_INT >= 9)
return ainfo.nativeLibraryDir;
return ainfo.dataDir + "/lib";
}
public static String[] getAssemblies ()
{
return MonoPackageManager_Resources.Assemblies;
}
public static String[] getDependencies ()
{
return MonoPackageManager_Resources.Dependencies;
}
public static String getApiPackageName ()
{
return MonoPackageManager_Resources.ApiPackageName;
}
}
class MonoPackageManager_Resources {
public static final String[] Assemblies = new String[]{
/* We need to ensure that "App7.Android.dll" comes first in this list. */
"App7.Android.dll",
"Acr.UserDialogs.dll",
"AndHUD.dll",
"App7.dll",
"Com.OneSignal.Abstractions.dll",
"Com.OneSignal.dll",
"FormsViewGroup.dll",
"Microsoft.AppCenter.Android.Bindings.dll",
"Microsoft.AppCenter.dll",
"Microsoft.AppCenter.Push.Android.Bindings.dll",
"Microsoft.AppCenter.Push.dll",
"Newtonsoft.Json.dll",
"OneSignal.Android.Binding.dll",
"Plugin.Connectivity.Abstractions.dll",
"Plugin.Connectivity.dll",
"Plugin.CurrentActivity.dll",
"Plugin.Geolocator.dll",
"Plugin.Permissions.dll",
"Plugin.Settings.Abstractions.dll",
"Plugin.Settings.dll",
"Plugin.Toast.Abstractions.dll",
"Plugin.Toast.dll",
"SQLite-net.dll",
"SQLiteNetExtensions.dll",
"SQLitePCLRaw.batteries_green.dll",
"SQLitePCLRaw.batteries_v2.dll",
"SQLitePCLRaw.core.dll",
"SQLitePCLRaw.lib.e_sqlite3.dll",
"SQLitePCLRaw.provider.e_sqlite3.dll",
"System.Net.Http.Extensions.dll",
"System.Net.Http.Primitives.dll",
"Xamarin.Android.Arch.Core.Common.dll",
"Xamarin.Android.Arch.Lifecycle.Common.dll",
"Xamarin.Android.Arch.Lifecycle.Runtime.dll",
"Xamarin.Android.Support.Animated.Vector.Drawable.dll",
"Xamarin.Android.Support.Annotations.dll",
"Xamarin.Android.Support.Compat.dll",
"Xamarin.Android.Support.Core.UI.dll",
"Xamarin.Android.Support.Core.Utils.dll",
"Xamarin.Android.Support.CustomTabs.dll",
"Xamarin.Android.Support.Design.dll",
"Xamarin.Android.Support.Fragment.dll",
"Xamarin.Android.Support.Media.Compat.dll",
"Xamarin.Android.Support.Transition.dll",
"Xamarin.Android.Support.v4.dll",
"Xamarin.Android.Support.v7.AppCompat.dll",
"Xamarin.Android.Support.v7.CardView.dll",
"Xamarin.Android.Support.v7.MediaRouter.dll",
"Xamarin.Android.Support.v7.Palette.dll",
"Xamarin.Android.Support.v7.RecyclerView.dll",
"Xamarin.Android.Support.Vector.Drawable.dll",
"Xamarin.Essentials.dll",
"Xamarin.Firebase.Common.dll",
"Xamarin.Firebase.Iid.dll",
"Xamarin.Firebase.Messaging.dll",
"Xamarin.Forms.Core.dll",
"Xamarin.Forms.Platform.Android.dll",
"Xamarin.Forms.Platform.dll",
"Xamarin.Forms.Xaml.dll",
"Xamarin.GooglePlayServices.Base.dll",
"Xamarin.GooglePlayServices.Basement.dll",
"Xamarin.GooglePlayServices.Gcm.dll",
"Xamarin.GooglePlayServices.Iid.dll",
"Xamarin.GooglePlayServices.Tasks.dll",
};
public static final String[] Dependencies = new String[]{
};
public static final String ApiPackageName = "Mono.Android.Platform.ApiLevel_27";
}
| [
"ayman.sarhan@mag-consulting.net"
] | ayman.sarhan@mag-consulting.net |
602af5e9ba08c6b4eb3e007cb54ffbbd134c181c | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/java-design-patterns/learning/1796/WizardDaoImplTest.java | fd165c7c495ad60a571314847b9ac1c41205f620 | [] | 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 | 2,040 | java | /**
* The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.servicelayer.wizard;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/28/15 - 11:46 PM
*
* @author Jeroen Meulemeester
*/
public class WizardDaoImplTest extends BaseDaoTest<Wizard,
WizardDaoImpl> {
public WizardDaoImplTest() {
super(Wizard::new, new WizardDaoImpl());
}
@Test
public void testFindByName() {
final WizardDaoImpl dao = getDao();
final List<Wizard> allWizards = dao.findAll();
for (final Wizard spell : allWizards) {
final Wizard byName = dao.findByName(spell.getName());
assertNotNull(byName);
assertEquals(spell.getId(), byName.getId());
assertEquals(spell.getName(), byName.getName());
}
}
}
| [
"bloriot97@gmail.com"
] | bloriot97@gmail.com |
a03f293346c767764f1add760b928d99e6484e83 | 0daf722feb3f801895e028e6d3389c91339c2d6d | /GingaJEmulator/lib/jmf/javax/media/PackageManager.java | 7ade792864c9d5703f5756d103fac8af0a1c5723 | [] | no_license | manoelnetom/IDTVSimulator | 1a781883b7456c1462e1eb5282f3019ef3ef934a | 3f6c31c01ef10ed87f06b9e1e88f853cfedcbcd1 | refs/heads/master | 2021-01-10T20:56:13.096038 | 2014-09-16T17:52:03 | 2014-09-16T17:52:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 480 | java | package javax.media;
public class PackageManager extends Object {
public static java.util.Vector getProtocolPrefixList() {
return null;
}
public static void setProtocolPrefixList(java.util.Vector list) {}
public static void commitProtocolPrefixList() {}
public static java.util.Vector getContentPrefixList() {
return null;
}
public static void setContentPrefixList(java.util.Vector list) {}
public static void commitContentPrefixList() {}
}
| [
"MANOELNETOM@GMAIL.COM"
] | MANOELNETOM@GMAIL.COM |
48c6694341b55594a7b6063235d0eb492afc36ea | 7e1511cdceeec0c0aad2b9b916431fc39bc71d9b | /flakiness-predicter/input_data/original_tests/Alluxio-alluxio/flakyMethods/tachyon.command.TFsShellTest-mkdirComplexPathTest.java | ff715eb668523126ad5958aadceae0f613937043 | [
"BSD-3-Clause"
] | permissive | Taher-Ghaleb/FlakeFlagger | 6fd7c95d2710632fd093346ce787fd70923a1435 | 45f3d4bc5b790a80daeb4d28ec84f5e46433e060 | refs/heads/main | 2023-07-14T16:57:24.507743 | 2021-08-26T14:50:16 | 2021-08-26T14:50:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 425 | java | @Test public void mkdirComplexPathTest() throws IOException {
mFsShell.mkdir(new String[]{"mkdir","/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"});
TachyonFile tFile=mTfs.getFile("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File");
Assert.assertNotNull(tFile);
Assert.assertEquals(getCommandOutput(new String[]{"mkdir","/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"}),mOutput.toString());
Assert.assertTrue(tFile.isDirectory());
}
| [
"aalsha2@masonlive.gmu.edu"
] | aalsha2@masonlive.gmu.edu |
3935891549fc1bdb689e13c7a70303598cc60100 | bf6a19e5a8d208b1c850a6ae13bea99a3ccbce5a | /src/lession5/Activity_51_Rectangle/Rectangle.java | 43fd46dc81eda3f7617737f4beebeb9935ac8848 | [] | no_license | nqq1405/javacore-6-10month-2020 | a2cc0cafda69e7f62538030cfa70123620483bf0 | 58c9958695722afa1a579447ca33515731592782 | refs/heads/master | 2022-11-22T10:25:56.326787 | 2020-07-29T10:00:31 | 2020-07-29T10:00:31 | 271,294,918 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,280 | java | package lession5.Activity_51_Rectangle;
import java.util.Scanner;
public class Rectangle {
private float width;
private float height;
public Rectangle() {
}
public Rectangle(int width, int height) {
this.width = width;
this.height = height;
}
public float getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public float getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
@Override
public String toString() {
return "Rectangle{" +
"width=" + width +
", height=" + height +
'}';
}
public float chuvi(float width,float height ){
return (width + height)/2;
}
public float dientich(float width,float height ){
return width*height;
}
public void nhap(){
Scanner sc = new Scanner(System.in);
System.out.println("Nhap width: "); width = sc.nextFloat();
System.out.println("Nhap height: "); height = sc.nextFloat();
}
public boolean kt_hinh_vuong(Rectangle re){
if(re.width == re.height){
return true;
}
return false;
}
}
| [
"quang20hn@gmail.com"
] | quang20hn@gmail.com |
3e16300cabf498c367a1658bba8a1cdd85470f68 | 2b3b3e32586b08c267098e4c7395f7bf872e3087 | /Technofusion/src/PercentageCalculator.java | 815ebb314410ed2263914f978fc608de47456fb1 | [] | no_license | aylin-asad/TechnoFusionInterview | f2dff4d09e6b71015de8444708bd1e256b30fc53 | 0c6beb42e8f83a79aa56300ec5c40919cbf21288 | refs/heads/main | 2023-03-13T21:07:28.230496 | 2021-03-09T11:24:20 | 2021-03-09T11:24:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,420 | java | import java.util.Scanner;
public class PercentageCalculator {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Please input a string: ");
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
int total = input.length();
int numOfUpper = 0;
int numOfLower = 0;
int numOfDigits = 0;
int numOfOthers = 0;
for(int i = 0; i < total; i++) {
if(Character.isUpperCase(input.charAt(i))) {
numOfUpper++;
}
else if(Character.isLowerCase(input.charAt(i))) {
numOfLower++;
}
else if(Character.isDigit(input.charAt(i))) {
numOfDigits++;
}
else {
numOfOthers++;
}
}
System.out.println("Number of uppercase letters is " + numOfUpper + ". So percentage is " + Math.round( (((numOfUpper*1.0)/(total*1.0))*100)* 100.0) / 100.0 + "%");
System.out.println("Number of lowercase letters is " + numOfLower + ". So percentage is " + Math.round( (((numOfLower*1.0)/(total*1.0))*100)* 100.0) / 100.0 + "%");
System.out.println("Number of digits is " + numOfDigits + ". So percentage is " + Math.round( (((numOfDigits*1.0)/(total*1.0))*100)* 100.0) / 100.0 + "%");
System.out.println("Number of other characters is " + numOfOthers + ". So percentage is " + Math.round( (((numOfOthers*1.0)/(total*1.0))*100)* 100.0) / 100.0 + "%");
}
}
| [
"noreply@github.com"
] | aylin-asad.noreply@github.com |
888f6b4c5455158c0744e9cd2783daa5841dfa09 | 90069e611d689c0a0763b8ea677e78ec33d684d6 | /app/src/main/java/poliv/jr/com/login/LoginRepositoryImpl.java | 2f281c90b4c23058bb37876858ede90f4635b8b0 | [] | no_license | spogy10/ChatApp | 7e900031dbfd4db23c8e29d666fd12c16ca5e5c8 | 37f4d35873648371f305b211efe98044ecc10f57 | refs/heads/master | 2020-03-19T11:04:26.698740 | 2018-07-03T07:49:41 | 2018-07-03T07:49:41 | 136,427,456 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,150 | java | package poliv.jr.com.login;
import android.support.annotation.NonNull;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.ValueEventListener;
import poliv.jr.com.contactlist.entities.User;
import poliv.jr.com.domain.FirebaseHelper;
import poliv.jr.com.lib.EventBus;
import poliv.jr.com.lib.GreenRobotEventBus;
import poliv.jr.com.login.events.LoginEvent;
class LoginRepositoryImpl implements LoginRepository {
private FirebaseHelper helper;
private DatabaseReference dataReference;
private DatabaseReference myUserReference;
public LoginRepositoryImpl(){
helper = FirebaseHelper.getInstance();
dataReference = helper.getDataReference();
myUserReference = helper.getMyUserReference();
}
@Override
public void signUp(final String email, final String password) {
FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password)
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
postEvent(LoginEvent.onSignUpSuccess);
signIn(email, password);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
postEvent(LoginEvent.onSignUpError, e.getMessage());
}
});
}
@Override
public void signIn(String email, String password) {
try{
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signInWithEmailAndPassword(email, password)
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
myUserReference = helper.getMyUserReference();
myUserReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
initSignIn(dataSnapshot);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
postEvent(LoginEvent.onSignInError, databaseError.getMessage());
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
postEvent(LoginEvent.onSignInError, e.getMessage());
}
});
}catch (Exception e) {
postEvent(LoginEvent.onSignInError, e.getMessage());
}
}
@Override
public void checkAlreadyAuthenticated() {
if(FirebaseAuth.getInstance().getCurrentUser() != null){
myUserReference = helper.getMyUserReference();
myUserReference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
initSignIn(dataSnapshot);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
postEvent(LoginEvent.onSignInError, databaseError.getMessage());
}
});
}else{
postEvent(LoginEvent.onFailedToRecoverSession);
}
}
private void registerNewUser() {
String email = helper.getAuthUserEmail();
if(email != null){
User currentUser = new User(email, true, null);
myUserReference.setValue(currentUser);
}
}
private void initSignIn(DataSnapshot dataSnapshot) {
User currentUser = dataSnapshot.getValue(User.class);
if(currentUser == null)
registerNewUser();
helper.changeUserConnectionsStatus(User.ONLINE);
postEvent(LoginEvent.onSignInSuccess);
}
private void postEvent(int type) {
postEvent(type, null);
}
private void postEvent(int type, String errorMessage) {
LoginEvent loginEvent = new LoginEvent();
loginEvent.setEventType(type);
if(errorMessage != null){
loginEvent.setErrorMessage(errorMessage);
}
EventBus eventBus = GreenRobotEventBus.getInstance();
eventBus.post(loginEvent);
}
}
| [
"poliverjr@hotmail.com"
] | poliverjr@hotmail.com |
d541cb861f8c41851d208aea622601c5b8f96032 | db6a378788cf018b5fe90f52a75a280575d3d314 | /app/src/test/java/com/me/enpopupwindow/ExampleUnitTest.java | fdbb958924200c841b74bd8d22c7e83ed850247e | [] | no_license | AWarmHug/EnPopupWindow | 927304a1aa72394badb5303b6c73077902449839 | 25ed57fd40cf7e6a7063f737ab3c8cc075ef0da5 | refs/heads/master | 2021-01-20T07:28:29.789541 | 2017-05-23T04:54:40 | 2017-05-23T04:54:40 | 90,002,084 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 398 | java | package com.me.enpopupwindow;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"51hs_android@promote.cache-dns.local"
] | 51hs_android@promote.cache-dns.local |
d04aef2a25b4af231c2d748e27eb4030b6d8ce69 | 4340330494a1cdc8610884d80da0f1956567603c | /java/leet/Pro448.java | 65b28c14a43e35caba998ab76c7a568b55d0be1f | [] | no_license | yahaa/algorithm | ca7fe2273418d75dc8230b6f0d680555c3cb1127 | 0beed2fe90e6d0ae5656f41608878c99994408d1 | refs/heads/master | 2021-10-12T00:50:48.228988 | 2019-01-31T07:07:18 | 2019-01-31T07:07:18 | 78,183,013 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 527 | java | import java.util.*;
public class Pro448 {
public static void main(String[]args) {
int []a = {1, 5, 3, 4, 6};
System.out.println(findDisappearedNumbers(a));
}
public static List<Integer> findDisappearedNumbers(int[] nums) {
List<Integer>res = new ArrayList<Integer>();
if (nums == null || nums.length == 0)return res;
Arrays.sort(nums);
int minum = 1;
int maxnum = nums.length;
for (int i = minum; i <= maxnum; i++) {
int t = Arrays.binarySearch(nums, i);
if (t < 0)res.add(i);
}
return res;
}
} | [
"1477765176@qq.com"
] | 1477765176@qq.com |
5608717cd23d8c1dd908591cdd650e50b49e2fb2 | 6918a485af394ce31aef60401c72e548c33f6a7b | /languages/DataDictionaryNew/source_gen/DataDictionary/editor/SemanticDomainDefinition_Editor.java | 261c9dac115f43f467db547ed0e4611d1f31d293 | [] | no_license | kiso3/DataDictionary | 738049b5f7147bbc2f8d1bc89962a593069b304c | 3b4a966393740d9efa00e300c5a9c3358c4acd73 | refs/heads/master | 2021-01-11T03:12:08.471534 | 2017-02-07T18:43:43 | 2017-02-07T18:43:43 | 66,709,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,358 | java | package DataDictionary.editor;
/*Generated by MPS */
import jetbrains.mps.nodeEditor.DefaultNodeEditor;
import jetbrains.mps.openapi.editor.cells.EditorCell;
import jetbrains.mps.openapi.editor.EditorContext;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.nodeEditor.cells.EditorCell_Collection;
import jetbrains.mps.nodeEditor.cells.EditorCell_Constant;
import jetbrains.mps.openapi.editor.style.Style;
import jetbrains.mps.editor.runtime.style.StyleImpl;
import jetbrains.mps.editor.runtime.style.StyleAttributes;
import jetbrains.mps.openapi.editor.style.StyleRegistry;
import jetbrains.mps.nodeEditor.MPSColors;
import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole;
import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider;
import jetbrains.mps.nodeEditor.EditorManager;
import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import jetbrains.mps.openapi.editor.cells.DefaultSubstituteInfo;
import jetbrains.mps.nodeEditor.cellMenu.OldNewCompositeSubstituteInfo;
import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfo;
import jetbrains.mps.nodeEditor.cellMenu.DefaultChildSubstituteInfo;
import jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler;
import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical;
import jetbrains.mps.lang.editor.cellProviders.RefNodeListHandler;
import jetbrains.mps.smodel.action.NodeFactoryManager;
import jetbrains.mps.openapi.editor.cells.CellActionType;
import jetbrains.mps.nodeEditor.cellActions.CellAction_DeleteNode;
public class SemanticDomainDefinition_Editor extends DefaultNodeEditor {
public EditorCell createEditorCell(EditorContext editorContext, SNode node) {
return this.createCollection_7hnofb_a(editorContext, node);
}
private EditorCell createCollection_7hnofb_a(EditorContext editorContext, SNode node) {
EditorCell_Collection editorCell = EditorCell_Collection.createIndent2(editorContext, node);
editorCell.setCellId("Collection_7hnofb_a");
editorCell.setBig(true);
editorCell.addEditorCell(this.createConstant_7hnofb_a0(editorContext, node));
editorCell.addEditorCell(this.createProperty_7hnofb_b0(editorContext, node));
editorCell.addEditorCell(this.createConstant_7hnofb_c0(editorContext, node));
editorCell.addEditorCell(this.createConstant_7hnofb_d0(editorContext, node));
editorCell.addEditorCell(this.createRefNode_7hnofb_e0(editorContext, node));
editorCell.addEditorCell(this.createConstant_7hnofb_f0(editorContext, node));
editorCell.addEditorCell(this.createConstant_7hnofb_g0(editorContext, node));
editorCell.addEditorCell(this.createRefNodeList_7hnofb_h0(editorContext, node));
return editorCell;
}
private EditorCell createConstant_7hnofb_a0(EditorContext editorContext, SNode node) {
EditorCell_Constant editorCell = new EditorCell_Constant(editorContext, node, "name:");
editorCell.setCellId("Constant_7hnofb_a0");
Style style = new StyleImpl();
style.set(StyleAttributes.TEXT_COLOR, 0, StyleRegistry.getInstance().getSimpleColor(MPSColors.DARK_BLUE));
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createProperty_7hnofb_b0(EditorContext editorContext, SNode node) {
CellProviderWithRole provider = new PropertyCellProvider(node, editorContext);
provider.setRole("name");
provider.setNoTargetText("<no name>");
EditorCell editorCell;
editorCell = provider.createEditorCell(editorContext);
editorCell.setCellId("property_name");
editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo());
SNode attributeConcept = provider.getRoleAttribute();
Class attributeKind = provider.getRoleAttributeClass();
if (attributeConcept != null) {
EditorManager manager = EditorManager.getInstanceFromContext(editorContext);
return manager.createNodeRoleAttributeCell(attributeConcept, attributeKind, editorCell);
} else
return editorCell;
}
private EditorCell createConstant_7hnofb_c0(EditorContext editorContext, SNode node) {
EditorCell_Constant editorCell = new EditorCell_Constant(editorContext, node, ";");
editorCell.setCellId("Constant_7hnofb_c0");
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_7hnofb_d0(EditorContext editorContext, SNode node) {
EditorCell_Constant editorCell = new EditorCell_Constant(editorContext, node, "type:");
editorCell.setCellId("Constant_7hnofb_d0");
Style style = new StyleImpl();
style.set(StyleAttributes.TEXT_COLOR, 0, StyleRegistry.getInstance().getSimpleColor(MPSColors.DARK_BLUE));
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createRefNode_7hnofb_e0(EditorContext editorContext, SNode node) {
SingleRoleCellProvider provider = new SemanticDomainDefinition_Editor.typeSingleRoleHandler_7hnofb_e0(node, MetaAdapterFactory.getContainmentLink(0xe00ab26049b415aL, 0x83b6dc09f3615dc4L, 0x4709666cc5e01982L, 0x4709666cc5e01983L, "type"), editorContext);
return provider.createCell();
}
private class typeSingleRoleHandler_7hnofb_e0 extends SingleRoleCellProvider {
public typeSingleRoleHandler_7hnofb_e0(SNode ownerNode, SContainmentLink containmentLink, EditorContext context) {
super(ownerNode, containmentLink, context);
}
protected EditorCell createChildCell(SNode child) {
EditorCell editorCell = super.createChildCell(child);
installCellInfo(child, editorCell);
return editorCell;
}
private void installCellInfo(SNode child, EditorCell editorCell) {
if (editorCell.getSubstituteInfo() == null || editorCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) {
editorCell.setSubstituteInfo(new OldNewCompositeSubstituteInfo(myEditorContext, new SChildSubstituteInfo(editorCell, myOwnerNode, MetaAdapterFactory.getContainmentLink(0xe00ab26049b415aL, 0x83b6dc09f3615dc4L, 0x4709666cc5e01982L, 0x4709666cc5e01983L, "type"), child), new DefaultChildSubstituteInfo(myOwnerNode, myContainmentLink.getDeclarationNode(), myEditorContext)));
}
if (editorCell.getRole() == null) {
editorCell.setRole("type");
}
}
@Override
protected EditorCell createEmptyCell() {
EditorCell editorCell = super.createEmptyCell();
editorCell.setCellId("empty_type");
installCellInfo(null, editorCell);
return editorCell;
}
protected String getNoTargetText() {
return "<no type>";
}
}
private EditorCell createConstant_7hnofb_f0(EditorContext editorContext, SNode node) {
EditorCell_Constant editorCell = new EditorCell_Constant(editorContext, node, ";");
editorCell.setCellId("Constant_7hnofb_f0");
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_7hnofb_g0(EditorContext editorContext, SNode node) {
EditorCell_Constant editorCell = new EditorCell_Constant(editorContext, node, "constraints:");
editorCell.setCellId("Constant_7hnofb_g0");
Style style = new StyleImpl();
style.set(StyleAttributes.TEXT_COLOR, 0, StyleRegistry.getInstance().getSimpleColor(MPSColors.red));
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createRefNodeList_7hnofb_h0(EditorContext editorContext, SNode node) {
AbstractCellListHandler handler = new SemanticDomainDefinition_Editor.constraintsListHandler_7hnofb_h0(node, "constraints", editorContext);
EditorCell_Collection editorCell = handler.createCells(editorContext, new CellLayout_Vertical(), false);
editorCell.setCellId("refNodeList_constraints");
Style style = new StyleImpl();
style.set(StyleAttributes.SELECTABLE, 0, false);
editorCell.getStyle().putAll(style);
editorCell.setRole(handler.getElementRole());
return editorCell;
}
private static class constraintsListHandler_7hnofb_h0 extends RefNodeListHandler {
public constraintsListHandler_7hnofb_h0(SNode ownerNode, String childRole, EditorContext context) {
super(ownerNode, childRole, context, false);
}
public SNode createNodeToInsert(EditorContext editorContext) {
SNode listOwner = super.getOwner();
return NodeFactoryManager.createNode(listOwner, editorContext, super.getElementRole());
}
public EditorCell createNodeCell(EditorContext editorContext, SNode elementNode) {
EditorCell elementCell = super.createNodeCell(editorContext, elementNode);
this.installElementCellActions(this.getOwner(), elementNode, elementCell, editorContext);
return elementCell;
}
public EditorCell createEmptyCell(EditorContext editorContext) {
EditorCell emptyCell = null;
emptyCell = super.createEmptyCell(editorContext);
this.installElementCellActions(super.getOwner(), null, emptyCell, editorContext);
return emptyCell;
}
public void installElementCellActions(SNode listOwner, SNode elementNode, EditorCell elementCell, EditorContext editorContext) {
if (elementCell.getUserObject(AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET) == null) {
elementCell.putUserObject(AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET, AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET);
if (elementNode != null) {
elementCell.setAction(CellActionType.DELETE, new CellAction_DeleteNode(elementNode, CellAction_DeleteNode.DeleteDirection.FORWARD));
elementCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteNode(elementNode, CellAction_DeleteNode.DeleteDirection.BACKWARD));
}
if (elementCell.getSubstituteInfo() == null || elementCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) {
elementCell.setSubstituteInfo(new OldNewCompositeSubstituteInfo(myEditorContext, new SChildSubstituteInfo(elementCell, myOwnerNode, MetaAdapterFactory.getContainmentLink(0xe00ab26049b415aL, 0x83b6dc09f3615dc4L, 0x4709666cc5e01982L, 0x4709666cc5e01986L, "constraints"), elementNode), new DefaultChildSubstituteInfo(myOwnerNode, elementNode, super.getLinkDeclaration(), myEditorContext)));
}
}
}
}
}
| [
"kiso33@gmail.com"
] | kiso33@gmail.com |
53f086a2f82bc12084ff5ca59074b563f8683924 | d78112dd004f566be1845bb83fb369e109e39369 | /src/com/blogspot/the3cube/beefree/logic/CommandType.java | 2a8da3f66d0cb805b203ac9f8b0afcf5c7203c24 | [] | no_license | lmk19922000/BeeFree | 2cfd682057ae50f39b8248c70656207258a3706b | 1d29d65b7543e7ce3c2a42d0508dc462557bb820 | refs/heads/master | 2020-03-26T01:03:55.843291 | 2013-12-12T05:59:25 | 2013-12-12T05:59:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | java | package com.blogspot.the3cube.beefree.logic;
/**
* The various command that BeeFree support.<br>
*
* @author The3Cube
* @since v0.1
* @version v0.1
*
*/
public enum CommandType {
// basic feature
ADD, DELETE, CLEAR, EDIT, DISPLAY, EXIT,
// unique feature
BLOCKOUT, COMPLETE,
// advance feature
UNDO, HELP, EXPORT,
// invalid
INVALID
}
| [
"lmk19922000@gmail.com"
] | lmk19922000@gmail.com |
3eb70cfa0707bfef93249b8fb7db1adbbfc5b414 | caa53f59abf41b702270707646a7420452cf186a | /Young'sDiary(8.30)/app/src/main/java/sqlDatabase/EventSQLiteOpenHelper.java | b10aa6e1da8619ab137b7f062ec6d5cde6c1026a | [] | no_license | Crescent9723/Young-s-Diary | a8fb78e0b93824a869c84cda363ce9ffac3aa486 | 342f9b282e2e458eaf5beb848f4788412b4ddd2d | refs/heads/master | 2021-01-10T18:19:40.018381 | 2015-11-17T08:32:38 | 2015-11-17T08:32:38 | 49,885,634 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,097 | java | package sqlDatabase;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Justin on 8/17/2015.
*/
public class EventSQLiteOpenHelper extends SQLiteOpenHelper {
public EventSQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
String query = "create table event (eventID INTEGER primary key autoincrement,"
+ " userID TEXT, title TEXT, startDate TEXT, endDate TEXT, startTime TEXT, endTime TEXT, " +
"description TEXT, tag TEXT, icon INTEGER, repeatType TEXT, duration INTEGER, weekdayList TEXT," +
"dayList TEXT, month INTEGER, day INTEGER)";
db.execSQL(query);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String query = "drop table if exists event";
db.execSQL(query);
onCreate(db);
}
} | [
"yychoi@sfu.ca"
] | yychoi@sfu.ca |
fb0de6fbe08652d0383f7d665398b450b7e28cf4 | da9770eb67576df8b0507f30b1bc1cf42c04949d | /app/src/main/java/com/bk/binakarya/binakarya/SplashScreen.java | 4a304198283c55394eee812288b7c4bbbca86882 | [] | no_license | FuadMZ/binakarir | afb3ed9411e717aba476546f41d6d3bc9c63fe98 | f61d40c6582c00ac5a8e84623126f9db7e05e33d | refs/heads/master | 2020-07-05T01:30:54.764625 | 2019-08-15T05:03:49 | 2019-08-15T05:03:49 | 202,483,432 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 348 | java | package com.bk.binakarya.binakarya;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
}
}
| [
"zakiyyulfuad@gmail.com"
] | zakiyyulfuad@gmail.com |
e245dcd224d9db5bb82864e9cf44268f309ee5a0 | 39fb274168d5ee5c5e482364cee935b09176ce95 | /src/wordclash/Audio.java | 132d72c475676b0d43565f56fa016c54a25787ec | [] | no_license | plab0n/WordClash | ed791191c9bd2c0d1b4d4c5c23acc774c003ab82 | a51b7697d4c8fc9fe7d9359bd0ae3fc6a9b0949d | refs/heads/master | 2020-03-11T21:13:50.352126 | 2018-04-19T19:16:27 | 2018-04-19T19:16:27 | 97,756,082 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 704 | java |
package wordclash;
import sun.audio.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Audio extends JFrame{
public JFrame fr;
public JButton btn;
public Audio(){
AudioPlayer bgp = AudioPlayer.player;
AudioStream bgm;
AudioData MD;
ContinuousAudioDataStream loop = null;
try{
bgm = new AudioStream(new FileInputStream("Game of Thrones Theme.wav"));
MD = bgm.getData();
loop = new ContinuousAudioDataStream(MD);
}
catch(IOException ex){
}
bgp.start(loop);
}
}
| [
"noreply@github.com"
] | plab0n.noreply@github.com |
f6954d83a2e7dab1fce2786ae1175ae71d4c32ab | ca7707ce559b195f2c5d66cd6bdd027d59ef59b7 | /POM-MVC/src/connect/ConnectLogin.java | b0e3104af2682010c2836fd13a5003d81f9fcbf1 | [] | no_license | NguyenHoangTrong/Selenium-Webdriver- | 14bec59eb0260bf662d03cd6e969aaed1560e3e4 | 36b4b13a71de71efda0cae7f04358644f35eed42 | refs/heads/master | 2020-06-12T08:12:35.726247 | 2019-06-30T02:24:30 | 2019-06-30T02:24:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 677 | java | package connect;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import model.HomePageM;
public class ConnectLogin {
public static WebDriver driver;
public void connect() throws InterruptedException {
HomePageM homepage;
System.setProperty("webdriver.chrome.driver","F:\\download\\selenium\\chromedriver_win32\\chromedriver74.exe");
driver = new ChromeDriver();
String url = "http://demo.guru99.com/V4/";
driver.navigate().to(url);
driver.manage().window().maximize();
homepage = new HomePageM(driver);
homepage.Login("mngr201222", "20Ae32%200");
Thread.sleep(5000);
}
public void quit() {
driver.quit();
}
}
| [
"49750987+trongandde@users.noreply.github.com"
] | 49750987+trongandde@users.noreply.github.com |
b9d304727e6dde70d6cef07321e46ef2273a3f93 | cb8c8e9643e17f282e14874304ed744dfcb9e9f6 | /api-sql-basics/src/main/java/com.kuduscreencast.sample/SimpleExample.java | 45f8cd65621c0f3dc48ce25f336c217efab2c6b4 | [] | no_license | HotmaPasaribu/kuduscreencast | 5472a1f756f42c03f260b6ca02ba54012e20395e | 1e82744cb7b5a842aa7590433348fad2b13fcd0c | refs/heads/master | 2021-06-15T09:46:08.041210 | 2017-03-11T21:54:37 | 2017-03-11T21:54:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,636 | java | package com.kuduscreencast.sample;
import org.apache.kudu.ColumnSchema;
import org.apache.kudu.Schema;
import org.apache.kudu.Type;
import org.apache.kudu.client.*;
import org.apache.kudu.client.shaded.com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
/**
* Created by bosshart on 11/11/16.
*/
public class SimpleExample {
private static final String KUDU_MASTER = System.getProperty(
"kuduMaster", "quickstart.cloudera");
public static void main(String[] args) {
String tableName = "movietable";
KuduClient client = new KuduClient.KuduClientBuilder(KUDU_MASTER).build();
try {
// delete the table if it already exists
if(client.tableExists(tableName)) {
client.deleteTable(tableName);
}
//Create our table
List<ColumnSchema> columns = new ArrayList(3);
columns.add(new ColumnSchema.ColumnSchemaBuilder("movieid", Type.INT32)
.key(true)
.build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("moviename", Type.STRING)
.build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("rating", Type.INT32)
.build());
Schema schema = new Schema(columns);
client.createTable(tableName, schema,
new CreateTableOptions().addHashPartitions(ImmutableList.of("movieid"), 3));
KuduTable table = client.openTable(tableName);
KuduSession session = client.newSession();
// Insert some data
List<String> movies = ImmutableList.of("Ghost", "Tombstone", "Star Wars");
for (int i = 0; i < movies.size(); i++) {
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
row.addInt(0, i);
row.addString(1, movies.get(i));
row.addInt("rating", 5) ;
session.apply(insert);
System.out.println("Inserted new row!");
}
// Read some data
List<String> projectionColumns = ImmutableList.of("moviename","rating");
KuduScanner scanner = client.newScannerBuilder(table)
.setProjectedColumnNames(projectionColumns)
.build();
while(scanner.hasMoreRows()) {
for(RowResult movieResult: scanner.nextRows()) {
System.out.println("The rating for " + movieResult.getString(0) + " is " + movieResult.getInt(1));
}
}
scanner.close();
session.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
client.close();
} catch(KuduException kuduE) {
kuduE.printStackTrace();
}
}
}
}
| [
"bosshart@cloudera.com"
] | bosshart@cloudera.com |
63d7dc0578130cea574595745db83026663e0bff | 62c76a1df341e9d79f3c81dd71c94113b1f9fc14 | /WEBFDMSWeb/src/fdms/ui/struts/action/.svn/text-base/ShowCaseStatusCheckList.java.svn-base | dc52b1e5972873a37068e767f4e9fdf1e424c1f4 | [] | no_license | mahendrakawde/FDMS-Source-Code | 3b6c0b5b463180d17e649c44a3a03063fa9c9e28 | ce27537b661fca0446f57da40c016e099d82cb34 | refs/heads/master | 2021-01-10T07:48:40.811038 | 2015-10-30T07:57:28 | 2015-10-30T07:57:28 | 45,235,253 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,294 | package fdms.ui.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.aldorsolutions.webfdms.beans.DbLocaleConfig;
import com.aldorsolutions.webfdms.beans.DbLocaleConfigType;
import com.aldorsolutions.webfdms.beans.DbUserSession;
import com.aldorsolutions.webfdms.beans.DbVitalsSchedule;
import com.aldorsolutions.webfdms.beans.FdmsDb;
import com.aldorsolutions.webfdms.database.DatabaseTransaction;
import com.aldorsolutions.webfdms.database.PersistenceException;
import com.aldorsolutions.webfdms.util.FormatDate;
import com.aldorsolutions.webfdms.util.SessionHelpers;
import fdms.ui.struts.form.CheckListForm;
public class ShowCaseStatusCheckList extends Action {
private Logger logger = Logger.getLogger(ShowCaseStatusCheckList.class.getName());
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException {
ActionErrors errors = new ActionErrors();
DbUserSession sessionUser = SessionHelpers.getUserSession(request);
DatabaseTransaction t = null;
DbVitalsSchedule checklistdata = null;
CheckListForm checklistform = new CheckListForm();
int vitalsid = 0;
if (sessionUser == null) {
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.login.invalid"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
vitalsid = SessionHelpers.getVitalsIdFromSession(request, sessionUser);
//Database Access Logic
try {
t = (DatabaseTransaction)DatabaseTransaction.getTransaction(sessionUser);
checklistdata = FdmsDb.getInstance().getVitalsSchedule(t,vitalsid);
DbLocaleConfig[] configs = FdmsDb.getInstance().getLocaleConfigForLocale(t, sessionUser.getRegion());
// get Locale specific details.
int showAtNeedCheckList = FdmsDb.getInstance().getLocaleConfigValueForLocale(t, configs, sessionUser.getRegion(),
DbLocaleConfigType.CONFIG_SHOW_AT_NEED_CHECKLIST);
int showAfterCareCheckList = FdmsDb.getInstance().getLocaleConfigValueForLocale(t, configs, sessionUser.getRegion(),
DbLocaleConfigType.CONFIG_SHOW_AFTER_CARE_CHECKLIST);
request.setAttribute("showAtNeedCheckList", Integer.valueOf(showAtNeedCheckList));
request.setAttribute("showAfterCareCheckList", Integer.valueOf(showAfterCareCheckList));
if ( checklistdata != null ) {
if ( (showAtNeedCheckList > 0) || (showAfterCareCheckList > 0) ) {
}
// --- Populate CHECK LIST section
checklistform.setChecked1(checklistdata.getChecked(0)>0);
checklistform.setChecked2(checklistdata.getChecked(1)>0);
checklistform.setChecked3(checklistdata.getChecked(2)>0);
checklistform.setChecked4(checklistdata.getChecked(3)>0);
checklistform.setChecked5(checklistdata.getChecked(4)>0);
checklistform.setChecked6(checklistdata.getChecked(5)>0);
checklistform.setChecked7(checklistdata.getChecked(6)>0);
checklistform.setChecked8(checklistdata.getChecked(7)>0);
checklistform.setChecked9(checklistdata.getChecked(8)>0);
checklistform.setChecked10(checklistdata.getChecked(9)>0);
checklistform.setChecked11(checklistdata.getChecked(10)>0);
checklistform.setChecked12(checklistdata.getChecked(11)>0);
checklistform.setChecked13(checklistdata.getChecked(12)>0);
checklistform.setChecked14(checklistdata.getChecked(13)>0);
checklistform.setChecked15(checklistdata.getChecked(14)>0);
checklistform.setChecked16(checklistdata.getChecked(15)>0);
checklistform.setSchedule1(checklistdata.getDescription(0));
checklistform.setSchedule2(checklistdata.getDescription(1));
checklistform.setSchedule3(checklistdata.getDescription(2));
checklistform.setSchedule4(checklistdata.getDescription(3));
checklistform.setSchedule5(checklistdata.getDescription(4));
checklistform.setSchedule6(checklistdata.getDescription(5));
checklistform.setSchedule7(checklistdata.getDescription(6));
checklistform.setSchedule8(checklistdata.getDescription(7));
checklistform.setSchedule9(checklistdata.getDescription(8));
checklistform.setSchedule10(checklistdata.getDescription(9));
checklistform.setSchedule11(checklistdata.getDescription(10));
checklistform.setSchedule12(checklistdata.getDescription(11));
checklistform.setSchedule13(checklistdata.getDescription(12));
checklistform.setSchedule14(checklistdata.getDescription(13));
checklistform.setSchedule15(checklistdata.getDescription(14));
checklistform.setSchedule16(checklistdata.getDescription(15));
checklistform.setDate9( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(0)));
checklistform.setDate10( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(1)));
checklistform.setDate11( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(2)));
checklistform.setDate12( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(3)));
checklistform.setDate13( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(4)));
checklistform.setDate14( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(5)));
checklistform.setDate15( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(6)));
checklistform.setDate16( FormatDate.MDYtoMMDDYYYY(checklistdata.getDate(7)));
}
} catch(PersistenceException pe) {
logger.error("Persistence Exception in ShowCaseStatusCheckList.doPerform. " + pe);
} catch(Exception pe) {
logger.error("Exception in ShowCaseStatusCheckList.doPerform. ", pe);
} finally {
if (t != null) {
t.closeConnection();
t = null;
}
}
request.setAttribute("checkListForm",checklistform);
return mapping.findForward("showCaseStatusJsp");
}
}
| [
"mahendrakawde@gmail.com"
] | mahendrakawde@gmail.com | |
8d4c7ae1d5d67ec9e72636b1cc59a3ca36b0e8b3 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/6/6_4cf9e4b63005e6e599607d88c78ca705bb3d2b56/Invocation/6_4cf9e4b63005e6e599607d88c78ca705bb3d2b56_Invocation_s.java | b4a05768c1577f4ba9560e76fa48a00af76a8504 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 59,933 | java | /*
* Copyright Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the authors tag. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License version 2.
*
* This particular file is subject to the "Classpath" exception as provided in the
* LICENSE file that accompanied this code.
*
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License,
* along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.redhat.ceylon.compiler.java.codegen;
import static com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.JT_COMPANION;
import static com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.JT_NO_PRIMITIVES;
import static com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.JT_RAW;
import static com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.JT_TYPE_ARGUMENT;
import static com.sun.tools.javac.code.Flags.FINAL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeMap;
import com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.BoxingStrategy;
import com.redhat.ceylon.compiler.typechecker.model.Class;
import com.redhat.ceylon.compiler.typechecker.model.ClassAlias;
import com.redhat.ceylon.compiler.typechecker.model.ClassOrInterface;
import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.model.Functional;
import com.redhat.ceylon.compiler.typechecker.model.FunctionalParameter;
import com.redhat.ceylon.compiler.typechecker.model.Interface;
import com.redhat.ceylon.compiler.typechecker.model.Method;
import com.redhat.ceylon.compiler.typechecker.model.Parameter;
import com.redhat.ceylon.compiler.typechecker.model.ParameterList;
import com.redhat.ceylon.compiler.typechecker.model.ProducedReference;
import com.redhat.ceylon.compiler.typechecker.model.ProducedType;
import com.redhat.ceylon.compiler.typechecker.model.ProducedTypedReference;
import com.redhat.ceylon.compiler.typechecker.model.TypedDeclaration;
import com.redhat.ceylon.compiler.typechecker.model.Value;
import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.Comprehension;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.Expression;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.FunctionArgument;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.PositionalArgument;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.PositionalArgumentList;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.Primary;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.QualifiedMemberExpression;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.QualifiedTypeExpression;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.SequencedArgument;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCNewClass;
import com.sun.tools.javac.tree.JCTree.JCReturn;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
abstract class Invocation {
static boolean onValueType(AbstractTransformer gen, Tree.Primary primary, Declaration primaryDeclaration) {
// don't use the value type mechanism for optimised Java arrays get/set invocations
if (primary instanceof Tree.QualifiedMemberOrTypeExpression){
Tree.Primary qmePrimary = ((Tree.QualifiedMemberOrTypeExpression) primary).getPrimary();
if(qmePrimary != null
&& gen.isJavaArray(qmePrimary.getTypeModel())
&& (primaryDeclaration.getName().equals("get")
|| primaryDeclaration.getName().equals("set"))) {
return false;
} else {
return Decl.isValueTypeDecl(qmePrimary)
&& (CodegenUtil.isUnBoxed(qmePrimary) || gen.isJavaArray(qmePrimary.getTypeModel()));
}
} else {
return false;
}
}
protected final AbstractTransformer gen;
private final Node node;
private final Tree.Primary primary;
private final Declaration primaryDeclaration;
private final ProducedType returnType;
protected boolean handleBoxing;
protected boolean unboxed;
protected BoxingStrategy boxingStrategy;
private final Tree.Primary qmePrimary;
private final boolean onValueType;
protected Invocation(AbstractTransformer gen,
Tree.Primary primary, Declaration primaryDeclaration,
ProducedType returnType, Node node) {
this.gen = gen;
this.primary = primary;
this.primaryDeclaration = primaryDeclaration;
this.returnType = returnType;
this.node = node;
if (primary instanceof Tree.QualifiedMemberOrTypeExpression){
this.qmePrimary = ((Tree.QualifiedMemberOrTypeExpression) primary).getPrimary();
} else {
this.qmePrimary = null;
}
this.onValueType = onValueType(gen, primary, primaryDeclaration);
}
public String toString() {
return getClass().getName() + " of " + node;
}
Node getNode() {
return node;
}
Tree.Primary getPrimary() {
return primary;
}
Declaration getPrimaryDeclaration() {
return primaryDeclaration;
}
ProducedType getReturnType() {
return returnType;
}
Tree.Primary getQmePrimary() {
return qmePrimary;
}
final boolean isOnValueType() {
return onValueType;
}
protected boolean isParameterRaw(Parameter param){
ProducedType type = param.getType();
return type == null ? false : type.isRaw();
}
protected boolean isParameterWithConstrainedTypeParameters(Parameter param) {
ProducedType type = param.getType();
return gen.hasConstrainedTypeParameters(type);
}
protected abstract void addReifiedArguments(ListBuffer<ExpressionAndType> result);
public final void setUnboxed(boolean unboxed) {
this.unboxed = unboxed;
}
public final void handleBoxing(boolean b) {
handleBoxing = b;
}
public final void setBoxingStrategy(BoxingStrategy boxingStrategy) {
this.boxingStrategy = boxingStrategy;
}
class TransformedInvocationPrimary {
final JCExpression expr;
final String selector;
TransformedInvocationPrimary(JCExpression expr, String selector) {
this.expr = expr;
this.selector = selector;
}
}
protected TransformedInvocationPrimary transformPrimary(JCExpression primaryExpr,
String selector) {
if (isMemberRefInvocation()) {
JCExpression callable = gen.expressionGen().transformMemberReference((Tree.QualifiedMemberOrTypeExpression)getPrimary(), (Tree.BaseMemberOrTypeExpression)getQmePrimary());
selector = Naming.getCallableMethodName();
handleBoxing(true);
return new TransformedInvocationPrimary(callable, selector);
}
JCExpression actualPrimExpr;
if (getPrimary() instanceof Tree.QualifiedTypeExpression
&& ((Tree.QualifiedTypeExpression)getPrimary()).getPrimary() instanceof Tree.BaseTypeExpression) {
actualPrimExpr = gen.makeSelect(primaryExpr, "this");
} else {
actualPrimExpr = primaryExpr;
}
if (getPrimary() instanceof Tree.Expression) {
Tree.Primary p = getPrimary();
while (p instanceof Tree.Expression) {
p = (Tree.Primary)((Expression)getPrimary()).getTerm();
}
primaryExpr = gen.expressionGen().transformFunctional(p, (Functional)((QualifiedMemberExpression)p).getDeclaration());
selector = null;
}
if (getPrimary() instanceof Tree.BaseTypeExpression) {
Tree.BaseTypeExpression type = (Tree.BaseTypeExpression)getPrimary();
Declaration declaration = type.getDeclaration();
if (Strategy.generateInstantiator(declaration)) {
if (Decl.withinInterface(declaration)) {
actualPrimExpr = primaryExpr != null ? primaryExpr : gen.naming.makeQuotedThis();
} else {
actualPrimExpr = null;
}
}
} else if (getPrimary() instanceof Tree.QualifiedTypeExpression) {
} else {
if (this instanceof IndirectInvocationBuilder
&& getPrimaryDeclaration() != null
&& (Decl.isGetter(getPrimaryDeclaration())
|| Decl.isToplevel(getPrimaryDeclaration())
|| (Decl.isValueOrSharedParam(getPrimaryDeclaration()) && Decl.isCaptured(getPrimaryDeclaration()))
&& !Decl.isLocal(getPrimaryDeclaration()))) {
actualPrimExpr = gen.make().Apply(null,
gen.naming.makeQualIdent(primaryExpr, selector),
List.<JCExpression>nil());
selector = Naming.getCallableMethodName();
} else if (getPrimaryDeclaration() instanceof FunctionalParameter
|| (this instanceof IndirectInvocationBuilder)) {
if (selector != null) {
actualPrimExpr = gen.naming.makeQualIdent(primaryExpr, selector);
} else {
actualPrimExpr = gen.naming.makeQualifiedName(primaryExpr, (TypedDeclaration)getPrimaryDeclaration(), Naming.NA_MEMBER);
}
if (!gen.isCeylonCallableSubtype(getPrimary().getTypeModel())) {
actualPrimExpr = gen.make().Apply(null, actualPrimExpr, List.<JCExpression>nil());
}
selector = Naming.getCallableMethodName();
}
}
return new TransformedInvocationPrimary(actualPrimExpr, selector);
}
boolean isMemberRefInvocation() {
return this instanceof IndirectInvocationBuilder
&& getPrimary() instanceof Tree.QualifiedMemberOrTypeExpression
&& getQmePrimary() instanceof Tree.BaseTypeExpression;
}
}
abstract class SimpleInvocation extends Invocation {
public SimpleInvocation(AbstractTransformer gen, Primary primary,
Declaration primaryDeclaration, ProducedType returnType, Node node) {
super(gen, primary, primaryDeclaration, returnType, node);
}
protected abstract boolean isParameterSequenced(int argIndex);
protected abstract ProducedType getParameterType(int argIndex);
//protected abstract String getParameterName(int argIndex);
protected abstract JCExpression getParameterExpression(int argIndex);
protected abstract boolean getParameterUnboxed(int argIndex);
protected abstract BoxingStrategy getParameterBoxingStrategy(int argIndex);
protected abstract boolean hasParameter(int argIndex);
// to be overridden
protected boolean isParameterRaw(int argIndex) {
return false;
}
// to be overridden
protected boolean isParameterWithConstrainedTypeParameters(int argIndex) {
return false;
}
/** Gets the number of arguments actually being supplied */
protected abstract int getNumArguments();
/**
* Gets the transformed expression supplying the argument value for the
* given argument index
*/
//protected abstract JCExpression getTransformedArgumentExpression(int argIndex);
protected abstract boolean isSpread();
protected abstract boolean isArgumentSpread(int argIndex);
/**
* For subclasses if the target method doesn't support default values for variadic
* using overloading.
*/
protected boolean requiresEmptyForVariadic() {
return false;
}
protected boolean isJavaMethod() {
if(getPrimaryDeclaration() instanceof Method) {
return gen.isJavaMethod((Method) getPrimaryDeclaration());
} else if (getPrimaryDeclaration() instanceof Class) {
return gen.isJavaCtor((Class) getPrimaryDeclaration());
}
return false;
}
protected abstract Tree.Expression getArgumentExpression(int argIndex);
protected ProducedType getArgumentType(int argIndex) {
return getArgumentExpression(argIndex).getTypeModel();
}
protected abstract JCExpression getTransformedArgumentExpression(int argIndex);
}
/**
* Generates calls to Callable methods. This is for regular {@code Callable<T>} objects and not
* functional parameters, which have more info like parameter names and default values.
*/
class IndirectInvocationBuilder extends SimpleInvocation {
private final java.util.List<ProducedType> parameterTypes;
private final java.util.List<Tree.Expression> argumentExpressions;
private final Comprehension comprehension;
private final boolean variadic;
private final boolean spread;
private final int minimumParameters;
public IndirectInvocationBuilder(
AbstractTransformer gen,
Tree.Primary primary,
Declaration primaryDeclaration,
Tree.InvocationExpression invocation) {
super(gen, primary, primaryDeclaration, invocation.getTypeModel(), invocation);
// find the parameter types
final java.util.List<ProducedType> tas = new ArrayList<>();
ProducedType callableType = primary.getTypeModel();
tas.add(gen.getReturnTypeOfCallable(callableType));
for (int ii = 0, l = gen.getNumParametersOfCallable(callableType); ii < l; ii++) {
tas.add(gen.getParameterTypeOfCallable(callableType, ii));
}
this.variadic = gen.isVariadicCallable(callableType);
this.minimumParameters = gen.getMinimumParameterCountForCallable(callableType);
//final java.util.List<ProducedType> tas = primary.getTypeModel().getTypeArgumentList();
final java.util.List<ProducedType> parameterTypes = tas.subList(1, tas.size());
PositionalArgumentList positionalArgumentList = invocation.getPositionalArgumentList();
final java.util.List<Tree.Expression> argumentExpressions = new ArrayList<Tree.Expression>(tas.size());
boolean spread = false;
Comprehension comprehension = null;
for (Tree.PositionalArgument argument : positionalArgumentList.getPositionalArguments()) {
if(argument instanceof Tree.ListedArgument)
argumentExpressions.add(((Tree.ListedArgument)argument).getExpression());
else if(argument instanceof Tree.SpreadArgument){
argumentExpressions.add(((Tree.SpreadArgument)argument).getExpression());
spread = true;
}else{
comprehension = (Comprehension) argument;
}
}
this.spread = spread;
this.comprehension = comprehension;
this.argumentExpressions = argumentExpressions;
this.parameterTypes = parameterTypes;
}
@Override
protected void addReifiedArguments(ListBuffer<ExpressionAndType> result) {
// can never be parameterised
}
@Override
protected boolean isParameterSequenced(int argIndex) {
return variadic && argIndex >= parameterTypes.size() - 1;
}
@Override
protected ProducedType getParameterType(int argIndex) {
// in the Java code, all Callable.call() params are of type Object so let's not
// pretend they are typed, this saves a lot of casting.
// except for sequenced parameters where we do care about the iterated type
if(isParameterSequenced(argIndex)){
return parameterTypes.get(parameterTypes.size()-1);
}
return gen.typeFact().getObjectDeclaration().getType();
}
@Override
protected JCExpression getParameterExpression(int argIndex) {
return gen.naming.makeQuotedIdent("arg" + argIndex);
}
@Override
protected boolean getParameterUnboxed(int argIndex) {
return false;
}
@Override
protected BoxingStrategy getParameterBoxingStrategy(int argIndex) {
return BoxingStrategy.BOXED;
}
@Override
protected boolean hasParameter(int argIndex) {
return true;
}
@Override
protected int getNumArguments() {
return argumentExpressions.size() + (comprehension != null ? 1 : 0);
}
@Override
protected boolean isSpread() {
return comprehension != null || spread;
}
@Override
protected boolean isArgumentSpread(int argIndex) {
if(spread) // spread args must be last argument
return argIndex == argumentExpressions.size() - 1;
if(comprehension != null) // comprehension must be last
return argIndex == argumentExpressions.size();
return false;
}
@Override
protected Tree.Expression getArgumentExpression(int argIndex) {
return argumentExpressions.get(argIndex);
}
@Override
protected ProducedType getArgumentType(int argIndex) {
if (argIndex == argumentExpressions.size() && comprehension != null) {
return gen.typeFact().getSequentialType(comprehension.getTypeModel());
}
return super.getArgumentType(argIndex);
}
@Override
protected JCExpression getTransformedArgumentExpression(int argIndex) {
if (argIndex == argumentExpressions.size() && comprehension != null) {
ProducedType type = getParameterType(argIndex);
return gen.expressionGen().comprehensionAsSequential(comprehension, type);
}
Tree.Expression expr = getArgumentExpression(argIndex);
if (expr.getTerm() instanceof FunctionArgument) {
FunctionArgument farg = (FunctionArgument)expr.getTerm();
return gen.expressionGen().transform(farg);
}
return gen.expressionGen().transformArg(this, argIndex);
}
}
/**
* An abstract implementation of InvocationBuilder support invocation
* via positional arguments. Supports with sequenced arguments but not
* defaulted arguments.
*/
abstract class DirectInvocation extends SimpleInvocation {
private final ProducedReference producedReference;
protected DirectInvocation(
AbstractTransformer gen,
Tree.Primary primary,
Declaration primaryDeclaration,
ProducedReference producedReference, ProducedType returnType,
Node node) {
super(gen, primary, primaryDeclaration, returnType, node);
this.producedReference = producedReference;
}
protected ProducedReference getProducedReference() {
return producedReference;
}
/**
* Gets the Parameter corresponding to the given argument
* @param argIndex
* @return
*/
protected abstract Parameter getParameter(int argIndex);
@Override
protected boolean isParameterSequenced(int argIndex) {
return getParameter(argIndex).isSequenced();
}
@Override
protected ProducedType getParameterType(int argIndex) {
int flags = AbstractTransformer.TP_TO_BOUND;
if(isParameterSequenced(argIndex)
&& isJavaMethod()
&& isSpread())
flags |= AbstractTransformer.TP_SEQUENCED_TYPE;
return gen.expressionGen().getTypeForParameter(getParameter(argIndex), getProducedReference(), flags);
}
@Override
protected JCExpression getParameterExpression(int argIndex) {
return gen.naming.makeName(getParameter(argIndex), Naming.NA_MEMBER);
}
@Override
protected boolean getParameterUnboxed(int argIndex) {
return getParameter(argIndex).getUnboxed();
}
@Override
protected BoxingStrategy getParameterBoxingStrategy(int argIndex) {
Parameter param = getParameter(argIndex);
if (isOnValueType() && Decl.isValueTypeDecl(param)) {
return BoxingStrategy.UNBOXED;
}
return CodegenUtil.getBoxingStrategy(param);
}
@Override
protected boolean hasParameter(int argIndex) {
return getParameter(argIndex) != null;
}
@Override
protected void addReifiedArguments(ListBuffer<ExpressionAndType> result) {
addReifiedArguments(gen, producedReference, result);
}
static void addReifiedArguments(AbstractTransformer gen, ProducedReference producedReference, ListBuffer<ExpressionAndType> result) {
java.util.List<JCExpression> reifiedTypeArgs = gen.makeReifiedTypeArguments(producedReference);
for(JCExpression reifiedTypeArg : reifiedTypeArgs)
result.append(new ExpressionAndType(reifiedTypeArg, gen.makeTypeDescriptorType()));
}
}
/**
* InvocationBuilder used for 'normal' method and initializer invocations via
* positional arguments. Supports sequenced and defaulted arguments.
*/
class PositionalInvocation extends DirectInvocation {
private final Tree.PositionalArgumentList positional;
private final java.util.List<Parameter> parameters;
public PositionalInvocation(
AbstractTransformer gen,
Tree.Primary primary,
Declaration primaryDeclaration,
ProducedReference producedReference, Tree.InvocationExpression invocation,
java.util.List<Parameter> parameters) {
super(gen, primary, primaryDeclaration, producedReference, invocation.getTypeModel(), invocation);
positional = invocation.getPositionalArgumentList();
this.parameters = parameters;
}
java.util.List<Parameter> getParameters() {
return parameters;
}
Tree.PositionalArgumentList getPositional() {
return positional;
}
@Override
protected Tree.Expression getArgumentExpression(int argIndex) {
PositionalArgument arg = getPositional().getPositionalArguments().get(argIndex);
if(arg instanceof Tree.ListedArgument)
return ((Tree.ListedArgument) arg).getExpression();
if(arg instanceof Tree.SpreadArgument)
return ((Tree.SpreadArgument) arg).getExpression();
throw new RuntimeException("Trying to get an argument expression which is a Comprehension: " + arg);
}
@Override
protected ProducedType getArgumentType(int argIndex) {
PositionalArgument arg = getPositional().getPositionalArguments().get(argIndex);
if (arg instanceof Tree.Comprehension) {
return gen.typeFact().getSequentialType(arg.getTypeModel());
}
return arg.getTypeModel();
}
@Override
protected JCExpression getTransformedArgumentExpression(int argIndex) {
PositionalArgument arg = getPositional().getPositionalArguments().get(argIndex);
// FIXME: I don't like much this weird special case here
if(arg instanceof Tree.ListedArgument){
Tree.Expression expr = ((Tree.ListedArgument) arg).getExpression();
if (expr.getTerm() instanceof FunctionArgument) {
FunctionArgument farg = (FunctionArgument)expr.getTerm();
return gen.expressionGen().transform(farg);
}
}
// special case for comprehensions which are not expressions
if(arg instanceof Tree.Comprehension){
ProducedType type = getParameterType(argIndex);
return gen.expressionGen().comprehensionAsSequential((Comprehension) arg, type);
}
return gen.expressionGen().transformArg(this, argIndex);
}
@Override
protected Parameter getParameter(int argIndex) {
return parameters.get(argIndex >= parameters.size() ? parameters.size()-1 : argIndex);
}
@Override
protected int getNumArguments() {
return getPositional().getPositionalArguments().size();
}
@Override
protected boolean isSpread() {
java.util.List<PositionalArgument> args = getPositional().getPositionalArguments();
if(args.isEmpty())
return false;
PositionalArgument last = args.get(args.size()-1);
return last instanceof Tree.SpreadArgument || last instanceof Tree.Comprehension;
}
@Override
protected boolean isArgumentSpread(int argIndex) {
PositionalArgument arg = getPositional().getPositionalArguments().get(argIndex);
return arg instanceof Tree.SpreadArgument || arg instanceof Tree.Comprehension;
}
@Override
protected boolean isParameterRaw(int argIndex){
return isParameterRaw(getParameter(argIndex));
}
@Override
protected boolean isParameterWithConstrainedTypeParameters(int argIndex) {
return isParameterWithConstrainedTypeParameters(getParameter(argIndex));
}
protected boolean hasDefaultArgument(int ii) {
return getParameters().get(ii).isDefaulted();
}
}
/**
* InvocationBuilder used for constructing invocations of {@code super()}
* when creating constructors.
*/
class SuperInvocation extends PositionalInvocation {
static Declaration unaliasedPrimaryDeclaration(Tree.InvocationExpression invocation) {
Declaration declaration = ((Tree.MemberOrTypeExpression)invocation.getPrimary()).getDeclaration();
if (declaration instanceof ClassAlias) {
declaration = ((ClassAlias) declaration).getExtendedTypeDeclaration();
}
return declaration;
}
private final Tree.ClassOrInterface sub;
SuperInvocation(AbstractTransformer gen,
Tree.ClassOrInterface sub,
Tree.InvocationExpression invocation,
ParameterList parameterList) {
super(gen,
invocation.getPrimary(),
unaliasedPrimaryDeclaration(invocation),
((Tree.MemberOrTypeExpression)invocation.getPrimary()).getTarget(),
invocation,
parameterList.getParameters());
this.sub = sub;
}
Tree.ClassOrInterface getSub() {
return sub;
}
}
/**
* InvocationBuilder for constructing the invocation of a method reference
* used when implementing {@code Callable.call()}.
*
* This will be used when you do:
* <p>
* <code>
* void f(){
* value callable = f;
* }
* </code>
* </p>
* And will generate the code required to put inside the Callable's {@code $call} method to
* invoke {@code f}: {@code f();}. The generation of the Callable or its methods is not done here.
*/
class CallableInvocation extends DirectInvocation {
private final java.util.List<Parameter> callableParameters;
private final java.util.List<Parameter> functionalParameters;
private final int parameterCount;
public CallableInvocation(
AbstractTransformer gen, Tree.MemberOrTypeExpression primary,
Declaration primaryDeclaration, ProducedReference producedReference, ProducedType returnType,
Tree.Term expr, ParameterList parameterList, int parameterCount) {
super(gen, primary, primaryDeclaration, producedReference, returnType, expr);
callableParameters = ((Functional)primary.getDeclaration()).getParameterLists().get(0).getParameters();
functionalParameters = parameterList.getParameters();
this.parameterCount = parameterCount;
setUnboxed(expr.getUnboxed());
setBoxingStrategy(BoxingStrategy.BOXED);// Must be boxed because non-primitive return type
handleBoxing(true);
}
@Override
protected int getNumArguments() {
return parameterCount;
}
@Override
protected boolean isSpread() {
return isParameterSequenced(getNumArguments() - 1);
}
@Override
protected boolean isArgumentSpread(int argIndex) {
return isSpread() && argIndex == getNumArguments() - 1;
}
@Override
protected JCExpression getTransformedArgumentExpression(int argIndex) {
Parameter param = callableParameters.get(argIndex);
return gen.makeUnquotedIdent(Naming.getCallableTempVarName(param));
}
@Override
protected Parameter getParameter(int index) {
return functionalParameters.get(index);
}
@Override
protected Expression getArgumentExpression(int argIndex) {
throw new RuntimeException("I override getTransformedArgumentExpression(), so should never be called");
}
@Override
protected ProducedType getArgumentType(int argIndex) {
return callableParameters.get(argIndex).getType();
}
}
/**
* InvocationBuilder for methods specified with a method reference. This builds the specifier invocation
* within the body of the specified method.
*
* For example for {@code void foo(); foo = f;} we generate: {@code f()} that you would then place into
* the generated method for {@code foo}.
*/
class MethodReferenceSpecifierInvocation extends DirectInvocation {
private final Method method;
public MethodReferenceSpecifierInvocation(
AbstractTransformer gen, Tree.Primary primary,
Declaration primaryDeclaration,
ProducedReference producedReference, Method method, Tree.SpecifierExpression node) {
super(gen, primary, primaryDeclaration, producedReference, method.getType(), node);
this.method = method;
setUnboxed(primary.getUnboxed());
setBoxingStrategy(CodegenUtil.getBoxingStrategy(method));
}
@Override
protected int getNumArguments() {
return method.getParameterLists().get(0).getParameters().size();
}
@Override
protected JCExpression getTransformedArgumentExpression(int argIndex) {
ProducedType exprType = getParameterType(argIndex);
Parameter declaredParameter = ((Functional)getPrimaryDeclaration()).getParameterLists().get(0).getParameters().get(argIndex);
JCExpression result = getParameterExpression(argIndex);
result = gen.expressionGen().applyErasureAndBoxing(
result,
exprType,
!getParameterUnboxed(argIndex),
CodegenUtil.getBoxingStrategy(declaredParameter),
declaredParameter.getType());
return result;
}
@Override
protected Parameter getParameter(int argIndex) {
return method.getParameterLists().get(0).getParameters().get(argIndex);
}
@Override
protected boolean isSpread() {
return method.getParameterLists().get(0).getParameters().get(getNumArguments() - 1).isSequenced();
}
@Override
protected boolean isArgumentSpread(int argIndex) {
return isSpread() && argIndex == getNumArguments() - 1;
}
@Override
protected Expression getArgumentExpression(int argIndex) {
throw new RuntimeException("I override getTransformedArgumentExpression(), so should never be called");
}
}
/**
* InvocationBuilder for methods specified eagerly with a Callable. This builds the Callable invocation
* within the body of the specified method.
*
* For example for {@code void foo(); foo = f;} we generate: {@code f.$call()} that you would then place into
* the generated method for {@code foo}.
*/
class CallableSpecifierInvocation extends Invocation {
private final Method method;
private final JCExpression callable;
public CallableSpecifierInvocation(
AbstractTransformer gen,
Method method,
JCExpression callableExpr,
Node node) {
super(gen, null, null, method.getType(), node);
this.callable = callableExpr;
this.method = method;
// Because we're calling a callable, and they always return a
// boxed result
setUnboxed(false);
setBoxingStrategy(method.getUnboxed() ? BoxingStrategy.UNBOXED : BoxingStrategy.BOXED);
}
@Override
protected void addReifiedArguments(ListBuffer<ExpressionAndType> result) {
// nothing required here
}
JCExpression getCallable() {
return callable;
}
Method getMethod() {
return method;
}
}
/**
* InvocationBuilder for 'normal' method and initializer invocations
* using named arguments.
*/
class NamedArgumentInvocation extends Invocation {
private final Tree.NamedArgumentList namedArgumentList;
private final ListBuffer<JCStatement> vars = ListBuffer.lb();
private final Naming.SyntheticName callVarName;
private final Naming.SyntheticName varBaseName;
private final Set<String> argNames = new HashSet<String>();
private final TreeMap<Integer, Naming.SyntheticName> argsNamesByIndex = new TreeMap<Integer, Naming.SyntheticName>();
private final TreeMap<Integer, ExpressionAndType> argsAndTypes = new TreeMap<Integer, ExpressionAndType>();
private final Set<Parameter> bound = new HashSet<Parameter>();
private ProducedReference producedReference;
public NamedArgumentInvocation(
AbstractTransformer gen, Tree.Primary primary,
Declaration primaryDeclaration,
ProducedReference producedReference,
Tree.InvocationExpression invocation) {
super(gen, primary, primaryDeclaration, invocation.getTypeModel(), invocation);
this.producedReference = producedReference;
namedArgumentList = invocation.getNamedArgumentList();
varBaseName = gen.naming.alias("arg");
callVarName = varBaseName.suffixedBy("$callable$");
}
@Override
protected void addReifiedArguments(ListBuffer<ExpressionAndType> result) {
if(!gen.supportsReified(producedReference.getDeclaration()))
return;
int tpCount = gen.getTypeParameters(producedReference).size();
for(int tpIndex = 0;tpIndex<tpCount;tpIndex++){
result.append(new ExpressionAndType(reifiedTypeArgName(tpIndex).makeIdent(), gen.makeTypeDescriptorType()));
}
}
ListBuffer<JCStatement> getVars() {
return vars;
}
Iterable<Naming.SyntheticName> getArgsNamesByIndex() {
return argsNamesByIndex.values();
}
Iterable<ExpressionAndType> getArgumentsAndTypes() {
return argsAndTypes.values();
}
/**
* Constructs the vars used in the Let expression
*/
private void buildVars() {
if (getPrimaryDeclaration() == null) {
return;
}
boolean prev = gen.expressionGen().withinInvocation(false);
java.util.List<Tree.NamedArgument> namedArguments = namedArgumentList.getNamedArguments();
SequencedArgument sequencedArgument = namedArgumentList.getSequencedArgument();
java.util.List<ParameterList> paramLists = ((Functional)getPrimaryDeclaration()).getParameterLists();
java.util.List<Parameter> declaredParams = paramLists.get(0).getParameters();
appendVarsForNamedArguments(namedArguments, declaredParams);
appendVarsForReifiedTypeArguments();
if(sequencedArgument != null)
appendVarsForSequencedArguments(sequencedArgument, declaredParams);
boolean hasDefaulted = appendVarsForDefaulted(declaredParams);
if (hasDefaulted
&& !Strategy.defaultParameterMethodStatic(getPrimaryDeclaration())
&& !Strategy.defaultParameterMethodOnOuter(getPrimaryDeclaration())) {
vars.prepend(makeThis());
}
gen.expressionGen().withinInvocation(prev);
}
private void appendVarsForReifiedTypeArguments() {
java.util.List<JCExpression> reifiedTypeArgs = gen.makeReifiedTypeArguments(producedReference);
int index = 0;
for(JCExpression reifiedTypeArg : reifiedTypeArgs){
Naming.SyntheticName argName = reifiedTypeArgName(index);
JCVariableDecl varDecl = gen.makeVar(argName, gen.makeTypeDescriptorType(), reifiedTypeArg);
this.vars.append(varDecl);
index++;
}
}
private void appendVarsForSequencedArguments(Tree.SequencedArgument sequencedArgument, java.util.List<Parameter> declaredParams) {
// FIXME: this is suspisciously similar to AbstractTransformer.makeIterable(java.util.List<Tree.PositionalArgument> list, ProducedType seqElemType)
// and possibly needs to be merged
Parameter parameter = sequencedArgument.getParameter();
ProducedType parameterType = parameterType(parameter, parameter.getType(), gen.TP_TO_BOUND);
// find out the individual type
ProducedType iteratedType = gen.typeFact().getIteratedType(parameterType);
// we can't just generate types like Foo<?> if the target type param is not raw because the bounds will
// not match, so we go raw, we also ignore primitives naturally
int flags = JT_RAW | JT_NO_PRIMITIVES;
JCTree.JCExpression sequenceValue = gen.makeIterable(sequencedArgument, iteratedType, flags);
JCTree.JCExpression sequenceType = gen.makeJavaType(parameterType, flags);
Naming.SyntheticName argName = argName(parameter);
JCTree.JCVariableDecl varDecl = gen.makeVar(argName, sequenceType, sequenceValue);
bind(parameter, argName, gen.makeJavaType(parameterType, flags), List.<JCTree.JCStatement>of(varDecl));
}
private JCExpression makeDefaultedArgumentMethodCall(Parameter param) {
JCExpression thisExpr = null;
switch (Strategy.defaultParameterMethodOwner(param)) {
case SELF:
case STATIC:
case OUTER:
break;
case OUTER_COMPANION:
thisExpr = callVarName.makeIdent();
break;
case INIT_COMPANION:
thisExpr = varBaseName.suffixedBy("$this$").makeIdent();
if (isOnValueType()) {
thisExpr = gen.boxType(thisExpr, getQmePrimary().getTypeModel());
}
break;
}
JCExpression defaultValueMethodName = gen.naming.makeDefaultedParamMethod(thisExpr, param);
JCExpression argExpr = gen.at(getNode()).Apply(null,
defaultValueMethodName,
makeVarRefArgumentList(param));
return argExpr;
}
// Make a list of ($arg0, $arg1, ... , $argN)
// or ($arg$this$, $arg0, $arg1, ... , $argN)
private List<JCExpression> makeVarRefArgumentList(Parameter param) {
ListBuffer<JCExpression> names = ListBuffer.<JCExpression> lb();
if (!Strategy.defaultParameterMethodStatic(getPrimaryDeclaration())
&& Strategy.defaultParameterMethodTakesThis(param)) {
names.append(varBaseName.suffixedBy("$this$").makeIdent());
}
// put all the required reified type args too
int tpCount = gen.getTypeParameters(producedReference).size();
for(int tpIndex = 0;tpIndex<tpCount;tpIndex++){
names.append(reifiedTypeArgName(tpIndex).makeIdent());
}
final int parameterIndex = parameterIndex(param);
for (int ii = 0; ii < parameterIndex; ii++) {
names.append(this.argsNamesByIndex.get(ii).makeIdent());
}
return names.toList();
}
/** Generates the argument name; namedArg may be null if no
* argument was given explicitly */
private Naming.SyntheticName argName(Parameter param) {
final int paramIndex = parameterIndex(param);
//if (this.argNames.isEmpty()) {
//this.argNames.addAll(Collections.<String>nCopies(parameterList(param).size(), null));
//}
String suffix = "$" + paramIndex;
final Naming.SyntheticName argName = varBaseName.suffixedBy(suffix);
if (this.argsNamesByIndex.containsValue(argName)) {
throw new RuntimeException();
}
//if (!this.argNames.add(argName)) {
// throw new RuntimeException();
//}
return argName;
}
/** Generates the argument name; namedArg may be null if no
* argument was given explicitly */
private Naming.SyntheticName reifiedTypeArgName(int index) {
return varBaseName.suffixedBy("$reified$" + index);
}
private java.util.List<Parameter> parameterList(Parameter param) {
Functional functional = (Functional)param.getContainer();
return functional.getParameterLists().get(0).getParameters();
}
private int parameterIndex(Parameter param) {
return parameterList(param).indexOf(param);
}
private ProducedType parameterType(Parameter declaredParam, ProducedType pt, int flags) {
if(declaredParam == null)
return pt;
return gen.getTypeForParameter(declaredParam, producedReference, flags);
}
private void appendVarsForNamedArguments(
java.util.List<Tree.NamedArgument> namedArguments,
java.util.List<Parameter> declaredParams) {
// Assign vars for each named argument given
for (Tree.NamedArgument namedArg : namedArguments) {
gen.at(namedArg);
Parameter declaredParam = namedArg.getParameter();
Naming.SyntheticName argName = argName(declaredParam);
if (namedArg instanceof Tree.SpecifiedArgument) {
bindSpecifiedArgument((Tree.SpecifiedArgument)namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.MethodArgument) {
bindMethodArgument((Tree.MethodArgument)namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.ObjectArgument) {
bindObjectArgument((Tree.ObjectArgument)namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.AttributeArgument) {
bindAttributeArgument((Tree.AttributeArgument)namedArg, declaredParam, argName);
} else {
throw new RuntimeException("" + namedArg);
}
}
}
private void bindSpecifiedArgument(Tree.SpecifiedArgument specifiedArg,
Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
Tree.Expression expr = specifiedArg.getSpecifierExpression().getExpression();
ProducedType type = parameterType(declaredParam, expr.getTypeModel(), gen.TP_TO_BOUND);
final BoxingStrategy boxType = getNamedParameterBoxingStrategy(declaredParam);
int jtFlags = 0;
int exprFlags = 0;
if(boxType == BoxingStrategy.BOXED)
jtFlags |= JT_TYPE_ARGUMENT;
if(!isParameterRaw(declaredParam)) {
exprFlags |= ExpressionTransformer.EXPR_EXPECTED_TYPE_NOT_RAW;
}
if(isParameterWithConstrainedTypeParameters(declaredParam)) {
exprFlags |= ExpressionTransformer.EXPR_EXPECTED_TYPE_HAS_CONSTRAINED_TYPE_PARAMETERS;
// we can't just generate types like Foo<?> if the target type param is not raw because the bounds will
// not match, so we go raw
jtFlags |= JT_RAW;
}
JCExpression typeExpr = gen.makeJavaType(type, jtFlags);
JCExpression argExpr = gen.expressionGen().transformExpression(expr, boxType, type, exprFlags);
JCVariableDecl varDecl = gen.makeVar(argName, typeExpr, argExpr);
statements = ListBuffer.<JCStatement>of(varDecl);
bind(declaredParam, argName, gen.makeJavaType(type, jtFlags), statements.toList());
}
private void bindMethodArgument(Tree.MethodArgument methodArg,
Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
Method model = methodArg.getDeclarationModel();
List<JCStatement> body;
boolean prevNoExpressionlessReturn = gen.statementGen().noExpressionlessReturn;
try {
gen.statementGen().noExpressionlessReturn = gen.isAnything(model.getType());
if (methodArg.getBlock() != null) {
body = gen.statementGen().transform(methodArg.getBlock()).getStatements();
if (!methodArg.getBlock().getDefinitelyReturns()) {
if (gen.isAnything(model.getType())) {
body = body.append(gen.make().Return(gen.makeNull()));
} else {
body = body.append(gen.make().Return(gen.makeErroneous(methodArg.getBlock(), "non-void method doesn't definitely return")));
}
}
} else {
Expression expr = methodArg.getSpecifierExpression().getExpression();
BoxingStrategy boxing = CodegenUtil.getBoxingStrategy(model);
ProducedType type = model.getType();
JCExpression transExpr = gen.expressionGen().transformExpression(expr, boxing, type);
JCReturn returnStat = gen.make().Return(transExpr);
body = List.<JCStatement>of(returnStat);
}
} finally {
gen.statementGen().noExpressionlessReturn = prevNoExpressionlessReturn;
}
ProducedType callableType = model.getProducedReference(null, Collections.<ProducedType>emptyList()).getFullType();
CallableBuilder callableBuilder = CallableBuilder.methodArgument(gen.gen(),
callableType,
model.getParameterLists().get(0),
methodArg.getParameterLists().get(0),
gen.classGen().transformMplBody(methodArg.getParameterLists(), model, body));
JCNewClass callable = callableBuilder.build();
JCExpression typeExpr = gen.makeJavaType(callableType, JT_RAW);
JCVariableDecl varDecl = gen.makeVar(argName, typeExpr, callable);
statements = ListBuffer.<JCStatement>of(varDecl);
bind(declaredParam, argName, gen.makeJavaType(callableType), statements.toList());
}
private void bindObjectArgument(Tree.ObjectArgument objectArg,
Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
List<JCTree> object = gen.classGen().transformObjectArgument(objectArg);
// No need to worry about boxing (it cannot be a boxed type)
JCVariableDecl varDecl = gen.makeLocalIdentityInstance(argName.getName(), Naming.quoteClassName(objectArg.getIdentifier().getText()), false);
statements = toStmts(objectArg, object).append(varDecl);
bind(declaredParam, argName, gen.makeJavaType(objectArg.getType().getTypeModel()), statements.toList());
}
private void bindAttributeArgument(Tree.AttributeArgument attrArg,
Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
final Value model = attrArg.getDeclarationModel();
final String name = model.getName();
final Naming.SyntheticName alias = gen.naming.alias(name);
final List<JCTree> attrClass = gen.gen().transformAttribute(model, alias.getName(), alias.getName(), null, attrArg.getBlock(), attrArg.getSpecifierExpression(), null);
ProducedTypedReference typedRef = gen.getTypedReference(model);
ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
ProducedType nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
ProducedType type = parameterType(declaredParam, model.getType(), 0);
final BoxingStrategy boxType = getNamedParameterBoxingStrategy(declaredParam);
JCExpression initValue = gen.make().Apply(null,
gen.makeSelect(alias.makeIdent(), Naming.getGetterName(model)),
List.<JCExpression>nil());
initValue = gen.expressionGen().applyErasureAndBoxing(
initValue,
nonWideningType,
!CodegenUtil.isUnBoxed(nonWideningTypedRef.getDeclaration()),
boxType,
type);
JCTree.JCVariableDecl var = gen.make().VarDef(
gen.make().Modifiers(FINAL, List.<JCAnnotation>nil()),
argName.asName(),
gen.makeJavaType(type, boxType==BoxingStrategy.BOXED ? JT_NO_PRIMITIVES : 0),
initValue);
statements = toStmts(attrArg, attrClass).append(var);
bind(declaredParam, argName, gen.makeJavaType(type, boxType==BoxingStrategy.BOXED ? JT_NO_PRIMITIVES : 0),
statements.toList());
}
private void bind(Parameter param, Naming.SyntheticName argName, JCExpression argType, List<JCStatement> statements) {
this.vars.appendList(statements);
this.argsAndTypes.put(parameterIndex(param), new ExpressionAndType(argName.makeIdent(), argType));
this.argsNamesByIndex.put(parameterIndex(param), argName);
this.bound.add(param);
}
private ListBuffer<JCStatement> toStmts(Tree.NamedArgument namedArg, final List<JCTree> listOfStatements) {
final ListBuffer<JCStatement> result = ListBuffer.<JCStatement>lb();
for (JCTree tree : listOfStatements) {
if (tree instanceof JCStatement) {
result.append((JCStatement)tree);
} else {
result.append(gen.make().Exec(gen.makeErroneous(namedArg, "Attempt to put a non-statement in a Let")));
}
}
return result;
}
private final void appendDefaulted(Parameter param, JCExpression argExpr) {
// we can't just generate types like Foo<?> if the target type param is not raw because the bounds will
// not match, so we go raw
int flags = JT_RAW;
if (getNamedParameterBoxingStrategy(param) == BoxingStrategy.BOXED) {
flags |= JT_TYPE_ARGUMENT;
}
ProducedType type = gen.getTypeForParameter(param, producedReference, gen.TP_TO_BOUND);
Naming.SyntheticName argName = argName(param);
JCExpression typeExpr = gen.makeJavaType(type, flags);
JCVariableDecl varDecl = gen.makeVar(argName, typeExpr, argExpr);
bind(param, argName, gen.makeJavaType(type, flags), List.<JCStatement>of(varDecl));
}
private BoxingStrategy getNamedParameterBoxingStrategy(Parameter param) {
if (param != null) {
if (isOnValueType() && Decl.isValueTypeDecl(param)) {
return BoxingStrategy.UNBOXED;
}
return CodegenUtil.getBoxingStrategy(param);
} else {
return BoxingStrategy.UNBOXED;
}
}
private boolean appendVarsForDefaulted(java.util.List<Parameter> declaredParams) {
boolean hasDefaulted = false;
if (!Decl.isOverloaded(getPrimaryDeclaration())) {
// append any arguments for defaulted parameters
for (Parameter param : declaredParams) {
if (bound.contains(param)) {
continue;
}
final JCExpression argExpr;
if (param.isDefaulted()) {
// special handling for "element" optional param of java array constructors
if(getPrimaryDeclaration() instanceof Class
&& gen.isJavaArray(((Class)getPrimaryDeclaration()).getType())){
// default values are hard-coded to Java default values, and are actually ignored
continue;
}else if(getQmePrimary() != null
&& gen.isJavaArray(getQmePrimary().getTypeModel())){
// we support array methods with optional parameters
if(getPrimaryDeclaration() instanceof Method
&& getPrimaryDeclaration().getName().equals("copyTo")){
if(param.getName().equals("sourcePosition")
|| param.getName().equals("destinationPosition")){
argExpr = gen.makeInteger(0);
hasDefaulted |= true;
}else if(param.getName().equals("length")){
argExpr = gen.makeSelect(varBaseName.suffixedBy("$this$").makeIdent(), "length");
hasDefaulted |= true;
}else{
argExpr = gen.makeErroneous(this.getNode(), "parameter to copyTo method of Java array type not supported: "+param.getName());
}
}else{
argExpr = gen.makeErroneous(this.getNode(), "virtual method of Java array type not supported: "+getPrimaryDeclaration());
}
}else{
argExpr = makeDefaultedArgumentMethodCall(param);
hasDefaulted |= true;
}
} else if (param.isSequenced()) {
// FIXME: this special case is just plain weird, it looks very wrong
if (getPrimaryDeclaration() instanceof FunctionalParameter) {
// honestly I don't know if it needs a cast but it can't hurt
argExpr = gen.makeEmptyAsSequential(true);
} else {
argExpr = makeDefaultedArgumentMethodCall(param);
hasDefaulted |= true;
}
} else if(gen.typeFact().isIterableType(param.getType())){
// must be an iterable we need to fill with empty
// FIXME: deal with this erasure bug later
argExpr = gen.make().TypeCast(gen.makeJavaType(gen.typeFact().getIterableDeclaration().getType(), AbstractTransformer.JT_RAW), gen.makeEmpty());
} else {
argExpr = gen.makeErroneous(this.getNode(), "Missing argument, and parameter is not defaulted");
}
appendDefaulted(param, argExpr);
}
}
return hasDefaulted;
}
private final JCVariableDecl makeThis() {
// first append $this
JCExpression defaultedParameterInstance;
// TODO Fix how we figure out the thisType, because it's doesn't
// handle type parameters correctly
// we used to use thisType = gen.getThisType(getPrimaryDeclaration());
final JCExpression thisType;
ProducedReference target = ((Tree.MemberOrTypeExpression)getPrimary()).getTarget();
if (getPrimary() instanceof Tree.BaseMemberExpression) {
if (Decl.withinClassOrInterface(getPrimaryDeclaration())) {
// a member method
thisType = gen.makeJavaType(target.getQualifyingType(), JT_NO_PRIMITIVES);
defaultedParameterInstance = gen.naming.makeThis();
} else {
// a local or toplevel function
thisType = gen.naming.makeName((TypedDeclaration)getPrimaryDeclaration(), Naming.NA_WRAPPER);
defaultedParameterInstance = gen.naming.makeName((TypedDeclaration)getPrimaryDeclaration(), Naming.NA_MEMBER);
}
} else if (getPrimary() instanceof Tree.BaseTypeExpression
|| getPrimary() instanceof Tree.QualifiedTypeExpression) {
ClassOrInterface declaration = (ClassOrInterface)((Tree.MemberOrTypeExpression) getPrimary()).getDeclaration();
thisType = gen.makeJavaType(declaration.getType(), JT_COMPANION);
defaultedParameterInstance = gen.make().NewClass(
null,
null,
gen.makeJavaType(declaration.getType(), JT_COMPANION),
List.<JCExpression>nil(), null);
} else {
if (isOnValueType()) {
thisType = gen.makeJavaType(target.getQualifyingType());
} else {
thisType = gen.makeJavaType(target.getQualifyingType(), JT_NO_PRIMITIVES);
}
defaultedParameterInstance = callVarName.makeIdent();
}
JCVariableDecl thisDecl = gen.makeVar(varBaseName.suffixedBy("$this$"),
thisType,
defaultedParameterInstance);
return thisDecl;
}
@Override
protected TransformedInvocationPrimary transformPrimary(JCExpression primaryExpr,
String selector) {
// We need to build the vars before transforming the primary, because the primary is just a var
buildVars();
JCExpression result;
TransformedInvocationPrimary actualPrimExpr = super.transformPrimary(primaryExpr, selector);
result = actualPrimExpr.expr;
if (vars != null
&& !vars.isEmpty()
&& primaryExpr != null
&& selector != null) {
// Prepare the first argument holding the primary for the call
ProducedType type = ((Tree.MemberOrTypeExpression)getPrimary()).getTarget().getQualifyingType();
JCExpression varType;
if (isOnValueType()) {
varType = gen.makeJavaType(type);
} else {
if (getPrimary() instanceof QualifiedTypeExpression
&& !getPrimaryDeclaration().isShared()
&& type.getDeclaration() instanceof Interface) {
varType = gen.makeJavaType(type, JT_NO_PRIMITIVES | JT_COMPANION);
} else {
varType = gen.makeJavaType(type, JT_NO_PRIMITIVES);
}
}
vars.prepend(gen.makeVar(callVarName, varType, result));
result = callVarName.makeIdent();
}
return new TransformedInvocationPrimary(result, actualPrimExpr.selector);
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
09b788dc5c1b4d0b8ed06b42aed157105d1321c7 | 16fe41ad19e85f3612ed92008ab09d5f68fc58ed | /app/src/androidTest/java/com/example/mis_mapleitemsacrifice/ExampleInstrumentedTest.java | 831d1ac925da0c3865ee4f3f759ab5d44a5bfc5f | [] | no_license | hotdog1993/MIS_MapleItemSacrifice | 4d83076cbb4ab983c50dd5c7084dbe9a51ea0911 | 0eb16dc432160dfa3bfab45c0e63cf1eb26a6d2c | refs/heads/master | 2023-02-06T17:29:38.929161 | 2020-12-29T02:55:08 | 2020-12-29T02:55:08 | 324,908,170 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 782 | java | package com.example.mis_mapleitemsacrifice;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.mis_mapleitemsacrifice", appContext.getPackageName());
}
} | [
"hotdog1993@naver.com"
] | hotdog1993@naver.com |
867c8bb8a65f7237fdf6f6d8347bc769dee24cea | 29037c50c2087120c1edc589d7f864579331d73f | /concurrency-utils/src/producer/consumer/Producer.java | 006f8a6090150ee363dd2feaa4e496b9b3c8f154 | [] | no_license | oxakam/java-practice | 33a98a161e75c3f02b0c29606113d78e5d47cc0f | 9007d5363ae4e3671b9e3012e5bd1af0f2f16cb9 | refs/heads/main | 2023-02-24T09:53:55.836423 | 2021-01-22T18:57:26 | 2021-01-22T18:57:26 | 309,383,425 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 694 | java | package producer.consumer;
import java.util.concurrent.BlockingQueue;
public class Producer implements Runnable {
private int questionNo;
BlockingQueue<Integer> questionQueue;
//constructor
public Producer(BlockingQueue<Integer> questionQueue) {
this.questionQueue = questionQueue;
}
@Override
public void run() {
while(true) {
try {
//use synchronized(this) to make Producer thread 100% safe
synchronized(this) {
int nextQuestion = questionNo++;
System.out.println("Got new question: "+ nextQuestion);
questionQueue.put(nextQuestion);
}
}
catch (InterruptedException e) {
}
}
}
}
| [
"72361217+oxakam@users.noreply.github.com"
] | 72361217+oxakam@users.noreply.github.com |
9071a5422c835ccc94df0ba133ccc9f8a67ba5f1 | f1b9273549bc1d217f02f9a592b5722740c5267a | /app/src/main/java/tk/alexlopez/sallefy/models/UserRegister.java | 2bba4e6bd79bee3181313d51f22268f28df587ff | [] | no_license | AlexLopezDevelop/sallefy | 9d38838576101217e324c3a39d83b191dfc0a5bb | b614fae1db81c82618a359b66bca8c09841ff451 | refs/heads/master | 2023-03-17T08:06:18.661308 | 2020-06-12T17:49:42 | 2020-06-12T17:49:42 | 242,106,359 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,060 | java | package tk.alexlopez.sallefy.models;
import com.google.gson.annotations.SerializedName;
public class UserRegister {
@SerializedName("activated")
private Boolean activated;
@SerializedName("email")
private String email;
@SerializedName("firstName")
private String firstName;
@SerializedName("id")
private Integer id;
@SerializedName("imageUrl")
private String imageUrl;
@SerializedName("langKey")
private String langKey;
@SerializedName("lastName")
private String lastName;
@SerializedName("login")
private String login;
@SerializedName("password")
private String password;
public UserRegister(String email, String login, String password) {
this.activated = true;
this.email = email;
this.login = login;
this.password = password;
this.id = null;
}
public Boolean getActivated() {
return activated;
}
public void setActivated(Boolean activated) {
this.activated = activated;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"cristianalex.lopez@students.salle.url.edu"
] | cristianalex.lopez@students.salle.url.edu |
a6fcb3aeb312ad98be0f4b8e83409252eab6dc20 | b78a22aae434c4b3a4a1591fd7a2eadada1adb62 | /src/main/java/org/mt4j/input/inputProcessors/componentProcessors/tapProcessor/TapAndHoldEvent.java | fad8d906b7abee26c6bc36aa17c970633d2f1a5d | [] | no_license | thelsing/mt4j-input | 27534d8110b921ea6061c386eb61000db0b62af1 | 62927c2f3a3582f06e0b4cad3a02c0f234458216 | refs/heads/main | 2023-03-22T09:13:29.504808 | 2021-03-03T21:12:11 | 2021-03-03T21:12:11 | 344,260,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,394 | java | /***********************************************************************
* mt4j Copyright (c) 2008 - 2009 Christopher Ruff, Fraunhofer-Gesellschaft All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***********************************************************************/
package org.mt4j.input.inputProcessors.componentProcessors.tapProcessor;
import org.mt4j.input.inputData.InputCursor;
import org.mt4j.input.inputProcessors.IInputProcessor;
import org.mt4j.input.inputProcessors.MTGestureEvent;
import org.mt4j.util.math.Vector3D;
import java.awt.*;
/**
* The Class TapAndHoldEvent.
*
* @author Christopher Ruff
*/
public class TapAndHoldEvent extends MTGestureEvent {
/** The cursor. */
private InputCursor cursor;
/** The click point. */
private Vector3D clickPoint;
private int holdTime;
private float elapsedTime;
/**
* Instantiates a new tap and hold event.
*
* @param source the source
* @param id the id
* @param targetComponent the target component
* @param m the m
* @param clickPoint the click point
*/
public TapAndHoldEvent(IInputProcessor source, int id, Component targetComponent, InputCursor m, Vector3D clickPoint, int holdTime, float elapsedTime) {
super(source, id, targetComponent);
this.cursor = m;
this.clickPoint = clickPoint;
this.holdTime = holdTime;
this.elapsedTime = elapsedTime;
}
/**
* Gets the total time required to hold for a successfully completed gesture.
*
* @return the hold time
*/
public int getHoldTime() {
return holdTime;
}
/**
* Checks if the tap and hold gesture was completed successfully or if it was aborted/not finished yet.
*
* @return true, if is hold complete
*/
public boolean isHoldComplete() {
return elapsedTime >= holdTime
&& (getId() == MTGestureEvent.GESTURE_ENDED || getId() == MTGestureEvent.GESTURE_UPDATED);
}
/**
* Gets the elapsed holding time in milliseconds.
*
* @return the elapsed time
*/
public float getElapsedTime() {
return elapsedTime;
}
/**
* Gets the elapsed time normalized from 0..1.
* Clamps the value to 1.0 if it would be slightly higher.
*
* @return the elapsed time normalized
*/
public float getElapsedTimeNormalized() {
return (float)elapsedTime / (float)holdTime;
}
/**
* Gets the click point.
*
* @return the click point
*/
public Vector3D getLocationOnScreen() {
return clickPoint;
}
public Point getLocationOn(Component component)
{
Point cpos = component.getLocationOnScreen();
Point p = new Point();
p.x = (int)clickPoint.x - cpos.x;
p.y = (int)clickPoint.y - cpos.y;
return p;
}
/**
* Gets the cursor.
*
* @return the cursor
*/
public InputCursor getCursor() {
return cursor;
}
}
| [
"thomas.kunze@gmx.com"
] | thomas.kunze@gmx.com |
03d33cbf1676c6dcaf1eb8f70712286fd782d79a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/3/3_4c8dd9c09c9c928e5725b68791cc8f0099740896/SkinnableCharonPortal/3_4c8dd9c09c9c928e5725b68791cc8f0099740896_SkinnableCharonPortal_s.java | 3a0bd62831dc3eb5986cb66c4b2b87f168e06ffb | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 63,901 | java | /**********************************************************************************
* $URL$
* $Id$
***********************************************************************************
*
* Copyright (c) 2005, 2006 The Sakai Foundation.
*
* Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************************/
package org.sakaiproject.portal.charon;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.portal.api.Portal;
import org.sakaiproject.portal.api.PortalHandler;
import org.sakaiproject.portal.api.PortalRenderContext;
import org.sakaiproject.portal.api.PortalRenderEngine;
import org.sakaiproject.portal.api.PortalService;
import org.sakaiproject.portal.api.StoredState;
import org.sakaiproject.portal.charon.handlers.AtomHandler;
import org.sakaiproject.portal.charon.handlers.DirectToolHandler;
import org.sakaiproject.portal.charon.handlers.ErrorDoneHandler;
import org.sakaiproject.portal.charon.handlers.ErrorReportHandler;
import org.sakaiproject.portal.charon.handlers.GalleryHandler;
import org.sakaiproject.portal.charon.handlers.GalleryResetHandler;
import org.sakaiproject.portal.charon.handlers.HelpHandler;
import org.sakaiproject.portal.charon.handlers.LoginGalleryHandler;
import org.sakaiproject.portal.charon.handlers.LoginHandler;
import org.sakaiproject.portal.charon.handlers.LogoutGalleryHandler;
import org.sakaiproject.portal.charon.handlers.LogoutHandler;
import org.sakaiproject.portal.charon.handlers.NavLoginGalleryHandler;
import org.sakaiproject.portal.charon.handlers.NavLoginHandler;
import org.sakaiproject.portal.charon.handlers.OpmlHandler;
import org.sakaiproject.portal.charon.handlers.PDAHandler;
import org.sakaiproject.portal.charon.handlers.PageHandler;
import org.sakaiproject.portal.charon.handlers.PresenceHandler;
import org.sakaiproject.portal.charon.handlers.ReLoginHandler;
import org.sakaiproject.portal.charon.handlers.RssHandler;
import org.sakaiproject.portal.charon.handlers.SiteHandler;
import org.sakaiproject.portal.charon.handlers.SiteResetHandler;
import org.sakaiproject.portal.charon.handlers.StaticScriptsHandler;
import org.sakaiproject.portal.charon.handlers.StaticStylesHandler;
import org.sakaiproject.portal.charon.handlers.ToolHandler;
import org.sakaiproject.portal.charon.handlers.ToolResetHandler;
import org.sakaiproject.portal.charon.handlers.WorksiteHandler;
import org.sakaiproject.portal.charon.handlers.WorksiteResetHandler;
import org.sakaiproject.portal.charon.handlers.XLoginHandler;
import org.sakaiproject.portal.render.api.RenderResult;
import org.sakaiproject.portal.render.cover.ToolRenderService;
import org.sakaiproject.portal.util.ErrorReporter;
import org.sakaiproject.portal.util.PortalSiteHelper;
import org.sakaiproject.portal.util.ToolURLManagerImpl;
import org.sakaiproject.entity.api.ResourceProperties;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.api.SitePage;
import org.sakaiproject.site.api.ToolConfiguration;
import org.sakaiproject.site.cover.SiteService;
import org.sakaiproject.thread_local.cover.ThreadLocalManager;
import org.sakaiproject.tool.api.ActiveTool;
import org.sakaiproject.tool.api.Placement;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.Tool;
import org.sakaiproject.tool.api.ToolException;
import org.sakaiproject.tool.api.ToolSession;
import org.sakaiproject.tool.api.ToolURL;
import org.sakaiproject.tool.cover.ActiveToolManager;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.tool.cover.ToolManager;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.user.cover.UserDirectoryService;
import org.sakaiproject.util.BasicAuth;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.StringUtil;
import org.sakaiproject.util.Web;
import net.sourceforge.wurfl.wurflapi.*;
/**
* <p/> Charon is the Sakai Site based portal.
* </p>
*
* @since Sakai 2.4
* @version $Rev$
*
*/
public class SkinnableCharonPortal extends HttpServlet implements Portal
{
/**
* Our log (commons).
*/
private static Log M_log = LogFactory.getLog(SkinnableCharonPortal.class);
/**
* messages.
*/
private static ResourceLoader rloader = new ResourceLoader("sitenav");
/**
* Parameter value to indicate to look up a tool ID within a site
*/
protected static final String PARAM_SAKAI_SITE = "sakai.site";
private BasicAuth basicAuth = null;
private boolean enableDirect = false;
private PortalService portalService;
private static final String PADDING = " ";
private static final String INCLUDE_BOTTOM = "include-bottom";
private static final String INCLUDE_LOGIN = "include-login";
private static final String INCLUDE_TITLE = "include-title";
private PortalSiteHelper siteHelper = new PortalSiteHelper();
// private HashMap<String, PortalHandler> handlerMap = new HashMap<String,
// PortalHandler>();
private GalleryHandler galleryHandler;
private WorksiteHandler worksiteHandler;
private SiteHandler siteHandler;
private String portalContext;
private String PROP_PARENT_ID = SiteService.PROP_PARENT_ID;
// 2.3 back port
// public String String PROP_PARENT_ID = "sakai:parent-id";
private String PROP_SHOW_SUBSITES = SiteService.PROP_SHOW_SUBSITES ;
// 2.3 back port
// public String PROP_SHOW_SUBSITES = "sakai:show-subsites";
// http://wurfl.sourceforge.net/
private boolean wurflLoaded = false;
public CapabilityMatrix cm = null;
public UAManager uam = null;
public String getPortalContext()
{
return portalContext;
}
/**
* Shutdown the servlet.
*/
public void destroy()
{
M_log.info("destroy()");
portalService.removePortal(this);
super.destroy();
}
public void doError(HttpServletRequest req, HttpServletResponse res, Session session,
int mode) throws ToolException, IOException
{
if (ThreadLocalManager.get(ATTR_ERROR) == null)
{
ThreadLocalManager.set(ATTR_ERROR, ATTR_ERROR);
// send to the error site
switch (mode)
{
case ERROR_SITE:
{
siteHandler.doSite(req, res, session, "!error", null, req
.getContextPath()
+ req.getServletPath());
break;
}
case ERROR_GALLERY:
{
galleryHandler.doGallery(req, res, session, "!error", null, req
.getContextPath()
+ req.getServletPath());
break;
}
case ERROR_WORKSITE:
{
worksiteHandler.doWorksite(req, res, session, "!error", null, req
.getContextPath()
+ req.getServletPath());
break;
}
}
return;
}
// error and we cannot use the error site...
// form a context sensitive title
String title = ServerConfigurationService.getString("ui.service") + " : Portal";
// start the response
PortalRenderContext rcontext = startPageContext("", title, null, req);
showSession(rcontext, true);
showSnoop(rcontext, true, getServletConfig(), req);
sendResponse(rcontext, res, "error", null);
}
private void showSnoop(PortalRenderContext rcontext, boolean b,
ServletConfig servletConfig, HttpServletRequest req)
{
Enumeration e = null;
rcontext.put("snoopRequest", req.toString());
if (servletConfig != null)
{
Map<String, Object> m = new HashMap<String, Object>();
e = servletConfig.getInitParameterNames();
if (e != null)
{
boolean first = true;
while (e.hasMoreElements())
{
String param = (String) e.nextElement();
m.put(param, servletConfig.getInitParameter(param));
}
}
rcontext.put("snoopServletConfigParams", m);
}
rcontext.put("snoopRequest", req);
e = req.getHeaderNames();
if (e.hasMoreElements())
{
Map<String, Object> m = new HashMap<String, Object>();
while (e.hasMoreElements())
{
String name = (String) e.nextElement();
m.put(name, req.getHeader(name));
}
rcontext.put("snoopRequestHeaders", m);
}
e = req.getParameterNames();
if (e.hasMoreElements())
{
Map<String, Object> m = new HashMap<String, Object>();
while (e.hasMoreElements())
{
String name = (String) e.nextElement();
m.put(name, req.getParameter(name));
}
rcontext.put("snoopRequestParamsSingle", m);
}
e = req.getParameterNames();
if (e.hasMoreElements())
{
Map<String, Object> m = new HashMap<String, Object>();
while (e.hasMoreElements())
{
String name = (String) e.nextElement();
String[] vals = (String[]) req.getParameterValues(name);
StringBuilder sb = new StringBuilder();
if (vals != null)
{
sb.append(vals[0]);
for (int i = 1; i < vals.length; i++)
sb.append(" ").append(vals[i]);
}
m.put(name, sb.toString());
}
rcontext.put("snoopRequestParamsMulti", m);
}
e = req.getAttributeNames();
if (e.hasMoreElements())
{
Map<String, Object> m = new HashMap<String, Object>();
while (e.hasMoreElements())
{
String name = (String) e.nextElement();
m.put(name, req.getAttribute(name));
}
rcontext.put("snoopRequestAttr", m);
}
}
protected void doThrowableError(HttpServletRequest req, HttpServletResponse res,
Throwable t)
{
ErrorReporter err = new ErrorReporter();
err.report(req, res, t);
}
/*
* Include the children of a site
*/
public void includeSubSites(PortalRenderContext rcontext, HttpServletRequest req,
Session session, String siteId, String toolContextPath,
String prefix, boolean resetTools)
// throws ToolException, IOException
{
if ( siteId == null || rcontext == null ) return;
// Check the setting as to whether we are to do this
String pref = ServerConfigurationService.getString("portal.experimental.includesubsites");
if ( "never".equals(pref) ) return;
Site site = null;
try
{
site = siteHelper.getSiteVisit(siteId);
}
catch (Exception e)
{
return;
}
if ( site == null ) return;
ResourceProperties rp = site.getProperties();
String showSub = rp.getProperty(PROP_SHOW_SUBSITES);
// System.out.println("Checking subsite pref:"+site.getTitle()+" pref="+pref+" show="+showSub);
if ( "false".equals(showSub) ) return;
if ( "false".equals(pref) )
{
if ( ! "true".equals(showSub) ) return;
}
List<Site> mySites = siteHelper.getSubSites(site);
if ( mySites == null || mySites.size() < 1 ) return;
List l = convertSitesToMaps(req, mySites, prefix, siteId,
/* myWorkspaceSiteId */ null,
/* includeSummary */ false,
/* expandSite */ false,
resetTools,
/* doPages */ false,
toolContextPath,
(session.getUserId() != null ));
rcontext.put("subSites", l);
}
/*
* Produce a portlet like view with the navigation all at the top with
* implicit reset
*/
public PortalRenderContext includePortal(HttpServletRequest req,
HttpServletResponse res, Session session, String siteId, String toolId,
String toolContextPath, String prefix, boolean doPages, boolean resetTools,
boolean includeSummary, boolean expandSite) throws ToolException, IOException
{
String errorMessage = null;
// find the site, for visiting
Site site = null;
try
{
site = siteHelper.getSiteVisit(siteId);
}
catch (IdUnusedException e)
{
errorMessage = "Unable to find site: " + siteId;
siteId = null;
toolId = null;
}
catch (PermissionException e)
{
if (session.getUserId() == null)
{
errorMessage = "No permission for anynymous user to view site: " + siteId;
}
else
{
errorMessage = "No permission to view site: " + siteId;
}
siteId = null;
toolId = null; // Tool needs the site and needs it to be visitable
}
// Get the Tool Placement
ToolConfiguration placement = null;
if (site != null && toolId != null)
{
placement = SiteService.findTool(toolId);
if (placement == null)
{
errorMessage = "Unable to find tool placement " + toolId;
toolId = null;
}
boolean thisTool = siteHelper.allowTool(site, placement);
if (!thisTool)
{
errorMessage = "No permission to view tool placement " + toolId;
toolId = null;
placement = null;
}
}
// Get the user's My WorkSpace and its ID
Site myWorkspaceSite = siteHelper.getMyWorkspace(session);
String myWorkspaceSiteId = null;
if (myWorkspaceSite != null)
{
myWorkspaceSiteId = myWorkspaceSite.getId();
}
// form a context sensitive title
String title = ServerConfigurationService.getString("ui.service");
if (site != null)
{
title = title + ":" + site.getTitle();
if (placement != null) title = title + " : " + placement.getTitle();
}
// start the response
String siteType = null;
String siteSkin = null;
if (site != null)
{
siteType = calcSiteType(siteId);
siteSkin = site.getSkin();
}
PortalRenderContext rcontext = startPageContext(siteType, title, siteSkin, req);
// Make the top Url where the "top" url is
String portalTopUrl = Web.serverUrl(req)
+ ServerConfigurationService.getString("portalPath") + "/";
if (prefix != null) portalTopUrl = portalTopUrl + prefix + "/";
rcontext.put("portalTopUrl", portalTopUrl);
rcontext.put("loggedIn", Boolean.valueOf(session.getUserId() != null));
if (placement != null)
{
Map m = includeTool(res, req, placement);
if (m != null) rcontext.put("currentPlacement", m);
}
boolean loggedIn = session.getUserId() != null;
if (site != null)
{
Map m = convertSiteToMap(req, site, prefix, siteId, myWorkspaceSiteId,
includeSummary,
/* expandSite */true, resetTools, doPages, toolContextPath, loggedIn);
if (m != null) rcontext.put("currentSite", m);
}
List mySites = siteHelper.getAllSites(req, session, true);
List l = convertSitesToMaps(req, mySites, prefix, siteId, myWorkspaceSiteId,
includeSummary, expandSite, resetTools, doPages, toolContextPath,
loggedIn);
rcontext.put("allSites", l);
includeLogin(rcontext, req, session);
includeBottom(rcontext);
return rcontext;
}
public boolean isPortletPlacement(Placement placement)
{
if (placement == null) return false;
Properties toolProps = placement.getTool().getFinalConfig();
if (toolProps == null) return false;
String portletContext = toolProps
.getProperty(PortalService.TOOL_PORTLET_CONTEXT_PATH);
return (portletContext != null);
}
public Map includeTool(HttpServletResponse res, HttpServletRequest req,
ToolConfiguration placement) throws IOException
{
// find the tool registered for this
ActiveTool tool = ActiveToolManager.getActiveTool(placement.getToolId());
if (tool == null)
{
// doError(req, res, session);
return null;
}
// Get the Site - we could change the API call in the future to
// pass site in, but that would break portals that extend Charon
// so for now we simply look this up here.
String siteId = placement.getSiteId();
Site site = null;
try
{
site = SiteService.getSiteVisit(siteId);
}
catch (IdUnusedException e)
{
site = null;
}
catch (PermissionException e)
{
site = null;
}
// FIXME: This does not look absolutely right,
// this appears to say, reset all tools on the page since there
// is no filtering of the tool that is bing reset, surely there
// should be a check which tool is being reset, rather than all
// tools on the page.
// let the tool do some the work (include) (see note above)
String toolUrl = ServerConfigurationService.getToolUrl() + "/"
+ Web.escapeUrl(placement.getId()) + "/";
String titleString = Web.escapeHtml(placement.getTitle());
// Reset the tool state if requested
if ("true".equals(req.getParameter(portalService.getResetStateParam()))
|| "true".equals(portalService.getResetState()))
{
Session s = SessionManager.getCurrentSession();
ToolSession ts = s.getToolSession(placement.getId());
ts.clearAttributes();
}
// emit title information
// for the reset button
boolean showResetButton = !"false".equals(placement.getConfig().getProperty(
Portal.TOOLCONFIG_SHOW_RESET_BUTTON));
String resetActionUrl = PortalStringUtil.replaceFirst(toolUrl, "/tool/",
"/tool-reset/")
+ "?panel=Main";
// Reset is different for Portlets
if (isPortletPlacement(placement))
{
resetActionUrl = Web.serverUrl(req)
+ ServerConfigurationService.getString("portalPath")
+ req.getPathInfo() + "?sakai.state.reset=true";
}
// for the help button
// get the help document ID from the tool config (tool registration
// usually).
// The help document ID defaults to the tool ID
boolean helpEnabledGlobally = ServerConfigurationService.getBoolean(
"display.help.icon", true);
boolean helpEnabledInTool = !"false".equals(placement.getConfig().getProperty(
Portal.TOOLCONFIG_SHOW_HELP_BUTTON));
boolean showHelpButton = helpEnabledGlobally && helpEnabledInTool;
String helpActionUrl = "";
if (showHelpButton)
{
String helpDocUrl = placement.getConfig().getProperty(
Portal.TOOLCONFIG_HELP_DOCUMENT_URL);
String helpDocId = placement.getConfig().getProperty(
Portal.TOOLCONFIG_HELP_DOCUMENT_ID);
if (helpDocUrl != null && helpDocUrl.length() > 0)
{
helpActionUrl = helpDocUrl;
}
else
{
if (helpDocId == null || helpDocId.length() == 0)
{
helpDocId = tool.getId();
}
helpActionUrl = ServerConfigurationService.getHelpUrl(helpDocId);
}
}
Map<String, Object> toolMap = new HashMap<String, Object>();
RenderResult result = ToolRenderService.render(placement, req, res,
getServletContext());
if (result.getJSR168HelpUrl() != null)
{
toolMap.put("toolJSR168Help", Web.serverUrl(req) + result.getJSR168HelpUrl());
}
// Must have site.upd to see the Edit button
if (result.getJSR168EditUrl() != null && site != null)
{
if (SecurityService.unlock(SiteService.SECURE_UPDATE_SITE, site
.getReference()))
{
toolMap.put("toolJSR168Edit", Web.serverUrl(req)
+ result.getJSR168EditUrl());
}
}
toolMap.put("toolRenderResult", result);
toolMap.put("hasRenderResult", Boolean.valueOf(true));
toolMap.put("toolUrl", toolUrl);
if (isPortletPlacement(placement))
{
toolMap.put("toolPlacementIDJS", "_self");
}
else
{
toolMap.put("toolPlacementIDJS", Web.escapeJavascript("Main"
+ placement.getId()));
}
toolMap.put("toolResetActionUrl", resetActionUrl);
toolMap.put("toolTitle", titleString);
toolMap.put("toolShowResetButton", Boolean.valueOf(showResetButton));
toolMap.put("toolShowHelpButton", Boolean.valueOf(showHelpButton));
toolMap.put("toolHelpActionUrl", helpActionUrl);
return toolMap;
}
public List<Map> convertSitesToMaps(HttpServletRequest req, List mySites,
String prefix, String currentSiteId, String myWorkspaceSiteId,
boolean includeSummary, boolean expandSite, boolean resetTools,
boolean doPages, String toolContextPath, boolean loggedIn)
{
List<Map> l = new ArrayList<Map>();
Map<String,Integer> depthChart = new HashMap<String,Integer>();
boolean motdDone = false;
for (Iterator i = mySites.iterator(); i.hasNext();)
{
Site s = (Site) i.next();
// The first site is the current site
if (currentSiteId == null) currentSiteId = s.getId();
ResourceProperties rp = s.getProperties();
String ourParent = rp.getProperty(PROP_PARENT_ID);
// System.out.println("Depth Site:"+s.getTitle()+" parent="+ourParent);
Integer cDepth = new Integer(0);
if ( ourParent != null )
{
Integer pDepth = depthChart.get(ourParent);
if ( pDepth != null )
{
cDepth = pDepth + 1;
}
}
// System.out.println("Depth = "+cDepth);
depthChart.put(s.getId(),cDepth);
Map m = convertSiteToMap(req, s, prefix, currentSiteId, myWorkspaceSiteId,
includeSummary, expandSite, resetTools, doPages, toolContextPath,
loggedIn);
// Add the Depth of the site
m.put("depth",cDepth);
if (includeSummary && m.get("rssDescription") == null)
{
if (!motdDone)
{
siteHelper.summarizeTool(m, s, "sakai.motd");
motdDone = true;
}
else
{
siteHelper.summarizeTool(m, s, "sakai.announcements");
}
}
l.add(m);
}
return l;
}
public Map convertSiteToMap(HttpServletRequest req, Site s, String prefix,
String currentSiteId, String myWorkspaceSiteId, boolean includeSummary,
boolean expandSite, boolean resetTools, boolean doPages,
String toolContextPath, boolean loggedIn)
{
if (s == null) return null;
Map<String, Object> m = new HashMap<String, Object>();
// In case the effective is different than the actual site
String effectiveSite = siteHelper.getSiteEffectiveId(s);
boolean isCurrentSite = currentSiteId != null
&& (s.getId().equals(currentSiteId) || effectiveSite
.equals(currentSiteId));
m.put("isCurrentSite", Boolean.valueOf(isCurrentSite));
m.put("isMyWorkspace", Boolean.valueOf(myWorkspaceSiteId != null
&& (s.getId().equals(myWorkspaceSiteId) || effectiveSite
.equals(myWorkspaceSiteId))));
m.put("siteTitle", Web.escapeHtml(s.getTitle()));
m.put("siteDescription", Web.escapeHtml(s.getDescription()));
String siteUrl = Web.serverUrl(req)
+ ServerConfigurationService.getString("portalPath") + "/";
if (prefix != null) siteUrl = siteUrl + prefix + "/";
// siteUrl = siteUrl + Web.escapeUrl(siteHelper.getSiteEffectiveId(s));
m.put("siteUrl", siteUrl + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)));
ResourceProperties rp = s.getProperties();
String ourParent = rp.getProperty(PROP_PARENT_ID);
boolean isChild = ourParent != null;
m.put("isChild",Boolean.valueOf(isChild) ) ;
m.put("parentSite",ourParent);
// Get the current site hierarchy
if ( isChild && isCurrentSite )
{
List<Site> pwd = getPwd(s,ourParent);
if ( pwd != null )
{
List<Map> l = new ArrayList<Map>();
for(int i=0;i<pwd.size(); i++ )
{
Site site = pwd.get(i);
// System.out.println("PWD["+i+"]="+site.getId()+" "+site.getTitle());
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("siteTitle", Web.escapeHtml(site.getTitle()));
pm.put("siteUrl", siteUrl + Web.escapeUrl(siteHelper.getSiteEffectiveId(site)));
l.add(pm);
}
m.put("pwd",l);
}
}
if (includeSummary)
{
siteHelper.summarizeTool(m, s, "sakai.announce");
}
if (expandSite)
{
Map pageMap = pageListToMap(req, loggedIn, s, /* SitePage */null,
toolContextPath, prefix, doPages, resetTools, includeSummary);
m.put("sitePages", pageMap);
}
return m;
}
public List<Site> getPwd(Site s,String ourParent)
{
if ( ourParent == null ) return null;
// System.out.println("Getting Current Working Directory for "+s.getId()+" "+s.getTitle());
int depth = 0;
Vector<Site> pwd = new Vector<Site>();
Set<String> added = new HashSet<String>();
// Add us to the list at the top (will become the end)
pwd.add(s);
added.add(s.getId());
// Make sure we don't go on forever
while( ourParent != null && depth < 8 )
{
depth++;
Site site = null;
try
{
site = SiteService.getSiteVisit(ourParent);
}
catch (Exception e)
{
break;
}
// We have no patience with loops
if ( added.contains(site.getId()) ) break;
// System.out.println("Adding Parent "+site.getId()+" "+site.getTitle());
pwd.insertElementAt(site,0); // Push down stack
added.add(site.getId());
ResourceProperties rp = site.getProperties();
ourParent = rp.getProperty(PROP_PARENT_ID);
}
// PWD is only defined for > 1 site
if ( pwd.size() < 2 ) return null;
return pwd;
}
/**
* Respond to navigation / access requests.
*
* @param req
* The servlet request.
* @param res
* The servlet response.
* @throws javax.servlet.ServletException.
* @throws java.io.IOException.
*/
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
int stat = PortalHandler.NEXT;
try
{
basicAuth.doLogin(req);
if (!ToolRenderService.preprocess(req, res, getServletContext()))
{
return;
}
// Check to see if the pre-process step has redirected us - if so,
// our work is done here - we will likely come back again to finish
// our
// work.
if (res.isCommitted())
{
return;
}
// get the Sakai session
Session session = SessionManager.getCurrentSession();
// recognize what to do from the path
String option = req.getPathInfo();
// if missing, set it to home or gateway
if ((option == null) || ("/".equals(option)))
{
if (session.getUserId() == null)
{
String siteId = null;
if (siteHelper.doGatewaySiteList())
{
List<Site> mySites = siteHelper.getAllSites(req, session, true);
if ( mySites.size() > 0 ) siteId = mySites.get(0).getId();
}
if ( siteId == null )
{
siteId = ServerConfigurationService.getGatewaySiteId();
}
option = "/site/" + siteId;
}
else
{
option = "/site/" + SiteService.getUserSiteId(session.getUserId());
}
}
// get the parts (the first will be "")
String[] parts = option.split("/");
Map<String, PortalHandler> handlerMap = portalService.getHandlerMap(this);
PortalHandler ph = handlerMap.get(parts[1]);
if (ph != null)
{
stat = ph.doGet(parts, req, res, session);
if (res.isCommitted())
{
if (stat != PortalHandler.RESET_DONE)
{
portalService.setResetState(null);
}
return;
}
}
if (stat == PortalHandler.NEXT)
{
List<PortalHandler> urlHandlers;
for (Iterator<PortalHandler> i = handlerMap.values().iterator(); i
.hasNext();)
{
ph = i.next();
stat = ph.doGet(parts, req, res, session);
if (res.isCommitted())
{
if (stat != PortalHandler.RESET_DONE)
{
portalService.setResetState(null);
}
return;
}
// this should be
if (stat != PortalHandler.NEXT)
{
break;
}
}
}
if (stat == PortalHandler.NEXT)
{
doError(req, res, session, Portal.ERROR_SITE);
}
}
catch (Throwable t)
{
doThrowableError(req, res, t);
}
// Make sure to clear any reset State at the end of the request unless
// we *just* set it
if (stat != PortalHandler.RESET_DONE)
{
portalService.setResetState(null);
}
}
public void doLogin(HttpServletRequest req, HttpServletResponse res, Session session,
String returnPath, boolean skipContainer) throws ToolException
{
try
{
if (basicAuth.doAuth(req, res))
{
// System.err.println("BASIC Auth Request Sent to the Browser
// ");
return;
}
}
catch (IOException ioex)
{
throw new ToolException(ioex);
}
// setup for the helper if needed (Note: in session, not tool session,
// special for Login helper)
// Note: always set this if we are passed in a return path... a blank
// return path is valid... to clean up from
// possible abandened previous login attempt -ggolden
if (returnPath != null)
{
// where to go after
session.setAttribute(Tool.HELPER_DONE_URL, Web.returnUrl(req, returnPath));
}
ActiveTool tool = ActiveToolManager.getActiveTool("sakai.login");
// to skip container auth for this one, forcing things to be handled
// internaly, set the "extreme" login path
String loginPath = (skipContainer ? "/xlogin" : "/relogin");
String context = req.getContextPath() + req.getServletPath() + loginPath;
tool.help(req, res, context, loginPath);
}
/**
* Process a logout
*
* @param req
* Request object
* @param res
* Response object
* @param session
* Current session
* @param returnPath
* if not null, the path to use for the end-user browser redirect
* after the logout is complete. Leave null to use the configured
* logged out URL.
* @throws IOException
*/
public void doLogout(HttpServletRequest req, HttpServletResponse res,
Session session, String returnPath) throws ToolException
{
// where to go after
if (returnPath == null)
{
// if no path, use the configured logged out URL
String loggedOutUrl = ServerConfigurationService.getLoggedOutUrl();
session.setAttribute(Tool.HELPER_DONE_URL, loggedOutUrl);
}
else
{
// if we have a path, use a return based on the request and this
// path
// Note: this is currently used only as "/gallery"
// - we should really add a
// ServerConfigurationService.getGalleryLoggedOutUrl()
// and change the returnPath to a normal/gallery indicator -ggolden
String loggedOutUrl = Web.returnUrl(req, returnPath);
session.setAttribute(Tool.HELPER_DONE_URL, loggedOutUrl);
}
ActiveTool tool = ActiveToolManager.getActiveTool("sakai.login");
String context = req.getContextPath() + req.getServletPath() + "/logout";
tool.help(req, res, context, "/logout");
}
/** Set up the WURFL objects - to use most classes will
* extend the register method and call this setup.
*/
public void setupWURFL()
{
// Only do this once
if ( wurflLoaded ) return;
wurflLoaded = true;
try {
ObjectsManager.initFromWebApplication(getServletContext());
uam = ObjectsManager.getUAManagerInstance();
cm = ObjectsManager.getCapabilityMatrixInstance();
if ( cm == null ) uam = null;
if ( uam == null ) cm = null;
if ( cm == null )
{
M_log.info("WURFL Initialization failed - PDA support may be limited");
}
else
{
M_log.info("WURFL Initialization cm="+cm+" uam="+uam);
}
}
catch (Exception e)
{
M_log.info("WURFL Initialization failed - PDA support may be limited "+e);
}
}
// Read the Wireless Universal Resource File and determine the display size
// http://wurfl.sourceforge.net/
public void setupMobileDevice(HttpServletRequest req, PortalRenderContext rcontext)
{
setupWURFL();
if ( cm == null || uam == null ) return;
String userAgent = req.getHeader("user-agent");
String device = uam.getDeviceIDFromUALoose(userAgent);
// System.out.println("device="+device+" agent="+userAgent);
// Not a mobile device
if ( device == null || device.length() < 1 || device.startsWith("generic") ) return;
rcontext.put("wurflDevice",device);
// Check to see if we have too few columns of text
String columns = cm.getCapabilityForDevice(device,"columns");
{
int icol = -1;
try { icol = Integer.parseInt(columns); } catch (Throwable t) { icol = -1; }
if ( icol > 1 && icol < 50 )
{
rcontext.put("wurflSmallDisplay",Boolean.TRUE);
return;
}
}
// Check if we have too few pixels
String width = cm.getCapabilityForDevice(device,"resolution_width");
if ( width != null && width.length() > 1 )
{
int iwidth = -1;
try { iwidth = Integer.parseInt(width); } catch (Throwable t) { iwidth = -1; }
if ( iwidth > 1 && iwidth < 400 )
{
rcontext.put("wurflSmallDisplay",Boolean.TRUE);
return;
}
}
}
public PortalRenderContext startPageContext(String siteType, String title,
String skin, HttpServletRequest request)
{
PortalRenderEngine rengine = portalService
.getRenderEngine(portalContext, request);
PortalRenderContext rcontext = rengine.newRenderContext(request);
if (skin == null)
{
skin = ServerConfigurationService.getString("skin.default");
}
String skinRepo = ServerConfigurationService.getString("skin.repo");
rcontext.put("pageSkinRepo", skinRepo);
rcontext.put("pageSkin", skin);
rcontext.put("pageTitle", Web.escapeHtml(title));
rcontext.put("pageScriptPath", getScriptPath());
rcontext.put("pageTop", Boolean.valueOf(true));
rcontext.put("rloader", rloader);
// rcontext.put("sitHelp", Web.escapeHtml(rb.getString("sit_help")));
// rcontext.put("sitReset", Web.escapeHtml(rb.getString("sit_reset")));
if (siteType != null && siteType.length() > 0)
{
siteType = "class=\"" + siteType + "\"";
}
else
{
siteType = "";
}
rcontext.put("pageSiteType", siteType);
rcontext.put("toolParamResetState", portalService.getResetStateParam());
return rcontext;
}
/**
* Respond to data posting requests.
*
* @param req
* The servlet request.
* @param res
* The servlet response.
* @throws ServletException
* @throws IOException
*/
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
int stat = PortalHandler.NEXT;
try
{
basicAuth.doLogin(req);
if (!ToolRenderService.preprocess(req, res, getServletContext()))
{
// System.err.println("POST FAILED, REDIRECT ?");
return;
}
// Check to see if the pre-process step has redirected us - if so,
// our work is done here - we will likely come back again to finish
// our
// work. T
if (res.isCommitted())
{
return;
}
// get the Sakai session
Session session = SessionManager.getCurrentSession();
// recognize what to do from the path
String option = req.getPathInfo();
// if missing, we have a stray post
if ((option == null) || ("/".equals(option)))
{
doError(req, res, session, ERROR_SITE);
return;
}
// get the parts (the first will be "")
String[] parts = option.split("/");
Map<String, PortalHandler> handlerMap = portalService.getHandlerMap(this);
PortalHandler ph = handlerMap.get(parts[1]);
if (ph != null)
{
stat = ph.doPost(parts, req, res, session);
if (res.isCommitted())
{
return;
}
}
if (stat == PortalHandler.NEXT)
{
List<PortalHandler> urlHandlers;
for (Iterator<PortalHandler> i = handlerMap.values().iterator(); i
.hasNext();)
{
ph = i.next();
stat = ph.doPost(parts, req, res, session);
if (res.isCommitted())
{
return;
}
// this should be
if (stat != PortalHandler.NEXT)
{
break;
}
}
}
if (stat == PortalHandler.NEXT)
{
doError(req, res, session, Portal.ERROR_SITE);
}
}
catch (Throwable t)
{
doThrowableError(req, res, t);
}
}
/*
* Checks to see which form of tool or page placement we have. The normal
* placement is a GUID. However when the parameter sakai.site is added to
* the request, the placement can be of the form sakai.resources. This
* routine determines which form of the placement id, and if this is the
* second type, performs the lookup and returns the GUID of the placement.
* If we cannot resolve the placement, we simply return the passed in
* placement ID. If we cannot visit the site, we send the user to login
* processing and return null to the caller.
*/
public String getPlacement(HttpServletRequest req, HttpServletResponse res,
Session session, String placementId, boolean doPage) throws ToolException
{
String siteId = req.getParameter(PARAM_SAKAI_SITE);
if (siteId == null) return placementId; // Standard placement
// find the site, for visiting
// Sites like the !gateway site allow visits by anonymous
Site site = null;
try
{
site = SiteService.getSiteVisit(siteId);
}
catch (IdUnusedException e)
{
return placementId; // cannot resolve placement
}
catch (PermissionException e)
{
// If we are not logged in, try again after we log in, otherwise
// punt
if (session.getUserId() == null)
{
doLogin(req, res, session, req.getPathInfo() + "?sakai.site="
+ res.encodeURL(siteId), false);
return null;
}
return placementId; // cannot resolve placement
}
if (site == null) return placementId;
ToolConfiguration toolConfig = site.getToolForCommonId(placementId);
if (toolConfig == null) return placementId;
if (doPage)
{
return toolConfig.getPageId();
}
else
{
return toolConfig.getId();
}
}
public void setupForward(HttpServletRequest req, HttpServletResponse res,
Placement p, String skin) throws ToolException
{
// setup html information that the tool might need (skin, body on load,
// js includes, etc).
if (skin == null || skin.length() == 0)
skin = ServerConfigurationService.getString("skin.default");
String skinRepo = ServerConfigurationService.getString("skin.repo");
String headCssToolBase = "<link href=\""
+ skinRepo
+ "/tool_base.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />\n";
String headCssToolSkin = "<link href=\"" + skinRepo + "/" + skin
+ "/tool.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />\n";
String headCss = headCssToolBase + headCssToolSkin;
String headJs = "<script type=\"text/javascript\" language=\"JavaScript\" src=\"/library/js/headscripts.js\"></script>\n";
String head = headCss + headJs;
StringBuilder bodyonload = new StringBuilder();
if (p != null)
{
String element = Web.escapeJavascript("Main" + p.getId());
bodyonload.append("setMainFrameHeight('" + element + "');");
}
bodyonload.append("setFocus(focus_path);");
// to force all non-legacy tools to use the standard css
// to help in transition (needs corresponding entry in properties)
// if
// ("true".equals(ServerConfigurationService.getString("skin.force")))
// {
// headJs = headJs + headCss;
// }
req.setAttribute("sakai.html.head", head);
req.setAttribute("sakai.html.head.css", headCss);
req.setAttribute("sakai.html.head.css.base", headCssToolBase);
req.setAttribute("sakai.html.head.css.skin", headCssToolSkin);
req.setAttribute("sakai.html.head.js", headJs);
req.setAttribute("sakai.html.body.onload", bodyonload.toString());
portalService.getRenderEngine(portalContext, req).setupForward(req, res, p, skin);
}
/**
* Forward to the tool - but first setup JavaScript/CSS etc that the tool
* will render
*/
public void forwardTool(ActiveTool tool, HttpServletRequest req,
HttpServletResponse res, Placement p, String skin, String toolContextPath,
String toolPathInfo) throws ToolException
{
// if there is a stored request state, and path, extract that from the
// session and reinstance it
// let the tool do the the work (forward)
if (enableDirect)
{
StoredState ss = portalService.getStoredState();
if (ss == null || !toolContextPath.equals(ss.getToolContextPath()))
{
setupForward(req, res, p, skin);
req.setAttribute(ToolURL.MANAGER, new ToolURLManagerImpl(res));
tool.forward(req, res, p, toolContextPath, toolPathInfo);
}
else
{
M_log.debug("Restoring StoredState [" + ss + "]");
HttpServletRequest sreq = ss.getRequest(req);
Placement splacement = ss.getPlacement();
String stoolContext = ss.getToolContextPath();
String stoolPathInfo = ss.getToolPathInfo();
ActiveTool stool = ActiveToolManager.getActiveTool(p.getToolId());
String sskin = ss.getSkin();
setupForward(sreq, res, splacement, sskin);
req.setAttribute(ToolURL.MANAGER, new ToolURLManagerImpl(res));
stool.forward(sreq, res, splacement, stoolContext, stoolPathInfo);
// this is correct as we have checked the context path of the
// tool
portalService.setStoredState(null);
}
}
else
{
setupForward(req, res, p, skin);
req.setAttribute(ToolURL.MANAGER, new ToolURLManagerImpl(res));
tool.forward(req, res, p, toolContextPath, toolPathInfo);
}
}
public void forwardPortal(ActiveTool tool, HttpServletRequest req,
HttpServletResponse res, ToolConfiguration p, String skin,
String toolContextPath, String toolPathInfo) throws ToolException,
IOException
{
// if there is a stored request state, and path, extract that from the
// session and reinstance it
// generate the forward to the tool page placement
String portalPlacementUrl = "/portal" + getPortalPageUrl(p);
res.sendRedirect(portalPlacementUrl);
return;
}
public String getPortalPageUrl(ToolConfiguration p)
{
return "/site/" + p.getSiteId() + "/page/" + p.getPageId();
}
protected String getScriptPath()
{
return "/library/js/";
}
/**
* Access the Servlet's information display.
*
* @return servlet information.
*/
public String getServletInfo()
{
return "Sakai Charon Portal";
}
public void includeBottom(PortalRenderContext rcontext)
{
if (rcontext.uses(INCLUDE_BOTTOM))
{
String copyright = ServerConfigurationService
.getString("bottom.copyrighttext");
String service = ServerConfigurationService.getString("ui.service", "Sakai");
String serviceVersion = ServerConfigurationService.getString(
"version.service", "?");
String sakaiVersion = ServerConfigurationService.getString("version.sakai",
"?");
String server = ServerConfigurationService.getServerId();
String[] bottomNav = ServerConfigurationService.getStrings("bottomnav");
String[] poweredByUrl = ServerConfigurationService.getStrings("powered.url");
String[] poweredByImage = ServerConfigurationService
.getStrings("powered.img");
String[] poweredByAltText = ServerConfigurationService
.getStrings("powered.alt");
{
List<Object> l = new ArrayList<Object>();
if ((bottomNav != null) && (bottomNav.length > 0))
{
for (int i = 0; i < bottomNav.length; i++)
{
l.add(bottomNav[i]);
}
}
rcontext.put("bottomNav", l);
}
// rcontext.put("bottomNavSitNewWindow",
// Web.escapeHtml(rb.getString("site_newwindow")));
if ((poweredByUrl != null) && (poweredByImage != null)
&& (poweredByAltText != null)
&& (poweredByUrl.length == poweredByImage.length)
&& (poweredByUrl.length == poweredByAltText.length))
{
{
List<Object> l = new ArrayList<Object>();
for (int i = 0; i < poweredByUrl.length; i++)
{
Map<String, Object> m = new HashMap<String, Object>();
m.put("poweredByUrl", poweredByUrl[i]);
m.put("poweredByImage", poweredByImage[i]);
m.put("poweredByAltText", poweredByAltText[i]);
l.add(m);
}
rcontext.put("bottomNavPoweredBy", l);
}
}
else
{
List<Object> l = new ArrayList<Object>();
Map<String, Object> m = new HashMap<String, Object>();
m.put("poweredByUrl", "http://sakaiproject.org");
m.put("poweredByImage", "/library/image/sakai_powered.gif");
m.put("poweredByAltText", "Powered by Sakai");
l.add(m);
rcontext.put("bottomNavPoweredBy", l);
}
rcontext.put("bottomNavService", service);
rcontext.put("bottomNavCopyright", copyright);
rcontext.put("bottomNavServiceVersion", serviceVersion);
rcontext.put("bottomNavSakaiVersion", sakaiVersion);
rcontext.put("bottomNavServer", server);
}
}
public void includeLogin(PortalRenderContext rcontext, HttpServletRequest req,
Session session)
{
if (rcontext.uses(INCLUDE_LOGIN))
{
// for the main login/out link
String logInOutUrl = Web.serverUrl(req);
String message = null;
String image1 = null;
// for a possible second link
String logInOutUrl2 = null;
String message2 = null;
String image2 = null;
// check for the top.login (where the login fields are present
// instead
// of a login link, but ignore it if container.login is set
boolean topLogin = Boolean.TRUE.toString().equalsIgnoreCase(
ServerConfigurationService.getString("top.login"));
boolean containerLogin = Boolean.TRUE.toString().equalsIgnoreCase(
ServerConfigurationService.getString("container.login"));
if (containerLogin) topLogin = false;
// if not logged in they get login
if (session.getUserId() == null)
{
// we don't need any of this if we are doing top login
if (!topLogin)
{
logInOutUrl += ServerConfigurationService.getString("portalPath")
+ "/login";
// let the login url be overridden by configuration
String overrideLoginUrl = StringUtil
.trimToNull(ServerConfigurationService.getString("login.url"));
if (overrideLoginUrl != null) logInOutUrl = overrideLoginUrl;
// check for a login text override
message = StringUtil.trimToNull(ServerConfigurationService
.getString("login.text"));
if (message == null) message = rloader.getString("log.login");
// check for an image for the login
image1 = StringUtil.trimToNull(ServerConfigurationService
.getString("login.icon"));
// check for a possible second, xlogin link
if (Boolean.TRUE.toString().equalsIgnoreCase(
ServerConfigurationService.getString("xlogin.enabled")))
{
// get the text and image as configured
message2 = StringUtil.trimToNull(ServerConfigurationService
.getString("xlogin.text"));
image2 = StringUtil.trimToNull(ServerConfigurationService
.getString("xlogin.icon"));
logInOutUrl2 = ServerConfigurationService.getString("portalPath")
+ "/xlogin";
}
}
}
// if logged in they get logout
else
{
logInOutUrl += ServerConfigurationService.getString("portalPath")
+ "/logout";
// check for a logout text override
message = StringUtil.trimToNull(ServerConfigurationService
.getString("logout.text"));
if (message == null) message = rloader.getString("sit_log");
// check for an image for the logout
image1 = StringUtil.trimToNull(ServerConfigurationService
.getString("logout.icon"));
// since we are doing logout, cancel top.login
topLogin = false;
}
rcontext.put("loginTopLogin", Boolean.valueOf(topLogin));
if (!topLogin)
{
rcontext.put("loginLogInOutUrl", logInOutUrl);
rcontext.put("loginMessage", message);
rcontext.put("loginImage1", image1);
rcontext.put("loginHasImage1", Boolean.valueOf(image1 != null));
rcontext.put("loginLogInOutUrl2", logInOutUrl2);
rcontext.put("loginHasLogInOutUrl2", Boolean
.valueOf(logInOutUrl2 != null));
rcontext.put("loginMessage2", message2);
rcontext.put("loginImage2", image2);
rcontext.put("loginHasImage2", Boolean.valueOf(image2 != null));
// put out the links version
// else put out the fields that will send to the login interface
}
else
{
// find the login tool
Tool loginTool = ToolManager.getTool("sakai.login");
String eidWording = null;
String pwWording = null;
eidWording = StringUtil.trimToNull(rloader.getString("log.userid"));
pwWording = StringUtil.trimToNull(rloader.getString("log.pass"));
if (eidWording == null) eidWording = "eid";
if (pwWording == null) pwWording = "pw";
String loginWording = rloader.getString("log.login");
rcontext.put("loginPortalPath", ServerConfigurationService
.getString("portalPath"));
rcontext.put("loginEidWording", eidWording);
rcontext.put("loginPwWording", pwWording);
rcontext.put("loginWording", loginWording);
// setup for the redirect after login
session.setAttribute(Tool.HELPER_DONE_URL, ServerConfigurationService
.getPortalUrl());
}
}
}
/*
* Produce a page and/or a tool list doPage = true is best for the
* tabs-based portal and for RSS - these think in terms of pages doPage =
* false is best for the portlet-style - it unrolls all of the tools unless
* a page is marked as a popup. If the page is a popup - it is left a page
* and marked as such. restTools = true - generate resetting tool URLs.
*/
public Map pageListToMap(HttpServletRequest req, boolean loggedIn, Site site,
SitePage page, String toolContextPath, String portalPrefix, boolean doPages,
boolean resetTools, boolean includeSummary)
{
Map<String, Object> theMap = new HashMap<String, Object>();
String pageUrl = Web.returnUrl(req, "/" + portalPrefix + "/"
+ Web.escapeUrl(siteHelper.getSiteEffectiveId(site)) + "/page/");
String toolUrl = Web.returnUrl(req, "/" + portalPrefix + "/"
+ Web.escapeUrl(siteHelper.getSiteEffectiveId(site)));
if (resetTools)
{
toolUrl = toolUrl + "/tool-reset/";
}
else
{
toolUrl = toolUrl + "/tool/";
}
String pagePopupUrl = Web.returnUrl(req, "/page/");
boolean showHelp = ServerConfigurationService.getBoolean("display.help.menu",
true);
String iconUrl = site.getIconUrlFull();
boolean published = site.isPublished();
String type = site.getType();
theMap.put("pageNavPublished", Boolean.valueOf(published));
theMap.put("pageNavType", type);
theMap.put("pageNavIconUrl", iconUrl);
// theMap.put("pageNavSitToolsHead",
// Web.escapeHtml(rb.getString("sit_toolshead")));
// order the pages based on their tools and the tool order for the
// site type
// List pages = site.getOrderedPages();
List pages = siteHelper.getPermittedPagesInOrder(site);
List<Map> l = new ArrayList<Map>();
for (Iterator i = pages.iterator(); i.hasNext();)
{
SitePage p = (SitePage) i.next();
// check if current user has permission to see page
// we will draw page button if it have permission to see at least
// one tool on the page
List pTools = p.getTools();
ToolConfiguration firstTool = null;
if ( pTools != null && pTools.size() > 0 ) {
firstTool = (ToolConfiguration) pTools.get(0);
}
String toolsOnPage = null;
boolean current = (page != null && p.getId().equals(page.getId()) && !p
.isPopUp());
String pagerefUrl = pageUrl + Web.escapeUrl(p.getId());
if (doPages || p.isPopUp())
{
Map<String, Object> m = new HashMap<String, Object>();
m.put("isPage", Boolean.valueOf(true));
m.put("current", Boolean.valueOf(current));
m.put("ispopup", Boolean.valueOf(p.isPopUp()));
m.put("pagePopupUrl", pagePopupUrl);
m.put("pageTitle", Web.escapeHtml(p.getTitle()));
m.put("jsPageTitle", Web.escapeJavascript(p.getTitle()));
m.put("pageId", Web.escapeUrl(p.getId()));
m.put("jsPageId", Web.escapeJavascript(p.getId()));
m.put("pageRefUrl", pagerefUrl);
if (toolsOnPage != null) m.put("toolsOnPage", toolsOnPage);
if (includeSummary) siteHelper.summarizePage(m, site, p);
if ( firstTool != null ) {
String menuClass = firstTool.getToolId();
menuClass = "icon-"+menuClass.replace('.','-');
m.put("menuClass", menuClass);
} else {
m.put("menuClass", "icon-default-tool" );
}
l.add(m);
continue;
}
// Loop through the tools again and Unroll the tools
Iterator iPt = pTools.iterator();
while (iPt.hasNext())
{
ToolConfiguration placement = (ToolConfiguration) iPt.next();
String toolrefUrl = toolUrl + Web.escapeUrl(placement.getId());
Map<String, Object> m = new HashMap<String, Object>();
m.put("isPage", Boolean.valueOf(false));
m.put("toolId", Web.escapeUrl(placement.getId()));
m.put("jsToolId", Web.escapeJavascript(placement.getId()));
m.put("toolRegistryId", placement.getToolId());
m.put("toolTitle", Web.escapeHtml(placement.getTitle()));
m.put("jsToolTitle", Web.escapeJavascript(placement.getTitle()));
m.put("toolrefUrl", toolrefUrl);
String menuClass = placement.getToolId();
menuClass = "icon-"+menuClass.replace('.', '-');
m.put("menuClass", menuClass);
l.add(m);
}
}
theMap.put("pageNavTools", l);
theMap.put("pageMaxIfSingle",ServerConfigurationService.getBoolean("portal.experimental.maximizesinglepage", false));
theMap.put("pageNavToolsCount", Integer.valueOf(l.size()));
String helpUrl = ServerConfigurationService.getHelpUrl(null);
theMap.put("pageNavShowHelp", Boolean.valueOf(showHelp));
theMap.put("pageNavHelpUrl", helpUrl);
theMap.put("helpMenuClass", "icon-sakai-help");
theMap.put("subsiteClass", "icon-sakai-subsite");
// theMap.put("pageNavSitContentshead",
// Web.escapeHtml(rb.getString("sit_contentshead")));
// Handle Presense
boolean showPresence = ServerConfigurationService.getBoolean(
"display.users.present", true);
String presenceUrl = Web.returnUrl(req, "/presence/"
+ Web.escapeUrl(site.getId()));
// theMap.put("pageNavSitPresenceTitle",
// Web.escapeHtml(rb.getString("sit_presencetitle")));
// theMap.put("pageNavSitPresenceFrameTitle",
// Web.escapeHtml(rb.getString("sit_presenceiframetit")));
theMap.put("pageNavShowPresenceLoggedIn", Boolean.valueOf(showPresence
&& loggedIn));
theMap.put("pageNavPresenceUrl", presenceUrl);
return theMap;
}
public void includeWorksite(PortalRenderContext rcontext, HttpServletResponse res,
HttpServletRequest req, Session session, Site site, SitePage page,
String toolContextPath, String portalPrefix) throws IOException
{
worksiteHandler.includeWorksite(rcontext, res, req, session, site, page,
toolContextPath, portalPrefix);
}
/**
* Initialize the servlet.
*
* @param config
* The servlet config.
* @throws ServletException
*/
public void init(ServletConfig config) throws ServletException
{
super.init(config);
portalContext = config.getInitParameter("portal.context");
if (portalContext == null || portalContext.length() == 0)
{
portalContext = DEFAULT_PORTAL_CONTEXT;
}
portalService = org.sakaiproject.portal.api.cover.PortalService.getInstance();
M_log.info("init()");
basicAuth = new BasicAuth();
basicAuth.init();
enableDirect = portalService.isEnableDirect();
// do this before adding handlers to prevent handlers registering 2
// times.
// if the handlers were already there they will be re-registered,
// but when they are added again, they will be replaced.
// warning messages will appear, but the end state will be the same.
portalService.addPortal(this);
galleryHandler = new GalleryHandler();
worksiteHandler = new WorksiteHandler();
siteHandler = new SiteHandler();
addHandler(siteHandler);
addHandler(new SiteResetHandler());
addHandler(new ToolHandler());
addHandler(new ToolResetHandler());
addHandler(new PageHandler());
addHandler(worksiteHandler);
addHandler(new WorksiteResetHandler());
addHandler(new RssHandler());
addHandler(new PDAHandler());
addHandler(new AtomHandler());
addHandler(new OpmlHandler());
addHandler(galleryHandler);
addHandler(new GalleryResetHandler());
addHandler(new NavLoginHandler());
addHandler(new NavLoginGalleryHandler());
addHandler(new PresenceHandler());
addHandler(new HelpHandler());
addHandler(new ReLoginHandler());
addHandler(new LoginHandler());
addHandler(new XLoginHandler());
addHandler(new LoginGalleryHandler());
addHandler(new LogoutHandler());
addHandler(new LogoutGalleryHandler());
addHandler(new ErrorDoneHandler());
addHandler(new ErrorReportHandler());
addHandler(new StaticStylesHandler());
addHandler(new StaticScriptsHandler());
addHandler(new DirectToolHandler());
}
/**
* Register a handler for a URL stub
*
* @param handler
*/
private void addHandler(PortalHandler handler)
{
portalService.addHandler(this, handler);
}
private void removeHandler(String urlFragment)
{
portalService.removeHandler(this, urlFragment);
}
/**
* Send the POST request to login
*
* @param req
* @param res
* @param session
* @throws IOException
*/
protected void postLogin(HttpServletRequest req, HttpServletResponse res,
Session session, String loginPath) throws ToolException
{
ActiveTool tool = ActiveToolManager.getActiveTool("sakai.login");
String context = req.getContextPath() + req.getServletPath() + "/" + loginPath;
tool.help(req, res, context, "/" + loginPath);
}
/**
* Output some session information
*
* @param rcontext
* The print writer
* @param html
* If true, output in HTML, else in text.
*/
protected void showSession(PortalRenderContext rcontext, boolean html)
{
// get the current user session information
Session s = SessionManager.getCurrentSession();
rcontext.put("sessionSession", s);
ToolSession ts = SessionManager.getCurrentToolSession();
rcontext.put("sessionToolSession", ts);
}
public void sendResponse(PortalRenderContext rcontext, HttpServletResponse res,
String template, String contentType) throws IOException
{
// headers
if (contentType == null)
{
res.setContentType("text/html; charset=UTF-8");
}
else
{
res.setContentType(contentType);
}
res.addDateHeader("Expires", System.currentTimeMillis()
- (1000L * 60L * 60L * 24L * 365L));
res.addDateHeader("Last-Modified", System.currentTimeMillis());
res
.addHeader("Cache-Control",
"no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
res.addHeader("Pragma", "no-cache");
// get the writer
PrintWriter out = res.getWriter();
try
{
PortalRenderEngine rengine = rcontext.getRenderEngine();
rengine.render(template, rcontext, out);
}
catch (Exception e)
{
throw new RuntimeException("Failed to render template ", e);
}
}
/**
* Returns the type ("course", "project", "workspace", "mySpecialSiteType",
* etc) of the given site; special handling of returning "workspace" for
* user workspace sites. This method is tightly coupled to site skinning.
*/
public String calcSiteType(String siteId)
{
String siteType = null;
if (siteId != null && siteId.length() != 0)
{
if (SiteService.isUserSite(siteId))
{
siteType = "workspace";
}
else
{
try
{
siteType = SiteService.getSite(siteId).getType();
}
catch (IdUnusedException ex)
{
// ignore, the site wasn't found
}
}
}
if (siteType != null && siteType.trim().length() == 0) siteType = null;
return siteType;
}
private void logXEntry()
{
Exception e = new Exception();
StackTraceElement se = e.getStackTrace()[1];
M_log.info("Log marker " + se.getMethodName() + ":" + se.getFileName() + ":"
+ se.getLineNumber());
}
/**
* Check for any just expired sessions and redirect
*
* @return true if we redirected, false if not
*/
public boolean redirectIfLoggedOut(HttpServletResponse res) throws IOException
{
// if we are in a newly created session where we had an invalid
// (presumed timed out) session in the request,
// send script to cause a sakai top level redirect
if (ThreadLocalManager.get(SessionManager.CURRENT_INVALID_SESSION) != null)
{
String loggedOutUrl = ServerConfigurationService.getLoggedOutUrl();
sendPortalRedirect(res, loggedOutUrl);
return true;
}
return false;
}
/**
* Send a redirect so our Portal window ends up at the url, via javascript.
*
* @param url
* The redirect url
*/
protected void sendPortalRedirect(HttpServletResponse res, String url)
throws IOException
{
PortalRenderContext rcontext = startPageContext("", null, null, null);
rcontext.put("redirectUrl", url);
sendResponse(rcontext, res, "portal-redirect", null);
}
/**
* Compute the string that will identify the user site for this user - use
* the EID if possible
*
* @param userId
* The user id
* @return The site "ID" but based on the user EID
*/
public String getUserEidBasedSiteId(String userId)
{
try
{
// use the user EID
String eid = UserDirectoryService.getUserEid(userId);
return SiteService.getUserSiteId(eid);
}
catch (UserNotDefinedException e)
{
M_log.warn("getUserEidBasedSiteId: user id not found for eid: " + userId);
return SiteService.getUserSiteId(userId);
}
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
29c16c369e93e190aaf7c8d0514a3795d8f028c7 | 7cd238caabc72c1fa265994d103a2662c04acfec | /app/src/main/java/com/example/alzheimers_detection/Attention.java | 38bc7c842d85411cdec4a271d07f7acf16fd3755 | [] | no_license | shuchi139/Project_integration | bebf56ac2112bdd5e34c47cce88285c0729ea575 | a66dcdb305102ee194e9205eb0df6fe80a2cd12e | refs/heads/master | 2022-11-20T15:29:13.844440 | 2020-07-23T15:31:49 | 2020-07-23T15:31:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,591 | java |
//images added to firebase storage
package com.example.alzheimers_detection;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.graphics.Color;
import android.os.*;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
public class Attention extends AppCompatActivity {
ImageView picture,donutdecor2,donutdecor,uncle,donutstand,open;
TextView instruction1,instruction2,instruction3;
double seconds=1,score=0.0;
String urldonutdecor2,urldonutdecor,urluncle,urldonutstand,urlopen;
Button yes,no;
public static Integer[] mThumbIds = {
R.drawable.tree1, R.drawable.tree2,R.drawable.tree2, R.drawable.tree3,R.drawable.tree1, R.drawable.tree1,R.drawable.tree1,R.drawable.tree6,R.drawable.tree2, R.drawable.tree6};
int i;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_attention);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
setContentView(R.layout.activity_attention);
picture = findViewById(R.id.picture);
picture.setImageResource(mThumbIds[0]);
yes=findViewById(R.id.yes);
no=findViewById(R.id.no);
yes.setEnabled(false);
no.setEnabled(false);
instruction1=findViewById(R.id.instruction1);
instruction2=findViewById(R.id.instruction2);
instruction3=findViewById(R.id.instruction3);
open=findViewById(R.id.open);
donutdecor=findViewById(R.id.donutdecor);
donutdecor2=findViewById(R.id.donutdecor2);
donutstand=findViewById(R.id.donutstand);
uncle=findViewById(R.id.uncle);
urldonutdecor="https://firebasestorage.googleapis.com/v0/b/alzheimers-detection.appspot.com/o/pic1.png?alt=media&token=07254029-77fd-44ff-b7c5-93a9e5e0500d";
urldonutdecor2="https://firebasestorage.googleapis.com/v0/b/alzheimers-detection.appspot.com/o/pic2.png?alt=media&token=13ea4f0d-cd5d-4e5c-9f04-6411a5436571";
urldonutstand="https://firebasestorage.googleapis.com/v0/b/alzheimers-detection.appspot.com/o/doughnutstand.jpg?alt=media&token=c19553cb-0fe1-434f-be9a-f28015a969eb";
urlopen="https://firebasestorage.googleapis.com/v0/b/alzheimers-detection.appspot.com/o/open.png?alt=media&token=1a2bbba3-ff80-41d6-8ec8-720103b9a3b0";
urluncle="https://firebasestorage.googleapis.com/v0/b/alzheimers-detection.appspot.com/o/man.gif?alt=media&token=59a1f2b5-b54e-4f49-8d4c-2d4a48266384";
Picasso.with(this).load(urluncle).into(uncle);
Picasso.with(this).load(urldonutdecor).into(donutdecor);
Picasso.with(this).load(urldonutdecor2).into(donutdecor2);
Picasso.with(this).load(urldonutstand).into(donutstand, new Callback(){
@Override
public void onSuccess() {
afterDonutLoad();
}
@Override
public void onError() {
}
});
Picasso.with(this).load(urlopen).into(open);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mThumbIds[i]==mThumbIds[i-1])
{
score=score+1;
Toast.makeText(getApplicationContext(),"score:"+score,Toast.LENGTH_LONG).show();
}
i++;
if(!(i==mThumbIds.length))
{
picture.setImageResource(R.drawable.blank);
picture.setAlpha(0);
seconds=1;
final Handler handler2=new Handler();
handler2.post(new Runnable() {
@Override
public void run() {
if(seconds>0)
{
seconds=seconds-1;
handler2.postDelayed(this,1000);
}
else
{
picture.setImageResource(mThumbIds[i]);
picture.setAlpha(255);
}
}
});
}
else
{
yes.setEnabled(false);
no.setEnabled(false);
Toast.makeText(getApplicationContext(),"score:"+(score/3),Toast.LENGTH_LONG).show();
Intent i=new Intent(getApplicationContext(),IntroVisuoperception.class);
startActivity(i);
Log.d("score",""+(score/3));
}
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mThumbIds[i]!=mThumbIds[i-1])
{
score=score+1;
Toast.makeText(getApplicationContext(),"score:"+score,Toast.LENGTH_LONG).show();
}
i++;
if(!(i==mThumbIds.length))
{
picture.setImageResource(R.drawable.blank);
picture.setAlpha(0);
seconds=1;
final Handler handler2=new Handler();
handler2.post(new Runnable() {
@Override
public void run() {
if(seconds>0)
{
seconds=seconds-1;
handler2.postDelayed(this,1000);
}
else
{
picture.setImageResource(mThumbIds[i]);
picture.setAlpha(255);
}
}
});
}
else
{
yes.setEnabled(false);
no.setEnabled(false);
Toast.makeText(getApplicationContext(),"score:"+(score/3),Toast.LENGTH_LONG).show();
Intent i=new Intent(getApplicationContext(),IntroVisuoperception.class);
startActivity(i);
Log.d("score",""+(score/3));
}
}
});
}
public void afterDonutLoad()
{
instruction3.setVisibility(View.INVISIBLE);
instruction2.setVisibility(View.INVISIBLE);
seconds=3;
final Handler handler=new Handler();
handler.post(new Runnable() {
@Override
public void run() {
if(seconds>0)
{
seconds=seconds-1;
handler.postDelayed(this,1000);
}
else
{
picture.setImageResource(R.drawable.blank);
picture.setAlpha(0);
seconds=1;
final Handler handler2=new Handler();
handler2.post(new Runnable() {
@Override
public void run() {
if(seconds>0)
{
seconds=seconds-1;
handler2.postDelayed(this,1000);
}
else
{
i=1;
picture.setImageResource(mThumbIds[1]);
instruction1.setVisibility(View.INVISIBLE);
instruction2.setVisibility(View.VISIBLE);
instruction3.setVisibility(View.VISIBLE);
picture.setAlpha(255);
yes.setEnabled(true);
no.setEnabled(true);
}
}
});
}
}
});
}
} | [
"samrudhi0909@gmail.com"
] | samrudhi0909@gmail.com |
646f83be549ebe8c21e1e7632f66111ab0713cda | 6be4e661a695dba593aff9335350a21e78135789 | /src/main/java/be/woutzah/chatbrawl/time/TimeManager.java | 6c4bb6f9fda34d26d20066e5df40174ee96260bc | [] | no_license | SirSalad/ChatBrawl | 01aac311a7c1483761a832ee782b4cd5fba03407 | 1e78517bf3a1b50799a0e0511efc158ac48eb8a4 | refs/heads/master | 2023-07-11T11:58:26.524593 | 2021-08-16T01:47:03 | 2021-08-16T01:47:03 | 392,866,989 | 0 | 0 | null | 2021-08-16T01:00:35 | 2021-08-05T01:22:25 | null | UTF-8 | Java | false | false | 877 | java | package be.woutzah.chatbrawl.time;
import be.woutzah.chatbrawl.ChatBrawl;
import java.time.Duration;
import java.time.Instant;
public class TimeManager {
private ChatBrawl plugin;
private Instant startTime;
private Instant stopTime;
public TimeManager(ChatBrawl plugin) {
this.plugin = plugin;
}
public void startTimer(){
startTime = Instant.now();
}
public void stopTimer(){
stopTime = Instant.now();
}
public int getTotalSeconds() {
return (int) Duration.between(startTime,stopTime).getSeconds();
}
public String getTimeString(){
return formatTime(getTotalSeconds());
}
public String formatTime(int seconds){
return String.format("%dh %02dm %02ds",
seconds / 3600,
(seconds % 3600) / 60,
(seconds % 60));
}
}
| [
"Wouter.Blockken@student.pxl.be"
] | Wouter.Blockken@student.pxl.be |
3e9b1fb79e4300041f9edb93beddb282414a0673 | 5ad067c1253b7026be6de7c718d39f9bb27cbed7 | /question/src/main/java/com/base/teacher/config/exception/BusinessException.java | 58ee8607b512734bc8641a0ae0b15314e2ca1d2d | [] | no_license | wangliangting6/question | aee4aacf2132f693e17b0c31d7244aa5fd78d63a | 9e4053e3c84f869aa712457a890d4db268c3a50f | refs/heads/master | 2022-12-14T03:34:25.409257 | 2019-07-12T16:25:22 | 2019-07-12T16:25:22 | 196,609,143 | 2 | 1 | null | 2022-12-10T22:12:12 | 2019-07-12T16:11:38 | Java | UTF-8 | Java | false | false | 707 | java | package com.base.teacher.config.exception;
import com.base.teacher.config.enums.BaseErrorEnum;
/**
* 头部信息缺少 异常 声明异常 service的异常
*
* @author xiong
*
*/
public class BusinessException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
private int code;
private String msg;
public BusinessException(BaseErrorEnum err) {
super(err.getErrorMessage());
this.code = err.getErrorCode();
this.msg = err.getErrorMessage();
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
| [
"873203428@qq.com"
] | 873203428@qq.com |
b77cfa39410d9d3258b64e6711954f912cb517fa | 882e77219bce59ae57cbad7e9606507b34eebfcf | /mi2s_securitycenter_miui12/src/main/java/com/xiaomi/stat/MiStatParams.java | d3b8ecc0fa1ebfa736c799048f033362875c4e2b | [] | no_license | CrackerCat/XiaomiFramework | 17a12c1752296fa1a52f61b83ecf165f328f4523 | 0b7952df317dac02ebd1feea7507afb789cef2e3 | refs/heads/master | 2022-06-12T03:30:33.285593 | 2020-05-06T11:30:54 | 2020-05-06T11:30:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,355 | java | package com.xiaomi.stat;
import com.xiaomi.stat.d.j;
import com.xiaomi.stat.d.k;
import com.xiaomi.stat.d.n;
import java.io.Reader;
import java.io.StringReader;
import org.json.JSONException;
import org.json.JSONObject;
public class MiStatParams {
/* renamed from: a reason: collision with root package name */
private static final String f8346a = "MiStatParams";
/* renamed from: b reason: collision with root package name */
private JSONObject f8347b;
public MiStatParams() {
this.f8347b = new JSONObject();
}
/* JADX WARNING: Code restructure failed: missing block: B:2:0x0005, code lost:
r1 = r1.f8347b;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
MiStatParams(com.xiaomi.stat.MiStatParams r1) {
/*
r0 = this;
r0.<init>()
if (r1 == 0) goto L_0x000e
org.json.JSONObject r1 = r1.f8347b
if (r1 == 0) goto L_0x000e
org.json.JSONObject r1 = r0.a((org.json.JSONObject) r1)
goto L_0x0013
L_0x000e:
org.json.JSONObject r1 = new org.json.JSONObject
r1.<init>()
L_0x0013:
r0.f8347b = r1
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.xiaomi.stat.MiStatParams.<init>(com.xiaomi.stat.MiStatParams):void");
}
private JSONObject a(JSONObject jSONObject) {
StringReader stringReader;
Exception e;
try {
stringReader = new StringReader(jSONObject.toString());
try {
StringBuilder sb = new StringBuilder();
while (true) {
int read = stringReader.read();
if (read != -1) {
sb.append((char) read);
} else {
JSONObject jSONObject2 = new JSONObject(sb.toString());
j.a((Reader) stringReader);
return jSONObject2;
}
}
} catch (Exception e2) {
e = e2;
try {
k.e(" deepCopy " + e);
j.a((Reader) stringReader);
return jSONObject;
} catch (Throwable th) {
th = th;
j.a((Reader) stringReader);
throw th;
}
}
} catch (Exception e3) {
Exception exc = e3;
stringReader = null;
e = exc;
k.e(" deepCopy " + e);
j.a((Reader) stringReader);
return jSONObject;
} catch (Throwable th2) {
th = th2;
stringReader = null;
j.a((Reader) stringReader);
throw th;
}
}
private boolean c(String str) {
return a() && !this.f8347b.has(str) && this.f8347b.length() == 30;
}
/* access modifiers changed from: package-private */
public boolean a() {
return true;
}
/* access modifiers changed from: package-private */
public boolean a(String str) {
return n.a(str);
}
/* access modifiers changed from: package-private */
public boolean b(String str) {
return n.b(str);
}
public int getParamsNumber() {
return this.f8347b.length();
}
public boolean isEmpty() {
return this.f8347b.length() == 0;
}
public void putBoolean(String str, boolean z) {
if (!a(str)) {
n.e(str);
} else if (c(str)) {
n.a();
} else {
try {
this.f8347b.put(str, z);
} catch (JSONException e) {
k.c(f8346a, "put value error " + e);
}
}
}
public void putDouble(String str, double d2) {
if (!a(str)) {
n.e(str);
} else if (c(str)) {
n.a();
} else {
try {
this.f8347b.put(str, d2);
} catch (JSONException e) {
k.c(f8346a, "put value error " + e);
}
}
}
public void putInt(String str, int i) {
if (!a(str)) {
n.e(str);
} else if (c(str)) {
n.a();
} else {
try {
this.f8347b.put(str, i);
} catch (JSONException e) {
k.c(f8346a, "put value error " + e);
}
}
}
public void putLong(String str, long j) {
if (!a(str)) {
n.e(str);
} else if (c(str)) {
n.a();
} else {
try {
this.f8347b.put(str, j);
} catch (JSONException e) {
k.c(f8346a, "put value error " + e);
}
}
}
public void putString(String str, String str2) {
if (!a(str)) {
n.e(str);
} else if (!b(str2)) {
n.f(str2);
} else if (c(str)) {
n.a();
} else {
try {
this.f8347b.put(str, n.c(str2));
} catch (JSONException e) {
k.c(f8346a, "put value error " + e);
}
}
}
public String toJsonString() {
return this.f8347b.toString();
}
}
| [
"sanbo.xyz@gmail.com"
] | sanbo.xyz@gmail.com |
0203f17396710649cca5fb2ed5c5116510defd51 | 9afc3c601d7269138064538b1c3e439491605ea1 | /src/files/configData/ConfigInt.java | 7666b700ee225fba12686360713dada238d41c1e | [] | no_license | Caspermartijn/GameEngine | 40b634948918fe84a092f8e1674f8dc66dd73277 | 93dc601853e61d83f1c185a4f8401dc542334d2b | refs/heads/master | 2018-11-18T16:19:11.631153 | 2018-09-06T17:27:43 | 2018-09-06T17:27:43 | 115,920,129 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 306 | java | package files.configData;
public class ConfigInt extends Config {
private int data;
public ConfigInt(String dat, int data) {
super(dat, ConfigType.Int);
this.data = data;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
}
| [
"gebruiker-pc@gebruiker.home"
] | gebruiker-pc@gebruiker.home |
7e682847e432bf5fb290fcdf98dcc77f2ece8497 | aa829afbbb350e3e7ff497619684a4390bad937b | /src/main/java/com/pescaria/workshopmongo/resources/exceptions/ResourceExceptionHandler.java | 86297b8a8b33f7fe6438dbd550a9050310332698 | [] | no_license | crisaoo/workshop-springboot-mongodb | a3177ead5398c75eafdae214b28348fe9b178b80 | 43be1e366574d116780adf9eff4bfe8677d51610 | refs/heads/master | 2022-12-11T18:16:55.627792 | 2020-08-28T13:35:24 | 2020-08-28T13:35:24 | 289,564,572 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 911 | java | package com.pescaria.workshopmongo.resources.exceptions;
import java.time.Instant;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.pescaria.workshopmongo.services.exceptions.ObjectNotFoundException;
@ControllerAdvice
public class ResourceExceptionHandler {
@ExceptionHandler(ObjectNotFoundException.class)
public ResponseEntity<StandardError> objectNotFound (ObjectNotFoundException e, HttpServletRequest request){
String error = "Not found";
HttpStatus status = HttpStatus.NOT_FOUND;
StandardError sError = new StandardError(Instant.now(), status.value(), error, e.getMessage(), request.getRequestURI());
return ResponseEntity.status(status).body(sError);
}
}
| [
"Cristianocosta2019@outlook.com"
] | Cristianocosta2019@outlook.com |
72a2e70f0b6ac298534831512be17c7fb2d21b6e | d4556b1ec2879185c41cb43fed9791bad3489107 | /src/Tables/StudentTable.java | 489bc2e6c14b89e48daf13c0d5d900745011b536 | [] | no_license | chidgana/Student-Management-System | b2b051dbc610d8b8c97e0f6eb61f4cc47792f9f0 | 3d215eb88778423ad523783d123acb3b7a1530a8 | refs/heads/master | 2023-07-15T10:38:52.215096 | 2021-08-31T07:10:21 | 2021-08-31T07:10:21 | 396,827,330 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,644 | java | package Tables;
import javafx.beans.property.SimpleStringProperty;
/**
* Created by chidgana on 07-03-18.
*/
public class StudentTable {
private final SimpleStringProperty admissionnumber;
private final SimpleStringProperty registernumber;
private final SimpleStringProperty name;
private final SimpleStringProperty dateofbirth;
private final SimpleStringProperty phonenumber;
private final SimpleStringProperty email;
private final SimpleStringProperty course;
private final SimpleStringProperty semester;
//constructor
public StudentTable(String admissionnumber, String registernumber, String name, String dateofbirth, String phonenumber, String email, String course, String semester) {
this.admissionnumber = new SimpleStringProperty(admissionnumber);
this.registernumber = new SimpleStringProperty(registernumber);
this.name = new SimpleStringProperty(name);
this.dateofbirth = new SimpleStringProperty(dateofbirth);
this.phonenumber = new SimpleStringProperty(phonenumber);
this.email = new SimpleStringProperty(email);
this.course = new SimpleStringProperty(course);
this.semester = new SimpleStringProperty(semester);
}
//get methods
public String getAdmissionnumber() {
return admissionnumber.get();
}
//set methods
public void setAdmissionnumber(String admissionnumber) {
this.admissionnumber.set(admissionnumber);
}
public String getRegisternumber() {
return registernumber.get();
}
public void setRegisternumber(String registernumber) {
this.registernumber.set(registernumber);
}
public String getName() {
return name.get();
}
public void setName(String name) {
this.name.set(name);
}
public String getDateofbirth() {
return dateofbirth.get();
}
public void setDateofbirth(String dateofbirth) {
this.dateofbirth.set(dateofbirth);
}
public String getPhonenumber() {
return phonenumber.get();
}
public void setPhonenumber(String phonenumber) {
this.phonenumber.set(phonenumber);
}
public String getEmail() {
return email.get();
}
public void setEmail(String email) {
this.email.set(email);
}
public String getCourse() {
return course.get();
}
public void setCourse(String course) {
this.course.set(course);
}
public String getSemester() {
return semester.get();
}
public void setSemester(String semester) {
this.semester.set(semester);
}
}
| [
"chidganahegade@gmail.com"
] | chidganahegade@gmail.com |
ed6ce775504e9830ed79a98b432ac022d8ee2b88 | 004e3b99698a33fe80a51bf6a2afcb5116a12c61 | /src/gardner/SammyHammy.java | eb6f7b20ddf6c66159774d43ad53a216206bf213 | [] | no_license | bgardner-edu/HelloFromBradley | ce53c6400c6efd76a92f79635a08f94353e65cd5 | dfdac5e49bfba7240e42b2aa493ca740a5a0f6c7 | refs/heads/master | 2023-02-25T12:34:45.013783 | 2021-01-31T04:09:34 | 2021-01-31T04:09:34 | 332,972,779 | 0 | 0 | null | 2021-01-31T01:58:23 | 2021-01-26T04:36:46 | Java | UTF-8 | Java | false | false | 153 | java | package gardner;
public class SammyHammy {
String myString = "Hello World";
public SammyHammy() {
System.out.println(myString);
}
}
| [
"78047932+Bozo-Cake@users.noreply.github.com"
] | 78047932+Bozo-Cake@users.noreply.github.com |
77cd529a2fec85625f8cfec74288b5674202e2ef | 3b3420271021d871cd0fbf31196e50813073a21f | /src/main/java/org/team1540/chonk/commands/bunnyarm/CloseBunnyDoor.java | 70a84792e16150d99e8ed9122453fe39398d0c18 | [] | no_license | flamingchickens1540/bunnybots-chonk-2019 | 8eb1fbe04efc14962baa06acbc4c498723e16720 | ea7f2ab801ec9834015217da6cc2542f8c7051c9 | refs/heads/master | 2020-07-27T17:23:52.168131 | 2020-01-01T21:05:52 | 2020-01-01T21:05:52 | 209,170,509 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 366 | java | package org.team1540.chonk.commands.bunnyarm;
import edu.wpi.first.wpilibj.command.TimedCommand;
import org.team1540.chonk.Robot;
public class CloseBunnyDoor extends TimedCommand {
public CloseBunnyDoor() {
super(0.25);
requires(Robot.bunnyDoor);
}
@Override
protected void initialize() {
Robot.bunnyDoor.close();
}
}
| [
"robinsonz@catlin.edu"
] | robinsonz@catlin.edu |
caef797a743eb80641084c5d1c2ed477542fad20 | 6050ca4fb3486ed658917fdb842e8c7c97be2137 | /app/src/main/java/com/wenjutian/injectleaning/dynamicProxy/Test.java | 64056e80c669c218313428eb4d33daddd31c151d | [] | no_license | tianwenju/InjectLeaning | 553526d687254a56407f5fee4266f03a8673c26d | f92d44948175c6b88e5ba639caf27fe2dec440f4 | refs/heads/master | 2021-01-20T00:23:50.611338 | 2016-11-25T05:25:32 | 2016-11-25T05:25:32 | 74,100,357 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 973 | java | package com.wenjutian.injectleaning.dynamicProxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* Created by V.Wenju.Tian on 2016/11/25.
*/
public class Test {
public static void main(String[] args) {
Object o = Proxy.newProxyInstance(ISeller.class.getClassLoader(), new Class[]{ISeller.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
System.out.println(method.getName()+proxy.getClass().getName());
for (Object arg : args) {
if(arg instanceof String)
System.out.println(((String) arg));
}
return null;
}
});
System.out.println(o.getClass().getName());
if(o instanceof ISeller){
((ISeller) o).buy("sdfsdfsdf");
}
}
}
| [
"V.Wenju.Tian@deltaww.com"
] | V.Wenju.Tian@deltaww.com |
16d772137a0b68bd1d5e8e3822efc766ab84e9d0 | 9ef8fd66645d911adcf201bf329b34c8a46385ff | /src/dsaone/dp/HouseRobbingProblem.java | 138f71a48bdb6baf7858d992aae07fb452fd3cfa | [] | no_license | Ritsz123/my-java-codedump | 2bee62dc78dbdd1e7897ac7a3567bb451cf6fa16 | 7e3a62140709a9349d78ac1f36851a05b4caffd5 | refs/heads/main | 2023-07-17T15:04:45.302957 | 2021-08-30T16:39:50 | 2021-08-30T16:39:50 | 349,318,511 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,189 | java | package dsaone.dp;
import java.util.Scanner;
public class HouseRobbingProblem {
static int maxProfitByRobbingDP(int i,int [] gold,int [] dp){
if(i==0) return gold[0];
if(i==1) return Math.max(gold[0],gold[1]);
if(dp[i]!=-1){
return dp[i];
}
int max = Math.max(maxProfitByRobbingDP(i-2,gold,dp) + gold[i],maxProfitByRobbingDP(i-1,gold,dp));
dp[i] = max;
return max;
}
static int maxProfitByRobbing(int i,int [] gold){
if(i==0){
return gold[0];
}
if(i==1) return Math.max(gold[0],gold[1]);
return Math.max(maxProfitByRobbing(i-2,gold)+gold[i],maxProfitByRobbing(i-1,gold));
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] gold = new int[n];
for(int i=0;i<n;i++){
gold[i] = sc.nextInt();
}
int[] dp = new int[n];
for (int i = 0; i < n; i++) {
dp[i]=-1;
}
// int ans = maxProfitByRobbing(n-1,gold);
int ans = maxProfitByRobbingDP(n-1,gold,dp);
System.out.println(ans);
}
}
| [
"riteshkhadse12@gmail.com"
] | riteshkhadse12@gmail.com |
54b626c75adc59abf79a9ea356b12be0bdf6ff9e | 9d0517091fe2313c40bcc88a7c82218030d2075c | /apis/chef/src/test/java/org/jclouds/chef/functions/BootstrapConfigForGroupTest.java | c704ee6f10b3204e4dc3384761f93d71056c37c5 | [
"Apache-2.0"
] | permissive | nucoupons/Mobile_Applications | 5c63c8d97f48e1051049c5c3b183bbbaae1fa6e6 | 62239dd0f17066c12a86d10d26bef350e6e9bd43 | refs/heads/master | 2020-12-04T11:49:53.121041 | 2020-01-04T12:00:04 | 2020-01-04T12:00:04 | 231,754,011 | 0 | 0 | Apache-2.0 | 2020-01-04T12:02:30 | 2020-01-04T11:46:54 | Java | UTF-8 | Java | false | false | 3,353 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.chef.functions;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import org.jclouds.chef.ChefApi;
import org.jclouds.chef.domain.BootstrapConfig;
import org.jclouds.chef.domain.Client;
import org.jclouds.chef.domain.DatabagItem;
import org.jclouds.json.Json;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
@Test(groups = "unit", testName = "BootstrapConfigForGroupTest")
public class BootstrapConfigForGroupTest {
private Json json;
@BeforeClass
public void setup() {
Injector injector = Guice.createInjector(new GsonModule());
json = injector.getInstance(Json.class);
}
@Test(expectedExceptions = IllegalStateException.class)
public void testWhenNoDatabagItem() throws IOException {
ChefApi chefApi = createMock(ChefApi.class);
Client client = createMock(Client.class);
BootstrapConfigForGroup fn = new BootstrapConfigForGroup("jclouds", chefApi, json);
expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null);
replay(client, chefApi);
fn.apply("foo");
verify(client, chefApi);
}
@Test
public void testReturnsItem() throws IOException {
ChefApi chefApi = createMock(ChefApi.class);
Client client = createMock(Client.class);
BootstrapConfigForGroup fn = new BootstrapConfigForGroup("jclouds", chefApi, json);
DatabagItem databag = new DatabagItem("foo",
"{\"environment\":\"development\",\"ssl_ca_file\":\"/etc/certs/chef-server.crt\","
+ "\"run_list\":[\"recipe[apache2]\",\"role[webserver]\"],"
+ "\"attributes\":{\"tomcat6\":{\"ssl_port\":8433}}}");
expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(databag);
replay(client, chefApi);
BootstrapConfig config = fn.apply("foo");
assertEquals(config.getEnvironment(), "development");
assertEquals(config.getSslCAFile(), "/etc/certs/chef-server.crt");
assertEquals(config.getRunList().get(0), "recipe[apache2]");
assertEquals(config.getRunList().get(1), "role[webserver]");
assertEquals(config.getAttributes().toString(), "{\"tomcat6\":{\"ssl_port\":8433}}");
verify(client, chefApi);
}
}
| [
"Administrator@fdp"
] | Administrator@fdp |
0dd5891346e864a33196786b7b721d5dcb61b9d7 | 59be1a176205836a4097a609f0cbef0a40bbe038 | /Example-creational-abstract-factory-pattern/src/main/java/com/codewr/example/FactoryProducer.java | 7f4a51294a72bfea9dd64f5a96b33121562a3bd9 | [] | no_license | sieurobo196/Design-Pattern | 78b5cbce3f57122ebf0e52f7456cbc40f4c72b02 | 90af4ce7348bbe10dab76bd2834dd542f8b48673 | refs/heads/master | 2020-04-01T23:36:59.436495 | 2018-10-26T11:23:03 | 2018-10-26T11:23:03 | 153,765,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 371 | java | package com.codewr.example;
/**
*
* @author codewr
*/
public class FactoryProducer {
public static AbstractFactory getFactory(String choice){
if(choice.equalsIgnoreCase("SHAPE")){
return new ShapeFactory();
}else if(choice.equalsIgnoreCase("COLOR")){
return new ColorFactory();
}
return null;
}
}
| [
"xuancu2006@gmail.com"
] | xuancu2006@gmail.com |
f4467eddc88b6fa38337547f0b444d499726e7c6 | 91aa5ccb8e8c57bf3e4ecc890b54dbc4057b7199 | /app/src/main/java/gbc/sa/vansales/adapters/StockTakeBadgeAdapter.java | dc8b22b1701dda6d5f32e40238966b0a81a9e33b | [] | no_license | gbcdevelopers/GBC | 8f284fe48082382ee2584e4461a28c25c29182f0 | 1f2a38240577d390de91ad5605a1724650ecafda | refs/heads/dev | 2020-06-14T21:35:02.649369 | 2017-09-25T03:46:21 | 2017-09-25T03:46:21 | 75,410,118 | 0 | 0 | null | 2016-12-07T15:37:22 | 2016-12-02T16:01:26 | Java | UTF-8 | Java | false | false | 4,166 | java | package gbc.sa.vansales.adapters;
import android.content.Context;
import android.content.Intent;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import java.util.ArrayList;
import gbc.sa.vansales.R;
import gbc.sa.vansales.activities.SelectOperationActivity;
import gbc.sa.vansales.activities.StockTakeActivity;
import gbc.sa.vansales.models.Product;
import gbc.sa.vansales.models.ShopStatus;
/**
* Created by Rakshit on 18-Nov-16.
*/
public class StockTakeBadgeAdapter extends ArrayAdapter<Product> {
private ArrayList<Product> productList;
private StockTakeActivity activity;
public StockTakeBadgeAdapter(Context context, ArrayList<Product> products){
super(context, R.layout.badge_shop_status,products);
// tempList = new ArrayList<>();
this.activity = (StockTakeActivity)context;
this.productList = products;
}
private class ViewHolder{
private TextView product_description;
private EditText quantitycs;
private EditText quantitybt;
public ViewHolder(View v){
product_description = (TextView) v.findViewById(R.id.lbl_product_description);
quantitycs = (EditText) v.findViewById(R.id.et_quantitycs);
quantitybt = (EditText) v.findViewById(R.id.et_quantitybt);
}
}
@Override
public View getView(final int position, View convertView, ViewGroup parent){
ViewHolder holder;
if(convertView==null){
LayoutInflater inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.badge_stock_take,parent,false);
// link the cached views to the convertview
holder = new ViewHolder(convertView);
// set tag for holder
convertView.setTag(holder);
}
else {
// if holder created, get tag from view
holder = (ViewHolder) convertView.getTag();
}
Product product = getItem(position);
holder.product_description = (TextView)convertView.findViewById(R.id.lbl_product_description);
holder.quantitycs = (EditText)convertView.findViewById(R.id.et_quantitycs);
holder.quantitybt = (EditText)convertView.findViewById(R.id.et_quantitybt);
holder.quantitycs.addTextChangedListener(onQuantityCSChanger(position, holder));
holder.product_description.setText(product.getProductDescription());
holder.quantitycs.setText(productList.get(position).getQuantityCS());
// holder.quantitybt.setText(productList.get(position).getQuantityBT());
return convertView;
}
private TextWatcher onQuantityCSChanger(final int position, final ViewHolder holder) {
return new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
/*Product product = productList.get(position);
product.setQuantityCS(s.toString());
productList.remove(position);
productList.add(product);
// Log.e("Change",""+productList.get(position).getQuantityCS());
activity.updateAdapter();*/
}
@Override
public void afterTextChanged(Editable s) {
Product product = productList.get(position);
product.setQuantityCS(s.toString());
productList.remove(position);
productList.add(position, product);
Log.e("Change",""+productList.get(position).getQuantityCS());
activity.updateAdapter();
}
};
}
}
| [
"rakshitdoshi@Rakshits-MacBook-Pro.local"
] | rakshitdoshi@Rakshits-MacBook-Pro.local |
5af0f3139eaa17b88f718f4ac735b53275f0dacc | a2881dfb3246eebda78c695ede7f5aa0b426aec9 | /1.8 obfuscated/u/um.java | 535dca608401e68ce6d4a2112e4bec929194ad90 | [] | no_license | Jckf/mc-dev | ca03c1907b4b33c94a7bcb7a2067e3963bbf05d2 | 128dae1fe7e2b7772d89dcf130a49210bfd06aa3 | refs/heads/master | 2016-09-05T11:14:19.324416 | 2014-10-01T00:53:05 | 2014-10-01T00:53:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,132 | java |
public class um {
private transient un[] a = new un[16];
private transient int b;
private int c = 12;
private final float d = 0.75F;
private static int g(int var0) {
var0 ^= var0 >>> 20 ^ var0 >>> 12;
return var0 ^ var0 >>> 7 ^ var0 >>> 4;
}
private static int a(int var0, int var1) {
return var0 & var1 - 1;
}
public Object a(int var1) {
int var2 = g(var1);
for(un var3 = this.a[a(var2, this.a.length)]; var3 != null; var3 = var3.c) {
if(var3.a == var1) {
return var3.b;
}
}
return null;
}
public boolean b(int var1) {
return this.c(var1) != null;
}
final un c(int var1) {
int var2 = g(var1);
for(un var3 = this.a[a(var2, this.a.length)]; var3 != null; var3 = var3.c) {
if(var3.a == var1) {
return var3;
}
}
return null;
}
public void a(int var1, Object var2) {
int var3 = g(var1);
int var4 = a(var3, this.a.length);
for(un var5 = this.a[var4]; var5 != null; var5 = var5.c) {
if(var5.a == var1) {
var5.b = var2;
return;
}
}
this.a(var3, var1, var2, var4);
}
private void h(int var1) {
un[] var2 = this.a;
int var3 = var2.length;
if(var3 == 1073741824) {
this.c = Integer.MAX_VALUE;
} else {
un[] var4 = new un[var1];
this.a(var4);
this.a = var4;
this.c = (int)((float)var1 * this.d);
}
}
private void a(un[] var1) {
un[] var2 = this.a;
int var3 = var1.length;
for(int var4 = 0; var4 < var2.length; ++var4) {
un var5 = var2[var4];
if(var5 != null) {
var2[var4] = null;
un var6;
do {
var6 = var5.c;
int var7 = a(var5.d, var3);
var5.c = var1[var7];
var1[var7] = var5;
var5 = var6;
} while(var6 != null);
}
}
}
public Object d(int var1) {
un var2 = this.e(var1);
return var2 == null?null:var2.b;
}
final un e(int var1) {
int var2 = g(var1);
int var3 = a(var2, this.a.length);
un var4 = this.a[var3];
un var5;
un var6;
for(var5 = var4; var5 != null; var5 = var6) {
var6 = var5.c;
if(var5.a == var1) {
--this.b;
if(var4 == var5) {
this.a[var3] = var6;
} else {
var4.c = var6;
}
return var5;
}
var4 = var5;
}
return var5;
}
public void c() {
un[] var1 = this.a;
for(int var2 = 0; var2 < var1.length; ++var2) {
var1[var2] = null;
}
this.b = 0;
}
private void a(int var1, int var2, Object var3, int var4) {
un var5 = this.a[var4];
this.a[var4] = new un(var1, var2, var3, var5);
if(this.b++ >= this.c) {
this.h(2 * this.a.length);
}
}
// $FF: synthetic method
static int f(int var0) {
return g(var0);
}
}
| [
"jckf@jckf.no"
] | jckf@jckf.no |
06d7429d6f3bea1f37bd3c3b481e6fc63588432f | f594ab271d307a4e2cd3c3a601dcd2b26791f183 | /AlphaServiceV1-war/src/java/com/AlphaDevs/Web/JSFBeans/SystemsHandler.java | 08f6caf49d65114dda2358f3f1c5b69d30b1dc38 | [] | no_license | AlphaDevTeam/WebPOS | 2337e89a33145d09bea39b4644cd71b36ee82724 | fbc0b86f76b5e9565847a75c712c363d818d2e66 | refs/heads/master | 2020-12-24T16:25:54.109038 | 2015-08-17T19:21:24 | 2015-08-17T19:21:24 | 11,567,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,297 | java |
package com.AlphaDevs.Web.JSFBeans;
import com.AlphaDevs.Web.Entities.Systems;
import com.AlphaDevs.Web.SessionBean.SystemsController;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
/**
*
* @author Mihindu Gajaba Karunarathne
* Alpha Development Team (Pvt) Ltd
*
*/
@ManagedBean
@RequestScoped
public class SystemsHandler extends SuperHandler{
@EJB
private SystemsController systemsController;
private Systems current;
public SystemsHandler() {
if(current == null){
current = new Systems();
}
}
public SystemsController getSystemsController() {
return systemsController;
}
public void setSystemsController(SystemsController systemsController) {
this.systemsController = systemsController;
}
public Systems getCurrent() {
return current;
}
public void setCurrent(Systems current) {
this.current = current;
}
public List<Systems> getList(){
return getSystemsController().findAll();
}
public String createSystem(){
getSystemsController().create(current);
return "Home";
}
}
| [
"mkarunarathne@tradecard.com"
] | mkarunarathne@tradecard.com |
2f614cc02b1aa69483601c8b403d76be0912668d | 7bee56dc860cd07934fc4282a9e8e29d19797c08 | /workspace/org.dafoe.terminologiclevel/src/org/dafoe/terminologiclevel/saillance/commands/MarkAsIndifferentiated.java | 346b10415b1094fc0cbb538319838c3a8cdff78f | [] | no_license | ics-upmc/Dafoe | 789834898719ac301381d7f4a852f9ea887c6ee1 | 0cacb779bf4b05b85c71b631e934be04455fc982 | refs/heads/master | 2021-01-17T04:32:16.044849 | 2012-02-28T19:36:31 | 2012-02-28T19:36:31 | 3,574,208 | 1 | 0 | null | null | null | null | IBM852 | Java | false | false | 2,642 | java | /*******************************************************************************************************************************
* (c) Copyright 2007, 2010 CRITT Informatique and INSERM, LISI/ENSMA, MONDECA, LIPN, IRIT, SUPELEC, TÚlÚcom ParisTech, CNRS/UTC.
* All rights reserved.
* This program has been developed by the CRITT Informatique for the ANR DAFOE4App Project.
* This program and the accompanying materials are made available under the terms
* of the CeCILL-C Public License v1 which accompanies this distribution,
* and is available at http://www.cecill.info/licences/Licence_CeCILL-C_V1-fr.html
*
* Contributors:
* INSERM, LISI/ENSMA, MONDECA, LIPN, IRIT, SUPELEC, TÚlÚcom ParisTech, CNRS/UTC and CRITT Informatique - specifications
* CRITT Informatique - initial API and implementation
********************************************************************************************************************************/
package org.dafoe.terminologiclevel.saillance.commands;
import java.util.ArrayList;
import java.util.List;
import org.dafoe.framework.core.terminological.model.ITerm;
import org.dafoe.framework.core.terminological.model.LINGUISTIC_STATUS;
import org.dafoe.terminologiclevel.saillance.SaillanceViewPart;
import org.dafoe.terminologiclevel.saillance.VarianteViewPart;
import org.dafoe.terminology.common.DatabaseAdapter;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.PlatformUI;
public class MarkAsIndifferentiated extends AbstractHandler {
public Object execute(ExecutionEvent arg0) throws ExecutionException {
SaillanceViewPart viewPart;
viewPart = (SaillanceViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().findView(SaillanceViewPart.ID);
TableItem[] sel = viewPart.getTableTermViewer().getTable().getSelection();
List<ITerm> terms = new ArrayList<ITerm>();
if (sel != null) {
for (int i = 0; i < sel.length; i++) {
terms.add((ITerm) (sel[i].getData()));
}
DatabaseAdapter.updateTermLinguisticStatus(terms, LINGUISTIC_STATUS.INDIFFERENTIATED);
viewPart.getTableTermViewer().refresh();
}
// retrieve variante viewpart
VarianteViewPart varianteViewPart = (VarianteViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().findView(VarianteViewPart.ID);
varianteViewPart.getTableVariantViewer().refresh();
return null;
}
}
| [
"laurent.mazuel@gmail.com"
] | laurent.mazuel@gmail.com |
4d9610edf94ff71162970301d25076df33f44d8e | 5c68bc950ba0a496ef68b7022f8fcf7b8c511e15 | /Project 2/Project_2/PivotRule.java | ecf58537a0e7cd0067fa679c0110ce1f40b1bd57 | [] | no_license | adimaini/algorithms | 364c0f39988c2e35e8e4a78d997513fc6f9128f8 | 2fc48630722203897a8650b242fd645f114764ed | refs/heads/master | 2022-12-09T21:11:36.775360 | 2020-05-03T07:31:03 | 2020-05-03T07:31:03 | 243,353,835 | 1 | 2 | null | 2022-09-30T20:02:53 | 2020-02-26T20:00:58 | Java | UTF-8 | Java | false | false | 1,923 | java | `import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class PivotRule {
public Integer getPivot(ArrayList<Integer> array){
return array.get(0);
}
}
public int randomPartition(Integer arr[], int left, int right) {
int n = right - left + 1;
int pivot = (int) (Math.random()) * n;
swap(arr, left + pivot, right);
return partition(arr, left, right);
}
class MedianOfMediansRule extends PivotRule {
@Override
public Integer getPivot(ArrayList<Integer> array){
ArrayList<Integer> al = array;
//while the array size is greater than five
while(array.size()>5)
array=medianize(array);
Collections.sort(array);
Integer value = array.get(array.size()/2);
//System.out.println("value: " + value);
//System.out.println("index: " + al.indexOf(value));
return al.indexOf(value);
}
public ArrayList medianize(ArrayList<Integer> array)
{
int full5s = (array.size()/5);
int notFull = array.size()%5;
for(int index = 0; index < array.size() - 5; index = index + 5)
{
Collections.sort(array.subList(index, index+5));
}
if(notFull>0)
Collections.sort(array.subList(array.size()-notFull,array.size()));
ArrayList<Integer> al = new ArrayList<Integer>();
for(int j=2;j<full5s*5;j=j+5)
{
al.add(array.get(j));
}
if(notFull==1)
al.add(array.get(array.size()-1));
else if(notFull==2)
{
al.add(array.get(array.size()-1));
al.add(array.get(array.size()-2));
}
else if(notFull==3)
al.add(array.get(array.size()-2));
else if(notFull==4)
{
al.add(array.get(array.size()-2));
al.add(array.get(array.size()-3));
}
return al;
}
}
| [
"adimaini@Adis-MBP.fios-router.home"
] | adimaini@Adis-MBP.fios-router.home |
70b1785166c1f03cb9bea6fa413cd40f53bfe772 | 2b5af26816c662d9840547e6870e389a01abf7b4 | /adm/src/main/java/com/wavefront/rest/api/client/QueryApi.java | ad8a72685a7b5e7d499b534e575186973dd03a2e | [
"Apache-2.0"
] | permissive | skajagar/integrations | 7bedd100252b612b52afe85991bd1b8a5d894d69 | e306f1d5fb3e276542ce4df74af6945f5eaad41e | refs/heads/master | 2022-12-04T19:53:10.977972 | 2020-08-05T22:07:16 | 2020-08-05T22:07:16 | 286,405,917 | 0 | 0 | Apache-2.0 | 2020-08-10T07:25:35 | 2020-08-10T07:25:35 | null | UTF-8 | Java | false | false | 26,186 | java | /*
* Wavefront REST API
* <p>The Wavefront REST API enables you to interact with Wavefront servers using standard REST API tools. You can use the REST API to automate commonly executed operations such as automatically tagging sources.</p><p>When you make REST API calls outside the Wavefront REST API documentation you must add the header \"Authorization: Bearer <<API-TOKEN>>\" to your HTTP requests.</p>
*
* OpenAPI spec version: v2
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.wavefront.rest.api.client;
import com.wavefront.rest.api.ApiCallback;
import com.wavefront.rest.api.ApiClient;
import com.wavefront.rest.api.ApiException;
import com.wavefront.rest.api.ApiResponse;
import com.wavefront.rest.api.Configuration;
import com.wavefront.rest.api.Pair;
import com.wavefront.rest.api.ProgressRequestBody;
import com.wavefront.rest.api.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import com.wavefront.rest.models.QueryResult;
import com.wavefront.rest.models.RawTimeseries;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class QueryApi {
private ApiClient apiClient;
public QueryApi() {
this(Configuration.getDefaultApiClient());
}
public QueryApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Build call for queryApi
*
* @param q the query expression to execute (required)
* @param s the start time of the query window in epoch milliseconds (required)
* @param g the granularity of the points returned (required)
* @param n name used to identify the query (optional)
* @param e the end time of the query window in epoch milliseconds (null to use now) (optional)
* @param p the approximate maximum number of points to return (may not limit number of points exactly) (optional)
* @param i whether series with only points that are outside of the query window will be returned (defaults to true) (optional)
* @param autoEvents whether events for sources included in the query will be automatically returned by the query (optional)
* @param summarization summarization strategy to use when bucketing points together (optional)
* @param listMode retrieve events more optimally displayed for a list (optional)
* @param strict do not return points outside the query window [s;e), defaults to false (optional)
* @param includeObsoleteMetrics include metrics that have not been reporting recently, defaults to false (optional)
* @param sorted sorts the output so that returned series are in order, defaults to false (optional, default to false)
* @param cached whether the query cache is used, defaults to true (optional, default to true)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call queryApiCall(String q, String s, String g, String n, String e, String p, Boolean i, Boolean autoEvents, String summarization, Boolean listMode, Boolean strict, Boolean includeObsoleteMetrics, Boolean sorted, Boolean cached, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/api/v2/chart/api";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (n != null)
localVarQueryParams.addAll(apiClient.parameterToPair("n", n));
if (q != null)
localVarQueryParams.addAll(apiClient.parameterToPair("q", q));
if (s != null)
localVarQueryParams.addAll(apiClient.parameterToPair("s", s));
if (e != null)
localVarQueryParams.addAll(apiClient.parameterToPair("e", e));
if (g != null)
localVarQueryParams.addAll(apiClient.parameterToPair("g", g));
if (p != null)
localVarQueryParams.addAll(apiClient.parameterToPair("p", p));
if (i != null)
localVarQueryParams.addAll(apiClient.parameterToPair("i", i));
if (autoEvents != null)
localVarQueryParams.addAll(apiClient.parameterToPair("autoEvents", autoEvents));
if (summarization != null)
localVarQueryParams.addAll(apiClient.parameterToPair("summarization", summarization));
if (listMode != null)
localVarQueryParams.addAll(apiClient.parameterToPair("listMode", listMode));
if (strict != null)
localVarQueryParams.addAll(apiClient.parameterToPair("strict", strict));
if (includeObsoleteMetrics != null)
localVarQueryParams.addAll(apiClient.parameterToPair("includeObsoleteMetrics", includeObsoleteMetrics));
if (sorted != null)
localVarQueryParams.addAll(apiClient.parameterToPair("sorted", sorted));
if (cached != null)
localVarQueryParams.addAll(apiClient.parameterToPair("cached", cached));
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json", "application/x-javascript; charset=UTF-8", "application/javascript; charset=UTF-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if (progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[]{"api_key"};
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call queryApiValidateBeforeCall(String q, String s, String g, String n, String e, String p, Boolean i, Boolean autoEvents, String summarization, Boolean listMode, Boolean strict, Boolean includeObsoleteMetrics, Boolean sorted, Boolean cached, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'q' is set
if (q == null) {
throw new ApiException("Missing the required parameter 'q' when calling queryApi(Async)");
}
// verify the required parameter 's' is set
if (s == null) {
throw new ApiException("Missing the required parameter 's' when calling queryApi(Async)");
}
// verify the required parameter 'g' is set
if (g == null) {
throw new ApiException("Missing the required parameter 'g' when calling queryApi(Async)");
}
com.squareup.okhttp.Call call = queryApiCall(q, s, g, n, e, p, i, autoEvents, summarization, listMode, strict, includeObsoleteMetrics, sorted, cached, progressListener, progressRequestListener);
return call;
}
/**
* Perform a charting query against Wavefront servers that returns the appropriate points in the specified time window and granularity
* Long time spans and small granularities can take a long time to calculate
*
* @param q the query expression to execute (required)
* @param s the start time of the query window in epoch milliseconds (required)
* @param g the granularity of the points returned (required)
* @param n name used to identify the query (optional)
* @param e the end time of the query window in epoch milliseconds (null to use now) (optional)
* @param p the approximate maximum number of points to return (may not limit number of points exactly) (optional)
* @param i whether series with only points that are outside of the query window will be returned (defaults to true) (optional)
* @param autoEvents whether events for sources included in the query will be automatically returned by the query (optional)
* @param summarization summarization strategy to use when bucketing points together (optional)
* @param listMode retrieve events more optimally displayed for a list (optional)
* @param strict do not return points outside the query window [s;e), defaults to false (optional)
* @param includeObsoleteMetrics include metrics that have not been reporting recently, defaults to false (optional)
* @param sorted sorts the output so that returned series are in order, defaults to false (optional, default to false)
* @param cached whether the query cache is used, defaults to true (optional, default to true)
* @return QueryResult
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public QueryResult queryApi(String q, String s, String g, String n, String e, String p, Boolean i, Boolean autoEvents, String summarization, Boolean listMode, Boolean strict, Boolean includeObsoleteMetrics, Boolean sorted, Boolean cached) throws ApiException {
ApiResponse<QueryResult> resp = queryApiWithHttpInfo(q, s, g, n, e, p, i, autoEvents, summarization, listMode, strict, includeObsoleteMetrics, sorted, cached);
return resp.getData();
}
/**
* Perform a charting query against Wavefront servers that returns the appropriate points in the specified time window and granularity
* Long time spans and small granularities can take a long time to calculate
*
* @param q the query expression to execute (required)
* @param s the start time of the query window in epoch milliseconds (required)
* @param g the granularity of the points returned (required)
* @param n name used to identify the query (optional)
* @param e the end time of the query window in epoch milliseconds (null to use now) (optional)
* @param p the approximate maximum number of points to return (may not limit number of points exactly) (optional)
* @param i whether series with only points that are outside of the query window will be returned (defaults to true) (optional)
* @param autoEvents whether events for sources included in the query will be automatically returned by the query (optional)
* @param summarization summarization strategy to use when bucketing points together (optional)
* @param listMode retrieve events more optimally displayed for a list (optional)
* @param strict do not return points outside the query window [s;e), defaults to false (optional)
* @param includeObsoleteMetrics include metrics that have not been reporting recently, defaults to false (optional)
* @param sorted sorts the output so that returned series are in order, defaults to false (optional, default to false)
* @param cached whether the query cache is used, defaults to true (optional, default to true)
* @return ApiResponse<QueryResult>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<QueryResult> queryApiWithHttpInfo(String q, String s, String g, String n, String e, String p, Boolean i, Boolean autoEvents, String summarization, Boolean listMode, Boolean strict, Boolean includeObsoleteMetrics, Boolean sorted, Boolean cached) throws ApiException {
com.squareup.okhttp.Call call = queryApiValidateBeforeCall(q, s, g, n, e, p, i, autoEvents, summarization, listMode, strict, includeObsoleteMetrics, sorted, cached, null, null);
Type localVarReturnType = new TypeToken<QueryResult>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Perform a charting query against Wavefront servers that returns the appropriate points in the specified time window and granularity (asynchronously)
* Long time spans and small granularities can take a long time to calculate
*
* @param q the query expression to execute (required)
* @param s the start time of the query window in epoch milliseconds (required)
* @param g the granularity of the points returned (required)
* @param n name used to identify the query (optional)
* @param e the end time of the query window in epoch milliseconds (null to use now) (optional)
* @param p the approximate maximum number of points to return (may not limit number of points exactly) (optional)
* @param i whether series with only points that are outside of the query window will be returned (defaults to true) (optional)
* @param autoEvents whether events for sources included in the query will be automatically returned by the query (optional)
* @param summarization summarization strategy to use when bucketing points together (optional)
* @param listMode retrieve events more optimally displayed for a list (optional)
* @param strict do not return points outside the query window [s;e), defaults to false (optional)
* @param includeObsoleteMetrics include metrics that have not been reporting recently, defaults to false (optional)
* @param sorted sorts the output so that returned series are in order, defaults to false (optional, default to false)
* @param cached whether the query cache is used, defaults to true (optional, default to true)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call queryApiAsync(String q, String s, String g, String n, String e, String p, Boolean i, Boolean autoEvents, String summarization, Boolean listMode, Boolean strict, Boolean includeObsoleteMetrics, Boolean sorted, Boolean cached, final ApiCallback<QueryResult> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = queryApiValidateBeforeCall(q, s, g, n, e, p, i, autoEvents, summarization, listMode, strict, includeObsoleteMetrics, sorted, cached, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<QueryResult>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for queryRaw
*
* @param metric metric to query ingested points for (cannot contain wildcards) (required)
* @param host host to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param source source to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param startTime start time in epoch milliseconds (cannot be more than a day in the past) null to use an hour before endTime (optional)
* @param endTime end time in epoch milliseconds (cannot be more than a day in the past) null to use now (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call queryRawCall(String metric, String host, String source, Long startTime, Long endTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/api/v2/chart/raw";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (host != null)
localVarQueryParams.addAll(apiClient.parameterToPair("host", host));
if (source != null)
localVarQueryParams.addAll(apiClient.parameterToPair("source", source));
if (metric != null)
localVarQueryParams.addAll(apiClient.parameterToPair("metric", metric));
if (startTime != null)
localVarQueryParams.addAll(apiClient.parameterToPair("startTime", startTime));
if (endTime != null)
localVarQueryParams.addAll(apiClient.parameterToPair("endTime", endTime));
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if (progressListener != null) {
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}
String[] localVarAuthNames = new String[]{"api_key"};
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call queryRawValidateBeforeCall(String metric, String host, String source, Long startTime, Long endTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'metric' is set
if (metric == null) {
throw new ApiException("Missing the required parameter 'metric' when calling queryRaw(Async)");
}
com.squareup.okhttp.Call call = queryRawCall(metric, host, source, startTime, endTime, progressListener, progressRequestListener);
return call;
}
/**
* Perform a raw data query against Wavefront servers that returns second granularity points grouped by tags
* An API to check if ingested points are as expected. Points ingested within a single second are averaged when returned.
*
* @param metric metric to query ingested points for (cannot contain wildcards) (required)
* @param host host to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param source source to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param startTime start time in epoch milliseconds (cannot be more than a day in the past) null to use an hour before endTime (optional)
* @param endTime end time in epoch milliseconds (cannot be more than a day in the past) null to use now (optional)
* @return List<RawTimeseries>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public List<RawTimeseries> queryRaw(String metric, String host, String source, Long startTime, Long endTime) throws ApiException {
ApiResponse<List<RawTimeseries>> resp = queryRawWithHttpInfo(metric, host, source, startTime, endTime);
return resp.getData();
}
/**
* Perform a raw data query against Wavefront servers that returns second granularity points grouped by tags
* An API to check if ingested points are as expected. Points ingested within a single second are averaged when returned.
*
* @param metric metric to query ingested points for (cannot contain wildcards) (required)
* @param host host to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param source source to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param startTime start time in epoch milliseconds (cannot be more than a day in the past) null to use an hour before endTime (optional)
* @param endTime end time in epoch milliseconds (cannot be more than a day in the past) null to use now (optional)
* @return ApiResponse<List<RawTimeseries>>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<List<RawTimeseries>> queryRawWithHttpInfo(String metric, String host, String source, Long startTime, Long endTime) throws ApiException {
com.squareup.okhttp.Call call = queryRawValidateBeforeCall(metric, host, source, startTime, endTime, null, null);
Type localVarReturnType = new TypeToken<List<RawTimeseries>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Perform a raw data query against Wavefront servers that returns second granularity points grouped by tags (asynchronously)
* An API to check if ingested points are as expected. Points ingested within a single second are averaged when returned.
*
* @param metric metric to query ingested points for (cannot contain wildcards) (required)
* @param host host to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param source source to query ingested points for (cannot contain wildcards). host or source is equivalent, only one should be used. (optional)
* @param startTime start time in epoch milliseconds (cannot be more than a day in the past) null to use an hour before endTime (optional)
* @param endTime end time in epoch milliseconds (cannot be more than a day in the past) null to use now (optional)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call queryRawAsync(String metric, String host, String source, Long startTime, Long endTime, final ApiCallback<List<RawTimeseries>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = queryRawValidateBeforeCall(metric, host, source, startTime, endTime, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<List<RawTimeseries>>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}
| [
"vikram@wavefront.com"
] | vikram@wavefront.com |
e55b0fc15cb2fa1b96b8418cfe9e50c0825ac889 | d7c3462a1e73f02c9ddb27c6c58e19286f344488 | /app/src/androidTest/java/id/sch/smktelkom_mlg/www/fragment2/ExampleInstrumentedTest.java | 80a7c65327df4860ceadbc4fc8a8aca0d4b918e8 | [] | no_license | finda15/Android_Fragment2 | 5b70ff5020bccd380347584bbf67f4d9da9a58f1 | d408b2cd1d4663503ced18ea99b44c937984d59d | refs/heads/master | 2020-04-29T16:39:03.296631 | 2019-03-18T11:40:23 | 2019-03-18T11:40:23 | 176,268,880 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 752 | java | package id.sch.smktelkom_mlg.www.fragment2;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("id.sch.smktelkom_mlg.www.fragment2", appContext.getPackageName());
}
}
| [
"finda_Nofitri_26rpl@student.smktelkom-mlg.sch.id"
] | finda_Nofitri_26rpl@student.smktelkom-mlg.sch.id |
99437db5b32ca2eee46d2d878b19ad08df1a50b3 | fb4e89cc96cf56ff1d8d189a4282c70168a67709 | /isystem-common/isystem-common-entity/src/main/java/com/yksys/isystem/common/pojo/HotNews.java | bc145cac08c5278768073fe61193b7d70cb86e6f | [
"Apache-2.0"
] | permissive | 289011505/YK-iSystem | 5a517dbb6d4487463b32d84d99c2c70a6b2d9c55 | 8dbaba1f395a0f67d21d4fa9c06a194cb0312a28 | refs/heads/master | 2022-04-23T02:49:18.087595 | 2020-04-20T09:37:05 | 2020-04-20T09:37:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,273 | java | package com.yksys.isystem.common.pojo;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 热点新闻表
*
* @author YuKai Fan
* @create 2020-04-13 15:32:29
*/
@Data
@ApiModel(value = "热点新闻表pojo对象", description = "热点新闻表")
public class HotNews implements Serializable {
private static final long serialVersionUID = 1L;
//热点新闻标识
@ApiModelProperty(value = "热点新闻标识", dataType = "String")
private String id;
//热点新闻主题
@ApiModelProperty(value = "热点新闻主题", dataType = "String")
private String subject;
//热点新闻标题
@ApiModelProperty(value = "热点新闻标题", dataType = "String")
private String title;
//热点新闻内容
@ApiModelProperty(value = "热点新闻内容", dataType = "String")
private String content;
//新闻链接
@ApiModelProperty(value = "新闻链接", dataType = "String")
private String url;
//发布时间
@ApiModelProperty(value = "发布时间", dataType = "DateTime")
private String publishTime;
//发布平台
@ApiModelProperty(value = "发布平台", dataType = "String")
private String publishPlatform;
//转发数
@ApiModelProperty(value = "转发数", dataType = "Integer")
private Integer forwardNum;
//评论数
@ApiModelProperty(value = "评论数", dataType = "Integer")
private Integer commentNum;
//点赞数
@ApiModelProperty(value = "点赞数", dataType = "Integer")
private Integer likeNum;
//序号
@ApiModelProperty(value = "序号", dataType = "Integer")
private Integer sort;
//新闻类型
@ApiModelProperty(value = "新闻类型", dataType = "Integer")
private Integer type;
//热点类型1:热, 2: 新, 3: 荐
@ApiModelProperty(value = "热点类型1:热, 2: 新, 3: 荐", dataType = "Integer")
private Integer hotType;
//备注
@ApiModelProperty(value = "备注", dataType = "String")
private String remark;
//状态:0 已禁用 1 正在使用
@ApiModelProperty(value = "状态:0 已禁用 1 正在使用", dataType = "Integer")
private Integer status;
}
| [
"goodMorning_glb@yukaifan.com"
] | goodMorning_glb@yukaifan.com |
05a31aec9377562c30f02471d05e5b6d4ecff1c8 | ec42e7f3a3b3ef60014dbee543f277ebc560522d | /projetos/trac/trac-cadastros/src/main/java/br/com/targettrust/traccadastros/repositorio/CustomRepository.java | 18cc704d6ab64461c0a95c0c22e9dc4a9af0b087 | [] | no_license | RoseliButzke/imersao-java-19-03 | c98b68c1935a9fdb585238acfb2e67c633279936 | 4a44d498a54de76f76fc76257b37910e5f2f2fe3 | refs/heads/master | 2020-05-20T23:39:18.267116 | 2019-05-07T14:40:14 | 2019-05-07T14:40:14 | 185,805,367 | 0 | 0 | null | 2019-05-09T13:34:08 | 2019-05-09T13:34:07 | null | UTF-8 | Java | false | false | 498 | java | package br.com.targettrust.traccadastros.repositorio;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import br.com.targettrust.traccadastros.entidades.Carro;
@Repository
public class CustomRepository {
@Autowired
private EntityManager entityManager;
@Transactional
public void saveCarro(Carro carro) {
entityManager.persist(carro);
}
}
| [
"valverde.thiago@gmail.com"
] | valverde.thiago@gmail.com |
b00ab2b73ba6a17b98a96bca6750ef0e56d291a5 | 834f2f68f13275a456f049cf15c965ff82cc39cd | /core/src/test/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/ExtendedStatsBucketTests.java | f0e320d4e80ac74a6feb16d4da35a5fdc108d3d1 | [
"Apache-2.0"
] | permissive | cchacin/elasticsearch | 96adf583fa208efb006298a50a44c8d58b9a97b0 | 80288ad60c0c608634fbf9e70cfc5a6a7d21d04e | refs/heads/master | 2021-01-24T14:39:37.385674 | 2016-04-20T20:10:56 | 2016-04-20T20:10:56 | 49,685,798 | 0 | 0 | Apache-2.0 | 2020-09-17T09:36:26 | 2016-01-15T01:02:00 | Java | UTF-8 | Java | false | false | 1,527 | java | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketPipelineAggregatorBuilder;
public class ExtendedStatsBucketTests extends AbstractBucketMetricsTestCase<ExtendedStatsBucketPipelineAggregatorBuilder> {
@Override
protected ExtendedStatsBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name, String bucketsPath) {
ExtendedStatsBucketPipelineAggregatorBuilder factory = new ExtendedStatsBucketPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.sigma(randomDoubleBetween(0.0, 10.0, false));
}
return factory;
}
}
| [
"colings86@users.noreply.github.com"
] | colings86@users.noreply.github.com |
cb7fe460dded02981b894626e0512b6645020024 | 3793c414f0e735ee10e33c22b98dd9e03069b911 | /app/src/main/java/br/com/vitrini/controller/MainActivity.java | 5db975156e63ffff06cd9c044f8fadc1f5058a0d | [] | no_license | vitrini/craft-design | 19c8de7803141dd0635fcb5f2ce56682ea35a6a5 | 546684481df51ffee513fa8707ca681935f7f928 | refs/heads/master | 2021-01-10T01:33:00.319965 | 2016-03-10T22:03:27 | 2016-03-10T22:03:27 | 53,091,118 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,724 | java | package br.com.vitrini.controller;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import br.com.vitrini.R;
import br.com.vitrini.persistence.DatabaseManager;
import br.com.vitrini.utils.ApplicationContextProvider;
import br.com.vitrini.utils.BitmapHelper;
import br.com.vitrini.utils.CirclePageIndicator;
import br.com.vitrini.view.AboutDialogFragment;
import br.com.vitrini.view.InfoComfortFragment;
import br.com.vitrini.view.InfoCraftFragment;
import br.com.vitrini.view.InfoHotelsFragment;
import br.com.vitrini.view.InfoPlacesFragment;
import br.com.vitrini.view.InfoRestaurantsFragment;
import br.com.vitrini.view.InfoRulesFragment;
import br.com.vitrini.view.adapters.ImagePagerAdapter;
public class MainActivity extends FragmentActivity {
private static final String TAG_ABOUT_POPUP = "ABOUT_POPUP";
private int _xDelta;
private int _lastX;
ViewGroup _root;
private ImageButton btnCraft;
private ImageButton btnRules;
private ImageButton btnComfort;
private ImageButton btnPlaces;
private ImageButton btnRestaurants;
private ImageButton btnHotels;
private static final String FRAGMENT_TAG = "INFO_TAG";
private int _dragLeftLimit;
private int _dragRightLimit;
CirclePageIndicator mIndicator;
ViewPager viewPager;
protected ActivityController controller;
protected DatabaseManager databaseManager;
protected void initDatabaseAndServices() {
if(databaseManager == null){
databaseManager = DatabaseManager.getInstance();
}
controller = new ActivityController( this, databaseManager );
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
initDatabaseAndServices();//should be
BitmapHelper.initializeSegmentImages(this);
initView();
if(((ApplicationContextProvider)getApplicationContext()).tabCallStack.isEmpty()) {
ActivityController.pushTabCall((ApplicationContextProvider)getApplicationContext(), 0);
}
}
protected void initEventInfoDrag() {
_root = (ViewGroup)findViewById(R.id.drag_event_details);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) _root.getLayoutParams();
Button dragButton = (Button) findViewById(R.id.button_drag_event_details);
_dragLeftLimit = layoutParams.leftMargin;
_dragRightLimit = 0;
dragButton.setOnTouchListener( new OnTouchListener()
{
@Override
public boolean onTouch(View view, MotionEvent event) {
final int X = (int) event.getRawX();
RelativeLayout.LayoutParams layoutParams = null;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
layoutParams = (RelativeLayout.LayoutParams) _root.getLayoutParams();
_xDelta = X - layoutParams.leftMargin;
_lastX = X;
break;
case MotionEvent.ACTION_UP:
layoutParams = (RelativeLayout.LayoutParams) _root.getLayoutParams();
if(X - _lastX > 0)
layoutParams.leftMargin = _dragRightLimit;
else
layoutParams.leftMargin = _dragLeftLimit;
layoutParams.topMargin = layoutParams.topMargin;
layoutParams.rightMargin = layoutParams.rightMargin;
layoutParams.bottomMargin = layoutParams.bottomMargin;
setLayoutParams( _root, layoutParams );
// Define a imagem da lingueta que deve ser utilizada
if(layoutParams.leftMargin == _dragRightLimit)
_root.setBackgroundResource( R.drawable.event_details_area_close );
else
if(layoutParams.leftMargin == _dragLeftLimit)
_root.setBackgroundResource( R.drawable.event_details_area_open );
break;
case MotionEvent.ACTION_POINTER_DOWN:
break;
case MotionEvent.ACTION_POINTER_UP:
break;
case MotionEvent.ACTION_MOVE:
layoutParams = (RelativeLayout.LayoutParams) _root.getLayoutParams();
layoutParams.leftMargin = X - _xDelta;
layoutParams.topMargin = layoutParams.topMargin;
layoutParams.rightMargin = layoutParams.rightMargin;
layoutParams.bottomMargin = layoutParams.bottomMargin;
// Define a imagem da lingueta que deve ser utilizada
if(X - _lastX > 0)
if(layoutParams.leftMargin >= _dragRightLimit)
{
_root.setBackgroundResource( R.drawable.event_details_area_close );
// BUG conhecido mais pouco frequente
_lastX = _dragRightLimit;
// _xDelta = _lastX - layoutParams.leftMargin;
}
else
_root.setBackgroundResource( R.drawable.event_details_area_open );
else
if(layoutParams.leftMargin <= _dragLeftLimit)
{
_root.setBackgroundResource( R.drawable.event_details_area_open );
_lastX = _dragLeftLimit;
// _xDelta = _lastX - layoutParams.leftMargin;
}
else
_root.setBackgroundResource( R.drawable.event_details_area_close );
setLayoutParams( _root, layoutParams );
break;
}
_root.invalidate();
return true;
}
});
}
private Boolean setLayoutParams( View view, RelativeLayout.LayoutParams layoutParams )
{
if(layoutParams.leftMargin >= _dragLeftLimit && layoutParams.leftMargin <= _dragRightLimit)
{
view.setLayoutParams(layoutParams);
return true;
}
else
{
return false;
}
}
protected void initImageSliderWidget() {
String[] imagesPath = new String[] {
"craft/tela_inicial/craft0.jpg",
"craft/tela_inicial/craft1.jpg",
"craft/tela_inicial/craft2.jpg",
"craft/tela_inicial/craft3.jpg",
"craft/tela_inicial/craft4.jpg",
"craft/tela_inicial/craft5.jpg"
};
viewPager = (ViewPager) findViewById(R.id.view_pager );
ImagePagerAdapter adapter = new ImagePagerAdapter( this, imagesPath );
viewPager.setAdapter(adapter);
mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
mIndicator.setViewPager( (ViewPager)viewPager);
}
protected void initView() {
initEventInfoDrag();
initImageSliderWidget();
initInfoButtons();
intiAboutBtn();
}
private void intiAboutBtn()
{
ImageButton aboutBtn = (ImageButton)findViewById(R.id.img_button_about);
aboutBtn.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View v)
{
FragmentManager manager = getSupportFragmentManager();
AboutDialogFragment dialog = new AboutDialogFragment();
dialog.show(manager, TAG_ABOUT_POPUP);
}
});
}
private void initFragment ( FragmentManager manager, Fragment frag, FrameLayout fl )
{
manager.beginTransaction().replace(fl.getId(), frag).commit();
// Fragment fragment = manager.findFragmentByTag( FRAGMENT_TAG );
// FragmentTransaction xact = manager.beginTransaction();
// if ( fragment != null )
// {
// xact.remove( fragment );
// }
// xact.add(R.id.frame_fragment_layout, frag, FRAGMENT_TAG);
// xact.commit();
}
private void resetBackgroundImg() {
btnComfort.setImageResource( R.drawable.lingueta_comodidades_icon );
btnRules.setImageResource( R.drawable.lingueta_regras_icon );
btnCraft.setImageResource( R.drawable.lingueta_craft_icon );
btnPlaces.setImageResource( R.drawable.lingueta_aonde_ir_icon );
btnRestaurants.setImageResource( R.drawable.lingueta_restaurantes_icon );
btnHotels.setImageResource( R.drawable.lingueta_hoteis_icon );
}
private void initInfoButtons()
{
btnComfort = (ImageButton) findViewById(R.id.img_btn_comfort);
btnPlaces = (ImageButton) findViewById(R.id.img_btn_places);
btnRules = (ImageButton) findViewById(R.id.img_btn_rules);
btnCraft = (ImageButton) findViewById(R.id.img_btn_craft);
btnHotels = (ImageButton) findViewById( R.id.img_btn_hotels );
btnRestaurants = (ImageButton) findViewById( R.id.img_btn_restaurants );
final FragmentManager manager = getSupportFragmentManager();
final FrameLayout fl = (FrameLayout)findViewById( R.id.frame_fragment_layout );
if ( manager.findFragmentByTag( FRAGMENT_TAG ) == null )
{
manager.beginTransaction().replace(fl.getId(), new InfoCraftFragment()).commit();
// FragmentTransaction xact = manager.beginTransaction();
// xact.add(R.id.frame_fragment_layout, new InfoCraftFragment(), FRAGMENT_TAG );
// xact.commit();
resetBackgroundImg();
btnCraft.setImageResource(R.drawable.lingueta_craft_icon_selected);
}
btnRules.setOnClickListener( new View.OnClickListener() {
public void onClick(View v)
{
resetBackgroundImg();
btnRules.setImageResource(R.drawable.lingueta_regras_icon_selected);
initFragment( manager, new InfoRulesFragment(), fl );
}
});
btnCraft.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
resetBackgroundImg();
btnCraft.setImageResource(R.drawable.lingueta_craft_icon_selected);
initFragment( manager, new InfoCraftFragment(), fl );
}
});
btnComfort.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
resetBackgroundImg();
btnComfort.setImageResource(R.drawable.lingueta_comodidades_icon_selected);
initFragment( manager, new InfoComfortFragment(), fl );
}
});
btnPlaces.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
resetBackgroundImg();
btnPlaces.setImageResource(R.drawable.lingueta_aonde_ir_icon_selected);
initFragment( manager, new InfoPlacesFragment(), fl );
}
});
btnRestaurants.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
resetBackgroundImg();
btnRestaurants.setImageResource(R.drawable.lingueta_restaurantes_icon_selected);
initFragment( manager, new InfoRestaurantsFragment(), fl );
}
});
btnHotels.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
resetBackgroundImg();
btnHotels.setImageResource(R.drawable.lingueta_hoteis_icon_selected);
initFragment( manager, new InfoHotelsFragment(), fl );
}
});
}
@Override
public void onBackPressed() {
int lastTab = ActivityController.getLastCalledTab((ApplicationContextProvider)getApplicationContext());
if(lastTab > 0) {
((VitriniTabActivity)getParent()).setCurrentTab(lastTab);
} else {
finish();
}
}
}
| [
"alessandrogurgel@localhost.localdomain"
] | alessandrogurgel@localhost.localdomain |
15b4e4aa0a66e4cddfe6fbbe7b87d72eddc7df46 | 16a3cd782238552914ffede682f578a201827876 | /src/com/dbyl/libarary/action/ViewHomePage.java | 44c83525bc61d4b410f5e463e742d1260ab5be6a | [] | no_license | litongliang/AutoTest | a88caacdab93546d50d8da5c28f8d4d5f11095a7 | a0efde6f6dda9c64036a79e7b0135053316b6ff0 | refs/heads/master | 2021-01-10T08:44:31.762275 | 2016-01-28T05:36:13 | 2016-01-28T05:36:13 | 48,420,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,540 | java | /**
*
*/
package com.dbyl.libarary.action;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.jbehave.core.steps.Steps;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.asserts.Assertion;
import com.dbyl.libarary.pageAction.HomePage;
public class ViewHomePage extends Steps{
private static WebDriver driver;
private static HomePage homePage;
public static WebDriver getDriver() {
return driver;
}
@When("I navigate to happfi homepage")
public static void navigateToLoginPage() throws Exception {
CommonLogin.setDriver(driver);
CommonLogin.loginToHomePage();
}
@Then("I type in name and password in login.html")
public static void submitLoginPage() throws Exception {
CommonLogin.setDriver(driver);
CommonLogin.login();
}
@Then("I should be taken to uCenter.html")
public static void checkuCenter() throws Exception {
WebElement aboutLink = driver.findElement(By.linkText("马上联系我"));
//Link lnkWelcome = new Link("welcome username link", "//span[@id='welcome-username']");
Assertion a = new Assertion();
a.assertTrue(aboutLink.isDisplayed(), "not current page");
}
public static void viewMyProfile() throws Exception {
CommonLogin.setDriver(driver);
homePage = CommonLogin.login();
homePage.clickOnMyProfile();
}
public static void setDriver(WebDriver driver) {
ViewHomePage.driver = driver;
}
}
| [
"ludongdaxue1989@126.com"
] | ludongdaxue1989@126.com |
f8ad2692153609847361826a1c64db31d2bb4a72 | 028cbe18b4e5c347f664c592cbc7f56729b74060 | /v2/appserv-core/src/java/com/sun/enterprise/admin/common/domains/registry/Registry.java | cfb403289ef9540346d50d744c866eb37a123236 | [] | no_license | dmatej/Glassfish-SVN-Patched | 8d355ff753b23a9a1bd9d7475fa4b2cfd3b40f9e | 269e29ba90db6d9c38271f7acd2affcacf2416f1 | refs/heads/master | 2021-05-28T12:55:06.267463 | 2014-11-11T04:21:44 | 2014-11-11T04:21:44 | 23,610,469 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,998 | java | /*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.enterprise.admin.common.domains.registry;
import java.io.Serializable;
import java.util.HashMap;
import java.io.File;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
import java.util.NoSuchElementException;
class Registry implements Serializable, Cloneable, DomainRegistryI
{
TreeMap roots = new TreeMap();
HashMap entries = new HashMap();
public boolean isRegistered(String name){
return roots.containsKey(name);
}
public void registerDomain(DomainEntry de) throws DomainRegistryException{
if (isRegistered(de.getName())) {
throw new AlreadyRegisteredException(de.getName());
}
if (containsRoot(de.getRoot())){
throw new InvalidRootException("The root \""+de.getRoot()+"\" is already registered");
}
roots.put(de.getName(), de.getRoot());
entries.put(de.getName(), de);
}
public void unregisterDomain(String domain_name) throws DomainRegistryException{
if (!isRegistered(domain_name)){
throw new UnregisteredDomainException(domain_name);
}
delete(domain_name);
}
public void unregisterDomain(DomainEntry de) throws DomainRegistryException{
unregisterDomain(de.getName());
}
public void reregisterDomain(DomainEntry de) throws DomainRegistryException {
if (isRegistered(de.getName())) {
if (!roots.get(de.getName()).equals(de.getRoot())){
throw new InvalidRootException("The given root ("+de.getRoot()+") of domain "+de.getName()+" doesn't match the already registered root for this domain");
}
} else {
if (containsRoot(de.getRoot())){
throw new InvalidRootException("The given root ("+de.getRoot()+") of domain "+de.getName()+" is already registered with a different domain");
}
};
entries.put(de.getName(), de);
}
public Iterator iterator() throws DomainRegistryException{
return new RegistryIterator(this);
}
public boolean containsDomain(DomainEntry de) throws DomainRegistryException{
return entries.values().contains(de);
}
public DomainEntry getDomain(String name) throws DomainRegistryException {
return (DomainEntry) entries.get(name);
}
public int size(){
return roots.size();
}
private boolean containsRoot(File root){
return roots.containsValue(root);
}
private void delete(String name){
roots.remove(name);
entries.remove(name);
}
protected Object clone(){
try {
Registry lhs = (Registry) super.clone();
lhs.roots = (TreeMap) this.roots.clone();
lhs.entries = (HashMap) this.entries.clone();
return lhs;
}
catch (CloneNotSupportedException cne){
return null;
}
}
class RegistryIterator implements Iterator
{
Registry registry;
Iterator iterator;
RegistryIterator(Registry r){
registry = (Registry) r.clone();
iterator = registry.roots.keySet().iterator();
}
public boolean hasNext(){
return iterator.hasNext();
}
public Object next() throws NoSuchElementException{
return entries.get((String) iterator.next());
}
public void remove() throws UnsupportedOperationException{
throw new UnsupportedOperationException();
}
}
}
| [
"kohsuke@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5"
] | kohsuke@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5 |
3d246f9d69bd8f9682d00e404fc37cd26178d024 | 6a04b1bf4b3fb054ef8a9852d5190c64e7c81633 | /src/util/pdu/server/Challenge.java | 6037a0304ed71a2d3d9b5af36ef88c121f7c571a | [] | no_license | davidw204/ld-liars-dice | c2e248000dd2f0fa76a8ace005b6c9580dbd0856 | 42277044be2752ae00e2f74e8f7a47761c9a10d8 | refs/heads/master | 2021-01-10T11:53:07.950553 | 2012-07-16T12:58:20 | 2012-07-16T12:58:20 | 52,911,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | java | package util.pdu.server;
//TEST
import static util.CommandIDs.*;
import static util.Converter.*;
import java.util.Arrays;
import util.pdu.PDU;
public class Challenge extends PDU {
private byte[] challenge = hexStringToByteArray("4C494152");
private int version = 1;
public Challenge() {
//Liar's Dice Packet ID
addBytes(MSG_CHALLENGE);
//Total Message Length
addBytes(challenge);
addByte(version);
addLength();
valid();
}
public Challenge(byte[] bytes) {
reset();
addBytes(bytes);
reverseConstructor();
}
@Override
protected void reverseConstructor() {
byte[] bytes = getBytes();
int l = bytes.length;
if (l > 7 && bytes[4] == MSG_CHALLENGE[0]) {
// byte[] packetID = Arrays.copyOfRange(bytes, 0, 4);
// byte[] cid = Arrays.copyOfRange(bytes, 4, 5);
byte[] length = Arrays.copyOfRange(bytes, 5, 7);
int len = toInt(length);
if (l == len + 7) {
byte[] ch = Arrays.copyOfRange(bytes, 7, 11);
byte[] version = Arrays.copyOfRange(bytes, 11, 12);
this.version = toInt(version);
if (match(ch, challenge)) {
valid();
}
}
}
}
public int getVersion() {
return version;
}
}
| [
"mikael.beyene@a34bd350-9789-1c81-bc76-8645c35be6ef"
] | mikael.beyene@a34bd350-9789-1c81-bc76-8645c35be6ef |
2f9521178b9d50baf64c370651acd6fd0cddb1fd | 668d300925d543e1eb929a476457982d0a29b355 | /GooglemapApiExample/GoogleMap/src/MyGoogleAPI/GoogleMap/MapOverlay.java | 69d9091064ccdd756abd783916d36d079cee7d07 | [] | no_license | k300021/Android_program | 1e5f392547a235ade3a082597f549caeb096cd68 | 6439e4ebb47754a487cca3822512e38d48707e9a | refs/heads/master | 2021-01-22T04:33:47.156430 | 2014-05-09T11:07:26 | 2014-05-09T11:07:26 | null | 0 | 0 | null | null | null | null | ISO-8859-9 | Java | false | false | 956 | java | package MyGoogleAPI.GoogleMap;
import java.util.ArrayList;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
public class MapOverlay extends ItemizedOverlay<OverlayItem>{
private ArrayList<OverlayItem> gList = new ArrayList<OverlayItem>();
Drawable marker;
public MapOverlay(Drawable defaultMarker) {
super(defaultMarker);
marker = defaultMarker;
}
// ±NOverlayItem¥[¤JgList¤¤
public void addOverlayItem(OverlayItem oItem){
gList.add(oItem);
populate();
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
boundCenterBottom(marker);
}
@Override
protected OverlayItem createItem(int arg0) {
return gList.get(arg0);
}
@Override public int size() {
return gList.size();
}
} | [
"k300021@yahoo.com.tw"
] | k300021@yahoo.com.tw |
0ff2fc6f80db84124fe80dc587c4e868ea83f07d | f36a48c574ea408d10f1ca23b5bc69f0321dd142 | /app/src/main/java/com/artion/androiddemos/view/MyDrawView.java | 7ecbb6af91d126c7c351ead068d3437f687d2937 | [] | no_license | fromsheng/AndroidDemos_AS | f5851252c1d752ed9a000b67bb1fd42ac70648de | dd6bb59ea6a9afb3ccb2897d264bb6e2c2fc3edc | refs/heads/master | 2020-12-24T11:20:40.989987 | 2020-04-18T12:06:27 | 2020-04-18T12:06:27 | 73,038,295 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,391 | java | package com.artion.androiddemos.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import com.artion.androiddemos.R;
import com.artion.androiddemos.common.ToastUtils;
public class MyDrawView extends View implements OnClickListener {
/**
* 屏幕的宽
*/
private int width=400;
/**
* 屏幕的高
*/
private int height=400;
/**
* 颜色区分区域
*/
private int[] colors = new int[] { Color.BLACK, Color.BLUE, Color.CYAN,
Color.GREEN, Color.GRAY, Color.MAGENTA, Color.RED, Color.LTGRAY};
private String[] colorStrs = new String[] {
"黑色", "蓝色", "青绿色", "绿色", "灰色", "洋红色", "红色", "浅灰色"};
/**
* 大园半径
*/
private float bigR;
/**
* 小圆半径
*/
private float litterR;
/**
* 屏幕中间点的X坐标
*/
private float centerX;
/**
* 屏幕中间点的Y坐标
*/
private float centerY;
public MyDrawView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
// 设置两个圆的半径
bigR = (width - 20)/2;
litterR = bigR/2;
centerX = width/2;
centerY = height/2;
}
public MyDrawView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
// 设置两个圆的半径
bigR = (width - 20)/2;
litterR = bigR/2;
centerX = width/2;
centerY = height/2;
}
public MyDrawView(Context context) {
super(context);
// TODO Auto-generated constructor stub
// 设置两个圆的半径
bigR = (width - 20)/2;
litterR = bigR/2;
centerX = width/2;
centerY = height/2;
}
private int count = 0;
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
// // 首先定义一个paint
// Paint paint = new Paint();
//
// // 绘制矩形区域-实心矩形
// // 设置颜色
// paint.setColor(Color.BLUE);
// // 设置样式-填充
// paint.setStyle(Style.FILL);
// // 绘制一个矩形
// canvas.drawRect(new Rect(0, 0, getWidth(), getHeight()), paint);
//
// // 绘空心矩形
// // 设置颜色
// paint.setColor(Color.RED);
// // 设置样式-空心矩形
// paint.setStyle(Style.STROKE);
// // 绘制一个矩形
// canvas.drawRect(new Rect(10, 10, 300, 200), paint);
//
// // 绘文字
// // 设置颜色
// paint.setColor(Color.GREEN);
// paint.setTextSize(18);
// // 绘文字
// canvas.drawText("Hello", 10, 50, paint);
//
// // 绘图
// // 从资源文件中生成位图
// Bitmap bitmap = null;
// if(count % 2 == 0) {
// bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.btn_blue_normal);
// } else {
// bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.btn_blue_down);
// }
// // 绘图
// canvas.drawBitmap(bitmap, 10, 60, paint);
//
// setOnClickListener(this);
Paint p = new Paint();
// 绘制矩形区域-实心矩形
// 设置颜色
p.setColor(Color.BLUE);
// 设置样式-填充
p.setStyle(Style.FILL);
canvas.drawRect(new Rect(0, 0, getWidth(), getHeight()), p);
// 画背景颜色
Paint bg = new Paint();
bg.setColor(Color.WHITE);
Rect bgR = new Rect(0, 0, width, height);
canvas.drawRect(bgR, bg);
float start = 0F;
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
for(int i = 0; i < 4; i ++) {
//注意一定要先画大圆,再画小圆,不然看不到效果,小圆在下面会被大圆覆盖
// 画大圆
RectF bigOval = new RectF(centerX - bigR, centerY - bigR,
centerX + bigR, centerY + bigR);
paint.setColor(colors[i]);
canvas.drawArc(bigOval, start, 90, true, paint);
// 画小圆
RectF litterOval = new RectF(centerX - litterR, centerY - litterR,
centerX + litterR, centerY + litterR);
paint.setColor(colors[i+2]);
canvas.drawArc(litterOval, start, 90, true, paint);
start += 90F;
}
bg.setColor(Color.LTGRAY);
Rect bgR2 = new Rect(0, height, width, 2*height);
canvas.drawRect(bgR2, bg);
float start2 = 0F;
Paint paint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
for(int i = 0; i < 2; i ++) {
//注意一定要先画大圆,再画小圆,不然看不到效果,小圆在下面会被大圆覆盖
// 画大圆
RectF bigOval = new RectF(centerX - bigR, centerY - bigR + height,
centerX + bigR, centerY + bigR + height);
paint2.setColor(getColor(count, true));
canvas.drawArc(bigOval, start2, 180, true, paint2);
// 画小圆
RectF litterOval = new RectF(centerX - litterR, centerY - litterR + height,
centerX + litterR, centerY + litterR + height);
paint2.setColor(getColor(count, false));
canvas.drawArc(litterOval, start2, 180, true, paint2);
start2 += 180F;
}
}
private int smallColorNormal = Color.GRAY;
private int smallColorPress = Color.BLUE;
private int smallColorDown = Color.YELLOW;
private int bigColorNormal = Color.RED;
private int bigColorPress = Color.CYAN;
private int bigColorDown = Color.MAGENTA;
private int getColor(int count, boolean isBig) {
int color = isBig ? bigColorNormal : smallColorNormal;
switch (count % 3) {
case 1:
color = isBig ? bigColorDown : smallColorDown;
break;
case 2:
color = isBig ? bigColorPress : smallColorPress;
break;
default:
color = isBig ? bigColorNormal : smallColorNormal;
break;
}
return color;
}
@Override
public void onClick(View v) {
count ++;
ToastUtils.showMessage(getContext(), "onclick");
invalidate();
}
String tips = "";
@Override
public boolean onTouchEvent(MotionEvent event) {
// 获取点击屏幕时的点的坐标
float x = event.getX();
float y = event.getY();
// whichCircle(x, y);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
count = 1;
invalidate();
tips = getWhichCircle(x, y);
return !super.onTouchEvent(event);
// break;
case MotionEvent.ACTION_UP:
count = 0;
ToastUtils.showMessage(getContext(), tips);
invalidate();
break;
default:
break;
}
return super.onTouchEvent(event);
}
private String getWhichCircle(float x, float y) {
// 将屏幕中的点转换成以屏幕中心为原点的坐标点
float mx = x - centerX;
float my = y - centerY;
float result = mx * mx + my * my;
StringBuilder tip = new StringBuilder();
tip.append("您点击了");
// 高中的解析几何
if(result <= litterR*litterR) {// 点击的点在小圆内
tip.append("小圆的");
tip.append(colorStrs[whichZone(mx, my)+2]);
tip.append("区域");
} else if(result <= bigR * bigR) {// 点击的点在大圆内
tip.append("大圆的");
tip.append(colorStrs[whichZone(mx, my)]);
tip.append("区域");
} else {// 点不在作作区域
tip.append("作用区域以外的区域");
}
return tip.toString();
}
/**
* 确定点击的点在哪个圆内
* @param x
* @param y
*/
private void whichCircle(float x, float y) {
// 将屏幕中的点转换成以屏幕中心为原点的坐标点
float mx = x - centerX;
float my = y - centerY;
float result = mx * mx + my * my;
StringBuilder tip = new StringBuilder();
tip.append("您点击了");
// 高中的解析几何
if(result <= litterR*litterR) {// 点击的点在小圆内
tip.append("小圆的");
tip.append(colorStrs[whichZone(mx, my)+2]);
tip.append("区域");
} else if(result <= bigR * bigR) {// 点击的点在大圆内
tip.append("大圆的");
tip.append(colorStrs[whichZone(mx, my)]);
tip.append("区域");
} else {// 点不在作作区域
tip.append("作用区域以外的区域");
}
ToastUtils.showMessage(getContext(), tip.toString());
}
/**
* 判断点击了圆的哪个区域
* @param x
* @param y
* @return
*/
private int whichZone(float x, float y) {
// 简单的象限点处理
// 第一象限在右下角,第二象限在左下角,代数里面的是逆时针,这里是顺时针
if(x > 0 && y > 0) {
return 0;
} else if(x > 0 && y < 0) {
return 3;
} else if(x < 0 && y < 0) {
return 2;
} else if(x < 0 && y > 0) {
return 1;
}
return -1;
}
}
| [
"312105857@qq.com"
] | 312105857@qq.com |
c0e03a4747edcfa9510de61ef99d27dbe8979448 | b14e517251cf4549059eb8ac150ce148f6fab14a | /src/main/java/frc/robot/subsystems/drivetrain/enums/TransmissionSide.java | 504d2513e798694038f013626d88b7610a3b8d79 | [] | no_license | RoboLancers/FRC_2019 | 86dce633511960ac984ef88d97cecf3798abb0d2 | d316860570e8e8fb817202f4f67d3af9b856dcd2 | refs/heads/master | 2022-04-02T22:24:58.922211 | 2020-02-22T20:29:03 | 2020-02-22T20:29:03 | 164,543,611 | 1 | 2 | null | 2019-04-07T20:27:40 | 2019-01-08T02:48:23 | Java | UTF-8 | Java | false | false | 97 | java | package frc.robot.subsystems.drivetrain.enums;
public enum TransmissionSide {
LEFT, RIGHT
}
| [
"brianchen0810@hotmail.com"
] | brianchen0810@hotmail.com |
a815a29ddb8da4640e497ad0d4dad765afe64ad1 | 8d82c672f97b4e13dca71c145aaea3474e7de79c | /ssm/spring_day04_tx_xml/src/test/java/cn/itcast/test/AccountServiceTest.java | 60a2f03a72de89dd2a3d66bf4f31cdab2aaad615 | [] | no_license | chenjiaren123/ssm | 5bd4e15ac806763e5b47c3d746affca22c09973a | 9153df03e72e80b9cc0eea0668a8ee6207336d64 | refs/heads/master | 2020-05-24T20:57:17.951173 | 2019-05-19T11:09:18 | 2019-05-19T11:09:18 | 187,465,757 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 611 | java | package cn.itcast.test;
import cn.itcast.service.AccountService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:bean.xml")
public class AccountServiceTest {
@Autowired
private AccountService accountService;
@Test
public void testTransfer(){
accountService.transfer("aaa", "bbb", 100F);
}
}
| [
"chen@qq.com"
] | chen@qq.com |
3bd75f3b73ce0cb946685b04b915fb73a3d74ae1 | 3a6f00b87343e60e24f586dae176bdf010b5dcae | /sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aad/implementation/constants/AadJwtClaimNames.java | 0bd52f42cd1446df9fa355d21ab7144e5bbce52b | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause",
"CC0-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.1-or-later"
] | permissive | RaviTella/azure-sdk-for-java | 4c3267ea7a3ef17ffef89621c8add0a8b7dc72cb | d82d70fde49071ee2cefb4a69621c680dfafc793 | refs/heads/main | 2022-04-26T21:11:08.604986 | 2022-04-11T07:03:32 | 2022-04-11T07:03:32 | 394,745,792 | 0 | 0 | MIT | 2021-09-13T15:03:34 | 2021-08-10T18:25:18 | Java | UTF-8 | Java | false | false | 801 | java | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.spring.cloud.autoconfigure.aad.implementation.constants;
/**
* Claim names in ID token or access token.
*
* @since 4.0.0
* @see <a href="https://docs.microsoft.com/azure/active-directory/develop/access-tokens">Access tokens</a>
* @see <a href="https://docs.microsoft.com/azure/active-directory/develop/id-tokens">ID tokens</a>
*/
public class AadJwtClaimNames {
public static final String AUD = "aud";
public static final String ISS = "iss";
public static final String NAME = "name";
public static final String ROLES = "roles";
public static final String SCP = "scp";
public static final String SUB = "sub";
public static final String TID = "tid";
}
| [
"noreply@github.com"
] | RaviTella.noreply@github.com |
6472706c9df849ad01591b1e73c085a61e0f15b6 | 5545c260f94a9db8cc263c8e50b8b74ac878ce7a | /LaitProjekt/src/Jacekpaczka/zad7.java | 154bc3d43f2e79f99db239ad5ab9fdb6feb32d00 | [] | no_license | lait2017/LaitGit | 68796ac3621c193a20f72cefe3dc083170473a88 | 2091e1415c299da8dd8e059b459f9049b46c09af | refs/heads/master | 2021-08-24T15:39:53.870968 | 2017-12-10T08:32:29 | 2017-12-10T08:32:29 | 111,019,260 | 0 | 1 | null | 2017-12-02T17:22:12 | 2017-11-16T20:33:50 | Java | WINDOWS-1250 | Java | false | false | 294 | java | package Jacekpaczka;
public class zad7 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int x;
System.out.println("obliczam wartość równania y=3x zmieniając x od 0 do 10");
x=0;
do {System.out.println(3*x);
x++;}
while
(x<10);
}
}
| [
"you@example.com"
] | you@example.com |
4db6d86e02eef3bc0e5ca9eab2edd714ee998058 | b016e43cbd057f3911ed5215c23a686592d98ff0 | /google-ads/src/main/java/com/google/ads/googleads/v8/services/stub/CampaignSimulationServiceStubSettings.java | a5994658b2e2a9a811b63d862cad851006434ea5 | [
"Apache-2.0"
] | permissive | devchas/google-ads-java | d53a36cd89f496afedefcb6f057a727ecad4085f | 51474d7f29be641542d68ea406d3268f7fea76ac | refs/heads/master | 2021-12-28T18:39:43.503491 | 2021-08-12T14:56:07 | 2021-08-12T14:56:07 | 169,633,392 | 0 | 1 | Apache-2.0 | 2021-08-12T14:46:32 | 2019-02-07T19:56:58 | Java | UTF-8 | Java | false | false | 11,404 | java | /*
* Copyright 2021 Google LLC
*
* 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 com.google.ads.googleads.v8.services.stub;
import com.google.ads.googleads.v8.resources.CampaignSimulation;
import com.google.ads.googleads.v8.services.GetCampaignSimulationRequest;
import com.google.api.core.ApiFunction;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.StatusCode;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;
import org.threeten.bp.Duration;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Settings class to configure an instance of {@link CampaignSimulationServiceStub}.
*
* <p>The default instance has everything set to sensible defaults:
*
* <ul>
* <li> The default service address (googleads.googleapis.com) and default port (443) are used.
* <li> Credentials are acquired automatically through Application Default Credentials.
* <li> Retries are configured for idempotent methods but not for non-idempotent methods.
* </ul>
*
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of getCampaignSimulation to 30 seconds:
*
* <pre>{@code
* CampaignSimulationServiceStubSettings.Builder campaignSimulationServiceSettingsBuilder =
* CampaignSimulationServiceStubSettings.newBuilder();
* campaignSimulationServiceSettingsBuilder
* .getCampaignSimulationSettings()
* .setRetrySettings(
* campaignSimulationServiceSettingsBuilder
* .getCampaignSimulationSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* CampaignSimulationServiceStubSettings campaignSimulationServiceSettings =
* campaignSimulationServiceSettingsBuilder.build();
* }</pre>
*/
@Generated("by gapic-generator-java")
public class CampaignSimulationServiceStubSettings
extends StubSettings<CampaignSimulationServiceStubSettings> {
/** The default scopes of the service. */
private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
ImmutableList.<String>builder().add("https://www.googleapis.com/auth/adwords").build();
private final UnaryCallSettings<GetCampaignSimulationRequest, CampaignSimulation>
getCampaignSimulationSettings;
/** Returns the object with the settings used for calls to getCampaignSimulation. */
public UnaryCallSettings<GetCampaignSimulationRequest, CampaignSimulation>
getCampaignSimulationSettings() {
return getCampaignSimulationSettings;
}
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CampaignSimulationServiceStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcCampaignSimulationServiceStub.create(this);
}
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
}
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
}
/** Returns the default service endpoint. */
public static String getDefaultEndpoint() {
return "googleads.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "googleads.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
}
/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
}
/** Returns a builder for the default ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(CampaignSimulationServiceStubSettings.class))
.setTransportToken(
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
/** Returns a new builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
}
/** Returns a builder containing all the values of this settings class. */
public Builder toBuilder() {
return new Builder(this);
}
protected CampaignSimulationServiceStubSettings(Builder settingsBuilder) throws IOException {
super(settingsBuilder);
getCampaignSimulationSettings = settingsBuilder.getCampaignSimulationSettings().build();
}
/** Builder for CampaignSimulationServiceStubSettings. */
public static class Builder
extends StubSettings.Builder<CampaignSimulationServiceStubSettings, Builder> {
private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
private final UnaryCallSettings.Builder<GetCampaignSimulationRequest, CampaignSimulation>
getCampaignSimulationSettings;
private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
RETRYABLE_CODE_DEFINITIONS;
static {
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"retry_policy_0_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}
private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
static {
ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(5000L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(3600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(3600000L))
.setTotalTimeout(Duration.ofMillis(3600000L))
.build();
definitions.put("retry_policy_0_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}
protected Builder() {
this(((ClientContext) null));
}
protected Builder(ClientContext clientContext) {
super(clientContext);
getCampaignSimulationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(getCampaignSimulationSettings);
initDefaults(this);
}
protected Builder(CampaignSimulationServiceStubSettings settings) {
super(settings);
getCampaignSimulationSettings = settings.getCampaignSimulationSettings.toBuilder();
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(getCampaignSimulationSettings);
}
private static Builder createDefault() {
Builder builder = new Builder(((ClientContext) null));
builder.setTransportChannelProvider(defaultTransportChannelProvider());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
private static Builder initDefaults(Builder builder) {
builder
.getCampaignSimulationSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
return builder;
}
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
return this;
}
public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
return unaryMethodSettingsBuilders;
}
/** Returns the builder for the settings used for calls to getCampaignSimulation. */
public UnaryCallSettings.Builder<GetCampaignSimulationRequest, CampaignSimulation>
getCampaignSimulationSettings() {
return getCampaignSimulationSettings;
}
@Override
public CampaignSimulationServiceStubSettings build() throws IOException {
return new CampaignSimulationServiceStubSettings(this);
}
}
}
| [
"noreply@github.com"
] | devchas.noreply@github.com |
48fb0749201565769d53cf5d96228557f3658789 | 16b80e7bbb40624b3d5564b873d71a2ef84a91be | /yats/src/main/java/com/github/cjnosal/yats/slideshow/Slide.java | 0e369081d45236946394a7718f112e107280c055 | [
"MIT"
] | permissive | cjnosal/yat-slides-reddit | 7dabf3a1d85eb048e5817c50b19a67f80fafe27b | 81c534530f2bab46544736b8a2fb87ea3b1ce20b | refs/heads/master | 2021-01-10T13:38:45.335025 | 2017-01-22T23:40:59 | 2017-01-22T23:40:59 | 53,793,299 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 585 | java | package com.github.cjnosal.yats.slideshow;
import java.io.Serializable;
public class Slide implements Serializable {
private String image;
private String title;
private String description;
public Slide(String image, String title, String description) {
this.image = image;
this.title = title;
this.description = description;
}
public String getDescription() {
return this.description;
}
public String getImageUrl() {
return this.image;
}
public String getTitle() {
return this.title;
}
}
| [
"c.nosal@gmail.com"
] | c.nosal@gmail.com |
c0581feab362cb3cd2b474f159be4da36ed536f1 | facf86f11d4de00f49ed1301909c961470e1593c | /lost-messages-tests/src/main/java/lostmessagestest/messages/TestMessage.java | 0db018942adb007533139e451bf65f4021547cfb | [
"Apache-2.0"
] | permissive | ChristianLehner98/clustering-tests | 012bcae39e5ec2774a1da1336cc7af3dac0a5bd8 | a57cdc467898b675373610a3218107fbb80509d8 | refs/heads/master | 2020-05-09T19:00:07.425883 | 2019-05-09T14:50:19 | 2019-05-09T14:50:19 | 181,363,325 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 71 | java | package lostmessagestest.messages;
public interface TestMessage {
}
| [
"christian.lehner@student.uni-augsburg.de"
] | christian.lehner@student.uni-augsburg.de |
c360addad497440da8f60205a3628af8034105c4 | edb52284995497d6e1a425d85e5a1bc8847ba76e | /python/src/com/jetbrains/python/debugger/concurrency/tool/graph/GraphCellRenderer.java | 38d9d28f274e1b6fabe79f20d98c29661916f6e3 | [] | no_license | Elizaveta239/ta | fac6d9f6fd491b13abaf658f5cafbe197567bf53 | 58e1c3136c48a43bed77034784a0d1412d2d5c50 | refs/heads/master | 2020-04-10T21:25:39.581838 | 2015-05-27T18:12:26 | 2015-05-27T18:12:26 | 28,911,347 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,203 | java |
package com.jetbrains.python.debugger.concurrency.tool.graph;
import com.intellij.ui.ColoredTableCellRenderer;
import com.jetbrains.python.debugger.concurrency.PyConcurrencyLogManager;
import com.jetbrains.python.debugger.concurrency.tool.GraphSettings;
import com.jetbrains.python.debugger.concurrency.tool.graph.elements.DrawElement;
import com.jetbrains.python.debugger.concurrency.tool.graph.states.StoppedThreadState;
import com.jetbrains.python.debugger.concurrency.tool.graph.states.ThreadState;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public class GraphCellRenderer extends ColoredTableCellRenderer {
private final PyConcurrencyLogManager myLogManager;
private final GraphManager myGraphManager;
private int myRow;
public GraphCellRenderer(PyConcurrencyLogManager logManager, GraphManager graphManager) {
myLogManager = logManager;
myGraphManager = graphManager;
}
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
myRow = row;
setBorder(null);
}
private void drawRelation(Graphics g, int parent, int child) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int x_start = Math.round((parent + 0.5f) * GraphSettings.NODE_WIDTH);
int x_finish = Math.round((child + 0.5f) * GraphSettings.NODE_WIDTH);
int y = Math.round(GraphSettings.CELL_HEIGH * 0.5f);
g2.drawLine(x_start, y, x_finish, y);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
ArrayList<DrawElement> rowElements = myGraphManager.getDrawElementsForRow(myRow);
int i = 0;
for (DrawElement element: rowElements) {
element.drawElement(g, i);
++i;
}
int[] relation = myGraphManager.getRelationForRow(myRow);
if (relation[0] != relation[1]) {
DrawElement element = rowElements.get(relation[1]);
ThreadState state = element.getAfter() instanceof StoppedThreadState ? element.getBefore(): element.getAfter();
state.prepareStroke(g);
drawRelation(g, relation[0], relation[1]);
}
}
}
| [
"Elizaveta.Shashkova@jetbrains.com"
] | Elizaveta.Shashkova@jetbrains.com |
ec98d50adcb69099813ab6badc4d297fbe32e35f | 421a7bfdadfb2561c53569842ce9e1b34b6b074f | /restaurante/src/main/java/br/com/douglas/restaurante/categoria/Categoria.java | 933964c2cf26d33574c288071bc7c87dbf84e98d | [] | no_license | DouglasZen/judFood | 398937438b987a4fada6bc9928ebe25d1233c8e6 | 6c78a6092525bd8a48d389ceaa75bf2afa208424 | refs/heads/master | 2021-01-23T10:20:49.059357 | 2018-01-12T11:29:27 | 2018-01-12T11:29:27 | 93,053,030 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,505 | java | package br.com.douglas.restaurante.categoria;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import br.com.douglas.restaurante.restaurante.Restaurante;
@Entity
@Table(name="categoria")
public class Categoria {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="codigo")
private Integer codigo;
@Column(name="descricao")
private String descricao;
@ManyToOne
@JoinColumn(name="codigo_restaurante")
private Restaurante restaurante;
@Column(name="imagem")
private String imagem;
public Categoria(Integer codigo, String descricao, Restaurante restaurante) {
super();
this.codigo = codigo;
this.descricao = descricao;
this.restaurante = restaurante;
}
public Categoria() {
super();
}
public Integer getCodigo() {
return codigo;
}
public void setCodigo(Integer codigo) {
this.codigo = codigo;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Restaurante getRestaurante() {
return restaurante;
}
public void setRestaurante(Restaurante restaurante) {
this.restaurante = restaurante;
}
public String getImagem() {
return imagem;
}
public void setImagem(String imagem) {
this.imagem = imagem;
}
}
| [
"douglas.zen@gmail.com"
] | douglas.zen@gmail.com |
49c421dfcb00d6f2fdad92c90de99e9b7019120b | c3b7c7f5d92396462b24698c07e6b43f57f26f3a | /src/main/java/cn/itsource/day6/code-练习/MaxValue.java | 1e11a21f262f040b66c928b0302d7d8761f4ac2e | [] | no_license | usami-muzugi/javahomework | d0abca56bfd664c042c30b07dc8ba6bf4526b759 | e0010bbfd0885d24db6ac87c671c7429be4b2a26 | refs/heads/master | 2021-09-17T14:07:45.305360 | 2018-07-02T14:28:36 | 2018-07-02T14:28:41 | 106,161,494 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 594 | java | public class MaxValue{
public static void main(String[] args){
//1) 定义一个方法,接受三个int参数,计算打印最大的一个数。
max(4,4,3);
}
public static void max(int i,int j, int k){
int index = 0;
if(i > j && i > k){
index = i;
}else if(j > i && j > k){
index = j;
}else if(k > i && k > j){
index = k;
}
if(!(index==0))
System.out.println("The Max Value = "+index);
else
System.out.println("The Max Value not exist!");
}
} | [
"715759898@qq.com"
] | 715759898@qq.com |
b25fc301c5115cca2544b035be1b8da608fa074c | 7d414583cbf338fe1db40899c94dfc98b3a0e3c9 | /modules/sample-apps/poc-employee/poc-service-builder/poc-employee-service/src/main/java/com/poc/employee/internal/search/query/contributor/EmployeeEntryKeywordQueryContributor.java | 137b0e4284f52cec9f9d68ae7e897831f0b26356 | [] | no_license | kevinanh9x/bee | 17f95da81fade79070a4481b4e9b663a87f971f5 | 54381386218e6ff764f2f9542fd98528e3e4b1af | refs/heads/master | 2023-08-12T08:18:58.726064 | 2021-10-15T12:13:11 | 2021-10-15T12:13:11 | 417,485,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,720 | java | package com.poc.employee.internal.search.query.contributor;
import com.liferay.portal.kernel.search.BooleanQuery;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.kernel.search.SearchContext;
import com.liferay.portal.search.query.QueryHelper;
import com.liferay.portal.search.spi.model.query.contributor.KeywordQueryContributor;
import com.liferay.portal.search.spi.model.query.contributor.helper.KeywordQueryContributorHelper;
import com.poc.employee.constant.SearchField;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@Component(
immediate = true,
property = "indexer.class.name=com.poc.employee.model.EmployeeEntry",
service = KeywordQueryContributor.class
)
public class EmployeeEntryKeywordQueryContributor implements KeywordQueryContributor{
@Reference
protected QueryHelper queryHelper;
@Override
public void contribute(String keywords, BooleanQuery booleanQuery, KeywordQueryContributorHelper keywordQueryContributorHelper) {
SearchContext searchContext =
keywordQueryContributorHelper.getSearchContext();
queryHelper.addSearchTerm(
booleanQuery, searchContext, Field.NAME, true);
queryHelper.addSearchTerm(
booleanQuery, searchContext, SearchField.GENDER, true);
queryHelper.addSearchTerm(
booleanQuery, searchContext, SearchField.ADDRESS, false);
queryHelper.addSearchTerm(
booleanQuery, searchContext, SearchField.BIRTHDAY, false);
queryHelper.addSearchTerm(
booleanQuery, searchContext, SearchField.HAS_ACCOUNT, true);
}
}
| [
"theanh4497@gmail.com"
] | theanh4497@gmail.com |
735095d55b0a174f6647c623f43c26b49f57a256 | 4a04c4d79844d7c3f212a9c3614f09e495f08ca5 | /Seminar6/src/ro/ase/cts/factorymethod/Fundas.java | e099a1ea9899cbf284b40cc9a6bb263c29f909a1 | [] | no_license | RomanDanielCSIE/Seminarii_CTS | 73b3dd11a0fd096cee7de6c5f6756d193df05a42 | b1cde79d3acc87f848d895f326cffb1f149122cd | refs/heads/main | 2023-05-02T21:51:36.071674 | 2021-05-29T06:39:37 | 2021-05-29T06:39:37 | 347,309,360 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 407 | java | package ro.ase.cts.factorymethod;
public class Fundas extends Jucator {
public Fundas(String nume, int meciuriJucate) {
super(nume, meciuriJucate);
}
@Override
public String toString() {
StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append("Fundas");
stringBuilder.append(super.toString());
return stringBuilder.toString();
}
}
| [
"roman.daniel.csie@gmail.com"
] | roman.daniel.csie@gmail.com |
c1d67bb933910d589337ed6a34e1949b554f1699 | 0a8e87d4e2563b9a62d01dbc9ca7cb7903ec1681 | /app/src/main/java/edu/psu/ab/ist/sworks/pojo/Timer.java | 4b914318cba8084d5cdae34a678c696e6639651c | [] | no_license | joeoakes/Sworks | 59592feed40400e84b4f13faa7637cc1669b54a5 | 27bd359c3956221a48e2a150f63ef92d63fec213 | refs/heads/master | 2020-05-05T13:17:36.736879 | 2019-04-09T03:09:17 | 2019-04-09T03:09:17 | 180,070,682 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 705 | java | package edu.psu.ab.ist.sworks.pojo;
public class Timer {
private int _timer_duration;
private String _timer_string;
public Timer() {}
public Timer(int timer_duration) {
this._timer_duration = timer_duration;
}
public Timer(String timer_duration) {
this._timer_string = timer_duration;
}
public int getTimerDuration() {
return _timer_duration;
}
public void setTimerDuration(int timer_duration) {
this._timer_duration = timer_duration;
}
public String get_timer_string() {
return _timer_string;
}
public void set_timer_string(String timer_string) {
this._timer_string = timer_string;
}
}
| [
"joe.oakes@gmail.com"
] | joe.oakes@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.