blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
593d73ab3498f7d449a79e7879c27c6768b136c5
a3caa6439679d267550ae337f11ca2a1e6aae19a
/Shike/src/com/yshow/shike/fragments/Fragment_Student_GuanYu.java
517571aceb7963ad86240f01965289a6aa4b9a66
[]
no_license
Nodeer/shike_github
ebe349e7def93eeae413effc950635fc5bf04ecf
f463e423d0293435a57fbe027b909282be7dfe21
refs/heads/master
2020-05-20T12:58:12.621453
2014-11-21T14:40:48
2014-11-21T14:40:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,532
java
package com.yshow.shike.fragments; import java.util.ArrayList; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.widget.EditText; import com.yshow.shike.R; import com.yshow.shike.activities.FankuiActivity; import com.yshow.shike.activities.WebViewActivity; import com.yshow.shike.entity.LoginManage; import com.yshow.shike.entity.Soft_Info; import com.yshow.shike.utils.MyAsyncHttpResponseHandler; import com.yshow.shike.utils.SKAsyncApiController; import com.yshow.shike.utils.SKResolveJsonUtil; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; import android.widget.Toast; /** * 学生的关于师课 */ public class Fragment_Student_GuanYu extends Activity { private TextView tv_wenti_send; private EditText fankui; private String url; private TextView ev_premiere; private TextView ev_faq_huida; private Soft_Info softInfo; Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_student_guanyu); context = this; TextView titletext = (TextView) findViewById(R.id.title_text); titletext.setText("关于师课家教宝"); findViewById(R.id.gongneng_jieshao_btn).setOnClickListener(listener); findViewById(R.id.faq_btn).setOnClickListener(listener); findViewById(R.id.wenti_fankui_btn).setOnClickListener(listener); findViewById(R.id.left_btn).setOnClickListener(listener); PackageManager packageManager = getPackageManager(); // getPackageName()是你当前类的包名,0代表是获取版本信息 PackageInfo packInfo = null; try { packInfo = packageManager.getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } String localVersion = packInfo.versionName; TextView versiontext = (TextView) findViewById(R.id.ver_name); versiontext.setText("当前版本: V" + localVersion); Sofy_Info(); } private OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { Intent intent; switch (v.getId()) { case R.id.wenti_fankui_btn:// 发送意见反馈 intent = new Intent(context, FankuiActivity.class); startActivity(intent); break; case R.id.gongneng_jieshao_btn:// 功能介绍 intent = new Intent(context, WebViewActivity.class); String url3 = softInfo.introduceurl; url = SKAsyncApiController.SHIKE_VALUE_API_SERVER_URL + url3; intent.putExtra("url", url); intent.putExtra("title", "功能介绍"); startActivity(intent); break; case R.id.faq_btn:// 如何获得学分. intent = new Intent(context, WebViewActivity.class); String stuurl = SKAsyncApiController.SHIKE_VALUE_API_SERVER_URL + softInfo.FAQurl; intent.putExtra("url", stuurl); intent.putExtra("title", "FAQ问答"); startActivity(intent); break; // case R.id.tv_onclick_seek_all:// 底部的查看全部 // Intent teatentent = new Intent(context, WebActivity.class); // String teaurl = "http://www.shikeke.com/"; // teatentent.putExtra("url", teaurl); // startActivity(teatentent); // break; case R.id.left_btn: finish(); break; default: break; } } }; // 關於綜合信息 private void Sofy_Info() { SKAsyncApiController.Sof_Info(new MyAsyncHttpResponseHandler(context, true) { @Override public void onSuccess(String json) { super.onSuccess(json); boolean success = SKResolveJsonUtil.getInstance().resolveIsSuccess(json, context); if (success) { softInfo = SKResolveJsonUtil.getInstance().Soft_Info(json); } } }); } }
5c7d04009abc58bbb7e37d848eb0b62716e5af3f
359ccd1c4ce695e7f428062105d980b3fa66dfb9
/app/src/main/java/com/nguyenthanhtu/doanmobile/DetailFragment.java
12eba81017cbd9ec6df4207e2153cc7eed903e37
[]
no_license
TuNguyenThanh/QuanLyHangHoa
18d9bd2fb51d943f6c62ddaa0a875dc32feba614
5f35c9e4ca7bf8f9b002f93f8052014c7fb84e42
refs/heads/master
2021-01-11T00:02:55.827277
2016-12-07T01:04:17
2016-12-07T01:04:17
70,767,026
1
0
null
null
null
null
UTF-8
Java
false
false
11,827
java
package com.nguyenthanhtu.doanmobile; import android.content.ContentValues; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import com.nguyenthanhtu.Database; import com.nguyenthanhtu.model.Category; import com.nguyenthanhtu.model.Product; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.InputStream; /** * Created by thanhtu on 11/2/16. */ public class DetailFragment extends Fragment { final String DATABASE_NAME = "qlhh.sqlite"; final int RESQUEST_TAKE_PHOTO = 123; final int RESQUEST_CHOOSE_PHOTO = 321; ImageView imgProduct; TextView txtIdProduct; EditText edtName, edtPrice, edtVolumetric, edtProduction; Spinner spinnerEditCategory; Button btnEdit, btnDel; Product product; View fragment; private ArrayAdapter<Category> adapterCategory; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { fragment = inflater.inflate(R.layout.fragment_detail, container, true); addControls(); addEvents(); if (Data.listDataProduct.size() != 0){ getData((Product)Data.listDataProduct.get(0)); }else{ imgProduct.setImageResource(R.drawable.hinh); txtIdProduct.setText(""); edtPrice.setText(""); edtName.setText(""); edtVolumetric.setText(""); edtProduction.setText(""); } return fragment; } public void getData(Product pro) { if (pro != null) { product = pro; SQLiteDatabase database = Database.initDatabase(getActivity(),DATABASE_NAME); Cursor cursor = database.rawQuery("SELECT * FROM Product Where idProduct = ?",new String[] {product.getProductId() + ""}); cursor.moveToFirst(); String id = cursor.getString(0); String name = cursor.getString(1); byte[] image = cursor.getBlob(2); Double price = cursor.getDouble(3); Integer volumetric = cursor.getInt(4); String production = cursor.getString(5); String idCategory = cursor.getString(6); cursor.close(); Cursor cursor2 = database.rawQuery("SELECT * FROM Category Where idCategory = ?", new String[] {idCategory + ""}); cursor2.moveToFirst(); String idCategory2 = cursor2.getString(0); String nameCategory = cursor2.getString(1); Category category = new Category(idCategory2, nameCategory); cursor2.close(); //Bitmap image Bitmap bitmap = BitmapFactory.decodeByteArray(image,0,image.length); //Day len giao dien imgProduct.setImageBitmap(bitmap); txtIdProduct.setText(id); edtName.setText(name); edtPrice.setText(String.valueOf(price)); edtVolumetric.setText(String.valueOf(volumetric)); edtProduction.setText(production); spinnerEditCategory.setSelection(adapterCategory.getPosition(category)); } } private void editProduct(){ String id = product.getProductId(); String name = edtName.getText().toString(); Double price = Double.parseDouble(edtPrice.getText().toString()); Integer volumetric = Integer.parseInt(edtVolumetric.getText().toString()); String production = edtProduction.getText().toString(); Category category = (Category) spinnerEditCategory.getSelectedItem(); byte[] image = convertImageViewToByte(imgProduct); ContentValues contentValues = new ContentValues(); contentValues.put("idProduct",id); contentValues.put("name",name); contentValues.put("image",image); contentValues.put("price",price); contentValues.put("volumetric",volumetric); contentValues.put("production",production); contentValues.put("idCategory",category.getCategoryId()); SQLiteDatabase database = Database.initDatabase(getActivity(), DATABASE_NAME); database.update("Product",contentValues,"idProduct = ?",new String[] {id + ""} ); Product productEdit = new Product(id,name,image,category,price,volumetric,production); ListviewFragment listviewFragment = (ListviewFragment) getFragmentManager().findFragmentById(R.id.frgListView); listviewFragment.editProduct(productEdit); } private void addEvents() { btnEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setIcon(android.R.drawable.ic_menu_edit); alert.setTitle(getActivity().getText(R.string.simple_editTitle)); alert.setMessage(getActivity().getText(R.string.simple_editMessage)); alert.setPositiveButton(getActivity().getText(R.string.simple_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { editProduct(); } }); alert.setNegativeButton(getActivity().getText(R.string.simple_no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog dialog = alert.create(); dialog.show(); } }); btnDel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setIcon(android.R.drawable.ic_delete); alert.setTitle(getActivity().getText(R.string.simple_removeTitle)); alert.setMessage(getActivity().getText(R.string.simple_removeMessage)); alert.setPositiveButton(getActivity().getText(R.string.simple_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteProduct(product.getProductId()); } }); alert.setNegativeButton(getActivity().getText(R.string.simple_no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog dialog = alert.create(); dialog.show(); } }); imgProduct.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CharSequence image[] = new CharSequence[] {getActivity().getText(R.string.simple_photo), getActivity().getText(R.string.simple_camera)}; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getActivity().getText(R.string.simple_chooseImage)); builder.setItems(image, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0){ choosePhoto(); }else if (which == 1){ takePicture(); } } }); builder.show(); } }); } private void addControls() { imgProduct = (ImageView) fragment.findViewById(R.id.imgEditProductFM); txtIdProduct = (TextView) fragment.findViewById(R.id.txtEditIdFM); edtPrice = (EditText) fragment.findViewById(R.id.edtEditPriceFM); edtName = (EditText) fragment.findViewById(R.id.edtEditNameFM); edtVolumetric = (EditText) fragment.findViewById(R.id.edtEditVolumetricFM); edtProduction = (EditText) fragment.findViewById(R.id.edtEditProductionFM); spinnerEditCategory = (Spinner) fragment.findViewById(R.id.spinnerEditCategoryFM); btnDel = (Button) fragment.findViewById(R.id.btnDelFM); btnEdit = (Button) fragment.findViewById(R.id.btnEditFM); adapterCategory = new ArrayAdapter<Category>(getActivity(), android.R.layout.simple_list_item_1, Data.listDataCategory); adapterCategory.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerEditCategory.setAdapter(adapterCategory); } private void deleteProduct(String idProduct) { SQLiteDatabase database = Database.initDatabase(getActivity(),DATABASE_NAME); database.delete("Product","idProduct = ?", new String[] {idProduct + ""}); ListviewFragment listviewFragment = (ListviewFragment) getFragmentManager().findFragmentById(R.id.frgListView); listviewFragment.delProduct(idProduct); imgProduct.setImageResource(R.drawable.hinh); txtIdProduct.setText(""); edtPrice.setText(""); edtName.setText(""); edtVolumetric.setText(""); edtProduction.setText(""); } public byte[] convertImageViewToByte(ImageView img){ BitmapDrawable drawable = (BitmapDrawable) img.getDrawable(); Bitmap bitmap = drawable.getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG,100,stream); byte[] bytes = stream.toByteArray(); return bytes; } private void takePicture(){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, RESQUEST_TAKE_PHOTO); } private void choosePhoto(){ Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, RESQUEST_CHOOSE_PHOTO); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == getActivity().RESULT_OK){ if (requestCode == RESQUEST_CHOOSE_PHOTO){ try { Uri imageUri = data.getData(); InputStream inputStream = getActivity().getContentResolver().openInputStream(imageUri); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); imgProduct.setImageBitmap(bitmap); } catch (FileNotFoundException e) { e.printStackTrace(); } }else if(requestCode == RESQUEST_TAKE_PHOTO) { Bitmap bitmap = (Bitmap) data.getExtras().get("data"); imgProduct.setImageBitmap(bitmap); } } } }
62ea308c7cfb7d014fecd1d51b88ca21777552a8
4c2ea676a253e0f98214c9701e78bd2fc0e49409
/src/auditoryTaskPackage/PracticeTrialStartWarningPanel.java
c554d4bf846db382e546738550b825c4e99efeae
[]
no_license
vbabushkin/auditoryTaskDistributions_v11
4ddc4aa591a0d35cbe1350e54c8acafb1edde898
847b2ea93de7a0fb4a56e2a861f5b2dccfb31374
refs/heads/master
2020-10-01T00:26:31.964343
2019-12-11T16:23:21
2019-12-11T16:23:21
227,409,603
1
0
null
null
null
null
UTF-8
Java
false
false
2,450
java
package auditoryTaskPackage; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.Font; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Point; import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; public class PracticeTrialStartWarningPanel extends JPanel{ static double cummulativeScorePerTrial =0; static boolean invoke = true; public PracticeTrialStartWarningPanel(){ setLayout(new BorderLayout()); JPanel tempGridPanel = new JPanel(new GridLayout(2,1,5,5)); tempGridPanel.setSize(Main.screenWidth, Main.screenHeight/2); JPanel FixedPanel = new JPanel(new GridBagLayout()); FixedPanel.setPreferredSize(this.getSize()); //hide mouse cursor Toolkit toolkit = Toolkit.getDefaultToolkit(); Point hotSpot = new Point(0,0); BufferedImage cursorImage = new BufferedImage(1, 1, BufferedImage.TRANSLUCENT); Cursor invisibleCursor = toolkit.createCustomCursor(cursorImage, hotSpot, "InvisibleCursor"); setCursor(invisibleCursor); String message = ""; message =String.format("<html><center>The next trial will start shortly.</center></html>"); // if(AdvancedOptionsWindow.isProbeTaskTimed) // if(!RunExperimentWindow.timedPracticeTrialsAreRunning)//currentPracticeTrial<=(AdvancedOptionsWindow.numOfDemoTrialsNotTimed)) // message =String.format("<html><center>The next trial will start shortly.</center></html>"); // else // message =String.format("<html><center>The next trial will start shortly.<br>For each guess you will have 20 seconds to submit your responce.</center></html>"); // else // message =String.format("<html><center>The next trial will start shortly.</center></html>"); // JLabel downLbl = new JLabel(message); //set fore ground color to the label downLbl.setForeground(Color.BLACK); //set font to the label downLbl.setFont(new Font(RunExperimentWindow.fontFamily, Font.BOLD | Font.ITALIC, (int)0.8*RunExperimentWindow.fontSize)); //set bounds of the label downLbl.setBounds(10, 200, 200, 32); downLbl.setHorizontalAlignment(SwingConstants.CENTER); //add label to the contentPane tempGridPanel.add(downLbl,BorderLayout.PAGE_END); FixedPanel.add(tempGridPanel); add(FixedPanel,BorderLayout.CENTER); } }
a598f074f95967d6145fa404e4411879ca8cdbea
4cd2f6895f2053d27b6fc03c189e97557a22ec18
/src/main/java/af/asr/coap/shell/infrastructure/util/PrintUtils.java
8937541b75607c0a74862f2bb55a7191e59630fc
[]
no_license
asr-registry/CoAP
4b4c8d3cc922f7041709eea55157ec919fb7ee08
0055056c86481238c7e4964238d186a29c740d9b
refs/heads/master
2022-08-31T03:06:30.543522
2019-12-28T11:55:27
2019-12-28T11:55:27
230,596,707
0
0
null
null
null
null
UTF-8
Java
false
false
5,563
java
package af.asr.coap.shell.infrastructure.util; import java.io.IOException; import java.io.StringWriter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.californium.core.CoapResponse; import org.eclipse.californium.core.coap.MediaTypeRegistry; import org.eclipse.californium.core.coap.Response; import org.eclipse.californium.elements.util.StringUtil; import org.w3c.dom.Document; import org.springframework.boot.ansi.AnsiColor; import org.springframework.boot.ansi.AnsiOutput; import org.springframework.http.HttpStatus; import org.springframework.util.MimeTypeUtils; import org.springframework.util.StringUtils; public class PrintUtils { /** * Formats a {@link Response} into a readable String representation. * * @param coapResponse * @return the pretty print */ public static String prettyPrint(CoapResponse coapResponse, String header) { if (coapResponse == null) { return red("NULL response!"); } Response r = coapResponse.advanced(); int httpStatusCode = Integer.valueOf(r.getCode().codeClass) * 100 + Integer.valueOf(r.getCode().codeDetail); HttpStatus httpStatus = HttpStatus.resolve(httpStatusCode); String status = colorText(String.format("%s-%s", httpStatusCode, httpStatus.getReasonPhrase()), httpStatus.isError() ? AnsiColor.RED : AnsiColor.CYAN); String rtt = (r.getRTT() != null) ? "" + r.getRTT() : ""; StringBuilder sb = new StringBuilder(); sb.append(green("----------------------------------- Response -----------------------------------")).append(StringUtil.lineSeparator()); if (StringUtils.hasText(header)) { sb.append(header).append(StringUtil.lineSeparator()); } sb.append(String.format("MID: %d, Type: %s, Token: %s, RTT: %sms", r.getMID(), cyan(r.getType().toString()), r.getTokenString(), rtt)).append(StringUtil.lineSeparator()); sb.append(String.format("Options: %s", r.getOptions().toString())).append(StringUtil.lineSeparator()); sb.append(String.format("Status : %s, Payload: %dB", status, r.getPayloadSize())).append(StringUtil.lineSeparator()); sb.append(green("................................... Payload ....................................")).append(StringUtil.lineSeparator()); if (r.getPayloadSize() > 0 && MediaTypeRegistry.isPrintable(r.getOptions().getContentFormat())) { sb.append(prettyPayload(r)).append(StringUtil.lineSeparator()); } sb.append(green("--------------------------------------------------------------------------------")); return sb.toString(); } public static String prettyPayload(Response r) { if (r.getOptions().toString().contains(MimeTypeUtils.APPLICATION_JSON_VALUE)) { return cyan(prettyJson(r.getPayloadString())); } else if (r.getOptions().toString().contains(MimeTypeUtils.APPLICATION_XML_VALUE)) { return cyan(prettyXml(r.getPayloadString())); } else if (r.getOptions().toString().contains("application/link-format")) { return cyan(prettyLink(r.getPayloadString())); } return r.getPayloadString(); } private static String prettyJson(String text) { try { ObjectMapper mapper = new ObjectMapper(); Object jsonObject = mapper.readValue(text, Object.class); return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject); } catch (IOException io) { return text; } } private static String prettyLink(String text) { try { StringBuffer sb = new StringBuffer(); for (String link : text.split(",")) { sb.append(link).append(StringUtil.lineSeparator()); } return sb.toString(); } catch (Exception io) { return text; } } private static String prettyXml(String text) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(text); Transformer tform = TransformerFactory.newInstance().newTransformer(); tform.setOutputProperty(OutputKeys.INDENT, "yes"); tform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); StringWriter sw = new StringWriter(); tform.transform(new DOMSource(document), new StreamResult(sw)); return sw.toString(); } catch (Exception e) { return text; } } public static String cyan(String text) { return colorText(text, AnsiColor.CYAN); } public static String red(String text) { return colorText(text, AnsiColor.RED); } public static String green(String text) { return colorText(text, AnsiColor.GREEN); } public static String normal(String text) { return colorText(text, AnsiColor.DEFAULT); } public static String colorText(String text, AnsiColor color) { return AnsiOutput.toString(color, text, AnsiColor.DEFAULT); } }
0830dfe21f0ade9b6584e9248732e988b5c79637
0284d2bd732953a414f9833ccec4243d476d4a58
/project_workspace/arapSurfaceModeling/src/display/ArcBall.java
ab8440667e30cef6086f3614e36e1ee527448def
[ "MIT" ]
permissive
AlexandreBinninger/arap-surface-modeling
bf6a0c16660c9c4976f9d385eab50b48c4ecdf13
dafbe2b2658f2f72487236be12fcbb5b91757da1
refs/heads/master
2021-10-08T20:20:33.362855
2018-12-17T12:07:34
2018-12-17T12:07:34
158,407,274
0
2
null
null
null
null
UTF-8
Java
false
false
5,354
java
package display; /* Adapted into Processing library 5th Feb 2006 Tom Carden from "simple arcball use template" 9.16.03 Simon Greenwold Copyright (c) 2003 Simon Greenwold Copyright (c) 2006 Tom Carden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import processing.core.PApplet; import java.awt.event.MouseEvent; public class ArcBall { PApplet parent; float center_x, center_y, center_z, radius; Vec3 v_down, v_drag; Quat q_now, q_down, q_drag; Vec3[] axisSet; int axis; /** defaults to radius of min(width/2,height/2) and center_z of -radius */ public ArcBall(PApplet parent) { this(parent.g.width / 2.0f, parent.g.height / 2.0f, -PApplet.min( parent.g.width / 2.0f, parent.g.height / 2.0f), PApplet.min( parent.g.width / 2.0f, parent.g.height / 2.0f), parent); } public ArcBall(float center_x, float center_y, float center_z, float radius, PApplet parent) { this.parent = parent; parent.registerMouseEvent(this); parent.registerPre(this); this.center_x = center_x; this.center_y = center_y; this.center_z = center_z; this.radius = radius; v_down = new Vec3(); v_drag = new Vec3(); q_now = new Quat(); q_down = new Quat(); q_drag = new Quat(); axisSet = new Vec3[] { new Vec3(1.0f, 0.0f, 0.0f), new Vec3(0.0f, 1.0f, 0.0f), new Vec3(0.0f, 0.0f, 1.0f) }; axis = -1; // no constraints... } public void mouseEvent(MouseEvent event) { int id = event.getID(); if (id == MouseEvent.MOUSE_DRAGGED) { mouseDragged(); } else if (id == MouseEvent.MOUSE_PRESSED) { mousePressed(); } } public void mousePressed() { v_down = mouse_to_sphere(parent.mouseX, parent.mouseY); q_down.set(q_now); q_drag.reset(); } public void mouseDragged() { v_drag = mouse_to_sphere(parent.mouseX, parent.mouseY); q_drag.set(Vec3.dot(v_down, v_drag), Vec3.cross(v_down, v_drag)); } public void pre() { parent.translate(center_x, center_y, center_z); q_now = Quat.mul(q_drag, q_down); applyQuat2Matrix(q_now); parent.translate(-center_x, -center_y, -center_z); } Vec3 mouse_to_sphere(float x, float y) { Vec3 v = new Vec3(); v.x = (x - center_x) / radius; v.y = (y - center_y) / radius; float mag = v.x * v.x + v.y * v.y; if (mag > 1.0f) { v.normalize(); } else { v.z = PApplet.sqrt(1.0f - mag); } return (axis == -1) ? v : constrain_vector(v, axisSet[axis]); } Vec3 constrain_vector(Vec3 vector, Vec3 axis) { Vec3 res = new Vec3(); res.sub(vector, Vec3.mul(axis, Vec3.dot(axis, vector))); res.normalize(); return res; } void applyQuat2Matrix(Quat q) { // instead of transforming q into a matrix and applying it... float[] aa = q.getValue(); parent.rotate(aa[0], aa[1], aa[2], aa[3]); } static class Vec3 { float x, y, z; Vec3() { } Vec3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } void normalize() { float length = length(); x /= length; y /= length; z /= length; } float length() { return PApplet.mag(x, y, z); } static Vec3 cross(Vec3 v1, Vec3 v2) { Vec3 res = new Vec3(); res.x = v1.y * v2.z - v1.z * v2.y; res.y = v1.z * v2.x - v1.x * v2.z; res.z = v1.x * v2.y - v1.y * v2.x; return res; } static float dot(Vec3 v1, Vec3 v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } static Vec3 mul(Vec3 v, float d) { Vec3 res = new Vec3(); res.x = v.x * d; res.y = v.y * d; res.z = v.z * d; return res; } void sub(Vec3 v1, Vec3 v2) { x = v1.x - v2.x; y = v1.y - v2.y; z = v1.z - v2.z; } } // Vec3 static class Quat { float w, x, y, z; Quat() { reset(); } Quat(float w, float x, float y, float z) { this.w = w; this.x = x; this.y = y; this.z = z; } void reset() { w = 1.0f; x = 0.0f; y = 0.0f; z = 0.0f; } void set(float w, Vec3 v) { this.w = w; x = v.x; y = v.y; z = v.z; } void set(Quat q) { w = q.w; x = q.x; y = q.y; z = q.z; } static Quat mul(Quat q1, Quat q2) { Quat res = new Quat(); res.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z; res.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y; res.y = q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z; res.z = q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x; return res; } float[] getValue() { // transforming this quat into an angle and an axis vector... float[] res = new float[4]; float sa = (float) Math.sqrt(1.0f - w * w); if (sa < PApplet.EPSILON) { sa = 1.0f; } res[0] = (float) Math.acos(w) * 2.0f; res[1] = x / sa; res[2] = y / sa; res[3] = z / sa; return res; } } // Quat }
700c8c3c1d737a0c8de6be6deabca92d32c106d2
266fd9d819c892908c3bfa35b76cfbabadbc0299
/app/src/main/java/com/self/viewtoglrendering/cuberenerer/CubeGLRenderer.java
70d0f0c7c556c83898c81e80f9a22317ac00a439
[]
no_license
jiayuliang1314/AndroidViewDrawOnOpenglES2Texture
60de344d7fbabfb65161df3de604b6c55e909e9d
86bb059fe03bc8e229cd599b2a04da0e6a936551
refs/heads/master
2022-04-14T11:33:44.915154
2020-04-20T13:24:08
2020-04-20T13:24:08
257,288,117
1
0
null
null
null
null
UTF-8
Java
false
false
23,169
java
package com.self.viewtoglrendering.cuberenerer; import android.content.Context; import android.opengl.GLES11Ext; import android.opengl.GLES20; import android.opengl.Matrix; import android.os.SystemClock; import com.self.viewtoglrendering.R; import com.self.viewtoglrendering.ViewToGLRenderer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; /** * Created by user on 3/15/15. */ public class CubeGLRenderer extends ViewToGLRenderer { /** * Store the model matrix. This matrix is used to move models from object space (where each model can be thought * of being located at the center of the universe) to world space. */ private float[] mModelMatrix = new float[16]; /** * Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space; * it positions things relative to our eye. */ private float[] mViewMatrix = new float[16]; /** Store the projection matrix. This is used to project the scene onto a 2D viewport. */ private float[] mProjectionMatrix = new float[16]; /** Allocate storage for the final combined matrix. This will be passed into the shader program. */ private float[] mMVPMatrix = new float[16]; /** * Stores a copy of the model matrix specifically for the light position. */ private float[] mLightModelMatrix = new float[16]; /** Store our model data in a float buffer. */ private final FloatBuffer mCubePositions; private final FloatBuffer mCubeColors; private final FloatBuffer mCubeNormals; private final FloatBuffer mCubeTextureCoordinates; /** This will be used to pass in the transformation matrix. */ private int mMVPMatrixHandle; /** This will be used to pass in the modelview matrix. */ private int mMVMatrixHandle; /** This will be used to pass in the light position. */ private int mLightPosHandle; /** This will be used to pass in the texture. */ private int mTextureUniformHandle; /** This will be used to pass in model position information. */ private int mPositionHandle; /** This will be used to pass in model color information. */ private int mColorHandle; /** This will be used to pass in model normal information. */ private int mNormalHandle; /** This will be used to pass in model texture coordinate information. */ private int mTextureCoordinateHandle; /** How many bytes per float. */ private final int mBytesPerFloat = 4; /** Size of the position data in elements. */ private final int mPositionDataSize = 3; /** Size of the color data in elements. */ private final int mColorDataSize = 4; /** Size of the normal data in elements. */ private final int mNormalDataSize = 3; /** Size of the texture coordinate data in elements. */ private final int mTextureCoordinateDataSize = 2; /** Used to hold a light centered on the origin in model space. We need a 4th coordinate so we can get translations to work when * we multiply this by our transformation matrices. */ private final float[] mLightPosInModelSpace = new float[] {0.0f, 0.0f, 0.0f, 1.0f}; /** Used to hold the current position of the light in world space (after transformation via model matrix). */ private final float[] mLightPosInWorldSpace = new float[4]; /** Used to hold the transformed position of the light in eye space (after transformation via modelview matrix) */ private final float[] mLightPosInEyeSpace = new float[4]; /** This is a handle to our cube shading program. */ private int mProgramHandle; /** This is a handle to our light point program. */ private int mPointProgramHandle; /** This is a handle to our texture data. */ // private int mTextureDataHandle; private Context mContext; public CubeGLRenderer(Context context) { mContext = context; final float[] cubePositionData = { // In OpenGL counter-clockwise winding is default. This means that when we look at a triangle, // if the points are counter-clockwise we are looking at the "front". If not we are looking at // the back. OpenGL has an optimization where all back-facing triangles are culled, since they // usually represent the backside of an object and aren't visible anyways. // Front face -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, // Right face 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, // Back face 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, // Left face -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, // Top face -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, // Bottom face 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, }; // R, G, B, A final float[] cubeColorData = { // Front face (red) 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Right face (green) 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, // Back face (blue) 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Left face (yellow) 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, // Top face (cyan) 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, // Bottom face (magenta) 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }; // X, Y, Z // The normal is used in light calculations and is a vector which points // orthogonal to the plane of the mSurface. For a cube model, the normals // should be orthogonal to the points of each face. final float[] cubeNormalData = { // Front face 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Right face 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // Back face 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, // Left face -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, // Top face 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // Bottom face 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f }; // S, T (or X, Y) // Texture coordinate data. // Because images have a Y axis pointing downward (values increase as you move down the image) while // OpenGL has a Y axis pointing upward, we adjust for that here by flipping the Y axis. // What's more is that the texture coordinates are the same for every face. final float[] cubeTextureCoordinateData = { // Front face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Right face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Back face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Left face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Top face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Bottom face 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f }; // Initialize the buffers. mCubePositions = ByteBuffer.allocateDirect(cubePositionData.length * mBytesPerFloat) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mCubePositions.put(cubePositionData).position(0); mCubeColors = ByteBuffer.allocateDirect(cubeColorData.length * mBytesPerFloat) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mCubeColors.put(cubeColorData).position(0); mCubeNormals = ByteBuffer.allocateDirect(cubeNormalData.length * mBytesPerFloat) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mCubeNormals.put(cubeNormalData).position(0); mCubeTextureCoordinates = ByteBuffer.allocateDirect(cubeTextureCoordinateData.length * mBytesPerFloat) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mCubeTextureCoordinates.put(cubeTextureCoordinateData).position(0); } protected String getVertexShader() { return RawResourceReader.readTextFileFromRawResource(mContext, R.raw.per_pixel_vertex_shader); } protected String getFragmentShader() { return RawResourceReader.readTextFileFromRawResource(mContext, R.raw.per_pixel_fragment_shader); } @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { super.onSurfaceCreated(gl, config); // Set the background clear color to black. GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Use culling to remove back faces. GLES20.glEnable(GLES20.GL_CULL_FACE); // Enable depth testing GLES20.glEnable(GLES20.GL_DEPTH_TEST); // The below glEnable() call is a holdover from OpenGL ES 1, and is not needed in OpenGL ES 2. // Enable texture mapping // GLES20.glEnable(GLES20.GL_TEXTURE_2D); // Position the eye in front of the origin. final float eyeX = 0.0f; final float eyeY = 0.0f; final float eyeZ = -0.5f; // We are looking toward the distance final float lookX = 0.0f; final float lookY = 0.0f; final float lookZ = -5.0f; // Set our up vector. This is where our head would be pointing were we holding the camera. final float upX = 0.0f; final float upY = 1.0f; final float upZ = 0.0f; // Set the view matrix. This matrix can be said to represent the camera position. // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose. Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ); final String vertexShader = getVertexShader(); final String fragmentShader = getFragmentShader(); final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader); final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader); mProgramHandle = ShaderHelper.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, new String[] {"a_Position", "a_Color", "a_Normal", "a_TexCoordinate"}); // Define a simple shader program for our point. final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mContext, R.raw.point_vertex_shader); final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mContext, R.raw.point_fragment_shader); final int pointVertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader); final int pointFragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader); mPointProgramHandle = ShaderHelper.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle, new String[] {"a_Position"}); } @Override public void onSurfaceChanged(GL10 gl, int width, int height) { super.onSurfaceChanged(gl, width, height); GLES20.glViewport(0, 0, width, height); // Create a new perspective projection matrix. The height will stay the same // while the width will vary as per aspect ratio. final float ratio = (float) width / height; final float left = -ratio; final float right = ratio; final float bottom = -1.0f; final float top = 1.0f; final float near = 1.0f; final float far = 10.0f; Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far); } @Override public void onDrawFrame(GL10 gl) { super.onDrawFrame(gl); // GL Draw code onwards GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); // Do a complete rotation every 10 seconds. long time = SystemClock.uptimeMillis() % 10000L; float angleInDegrees = (360.0f / 10000.0f) * ((int) time); // Set our per-vertex lighting program. GLES20.glUseProgram(mProgramHandle); // Set program handles for cube drawing. mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVPMatrix"); mMVMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVMatrix"); mLightPosHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_LightPos"); mTextureUniformHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Texture"); mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Position"); mColorHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Color"); mNormalHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Normal"); mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate"); GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, getGLSurfaceTexture()); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glUniform1i(mTextureUniformHandle, 0); // GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0); // GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, glSurfaceTex); // GLES20.glActiveTexture(GLES20.GL_TEXTURE0); // // Set the active texture unit to texture unit 0. // GLES20.glActiveTexture(GLES20.GL_TEXTURE0); // // // Bind the texture to this unit. // GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, glSurfaceTex); // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0. // GLES20.glUniform1i(mTextureUniformHandle, 0); // Calculate position of the light. Rotate and then push into the distance. Matrix.setIdentityM(mLightModelMatrix, 0); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -4.0f); Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f); Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0); Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0); Matrix.setIdentityM(mModelMatrix, 0); Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -3.3f); Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 0.0f); drawCube(); // Draw a point to indicate the light. GLES20.glUseProgram(mPointProgramHandle); drawLight(); } /** * Draws a cube. */ private void drawCube() { // Pass in the position information mCubePositions.position(0); GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false, 0, mCubePositions); GLES20.glEnableVertexAttribArray(mPositionHandle); // Pass in the color information mCubeColors.position(0); GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false, 0, mCubeColors); GLES20.glEnableVertexAttribArray(mColorHandle); // Pass in the normal information mCubeNormals.position(0); GLES20.glVertexAttribPointer(mNormalHandle, mNormalDataSize, GLES20.GL_FLOAT, false, 0, mCubeNormals); GLES20.glEnableVertexAttribArray(mNormalHandle); // Pass in the texture coordinate information mCubeTextureCoordinates.position(0); GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 0, mCubeTextureCoordinates); GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle); // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix // (which currently contains model * view). Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); // Pass in the modelview matrix. GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0); // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix // (which now contains model * view * projection). Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); // Pass in the combined matrix. GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0); // Pass in the light position in eye space. GLES20.glUniform3f(mLightPosHandle, mLightPosInEyeSpace[0], mLightPosInEyeSpace[1], mLightPosInEyeSpace[2]); // Draw the cube. GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36); } private void drawLight() { final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix"); final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position"); // Pass in the position. GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]); // Since we are not using a buffer object, disable vertex arrays for this attribute. GLES20.glDisableVertexAttribArray(pointPositionHandle); // Pass in the transformation matrix. Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0); // Draw the point. GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1); } }
c415933e4cea31e9bf7267bdc4ab61d62eed3ee3
e790b6e1e48f9b20cb7e697806eaa021cc57584f
/LibrarySystem-ejb/src/java/library_system/LibrarySessionRemote.java
da04802db9c7a4d5ed0fe69c60c603d1859365ef
[]
no_license
timarkh1669/LibrarySystem
fb229e5a15e84eaf2db6a7e82ac99e15225e258b
66a28c3673390a612317825dcbf8e600aa9b29a8
refs/heads/master
2021-01-19T14:22:12.178096
2017-04-16T19:33:51
2017-04-16T19:33:51
88,152,871
0
0
null
null
null
null
UTF-8
Java
false
false
907
java
package library_system; import javax.ejb.Remote; import java.util.List; @Remote public interface LibrarySessionRemote { int getUserID(String username); int findBookCount(String author, String title); List<Books> findBooks(String author, String title); List<Books> findBooksFullMatch(String author, String title); Libraryuser findUserByName(String name); int registerReader(String name, String password); Libraryuser findUserByID(int id); boolean loginReader(String name, String password); int orderBook(String username, int bookID); List<Orders> findOrderedBooks(String username); String findAuthorByOrderID(int orderID); String findTitleByOrderID(int orderID); boolean returnBook(int orderID); String findLibraryAddressByID(int libraryId); String findLibraryAddressByOrderID(int orderID); }
514e53a3787e901c098302bf204a4ee55cf39cb5
b739e49b75676483a3e0a1715a97f9a2dc4d24da
/Ghetto/src/java/Controlador/Servlets/RegistrarInvM.java
67f7de14f632291556450e19caa76104ac1dc33a
[]
no_license
monojuanda/Ghetto
5d8c0666a8d550a7ececa89dd579bed2ab59ca2e
2bee9643cf554341dc492db5add7e8504fb1033f
refs/heads/master
2020-04-22T14:18:54.419363
2019-02-13T05:06:08
2019-02-13T05:06:08
170,439,491
0
0
null
null
null
null
UTF-8
Java
false
false
3,713
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 Controlador.Servlets; import Controlador.conexion.Conectadb; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author Tamayo B */ public class RegistrarInvM extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String it = request.getParameter("item"); String cate = request.getParameter("cate"); String col = request.getParameter("color"); String gene = request.getParameter("genero"); String desc = request.getParameter("descripcion"); String pre = request.getParameter("precio"); String colec = request.getParameter("coleccion"); String cant = request.getParameter("cantidad"); try{ Conectadb con = new Conectadb(); Connection c = con.conectar(); Statement stm = c.createStatement(); String query = "insert into Invmujer (item, categoria, color, genero, descripcion, precio, coleccion, cantidad) values ('"+it+"','"+cate+"','"+col+"','"+gene+"','"+desc+"','"+pre+"','"+colec+"','"+cant+"');"; stm.executeUpdate(query); System.out.println(query); stm.close(); c.close(); System.out.println("Insertó"); }catch(SQLException e){ e.printStackTrace(); } response.sendRedirect("ListarInventarioM"); } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }
ff8b30b72838457134c8e28b254fd99ffd7d347f
e427094668b85dd4af106e53e6e99d5b1efed329
/project-1/src/main/java/com/revature/dao/StatusDAO.java
2123981cc758c0564ef288896968284f6e817b17
[]
no_license
jeremycritchley/ReimbursementPortal
f7f26ab7c74e02d70df9c658d5b371dc7f130508
d725e3fa0b2637955ee64029352b4c008a3865c6
refs/heads/main
2023-02-06T13:10:41.531205
2020-12-23T03:35:52
2020-12-23T03:35:52
320,059,732
0
0
null
null
null
null
UTF-8
Java
false
false
456
java
package com.revature.dao; import org.hibernate.Session; import com.revature.models.ReimStatus; import com.revature.utils.HibernateUtil; public class StatusDAO { /** * Necessary for Hibernate * * @param id - ID of Reimbursement Status * @return - Persistent Hibernate Role */ public static final ReimStatus selectById(int id) { Session ses = HibernateUtil.getSession(); ReimStatus rs = ses.get(ReimStatus.class, id); return rs; } }
12d87231fdae33080f06d30a91a3740e2c5cf7f7
9d3d534c4e77cad1aa85963f1eef71c18d297080
/config-client/src/test/java/com/gzport/ConfigClientApplicationTests.java
4e5b3a275bb8d3bcdbf7dadf5a6ee884984b6287
[ "Apache-2.0" ]
permissive
jinn520/spring-cloud-config
a7701b1a1dd0d1414d20da175abe8a55895cc1bf
7fb559718d5d24a94d02fcc7897f8c17ea8feaa5
refs/heads/master
2020-07-26T17:54:17.267246
2019-09-16T06:55:54
2019-09-16T06:55:54
208,723,008
0
0
null
null
null
null
UTF-8
Java
false
false
333
java
package com.gzport; 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 ConfigClientApplicationTests { @Test public void contextLoads() { } }
2ed7dfd60eca9a38104e7557fea3dac0ea39f2bb
2fd9d77d529e9b90fd077d0aa5ed2889525129e3
/DecompiledViberSrc/app/src/main/java/com/google/e/f/h.java
35e034e1b71ae1e2d8dd791b101381c7c0d88332
[]
no_license
cga2351/code
703f5d49dc3be45eafc4521e931f8d9d270e8a92
4e35fb567d359c252c2feca1e21b3a2a386f2bdb
refs/heads/master
2021-07-08T15:11:06.299852
2021-05-06T13:22:21
2021-05-06T13:22:21
60,314,071
1
3
null
null
null
null
UTF-8
Java
false
false
5,566
java
package com.google.e.f; import com.google.e.e; import com.google.e.g; import com.google.e.j; import com.google.e.n; import com.google.e.p; import java.util.Map; public final class h extends k { static final int[][] a = { { 1, 1, 3, 3, 1 }, { 3, 1, 1, 1, 3 }, { 1, 3, 1, 1, 3 }, { 3, 3, 1, 1, 1 }, { 1, 1, 3, 1, 3 }, { 3, 1, 3, 1, 1 }, { 1, 3, 3, 1, 1 }, { 1, 1, 1, 3, 3 }, { 3, 1, 1, 3, 1 }, { 1, 3, 1, 3, 1 } }; private static final int[] b = { 6, 8, 10, 12, 14 }; private static final int[] d = { 1, 1, 1, 1 }; private static final int[] e = { 1, 1, 3 }; private int c = -1; private static int a(int[] paramArrayOfInt) throws j { float f1 = 0.38F; int i = -1; int j = a.length; int k = 0; float f2; if (k < j) { f2 = a(paramArrayOfInt, a[k], 0.78F); if (f2 >= f1) break label62; i = k; } while (true) { k++; f1 = f2; break; if (i >= 0) return i; throw j.a(); label62: f2 = f1; } } private void a(com.google.e.c.a parama, int paramInt) throws j { int i = 10 * this.c; int j; int k; if (i < paramInt) { j = paramInt - 1; k = i; } for (int m = j; ; m--) { if ((k <= 0) || (m < 0) || (parama.a(m))) { if (k == 0) return; throw j.a(); i = paramInt; break; } k--; } } private static void a(com.google.e.c.a parama, int paramInt1, int paramInt2, StringBuilder paramStringBuilder) throws j { int[] arrayOfInt1 = new int[10]; int[] arrayOfInt2 = new int[5]; int[] arrayOfInt3 = new int[5]; int m; for (int i = paramInt1; i < paramInt2; i = m) { a(parama, i, arrayOfInt1); for (int j = 0; j < 5; j++) { int i1 = j * 2; arrayOfInt2[j] = arrayOfInt1[i1]; arrayOfInt3[j] = arrayOfInt1[(i1 + 1)]; } paramStringBuilder.append((char)(48 + a(arrayOfInt2))); paramStringBuilder.append((char)(48 + a(arrayOfInt3))); int k = arrayOfInt1.length; m = i; for (int n = 0; n < k; n++) m += arrayOfInt1[n]; } } private static int c(com.google.e.c.a parama) throws j { int i = parama.a(); int j = parama.c(0); if (j == i) throw j.a(); return j; } private static int[] c(com.google.e.c.a parama, int paramInt, int[] paramArrayOfInt) throws j { int i = paramArrayOfInt.length; int[] arrayOfInt = new int[i]; int j = parama.a(); int k = paramInt; int m = 0; int n = 0; if (paramInt < j) { if ((n ^ parama.a(paramInt)) != 0) arrayOfInt[m] = (1 + arrayOfInt[m]); while (true) { paramInt++; break; if (m == i - 1) { if (a(arrayOfInt, paramArrayOfInt, 0.78F) < 0.38F) return new int[] { k, paramInt }; k += arrayOfInt[0] + arrayOfInt[1]; System.arraycopy(arrayOfInt, 2, arrayOfInt, 0, i - 2); arrayOfInt[(i - 2)] = 0; arrayOfInt[(i - 1)] = 0; m--; } while (true) { arrayOfInt[m] = 1; if (n != 0) break label159; n = 1; break; m++; } label159: n = 0; } } throw j.a(); } public n a(int paramInt, com.google.e.c.a parama, Map<e, ?> paramMap) throws g, j { int[] arrayOfInt1 = a(parama); int[] arrayOfInt2 = b(parama); StringBuilder localStringBuilder = new StringBuilder(20); a(parama, arrayOfInt1[1], arrayOfInt2[0], localStringBuilder); String str = localStringBuilder.toString(); if (paramMap != null); for (int[] arrayOfInt3 = (int[])paramMap.get(e.f); ; arrayOfInt3 = null) { if (arrayOfInt3 == null) arrayOfInt3 = b; int i = str.length(); int j = arrayOfInt3.length; int k = 0; int m = 0; int i1; if (k < j) { i1 = arrayOfInt3[k]; if (i != i1); } for (int n = 1; ; n = 0) { if ((n == 0) && (i > m)) n = 1; if (n == 0) { throw g.a(); if (i1 <= m) break label218; } while (true) { k++; m = i1; break; p[] arrayOfp = new p[2]; arrayOfp[0] = new p(arrayOfInt1[1], paramInt); arrayOfp[1] = new p(arrayOfInt2[0], paramInt); return new n(str, null, arrayOfp, com.google.e.a.i); label218: i1 = m; } } } } int[] a(com.google.e.c.a parama) throws j { int[] arrayOfInt = c(parama, c(parama), d); this.c = ((arrayOfInt[1] - arrayOfInt[0]) / 4); a(parama, arrayOfInt[0]); return arrayOfInt; } int[] b(com.google.e.c.a parama) throws j { parama.e(); try { int[] arrayOfInt = c(parama, c(parama), e); a(parama, arrayOfInt[0]); int i = arrayOfInt[0]; arrayOfInt[0] = (parama.a() - arrayOfInt[1]); arrayOfInt[1] = (parama.a() - i); return arrayOfInt; } finally { parama.e(); } } } /* Location: E:\Study\Tools\apktool2_2\dex2jar-0.0.9.15\classes_viber_2_dex2jar.jar * Qualified Name: com.google.e.f.h * JD-Core Version: 0.6.2 */
4e524c331f4e07a7d667426dbacba8960758ed83
34c3b0887f71165a6d4a533bc06ffa2624c2dc10
/summer-alipay-core/src/main/java/com/alipay/api/response/AlipayMemberCouponQuerylistResponse.java
4a77d08391434fb5dd229840281dbe697fe6705d
[]
no_license
songhaoran/summer-alipay
91a7a7fdddf67265241785cd6bb2b784c0f0f1c4
d02e33d9ab679dfc56160af4abd759c0abb113a4
refs/heads/master
2021-05-04T16:39:11.272890
2018-01-17T09:52:32
2018-01-17T09:52:32
120,255,759
1
0
null
2018-02-05T04:42:15
2018-02-05T04:42:15
null
UTF-8
Java
false
false
2,279
java
package com.alipay.api.response; import java.util.List; import com.alipay.api.internal.mapping.ApiField; import com.alipay.api.internal.mapping.ApiListField; import com.alipay.api.domain.Coupon; import com.alipay.api.AlipayResponse; /** * ALIPAY API: alipay.member.coupon.querylist response. * * @author auto create * @since 1.0, 2017-04-14 11:46:40 */ public class AlipayMemberCouponQuerylistResponse extends AlipayResponse { private static final long serialVersionUID = 5544839423536636396L; /** * 券信息数组. 如果没有查询到券信息,则为数组长度为0。 否则返回券信息数组 */ @ApiListField("coupon_list") @ApiField("coupon") private List<Coupon> couponList; /** * 请求成功时,不存在本参数; 请求失败时,本参数为错误代码,参见“7 错误码”。 */ @ApiField("error_code") private String errorCode; /** * 请求成功时,不存在本参数; 请求失败时,本参数返回具体的错误原因。 */ @ApiField("error_msg") private String errorMsg; /** * 本轮查询返回的数量 */ @ApiField("list_size") private String listSize; /** * 整个业务处理成功时 返回T否则返回F。 具体的错误码和 信息科参考error_code和error_msg信息 */ @ApiField("success_code") private String successCode; /** * 总记录数 */ @ApiField("total_num") private String totalNum; public void setCouponList(List<Coupon> couponList) { this.couponList = couponList; } public List<Coupon> getCouponList( ) { return this.couponList; } public void setErrorCode(String errorCode) { this.errorCode = errorCode; } public String getErrorCode( ) { return this.errorCode; } public void setErrorMsg(String errorMsg) { this.errorMsg = errorMsg; } public String getErrorMsg( ) { return this.errorMsg; } public void setListSize(String listSize) { this.listSize = listSize; } public String getListSize( ) { return this.listSize; } public void setSuccessCode(String successCode) { this.successCode = successCode; } public String getSuccessCode( ) { return this.successCode; } public void setTotalNum(String totalNum) { this.totalNum = totalNum; } public String getTotalNum( ) { return this.totalNum; } }
51aa7ad748d64ebdcfa01378dbea2cebac853fd7
f4c2ce96c538d614a208df54f1960b3ee7d6e8c7
/model/src/main/java/com/team26/model/TrackDAO.java
bb8559a6d8e225e7e08cc47e5fbec5fe7685fc2b
[]
no_license
cracker26/NCracker
30d5a060dafe5ebdbe7028a4b2166763b1b976b4
e09a8db1a24f5c5fb0c685370dbfffdaf807f461
refs/heads/master
2020-04-04T06:32:57.838649
2018-12-07T15:23:36
2018-12-07T15:23:36
155,748,764
0
0
null
null
null
null
UTF-8
Java
false
false
259
java
package com.team26.model; import java.util.List; import java.util.UUID; public interface TrackDAO { void add(Track newTrack); void update(UUID id, Track newTrack); void delete(UUID id); Track getTrack(UUID id); List<Track> getAll(); }
406b9b729f3b783390a9f1f12ace0ce2ddd07259
99634562853d25db62a3f12f90d537f549cad95b
/src/main/java/onlineshopping/customer/repository/CustomerRepository.java
6d2800b94b1920408c7c1861a1750b58350965d1
[]
no_license
tanvid10/shopping
04b7051e629fd61acf323ad613e9fc75c64e5630
72c04a23a814b31d227ec398c4a180fbfeffc18f
refs/heads/main
2023-03-14T02:02:34.271698
2021-03-04T07:12:05
2021-03-04T07:12:05
344,379,385
0
0
null
null
null
null
UTF-8
Java
false
false
668
java
package onlineshopping.customer.repository; import java.util.List; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; import onlineshopping.document.Customer; @Repository public interface CustomerRepository extends MongoRepository<Customer, Integer>{ /** * finds customer by name * @param name * @return customer */ public Customer findByName(String name); /** * finds customer by status * @param status * @return Customer */ public List<Customer> findByStatus(String status); /** * deletes customer by name * @param name */ public void deleteByName(String name); }
19f89b7421d21b9059af94da2d5fcea6163c332a
601f22ce23e07a0d1a71a5753b8abf1ed5e6fed8
/src/main/java/com/coaching/customerapi/controller/CustomerController.java
464dd7b8336f235bb041e4b5f15f6889d3f51310
[]
no_license
JackyPrice/CustomerApi
50eb543e7c7dc812a15a562ea9d11aa2488bdd9f
96b71273774d706b71ba0f96b828d4f542766068
refs/heads/master
2022-12-07T01:54:29.906723
2020-07-03T21:51:20
2020-07-03T21:51:20
276,944,000
0
0
null
null
null
null
UTF-8
Java
false
false
1,395
java
package com.coaching.customerapi.controller; import com.coaching.customerapi.model.Customer; import com.coaching.customerapi.service.CustomerService; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController public class CustomerController { private final CustomerService customerService; public CustomerController(CustomerService customerService) { this.customerService = customerService; } @PostMapping("/api/customers") public Customer createCustomer(@RequestBody Customer customer) { return customerService.createCustomer(customer); } @GetMapping("/api/customer/{id}") public Customer getCustomer(@PathVariable("id") Long id) { return customerService.getCustomer(id); } @GetMapping("/api/customers") public List<Customer> getCustomers() { return customerService.getCustomers(); } @PutMapping("/api/customers") public Customer updateCustomer(@RequestBody Customer customer) { return customerService.updateCustomer(customer); } @PatchMapping("/api/customers") public Customer patchCustomer(@RequestBody Customer customer) { return customerService.patchCustomer(customer); } @DeleteMapping("/api/customers/{id}") public void deleteCustomer(@PathVariable("id") Long id) { customerService.deleteCustomer(id); } }
ca0c5f82ebdf68c7eb2757b450fb3f550fffcb4c
c655672afbc0496b5519184ff6c24504a7462cc6
/WebServiceProject/src/client/Start.java
3f767693f29860df35fbc6c2b6396899be6de3e4
[]
no_license
liufengyuqing/webServiceProject
3eba15ac79c3de93891b7641c8c3133dc7066596
1b5f905481d83d289093539b8012071cc0ddc3ce
refs/heads/master
2021-01-22T19:55:06.843046
2017-08-18T12:29:04
2017-08-18T12:29:04
100,710,795
0
0
null
null
null
null
UTF-8
Java
false
false
128
java
package client; public class Start { public static void main(String[] args) { Realize web = new Realize(); } }
f689547b7716afea1204a7b868feb1103f30a126
ed0261afd3d7af2a2c7c226c1ea8577ce5ff5c58
/src/day34/ReturnPractice.java
8df48bd5291d247064cf645a8eedeff560f5a84c
[]
no_license
Mukaddes06/JavaPractice2020
c7be9367af64178767a886d4f4ff3854c73cbd5f
fd92e845e6cc95764117ab74ae44c0899583c372
refs/heads/master
2020-12-03T22:26:47.732829
2020-02-29T18:01:58
2020-02-29T18:01:58
231,504,657
0
0
null
null
null
null
UTF-8
Java
false
false
1,157
java
package day34; public class ReturnPractice { public static void main(String[] args) { // what is return keyword is used // //break VS return //break ---->> loop: break out of the loop //---> switch : break out of case // ---> can we use it to exit method ?? NOO!!!! // return --->> inside a method // return the value out of a method with return type // the moment the return keyword is reached it wiill terminate the method // Can it be used in valid method ?? // Yes BUT ONLY IN THIS WAY : return ; //What is the benefit of using in void method // to terminate the method early print4CharacterLengthName("Jon"); print4CharacterLengthName("Java Shark"); } public static void print4CharacterLengthName(String name){ // if the name has less than 4 chars , get out of the method if(name.length()<4){ System.out.println("INVALID NAME!!!"); return; // this return is being used to get out of the method early } System.out.println(name); } }
e13d9f1f35fe494fd76c48a0517da5cfe4afbd62
795d73ad0ec7e8be34ac6bcbeb43abc187dffe8e
/WordSearchAdapter.java
0c59cb13d1d79134a252318be090a06d62d29366
[]
no_license
caitongzz123/yidongkaifa
47e19a6cc4bfba21696c63ddf324adf6f344f17b
7a0d4713f39e0a4446c4962d68f067d8ba670abd
refs/heads/main
2023-01-09T08:24:57.795044
2020-11-15T09:08:49
2020-11-15T09:08:49
301,327,603
0
0
null
null
null
null
UTF-8
Java
false
false
1,571
java
package com.hwhhhh.wordbook.adapter; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.hwhhhh.wordbook.R; import com.hwhhhh.wordbook.entity.Word; import java.util.List; public class WordSearchAdapter extends BaseAdapter { private Context mContext; private List<Word> words; public WordSearchAdapter(Context mContext, List<Word> words) { this.mContext = mContext; this.words = words; } @Override public int getCount() { return words.size(); } @Override public Object getItem(int i) { return words.get(i); } @Override public long getItemId(int i) { return i; } @Override public View getView(int i, View view, ViewGroup viewGroup) { View mView; Word word = words.get(i); ViewHolder viewHolder; if (view == null) { mView = LayoutInflater.from(mContext).inflate(R.layout.item_search_fuzzy, null); viewHolder = new ViewHolder(); viewHolder.textView = mView.findViewById(R.id.item_search_word); mView.setTag(viewHolder); } else { mView = view; viewHolder = (ViewHolder) mView.getTag(); } viewHolder.textView.setText(word.getWord()); return mView; } private class ViewHolder { TextView textView; } }
4b49a23f533194b487492dd127f56231ead232dc
411e9b935c3138660ff8fe91efb57aac922ecc90
/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/codesystems/UsageContextType.java
5bb02d20c6362bdba3ab21bf26bfd84b4c145296
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
pobedite/hapi-fhir
6591f9004f4bd6b59491026d4db6440e20223072
223df60c1d0ad5683b62a801bebf3b3a793e5335
refs/heads/master
2020-06-09T12:59:04.666298
2016-12-08T15:50:42
2016-12-08T15:50:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,072
java
package org.hl7.fhir.dstu3.model.codesystems; /* Copyright (c) 2011+, HL7, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of HL7 nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Generated on Sat, Nov 5, 2016 08:41-0400 for FHIR v1.7.0 import org.hl7.fhir.exceptions.FHIRException; public enum UsageContextType { /** * The gender of the patient. For this context type, the value should be a code taken from the [AdministrativeGender](valueset-administrative-gender.html) value set */ GENDER, /** * The age of the patient. For this context type, the value should be a range the specifies the applicable ages or a code from the MeSH value set AgeGroupObservationValue */ AGE, /** * The clinical concept(s) addressed by the artifact. For example, disease, diagnostic test interpretation, medication ordering. */ FOCUS, /** * The clinical speciality of the context in which the patient is bring treated - For example, PCP, Patient, Cardiologist, Behavioral Professional, Oral Health Professional, Prescriber, etc... taken from the NUCC Health Care provider taxonomyCode system (OID: 2.16.840.1.113883.6.101). */ USER, /** * The settings in which the artifact is intended for use. For example, admission, pre-op, etc */ WORKFLOW, /** * The context for the clinical task(s) represented by this artifact. Can be any task context represented by the HL7 ActTaskCode value set (OID: 2.16.840.1.113883.1.11.19846). General categories include: order entry, patient documentation and patient information review. */ TASK, /** * The venue in which an artifact could be used. For example, Outpatient, Inpatient, Home, Nursing home. The code value may originate from either the HL7 ActEncounter (OID: 2.16.840.1.113883.1.11.13955) or NUCC non-individual provider codes OID: 2.16.840.1.113883.1.11.19465. */ VENUE, /** * added to help the parsers */ NULL; public static UsageContextType fromCode(String codeString) throws FHIRException { if (codeString == null || "".equals(codeString)) return null; if ("gender".equals(codeString)) return GENDER; if ("age".equals(codeString)) return AGE; if ("focus".equals(codeString)) return FOCUS; if ("user".equals(codeString)) return USER; if ("workflow".equals(codeString)) return WORKFLOW; if ("task".equals(codeString)) return TASK; if ("venue".equals(codeString)) return VENUE; throw new FHIRException("Unknown UsageContextType code '"+codeString+"'"); } public String toCode() { switch (this) { case GENDER: return "gender"; case AGE: return "age"; case FOCUS: return "focus"; case USER: return "user"; case WORKFLOW: return "workflow"; case TASK: return "task"; case VENUE: return "venue"; default: return "?"; } } public String getSystem() { return "http://hl7.org/fhir/usage-context-type"; } public String getDefinition() { switch (this) { case GENDER: return "The gender of the patient. For this context type, the value should be a code taken from the [AdministrativeGender](valueset-administrative-gender.html) value set"; case AGE: return "The age of the patient. For this context type, the value should be a range the specifies the applicable ages or a code from the MeSH value set AgeGroupObservationValue"; case FOCUS: return "The clinical concept(s) addressed by the artifact. For example, disease, diagnostic test interpretation, medication ordering."; case USER: return "The clinical speciality of the context in which the patient is bring treated - For example, PCP, Patient, Cardiologist, Behavioral Professional, Oral Health Professional, Prescriber, etc... taken from the NUCC Health Care provider taxonomyCode system (OID: 2.16.840.1.113883.6.101)."; case WORKFLOW: return "The settings in which the artifact is intended for use. For example, admission, pre-op, etc"; case TASK: return "The context for the clinical task(s) represented by this artifact. Can be any task context represented by the HL7 ActTaskCode value set (OID: 2.16.840.1.113883.1.11.19846). General categories include: order entry, patient documentation and patient information review."; case VENUE: return "The venue in which an artifact could be used. For example, Outpatient, Inpatient, Home, Nursing home. The code value may originate from either the HL7 ActEncounter (OID: 2.16.840.1.113883.1.11.13955) or NUCC non-individual provider codes OID: 2.16.840.1.113883.1.11.19465."; default: return "?"; } } public String getDisplay() { switch (this) { case GENDER: return "Gender"; case AGE: return "Age Range"; case FOCUS: return "Clinical Focus"; case USER: return "User Type"; case WORKFLOW: return "Workflow Setting"; case TASK: return "Workflow Task"; case VENUE: return "Clinical Venue"; default: return "?"; } } }
8789753310c5f2b258dde8332182c8523d543902
46435106abfcad5aa79f06371608b30b36de2c03
/src/casestudy/model/facility/Facility.java
5027af772baffc4a92905df13c97de367b9c16b4
[]
no_license
Thanh0906/casestudy
3ab234b9512aaa514a5844cff66b916ba287663a
9b8cc0937007228f943f407c548073dac0bf770c
refs/heads/main
2023-08-11T15:42:30.383620
2021-09-18T09:45:52
2021-09-18T09:45:52
406,700,620
0
0
null
null
null
null
UTF-8
Java
false
false
2,461
java
package casestudy.model.facility; public abstract class Facility { //cơ sở vật chất private String idService; // Mã dịch vụ private String nameService;//tên dịch vụ private double useArea;//diện tích sử dụng private double rentalCosts;//chi phí cho thuê private int numberPeople;//số người tối da private String styleRental;//kiêu thuê bao gồm thuê theo năm, tháng, ngày, giờ. public Facility() { } public Facility(String idService, String nameService, double useArea, double rentalCosts, int numberPeople, String styleRental) { this.idService = idService; this.nameService = nameService; this.useArea = useArea; this.rentalCosts = rentalCosts; this.numberPeople = numberPeople; this.styleRental = styleRental; } public String getIdService() { return idService; } public void setIdService(String idService) { this.idService = idService; } public String getNameService() { return nameService; } public void setNameService(String nameService) { this.nameService = nameService; } public double getUseArea() { return useArea; } public void setUseArea(double useArea) { this.useArea = useArea; } public double getRentalCosts() { return rentalCosts; } public void setRentalCosts(double rentalCosts) { this.rentalCosts = rentalCosts; } public int getNumberPeople() { return numberPeople; } public void setNumberPeople(int numberPeople) { this.numberPeople = numberPeople; } public String getStyleRental() { return styleRental; } public void setStyleRental(String styleRental) { this.styleRental = styleRental; } @Override public String toString() { return "Facility{" + "idService='" + idService + '\'' + ", nameService='" + nameService + '\'' + ", useArea=" + useArea + ", rentalCosts=" + rentalCosts + ", numberPeople=" + numberPeople + ", styleRental='" + styleRental + '\'' + '}'; } public String getToString(){ return this.getIdService()+","+this.getNameService()+","+this.getUseArea()+","+this.getRentalCosts() +","+this.getNumberPeople()+","+this.getStyleRental(); } }
4b7a68af79436d6269b22c9ba0f2f5e161895019
d307073705686f74c053344fceb2acc2235b01dc
/src/Tokenizer.java
6d1b57406727beca8c883559c09f80c39a382406
[]
no_license
kareemhamdy100/L_project
99a164f321670648751dcca2233b732c6c047385
e0e0520f04722efbc934711519332ab87e59c6ca
refs/heads/master
2020-03-31T19:38:59.881294
2018-10-11T00:29:26
2018-10-11T00:29:26
152,505,421
0
0
null
null
null
null
UTF-8
Java
false
false
6,365
java
import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Created by kareem on 10/8/2018. */ public class Tokenizer { public List<Token> returnTokens; HashMap<Character, Token> charTokens; HashMap<String, Token> keyWords; String source; Token current_token; int pos; public Tokenizer(String source) { this.source = source; pos = 0; current_token = null; returnTokens = new ArrayList<Token>(); initcharTokens(); intiKeyWords (); } private void initcharTokens() { charTokens = new HashMap<Character, Token>(); charTokens.put('~', new Token( "Tilde","~" )); charTokens.put('!', new Token( "Exclamation mark","!" )); charTokens.put('#', new Token( "Number sign","#" )); charTokens.put('$',new Token( "Dollar sig","$")); charTokens.put('%', new Token( "Percent sign","%" )); charTokens.put('^', new Token( "Caret","^" )); charTokens.put('&', new Token( "Ampersand","&" )); charTokens.put('*', new Token( "Asterisk","*" )); charTokens.put('(', new Token( "Left parenthesis","(" )); charTokens.put(')',new Token( "Right parenthesis",")")); charTokens.put('_',new Token( "Underscor","_")); charTokens.put('+', new Token( "Plus sign","+" )); charTokens.put('|', new Token( "Vertical bar","|" )); charTokens.put('\\',new Token("Backslas","\\")); charTokens.put('`', new Token( "Apostrophe","`" )); charTokens.put('–', new Token( "Minus sign","–" )); charTokens.put('=', new Token( "Equal to sign","=" )); charTokens.put('{', new Token( "Left brace","{" )); charTokens.put('}',new Token( "Right brace","}")); charTokens.put('[' , new Token( "Left bracket","[" )); charTokens.put(']',new Token("Right bracke","]")); charTokens.put(':', new Token( "Colon",":" )); // charTokens.put('"', new Token("Quotation mark","\"" )); charTokens.put(';',new Token( "Semicolon",";")); charTokens.put('<', new Token( "Opening angle bracket","<" )); charTokens.put('>', new Token( "Closing angle bracket",">" )); charTokens.put('?', new Token( "Question mark","?" )); charTokens.put(',',new Token( "Comma",",")); charTokens.put('.', new Token( "Period","." )); charTokens.put('/', new Token( "Slash","/" )); } private void intiKeyWords (){ keyWords = new HashMap<String, Token>(); keyWords.put( "auto",new Token("auto",null)); keyWords.put( "double",new Token("double",null)); keyWords.put( "int",new Token("int",null)); keyWords.put( "struct",new Token("struct",null)); keyWords.put( "break",new Token("break",null)); keyWords.put( "else",new Token("else",null)); keyWords.put( "long",new Token("long",null)); keyWords.put( "switch",new Token("switch",null)); keyWords.put( "case",new Token("case",null)); keyWords.put( "enum",new Token("enum",null)); keyWords.put( "register",new Token("register",null)); keyWords.put( "typedef",new Token("typedef",null)); keyWords.put( "char",new Token("char",null)); keyWords.put( "extern",new Token("extern",null)); keyWords.put( "return",new Token("return",null)); keyWords.put( "union",new Token("union",null)); keyWords.put( "const",new Token("const",null)); keyWords.put( "float",new Token("float",null)); keyWords.put( "short",new Token("short",null)); keyWords.put( "unsigned",new Token("unsigned",null)); keyWords.put( "continue",new Token("continue",null)); keyWords.put( "for",new Token("for",null)); keyWords.put( "signed",new Token("signed",null)); keyWords.put( "void",new Token("void",null)); keyWords.put( "default",new Token("default",null)); keyWords.put( "goto",new Token("goto",null)); keyWords.put( "sizeof",new Token("sizeof",null)); keyWords.put( "volatile",new Token("volatile",null)); keyWords.put( "do",new Token("do",null)); keyWords.put( "if",new Token("if",null)); keyWords.put( "static",new Token("static",null)); keyWords.put( "while",new Token("while",null)); } public void scan() { int start_po = 0; int end_po =0; for (int i = 0; i < source.length(); i++) { char current = source.charAt(i); if(current==' '){ if(end_po <= start_po){ start_po= i+1; }else { end_po=i; Token newToken= checkTypeOFToken(source.substring(start_po,end_po)); returnTokens.add(newToken); start_po=i+1; } } else if (charTokens.keySet().contains(current)){ if(end_po> start_po) { end_po = i; returnTokens.add(checkTypeOFToken(source.substring(start_po,end_po))); } returnTokens.add(charTokens.get(current)); start_po = i + 1; }else if (current == '"'){ int end_string= source.indexOf('"',i+1)+1; Token string_token= new Token("String",source.substring(i,end_string)); returnTokens.add(string_token); if (end_string == 0) { throw new Error("the double quote didn't closed"); } else { i=end_string; start_po = end_string; } } else {end_po=i+1;} if(i== source.length()-1){ if(end_po> start_po) returnTokens.add(checkTypeOFToken(source.substring(start_po,end_po))); returnTokens.add(new Token("EOF",null)); } } } private Token checkTypeOFToken(String tokenString ){ if(Character.isDigit(tokenString.charAt(0))){ for (int i=0;i<tokenString.length();i++ ) { if(!Character.isDigit(tokenString.charAt(i))){ throw new Error("type error can't be a number or variable name"); } } return new Token("constant",tokenString); }else if(keyWords.keySet().contains(tokenString)) { return keyWords.get(tokenString); } else { return new Token("Identifier",tokenString); } } }
6df72063bd08e3d17dc7132f0dd0c6d14c83a775
1004ecf42a1423a802b0dd9d1298a3288368721f
/gyum_02/src/main/java/gyum_02/member/model/My_memberParentDTO.java
1d4e1efba704256012caff429dbf44bec26ed2c4
[]
no_license
grapematstar/MenagementSystem
4262f09511e956c1e444d64aac2b585dbd1c523b
545f0f6899a9226f3ae336f06523c43f8c3e9502
refs/heads/master
2021-01-21T22:05:31.605401
2018-05-28T12:02:28
2018-05-28T12:02:28
95,158,969
0
1
null
null
null
null
UTF-8
Java
false
false
2,040
java
package gyum_02.member.model; import java.sql.Date; public class My_memberParentDTO { private int par_idx; private String par_id; private String par_pwd; private int pwd_q_idx; private String par_pwd_a; private String par_name; private String par_tel; private String par_email; private Date par_in_date; public My_memberParentDTO() { super(); } public My_memberParentDTO(int par_idx, String par_id, String par_pwd, int pwd_q_idx, String par_pwd_a, String par_name, String par_tel, String par_email, Date par_in_date) { super(); this.par_idx = par_idx; this.par_id = par_id; this.par_pwd = par_pwd; this.pwd_q_idx = pwd_q_idx; this.par_pwd_a = par_pwd_a; this.par_name = par_name; this.par_tel = par_tel; this.par_email = par_email; this.par_in_date = par_in_date; } public int getPar_idx() { return par_idx; } public void setPar_idx(int par_idx) { this.par_idx = par_idx; } public String getPar_id() { return par_id; } public void setPar_id(String par_id) { this.par_id = par_id; } public String getPar_pwd() { return par_pwd; } public void setPar_pwd(String par_pwd) { this.par_pwd = par_pwd; } public int getPwd_q_idx() { return pwd_q_idx; } public void setPwd_q_idx(int pwd_q_idx) { this.pwd_q_idx = pwd_q_idx; } public String getPar_pwd_a() { return par_pwd_a; } public void setPar_pwd_a(String par_pwd_a) { this.par_pwd_a = par_pwd_a; } public String getPar_name() { return par_name; } public void setPar_name(String par_name) { this.par_name = par_name; } public String getPar_tel() { return par_tel; } public void setPar_tel(String par_tel) { this.par_tel = par_tel; } public String getPar_email() { return par_email; } public void setPar_email(String par_email) { this.par_email = par_email; } public Date getPar_in_date() { return par_in_date; } public void setPar_in_date(Date par_in_date) { this.par_in_date = par_in_date; } }
[ "bae@bae-PC" ]
bae@bae-PC
3f71697acee171ee428da27b7be75ceef4eb38bd
e1f8d628949625b8cb36c2a7f721f74a793024b2
/ApplesTask/src/by/bsu/goncharov/model/Apple.java
99bc6b30c456e36cbf62ccbd773bca5f0c9ffff3
[]
no_license
ramanhancharou/ProgectManagment
aac62b222f9c2aa22901cff38dacefd5dc3b054f
706a5623c5b28bd1b24aed4e51b1a232d765592c
refs/heads/master
2021-01-01T16:05:37.644227
2013-09-12T15:23:31
2013-09-12T15:23:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
409
java
package by.bsu.goncharov.model; import java.util.Random; public class Apple { private static final int MAX_SEEDS = 20; private int numberOfSeeds; public Apple() { Random rand = new Random(); numberOfSeeds = rand.nextInt() % MAX_SEEDS; } public int getNumberOfSeeds() { return numberOfSeeds; } public void setNumberOfSeeds(int numberOfSeeds) { this.numberOfSeeds = numberOfSeeds; } }
4dda53d1c633c3221326216ca4c487ca2b8f53d9
0c0c772897be394287170390eeb6613abbf44825
/common/src/com/entity/Grade.java
50c1a80b4ecb68604266beaf0d708b7020b7e3e8
[]
no_license
KUNICA/-plywood
8b9a23b2b4e6f68bc18a6974beca4d97a6b70769
95b62f9eeb67214a96e9d2afbf3fb8402254983d
refs/heads/master
2020-07-10T21:05:28.611483
2017-01-23T18:20:40
2017-01-23T18:20:42
66,144,505
0
0
null
null
null
null
UTF-8
Java
false
false
1,388
java
package com.entity; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Strings; /** * Created by user on 05.09.2016. */ @JsonFormat(shape = JsonFormat.Shape.OBJECT) public enum Grade { FIRST_FIRST("1/1"), SECOND_SECOND("2/2"), TREE_TREE("3/3"), FOUR_FOUR("4/4"); String nameField; Grade(String name){ this.nameField = name; } public String getNameField() { return nameField; } public boolean isStirng(String ch){ return !Strings.isNullOrEmpty(ch) && ch.indexOf(this.nameField)!=-1; } public static Grade getField(String ch) { Grade[] particleboardFields = values(); Grade particleboardField = null; for(int i=0; i<particleboardFields.length;i++){ if(particleboardFields[i].isStirng(ch)){ particleboardField = particleboardFields[i]; } } return particleboardField; } public static boolean isField(String ch) { Grade[] particleboardFields = values(); boolean particleboardField = false; for(int i=0; i<particleboardFields.length;i++){ if(particleboardFields[i].isStirng(ch)){ particleboardField = true; } } return particleboardField; } }
05661a080e954b4f21fc962b0567b27fc1845952
a7ce44e1c5c621335069921bd5f6b83616189ea7
/src/test/java/com/irurueta/navigation/inertial/INSTightlyCoupledKalmanInitializerConfigTest.java
a1821044f891a085c22846cb85482127d5953764
[ "Apache-2.0" ]
permissive
yxw027/irurueta-navigation-inertial
3f9c88a0b32fb7d315d209b77faa0cf4ed492332
78952c3bb49af90cd538a394aefa00b9202bb798
refs/heads/master
2023-03-26T16:17:48.305336
2021-03-25T08:53:53
2021-03-25T08:53:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
44,172
java
/* * Copyright (C) 2019 Alberto Irurueta Carro ([email protected]) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.irurueta.navigation.inertial; import com.irurueta.statistics.UniformRandomizer; import com.irurueta.units.*; import org.junit.Test; import java.util.Random; import static org.junit.Assert.*; public class INSTightlyCoupledKalmanInitializerConfigTest { private static final double MIN_VALUE = 1e-4; private static final double MAX_VALUE = 1e-3; private static final double THRESHOLD = 1e-6; @Test public void testConstructor() { // test empty constructor INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default values assertEquals(config.getInitialAttitudeUncertainty(), 0.0, 0.0); assertEquals(config.getInitialVelocityUncertainty(), 0.0, 0.0); assertEquals(config.getInitialPositionUncertainty(), 0.0, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), 0.0, 0.0); // test constructor with values final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); // check default values assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); // test constructor with measurement values final Angle initialAttitudeUncertaintyAngle = new Angle(initialAttitudeUncertainty, AngleUnit.RADIANS); final Speed initialVelocityUncertaintySpeed = new Speed(initialVelocityUncertainty, SpeedUnit.METERS_PER_SECOND); final Distance initialPositionUncertaintyDistance = new Distance(initialPositionUncertainty, DistanceUnit.METER); final Acceleration initialAccelerationBiasUncertaintyAcceleration = new Acceleration(initialAccelerationBiasUncertainty, AccelerationUnit.METERS_PER_SQUARED_SECOND); final AngularSpeed initialGyroscopeBiasUncertaintyAngularSpeed = new AngularSpeed(initialGyroscopeBiasUncertainty, AngularSpeedUnit.RADIANS_PER_SECOND); final Distance initialClockOffsetUncertaintyDistance = new Distance(initialClockOffsetUncertainty, DistanceUnit.METER); final Speed initialClockDriftUncertaintySpeed = new Speed(initialClockDriftUncertainty, SpeedUnit.METERS_PER_SECOND); config = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertaintyAngle, initialVelocityUncertaintySpeed, initialPositionUncertaintyDistance, initialAccelerationBiasUncertaintyAcceleration, initialGyroscopeBiasUncertaintyAngularSpeed, initialClockOffsetUncertaintyDistance, initialClockDriftUncertaintySpeed); // check default values assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); // test copy constructor final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(config); // check default values assertEquals(config2.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config2.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config2.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config2.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config2.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config2.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config2.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testGetSetInitialAttitudeUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialAttitudeUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialAttitudeUncertainty(initialAttitudeUncertainty); // check assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); } @Test public void testGetSetInitialAttitudeUncertaintyAngle() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Angle initialAttitudeUncertainty1 = config.getInitialAttitudeUncertaintyAngle(); assertEquals(initialAttitudeUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialAttitudeUncertainty1.getUnit(), AngleUnit.RADIANS); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Angle initialAttitudeUncertainty2 = new Angle(initialAttitudeUncertainty, AngleUnit.RADIANS); config.setInitialAttitudeUncertainty(initialAttitudeUncertainty2); // check final Angle initialAttitudeUncertainty3 = config.getInitialAttitudeUncertaintyAngle(); final Angle initialAttitudeUncertainty4 = new Angle(0.0, AngleUnit.DEGREES); config.getInitialAttitudeUncertaintyAngle(initialAttitudeUncertainty4); assertEquals(initialAttitudeUncertainty2, initialAttitudeUncertainty3); assertEquals(initialAttitudeUncertainty2, initialAttitudeUncertainty4); } @Test public void testGetSetInitialVelocityUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialVelocityUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialVelocityUncertainty(initialVelocityUncertainty); // check assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); } @Test public void testGetSetInitialVelocityUncertaintySpeed() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Speed initialVelocityUncertaintySpeed1 = config.getInitialVelocityUncertaintySpeed(); assertEquals(initialVelocityUncertaintySpeed1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialVelocityUncertaintySpeed1.getUnit(), SpeedUnit.METERS_PER_SECOND); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Speed initialVelocityUncertainty2 = new Speed(initialVelocityUncertainty, SpeedUnit.METERS_PER_SECOND); config.setInitialVelocityUncertainty(initialVelocityUncertainty2); // check final Speed initialVelocityUncertainty3 = config.getInitialVelocityUncertaintySpeed(); final Speed initialVelocityUncertainty4 = new Speed(0.0, SpeedUnit.KILOMETERS_PER_HOUR); config.getInitialVelocityUncertaintySpeed(initialVelocityUncertainty4); assertEquals(initialVelocityUncertainty2, initialVelocityUncertainty3); assertEquals(initialVelocityUncertainty2, initialVelocityUncertainty4); } @Test public void testGetSetInitialPositionUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialPositionUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialPositionUncertainty(initialPositionUncertainty); // check assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); } @Test public void testGetSetInitialPositionUncertaintyDistance() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Distance initialPositionUncertainty1 = config.getInitialPositionUncertaintyDistance(); assertEquals(initialPositionUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialPositionUncertainty1.getUnit(), DistanceUnit.METER); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Distance initialPositionUncertainty2 = new Distance(initialPositionUncertainty, DistanceUnit.METER); config.setInitialPositionUncertainty(initialPositionUncertainty2); // check final Distance initialPositionUncertainty3 = config.getInitialPositionUncertaintyDistance(); final Distance initialPositionUncertainty4 = new Distance(0.0, DistanceUnit.KILOMETER); config.getInitialPositionUncertaintyDistance(initialPositionUncertainty4); assertEquals(initialPositionUncertainty2, initialPositionUncertainty3); assertEquals(initialPositionUncertainty2, initialPositionUncertainty4); } @Test public void testGetSetInitialAccelerationBiasUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialAccelerationBiasUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialAccelerationBiasUncertainty( initialAccelerationBiasUncertainty); // check assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); } @Test public void testGetSetInitialAccelerationBiasUncertaintyAcceleration() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Acceleration initialAccelerationBiasUncertainty1 = config.getInitialAccelerationBiasUncertaintyAcceleration(); assertEquals(initialAccelerationBiasUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialAccelerationBiasUncertainty1.getUnit(), AccelerationUnit.METERS_PER_SQUARED_SECOND); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Acceleration initialAccelerationBiasUncertainty2 = new Acceleration(initialAccelerationBiasUncertainty, AccelerationUnit.METERS_PER_SQUARED_SECOND); config.setInitialAccelerationBiasUncertainty( initialAccelerationBiasUncertainty2); // check final Acceleration initialAccelerationBiasUncertainty3 = config.getInitialAccelerationBiasUncertaintyAcceleration(); final Acceleration initialAccelerationBiasUncertainty4 = new Acceleration(0.0, AccelerationUnit.FEET_PER_SQUARED_SECOND); config.getInitialAccelerationBiasUncertaintyAcceleration( initialAccelerationBiasUncertainty4); assertEquals(initialAccelerationBiasUncertainty2, initialAccelerationBiasUncertainty3); assertEquals(initialAccelerationBiasUncertainty2, initialAccelerationBiasUncertainty4); } @Test public void testGetSetInitialGyroscopeBiasUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialGyroscopeBiasUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialGyroscopeBiasUncertainty( initialGyroscopeBiasUncertainty); // check assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); } @Test public void testGetSetInitialGyroscopeBiasUncertaintyAngularSpeed() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final AngularSpeed initialGyroscopeBiasUncertainty1 = config.getInitialGyroscopeBiasUncertaintyAngularSpeed(); assertEquals(initialGyroscopeBiasUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialGyroscopeBiasUncertainty1.getUnit(), AngularSpeedUnit.RADIANS_PER_SECOND); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final AngularSpeed initialGyroscopeBiasUncertainty2 = new AngularSpeed(initialGyroscopeBiasUncertainty, AngularSpeedUnit.RADIANS_PER_SECOND); config.setInitialGyroscopeBiasUncertainty( initialGyroscopeBiasUncertainty2); // check final AngularSpeed initialGyroscopeBiasUncertainty3 = config.getInitialGyroscopeBiasUncertaintyAngularSpeed(); final AngularSpeed initialGyroscopeBiasUncertainty4 = new AngularSpeed(0.0, AngularSpeedUnit.RADIANS_PER_SECOND); config.getInitialGyroscopeBiasUncertaintyAngularSpeed( initialGyroscopeBiasUncertainty4); assertEquals(initialGyroscopeBiasUncertainty2, initialGyroscopeBiasUncertainty3); assertEquals(initialGyroscopeBiasUncertainty2, initialGyroscopeBiasUncertainty4); } @Test public void testGetSetInitialClockOffsetUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialClockOffsetUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialClockOffsetUncertainty(initialClockOffsetUncertainty); // check assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); } @Test public void testGetSetInitialClockOffsetUncertaintyDistance() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Distance initialClockOffsetUncertainty1 = config.getInitialClockOffsetUncertaintyDistance(); assertEquals(initialClockOffsetUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialClockOffsetUncertainty1.getUnit(), DistanceUnit.METER); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Distance initialClockOffsetUncertainty2 = new Distance(initialClockOffsetUncertainty, DistanceUnit.METER); config.setInitialClockOffsetUncertainty(initialClockOffsetUncertainty2); // check final Distance initialClockOffsetUncertainty3 = config.getInitialClockOffsetUncertaintyDistance(); final Distance initialClockOffsetUncertainty4 = new Distance(0.0, DistanceUnit.METER); config.getInitialClockOffsetUncertaintyDistance( initialClockOffsetUncertainty4); assertEquals(initialClockOffsetUncertainty2, initialClockOffsetUncertainty3); assertEquals(initialClockOffsetUncertainty2, initialClockOffsetUncertainty4); } @Test public void testGetSetInitialClockDriftUncertainty() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialClockDriftUncertainty(), 0.0, 0.0); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setInitialClockDriftUncertainty( initialClockDriftUncertainty); // check assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testGetSetInitialClockDriftUncertaintySpeed() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value final Speed initialClockDriftUncertainty1 = config.getInitialClockDriftUncertaintySpeed(); assertEquals(initialClockDriftUncertainty1.getValue().doubleValue(), 0.0, 0.0); assertEquals(initialClockDriftUncertainty1.getUnit(), SpeedUnit.METERS_PER_SECOND); // set new value final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Speed initialClockDriftUncertainty2 = new Speed(initialClockDriftUncertainty, SpeedUnit.METERS_PER_SECOND); config.setInitialClockDriftUncertainty( initialClockDriftUncertainty2); // check final Speed initialClockDriftUncertainty3 = config.getInitialClockDriftUncertaintySpeed(); final Speed initialClockDriftUncertainty4 = new Speed(0.0, SpeedUnit.KILOMETERS_PER_HOUR); config.getInitialClockDriftUncertaintySpeed( initialClockDriftUncertainty4); assertEquals(initialClockDriftUncertainty2, initialClockDriftUncertainty3); assertEquals(initialClockDriftUncertainty2, initialClockDriftUncertainty4); } @Test public void testSetValues() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialAttitudeUncertainty(), 0.0, 0.0); assertEquals(config.getInitialVelocityUncertainty(), 0.0, 0.0); assertEquals(config.getInitialPositionUncertainty(), 0.0, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), 0.0, 0.0); // set new values final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); config.setValues(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); // check assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testSetValues2() { final INSTightlyCoupledKalmanInitializerConfig config = new INSTightlyCoupledKalmanInitializerConfig(); // check default value assertEquals(config.getInitialAttitudeUncertainty(), 0.0, 0.0); assertEquals(config.getInitialVelocityUncertainty(), 0.0, 0.0); assertEquals(config.getInitialPositionUncertainty(), 0.0, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), 0.0, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), 0.0, 0.0); // set new values final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final Angle initialAttitudeUncertaintyAngle = new Angle(initialAttitudeUncertainty, AngleUnit.RADIANS); final Speed initialVelocityUncertaintySpeed = new Speed(initialVelocityUncertainty, SpeedUnit.METERS_PER_SECOND); final Distance initialPositionUncertaintyDistance = new Distance(initialPositionUncertainty, DistanceUnit.METER); final Acceleration initialAccelerationBiasUncertaintyAcceleration = new Acceleration(initialAccelerationBiasUncertainty, AccelerationUnit.METERS_PER_SQUARED_SECOND); final AngularSpeed initialGyroscopeBiasUncertaintyAngularSpeed = new AngularSpeed(initialGyroscopeBiasUncertainty, AngularSpeedUnit.RADIANS_PER_SECOND); final Distance initialClockOffsetUncertaintyDistance = new Distance(initialClockOffsetUncertainty, DistanceUnit.METER); final Speed initialClockDriftUncertaintySpeed = new Speed(initialClockDriftUncertainty, SpeedUnit.METERS_PER_SECOND); config.setValues(initialAttitudeUncertaintyAngle, initialVelocityUncertaintySpeed, initialPositionUncertaintyDistance, initialAccelerationBiasUncertaintyAcceleration, initialGyroscopeBiasUncertaintyAngularSpeed, initialClockOffsetUncertaintyDistance, initialClockDriftUncertaintySpeed); // check assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); // check assertEquals(config.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testCopyTo() { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(); config1.copyTo(config2); // check assertEquals(config2.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config2.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config2.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config2.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config2.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config2.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config2.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testCopyFrom() { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(); config2.copyFrom(config1); // check assertEquals(config2.getInitialAttitudeUncertainty(), initialAttitudeUncertainty, 0.0); assertEquals(config2.getInitialVelocityUncertainty(), initialVelocityUncertainty, 0.0); assertEquals(config2.getInitialPositionUncertainty(), initialPositionUncertainty, 0.0); assertEquals(config2.getInitialAccelerationBiasUncertainty(), initialAccelerationBiasUncertainty, 0.0); assertEquals(config2.getInitialGyroscopeBiasUncertainty(), initialGyroscopeBiasUncertainty, 0.0); assertEquals(config2.getInitialClockOffsetUncertainty(), initialClockOffsetUncertainty, 0.0); assertEquals(config2.getInitialClockDriftUncertainty(), initialClockDriftUncertainty, 0.0); } @Test public void testHashCode() { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config3 = new INSTightlyCoupledKalmanInitializerConfig(); assertEquals(config1.hashCode(), config2.hashCode()); assertNotEquals(config1.hashCode(), config3.hashCode()); } @Test public void testEquals() { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config3 = new INSTightlyCoupledKalmanInitializerConfig(); //noinspection ConstantConditions,SimplifiableJUnitAssertion assertTrue(config1.equals((Object) config1)); assertTrue(config1.equals(config1)); assertTrue(config1.equals(config2)); assertFalse(config1.equals(config3)); //noinspection SimplifiableJUnitAssertion,ConstantConditions assertFalse(config1.equals((Object) null)); assertFalse(config1.equals(null)); //noinspection SimplifiableJUnitAssertion assertFalse(config1.equals(new Object())); } @Test public void testEqualsWithThreshold() { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config2 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final INSTightlyCoupledKalmanInitializerConfig config3 = new INSTightlyCoupledKalmanInitializerConfig(); assertTrue(config1.equals(config1, THRESHOLD)); assertTrue(config1.equals(config2, THRESHOLD)); assertFalse(config1.equals(config3, THRESHOLD)); assertFalse(config1.equals(null, THRESHOLD)); } @Test public void testClone() throws CloneNotSupportedException { final UniformRandomizer randomizer = new UniformRandomizer(new Random()); final double initialAttitudeUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialVelocityUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialPositionUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialAccelerationBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialGyroscopeBiasUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockOffsetUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final double initialClockDriftUncertainty = randomizer.nextDouble( MIN_VALUE, MAX_VALUE); final INSTightlyCoupledKalmanInitializerConfig config1 = new INSTightlyCoupledKalmanInitializerConfig(initialAttitudeUncertainty, initialVelocityUncertainty, initialPositionUncertainty, initialAccelerationBiasUncertainty, initialGyroscopeBiasUncertainty, initialClockOffsetUncertainty, initialClockDriftUncertainty); final Object config2 = config1.clone(); assertEquals(config1, config2); } }
c5337f0e6d919e72331d8f9bda7c9f37007e071d
0cd9f341b3270f7df82e6dc0d895d1e168f7c9ca
/lw/src/main/java/com/dock/lw/code/web/UserReportController.java
6ace6fab038793f0e2165a5a4b69ccbe9c9e8308
[]
no_license
xx52lw/LWJava
d45a48c2fd23ecb583c802dd19fad991c9a1d624
028b960c11881bfe52850be2bbde86a88b2b03c6
refs/heads/master
2022-11-28T03:21:23.800303
2020-04-01T05:09:04
2020-04-01T05:09:04
252,077,594
0
0
null
2022-11-21T22:38:45
2020-04-01T05:08:09
Java
UTF-8
Java
false
false
1,477
java
package com.dock.lw.code.web; import com.dock.lw.common.Constant; import com.dock.lw.common.IPageDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import com.baomidou.mybatisplus.core.metadata.IPage; import com.dock.lw.code.model.UserReport; import com.dock.lw.code.service.UserReportService; /** * <p> * 用户登记接口 * </p> * * @author liwei * @since 2020-03-05 */ @RestController @RequestMapping(Constant.PLATFORM.APP +"/userReport") @Api(value = "用户登记接口", description = "用户登记接口") public class UserReportController { @Autowired private UserReportService userReportService; @ApiOperation(value = "分页查询用户登记",response=UserReport.class) @PostMapping(value = "/getDetail") public IPage<UserReport> getDetail(@RequestBody IPageDto param) { return userReportService.selectByPage(param.getPage(), param.getCm()); } @ApiOperation(value = "分页查询用户登记",response=UserReport.class) @PostMapping(value = "/getByPage") public IPage<UserReport> query(@RequestBody IPageDto param) { return userReportService.selectByPage(param.getPage(), param.getCm()); } }
a467fff50a7a252b32be5d2c246df9735cd5b68c
dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9
/data_defect4j/preprossed_method_corpus/Math/59/org/apache/commons/math/linear/OpenMapRealVector_getL1Distance_514.java
ef71c3f29702c817e684080903110f4f2ac442e3
[]
no_license
hvdthong/NetML
dca6cf4d34c5799b400d718e0a6cd2e0b167297d
9bb103da21327912e5a29cbf9be9ff4d058731a5
refs/heads/master
2021-06-30T15:03:52.618255
2020-10-07T01:58:48
2020-10-07T01:58:48
150,383,588
1
1
null
2018-09-26T07:08:45
2018-09-26T07:08:44
null
UTF-8
Java
false
false
1,384
java
org apach common math linear link real vector realvector link open int doubl hash map openinttodoublehashmap back store version revis date open map real vector openmaprealvector abstract real vector abstractrealvector inherit doc inheritdoc overrid distanc getl1dist real vector realvector check vector dimens checkvectordimens dimens getdimens open map real vector openmaprealvector distanc getl1dist open map real vector openmaprealvector distanc getl1dist data getdata
1e2c3201f760102b6e5b9cf1037b1badcd0f0568
7d3f5b69e744fe37b4a6c697b8961a869904e731
/app/src/main/java/com/example/testsqlite/DatabaseHelper.java
af16f7e2e975af650ac043902c22d4c257bfd80e
[]
no_license
ChainarongN/SQLite
c5a3033c593b76784a604f1a04b7ea8c534960ee
818ea739820e5accc0946f52ce4d33093b461574
refs/heads/master
2022-11-23T05:54:24.237230
2020-07-21T13:29:47
2020-07-21T13:29:47
281,405,491
0
0
null
null
null
null
UTF-8
Java
false
false
3,373
java
package com.example.testsqlite; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; /** * Created by User on 2/28/2017. */ public class DatabaseHelper extends SQLiteOpenHelper { private static final String TAG = "DatabaseHelper"; private static final String TABLE_NAME = "people_table"; private static final String COL1 = "ID"; private static final String COL2 = "name"; public DatabaseHelper(Context context) { super(context, TABLE_NAME, null, 1); } @Override public void onCreate(SQLiteDatabase db) { String createTable = "CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, " + COL2 +" TEXT)"; db.execSQL(createTable); } @Override public void onUpgrade(SQLiteDatabase db, int i, int i1) { // db.execSQL("DROP IF TABLE EXISTS " + TABLE_NAME); // onCreate(db); } public boolean addData(String item) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put(COL2, item); Log.d(TAG, "addData: Adding " + item + " to " + TABLE_NAME); long result = db.insert(TABLE_NAME, null, contentValues); //if date as inserted incorrectly it will return -1 if (result == -1) { return false; } else { return true; } } /** * Returns all the data from database * @return */ public Cursor getData(){ SQLiteDatabase db = this.getWritableDatabase(); String query = "SELECT * FROM " + TABLE_NAME; Cursor data = db.rawQuery(query, null); return data; } /** * Returns only the ID that matches the name passed in * @param name * @return */ public Cursor getItemID(String name){ SQLiteDatabase db = this.getWritableDatabase(); String query = "SELECT " + COL1 + " FROM " + TABLE_NAME + " WHERE " + COL2 + " = '" + name + "'"; Cursor data = db.rawQuery(query, null); return data; } /** * Updates the name field * @param newName * @param id * @param oldName */ public void updateName(String newName, int id, String oldName){ SQLiteDatabase db = this.getWritableDatabase(); String query = "UPDATE " + TABLE_NAME + " SET " + COL2 + " = '" + newName + "' WHERE " + COL1 + " = '" + id + "'" + " AND " + COL2 + " = '" + oldName + "'"; Log.d(TAG, "updateName: query: " + query); Log.d(TAG, "updateName: Setting name to " + newName); db.execSQL(query); } /** * Delete from database * @param id * @param name */ public void deleteName(int id, String name){ SQLiteDatabase db = this.getWritableDatabase(); String query = "DELETE FROM " + TABLE_NAME + " WHERE " + COL1 + " = '" + id + "'" + " AND " + COL2 + " = '" + name + "'"; Log.d(TAG, "deleteName: query: " + query); Log.d(TAG, "deleteName: Deleting " + name + " from database."); db.execSQL(query); } }
df7496750a9029d08b3227b4e3130397e8f13aea
29345337bf86edc938f3b5652702d551bfc3f11a
/core/src/main/java/com/alibaba/alink/operator/common/optim/activeSet/SqpUtil.java
ddc0335f9cebc5c93beae6ee24e3653b66c994b1
[ "Apache-2.0" ]
permissive
vacaly/Alink
32b71ac4572ae3509d343e3d1ff31a4da2321b6d
edb543ee05260a1dd314b11384d918fa1622d9c1
refs/heads/master
2023-07-21T03:29:07.612507
2023-07-12T12:41:31
2023-07-12T12:41:31
283,079,072
0
0
Apache-2.0
2020-07-28T02:46:14
2020-07-28T02:46:13
null
UTF-8
Java
false
false
2,024
java
package com.alibaba.alink.operator.common.optim.activeSet; import org.apache.flink.api.java.tuple.Tuple2; import com.alibaba.alink.common.linalg.DenseMatrix; import com.alibaba.alink.common.linalg.DenseVector; public class SqpUtil { public static void fillMatrix(double[][] targetMatrix, int rowStart, int colStart, double[][] values) { int rowLength = values.length; if (rowLength != 0) { int colLength = values[0].length; if (colLength != 0) { for (int i = 0; i < rowLength; i++) { System.arraycopy(values[i], 0, targetMatrix[rowStart + i], colStart, colLength); } } } } // public static DenseVector slice(DenseVector dv, int start, int length) { // double[] d = dv.getData(); // double[] e = new double[length]; // System.arraycopy(d, start, e, 0, length); // return new DenseVector(e); // } public static DenseMatrix concatMatrixRow(DenseMatrix equalMatrix, DenseMatrix inequalMatrix) { int r1 = equalMatrix.numRows(); int r2 = inequalMatrix.numRows(); int c = equalMatrix.numCols(); double[][] res = new double[r1 + r2][c]; fillMatrix(res, 0, 0, equalMatrix.getArrayCopy2D()); fillMatrix(res, r1, 0, inequalMatrix.getArrayCopy2D()); return new DenseMatrix(res); } public static DenseVector generateMaxVector(DenseVector x, double value) { double[] data = x.getData(); int length = data.length; for (int i = 0; i < length; i++) { data[i] = Math.max(data[i], value); } return x; } public static DenseVector copyVec(DenseVector vector, int start, int length) { double[] res = new double[length]; System.arraycopy(vector.getData(), start, res, 0, length); return new DenseVector(res); } public static Tuple2 <Double, Integer> findMin(DenseVector vector, int start, int length) { double min = Double.MAX_VALUE; int index = 0; for (int i = start; i < (start + length); i++) { if (vector.get(i) < min) { min = vector.get(i); index = i; } } return Tuple2.of(min, index - start); } }
1cf17996afe183a0a5ac940ef6677aefbba684f7
fb1abf3a056cb7c2d398e747d4da527ced3456dc
/src/test/java/com/yeren/common/service/TestUserService.java
2fd6ea9f4dd60dce16c94c81aed451a5c1b727af
[]
no_license
yeren108/common
59e599f6b0a0e506eccb603bf18001347b1ed97b
745caedccc2e4878cdb741ea32eb0bd2d06dda5b
refs/heads/master
2021-01-11T20:53:37.513415
2017-12-06T08:57:47
2017-12-06T08:57:47
79,205,976
0
0
null
null
null
null
UTF-8
Java
false
false
1,583
java
package com.yeren.common.service; import java.lang.reflect.InvocationTargetException; import java.util.List; 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; import com.yeren.common.bo.User; import com.yeren.common.dto.UserDto; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext-test.xml") public class TestUserService { @Autowired UserService userService; // @Test public void testSave() { User user = new User(); user.setMobile("182175543888"); userService.save(user); } // @Test public void TestDelete() { User user = new User(); user.setId(2); userService.delete(user); } // @Test public void TestUpdate() { User user = new User(); user.setId(3); user.setNickname("yeren108"); userService.update(user); } // @Test public void TestGetUserById() { User user = userService.find(3); System.out.println(user.getMobile()); } // @Test public void TestFindUserByUsername() throws IllegalAccessException, InvocationTargetException { UserDto user = null; List<UserDto> listUser = userService.findUserByUsername("yeren"); user = listUser.get(0); System.out.println(user.getMobile()); } // @Test public void TestGetUserNum() { long userNum = userService.getUserNum(); System.out.println(userNum); } @Test public void TestSuccess() { System.out.println("success test"); } }
db8b41f936dca7bf5f80ba35c58e79182e2f380c
426040f19e4ab0abb5977e8557451cfd94bf6c2d
/apks/aldi/src/com/google/android/gms/internal/auth/zzs.java
9af8bfd9eb83ddf156923d1af32e603ab711368d
[]
no_license
kmille/android-pwning
0e340965f4c27dfc9df6ecadddd124448e6cec65
e82b96d484e618fe8b2c3f8ff663e74f793541b8
refs/heads/master
2020-05-09T17:22:54.876992
2020-04-06T18:04:16
2020-04-06T18:04:16
181,300,145
0
0
null
null
null
null
UTF-8
Java
false
false
1,343
java
package com.google.android.gms.internal.auth; import android.os.RemoteException; import com.google.android.gms.auth.api.accounttransfer.DeviceMetaData; import com.google.android.gms.auth.api.accounttransfer.zzl; import com.google.android.gms.auth.api.accounttransfer.zzt; import com.google.android.gms.common.api.Status; public class zzs extends zzy { public void onFailure(Status paramStatus) { throw new UnsupportedOperationException(); } public void zza(DeviceMetaData paramDeviceMetaData) { throw new UnsupportedOperationException(); } public final void zza(Status paramStatus, zzl paramzzl) { throw new UnsupportedOperationException(); } public final void zza(Status paramStatus, zzt paramzzt) { throw new UnsupportedOperationException(); } public void zza(byte[] paramArrayOfByte) { throw new UnsupportedOperationException(); } public final void zzb(Status paramStatus) throws RemoteException { throw new UnsupportedOperationException(); } public void zzd() { throw new UnsupportedOperationException(); } } /* Location: /home/kmille/projects/android-pwning/apks/aldi/ALDI TALK_v6.2.1_apkpure.com-dex2jar.jar!/com/google/android/gms/internal/auth/zzs.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
3c9832f22283991a42aa012cc50b79028cae1afb
7fab394410f0ec219e8cb0472422274badff2b2d
/src/main/java/studio/lineage2/cms/repository/BlockRepository.java
e1cbc384ff3dead92c41228ba681733f177d2b3c
[]
no_license
Rozhek/L2CMS
8c85375e5b70224b542cbca1ae6268916f676521
5412142845c2cf2546eed8e312f72b6bb05a63b0
refs/heads/master
2022-12-04T04:55:01.892466
2022-11-23T07:51:42
2022-11-23T07:51:42
186,691,835
0
0
null
null
null
null
UTF-8
Java
false
false
314
java
package studio.lineage2.cms.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import studio.lineage2.cms.model.Block; /** Created by iRock 29.10.2015 */ @Repository public interface BlockRepository extends JpaRepository<Block, Long> {}
fbfc758107f637a47f89a7c9cb7dfe248429cc5d
d4fe3b691ce830b9d8b4068f4cbf3dc0e2e42010
/Geometry1/src/test/java/com/epam/geometry/director/DataDirectorTest.java
c5a68e5a471920576e7cad1be55a24492964d255
[]
no_license
mvladmoss/EpamTasks
6644a51ef9b6287589c2e4049554e45cabfc8b35
f3fe371addb3db9c7ed5c5a30ca566f2c376dff7
refs/heads/master
2020-04-09T04:43:10.493667
2018-12-02T09:52:52
2018-12-02T09:52:52
160,033,700
0
0
null
null
null
null
UTF-8
Java
false
false
2,824
java
package com.epam.geometry.director; import com.epam.geometry.entity.Point3D; import com.epam.geometry.entity.Tetrahedron; import com.epam.geometry.parsers.DataParser; import com.epam.geometry.reader.FileReader; import com.epam.geometry.validator.DataValidator; import com.epam.geometry.validator.TetrahedronExistValidator; import org.junit.jupiter.api.Assertions; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.util.Arrays; import java.util.List; public class DataDirectorTest { private static final List<Tetrahedron> TETRAHEDRON_LIST_FIRST = Arrays.asList( new Tetrahedron( new Point3D(1, 2, -2), new Point3D(9, 2, -2), new Point3D(5, (2 + 4 * Math.sqrt(3)), -2), new Point3D(5, 2 + 4 / Math.sqrt(3), -2 + 8 * Math.sqrt((double) 2 / 3))), new Tetrahedron( new Point3D( (Math.sqrt(3)/3),0,(double) 2/3*Math.sqrt(6)), new Point3D(0,-1,0), new Point3D(Math.sqrt(3),0,0), new Point3D(0,1,0))); private static final List<Tetrahedron> TETRAHEDRON_LIST_SECOND = Arrays.asList( new Tetrahedron( new Point3D( (Math.sqrt(3)/3),0,(double) 2/3*Math.sqrt(6)), new Point3D(0,-1,0), new Point3D(Math.sqrt(3),0,0), new Point3D(0,1,0))); private static final List<Tetrahedron> TETRAHEDRON_LIST_THIRD = Arrays.asList( new Tetrahedron( new Point3D(1, 2, -2), new Point3D(9, 2, -2), new Point3D(5, (2 + 4 * Math.sqrt(3)), -2), new Point3D(5, 2 + 4 / Math.sqrt(3), -2 + 8 * Math.sqrt((double) 2 / 3)))); @DataProvider(name = "dataForTetrahedronCreation") public Object[][] dataForTetrahedrons() { return new Object[][]{ {TETRAHEDRON_LIST_FIRST, "src/main/resources/data_files/correctData1.txt"}, {TETRAHEDRON_LIST_SECOND, "src/main/resources/data_files/correctData2.txt"}, {TETRAHEDRON_LIST_THIRD, "src/main/resources/data_files/incorrectData1.txt"}, }; } @Test(dataProvider ="dataForTetrahedronCreation" ) public void shouldCreateTetradedronFromFile(List<Tetrahedron> expectedTetrahedronList, String PATH){ //given DataDirector creator = new DataDirector(new FileReader(), new DataParser(new DataValidator()), new TetrahedronExistValidator()); //when List<Tetrahedron> actualTetrahedronList = creator.getTetrahedronFromFile(PATH); //then Assertions.assertEquals(expectedTetrahedronList,actualTetrahedronList); } }
174f80dda93a734bb89d716dac22f27c118146fd
9da86feda3edb45e23eb02da09877f798c61682a
/service/service_acl/src/main/java/com/zjx/aclservice/service/impl/RoleServiceImpl.java
9fbc9f49fadd89e0ad63673c1fbb205f466d8318
[]
no_license
476554858/acl_parent
2da6e2e30aac9738f8be40a6f61770943fb5e6d4
9cf53da9c654730615b7daa13ce6c746f8236536
refs/heads/master
2023-03-20T03:50:18.694178
2021-03-06T08:14:00
2021-03-06T08:14:00
345,040,473
0
0
null
null
null
null
UTF-8
Java
false
false
3,058
java
package com.zjx.aclservice.service.impl; import com.zjx.aclservice.entity.Role; import com.zjx.aclservice.entity.UserRole; import com.zjx.aclservice.mapper.RoleMapper; import com.zjx.aclservice.service.RoleService; import com.zjx.aclservice.service.UserRoleService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * <p> * 服务实现类 * </p> * * @author testjava * @since 2020-01-12 */ @Service public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService { @Autowired private UserRoleService userRoleService; //根据用户获取角色数据 @Override public Map<String, Object> findRoleByUserId(String userId) { //查询所有的角色 List<Role> allRolesList =baseMapper.selectList(null); //根据用户id,查询用户拥有的角色id List<UserRole> existUserRoleList = userRoleService.list(new QueryWrapper<UserRole>().eq("user_id", userId).select("role_id")); List<String> existRoleList = existUserRoleList.stream().map(c->c.getRoleId()).collect(Collectors.toList()); //对角色进行分类 List<Role> assignRoles = new ArrayList<Role>(); for (Role role : allRolesList) { //已分配 if(existRoleList.contains(role.getId())) { assignRoles.add(role); } } Map<String, Object> roleMap = new HashMap<>(); roleMap.put("assignRoles", assignRoles); roleMap.put("allRolesList", allRolesList); return roleMap; } //根据用户分配角色 @Override public void saveUserRoleRealtionShip(String userId, String[] roleIds) { userRoleService.remove(new QueryWrapper<UserRole>().eq("user_id", userId)); List<UserRole> userRoleList = new ArrayList<>(); for(String roleId : roleIds) { if(StringUtils.isEmpty(roleId)) continue; UserRole userRole = new UserRole(); userRole.setUserId(userId); userRole.setRoleId(roleId); userRoleList.add(userRole); } userRoleService.saveBatch(userRoleList); } @Override public List<Role> selectRoleByUserId(String id) { //根据用户id拥有的角色id List<UserRole> userRoleList = userRoleService.list(new QueryWrapper<UserRole>().eq("user_id", id).select("role_id")); List<String> roleIdList = userRoleList.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); List<Role> roleList = new ArrayList<>(); if(roleIdList.size() > 0) { roleList = baseMapper.selectBatchIds(roleIdList); } return roleList; } }
[ "zjx93021947220" ]
zjx93021947220
783ca7ff80d7783c6e0c7330efa70f4a3774c8fb
1a3676dfdc5f57137b71d71de46b724359824eca
/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/LZWDecoder.java
51fa49f7c664272ae487a8bea3455d719d3d73c8
[ "BSD-3-Clause" ]
permissive
pugang/TwelveMonkeys
b56f7be38eeedbc6f82017eb019a0adc7ae72056
94144954e680a019f1125db7b08494e73751c1a9
refs/heads/master
2020-12-30T22:44:10.792703
2014-11-29T16:35:17
2014-11-29T16:35:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,923
java
/* * Copyright (c) 2012, Harald Kuhr * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name "TwelveMonkeys" nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.twelvemonkeys.imageio.plugins.tiff; import com.twelvemonkeys.io.enc.DecodeException; import com.twelvemonkeys.io.enc.Decoder; import java.io.IOException; import java.io.InputStream; import java.lang.String; import java.nio.ByteBuffer; /** * Lempel–Ziv–Welch (LZW) decompression. LZW is a universal loss-less data compression algorithm * created by Abraham Lempel, Jacob Ziv, and Terry Welch. * Inspired by libTiff's LZW decompression. * * @author <a href="mailto:[email protected]">Harald Kuhr</a> * @author last modified by $Author: haraldk$ * @version $Id: LZWDecoder.java,v 1.0 08.05.12 21:11 haraldk Exp$ * @see <a href="http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch">LZW (Wikipedia)</a> */ abstract class LZWDecoder implements Decoder { /** Clear: Re-initialize tables. */ static final int CLEAR_CODE = 256; /** End of Information. */ static final int EOI_CODE = 257; private static final int MIN_BITS = 9; private static final int MAX_BITS = 12; private static final int TABLE_SIZE = 1 << MAX_BITS; private final boolean compatibilityMode; private final LZWString[] table; private int tableLength; int bitsPerCode; private int oldCode = CLEAR_CODE; private int maxCode; int bitMask; private int maxString; boolean eofReached; int nextData; int nextBits; protected LZWDecoder(final boolean compatibilityMode) { this.compatibilityMode = compatibilityMode; table = new LZWString[compatibilityMode ? TABLE_SIZE + 1024 : TABLE_SIZE]; // libTiff adds 1024 "for compatibility"... // First 258 entries of table is always fixed for (int i = 0; i < 256; i++) { table[i] = new LZWString((byte) i); } init(); } private static int bitmaskFor(final int bits) { return (1 << bits) - 1; } private void init() { tableLength = 258; bitsPerCode = MIN_BITS; bitMask = bitmaskFor(bitsPerCode); maxCode = maxCode(); maxString = 1; } public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException { // Adapted from the pseudo-code example found in the TIFF 6.0 Specification, 1992. // See Section 13: "LZW Compression"/"LZW Decoding", page 61+ int code; while ((code = getNextCode(stream)) != EOI_CODE) { if (code == CLEAR_CODE) { init(); code = getNextCode(stream); if (code == EOI_CODE) { break; } table[code].writeTo(buffer); } else { if (table[oldCode] == null) { System.err.println("tableLength: " + tableLength); System.err.println("oldCode: " + oldCode); } if (isInTable(code)) { table[code].writeTo(buffer); addStringToTable(table[oldCode].concatenate(table[code].firstChar)); } else { LZWString outString = table[oldCode].concatenate(table[oldCode].firstChar); outString.writeTo(buffer); addStringToTable(outString); } } oldCode = code; if (buffer.remaining() < maxString + 1) { // Buffer full, stop decoding for now break; } } return buffer.position(); } private void addStringToTable(final LZWString string) throws IOException { table[tableLength++] = string; if (tableLength > maxCode) { bitsPerCode++; if (bitsPerCode > MAX_BITS) { if (compatibilityMode) { bitsPerCode--; } else { throw new DecodeException(String.format("TIFF LZW with more than %d bits per code encountered (table overflow)", MAX_BITS)); } } bitMask = bitmaskFor(bitsPerCode); maxCode = maxCode(); } if (string.length > maxString) { maxString = string.length; } } protected abstract int maxCode(); private boolean isInTable(int code) { return code < tableLength; } protected abstract int getNextCode(final InputStream stream) throws IOException; static boolean isOldBitReversedStream(final InputStream stream) throws IOException { stream.mark(2); try { int one = stream.read(); int two = stream.read(); return one == 0 && (two & 0x1) == 1; // => (reversed) 1 00000000 == 256 (CLEAR_CODE) } finally { stream.reset(); } } public static LZWDecoder create(boolean oldBitReversedStream) { return oldBitReversedStream ? new LZWCompatibilityDecoder() : new LZWSpecDecoder(); } private static final class LZWSpecDecoder extends LZWDecoder { protected LZWSpecDecoder() { super(false); } @Override protected int maxCode() { return bitMask - 1; } protected final int getNextCode(final InputStream stream) throws IOException { if (eofReached) { return EOI_CODE; } int code; int read = stream.read(); if (read < 0) { eofReached = true; return EOI_CODE; } nextData = (nextData << 8) | read; nextBits += 8; if (nextBits < bitsPerCode) { read = stream.read(); if (read < 0) { eofReached = true; return EOI_CODE; } nextData = (nextData << 8) | read; nextBits += 8; } code = ((nextData >> (nextBits - bitsPerCode)) & bitMask); nextBits -= bitsPerCode; return code; } } private static final class LZWCompatibilityDecoder extends LZWDecoder { // NOTE: This is a spec violation. However, libTiff reads such files. // TIFF 6.0 Specification, Section 13: "LZW Compression"/"The Algorithm", page 61, says: // "LZW compression codes are stored into bytes in high-to-low-order fashion, i.e., FillOrder // is assumed to be 1. The compressed codes are written as bytes (not words) so that the // compressed data will be identical whether it is an ‘II’ or ‘MM’ file." protected LZWCompatibilityDecoder() { super(true); } @Override protected int maxCode() { return bitMask; } protected final int getNextCode(final InputStream stream) throws IOException { if (eofReached) { return EOI_CODE; } int code; int read = stream.read(); if (read < 0) { eofReached = true; return EOI_CODE; } nextData |= read << nextBits; nextBits += 8; if (nextBits < bitsPerCode) { read = stream.read(); if (read < 0) { eofReached = true; return EOI_CODE; } nextData |= read << nextBits; nextBits += 8; } code = (nextData & bitMask); nextData >>= bitsPerCode; nextBits -= bitsPerCode; return code; } } static final class LZWString { final LZWString previous; final int length; final byte value; final byte firstChar; // Copied forward for fast access public LZWString(final byte code) { this(code, code, 1, null); } private LZWString(final byte value, final byte firstChar, final int length, final LZWString previous) { this.value = value; this.firstChar = firstChar; this.length = length; this.previous = previous; } public final LZWString concatenate(final byte firstChar) { return new LZWString(firstChar, this.firstChar, length + 1, this); } public final void writeTo(final ByteBuffer buffer) { if (length == 0) { return; } if (length == 1) { buffer.put(value); } else { LZWString e = this; final int offset = buffer.position(); for (int i = length - 1; i >= 0; i--) { buffer.put(offset + i, e.value); e = e.previous; } buffer.position(offset + length); } } @Override public String toString() { StringBuilder builder = new StringBuilder("ZLWString["); int offset = builder.length(); LZWString e = this; for (int i = length - 1; i >= 0; i--) { builder.insert(offset, String.format("%2x", e.value)); e = e.previous; } builder.append("]"); return builder.toString(); } @Override public boolean equals(final Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } LZWString string = (LZWString) other; return firstChar == string.firstChar && length == string.length && value == string.value && // !(previous != null ? !previous.equals(string.previous) : string.previous != null); previous == string.previous; } @Override public int hashCode() { int result = previous != null ? previous.hashCode() : 0; result = 31 * result + length; result = 31 * result + (int) value; result = 31 * result + (int) firstChar; return result; } } }
a0c83252e902ae76810b45206aefc120a76e123f
00835cbf6d616800246112bd3d2602c0436b1ead
/spring-boot-web1/src/main/java/com/example/demo/SpringBootWeb1Application.java
1d9cec8d6fe3d9ec417744526c9bd52b5ae00e64
[]
no_license
influence160/spring-cerification-samples-2
ba62a4658464191d80464dd365368cc886827d30
2d1fa1d7f9c2475433975a42f28bc3f4f478b835
refs/heads/main
2023-01-12T13:36:50.456761
2020-11-21T14:18:28
2020-11-21T14:18:28
314,812,311
0
0
null
null
null
null
UTF-8
Java
false
false
636
java
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.UrlBasedViewResolver; @SpringBootApplication public class SpringBootWeb1Application { public static void main(String[] args) { SpringApplication.run(SpringBootWeb1Application.class, args); } @Bean public UrlBasedViewResolver urlBasedViewResolver() { return new InternalResourceViewResolver("", ".jsp"); } }
6e2a00888292df88282382d2a94bc764cd7abbe4
a11b8c2d2c482879ee49a528cfa95782227fe8d7
/approvaltests/src/main/java/org/approvaltests/scrubbers/NoOpScrubber.java
4240fe9e2dcad7776cb6f7ba3077ca5120382d77
[ "Apache-2.0" ]
permissive
approvals/ApprovalTests.Java
dfa30be480d3310dc0bdb9c28d9c836d998b09fb
58f1756ab03a6de0796da66c122fe6b5f40c8346
refs/heads/master
2023-08-04T15:21:56.401052
2023-08-01T20:37:58
2023-08-01T20:42:10
8,533,893
270
78
Apache-2.0
2023-09-07T20:42:09
2013-03-03T08:44:41
Java
UTF-8
Java
false
false
265
java
package org.approvaltests.scrubbers; import org.approvaltests.core.Scrubber; public class NoOpScrubber implements Scrubber { public static final Scrubber INSTANCE = new NoOpScrubber(); @Override public String scrub(String input) { return input; } }
2f41d406933c3c9debe9ac40db938131bd9f0b16
180e78725121de49801e34de358c32cf7148b0a2
/dataset/protocol1/commons-lang/testing/910/GmtTimeZone.java
dfe3e3d126b08b5ebb0ff2b44d28f9ddeff66eb1
[]
no_license
ASSERT-KTH/synthetic-checkstyle-error-dataset
40e8d1e0a7ebe7f7711def96a390891a6922f7bd
40c057e1669584bfc6fecf789b5b2854660222f3
refs/heads/master
2023-03-18T12:50:55.410343
2019-01-25T09:54:39
2019-01-25T09:54:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,192
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.lang3.time; import java.util.Date; import java.util.TimeZone; /** * Custom timezone that contains offset from GMT. * * @since 3.7 */ class GmtTimeZone extends TimeZone { private static final int MILLISECONDS_PER_MINUTE = 60 * 1000; private static final int MINUTES_PER_HOUR = 60; private static final int HOURS_PER_DAY = 24; // Serializable! static final long serialVersionUID = 1L; private final int offset; private final String zoneId; GmtTimeZone(final boolean negate, final int hours, final int minutes) { if (hours >= HOURS_PER_DAY) { throw new IllegalArgumentException(hours + " hours out of range"); } if (minutes >= MINUTES_PER_HOUR) { throw new IllegalArgumentException(minutes + " minutes out of range"); } final int milliseconds = (minutes + (hours * MINUTES_PER_HOUR)) * MILLISECONDS_PER_MINUTE; offset = negate ? -milliseconds : milliseconds; zoneId = twoDigits( twoDigits(new StringBuilder(9).append("GMT").append(negate ? '-' : '+'), hours) .append(':'), minutes).toString(); } private static StringBuilder twoDigits(final StringBuilder sb, final int n) { return sb.append((char) ('0' + (n / 10))).append((char) ('0' + (n % 10))); } @Override public int getOffset(final int era, final int year, final int month, final int day, final int dayOfWeek, final int milliseconds) { return offset; } @Override public void setRawOffset(final int offsetMillis) { throw new UnsupportedOperationException(); } @Override public int getRawOffset() { return offset; } @Override public String getID() { return zoneId; } @Override public boolean useDaylightTime() { return false; } @Override public boolean inDaylightTime(final Date date) { return false; } @Override public String toString() { return "[GmtTimeZone id=\"" + zoneId + "\",offset=" + offset + ']'; } @Override public int hashCode() { return offset; } @Override public boolean equals(final Object other) { if (!(other instanceof GmtTimeZone)) { return false; } return zoneId == ((GmtTimeZone) other).zoneId; } }
b864762267418b32e211b2dc1bad65046575a039
51fc3fb0d1e77e19e59b9fec409a14bf80d006cb
/05.JavaOOPBasic/Polymorphism/src/wild_farm/foods/Meat.java
c1916c9184fc99c201658b62887a86daa7633566
[ "MIT" ]
permissive
AngelMilovski/SoftUniLearning
88af910532492bed75c26967217896d5220cdea3
3628168548739aa4e1f60578eb4413e8ca799fe4
refs/heads/master
2022-11-15T16:23:19.531277
2019-11-11T11:30:52
2019-11-11T11:30:52
120,227,145
0
0
MIT
2022-11-10T01:49:59
2018-02-04T21:58:47
Java
UTF-8
Java
false
false
166
java
package wild_farm.foods; import wild_farm.abstract_classes.Food; public class Meat extends Food { public Meat(int quantity) { super(quantity); } }
756382407f071302456728877b565f965a259ccc
9409b07c210556b2d18e3c79d31dd8fb3069d118
/day09_IO/demo08_Writer.java
f1345c4dbc0ce3e4703c103ebb2dbc6a101a3042
[]
no_license
victor-lsn/java_review
ce8941bd4f5f383f7c16507f194fead67d8dbac8
0e0e33fb28836f3257562eb4c5213b1d435142ca
refs/heads/master
2022-11-17T16:50:08.244795
2020-07-18T09:56:46
2020-07-18T09:56:46
279,094,994
1
0
null
null
null
null
UTF-8
Java
false
false
504
java
package day09_IO; import java.io.FileWriter; import java.io.IOException; /** * @author Victor * @version 1.0 * @date 20-7-13 下午10:10 */ public class demo08_Writer { public static void main(String[] args) throws IOException { FileWriter fileWriter = new FileWriter("src/day09_IO/b.txt", true); fileWriter.write("hello\n");//把数据写入到内存缓冲区中 fileWriter.flush();//把内存缓冲区中的数据刷新到文件中 fileWriter.close(); } }
f340bbe39ded805c5bab12292dd156ed909310f5
01fac89c787f33e653e668bed07e3151f29af3ee
/src/test/java/com/qa/mobile/tests/Scenario8.java
5df258362d934ee339fb560432f2839144302ac0
[]
no_license
akashnv/NagarroAssignment-VAkashNarayan
b2abba8c89956da4f0d5950af73feea65446b24e
0e1a1c7a9297e3704bade8196ef2b87df4814a72
refs/heads/master
2023-04-29T23:21:40.974691
2021-05-15T15:00:27
2021-05-15T15:00:27
364,564,680
0
1
null
null
null
null
UTF-8
Java
false
false
849
java
package com.qa.mobile.tests; import java.net.MalformedURLException; import org.openqa.selenium.By; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.qa.base.TestBase; import io.appium.java_client.MobileElement; public class Scenario8 extends TestBase{ @BeforeTest public void initialise() throws MalformedURLException { System.out.println("Running scenario-8"); init(); } @Test public void clickOnExceptionBtnAndVerifyHomescreenTitle() throws MalformedURLException { MobileElement eButton = driver.findElement(By.id("io.selendroid.testapp:id/exceptionTestButton")); eButton.click(); driver.closeApp(); initialise(); MobileElement title = driver.findElement(By.id("android:id/title")); Assert.assertEquals(title.getText(), "selendroid-test-app"); } }
99138f8b28ce2f2009536ab919a421575b75aa43
13ae3a0d2e51479857157186d31f9dc033b85e69
/getting-started/src/main/java/org/acme/NLPUtils.java
3d60f4caad36f1aa1c1f7111091c52f8e383a230
[]
no_license
diogodanielsoaresferreira/apache_camel_demo
f0b3e3a169bdce8f2e7fd651d63dd10fbb6761b8
6f62339d6867be9fc1d7cfaaa4071314e4ca9876
refs/heads/main
2023-05-28T12:02:06.286987
2021-06-11T22:19:47
2021-06-11T22:19:47
376,153,343
0
0
null
null
null
null
UTF-8
Java
false
false
293
java
package org.acme; public class NLPUtils { public static UserMessages createUserMessages(final CombinedUserMessage event) { return UserMessages.builder() .emitter(event.getEmitter()) .text(String.join(". ", event.getText())) .build(); } }
46cd8cb0ad35e372313b30aedc3f8914589a1e21
17778f171cb046847afec9d947e447b87c9e8eaf
/src/main/java/com/atex/milan/video/processor/BaseGuiceProcessor.java
06b2980e32c2bfc4ce7225f484e55551234e6fd6
[]
no_license
themnd/atex-video
a6fb1fe75fe83a6820387111b7330dac8cbed099
8db83d2ca1382a70e0a1a917c83e7cf7cc888a8a
refs/heads/master
2016-09-15T11:18:00.466715
2016-03-03T16:01:26
2016-03-03T16:01:26
18,644,999
0
0
null
null
null
null
UTF-8
Java
false
false
955
java
package com.atex.milan.video.processor; import java.util.Map; import java.util.logging.Logger; import org.apache.camel.Message; import org.apache.camel.Processor; import com.atex.milan.video.util.InjectorUtils; /** * Base guice processor * * @author mnova */ public abstract class BaseGuiceProcessor implements Processor { private static final Logger logger = Logger.getLogger(BaseGuiceProcessor.class.getName()); public BaseGuiceProcessor() { final InjectorUtils injectorUtils = InjectorUtils.getInstance(); injectorUtils.injectMembers(this); } protected <T extends Object> T getMessageProperty(final Message msg, final String name) { final Map<String, Object> headers = msg.getHeaders(); return (T) headers.get(name); } protected void setMessageProperty(final Message msg, final String name, final Object value) { final Map<String, Object> headers = msg.getHeaders(); headers.put(name, value); } }
890cbda0916036214ec1c89164d2be1c5dd84358
b59ea8f389f1cd42385e5b319084f69171502e96
/app/src/main/java/com/example/userlist/Adapter/CharacterAdapter.java
d4fb9191d4a5c6d3f3d34821718a76861a1b3a4e
[]
no_license
alexferlozano/AppDragonBall
49a4c9d44274628ac81a8c24fd6126093ff4fa90
5aa4022b63496ecb56bfc8ac83ffa8aef1069608
refs/heads/main
2023-03-21T02:33:04.138660
2021-03-02T04:15:21
2021-03-02T04:15:21
343,292,332
0
0
null
null
null
null
UTF-8
Java
false
false
1,743
java
package com.example.userlist.Adapter; import android.view.LayoutInflater; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.userlist.MainActivity; import com.example.userlist.databinding.ListCharactersBinding; import java.util.List; public class CharacterAdapter extends RecyclerView.Adapter<CharacterAdapter.ViewHolder> { private final List<MainActivity.Character> charactersList; public CharacterAdapter (List<MainActivity.Character> charactersList) { this.charactersList=charactersList; } @NonNull @Override public CharacterAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { final ListCharactersBinding listCharacterBinding = ListCharactersBinding.inflate(LayoutInflater.from(parent.getContext()), parent,false); return new CharacterAdapter.ViewHolder(listCharacterBinding); } @Override public void onBindViewHolder(final CharacterAdapter.ViewHolder holder, final int position) { final MainActivity.Character character = this.charactersList.get(position); holder.bind(character); } @Override public int getItemCount() { return charactersList.size(); } public class ViewHolder extends RecyclerView.ViewHolder { private final ListCharactersBinding listCharactersBinding; public ViewHolder(@NonNull ListCharactersBinding listView) { super(listView.getRoot()); this.listCharactersBinding=listView; } private void bind (MainActivity.Character character){ this.listCharactersBinding.setCharacter(character); } } }
aee114acfdabaf466a711edca92f5f759e8c3434
b5bd581d4a264e34041473c64c1fa2d248d858bc
/src/spms/bind/DataBinding.java
7fc0225da232b05714d0c65266ae3f0cffc0b994
[]
no_license
woonhyeong/guest-book
9ba3d2758b1a61ba04acd6ab29ab88905e1db4f4
669275621ba7f035be1e45036ee8b7a02c92feb7
refs/heads/develop
2020-11-24T05:54:26.744216
2020-01-12T04:54:03
2020-01-12T04:54:03
227,994,699
0
0
null
2019-12-31T14:57:42
2019-12-14T09:04:35
Java
UTF-8
Java
false
false
176
java
package spms.bind; public interface DataBinding { Object[] getDataBinders(); // new Object[]{ "데이터이름", 데이터타입, "데이터이름", 데이터타입, ...} }
98b7e3f00305f7cde83391caefb96cf1fdb31653
a0e31c35a7052c8384f72c73e5c3df389131ad31
/src/main/java/com/example/secondKill/redis/OrderKey.java
e238926820f7ae5a2795dff73c1b89fc45ab3e4a
[]
no_license
zhoujiahao123/Miaosha
aea29a8430d00918a1481957f1023782c59dfc44
39811c24f9cdc7b8a62ad1675ab9a81c6cc519e2
refs/heads/master
2023-01-19T16:29:21.558051
2020-12-02T13:32:11
2020-12-02T13:32:11
309,613,365
1
0
null
null
null
null
UTF-8
Java
false
false
325
java
package com.example.secondKill.redis; public class OrderKey extends BasePrefix { public OrderKey(int expireSeconds, String prefix) { super(expireSeconds, prefix); } public OrderKey(String prefix) { super(prefix); } public static OrderKey getMiaoshaOrderByUidGid = new OrderKey("moug"); }
d42eee93fde1cb1fead5d9b7821328405cb15809
6732796da80d70456091ec1c3cc1ee9748b97cc5
/TS/jackson-databind/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualSerialization.java
90d4c00dd7bb6073393f6e8e02e17a7fed787564
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
nharrand/argo
f88c13a1fb759f44fab6dbc6614de3c0c0554549
c09fccba668e222a1b349b95d34177b5964e78e1
refs/heads/main
2023-08-13T10:39:48.526694
2021-10-13T09:40:19
2021-10-13T09:40:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,586
java
package com.fasterxml.jackson.databind.contextual; import java.io.IOException; import java.lang.annotation.*; import java.util.*; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.ContextualSerializer; import com.fasterxml.jackson.databind.ser.ResolvableSerializer; /** * Test cases to verify that it is possible to define serializers * that can use contextual information (like field/method * annotations) for configuration. */ public class TestContextualSerialization extends BaseMapTest { // NOTE: important; MUST be considered a 'Jackson' annotation to be seen // (or recognized otherwise via AnnotationIntrospect.isHandled()) @Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface Prefix { public String value(); } static class ContextualBean { protected final String _value; public ContextualBean(String s) { _value = s; } @Prefix("see:") public String getValue() { return _value; } } // For [JACKSON-569] static class AnnotatedContextualBean { @Prefix("prefix->") @JsonSerialize(using=AnnotatedContextualSerializer.class) protected final String value; public AnnotatedContextualBean(String s) { value = s; } } @Prefix("wrappedBean:") static class ContextualBeanWrapper { @Prefix("wrapped:") public ContextualBean wrapped; public ContextualBeanWrapper(String s) { wrapped = new ContextualBean(s); } } static class ContextualArrayBean { @Prefix("array->") public final String[] beans; public ContextualArrayBean(String... strings) { beans = strings; } } static class ContextualArrayElementBean { @Prefix("elem->") @JsonSerialize(contentUsing=AnnotatedContextualSerializer.class) public final String[] beans; public ContextualArrayElementBean(String... strings) { beans = strings; } } static class ContextualListBean { @Prefix("list->") public final List<String> beans = new ArrayList<String>(); public ContextualListBean(String... strings) { for (String string : strings) { beans.add(string); } } } static class ContextualMapBean { @Prefix("map->") public final Map<String, String> beans = new HashMap<String, String>(); } /** * Another bean that has class annotations that should be visible for * contextualizer, too */ @Prefix("Voila->") static class BeanWithClassConfig { public String value; public BeanWithClassConfig(String v) { value = v; } } /** * Annotation-based contextual serializer that simply prepends piece of text. */ static class AnnotatedContextualSerializer extends JsonSerializer<String> implements ContextualSerializer { protected final String _prefix; public AnnotatedContextualSerializer() { this(""); } public AnnotatedContextualSerializer(String p) { _prefix = p; } @Override public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(_prefix + value); } @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { String prefix = "UNKNOWN"; Prefix ann = null; if (property != null) { ann = property.getAnnotation(Prefix.class); if (ann == null) { ann = property.getContextAnnotation(Prefix.class); } } if (ann != null) { prefix = ann.value(); } return new AnnotatedContextualSerializer(prefix); } } static class ContextualAndResolvable extends JsonSerializer<String> implements ContextualSerializer, ResolvableSerializer { protected int isContextual; protected int isResolved; public ContextualAndResolvable() { this(0, 0); } public ContextualAndResolvable(int resolved, int contextual) { isContextual = contextual; isResolved = resolved; } @Override public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString("contextual="+isContextual+",resolved="+isResolved); } @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { return new ContextualAndResolvable(isResolved, isContextual+1); } @Override public void resolve(SerializerProvider provider) { ++isResolved; } } static class AccumulatingContextual extends JsonSerializer<String> implements ContextualSerializer { protected String desc; public AccumulatingContextual() { this(""); } public AccumulatingContextual(String newDesc) { desc = newDesc; } @Override public void serialize(String value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeString(desc+"/"+value); } @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property == null) { return new AccumulatingContextual(desc+"/ROOT"); } return new AccumulatingContextual(desc+"/"+property.getName()); } } /* /********************************************************** /* Unit tests /********************************************************** */ // Test to verify that contextual serializer can make use of property // (method, field) annotations. public void testMethodAnnotations() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); //ARGO_PLACEBO assertEquals("{\"value\":\"see:foobar\"}", mapper.writeValueAsString(new ContextualBean("foobar"))); } // Test to verify that contextual serializer can also use annotations // for enclosing class. public void testClassAnnotations() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); //ARGO_PLACEBO assertEquals("{\"value\":\"Voila->xyz\"}", mapper.writeValueAsString(new BeanWithClassConfig("xyz"))); } public void testWrappedBean() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); //ARGO_PLACEBO assertEquals("{\"wrapped\":{\"value\":\"see:xyz\"}}", mapper.writeValueAsString(new ContextualBeanWrapper("xyz"))); } // Serializer should get passed property context even if contained in an array. public void testMethodAnnotationInArray() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); ContextualArrayBean beans = new ContextualArrayBean("123"); //ARGO_PLACEBO assertEquals("{\"beans\":[\"array->123\"]}", mapper.writeValueAsString(beans)); } // Serializer should get passed property context even if contained in a Collection. public void testMethodAnnotationInList() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); ContextualListBean beans = new ContextualListBean("abc"); //ARGO_PLACEBO assertEquals("{\"beans\":[\"list->abc\"]}", mapper.writeValueAsString(beans)); } // Serializer should get passed property context even if contained in a Collection. public void testMethodAnnotationInMap() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new AnnotatedContextualSerializer()); mapper.registerModule(module); ContextualMapBean map = new ContextualMapBean(); map.beans.put("first", "In Map"); //ARGO_PLACEBO assertEquals("{\"beans\":{\"first\":\"map->In Map\"}}", mapper.writeValueAsString(map)); } public void testContextualViaAnnotation() throws Exception { ObjectMapper mapper = new ObjectMapper(); AnnotatedContextualBean bean = new AnnotatedContextualBean("abc"); //ARGO_PLACEBO assertEquals("{\"value\":\"prefix->abc\"}", mapper.writeValueAsString(bean)); } public void testResolveOnContextual() throws Exception { SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addSerializer(String.class, new ContextualAndResolvable()); ObjectMapper mapper = jsonMapperBuilder() .addModule(module) .build(); //ARGO_PLACEBO assertEquals(quote("contextual=1,resolved=1"), mapper.writeValueAsString("abc")); // also: should NOT be called again //ARGO_PLACEBO assertEquals(quote("contextual=1,resolved=1"), mapper.writeValueAsString("foo")); } public void testContextualArrayElement() throws Exception { ObjectMapper mapper = newJsonMapper(); ContextualArrayElementBean beans = new ContextualArrayElementBean("456"); //ARGO_PLACEBO assertEquals("{\"beans\":[\"elem->456\"]}", mapper.writeValueAsString(beans)); } // Test to verify aspects of [databind#2429] public void testRootContextualization2429() throws Exception { ObjectMapper mapper = jsonMapperBuilder() .addModule(new SimpleModule("test", Version.unknownVersion()) .addSerializer(String.class, new AccumulatingContextual())) .build(); //ARGO_PLACEBO assertEquals(quote("/ROOT/foo"), mapper.writeValueAsString("foo")); //ARGO_PLACEBO assertEquals(quote("/ROOT/bar"), mapper.writeValueAsString("bar")); //ARGO_PLACEBO assertEquals(quote("/ROOT/3"), mapper.writeValueAsString("3")); } }
03771e709e76708359022db4b93542beedfa87f6
511fd8c7980d03ba4c040c8513db28a5278670b3
/processor/src/test/java/org/mapstruct/ap/test/imports/nested/TargetInOtherPackageMapper.java
a40d52eb1c7e26cae09f8f747eb99af4edd9a875
[ "Apache-2.0" ]
permissive
mapstruct/mapstruct
9894232e655c5607643802027c23150827c356ff
ea997f83cefd7d3900f8a6a218af1c20f7a1ef8a
refs/heads/main
2023-09-01T20:38:39.275117
2023-08-19T08:09:36
2023-08-19T08:09:36
4,470,435
6,519
1,025
NOASSERTION
2023-09-10T10:26:50
2012-05-28T12:42:42
Java
UTF-8
Java
false
false
433
java
/* * Copyright MapStruct Authors. * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ package org.mapstruct.ap.test.imports.nested; import org.mapstruct.Mapper; import org.mapstruct.ap.test.imports.nested.other.TargetInOtherPackage; /** * @author Filip Hrisafov */ @Mapper public interface TargetInOtherPackageMapper { TargetInOtherPackage map(Source source); }
c67cd4ba760db4d2088f9a96932e6943bd236163
25cb639a3e783de1b2dcf64bcf6881dd7831ae79
/updatelibrary/src/main/java/cn/nobita/updatelibrary/UpdateAppReceiver.java
235ba7fa18f224b8ad1ecf0c8247b87d91924145
[]
no_license
cnobita/UpdateAppUtil
c183c7e20daf69250d02ba4600ba15a9e370ed32
13bffd9181d13df36abee43df6985220bb7e72c7
refs/heads/master
2020-06-29T14:42:05.888157
2019-08-15T08:50:35
2019-08-15T08:50:35
200,562,824
0
0
null
null
null
null
UTF-8
Java
false
false
2,779
java
package cn.nobita.updatelibrary; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Build; import androidx.core.app.NotificationCompat; import java.io.File; public class UpdateAppReceiver extends BroadcastReceiver { private NotificationManager nm = null; @Override public void onReceive(Context context, Intent intent) { int notifyId = 1; int progress = intent.getIntExtra("progress", 0); int total = intent.getIntExtra("total", 100); boolean sound = intent.getBooleanExtra("sound", false); String title = intent.getStringExtra("title"); if (Build.VERSION.SDK_INT >= 26) { String channelID = "1"; String channelName = "channel_name"; NotificationChannel channel = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_HIGH); Notification notification = new Notification.Builder(context, channelID) .setSmallIcon(android.R.mipmap.sym_def_app_icon) .setContentTitle("正在下载" + title) .setProgress(total, progress, false) .setDefaults(Notification.DEFAULT_SOUND) .setAutoCancel(true) .build(); if (null == nm) { nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); } nm.createNotificationChannel(channel); nm.notify(notifyId, notification); } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setContentTitle("正在下载" + title); builder.setSmallIcon(android.R.mipmap.sym_def_app_icon); builder.setProgress(total, progress, false); Notification notification = builder.build(); if (sound) { notification.defaults = Notification.DEFAULT_SOUND; } if (null == nm) { nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); } nm.notify(notifyId, notification); } if (progress == 100) { if (nm != null) { nm.cancel(notifyId); } if (DownloadAppUtils.downloadUpdateApkFilePath != null) { Intent i = new Intent(Intent.ACTION_VIEW); File apkFile = new File(DownloadAppUtils.downloadUpdateApkFilePath); CallSystemAction.openApk(context, apkFile.getAbsolutePath()); } } } }
06312a41e1b0da039553078b4564eba18c79bd9a
2ac2c7fcd09a66cd96f42b752873e3983a6a727f
/NumberToWords/src/NumberToWords.java
18b1d42cb819b7179ad760337f467885dce6bb0b
[]
no_license
JCarlos831/JavaProjects
67dc103fe6aad991a888c1a7e14e66c0ca8732f0
343942ca7e03df5b3f96712a54821b322b975535
refs/heads/master
2020-04-07T15:01:12.528321
2018-12-20T22:47:26
2018-12-20T22:47:26
158,469,976
0
0
null
null
null
null
UTF-8
Java
false
false
2,496
java
public class NumberToWords { public static void main(String[] args) { numberToWords(123); System.out.println("**********"); numberToWords(1010); System.out.println("**********"); numberToWords(1000); System.out.println("**********"); numberToWords(-12); } public static void numberToWords(int number) { if (number < 0) System.out.println("Invalid Value"); int reversed = reverse(number); int ogReversed = reversed; while (reversed > 0) { int digit = reversed % 10; switch (digit) { case 0: System.out.println("Zero"); break; case 1: System.out.println("One"); break; case 2: System.out.println("Two"); break; case 3: System.out.println("Three"); break; case 4: System.out.println("Four"); break; case 5: System.out.println("Five"); break; case 6: System.out.println("Six"); break; case 7: System.out.println("Seven"); break; case 8: System.out.println("Eight"); break; case 9: System.out.println("Nine"); break; default: System.out.println("Invalid Value"); break; } reversed /= 10; } int numOfZeros = getDigitCount(number) - getDigitCount(ogReversed); for (int i = 1; i <= numOfZeros; i++) System.out.println("Zero"); } public static int reverse(int number) { int reversedNumber = 0; while (number != 0) { reversedNumber = (reversedNumber * 10) + (number % 10); number /= 10; } return reversedNumber; } public static int getDigitCount(int number) { int digitCount = 0; if (number < 0) return -1; if (number < 10) return 1; while (number > 0) { number /= 10; digitCount++; } return digitCount; } }
02d30624324e7b0c0a3635a1922664b7c6d66b95
ebed84df95adada4d818bc49fb1c81ec52ae51aa
/app/src/test/java/com/example/rainbowdinosaur/ExampleUnitTest.java
4e44bc8945f01f339d6456cc41ed0e5ffcdeff1e
[]
no_license
Vikramjeet01/AndroidTest-RainbowDinosaur
d96b8760d4f706cc487ab1d7b1127ef838d236c6
5e30dd55216669359963ad8de8a3802aa264bb4f
refs/heads/master
2020-08-05T17:35:11.208550
2019-10-03T17:36:55
2019-10-03T17:36:55
212,635,928
0
0
null
null
null
null
UTF-8
Java
false
false
388
java
package com.example.rainbowdinosaur; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
2cc497f8bb169bf789bbec645f207eab2fff4e01
3c4763922cda3f3a990b74cdba6f8a30b07467de
/src/main/java/students/nikita_bunevich/lesson_5/level_1/task_5/ArrayDefinition5.java
bc329a8edf6d4de44faf3b7dcf31dbb471eec4ac
[]
no_license
VitalyPorsev/JavaGuru1
07db5a0cc122b097a20e56c9da431cd49d3c01ea
f3c25b6357309d4e9e8ac0047e51bb8031d14da8
refs/heads/main
2023-05-10T15:35:55.419713
2021-05-15T18:48:12
2021-05-15T18:48:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
173
java
package students.nikita_bunevich.lesson_5.level_1.task_5; class ArrayDefinition5 { public static void main(String[] args) { int [] numbers = {1, 2, 3}; } }
1d5c1d41c6715f2f6aa3dc7afa86285092c17a39
09bbdb6fc071191360ac868fc9426349a3768c07
/src/test/java/com/cobber/fta/TestBooleans.java
713fa957dc088a5b8f9ccab7d155ee7eca98e96a
[ "Apache-2.0" ]
permissive
himanshusin/fta
e1c2371d3141609454096c81e909913ab8fa3a1b
32409815f981d87d507d4a8c94af516e8e3129ed
refs/heads/master
2021-11-24T08:49:35.481687
2019-03-04T03:20:29
2019-03-04T03:20:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,149
java
package com.cobber.fta; import java.io.IOException; import java.util.Map; import org.testng.Assert; import org.testng.annotations.Test; public class TestBooleans { @Test public void onlyTrue() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); analysis.train("true"); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(result.getSampleCount(), 1); Assert.assertEquals(result.getOutlierCount(), 0); Assert.assertEquals(result.getMatchCount(), 1); Assert.assertEquals(result.getNullCount(), 0); Assert.assertEquals(result.getRegExp(), "(?i)(true|false)"); Assert.assertEquals(result.getConfidence(), 1.0); Assert.assertEquals(result.getType(), PatternInfo.Type.BOOLEAN); Assert.assertEquals(result.getMinLength(), 4); Assert.assertEquals(result.getMaxLength(), 4); Assert.assertEquals(result.getMinValue(), "true"); Assert.assertEquals(result.getMaxValue(), "true"); Assert.assertTrue("true".matches(result.getRegExp())); } @Test public void basicBoolean() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); final String[] inputs = "false|true|TRUE| false |FALSE |TRUE|true|false|False|True|false| FALSE|FALSE|true|TRUE|bogus".split("\\|"); int locked = -1; analysis.train(null); for (int i = 0; i < inputs.length; i++) { if (analysis.train(inputs[i]) && locked == -1) locked = i; } analysis.train(null); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(locked, -1); Assert.assertEquals(result.getSampleCount(), inputs.length + 2); Assert.assertEquals(result.getOutlierCount(), 1); Assert.assertEquals(result.getMatchCount(), inputs.length - result.getOutlierCount()); Assert.assertEquals(result.getNullCount(), 2); Assert.assertEquals(result.getRegExp(), "\\p{javaWhitespace}*((?i)(true|false))\\p{javaWhitespace}*"); Assert.assertEquals(result.getConfidence(), .9375); Assert.assertEquals(result.getType(), PatternInfo.Type.BOOLEAN); Assert.assertEquals(result.getTypeQualifier(), "TRUE_FALSE"); Assert.assertEquals(result.getMinLength(), 4); Assert.assertEquals(result.getMaxLength(), 12); Assert.assertEquals(result.getMinValue(), "false"); Assert.assertEquals(result.getMaxValue(), "true"); Assert.assertTrue(inputs[0].matches(result.getRegExp())); int matches = 0; for (int i = 0; i < inputs.length; i++) { if (inputs[i].matches(result.getRegExp())) matches++; } Assert.assertEquals(result.getMatchCount(), matches); } @Test public void basicBooleanYN() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); final String[] inputs = "no|yes|YES| no |NO |YES|yes|no|No|Yes|no| NO|NO|yes|YES|bogus".split("\\|"); int locked = -1; analysis.train(null); for (int i = 0; i < inputs.length; i++) { if (analysis.train(inputs[i]) && locked == -1) locked = i; } analysis.train(null); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(locked, -1); Assert.assertEquals(result.getSampleCount(), inputs.length + 2); Assert.assertEquals(result.getOutlierCount(), 1); Assert.assertEquals(result.getMatchCount(), inputs.length - result.getOutlierCount()); Assert.assertEquals(result.getNullCount(), 2); Assert.assertEquals(result.getRegExp(), "\\p{javaWhitespace}*((?i)(yes|no))\\p{javaWhitespace}*"); Assert.assertEquals(result.getConfidence(), .9375); Assert.assertEquals(result.getType(), PatternInfo.Type.BOOLEAN); Assert.assertEquals(result.getTypeQualifier(), "YES_NO"); Assert.assertEquals(result.getMinLength(), 2); Assert.assertEquals(result.getMaxLength(), 9); Assert.assertEquals(result.getMinValue(), "no"); Assert.assertEquals(result.getMaxValue(), "yes"); Assert.assertTrue(inputs[0].matches(result.getRegExp())); int matches = 0; for (int i = 0; i < inputs.length; i++) { if (inputs[i].trim().matches(result.getRegExp())) matches++; } Assert.assertEquals(result.getMatchCount(), matches); } @Test public void basicPseudoBoolean() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); final String[] inputs = "0|1|1|0|0|1|1|0|0|1|0|0|0|1|1|0|1|1|1|1|0|0|0|0|1|1|1".split("\\|"); int locked = -1; analysis.train(null); for (int i = 0; i < inputs.length; i++) { if (analysis.train(inputs[i]) && locked == -1) locked = i; } analysis.train(null); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(locked, TextAnalyzer.SAMPLE_DEFAULT); Assert.assertEquals(result.getSampleCount(), inputs.length + 2); Assert.assertEquals(result.getOutlierCount(), 0); Assert.assertEquals(result.getMatchCount(), inputs.length - result.getOutlierCount()); Assert.assertEquals(result.getNullCount(), 2); Assert.assertEquals(result.getRegExp(), "[0|1]"); Assert.assertEquals(result.getConfidence(), 1.0); Assert.assertEquals(result.getType(), PatternInfo.Type.BOOLEAN); Assert.assertEquals(result.getMinLength(), 1); Assert.assertEquals(result.getMaxLength(), 1); Assert.assertEquals(result.getMinValue(), "0"); Assert.assertEquals(result.getMaxValue(), "1"); Assert.assertTrue(inputs[0].matches(result.getRegExp())); for (int i = 0; i < inputs.length; i++) { Assert.assertTrue(inputs[i].matches(result.getRegExp())); } } @Test public void notPseudoBoolean() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); final String[] inputs = "7|1|1|7|7|1|1|7|7|1|7|7|7|1|1|7|1|1|1|1|7|7|7|7|1|1|1".split("\\|"); int locked = -1; analysis.train(null); for (int i = 0; i < inputs.length; i++) { if (analysis.train(inputs[i]) && locked == -1) locked = i; } analysis.train(null); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(locked, TextAnalyzer.SAMPLE_DEFAULT); Assert.assertEquals(result.getSampleCount(), inputs.length + 2); Assert.assertEquals(result.getOutlierCount(), 0); Assert.assertEquals(result.getMatchCount(), inputs.length - result.getOutlierCount()); Assert.assertEquals(result.getNullCount(), 2); Assert.assertEquals(result.getRegExp(), "\\d{1}"); Assert.assertEquals(result.getConfidence(), 1.0); Assert.assertEquals(result.getType(), PatternInfo.Type.LONG); Assert.assertEquals(result.getMinLength(), 1); Assert.assertEquals(result.getMaxLength(), 1); Assert.assertEquals(result.getMinValue(), "1"); Assert.assertEquals(result.getMaxValue(), "7"); Assert.assertTrue(inputs[0].matches(result.getRegExp())); for (int i = 0; i < inputs.length; i++) { Assert.assertTrue(inputs[i].matches(result.getRegExp())); } } @Test public void basicNotPseudoBoolean() throws IOException { final TextAnalyzer analysis = new TextAnalyzer(); final String[] inputs = "0|5|5|0|0|5|5|0|0|5|0|0|0|5|5|0|5|5|5|5|0|0|0|0|5|5|5|A".split("\\|"); int locked = -1; analysis.train(null); for (int i = 0; i < inputs.length; i++) { if (analysis.train(inputs[i]) && locked == -1) locked = i; } analysis.train(null); final TextAnalysisResult result = analysis.getResult(); Assert.assertEquals(locked, TextAnalyzer.SAMPLE_DEFAULT); Assert.assertEquals(result.getSampleCount(), inputs.length + 2); Assert.assertEquals(result.getOutlierCount(), 1); Assert.assertEquals(result.getMatchCount(), inputs.length - result.getOutlierCount()); Assert.assertEquals(result.getNullCount(), 2); Assert.assertEquals(result.getRegExp(), "\\d{1}"); Assert.assertEquals(result.getConfidence(), 1 - (double)1/(result.getSampleCount() - result.getNullCount())); Assert.assertEquals(result.getType(), PatternInfo.Type.LONG); Assert.assertEquals(result.getCardinality(), 2); final Map<String, Integer> details = result.getCardinalityDetails(); Assert.assertEquals(details.get("0"), Integer.valueOf(13)); Assert.assertEquals(details.get("5"), Integer.valueOf(14)); Assert.assertTrue(inputs[0].matches(result.getRegExp())); int matches = 0; for (int i = 0; i < inputs.length; i++) { if (inputs[i].matches(result.getRegExp())) matches++; } Assert.assertEquals(result.getMatchCount(), matches); } }
1aeb3c056a9917d7805e639ae5540d3791790202
73601deb01f3c3f90fbe6346c5d407653431609a
/First_Step/data/46/146/submittedfiles/Tools.java
8ee8550ae7aa9a03067b5da44500eb7c51dd5de7
[]
no_license
Benjam73/ComplexityAnalyzer
145fbac896ac18e6239791a636fe871efc3de332
27a0f1d5528ee66f2913b18137425aae59d06b0f
refs/heads/master
2020-03-17T09:25:31.308634
2018-07-20T13:34:17
2018-07-20T13:34:17
133,474,612
0
0
null
null
null
null
UTF-8
Java
false
false
635
java
/** * A class providing static methods for zero pairs algorithms. */ public class Tools { /** * Give a O(n^2) algorithm for the zero pairs. */ public static int numberOfCancellations(int[] tab) { int count=0; for(int i=0; i<tab.length-1; i++){ for(int k=0; k<tab.length; k++){ if(tab[i]==-tab[k]){ count+=1; } } } return count/2; } } /** * Give a O(nlog(n)) algorithm for the zero pairs. */ public static int fastNumberOfCancellations(int[] tab) { } }
d2b160894b27938c0bb231b9f91adc21a02281c0
15401fa040af552679715a9bf9c760ca487e128a
/app/src/main/java/com/example/coco/bannerlayout/MainActivity.java
b8c3fd12d489a70da12570eff3b021b4682e87fa
[]
no_license
CocoQueen/BannerLayout
cf3bee49e0eaca5fd1d814e6f51976bdd9b31c53
b46cf83da36bbf2401f5b27eb2300886e70ca13f
refs/heads/master
2021-08-17T13:14:46.917228
2017-11-21T07:06:43
2017-11-21T07:06:43
111,355,573
0
0
null
null
null
null
UTF-8
Java
false
false
1,640
java
package com.example.coco.bannerlayout; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.example.coco.bannerlayout.utils.GlideImageLoader; import com.yyydjk.library.BannerLayout; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private BannerLayout banner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); banner = findViewById(R.id.banner); final List<String> urls = new ArrayList<>();//存放轮播图片的集合 urls.add("http://p0.so.qhimgs1.com/t016e00c9485326b764.jpg"); urls.add("http://p0.so.qhimgs1.com/t01dc3718ec509e0050.jpg"); urls.add("http://p0.so.qhimgs1.com/t0124a6870f243a4be4.jpg"); urls.add("http://p2.so.qhimgs1.com/t014bb11b1742a1998e.jpg"); urls.add("http://p1.so.qhimgs1.com/t01443fc83ad628a72d.jpg"); //设置加载器 banner.setImageLoader(new GlideImageLoader()); //网络地址 banner.setViewUrls(urls); //添加点击监听 banner.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() { @Override public void onItemClick(int position) { // Intent intent = new Intent(); // intent.setData(Uri.parse("http://p0.so.qhimgs1.com/t016e00c9485326b764.jpg"));//Url 就是你要打开的网址 // intent.setAction(Intent.ACTION_VIEW); // startActivity(intent); //启动浏览器 } }); } }
17f6f72e915893cc67abae545cd15ade05ee4402
7fee6d076257e5390833dcf9923825904cb15368
/src/game/Base.java
aa16c96a8d8a09585eba70f23ba07f0c9abcf6a6
[]
no_license
snowsiechau/runforyourlife-1
7f2251b2ca78bc194ca917b8f7c4ec97bb8b12a4
385233a885bf0cf9b535a15891735b067a570471
refs/heads/master
2021-01-06T20:44:30.875109
2017-08-06T10:45:03
2017-08-06T10:45:03
null
0
0
null
null
null
null
UTF-8
Java
false
false
183
java
package game; /** * Created by Administrator on 7/18/2017. */ public class Base { public void doSomething() { System.out.println("Do something with base"); } }
8c17aeda4aee3f6d3e254fbd992ce0cad5b10334
6ffd590dbf461bd5bc68c75ed8357c3bc85a2bea
/dl4j-eclipse/src/deeplearning4j_nn/src/main/java/org/deeplearning4j/nn/conf/stepfunctions/GradientStepFunction.java
212b0b2a186096e3d2e2a2032abf9bf1b434cdad
[]
no_license
nagyistge/dl4j_for_eclipse
e017fcfd545c879e18f91d36c15d46872fba390f
8fb1a2d813dd064d7b46e24e8b696c364d84c6b6
refs/heads/master
2021-06-14T16:11:23.572374
2017-02-13T07:15:41
2017-02-13T07:15:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,343
java
/* * * * Copyright 2015 Skymind,Inc. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * */ package deeplearning4j_nn.src.main.java.org.deeplearning4j.nn.conf.stepfunctions; /** * Normal gradient step function */ public class GradientStepFunction extends StepFunction { private static final long serialVersionUID = -2078308971477295356L; @Override public int hashCode() { return 0; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; return true; } public String toString() { return "GradientStepFunction{" + '}'; } }
50a157aaf27741d62724c668b4969bcfb6f00f7a
c43c8f52b3be13162477e7ca6bcd51db080d156b
/src/App04.java
6b02baf536bd743744b72e2ee1dd1402d4b371b5
[]
no_license
watanabe223/text
5de952889d00703f66e7961d2bd5397b98b21acf
a6b9c49a8f3e81efa7c26d33f08210c81138e35d
refs/heads/master
2023-03-23T08:13:29.439269
2021-03-09T09:58:51
2021-03-09T09:58:51
345,960,194
0
0
null
null
null
null
UTF-8
Java
false
false
1,326
java
import java.io.*; public class App04 { public static void main(String s[]) { try { String path = "D:\\桌面\\蓝桥\\2021-03-04(视频+代码)\\BIGIMAGE"; String FileName = "info.dat"; File file = new File(path); file.mkdirs();//创建文件夹 File fil = new File(path); fil.createNewFile(); FileWriter fileWriter=new FileWriter(path+FileName); fileWriter.write("gsmc");//写入文件 fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } public void writeFile(String result) { try { String fileName = "E:\\Data.dat"; File file = new File(fileName); File fileParent = file.getParentFile(); if(!fileParent.exists()){ fileParent.mkdirs(); } file.createNewFile(); // false:覆盖之前写的 如果是true则为追加 BufferedWriter writer = new BufferedWriter (new OutputStreamWriter(new FileOutputStream (file,false),"UTF-8")); writer.write(result); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } } }
a2fe14cf832f663c1195b2db48b3b4483cceb777
3358304429ff367634b47d07f8331e4e21e3e036
/3ano/Linguagem de Programação Multiplataforma - Java/ExGetSet_Osses/src/exgetset_osses/ExGetSet_Osses.java
fb36c488447c120864896e1c902575ca7fab56cf
[]
no_license
VictorHugoCostaOsses/School-Projects
9d7229a2d24d7c198b26c4605a0aedd56564f209
1e5d789f624e7e06314f128ff2e5df7206798677
refs/heads/master
2022-11-29T22:36:55.003760
2020-08-16T00:50:16
2020-08-16T02:22:41
287,841,097
0
0
null
null
null
null
UTF-8
Java
false
false
618
java
package exgetset_osses; public class ExGetSet_Osses { public static void main(String[] args) { RegistroAcademico primeiroRegistro = new RegistroAcademico("Victor", 18152,17,"informática", "3INFD"); RegistroAcademico segundoRegistro = new RegistroAcademico("Victor"); RegistroAcademico terceiroRegistro = new RegistroAcademico(18152); RegistroAcademico quartoRegistro = new RegistroAcademico(); System.out.println(primeiroRegistro); System.out.println(segundoRegistro); System.out.println(terceiroRegistro); System.out.println(quartoRegistro); } }
a7aec32c6f4b3fa91bec529c883e1352f350656c
c6f732aecb45294a472310ed97b0e4d1a6051dee
/src/main/java/demo/example/ExceptionThrower.java
59783e3f9dd46daed0546a984396fc1f79d3a051
[]
no_license
rhatlapa/byteman-demo
b41753c5e1d86018230b2f271cac1e3aa2526d83
1da78be691fee14c9425d92278ccb336bf373528
refs/heads/master
2022-12-27T07:53:27.062435
2020-02-12T14:57:23
2020-02-12T14:57:23
175,972,342
0
0
null
2020-10-13T19:28:20
2019-03-16T12:58:38
Java
UTF-8
Java
false
false
2,090
java
package demo.example; public class ExceptionThrower implements Runnable { public static void main(String[] args) { new Thread(new ExceptionThrower()).start(); } public void run() { int num = 10; while (num == 10) { num--; num--; try { while (num == 8) { num++; while (num == 9) { while (num < 50) { if (num <= 500) { int random = (int) (Math.random() * 3); switch (random) { case 0: while (true) { num = num / num - 1; } case 1: String c = null; final String lower = c.toLowerCase(); break; case 2: final int[] arr = new int[5]; num = 4; while (true) { arr[num] = num; num--; } } } else { num /= num - 1; } } num = 9; } num = 8; } } catch (ArithmeticException e) { System.out.println("Zero Div Err"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Arr Idx Err"); } catch (NullPointerException e) { System.out.println("Null Ptr Err"); } finally { num = 10; } } } }
902f078aa1ca9fafb3eb68642e936d7bda665c15
dc078d3f3d4f25404edccff0878aeaf64f2fb23d
/Musician/src/com/company/Bassist.java
3cbf06ccf718f2b87d287c9309ed303dad2af46b
[]
no_license
jhe09/ObjektOrientierung
35e7f843935dafd47ff474b53f52b7a4a2e71fed
b785c4bea97feb316f9ddf6f9ad2abcf86e179ab
refs/heads/master
2021-05-21T19:47:56.226779
2020-04-03T16:04:47
2020-04-03T16:04:47
252,776,334
0
0
null
null
null
null
UTF-8
Java
false
false
264
java
package com.company; public class Bassist extends Musician { public Bassist(String alias, String name, String surname) { super(alias, name, surname); } @Override public void playMusic(){ System.out.println("LiLaLuLiLaLu"); } }
23a8529c9d568444ea160a57064c9f4235fe977e
4655191601fa1df2072c099223b15ead7f47cde6
/src/main/cp/leetcode/problems/_1577_Number_Of_Ways_Where_Square_Of_Number_Is_Equal_To_Product_Of_Two_Numbers.java
f7f2ada825aff51db3de912c2fbc3f0b6180fcf5
[]
no_license
naresh1406/youtube
9e179d9e3e377433c59b17ccadb1c02f18005543
ec2e7acf7bd911e117202a9cc37d069e78d96c2c
refs/heads/master
2023-08-06T07:43:10.428766
2021-09-09T19:10:01
2021-09-09T19:10:01
271,821,289
33
35
null
null
null
null
UTF-8
Java
false
false
922
java
package main.cp.leetcode.problems; import java.util.HashMap; import java.util.Map; public class _1577_Number_Of_Ways_Where_Square_Of_Number_Is_Equal_To_Product_Of_Two_Numbers { class Solution { public int numTriplets(int[] nums1, int[] nums2) { return helper(nums1, nums2) + helper(nums2, nums1); } private int helper(int[] nums1, int[] nums2) { Map<Long, Integer> map = new HashMap(); for (long n : nums1) map.put(n * n, map.getOrDefault(n * n, 0) + 1); int count = 0; for (int j = 0; j < nums2.length - 1; j++) { for (int k = j + 1; k < nums2.length; k++) { long prod = (long) nums2[j] * nums2[k]; if (map.containsKey(prod)) { count += map.get(prod); } } } return count; } } }
ffc9612f3ee9ea9991cecb1408070d8128af49bd
1d17dc13a8bf7a891fa23b6a2d65c72ca8414186
/src/test/java/tests/TraditionalTests/TableSortTests.java
2dd02d634d690ba9742af826c07298399c15c34d
[]
no_license
yashzanwar/applitoolHackhathon
b9495a100c8a77eb417dfa335a478ebd518c04c2
9980023c7b35414dbc6a872fd5b8d31b28a73a4d
refs/heads/master
2020-09-10T08:25:36.877579
2019-11-14T13:40:12
2019-11-14T13:40:12
221,702,163
0
0
null
null
null
null
UTF-8
Java
false
false
1,476
java
package tests.TraditionalTests; import Framework.DriveInitialization; import Pages.AppPage; import Pages.LoginPage; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.testng.asserts.SoftAssert; import java.util.ArrayList; /** * created by yash.zanwar on 2019-11-13 */ public class TableSortTests extends DriveInitialization { @BeforeMethod public void createDriver() { driver = initialization(); driver.get(prop.getProperty("urlVersion1")); softAssert = new SoftAssert(); } @Test public void testTableSorts() { try { LoginPage loginPage = new LoginPage(driver); loginPage.doLogin(prop.getProperty("userName"), prop.getProperty("password")); AppPage appPage = new AppPage(driver); ArrayList<String> tableContents = appPage.getAllTheRecentTransactions(); appPage.clickOnAmountHeader(); softAssert.assertTrue(appPage.checkAmountIsInAscendingOrder(), "The Amount is not in ascending order."); ArrayList<String> tableContents1 = appPage.getAllTheRecentTransactions(); softAssert.assertTrue(appPage.checkTheTransactionsAreIntact(tableContents, tableContents1), "Transactions are not intact."); } finally { softAssert.assertAll(); } } @AfterMethod public void tearDown() { driver.quit(); } }
766c79562409ff89cecbbedc741269cc87501e0e
91d415b8aa70ad09c0a3f5f279df5cfca998f2b1
/src/main/java/address/controller/TagSelectionEditDialogController.java
fb878cd99e3f5079192cf2870aa561db4bbfb753
[]
no_license
damithc/addressbook-1
5f9a39d0353fdaffd9d945d86709b73ef8bd6a2c
78f53ae8d02459c1cf50af8b6cce77d6c3d71d52
refs/heads/master
2020-12-01T01:06:00.401391
2016-06-28T06:24:10
2016-06-28T06:24:53
62,119,283
0
0
null
2016-06-28T07:22:31
2016-06-28T07:22:31
null
UTF-8
Java
false
false
6,455
java
package address.controller; import address.model.TagSelectionEditDialogModel; import address.model.datatypes.tag.SelectableTag; import address.model.datatypes.tag.Tag; import javafx.animation.ScaleTransition; import javafx.application.Platform; import javafx.collections.ListChangeListener; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Duration; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * Dialog to select a subset of tags from an available list of tags * * Stage, initially selected and full list of tags should be set before showing stage */ public class TagSelectionEditDialogController extends EditDialogController { private static final String TRANSITION_END = "end"; private static final int TAG_LABEL_WIDTH = 235; private static final String STYLE_SELECTED_BACKGROUND = "-fx-background-color: blue;"; @FXML AnchorPane mainPane; @FXML FlowPane tagList; @FXML ScrollPane tagResults; @FXML TextField tagSearch; private TagSelectionEditDialogModel model; private Stage dialogStage; private ScaleTransition transition; public TagSelectionEditDialogController(){ super(); } @FXML public void initialize() { transition = getPaneTransition(mainPane); transition.play(); model = new TagSelectionEditDialogModel(); addListeners(); Platform.runLater(() -> tagSearch.requestFocus()); } public void setTags(List<Tag> tags, List<Tag> assignedTags) { model.init(tags, assignedTags, ""); } /** * Sets the stage of this dialog. * * @param dialogStage */ public void setDialogStage(Stage dialogStage) { dialogStage.getScene().setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ESCAPE) { e.consume(); handleCancel(); } if (e.getCode() == KeyCode.ENTER) { e.consume(); handleOk(); } }); this.dialogStage = dialogStage; } public List<Tag> getFinalAssignedTags() { return model.getAssignedTags(); } private ScaleTransition getPaneTransition(AnchorPane pane) { ScaleTransition transition = new ScaleTransition(Duration.millis(200), pane); transition.setFromX(0); transition.setFromY(0); transition.setFromZ(0); transition.setToX(1); transition.setToY(1); transition.setToZ(1); return transition; } /** * Returns the list of nodes that represent the given list of selectable tags * * @param tagList * @return */ private List<Node> getSelectableTagListNodes(List<? extends SelectableTag> tagList) { return tagList.stream() .map(this::getNodeForSelectableTag) .collect(Collectors.toCollection(ArrayList::new)); } /** * Returns the list of nodes that represent the given list of tags * * @param tagList * @return */ private List<Node> getTagListNodes(List<? extends Tag> tagList) { return tagList.stream() .map(this::getNodeForTag) .collect(Collectors.toCollection(ArrayList::new)); } private Label getNodeForSelectableTag(SelectableTag contactTag) { Label newLabel = getNodeForTag(contactTag); if (contactTag.isSelected()) newLabel.setStyle(STYLE_SELECTED_BACKGROUND); return newLabel; } private Label getNodeForTag(Tag contactTag) { Label newLabel = new Label(contactTag.getName()); newLabel.setPrefWidth(TAG_LABEL_WIDTH); return newLabel; } /** * Returns a VBox containing the list of tags' labels * * Each of the labels might be blue (selected) depending on the respective tag's isSelected() property * * @param tagList * @return */ private VBox getTagsVBox(List<? extends SelectableTag> tagList) { List<Node> tagNodes = getSelectableTagListNodes(tagList); VBox content = new VBox(); content.getChildren().addAll(tagNodes); return content; } private void addListeners() { tagSearch.textProperty().addListener((observableValue, oldValue, newValue) -> handleTagInput(newValue)); tagSearch.setOnKeyTyped(e -> { if (!e.getCharacter().equals(" ")) return; e.consume(); model.toggleSelection(); tagSearch.clear(); }); tagSearch.setOnKeyPressed(e -> { switch (e.getCode()) { case DOWN: e.consume(); model.selectNext(); break; case UP: e.consume(); model.selectPrevious(); break; default: break; } }); model.getAssignedTags().addListener((ListChangeListener<Tag>) change -> { while (change.next()) tagList.getChildren().setAll(getTagListNodes(change.getList())); }); model.getFilteredTags().addListener((ListChangeListener<SelectableTag>) change -> { while (change.next()) tagResults.setContent(getTagsVBox(change.getList())); }); } private void playReversedTransition() { transition.setOnFinished(e -> dialogStage.close()); transition.setRate(-1); transition.playFrom(TRANSITION_END); } /** * Handles when the text in the tag search field has changed * @param newTags */ protected void handleTagInput(String newTags) { model.setFilter(newTags); } /** * Handles when the user indicates confirmation * * Assumes that transition is not null */ protected void handleOk() { isOkClicked = true; playReversedTransition(); } /** * Handles when the user indicates cancellation * * Assumes that transition is not null */ protected void handleCancel() { playReversedTransition(); } }
2b6a689e4bc968da19f2fc16cee4515765e5b374
ae482f1b2295833c713b02f882accab3ef92eba8
/src/Student.java
b5ed233d2f6b685b33f9bf0bbb31daae2cc88792
[]
no_license
jubelAhmed/school_result_builder
84aef9490702433c2cfe4da251b30018bfd5cde0
327f4ecfdec938e556553ced799082829bb0aa1e
refs/heads/master
2020-08-05T04:25:02.248180
2019-10-25T18:54:51
2019-10-25T18:54:51
212,394,008
1
0
null
null
null
null
UTF-8
Java
false
false
1,087
java
import java.util.HashMap; import java.util.Map; public class Student { private String name; private int roll_number; private SchoolClass schoolClass; private HashMap<String,Double> marks; public Student(String name, int roll_number, SchoolClass schoolClass) { this.name = name; this.roll_number = roll_number; this.schoolClass = schoolClass; marks = new HashMap(); } public String getName() { return name; } public int getRoll_number() { return roll_number; } public SchoolClass getSchoolClass() { return schoolClass; } public void setSchoolClass(SchoolClass schoolClass) { this.schoolClass = schoolClass; } public Map getMarks() { return marks; } public void setMarks(String subject,double mark) { marks.put(subject,mark); } @Override public String toString() { return "Student{" + "name='" + name + '\'' + ", roll_number=" + roll_number + '}'; } }
96934d0770d790c6d6af5c69ab6ef564c5d85ee1
4e390e1d3ee8db4277d7e86c74e67730a3583a1b
/components/CAR_components_sources/component-2/CAR/robots/src/robot/impl/WhileImpl.java
32063516efc7df30ae4dd758adb5a65ae5912265
[]
no_license
WasteService/WasteService.github.io
6dd28b9673895dc53c00bfee751a0378d684813a
fefe1185e6c7a53806f28e759f5104904a80db01
refs/heads/master
2023-01-05T09:56:28.057174
2020-10-28T10:13:53
2020-10-28T10:13:53
307,663,150
0
0
null
null
null
null
UTF-8
Java
false
false
2,275
java
/** * <copyright> * </copyright> * * $Id$ */ package robot.impl; import org.eclipse.emf.ecore.EClass; import robot.Condition; import robot.Operation; import robot.RobotPackage; import robot.Value; import robot.While; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>While</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link robot.impl.WhileImpl#getOperation <em>Operation</em>}</li> * <li>{@link robot.impl.WhileImpl#getCondition <em>Condition</em>}</li> * </ul> * </p> * * @generated */ public class WhileImpl extends OperationImpl implements While { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected WhileImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return RobotPackage.Literals.WHILE; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Operation getOperation() { return (Operation)eGet(RobotPackage.Literals.WHILE__OPERATION, true); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setOperation(Operation newOperation) { eSet(RobotPackage.Literals.WHILE__OPERATION, newOperation); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Condition getCondition() { return (Condition)eGet(RobotPackage.Literals.WHILE__CONDITION, true); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setCondition(Condition newCondition) { eSet(RobotPackage.Literals.WHILE__CONDITION, newCondition); } /** * <!-- begin-user-doc --> * Code correspondant au While * <!-- end-user-doc --> * @generated NOT */ public String toUrbiString(String indent) { String returnvalue = ""; if(this.getCondition() instanceof Value) returnvalue += indent+"while("+this.getCondition().toUrbiString()+")\n"; else returnvalue += indent+"while"+this.getCondition().toUrbiString()+"\n"; returnvalue += indent+"{\n"; returnvalue += this.getOperation().toUrbiString(indent+"\t")+"\n"; returnvalue += indent+"};\n"; return returnvalue; } } //WhileImpl
[ "" ]
d3b749200d28ab3b0fc61abcc7c0804d79707a25
78cf894c99a370808ca193503bb4b10688bc7e72
/app/src/main/java/com/zemoso/videotranscoder/format/Android720pFormatStrategy.java
05e626b88781a5541ad72b811a06945983bc2b57
[]
no_license
Bhupathi-Raju/VideoTranscoder
d742a036273bdea44ad99c599ba17932cb82c8ed
5a03de655fe232d7ba86b5de9d904afb91eea047
refs/heads/master
2021-05-11T12:34:42.635705
2018-01-16T09:21:07
2018-01-16T09:21:07
117,661,239
0
0
null
null
null
null
UTF-8
Java
false
false
3,298
java
package com.zemoso.videotranscoder.format; /** * @author Bhupathi * Created on 12/1/18. */ import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.util.Log; class Android720pFormatStrategy implements MediaFormatStrategy { public static final int AUDIO_BITRATE_AS_IS = -1; public static final int AUDIO_CHANNELS_AS_IS = -1; private static final String TAG = "720pFormatStrategy"; private static final int LONGER_LENGTH = 1280; private static final int SHORTER_LENGTH = 720; private static final int DEFAULT_VIDEO_BITRATE = 8000 * 1000; // From Nexus 4 Camera in 720p private final int mVideoBitrate; private final int mAudioBitrate; private final int mAudioChannels; public Android720pFormatStrategy() { this(DEFAULT_VIDEO_BITRATE); } public Android720pFormatStrategy(int videoBitrate) { this(videoBitrate, AUDIO_BITRATE_AS_IS, AUDIO_CHANNELS_AS_IS); } public Android720pFormatStrategy(int videoBitrate, int audioBitrate, int audioChannels) { mVideoBitrate = videoBitrate; mAudioBitrate = audioBitrate; mAudioChannels = audioChannels; } @Override public MediaFormat createVideoOutputFormat(MediaFormat inputFormat) { int width = inputFormat.getInteger(MediaFormat.KEY_WIDTH); int height = inputFormat.getInteger(MediaFormat.KEY_HEIGHT); int longer, shorter, outWidth, outHeight; if (width >= height) { longer = width; shorter = height; outWidth = LONGER_LENGTH; outHeight = SHORTER_LENGTH; } else { shorter = width; longer = height; outWidth = SHORTER_LENGTH; outHeight = LONGER_LENGTH; } if (longer * 9 != shorter * 16) { throw new OutputFormatUnavailableException("This video is not 16:9, and is not able to transcode. (" + width + "x" + height + ")"); } if (shorter <= SHORTER_LENGTH) { Log.d(TAG, "This video is less or equal to 720p, pass-through. (" + width + "x" + height + ")"); return null; } MediaFormat format = MediaFormat.createVideoFormat("video/avc", outWidth, outHeight); // From Nexus 4 Camera in 720p format.setInteger(MediaFormat.KEY_BIT_RATE, mVideoBitrate); format.setInteger(MediaFormat.KEY_FRAME_RATE, 30); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 3); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); return format; } @Override public MediaFormat createAudioOutputFormat(MediaFormat inputFormat) { if (mAudioBitrate == AUDIO_BITRATE_AS_IS || mAudioChannels == AUDIO_CHANNELS_AS_IS) return null; // Use original sample rate, as resampling is not supported yet. final MediaFormat format = MediaFormat.createAudioFormat(MediaFormatExtraConstants.MIMETYPE_AUDIO_AAC, inputFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE), mAudioChannels); format.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC); format.setInteger(MediaFormat.KEY_BIT_RATE, mAudioBitrate); return format; } }
20d9f83a18ea73e3bf9ce5abbc1fbb5f3a08d098
5634e33106cfc97b26d85b6b001235c472728338
/src/common/org/eclipse/swt/internal/mozilla/IIDStore.java
941774cd66e956d7981610eb3d0ce13ed9b04875
[]
no_license
my2iu/eclipse.swt.mozilla
8ade4ff16be2ac6808c0a33d5ca856285bcd0a5a
665a1114e4ff69e6ac749645ed7c1bf59c84b1ac
refs/heads/master
2021-01-10T06:53:47.825545
2016-03-01T22:26:38
2016-03-01T22:26:38
52,636,074
2
1
null
null
null
null
UTF-8
Java
false
false
2,708
java
/******************************************************************************* * Copyright (c) 2014, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.internal.mozilla; import java.util.HashMap; import org.eclipse.swt.internal.C; public abstract class IIDStore { static HashMap<Class<?>,nsID[]> IIDs = new HashMap<> (); public static nsID GetIID (Class<?> clazz) { return GetIID (clazz, MozillaVersion.GetCurrentVersion ()); } public static nsID GetIID (Class<?> clazz, int version) { return GetIID (clazz, version, false); } public static nsID GetIID (Class<?> clazz, int version, boolean exact) { if (version <= MozillaVersion.GetLatestVersion ()) { nsID[] table = IIDs.get (clazz); if (table == null) { /* The nsI* class has not been loaded, so attempt to create a default instance to make this happen */ try { Class<?> argType = C.PTR_SIZEOF == 4 ? Integer.TYPE : Long.TYPE; clazz.getConstructor (new Class<?>[] {argType}).newInstance (new Object[] {0}); table = IIDs.get (clazz); } catch (Exception e) { /* clazz appears to not be an nsI* class, which is not valid */ } } if (table != null) { if (exact) { return table[version]; } int defaultIIDIndex = MozillaVersion.GetLatestVersion () + 1; if (version == MozillaVersion.GetCurrentVersion () && table[defaultIIDIndex] != null) { return table[defaultIIDIndex]; /* the cached value */ } for (int i = version; MozillaVersion.VERSION_BASE <= i; i--) { if (table[i] != null) { if (version == MozillaVersion.GetCurrentVersion ()) { table[defaultIIDIndex] = table[i]; /* cache for future reference */ } return table[i]; } } } } return null; } protected static void RegisterIID (Class<?> clazz, int version, nsID iid) { if (version <= MozillaVersion.GetLatestVersion ()) { nsID[] table = IIDs.get (clazz); if (table == null) { /* * Note that the table's final slot is used to cache the iid for * the current version since this is the most frequently used one. */ table = new nsID[MozillaVersion.GetLatestVersion () + 2]; IIDs.put (clazz, table); } table[version] = iid; } } }
9734b87036be6e09d0af6b8c4733660a9bafd3d6
16b08aa2cc6d887c9a53f163af8bbf715d78a206
/app/src/main/java/com/jakester/nytarticlesapp/models/Response.java
189c0877dea181e503044c98b1f662b490be48b6
[ "Apache-2.0" ]
permissive
Jakester0813/NYTArticles
5afc3228e543fe1d3db549a0c049a05b905076fe
627f9d6781990641934c0da242846589dfcf3490
refs/heads/master
2021-08-14T08:49:55.657576
2017-11-15T06:14:09
2017-11-15T06:14:09
104,011,538
0
0
null
null
null
null
UTF-8
Java
false
false
330
java
package com.jakester.nytarticlesapp.models; import com.google.gson.annotations.SerializedName; /** * Created by Jake on 9/18/2017. */ public class Response { @SerializedName("response") ArticlesResponse mArticlesResponse; public ArticlesResponse getArticlesResponse(){ return mArticlesResponse; } }
d93ee6a58e6caac87827aa7d3c1a6c234bff42e8
b8c35e13f8268fd0f41d6f62c9bc8a6abf4112d9
/src/com/lalit/designPattern/proxy/dynamic/javapackage/cglib/example2/ContactList.java
1b4f8bb1a3e995eaf79afdb319d31d9e99d3149b
[]
no_license
lgoyal06/ReviseProgramming
c83f0e28238d955f294846fd2795537294622c66
2ea4fd1ccdef0753268228d4df0fd5c2118da575
refs/heads/master
2020-07-25T20:53:24.015777
2020-03-07T11:26:32
2020-03-07T11:26:32
208,421,020
0
0
null
null
null
null
UTF-8
Java
false
false
837
java
package com.lalit.designPattern.proxy.dynamic.javapackage.cglib.example2; import java.util.ArrayList; import java.util.List; //We want to defer loading of employee list until required public class ContactList { private List<Employee> employees; public List<Employee> getEmployees() { if (employees == null) { setEmployees(); } return employees; } private void setEmployees() { //Load from DB System.out.println("Loading Employee from DB"); List<Employee> listEmployee = new ArrayList<>(); listEmployee.add(new Employee(23, "A", "M")); listEmployee.add(new Employee(23, "B", "F")); listEmployee.add(new Employee(23, "C", "M")); listEmployee.add(new Employee(23, "D", "O")); this.employees = listEmployee; } }
[ "vaRaNa8!@#" ]
vaRaNa8!@#
7f49a31e47e032f855f8806753565b60f3c7a61a
48e835e6f176a8ac9ae3ca718e8922891f1e5a18
/benchmark/test/io/fabric8/maven/docker/wait/ExitCodeCheckerTest.java
28c16b3a4ebf8deb474577fccd46be73a77e84af
[]
no_license
STAMP-project/dspot-experiments
f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5
121487e65cdce6988081b67f21bbc6731354a47f
refs/heads/master
2023-02-07T14:40:12.919811
2019-11-06T07:17:09
2019-11-06T07:17:09
75,710,758
14
19
null
2023-01-26T23:57:41
2016-12-06T08:27:42
null
UTF-8
Java
false
false
2,212
java
package io.fabric8.maven.docker.wait; import io.fabric8.maven.docker.access.DockerAccessException; import io.fabric8.maven.docker.model.Container; import io.fabric8.maven.docker.service.QueryService; import mockit.Expectations; import mockit.Mocked; import org.junit.Test; public class ExitCodeCheckerTest { private static final String CONTAINER_ID = "1234"; @Mocked private QueryService queryService; @Mocked private Container container; @Test public void checkReturnsFalseIfContainerDoesNotExist() throws Exception { new Expectations() { { Exception e = new DockerAccessException("Cannot find container %s", ExitCodeCheckerTest.CONTAINER_ID); queryService.getMandatoryContainer(ExitCodeCheckerTest.CONTAINER_ID); result = e; } }; ExitCodeChecker checker = new ExitCodeChecker(0, queryService, ExitCodeCheckerTest.CONTAINER_ID); assertThat(checker.check()).isFalse(); } @Test public void checkReturnsFalseIfContainerIsStillRunning() throws Exception { new Expectations() { { container.getExitCode(); result = null; } }; ExitCodeChecker checker = new ExitCodeChecker(0, queryService, ExitCodeCheckerTest.CONTAINER_ID); assertThat(checker.check()).isFalse(); } @Test public void checkReturnsFalseIfActualExitCodeDoesNotMatchExpectedExitCode() throws Exception { new Expectations() { { container.getExitCode(); result = 1; } }; ExitCodeChecker checker = new ExitCodeChecker(0, queryService, ExitCodeCheckerTest.CONTAINER_ID); assertThat(checker.check()).isFalse(); } @Test public void checkReturnsTrueIfActualExitCodeMatchesExpectedExitCode() throws Exception { new Expectations() { { container.getExitCode(); result = 0; } }; ExitCodeChecker checker = new ExitCodeChecker(0, queryService, ExitCodeCheckerTest.CONTAINER_ID); assertThat(checker.check()).isTrue(); } }
29dc1eb1a0edd6d7835ede324510ef1af2ca95a0
b2ac08091476e3498e68ac4bc6ce02382d5933f0
/Spring/Spring-data/spring-data-redis/src/main/java/org/springframework/data/redis/core/RedisHash.java
f5dce8e55208fab3233c1243dd1c0ac7699234ac
[ "LicenseRef-scancode-generic-cla" ]
no_license
xuqb981956807/bagdata-study
3f4ffbbf6afee15981badec4c9947d11462585a5
944217eb7b8dee2d414f55341d36f0332e278cbc
refs/heads/master
2023-05-28T12:46:04.712048
2021-06-03T06:04:34
2021-06-03T06:04:34
373,395,925
0
0
null
null
null
null
UTF-8
Java
false
false
1,733
java
/* * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.data.redis.core; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.data.annotation.Persistent; import org.springframework.data.keyvalue.annotation.KeySpace; /** * {@link RedisHash} marks Objects as aggregate roots to be stored in a Redis hash. * * @author Christoph Strobl * @since 1.7 */ @Persistent @Documented @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE }) @KeySpace public @interface RedisHash { /** * The prefix to distinguish between domain types. * * @return * @see KeySpace */ @AliasFor(annotation = KeySpace.class, attribute = "value") String value() default ""; /** * Time before expire in seconds. Superseded by {@link TimeToLive}. * * @return positive number when expiration should be applied. */ long timeToLive() default -1L; }
15fae7f0b817119543ec5fba1b340f81804c9c28
d4dd8c017d7d2a87fb3050bb896dc6ee0c140e41
/tenant-mngt/net.onebean.tenant.mngt.service/src/main/java/net/onebean/tenant/mngt/common/MqExchangeNameEnum.java
65aa3d89abd1d6db1d7be49accf6a0706072022d
[ "Apache-2.0" ]
permissive
deeplearnings/Magnesium
a3c6b05a8eb91d270baec87a8c5b379f916b002c
5c78067f48a55dac9931ee52f2a36c0a1e24708b
refs/heads/master
2022-09-20T09:06:05.686914
2022-09-14T16:26:14
2022-09-14T16:26:14
223,410,478
0
0
null
2019-11-22T13:32:40
2019-11-22T13:32:40
null
UTF-8
Java
false
false
316
java
package net.onebean.tenant.mngt.common; public enum MqExchangeNameEnum { ; private String name; MqExchangeNameEnum(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
5841b8640095a7f50a5f67d5d7c076fe21ff8df7
f4906d82eff77bb0b0f6758c2b119622297ed721
/tttare_model/src/main/java/com/tttare/springDemo/model/designPattern/DemoExplain.java
384fcfa177a8005fc3ecb3885e2c99130656a741
[]
no_license
tttare/springBootDemo
6cba8015323b44e00cbff31a39ccef1b0998f3da
318ee91816ebc68ed8e7f047a7c6ec54aaf48dca
refs/heads/master
2022-11-23T12:47:56.753156
2019-12-26T14:46:43
2019-12-26T14:46:43
204,315,269
6
2
null
2022-11-16T10:52:46
2019-08-25T15:44:31
JavaScript
UTF-8
Java
false
false
247
java
package com.tttare.springDemo.model.designPattern; /** * ClassName: DemoExplain <br/> * Description: <br/> * date: 2019/9/24 20:34<br/> * * @author: tttare<br /> * @since JDK 1.8 */ public class DemoExplain { //设计模式专用包 }
7019ecd53b2f642ffa08792b05a4d268d565c0f7
5c4a6423aacfcea5071d5b7ea897056147f2376d
/rpct-masking/src/rpct/masking/utils/Layer.java
f71879de312106314dff87865ad4e9ee4dab5aa6
[]
no_license
muhammadimranfarooqi/RPC_DetectorConfiguration_CERN
9b84a241fa7817681e6daec70470548a361fbf92
cf7fb58d72919a4e8f9a4039ed110f6417d8fe3d
refs/heads/master
2022-07-20T15:53:22.830302
2019-07-31T17:02:56
2019-07-31T17:02:56
199,895,411
1
0
null
2022-07-08T18:56:25
2019-07-31T16:51:18
Java
UTF-8
Java
false
false
2,123
java
package rpct.masking.utils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public enum Layer { RB1IN("1in", 1, Division.BARREL), RB1OUT("1out", 2, Division.BARREL), RB2IN("2in", 3, Division.BARREL), RB2OUT("2out", 4, Division.BARREL), RB3("3", 5, Division.BARREL), RB4("4", 6, Division.BARREL), RING1("1", 1, Division.ENDCAP), RING2("2", 2, Division.ENDCAP), RING3("3", 3, Division.ENDCAP); private final String alias; private final int number; private final Division division; private Layer(String alias, int number, Division division) { this.alias = alias; this.number = number; this.division = division; } public String alias() { return alias; } public int number() { return number; } public Division division() { return division; } private static final Map<Division, Map<String, Layer>> aliasToLayer = new HashMap<Division, Map<String, Layer>>(); static { aliasToLayer.put(Division.BARREL, new HashMap<String, Layer>()); aliasToLayer.put(Division.ENDCAP, new HashMap<String, Layer>()); for (Layer each: Layer.values()) { final String key = each.alias.toUpperCase(); aliasToLayer.get(each.division).put(key, each); aliasToLayer.get(each.division).put(each.name().toUpperCase(), each); } } public static Layer get(Division division, String alias) throws IllegalArgumentException { final String key = alias.toUpperCase(); if (aliasToLayer.containsKey(division) && aliasToLayer.get(division).containsKey(key)) return aliasToLayer.get(division).get(key); else throw new IllegalArgumentException("Division '" + division + "', Layer '" + alias + "' is not defined!"); } public static final List<Layer> ALL_BARREL = new ArrayList<Layer>(); public static final List<Layer> ALL_ENDCAP = new ArrayList<Layer>(); static { for (Layer layer: Layer.values()) { if (layer.division() == Division.BARREL) ALL_BARREL.add(layer); else if (layer.division() == Division.ENDCAP) ALL_ENDCAP.add(layer); else throw new RuntimeException("Unknown division " + layer.division()); } } }
7d9d7912ba7f7fd9d4038bdaa724f91ecb1334ef
6df82496ebaba8cbe81ed6b188afb9bed38d6f1e
/firstApp/src/com/company/Main.java
b2feb1c9d1364989301ca500cfd37290d7bf53a8
[]
no_license
guvense/Java-Generics-Working-Notes
bd0a89ad75480bc9f8631fc8966b2a4f5f5d3961
26919a39c72d60a594ea326be344d7895c035ea6
refs/heads/master
2022-02-23T23:11:17.512337
2019-09-01T19:58:21
2019-09-01T19:58:21
204,205,539
1
0
null
null
null
null
UTF-8
Java
false
false
6,301
java
package com.company; import org.jetbrains.annotations.NotNull; import javax.print.attribute.standard.NumberUp; import java.util.*; public class Main { public static void main(String[] args) { // PECS List<Integer> a = new ArrayList<>(); a.add(1); List<? super Integer> numbers = a; numbers.add(0); sum(numbers); // List<Number> numbers = new ArrayList<>(); // numbers.add(2); // numbers.add(3.4); // assert numbers.toString().equals("[2,3.14]"); // compile time error because Lists are invariant // List<Integer> ints= new ArrayList<>(); // ints.add(1); // ints.add(2); // List<Number> numbers=ints; // List<Number> nums = new ArrayList<Number>(); // List<Integer> ints= Arrays.asList(1,2); // List<Double> doubles= Arrays.asList(2.78,3.14); // List<Integer> test= Collections.singletonList(1); // nums.addAll(ints); // nums.addAll(doubles); // nums.add(test.get(0)); // List<Integer> integers = new ArrayList<Integer>(); // integers.add(1); // integers.add(2); // // List<? extends Number> numbers = integers; // In general, if a structure contains elements with a type of the form ? extends E , we can // get elements out of the structure, but we cannot put elements into the structure // List<Object> objs = Arrays.asList(2, 3.14, "hi"); // List<Integer> ints = Arrays.asList(5, 6); // List<Double> doubles = Arrays.asList(1.1, 1.2); // double sum = sum(doubles); // System.out.println(sum); // // Extend e get okay but put is error // List<Integer> integers = new ArrayList<Integer>(); // integers.add(1); // integers.add(2); // List<? extends Number> nums = integers; // sum is fine because of get values // double sum = sum(nums); // // add is not except null because puts a value otherwise we can add double // nums.add(null); //You cannot //put anything into a type declared with an extends wildcard—except for the value //null , which belongs to every reference type // Super de ise put okay get fail // List<Object> objects = new ArrayList<>(); // objects.add(1); // List<? super Integer> integers1 = objects; // put a value is ok for super pecs // integers1.add(1); // error // sum(integers1); // The assignment violates the Get and Put Principle, be- // cause you cannot put a value into a type declared with an extends wildcard // Arrays // Why ? // Reified type is a run type representation of its component type // Integer[] f = new Integer[]{1, 2, 3}; // Number[] numbers = integers2; // numbers[2] = 3.14; // Wildcards also introduce contravariant subtyping for generics, in that type List<S> is //considered to be a subtype of List<? super T> when S is a supertype of T (as opposed //to a subtype). // generally get is okay for extends put is invalid except null // put is okay for super get is invalid except object } // Wildcard Capture // we write the values from T to T so its okay private static <T> void reverse0(List<T> list) { List<T> tmp = new ArrayList<T>(list); for (int i = 0; i< list.size(); i++){ list.set(i,tmp.get(list.size()-i-1)); } } // second // we write values from object to unknown type so its not okay /* public static void reverse2(List<?> list){ List<Object> tmp = new ArrayList<>(list); for(int i =0; i< list.size();i++){ list.set(i,tmp.get(list.size()-i-1)); } }*/ // wildcard capture public static void reverse(List<?> list) { rev(list); } private static <T> void rev(List<T> list) { List<T> tmp = new ArrayList<T>(list); for (int i = 0; i < list.size(); i++) { list.set(i, tmp.get(list.size()-i-1)); } } // Restrictions on Wildcards /* * 1. Instance creation * List<?> list= new ArrayList<?>(); compile time error * Nested is okey * List<List<?>> lists= new ArrayList< * List<?> list = new ArrayList<Object>(); // ok List<?> list = new List<Object>() // compile-time error Lİst interface List<?> list = new ArrayList<?>() // compile-time error wildcard object creation fail * The Java designers had in mind that every wildcard type is shorthand for some ordinary type, so they believed that ultimately every object should be created with an ordinary type * * 2. explicit type parameter cannot be wildcard * List<?> list = Lists.<?>factory(); // compile-time error (nested is okay) * * 3. class extends * class AnyList extends ArrayList<?> {...} // compile-time error (nested okay) * */ // PECS Producer extend consumer super or get put principle // producer get consumer set // private static <T> void copy(List<? super T> dst, List<? extends T> src) { // // for (int i = 0; i < src.size(); i++) { // dst.set(i, src.get(i)); // } // } // Works only if t is same type // public static <T> void copy1(List<T> dst, List<T> src){} // T is object // public static <T> void copy2(List<T> dst,List<? extends T> src){} // T is a Integer // public static <T> void copy3(List<? super T> dst, List<T> src){} // // object number integer // public static <T> void copy4(List<? super T> dst, List<? extends T> src){} // The Get and Put Principle: use an extends wildcard when you only get values out of a // structure, use a super wildcard when you only put values into a structure, and don’t use // a wildcard when you both get and put. // producer example private static double sum(@NotNull Collection<? extends Number> nums) { double s = 0.0; for (Number a : nums) s += a.doubleValue(); return s; } /* public static void count(Collection<? super Integer> ints, int n) { for (int i = 0; i < n; i++) ints.add(i); } */ }
6f36a1b3d72341e7f991730f74c8ce56f3bc3dc3
861774a4e110db7d9d8aec4f972359d5f4ad24d9
/app/src/main/java/com/fancy/myapplication/SuperVideoView.java
ae38cf05aeb8a38508e4c2024d64584787ee7d2b
[]
no_license
heiseyoumo/PengKuanWang
d95adddf65ac23ecbaf019b745d653289a3a80c0
3dcd40f2d5d5f22b3dbb70d36c65fbc6a9338c5c
refs/heads/master
2020-06-19T14:01:16.770222
2019-07-25T01:14:17
2019-07-25T01:14:17
196,735,408
0
0
null
null
null
null
UTF-8
Java
false
false
13,787
java
package com.fancy.myapplication; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.net.Uri; import android.os.Build; import android.os.Handler; import android.os.Message; import android.support.annotation.RequiresApi; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; /** * Created by Song on 2017/4/25. */ public class SuperVideoView extends RelativeLayout { private CustomVideoView videoView; private SeekBar seekbarProgress; private ImageView btnController; private TextView tvCurrentProgress; private TextView tvTotalProgress; private ImageView ivVolume; private SeekBar seekbarVolume; private ImageView btnScreen; private FrameLayout flVolume; private FrameLayout flLight; private LinearLayout llyController; private RelativeLayout rlContainer; private AudioManager mAudioManager; private int screenWidth; private int screenHeight; private Context mContext; private View videoLayout; private Activity mActivity; private int videoPos; private int state = 0; private boolean isVerticalScreen = true; private static final int UPDATE_PROGRESS = 1; public SuperVideoView(Context context) { this(context, null); } public SuperVideoView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SuperVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mContext = context; init(); initView(); initData(); initListener(); } public void register(Activity activity){ this.mActivity = activity; } /** * 设置媒体路径 * @param path */ public void setVideoPath(String path) { if(path.startsWith("http") || path.startsWith("https")) { videoView.setVideoURI(Uri.parse(path)); } else { videoView.setVideoPath(path); } } private void init() { screenWidth = ScreenUtils.getScreenWidth(mContext); screenHeight = ScreenUtils.getScreenHeight(mContext); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); IntentFilter filter = new IntentFilter("android.media.VOLUME_CHANGED_ACTION"); mContext.registerReceiver(new MyVolumeReceiver(),filter); } /** * UI 初始化 */ private void initView() { videoLayout = LayoutInflater.from(mContext).inflate(R.layout.video_layout, this, true); flVolume = (FrameLayout) videoLayout.findViewById(R.id.fl_volume); flLight = (FrameLayout) videoLayout.findViewById(R.id.fl_light); videoView = (CustomVideoView) videoLayout.findViewById(R.id.videoView); seekbarProgress = (SeekBar) videoLayout.findViewById(R.id.seekbar_progress); seekbarVolume = (SeekBar) videoLayout.findViewById(R.id.seekbar_volume); btnController = (ImageView) videoLayout.findViewById(R.id.btn_controller); btnScreen = (ImageView) videoLayout.findViewById(R.id.btn_screen); tvCurrentProgress = (TextView) videoLayout.findViewById(R.id.tv_currentProgress); tvTotalProgress = (TextView) videoLayout.findViewById(R.id.tv_totalProgress); ivVolume = (ImageView) videoLayout.findViewById(R.id.iv_volume); llyController = (LinearLayout) videoLayout.findViewById(R.id.lly_controller); rlContainer = (RelativeLayout) videoLayout.findViewById(R.id.rl_container); } /** * 初始化数据 */ private void initData() { int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); seekbarVolume.setProgress(currentVolume); } /** * 注册事件 */ private void initListener() { btnScreen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isVerticalScreen) { mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } }); btnController.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (videoView.isPlaying()) { btnController.setImageResource(R.drawable.btn_play_style); videoView.pause(); mHandler.removeMessages(UPDATE_PROGRESS); } else { btnController.setImageResource(R.drawable.btn_pause_style); videoView.start(); mHandler.sendEmptyMessage(UPDATE_PROGRESS); if (state == 0) state = 1; } } }); /** * 状态事件 */ videoView.setStateListener(new CustomVideoView.StateListener() { /** * 改变声音大小 */ @Override public void changeVolumn(float detlaY) { if(flVolume.getVisibility() == View.GONE){ flVolume.setVisibility(View.VISIBLE); } int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); int index = (int)(detlaY / screenHeight * maxVolume * 3); int volume = Math.max(0,currentVolume - index); mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,0); seekbarVolume.setProgress(volume); } /** * 改变屏幕亮度 * @param detlaX */ @RequiresApi(api = Build.VERSION_CODES.CUPCAKE) @Override public void changeBrightness(float detlaX) { if(flLight.getVisibility() == View.GONE){ flLight.setVisibility(View.VISIBLE); } WindowManager.LayoutParams wml = mActivity.getWindow().getAttributes(); float screenBrightness = wml.screenBrightness; float index = detlaX / screenWidth / 3; screenBrightness+=index; if(screenBrightness > 1.0f){ screenBrightness = 1.0f; } else if(screenBrightness < 0.01f){ screenBrightness = 0.01f; } wml.screenBrightness = screenBrightness; mActivity.getWindow().setAttributes(wml); } @Override public void hideHint() { if(flLight.getVisibility() == View.VISIBLE) { flLight.setVisibility(GONE); } if(flVolume.getVisibility() == View.VISIBLE) { flVolume.setVisibility(GONE); } } }); /** * 声音控制 */ seekbarVolume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); /** * 播放进度 */ seekbarProgress.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { updateTextViewFormat(tvCurrentProgress, progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // 暂停刷新 mHandler.removeMessages(UPDATE_PROGRESS); } @Override public void onStopTrackingTouch(SeekBar seekBar) { if (state != 0) { mHandler.sendEmptyMessage(UPDATE_PROGRESS); } videoView.seekTo(seekBar.getProgress()); } }); } /** * 屏幕状态改变 * @param newConfig */ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { //竖屏 isVerticalScreen = true; ivVolume.setVisibility(View.GONE); seekbarVolume.setVisibility(View.GONE); setVideoViewScale(ViewGroup.LayoutParams.MATCH_PARENT,ScreenUtils.dipToPx(mContext,290)); mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { isVerticalScreen = false; ivVolume.setVisibility(View.VISIBLE); seekbarVolume.setVisibility(View.VISIBLE); setVideoViewScale(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT); // 移除半屏状态 mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } /** * 切换尺寸 * @param width * @param height */ public void setVideoViewScale(int width, int height) { ViewGroup.LayoutParams videoViewLayoutParams = videoView.getLayoutParams(); videoViewLayoutParams.width = width; videoViewLayoutParams.height = height; videoView.setLayoutParams(videoViewLayoutParams); LayoutParams rlContainerLayoutParams = (LayoutParams) rlContainer.getLayoutParams(); rlContainerLayoutParams.width = width; rlContainerLayoutParams.height = height; rlContainer.setLayoutParams(rlContainerLayoutParams); } /** * 格式化时间进度 */ private void updateTextViewFormat(TextView tv, int m) { String result; // 毫秒转成秒 int second = m / 1000; int hour = second / 3600; int minute = second % 3600 / 60; int ss = second % 60; if (hour != 0) { result = String.format("%02d:%02d:%02d", hour, minute, ss); } else { result = String.format("%02d:%02d", minute, ss); } tv.setText(result); } private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { if (msg.what == UPDATE_PROGRESS) { // 获取当前时间 int currentTime = videoView.getCurrentPosition(); // 获取总时间 int totalTime = videoView.getDuration() - 100; if (currentTime >= totalTime) { videoView.pause(); videoView.seekTo(0); seekbarProgress.setProgress(0); btnController.setImageResource(R.drawable.btn_play_style); updateTextViewFormat(tvCurrentProgress, 0); mHandler.removeMessages(UPDATE_PROGRESS); } else { seekbarProgress.setMax(totalTime); seekbarProgress.setProgress(currentTime); updateTextViewFormat(tvCurrentProgress, currentTime); updateTextViewFormat(tvTotalProgress, totalTime); mHandler.sendEmptyMessageDelayed(UPDATE_PROGRESS, 100); } } } }; public void onPause() { videoPos = videoView.getCurrentPosition(); videoView.stopPlayback(); mHandler.removeMessages(UPDATE_PROGRESS); } public void onResume() { videoView.seekTo(videoPos); videoView.resume(); } /** * 设置播放进度条样式 * @param drawable */ public void setProgressBg(Drawable drawable) { seekbarProgress.setProgressDrawable(drawable); } /** * 设置声音控制条样式 * @param drawable */ public void setVolumeBg(Drawable drawable){ seekbarVolume.setProgressDrawable(drawable); } class MyVolumeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //如果音量发生变化则更改seekbar的位置 if(intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")){ // 当前的媒体音量 int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); seekbarVolume.setProgress(currentVolume); } } } }
e65d9f653556c69a8801b8e244e88aaece6c0958
b07642404c4f50a8dd4dcf6d523604777d64c8c8
/2020-04-11/chap08/sec02/exam02/CarExample.java
173a779ae962b9aa0bdcf60b248ff54883b11efb
[]
no_license
khh2hoya/JAVAStudy
99ed61e1ae49084cdb1bd2da9a835115d98a1eb0
990f531bd9213b72d8d9af830fdc49e4d23cf917
refs/heads/master
2021-05-23T16:47:57.592426
2020-06-08T07:20:06
2020-06-08T07:20:06
253,387,208
0
0
null
null
null
null
UTF-8
Java
false
false
225
java
package sec02.exam02; public class CarExample { public static void main(String[] args) { Driver driver = new Driver(); Bus bus = new Bus(); Texi taxi =new Texi(); driver.drive(bus); driver.drive(taxi); } }
0a2a7c63663ee3c41d057a354a5119f9669e7380
555de286cdf913fb59fec05493cdf82665a02df5
/src/main/java/com/mycompany/webapp/validator/Ch04MemberEmailValidator.java
d6ac6fef57a6248e2e7c7c0cb435164afefe44cf
[]
no_license
wandukong/SpringframeworkStudy
f276fd7cc185ae2fc71416b38ff5afd123fe9f9c
ecc56ab262e7142639df2fbecb4b51013b02522a
refs/heads/master
2023-08-28T16:43:54.496312
2021-10-22T08:35:39
2021-10-22T08:35:39
400,070,277
1
0
null
null
null
null
UTF-8
Java
false
false
1,199
java
package com.mycompany.webapp.validator; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.validation.Errors; import org.springframework.validation.Validator; import com.mycompany.webapp.dto.Ch04Member; public class Ch04MemberEmailValidator implements Validator { private static final Logger logger = LoggerFactory.getLogger(Ch04MemberEmailValidator.class); @Override public boolean supports(Class<?> clazz) { logger.info("memail supports 실행"); boolean check = Ch04Member.class.isAssignableFrom(clazz); return check; } @Override public void validate(Object target, Errors errors) { logger.info("memail validate 실행"); Ch04Member member = (Ch04Member) target; // memail 검사 if (member.getMemail() == null || member.getMemail().trim().equals("")) { errors.rejectValue("memail", "errors.memail.required"); } else { String regExp = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$"; Pattern pattern = Pattern.compile(regExp); if (!pattern.matcher(member.getMemail()).matches()) { errors.rejectValue("memail", "errors.memail.invalid"); } } } }
a38a705fe29c7c7f8e9b5643ec4bd8b5be2a7c04
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/10/10_ab84dc33d7547a13edd614fa58ee516a9c982fa1/UltimateArena/10_ab84dc33d7547a13edd614fa58ee516a9c982fa1_UltimateArena_s.java
78d49cb06d1046d4f85defdab1a216bcd10cde8d
[]
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
34,095
java
/** * UltimateArena - a bukkit plugin * Copyright (C) 2012 - 2014 MineSworn and Affiliates * * 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 net.dmulloy2.ultimatearena; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.logging.Level; import lombok.Getter; import net.dmulloy2.ultimatearena.arenas.Arena; import net.dmulloy2.ultimatearena.arenas.BOMBArena; import net.dmulloy2.ultimatearena.arenas.CONQUESTArena; import net.dmulloy2.ultimatearena.arenas.CTFArena; import net.dmulloy2.ultimatearena.arenas.FFAArena; import net.dmulloy2.ultimatearena.arenas.HUNGERArena; import net.dmulloy2.ultimatearena.arenas.INFECTArena; import net.dmulloy2.ultimatearena.arenas.KOTHArena; import net.dmulloy2.ultimatearena.arenas.MOBArena; import net.dmulloy2.ultimatearena.arenas.PVPArena; import net.dmulloy2.ultimatearena.arenas.SPLEEFArena; import net.dmulloy2.ultimatearena.commands.CmdClass; import net.dmulloy2.ultimatearena.commands.CmdClassList; import net.dmulloy2.ultimatearena.commands.CmdCreate; import net.dmulloy2.ultimatearena.commands.CmdDelete; import net.dmulloy2.ultimatearena.commands.CmdDisable; import net.dmulloy2.ultimatearena.commands.CmdDislike; import net.dmulloy2.ultimatearena.commands.CmdEnable; import net.dmulloy2.ultimatearena.commands.CmdForceStop; import net.dmulloy2.ultimatearena.commands.CmdHelp; import net.dmulloy2.ultimatearena.commands.CmdInfo; import net.dmulloy2.ultimatearena.commands.CmdJoin; import net.dmulloy2.ultimatearena.commands.CmdKick; import net.dmulloy2.ultimatearena.commands.CmdLeave; import net.dmulloy2.ultimatearena.commands.CmdLike; import net.dmulloy2.ultimatearena.commands.CmdList; import net.dmulloy2.ultimatearena.commands.CmdPause; import net.dmulloy2.ultimatearena.commands.CmdReload; import net.dmulloy2.ultimatearena.commands.CmdSetPoint; import net.dmulloy2.ultimatearena.commands.CmdSpectate; import net.dmulloy2.ultimatearena.commands.CmdStart; import net.dmulloy2.ultimatearena.commands.CmdStats; import net.dmulloy2.ultimatearena.commands.CmdStop; import net.dmulloy2.ultimatearena.commands.CmdVersion; import net.dmulloy2.ultimatearena.creation.ArenaCreator; import net.dmulloy2.ultimatearena.creation.BombCreator; import net.dmulloy2.ultimatearena.creation.CTFCreator; import net.dmulloy2.ultimatearena.creation.ConquestCreator; import net.dmulloy2.ultimatearena.creation.FFACreator; import net.dmulloy2.ultimatearena.creation.HungerCreator; import net.dmulloy2.ultimatearena.creation.InfectCreator; import net.dmulloy2.ultimatearena.creation.KOTHCreator; import net.dmulloy2.ultimatearena.creation.MobCreator; import net.dmulloy2.ultimatearena.creation.PvPCreator; import net.dmulloy2.ultimatearena.creation.SpleefCreator; import net.dmulloy2.ultimatearena.handlers.CommandHandler; import net.dmulloy2.ultimatearena.handlers.EssentialsHandler; import net.dmulloy2.ultimatearena.handlers.FileHandler; import net.dmulloy2.ultimatearena.handlers.LogHandler; import net.dmulloy2.ultimatearena.handlers.PermissionHandler; import net.dmulloy2.ultimatearena.handlers.SignHandler; import net.dmulloy2.ultimatearena.handlers.SpectatingHandler; import net.dmulloy2.ultimatearena.handlers.WorldEditHandler; import net.dmulloy2.ultimatearena.listeners.BlockListener; import net.dmulloy2.ultimatearena.listeners.EntityListener; import net.dmulloy2.ultimatearena.listeners.PlayerListener; import net.dmulloy2.ultimatearena.tasks.ArenaJoinTask; import net.dmulloy2.ultimatearena.types.ArenaClass; import net.dmulloy2.ultimatearena.types.ArenaConfig; import net.dmulloy2.ultimatearena.types.ArenaLocation; import net.dmulloy2.ultimatearena.types.ArenaPlayer; import net.dmulloy2.ultimatearena.types.ArenaSign; import net.dmulloy2.ultimatearena.types.ArenaZone; import net.dmulloy2.ultimatearena.types.FieldType; import net.dmulloy2.ultimatearena.types.LeaveReason; import net.dmulloy2.ultimatearena.types.Permission; import net.dmulloy2.ultimatearena.types.Reloadable; import net.dmulloy2.ultimatearena.types.SimpleVector; import net.dmulloy2.ultimatearena.util.FormatUtil; import net.dmulloy2.ultimatearena.util.InventoryUtil; import net.dmulloy2.ultimatearena.util.TimeUtil; import net.dmulloy2.ultimatearena.util.Util; import net.milkbowl.vault.economy.Economy; import org.bukkit.Location; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.serialization.ConfigurationSerialization; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import com.earth2me.essentials.Essentials; import com.sk89q.worldedit.bukkit.WorldEditPlugin; /** * @author dmulloy2 */ public class UltimateArena extends JavaPlugin implements Reloadable { // Handlers private @Getter PermissionHandler permissionHandler; private @Getter SpectatingHandler spectatingHandler; private @Getter CommandHandler commandHandler; private @Getter FileHandler fileHandler; private @Getter SignHandler signHandler; private @Getter LogHandler logHandler; // Integration private @Getter Economy economy; private @Getter WorldEditPlugin worldEdit; private @Getter WorldEditHandler worldEditHandler; private @Getter EssentialsHandler essentialsHandler; // Lists and Maps private @Getter HashMap<String, ArenaJoinTask> waiting = new HashMap<String, ArenaJoinTask>(); private @Getter List<ArenaCreator> makingArena = new ArrayList<ArenaCreator>(); private @Getter List<ArenaConfig> configs = new ArrayList<ArenaConfig>(); private @Getter List<ArenaClass> classes = new ArrayList<ArenaClass>(); private @Getter List<ArenaZone> loadedArenas = new ArrayList<ArenaZone>(); private @Getter List<String> whitelistedCommands = new ArrayList<String>(); private @Getter List<String> pluginsUsingAPI = new ArrayList<String>(); private List<Arena> activeArenas = new ArrayList<Arena>(); private @Getter boolean stopping; // Global prefix private @Getter String prefix = FormatUtil.format("&6[&4&lUA&6] "); @Override public void onEnable() { long start = System.currentTimeMillis(); // Register Handlers logHandler = new LogHandler(this); permissionHandler = new PermissionHandler(this); spectatingHandler = new SpectatingHandler(this); commandHandler = new CommandHandler(this); fileHandler = new FileHandler(this); // Integration setupVaultIntegration(); setupEssentialsIntegration(); setupWorldEditIntegration(); // IO Stuff checkDirectories(); saveDefaultConfig(); // Register Commands commandHandler.setCommandPrefix("ua"); commandHandler.registerCommand(new CmdClass(this)); commandHandler.registerCommand(new CmdClassList(this)); commandHandler.registerCommand(new CmdCreate(this)); commandHandler.registerCommand(new CmdDelete(this)); commandHandler.registerCommand(new CmdDisable(this)); commandHandler.registerCommand(new CmdDislike(this)); commandHandler.registerCommand(new CmdEnable(this)); commandHandler.registerCommand(new CmdForceStop(this)); commandHandler.registerCommand(new CmdHelp(this)); commandHandler.registerCommand(new CmdInfo(this)); commandHandler.registerCommand(new CmdJoin(this)); commandHandler.registerCommand(new CmdKick(this)); commandHandler.registerCommand(new CmdLeave(this)); commandHandler.registerCommand(new CmdLike(this)); commandHandler.registerCommand(new CmdList(this)); commandHandler.registerCommand(new CmdPause(this)); commandHandler.registerCommand(new CmdReload(this)); commandHandler.registerCommand(new CmdSetPoint(this)); commandHandler.registerCommand(new CmdSpectate(this)); commandHandler.registerCommand(new CmdStart(this)); commandHandler.registerCommand(new CmdStats(this)); commandHandler.registerCommand(new CmdStop(this)); commandHandler.registerCommand(new CmdVersion(this)); // Register Listeners PluginManager pm = getServer().getPluginManager(); pm.registerEvents(new EntityListener(this), this); pm.registerEvents(new BlockListener(this), this); pm.registerEvents(new PlayerListener(this), this); // Register serializables ConfigurationSerialization.registerClass(ArenaLocation.class); ConfigurationSerialization.registerClass(SimpleVector.class); ConfigurationSerialization.registerClass(ArenaSign.class); // Load files loadFiles(); // Arena Updater, runs every second new ArenaUpdateTask().runTaskTimer(this, 2L, TimeUtil.toTicks(1)); outConsole("{0} has been enabled ({1}ms)", getDescription().getFullName(), System.currentTimeMillis() - start); } @Override public void onDisable() { long start = System.currentTimeMillis(); // Unregister getServer().getServicesManager().unregisterAll(this); getServer().getScheduler().cancelTasks(this); stopping = true; // Stop all arenas stopAll(); // Save Signs signHandler.onDisable(); // Refresh arena saves for (ArenaZone az : loadedArenas) { az.save(); } // Clear Memory clearMemory(); outConsole("{0} has been disabled ({1}ms)", getDescription().getFullName(), System.currentTimeMillis() - start); } // Console logging public void outConsole(Level level, String string, Object... objects) { logHandler.log(level, FormatUtil.format(string, objects)); } public void outConsole(String string, Object... objects) { logHandler.log(string, objects); } public void debug(String string, Object... objects) { logHandler.debug(string, objects); } public void broadcast(String string, Object... objects) { String broadcast = FormatUtil.format(string, objects); getServer().broadcastMessage(prefix + broadcast); debug("Broadcasted message: {0}", broadcast); } /** * Loads all files. */ public void loadFiles() { loadClasses(); loadConfigs(); loadArenas(); loadSigns(); } /** * Basic reload method. */ @Override public void reload() { // Reload config reloadConfig(); // TODO: Check for deleted/new files when reloading // Reload configs for (ArenaConfig conf : Util.newList(configs)) { conf.reload(); } // Reload ArenaZones for (ArenaZone az : Util.newList(loadedArenas)) { az.reload(); } // Reload active arenas for (Arena a : Util.newList(activeArenas)) { a.reload(); } // Reload classes for (ArenaClass ac : Util.newList(classes)) { ac.reload(); } } /** * Sets up integration with Vault Economy */ public void setupVaultIntegration() { try { PluginManager pm = getServer().getPluginManager(); if (pm.isPluginEnabled("Vault")) { RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class); if (economyProvider != null) { economy = economyProvider.getProvider(); outConsole("Enabled economy through {0}!", economy.getName()); } else { outConsole("Failed to hook into Vault economy."); } } } catch (Throwable ex) { // } } /** * Sets up integration with WorldEdit */ private void setupWorldEditIntegration() { worldEditHandler = new WorldEditHandler(this); try { PluginManager pm = getServer().getPluginManager(); if (pm.isPluginEnabled("WorldEdit")) { Plugin plugin = pm.getPlugin("WorldEdit"); if (plugin instanceof WorldEditPlugin) { worldEdit = (WorldEditPlugin) plugin; worldEditHandler.setUseWorldEdit(getConfig().getBoolean("useWorldEdit", true)); outConsole("Integration with WorldEdit successful!"); return; } } } catch (Throwable ex) { worldEditHandler.setUseWorldEdit(false); } } /** * Sets up integration with Essentials */ private void setupEssentialsIntegration() { try { essentialsHandler = new EssentialsHandler(this); PluginManager pm = getServer().getPluginManager(); if (pm.isPluginEnabled("Essentials")) { Plugin plugin = pm.getPlugin("Essentials"); if (plugin instanceof Essentials) { essentialsHandler.setEssentials(plugin); essentialsHandler.setUseEssentials(true); outConsole("Integration with Essentials successful!"); return; } } } catch (Throwable ex) { // } } /** * Returns whether or not to use Essentials */ public final boolean useEssentials() { try { return essentialsHandler.useEssentials(); } catch (Throwable ex) { return false; } } // Create Directories private void checkDirectories() { debug("Checking directories!"); File dataFile = getDataFolder(); if (! dataFile.exists()) { dataFile.mkdir(); debug("Created data file!"); } File arenaFile = new File(getDataFolder(), "arenas"); if (! arenaFile.exists()) { arenaFile.mkdir(); debug("Created arenas directory!"); } File classFile = new File(getDataFolder(), "classes"); if (! classFile.exists()) { classFile.mkdir(); debug("Created classes directory!"); } File configsFile = new File(getDataFolder(), "configs"); if (! configsFile.exists()) { configsFile.mkdir(); debug("Created configs directory!"); } } // Load Stuff private void loadArenas() { File folder = new File(getDataFolder(), "arenas"); File[] children = folder.listFiles(); int total = 0; for (File file : children) { ArenaZone az = new ArenaZone(this, file); if (az.isLoaded()) { debug("Successfully loaded arena {0}!", az.getArenaName()); total++; } } outConsole("Loaded {0} arena files!", total); } private void loadConfigs() { int total = 0; for (FieldType type : FieldType.values()) { if (loadConfig(type.getName())) total++; } outConsole("Loaded {0} arena config files!", total); loadWhiteListedCommands(); } private void loadWhiteListedCommands() { File file = new File(getDataFolder(), "whiteListedCommands.yml"); if (! file.exists()) { generateWhitelistedCommands(); debug("Generating Whitelisted Commands file!"); } YamlConfiguration fc = YamlConfiguration.loadConfiguration(file); for (String cmd : fc.getStringList("whiteListedCmds")) { whitelistedCommands.add(cmd); } debug("Loaded {0} whitelisted commands!", fc.getStringList("whiteListedCmds").size()); } private boolean loadConfig(String str) { File folder = new File(getDataFolder(), "configs"); File file = new File(folder, str + "Config.yml"); if (! file.exists()) { debug("Generating config for: {0}", str); generateArenaConfig(str); } ArenaConfig a = new ArenaConfig(this, str, file); if (a.isLoaded()) { configs.add(a); return true; } return false; } private void loadClasses() { File folder = new File(getDataFolder(), "classes"); File[] children = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.getName().contains(".yml"); } }); if (children.length == 0) { generateStockClasses(); } children = folder.listFiles(); int total = 0; for (File file : children) { ArenaClass ac = new ArenaClass(this, file); if (ac.isLoaded()) { classes.add(ac); total++; } } outConsole("Loaded {0} Arena Classes!", total); } /** * Generates the WhiteListedCommands file */ private void generateWhitelistedCommands() { saveResource("whiteListedCommands.yml", false); } /** * Generates an arena config for a particular field * * @param field * - Field to generate config for */ private void generateArenaConfig(String field) { saveResource("configs" + File.separator + field + "Config.yml", false); } /** * Generates stock classes */ private void generateStockClasses() { String[] stockClasses = new String[] { "archer", "brute", "dumbass", "gunner", "healer", "shotgun", "sniper", "spleef" }; for (String stockClass : stockClasses) { saveResource("classes" + File.separator + stockClass + ".yml", false); } } private void loadSigns() { signHandler = new SignHandler(this); outConsole("Loaded {0} arena signs!", signHandler.getSigns().size()); } public ArenaConfig getConfig(String type) { for (ArenaConfig ac : Util.newList(configs)) { if (ac.getArenaName().equalsIgnoreCase(type)) return ac; } return null; } public void stopAll() { for (Arena a : Util.newList(activeArenas)) { a.stop(); } activeArenas.clear(); } public ArenaClass getArenaClass(String line) { for (ArenaClass ac : Util.newList(classes)) { if (ac.getName().equalsIgnoreCase(line)) return ac; } return null; } // Delete Stuff! public void deleteArena(Player player, String str) { ArenaZone az = getArenaZone(str); if (az != null) { // Delete the file File file = az.getFile(); if (file.exists()) { file.delete(); } // Stop the active arena, if applicable for (Arena a : Util.newList(activeArenas)) { if (a.getName().equalsIgnoreCase(str)) { a.stop(); } } // Delete any signs for (ArenaSign sign : signHandler.getSigns(az)) { signHandler.deleteSign(sign); } // Remove it from the list loadedArenas.remove(az); player.sendMessage(prefix + FormatUtil.format("&3Successfully deleted arena: &e{0}", str)); outConsole("Successfully deleted arena: {0}!", str); } else { player.sendMessage(prefix + FormatUtil.format("&cCould not find an arena by the name of \"{0}\"!", str)); } } // ---- Locational Checks ---- // public ArenaZone getZoneInside(Location location) { for (ArenaZone az : Util.newList(loadedArenas)) { if (az.checkLocation(location)) return az; } return null; } public Arena getArenaInside(Location location) { ArenaZone az = getZoneInside(location); if (az != null) return getArena(az.getArenaName()); return null; } public boolean isInArena(Location loc) { return getZoneInside(loc) != null; } public boolean isInArena(ArenaLocation loc) { return isInArena(loc.getLocation()); } // Special case for player public boolean isInArena(Player player) { return getArenaPlayer(player) != null; } public ArenaPlayer getArenaPlayer(Player player, boolean inactive) { for (Arena a : Util.newList(activeArenas)) { ArenaPlayer ap = a.getArenaPlayer(player, inactive); if (ap != null) return ap; } return null; } public ArenaPlayer getArenaPlayer(Player player) { return getArenaPlayer(player, false); } public void attemptJoin(Player player, String arena) { if (! permissionHandler.hasPermission(player, Permission.JOIN)) { player.sendMessage(prefix + FormatUtil.format("&cYou do not have permission to do this!")); return; } if (isCreatingArena(player)) { player.sendMessage(prefix + FormatUtil.format("&cYou are in the middle of making an arena!")); return; } if (! InventoryUtil.isEmpty(player.getInventory())) { if (! getConfig().getBoolean("saveInventories")) { player.sendMessage(prefix + FormatUtil.format("&cPlease clear your inventory!")); return; } } ArenaZone a = getArenaZone(arena); if (a == null) { player.sendMessage(prefix + FormatUtil.format("&3Unknown arena: &e{0}", arena)); List<ArenaZone> matches = matchArena(arena); if (matches.size() > 0) { StringBuilder matchString = new StringBuilder(); for (ArenaZone match : matches) { matchString.append("&e" + match.getArenaName() + "&3, "); } matchString.replace(matchString.lastIndexOf(","), matchString.lastIndexOf(" "), "?"); if (matchString.lastIndexOf(",") >= 0) { matchString.replace(matchString.lastIndexOf(","), matchString.lastIndexOf(","), "or"); } player.sendMessage(prefix + FormatUtil.format("&3Did you mean {0}", matchString.toString())); } return; } if (isInArena(player)) { player.sendMessage(prefix + FormatUtil.format("&cYou are already in an arena!")); return; } ArenaPlayer ap = getArenaPlayer(player, true); if (ap != null) { Arena ar = ap.getArena(); if (ar != null) { if (ar.getName().equalsIgnoreCase(arena)) { if (ar.isInGame()) { player.sendMessage(prefix + FormatUtil.format("&cYou cannot leave and rejoin this arena!")); return; } } } } if (isPlayerWaiting(player)) { player.sendMessage(prefix + FormatUtil.format("&cYou are already waiting!")); return; } ArenaJoinTask join = new ArenaJoinTask(player.getName(), arena, this); if (getConfig().getBoolean("joinTimer.enabled")) { int seconds = getConfig().getInt("joinTimer.wait"); int wait = seconds * 20; join.runTaskLater(this, wait); waiting.put(player.getName(), join); player.sendMessage(prefix + FormatUtil.format("&3Please stand still for &e{0} &3seconds!", seconds)); } else { join.run(); } } public void join(Player player, String name) { boolean forced = permissionHandler.hasPermission(player, Permission.JOIN_FORCE); ArenaZone az = getArenaZone(name); Arena a = getArena(name); if (a != null) { if (a.isStopped()) { // Will only occur while the arena is stopping, so this message is valid player.sendMessage(prefix + FormatUtil.format("&cThis arena is currently stopping")); return; } if (a.isInLobby()) { if (a.getPlayerCount() + 1 <= az.getMaxPlayers()) { a.addPlayer(player); } else { if (! forced) { player.sendMessage(prefix + FormatUtil.format("&cThis arena is full!")); } else { if (kickRandomPlayer(a)) { a.addPlayer(player); } else { player.sendMessage(prefix + FormatUtil.format("&cCould not join the arena!")); } } } } else { player.sendMessage(prefix + FormatUtil.format("&cThis arena has already started!")); } } else { if (az.isDisabled()) { player.sendMessage(prefix + FormatUtil.format("&cThis arena is disabled!")); return; } Arena arena = null; switch (az.getType()) { case BOMB: arena = new BOMBArena(az); break; case CONQUEST: arena = new CONQUESTArena(az); break; case CTF: arena = new CTFArena(az); break; case FFA: arena = new FFAArena(az); break; case HUNGER: arena = new HUNGERArena(az); break; case INFECT: arena = new INFECTArena(az); break; case KOTH: arena = new KOTHArena(az); break; case MOB: arena = new MOBArena(az); break; case PVP: arena = new PVPArena(az); break; case SPLEEF: arena = new SPLEEFArena(az); break; } // Won't ever be null, but just in case if (arena == null) { player.sendMessage(prefix + FormatUtil.format("&cCould not find a valid arena for the type: {0}", az.getType())); return; } activeArenas.add(arena); arena.addPlayer(player); arena.announce(); } } // Kicks a random player if the arena is full // This will only be called if someone with forcejoin joins public boolean kickRandomPlayer(Arena arena) { List<ArenaPlayer> validPlayers = new ArrayList<ArenaPlayer>(); List<ArenaPlayer> totalPlayers = arena.getActivePlayers(); for (ArenaPlayer ap : totalPlayers) { if (! permissionHandler.hasPermission(ap.getPlayer(), Permission.JOIN_FORCE)) { validPlayers.add(ap); } } int rand = Util.random(validPlayers.size()); ArenaPlayer apl = validPlayers.get(rand); if (apl != null) { apl.leaveArena(LeaveReason.KICK); return true; } return false; } // Gets the arena a player is in public Arena getArena(Player player) { for (int i = 0; i < activeArenas.size(); i++) { Arena a = activeArenas.get(i); ArenaPlayer ap = a.getArenaPlayer(player); if (ap != null) { if (ap.getName().equals(player.getName())) return a; } } return null; } // Gets an arena by its name public Arena getArena(String name) { for (int i = 0; i < activeArenas.size(); i++) { Arena ac = activeArenas.get(i); if (ac.getName().equalsIgnoreCase(name)) return ac; } return null; } public List<ArenaZone> matchArena(String partial) { List<ArenaZone> ret = new ArrayList<ArenaZone>(); for (int i = 0; i < loadedArenas.size(); i++) { ArenaZone az = loadedArenas.get(i); if (az.getArenaName().contains(partial)) ret.add(az); } return ret; } // Gets an arena zone by its name public ArenaZone getArenaZone(String name) { for (int i = 0; i < loadedArenas.size(); i++) { ArenaZone az = loadedArenas.get(i); if (az.getArenaName().equalsIgnoreCase(name)) return az; } return null; } // ---- Arena Creation ----// /** * Attempts to create a new {@link Arena} * * @param player * - {@link Player} who is creating the arena * @param name * - Name of the new arena * @param type * - Type of the new arena */ public void createArena(Player player, String name, String type) { if (isCreatingArena(player)) { player.sendMessage(prefix + FormatUtil.format("&cYou are already creating an arena!")); return; } if (! FieldType.contains(type.toLowerCase())) { player.sendMessage(prefix + FormatUtil.format("\"{0}\" is not a valid field type!", type)); return; } FieldType fieldType = FieldType.getByName(type); for (ArenaZone az : Util.newList(loadedArenas)) { if (az.getArenaName().equalsIgnoreCase(name)) { player.sendMessage(prefix + FormatUtil.format("&cAn arena by this name already exists!")); return; } } ArenaCreator ac = null; switch (fieldType) { case BOMB: ac = new BombCreator(player, name, this); break; case CONQUEST: ac = new ConquestCreator(player, name, this); break; case CTF: ac = new CTFCreator(player, name, this); break; case FFA: ac = new FFACreator(player, name, this); break; case HUNGER: ac = new HungerCreator(player, name, this); break; case INFECT: ac = new InfectCreator(player, name, this); break; case KOTH: ac = new KOTHCreator(player, name, this); break; case MOB: ac = new MobCreator(player, name, this); break; case PVP: ac = new PvPCreator(player, name, this); break; case SPLEEF: ac = new SpleefCreator(player, name, this); break; } // It won't ever be null, but just in case... if (ac == null) { player.sendMessage(prefix + FormatUtil.format("&cCould not find an applicable ArenaCreator for \"{0}\"", type)); return; } outConsole("{0} has started the creation of Arena: {1}. Type: {2}", player.getName(), name, type); makingArena.add(ac); } /** * Returns a player's {@link ArenaCreator} instance * <p> * Will return <code>null</code> if the player is not creating an arena. * * @param player * - {@link Player} to get {@link ArenaCreator} instance for. * * @return The player's {@link ArenaCreator} instance */ public ArenaCreator getArenaCreator(Player player) { for (ArenaCreator ac : Util.newList(makingArena)) { if (ac.getPlayer().getName().equalsIgnoreCase(player.getName())) return ac; } return null; } /** * Returns whether or not a {@link Player} is creating an arena. * * @param player * - {@link Player} to check * @return Whether or not a {@link Player} is creating an arena. */ public boolean isCreatingArena(Player player) { return getArenaCreator(player) != null; } /** * Sets a point in the arena creation process * * @param player * - {@link Player} setting the point */ public void setPoint(Player player, String[] args) { if (! isCreatingArena(player)) { player.sendMessage(prefix + FormatUtil.format("&cYou are not creating an arena!")); return; } ArenaCreator ac = getArenaCreator(player); ac.setPoint(args); } /** * Stops the creation of an arena * * @param player * - {@link Player} who is stopping */ public void stopCreatingArena(Player player) { ArenaCreator ac = getArenaCreator(player); if (ac.getPlayer().getName().equalsIgnoreCase(player.getName())) { makingArena.remove(ac); player.sendMessage(prefix + FormatUtil.format("&3Stopped the creation of arena: &e{0}", ac.getArenaName())); } } /** * Clears memory */ public void clearMemory() { whitelistedCommands.clear(); loadedArenas.clear(); activeArenas.clear(); makingArena.clear(); waiting.clear(); classes.clear(); configs.clear(); } /** * Accepts registration from a {@link JavaPlugin} * * @param plugin * - {@link JavaPlugin} to accept the registration from */ public void acceptRegistration(JavaPlugin plugin) { outConsole("Accepted API registration from {0}", plugin.getName()); pluginsUsingAPI.add(plugin.getName()); } /** * Dumps plugins currently using the UltimateArena API */ public void dumpRegistrations() { if (pluginsUsingAPI.isEmpty()) { outConsole("No plugins currently using the UltimateArena API"); return; } StringBuilder line = new StringBuilder(); line.append("Plugins currently using the UltimateArena API: "); for (String name : pluginsUsingAPI) { line.append(name + ", "); } line.replace(line.lastIndexOf(","), line.lastIndexOf(" "), ""); outConsole(line.toString()); } /** * Returns whether or not a command is whitelisted * * @param command * - Command to check * @return Whether or not a command is whitelisted */ public final boolean isWhitelistedCommand(String command) { for (String cmd : whitelistedCommands) { if (cmd.matches(cmd.contains("/") ? "" : "/" + cmd + ".*")) return true; } return false; } public final boolean isPlayerWaiting(Player player) { return waiting.containsKey(player.getName()); } /** * Returns how many arenas have been played * <p> * Will return 1 if none have been played * * @return How many arenas have been played */ public final int getTotalArenasPlayed() { int ret = 0; for (ArenaZone az : loadedArenas) { ret += az.getTimesPlayed(); } return ret > 0 ? ret : 1; } /** * Returns a list of active arenas * <p> * Should not be used to add or remove */ public final List<Arena> getActiveArenas() { return Util.newList(activeArenas); } /** * Removes an active {@link Arena} * * @param a * - Arena to remove */ public final void removeActiveArena(Arena a) { activeArenas.remove(a); } /** * Arena Update Task * <p> * While I hate to use it, it works. */ public class ArenaUpdateTask extends BukkitRunnable { @Override public void run() { for (Arena arena : getActiveArenas()) { arena.update(); } } } }
d9bcb5860652f2d09bbb88fb9565f2ca63f467fc
3f2d01d5a4f435b25cc0a54edf13af725f979a8f
/src/main/java/seva/sahyog/sahashiksha/dao/impl/TeacherDaoImpl.java
2e748fc12be966313501adffc7782bc77e415ce0
[]
no_license
dcoolnik/seva_sahyog_services
de426c581f7352acd76a9a0989b4f6a5d5ce8a42
f0c087976a8c5f1445433135cbe120fd91d6bd63
refs/heads/master
2022-12-31T04:21:00.755880
2020-10-04T13:09:08
2020-10-04T13:09:08
280,888,036
2
0
null
2020-09-07T05:21:41
2020-07-19T14:56:04
Java
UTF-8
Java
false
false
1,211
java
package seva.sahyog.sahashiksha.dao.impl; import org.hibernate.query.Query; import seva.sahyog.sahashiksha.dao.DaoTemplate; import seva.sahyog.sahashiksha.dao.TeacherDao; import seva.sahyog.sahashiksha.dto.Teacher; import java.util.List; import java.util.stream.Collectors; public class TeacherDaoImpl extends DaoTemplate implements TeacherDao { @Override public List<Teacher> getAllTeachers() { Query<Teacher> query = getCurrentSession().createQuery("from Teacher t", Teacher.class); return query.getResultList(); } @Override public List<Teacher> getAllActiveTeachers() { return getAllTeachers().stream() .filter(Teacher::isActive) .collect(Collectors.toList()); } @Override public Teacher getTeacherForId(long id) { Query<Teacher> query = getCurrentSession().createQuery("from Teacher t where" + " t.teacherId=:teacherId", Teacher.class); query.setParameter("teacherId", id); return query.uniqueResult(); } @Override public long saveTeacher(Teacher teacher) { getCurrentSession().saveOrUpdate(teacher); return teacher.getTeacherId(); } }
8a6d4f777e9058cb5fd6890476348698829d286c
2d214fc472b51f698d46430f72f974eded596c91
/src/main/java/com/episen/ing3/jag/episenscajagbackend/controller/Controller.java
834eb395254704104654a9bae85aef09beca79b1
[]
no_license
JAguesse/episen-sca-jag-backend
22df2ede7660c34f3afe701e270c302ac9b0806b
a410cf644996b16e815822693de05bd53777e112
refs/heads/main
2022-12-27T13:58:07.689025
2020-10-17T10:38:43
2020-10-17T10:38:43
304,049,813
0
0
null
null
null
null
UTF-8
Java
false
false
1,362
java
package com.episen.ing3.jag.episenscajagbackend.controller; import java.io.IOException; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.episen.ing3.jag.episenscajagbackend.EpisenScaJagBackendApplication; import com.fasterxml.jackson.annotation.JsonAutoDetect; import lombok.extern.slf4j.Slf4j; @RestController @Slf4j @JsonAutoDetect public class Controller { @PostMapping("/add/order") @ResponseBody public ResponseEntity<String> createTweet(@RequestBody String chat) throws IOException { log.info(chat.toString()); EpisenScaJagBackendApplication.chartreuse.add(chat); EpisenScaJagBackendApplication.write.write(chat + System.lineSeparator()); EpisenScaJagBackendApplication.write.flush(); return ResponseEntity.ok(chat); } @GetMapping("/monChat") @ResponseBody public ResponseEntity<String> createTweet() { try { return ResponseEntity.ok(EpisenScaJagBackendApplication.chartreuse.get(EpisenScaJagBackendApplication.chartreuse.size()-1)); }catch (Exception e) { e.printStackTrace(); } return null; } }
f5c069f799b696fbfc5413511f2e6cfeed7ee8e5
24dc3b0442b332d6baaffc047ca10fb43659d8b2
/app/src/test/java/com/joss/achords/ExampleUnitTest.java
482c561f71d48d21d88f4ac5a554d17b60f4e1d7
[]
no_license
joss94/achords
e9c05f1cecefaef8454bd839e36182931f6523d2
3f4f55bb01229c650e08252cb141481cfa78c795
refs/heads/master
2021-01-13T11:58:21.146167
2017-04-24T01:42:44
2017-04-24T01:42:44
81,142,869
0
0
null
null
null
null
UTF-8
Java
false
false
421
java
package com.joss.achords; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * 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); } }
497bc42a4021a20e09fbd55c3ea9f067f0dc9e57
5d0e5b9aa7fbe92b9d93becec243064384513c1f
/app/src/main/java/com/example/moham/footnews/ui/activity/WebViewActivity.java
7819bec2431f001631336ab9e1db1433e06458b0
[]
no_license
mohamedmabrouk582/FootNews
8aa567075f36558a549475fe05ff31e8047c864b
42f4d36a4b7f3970be873cbc8af7324fa684d06c
refs/heads/master
2020-03-28T11:18:21.966507
2018-09-10T18:42:46
2018-09-10T18:42:46
148,199,717
0
0
null
null
null
null
UTF-8
Java
false
false
2,119
java
package com.example.moham.footnews.ui.activity; import android.content.Context; import android.content.Intent; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import com.example.moham.footnews.R; import com.example.moham.footnews.base.activity.BaseActivity; public class WebViewActivity extends BaseActivity { private static String URLFB="url"; WebView mWebView; ProgressBar mProgressBar; private String mUri; public static void start(Context context, String url){ Intent intent=new Intent(context,WebViewActivity.class); intent.putExtra(URLFB,url); context.startActivity(intent); } @Override public int setContentView() { return R.layout.web_view_activty; } @Override public void iniViews() { mWebView=bind(R.id.fb_web_view); mProgressBar=bind(R.id.fb_progress_par); mUri=getIntent().getStringExtra(URLFB); mProgressBar.setMax(100); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebChromeClient(new WebChromeClient(){ @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress==100){ mProgressBar.setVisibility(View.GONE); }else{ mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setProgress(newProgress); } } @Override public void onReceivedTitle(WebView view, String title) { getSupportActionBar().setTitle(title); } }); mWebView.setWebViewClient(new WebViewClient() { /****************** determines what will happen when a new URL is loaded in the WebView *******************/ public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } }); mWebView.loadUrl(String.valueOf(mUri)); } }
052b24b3c13ea73a5b57c6e712706db9dcd2be0f
2d5cdaacd7d99bb3c658c4fa78edbfe9cfc72f88
/app/src/main/java/com/bysj/xl/chess/mychess/WebSocket/WsEvent/WebSocketConnectionErrorEvent.java
84ccfafbaa3ba63e9eadf074dbbcca73cc5bed10
[]
no_license
xianglei960811/MyChess
109827e2d9434ff80840ec965efc84e3eca85ae2
af6a165c2262652de902352b1d59bd45145248ed
refs/heads/master
2020-03-29T05:01:04.188821
2019-04-27T05:09:55
2019-04-27T05:09:55
149,561,434
0
0
null
null
null
null
UTF-8
Java
false
false
277
java
package com.bysj.xl.chess.mychess.WebSocket.WsEvent; /** * author:向磊 * date:2018/9/18 * Describe:连接错误事件 */ public class WebSocketConnectionErrorEvent { String msg; public WebSocketConnectionErrorEvent(String msg) { this.msg = msg; } }
81a3349870f73d92da502bae5422e7e04aa0a9b9
29c5c5d7225abe3ce068d4cc819803747c47b3e7
/src/org/jacorb/orb/giop/ServerGIOPConnection.java
3712c2aad072dc99a77767ec2a1be79b6b621d4d
[]
no_license
wolfc/jacorb
308a770016586ce3e8f902507ba1bde295df78c1
40e0ec34c36fdcfe67b67a9ceba729e1d4581899
refs/heads/master
2020-05-02T12:50:56.097066
2010-05-25T22:23:05
2010-05-25T22:23:05
686,203
0
1
null
null
null
null
UTF-8
Java
false
false
7,493
java
/* * JacORB - a free Java ORB * * Copyright (C) 1997-2004 Gerald Brose. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package org.jacorb.orb.giop; import org.jacorb.config.*; import org.jacorb.orb.iiop.IIOPConnection; /** * @author Nicolas Noffke * @version $Id: ServerGIOPConnection.java,v 1.26 2009-04-25 10:10:36 andre.spiegel Exp $ */ public class ServerGIOPConnection extends GIOPConnection { private static final byte[] CLOSE_CONNECTION_MESSAGE = new byte[] { // Byte casts are for JDK1.2 compatibility. (byte )'G', (byte )'I', (byte )'O', (byte )'P', //magic start 1, //GIOP major 0, //GIOP minor 0, //endianess, big-endian 5, //message type, CloseConnection message 0, 0, 0, 0 // message size, 0 because CloseConnection has no body }; private final GIOPConnectionManager manager; private boolean closeOnReadTimeout = false; private boolean delayClose = false; public ServerGIOPConnection( org.omg.ETF.Profile profile, org.omg.ETF.Connection transport, RequestListener request_listener, ReplyListener reply_listener, StatisticsProvider statistics_provider, GIOPConnectionManager manager ) { super( profile, transport, request_listener, reply_listener, statistics_provider ); this.manager = manager; } public void configure(Configuration configuration) throws ConfigurationException { super.configure(configuration); delayClose = configuration.getAttribute("jacorb.connection.delay_close","off").equals("on"); } /** * Try an orderly shutdown of this connection by sending a * CloseConnection message. The CORBA spec only allows us to * do that if we have no more pending messages for which we * haven't sent a reply yet (CORBA 3.0, 15.5.1.1). If there are * pending messages, this method does nothing and returns false. * If there are no pending messages, it sets the connection into * discarding mode, sends the CloseConnection message, and reports * the connection as closed to any connection_listener that's registered * with this connection. The actual closing of the connection will happen * later, when the transport gets closed by the client, or the final * timeout has passed. */ boolean tryClose() { if( tryDiscard() ) { if (logger.isDebugEnabled()) { logger.debug(this.toString() + ": tryClose() -- will send close connection"); } sendCloseConnection(); closeOnReadTimeout = true; if( connection_listener != null ) { connection_listener.connectionClosed(); } return true; } if (logger.isDebugEnabled()) { logger.debug(this.toString() + ": tryClose() -- cannot close connection"); } return false; } /** * Atomically try to set this connection into discarding mode, if * it doesn't have any pending messages. * * @return true, if the connection has been idle and discarding * has been set */ private boolean tryDiscard() { if( ! hasPendingMessages() ) { synchronized( pendingUndecidedSync ) { discard_messages = true; } return true; } return false; } /** * Sends a close connection message flushing the transport. */ private void sendCloseConnection() { try { getWriteLock(); write( CLOSE_CONNECTION_MESSAGE, 0, CLOSE_CONNECTION_MESSAGE.length ); transport.flush(); if (getStatisticsProviderAdapter() != null) { getStatisticsProviderAdapter().flushed(); } if( delayClose && transport instanceof IIOPConnection ) { ((IIOPConnection)transport).turnOnFinalTimeout(); } else { // Set do_close to true so anything waiting in waitUntilConnection // doesn't think there is a possibility of connecting. I think. do_close = true; transport.close(); } } catch( org.omg.CORBA.COMM_FAILURE e ) { logger.error ( "COMM_FAILURE in sendCloseConnection(), in " + this.toString(), e ); } finally { releaseWriteLock(); } if( manager != null ) { manager.unregisterServerGIOPConnection( this ); } } /** * Server-side implementation what to do when a read timeout occurs. * We react by trying an orderly shutdown that's initiated with * a CloseConnection message. If this timeout occured after we have * already sent CloseConnection, just close down unconditionally. */ protected void readTimedOut() { if (logger.isDebugEnabled()) { logger.debug (this.toString() + ": readTimedOut()"); } if( closeOnReadTimeout ) { // we get here if we have sent a CloseConnection message // on this connection before close(); } else { // attempt an orderly shutdown by sending a CloseConnection // message tryClose(); } } /** * Server-side implementation what to do if the underlying transport * gets closed during a read operation. Since we're server-side and * can't reopen, we simply close completely. */ protected void streamClosed() { if (logger.isDebugEnabled()) { logger.debug (this.toString() + ": streamClosed()"); } close(); } /** * @see GIOPConnection#close() */ public void close() { super.close(); if( manager != null ) { manager.unregisterServerGIOPConnection( this ); } } public String toString() { if (profile != null) { return "ServerGIOPConnection to " + profile.toString() + " (" + Integer.toHexString(this.hashCode()) + ")"; } return super.toString(); } }// ServerGIOPConnection
9c8ab1ade240e520626f23d478d03f3031c38f22
59a03fa15eeb78d66784fb29718f361d19396004
/mall-coupon/src/main/java/com/kelvin/mall/coupon/service/impl/HomeSubjectServiceImpl.java
37cce93652fce0ec15da8a2eac7113621b646c10
[]
no_license
KaiwenSu-Kelvin/KelvinMall
3e0ed4dffb06069916878ffd772d4b4a26ff063f
0a9ddfedad626251d9ac8283028e602401ea1a5d
refs/heads/main
2023-08-16T23:11:51.866675
2021-09-15T09:18:47
2021-09-15T09:18:47
406,327,805
0
0
null
null
null
null
UTF-8
Java
false
false
1,006
java
package com.kelvin.mall.coupon.service.impl; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.kelvin.common.utils.PageUtils; import com.kelvin.common.utils.Query; import com.kelvin.mall.coupon.dao.HomeSubjectDao; import com.kelvin.mall.coupon.entity.HomeSubjectEntity; import com.kelvin.mall.coupon.service.HomeSubjectService; @Service("homeSubjectService") public class HomeSubjectServiceImpl extends ServiceImpl<HomeSubjectDao, HomeSubjectEntity> implements HomeSubjectService { @Override public PageUtils queryPage(Map<String, Object> params) { IPage<HomeSubjectEntity> page = this.page( new Query<HomeSubjectEntity>().getPage(params), new QueryWrapper<HomeSubjectEntity>() ); return new PageUtils(page); } }
8b978c6bef60a6c30e73ec9b4acc837a6c57c461
764c94d4cf116b0e4d98a38e842e4e6a0468a666
/ebaysdkcore/src/main/java/com/ebay/soap/eBLBaseComponents/ShipmentStatusCodeType.java
972051569f5c9ddfe25112c58e839e37c5554ff4
[]
no_license
linus87/ebaysdk
26dde361dbb75e03fca137eaf6a61c5e892f1303
2fb2cbade57ae654fa83ae1b7c5f3e4f741b1fc1
refs/heads/master
2023-07-19T10:34:02.644641
2021-06-01T13:30:36
2021-06-01T13:30:36
150,661,586
1
0
null
2023-07-18T06:53:34
2018-09-28T00:06:01
Java
UTF-8
Java
false
false
1,511
java
package com.ebay.soap.eBLBaseComponents; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for ShipmentStatusCodeType. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="ShipmentStatusCodeType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}token"> * &lt;enumeration value="Active"/> * &lt;enumeration value="Canceled"/> * &lt;enumeration value="CustomCode"/> * &lt;/restriction> * &lt;/simpleType> * </pre> * * Note: Per JAXB standards, underscores are added to separate words in enumerations (e.g., PayPal becomes PAY_PAL). */ @XmlType(name = "ShipmentStatusCodeType") @XmlEnum public enum ShipmentStatusCodeType { @XmlEnumValue("Active") ACTIVE("Active"), @XmlEnumValue("Canceled") CANCELED("Canceled"), @XmlEnumValue("CustomCode") CUSTOM_CODE("CustomCode"); private final String value; ShipmentStatusCodeType(String v) { value = v; } public String value() { return value; } public static ShipmentStatusCodeType fromValue(String v) { for (ShipmentStatusCodeType c: ShipmentStatusCodeType.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } }
57a0a80484db96d4b0ddce3169625524cea9ddcb
68cb9036f99be362d7b976e3668c680d79f80cb0
/spff/com.sp.platform.web/src/main/java/com/sp/platform/web/action/cp/CpbillAction.java
043f9075ae0d9c1eae69cc649f3313d96e346090
[]
no_license
mopdzz/sp-platform
53184d6a663fda1b2ce15b3220331fe928d65e2a
cc545ff2fd71b53f2d12eaa31671048ed8001eb2
refs/heads/master
2021-01-20T02:16:33.601502
2014-04-01T16:25:02
2014-04-01T16:25:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,649
java
package com.sp.platform.web.action.cp; import com.opensymphony.xwork2.ActionSupport; import com.sp.platform.cache.CpSyncCache; import com.sp.platform.cache.SpInfoCache; import com.sp.platform.common.GroupType; import com.sp.platform.common.PageView; import com.sp.platform.entity.User; import com.sp.platform.service.BillLogService; import com.sp.platform.service.SpInfoService; import com.sp.platform.service.UserService; import com.sp.platform.vo.BillVo; import com.yangl.common.Constants; import com.yangl.common.Struts2Utils; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import java.io.UnsupportedEncodingException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * User: yangl * Date: 13-5-30 上午3:08 */ @Namespace("/cp") @Scope("prototype") @InterceptorRefs({@InterceptorRef("loginInterceptor")}) @Results({@Result(name = "list", location = "bill_list.jsp")}) public class CpbillAction extends ActionSupport { @Autowired private BillLogService billLogService; @Autowired private UserService userService; @Autowired private SpInfoService spInfoService; private PageView pageView = new PageView(); private List<BillVo> list; private List list3; public String list() { if (pageView == null) { pageView = new PageView(); } if (StringUtils.isEmpty(pageView.getBtime()) || StringUtils.isEmpty(pageView.getEtime())) { DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String shj = format.format(new Date()); pageView.setBtime(shj); pageView.setEtime(shj); } if (StringUtils.isNotBlank(pageView.getProvince())) { try { pageView.setProvince(new String(pageView.getProvince().getBytes("ISO-8859-1"), "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } User user = (User) Struts2Utils.getSession().getAttribute(Constants.SESSION_KEY); if (user.getRole() == 10) { pageView.setParentId(user.getId()); } else if (StringUtils.isBlank(pageView.getGroup2())) { pageView.setCpid(user.getId()); pageView.setGroup2(GroupType.GROUP_CALLED.getType() + ""); } list = billLogService.getCpBillInfo(pageView); if (list != null) { int groupType = 3; if (StringUtils.isNotBlank(pageView.getGroup())) { try { groupType = Integer.parseInt(pageView.getGroup()); } catch (Exception e) { } } for (BillVo bean : list) { if ("总计".equals(bean.getGroup())) { continue; } if (bean.getType() == 1) { if (StringUtils.isNotBlank(bean.getHref())) { bean.setGroup(bean.getHref() + SpInfoCache.getSpInfoName(toInt(bean.getGroup())) + "</a>"); } else { bean.setGroup(bean.getGroup()); } } else if (bean.getType() == 2) { if (StringUtils.isNotBlank(bean.getHref())) { bean.setGroup(bean.getHref() + CpSyncCache.getCpName(toInt(bean.getGroup())) + "</a>"); } else { bean.setGroup(CpSyncCache.getCpName(toInt(bean.getGroup()))); } } else { if (StringUtils.isNotBlank(bean.getHref())) { bean.setGroup(bean.getHref() + bean.getGroup() + "</a>"); } else { bean.setGroup(bean.getGroup()); } } } } return "list"; } private int toInt(String val) { if (StringUtils.isBlank(val)) { return 3; } else { return Integer.parseInt(val); } } public List<BillVo> getList() { return list; } public void setList(List<BillVo> list) { this.list = list; } public PageView getPageView() { return pageView; } public void setPageView(PageView pageView) { this.pageView = pageView; } public List getList3() { return list3; } public void setList3(List list3) { this.list3 = list3; } }
63a2daa197b1ae55da6a2df724f4184c47bce26f
6653b02b0b9255f532d923b20d0db738199a8003
/app/src/androidTest/java/com/acme/a3csci3130/EraseTest.java
3188957043895e1b29549b53064909b071c05118
[]
no_license
Waichung1015/A3csci3130
55343f80123d0c8a5f5f7425d0497b78177d4037
6c1ce13493d908ac23386e257d50365f84985c50
refs/heads/master
2020-03-21T21:43:55.274672
2018-06-30T17:47:44
2018-06-30T17:47:44
139,080,707
0
0
null
null
null
null
UTF-8
Java
false
false
996
java
package com.acme.a3csci3130; import android.support.test.rule.ActivityTestRule; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onData; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static org.hamcrest.CoreMatchers.anything; import static org.hamcrest.core.AllOf.allOf; import org.junit.Rule; import org.junit.Test; public class EraseTest { @Rule public ActivityTestRule<MainActivity> myact = new ActivityTestRule<MainActivity>(MainActivity.class); @Test public void remove() throws Exception{ Thread.sleep(5000); onData(anything()).inAdapterView(allOf(withId(R.id.listView), isCompletelyDisplayed())).atPosition(0).perform(click()); onView(withId(R.id.deleteButton)).perform(click()); } }
4601fd9649bd0be20e1bf9fe2524ff92e5f701f1
8e5a7c322244f65ac30596c183d7451e7330d3f5
/src/main/java/com/nnamdi/account/service/UserDetailsImpl.java
14c8468199b68850c1e62842446e45ed5f06138f
[]
no_license
nnamdi16/AccountMicroService
c76c2edcc941e572b6da72dae39fd3b1cc5604d2
0181ef818d11e8bac92834de3c451f4479012608
refs/heads/main
2023-04-02T05:37:14.082761
2021-04-12T08:19:34
2021-04-12T08:19:34
348,112,746
0
0
null
2021-04-12T08:19:34
2021-03-15T20:26:18
Java
UTF-8
Java
false
false
2,589
java
package com.nnamdi.account.service; import com.fasterxml.jackson.annotation.JsonIgnore; import com.nnamdi.account.model.Account; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; public class UserDetailsImpl implements UserDetails { private static final long serialVersionUID = 1L; private Long id; private String username; private String email; @JsonIgnore private String password; private Collection<? extends GrantedAuthority> authorities; public UserDetailsImpl(Long id, String username, String email, String password, Collection<? extends GrantedAuthority> authorities) { this.id = id; this.username = username; this.email = email; this.password = password; this.authorities = authorities; } public static UserDetailsImpl build(Account account) { List<GrantedAuthority> authorities = account.getRoles().stream() .map(role -> new SimpleGrantedAuthority(role.getName().name())) .collect(Collectors.toList()); return new UserDetailsImpl( account.getAccountId(), account.getUsername(), account.getEmail(), account.getPassword(), authorities ); } @Override public Collection<? extends GrantedAuthority> getAuthorities() { return authorities; } public Long getId() { return id; } public String getEmail() { return email; } @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } @Override public boolean isAccountNonExpired() { return true; } @Override public boolean isAccountNonLocked() { return true; } @Override public boolean isCredentialsNonExpired() { return true; } @Override public boolean isEnabled() { return true; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UserDetailsImpl userDetails = (UserDetailsImpl) o; return Objects.equals(id, userDetails.id); } }
46ee0337b560988eb144156d8e1f1cb98d63d812
f15ed061666638f51596391bfd729da07846b481
/fantacalcio-coredomain-user/src/test/java/com/javangarda/fantacalcio/user/infrastructure/port/adapter/messaging/ExternalMessageEmailCommandSenderTest.java
d9abdfb73cce4e7dec38516b00bb82d430b08e58
[]
no_license
acichon89/fantacalcio
4a2925b5bdfc6710dc3f48d0e777905a4e587716
39bd842fdc0d676dd1f998133a36a3de69b2a015
refs/heads/master
2021-04-12T04:22:58.078653
2017-03-27T18:43:25
2017-03-27T18:43:25
40,620,164
0
1
null
2016-12-02T21:25:57
2015-08-12T19:30:54
Java
UTF-8
Java
false
false
1,408
java
package com.javangarda.fantacalcio.user.infrastructure.port.adapter.messaging; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import static org.junit.Assert.assertEquals; @RunWith(MockitoJUnitRunner.class) public class ExternalMessageEmailCommandSenderTest { @Mock private Events events; @InjectMocks private ExternalMessageEmailCommandSender externalMessageEmailCommandSender; @Test public void shouldSendMessageToChannel(){ //given: MessageChannel messageChannel = Mockito.mock(MessageChannel.class); Mockito.when(events.activationMailChannel()).thenReturn(messageChannel); //when: externalMessageEmailCommandSender.sendConfirmationEmail("[email protected]", "test123"); //then: ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class); Mockito.verify(messageChannel).send(messageArgumentCaptor.capture()); assertEquals("[email protected]", messageArgumentCaptor.getValue().getPayload()); assertEquals("test123", messageArgumentCaptor.getValue().getHeaders().get("activationToken")); } }
9b1603dc4760a18d0856f0f891dd67be0c486b49
6cc87a0f2651f9596123a9cbad1b880fa2f4b93c
/common/src/main/java/com/project/common/preference/Utils.java
5a4ffc64c8758bd7275c5a0fa3c47c99485ebf28
[]
no_license
ruirong1997/cim
13c9dbb35269dad87ef4a680a677409ebf1e7adc
d00b915a5e2344d34fc3bb0c17b053853c12dc34
refs/heads/master
2023-07-15T07:54:44.291156
2021-08-18T06:20:03
2021-08-18T06:20:03
397,440,352
0
0
null
null
null
null
UTF-8
Java
false
false
2,195
java
/* * Copyright (C) 2010-2013 TENCENT Inc.All Rights Reserved. * * Description: 与应用和业务无关的工具类 * * History: * 1.0 dancycai ([email protected]) 2013-7-10 Created */ package com.project.common.preference; import android.util.SparseArray; import java.util.Collection; import java.util.Map; public class Utils { private static final String TAG = "Utils"; private static final boolean DEBUG = false; public static boolean isEmpty(final String str) { return str == null || str.length() <= 0; } public static boolean isEmpty(final SparseArray sparseArray) { return sparseArray == null || sparseArray.size() <= 0; } public static boolean isEmpty(final Collection<? extends Object> collection) { return collection == null || collection.size() <= 0; } public static boolean isEmpty(final Map<? extends Object, ? extends Object> list) { return list == null || list.size() <= 0; } public static boolean isEmpty(final byte[] bytes) { return bytes == null || bytes.length <= 0; } public static boolean isEmpty(final String[] strArr) { return strArr == null || strArr.length <= 0; } public static int nullAs(final Integer obj, final int def) { return obj == null ? def : obj; } public static long nullAs(final Long obj, final long def) { return obj == null ? def : obj; } public static boolean nullAs(final Boolean obj, final boolean def) { return obj == null ? def : obj; } public static String nullAs(final String obj, final String def) { return obj == null ? def : obj; } public static String emptyAs(final String obj, final String def) { return isEmpty(obj) ? def : obj; } public static int nullAsNil(final Integer obj) { return obj == null ? 0 : obj; } public static long nullAsNil(final Long obj) { return obj == null ? 0L : obj; } public static String nullAsNil(final String obj) { return obj == null ? "" : obj; } public static boolean isEmpty(int[] si) { return si == null || si.length == 0; } }
9e5024043b385040c04c4afe123d3e4a7ea4ff1b
986eb8d6a0f447ad9c1c85ec17af33228cfbd66d
/src/JDBC/myResultSetMetaData.java
2735bdc5866fc7d1adc06de738f529951ec09979
[]
no_license
aliiitarek/DBMS-and-JDBC
b995b4ae818a92924f159abbd4ed24206f5d114f
ae22b1b1f001b52b2f83151d50da62033f1adfdb
refs/heads/master
2021-01-22T23:57:55.089304
2014-10-01T13:33:22
2014-10-01T13:33:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,800
java
package JDBC; import java.sql.SQLException; import java.util.StringTokenizer; public class myResultSetMetaData implements java.sql.ResultSetMetaData { private String table[][]; private int length; private int width; private String tableName = null; public myResultSetMetaData(String Table[][], String _tableName) { length = Table.length; width = Table[0].length; table = new String[length][width]; table = Table; tableName = _tableName; } @Override public boolean isWrapperFor(Class<?> arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public <T> T unwrap(Class<T> arg0) throws SQLException { // TODO Auto-generated method stub return null; } @Override public String getCatalogName(int arg0) throws SQLException { // TODO Auto-generated method stub return null; } @Override public String getColumnClassName(int arg0) throws SQLException { // TODO Auto-generated method stub return null; } @Override public int getColumnCount() throws SQLException { // TODO Auto-generated method stub return this.width; } @Override public int getColumnDisplaySize(int arg0) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public String getColumnLabel(int col) throws SQLException { // TODO Auto-generated method stub if (col <= this.width && col >= 1) { col--; String str = table[0][col]; StringTokenizer token = new StringTokenizer(str, ","); String label = token.nextToken(); return label; } else throw new SQLException("column requested out of table bounds "); } @Override public String getColumnName(int col) throws SQLException { // TODO Auto-generated method stub if (col <= this.width && col >= 1) { col--; String str = table[0][col]; StringTokenizer token = new StringTokenizer(str, ","); String label = token.nextToken(); return label; } else throw new SQLException("column requested out of table bounds "); } @Override public int getColumnType(int col) throws SQLException { // TODO Auto-generated method stub if (col <= width && col >= 1) { col--; String str = table[0][col]; StringTokenizer token = new StringTokenizer(str, ","); String name = token.nextToken(); String type = token.nextToken(); /* * possible errors here according . we should check accurately the * name of types returned by amr to make sure they match the words * here . anyway I wrote them now and can be modified in * logartithmic time easily :P :D */ if (type.equals("double")) return java.sql.Types.DOUBLE; else if (type.equals("integer")) return java.sql.Types.INTEGER; else if (type.equals("string")) return java.sql.Types.VARCHAR; else if (type.equals("boolean")) return java.sql.Types.BOOLEAN; else if (type.equals("date")) return java.sql.Types.DATE; else return java.sql.Types.NULL; } else throw new SQLException("column requested out of table bounds"); } @Override public String getColumnTypeName(int col) throws SQLException { if (col <= this.width && col >= 1) { col--; String str = table[0][col]; StringTokenizer token = new StringTokenizer(str, ","); String name = token.nextToken(); String type = token.nextToken(); return type; } else throw new SQLException("column requested out of table bounds"); } @Override public int getPrecision(int arg0) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getScale(int arg0) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public String getSchemaName(int arg0) throws SQLException { // TODO Auto-generated method stub return null; } @Override public String getTableName(int col) throws SQLException { // TODO Auto-generated method stub if (col <= width && col >= 1) { col--; return this.tableName; } else throw new SQLException("column requested out of table bounds"); } @Override public boolean isAutoIncrement(int col) throws SQLException { // TODO Auto-generated method stub // if (col <= width && col >= 1) { // // col--; // if (this.getColumnType(col) != java.sql.Types.INTEGER) // return false; // else { // // for (int i = 1; i < length - 1; i++) { // int Integer1 = Integer.parseInt(table[i][col]); // int Integer2 = Integer.parseInt(table[i + 1][col]); // // if (Integer2 != Integer1 + 1) // return false; // // } // // return true; // // } // // } else // throw new SQLException("column requested out of table bounds"); return false; } @Override public boolean isCaseSensitive(int arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean isCurrency(int arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean isDefinitelyWritable(int arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public int isNullable(int arg0) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public boolean isReadOnly(int arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean isSearchable(int arg0) throws SQLException { // TODO Auto-generated method stub // return false; this is the default value return true; } @Override public boolean isSigned(int arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean isWritable(int arg0) throws SQLException { // TODO Auto-generated method stub // return false; this is the default value ; return true; } }
05eb897c5bfb824402504da27566776c6d686b2e
bf4896d4eeca31bb24ce7e06ef2c969a40f22f77
/src/main/java/com/bookstore/webservice/mypage/MyPageVO.java
b99ae369257af30d5ed9e12466918479ae8147ec
[]
no_license
Bamnamo/bookstore-webservice
d83b895680eb14b43c53062d2adfbe9961321d8a
00e03419035b977ca7b900de23e7efcd01733e32
refs/heads/master
2023-03-13T16:23:25.860555
2021-03-11T05:04:01
2021-03-11T05:04:01
323,324,791
0
0
null
null
null
null
UTF-8
Java
false
false
182
java
package com.bookstore.webservice.mypage; import lombok.Data; @Data public class MyPageVO { private String memberId; private String beginDate; private String endDate; }
916b3af38702fdf11155540d6a6e7e8a7e3f7649
1389c6c3b68a84caf267c4b9c0304f096631064a
/app/src/main/java/com/example/news/adapter/NothingSelectedSpinnerAdapter.java
182d722d9f2812885d119ba54604d5054662dbf7
[]
no_license
Mustafahandour/News
c497bfc7db3f5d2b4ba1f3c74d1b81786c5fbeb9
b06c40630d0b5e13d536c92e3421424e7435a249
refs/heads/master
2020-11-29T02:49:43.635666
2020-09-06T01:16:58
2020-09-06T01:16:58
240,777,348
0
1
null
null
null
null
UTF-8
Java
false
false
5,471
java
package com.example.news.adapter; import android.content.Context; import android.database.DataSetObserver; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListAdapter; import android.widget.SpinnerAdapter; /** * Decorator Adapter to allow a Spinner to show a 'Nothing Selected...' initially * displayed instead of the first choice in the Adapter. */ public class NothingSelectedSpinnerAdapter implements SpinnerAdapter, ListAdapter { protected static final int EXTRA = 1; protected SpinnerAdapter adapter; protected Context context; protected int nothingSelectedLayout; protected int nothingSelectedDropdownLayout; protected LayoutInflater layoutInflater; /** * Use this constructor to have NO 'Select One...' item, instead use * the standard prompt or nothing at all. * * @param spinnerAdapter wrapped Adapter. * @param nothingSelectedLayout layout for nothing selected, perhaps * you want text grayed out like a prompt... * @param context */ public NothingSelectedSpinnerAdapter( SpinnerAdapter spinnerAdapter, int nothingSelectedLayout, Context context) { this(spinnerAdapter, nothingSelectedLayout, -1, context); } /** * Use this constructor to Define your 'Select One...' layout as the first * row in the returned choices. * If you do this, you probably don't want a prompt on your spinner or it'll * have two 'Select' rows. * * @param spinnerAdapter wrapped Adapter. Should probably return false for isEnabled(0) * @param nothingSelectedLayout layout for nothing selected, perhaps you want * text grayed out like a prompt... * @param nothingSelectedDropdownLayout layout for your 'Select an Item...' in * the dropdown. * @param context */ public NothingSelectedSpinnerAdapter(SpinnerAdapter spinnerAdapter, int nothingSelectedLayout, int nothingSelectedDropdownLayout, Context context) { this.adapter = spinnerAdapter; this.context = context; this.nothingSelectedLayout = nothingSelectedLayout; this.nothingSelectedDropdownLayout = nothingSelectedDropdownLayout; layoutInflater = LayoutInflater.from(context); } @Override public final View getView(int position, View convertView, ViewGroup parent) { // This provides the View for the Selected Item in the Spinner, not // the dropdown (unless dropdownView is not set). if (position == 0) { return getNothingSelectedView(parent); } return adapter.getView(position - EXTRA, null, parent); // Could re-use // the convertView if possible. } /** * View to show in Spinner with Nothing Selected * Override this to do something dynamic... e.g. "37 Options Found" * * @param parent * @return */ protected View getNothingSelectedView(ViewGroup parent) { return layoutInflater.inflate(nothingSelectedLayout, parent, false); } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { // Android BUG! http://code.google.com/p/android/issues/detail?id=17128 - // Spinner does not support multiple view types if (position == 0) { return nothingSelectedDropdownLayout == -1 ? new View(context) : getNothingSelectedDropdownView(parent); } // Could re-use the convertView if possible, use setTag... return adapter.getDropDownView(position - EXTRA, null, parent); } /** * Override this to do something dynamic... For example, "Pick your favorite * of these 37". * * @param parent * @return */ protected View getNothingSelectedDropdownView(ViewGroup parent) { return layoutInflater.inflate(nothingSelectedDropdownLayout, parent, false); } @Override public int getCount() { int count = adapter.getCount(); return count == 0 ? 0 : count + EXTRA; } @Override public Object getItem(int position) { return position == 0 ? null : adapter.getItem(position - EXTRA); } @Override public int getItemViewType(int position) { return 0; } @Override public int getViewTypeCount() { return 1; } @Override public long getItemId(int position) { return position >= EXTRA ? adapter.getItemId(position - EXTRA) : position - EXTRA; } @Override public boolean hasStableIds() { return adapter.hasStableIds(); } @Override public boolean isEmpty() { return adapter.isEmpty(); } @Override public void registerDataSetObserver(DataSetObserver observer) { adapter.registerDataSetObserver(observer); } @Override public void unregisterDataSetObserver(DataSetObserver observer) { adapter.unregisterDataSetObserver(observer); } @Override public boolean areAllItemsEnabled() { return false; } @Override public boolean isEnabled(int position) { return position != 0; // Don't allow the 'nothing selected' // item to be picked. } }
36ad7c05247e5125d5c68a9833713b531e035131
70f1bfd96a60bef80896a25a4cfefbaee43a4bf8
/src/main/java/top/kwseeker/concurrency/concurrent_module/lock/StampedLockDemo.java
70ab17dd4962609731be173a6fd41b346b52d83c
[]
no_license
kwseeker/concurrency
2a0a52970a09dd0b12c2fadea5c22d7f87df6a77
0f23bb3903dc5da5fbe4383801a4aeb0fe69abf2
refs/heads/master
2023-04-02T18:35:17.241839
2023-03-22T06:06:01
2023-03-22T06:06:01
150,627,836
2
0
null
null
null
null
UTF-8
Java
false
false
2,784
java
package top.kwseeker.concurrency.concurrent_module.lock; import java.util.concurrent.locks.StampedLock; /** * StampedLock 也是读写锁,同时是乐观锁 * * 控制锁的方式: * 读: * 写: * 乐观读: * */ // StampedLock 源码作者给的一个 Demo // TODO: 代码有点难以理解,需要继续研究源码实现 public class StampedLockDemo { class Point { private double x, y; private final StampedLock sl = new StampedLock(); void move(double deltaX, double deltaY) { // an exclusively locked method long stamp = sl.writeLock(); try { x += deltaX; y += deltaY; } finally { sl.unlockWrite(stamp); } } //下面看看乐观读锁案例 double distanceFromOrigin() { // A read-only method long stamp = sl.tryOptimisticRead(); //获得一个乐观读锁 double currentX = x, currentY = y; //将两个字段读入本地局部变量 if (!sl.validate(stamp)) { //检查发出乐观读锁后同时是否有其他写锁发生?如果没有写锁,乐观读的字段有效;否则需要补救 stamp = sl.readLock(); //乐观读时有写锁发生,加悲观读锁重新读取 try { currentX = x; // 将两个字段读入本地局部变量 currentY = y; // 将两个字段读入本地局部变量 } finally { sl.unlockRead(stamp); } } return Math.sqrt(currentX * currentX + currentY * currentY); } //下面是悲观读锁案例 void moveIfAtOrigin(double newX, double newY) { // upgrade // Could instead start with optimistic, not read mode long stamp = sl.readLock(); try { while (x == 0.0 && y == 0.0) { //循环,检查当前状态是否符合 long ws = sl.tryConvertToWriteLock(stamp); //将读锁转为写锁 if (ws != 0L) { //这是确认转为写锁是否成功 stamp = ws; //如果成功 替换票据 x = newX; //进行状态改变 y = newY; //进行状态改变 break; } else { //如果不能成功转换为写锁 sl.unlockRead(stamp); //我们显式释放读锁 stamp = sl.writeLock(); //显式直接进行写锁 然后再通过循环再试 } } } finally { sl.unlock(stamp); //释放读锁或写锁 } } } }
d8d7d500010953d3ceaca0baebe463ee9af95a3a
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/shardingjdbc--sharding-jdbc/07843a3064b8856cbd3b0909b0abdaa414d54d4a/after/AggregationResultSetTest.java
f27708237670a94ee35e7eed1cfd389c02bf291a
[]
no_license
fracz/refactor-extractor
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
dd5e82bfcc376e74a99e18c2bf54c95676914272
refs/heads/master
2021-01-19T06:50:08.211003
2018-11-30T13:00:57
2018-11-30T13:00:57
87,353,478
0
0
null
null
null
null
UTF-8
Java
false
false
7,450
java
/** * Copyright 1999-2015 dangdang.com. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * 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. * </p> */ package com.dangdang.ddframe.rdb.sharding.merger.aggregation; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory; import com.dangdang.ddframe.rdb.sharding.merger.fixture.MergerTestUtil; import com.dangdang.ddframe.rdb.sharding.merger.fixture.MockResultSet; import com.dangdang.ddframe.rdb.sharding.parser.result.merger.AggregationColumn.AggregationType; import com.dangdang.ddframe.rdb.sharding.parser.result.merger.MergeContext; import com.google.common.base.Optional; import lombok.RequiredArgsConstructor; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @RunWith(Parameterized.class) @RequiredArgsConstructor public final class AggregationResultSetTest { private final TestTarget type; private final AggregationType aggregationType; private final List<String> columns; private final List<Integer> resultSet1; private final List<Integer> resultSet2; private final Optional<String> nameOfGetResult; private final Class<? extends Number> resultClass; private final Number result; @Parameterized.Parameters(name = "{index}: testTarget:{0}, aggregation type:{1}, columns:{2}, r1:{3}, r2:{4}, rsName:{5}, rsClass:{6}, result:{7}") public static Collection init() { return Arrays.asList(new Object[][]{ {TestTarget.INDEX, AggregationType.SUM, Collections.singletonList(""), Collections.singletonList(6), Collections.singletonList(2), Optional.absent(), Integer.class, 8}, {TestTarget.COLUMN_NAME, AggregationType.SUM, Collections.singletonList("SUM(0)"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("SUM(0)"), Integer.class, 8}, {TestTarget.ALIAS, AggregationType.SUM, Collections.singletonList("SUM_RESULT"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("SUM_RESULT"), Integer.class, 8}, {TestTarget.INDEX, AggregationType.COUNT, Collections.singletonList(""), Collections.singletonList(6), Collections.singletonList(2), Optional.absent(), Integer.class, 8}, {TestTarget.COLUMN_NAME, AggregationType.COUNT, Collections.singletonList("COUNT(`id`)"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("COUNT(`id`)"), Integer.class, 8}, {TestTarget.ALIAS, AggregationType.COUNT, Collections.singletonList("COUNT_RESULT"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("COUNT_RESULT"), Integer.class, 8}, {TestTarget.INDEX, AggregationType.MAX, Collections.singletonList(""), Collections.singletonList(6), Collections.singletonList(2), Optional.absent(), Integer.class, 6}, {TestTarget.COLUMN_NAME, AggregationType.MAX, Collections.singletonList("MAX(id)"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("MAX(`id`)"), Integer.class, 6}, {TestTarget.ALIAS, AggregationType.MAX, Collections.singletonList("MAX_RESULT"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("MAX_RESULT"), Integer.class, 6}, {TestTarget.INDEX, AggregationType.MIN, Collections.singletonList(""), Collections.singletonList(6), Collections.singletonList(2), Optional.absent(), Integer.class, 2}, {TestTarget.COLUMN_NAME, AggregationType.MIN, Collections.singletonList("MIN(0)"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("MIN(0)"), Integer.class, 2}, {TestTarget.ALIAS, AggregationType.MIN, Collections.singletonList("MIN_RESULT"), Collections.singletonList(6), Collections.singletonList(2), Optional.of("MIN_RESULT"), Integer.class, 2}, {TestTarget.INDEX, AggregationType.AVG, Arrays.asList("sharding_gen_1", "sharding_gen_2"), Arrays.asList(5, 10), Arrays.asList(10, 100), Optional.absent(), Double.class, 7.3333D}, {TestTarget.COLUMN_NAME, AggregationType.AVG, Arrays.asList("sharding_gen_1", "sharding_gen_2"), Arrays.asList(5, 10), Arrays.asList(10, 100), Optional.of("AVG(*)"), Double.class, 7.3333D}, {TestTarget.ALIAS, AggregationType.AVG, Arrays.asList("sharding_gen_1", "sharding_gen_2"), Arrays.asList(5, 10), Arrays.asList(10, 100), Optional.of("AVG_RESULT"), Double.class, 7.3333D} }); } @Test public void assertNext() throws SQLException { MergeContext mergeContext; switch (type) { case INDEX: mergeContext = MergerTestUtil.createMergeContext(1, "column", null, aggregationType); break; case COLUMN_NAME: mergeContext = MergerTestUtil.createMergeContext(1, nameOfGetResult.get(), null, aggregationType); break; case ALIAS: mergeContext = MergerTestUtil.createMergeContext(1, "column", nameOfGetResult.get(), aggregationType); break; default: throw new RuntimeException(); } ResultSet resultSet = ResultSetFactory.getResultSet(Arrays.<ResultSet>asList( MergerTestUtil.createMock(columns, resultSet1), MergerTestUtil.createMock(columns, resultSet2), new MockResultSet<Integer>()), mergeContext); assertTrue(resultSet.next()); Number actual; switch (type) { case INDEX: if (Integer.class.equals(resultClass)) { actual = resultSet.getInt(1); } else if (Double.class.equals(resultClass)) { actual = resultSet.getDouble(1); } else { throw new RuntimeException(); } break; default: if (Integer.class.equals(resultClass)) { actual = resultSet.getInt(this.nameOfGetResult.get()); } else if (Double.class.equals(resultClass)) { actual = resultSet.getDouble(this.nameOfGetResult.get()); } else { throw new RuntimeException(); } break; } assertThat(actual, is(result)); assertFalse(resultSet.next()); } private enum TestTarget { INDEX, COLUMN_NAME, ALIAS } }
a6fc1874c46e701b6d37f13a6580f236edb4b68e
e8d95324989dedd8d54502090e898dc7a390ff36
/android/app/src/main/java/com/rn_demo/HelloActivity.java
9ae67dc271215a38aa553c0a392270ab473864e2
[]
no_license
listingzhao/rn_demo
4e13aa78bb25df81592f71d938020f89b8183538
c4d1567291995e1514241107accdb015ff223afc
refs/heads/master
2020-03-29T21:42:21.252253
2018-10-23T02:54:13
2018-10-23T02:54:13
150,382,261
2
0
null
null
null
null
UTF-8
Java
false
false
326
java
package com.rn_demo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class HelloActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hello); } }
5b52b909dd273f7adf5f477378306109dd8dde0e
9c5e6711497721a1bcdbe8ca023c558275f09f22
/SICECD/4/Interface/InscripcionRepImpl.java
4a3b6f184ffa30c42cd6c409925cc5b6ca62c85e
[]
no_license
MicroRefact/ProyectoUNAMMs
7a5896744c9579056fc38fdefd95e74e6d6168c3
d9f1bbe81398f833ecc57bddb7ee4321d3f86cbf
refs/heads/main
2023-05-05T05:33:28.547684
2021-05-25T16:17:37
2021-05-25T16:17:37
370,755,606
0
0
null
null
null
null
UTF-8
Java
false
false
638
java
import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; public class InscripcionRepImpl implements InscripcionRep{ private RestTemplate restTemplate; String url = "http://localhost:teste"; public void saveI(int fk_id_grupo,int fk_id_profesor,String calif,boolean aprobado){ UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url.concat("saveI")) .queryParam("fk_id_grupo",fk_id_grupo) .queryParam("fk_id_profesor",fk_id_profesor) .queryParam("calif",calif) .queryParam("aprobado",aprobado); restTemplate.put(builder.toUriString(), null) }