blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
02511af343b74a14b57100bacf220cb1d64e6258 | c71463c049090028a06bc7aa8dacd813d7643129 | /app/src/main/java/br/edu/uni/projetoteste/Produto.java | 202a93bf6cd5ea19d4167abb6ed689971e636a7e | [] | no_license | JoseWillame/testeJavaInterface | f8ab855175b524c6891ee00b2cff31b11cace399 | ab4386cd4cbd59784c3895795881721b45cdcd70 | refs/heads/master | 2023-01-04T22:15:27.885954 | 2020-11-06T17:25:34 | 2020-11-06T17:25:34 | 310,659,978 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 928 | java | package br.edu.uni.projetoteste;
import android.util.Log;
public class Produto implements Crud{
private static final String TAG = "Crud";
private String nomeProduto;
private String fornecedor;
public String getNomeProduto(){
return nomeProduto;
}
public void setNomeProduto(String nomeProduto){
this.nomeProduto = nomeProduto;
}
public String getFornecedor(){
return fornecedor;
}
public void setFornecedor(String fornecedor){
this.fornecedor = fornecedor;
}
@Override
public void incluir() {
Log.i(TAG, "incluir: Produto");
}
@Override
public void alterar() {
Log.i(TAG, "alterar: Produto");
}
@Override
public void deletar() {
Log.i(TAG, "deletar: Produto");
}
@Override
public void listar() {
Log.i(TAG, "listar: Produto");
}
/**
* @param args
*/
}
| [
"git@github.com:JoseWillame/testeJavaInterface.git"
] | git@github.com:JoseWillame/testeJavaInterface.git |
a72ef57c658ead141b695c285c6ef2b6a0dbbb88 | 59a50e0764cfe2a89a50ad3c23f1fb351bfe5659 | /player-vs-enemy/pve/src/test/java/com/project/pve/AppTest.java | 9558d157a5d733b3ac6e4b5afb056c08e103d1ba | [] | no_license | lallers/JAVA-Player-Vs-Enemy-Intro-To-OOP | 520a7d4729d36404bd086422cb3348e3672ab067 | 7c81bfe70ae6408c30ce510eea622eabb6b5c912 | refs/heads/master | 2020-04-12T17:34:05.804636 | 2018-12-21T01:24:21 | 2018-12-21T01:24:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 643 | java | package com.project.pve;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| [
"lallers@users.noreply.github.com"
] | lallers@users.noreply.github.com |
c86976d38c420832c596855f483690dfd67afa18 | fa3e9decc014084ca3fd6cca154d53abcc3cbf75 | /NestleTime/Android_Plugin/NestleTime/imageedittor/src/main/java/com/bravvura/nestledtime/imageedittor/filter/library/filter/CameraFilter.java | f0dfc6365ad806ee6469237ddfd7e6c0cf761d63 | [] | no_license | deepakappdev/nestledtime | db804e3128845ec67d1149d100c737e2b9d29b35 | 8f85e756c2722a3d4521bc269e5e39250c21f518 | refs/heads/master | 2021-04-29T20:50:24.698789 | 2018-03-29T17:31:44 | 2018-03-29T17:31:44 | 121,604,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,148 | java | package com.bravvura.nestledtime.imageedittor.filter.library.filter;
import android.content.Context;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import com.bravvura.nestledtime.imageedittor.R;
import com.bravvura.nestledtime.imageedittor.filter.library.gles.GlUtil;
import java.nio.FloatBuffer;
public class CameraFilter extends AbstractFilter implements IFilter {
protected int mProgramHandle;
private int maPositionLoc;
private int muMVPMatrixLoc;
private int muTexMatrixLoc;
private int maTextureCoordLoc;
private int mTextureLoc;
protected int mIncomingWidth, mIncomingHeight;
public CameraFilter(Context applicationContext) {
mProgramHandle = createProgram(applicationContext);
if (mProgramHandle == 0) {
throw new RuntimeException("Unable to create program");
}
getGLSLValues();
}
@Override public int getTextureTarget() {
return GLES11Ext.GL_TEXTURE_EXTERNAL_OES;
}
@Override public void setTextureSize(int width, int height) {
if (width == 0 || height == 0) {
return;
}
if (width == mIncomingWidth && height == mIncomingHeight) {
return;
}
mIncomingWidth = width;
mIncomingHeight = height;
}
@Override protected int createProgram(Context applicationContext) {
return GlUtil.createProgram(applicationContext, R.raw.vertex_shader,
R.raw.fragment_shader_ext);
}
@Override protected void getGLSLValues() {
mTextureLoc = GLES20.glGetUniformLocation(mProgramHandle, "uTexture");
maPositionLoc = GLES20.glGetAttribLocation(mProgramHandle, "aPosition");
muMVPMatrixLoc = GLES20.glGetUniformLocation(mProgramHandle, "uMVPMatrix");
muTexMatrixLoc = GLES20.glGetUniformLocation(mProgramHandle, "uTexMatrix");
maTextureCoordLoc = GLES20.glGetAttribLocation(mProgramHandle, "aTextureCoord");
}
@Override public void onDraw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride, float[] texMatrix,
FloatBuffer texBuffer, int textureId, int texStride) {
GlUtil.checkGlError("draw start");
useProgram();
bindTexture(textureId);
//runningOnDraw();
bindGLSLValues(mvpMatrix, vertexBuffer, coordsPerVertex, vertexStride, texMatrix, texBuffer,
texStride);
drawArrays(firstVertex, vertexCount);
unbindGLSLValues();
unbindTexture();
disuseProgram();
}
@Override protected void useProgram() {
GLES20.glUseProgram(mProgramHandle);
//GlUtil.checkGlError("glUseProgram");
}
@Override protected void bindTexture(int textureId) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(getTextureTarget(), textureId);
GLES20.glUniform1i(mTextureLoc, 0);
}
@Override
protected void bindGLSLValues(float[] mvpMatrix, FloatBuffer vertexBuffer, int coordsPerVertex,
int vertexStride, float[] texMatrix, FloatBuffer texBuffer, int texStride) {
GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
GLES20.glEnableVertexAttribArray(maPositionLoc);
GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex, GLES20.GL_FLOAT, false,
vertexStride, vertexBuffer);
GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
GLES20.glVertexAttribPointer(maTextureCoordLoc, 2, GLES20.GL_FLOAT, false, texStride,
texBuffer);
}
@Override protected void drawArrays(int firstVertex, int vertexCount) {
GLES20.glClearColor(0f, 0f, 0f, 1f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
}
@Override protected void unbindGLSLValues() {
GLES20.glDisableVertexAttribArray(maPositionLoc);
GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
}
@Override protected void unbindTexture() {
GLES20.glBindTexture(getTextureTarget(), 0);
}
@Override protected void disuseProgram() {
GLES20.glUseProgram(0);
}
@Override public void releaseProgram() {
GLES20.glDeleteProgram(mProgramHandle);
mProgramHandle = -1;
}
/////////// Set Runnable ////////////
//protected void addRunnableOnDraw(final Runnable runnable) {
// synchronized (mRunnableOnDraw) {
// mRunnableOnDraw.addLast(runnable);
// }
//}
//
//protected void setFloat(final int location, final float floatValue) {
// addRunnableOnDraw(new Runnable() {
// @Override public void run() {
// GLES20.glUniform1f(location, floatValue);
// }
// });
//}
//
//@Override protected void runningOnDraw() {
// while (!mRunnableOnDraw.isEmpty()) {
// mRunnableOnDraw.removeFirst().run();
// }
//}
}
| [
"deepak.appdev@gmail.com"
] | deepak.appdev@gmail.com |
b391fc12854d72f4654c5730deee3804d60f05aa | 0f5ef627fa8b2ffb5a136b2ccd5175a0903cc848 | /_posts/A.java | 5fe136f44d1ded6accbad6f3a37a07ab5553f476 | [
"MIT"
] | permissive | fengjunpeng/fengjunpeng.github.io | 56f665d91afb2a750a02046717c810e50a255a65 | 8413529221b2d495ca2bc80c396245839d737ae6 | refs/heads/master | 2020-06-01T18:13:17.305866 | 2020-01-10T03:10:32 | 2020-01-10T03:10:32 | 190,878,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,369 | java | public class A {
static int[] array = new int[]{9,7,5,8,2};
public static void main(String [] args) {
for (int i = 0; i < array.length; i++ )
System.out.print(array[i] + " " );
System.out.println();
// bubbleSort(array);
selectSort(array);
System.out.println("Sort : ");
for (int i = 0; i < array.length; i++ )
System.out.print(array[i] + " ");
}
public static void bubbleSort (int[] array) {
for ( int i = 0; i < array.length - 1; i++ ) {
boolean isSort = true;
for ( int j = 0; j < array.length - 1 - i; j++ ) {
if (array[ j ] > array[ j + 1 ]) {
int temp = array[ j ];
array[ j ] = array[ j + 1 ];
array[ j + 1 ] = temp;
isSort = false;
}
}
if (isSort) {
break;
}
}
}
private static void selectSort (int[] array) {
for ( int i = 0; i < array.length - 1; i++ ) {
int min = i;
for (int j = i; j < array.length; j++ ) {
if (array[j] < array[min]) {
min = j;
}
}
int temp = array[min];
array[min] = array[i];
array[i] = temp;
}
}
} | [
"fengjunpeng@github.com"
] | fengjunpeng@github.com |
7d96ff75f8547de7872718b528d190cded923e8e | 24d058f17ad39d7a9b04a38c6fcf93b8ad52be55 | /POS_v2/src/main/java/com/masterdev/student/hbm/HibernateSessionFactory.java | d15a06179eefe448400f9b9d7f035e2485078a15 | [] | no_license | luis-ayestaran/POS_v2 | c6da9f77fbd0e436012884dc47952f07c8caf54b | 656ff676a1c1dfe5ed1c4c0b41921232908c3f34 | refs/heads/master | 2022-12-15T06:07:43.438075 | 2019-03-26T14:57:04 | 2019-03-26T14:57:04 | 177,810,498 | 0 | 0 | null | 2022-11-24T09:51:04 | 2019-03-26T14:55:13 | Java | UTF-8 | Java | false | false | 694 | java | package com.masterdev.student.hbm;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
public class HibernateSessionFactory {
private SessionFactory sessionFactory;
public HibernateSessionFactory() {
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build();
try {
sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
}catch(Exception e) {
e.printStackTrace();
}
}
public SessionFactory getSessionFactory() {
return sessionFactory;
}
}
| [
"LuisF@DESKTOP-ND387K3"
] | LuisF@DESKTOP-ND387K3 |
df43e6a94db6e0b5c316874d6794f6c1b432d90a | dcbec0cdd7c337f3572830f30adedee756ce7eae | /project-pension-core/src/main/java/com/longjun/cto/framework/sm/pay/web/PayIapReceiptController.java | a78b6c87187319dd0ceb19e44de588b6d1899af2 | [] | no_license | lm568618500/project-pension | 8c590e7f8eeffab7d3ae21e9610fee2745017c8c | 68c1fcd1206ea36482c1a21b19368d32c4262a29 | refs/heads/master | 2023-03-14T10:13:13.418797 | 2021-03-04T02:38:50 | 2021-03-04T02:38:50 | 330,593,390 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,919 | java | package com.longjun.cto.framework.sm.pay.web;
import org.springframework.beans.factory.annotation.Autowired;
import com.eims.cto.framework.standard.base.StandardBaseController;
import com.longjun.cto.framework.sm.pay.entity.dto.PayIapReceiptDto;
import com.longjun.cto.framework.sm.pay.entity.dto.PayIapReceiptModifyDto;
import com.longjun.cto.framework.sm.pay.entity.model.PayIapReceiptModel;
import com.longjun.cto.framework.sm.pay.entity.view.PayIapReceiptView;
import com.longjun.cto.framework.sm.pay.service.IPayIapReceiptService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.eims.cto.framework.common.base.page.PageUtils;
import com.eims.cto.framework.common.base.ret.ActionResult;
import com.eims.cto.framework.common.base.ret.ApiResult;
/**
* PayIapReceipt Coontroller
* @author yangxuan
* @date 2019-03-31 05:17:12
*/
@RequestMapping("/mgn/sm/pay/payIapReceipt")
@Controller
public class PayIapReceiptController extends StandardBaseController {
@Autowired
IPayIapReceiptService iPayIapReceiptService;
/**
* 列表渲染页面
* @return
*/
@RequestMapping(value = "/payIapReceiptListInit" , method = {RequestMethod.POST , RequestMethod.GET})
public ModelAndView payIapReceiptListInit() {
ModelAndView model = getModelAndView("/mgn/sm/pay/payIapReceipt/payIapReceiptListInit");
return model;
}
/**
* 新增渲染页面
* @return
*/
@RequestMapping(value = "/payIapReceiptAddInit" , method = {RequestMethod.POST , RequestMethod.GET})
public ModelAndView payIapReceiptAddInit() {
ModelAndView model = getModelAndView("/mgn/sm/pay/payIapReceipt/payIapReceiptAddInit");
return model;
}
/**
* 编辑渲染页面
* @return
*/
@RequestMapping(value = "/payIapReceiptEditInit" , method = {RequestMethod.POST , RequestMethod.GET})
public ModelAndView payIapReceiptEditInit() {
ModelAndView model = getModelAndView("/mgn/sm/pay/payIapReceipt/payIapReceiptEditInit");
return model;
}
/**
* 编辑渲染页面
* @return
*/
@RequestMapping(value = "/payIapReceiptShowInit" , method = {RequestMethod.POST , RequestMethod.GET})
public ModelAndView payIapReceiptShowInit(long id) {
ModelAndView model = getModelAndView("/mgn/sm/pay/payIapReceipt/payIapReceiptShowInit");
PayIapReceiptView ret = this.iPayIapReceiptService.findViewById(id);
model.addObject("view", ret);
return model;
}
/**
* 分页查询
* @return
*/
@ResponseBody
@RequestMapping(value = "/getByPage" , method = {RequestMethod.POST ,RequestMethod.GET})
public ActionResult<PageUtils<PayIapReceiptView>> getByPage(PayIapReceiptDto dto){
PageUtils<PayIapReceiptView> ret = this.iPayIapReceiptService.getByPage(dto);
return ActionResult.ok(ret);
}
/**
* 查询View数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/getViewById" , method = {RequestMethod.GET})
public ActionResult<PayIapReceiptView> getViewById(long id){
PayIapReceiptView ret = this.iPayIapReceiptService.findViewById(id);
return ActionResult.ok(ret);
}
/**
* 查询Model数据
* @return
*/
@ResponseBody
@RequestMapping(value = "/getModelById" , method = {RequestMethod.GET})
public ActionResult<PayIapReceiptModel> findModelById(long id){
PayIapReceiptModel ret = this.iPayIapReceiptService.findModelById(id);
return ActionResult.ok(ret);
}
/**
* 停用
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/stop" , method = {RequestMethod.POST})
public ApiResult stop(long id){
Boolean ret = this.iPayIapReceiptService.stop(id);
return ApiResult.instance().ok("ret" , ret);
}
/**
* 开启
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/start" , method = {RequestMethod.POST})
public ApiResult start(long id ){
Boolean ret = this.iPayIapReceiptService.start(id);
return ApiResult.instance().ok("ret" , ret);
}
/**
* 保存
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/saveModel" , method = {RequestMethod.POST})
public ApiResult saveModel(PayIapReceiptModel model){
this.iPayIapReceiptService.saveModel(model);
return ApiResult.instance().ok("ret" , true);
}
/**
* 保存
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/modify" , method = {RequestMethod.POST})
public ApiResult modify(PayIapReceiptModifyDto model){
this.iPayIapReceiptService.modify(model);
return ApiResult.instance().ok("ret" , true);
}
}
| [
"568618500@qq.com"
] | 568618500@qq.com |
d74e065bc87286e722e0bc133c07b48bce257ba8 | 884ba3a5101e66709d7edae20de271457e80fedb | /gmall-pms/src/main/java/com/java/gmall/pms/service/AttrAttrgroupRelationService.java | 94b75188412005d3a2686ba6be8b251d80c0ab57 | [
"Apache-2.0"
] | permissive | dingzichaogit/gmall | f630361973f41fd3f5d85f3b444371f58351dfa0 | aa821ca6fb7e65f378f7b9236b576fcf5d41bcf4 | refs/heads/main | 2023-08-09T11:18:30.459534 | 2021-09-13T08:08:56 | 2021-09-13T08:08:56 | 403,913,337 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 454 | java | package com.java.gmall.pms.service;
import com.java.core.bean.PageVo;
import com.java.core.bean.QueryCondition;
import com.baomidou.mybatisplus.extension.service.IService;
import com.java.gmall.pms.entity.AttrAttrgroupRelation;
/**
* 属性&属性分组关联
*
* @author dzc
* @since 2021-09-07 18:06:57
*/
public interface AttrAttrgroupRelationService extends IService<AttrAttrgroupRelation> {
PageVo queryPage(QueryCondition params);
}
| [
"18834406627@163.com"
] | 18834406627@163.com |
bb2f281893caea10df5092a9b80c75b3f7318155 | c905ea1d3a4e6bd3ea837bcdcde553d9625ea062 | /app/src/main/java/com/example/cricketapiretrofit/Activity/RegistrationActivity.java | 220feea0d0c43de053ad40d5c0681e765f5af15f | [] | no_license | tausifabir/PracticePostMethod | b09a30a7bcbb56f94ae9d3c834e329491fbf9c55 | c272949eaae1208fcf60fc47ad79236d73863b8f | refs/heads/master | 2022-11-12T13:20:05.272323 | 2020-07-08T11:00:23 | 2020-07-08T11:00:23 | 271,508,985 | 0 | 0 | null | 2020-06-12T19:09:41 | 2020-06-11T09:45:34 | Java | UTF-8 | Java | false | false | 2,279 | java | package com.example.cricketapiretrofit.Activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.cricketapiretrofit.R;
import com.example.cricketapiretrofit.SharedPreferenceClass.Userpreferences;
public class RegistrationActivity extends AppCompatActivity {
private EditText emailET,emailpassET;
private Button RegisterBTN;
private Userpreferences userpreferences;
private ImageView imageView4;
public RegistrationActivity() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration3);
Intent intent = getIntent();
imageView4 = findViewById(R.id.imageView4);
imageView4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RegistrationActivity.this,FundActivity.class);
startActivity(intent);
}
});
/* intWidget();*/
}
/* private void intWidget() {
emailET = findViewById(R.id.emailText);
emailpassET = findViewById(R.id.emailpassText);
RegisterBTN = findViewById(R.id.registerBtn);
}
public void registerClick(View view) {
userpreferences = new Userpreferences(this);
String pass = emailpassET.getText().toString();
String email = emailET.getText().toString();
if(TextUtils.isEmpty(email)){
emailET.setError("invaild");
}else if(TextUtils.isEmpty(pass)){
emailpassET.setError("invaild");
}
else {
userpreferences.saveUser(email,pass);
Intent intent = new Intent(RegistrationActivity.this,LoginActivity.class);
startActivity(intent);
Toast.makeText(this, ""+userpreferences.getUserEmail(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Saved successfully", Toast.LENGTH_SHORT).show();
}
}*/
} | [
"tausifabir94@gmail.com"
] | tausifabir94@gmail.com |
c67301b17aeb3ecc032d5cd2c8c342fe64faf3c4 | ed3cb95dcc590e98d09117ea0b4768df18e8f99e | /project_1_1/src/b/g/d/a/Calc_1_1_16306.java | 0299e3593fdac4cf31de69369284706c26f2b3b9 | [] | no_license | chalstrick/bigRepo1 | ac7fd5785d475b3c38f1328e370ba9a85a751cff | dad1852eef66fcec200df10083959c674fdcc55d | refs/heads/master | 2016-08-11T17:59:16.079541 | 2015-12-18T14:26:49 | 2015-12-18T14:26:49 | 48,244,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package b.g.d.a;
public class Calc_1_1_16306 {
/** @return the sum of a and b */
public int add(int a, int b) {
return a+b;
}
}
| [
"christian.halstrick@sap.com"
] | christian.halstrick@sap.com |
4bfa32852e7d2a27bf658fff1956d6597219084c | 471a1d9598d792c18392ca1485bbb3b29d1165c5 | /jadx-MFP/src/main/java/com/myfitnesspal/feature/challenges/ui/viewmodel/ChallengePrizesViewModel.java | 80625e69ff2ec4f1a433619661392fa8bf922fb0 | [] | no_license | reed07/MyPreferencePal | 84db3a93c114868dd3691217cc175a8675e5544f | 365b42fcc5670844187ae61b8cbc02c542aa348e | refs/heads/master | 2020-03-10T23:10:43.112303 | 2019-07-08T00:39:32 | 2019-07-08T00:39:32 | 129,635,379 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 836 | java | package com.myfitnesspal.feature.challenges.ui.viewmodel;
import com.myfitnesspal.feature.challenges.model.ChallengeImageOutput;
import com.myfitnesspal.feature.challenges.model.ChallengePrize;
import com.myfitnesspal.framework.mvvm.BaseViewModel;
import java.util.List;
public class ChallengePrizesViewModel extends BaseViewModel {
private ChallengeImageOutput bannerImage;
private List<ChallengePrize> challengePrizeList;
public ChallengePrizesViewModel(List<ChallengePrize> list, ChallengeImageOutput challengeImageOutput) {
this.challengePrizeList = list;
this.bannerImage = challengeImageOutput;
}
public List<ChallengePrize> getChallengePrizeList() {
return this.challengePrizeList;
}
public ChallengeImageOutput getBannerImage() {
return this.bannerImage;
}
}
| [
"anon@ymous.email"
] | anon@ymous.email |
76a21b96522b9a190261f27f492b758892009c12 | 72d9dcd57a5981cd3f0501396dba9d14ce504f84 | /maven-jdbc/src/main/java/digytal/dao/CadastroDaoCompleto.java | 34cd850fc2649fa64d9d1ea90a23a0b9ee821ad4 | [] | no_license | lucaslabre/MJVdevSchool | 996321cfab0910dd29d9eb965ff0060fa630de3d | cbcb35ac22fe2746f44c104c14a250dc5c0342df | refs/heads/master | 2023-06-17T23:43:59.927598 | 2021-07-04T20:39:31 | 2021-07-04T20:39:31 | 377,922,144 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,843 | java | package digytal.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import digytal.jdbc.connection.FabricaConexao;
import digytal.model.CadastroCompleto;
public class CadastroDaoCompleto {
private Connection cnn;
public CadastroDaoCompleto() {
FabricaConexao fc = new FabricaConexao();
cnn = fc.criarConexao();
}
public void inserir(CadastroCompleto cad) {
try {
String sql = "INSERT INTO public.tab_cliente (pj_pf,razao_social,cpf_cnpj,ins_est_rg,tel1,tel2,"
+ "email,ativ_prof,cep,estado,cidade,rua,numero,complemento,bairro,site,observacoes) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
PreparedStatement st = cnn.prepareStatement(sql);
st.setString(1, cad.getPjPf());
st.setString(2, cad.getRazaoSocial());
st.setString(3, cad.getCpfCnpj());
st.setString(4, cad.getIns_est_rg());
st.setLong(5, cad.getTel1());
st.setLong(6, cad.getTel2());
st.setString(7, cad.getEmail());
st.setString(8, cad.getAtiv_prof());
st.setString(9, cad.getCep());
st.setString(10, cad.getEstado());
st.setString(11, cad.getCidade());
st.setString(12, cad.getRua());
st.setInt(13, cad.getNumero());
st.setString(14, cad.getComplemento());
st.setString(15, cad.getBairro());
st.setString(16, cad.getSite());
st.setString(17, cad.getObservacoes());
st.execute();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void excluirCodigo(Integer codigo) {
try {
String sql = "DELETE FROM public.tab_cliente WHERE codigo=?;";
PreparedStatement st = cnn.prepareStatement(sql);
st.setInt(1, codigo);
st.execute();
st.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void alterarDados(Integer id, CadastroCompleto cc) {
try {
String sql = "UPDATE public.tab_cliente SET razao_social=?, tel2=?, email=?, ativ_prof=? "
+ "WHERE codigo=?;";
PreparedStatement st = cnn.prepareStatement(sql);
st.setString(1, cc.getRazaoSocial());
st.setLong(2, cc.getTel2());
st.setString(3, cc.getEmail());
st.setString(4, cc.getAtiv_prof());
st.setInt(5, id);
st.executeUpdate();
st.close();
}catch (SQLException e) {
e.printStackTrace();
}
}
public List<CadastroCompleto> listar(){
// ResultSet -> pesquisar sobre essa classe
List<CadastroCompleto> lista = new ArrayList<CadastroCompleto>();
try {
String sql = "SELECT * FROM public.tab_cliente;";
PreparedStatement st = cnn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
CadastroCompleto cad = new CadastroCompleto();
cad.setCodigo(rs.getInt("codigo"));
cad.setPjPf(rs.getString("pj_pf"));
cad.setRazaoSocial(rs.getString("razao_social"));
cad.setCpfCnpj(rs.getString("cpf_cnpj"));
cad.setIns_est_rg(rs.getString("ins_est_rg"));
cad.setTel1(rs.getLong("tel1"));
cad.setTel2(rs.getLong("tel2"));
cad.setEmail(rs.getString("email"));
cad.setAtiv_prof(rs.getString("ativ_prof"));
cad.setCep(rs.getString("cep"));
cad.setEstado(rs.getString("estado"));
cad.setCidade(rs.getString("cidade"));
cad.setRua(rs.getString("rua"));
cad.setNumero(rs.getInt("numero"));
cad.setComplemento(rs.getString("complemento"));
cad.setBairro(rs.getString("bairro"));
cad.setSite(rs.getString("site"));
cad.setObservacoes(rs.getString("observacoes"));
lista.add(cad);
}
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
return lista;
}
public CadastroCompleto buscarCodigo(Integer codigo) {
CadastroCompleto cad = null;
try {
String sql = "SELECT * FROM public.tab_cliente WHERE codigo=?;";
PreparedStatement st = cnn.prepareStatement(sql);
st.setInt(1, codigo);
ResultSet rs = st.executeQuery();
while(rs.next()) {
cad = new CadastroCompleto();
cad.setCodigo(rs.getInt("codigo"));
cad.setPjPf(rs.getString("pj_pf"));
cad.setRazaoSocial(rs.getString("razao_social"));
cad.setCpfCnpj(rs.getString("cpf_cnpj"));
cad.setIns_est_rg(rs.getString("ins_est_rg"));
cad.setTel1(rs.getLong("tel1"));
cad.setTel2(rs.getLong("tel2"));
cad.setEmail(rs.getString("email"));
cad.setAtiv_prof(rs.getString("ativ_prof"));
cad.setCep(rs.getString("cep"));
cad.setEstado(rs.getString("estado"));
cad.setCidade(rs.getString("cidade"));
cad.setRua(rs.getString("rua"));
cad.setNumero(rs.getInt("numero"));
cad.setComplemento(rs.getString("complemento"));
cad.setBairro(rs.getString("bairro"));
cad.setSite(rs.getString("site"));
cad.setObservacoes(rs.getString("observacoes"));
}
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
return cad;
}
}
| [
"48772886+lucaslabre@users.noreply.github.com"
] | 48772886+lucaslabre@users.noreply.github.com |
f5d6ff6d7abc00c7c8685f5f48ee1c7f01eb5ab5 | 42e0bc6e53b8946769c9a86b078ab0cceab393fb | /NumericonsAndroid/app/src/main/java/sen/sen/numericonsandroid/Global/BaseApplication.java | 290c5df8bda923a39c815c77f88476be36d00597 | [] | no_license | sen-yang/cs446 | 003e1ed0be6685fc9f0b2515e898d83aec3bc5e2 | cbde80be2e3c3b3f316e33df984debba934277d8 | refs/heads/master | 2021-05-13T18:50:45.272333 | 2018-04-04T02:24:10 | 2018-04-04T02:24:10 | 116,877,636 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package sen.sen.numericonsandroid.Global;
import android.app.Application;
import android.content.Context;
public class BaseApplication extends Application{
private static Context context;
public void onCreate() {
super.onCreate();
BaseApplication.context = getApplicationContext();
}
public static Context getAppContext() {
return BaseApplication.context;
}
}
| [
"sen.yang2595@gmail.com"
] | sen.yang2595@gmail.com |
94d81cdfa80064a247fc650918f5c4864cf31cf3 | 687466219fd24017b8f99344beacf226aa71ef1b | /src/kapitel13_Sortering_och_Sökning/Bubbelsortering.java | 6accb173820712fd1a75a2051e77185746d5a3e2 | [] | no_license | JoakimRudbeck/Programmering_1 | e16f555dab80329f4300d2aebceb8115f46f22f5 | 62c305fc4b8a8d27566c2b88cc2ca5411da89482 | refs/heads/master | 2021-07-08T02:15:37.276296 | 2020-12-04T08:19:13 | 2020-12-04T08:19:13 | 212,587,651 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,498 | java | package kapitel13_Sortering_och_Sökning;
public class Bubbelsortering {
public static void main(String[] args) {
bubbelSortering();
}
static void bubbelSortering() {
int[] osorterad = new int[]{3,7,2,1,0,-34,128,-4,7}; // Osorterad lista
System.out.println("Listan innan: " + snyggUtskriftAvElementILista(osorterad));
int[] sorterad = bubbelSortera(osorterad); // Sorterad lista
System.out.println("Listan efter: " + snyggUtskriftAvElementILista(sorterad));
}
static int[] bubbelSortera(int[] lista){
for(int i = lista.length - 1; i >= 0; i--){
for(int j = 0; j < i; j++){ // Loopar igenom paren i listan.
if(lista[j] > lista[j+1]){ // Om de vänstra värdet i paret är större än de högra.
int temp = lista[j+1]; // Sparar undan de högra (mindre) värdet.
lista[j+1] = lista[j]; // Lägger in de vänstra (större) värdet på den högra platsen i paret.
lista[j] = temp; // Lägger in de undansparade högra (mindre) värdet på den vänstra platsen i paret.
}
}
}
return lista;
}
private static String snyggUtskriftAvElementILista(int[] sorterad) {
String utdata = "";
for (int i = 0; i < sorterad.length; i++) {
utdata += "," + sorterad[i];
}
return utdata.substring(1);
}
} | [
"sbu470@edu.sollentuna.se"
] | sbu470@edu.sollentuna.se |
4817dd8f6ab157a3420649018db15fbd140173d0 | 3229e73df969d35254263e1fd0b66218b68a6862 | /fineract-project_snapshot/fineract-project/tools/javamoney-lib/calc/src/main/java/org/javamoney/calc/common/DoublingTime.java | 0ea1a63f764b024e563e6a05251815229d6fbfbb | [
"Apache-2.0"
] | permissive | phuocnguyen210495/BankingInTheCloud-Fineract | ea1875857aa0f5c147d8d1d3c66de39e8bc1bf00 | 0de4ca4cf00f251ec53ff7d8e355e9c5e6ef65ec | refs/heads/master | 2021-06-19T11:44:35.443308 | 2017-07-27T18:04:38 | 2017-07-27T18:04:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,453 | java | /*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* 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.javamoney.calc.common;
import org.javamoney.calc.CalculationContext;
import javax.money.MonetaryException;
import java.math.BigDecimal;
import java.math.MathContext;
/**
* The Doubling Time formula is used in Finance to calculate the length of time
* required to double an investment or money in an interest bearing account. It
* is important to note that r in the doubling time formula is the rate per
* period. If one wishes to calculate the amount of time to double their money
* in a money market account that is compounded monthly, then r needs to express
* the monthly rate and not the annual rate. The monthly rate can be found by
* dividing the annual rate by 12. With this situation, the doubling time
* formula will give the number of months that it takes to double money and not
* years. In addition to expressing r as the monthly rate if the account is
* compounded monthly, one could also use the effective annual rate, or annual
* percentage yield, as r in the doubling time formula.
*
* @author Anatole Tresch
* @see http://www.financeformulas.net/Doubling_Time.html
*/
public final class DoublingTime {
private DoublingTime() {
}
/**
* This function returns the number of periods required to double an amount
* with continuous compounding, given a rate.
*/
public static BigDecimal calculate(Rate rate) {
if(rate.get().signum()==0){
throw new MonetaryException("Cannot calculate DoublingTime with a rate=zero");
}
return new BigDecimal(Math.log(2.0d), CalculationContext.mathContext())
.divide(
new BigDecimal(
Math.log(1.0d + rate.get().doubleValue())
), CalculationContext.mathContext());
}
}
| [
"daniel.karzel@senacor.com"
] | daniel.karzel@senacor.com |
b4d58ecc7dcc7a1233213154f7668e3fbef0926b | facf7939099be46f4647c5c36e3829119bb52a50 | /src/RestrAdminPage.java | a4d21fa45f08fe4c730bb7c3c4cb612dbd644b96 | [] | no_license | DongeunJung/DB_Project | 5420b808b2dbecdf006210b82f7341fbc5a1ab8b | d81991d8727606e8bbf0c52ab7ffd1d8de571c2f | refs/heads/main | 2023-01-13T15:51:52.465831 | 2020-11-20T04:59:32 | 2020-11-20T04:59:32 | 314,449,231 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 8,322 | java | import java.util.ArrayList;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;
import java.util.StringTokenizer;
public class RestrAdminPage {
protected Shell shell;
/**
* @wbp.parser.entryPoint
*/
public void restrRegist() {
Text rName;
Text address;
Text minPrice;
Text maxPrice;
Display display = Display.getDefault();
shell = new Shell();
shell.setSize(450, 300);
shell.setText("Restaurant Register");
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setFont(SWTResourceManager.getFont("맑은 고딕", 20, SWT.BOLD));
lblNewLabel.setAlignment(SWT.CENTER);
lblNewLabel.setBounds(10, 23, 414, 40);
lblNewLabel.setText("식당을 등록합니다");
rName = new Text(shell, SWT.BORDER);
rName.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
rName.setText("\uC2DD\uB2F9 \uC774\uB984");
rName.setBounds(90, 65, 250, 21);
address = new Text(shell, SWT.BORDER);
address.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
address.setText("\uC2DD\uB2F9 \uC8FC\uC18C");
address.setBounds(90, 90, 250, 21);
minPrice = new Text(shell, SWT.BORDER);
minPrice.setText("\uBA54\uB274 \uCD5C\uC800\uAC00");
minPrice.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
minPrice.setBounds(90, 115, 250, 21);
maxPrice = new Text(shell, SWT.BORDER);
maxPrice.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
maxPrice.setText("\uBA54\uB274 \uCD5C\uACE0\uAC00");
maxPrice.setBounds(90, 140, 250, 21);
Button accessible = new Button(shell, SWT.CHECK);
accessible.setBounds(90, 170, 150, 16);
accessible.setText("\uC8FC\uCD9C\uC785\uAD6C \uC7A5\uC560\uC778 \uC811\uADFC\uB85C");
Button parking = new Button(shell, SWT.CHECK);
parking.setBounds(90, 190, 150, 16);
parking.setText("\uC7A5\uC560\uC778 \uC804\uC6A9 \uC8FC\uCC28\uC7A5");
Button isFlat = new Button(shell, SWT.CHECK);
isFlat.setBounds(90, 210, 150, 16);
isFlat.setText("\uC8FC\uCD9C\uC785\uAD6C \uB192\uC774 \uCC28 \uC81C\uAC70 ");
Button elevator = new Button(shell, SWT.CHECK);
elevator.setBounds(90, 230, 150, 16);
elevator.setText("\uC7A5\uC560\uC778\uC6A9 \uC5D8\uB9AC\uBCA0\uC774\uD130");
Button btnNewButton = new Button(shell, SWT.NONE);
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String yn1, yn2, yn3, yn4;
if(accessible.getSelection()==true)
yn1="Y";
else
yn1="N";
if(parking.getSelection()==true)
yn2="Y";
else
yn2="N";
if(isFlat.getSelection()==true)
yn3="Y";
else
yn3="N";
if(elevator.getSelection()==true)
yn4="Y";
else
yn4="N";
new ModifRestaurant().InsertValues(rName.getText(), address.getText(), yn1, yn2, yn3, yn4, Integer.parseInt(minPrice.getText()), Integer.parseInt(maxPrice.getText()));
shell.close();
}
});
btnNewButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
btnNewButton.setFont(SWTResourceManager.getFont("맑은 고딕", 10, SWT.BOLD));
btnNewButton.setBounds(316, 221, 108, 25);
btnNewButton.setText("\uB4F1\uB85D");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public void restrModify() {
Text rName;
Text address;
Text minPrice;
Text maxPrice;
Display display = Display.getDefault();
shell = new Shell();
shell.setSize(450, 300);
shell.setText("Restaurant Modify");
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setFont(SWTResourceManager.getFont("맑은 고딕", 20, SWT.BOLD));
lblNewLabel.setAlignment(SWT.CENTER);
lblNewLabel.setBounds(10, 23, 414, 40);
lblNewLabel.setText("식당을 수정합니다");
rName = new Text(shell, SWT.BORDER);
rName.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
rName.setText("\uC2DD\uB2F9 \uC774\uB984");
rName.setBounds(90, 65, 250, 21);
address = new Text(shell, SWT.BORDER);
address.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
address.setText("\uC2DD\uB2F9 \uC8FC\uC18C");
address.setBounds(90, 90, 250, 21);
minPrice = new Text(shell, SWT.BORDER);
minPrice.setText("\uBA54\uB274 \uCD5C\uC800\uAC00");
minPrice.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
minPrice.setBounds(90, 115, 250, 21);
maxPrice = new Text(shell, SWT.BORDER);
maxPrice.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
maxPrice.setText("\uBA54\uB274 \uCD5C\uACE0\uAC00");
maxPrice.setBounds(90, 140, 250, 21);
Button accessible = new Button(shell, SWT.CHECK);
accessible.setBounds(90, 170, 150, 16);
accessible.setText("\uC8FC\uCD9C\uC785\uAD6C \uC7A5\uC560\uC778 \uC811\uADFC\uB85C");
Button parking = new Button(shell, SWT.CHECK);
parking.setBounds(90, 190, 150, 16);
parking.setText("\uC7A5\uC560\uC778 \uC804\uC6A9 \uC8FC\uCC28\uC7A5");
Button isFlat = new Button(shell, SWT.CHECK);
isFlat.setBounds(90, 210, 150, 16);
isFlat.setText("\uC8FC\uCD9C\uC785\uAD6C \uB192\uC774 \uCC28 \uC81C\uAC70 ");
Button elevator = new Button(shell, SWT.CHECK);
elevator.setBounds(90, 230, 150, 16);
elevator.setText("\uC7A5\uC560\uC778\uC6A9 \uC5D8\uB9AC\uBCA0\uC774\uD130");
Button btnNewButton = new Button(shell, SWT.NONE);
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String yn1, yn2, yn3, yn4;
if(accessible.getSelection()==true)
yn1="Y";
else
yn1="N";
if(parking.getSelection()==true)
yn2="Y";
else
yn2="N";
if(isFlat.getSelection()==true)
yn3="Y";
else
yn3="N";
if(elevator.getSelection()==true)
yn4="Y";
else
yn4="N";
new ModifRestaurant().UpdateValues(rName.getText(), address.getText(), yn1, yn2, yn3, yn4, Integer.parseInt(minPrice.getText()), Integer.parseInt(maxPrice.getText()));
shell.close();
}
});
btnNewButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
btnNewButton.setFont(SWTResourceManager.getFont("맑은 고딕", 10, SWT.BOLD));
btnNewButton.setBounds(316, 221, 108, 25);
btnNewButton.setText("\uB4F1\uB85D");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
public void restrDelete() {
Table table;
Display display = Display.getDefault();
shell = new Shell();
shell.setSize(450, 300);
shell.setText("Restaurant Delete");
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setFont(SWTResourceManager.getFont("맑은 고딕", 20, SWT.BOLD));
lblNewLabel.setAlignment(SWT.CENTER);
lblNewLabel.setBounds(10, 23, 414, 40);
lblNewLabel.setText("식당을 삭제합니다");
ArrayList<String> list=new ArrayList<>();
new ModifRestaurant().GetValues(list);
CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(shell, SWT.BORDER | SWT.FULL_SELECTION);
for(String s : list)
checkboxTableViewer.add(s);
table = ((CheckboxTableViewer)checkboxTableViewer).getTable();
table.setBounds(50, 70, 350, 150);
Button btnNewButton = new Button(shell, SWT.NONE);
btnNewButton.addSelectionListener(new SelectionAdapter() {
StringTokenizer tok;
@Override
public void widgetSelected(SelectionEvent e) {
Object[] result=checkboxTableViewer.getCheckedElements();
list.clear();
for(Object o : result) {
tok=new StringTokenizer((String)o, ",");
list.add(tok.nextToken());
}
new ModifRestaurant().DeleteValues(list);
shell.close();
}
});
btnNewButton.setBounds(350, 230, 76, 25);
btnNewButton.setText("확인");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
| [
"cscid170319@ajou.ac.kr"
] | cscid170319@ajou.ac.kr |
ee5601baf147a82552e71f04bd8fca4be07b5ed7 | 62b12a7a003e90b05c1adca15541ce8b9b1d9f1c | /src/util/acordionmenu/AccordionRootItem.java | 7aa9598a30bf3247ebbb805ed79ea0032274759b | [] | no_license | Mike94/UFi6W7iK3Hr | 573810403e9e9685969f78a9dbe7f6a70371bd6d | 717a2b3d7f59a055ef0b2f720955ffbb445718de | refs/heads/master | 2021-01-01T06:55:23.585392 | 2013-03-02T14:20:09 | 2013-03-02T14:20:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,963 | java | /*
* Copyright 2010 Daniele.
*
* 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.
* under the License.
*/
package util.acordionmenu;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.GradientPaint;
import java.awt.Paint;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
public class AccordionRootItem extends AccordionItem {
private AccordionBranch branchPanel;
/**
* Simple constructor. Create a void JPanel, it will contains menu leafs.
* @param text Title of menu.
*/
public AccordionRootItem(String text) {
super(text);
this.branchPanel = new AccordionBranch();
}
/**
* Sets default mouse events. Show <code>HAND_CURSOR</code> when mouse is over.
* @return {@link MouseAdapter} object.
*/
@Override
public MouseAdapter getDefaultMouseActions() {
return new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
};
}
/**
* Creates an <code>IconImage</code> for when menu is collapsed.
* @return {@ IconImage} object containing image reference.
*/
@Override
public ImageIcon getDefaultNormalIcon() {
return new ImageIcon(this.getClass().getResource("/resource/list_plus.png"));
}
/**
* Creates an <code>IconImage</code> for when menu is expanded.
* @return {@ IconImage} object containing image reference.
*/
@Override
public ImageIcon getDefaultSelectedIcon() {
return new ImageIcon(this.getClass().getResource("/resource/list_minus.png"));
}
/**
* Creates a {@link GradientPaint} surface for background; 3D effect for menu item.
* @return
*/
@Override
public Paint getDefaultBackgroundPaint() {
Color c1, c2;
if (isSelected()) {
c2 = getBackground();
c1 = c2.darker();
} else {
c1 = getBackground();
c2 = c1.darker();
}
return new GradientPaint(0, 0, c1, 0, getHeight(), c2);
}
/**
*
* @return JPanel object that is leaf containter. It is used as an handle to
* relative panel, rather than create it externally and bind them togheter.
*/
public AccordionBranch getBranchPanel() {
return branchPanel;
}
}
| [
"Mike_5_62@hotmail.com"
] | Mike_5_62@hotmail.com |
77e8d19e914ce313fc7e27f4db5bbc68ddcf12d4 | 0ee2a341555eb46cf3bd63519ca395b31d8b88b6 | /src/Jogo/Jogo.java | 3b6920da1fb20b1d598a301d40e38a2d17b5309b | [] | no_license | rayssasandrade/EstuturasDeDados | 64ad8380c27e8735911ff300add13c7ebabddf9b | 3971c9fa7e55e1aa419de2d415e54f93b5dc795d | refs/heads/master | 2022-06-12T23:07:31.518135 | 2020-04-28T19:21:40 | 2020-04-28T19:21:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,694 | java | package Jogo;
import EstruturasII.ArvoreBinaria.Arvore;
import EstruturasII.ArvoreBinaria.ArvoreVaziaException;
import EstruturasII.ArvoreBinaria.InvalidPositionException;
import EstruturasII.ArvoreBinaria.No;
import com.google.gson.reflect.TypeToken;
import iojava.IOJson;
import javax.swing.*;
import java.io.Serializable;
import java.lang.reflect.Type;
public class Jogo implements Serializable {
public static void main(String[] args){
String path = "C:\\Users\\Rayssa\\IdeaProjects\\EstruturasDeDados\\src\\Jogo\\jogo.json";
Arvore<String> arvore = new Arvore<>();
IOJson iOJson = new IOJson();
if (path==null){
try {
iOJson.write(arvore);
} catch (Exception e){
e.getMessage();
}
} else {
try {
iOJson = new IOJson(path);
Type type = new TypeToken<Arvore<String>>(){}.getType();
arvore = (Arvore<String>)iOJson.read(type);
} catch (Exception e){
System.out.println(e.getMessage());
}
}
int opJogar;
do {
opJogar = JOptionPane.showConfirmDialog(null, "Jogar?", "Escolha", JOptionPane.YES_NO_OPTION);
if (opJogar == JOptionPane.YES_OPTION) {
if (arvore.estaVazia()){
String pergunta = JOptionPane.showInputDialog("Entre com uma pergunta: ");
arvore.inserir(pergunta);
String respostaErrada = JOptionPane.showInputDialog("Entre com uma resposta incorreta: ");
try {
arvore.inserirEsq(arvore.raiz(), respostaErrada);
} catch (ArvoreVaziaException e){
System.out.println(e.getMessage());
}
String respostaCorreta = JOptionPane.showInputDialog("Entre com uma resposta correta: ");
try {
arvore.inserirDir(arvore.raiz(), respostaCorreta);
} catch (ArvoreVaziaException e){
System.out.println(e.getMessage());
}
} else {
int msgPense = JOptionPane.showConfirmDialog( null, "Pense em algo! Ok?", "", JOptionPane.OK_CANCEL_OPTION);
if (msgPense == JOptionPane.OK_OPTION){
try{
No atual = arvore.raiz();
while(!arvore.eInterno(atual)){
int op = JOptionPane.showConfirmDialog(null, atual.getInfo(), "Escolha", JOptionPane.YES_NO_OPTION);
if (op == JOptionPane.YES_OPTION) {
atual = atual.getDir();
} else {
atual = atual.getEsq();
}
}
int msgAdvinhada = JOptionPane.showConfirmDialog(null, "O que você pensou foi "+arvore.exibirAtual(atual)+"? ", "", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE);
if (msgAdvinhada == JOptionPane.YES_OPTION){
JOptionPane.showMessageDialog(null, "Eu não erro!");
} else {
JOptionPane.showMessageDialog(null, "A máquina errou! :( ");
String pergunta2 = JOptionPane.showInputDialog("Entre com outra pergunta: ");
arvore.inserirEsqTroca(atual,pergunta2);
String resposta2 = JOptionPane.showInputDialog("Entre com uma resposta correta: ");
arvore.inserirDir(atual, resposta2);
}
} catch (ArvoreVaziaException | InvalidPositionException e) {
System.out.println(e.getMessage());
}
} else {
JOptionPane.showMessageDialog(null, "Jogo cancelado! :( ");
}
}
} else {
JOptionPane.showMessageDialog(null, "Fim do jogo!");
}
} while (opJogar == JOptionPane.YES_OPTION);
try {
iOJson.write(arvore);
} catch (Exception e){
e.getMessage();
}
}
} | [
"rayssa.andrade071@outlook.com"
] | rayssa.andrade071@outlook.com |
f150c208f98e9be14b712c55c14beec656dd7b6b | dbd441cfafd336fc2de36104d23a21a8d072ba5b | /Web-Study/servlet-01/src/yf513/yhc/servlet/ServletDemo04.java | c57b9da7c08269a6f9690a18d7c65e807fb8af38 | [] | no_license | 1701rehe/java-study | ce1901adbb3b24bbe5ff943ee0bb1321b444a48b | f8ca7ec10693865a13ecfae401db80cdd1b40855 | refs/heads/master | 2023-03-08T22:32:31.388308 | 2021-02-26T08:42:27 | 2021-02-26T08:42:27 | 311,602,706 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,211 | java | package yf513.yhc.servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author CHY
* @date 2020/11/5 15:21
*/
public class ServletDemo04 extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//定义一个商品价格
int money = 1000;
//获取访问资源路径
String path = req.getRequestURI();
path = path.substring(path.lastIndexOf("/"));
//条件判断
if ("/vip".equals(path)) {
System.out.println("商品的原价为:" + money + " 优惠后:" + (money * 0.9));
} else if ("/vvip".equals(path)) {
System.out.println("商品的原价为:" + money + " 优惠后:" + (money * 0.5));
} else {
System.out.println("商品的价格为:" + money);
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
}
| [
"251134852@qq.com"
] | 251134852@qq.com |
9009d4527f346af4b8f5fd377a78dfd1c5cbd6dc | 291b6128af1bedb6e5f9a4821a13f69edff62618 | /gmall-oms/src/main/java/com/atguigu/gmall/oms/service/impl/OrderReturnReasonServiceImpl.java | 9b2cd6b89fbe5d30c85bf148bdb6342f76d752e6 | [
"Apache-2.0"
] | permissive | joedyli/gmall-1010 | 0ae2c4998b610b92e618ac45314a20f7f0046dbb | c212da2465bab4b645d3a3fb2dfcc6c447628892 | refs/heads/master | 2022-12-21T14:48:17.237114 | 2020-06-04T11:05:06 | 2020-06-04T11:05:06 | 251,473,083 | 2 | 4 | Apache-2.0 | 2022-12-16T15:36:46 | 2020-03-31T01:47:55 | JavaScript | UTF-8 | Java | false | false | 1,062 | java | package com.atguigu.gmall.oms.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.atguigu.gmall.common.bean.PageResultVo;
import com.atguigu.gmall.common.bean.PageParamVo;
import com.atguigu.gmall.oms.mapper.OrderReturnReasonMapper;
import com.atguigu.gmall.oms.entity.OrderReturnReasonEntity;
import com.atguigu.gmall.oms.service.OrderReturnReasonService;
@Service("orderReturnReasonService")
public class OrderReturnReasonServiceImpl extends ServiceImpl<OrderReturnReasonMapper, OrderReturnReasonEntity> implements OrderReturnReasonService {
@Override
public PageResultVo queryPage(PageParamVo paramVo) {
IPage<OrderReturnReasonEntity> page = this.page(
paramVo.getPage(),
new QueryWrapper<OrderReturnReasonEntity>()
);
return new PageResultVo(page);
}
} | [
"joedy23@aliyun.com"
] | joedy23@aliyun.com |
04e03c67b889268c2cb783fa8681bd3bdd88b405 | 19135d976144054a5f5f899c2abe3f4d13f3fafa | /cp2/cp-platform-app/trunk/MasterUtils/src/com/master/util/common/ObjectUtil.java | db071ef003bc6ad9facdda83a4d21105511ebeee | [] | no_license | xubin5210/document | 0e3b19e55c5e596677e6e2530f025c9ea73080a8 | 066d34d30d11180fd1c10ec75bdbf4963819dd89 | refs/heads/master | 2020-11-25T19:31:51.409588 | 2016-09-15T14:49:54 | 2016-09-15T14:49:54 | 66,202,322 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 892 | java | /**
* @author maomy
* @Description: object 工具类
* @Package com.master.util.common
* @Title: ObjectUtil.java
* @date 2015年6月8日 上午11:52:41
* @version V1.0
* @说明 代码版权归 杭州安存网络科技有限公司 所有
*/
package com.master.util.common;
import java.util.ArrayList;
public class ObjectUtil {
/**
* @Auther: maomy
* @Description: object 转成 javabean
* @Date:2015年6月8日上午11:52:50
* @param list
* @return
* @return ArrayList<T>
* @说明 代码版权归 杭州安存网络科技有限公司 所有
*/
public static <T> ArrayList<T> convertObjToBeanList(ArrayList<Object> list){
ArrayList<T> result = new ArrayList<T>();
if(list.size() <= 0)
return result;
for (Object obj : list) {
@SuppressWarnings("unchecked")
T t = (T)obj;
result.add(t);
}
return result;
}
}
| [
"47816778@qq.com"
] | 47816778@qq.com |
10b453725a03071d6a5628575468a55832eda351 | 4494de1e52299cbc455c41e3433e451104d24af1 | /DatWebApplication1/src/java/MyConnection.java | 8563481bbeaef2e4b7fbf072afdcd983553a52c2 | [] | no_license | Shihab27/DatWebApplication1 | 0fcee6edcad1edcb988d65bf57c99b982d1a6612 | 60fd6d38f69cea9ae0879fcf7f770e74a09e0b47 | refs/heads/master | 2022-12-20T18:23:07.579856 | 2020-09-16T17:50:48 | 2020-09-16T17:50:48 | 296,107,156 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 671 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author HP
*/
import java.sql.Connection;
import java.sql.DriverManager;
public class MyConnection
{
public static Connection getConnection(){
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/cse310project?","root","");
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return con;
}
} | [
"65851806+Shihab27@users.noreply.github.com"
] | 65851806+Shihab27@users.noreply.github.com |
4f6bf4d10506f1ae3acf48799a2edf81449257fa | f715808c953772dd0fbe869e6fb8d410aea574ee | /src/test/java/FastTest2.java | 78c7f61b2ca06f294892605b28dec7d60dbe7550 | [] | no_license | irof/ParallelTest | 6a63e34ed359efe7900d3401eda24aeb754f43c9 | a2929c8ae47ab0f7a5afb055d425a03662dc7b1e | refs/heads/master | 2021-01-22T11:54:39.195836 | 2013-03-09T05:30:59 | 2013-03-09T05:30:59 | 8,665,340 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 230 | java | import org.junit.Test;
public class FastTest2 {
@Test
public void test1() {
// success
}
@Test
public void test2() {
// success
}
@Test
public void test3() {
throw new AssertionError("fail");
}
}
| [
"irof@hogedriven.net"
] | irof@hogedriven.net |
b32391e9d72f2ca7b4224e55045eb8b6b4d5e5f2 | 0e7faa69745e0e5ff0546e424d359b907665f1f2 | /src/main/java/com/lson/controller/BaseController.java | bac8417e7d870c39af620201438e304f58f299ab | [] | no_license | lxj88180158/sss-project | 6d0d208c8b165dbcd6946f3a3577a6024c31f028 | ca4d484d71b7ae171d62a57aee347b55ce6c0c7f | refs/heads/master | 2021-08-23T23:50:10.684629 | 2017-12-07T04:34:22 | 2017-12-07T04:34:22 | 113,395,034 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 64 | java | package com.lson.controller;
public class BaseController {
}
| [
"61433774@qq.com"
] | 61433774@qq.com |
29923c9deb3efaead05c1a854e91b14f06faa088 | 82c195c68c8e3898ec6f07933a7291ba8931fc9a | /SUFU-Backend/src/main/java/org/sitenv/spring/auth/Common.java | f2440db9f8ad0a0db86fa02d7545f86a8038a679 | [] | no_license | onc-healthit/crn | 8b7e53bfdacc14f9590a22c626db1f4640a1f8c5 | ff58b493d330999de1311fe76a6bcceeedabb833 | refs/heads/master | 2023-01-10T15:14:07.995175 | 2019-12-12T07:14:33 | 2019-12-12T07:14:33 | 216,591,101 | 2 | 1 | null | 2023-01-07T11:12:29 | 2019-10-21T14:38:11 | TSQL | UTF-8 | Java | false | false | 969 | java | package org.sitenv.spring.auth;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class Common {
public static Integer convertTimestampToUnixTime(String timestamp) throws ParseException {
if (timestamp != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
int epoch = (int) (sdf.parse(timestamp).getTime() / 1000);
return epoch;
} else {
return null;
}
}
public static Date convertToDateFormat(String timeStamp) {
SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy",
Locale.ENGLISH);
Date parsedDate=null;
try {
parsedDate = sdf.parse(timeStamp);
} catch (ParseException e) {
e.printStackTrace();
}
return parsedDate;
}
}
| [
"raghunath.umapathi@xyramsoft.com"
] | raghunath.umapathi@xyramsoft.com |
cee7e448fd5810a685530f7d49361e11da8963bd | 7391a73e51deadca0ab8ceec6a8ad262956da252 | /src/main/java/com/syneHealthInsurance/Services/PolicyService.java | 068d5834f3bc19780d24c5ce6509ad9382b21c0d | [] | no_license | surbhi-111/HealthInsuranceAssignment | 46d7eb54d303cd4e615ce6f7a92376073b7500ed | cfd5b108083f656ee4bba150bbebed1e3ae1f93a | refs/heads/master | 2022-06-12T05:14:22.545542 | 2020-05-01T12:40:20 | 2020-05-01T12:40:20 | 256,500,047 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 539 | java | package com.syneHealthInsurance.Services;
import java.util.List;
import com.syneHealthInsurance.Entity.Policy;
public interface PolicyService {
public List<Policy> getAllPolicy();
public Policy getPolicyById(long policyId);
public Policy updatePolicy(Policy policy);
public Policy addPolicy(Policy policy);
public void deletePolicy(long policyId);
public List<Policy> getPolicyByAgeAndMonthlyPremium(int age, double monthlyPremium);
public List<Policy> getPolicyByAgeAndType(int age, String type);
}
| [
"surbhijaiswal111@gmail.com"
] | surbhijaiswal111@gmail.com |
c79c7ef54323c5bcd445474106a3c2fb5ca75337 | 60ff26be849f29fb2f8150711011d45c879ca7f8 | /src/main/java/firstproject/demo/exception/PizzaException.java | 82892051b3ff6d6385497e0d4c6efe6cc2aaa995 | [] | no_license | elzaujk/PizzaOrder | 37ff1e89ff9dc554b158e51a89bb6e928ca5aec4 | 123f24b454f034c8306844603f567b32e08a8972 | refs/heads/master | 2022-01-07T07:40:40.008972 | 2019-06-30T21:24:41 | 2019-06-30T21:24:41 | 194,562,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 160 | java | package firstproject.demo.exception;
public class PizzaException extends Exception{
public PizzaException(String message) {
super(message);
}
}
| [
"elzaujkani@gmail.com"
] | elzaujkani@gmail.com |
0116b0fefab108f13c89223012fd2231f17bfa34 | 5ccdbbf2da6735b6814745e00b3a61eea7b5db49 | /app/src/main/java/ru/club/sfera/FriendsFragment.java | 45c7de109b67e39f21302bbb0e98948ebc0381cc | [] | no_license | mick3247652/sfera | c758cf5cd4867bfef3a9558b0976694437be8493 | 96ca735d34ff8a092bfe4878d18fd2614e0e5c9c | refs/heads/master | 2020-05-30T15:11:52.751779 | 2019-06-10T16:41:48 | 2019-06-10T16:41:48 | 188,374,471 | 0 | 0 | null | 2019-06-02T04:43:37 | 2019-05-24T07:29:40 | Java | UTF-8 | Java | false | false | 10,097 | java | package ru.club.sfera;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import ru.club.sfera.adapter.SearchListAdapter;
import ru.club.sfera.app.App;
import ru.club.sfera.constants.Constants;
import ru.club.sfera.model.Profile;
import ru.club.sfera.util.CustomRequest;
import ru.club.sfera.util.Helper;
public class FriendsFragment extends Fragment implements Constants, SwipeRefreshLayout.OnRefreshListener {
private static final String STATE_LIST = "State Adapter Data";
RecyclerView mRecyclerView;
TextView mMessage;
ImageView mSplash;
SwipeRefreshLayout mItemsContainer;
private ArrayList<Profile> itemsList;
private SearchListAdapter itemsAdapter;
private long profileId = 0;
private int itemId = 0;
private int arrayLength = 0;
private Boolean loadingMore = false;
private Boolean viewMore = false;
private Boolean restore = false;
int pastVisiblesItems = 0, visibleItemCount = 0, totalItemCount = 0;
public FriendsFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(false);
if (savedInstanceState != null) {
itemsList = savedInstanceState.getParcelableArrayList(STATE_LIST);
itemsAdapter = new SearchListAdapter(getActivity(), itemsList);
viewMore = savedInstanceState.getBoolean("viewMore");
restore = savedInstanceState.getBoolean("restore");
itemId = savedInstanceState.getInt("itemId");
} else {
itemsList = new ArrayList<>();
itemsAdapter = new SearchListAdapter(getActivity(), itemsList);
restore = false;
itemId = 0;
}
Intent i = getActivity().getIntent();
profileId = i.getLongExtra("profileId", 0);
if (profileId == 0) profileId = App.getInstance().getId();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_friends, container, false);
mItemsContainer = (SwipeRefreshLayout) rootView.findViewById(R.id.container_items);
mItemsContainer.setOnRefreshListener(this);
mMessage = (TextView) rootView.findViewById(R.id.message);
mSplash = (ImageView) rootView.findViewById(R.id.splash);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
final LinearLayoutManager mLayoutManager = new GridLayoutManager(getActivity(), Helper.getGridSpanCount(getActivity()));
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setAdapter(itemsAdapter);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) { //check for scroll down
visibleItemCount = mLayoutManager.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if (!loadingMore) {
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount && (viewMore) && !(mItemsContainer.isRefreshing())) {
loadingMore = true;
Log.e("...", "Last Item Wow !");
getItems();
}
}
}
}
});
itemsAdapter.setOnItemClickListener(new SearchListAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, Profile obj, int position) {
Intent intent = new Intent(getActivity(), ProfileActivity.class);
intent.putExtra("profileId", obj.getId());
startActivity(intent);
}
});
if (itemsAdapter.getItemCount() == 0) {
showMessage(getText(R.string.label_empty_list).toString());
} else {
hideMessage();
}
if (!restore) {
showMessage(getText(R.string.msg_loading_2).toString());
getItems();
}
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onRefresh() {
if (App.getInstance().isConnected()) {
itemId = 0;
getItems();
} else {
mItemsContainer.setRefreshing(false);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("viewMore", viewMore);
outState.putBoolean("restore", true);
outState.putInt("itemId", itemId);
outState.putParcelableArrayList(STATE_LIST, itemsList);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
}
public void getItems() {
mItemsContainer.setRefreshing(true);
CustomRequest jsonReq = new CustomRequest(Request.Method.POST, METHOD_FRIENDS_GET, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (!isAdded() || getActivity() == null) {
Log.e("ERROR", "FriendsFragment Not Added to Activity");
return;
}
if (!loadingMore) {
itemsList.clear();
}
try {
arrayLength = 0;
if (!response.getBoolean("error")) {
if (itemId == 0) {
App.getInstance().setFriendsCount(0);
}
itemId = response.getInt("itemId");
if (response.has("items")) {
JSONArray usersArray = response.getJSONArray("items");
arrayLength = usersArray.length();
if (arrayLength > 0) {
for (int i = 0; i < usersArray.length(); i++) {
JSONObject userObj = (JSONObject) usersArray.get(i);
Profile item = new Profile(userObj);
itemsList.add(item);
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
} finally {
loadingComplete();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (!isAdded() || getActivity() == null) {
Log.e("ERROR", "FriendsFragment Not Added to Activity");
return;
}
loadingComplete();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("accountId", Long.toString(App.getInstance().getId()));
params.put("accessToken", App.getInstance().getAccessToken());
params.put("profileId", Long.toString(profileId));
params.put("itemId", Long.toString(itemId));
params.put("language", "en");
return params;
}
};
App.getInstance().addToRequestQueue(jsonReq);
}
public void loadingComplete() {
if (arrayLength == LIST_ITEMS) {
viewMore = true;
} else {
viewMore = false;
}
itemsAdapter.notifyDataSetChanged();
if (itemsAdapter.getItemCount() == 0) {
showMessage(getText(R.string.label_empty_list).toString());
} else {
hideMessage();
}
loadingMore = false;
mItemsContainer.setRefreshing(false);
}
public void showMessage(String message) {
mMessage.setText(message);
mMessage.setVisibility(View.VISIBLE);
mSplash.setVisibility(View.VISIBLE);
}
public void hideMessage() {
mMessage.setVisibility(View.GONE);
mSplash.setVisibility(View.GONE);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onDetach() {
super.onDetach();
}
} | [
"ofxsite@gmail.com"
] | ofxsite@gmail.com |
2e5b7c56df58d90204393d3631522145b59e6406 | afe4955cc588d5c054c6e2d6cc6e110d1e2a3415 | /app/src/main/java/com/achep/acdisplay/services/activemode/detectors/IdleExitDetector.java | 96249f9a24b798455d24325aba2375d9f7956af9 | [] | no_license | meyhuan/SimpleLocker | ab48014e2420a8f230dfec0ff339609a8d019c54 | d47c99b2e170ebe1183052e315c2597b61d1f82a | refs/heads/master | 2020-07-02T11:56:37.080684 | 2015-12-28T13:53:54 | 2015-12-28T13:53:58 | 48,694,627 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,608 | java | /*
* Copyright (C) 2015 AChep@xda <artemchep@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.achep.acdisplay.services.activemode.detectors;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.util.Log;
import com.achep.base.Build;
import com.achep.base.tests.Check;
import java.util.ArrayList;
import java.util.List;
public class IdleExitDetector implements SensorEventListener {
@SuppressWarnings("PointlessBooleanExpression")
private static final boolean DEBUG_ALGORITHM = true && Build.DEBUG;
private static final String TAG = "ShakeDetector";
/**
* After we detect a shake, we ignore any events for a bit of time.
* We don't want two shakes to close together.
*/
private static final int IGNORE_EVENTS_AFTER_SHAKE = 1500; // 1.5 sec.
private static final long KEEP_DATA_POINTS_FOR = 1400;
private final List<DataPoint> mDataPoints = new ArrayList<>();
private final Listener mListener;
private SensorManager mSensorManager;
private long lastShake = 0;
private float last_x = 0, last_y = 0, last_z = 0;
private float ave_x = 0, ave_y = 0, ave_z = 0;
public interface Listener {
/**
* Called on shake detected.
*/
void onShakeDetected();
}
private static class DataPoint {
public float x, y, z;
public long time;
public DataPoint(float x, float y, float z, long time) {
this.x = x;
this.y = y;
this.z = z;
this.time = time;
}
}
public IdleExitDetector(@NonNull Listener listener) {
mListener = listener;
}
public void start(@NonNull SensorManager sensorManager) {
mSensorManager = sensorManager;
Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
Check.getInstance().isNonNull(sensor);
mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);
}
public void stop() {
mSensorManager.unregisterListener(this);
mSensorManager = null;
}
@Override
public void onSensorChanged(@NonNull SensorEvent event) {
Check.getInstance().isTrue(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER);
final long now = SystemClock.elapsedRealtime();
final long deltaTime = now - KEEP_DATA_POINTS_FOR;
// If a shake in last X seconds ignore.
if (lastShake != 0 && (now - lastShake) < IGNORE_EVENTS_AFTER_SHAKE) return;
float x = event.values[0];
float y = event.values[1];
float z = event.values[2];
if (last_x != 0 && last_y != 0 && last_z != 0 && (last_x != x || last_y != y || last_z != z)) {
DataPoint dp = new DataPoint(last_x - x, last_y - y, last_z - z, now);
mDataPoints.add(dp);
// Remove outdated data points.
while (mDataPoints.size() > 0 && mDataPoints.get(0).time < deltaTime) {
mDataPoints.remove(0);
}
// Calculate average threshold.
final int length = mDataPoints.size();
if (length > 10) {
for (DataPoint i : mDataPoints) {
ave_x += Math.abs(i.x);
ave_y += Math.abs(i.y);
ave_z += Math.abs(i.z);
}
ave_x /= length;
ave_y /= length;
ave_z /= length;
// if (DEBUG_ALGORITHM) {
// Log.d(TAG, "ave_x=" + ave_x
// + " ave_y=" + ave_y
// + " ave_z=" + ave_z
// + " length=" + length);
// }
final float ave = (ave_x + ave_y + ave_z) / 3f;
final float aveDp = (Math.abs(dp.x) + Math.abs(dp.x) + Math.abs(dp.x)) / 3f;
final float ratio = aveDp / ave;
if (DEBUG_ALGORITHM) {
Log.d(TAG, "ave=" + ave
+ " ave_dp=" + aveDp
+ " ave_ratio=" + ratio
+ " delta=" + (aveDp - ave));
}
if (Math.abs(ratio) > 6 && Math.abs(aveDp - ave) > 0.5f && ave <= 0.3f) {
mListener.onShakeDetected();
Log.e(TAG, "ave=" + ave
+ " ave_dp=" + aveDp
+ " ave_ratio=" + ratio
+ " delta=" + (aveDp - ave));
}
}
}
last_x = x;
last_y = y;
last_z = z;
}
@Override
public void onAccuracyChanged(@NonNull Sensor sensor, int accuracy) { /* unused */ }
} | [
"627655140@gmail.com"
] | 627655140@gmail.com |
65993e1553e1bbfbd2e9fe1fefe9bc824c82f418 | 234bbd50ad84d97059337841041316f9e408637a | /src/main/java/it/beergash/api/common/config/RequestInteceptorConfigurer.java | d5cfe6b41036db9fa77583af017eb07d5f1c263e | [] | no_license | beergash/api-common | cbbf94a1d7bf760b57865d24937d014fb0d084ee | d214f7422238238be027350bf7e25ad40713464d | refs/heads/master | 2023-02-15T07:58:40.578960 | 2021-01-05T16:49:15 | 2021-01-05T16:49:15 | 323,114,072 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 717 | java | package it.beergash.api.common.config;
import it.beergash.api.common.handler.LoggerRequestHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class RequestInteceptorConfigurer implements WebMvcConfigurer {
@Bean
public LoggerRequestHandler loggingReqInterceptor() {
return new LoggerRequestHandler();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loggingReqInterceptor());
}
}
| [
"a.aresta@almaviva.it"
] | a.aresta@almaviva.it |
6e3649c4a8f7f99ce638c9997f5c76b665362a10 | 65e39ad0d545bcbf7eaf594879c07c2a39b97e8d | /src/com/crazyvoice/activity/RegistActicity.java | c69bd80a28e25107d7ab9abcce1e44bf0c5734f3 | [
"Apache-2.0"
] | permissive | EditYJ/CrazyVoiceNew | 2e27a8b3f07d0321856f1094c05cd296648426fd | 2d483b9caeab9bd0cb888437d2881913035a1f0a | refs/heads/master | 2021-06-13T01:12:49.712980 | 2016-12-15T11:46:17 | 2016-12-15T11:46:17 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,517 | java | package com.crazyvoice.activity;
import org.jivesoftware.smack.SmackAndroid;
import com.crazyvoice.app.R;
import com.crazyvoice.util.RegistServer;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
/**
* 注册界面
*
* @author admin
*
*/
public class RegistActicity extends Activity implements OnClickListener {
private EditText reName;
private EditText rePwd;
private Button reButton;
private String registResult;
private RegistServer registServer = new RegistServer(RegistActicity.this);
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
Toast.makeText(RegistActicity.this, msg.obj.toString(),
Toast.LENGTH_SHORT).show();
finish();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setBar();
setContentView(R.layout.activity_regist);
init();
}
public void init() {
reName = (EditText) findViewById(R.id.regist_name);
rePwd = (EditText) findViewById(R.id.regist_pwd);
reButton = (Button) findViewById(R.id.regist_button);
reButton.setOnClickListener(this);
SmackAndroid.init(RegistActicity.this);
}
/**
* 设置标题菜单栏
*/
private void setBar() {
// TODO Auto-generated method stub
ActionBar bar = getActionBar();
bar.setDisplayHomeAsUpEnabled(true);
setTitle("吐槽星球-注册");
}
@Override
// 设置菜单栏按钮事件
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case android.R.id.home:
finish();
}
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v.getId() == R.id.regist_button) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
int restult = registServer.regist(reName.getText().toString().trim(),rePwd.getText().toString().trim());
if (restult == 1) {
registResult = "Success!";
} else {
registResult = "Unsuccess!";
}
Message Msg = new Message();
Msg.obj = registResult;
handler.sendMessage(Msg);
}
}).start();
}
}
}
| [
"158392613@qq.com"
] | 158392613@qq.com |
f21aaa6d285a609b53035a8e54b528145eae4ac5 | 0f87c7015185a33519ea83e103dc75d2d67a5ccb | /AndTroin/src/org/kohaerenzstiftung/andtroin/PurchaseActivity.java | a47111a663ef190e139f4413b9e6118855ef3e1a | [] | no_license | kohaerenzstifter/android | 67e829347d599324592dfbc241a64e17e66c7b50 | 688b1e337dc3e0275ed7aa487f9201d126119968 | refs/heads/master | 2020-12-25T19:26:20.683449 | 2015-05-16T22:42:20 | 2015-05-16T22:42:20 | 22,081,247 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,123 | java | package org.kohaerenzstiftung.andtroin;
import java.util.ArrayList;
import org.kohaerenzstiftung.ContextItemExecutor;
import org.kohaerenzstiftung.ContextMenuCreator;
import org.kohaerenzstiftung.Language;
import org.kohaerenzstiftung.ListView;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
public class PurchaseActivity extends AndtroinActivity {
public class PurchasebleList {
public String getmName() {
return mName;
}
public void setmName(String mName) {
this.mName = mName;
}
public String getmDescription() {
return mDescription;
}
public void setmDescription(String mDescription) {
this.mDescription = mDescription;
}
public Language getmSourceLanguage() {
return mSourceLanguage;
}
public void setmSourceLanguage(Language mSourceLanguage) {
this.mSourceLanguage = mSourceLanguage;
}
public Language getmTargetLanguage() {
return mTargetLanguage;
}
public void setmTargetLanguage(Language mTargetLanguage) {
this.mTargetLanguage = mTargetLanguage;
}
private String mName;
private String mDescription;
private Language mSourceLanguage;
private Language mTargetLanguage;
public PurchasebleList(String name, String description,
Language sourceLanguage, Language targetLanguage) {
this.mName = name;
this.mDescription = description;
this.mSourceLanguage = sourceLanguage;
this.mTargetLanguage = targetLanguage;
}
}
public class PurchasebleListsAdapter extends BaseAdapter {
public int getCount() {
return 42;
}
public Object getItem(int pos) {
ArrayList<Language> languages = Language.getLanguages();
int count = languages.size();
int idx1 = ((pos) % count);
int idx2 = ((pos + 1) % count);
return new PurchasebleList("liste " + pos, "beschreibung",
languages.get(idx1), languages.get(idx2));
}
public long getItemId(int pos) {
return pos;
}
public View getView(int pos, View arg1, ViewGroup arg2) {
ItemView result = new ItemView(PurchaseActivity.this, 1, LinearLayout.HORIZONTAL);
PurchasebleList list =
(PurchasebleList) getItem(pos);
result.setTextValue(0, list.getmName());
return result;
}
}
private ListView mPurchasebleLists;
@Override
protected void onBind() {
// TODO Auto-generated method stub
}
@Override
protected void setHelp() {
// TODO Auto-generated method stub
}
@Override
protected void setOptionItemExecutors() {
// TODO Auto-generated method stub
}
@Override
protected void setContextItemExecutors() {
setContextItemExecutor(R.id.menuitem_purchaselist, new ContextItemExecutor() {
public void execute(MenuItem item) {
//AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
//int id = (int) menuInfo.id;
//PurchaseActivity.this.purchaseList(id);
}
});
setContextItemExecutor(R.id.menuitem_purchase, new ContextItemExecutor() {
public void execute(MenuItem item) {
PurchaseActivity.this.purchase();
}
});
setContextItemExecutor(R.id.menuitem_cancelled, new ContextItemExecutor() {
public void execute(MenuItem item) {
PurchaseActivity.this.cancelled();
}
});
setContextItemExecutor(R.id.menuitem_refunded, new ContextItemExecutor() {
public void execute(MenuItem item) {
PurchaseActivity.this.refunded();
}
});
setContextItemExecutor(R.id.menuitem_unavailable, new ContextItemExecutor() {
public void execute(MenuItem item) {
PurchaseActivity.this.unavailable();
}
});
}
protected void unavailable() {
this.mAndtroinService.unavailable(this);
}
protected void refunded() {
this.mAndtroinService.refunded(this);
}
protected void cancelled() {
this.mAndtroinService.cancelled(this);
}
protected void purchase() {
this.mAndtroinService.purchase(this);
}
protected void purchaseList(int id) {
this.mAndtroinService.purchaseList(id);
}
@Override
protected void registerForContextMenus() {
registerForContextMenu(this.mPurchasebleLists, new ContextMenuCreator() {
public int createContextMenu(ContextMenuInfo menuInfo) {
return R.menu.context_purchase;
}
});
}
@Override
protected void assignHandlers() {
// TODO Auto-generated method stub
}
@Override
protected void readArguments(Bundle extras) {
// TODO Auto-generated method stub
}
@Override
protected void recoverResources() {
// TODO Auto-generated method stub
}
@Override
protected void releaseResources() {
// TODO Auto-generated method stub
}
@Override
protected void updateViews() {
setAdapters();
}
private void setAdapters() {
this.mPurchasebleLists.setAdapter(new PurchasebleListsAdapter());
}
@Override
protected void findElements() {
this.mPurchasebleLists =
(ListView) findViewById(R.id.listview_purchaseblelists);
}
@Override
protected int getOptionsMenu() {
return -1;
}
@Override
protected int getLayout() {
return R.layout.activity_purchase;
}
}
| [
"kohaerenzstifter@posteo.de"
] | kohaerenzstifter@posteo.de |
f07c0c4a4e9364498895fb9b9b0b120dcbdeee2c | a2df2385da9187b982ce433cfda851aa639baebe | /OrangeHRM12/src/test/java/Day_011_Katalon_Recorder/TC01_login.java | 7d800f0b20a7da64740020ac7efa2f6509d34920 | [] | no_license | GaneshYD/James | f791377336e0b69ae4f259c1a5054d8d9044aa23 | 7aae761b074dbd01aefd3794f861ca2728c63a29 | refs/heads/main | 2023-09-05T18:52:33.845512 | 2021-11-24T05:47:18 | 2021-11-24T05:47:18 | 431,360,112 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,316 | java | package Day_011_Katalon_Recorder;
import CommonUtil.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.testng.annotations.*;
public class TC01_login
{
WebDriver driver;
Reporter1 R1;
public void TC01_Report_Test() throws Exception {
driver.get("https://opensource-demo.orangehrmlive.com/");
driver.findElement(By.id("txtUsername")).sendKeys("Admin");
driver.findElement(By.id("txtPassword")).sendKeys("admin123");
driver.findElement(By.id("btnLogin")).click();
}
@Test
public void testTC01() throws Exception {
driver = TestBrowser.OpenChromeBrowser();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.get("https://opensource-demo.orangehrmlive.com/");
driver.findElement(By.id("txtUsername")).click();
driver.findElement(By.id("txtUsername")).clear();
driver.findElement(By.id("txtUsername")).sendKeys("Admin");
driver.findElement(By.id("txtPassword")).click();
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys("admin123");
driver.findElement(By.id("btnLogin")).click();
driver.findElement(By.xpath("//a[@id='menu_admin_viewAdminModule']/b")).click();
driver.findElement(By.id("menu_admin_nationality")).click();
driver.findElement(By.id("btnAdd")).click();
driver.findElement(By.id("nationality_name")).click();
driver.findElement(By.id("nationality_name")).clear();
driver.findElement(By.id("nationality_name")).sendKeys("indian1235");
driver.findElement(By.id("btnSave")).click();
driver.quit();
}
// Draws a red border around the found element. Does not set it back anyhow.
public WebElement findElement(By by) throws Exception
{
WebElement elem = driver.findElement(by);
// draw a border around the found element
if (driver instanceof JavascriptExecutor)
{
((JavascriptExecutor)driver).executeScript("arguments[0].style.border='3px solid red'", elem);
}
return elem;
}
}
| [
"durgaganeshyennati@gmail.com"
] | durgaganeshyennati@gmail.com |
45b68ed257e3206ad82ae744d271eee7b514d11d | 82ecd67664fca0f8e705cf32526dcac0b26ea759 | /src/src/test/Program5.java | 4e340cfcb9d4af236400cc4662fb640f9e53ee1d | [] | no_license | kingchan223/JDBcConsoleProgram | 01a4fcb19e2f99dd18c823e9353d155019aba0a0 | 49f4707b614b7be55c10d8b7f1ff65733fd4ce5c | refs/heads/master | 2023-04-01T22:02:46.103562 | 2021-03-30T05:00:35 | 2021-03-30T05:00:35 | 352,874,688 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 925 | java | package src.test;
import java.sql.SQLException;
import src.com.newlecture.app.console.NoticeConsole;
public class Program5 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
NoticeConsole console = new NoticeConsole();
Exit:
while(true){
console.printNoticeList();
int menu = console.inputNoticeMenu();
switch(menu) {
case 1://상세조회
console.seeDetail();
break;
case 2://이전
console.movePrevList();
break;
case 3://다음
console.moveNextList();
break;
case 4://글쓰기
console.insertPost();
//console.printNoticeList();
break;
case 5://검색
console.inputSearchWord();
console.printNoticeList();
break;
case 6://종료
System.out.println("Bye!!!");
break Exit;
default:
System.out.println("메뉴에 없는 번호를 입려하셨습니다.");
break;
}
}
}
}
| [
"kokiyo97@naver.com"
] | kokiyo97@naver.com |
cad699fc71da45e2ed9b46eca647d623e2d87402 | 7812cceb7dd22178082aee1cc6a74dccb3e4d5d7 | /android/app/src/main/java/br/com/jonathas/ru/ru/MainActivity.java | 5271295c97287b9beb3c9714bcc0725e95b8d92e | [] | no_license | Jonathas107/RestauranteUniversitario | 98cb93a9c1dcfdf40b58dce1b3ae1a5c19765af4 | 333cb01d203703f0ecf4bc5da4de379e5f00fb86 | refs/heads/master | 2020-09-14T17:44:39.362696 | 2020-02-06T15:01:21 | 2020-02-06T15:01:21 | 223,203,308 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 366 | java | package br.com.jonathas.ru.ru;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
| [
"jonathatiago@hotmail.com"
] | jonathatiago@hotmail.com |
26f47719af3684bf1b596a8b3ff8935a1be77620 | 2190cc8144f42178067c0aad0408adf87db1fe27 | /app/src/com.y/component/ActivityComponent.java | 3e97e11faf0e9f1058e853223e0b47a48a693bd2 | [] | no_license | vpractical/Cat-Dog | f4565f4367326cf39f36d58a2803204398bc1bf7 | 2e0a91f749383ee809cc5d0b2e6c0b1f4c626e49 | refs/heads/master | 2021-07-25T04:37:04.417956 | 2018-11-23T01:24:58 | 2018-11-23T01:24:58 | 145,060,712 | 0 | 0 | null | 2018-11-02T08:19:55 | 2018-08-17T02:16:01 | Java | UTF-8 | Java | false | false | 698 | java | package com.y.component;
import com.y.mvp.activity.ASCIIImageActivity;
import com.y.mvp.activity.MainActivity;
import com.y.mvp.activity.RoleActivity;
import com.y.mvp.activity.video.VideoActivity;
import com.y.mvp.component.AppComponent;
import com.y.mvp.login.LoginActivity;
import com.y.mvp.scope.CustomizeScope;
import dagger.Component;
@CustomizeScope
@Component(dependencies = AppComponent.class)
public interface ActivityComponent {
void inject(MainActivity main);
void inject(LoginActivity login);
// void inject(RegisterFaceActivity registerFaceActivity);
void inject(RoleActivity role);
void inject(VideoActivity video);
void inject(ASCIIImageActivity ascii);
}
| [
"574264083@qq.com"
] | 574264083@qq.com |
b7ad4d88c098044f8f45871d91c91a29f72f1bd1 | aea2daaead14133eb55ec99db15e6da6650cd6a6 | /src/exo/Exo2.java | ddaa1b66c3759e1103973d54ef1015699347d16c | [] | no_license | fbalitrand/TP0_exo2 | 94a944bf321eb6677cf6e29ff9e5260e1454f6c0 | 5d250317887d0185902ff296f230ebdfbdcd1bf7 | refs/heads/master | 2023-08-17T10:49:21.824643 | 2021-10-03T15:44:40 | 2021-10-03T15:44:40 | 413,120,885 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,048 | java | /*
*
* Flavie Balitrand
* TDC
* TP0
* 27/09/21
*/
package exo;
import java.util.Scanner;
/**
*
* @author Flavie BALITRAND
*/
public class Exo2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Declaration des variables
int nb; // nombre d'entiers a additionner
int result; //resultat
int ind; //indice
//nb=5;
Scanner sc = new Scanner(System.in);
System.out.println("\n Entrer le nombre :");
nb=sc.nextInt(); // On demande a sc de donner le prochain entier
result=0;
//Addition des nb premiers entiers
ind=1;
while (ind<= nb) {
result=result+ind;
ind++;
}
//Affichage du resultat
System.out.println();
System.out.println("La somme des "+ nb + " entiers est: "+result );
}
}
| [
"Flavie BALITRAND@10.18.106.227"
] | Flavie BALITRAND@10.18.106.227 |
0845a17bdc2e91142e5d7a62f1a0f9b1ab96246e | 774b50fe5091754f23ef556c07a4d1aab56efe27 | /oag/src/main/java/org/oagis/model/v101/TimeToleranceType.java | e140e0cef56f3162d278dd8251647a54e73f21a6 | [] | no_license | otw1248/thirdpartiess | daa297c2f44adb1ffb6530f88eceab6b7f37b109 | 4cbc4501443d807121656e47014d70277ff30abc | refs/heads/master | 2022-12-07T17:10:17.320160 | 2022-11-28T10:56:19 | 2022-11-28T10:56:19 | 33,661,485 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,712 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.04.09 at 05:03:55 PM CST
//
package org.oagis.model.v101;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for TimeToleranceType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="TimeToleranceType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="UnderDuration" type="{http://www.openapplications.org/oagis/10}DurationMeasureType" minOccurs="0"/>
* <element name="OverDuration" type="{http://www.openapplications.org/oagis/10}DurationMeasureType" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TimeToleranceType", propOrder = {
"underDuration",
"overDuration"
})
public class TimeToleranceType {
@XmlElement(name = "UnderDuration")
@XmlSchemaType(name = "anySimpleType")
protected String underDuration;
@XmlElement(name = "OverDuration")
@XmlSchemaType(name = "anySimpleType")
protected String overDuration;
/**
* Gets the value of the underDuration property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getUnderDuration() {
return underDuration;
}
/**
* Sets the value of the underDuration property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setUnderDuration(String value) {
this.underDuration = value;
}
/**
* Gets the value of the overDuration property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getOverDuration() {
return overDuration;
}
/**
* Sets the value of the overDuration property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setOverDuration(String value) {
this.overDuration = value;
}
}
| [
"otw1248@otw1248.com"
] | otw1248@otw1248.com |
0798638355911ca9f191f98d88af0c948b9c8db8 | f1f72de19c2a5384ed912373387275e136a7a7d8 | /src/main/java/com/btson/aoes/security/AppSecurityConfigurer.java | c4481bea0cda69e3ab769cad579385306f802e58 | [] | no_license | we-coder/AotuOnlinExamSystem | 28c4a384c7cd3f1de183d35e3921d1014a4e8d24 | 457007a1ff17c86eb38f2ccb7f872ef5585a439e | refs/heads/master | 2023-01-06T11:02:26.188468 | 2020-11-09T01:48:27 | 2020-11-09T01:48:27 | 292,815,417 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,594 | java | package com.btson.aoes.security;
import com.btson.aoes.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
* 自定义Spring Security认证处理类的时候
* 我们需要继承自WebSecurityConfigurerAdapter来完成,相关配置重写对应 方法即可。
* */
@Configuration
public class AppSecurityConfigurer extends WebSecurityConfigurerAdapter{
// 依赖注入用户服务类
@Autowired
private UserService userService;
// 依赖注入加密接口
@Autowired
private PasswordEncoder passwordEncoder;
// 依赖注入用户认证接口
@Autowired
private AuthenticationProvider authenticationProvider;
// 依赖注入认证处理成功类,验证用户成功后处理不同用户跳转到不同的页面
@Autowired
AppAuthenticationSuccessHandler appAuthenticationSuccessHandler;
/*
* BCryptPasswordEncoder是Spring Security提供的PasswordEncoder接口是实现类
* 用来创建密码的加密程序,避免明文存储密码到数据库
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
// DaoAuthenticationProvider是Spring Security提供AuthenticationProvider的实现
@Bean
public AuthenticationProvider authenticationProvider() {
// 创建DaoAuthenticationProvider对象
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
// 不要隐藏"用户未找到"的异常
provider.setHideUserNotFoundExceptions(false);
// 通过重写configure方法添加自定义的认证方式。
provider.setUserDetailsService(userService);
// 设置密码加密程序认证
provider.setPasswordEncoder(passwordEncoder);
return provider;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
// 加密
String encodedPassword = passwordEncoder.encode("123456".trim());
System.out.println(encodedPassword);
// 设置认证方式。
auth.authenticationProvider(authenticationProvider);
}
/**
* 设置了登录页面,而且登录页面任何人都可以访问,然后设置了登录失败地址,也设置了注销请求,注销请求也是任何人都可以访问的。
* permitAll表示该请求任何人都可以访问,.anyRequest().authenticated(),表示其他的请求都必须要有权限认证。
* */
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
// spring-security 5.0 之后需要过滤静态资源
.antMatchers("/grade/testView","/correction/auto","/notice/user/**","/logout","/","/user/toRegister","/login","/register","/css/**","/js/**","/img/**","/images/**","/assets/**","/layui/**","/paper/**","/tree/**","/guide/**","/user/**","/catalogue/getAllData","/uploadfile/**").permitAll()
.antMatchers( "/examinees/**","/stu/**").hasRole( "STU")
.antMatchers("/**").hasAnyRole("ADMIN","TEACHER")
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").successHandler(appAuthenticationSuccessHandler)
.usernameParameter("loginName").passwordParameter("password")
.and()
.logout().permitAll()
.and()
.exceptionHandling().accessDeniedPage("/accessDenied");
//关掉跨域攻击保护
http.csrf().disable();
}
/**
* 用户认证操作
* */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// spring-security 5.0 之后需要密码编码器,否则会抛出异常:There is no PasswordEncoder mapped for the id "null"
auth.inMemoryAuthentication().passwordEncoder(new MyPasswordEncoder()).withUser("fkit").password("123456").roles("STU");
auth.inMemoryAuthentication().passwordEncoder(new MyPasswordEncoder()).withUser("admin").password("admin").roles("ADMIN","TEACHER");
}
}
| [
"1799772817@qq.com"
] | 1799772817@qq.com |
58defd3fe48e2559cc065828131c79eedf7e67a9 | e77daf801af7d06e1679ab776dbee3459e3126fe | /Adaptor/src/com/adaptor/SocketClassAdaptorImpl.java | a9285d1c53aaa38f2c7977429760915ca96b8222 | [] | no_license | anitatripuraneni/javadesignpatterns | 7b178f18b60ac5338d8b62195c89a2fb5b90841f | e4ef37371a29431f5f4e7cd694ec3b06ee673a66 | refs/heads/master | 2020-12-14T08:52:24.999531 | 2017-06-27T06:11:12 | 2017-06-27T06:11:12 | 95,523,661 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | package com.adaptor;
public class SocketClassAdaptorImpl extends Socket implements SocketAdaptor {
@Override
public Volt get120Volt() {
return getVolt();
}
@Override
public Volt get12Volt() {
Volt v = getVolt();
return convertVolt(v, 10);
}
@Override
public Volt get3Volt() {
Volt v = getVolt();
return convertVolt(v, 40);
}
private Volt convertVolt(Volt v, int i) {
return new Volt(v.getVolt() / i);
}
}
| [
"chandrika.paturi@gmail.com"
] | chandrika.paturi@gmail.com |
d9b3e0cb9b863a3108830c888fbfde65fd00cc9b | 9254e7279570ac8ef687c416a79bb472146e9b35 | /sofa-20190815/src/main/java/com/aliyun/sofa20190815/models/UpdateAKSNodeDaemonSetRequest.java | b02cf89ba9bf4c4f3192bf1f31d33967d2cc20dc | [
"Apache-2.0"
] | permissive | lquterqtd/alibabacloud-java-sdk | 3eaa17276dd28004dae6f87e763e13eb90c30032 | 3e5dca8c36398469e10cdaaa34c314ae0bb640b4 | refs/heads/master | 2023-08-12T13:56:26.379027 | 2021-10-19T07:22:15 | 2021-10-19T07:22:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,071 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sofa20190815.models;
import com.aliyun.tea.*;
public class UpdateAKSNodeDaemonSetRequest extends TeaModel {
@NameInMap("Name")
public String name;
@NameInMap("Namespace")
public String namespace;
@NameInMap("Nodes")
public java.util.List<UpdateAKSNodeDaemonSetRequestNodes> nodes;
@NameInMap("OperatorName")
public String operatorName;
@NameInMap("UpdateStrategy")
public String updateStrategy;
@NameInMap("UpdateVersion")
public String updateVersion;
@NameInMap("Workspace")
public String workspace;
public static UpdateAKSNodeDaemonSetRequest build(java.util.Map<String, ?> map) throws Exception {
UpdateAKSNodeDaemonSetRequest self = new UpdateAKSNodeDaemonSetRequest();
return TeaModel.build(map, self);
}
public UpdateAKSNodeDaemonSetRequest setName(String name) {
this.name = name;
return this;
}
public String getName() {
return this.name;
}
public UpdateAKSNodeDaemonSetRequest setNamespace(String namespace) {
this.namespace = namespace;
return this;
}
public String getNamespace() {
return this.namespace;
}
public UpdateAKSNodeDaemonSetRequest setNodes(java.util.List<UpdateAKSNodeDaemonSetRequestNodes> nodes) {
this.nodes = nodes;
return this;
}
public java.util.List<UpdateAKSNodeDaemonSetRequestNodes> getNodes() {
return this.nodes;
}
public UpdateAKSNodeDaemonSetRequest setOperatorName(String operatorName) {
this.operatorName = operatorName;
return this;
}
public String getOperatorName() {
return this.operatorName;
}
public UpdateAKSNodeDaemonSetRequest setUpdateStrategy(String updateStrategy) {
this.updateStrategy = updateStrategy;
return this;
}
public String getUpdateStrategy() {
return this.updateStrategy;
}
public UpdateAKSNodeDaemonSetRequest setUpdateVersion(String updateVersion) {
this.updateVersion = updateVersion;
return this;
}
public String getUpdateVersion() {
return this.updateVersion;
}
public UpdateAKSNodeDaemonSetRequest setWorkspace(String workspace) {
this.workspace = workspace;
return this;
}
public String getWorkspace() {
return this.workspace;
}
public static class UpdateAKSNodeDaemonSetRequestNodes extends TeaModel {
@NameInMap("Data")
public String data;
public static UpdateAKSNodeDaemonSetRequestNodes build(java.util.Map<String, ?> map) throws Exception {
UpdateAKSNodeDaemonSetRequestNodes self = new UpdateAKSNodeDaemonSetRequestNodes();
return TeaModel.build(map, self);
}
public UpdateAKSNodeDaemonSetRequestNodes setData(String data) {
this.data = data;
return this;
}
public String getData() {
return this.data;
}
}
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
827b82afb681c2ecc144d1dc3ec5b39552d6d5f3 | afdba4c70e1c19b4f4384e5599da37ad553bae27 | /src/test/java/com/ilirus/rolesystem/RolesystemApplicationTests.java | 5ebc81f0e6618db5ee4318f2039566a7eb0cca55 | [] | no_license | ChaosAlphard/spring-role | 0ba8b89ab4207a9ef06811b0eb9d8cb091e23ec4 | db44c5dff94ad857d8a60cd097c268fd85c7f123 | refs/heads/master | 2021-01-06T10:31:34.292933 | 2020-02-19T11:27:34 | 2020-02-19T11:27:34 | 241,296,677 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 226 | java | package com.ilirus.rolesystem;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class RolesystemApplicationTests {
@Test
void contextLoads() {
}
}
| [
"Alphard450@outlook.com"
] | Alphard450@outlook.com |
8747fe56b2524c2935abddf168a81359f40e2296 | 33876322d2c529395d15d7769598314ff6881933 | /src/data/Location.java | d71e20cba5e4107c5a277bf31dae2144dbc61cfc | [] | no_license | andyWynyard/MVCSQLCRUD | 3aa09ed7a1a26b8fb09827ce13080e7c33821c6e | 1436006895a4aab3a8d5ac3d6886f5801a8a4f63 | refs/heads/master | 2021-01-01T18:25:17.255853 | 2017-07-26T00:39:10 | 2017-07-26T00:39:10 | 98,333,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,489 | java | package data;
public class Location {
private int id;
private String countryName;
private String gps_coords;
private int bucketId;
public Location(int id, String countryName, String gps_coords) {
super();
this.id = id;
this.countryName = countryName;
this.gps_coords = gps_coords;
}
public Location(int id, String countryName, int bucketId) {
super();
this.id = id;
this.countryName = countryName;
this.bucketId = bucketId;
}
public Location(String countryName, String gps_coords, int bucketId) {
super();
this.countryName = countryName;
this.gps_coords = gps_coords;
this.bucketId = bucketId;
}
public Location(String countryName, int bucketId) {
super();
this.countryName = countryName;
this.bucketId = bucketId;
}
public Location() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
public String getGps_coords() {
return gps_coords;
}
public void setGps_coords(String gps_coords) {
this.gps_coords = gps_coords;
}
@Override
public String toString() {
return "Location [id=" + id + ", countryName=" + countryName + ", gps_coords=" + gps_coords + ", bucketId="
+ bucketId + "]";
}
public int getBucketId() {
return bucketId;
}
public void setBucketId(int bucketId) {
this.bucketId = bucketId;
}
}
| [
"andrew.wynyard@gmail.com"
] | andrew.wynyard@gmail.com |
9225b79ee3018e2a3a3b2e691f226319539871f0 | 8f788c58426b5edef9ed9d89591a1888c0bebc8c | /src/main/java/com/bwz/study/syslog/LogEventBroadcaster.java | 8c6752fb1d608458a7aa5c8314b895b0340caa0f | [] | no_license | nh0823/study | c671556f0fe57b7015a13f76765ddf1c16c57494 | 8512e13f94fe81a29cd54e2056864bebd33bf034 | refs/heads/master | 2020-04-11T01:30:32.419765 | 2018-12-12T01:39:31 | 2018-12-12T02:00:56 | 161,417,676 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,009 | java | package com.bwz.study.syslog;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;
public class LogEventBroadcaster {
public void run(int port) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new LogEventEncoder());
bootstrap.bind(port).sync().channel().closeFuture().await();
}
public static void main(String[] args) throws Exception{
//String filePath = "/Users/biwenzhi/java/netty/src/main/resources/test.txt";
LogEventBroadcaster broadcaster = new LogEventBroadcaster();
try {
broadcaster.run(8080);
} finally {
}
}
}
| [
"m18589056995@163.com"
] | m18589056995@163.com |
eef5e90014c37a67c290e758de3ef12fa6daf95f | 533ff159f125813460432c8d43956788e6da045f | /Zemose/ZemoseRegionAdminFiles/sources/com/bumptech/glide/manager/Lifecycle.java | 13ecbd4c26ad59e342b91fa251c5c5ab96aab4f6 | [] | no_license | AitoApps/AndroidWorks | 7747b084e84b8ad769f4552e8b2691d9cdec3f06 | 3c6c7d17f085ee3aa714e66f13fec2a4d8663ca3 | refs/heads/master | 2022-03-14T10:57:59.215113 | 2019-12-06T17:03:24 | 2019-12-06T17:03:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 261 | java | package com.bumptech.glide.manager;
import android.support.annotation.NonNull;
public interface Lifecycle {
void addListener(@NonNull LifecycleListener lifecycleListener);
void removeListener(@NonNull LifecycleListener lifecycleListener);
}
| [
"me.salmanponnani@gmail.com"
] | me.salmanponnani@gmail.com |
9d2362eaed2f120b2923dd11a4064603d6c31ff2 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-12798-109-11-FEMO-WeightedSum:TestLen:CallDiversity/org/xwiki/velocity/internal/DefaultVelocityEngine_ESTest.java | 6e0e6b39d3c4e5f2e6f5b0f4a5ec444cdf6b2d5b | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 576 | java | /*
* This file was automatically generated by EvoSuite
* Sat Apr 04 20:13:16 UTC 2020
*/
package org.xwiki.velocity.internal;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class DefaultVelocityEngine_ESTest extends DefaultVelocityEngine_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
bc5b4a6790222cb2f047270198c25a58398c935e | 95e944448000c08dd3d6915abb468767c9f29d3c | /sources/com/google/android/gms/internal/ads/C15848lo.java | 35c6bb48bde241e1aeb193b22d05a3a4b8be596e | [] | no_license | xrealm/tiktok-src | 261b1faaf7b39d64bb7cb4106dc1a35963bd6868 | 90f305b5f981d39cfb313d75ab231326c9fca597 | refs/heads/master | 2022-11-12T06:43:07.401661 | 2020-07-04T20:21:12 | 2020-07-04T20:21:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,707 | java | package com.google.android.gms.internal.ads;
import android.net.Uri;
import com.google.android.gms.common.util.C15334q;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@C6505uv
/* renamed from: com.google.android.gms.internal.ads.lo */
public class C15848lo<ReferenceT> {
/* renamed from: a */
public ReferenceT f44603a;
/* renamed from: b */
private final Map<String, CopyOnWriteArrayList<C15742hq<? super ReferenceT>>> f44604b = new HashMap();
/* renamed from: a */
public final boolean mo41735a(Uri uri) {
if (!"gmsg".equalsIgnoreCase(uri.getScheme()) || !"mobileads.google.com".equalsIgnoreCase(uri.getHost())) {
return false;
}
mo39809a(uri.getPath(), acl.m45523a(uri));
return true;
}
/* renamed from: a */
private final synchronized void mo39809a(String str, Map<String, String> map) {
if (acd.m45776a(2)) {
String str2 = "Received GMSG: ";
String valueOf = String.valueOf(str);
acd.m45438a(valueOf.length() != 0 ? str2.concat(valueOf) : new String(str2));
for (String str3 : map.keySet()) {
String str4 = (String) map.get(str3);
StringBuilder sb = new StringBuilder(String.valueOf(str3).length() + 4 + String.valueOf(str4).length());
sb.append(" ");
sb.append(str3);
sb.append(": ");
sb.append(str4);
acd.m45438a(sb.toString());
}
}
CopyOnWriteArrayList copyOnWriteArrayList = (CopyOnWriteArrayList) this.f44604b.get(str);
if (copyOnWriteArrayList != null) {
Iterator it = copyOnWriteArrayList.iterator();
while (it.hasNext()) {
ago.f40189a.execute(new C15850lq(this, (C15742hq) it.next(), map));
}
}
}
/* renamed from: a */
public final synchronized void mo41734a(String str, C15742hq<? super ReferenceT> hqVar) {
CopyOnWriteArrayList copyOnWriteArrayList = (CopyOnWriteArrayList) this.f44604b.get(str);
if (copyOnWriteArrayList == null) {
copyOnWriteArrayList = new CopyOnWriteArrayList();
this.f44604b.put(str, copyOnWriteArrayList);
}
copyOnWriteArrayList.add(hqVar);
}
/* renamed from: b */
public final synchronized void mo41736b(String str, C15742hq<? super ReferenceT> hqVar) {
CopyOnWriteArrayList copyOnWriteArrayList = (CopyOnWriteArrayList) this.f44604b.get(str);
if (copyOnWriteArrayList != null) {
copyOnWriteArrayList.remove(hqVar);
}
}
/* renamed from: a */
public final synchronized void mo41733a(String str, C15334q<C15742hq<? super ReferenceT>> qVar) {
CopyOnWriteArrayList copyOnWriteArrayList = (CopyOnWriteArrayList) this.f44604b.get(str);
if (copyOnWriteArrayList != null) {
ArrayList arrayList = new ArrayList();
Iterator it = copyOnWriteArrayList.iterator();
while (it.hasNext()) {
C15742hq hqVar = (C15742hq) it.next();
if (qVar.mo38687a(hqVar)) {
arrayList.add(hqVar);
}
}
copyOnWriteArrayList.removeAll(arrayList);
}
}
/* renamed from: d */
public final synchronized void mo41737d() {
this.f44604b.clear();
}
/* access modifiers changed from: 0000 */
/* renamed from: a */
public final /* synthetic */ void mo41732a(C15742hq hqVar, Map map) {
hqVar.mo37744a(this.f44603a, map);
}
}
| [
"65450641+Xyzdesk@users.noreply.github.com"
] | 65450641+Xyzdesk@users.noreply.github.com |
c92e0a5ff8c29fb7cff7f4ec339e4e39c150cbdf | 37ff7404e19a46a57ed0de8b02fb8bd2f7700b2e | /example-spring-java/src/test/java/com/peak/spel/SpElJavaTest.java | 80f0c3f87ff5569bade82947761c832d2473034d | [] | no_license | gaofeng0527/example | 4cee6565c06e65e4ae82cb7e51bd9083c7148cd2 | 11de5aa934a41264e1121c1d4f1a01b32392a446 | refs/heads/master | 2020-04-11T15:27:46.604917 | 2019-05-24T05:31:44 | 2019-05-24T05:31:44 | 139,731,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | package com.peak.spel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpELJavaConfig.class)
public class SpElJavaTest {
@Autowired
Person person;
@Autowired
DataBase db;
@Test
public void spelTest(){
assert person != null;
person.say();
assert db != null;
db.getCon();
}
@Test
public void randomTest(){
System.out.println((int) (Math.random() * 10000000));
}
}
| [
"gaofeng0527@163.com"
] | gaofeng0527@163.com |
50e2799c6475501f61a00236482fb24ac83a404c | 68e8c0a2fbfe5cbcb53be1e7664ca356bdb086b5 | /biz.aQute.bndlib/src/aQute/bnd/osgi/ClassDataCollectorRecorder.java | 6bf4747365b9bbe323f9662f250e8ba65052feae | [
"Apache-2.0"
] | permissive | ScienceCityJena/bnd | 7fea2e4794d5c69eb14f247ec96e8084cfb1d898 | 7ed389319e22a41fd1d07f77b68e995c3ba12104 | refs/heads/master | 2020-03-23T19:46:27.900795 | 2018-10-09T16:41:42 | 2018-10-09T16:41:42 | 142,001,568 | 0 | 0 | Apache-2.0 | 2018-08-15T07:28:47 | 2018-07-23T10:52:42 | Java | UTF-8 | Java | false | false | 3,900 | java | package aQute.bnd.osgi;
import java.util.ArrayList;
import java.util.List;
import org.osgi.util.function.Consumer;
import aQute.bnd.osgi.Clazz.MethodParameter;
import aQute.bnd.osgi.Descriptors.TypeRef;
class ClassDataCollectorRecorder extends ClassDataCollector {
private final List<Consumer<ClassDataCollector>> actions = new ArrayList<>();
private boolean start;
ClassDataCollectorRecorder() {}
void play(ClassDataCollector cdc) throws Exception {
start = true;
for (Consumer<ClassDataCollector> action : actions) {
if (!start) {
break;
}
action.accept(cdc);
}
}
ClassDataCollectorRecorder reset() {
actions.clear();
return this;
}
@Override
public void classBegin(int access, TypeRef name) {
actions.add(cdc -> cdc.classBegin(access, name));
}
@Override
public boolean classStart(int access, TypeRef className) {
actions.add(cdc -> {
if (!cdc.classStart(access, className)) {
start = false;
}
});
return true;
}
@Override
public boolean classStart(Clazz c) {
actions.add(cdc -> {
if (!cdc.classStart(c)) {
start = false;
}
});
return true;
}
@Override
public void extendsClass(TypeRef zuper) throws Exception {
actions.add(cdc -> cdc.extendsClass(zuper));
}
@Override
public void implementsInterfaces(TypeRef[] interfaces) throws Exception {
actions.add(cdc -> cdc.implementsInterfaces(interfaces));
}
@Override
public void addReference(TypeRef ref) {
actions.add(cdc -> cdc.addReference(ref));
}
@Override
public void annotation(Annotation annotation) throws Exception {
actions.add(cdc -> cdc.annotation(annotation));
}
@Override
public void parameter(int p) {
actions.add(cdc -> cdc.parameter(p));
}
@Override
public void method(Clazz.MethodDef method) {
actions.add(cdc -> cdc.method(method));
}
@Override
public void field(Clazz.FieldDef field) {
actions.add(cdc -> cdc.field(field));
}
@Override
public void classEnd() throws Exception {
actions.add(ClassDataCollector::classEnd);
}
@Override
public void deprecated() throws Exception {
actions.add(ClassDataCollector::deprecated);
}
@Override
public void enclosingMethod(TypeRef cName, String mName, String mDescriptor) {
actions.add(cdc -> cdc.enclosingMethod(cName, mName, mDescriptor));
}
@Override
public void innerClass(TypeRef innerClass, TypeRef outerClass, String innerName, int innerClassAccessFlags)
throws Exception {
actions.add(cdc -> cdc.innerClass(innerClass, outerClass, innerName, innerClassAccessFlags));
}
@Override
public void signature(String signature) {
actions.add(cdc -> cdc.signature(signature));
}
@Override
public void constant(Object object) {
actions.add(cdc -> cdc.constant(object));
}
@Override
public void memberEnd() {
actions.add(ClassDataCollector::memberEnd);
}
@Override
public void version(int minor, int major) {
actions.add(cdc -> cdc.version(minor, major));
}
@Override
public void referenceMethod(int access, TypeRef className, String method, String descriptor) {
actions.add(cdc -> cdc.referenceMethod(access, className, method, descriptor));
}
@Override
public void referTo(TypeRef typeRef, int modifiers) {
actions.add(cdc -> cdc.referTo(typeRef, modifiers));
}
@Override
public void annotationDefault(Clazz.MethodDef method) {
actions.add(cdc -> cdc.annotationDefault(method));
}
@Override
public void annotationDefault(Clazz.MethodDef method, Object value) {
actions.add(cdc -> cdc.annotationDefault(method, value));
}
@Override
public void typeuse(int target_type, int target_index, byte[] target_info, byte[] type_path) {
actions.add(cdc -> cdc.typeuse(target_type, target_index, target_info, type_path));
}
@Override
public void methodParameters(Clazz.MethodDef method, MethodParameter[] parameters) {
actions.add(cdc -> cdc.methodParameters(method, parameters));
}
}
| [
"bj@bjhargrave.com"
] | bj@bjhargrave.com |
06710680b0cb05a026b2d9b66de27c9fbe834f39 | 67155149d575882b0d1b0aa62417fe4e16fd779a | /jte-maven-plugin/src/main/java/gg/jte/maven/GeneratorMojo.java | 28670b48d04547685126897680cd15a1486c9485 | [
"Apache-2.0"
] | permissive | mitchdennett/jte | 78f769e9c7441b4d20f58ad4f0b6aecf4c1e909f | 3b9fc65930d9071e2e56ef5522eda1dd9134da6d | refs/heads/master | 2022-12-18T16:55:13.321202 | 2020-09-14T05:52:26 | 2020-09-14T05:52:26 | 295,399,029 | 0 | 0 | null | 2020-09-14T11:47:18 | 2020-09-14T11:47:17 | null | UTF-8 | Java | false | false | 2,321 | java | package gg.jte.maven;
import gg.jte.ContentType;
import gg.jte.TemplateEngine;
import gg.jte.resolve.DirectoryCodeResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES;
@Mojo(name = "generate", defaultPhase = GENERATE_SOURCES)
public class GeneratorMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}")
public MavenProject project;
/**
* The directory where template files are located.
*/
@Parameter
public String sourceDirectory;
/**
* Destination directory to store generated templates. Defaults to 'target/generated-sources/jte'.
*/
@Parameter(defaultValue = "${project.build.directory}/generated-sources/jte")
public String targetDirectory;
@Parameter(readonly = true, required = true)
public String contentType;
@Parameter(readonly = true)
public String[] htmlTags;
@Parameter(readonly = true)
public String[] htmlAttributes;
@Override
public void execute() {
long start = System.nanoTime();
Path source = Path.of(sourceDirectory);
Path target = Path.of(targetDirectory);
getLog().info("Generating jte templates found in " + source);
TemplateEngine templateEngine = TemplateEngine.create(new DirectoryCodeResolver(source), target, ContentType.valueOf(contentType));
templateEngine.setHtmlTags(htmlTags);
templateEngine.setHtmlAttributes(htmlAttributes);
int amount;
try {
templateEngine.cleanAll();
amount = templateEngine.generateAll();
} catch (Exception e) {
getLog().error("Failed to generate templates.");
getLog().error(e);
throw e;
}
long end = System.nanoTime();
long duration = TimeUnit.NANOSECONDS.toSeconds(end - start);
getLog().info("Successfully generated " + amount + " jte file" + (amount == 1 ? "" : "s") + " in " + duration + "s to " + target);
project.addCompileSourceRoot(targetDirectory);
}
}
| [
"andy@mazebert.com"
] | andy@mazebert.com |
17c4c9d8f2726de0b18e04a329066022e35983fb | 2d2a6f4a6ad98b771ddad622d05e6a807f0479cf | /src/main/java/com/gypsyengineer/tlsbunny/tls13/test/openssl/client/DoubleClientHello.java | b9246cd9ab23c5014858d58dcc86796a32ea5308 | [
"Apache-2.0"
] | permissive | Tony-Nevermore/tlsbunny | 6e7a10b7307b3f8e1bd524781a5f69b83f2923b3 | 3d601ff0c5fb84fa08a169442fa62b44dd59715b | refs/heads/master | 2020-03-19T09:32:41.869097 | 2018-06-03T08:58:38 | 2018-06-03T08:58:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,079 | java | package com.gypsyengineer.tlsbunny.tls13.test.openssl.client;
import com.gypsyengineer.tlsbunny.tls13.connection.*;
import com.gypsyengineer.tlsbunny.tls13.connection.action.composite.*;
import com.gypsyengineer.tlsbunny.tls13.test.SystemPropertiesConfig;
public class DoubleClientHello {
public static void main(String[] args) throws Exception {
SystemPropertiesConfig config = SystemPropertiesConfig.load();
Engine.init()
.target(config.host())
.target(config.port())
.send(new OutgoingClientHello())
.require(new IncomingServerHello())
.require(new IncomingChangeCipherSpec())
.require(new IncomingEncryptedExtensions())
.require(new IncomingCertificate())
.require(new IncomingCertificateVerify())
.require(new IncomingFinished())
.run(new OutgoingFinished())
.send(new OutgoingClientHello())
.require(new IncomingAlert())
.connect();
}
}
| [
"artem.smotrakov@gmail.com"
] | artem.smotrakov@gmail.com |
4b984875fba4ab0f3682f723183c50278f983da7 | 9d8a38464c6726c58aefb6da20b415dfa546cfdf | /src/main/java/design/principle/dependence_inversion/Hum.java | ac4446b704bb7bc055124c21301c58a4f92ed189 | [] | no_license | humwawe/design-pattern | 124b2b4d3667957f5fc80709358dfbe3c8327e87 | e80b840ec3ddbc5f7cf91ae50987f94dc56b4355 | refs/heads/master | 2020-04-09T13:26:41.417348 | 2018-12-23T14:15:28 | 2018-12-23T14:15:28 | 160,372,349 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 268 | java | package design.principle.dependence_inversion;
/**
* @author hum
*/
public class Hum {
public void setCourse(Course course) {
this.course = course;
}
private Course course;
public void studyCourse() {
course.studyCourse();
}
}
| [
"wawe8963098@163.com"
] | wawe8963098@163.com |
022bf91f350b5fd8bee66df7324aac0871ab8ad9 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/27/27_7414aa85d5fc52362533a24e4d063beaa5e4c754/DeviceFileRestServlet/27_7414aa85d5fc52362533a24e4d063beaa5e4c754_DeviceFileRestServlet_t.java | 8879e660676d89514ae9522dacf6ac3f73b42821 | [] | 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 | 4,110 | java | /*
* Copyright (C) 2010-2012 Stichting Akvo (Akvo Foundation)
*
* This file is part of Akvo FLOW.
*
* Akvo FLOW is free software: you can redistribute it and modify it under the terms of
* the GNU Affero General Public License (AGPL) as published by the Free Software Foundation,
* either version 3 of the License or any later version.
*
* Akvo FLOW 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 Affero General Public License included below for more details.
*
* The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>.
*/
package org.waterforpeople.mapping.app.web;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONObject;
import org.waterforpeople.mapping.app.gwt.client.devicefiles.DeviceFilesDto;
import org.waterforpeople.mapping.app.util.DtoMarshaller;
import org.waterforpeople.mapping.app.web.dto.DeviceFileFindRestResponse;
import org.waterforpeople.mapping.app.web.dto.DeviceFileRestRequest;
import org.waterforpeople.mapping.app.web.dto.DeviceFileRestResponse;
import org.waterforpeople.mapping.dao.DeviceFilesDao;
import org.waterforpeople.mapping.domain.Status.StatusCode;
import com.gallatinsystems.device.domain.DeviceFiles;
import com.gallatinsystems.framework.dao.BaseDAO;
import com.gallatinsystems.framework.rest.AbstractRestApiServlet;
import com.gallatinsystems.framework.rest.RestRequest;
import com.gallatinsystems.framework.rest.RestResponse;
public class DeviceFileRestServlet extends AbstractRestApiServlet {
@SuppressWarnings("unused")
private static final Logger log = Logger
.getLogger(DeviceFileRestServlet.class.getName());
DeviceFilesDao dfDao = null;
public DeviceFileRestServlet() {
super();
setMode(JSON_MODE);
dfDao = new DeviceFilesDao();
}
/**
*
*/
private static final long serialVersionUID = -3626408824020380901L;
@Override
protected RestRequest convertRequest() throws Exception {
HttpServletRequest req = getRequest();
RestRequest restRequest = new DeviceFileRestRequest();
restRequest.populateFromHttpRequest(req);
return restRequest;
}
@Override
protected RestResponse handleRequest(RestRequest req) throws Exception {
DeviceFileRestRequest importReq = (DeviceFileRestRequest) req;
if (DeviceFileRestRequest.LIST_DEVICE_FILES_ACTION.equals(importReq
.getAction())) {
List<DeviceFilesDto> dtoList = new ArrayList<DeviceFilesDto>();
String cursor = importReq.getCursor();
List<DeviceFiles> dfList = dfDao.listDeviceFilesByStatus(
StatusCode.valueOf(importReq.getProcessedStatus()), cursor);
for (DeviceFiles instance : dfList) {
DeviceFilesDto dto = new DeviceFilesDto();
DtoMarshaller.copyToDto(instance, dto);
dtoList.add(dto);
}
DeviceFileRestResponse response = new DeviceFileRestResponse();
cursor = BaseDAO.getCursor(dfList);
response.setDtoList(dtoList);
response.setCursor(cursor);
return response;
} else if (DeviceFileRestRequest.FIND_DEVICE_FILE_ACTION
.equals(importReq.getAction())) {
String deviceFileFullPath = importReq.getDeviceFullPath().trim();
Boolean foundFlag = false;
if (deviceFileFullPath != null && !deviceFileFullPath.equals("")) {
DeviceFiles df = dfDao.findByUri(deviceFileFullPath);
DeviceFileFindRestResponse response = new DeviceFileFindRestResponse();
DeviceFilesDto dto=null;
if (df != null) {
dto = new DeviceFilesDto();
DtoMarshaller.copyToDto(df, dto);
foundFlag = true;
}
response.setFoundFlag(foundFlag);
response.setDeviceFile(dto);
return response;
}
}
return null;
}
@Override
protected void writeOkResponse(RestResponse resp) throws Exception {
getResponse().setStatus(200);
getResponse().getWriter().println(new JSONObject(resp).toString());
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
566c565ff5d44f12f0bddf8d5439221b73d94b75 | e297a12b17b94e4143cf33acb92ac42f0beff4db | /src/UnicodeContent.java | 538ba47ac72aa238b23d6f3b19d0d1040bc9f164 | [] | no_license | dwaynewade0033/quiz | b6dbef8696acfe1b7b5b03e7df8dc179bde07c14 | 58dba0685f1d1ca16d915687c644b781fa58557f | refs/heads/master | 2021-05-08T22:35:50.705769 | 2018-02-11T16:03:57 | 2018-02-11T16:03:57 | 119,680,717 | 0 | 0 | null | 2018-01-31T11:52:33 | 2018-01-31T11:52:33 | null | UTF-8 | Java | false | false | 651 | java | import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
public class UnicodeContent implements Content {
private final File file;
public UnicodeContent(final File file) {
this.file= file;
}
@Override
public String toString() {
try {
return new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())));
} catch (IOException e) {
e.printStackTrace();
}
return toString();
}
@Override
public void save(String content) throws IOException {
Files.write(Paths.get(file.getAbsolutePath()), content.getBytes("UTF-8"));
}
}
| [
"dwaynewade0033@gmail.com"
] | dwaynewade0033@gmail.com |
25eefb5cacb80f26cd03e8fd29c1488634513db6 | ef2defbb5a523d114c32b4824ef29e81334b1604 | /src/main/java/cn/liuyiyou/java/lang/Something.java | d85b4793b29f240309aca4ffe5950323d2a62dbb | [] | no_license | liuyiyou/cn.liuyiyou.java | daf5c37cadf88596d07f7eb13a9a44c5dce9d813 | 48c71965fb407b201e46c6ff137dc537e34be4c8 | refs/heads/master | 2022-12-22T06:54:38.492277 | 2020-05-13T10:11:15 | 2020-05-13T10:11:15 | 110,930,489 | 0 | 0 | null | 2022-12-16T04:30:38 | 2017-11-16T06:07:11 | Java | UTF-8 | Java | false | false | 407 | java | /**
* 所属项目:cn.liuyiyou.java
* 文件名称:cn.liuyiyou.java.language.Something.java
* 日期: 2017年8月9日下午7:17:24
* Copyright (c) 2017, liuyiyou.cn All Rights Reserved.
*
*/
package cn.liuyiyou.java.lang;
/**
* @author liuyiyou.cn
* @date 2017年8月9日 下午7:17:24
* @version
*/
public class Something {
public int addOne(final int i){
//return ++i;
return 0;
}
}
| [
"liuyiyou@daojia.com"
] | liuyiyou@daojia.com |
188798a051e95c0d670d0e3ef915bda60ad3c0ed | e12af772256dccc4f44224f68b7a3124673d9ced | /jitsi/src/net/java/sip/communicator/impl/neomedia/codec/video/ImageScaler.java | 4850460b69b106bd24dece4e1458dc547c00f99f | [] | no_license | leshikus/dataved | bc2f17d9d5304b3d7c82ccb0f0f58c7abcd25b2a | 6c43ab61acd08a25b21ed70432cd0294a5db2360 | refs/heads/master | 2021-01-22T02:33:58.915867 | 2016-11-03T08:35:22 | 2016-11-03T08:35:22 | 32,135,163 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 8,359 | java | /*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.neomedia.codec.video;
import java.awt.*;
import java.awt.image.*;
import javax.media.Buffer;
import javax.media.Codec;
import javax.media.Format;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import net.sf.fmj.media.AbstractCodec;
import net.sf.fmj.media.util.BufferToImage;
import net.sf.fmj.media.util.ImageToBuffer;
/**
* Codec that scales images from one size to another.
* Interestingly, cross-platform JMF does not appear to have a corresponding codec.
* @author Ken Larson
*
* Original from fmj project, changed only output format sizes.
* The sizes are those supported in h263 and h264.
* @author Damian Minkov
* @author Sebastien Vincent
*/
public class ImageScaler
extends AbstractCodec
implements Codec
{
// TODO: all formats supported by BufferToImage
private final Format[] supportedInputFormats = new Format[] {
new RGBFormat(null, -1, Format.intArray, -1.0f, 32, -1, -1, -1),
};
private final Format[] supportedOutputFormats = new Format[] {
//new RGBFormat(new Dimension(1280, 1024), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//new RGBFormat(new Dimension(1280, 800), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(new Dimension(1024, 768), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(new Dimension(800, 600), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(new Dimension(640, 480), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(new Dimension(720, 576), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//P720
new RGBFormat(new Dimension(720, 480), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//CIF4
new RGBFormat(new Dimension(704, 576), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//CIF
new RGBFormat(new Dimension(352, 288), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
new RGBFormat(new Dimension(320, 240), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//QCIF
new RGBFormat(new Dimension(176, 144), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
//SQCIF
new RGBFormat(new Dimension(128, 96), -1, Format.intArray, -1.0f, 32, -1, -1, -1),
};
private BufferToImage bufferToImage;
private boolean passthrough;
@Override
public Format[] getSupportedInputFormats()
{
return supportedInputFormats;
}
@Override
public Format[] getSupportedOutputFormats(Format input)
{
// if (input == null)
return supportedOutputFormats;
// VideoFormat inputCast = (VideoFormat) input;
// final Format[] result = new Format[] {
// new RGBFormat(DIMENSION, -1, Format.intArray, -1.0f, 32, -1, -1, -1)};
// // TODO: we have to specify the RGB, etc. in the output format.
// return result;
}
@Override
public Format setInputFormat(Format format)
{
final VideoFormat videoFormat = (VideoFormat) format;
if (videoFormat.getSize() == null)
return null; // must set a size.
// TODO: check VideoFormat and compatibility
bufferToImage = new BufferToImage(videoFormat);
format = super.setInputFormat(format);
updatePassthrough();
return format;
}
@Override
public Format setOutputFormat(Format format)
{
format = super.setOutputFormat(format);
updatePassthrough();
return format;
}
private void updatePassthrough()
{
Format outputFormat = getOutputFormat();
if (outputFormat != null)
{
Dimension outputSize = ((VideoFormat) outputFormat).getSize();
if (outputSize != null)
{
Format inputFormat = getInputFormat();
passthrough =
(inputFormat != null)
&& outputSize.equals(
((VideoFormat) inputFormat).getSize());
return;
}
}
passthrough = false;
}
@Override
public int process(Buffer input, Buffer output)
{
if (!checkInputBuffer(input))
{
return BUFFER_PROCESSED_FAILED;
}
if (isEOM(input))
{
propagateEOM(output); // TODO: what about data? can there be any?
return BUFFER_PROCESSED_OK;
}
// sometimes format sizes are the same but some other field is different
// and jmf use the scaler (in my case length field was not sent in
// one of the formats) the check for sizes is made in method
// setInputFormat
if(passthrough)
{
output.setData(input.getData());
output.setLength(input.getLength());
output.setOffset(input.getOffset());
return BUFFER_PROCESSED_OK;
}
final BufferedImage image = (BufferedImage) bufferToImage.createImage(input);
/*
final Dimension inputSize = ((VideoFormat) inputFormat).getSize();
final Dimension outputSize = ((VideoFormat) outputFormat).getSize();
final double scaleX = ((double) outputSize.width) / ((double) inputSize.width);
final double scaleY = ((double) outputSize.height) / ((double) inputSize.height);
final BufferedImage scaled = scale(image, scaleX, scaleY); // TODO: is the size exact? what about rounding errors?
*/
final Dimension outputSize = ((VideoFormat) outputFormat).getSize();
/* rescale by preserving ratio */
final BufferedImage scaled = scalePreserveRatio(image, outputSize.width, outputSize.height); // TODO: is the size exact? what about rounding errors?
final Buffer b = ImageToBuffer.createBuffer(scaled, ((VideoFormat) outputFormat).getFrameRate());
output.setData(b.getData());
output.setLength(b.getLength());
output.setOffset(b.getOffset());
output.setFormat(b.getFormat());
// TODO: what about format?
return BUFFER_PROCESSED_OK;
}
/**
* Get a scaled <tt>BufferedImage</tt> that preserves ratio and puts black
* borders if the ratio of the source image is different than the ratio of
* the scaled image.
* <p>
* Mainly inspired by
* http://java.developpez.com/faq/gui/?page=graphique_general_images
* #GRAPHIQUE_IMAGE_redimensionner
* </p>
*
* @param src the <tt>BufferedImage<tt> to scale
* @param width width of the scaled image
* @param height height of scaled image
* @return the <tt>BufferedImage</tt> which represents <tt>src</tt> scaled
* to <tt>width</tt> and <tt>height</tt>
*/
public static BufferedImage scalePreserveRatio(BufferedImage src,
int width,
int height)
{
BufferedImage buf = new BufferedImage(width, height, src.getType());
double ratioSrc = (double)src.getWidth() / (double)src.getHeight();
double ratioDst = width / height;
int startWidth = 0;
int startHeight = 0;
if(Double.compare(ratioSrc, ratioDst) != 0)
{
/* adjust ratio */
int newWidth = 0;
int newHeight = ((src.getHeight() * width) / src.getWidth());
/* first try to adjust height */
startHeight = (height - newHeight) / 2;
if(startHeight < 0)
{
/* rescale width */
newWidth = ((src.getWidth() * height) / src.getHeight());
startWidth = (width - newWidth) / 2;
startHeight = 0;
width = newWidth;
}
else
{
height = newHeight;
}
}
Graphics2D g2d = buf.createGraphics();
g2d.setBackground(Color.BLACK);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.drawImage(src, startWidth, startHeight, width, height, null);
g2d.dispose();
return buf;
}
}
| [
"alexei.fedotov@917aa43a-1baf-11df-844d-27937797d2d2"
] | alexei.fedotov@917aa43a-1baf-11df-844d-27937797d2d2 |
ca3580b880dfde96a663254537598190caaefd06 | ef185a5f5898fa23f580df4c7aa4079d70f0e490 | /app/src/main/java/ua/hey/hey/SocketConnection.java | 7f3f937304a0cb02a4634caf51e40a2f901e26fc | [] | no_license | Ramiel2009/Hey | 944b081afcb33d6f5bc0ff4197f3f264b96ac465 | a0ae1ac29d9597a3cb5cad609dfcfc1f0a6a9351 | refs/heads/master | 2016-08-12T14:22:23.863878 | 2016-02-11T20:11:44 | 2016-02-11T20:11:44 | 46,302,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,165 | java | package ua.hey.hey;
import android.content.Context;
import android.os.AsyncTask;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
/**
* Created by mmaloshtan2 on 26.01.2016.
*/
public class SocketConnection extends AsyncTask<Void, Void, Void> {
public void setContext(Context context) {
this.context = context;
}
private Context context;
private String recPhone;
public String getRecPhone() {
return recPhone;
}
public void setRecPhone(String recPhone) {
this.recPhone = recPhone;
}
private String action;
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
private String message;
@Override
protected Void doInBackground(Void... params) {
Socket socket = null;
String address = "192.168.0.52";
int port = 8082;
try {
System.out.println("try\n");
socket = new Socket(address, port);
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
Variables var = new Variables();
switch (action){
case "send_message" :
PhoneNumber pn = new PhoneNumber();
message = "action:" + action + ";" + pn.getPhoneNumber(context) + ";"
+ this.getRecPhone()+";"+"00001"; //send message
oos.writeObject(message);
ObjectInputStream objectInputStream;
objectInputStream = new ObjectInputStream(socket.getInputStream());
var.setResponse((String) objectInputStream.readObject());
System.out.println(var.getResponse());
break;
case "get_messages": //get message templates from server
message = "action:get_messages";
oos.writeObject(message);
objectInputStream = new ObjectInputStream(socket.getInputStream());
var.setResponse((String) objectInputStream.readObject());
Pref pref = new Pref();
pref.setMessagesList(var.getResponse());
pref.savePreferences("get_messages");
System.out.println(var.getResponse());
break;
case "get_message_log": //get message history
message = "action:get_message_log";
oos.writeObject(message);
objectInputStream = new ObjectInputStream(socket.getInputStream());
var.setResponse((String) objectInputStream.readObject());
System.out.println(var.getResponse());
break;
case "get_new_messages": //get new messages from server
message = "action:get_new_messages;" + new PhoneNumber().getPhoneNumber(context);
while (true) {
oos.writeObject(message);
objectInputStream = new ObjectInputStream(socket.getInputStream());
var.setResponse((String) objectInputStream.readObject());
System.out.println(var.getResponse());
if (var.getResponse() != null){
//TODO show notification
}
Thread.sleep(100);
}
}
}
catch (Exception e){
System.out.println("Douch!");
e.printStackTrace();
}
finally {
if(socket != null){
try {
socket.close();
System.out.println("connection closed");
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
@Override
protected void onPostExecute (Void result){
System.out.println("\ndone!");
}
} | [
"ramiel2009@gmail.com"
] | ramiel2009@gmail.com |
719c853abb70628a4180d3af5ff2b50cb9af6eae | 17ced39c5c959582cbf1059c95f3c099f8a6abce | /data-structure/src/main/java/com/liyc/algs/pata/A1034.java | 7c6efda1356cb7692db20057f3a840d80d8a8a0d | [
"MIT"
] | permissive | YuchangLi/algs | 642c770e808d1dfe964ee11de7cd0ac3bbfadd15 | ce9502974c13d79a833afd874e028888aee98804 | refs/heads/master | 2021-07-14T14:20:03.272492 | 2019-10-23T04:13:05 | 2019-10-23T04:13:05 | 215,472,123 | 0 | 0 | MIT | 2020-10-13T16:46:01 | 2019-10-16T06:20:52 | Java | UTF-8 | Java | false | false | 3,031 | java | package com.liyc.algs.pata;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/**
* 构建Map<index, name>, 构建图g[name1][name2]
* DFS遍历图,找出所有联通子图,然后子图的边权总和。
*/
public class A1034 {
// 图
private static int[][] g;
// 顶点是否已访问过
private static int[] v;
// 顶点权重
private static int[] w;
// 阀值
private static int threthold;
// 总人数
private static int personsN;
public static void main(String[] args) throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String line1 = bf.readLine();
String[] line1as = line1.split(" ");
int totalcalls = Integer.valueOf(line1as[0]);
threthold = Integer.valueOf(line1as[1]);
int maxpersons = totalcalls * 2;
int index = 0;
Map<Integer, String> persons = new HashMap<>(maxpersons);
g = new int[maxpersons][maxpersons];
v = new int[maxpersons];
w = new int[maxpersons];
// 构建图
for (int k = 0; k < totalcalls; k++) {
String[] lines = bf.readLine().split(" ");
String name1 = lines[0];
String name2 = lines[1];
int i = 0;
if(!persons.containsValue(name1)){
i = index++;
persons.put(i, name1);
} else{
i = getKeyFromValue(persons, name1);
}
int j = 0;
if(!persons.containsValue(name2)){
j = index++;
persons.put(j, name2);
} else{
j = getKeyFromValue(persons, name2);
}
int time = Integer.valueOf(lines[2]);
g[i][j] += time;
g[j][i] += time;
w[j] = w[j] + time;
w[i] = w[i] + time;
}
bf.close();
personsN = persons.size();
// 保存各个联通子图
Set<Set<Integer>> subg = new HashSet<>();
// 遍历图
for (int i = 0; i < personsN; i++) {
if( v[i] > 0){
continue;
}
Set<Integer> set = new HashSet<>(maxpersons);
subg.add(set);
dfs(i, set);
}
int count = 0;
Map<Integer, Integer> ps = new TreeMap<>(Comparator.comparing(persons::get));
// 遍历各子图判断,存入ps
for (Set<Integer> set : subg){
if(set.size() <= 2){
continue;
}
int max = -1;
int sum = 0;
for (int i : set) {
int iw = w[i];
sum += iw;
if (max == -1 || iw > w[max]) {
max = i;
}
}
if( sum /2 <= threthold) {
continue;
}
count++;
ps.put(max, set.size());
}
System.out.println(count);
if(count==0){
return;
}
ps.forEach((k, v)->{
String name = persons.get(k);
System.out.println(name+" "+ps.get(k));
});
}
private static int getKeyFromValue(Map<Integer, String> persons, String name1) {
Set<Map.Entry<Integer, String>> set = persons.entrySet();
for (Map.Entry<Integer, String> en : set) {
if(en.getValue().equals(name1)) {
return en.getKey();
}
}
return 0;
}
private static void dfs(int i, Set<Integer> list) {
v[i] = 1;
list.add(i);
for (int j = 0; j < personsN; j++) {
if(g[i][j] == 0){
continue;
}
if(v[j] > 0) {
continue;
}
dfs(j, list);
}
}
}
| [
"liyuchang@ruubypay.com"
] | liyuchang@ruubypay.com |
5cc52e89b651ccf2fc366237ee5e744ba77bff95 | c908edeca98cb3ff20a25ff9d8afd4b090b063fd | /src/main/java/com/demo/spring/data/repository/EmployeeRepository.java | 33df86fdfe1b2d0502aaff4902dd0126c0eae365 | [] | no_license | suryat789/SpringDataDemo | ec0079efbb1d2f59dbac67849693e0feb9aaa772 | 10ae2cd902ba91bd5a44f3044097dc8f2909874c | refs/heads/master | 2021-01-25T07:39:43.007513 | 2015-03-31T14:19:17 | 2015-03-31T14:19:17 | 33,189,430 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 446 | java | package com.demo.spring.data.repository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.demo.spring.data.entities.Address;
import com.demo.spring.data.entities.Employee;
@Repository
public interface EmployeeRepository extends CrudRepository<Employee, Integer> {
public Employee findByEmployeeId(Integer id);
public Employee findEmployeeByAddress(Address address);
}
| [
"suryat789@gmail.com"
] | suryat789@gmail.com |
181ddff919ad48aef9455bf7bac798f364e81c2c | 4327ba5d6c7bb63a81a61cece2632fd91eee5548 | /src/ancloud-ui/src/main/java/org/ancloud/presentation/modules/navigation/NavigationLinkController.java | e35e63cbf4ed8f52e9ae642f152ff9bd57fb510d | [] | no_license | njmube/ancloud | 13d593398a7e862ae907f394509cf6865b99d8e4 | 82d0849671cef55a0eb613d5307df39e09b1492d | refs/heads/master | 2021-08-22T15:49:26.844350 | 2017-11-30T15:12:56 | 2017-11-30T15:12:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,691 | java | package org.ancloud.presentation.modules.navigation;
import java.util.Locale;
import javax.inject.Inject;
import javax.validation.Valid;
import org.ancloud.domain.NavigationLink;
import org.ancloud.domain.Project;
import org.ancloud.domain.constant.SessionConstant;
import org.ancloud.fw.core.service.SessionService;
import org.ancloud.fw.presentation.BaseController;
import org.ancloud.fw.presentation.resolver.Session;
import org.ancloud.service.navigation.NavigationLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@Controller
@RequestMapping(value = {"/navigation-link"})
public class NavigationLinkController extends BaseController {
private RequestMappingHandlerMapping handlerMapping;
@Autowired
public NavigationLinkController(RequestMappingHandlerMapping handlerMapping) {
this.handlerMapping = handlerMapping;
}
@Inject
SessionService sessionService;
@Inject
NavigationLinkService navigationLinkService;
@ModelAttribute
public FmNavigationLink getFmNavigationLink() {
return new FmNavigationLink();
}
@RequestMapping(value = {"","/modify"}, method = RequestMethod.GET)
public String displayModify(FmNavigationLink fmNavigationLink, Model model,@Session(key=SessionConstant.SESSION_CURRENT_PROJECT) Project project,@Session(key=SessionConstant.SESSION_CURRENT_LOCALE) Locale locale) {
fmNavigationLink.setNavigationLinks(this.mapper.mapAsList(navigationLinkService.findAllNavigationLinkByProject(project,locale), FmiNavigationLink.class));
return "navigation-link/FmNavigationLink";
}
@RequestMapping(value = {"/modify"}, method = RequestMethod.POST)
public String processModify(@Valid FmNavigationLink fmNavigationLink,BindingResult bindingResult, Model model,@Session(key=SessionConstant.SESSION_CURRENT_PROJECT) Project project) {
String dest = null;
if(bindingResult.hasErrors()){
dest = "navigation-link/FmNavigationLink";
} else {
navigationLinkService.modifyList(this.mapper.mapAsList(fmNavigationLink.getNavigationLinks(), NavigationLink.class),project);
// TODO sessionService.put(SessionConstant.SESSION_NAVIGATION_LINKS, navigationLinkService.findAllNavigationLinkByProject(project, null));
dest = "redirect:/navigation-link/modify";
}
return dest;
}
}
| [
"tamanle23@gmail.com"
] | tamanle23@gmail.com |
76a091dad9a9aa0a7698fffc51f4a25c32d7d98d | d370b0fdd1f531a81818751bc5dc44d86ae603a0 | /flexodesktop/model/flexofoundation/src/main/java/org/openflexo/foundation/dm/JDKRepository.java | 75ffb64a0c47028db2b8e262f327e619f6cb6c94 | [] | no_license | bluepimento/openflexo | 0e06db9817e9eb21f3302da3b705f4c4aed5678c | b586b75362ffa4cd11c10397e0c343795ba1dd94 | refs/heads/master | 2020-12-24T10:53:49.783246 | 2012-03-02T08:24:06 | 2012-03-02T08:24:06 | 2,553,912 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,841 | java | /*
* (c) Copyright 2010-2011 AgileBirds
*
* This file is part of OpenFlexo.
*
* OpenFlexo 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.
*
* OpenFlexo 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 OpenFlexo. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.openflexo.foundation.dm;
import java.io.File;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openflexo.foundation.dm.action.ImportJDKEntity;
import org.openflexo.foundation.xml.FlexoDMBuilder;
import org.openflexo.localization.FlexoLocalization;
import org.openflexo.toolbox.Duration;
/**
* Represents a logical group of objects defined in common JDK implementation and used in the project
*
* @author sguerin
*
*/
public class JDKRepository extends DMRepository {
private static final Logger logger = Logger.getLogger(JDKRepository.class.getPackage().getName());
// ==========================================================================
// ============================= Instance variables
// =========================
// ==========================================================================
// ==========================================================================
// ============================= Constructor
// ================================
// ==========================================================================
/**
* Constructor used during deserialization
*/
public JDKRepository(FlexoDMBuilder builder) {
this(builder.dmModel);
initializeDeserialization(builder);
}
/**
* Default constructor
*/
public JDKRepository(DMModel dmModel) {
super(dmModel);
}
@Override
public DMRepositoryFolder getRepositoryFolder() {
return getDMModel().getInternalRepositoryFolder();
}
@Override
public int getOrder() {
return 1;
}
@Override
public String getName() {
return "jdk_repository";
}
@Override
public String getLocalizedName() {
return FlexoLocalization.localizedForKey(getName());
}
@Override
public void setName(String name) {
// Not allowed
}
/**
* @param dmModel
* @return
*/
public static JDKRepository createNewJDKRepository(DMModel dmModel) {
JDKRepository newJDKRepository = new JDKRepository(dmModel);
dmModel.setJDKRepository(newJDKRepository);
LoadableDMEntity.createLoadableDMEntity(dmModel, Integer.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Long.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Short.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Float.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Double.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Character.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Byte.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Boolean.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Integer.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Long.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Short.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Float.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Double.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Character.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Byte.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Boolean.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, Void.TYPE);
LoadableDMEntity.createLoadableDMEntity(dmModel, String.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Vector.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Hashtable.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, File.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, URL.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Date.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Calendar.class);
LoadableDMEntity.createLoadableDMEntity(dmModel, Duration.class);
return newJDKRepository;
}
@Override
public String getFullyQualifiedName() {
return getDMModel().getFullyQualifiedName() + ".JDK";
}
@Override
public boolean isReadOnly() {
return true;
}
@Override
public boolean isDeletable() {
return false;
}
@Override
public boolean isUpdatable() {
return true;
}
@Override
public DMPackage packageForEntity(DMEntity entity) {
String packageName = entity.getEntityPackageName();
if (packageName == null) {
if (entity instanceof JDKPrimitive) {
DMPackage primitivePackage = packages.get("primitives");
if (primitivePackage == null) {
primitivePackage = new DMPackage(getDMModel(), this, "primitives");
packages.put("primitives", primitivePackage);
}
return primitivePackage;
} else {
if (logger.isLoggable(Level.WARNING)) {
logger.warning("No package for entity " + entity.getFullyQualifiedName());
}
}
}
return super.packageForEntity(entity);
}
@Override
protected Vector getSpecificActionListForThatClass() {
Vector returned = super.getSpecificActionListForThatClass();
returned.add(ImportJDKEntity.actionType);
return returned;
}
/**
* Overrides getClassNameKey
*
* @see org.openflexo.foundation.FlexoModelObject#getClassNameKey()
*/
@Override
public String getClassNameKey() {
return getName();
}
}
| [
"guillaume.polet@gmail.com"
] | guillaume.polet@gmail.com |
a3b01c3578f55ad32295eeb7a92f0b6cdd6b45fb | 91cd9fbc1d7cc486f43dcb863519abde880dabf2 | /students/net1814080903107/component/MyFoodLinearLayout.java | 6980b7c8fc5484d9d1e8ceda348f8caded04f9ba | [] | no_license | 15218047860/android-labs-2020 | 701656f4c433d571616d72878c5c3d076a49c356 | aa87cc7905faacd8b1925fada747b45211b390e5 | refs/heads/master | 2023-01-29T15:16:59.050147 | 2020-12-15T12:19:22 | 2020-12-15T12:19:22 | 297,191,075 | 0 | 0 | null | 2020-09-21T00:43:09 | 2020-09-21T00:43:08 | null | UTF-8 | Java | false | false | 6,243 | java | package com.example.thefirst.component;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.example.thefirst.constant.transmission;
import com.example.thefirst.model.DownloadModel;
import com.example.thefirst.pool.DownloadPool;
public class MyFoodLinearLayout extends LinearLayout implements transmission {
private int num=0;
private int foodID;
private String foodName;
private int price;
private String introduction;
private Bitmap foodBitmap;
private Context context;
private ImageView i1;
private LinearLayout l2;
private TextView t1;
private LinearLayout l3;
private Button b1;
private Button b2;
private TextView t2;
private TextView t3;
public MyFoodLinearLayout(Context context) { super(context); this.context=context;init();}
public MyFoodLinearLayout(Context context, @Nullable AttributeSet attrs) { super(context, attrs);this.context=context; init();}
public MyFoodLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.context=context;init();}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public MyFoodLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); this.context=context;init();}
public ImageView getImageView(){return i1;}
public void init(){
i1=new ImageView(MyFoodLinearLayout.this.getContext());
l2=new LinearLayout(MyFoodLinearLayout.this.getContext());
t1=new TextView(l2.getContext());//name
l3=new LinearLayout(l2.getContext());
b1=new Button(l3.getContext());//+
b2=new Button(l3.getContext());//-
t2=new TextView(l2.getContext());//num
t3=new TextView(l2.getContext());//price
MyFoodLinearLayout.this.setOrientation(LinearLayout.HORIZONTAL);//行布局
MyFoodLinearLayout.this.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,300));
i1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,2));
i1.setScaleType(ImageView.ScaleType.FIT_XY);
l2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,1));
l2.setOrientation(LinearLayout.VERTICAL);
t1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
l3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
b1.setText("+");
b2.setText("-");
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
num++;
t2.setText("num:"+Integer.toString(num));
}
});
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
num--;
t2.setText("num:"+Integer.toString(num));
if(num<=0){
LinearLayout p=(LinearLayout)MyFoodLinearLayout.this.getParent();
p.removeView(MyFoodLinearLayout.this);
}
}
});
l3.addView(b1);
l3.addView(b2);
t2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
t2.setText("num:0");
t3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
l2.addView(t1);
l2.addView(l3);
l2.addView(t2);
l2.addView(t3);
MyFoodLinearLayout.this.addView(i1);
MyFoodLinearLayout.this.addView(l2);
}
public MyFoodLinearLayout setFoodID(int foodID) {
this.foodID = foodID;
return this;
}
public MyFoodLinearLayout setFoodName(String foodName) {
this.foodName = foodName;
t1.setText(foodName);
return this;
}
public MyFoodLinearLayout setPrice(int price) {
this.price = price;
t3.setText("price:"+Integer.toString(price));
return this;
}
public MyFoodLinearLayout setFoodBitmap(Bitmap foodBitmap) {
this.foodBitmap = foodBitmap;
return this;
}
public int getFoodID() {
return foodID;
}
public String getFoodName() {
return foodName;
}
public int getPrice() {
return price;
}
public Bitmap getFoodBitmap() {
return foodBitmap;
}
public void buyFood(LinearLayout linearLayout,String foodBitmap){
b1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
num++;
t2.setText("num:"+Integer.toString(num));
MyFoodLinearLayout myFoodLinearLayout =new MyFoodLinearLayout(linearLayout.getContext());
myFoodLinearLayout.
setFoodID(foodID).
setFoodName(foodName).
setPrice(price);
linearLayout.addView(myFoodLinearLayout);
DownloadPool.queue.add(new DownloadModel(myFoodLinearLayout.getImageView(),IMAGEVIEW,foodBitmap));
}
});
b2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
num--;
t2.setText("num:"+Integer.toString(num));
if(num==0){
LinearLayout p=(LinearLayout)MyFoodLinearLayout.this.getParent();
p.removeView(MyFoodLinearLayout.this);
}
}
});
}
}
| [
"2814757819@qq.com"
] | 2814757819@qq.com |
d644540d280d3dabf5c3dc78b704b14551d72123 | 52821e9c5d83d0805b76bb741e8e4276d7800ff6 | /src/benl/student/androidjournal/StrokeView.java | 851785dc990d2d5b79fb519ce0b779461657bb25 | [] | no_license | ayroblu/AndroidJournal | 7430b702fd4482d977abcd71fc6c11e7f2b755fa | 0b7deda2c608b52ecc6989bdaeb672d05a017eed | refs/heads/master | 2021-01-12T13:30:33.352220 | 2016-10-04T11:47:03 | 2016-10-04T11:47:03 | 69,959,888 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,104 | java | package benl.student.androidjournal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.View;
public class StrokeView extends View {
private static final int DEFAULT_COLOUR = 0xFF000000;
private static final int DEFAULT_RADIUS = 10;
private Paint paint;
private int radius;
public StrokeView(Context context) {
super(context);
paint = new Paint();
paint.setColor(DEFAULT_COLOUR);
paint.setStyle(Style.FILL);
paint.setAntiAlias(true);
paint.setDither(true);
radius = DEFAULT_RADIUS;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawCircle(canvas);
}
private void drawCircle(Canvas canvas) {
int x = (this.getRight() - this.getLeft())/2;
int y = (this.getBottom() - this.getTop())/2;
canvas.drawCircle(x, y, radius, paint);
}
public void setColour(int colour) {
paint.setColor(colour);
}
public void setRadius(int radius) {
this.radius = radius;
invalidate();
}
}
| [
"ben@ben-l.com"
] | ben@ben-l.com |
fc9d699d2b9ac61033c8afb67d48e47da9e62438 | 4e4b10e17b3e57772a7faeb321d7580f4f9e7be7 | /src/InheritanceExample/Employee.java | 093e9fba669ad355e86ee80e667a2b6e598886a2 | [] | no_license | binupgtm/evening-javaclass | 3e551a42927ac7b2ba7a1ec443e0b0fd2564745a | 2abb606d620acb09b1906d46ebbdea04db9ba4c5 | refs/heads/master | 2021-01-03T17:20:01.112344 | 2020-03-16T23:15:32 | 2020-03-16T23:15:32 | 240,165,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 298 | java | package InheritanceExample;
class Employee {
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String[]args) {
Programmer p=new Programmer();
System.out.println("Programmer salary is:"+p.salary+"bonus of programmer is:"+p.bonus);
}
}
| [
"binupgtm@gmail.com"
] | binupgtm@gmail.com |
a9e6bf51a6d98febfef89ebeaca66b89c47d2f73 | 374f5d1e8831550a9496b2162a1365b42a8baaf8 | /Tangerine_App/app/src/main/java/com/aryagami/tangerine/activities/ResellerChangePasswordActivity.java | 2af705dd4f2a5a8218b95dbc1e446239086c6035 | [] | no_license | surekhakoliebill/tangerine_fab_13march | 3c4d33584bf531d53cc72f11165236f4da8a2fc3 | 82b786a51525a2bb869d5b45e3da4107d9e9684d | refs/heads/master | 2021-03-18T22:22:34.873647 | 2020-05-15T20:18:28 | 2020-05-15T20:18:28 | 247,105,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,533 | java | package com.aryagami.tangerine.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputEditText;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
import com.aryagami.R;
import com.aryagami.data.Constants;
import com.aryagami.data.DataModel;
import com.aryagami.data.UserInfo;
import com.aryagami.restapis.RestServiceHandler;
import com.aryagami.util.BugReport;
import com.aryagami.util.CheckNetworkConnection;
import com.aryagami.util.MyToast;
import com.aryagami.util.ProgressDialogUtil;
import com.aryagami.util.ReDirectToParentActivity;
import com.aryagami.util.UserSession;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ResellerChangePasswordActivity extends AppCompatActivity {
Activity activity = this;
ProgressDialog progressDialog;
TextInputEditText currentPassword, newPassword, confirmPassword;
Pattern pattern;
Matcher matcher;
ImageButton backImageButton;
private static final String PASSWORD_PATTERN =
"((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!\"#$%&'()*+,-./:;<=>?@^_`{|}~]).{6,20})";
//@#*&$!% --> !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
public ResellerChangePasswordActivity() {
pattern = Pattern.compile(PASSWORD_PATTERN);
}
public void onTrimMemory(int level) {
System.gc();
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.change_password);
newPassword = (TextInputEditText) findViewById(R.id.reseller_new_password);
currentPassword = (TextInputEditText) findViewById(R.id.reseller_current_password);
confirmPassword = (TextInputEditText) findViewById(R.id.confirm_password);
backImageButton = (ImageButton) findViewById(R.id.back_imgbtn);
//Fabric.with(this, new Crashlytics());
Button submit = (Button) findViewById(R.id.reseller_save_btn);
backImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.finish();
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String currPasswordText = currentPassword.getText().toString();
String newPasswordText = newPassword.getText().toString();
String confirmPasswordText = confirmPassword.getText().toString();
if (!currPasswordText.isEmpty()) {
if(!currPasswordText.contains("Tangerine") | !currPasswordText.contains("tangerine")| !currPasswordText.contains("Lyca")| !currPasswordText.contains("lyca")) {
if (!newPasswordText.isEmpty()) {
if (!currPasswordText.trim().equalsIgnoreCase(newPasswordText.trim())) {
if (validate(newPasswordText)) {
if (!confirmPasswordText.isEmpty()) {
if (newPasswordText.equals(confirmPasswordText)) {
changePassword(currPasswordText, newPasswordText);
} else {
MyToast.makeMyToast(activity, "Entered New & Confirm Passwords are not Matched.", Toast.LENGTH_SHORT);
}
} else {
MyToast.makeMyToast(activity, "Please enter Confirm Password.", Toast.LENGTH_SHORT);
}
} else {
MyToast.makeMyToast(activity, "Entered New Password is not Matched with Password Policy.", Toast.LENGTH_SHORT);
}
} else {
MyToast.makeMyToast(activity, "Entered New & Old passwords should be Different..", Toast.LENGTH_SHORT);
}
} else {
MyToast.makeMyToast(activity, "Please enter New Password.", Toast.LENGTH_SHORT);
}
}else{
MyToast.makeMyToast(activity, "Current Password should not include such text as, Lyca, Tangerine, tangerine, lyca.", Toast.LENGTH_SHORT);
}
} else {
MyToast.makeMyToast(activity, "Please enter Current Password.", Toast.LENGTH_SHORT);
}
}
});
}
@Override
protected void onResume() {
super.onResume();
CheckNetworkConnection.cehckNetwork(ResellerChangePasswordActivity.this);
}
private void changePassword(String currPassword, String newPassword) {
UserInfo userInfo = new UserInfo();
userInfo.userId = UserSession.getUserId(ResellerChangePasswordActivity.this);
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-256");
byte[] hash = new byte[0];
byte[] hash1 = new byte[0];
try {
hash = digest.digest(currPassword.getBytes("UTF-8"));
hash1 = digest.digest(newPassword.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
BugReport.postBugReport(activity, Constants.emailId,"Error:"+e.getMessage()+" "+e.getCause(),"ResellerChangePasswordActivity");
}
userInfo.oldPassword = LoginActivity.bytesToHex(hash);
userInfo.password = LoginActivity.bytesToHex(hash1);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
BugReport.postBugReport(activity, Constants.emailId,"Error:"+e.getMessage()+" "+e.getCause(),"ResellerChangePasswordActivity");
}
RestServiceHandler service = new RestServiceHandler();
try {
progressDialog = ProgressDialogUtil.startProgressDialog(activity, "");
progressDialog.setCanceledOnTouchOutside(false);
service.changePassword(userInfo, new RestServiceHandler.Callback() {
@Override
public void success(DataModel.DataType type, List<DataModel> data) {
if (isFinishing()) {
return;
}
ProgressDialogUtil.stopProgressDialog(progressDialog);
UserInfo changedPassword = (UserInfo) data.get(0);
if (changedPassword.status.equals("success")) {
displayAlertMessage(getResources().getString(R.string.changed_password));
} else {
// BugReport.postBugReport(activity, Constants.emailId, changedPassword.status, "ChangePassword");
if (changedPassword.status.equals("INVALID_SESSION")) {
ReDirectToParentActivity.callLoginActivity(activity);
} else {
displayAlertMessage(changedPassword.status);
}
}
}
@Override
public void failure(RestServiceHandler.ErrorCode error, String status) {
if (isFinishing()) {
return;
}
ProgressDialogUtil.stopProgressDialog(progressDialog);
displayAlertMessage("Error:" + error + "\t " + getResources().getString(R.string.request_password_change) + ", " + status);
BugReport.postBugReport(activity, Constants.emailId, "ERROR:"+error+"\n STATUS:"+status, "ChangePassword- ResellerChangePasswordActivity");
}
});
} catch (IOException e) {
e.printStackTrace();
BugReport.postBugReport(activity, Constants.emailId,"Error:"+e.getMessage()+" "+e.getCause(),"ResellerChangePasswordActivity");
}
}
private void displayAlertMessage(String message) {
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
alertDialog.setCancelable(false);
alertDialog.setMessage(message);
alertDialog.setNeutralButton(getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
activity.finish();
Intent intent = new Intent(activity, NavigationMainActivity.class);
startActivity(intent);
}
});
alertDialog.show();
}
public boolean validate(final String password) {
matcher = pattern.matcher(password);
return matcher.matches();
}
}
| [
"surekha.koli16@gmail.com"
] | surekha.koli16@gmail.com |
2ac8d837cd42f76ff66d4fcfe24e747fc28b2a48 | ce2dd90be609baad6656177e3a59ce69f1d150bd | /mediachooser/src/main/java/com/learnncode/mediachooser/fragment/ImageFragment.java | 347d3a3558c55df072e48ba35aaa7a126a78837c | [] | no_license | woshiwzy/joker | cac3c0ee47817db2f9785356e598a3288524b62f | ad1282fc027d9083cf21e55ed9f95b86e6cc21f5 | refs/heads/master | 2021-04-12T07:50:33.653812 | 2017-06-23T08:29:17 | 2017-06-23T08:29:17 | 94,511,534 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,865 | java |
package com.learnncode.mediachooser.fragment;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.GridView;
import android.widget.Toast;
import com.learnncode.mediachooser.MediaChooserConstants;
import com.learnncode.mediachooser.MediaModel;
import com.learnncode.mediachooser.R;
import com.learnncode.mediachooser.adapter.GridViewAdapter;
import java.io.File;
import java.util.ArrayList;
public class ImageFragment extends Fragment {
private ArrayList<MediaModel> mGalleryModelList;
private GridView mImageGridView;
private View mView;
private OnImageSelectedListener mCallback;
private GridViewAdapter mImageAdapter;
private Cursor mImageCursor;
// Container Activity must implement this interface
public interface OnImageSelectedListener {
public void onImageSelected(int count);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
mCallback = (OnImageSelectedListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement OnImageSelectedListener");
}
}
public ImageFragment() {
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (mView == null) {
mView = inflater.inflate(R.layout.view_grid_layout_media_chooser, container, false);
mImageGridView = (GridView) mView.findViewById(R.id.gridViewFromMediaChooser);
if (getArguments() != null) {
initPhoneImages(getArguments().getString("name"));
} else {
initPhoneImages();
}
} else {
// ViewParent pView = mView.getParent();
// if(null!=pView){
// ((ViewGroup)pView).removeView(mView);
// }
// if(mImageAdapter == null || mImageAdapter.getCount() == 0){
// Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show();
// }
}
//
if (null != mImageAdapter) {
mImageAdapter.clearAllSelect();
}
// MediaChooserConstants.SELECTED_MEDIA_COUNT=0;
return mView;
}
private void initPhoneImages(String bucketName) {
try {
final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
String searchParams = null;
String bucket = bucketName;
searchParams = "bucket_display_name = \"" + bucket + "\"";
final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
mImageCursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, searchParams, null, orderBy + " DESC");
setAdapter(mImageCursor);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initPhoneImages() {
try {
final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
mImageCursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy + " DESC");
setAdapter(mImageCursor);
} catch (Exception e) {
e.printStackTrace();
}
}
private void setAdapter(Cursor imagecursor) {
if (imagecursor.getCount() > 0) {
mGalleryModelList = new ArrayList<MediaModel>();
for (int i = 0; i < imagecursor.getCount(); i++) {
imagecursor.moveToPosition(i);
int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
String file=imagecursor.getString(dataColumnIndex).toString();
if(null!=file && (new File(file)).exists()){
MediaModel galleryModel = new MediaModel(file, false);
mGalleryModelList.add(galleryModel);
}
}
mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false);
mImageGridView.setAdapter(mImageAdapter);
} else {
Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show();
}
mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter();
MediaModel galleryModel = (MediaModel) adapter.getItem(position);
File file = new File(galleryModel.url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(intent);
return true;
}
});
mImageGridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
// update the mStatus of each category in the adapter
GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter();
MediaModel galleryModel = (MediaModel) adapter.getItem(position);
if (adapter.isSelect(galleryModel)) {
adapter.selectModel(galleryModel);
} else {
// long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false);
if (adapter.getSlectMode().size() == MediaChooserConstants.MAX_IMG_LIMIT) {
Toast.makeText(getActivity(), "Max image files is " + MediaChooserConstants.MAX_IMG_LIMIT, Toast.LENGTH_LONG).show();
return;
}
// if (size > MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB) {
// Toast.makeText(getActivity(), "This image file too large", Toast.LENGTH_LONG).show();
// return;
// }
adapter.selectModel(galleryModel);
}
if (mCallback != null) {
mCallback.onImageSelected(adapter.getSlectMode().size());
Intent intent = new Intent();
intent.putStringArrayListExtra("list", adapter.getSelectList());
getActivity().setResult(Activity.RESULT_OK, intent);
}
}
});
}
public ArrayList<String> getSelectedImageList() {
if(null==mImageAdapter){
return new ArrayList<String>(0);
}
return mImageAdapter.getSelectList();
}
public void addItem(String item) {
if (mImageAdapter != null) {
MediaModel model = new MediaModel(item, false);
mGalleryModelList.add(0, model);
mImageAdapter.notifyDataSetChanged();
} else {
initPhoneImages();
}
}
}
| [
"wzyfly@sina.com"
] | wzyfly@sina.com |
6e1253a198d17aa7778800685d75537cb577edd1 | e15dada2485a1cc8927de31a2bee7bd0e8f81319 | /src/main/java/com/financing/service/ProjectUpdateService.java | 6f29a86070c51fdbf8dc04f73f590fc596da6b82 | [] | no_license | lizexu122/zhongchou | f337953adb97832a09c6543587c4d78d8a076058 | 0ed288c5dacb010ee16ea886b22257c4149e1ef9 | refs/heads/master | 2020-04-06T19:11:26.072038 | 2019-05-13T15:19:47 | 2019-05-13T15:19:47 | 157,729,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 277 | java | package com.financing.service;
import com.financing.entity.Project;
import com.financing.entity.ProjectUpdate;
import java.util.List;
public interface ProjectUpdateService {
void addUpdate(ProjectUpdate update);
List<ProjectUpdate> getUpdateList(Project project);
}
| [
"2694294196@qq.com"
] | 2694294196@qq.com |
4cac4b770b79641b320a00868aeebcfb3549c08c | 09a1cf766a0f2877de2076d62479ffb8fb9e54e3 | /MusicBuzzer/src/DurationValue.java | 3ef5dd14e4ab33823d8669f8e6f2491fb399ecc2 | [] | no_license | telis93/MusicBuzzer | 6aba4fa30dc9a52d66ef961021b02c88e592bb25 | 782d3b6961a27b4a404f2f3d57d1045c06588a5a | refs/heads/master | 2020-05-31T17:58:06.608284 | 2014-01-27T20:12:43 | 2014-01-27T20:12:43 | 15,005,061 | 0 | 0 | null | 2016-12-18T00:41:46 | 2013-12-07T12:12:46 | Java | UTF-8 | Java | false | false | 105 | java |
public enum DurationValue {
WHOLE, HALF, QUARTER, EIGHTTH, SIXTEENTH,
THIRTYSECOND, SIXTYFOURTH
} | [
"dossas07@hotmail.com"
] | dossas07@hotmail.com |
8bf55085146ef5e17572a539abe7cf215b78abcd | c808e0c6b81104a62c9d08dba2dccd9ca9a5afe0 | /Polymorphism/Lab/shapes/Circle.java | f208101a691c3bac89ab04b472b76eff49cd4178 | [] | no_license | HristoNakov13/SoftUni-Java-OOP | 83470e7ed54e9c9748353eb3bb8387b37f9b6c66 | 6a12b78858effe8332ea61388d042e60de757453 | refs/heads/master | 2021-07-05T12:57:46.877012 | 2019-08-12T20:45:14 | 2019-08-12T20:45:14 | 194,120,536 | 0 | 1 | null | 2020-10-13T14:35:51 | 2019-06-27T15:30:47 | Java | UTF-8 | Java | false | false | 436 | java | package shapes;
public class Circle extends Shape {
private Double radius;
public Circle(Double radius) {
this.radius = radius;
}
public final Double getRadius() {
return radius;
}
@Override
double calculatePerimeter() {
return 2 * Math.PI * this.getRadius();
}
@Override
double calculateArea() {
return Math.PI * this.getRadius() * this.getRadius();
}
}
| [
"admiralbiat"
] | admiralbiat |
1d15f68c163198c052b608720fbd604903581832 | b405a6f7a3358c9008f7a7b30046201647de988d | /Branches/Edexer/Technical/Code/edexer/src/main/java/com/edexer/model/BcPermissions.java | cc749745d5523fc1941f89ba74e221fdb2fe385a | [] | no_license | edexcompany/edexer | 1b9fb02ec4839406ff7c9f448986785b0a873ab7 | 74621fd172d52948c1878a2c299e941f2bfea0e8 | refs/heads/master | 2016-09-06T13:12:31.104932 | 2015-06-04T22:25:00 | 2015-06-04T22:25:00 | 35,110,101 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,973 | java | package com.edexer.model;
// Generated May 24, 2015 10:17:18 AM by Hibernate Tools 3.6.0
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* BcPermissions generated by hbm2java
*/
@Entity
@Table(name = "bc_permissions", catalog = "edexer_edexer")
public class BcPermissions implements java.io.Serializable {
private Integer bcPermissionsId;
private UserSubscription userSubscription;
private BusinessCard businessCard;
public BcPermissions() {
}
public BcPermissions(UserSubscription userSubscription,
BusinessCard businessCard) {
this.userSubscription = userSubscription;
this.businessCard = businessCard;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "bc_permissions_id", unique = true, nullable = false)
public Integer getBcPermissionsId() {
return this.bcPermissionsId;
}
public void setBcPermissionsId(Integer bcPermissionsId) {
this.bcPermissionsId = bcPermissionsId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "user_subscription_user_id", referencedColumnName = "user_id", nullable = false),
@JoinColumn(name = "user_subscription_sub_type", referencedColumnName = "sub_type", nullable = false) })
public UserSubscription getUserSubscription() {
return this.userSubscription;
}
public void setUserSubscription(UserSubscription userSubscription) {
this.userSubscription = userSubscription;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "bc_id", nullable = false)
public BusinessCard getBusinessCard() {
return this.businessCard;
}
public void setBusinessCard(BusinessCard businessCard) {
this.businessCard = businessCard;
}
}
| [
"y.radwan@edex.co"
] | y.radwan@edex.co |
0457adbf82cd4b558c943da8062a2e903231380b | 8b9e9de996cedd31561c14238fe655c202692c39 | /tree/leetcode_Flatten_Binary_Tree_to_Linked_List.java | 4a9454e03b069516effeebf38cbe93ec88bffa01 | [] | no_license | monkeylyf/interviewjam | 0049bc1d79e6ae88ca6d746b05d07b9e65bc9983 | 33c623f226981942780751554f0593f2c71cf458 | refs/heads/master | 2021-07-20T18:25:37.537856 | 2021-02-19T03:26:16 | 2021-02-19T03:26:16 | 6,741,986 | 59 | 31 | null | null | null | null | UTF-8 | Java | false | false | 2,589 | java | /*Flatten_Binary_Tree_to_Linked_List
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6
*/
public class leetcode_Flatten_Binary_Tree_to_Linked_List {
public static void main(String[] args) {
// Test case.
TreeNode root = new TreeNode(0);
flatten(root);
}
// This is the solution i came up with recently. Way better than the one below.
// Post-order recursion +
public static void myFlatten(TreeNode root) {
if (root == null) {
return;
}
flatten(root.left);
flatten(root.right);
// Cache root.right for swap.
TreeNode right = root.right;
// Copy left to right and empty left.
root.right = root.left;
root.left = null;
// Right the last node of linked copied to right and connect it with the right linkedlist.
TreeNode cursor = root;
while (cursor.right != null) {
cursor = cursor.right;
}
cursor.right = right;
}
// The version one solution.
public static void flatten(TreeNode root) {
// The quetion is not very clear on the order of linked list.
// OJ test case tells that it should be in order of preorder traversal.
if (root == null) {
return;
}
TreeNode node = root;
// Find first node with non-null left child.
while (node.left == null) {
node = node.right;
if (node == null) {
// if all node has no left child.
return;
}
}
TreeNode left = node.left;
// Along left child node, find last non-null right child.
while (left.right != null) {
left = left.right;
}
if (node.right != null) {
left.right = node.right;
}
node.right = node.left;
node.left = null;
flatten(node.right);
}
}
class TreeNode {
TreeNode left;
TreeNode right;
int val;
TreeNode(int val) {
this.left = null;
this.right = null;
this.val = val;
}
}
/* Python Version
def flatten(self, root):
if not root:
return
right = root.right
left = root.left
root.left = None
root.right = left
cursor = root
while cursor.right:
cursor = cursor.right
cursor.right = right
self.flatten(root.right)
*/
| [
"laituan1986@gmail.com"
] | laituan1986@gmail.com |
d33226971571357ffcec3a90fcff956cc1cef4f5 | 0f3e4966b41264638dca454c62ab041d56eb7a11 | /src/main/java/com/bios/app/controller/ClienteController.java | 7ddd387a902ad9fd35f87733c2ac20836eb8da2a | [] | no_license | fabiolopes/cliente-service | 500684b83df794b4e4284928b5aee4a5c013f0ba | ac635782360841bf2b6b83d2d5c23ff4d850c88f | refs/heads/master | 2022-04-22T11:05:20.003781 | 2020-04-19T14:51:41 | 2020-04-19T14:51:41 | 257,025,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,024 | java | package com.bios.app.controller;
import static com.bios.app.repository.ClienteRepository.*;
import java.time.LocalDateTime;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/cliente")
@CrossOrigin(origins="*")
public class ClienteController {
@GetMapping
public ResponseEntity<?> getCliente(){
System.out.println("/cliente Acessado em " + LocalDateTime.now());
try {
return ResponseEntity.ok(generateCliente());
}catch (Exception e) {
return ResponseEntity.badRequest().body("Deu ruim hein. "+e.getStackTrace());
}
}
@GetMapping(path= "/conta/{cnpj:.+}")
public ResponseEntity<?> getContaByCNPJ(@PathVariable String cnpj){
System.out.println("/cliente/"+cnpj+" Acessado em " + LocalDateTime.now());
try {
return ResponseEntity.ok(getContasByCNPJ(cnpj.replace("_", "/")));
}catch (Exception e) {
return ResponseEntity.badRequest().body("Deu ruim hein. "+e.getStackTrace());
}
}
@GetMapping(path= "/linha/{cnpj:.+}")
public ResponseEntity<?> getLinhaByCNPJ(@PathVariable String cnpj){
System.out.println("/linha/"+cnpj+" Acessado em " + LocalDateTime.now());
try {
return ResponseEntity.ok(getLinhasByCNPJ(cnpj.replace("_", "/")));
}catch (Exception e) {
return ResponseEntity.badRequest().body("Deu ruim hein. "+e.getStackTrace());
}
}
@GetMapping(path= "/endereco/{cnpj:.+}")
public ResponseEntity<?> getEnderecoByCNPJ(@PathVariable String cnpj){
System.out.println("/endereco/"+cnpj+" Acessado em " + LocalDateTime.now());
try {
return ResponseEntity.ok(getEnderecosByCNPJ(cnpj.replace("_", "/")));
}catch (Exception e) {
return ResponseEntity.badRequest().body("Deu ruim hein. "+e.getStackTrace());
}
}
}
| [
"fabiolopesbione@hotmail.com"
] | fabiolopesbione@hotmail.com |
ea2b87123bc69b489be1a638591f167ff03f2e40 | 5107b2af627a7b869c335b2408f8a01242c8a147 | /nkdonate-module-nap1s/src/main/java/me/kazoku/donate/module/topup/thecaofast/Nap1sModule.java | e4c13bac63f6b78468fe96ae2a54b47f11def780 | [
"MIT"
] | permissive | K4zoku/nkdonate-project | f3fe21791149a509c90469f00ad93ed14597c096 | 98981fb77ed629f083674e4440ec8522cf249f42 | refs/heads/master | 2023-03-30T19:11:50.498996 | 2021-03-30T04:57:49 | 2021-03-30T04:57:49 | 321,001,982 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,495 | java | package me.kazoku.donate.module.topup.thecaofast;
import com.google.gson.JsonObject;
import me.kazoku.artxe.converter.time.prototype.TickConverter;
import me.kazoku.donate.NKDonatePlugin;
import me.kazoku.donate.external.api.NKDonateAPI;
import me.kazoku.donate.internal.handler.RewardsProfile;
import me.kazoku.donate.internal.util.file.FileUtils;
import me.kazoku.donate.modular.topup.Response;
import me.kazoku.donate.modular.topup.TopupModule;
import me.kazoku.donate.modular.topup.object.Card;
import net.thecaofast.api.CardPrice;
import net.thecaofast.api.CardType;
import net.thecaofast.api.Nap1SAPI;
import org.jetbrains.annotations.NotNull;
import org.simpleyaml.configuration.Configuration;
import org.simpleyaml.configuration.ConfigurationSection;
import org.simpleyaml.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.InputStream;
import java.util.*;
import java.util.logging.Level;
public class Nap1sModule extends TopupModule {
private static final RewardsProfile rewards = new RewardsProfile();
private static final List<Card.Type> CARD_TYPES = new ArrayList<>();
private static final List<Card.Price> CARD_PRICES = new ArrayList<>();
private File configFile;
private Nap1SAPI api;
private long period;
@Override
public boolean onPreStartup() {
configFile = new File(getDataFolder(), "config.yml");
saveDefaults();
return loadConfig();
}
@Override
public void onStartup() {
NKDonatePlugin.getInstance().getDebugLogger().debug("[N1S] Running checking task...");
NKDonateAPI.runAsyncTimerTask(NKDonatePlugin.getInstance().getQueue()::checkAll, 0, period);
NKDonatePlugin.getInstance().getDebugLogger().debug(() -> "[N1S] Period: " + period);
}
private void saveDefaults() {
final InputStream is = getClassLoader().getResourceAsStream("config.yml");
if (Objects.nonNull(is)) {
if (configFile.exists()) {
Configuration config = getConfig();
config.setDefaults(YamlConfiguration.loadConfiguration(is));
config.options().copyDefaults(true);
} else {
FileUtils.toFile(is, configFile, getModuleManager().getLogger());
}
}
}
private boolean loadConfig() {
final Configuration config = getConfig();
final String apiKey = config.getString("APIKey", "");
final String rewardProfile = config.getString("RewardProfile", "");
if (apiKey.isEmpty()) {
getModuleManager().getLogger().log(Level.WARNING, "Missing API information, disabling...");
return false;
}
api = new Nap1SAPI(apiKey, getModuleManager().getLogger());
if (!rewardProfile.isEmpty()) rewards.load(config.getConfigurationSection("Rewards." + rewardProfile));
period = TickConverter.convertToTick(config.get("Period", "1200tick")).getValue().longValue();
CARD_TYPES.clear();
final ConfigurationSection typeSection = config.getConfigurationSection("Card.Type");
Arrays.stream(CardType.values())
.forEach(type -> Optional.ofNullable(typeSection.getString(type.getValue()))
.map(type::toGenericType)
.ifPresent(CARD_TYPES::add));
CARD_PRICES.clear();
final ConfigurationSection priceSection = config.getConfigurationSection("Card.Price");
Arrays.stream(CardPrice.values())
.forEach(price -> Optional.ofNullable(priceSection.getString(price.getValue()))
.map(price::toGenericPrice)
.ifPresent(CARD_PRICES::add));
return true;
}
@NotNull
@Override
public Response sendCard(Card card) {
JsonObject json = api.createTransaction(
card.getType().getValue(), card.getPrice().getValue(),
card.getSerial(), card.getPin()
);
boolean success = json.get("status").getAsString().equals("success");
if (success) card.updateId(json.get("transactionId")::getAsString);
return new Response(success, json.get("msg").getAsString());
}
@Override
public void checkCard(Card card) {
JsonObject json = api.checkTransaction(card.getId());
int code = json.get("statusId").getAsInt();
Card.Status status = code == 1 ? Card.Status.SUCCESS : code == 0 ? Card.Status.AWAITING : Card.Status.FAILED;
card.updateStatus(status, json.get("msg").getAsString());
}
@Override
public List<Card.Type> getCardTypes() {
return CARD_TYPES;
}
@Override
public List<Card.Price> getCardPrices() {
return CARD_PRICES;
}
@Override
public RewardsProfile getRewards() {
return rewards;
}
}
| [
"takahatashunvn@gmail.com"
] | takahatashunvn@gmail.com |
064cf27294196969fe9750665ec3b4de138b2edb | 5a8e3ffdd42c5a4208435668a61f3fee5df5badf | /LevdeoWMSWebService/src/main/java/com/tre/jdevtemplateboot/service/impl/SysRoleFunctionServiceImpl.java | 4d322ed96ab48047afb783015011aa2f9029294e | [] | no_license | P79N6A/LevdeoWMS | 5a73c0753db1130fd1954d74730ea756778d1c5b | c1850e7d40448a5e2c6104497636d27ec1775cb6 | refs/heads/master | 2020-05-14T13:09:38.907116 | 2019-04-17T02:53:22 | 2019-04-17T02:53:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 581 | java | package com.tre.jdevtemplateboot.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tre.jdevtemplateboot.domain.po.SysRoleFunction;
import com.tre.jdevtemplateboot.mapper.SysRoleFunctionMapper;
import com.tre.jdevtemplateboot.service.ISysRoleFunctionService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author JDev
* @since 2018-12-17
*/
@Service
public class SysRoleFunctionServiceImpl extends ServiceImpl<SysRoleFunctionMapper, SysRoleFunction> implements ISysRoleFunctionService {
}
| [
"ttkk1024@qq.com"
] | ttkk1024@qq.com |
627d67e00e72860506f9f0a7c4b3dc24df90d572 | e8aed3abd7818db589ab8026b22d65c795774a4f | /src/main/java/com/d_project/xprint/io/XRawWriter.java | aabf42057b13dc8a01539be87d82653970c3bb2d | [] | no_license | kazuhikoarase/xprint | c8899057b23d98b69be80cae683b2dbc53634f51 | 3b271586b8dc6e34e0d3541ea243f30e58b352dc | refs/heads/master | 2023-09-05T21:56:57.678936 | 2022-01-21T00:13:44 | 2022-01-21T00:13:44 | 32,196,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,489 | java | package com.d_project.xprint.io;
import java.awt.print.PrinterException;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import com.d_project.xprint.core.AttributeKeys;
/**
* XRawWriter
* @author Kazuhiko Arase
*/
public class XRawWriter extends AbstractXWriter {
public XRawWriter() {
}
public void create(OutputStream out, IXWriterListener listener) throws PrinterException, IOException {
DeflaterOutputStream defOut = new DeflaterOutputStream(out);
try {
DataOutputStream objOut = new DataOutputStream(defOut);
try {
canceled = false;
double width = pages[0].getNumberAttribute(AttributeKeys.WIDTH);
double height = pages[0].getNumberAttribute(AttributeKeys.HEIGHT);
objOut.writeDouble(width);
objOut.writeDouble(height);
objOut.writeInt(pages.length);
for (int i = 0; i < pages.length; i++) {
pages[i].paintAll(context, new XRawGraphics(objOut) );
objOut.writeByte(XRawCommand.CMD_TYPE_END);
if (canceled) {
return;
}
if (listener != null) {
listener.onPage(i);
}
}
} finally {
objOut.flush();
}
} finally {
defOut.finish();
defOut.flush();
}
}
}
| [
"kazuhiko.arase@gmail.com"
] | kazuhiko.arase@gmail.com |
0200e11a42de4a52c0c8eecda59ea23e200115cb | ecb1a90d482da5cb8ddfea673cc370e7e1aee120 | /solid principles/DIExample.java | 390b0e3cf3b016a86e0eaa6623bfa7063cff14ea | [] | no_license | psahni/TAA | 6bba3a84b888f3b6eb21aa84d26518da0ab2c556 | b8f7fae51c7e4f1a18b3142b333f728de8303677 | refs/heads/master | 2020-12-21T14:54:28.061263 | 2020-04-06T12:18:03 | 2020-04-06T12:18:03 | 236,465,753 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,137 | java | public interface Switch {
boolean isOn();
void press();
}
public interface Switchable {
void turnOn();
void turnOff();
}
//package guru.springframework.blog.dependencyinversionprinciple.highlevel;
public class ElectricPowerSwitch implements Switch {
public Switchable client;
public boolean on;
public ElectricPowerSwitch(Switchable client) {
this.client = client;
this.on = false;
}
public boolean isOn() {
return this.on;
}
public void press() {
boolean checkOn = isOn();
if (checkOn) {
client.turnOff();
this.on = false;
} else {
client.turnOn();
this.on = true;
}
}
}
//---
import guru.springframework.blog.dependencyinversionprinciple.highlevel.Switchable;
public class LightBulb implements Switchable {
@Override
public void turnOn() {
System.out.println("LightBulb: Bulb turned on...");
}
@Override
public void turnOff() {
System.out.println("LightBulb: Bulb turned off...");
}
}
//---
import guru.springframework.blog.dependencyinversionprinciple.highlevel.Switchable;
public class Fan implements Switchable {
@Override
public void turnOn() {
System.out.println("Fan: Fan turned on...");
}
@Override
public void turnOff() {
System.out.println("Fan: Fan turned off...");
}
}
//---
//package guru.springframework.blog.dependencyinversionprinciple.highlevel;
import guru.springframework.blog.dependencyinversionprinciple.lowlevel.Fan;
import guru.springframework.blog.dependencyinversionprinciple.lowlevel.LightBulb;
import org.junit.Test;
public class ElectricPowerSwitchTest {
@Test
public void testPress() throws Exception {
Switchable switchableBulb = new LightBulb();
Switch bulbPowerSwitch = new ElectricPowerSwitch(switchableBulb);
bulbPowerSwitch.press();
bulbPowerSwitch.press();
Switchable switchableFan = new Fan();
Switch fanPowerSwitch = new ElectricPowerSwitch(switchableFan);
fanPowerSwitch.press();
fanPowerSwitch.press();
}
} | [
"sahni.prashantkumar.externe@prosodie.com"
] | sahni.prashantkumar.externe@prosodie.com |
b6a577aae70a43828a6b795f41c5fe847a3117df | 7dfda9db0b5eca9091c84e3cf4a0497858cac1cb | /src/mapred/org/apache/hadoop/mapred/Merger.java | 986b3c4ce9df75472d696f4dc2d1074c34b42c0d | [
"LicenseRef-scancode-unknown",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | smiley0907/purnacache | bc7364a9fa292f7606671cb494c3896d74156c13 | 0370c725d061a7fb460f7088b3cf4c8c47916d3b | refs/heads/master | 2020-03-25T19:31:13.053441 | 2020-02-07T00:56:27 | 2020-02-07T00:56:27 | 144,087,062 | 0 | 0 | Apache-2.0 | 2018-08-09T01:40:37 | 2018-08-09T01:40:37 | null | UTF-8 | Java | false | false | 18,042 | 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.hadoop.mapred;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.ChecksumFileSystem;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalDirAllocator;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DataInputBuffer;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.mapred.IFile.Reader;
import org.apache.hadoop.mapred.IFile.Writer;
import org.apache.hadoop.util.PriorityQueue;
import org.apache.hadoop.util.Progress;
import org.apache.hadoop.util.Progressable;
class Merger {
private static final Log LOG = LogFactory.getLog(Merger.class);
// Local directories
private static LocalDirAllocator lDirAlloc = new LocalDirAllocator(
"mapred.local.dir");
public static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, CompressionCodec codec, Path[] inputs,
boolean deleteInputs, int mergeFactor, Path tmpDir,
RawComparator<K> comparator, Progressable reporter,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
return new MergeQueue<K, V>(conf, fs, inputs, deleteInputs, codec,
comparator, reporter).merge(keyClass, valueClass, mergeFactor,
tmpDir, readsCounter, writesCounter);
}
public static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, CompressionCodec codec,
List<Segment<K, V>> segments, int mergeFactor, Path tmpDir,
RawComparator<K> comparator, Progressable reporter,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
return new MergeQueue<K, V>(conf, fs, segments, comparator, reporter,
false, codec).merge(keyClass, valueClass, mergeFactor, tmpDir,
readsCounter, writesCounter);
}
public static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, List<Segment<K, V>> segments, int mergeFactor,
Path tmpDir, RawComparator<K> comparator, Progressable reporter,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
return merge(conf, fs, keyClass, valueClass, segments, mergeFactor,
tmpDir, comparator, reporter, false, readsCounter,
writesCounter);
}
public static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, List<Segment<K, V>> segments, int mergeFactor,
Path tmpDir, RawComparator<K> comparator, Progressable reporter,
boolean sortSegments, Counters.Counter readsCounter,
Counters.Counter writesCounter) throws IOException {
return new MergeQueue<K, V>(conf, fs, segments, comparator, reporter,
sortSegments).merge(keyClass, valueClass, mergeFactor, tmpDir,
readsCounter, writesCounter);
}
static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, List<Segment<K, V>> segments, int mergeFactor,
int inMemSegments, Path tmpDir, RawComparator<K> comparator,
Progressable reporter, boolean sortSegments,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
return new MergeQueue<K, V>(conf, fs, segments, comparator, reporter,
sortSegments).merge(keyClass, valueClass, mergeFactor,
inMemSegments, tmpDir, readsCounter, writesCounter);
}
static <K extends Object, V extends Object> RawKeyValueIterator merge(
Configuration conf, FileSystem fs, Class<K> keyClass,
Class<V> valueClass, CompressionCodec codec,
List<Segment<K, V>> segments, int mergeFactor, int inMemSegments,
Path tmpDir, RawComparator<K> comparator, Progressable reporter,
boolean sortSegments, Counters.Counter readsCounter,
Counters.Counter writesCounter) throws IOException {
return new MergeQueue<K, V>(conf, fs, segments, comparator, reporter,
sortSegments, codec).merge(keyClass, valueClass, mergeFactor,
inMemSegments, tmpDir, readsCounter, writesCounter);
}
public static <K extends Object, V extends Object> void writeFile(
RawKeyValueIterator records, Writer<K, V> writer,
Progressable progressable, Configuration conf) throws IOException {
long progressBar = conf.getLong("mapred.merge.recordsBeforeProgress",
10000);
long recordCtr = 0;
while (records.next()) {
writer.append(records.getKey(), records.getValue());
if (((recordCtr++) % progressBar) == 0) {
progressable.progress();
}
}
}
public static class Segment<K extends Object, V extends Object> {
Reader<K, V> reader = null;
DataInputBuffer key = new DataInputBuffer();
DataInputBuffer value = new DataInputBuffer();
Configuration conf = null;
FileSystem fs = null;
Path file = null;
boolean preserve = false;
CompressionCodec codec = null;
long segmentOffset = 0;
long segmentLength = -1;
public Segment(Configuration conf, FileSystem fs, Path file,
CompressionCodec codec, boolean preserve) throws IOException {
this(conf, fs, file, 0, fs.getFileStatus(file).getLen(), codec,
preserve);
}
public Segment(Configuration conf, FileSystem fs, Path file,
long segmentOffset, long segmentLength, CompressionCodec codec,
boolean preserve) throws IOException {
this.conf = conf;
this.fs = fs;
this.file = file;
this.codec = codec;
this.preserve = preserve;
this.segmentOffset = segmentOffset;
this.segmentLength = segmentLength;
}
public Segment(Reader<K, V> reader, boolean preserve) {
this.reader = reader;
this.preserve = preserve;
this.segmentLength = reader.getLength();
}
private void init(Counters.Counter readsCounter) throws IOException {
if (reader == null) {
FSDataInputStream in = fs.open(file);
in.seek(segmentOffset);
reader = new Reader<K, V>(conf, in, segmentLength, codec,
readsCounter);
}
}
DataInputBuffer getKey() {
return key;
}
DataInputBuffer getValue() {
return value;
}
long getLength() {
return (reader == null) ? segmentLength : reader.getLength();
}
boolean next() throws IOException {
return reader.next(key, value);
}
void close() throws IOException {
reader.close();
if (!preserve && fs != null) {
fs.delete(file, false);
}
}
public long getPosition() throws IOException {
return reader.getPosition();
}
}
private static class MergeQueue<K extends Object, V extends Object> extends
PriorityQueue<Segment<K, V>> implements RawKeyValueIterator {
Configuration conf;
FileSystem fs;
CompressionCodec codec;
List<Segment<K, V>> segments = new ArrayList<Segment<K, V>>();
RawComparator<K> comparator;
private long totalBytesProcessed;
private float progPerByte;
private Progress mergeProgress = new Progress();
Progressable reporter;
DataInputBuffer key;
DataInputBuffer value;
Segment<K, V> minSegment;
Comparator<Segment<K, V>> segmentComparator = new Comparator<Segment<K, V>>() {
public int compare(Segment<K, V> o1, Segment<K, V> o2) {
if (o1.getLength() == o2.getLength()) {
return 0;
}
return o1.getLength() < o2.getLength() ? -1 : 1;
}
};
public MergeQueue(Configuration conf, FileSystem fs, Path[] inputs,
boolean deleteInputs, CompressionCodec codec,
RawComparator<K> comparator, Progressable reporter)
throws IOException {
this.conf = conf;
this.fs = fs;
this.codec = codec;
this.comparator = comparator;
this.reporter = reporter;
for (Path file : inputs) {
segments.add(new Segment<K, V>(conf, fs, file, codec,
!deleteInputs));
}
// Sort segments on file-lengths
Collections.sort(segments, segmentComparator);
}
public MergeQueue(Configuration conf, FileSystem fs,
List<Segment<K, V>> segments, RawComparator<K> comparator,
Progressable reporter) {
this(conf, fs, segments, comparator, reporter, false);
}
public MergeQueue(Configuration conf, FileSystem fs,
List<Segment<K, V>> segments, RawComparator<K> comparator,
Progressable reporter, boolean sortSegments) {
this.conf = conf;
this.fs = fs;
this.comparator = comparator;
this.segments = segments;
this.reporter = reporter;
if (sortSegments) {
Collections.sort(segments, segmentComparator);
}
}
public MergeQueue(Configuration conf, FileSystem fs,
List<Segment<K, V>> segments, RawComparator<K> comparator,
Progressable reporter, boolean sortSegments,
CompressionCodec codec) {
this(conf, fs, segments, comparator, reporter, sortSegments);
this.codec = codec;
}
public void close() throws IOException {
Segment<K, V> segment;
while ((segment = pop()) != null) {
segment.close();
}
}
public DataInputBuffer getKey() throws IOException {
return key;
}
public DataInputBuffer getValue() throws IOException {
return value;
}
private void adjustPriorityQueue(Segment<K, V> reader)
throws IOException {
long startPos = reader.getPosition();
boolean hasNext = reader.next();
long endPos = reader.getPosition();
totalBytesProcessed += endPos - startPos;
mergeProgress.set(totalBytesProcessed * progPerByte);
if (hasNext) {
adjustTop();
} else {
pop();
reader.close();
}
}
public boolean next() throws IOException {
if (size() == 0)
return false;
if (minSegment != null) {
// minSegment is non-null for all invocations of next except the
// first
// one. For the first invocation, the priority queue is ready
// for use
// but for the subsequent invocations, first adjust the queue
adjustPriorityQueue(minSegment);
if (size() == 0) {
minSegment = null;
return false;
}
}
minSegment = top();
key = minSegment.getKey();
value = minSegment.getValue();
return true;
}
@SuppressWarnings("unchecked")
protected boolean lessThan(Object a, Object b) {
DataInputBuffer key1 = ((Segment<K, V>) a).getKey();
DataInputBuffer key2 = ((Segment<K, V>) b).getKey();
int s1 = key1.getPosition();
int l1 = key1.getLength() - s1;
int s2 = key2.getPosition();
int l2 = key2.getLength() - s2;
return comparator.compare(key1.getData(), s1, l1, key2.getData(),
s2, l2) < 0;
}
public RawKeyValueIterator merge(Class<K> keyClass,
Class<V> valueClass, int factor, Path tmpDir,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
return merge(keyClass, valueClass, factor, 0, tmpDir, readsCounter,
writesCounter);
}
RawKeyValueIterator merge(Class<K> keyClass, Class<V> valueClass,
int factor, int inMem, Path tmpDir,
Counters.Counter readsCounter, Counters.Counter writesCounter)
throws IOException {
LOG.info("Merging " + segments.size() + " sorted segments");
// create the MergeStreams from the sorted map created in the
// constructor
// and dump the final output to a file
int numSegments = segments.size();
int origFactor = factor;
int passNo = 1;
do {
// get the factor for this pass of merge. We assume in-memory
// segments
// are the first entries in the segment list and that the pass
// factor
// doesn't apply to them
factor = getPassFactor(factor, passNo, numSegments - inMem);
if (1 == passNo) {
factor += inMem;
}
List<Segment<K, V>> segmentsToMerge = new ArrayList<Segment<K, V>>();
int segmentsConsidered = 0;
int numSegmentsToConsider = factor;
long startBytes = 0; // starting bytes of segments of this merge
while (true) {
// extract the smallest 'factor' number of segments
// Call cleanup on the empty segments (no key/value data)
List<Segment<K, V>> mStream = getSegmentDescriptors(numSegmentsToConsider);
for (Segment<K, V> segment : mStream) {
// Initialize the segment at the last possible moment;
// this helps in ensuring we don't use buffers until we
// need them
segment.init(readsCounter);
long startPos = segment.getPosition();
boolean hasNext = segment.next();
long endPos = segment.getPosition();
startBytes += endPos - startPos;
if (hasNext) {
segmentsToMerge.add(segment);
segmentsConsidered++;
} else {
segment.close();
numSegments--; // we ignore this segment for the
// merge
}
}
// if we have the desired number of segments
// or looked at all available segments, we break
if (segmentsConsidered == factor || segments.size() == 0) {
break;
}
numSegmentsToConsider = factor - segmentsConsidered;
}
// feed the streams to the priority queue
initialize(segmentsToMerge.size());
clear();
for (Segment<K, V> segment : segmentsToMerge) {
put(segment);
}
// if we have lesser number of segments remaining, then just
// return the
// iterator, else do another single level merge
if (numSegments <= factor) {
// Reset totalBytesProcessed to track the progress of the
// final merge.
// This is considered the progress of the reducePhase, the
// 3rd phase
// of reduce task. Currently totalBytesProcessed is not used
// in sort
// phase of reduce task(i.e. when intermediate merges
// happen).
totalBytesProcessed = startBytes;
// calculate the length of the remaining segments. Required
// for
// calculating the merge progress
long totalBytes = 0;
for (int i = 0; i < segmentsToMerge.size(); i++) {
totalBytes += segmentsToMerge.get(i).getLength();
}
if (totalBytes != 0) // being paranoid
progPerByte = 1.0f / (float) totalBytes;
if (totalBytes != 0)
mergeProgress.set(totalBytesProcessed * progPerByte);
else
mergeProgress.set(1.0f); // Last pass and no segments
// left - we're done
LOG.info("Down to the last merge-pass, with " + numSegments
+ " segments left of total size: " + totalBytes
+ " bytes");
return this;
} else {
LOG.info("Merging " + segmentsToMerge.size()
+ " intermediate segments out of a total of "
+ (segments.size() + segmentsToMerge.size()));
// we want to spread the creation of temp files on multiple
// disks if
// available under the space constraints
long approxOutputSize = 0;
for (Segment<K, V> s : segmentsToMerge) {
approxOutputSize += s.getLength()
+ ChecksumFileSystem.getApproxChkSumLength(s
.getLength());
}
Path tmpFilename = new Path(tmpDir, "intermediate")
.suffix("." + passNo);
Path outputFile = lDirAlloc.getLocalPathForWrite(
tmpFilename.toString(), approxOutputSize, conf);
Writer<K, V> writer = new Writer<K, V>(conf, fs,
outputFile, keyClass, valueClass, codec,
writesCounter);
writeFile(this, writer, reporter, conf);
writer.close();
// we finished one single level merge; now clean up the
// priority
// queue
this.close();
// Add the newly create segment to the list of segments to
// be merged
Segment<K, V> tempSegment = new Segment<K, V>(conf, fs,
outputFile, codec, false);
segments.add(tempSegment);
numSegments = segments.size();
Collections.sort(segments, segmentComparator);
passNo++;
}
// we are worried about only the first pass merge factor. So
// reset the
// factor to what it originally was
factor = origFactor;
} while (true);
}
/**
* Determine the number of segments to merge in a given pass. Assuming
* more than factor segments, the first pass should attempt to bring the
* total number of segments - 1 to be divisible by the factor - 1 (each
* pass takes X segments and produces 1) to minimize the number of
* merges.
*/
private int getPassFactor(int factor, int passNo, int numSegments) {
if (passNo > 1 || numSegments <= factor || factor == 1)
return factor;
int mod = (numSegments - 1) % (factor - 1);
if (mod == 0)
return factor;
return mod + 1;
}
/**
* Return (& remove) the requested number of segment descriptors from
* the sorted map.
*/
private List<Segment<K, V>> getSegmentDescriptors(int numDescriptors) {
if (numDescriptors > segments.size()) {
List<Segment<K, V>> subList = new ArrayList<Segment<K, V>>(
segments);
segments.clear();
return subList;
}
List<Segment<K, V>> subList = new ArrayList<Segment<K, V>>(segments
.subList(0, numDescriptors));
for (int i = 0; i < numDescriptors; ++i) {
segments.remove(0);
}
return subList;
}
public Progress getProgress() {
return mergeProgress;
}
}
}
| [
"raghavendra.pra.yelisetty@hpe.com"
] | raghavendra.pra.yelisetty@hpe.com |
f6590f7cc41cfcf5b4b79e812f2f507ffc3dae2c | ba03cce2589ed64d228053a65442b9fcf2de45ee | /app/src/main/java/com/project/palande/thefitness/ScrollingAbsActivity.java | b6ef6459a619c05947f1059bd0ffc8a035b02472 | [
"Apache-2.0"
] | permissive | r4zorgeek/FitnessApp | 0fa2d8c483cc447341238c6515032a9d3a9eaa16 | 4a4893a06ba780c1f5fec80deb80217acd081223 | refs/heads/master | 2020-08-13T01:59:01.267570 | 2019-10-13T20:08:39 | 2019-10-13T20:08:39 | 214,886,160 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,096 | java | package com.project.palande.thefitness;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class ScrollingAbsActivity extends AppCompatActivity {
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, ScrollingAbsActivity.class);
return intent;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling_abs);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
collapsingToolbarLayout.setTitle("Abs Workout");
}
}
| [
"abhishekmane747@gmail.com"
] | abhishekmane747@gmail.com |
5afee7370ebcc198d30e79369a742e43d2744527 | a77bb153ce5c0bae240b263a93aed3dd84540f90 | /rocketmq-service/src/test/java/com/xiao/service/transaction/TxProducerTest.java | a48e0840bde7d67c129b701a451a126088f9c295 | [] | no_license | yixiaotian99/rocketmq-springboot | b8cb184cbd5946b24934bc5214e977635b75e513 | 2ec093e265f15be3a06463b42a897b600d4b234a | refs/heads/master | 2022-12-28T08:12:12.843702 | 2020-06-22T13:10:33 | 2020-06-22T13:10:33 | 274,066,265 | 0 | 0 | null | 2020-10-13T22:58:37 | 2020-06-22T07:14:33 | Java | UTF-8 | Java | false | false | 600 | java | package com.xiao.service.transaction;
import cn.hutool.core.thread.ThreadUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
/**
* @Author sunjinwei
* @Date 2020-06-22 21:00
* @Description TODO
**/
@SpringBootTest
class TxProducerTest {
@Autowired
private TxProducer txProducer;
@Test
void sendTxMsg() {
for (int i = 0; i < 10; i++) {
txProducer.sendTxMsg("推送事务消息i: " + i);
ThreadUtil.sleep(1000);
}
}
} | [
""
] | |
60028239ea61cecf2602121e5c093b87fdc425c1 | f8974893c411540cce18b517a55f63aae6f22877 | /app/src/main/java/com/sweetoranges/abc/unsunged/Classes/PlayListViewHolder.java | 1bbf8135844013822652a5d060440b3b6d614113 | [] | no_license | rush44447/Unsunged | 065b58ef20694cfaf5e4af532f463e69a186b07e | 87ea66df640d5f7bb88c976a444cf3d202c61987 | refs/heads/master | 2020-05-03T13:20:16.685612 | 2019-07-30T09:48:53 | 2019-07-30T09:48:53 | 178,650,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 442 | java | package com.sweetoranges.abc.unsunged.Classes;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.RecyclerView;
import com.sweetoranges.abc.unsunged.R;
public class PlayListViewHolder extends RecyclerView.ViewHolder {
ImageView image;
public PlayListViewHolder(View itemView) {
super(itemView);
image = (ImageView) itemView.findViewById(R.id.image);
}
} | [
"rushabh.insomniacs@gmail.com"
] | rushabh.insomniacs@gmail.com |
3b64a5291ef36debc6dd3283df1a522db3de6516 | 96285aaa7de79cc53b41c2157e639e91aabd3a24 | /src/String/Reverse_Words_in_a_String_III/Solution.java | a9fd88d242e781f0808d5cc30f1f937a719f587e | [] | no_license | jzhzj/leetcode | da1b14295e3976daf706b5a0f18ca718e9273f83 | ccfcfb839f079109c3457ff1ce1d2a16f0e27f3d | refs/heads/master | 2020-03-19T10:59:29.377688 | 2018-08-07T06:20:58 | 2018-08-07T06:20:58 | 136,417,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,086 | java | package String.Reverse_Words_in_a_String_III;
/**
* Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
* <p>
* Example 1:
* Input: "Let's take LeetCode contest"
* Output: "s'teL ekat edoCteeL tsetnoc"
* Note: In the string, each word is separated by single space and there will not be any extra space in the string.
*/
public class Solution {
public String reverseWords(String s) {
String[] words = s.split(" ");
StringBuilder sb = new StringBuilder();
int iMax = words.length;
for (int i = 0; ; i++) {
sb.append(reverse(words[i]));
if (i == iMax - 1)
return sb.toString();
sb.append(" ");
}
}
private String reverse(String s) {
int len = s.length();
char[] output = new char[len];
char[] input = s.toCharArray();
for (int i = 0; i < len; i++) {
output[i] = input[len - 1 - i];
}
return new String(output);
}
}
| [
"35633477+jzhzj@users.noreply.github.com"
] | 35633477+jzhzj@users.noreply.github.com |
2f1a4a1fbc87c8bd7365c0fa829f17635a9743ab | 9b3bc87b5c5f5fd7536ecc58e507a81d550bc6ac | /src/main/java/com/bigbird/netty/httpdemo1/HttpServer1.java | ae697b0cd9b46d0345adc8cb1e43cc17a7e9a202 | [] | no_license | bigbirditedu/nettylearn | b425d07682aeef66953b0d06da90bd939f2168e2 | 772806b045fb744091ae007bd49fb0c333ff8aee | refs/heads/master | 2023-06-18T01:58:39.306336 | 2021-07-16T09:23:28 | 2021-07-16T09:23:28 | 385,621,312 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,144 | java | package com.bigbird.netty.httpdemo1;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.HttpContentCompressor;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;
import java.net.InetSocketAddress;
public class HttpServer1 {
public void start(int port) throws InterruptedException {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.localAddress(new InetSocketAddress(port))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("decoder", new HttpRequestDecoder()) // HTTP解码
.addLast("aggregator", new HttpObjectAggregator(2 * 1024 * 1024))//HTTP消息聚合
.addLast("encoder", new HttpResponseEncoder())// HTTP编码
.addLast("compressor", new HttpContentCompressor())//HttpContent压缩
.addLast("handler", new HttpServerHandler1());
}
})
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childOption(ChannelOption.TCP_NODELAY, true);
b.bind().sync();//同步阻塞,避免程序退出
System.out.println("netty http server started on port(" + port + ")");
}
public static void main(String[] args) throws InterruptedException {
new HttpServer1().start(8800);
}
}
| [
"zpcandzhj@163.com"
] | zpcandzhj@163.com |
70b9cc2687bc86b3d3a7b129774c350d74ae53af | 146bffaa4a056f6a7f02019917a65ac96eda83a5 | /src/org/dynami/ta/volatility/Atr.java | 4331414117fa870d8368101a8ac64a31da2b8e82 | [] | no_license | Dynami/Dynami-TA | b5fc291a53d8a10125718f840c1b88c948131cb7 | a777a38a5a07d3e2c5335f38276573a1299f1b43 | refs/heads/master | 2023-05-29T07:34:00.742934 | 2023-05-14T14:58:49 | 2023-05-14T14:58:49 | 42,601,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,172 | java | /*
* Copyright 2023 Alessandro Atria - a.atria@gmail.com
*
* 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.dynami.ta.volatility;
import com.tictactec.ta.lib.MInteger;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import org.dynami.ta.TaLibIndicator;
import org.dynami.core.data.Series;
import org.dynami.core.utils.DUtils;
/**
* GENERATED CODE
*/
public class Atr extends TaLibIndicator {
private int timePeriod = 14;
// output series
private Series outReal = new Series();
/**
* Default constructor with standard input parameters</br>
* default value for timePeriod = 14</br>
*/
public Atr(){
computePad( timePeriod, PAD);
}
/**
* Default constructor with custom input parameters:
* @param timePeriod default value 14
*/
public Atr(int timePeriod){
this.timePeriod = timePeriod;
computePad( timePeriod, PAD);
}
private void computePad(int...v){
int max = Integer.MIN_VALUE;
for(int d : v){
if(d > max)
max = d;
}
PAD = max;
}
@Override
public String getName(){
return "Atr";
}
@Override
public String getDescription(){
return "Atr - Volatility Indicators";
}
/**
* Compute indicator based on constructor class parameters
* and input Series.
*/
public Atr compute( final Series high, final Series low, final Series close) {
final MInteger outBegIdx = new MInteger();
final MInteger outNBElement = new MInteger();
// define strict necessary input parameters
final int currentLength = high.size()-1;
final double[] _tmphigh = high.toArray(Math.max(lastLength-PAD, 0), currentLength);
final double[] _tmplow = low.toArray(Math.max(lastLength-PAD, 0), currentLength);
final double[] _tmpclose = close.toArray(Math.max(lastLength-PAD, 0), currentLength);
// define output parameters
final double[] _outReal = new double[_tmphigh.length];
ready = DUtils.max(_tmphigh.length, _tmplow.length, _tmpclose.length) >= DUtils.max(timePeriod);
// calculate output
core.atr(0, _tmphigh.length-1, _tmphigh, _tmplow, _tmpclose, this.timePeriod, outBegIdx, outNBElement, _outReal);
// shift data to end of array and set output fields
DUtils.shift(_outReal, outBegIdx.value);
for(int i = lastLength, j = currentLength-lastLength; i < currentLength; i++, lastLength++, j--){
outReal.append(_outReal[_outReal.length-j]);
}
return this;
}
public Series get(){
return outReal;
}
@Override
public List<Supplier<Series>> series() {
return Arrays.asList(this::get);
}
@Override
public boolean isReady() {
return ready;
}
@Override
public String[] seriesNames() {
return new String[]{"Atr"};
}
}
| [
"a.atria@gmail.com"
] | a.atria@gmail.com |
e7b9e9134b63b1060b8b35729e356e7b18191a07 | 6af2ba478c7a1ca2e68f75e385a0d9b1ff56cdc6 | /Day35_JDBC/src/com/tcwgq/demo3/SQLInjection.java | 182aa5d10811b5be673ba889a9ecbb6c5f288b2b | [] | no_license | tcwgq/learn-java-base | 20f2a8c895cf8719730beada81b069d857a4ac37 | e483ba3cbe6353dc1e16fded257eecf59321331e | refs/heads/master | 2022-01-10T07:57:49.167924 | 2019-06-16T01:36:59 | 2019-06-16T01:36:59 | 104,757,290 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 900 | java | package com.tcwgq.demo3;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class SQLInjection {
public static void main(String[] args) throws SQLException {
retrieve("张三");// 正常查询
retrieve("'or 1 or'");// SQL注入
}
private static void retrieve(String name) throws SQLException {
String sql = "select id, name, birthday, money from user where name = '" + name + "'";
System.out.println(sql);
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = JDBCUtils.getConnection();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt(1) + "\t" + rs.getString("name") + "\t" + rs.getString("birthday") + "\t"
+ rs.getFloat(4));
}
} finally {
JDBCUtils.free(rs, ps, conn);
}
}
}
| [
"tcwgq@outlook.com"
] | tcwgq@outlook.com |
511d312763c3d439eedd1a1c9348a256e0c8299e | 63ab1f6373b80ad833490683584a80d00c29278d | /core/manager/manager/HostInformation.java | e0d1b92d88dbc6e39b69185f5de63c26da6dc531 | [] | no_license | copton/lethe | 811986784571a65e1a02100f3bc0c304535ca0ff | 5d18a99a3932a3ecbe59dade8c67cb93f6fcd2ba | refs/heads/master | 2020-05-16T18:01:51.670153 | 2012-08-22T12:33:20 | 2012-08-22T12:33:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 353 | java | package manager;
public class HostInformation {
String name;
int maxRunningSimulations;
int maxPausedSimulations;
public HostInformation(String name) {
this(name, 1, 5);
}
public HostInformation(String name, int maxRunning, int maxPaused) {
this.name = name;
maxRunningSimulations = maxRunning;
maxPausedSimulations = maxPaused;
}
}
| [
"alex@copton.net"
] | alex@copton.net |
fa7776c7da2853d5f900a32b47027dd2eeecc302 | d9e39fc2362acd134ddc15a5a524091c5d63b7fa | /YuryShahov/Task2/src/by/epam/model/comparator/WordsCountComparator.java | eaaf9a956c58c6f2c4fd66009a4a3ffaeaec5e67 | [] | no_license | yuryshahov/YuryShahov | b219f8878f7e5ef1500d552c329b3156b75a5ef4 | 98ee0b1be5e765788f0c4ab897fa2a184838d70f | refs/heads/master | 2021-01-19T18:55:35.064189 | 2014-09-07T13:32:09 | 2014-09-07T13:32:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java | package by.epam.model.comparator;
import java.util.Comparator;
import by.epam.model.entity.ILexeme;
public class WordsCountComparator implements Comparator<ILexeme> {
@Override
public int compare(ILexeme l1, ILexeme l2) {
int res = l1.wordsCount() - l2.wordsCount();
if (res != 0) {
return res;
}
return 0;
}
}
| [
"shahovyury@mail.ru"
] | shahovyury@mail.ru |
027e58501141563ed59c48f2a8ebbd6f8e2e97b8 | 5c49a79453f444516be82c20d4befa2498c71e2b | /myboard/src/com/kb/www/board/controller/BoardController.java | ac6786723fbd18dd5ed4401883db30958d4b8dbc | [] | no_license | sks2p/project | e0ff8caad8a5ad8674df0d8f8c96c2e1caa13b6c | 1df12ace0817464cc774c23f42ae8b8643a4fae3 | refs/heads/master | 2022-12-31T09:20:02.300484 | 2020-10-23T07:41:37 | 2020-10-23T07:41:37 | 280,083,251 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,501 | java | package com.kb.www.board.controller;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.kb.www.board.home.action.HomeAction;
import com.kb.www.board.member.action.MemberDetailAction;
import com.kb.www.board.member.action.MemberJoinAction;
import com.kb.www.board.member.action.MemberJoinProcAction;
import com.kb.www.board.member.action.MemberLeaveAction;
import com.kb.www.board.member.action.MemberLoginAction;
import com.kb.www.board.member.action.MemberLoginProcAction;
import com.kb.www.board.member.action.MemberLogoutAction;
import com.kb.www.board.member.action.ModifyMemberInfoAction;
import com.kb.www.board.member.action.ModifyMemberProcAction;
import com.kb.www.common.Action;
import com.kb.www.common.ActionForward;
/**
* Servlet implementation class BoardController
*/
@WebServlet("*.do")
public class BoardController extends HttpServlet {
private static final long serialVersionUID = 1L;
public BoardController() {
super();
// TODO Auto-generated constructor stub
}
protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String requestURI = request.getRequestURI();
String contextPath = request.getContextPath();
String command = requestURI.substring(contextPath.length());
ActionForward forward = null;
Action action = null;
if (command.equals("/memberJoin.do")) {
action = new MemberJoinAction();
} else if (command.equals("/memberJoinProc.do")) {
action = new MemberJoinProcAction();
} else if (command.equals("/login.do")) {
action = new MemberLoginAction();
} else if (command.equals("/loginProc.do")) {
action = new MemberLoginProcAction();
} else if (command.equals("/logout.do")) {
action = new MemberLogoutAction();
} else if (command.equals("/leave.do")) {
action = new MemberLeaveAction();
}else if (command.equals("/MemberDetail.do")) {
action = new MemberDetailAction();
}else if (command.equals("/modifyMemberInfo.do")) {
action = new ModifyMemberInfoAction();
}else if (command.equals("/modifyMemberProc.do")) {
action = new ModifyMemberProcAction();
}
try {
forward = action.execute(request, response);
} catch (Exception e) {
e.printStackTrace();
forward = new ActionForward();
forward.setPath("/views/error.jsp");
forward.setRedirect(true);
}
if (forward != null) {
if (forward.isRedirect()) {
// 리다이렉트
response.sendRedirect(forward.getPath());
} else {
// 디스패치
RequestDispatcher dispatcher
= request.getRequestDispatcher(forward.getPath());
dispatcher.forward(request, response);
}
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
}
| [
"65517031+sks2p@users.noreply.github.com"
] | 65517031+sks2p@users.noreply.github.com |
37d340b2f0f795f54394f2516fb613f7d3e4e52a | 3fc8406d53de4fbad56792945409ff9ba77641d4 | /mybatis/src/main/java/com/example/mybatis/model/User.java | a80d08978816f8919e6fac5bfea45ef65461b637 | [] | no_license | wozeng520/jenkensTest | 487f18dafa12a2f150507f0bafc3a80c259826ce | 6d2273bcf35db0dd7c017f95188d3c7474febf17 | refs/heads/master | 2023-05-11T08:01:11.107738 | 2019-11-30T05:42:12 | 2019-11-30T05:42:12 | 224,867,252 | 0 | 0 | null | 2023-05-09T18:35:20 | 2019-11-29T14:14:48 | Java | UTF-8 | Java | false | false | 233 | java | package com.example.mybatis.model;
import lombok.Data;
/**
* ${DESCRIPTION}
*
* @author 272420251
* @create 2019-11-26-13:35
*/
@Data
public class User {
private int id;
private String userName;
private int age;
}
| [
"272420251@qq.com"
] | 272420251@qq.com |
0848addd9fdab9ba262c27caa35e5dbf1f3a2f73 | eb33e24c11d89bd4338a96dc9d5ee31817197153 | /src/main/java/com/owl/kafka/client/util/Preconditions.java | b43b06502ea615d91ee9fb65dc0c88861292f2b8 | [] | no_license | Technoboy-/kafka-client | 26157b4394c195678eb1656b77524d98ffe54aa2 | ff29697b1325643d416b0bf5fb4935793c7440e0 | refs/heads/master | 2020-04-11T02:19:53.329692 | 2019-05-15T11:38:33 | 2019-05-15T11:38:33 | 161,442,119 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | java | package com.owl.kafka.client.util;
/**
* @Author: Tboy
*/
public final class Preconditions {
private Preconditions() {}
public static void checkArgument(boolean expression, Object errorMessage) {
if (!expression) {
throw new IllegalArgumentException(String.valueOf(errorMessage));
}
}
}
| [
"guo.jiwei@immomo.com"
] | guo.jiwei@immomo.com |
51e0d06b869748b23f41bdc2d473e5ba3a16252f | 98d42c884bc68c3db9f6f552cf3dd567f4d496a2 | /src/main/java/passionx3/jkdk/util/Message.java | 5d4be656d696956ee999424a740bc651a525b570 | [] | no_license | KangHyojin1401/Jakudaku | 437c9c228b97f1e3030d19b6e5d2c8f2a1c8b517 | 5b87bfdc856a5b06db8a39820af869a3f16e1b8c | refs/heads/develop | 2023-06-02T01:11:29.976015 | 2021-06-22T06:35:03 | 2021-06-22T06:35:03 | 367,687,330 | 1 | 6 | null | 2021-06-22T06:35:04 | 2021-05-15T17:05:04 | Java | UTF-8 | Java | false | false | 449 | java | package passionx3.jkdk.util;
public class Message {
String message = "";
String href = "";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
public Message() {
}
public Message(String message, String href) {
this.message = message;
this.href = href;
}
} | [
"kor3334@naver.com"
] | kor3334@naver.com |
bf853979d40b6923ca8b55f9e33b53f8e8babf2a | 4e7de802fa70013a9391633d97416ad1b5db2cb5 | /TestEx15x1x2.java | 1ec1462c5913baba489ef0f83a19642e7ccde766 | [] | no_license | bbk-pij-2012-59/General | d15409fc5703cf868420bc28b1ebd2361b3a2807 | cf7ea501265fdf7bb5bbdae498835add13051573 | refs/heads/master | 2021-01-25T06:40:18.140904 | 2013-01-31T17:41:55 | 2013-01-31T17:41:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 999 | java | //Ex15x1
//28th January 2013 - Created
import java.util.List;
import java.util.ArrayList;
public class TestEx15x1x2
{
public static void main(String[] args)
{
TestEx15x1x2 test = new TestEx15x1x2();
test.launch(2);
}
public void launch(int userInput)
{
List<Integer> intList = new ArrayList<Integer>();
intList.add(1);
intList.add(2);
intList.add(3);
intList.add(4);
intList.add(5);
intList.add(6);
try
{
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
intList.remove(0);
System.out.println(intList.get(userInput));
}
catch (IndexOutOfBoundsException ex)
{
ex.printStackTrace();
}
}
}
| [
"rw269[at]yahoo.com"
] | rw269[at]yahoo.com |
a49416142f295066ef29465a229099ca774b9f8b | 47aa8db4e533ee531c5fb585a0df3ace9a26fc09 | /OcavaCore/src/main/java/com/ocadotechnology/config/Config.java | 7697c82e78a98b2c835e7c599f14defd811ea098 | [
"Apache-2.0"
] | permissive | tivrfoa/Ocava | f28731379bff59ddc951b9ba894169ef162d0b3c | a8bb71658a72ec037ff06e3869dc9a2c6354b548 | refs/heads/master | 2022-10-14T23:46:22.280151 | 2020-06-12T06:06:12 | 2020-06-12T07:26:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 71,377 | java | /*
* Copyright © 2017-2020 Ocado (Ocava)
*
* 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.ocadotechnology.config;
import java.io.Serializable;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Stream;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Maps;
import com.ocadotechnology.id.Id;
import com.ocadotechnology.id.StringId;
import com.ocadotechnology.physics.units.LengthUnit;
/**
* Ocava Configuration is a properties file parser where keys are backed by an Enum.
* <h2>Basic Usage</h2>
* The Enum for Config can contain nested Enumeration, i.e.
* <pre>
* public Enum MyConfig {
* ROOT_KEY;
* public Enum MyChildConfig {
* CHILD_KEY,
* SECOND_KEY;
* ...
* }
* }
* </pre>
* <p>
* Each Key in the properties file ends with a Enum value (i.e. CHILD_KEY) and is prefixed by each class dot separated
* (i.e. MyConfig.MyChildConfig.CHILD_KEY).
* <p>
* So a simple example properties file could look like:
* <pre>
* MyConfig.ROOT_KEY=A root key
* MyConfig.MyChildConfig.CHILD_KEY=1, SECONDS
* MyConfig.MyChildConfig.SECOND_KEY=false
* </pre>
* <h3>Data Types</h3>
* The configuration object also has support for several data types (some can be seen in the example) some of these
* data types are (For the full list inspect the different get methods):
* <ul>
* <li><strong>String</strong></li>
* <li><strong>Numeric</strong> - Integer, Long, Double</li>
* <li><strong>Boolean</strong></li>
* <li><strong>Time</strong> - Either as a Long, or as a {@link Duration}</li>
* <li><strong>Speed</strong> - See {@link #getSpeed(Enum)}</li>
* <li><strong>Acceleration</strong> - See {@link #getAcceleration(Enum)}</li>
* <li><strong>Lists</strong></li>
* <li><strong>Enum</strong> - See {@link #getEnum(Enum, Class)}</li>
* <li><strong>Sub Config</strong> - See {@link #getSubConfig(Class)}</li>
* <li><strong>Map</strong> - See {@link #getMap(Enum, Function, Function)}</li>
* <li><strong>Integer</strong></li>
* </ul>
*
* <h3>GetOrDefault and not Optional</h3>
* Because of the way the configuration library works by layering multiple configuration on top of each other, the
* idea of using optional may seem nice but can lead to complications.
* <p>
* If for instance the presence of a config value is used to change the flow of logic (i.e. a config flag) it might be
* that you wish to override it's presence by command line or specific additional config file, however once a config
* key is present it cannot be removed.
* <p>
* A good use for Optionals is to getOptional().orElse(), in this case it is identical to having a getOrDefault,
* without the ability to use it for controlling logic flow based on presence of a key.
*
* <h2>Prefixes</h2>
* Additionally to the configuration Object and the different data types it can handle there is also the concept of
* prefixes.
* <p>
* Prefixes allow for multiple layers for a single config key, or for a single config key to be defined multiple times.
* Taking the configuration enum example from above we could write a properties file like:
* <pre>
* MyConfig.ROOT_KEY=root_key
* site1@MyConfig.ROOT_KEY=site1_key
* site1@node1@MyConfig.ROOT_KEY=node1_key
* site2@MyConfig.ROOT_KEY=site2_key
* </pre>
* <p>
* With the above when we want to get the root key for say a specific site we can use use
* {@link #getPrefixedConfigItems(String)} and then call {@link #getString(Enum)}
*
* <pre>
* var siteConfig = config.getPrefixedConfigItems("site10");
* var key = siteConfig.getString(MyConfig.ROOT_KEY)
* </pre>
* <p>
* Note that in the properties file site10 is not one of the listed prefixes, in this case it falls back to the default
* value of "root_key". Prefixes can be nested, so it would be possible to do:
*
* <pre>
* var nodeConfig = config.getPrefixedConfigItems("site1").getPrefixedConfigItems("node1");
* var key = nodeConfig.getString(MyConfig.ROOT_KEY)
* </pre>
* <p>
* In the above case key would equal node1_key, as the prefix site1 exists and the prefix node1 exists under site1
*
* @param <E> Configuration Enumeration containing all allowed property keys
*/
public class Config<E extends Enum<E>> implements Serializable, Comparable<Config<?>> {
private static final long serialVersionUID = 1L;
public final Class<E> cls;
private final ImmutableMap<E, ConfigValue> values;
private final ImmutableMap<?, Config<?>> subConfig;
private final String qualifier;
private final TimeUnit timeUnit;
private final LengthUnit lengthUnit;
private Config(
Class<E> cls,
ImmutableMap<E, ConfigValue> values,
ImmutableMap<?, Config<?>> subConfig,
String qualifier,
TimeUnit timeUnit,
LengthUnit lengthUnit) {
this.cls = cls;
this.values = values;
this.subConfig = subConfig;
this.qualifier = qualifier;
this.timeUnit = timeUnit;
this.lengthUnit = lengthUnit;
}
Config(
Class<E> cls,
ImmutableMap<E, ConfigValue> values,
ImmutableMap<?, Config<?>> subConfig,
String qualifier) {
this(cls, values, subConfig, qualifier, null, null);
}
/**
* Returns a new Config that has entered one layer into the prefix config values.
* This means that when multi-prefix values are being used,
* the sub-prefixes can now be accessed below the given prefix.
* For each config item, it will set the value to be that of the prefix value if present,
* otherwise it will keep its original value.
*
* @param prefix The prefix to use for the current value / the prefix tree to use for multi-prefix configs
* @return a new Config object with config values and prefixes from the given prefix
*/
public Config<E> getPrefixedConfigItems(String prefix) {
return map(configValue -> configValue.getPrefix(prefix));
}
/**
* Returns a new Config where for each config item, it will set the value to be that of the prefix value if present,
* otherwise it will keep its original value.
* The Config returned will have the same prefix data as the original, so multi-prefixed values are not accessible
* and prefixed values with a different root are still present.
*
* @param prefix The prefix to use for the current value / the prefix tree to use for multi-prefix configs
* @return a new Config object with config values and prefixes from the given prefix
*/
public Config<E> getPrefixBiasedConfigItems(String prefix) {
return map(configValue -> configValue.getWithPrefixBias(prefix));
}
public ImmutableSet<String> getPrefixes() {
Stream<String> subConfigStream = subConfig.values().stream()
.flatMap(subConfig -> subConfig.getPrefixes().stream());
Stream<String> valuesStream = values.values().stream()
.flatMap(value -> value.getPrefixes().stream());
return Stream.concat(subConfigStream, valuesStream)
.collect(ImmutableSet.toImmutableSet());
}
public ImmutableMap<E, ConfigValue> getValues() {
return this.values;
}
public static <T extends Enum<T>> Config<T> empty(Class<T> c) {
return new Config<>(c, ImmutableMap.of(), ImmutableMap.of(), c.getSimpleName(), null, null);
}
public TimeUnit getTimeUnit() {
return Preconditions.checkNotNull(timeUnit, "timeUnit not set. See ConfigManager.Builder.setTimeUnit.");
}
public LengthUnit getLengthUnit() {
return Preconditions.checkNotNull(lengthUnit, "lengthUnit not set. See ConfigManager.Builder.setLengthUnit.");
}
/**
* @deprecated to discourage key presence on its own to be used for flow control
* (see class javadoc for reasoning). Use {@link #isValueDefined(Enum)}
* or {@link #areKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public boolean containsKey(Enum<?> key) {
return getOrNone(key).isPresent();
}
/**
* Check if the value of key is not the empty string.
* @throws ConfigKeyNotFoundException if the key has not been explicitly defined
*/
public boolean isValueDefined(Enum<?> key) {
Optional<String> value = getOrNone(key);
return value.map(s -> !s.trim().isEmpty()).orElseThrow(() -> new ConfigKeyNotFoundException(key));
}
/**
* Check that the key has been explicitly defined and not to the empty string.
* The two checks are done simultaneously because key presence on its own should not
* be used for flow control (see class javadoc for reasoning).
*/
public boolean areKeyAndValueDefined(Enum<?> key) {
Optional<String> value = getOrNone(key);
return value.map(s -> !s.trim().isEmpty()).orElse(false);
}
/**
* Check that the this config enum type contains the enum key independently from whether the key's value is set.
* For example, ExampleConfig.VALUE does have the same enum type of Config<ExampleConfig>,
* CounterExample.VALUE does not.
*/
public boolean enumTypeIncludes(Enum<?> key) {
Class<?> clazz = key.getClass();
while (clazz != null) {
if (clazz.equals(cls)) {
return true;
}
clazz = clazz.getEnclosingClass();
}
return false;
}
@SuppressWarnings("unchecked")
public <T extends Enum<T>> Config<T> getSubConfig(Class<T> key) {
return (Config<T>) subConfig.get(key);
}
/**
* Create a {@link StrictValueParser} object to parse the value associated with the given key.
*
* @param key the key to look up in this config object.
* @return a {@link StrictValueParser} object built from the value associated with the specified key.
* @throws ConfigKeyNotFoundException if the key is not defined in this Config object.
*/
public StrictValueParser getValue(Enum<?> key) {
return new StrictValueParser(getString(key), timeUnit);
}
/**
* Create an {@link OptionalValueParser} object to parse the value associated with the given key. This will return
* {@link Optional#empty()} if the value is defined as an empty string.
*
* @param key the key to look up in this config object.
* @return an {@link OptionalValueParser} object built from the value associated with the specified key.
* @throws ConfigKeyNotFoundException if the key is not defined in this Config object.
*/
public OptionalValueParser getIfValueDefined(Enum<?> key) {
return new OptionalValueParser(getString(key), timeUnit);
}
/**
* Create an {@link OptionalValueParser} object to parse the value associated with the given key. This will return
* {@link Optional#empty()} if the key is not defined in this config object or if the associated value is an empty
* string.
*
* @param key the key to look up in this config object.
* @return an {@link OptionalValueParser} object built from the value associated with the specified key.
*/
public OptionalValueParser getIfKeyAndValueDefined(Enum<?> key) {
String value = getOrNone(key).map(String::trim).orElse("");
return new OptionalValueParser(value, timeUnit);
}
/**
* Interprets a config value as an integer. If it is the String "max" or "min" (case insensitive) returns
* {@link Integer#MAX_VALUE} or {@link Integer#MIN_VALUE} respectively.
*
* @throws NumberFormatException if the value is not equal to either the string "max" or "min", ignoring case and is
* not a valid base-10 integer.
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object.
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public int getInt(Enum<?> key) {
return ConfigParsers.parseInt(getString(key));
}
/**
* Interprets a config value as an integer, if it is present. If the value is not present, returns the default
* value.
*
* If the value is the String "max" or "min" (case insensitive), returns {@link Integer#MAX_VALUE} or
* {@link Integer#MIN_VALUE} respectively.
*
* @throws NumberFormatException if the value is not equal to either the string "max" or "min", ignoring case and is
* not a valid base-10 integer.
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public int getIntOrDefault(Enum<?> key, int defaultValue) {
return getOrDefault(key, ConfigParsers::parseInt, defaultValue);
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public OptionalInt getIntIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return OptionalInt.empty();
}
return OptionalInt.of(getInt(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public Optional<Double> getDoubleIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return Optional.empty();
}
return Optional.of(getDouble(key));
}
/**
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public double getDouble(Enum<?> key) {
return ConfigParsers.parseDouble(getString(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public double getDoubleOrDefault(Enum<?> key, double defaultValue) {
return getOrDefault(key, ConfigParsers::parseDouble, defaultValue);
}
/**
* Interprets a config value as a boolean.
*
* @throws IllegalStateException if the value is not equal to either the string "true" or "false", ignoring case.
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public boolean getBoolean(Enum<?> key) {
return ConfigParsers.parseBoolean(getString(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public boolean getBooleanOrDefault(Enum<?> key, boolean defaultValue) {
return getOrDefault(key, ConfigParsers::parseBoolean, defaultValue);
}
/**
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public long getLong(Enum<?> key) {
return ConfigParsers.parseLong(getString(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public long getLongOrDefault(Enum<?> key, long defaultValue) {
return getOrDefault(key, ConfigParsers::parseLong, defaultValue);
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public OptionalLong getLongIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return OptionalLong.empty();
}
return OptionalLong.of(getLong(key));
}
/**
* Interprets a config value as a length using the declared application length unit.
* <p>
* Length config values can be given either
* - as a double, in which case Config will assume that the value is being specified in m
* - in the form {@code <value>,<length unit>} or {@code <value>:<length unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NullPointerException if the application length unit has not been set
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the length unit in the config value does not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
*/
public double getLength(Enum<?> key) {
return ConfigParsers.parseLength(getString(key), getLengthUnit());
}
public double getLengthOrDefault(Enum<?> key, double defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseLength(v, getLengthUnit()), defaultValue);
}
/**
* Interprets a config value as a time using the declared application time unit.
* <p>
* Time config values can be given either
* - as a double, in which case Config will assume that the value is being specified in s
* - in the form {@code <value>,<time unit>} or {@code <value>:<time unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NullPointerException if the application time unit has not been set
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the time unit in the config value does not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public double getFractionalTime(Enum<?> key) {
return ConfigParsers.parseFractionalTime(getString(key), getTimeUnit());
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public double getFractionalTimeOrDefault(Enum<?> key, double defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseFractionalTime(v, getTimeUnit()), defaultValue);
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*
* @return the result of {@link Config#getFractionalTime} if the config key has a defined value, else {@link Optional#empty()}
* Optional is used in place of OptionalDouble as OptionalDouble is missing some features.
*/
@Deprecated
public Optional<Double> getFractionalTimeIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return Optional.empty();
}
return Optional.of(getFractionalTime(key));
}
/**
* Interprets a config value as a time using the declared application time unit.
* <p>
* Time config values can be given either
* - as a double, in which case Config will assume that the value is being specified in s
* - in the form {@code <value>,<time unit>} or {@code <value>:<time unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NullPointerException if the application time unit has not been set
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the time unit in the config value does not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public long getTime(Enum<?> key) {
return Math.round(getFractionalTime(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public long getTimeOrDefault(Enum<?> key, long defaultValue) {
return getOrDefault(key, v -> Math.round(ConfigParsers.parseFractionalTime(v, getTimeUnit())), defaultValue);
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*
* @return the result of {@link Config#getTime} if the config key has a defined value, else {@link Optional#empty()}
* Optional is used in place of OptionalLong as OptionalLong is missing some features.
*/
@Deprecated
public Optional<Long> getTimeIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return Optional.empty();
}
return Optional.of(getTime(key));
}
/**
* Interprets a config value as a {@link Duration} rounded to the nearest nanosecond
* <p>
* Duration config values can be given either:
* - As a double on its own, in which case it will be assumed that the value is being specified in seconds
* - In the form {@code <value>,<time unit>} or {@code <value>:<time unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the time unit in the config value does not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public Duration getDuration(Enum<?> key) {
return ConfigParsers.parseDuration(getString(key));
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public Duration getDurationOrDefault(Enum<?> key, Duration defaultValue) {
return getOrDefault(key, ConfigParsers::parseDuration, defaultValue);
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*
* @return the result of {@link Config#getDuration} if the config key has a defined value, else {@link Optional#empty()}
*/
@Deprecated
public Optional<Duration> getDurationIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return Optional.empty();
}
return Optional.of(getDuration(key));
}
/**
* Interprets a config value as a speed using the declared application time and length units.
* <p>
* Speed config values can be given either
* - as a double, in which case Config will assume that the value is being specified in m/s
* - in the form {@code <value>,<length unit>,<time unit>} or {@code <value>:<length unit>:<time unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NullPointerException if the application time or length units have not been set
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the time or length units in the config value do not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
*/
public double getSpeed(Enum<?> key) {
return ConfigParsers.parseSpeed(getString(key), getLengthUnit(), getTimeUnit());
}
public double getSpeedOrDefault(Enum<?> key, double defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseSpeed(v, getLengthUnit(), getTimeUnit()), defaultValue);
}
/**
* Interprets a config value as an acceleration using the declared application time and length units.
* <p>
* Acceleration config values can be given either
* - as a double, in which case Config will assume that the value is being specified in m/s^2
* - in the form {@code <value>,<length unit>,<time unit>} or {@code <value>:<length unit>:<time unit>}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NullPointerException if the application time or length units have not been set
* @throws IllegalStateException if the config value does not satisfy one of the formats given above
* @throws IllegalArgumentException if the time or length units in the config value do not match an enum value
* @throws NumberFormatException if the value given cannot be parsed as a double
*/
public double getAcceleration(Enum<?> key) {
return ConfigParsers.parseAcceleration(getString(key), getLengthUnit(), getTimeUnit());
}
public double getAccelerationOrDefault(Enum<?> key, double defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseAcceleration(v, getLengthUnit(), getTimeUnit()), defaultValue);
}
/**
* Returns a list of T
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public <T> ImmutableList<T> getListOf(Enum<?> key, Function<String, T> valueFunction) {
return ConfigParsers.getListOf(valueFunction).apply(getString(key));
}
/**
* Returns a list of T or empty if the key is not present
*/
public <T> ImmutableList<T> getListOfOrEmpty(Enum<?> key, Function<String, T> valueFunction) {
return getListOfOrDefault(key, valueFunction, ImmutableList.of());
}
/**
* Returns a list of T or the default value if the key is not present
*/
public <T> ImmutableList<T> getListOfOrDefault(Enum<?> key, Function<String, T> valueFunction, ImmutableList<T> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOf(valueFunction), defaultValue);
}
/**
* Returns a set of T
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public <T> ImmutableSet<T> getSetOf(Enum<?> key, Function<String, T> valueFunction) {
return ConfigParsers.getSetOf(valueFunction).apply(getString(key));
}
/**
* Returns a set of T or empty if the key is not present
*/
public <T> ImmutableSet<T> getSetOfOrEmpty(Enum<?> key, Function<String, T> valueFunction) {
return getSetOfOrDefault(key, valueFunction, ImmutableSet.of());
}
/**
* Returns a set of T or the default value if the key is not present
*/
public <T> ImmutableSet<T> getSetOfOrDefault(Enum<?> key, Function<String, T> valueFunction, ImmutableSet<T> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOf(valueFunction), defaultValue);
}
/**
* Returns a list of Integers. Defers value parsing to {@link ConfigParsers#parseInt(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableList<Integer> getListOfIntegers(Enum<?> key) {
return ConfigParsers.getListOfIntegers().apply(getString(key));
}
/**
* Returns a list of Integers or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseInt(String)}
*/
public ImmutableList<Integer> getListOfIntegersOrEmpty(Enum<?> key) {
return getListOfIntegersOrDefault(key, ImmutableList.of());
}
/**
* Returns a list of Integers or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseInt(String)}
*/
public ImmutableList<Integer> getListOfIntegersOrDefault(Enum<?> key, ImmutableList<Integer> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfIntegers(), defaultValue);
}
/**
* Returns a Set of Integers. Defers value parsing to {@link ConfigParsers#parseInt(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableSet<Integer> getSetOfIntegers(Enum<?> key) {
return ConfigParsers.getSetOfIntegers().apply(getString(key));
}
/**
* Returns a Set of Integers or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseInt(String)}
*/
public ImmutableSet<Integer> getSetOfIntegersOrEmpty(Enum<?> key) {
return getSetOfIntegersOrDefault(key, ImmutableSet.of());
}
/**
* Returns a Set of Integers or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseInt(String)}
*/
public ImmutableSet<Integer> getSetOfIntegersOrDefault(Enum<?> key, ImmutableSet<Integer> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfIntegers(), defaultValue);
}
/**
* Returns a list of Longs. Defers value parsing to {@link ConfigParsers#parseLong(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableList<Long> getListOfLongs(Enum<?> key) {
return ConfigParsers.getListOfLongs().apply(getString(key));
}
/**
* Returns a list of Longs or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseLong(String)}
*/
public ImmutableList<Long> getListOfLongsOrEmpty(Enum<?> key) {
return getListOfLongsOrDefault(key, ImmutableList.of());
}
/**
* Returns a list of Longs or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseLong(String)}
*/
public ImmutableList<Long> getListOfLongsOrDefault(Enum<?> key, ImmutableList<Long> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfLongs(), defaultValue);
}
/**
* Returns a Set of Longs. Defers value parsing to {@link ConfigParsers#parseLong(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableSet<Long> getSetOfLongs(Enum<?> key) {
return ConfigParsers.getSetOfLongs().apply(getString(key));
}
/**
* Returns a Set of Longs or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseLong(String)}
*/
public ImmutableSet<Long> getSetOfLongsOrEmpty(Enum<?> key) {
return getSetOfLongsOrDefault(key, ImmutableSet.of());
}
/**
* Returns a Set of Longs or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseLong(String)}
*/
public ImmutableSet<Long> getSetOfLongsOrDefault(Enum<?> key, ImmutableSet<Long> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfLongs(), defaultValue);
}
/**
* Returns a list of Doubles. Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableList<Double> getListOfDoubles(Enum<?> key) {
return ConfigParsers.getListOfDoubles().apply(getString(key));
}
/**
* Returns a list of Doubles or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*/
public ImmutableList<Double> getListOfDoublesOrEmpty(Enum<?> key) {
return getListOfDoublesOrDefault(key, ImmutableList.of());
}
/**
* Returns a list of Doubles or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*/
public ImmutableList<Double> getListOfDoublesOrDefault(Enum<?> key, ImmutableList<Double> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfDoubles(), defaultValue);
}
/**
* Returns a Set of Doubles. Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public ImmutableSet<Double> getSetOfDoubles(Enum<?> key) {
return ConfigParsers.getSetOfDoubles().apply(getString(key));
}
/**
* Returns a Set of Doubles or empty if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*/
public ImmutableSet<Double> getSetOfDoublesOrEmpty(Enum<?> key) {
return getSetOfDoublesOrDefault(key, ImmutableSet.of());
}
/**
* Returns a Set of Doubles or the default value if the key is not present.
* Defers value parsing to {@link ConfigParsers#parseDouble(String)}
*/
public ImmutableSet<Double> getSetOfDoublesOrDefault(Enum<?> key, ImmutableSet<Double> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfDoubles(), defaultValue);
}
/**
* @deprecated - see class javadoc for reasoning - use {@link #getListOfIdsOrDefault(Enum, ImmutableList)} or
* {@link #getListOfIdsOrEmpty(Enum)} instead.
*
* @return the same as {@link #getListOfIds} or an empty list if the config key isn't found
* @throws NumberFormatException if the values given cannot be parsed as longs
*/
@Deprecated
public <T> ImmutableList<Id<T>> getListOfIdsIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return ImmutableList.of();
}
return getListOfIds(key);
}
/**
* @return the same as {@link ConfigParsers#getListOfIds()} with the value linked to the given config key
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NumberFormatException if the values given cannot be parsed as longs
*/
public <T> ImmutableList<Id<T>> getListOfIds(Enum<?> key) {
return ConfigParsers.<T>getListOfIds().apply(getString(key));
}
public <T> ImmutableList<Id<T>> getListOfIdsOrEmpty(Enum<?> key) {
return getListOfIdsOrDefault(key, ImmutableList.of());
}
public <T> ImmutableList<Id<T>> getListOfIdsOrDefault(Enum<?> key, ImmutableList<Id<T>> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfIds(), defaultValue);
}
/**
* @deprecated - see class javadoc for reasoning - use {@link #getSetOfIdsOrEmpty(Enum)} or
* {@link #getSetOfIdsOrDefault(Enum, ImmutableSet)} instead.
*
* @return the same as {@link #getSetOfIds} or an empty set if the config key isn't found
* @throws NumberFormatException if the values given cannot be parsed as longs
*/
@Deprecated
public <T> ImmutableSet<Id<T>> getSetOfIdsIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return ImmutableSet.of();
}
return getSetOfIds(key);
}
/**
* @return the set of ids in the list returned by {@link ConfigParsers#getSetOfIds()} for the given config key
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @throws NumberFormatException if the values given cannot be parsed as longs
*/
public <T> ImmutableSet<Id<T>> getSetOfIds(Enum<?> key) {
return ImmutableSet.copyOf(getListOfIds(key));
}
public <T> ImmutableSet<Id<T>> getSetOfIdsOrEmpty(Enum<?> key) {
return getSetOfIdsOrDefault(key, ImmutableSet.of());
}
public <T> ImmutableSet<Id<T>> getSetOfIdsOrDefault(Enum<?> key, ImmutableSet<Id<T>> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfIds(), defaultValue);
}
public <T extends Enum<T>> ImmutableSet<T> getSetOfEnums(Enum<?> key, Class<T> enumClass) {
return ConfigParsers.getSetOfEnums(enumClass).apply(getString(key));
}
public <T extends Enum<T>> ImmutableSet<T> getSetOfEnumsOrEmpty(Enum<?> key, Class<T> enumClass) {
return getSetOfEnumsOrDefault(key, enumClass, ImmutableSet.of());
}
public <T extends Enum<T>> ImmutableSet<T> getSetOfEnumsOrDefault(Enum<?> key, Class<T> enumClass, ImmutableSet<T> defaultValue) {
return getOrDefault(key, v -> ConfigParsers.getSetOfEnums(enumClass).apply(v), defaultValue);
}
public <T extends Enum<T>> ImmutableList<T> getListOfEnums(Enum<?> key, Class<T> enumClass) {
return ConfigParsers.getListOfEnums(enumClass).apply(getString(key));
}
public <T extends Enum<T>> ImmutableList<T> getListOfEnumsOrEmpty(Enum<?> key, Class<T> enumClass) {
return getOrDefault(key, ConfigParsers.getListOfEnums(enumClass), ImmutableList.of());
}
public <T extends Enum<T>> ImmutableList<T> getListOfEnumsOrDefault(Enum<?> key, Class<T> enumClass, ImmutableList<T> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfEnums(enumClass), defaultValue);
}
public ImmutableList<String> getListOfStrings(Enum<?> key) {
return ConfigParsers.getListOf(Function.identity()).apply(getString(key));
}
public ImmutableList<String> getListOfStringsOrEmpty(Enum<?> key) {
return getListOfStringsOrDefault(key, ImmutableList.of());
}
public ImmutableList<String> getListOfStringsOrDefault(Enum<?> key, ImmutableList<String> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfStrings(), defaultValue);
}
public ImmutableSet<String> getSetOfStrings(Enum<?> key) {
return ConfigParsers.getSetOf(Function.identity()).apply(getString(key));
}
public ImmutableSet<String> getSetOfStringsOrEmpty(Enum<?> key) {
return getSetOfStringsOrDefault(key, ImmutableSet.of());
}
public ImmutableSet<String> getSetOfStringsOrDefault(Enum<?> key, ImmutableSet<String> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfStrings(), defaultValue);
}
/**
* @deprecated - see class javadoc for reasoning - use {@link #getListOfStringIdsOrEmpty(Enum)} or
* {@link #getListOfStringIdsOrDefault(Enum, ImmutableList)} instead.
*
* @return the same as {@link #getListOfStringIds} or an empty list if the config key isn't found
*/
@Deprecated
public <T> ImmutableList<StringId<T>> getListOfStringIdsIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return ImmutableList.of();
}
return getListOfStringIds(key);
}
/**
* @return the same as {@link ConfigParsers#getListOfStringIds()} with the value linked to the given config key
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public <T> ImmutableList<StringId<T>> getListOfStringIds(Enum<?> key) {
return ConfigParsers.<T>getListOfStringIds().apply(getString(key));
}
public <T> ImmutableList<StringId<T>> getListOfStringIdsOrEmpty(Enum<?> key) {
return getListOfStringIdsOrDefault(key, ImmutableList.of());
}
public <T> ImmutableList<StringId<T>> getListOfStringIdsOrDefault(Enum<?> key, ImmutableList<StringId<T>> defaultValue) {
return getOrDefault(key, ConfigParsers.getListOfStringIds(), defaultValue);
}
/**
* @deprecated - see class javadoc for reasoning - use {@link #getSetOfStringIdsOrEmpty(Enum)} or
* {@link #getSetOfStringIdsOrDefault(Enum, ImmutableSet)} instead.
*
* @return the same as {@link #getSetOfStringIds} or an empty set if the config key isn't found
*/
@Deprecated
public <T> ImmutableSet<StringId<T>> getSetOfStringIdsIfPresent(Enum<?> key) {
if (!containsKey(key)) {
return ImmutableSet.of();
}
return getSetOfStringIds(key);
}
/**
* @return the set of ids in the list returned by {@link ConfigParsers#getSetOfStringIds()} for the given config key
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
*/
public <T> ImmutableSet<StringId<T>> getSetOfStringIds(Enum<?> key) {
return ImmutableSet.copyOf(getListOfStringIds(key));
}
public <T> ImmutableSet<StringId<T>> getSetOfStringIdsOrEmpty(Enum<?> key) {
return getSetOfStringIdsOrDefault(key, ImmutableSet.of());
}
public <T> ImmutableSet<StringId<T>> getSetOfStringIdsOrDefault(Enum<?> key, ImmutableSet<StringId<T>> defaultValue) {
return getOrDefault(key, ConfigParsers.getSetOfStringIds(), defaultValue);
}
/**
* Get a value from the Config set.
*
* @param key Configuration key
* @return the raw {@link String} value of that key
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public String getString(Enum<?> key) {
Optional<String> value = getOrNone(key);
return value.map(String::trim).orElseThrow(() -> new ConfigKeyNotFoundException(key));
}
/**
* Get a value from the Config set or return a specified default if the key does not have a defined value.
*
* @param key Configuration key
* @param defaultValue The value to return if the key is not specified
* @return the raw {@link String} value of that key or {@code defaultValue} if no value is found
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public String getStringOrDefault(Enum<?> key, String defaultValue) {
return getOrDefault(key, Function.identity(), defaultValue);
}
/**
* Get a single value and transform it using the valueFunction.
*
* @param key Configuration key
* @param valueFunction Function for extracting the value from the config
* @param <V> Result type
* @return the value of the key after valueFunction is applied
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public <V> V get(Enum<?> key, Function<String, V> valueFunction) {
return valueFunction.apply(getString(key));
}
/**
* Wrapper for handling a get or default.
*
* @param key Configuration key
* @param valueExtractor Function for extracting the value from a String
* @param defaultValue Default value to return if the key is not present in the config
* @param <V> Result type
* @return if the Key exists in the config then the result of valueExtractor otherwise defaultValue
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public <V> V getOrDefault(Enum<?> key, Function<String, V> valueExtractor, V defaultValue) {
if (containsKey(key)) {
return get(key, valueExtractor);
} else {
return defaultValue;
}
}
/**
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public Optional<String> getStringIfPresent(Enum<?> key) {
return getOrNone(key).map(String::trim);
}
/**
* Returns a Map for config specified as a collection of key-value pairs with keys and values as Strings.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
*
* @param key Config key which contains the key-value pairs as a String.
* @return a {@code Map<String, String>} of key-value pairs parsed from the config value
* @throws IllegalArgumentException if duplicate keys are specified
* @throws ConfigKeyNotFoundException if the config key does not have a value in this Config object
*/
public ImmutableMap<String, String> getStringMap(Enum<?> key) {
return getMap(key, Function.identity(), Function.identity());
}
/**
* Returns a Map for config specified as a collection of key-value pairs with keys and values as Strings.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
*
* If no value is specified for the config key, returns an empty map.
*
* @param key Config key which contains the key-value pairs as a String.
* @return a {@code Map<String, String>} of key-value pairs parsed from the config value, or an empty map if the
* config key has no specified value
* @throws IllegalArgumentException if duplicate keys are specified
*/
public ImmutableMap<String, String> getStringMapOrEmpty(Enum<?> key) {
return getStringMapOrDefault(key, ImmutableMap.of());
}
/**
* Returns a Map for config specified as a collection of key-value pairs with keys and values as Strings.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
*
* If no value is specified for the config key, returns the specified default value.
*
* @param key Config key which contains the key-value pairs as a String.
* @param defaultValue the value to return if the config key has no specified value
* @return a {@code Map<String, String>} of key-value pairs parsed from the config value, or {@code defaultValue} if
* the config key has no specified value
* @throws IllegalArgumentException if duplicate keys are specified
*/
public ImmutableMap<String, String> getStringMapOrDefault(Enum<?> key, ImmutableMap<String, String> defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseMap(v, Function.identity(), Function.identity()), defaultValue);
}
/**
* Returns a typed-Map for config specified as a collection of key-value pairs.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param <K> The type of key in resulting {@code Map}
* @param <V> The type of value in resulting {@code Map}
* @return a Map of key-value pairs parsed from the config value
* @throws IllegalArgumentException if duplicate map keys are specified
* @throws NullPointerException if the keyParser or valueParser return null for any provided string
* @throws ConfigKeyNotFoundException if the config key does not have a value in this Config object
*/
public <K, V> ImmutableMap<K, V> getMap(Enum<?> configKey, Function<String, K> keyParser, Function<String, V> valueParser) {
String val = getString(configKey);
return ConfigParsers.parseMap(val, keyParser, valueParser);
}
/**
* Returns a typed-Map for config specified as a collection of key-value pairs.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
*
* If no value is specified for the config key, returns an empty map.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param <K> The type of key in the resulting {@code Map}
* @param <V> The type of value in the resulting {@code Map}
* @return a Map of key-value pairs parsed from the config value or an empty map if the config key has no value
* @throws IllegalArgumentException if duplicate map keys are specified
* @throws NullPointerException if the keyParser or valueParser return null for any provided string
*/
public <K, V> ImmutableMap<K, V> getMapOrEmpty(Enum<?> configKey, Function<String, K> keyParser, Function<String, V> valueParser) {
return getMapOrDefault(configKey, keyParser, valueParser, ImmutableMap.of());
}
/**
* Returns a typed-Map for config specified as a collection of key-value pairs.
* <p>
* Given a config value that is a (semicolon-separated) list of (equals-separated) key-value pairs:
* <pre>"key1=value1;key2=value2"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
*
* If no value is specified for the config key, returns the specified default value.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param defaultValue The value to return if the config key has no specified value.
* @param <K> The type of key in the resulting {@code Map}.
* @param <V> The type of value in the resulting {@code Map}.
* @return a Map of key-value pairs parsed from the config value or {@code defaultValue} if the config key has no
* value.
* @throws IllegalArgumentException if duplicate map keys are specified.
* @throws NullPointerException if the keyParser or valueParser return null for any provided string.
*/
public <K, V> ImmutableMap<K, V> getMapOrDefault(Enum<?> configKey, Function<String, K> keyParser, Function<String, V> valueParser, ImmutableMap<K, V> defaultValue) {
return getOrDefault(configKey, v -> ConfigParsers.parseMap(v, keyParser, valueParser), defaultValue);
}
/**
* Returns a Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @return a Multimap of key-value pairs parsed from the config value
* @throws ConfigKeyNotFoundException if the config key does not have a value in this Config object
*/
public ImmutableSetMultimap<String, String> getStringSetMultimap(Enum<?> configKey) {
return getSetMultimap(configKey, Function.identity(), Function.identity());
}
/**
* Returns a Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* If no value is specified for the config key, returns an empty map.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @return a Multimap of key-value pairs parsed from the config value or an empty map if there is no value
*/
public ImmutableSetMultimap<String, String> getStringSetMultimapOrEmpty(Enum<?> configKey) {
return getStringSetMultimapOrDefault(configKey, ImmutableSetMultimap.of());
}
/**
* Returns a Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* If no value is specified for the config key, returns the specified default value.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param defaultValue The value to return if the config key has no specified value.
* @return a Multimap of key-value pairs parsed from the config value or {@code defaultValue} if there is no value
*/
public ImmutableSetMultimap<String, String> getStringSetMultimapOrDefault(
Enum<?> configKey,
ImmutableSetMultimap<String, String> defaultValue) {
return getSetMultimapOrDefault(configKey, Function.identity(), Function.identity(), defaultValue);
}
/**
* Returns a typed-Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* If no value is specified for the config key, returns an empty multimap.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param <K> The type of key in the resulting {@code Map}
* @param <V> The type of value in the resulting {@code Map}
* @return a Multimap of key-value pairs parsed from the config value or an empty map if there is no specified value
* @throws NullPointerException if the keyParser or valueParser return null for any provided string
*/
public <K, V> ImmutableSetMultimap<K, V> getSetMultimapOrEmpty(
Enum<?> configKey,
Function<String, K> keyParser,
Function<String, V> valueParser) {
return getSetMultimapOrDefault(configKey, keyParser, valueParser, ImmutableSetMultimap.of());
}
/**
* Returns a typed-Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* If no value is specified for the config key, returns the specified default value.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param defaultValue The value to return if the config key has no specified value.
* @param <K> The type of key in the resulting {@code Map}
* @param <V> The type of value in the resulting {@code Map}
* @return a Multimap of key-value pairs parsed from the config value or the default value
* @throws NullPointerException if the keyParser or valueParser return null for any provided string
*/
public <K, V> ImmutableSetMultimap<K, V> getSetMultimapOrDefault(
Enum<?> configKey,
Function<String, K> keyParser,
Function<String, V> valueParser,
ImmutableSetMultimap<K, V> defaultValue) {
return getOrDefault(
configKey,
v -> ConfigParsers.parseSetMultimap(v, keyParser, valueParser),
defaultValue);
}
/**
* Returns a typed-Multimap for config specified as a collection of key-value pairs, with repeating keys.
* <p>Given a config value that is a (semicolon-separated) list of (equals-separated) key-value paris:
* <pre>"key1=value1;key1=value2;key2=value3"</pre>
* Keys and values will be trimmed, before being supplied to the functions that translate them to the
* correct types.
* Any pair which does not contain the character '=' will be ignored.
* Each additional value to a key has to come as a new key=value, and cannot be provided as a list of elements (i.e.
* key=value1,value2) as this would not make it possible to have values as a List type.
*
* @param configKey Config key which contains the key-value pairs as a String.
* @param keyParser Function to convert a String to a key in the resulting Map.
* @param valueParser Function to convert a String to a value in the resulting Map.
* @param <K> The type of key in the resulting {@code Map}
* @param <V> The type of value in the resulting {@code Map}
* @return a Multimap of key-value pairs parsed from the config value
* @throws NullPointerException if the keyParser or valueParser return null for any provided string
* @throws ConfigKeyNotFoundException if the config key does not have a value in this Config object
*/
public <K, V> ImmutableSetMultimap<K, V> getSetMultimap(
Enum<?> configKey,
Function<String, K> keyParser,
Function<String, V> valueParser) {
String val = getString(configKey);
return ConfigParsers.parseSetMultimap(val, keyParser, valueParser);
}
/**
* Returns the enum value to which the specified key is mapped.
*
* @param key Key for which to lookup the enum value.
* @param enumClass Enum class defining the set of permitted values.
* @param <T> Type of {@code enumClass}
* @return the value from the specified enum class which corresponds to the config value associated with the given
* key.
* @throws IllegalArgumentException if the config value does not match any of the values in the specified enum.
* @throws ConfigKeyNotFoundException if the key does not have a value in this Config object.
* @deprecated use {@link Config#getValue(Enum)} instead.
*/
@Deprecated
public <T extends Enum<T>> T getEnum(Enum<?> key, Class<T> enumClass) {
return Enum.valueOf(enumClass, getString(key));
}
/**
* Like {@link #getEnum(Enum, Class)} but if the key is not present return the default value instead of an exception
*
* @param defaultValue Value to return if the key is not present
* @return the value from the specified enum class which corresponds to the config value associated with the given
* key, or default if the key is not present
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public <T extends Enum<T>> T getEnumOrDefault(Enum<?> key, Class<T> enumClass, T defaultValue) {
return getOrDefault(key, v -> ConfigParsers.parseEnum(v, enumClass), defaultValue);
}
/**
* Returns the enum value to which the specified key is mapped, if present.
*
* @param key Key for which to lookup the enum value.
* @param enumClass Enum class defining the set of permitted values.
* @param <T> Type of {@code enumClass}
* @return the value from the specified enum class which corresponds to the config value associated with the given
* key, or {@link Optional#empty()} if no entry for that key exists.
* @throws IllegalArgumentException when the config value does not match any of the values in the specified enum.
* @deprecated use {@link Config#getIfValueDefined(Enum)} or {@link Config#getIfKeyAndValueDefined(Enum)} instead.
*/
@Deprecated
public <T extends Enum<T>> Optional<T> getEnumIfPresent(Enum<?> key, Class<T> enumClass) {
if (!containsKey(key)) {
return Optional.empty();
}
return Optional.of(getEnum(key, enumClass));
}
public String getQualifiedKeyName(E key) {
return qualifier + "." + key.toString();
}
/**
* @deprecated - exposes secret keys. Use {@link #getKeyValueStringMapWithoutSecrets()} instead
*/
@Deprecated
public ImmutableMap<String, String> getKeyValueStringMap() {
ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
consumeConfigValues((k, v, isSecret) -> map.put(k, v), false);
return map.build();
}
public ImmutableMap<String, String> getKeyValueStringMapWithoutSecrets() {
ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
consumeConfigValues((k, v, isSecret) -> {
if (!isSecret) {
map.put(k, v);
}
}, false);
return map.build();
}
public ImmutableMap<String, String> getKeyValueStringMapWithPrefixesWithoutSecrets() {
ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
consumeConfigValues((k, v, isSecret) -> {
if (!isSecret) {
map.put(k, v);
}
}, true);
return map.build();
}
/**
* @deprecated - exposes secret keys. Use {@link #getUnqualifiedKeyValueStringMapWithoutSecrets(Class)} instead
*/
@Deprecated
public <T extends Enum<T>> ImmutableMap<String, String> getUnqualifiedKeyValueStringMap(Class<T> key) {
Config<T> subConfig = getSubConfig(key);
ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
subConfig.consumeConfigValues((k, v, isSecret) -> map.put(k.substring(subConfig.qualifier.length() + 1), v), false);
return map.build();
}
public <T extends Enum<T>> ImmutableMap<String, String> getUnqualifiedKeyValueStringMapWithoutSecrets(Class<T> key) {
Config<T> subConfig = getSubConfig(key);
ImmutableMap.Builder<String, String> map = ImmutableMap.builder();
subConfig.consumeConfigValues((k, v, isSecret) -> {
if (!isSecret) {
map.put(k.substring(subConfig.qualifier.length() + 1), v);
}
}, false);
return map.build();
}
private void consumeConfigValues(ToStringHelper toStringHelper, boolean includePrefixes) {
values.entrySet().stream()
.sorted(Comparator.comparing(e -> e.getKey().toString()))
.forEach(e -> consumeConfigValue(toStringHelper, includePrefixes, e.getKey(), e.getValue()));
subConfig.entrySet().stream()
.sorted(Comparator.comparing(e -> e.getKey().toString()))
.forEach(x -> x.getValue().consumeConfigValues(toStringHelper, includePrefixes));
}
private void consumeConfigValue(ToStringHelper toStringHelper, boolean includePrefixes, E key, ConfigValue value) {
// currentValue is null when a prefixed Config value has no un-prefixed equivalent
if (value.currentValue != null) {
toStringHelper.accept(
getQualifiedKeyName(key),
value.currentValue,
isSecretConfig(key));
}
if (includePrefixes) {
value.getValuesByPrefixedKeys(getQualifiedKeyName(key)).forEach((prefixedKey, prefixedValue) ->
toStringHelper.accept(
prefixedKey,
prefixedValue,
isSecretConfig(key)));
}
}
private boolean isSecretConfig(E key) {
try {
return cls.getField(key.toString()).isAnnotationPresent(SecretConfig.class);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
return false;
}
@Override
public int compareTo(Config<?> o) {
return qualifier.compareTo(o.qualifier);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Config<?> config = (Config<?>) o;
return Objects.equals(cls, config.cls)
&& Objects.equals(values, config.values)
&& Objects.equals(subConfig, config.subConfig)
&& Objects.equals(qualifier, config.qualifier)
&& timeUnit == config.timeUnit
&& lengthUnit == config.lengthUnit;
}
@Override
public int hashCode() {
return Objects.hash(cls, values, subConfig, qualifier, timeUnit, lengthUnit);
}
/**
* @return a superset of all config contained in this and other, with the values from other being given priority.
*/
@SuppressWarnings("unchecked")
//this method needs to be unchecked because subConfig is unchecked.
Config<E> merge(Config other) {
Preconditions.checkState(qualifier.equals(other.qualifier), "Mismatched qualifiers:", qualifier, other.qualifier);
Preconditions.checkState(cls.equals(other.cls), "Mismatched classes:", cls, other.cls);
HashMap tempValues = new HashMap<>(values);
other.values.forEach((e, v) -> tempValues.merge(e, v, (a, b) -> b));
HashMap tempSubConfig = new HashMap<>(subConfig);
other.subConfig.forEach((clz, conf) -> tempSubConfig.merge(clz, conf, (oldConf, newConf) -> ((Config) oldConf).merge((Config) newConf)));
return new Config<>(
cls,
ImmutableMap.copyOf(tempValues),
ImmutableMap.copyOf(tempSubConfig),
qualifier,
other.timeUnit != null ? other.timeUnit : timeUnit,
other.lengthUnit != null ? other.lengthUnit : lengthUnit);
}
Config<E> setUnits(TimeUnit timeUnit, LengthUnit lengthUnit) {
ImmutableMap<?, Config<?>> newSubConfig = subConfig.entrySet()
.stream()
.collect(ImmutableMap.toImmutableMap(Entry::getKey, e -> e.getValue()
.setUnits(timeUnit, lengthUnit)));
return new Config<>(
cls,
values,
newSubConfig,
qualifier,
timeUnit,
lengthUnit);
}
@Override
public String toString() {
Joiner joiner = Joiner.on("\n");
return joiner.join(qualifier + '{', getStringValues(joiner), '}');
}
private String getStringValues(Joiner joiner) {
List<String> entries = new ArrayList<>();
consumeConfigValues((k, v, isSecret) -> {
if (!isSecret) {
entries.add(k + '=' + v);
}
}, true);
return joiner.join(entries);
}
@FunctionalInterface
private interface ToStringHelper {
void accept(String key, String value, Boolean isSecret);
}
private Optional<String> getOrNone(Enum<?> key) {
if (key.getClass().equals(cls) && values.containsKey(cls.cast(key))) {
return Optional.ofNullable(values.get(cls.cast(key)).currentValue);
}
Class<?> declaringClass = key.getDeclaringClass();
while (declaringClass != null) {
if (subConfig.containsKey(declaringClass)) {
return subConfig.get(declaringClass).getOrNone(key);
}
declaringClass = declaringClass.getDeclaringClass();
}
return Optional.empty();
}
/**
* Perform a function on all config values in the config tree
*
* @param mutator function to apply
* @return a new config with the function applied
*/
private Config<E> map(Function<ConfigValue, ConfigValue> mutator) {
ImmutableMap<E, ConfigValue> values = this.values.entrySet().stream()
.collect(Maps.toImmutableEnumMap(Entry::getKey, e -> mutator.apply(e.getValue())));
ImmutableMap<?, Config<?>> subConfig = this.subConfig.entrySet().stream()
.collect(ImmutableMap.toImmutableMap(Entry::getKey, e -> e.getValue().map(mutator)));
return new Config<>(this.cls, values, subConfig, this.qualifier, this.timeUnit, this.lengthUnit);
}
}
| [
"colin.janke@ocado.com"
] | colin.janke@ocado.com |
a7ebedd6734f460f35a492a97b41ca10ec19e257 | bfc1babf4418cdcfd80f3d4158b3eba245b04a72 | /newnius/src/Bullet/Bullet.java | c23c536ef6f5311a399f0350e086fbf15f1a6881 | [] | no_license | newnius/shooting-game | ad60c3991015366be91d14c7008ce02546d25c84 | 4703a246896ae8e13c5c5d6ff89ef344b2723f2a | refs/heads/master | 2021-01-10T19:05:13.428249 | 2015-08-05T08:58:17 | 2015-08-05T08:58:17 | 40,234,388 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,104 | 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 Bullet;
import config.GlobalVars;
import java.awt.Point;
import mycs.Player;
/**
*
* @author Newnius
*/
public class Bullet implements Cloneable{
private int speed;
private int directionX;
private int directionY;
private int locationX;
private int locationY;
private Player owner;
public Bullet(Player player, int tmpDirectionX, int tmpDirectionY,int tmpLocationX,int tmpLocationY) {
speed = GlobalVars.BULLET_SPEED;
directionX = tmpDirectionX;
directionY = tmpDirectionY;
locationX = tmpLocationX;
locationY=tmpLocationY;
owner=player;
}
public Bullet clone(Bullet bullet){
return new Bullet(bullet.getOwner(),bullet.getDirectionX(),bullet.getDirectionY(),bullet.getLocationX(),bullet.getLocationY());
}
public int getSpeed() {
return speed;
}
public int getDirectionX() {
return directionX;
}
public int getDirectionY() {
return directionY;
}
public int getLocationX() {
return locationX;
}
public int getLocationY() {
return locationY;
}
public Player getOwner() {
return owner;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public void setDirectionX(int directionX) {
this.directionX = directionX;
}
public void setDirectionY(int directionY) {
this.directionY = directionY;
}
public void setLocationX(int locationX) {
this.locationX = locationX;
}
public void setLocationY(int locationY) {
this.locationY = locationY;
}
public void setOwner(Player player) {
this.owner=player;
}
public Point fly(){
return null;
}
}
| [
"newnius.cn@gmail.com"
] | newnius.cn@gmail.com |
36eaae03e7c0c3a98eee301549110d2fd552352c | 475fad5e659575eac1bcf07a3f67a0cbe7da827e | /src/main/java/com/bytatech/ayoos/appointment/config/SerdeConfig.java | c2b7f396b9e89261e1af82fc6eda481a22359a23 | [] | no_license | tayduivn/APPOINTMENT-MICROSERVICE | ff4edcce21df9fd5b54d705db79b887235468313 | 5ef7711245cccfb8649fcfde426fbb07cab6b375 | refs/heads/master | 2022-11-17T02:09:06.559617 | 2019-11-06T04:03:15 | 2019-11-06T04:03:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,139 | java | package com.bytatech.ayoos.appointment.config;
import java.util.Collections;
import java.util.Map;
import org.apache.avro.specific.SpecificRecordBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig;
import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerializer;
public class SerdeConfig<T extends SpecificRecordBase> extends SpecificAvroSerializer<T> {
private static Logger log = LoggerFactory.getLogger("Logger SerdeConfig");
@Value("${spring.cloud.stream.schemaRegistryClient.endpoint:}")
private String schemaRegistryEndpoint;
@Override
public void configure(Map<String, ?> serializerConfig, boolean isSerializerForRecordKeys) {
log.info("Schema registry client uri is "+schemaRegistryEndpoint);
log.info("Enter into SerdeConfig " + serializerConfig);
final Map<String, String> serdeConfig = Collections
.singletonMap(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, "http://35.225.189.219:8081");
super.configure(serdeConfig, isSerializerForRecordKeys);
}
}
| [
"abilash.s@lxisoft.com"
] | abilash.s@lxisoft.com |
d982d1f8829a2651f7c5a1153d9365a421efd3e9 | 786db004ac35f292d4aed533a4b8725da8ee723d | /src/texturing/Texture.java | d4736fc5adc32c45b17c3b59b51902af00708bf0 | [] | no_license | bbuck108/3Drendering | 12f3cde452b587dc0d28511c331d963a955556ac | a1d7a4f7b952e9d61ab3a4a63cedf2560fa6abdc | refs/heads/master | 2021-01-17T11:34:33.809197 | 2016-11-23T22:28:24 | 2016-11-23T22:28:24 | 51,848,819 | 0 | 1 | null | 2016-05-04T14:36:51 | 2016-02-16T16:02:24 | Java | UTF-8 | Java | false | false | 2,074 | java | package texturing;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/** Texture for a physical object
* @author Connor Lehmacher*/
public class Texture {
private ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
public Texture(String key) {
if(key.equals("shape.Sphere") || key.equals("Sphere")) {
images.add(null);
}
else{ if(key.equals("shape.RectangularPrism") || key.equals("RectangularPrism")) {
//order: front:x,y,z , back:x,y,z
for(int i = 0; i < 6; i++) {
images.add(null);
}
}
else {
images.add(null);
System.err.println("Unsupported Key");
System.err.println("You typed: " + key);
}}
}
/** Sets a particular image to be blank*/
public void defineDefaultImage(int index) {
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
images.set(index, img);
}
/** Fills the texture with all black images*/
public void fillWithBlanks() {
int end = images.size();
for(int i = 0; i < end; i++) {
defineDefaultImage(i);
}
}
public void defineImage(int index, BufferedImage i) {
images.set(index, i);
}
/** Fills the Texture with the same one image */
public void fillWithImages(BufferedImage bi) {
int end = images.size();
for(int i = 0; i < end; i++) {
defineImage(i, bi);
}
}
/** Makes the texture be solid one color */
public void defineFullColor(Color c) {
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(c);
g.fillRect(0, 0, 999, 999);
fillWithImages(img);
}
/** Sets the color of one side */
public void defineSidesColor(int i, Color c) {
BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(c);
g.fillRect(0, 0, 999, 999);
defineImage(i, img);
}
public BufferedImage getImage(int index) {
return images.get(index);
}
}
| [
"clehmac@hotmail.com"
] | clehmac@hotmail.com |
380b2efdfc672d6a68a2532f9242aff0a4e44267 | ca0e9689023cc9998c7f24b9e0532261fd976e0e | /src/com/tencent/mm/pluginsdk/ui/preference/p.java | 6ae9984a9b076d5414f6254f21ed1fac5524f6b3 | [] | no_license | honeyflyfish/com.tencent.mm | c7e992f51070f6ac5e9c05e9a2babd7b712cf713 | ce6e605ff98164359a7073ab9a62a3f3101b8c34 | refs/heads/master | 2020-03-28T15:42:52.284117 | 2016-07-19T16:33:30 | 2016-07-19T16:33:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 698 | java | package com.tencent.mm.pluginsdk.ui.preference;
import android.view.View;
import android.view.View.OnClickListener;
import com.tencent.mm.pluginsdk.ui.o;
final class p
implements View.OnClickListener
{
p(NormalUserHeaderPreference paramNormalUserHeaderPreference) {}
public final void onClick(View paramView)
{
paramView = bgYI).field_username;
o localo = new o(NormalUserHeaderPreference.a(gYI), paramView);
if (com.tencent.mm.storage.k.yx(paramView)) {
com.tencent.mm.storage.k.yz(paramView);
}
localo.aAc();
}
}
/* Location:
* Qualified Name: com.tencent.mm.pluginsdk.ui.preference.p
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"reverseengineeringer@hackeradmin.com"
] | reverseengineeringer@hackeradmin.com |
8466befad7815a27151cce60e11fd4c4a151eb96 | e73d7e53f5d870235bc8f6c8359982782a87a939 | /taotaocommon/src/main/java/com/taotao/common/pojo/EasyUITreeNode.java | 43b955783a2eb28bd3481d5282b75a462d7b261f | [] | no_license | npjtwy/taotao | 3a8d5f7a6a3858253c2a86b7249b7646209248f8 | c199dc31d820ed683f31c7680ff00f10eedc00c9 | refs/heads/master | 2020-03-23T06:47:05.962722 | 2018-07-21T15:22:51 | 2018-07-21T15:22:51 | 141,229,503 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 661 | java | package com.taotao.common.pojo;
import java.io.Serializable;
/**
* EasyUITreeNode
*
* 类目 树形结构
*
* @author Yang
* @date 2018/7/21
*/
public class EasyUITreeNode implements Serializable {
private Long id;
private String text;
private String state;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
| [
"npjtwy@qq.com"
] | npjtwy@qq.com |
8bbccbda71415244275332c55f2a9ba4f56c34e6 | edc64570b4303aee42487bd0660ac646a9baefe8 | /src/main/java/com/tombit/dhcp/utils/common/impl/HostImpl.java | bf3355b3e0156d6ba95dbeb7084fbd65c41d9556 | [
"MIT"
] | permissive | tierman/dhcpUtils | 1218160ecff356c2b754ef4726b9d26db1246997 | e4be7cf1042f78d19e5a6e2ef97a887e016a0f14 | refs/heads/master | 2021-01-10T02:38:08.516706 | 2016-02-13T15:40:18 | 2016-02-13T15:40:18 | 51,609,943 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,157 | java | package com.tombit.dhcp.utils.common.impl;
import com.tombit.dhcp.utils.common.*;
import java.util.LinkedList;
/**
* Created by Tomasz Jonczyk on 06.02.2016.
*/
public class HostImpl implements Host {
private String hostName;
private LinkedList<Parameter> parameters;
private LinkedList<String> comments;
private boolean completed;
@Override
public String getHostname() {
return hostName;
}
@Override
public void setHostname(String hostname) {
this.hostName = hostname;
}
@Override
public boolean isCompleted() {
return completed;
}
@Override
public void setCompleted(boolean completed) {
this.completed = completed;
}
@Override
public LinkedList<Parameter> getParameters() {
if (parameters == null) {
parameters = new LinkedList<>();
}
return parameters;
}
@Override
public void addParameter(Parameter parameter) {
getParameters().addLast(parameter);
}
@Override
public LinkedList<String> getComments() {
if (comments == null) {
comments = new LinkedList<>();
}
return comments;
}
@Override
public void addComment(String comment) {
getComments().addLast(comment);
}
@Override
public LinkedList<Chunk> getChunks() {
return null;
}
@Override
public void addChunk(Chunk chunk) {
throw new IllegalArgumentException("Cannot add chunk to Host.");
}
@Override
public ChunkType getType() {
return TYPE;
}
@Override
public Chunk getOpenChunk() {
return null;
}
@Override
public String getOpenStatement() {
return TYPE.getPrefix() + " " + hostName + " {";
}
@Override
public String getCloseStatement() {
return CLOSE_STATEMENT;
}
@Override
public String toString() {
return "HostImpl{" +
"hostName='" + hostName + '\'' +
", parameters=" + parameters +
", comments=" + comments +
", completed=" + completed +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HostImpl)) return false;
HostImpl host = (HostImpl) o;
if (isCompleted() != host.isCompleted()) return false;
if (hostName != null ? !hostName.equals(host.hostName) : host.hostName != null) return false;
if (getParameters() != null ? !getParameters().equals(host.getParameters()) : host.getParameters() != null)
return false;
return getComments() != null ? getComments().equals(host.getComments()) : host.getComments() == null;
}
@Override
public int hashCode() {
int result = hostName != null ? hostName.hashCode() : 0;
result = 31 * result + (getParameters() != null ? getParameters().hashCode() : 0);
result = 31 * result + (getComments() != null ? getComments().hashCode() : 0);
result = 31 * result + (isCompleted() ? 1 : 0);
return result;
}
}
| [
"tomek.jonczyk@gmail.com"
] | tomek.jonczyk@gmail.com |
6e4baae6e40a7d215503d727269718ee314c86cd | bc75510c0a7f6e8ed4fff6c489c7948061bdbbd4 | /Lab1/clientsdsocket/src/main/java/ClientSocket.java | 2c0a5fbb7d11a2fb653f1951c8c0464d03cf391f | [] | no_license | gustavobarbosab/LabSistemasDistribuidos | 100e0e9895df258360363fac70ec6d0a9fc4bcc5 | b766ebf2b545d125ae1077a0b5560cdde21d1bdc | refs/heads/master | 2020-03-10T03:16:20.028197 | 2018-04-11T22:13:56 | 2018-04-11T22:13:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,960 | java | import javax.swing.*;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class ClientSocket {
public static void main(String[] args) throws UnknownHostException {
//get the localhost IP address, if server is running on some other IP, you need to use that
InetAddress host = InetAddress.getLocalHost();
Socket socket = null;
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
Scanner scanner = new Scanner(System.in);
try{
//establish socket connection to server
socket = new Socket(host.getHostName(), 9876);
//write to socket using ObjectOutputStream
oos = new ObjectOutputStream(socket.getOutputStream());
System.out.println("Java client");
System.out.print("Digite uma mensagem:");
String msgSend = scanner.next();
System.out.println("A mensagem enviada eh: "+msgSend);
oos.writeObject(msgSend);
System.out.println("Aguardando a resposta");
//read the server response message
ois = new ObjectInputStream(socket.getInputStream());
String msgRec = (String) ois.readObject();
System.out.println("Resposta recebida:" + msgRec);
//close resources
System.out.println("Desconectado");
ois.close();
oos.close();
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
| [
"gustaovbarbosabarreto@hotmail.com"
] | gustaovbarbosabarreto@hotmail.com |
0988c41a93f9db88023f42f39b0fa600e3ec115c | 981e4c747dd8a7e3303f95fee3488c1945f35198 | /MusicAPIv2/src/main/java/BackendMashupExercise/MusicAPI/WikipediaService.java | ba0c83887dfaf97d82e14d35a06f33cec9bd6757 | [] | no_license | honeybadger5/artist-api | 45a22696f2817bc4e8f55a424ccf9d5457bf1a07 | 894befd522cc465d97e53ae45c5b3cb3e509c6d8 | refs/heads/master | 2020-12-24T11:45:28.825969 | 2017-02-10T08:57:05 | 2017-02-10T08:57:05 | 73,017,907 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,500 | java | package BackendMashupExercise.MusicAPI;
import java.net.URI;
import java.net.URISyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.client.AsyncRestTemplate;
import org.springframework.web.client.RestClientException;
import org.springframework.web.context.request.async.DeferredResult;
import BackendMashupExercise.MusicAPI.dto.wikipedia.WikiData;
@Service
public class WikipediaService {
private static final Logger logger = LoggerFactory.getLogger(WikipediaService.class);
private String wikiUrlBase = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro=true&redirects=true&titles=";
AsyncRestTemplate restTemplate;
public WikipediaService(AsyncRestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public DeferredResult<String> getArtistDescription(String wikipediaResourceUrl) {
String wikiName = "";
try
{
URI uri = new URI(wikipediaResourceUrl);
String path = uri.getPath();
wikiName = path.substring(path.lastIndexOf('/') + 1);
}
catch(URISyntaxException e)
{
System.err.println("URISyntaxException: " + e.getMessage());
}
DeferredResult<String> deferredResult = new DeferredResult<String>();
ListenableFuture<ResponseEntity<WikiData>> future = null;
logger.debug("Requesting artist description, URL="+wikiUrlBase+wikiName);
try {
future = restTemplate.getForEntity(wikiUrlBase+wikiName, WikiData.class);
}
catch (RestClientException e) {
System.err.println(e.getMessage());
}
future.addCallback(new ListenableFutureCallback<ResponseEntity<WikiData>>() {
@Override
public void onSuccess(ResponseEntity<WikiData> result) {
String description = result.getBody().getQuery().getPages().get(result.getBody().getQuery().getPages().keySet().stream().findFirst().get()).getExtract();
logger.debug("Requesting artist description SUCCESS: "+description);
deferredResult.setResult(description);
}
@Override
public void onFailure(Throwable ex) {
logger.debug("Requesting artist description FAILURE: "+ex.getMessage());
deferredResult.setErrorResult(new String());
}
});
return deferredResult;
}
}
| [
"malin.lind40@gmail.com"
] | malin.lind40@gmail.com |
503f13991eb4977eaad79b0ced474436af542a16 | 7df62a93d307a01b1a42bb858d6b06d65b92b33b | /src/com/afunms/biosreport/model/DbOracleReportModel.java | 3d1949af594395428d15ca2494229e3595f90c0d | [] | no_license | wu6660563/afunms_fd | 79ebef9e8bca4399be338d1504faf9630c42a6e1 | 3fae79abad4f3eb107f1558199eab04e5e38569a | refs/heads/master | 2021-01-10T01:54:38.934469 | 2016-01-05T09:16:38 | 2016-01-05T09:16:38 | 48,276,889 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 2,066 | java | package com.afunms.biosreport.model;
/**
* Oracle 数据库模板
*
* @author Administrator
*
*/
public class DbOracleReportModel extends BiosReportBaseModel{
public DbOracleReportModel(){
}
public DbOracleReportModel(String ip, String name, String connectivty){
super(ip, name, connectivty);
}
// 缓冲区命中率
private String bufferCache;
// 数据字典命中率
private String dictionaryCache;
// PGA
private String pga;
// sga
private String sga;
// 打开的游标数
private String openCur;
// 内存中的排序
private String memorySort;
public String toString(){
return getClass().getName()
+ "[IP=" + super.getIpAddress()
+ ", aliasName=" + super.getAliasName()
+ ", nodeid=" + super.getNodeid()
+ ", collecttime=" + super.getCollectTime()
+ ", dept=" + super.getDeptName()
+ ", ping=" + super.getAvergeConnectivity()
+ ", bufferCache=" + getBufferCache()
+ ", dictionaryCache=" + getDictionaryCache()
+ ", pga=" + getPga()
+ ", sga=" + getSga()
+ ", openCur=" + getOpenCur()
+ ", memorySort=" + getMemorySort()
+ ", alarmCommon=" + getAlarmCommon()
+ ", alarmSerious=" + getAlarmSerious()
+ ", alarmUrgency=" + getAlarmUrgency();
}
public String getBufferCache() {
return bufferCache;
}
public void setBufferCache(String bufferCache) {
this.bufferCache = get2(bufferCache);
}
public String getDictionaryCache() {
return dictionaryCache;
}
public void setDictionaryCache(String dictionaryCache) {
this.dictionaryCache = get2(dictionaryCache);
}
public String getPga() {
return pga;
}
public void setPga(String pga) {
this.pga = get2(pga);
}
public String getSga() {
return sga;
}
public void setSga(String sga) {
this.sga = get2(sga);
}
public String getOpenCur() {
return openCur;
}
public void setOpenCur(String openCur) {
this.openCur = get2(openCur);
}
public String getMemorySort() {
return memorySort;
}
public void setMemorySort(String memorySort) {
this.memorySort = get2(memorySort);
}
}
| [
"nick@comprame.com"
] | nick@comprame.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.