blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
โ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4f50ab255bdaccfc9b96b66f9ed681485f97bdc5 | 0398f66458d68e87adbe11393a07ed07ce78574a | /src/main/java/com/octavio/mancillaco/security/DatabaseWebSecurity.java | 21dc3cb7b913571221b5ade19d65358c47ed442c | [] | no_license | octasvio1330/EstacionVelaOctavio- | 34685877cd1353f5b9aa4dcc63b5de3c46a7fcdc | 1b848c3142532a6068fd98c8ffef7806b1e082d8 | refs/heads/main | 2023-07-31T23:09:55.009139 | 2021-09-20T19:42:25 | 2021-09-20T19:42:25 | 408,576,581 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,318 | java | package com.octavio.mancillaco.security;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
@EnableWebSecurity
public class DatabaseWebSecurity extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//auth.jdbcAuthentication().dataSource(dataSource);
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select username, password, estatus from Usuarios where username=?")
.authoritiesByUsernameQuery("select u.username, p.perfil from UsuarioPerfil up " +
"inner join Usuarios u on u.id = up.idUsuario " +
"inner join Perfiles p on p.id = up.idPerfil " +
"where u.username = ?");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
// Los recursos estรกticos no requieren autenticaciรณn
.antMatchers(
"/bootstrap/**",
"/images/**",
"/tinymce/**",
"/logos/**").permitAll()
// Las vistas pรบblicas no requieren autenticaciรณn
.antMatchers("/",
"/crear",
"/guardar",
"/acerca",
"/vacantes/detalle/**").permitAll()
// Asignar permisos a URLs por ROLES
.antMatchers("/vacantes/**").hasAnyAuthority("Supervisor","Administrador")
.antMatchers("/categorias/**").hasAnyAuthority("Supervisor","Administrador")
.antMatchers("/usuarios/**").hasAnyAuthority("Supervisor","Administrador")
// Todas las demรกs URLs de la Aplicaciรณn requieren autenticaciรณn
.anyRequest().authenticated()
// El formulario de Login no requiere autenticacion
.and().formLogin().loginPage("/login").permitAll();
}
}
| [
"[email protected]"
] | |
b90eddc608e3a9f985600efe29ec008292aa95cd | 8176ef7683bd30f7412eac5d3393518026fbb217 | /app/src/main/java/com/bharatarmy/Activity/ImageVideoPrivacyActivity.java | 6057d4276f10c5e7ce01e8ad693c7be8bff62ffe | [] | no_license | gitbharatarmy/BharatArmy | 39265097ca24aa07d5dcd714dc6cf5bde7dc6e67 | aac64f88c8a25b7da144f8222986994d9fc8e738 | refs/heads/master | 2021-07-23T00:22:28.924033 | 2020-05-29T14:27:20 | 2020-05-29T14:27:20 | 179,429,853 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,582 | java | package com.bharatarmy.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.View;
import com.bharatarmy.Adapter.ImageVideoPrivacyAdapter;
import com.bharatarmy.Interfaces.MorestoryClick;
import com.bharatarmy.Models.GalleryImageModel;
import com.bharatarmy.Models.MyScreenChnagesModel;
import com.bharatarmy.R;
import com.bharatarmy.databinding.ActivityImageVideoPrivacyBinding;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
public class ImageVideoPrivacyActivity extends AppCompatActivity implements View.OnClickListener {
ActivityImageVideoPrivacyBinding activityImageVideoPrivacyBinding;
Context mContext;
ImageVideoPrivacyAdapter imageVideoPrivacyAdapter;
List<GalleryImageModel> privacyoptionList;
int selectedposition = -1;
String privacyStr,headertxt,subtxt,privacytagStr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityImageVideoPrivacyBinding = DataBindingUtil.setContentView(this, R.layout.activity_image_video_privacy);
mContext = ImageVideoPrivacyActivity.this;
init();
setListiner();
}
public void init() {
privacyStr=getIntent().getStringExtra("privacytxt");
privacytagStr =getIntent().getStringExtra("privacytype");
if (privacytagStr.equalsIgnoreCase("Image")){
privacyoptionList = new ArrayList<GalleryImageModel>();
privacyoptionList.add(new GalleryImageModel(getResources().getString(R.string.photo_public_option_Imageheader_txt), getResources().getString(R.string.photo_public_option_Imagesub_txt),
R.drawable.ic_aboutus, "1"));
privacyoptionList.add(new GalleryImageModel(getResources().getString(R.string.photo_private_option_Imageheader_txt), getResources().getString(R.string.photo_private_option_Imagesub_txt),
R.drawable.ic_private_user, "0"));
activityImageVideoPrivacyBinding.privacyHeaderTxt.setText(getResources().getString(R.string.photo_privacy_Imageheader_txt));
activityImageVideoPrivacyBinding.privacySubTxt.setText(getResources().getString(R.string.photo_privacy_Imagesub_txt));
activityImageVideoPrivacyBinding.privacyLinkTxt.setText(Html.fromHtml("<u>"+getResources().getString(R.string.photo_privacy_Imagetxt)+"<u>"));
}else{
privacyoptionList = new ArrayList<GalleryImageModel>();
privacyoptionList.add(new GalleryImageModel(getResources().getString(R.string.photo_public_option_videoheader_txt), getResources().getString(R.string.photo_public_option_videosub_txt),
R.drawable.ic_aboutus, "1"));
privacyoptionList.add(new GalleryImageModel(getResources().getString(R.string.photo_private_option_videoheader_txt), getResources().getString(R.string.photo_private_option_videosub_txt),
R.drawable.ic_private_user, "0"));
activityImageVideoPrivacyBinding.privacyHeaderTxt.setText(getResources().getString(R.string.photo_privacy_videoheader_txt));
activityImageVideoPrivacyBinding.privacySubTxt.setText(getResources().getString(R.string.photo_privacy_videosub_txt));
activityImageVideoPrivacyBinding.privacyLinkTxt.setText(Html.fromHtml("<u>"+getResources().getString(R.string.photo_privacy_videotxt)+"<u>"));
}
for (int i = 0; i < privacyoptionList.size(); i++) {
if (privacyoptionList.get(i).getHeadertxt().equalsIgnoreCase(privacyStr)) {
selectedposition = i;
}
}
Log.d("selectedposition : ", "" + selectedposition);
imageVideoPrivacyAdapter = new ImageVideoPrivacyAdapter(mContext, privacyoptionList, selectedposition, new MorestoryClick() {
@Override
public void getmorestoryClick() {
String getData = String.valueOf(imageVideoPrivacyAdapter.getDatas());
getData=getData.substring(1,getData.length()-1);
String[] splitString = getData.split("\\|");
headertxt = splitString[0];
subtxt = splitString[1];
Log.d("headertxt :", headertxt + " subtxt :" + subtxt);
}
});
LinearLayoutManager mLayoutManager = new LinearLayoutManager(mContext, RecyclerView.VERTICAL, false);
activityImageVideoPrivacyBinding.privacyRcv.setLayoutManager(mLayoutManager);
activityImageVideoPrivacyBinding.privacyRcv.setItemAnimator(new DefaultItemAnimator());
activityImageVideoPrivacyBinding.privacyRcv.setAdapter(imageVideoPrivacyAdapter);
}
public void setListiner() {
activityImageVideoPrivacyBinding.backImg.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.back_img:
EventBus.getDefault().post(new MyScreenChnagesModel(headertxt,subtxt));
finish();
break;
}
}
@Override
public void onBackPressed() {
EventBus.getDefault().post(new MyScreenChnagesModel(headertxt,subtxt));
finish();
super.onBackPressed();
}
}
| [
"[email protected]"
] | |
7c8aa8a0c296936dcc956bde3d2b79df54b69a71 | f7145608e0c57f36a9c6b8e35fa84da245c2d247 | /Protรณtipo funcional/JAVA/src/CadastroFamilia.java | a285da98e1106813d7e845843b4da326e9ef6f46 | [] | no_license | Harrisonlb/DHK-Sofware | 82745eeb3544d26531ee1a6e5f998c5e96306058 | 9aecec12f2e7c43f3d2acf12e7370aa90f7bc9cd | refs/heads/master | 2021-01-01T19:31:21.698578 | 2017-07-28T02:53:44 | 2017-07-28T02:53:44 | 98,600,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,597 | java | import java.util.*;
/*
* 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 Dalvan
*/
public class CadastroFamilia extends javax.swing.JFrame {
/**
* Creates new form CadastroFamilia
*/
public CadastroFamilia() {
initComponents();
setSize(550,750);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
nome = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
cpf = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
cep = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
cidade = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
nomePrincipal = new javax.swing.JTextField();
cpfPrincipal = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
estado = new javax.swing.JTextField();
doenca = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
fundo = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
jLabel2.setText("Cadastro de famรญlia");
getContentPane().add(jLabel2);
jLabel2.setBounds(180, 100, 173, 25);
jLabel1.setText("Integrante Principal");
getContentPane().add(jLabel1);
jLabel1.setBounds(90, 160, 130, 14);
jLabel3.setText("Nome:");
getContentPane().add(jLabel3);
jLabel3.setBounds(110, 420, 80, 14);
nome.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
nome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nomeActionPerformed(evt);
}
});
getContentPane().add(nome);
nome.setBounds(190, 420, 260, 19);
jLabel4.setText("CPF:");
getContentPane().add(jLabel4);
jLabel4.setBounds(110, 460, 60, 14);
cpf.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
getContentPane().add(cpf);
cpf.setBounds(190, 460, 150, 19);
jLabel5.setText("Endereรงo:");
getContentPane().add(jLabel5);
jLabel5.setBounds(90, 270, 70, 14);
cep.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
getContentPane().add(cep);
cep.setBounds(190, 290, 140, 19);
jLabel6.setText("CEP:");
getContentPane().add(jLabel6);
jLabel6.setBounds(110, 290, 60, 14);
jLabel7.setText("Cidade:");
getContentPane().add(jLabel7);
jLabel7.setBounds(110, 320, 70, 14);
cidade.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
cidade.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cidadeActionPerformed(evt);
}
});
getContentPane().add(cidade);
cidade.setBounds(190, 320, 140, 19);
jLabel8.setText("Estado:");
getContentPane().add(jLabel8);
jLabel8.setBounds(340, 320, 50, 14);
jLabel9.setText("Integrantes da Famรญlia");
getContentPane().add(jLabel9);
jLabel9.setBounds(90, 370, 130, 14);
jLabel10.setText("Nome:");
getContentPane().add(jLabel10);
jLabel10.setBounds(100, 180, 80, 14);
nomePrincipal.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
nomePrincipal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nomePrincipalActionPerformed(evt);
}
});
getContentPane().add(nomePrincipal);
nomePrincipal.setBounds(190, 180, 260, 19);
cpfPrincipal.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
getContentPane().add(cpfPrincipal);
cpfPrincipal.setBounds(190, 210, 150, 19);
jLabel11.setText("CPF:");
getContentPane().add(jLabel11);
jLabel11.setBounds(100, 210, 60, 14);
jButton1.setText("Cadastrar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(120, 570, 90, 23);
jLabel12.setText("Doenรงa:");
getContentPane().add(jLabel12);
jLabel12.setBounds(110, 500, 50, 14);
estado.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
getContentPane().add(estado);
estado.setBounds(400, 320, 50, 19);
doenca.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
getContentPane().add(doenca);
doenca.setBounds(190, 500, 100, 19);
jButton2.setText("Sair");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(350, 570, 73, 23);
fundo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/board.png"))); // NOI18N
getContentPane().add(fundo);
fundo.setBounds(0, 0, 540, 720);
pack();
}// </editor-fold>//GEN-END:initComponents
private void cidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cidadeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cidadeActionPerformed
private void nomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_nomeActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
MembroFamilia novo = new MembroFamilia(nome.getText(), cpf.getText(), doenca.getText(),true);
Familia nova = new Familia(cidade.getText(),estado.getText(),cep.getText(), novo);
Lista.adiciona(nova);
new TelaAgente().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
new TelaAgente().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void nomePrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomePrincipalActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_nomePrincipalActionPerformed
private void add(Familia nova){
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(CadastroFamilia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CadastroFamilia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CadastroFamilia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CadastroFamilia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CadastroFamilia().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField cep;
private javax.swing.JTextField cidade;
private javax.swing.JTextField cpf;
private javax.swing.JTextField cpfPrincipal;
private javax.swing.JTextField doenca;
private javax.swing.JTextField estado;
private javax.swing.JLabel fundo;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField nome;
private javax.swing.JTextField nomePrincipal;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
ccbb19633f500aa623b7a8c8cad00e0993bb394d | c4dc2bc29c5590f1b8290b049d49a33c5973d4e4 | /niubi-job-core/src/main/java/com/zuoxiaolong/niubi/job/core/helper/AssertHelper.java | 3d183f88f096a3db2214212bc9136229f2b2fcb8 | [
"Apache-2.0"
] | permissive | tangzhengyue/niubi-job | a2a6d14fe5e6fe44eb44600c20c7b46cdddc15ac | 92d9647c8f5b599bd74091d8d8bbd01a435541fa | refs/heads/master | 2021-01-20T18:45:12.498592 | 2016-01-20T12:30:36 | 2016-01-20T12:30:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,120 | java | /*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zuoxiaolong.niubi.job.core.helper;
/**
* @author Xiaolong Zuo
* @since 16/1/13 02:43
*/
public abstract class AssertHelper {
public static void notNull(Object o, String message) {
if (o == null) {
throw new IllegalArgumentException(message);
}
}
public static void notEmpty(Object o, String message) {
if (o == null || o.toString().trim().length() == 0) {
throw new IllegalArgumentException(message);
}
}
}
| [
"[email protected]"
] | |
2625b44233945607ef77e7bc0841b09ce9e591aa | 8bcfea9936a4ca147948a2a77be435ac1bfa2566 | /src/main/java/dataAccess/TraingSurveysAcces.java | 3ec5825ea732a22d120a374be05527b87bfbb028 | [] | no_license | SoftwareProjectIIGroep4/java | 8e0d5d037a993bb283717a9b63dd7b4aa0fd180f | 51f623a49dffe5b8c0b86f470def0eccd00e45b9 | refs/heads/master | 2021-05-15T09:29:55.952233 | 2017-12-24T11:59:57 | 2017-12-24T11:59:57 | 108,137,863 | 0 | 0 | null | 2017-12-25T07:05:04 | 2017-10-24T14:22:56 | Java | UTF-8 | Java | false | false | 2,118 | java | package dataAccess;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import models.Address;
import models.TrainigSurvey;
//TODO
public class TraingSurveysAcces extends RestRequest {
public static TrainigSurvey get(TrainigSurvey traingSurveys) throws IOException, URISyntaxException {
String JSONts = getAllOrOne(new URI(Constants.TRAINING_SURVEYS_SOURCE));
TrainigSurvey NTraingSurvey = mapper.readValue(JSONts, TrainigSurvey.class);
return NTraingSurvey;
}
public static HashMap<Integer, TrainigSurvey> getAll() throws IOException, URISyntaxException {
String JSONts = getAllOrOne(new URI(Constants.TRAINING_SURVEYS_SOURCE));
List<TrainigSurvey> traingSurveys = mapper.readValue(JSONts, new TypeReference<List<TrainigSurvey>>() {
});
HashMap<Integer, TrainigSurvey> traingSurveysMap = new HashMap<Integer, TrainigSurvey>();
for (TrainigSurvey traingSurvey : traingSurveys) {
traingSurveysMap.put(traingSurvey.getSurveyId(), traingSurvey);
}
return traingSurveysMap;
}
public static TrainigSurvey add(TrainigSurvey trainigSurvey) throws IOException, URISyntaxException {
String JSONts = postObject(trainigSurvey, new URI(Constants.TRAINING_SURVEYS_SOURCE));
return mapper.readValue(JSONts, TrainigSurvey.class);
}
public static void update(TrainigSurvey trainigSurvey) throws URISyntaxException, IOException {
putObject(trainigSurvey, new URI(Constants.TRAINING_SURVEYS_SOURCE + trainigSurvey.getSurveyId()));
}
public static TrainigSurvey remove(Integer id) throws URISyntaxException, IOException {
String JSONts = deleteObject(id, new URI(Constants.TRAINING_SURVEYS_SOURCE + id));
return mapper.readValue(JSONts, TrainigSurvey.class);
}
public static TrainigSurvey getBySurveyId(Integer id) throws IOException, URISyntaxException {
String JSONts = getAllOrOne(new URI(Constants.TRAINING_SURVEYS_SOURCE+"/"+id));
TrainigSurvey NTraingSurvey = mapper.readValue(JSONts, TrainigSurvey.class);
return NTraingSurvey;
}
}
| [
"[email protected]"
] | |
7b24e66485334069a953f35f6021d017e20293be | 7dbbf698227e3943a54b025350f032524e883dd7 | /recyclerviewfinalapp/src/main/java/com/example/recyclerviewfinalapp/interfaces/OnItemClickListener.java | ecd5b30cf7e9728a76d26541223f0ae2ca5a78e7 | [] | no_license | YugandharVadlamudi/MaterialDesignApplication | 492c9f724bee600a3e5f0a6f9561a667158530a8 | 57f7c9f3dde708729b0e048f8c2ae6c50787768f | refs/heads/master | 2020-04-10T21:03:14.736322 | 2016-09-15T10:37:18 | 2016-09-15T10:37:18 | 68,274,217 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package com.example.recyclerviewfinalapp.interfaces;
import android.view.View;
/**
* Created by Kiran on 08-06-2016.
*/
public interface OnItemClickListener {
public void onItemClickListener(View v);
}
| [
"[email protected]"
] | |
c1a0cad47621534fc815ba820fe1582b301b384c | 92225460ebca1bb6a594d77b6559b3629b7a94fa | /src/com/kingdee/eas/fdc/market/client/AreaSetListUI.java | af2d024949ff56e730b20f6136d4e504dea13aff | [] | no_license | yangfan0725/sd | 45182d34575381be3bbdd55f3f68854a6900a362 | 39ebad6e2eb76286d551a9e21967f3f5dc4880da | refs/heads/master | 2023-04-29T01:56:43.770005 | 2023-04-24T05:41:13 | 2023-04-24T05:41:13 | 512,073,641 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,762 | java | /**
* output package name
*/
package com.kingdee.eas.fdc.market.client;
import org.apache.log4j.Logger;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.org.OrgConstants;
import com.kingdee.eas.basedata.org.SaleOrgUnitInfo;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.fdc.basedata.FDCDataBaseInfo;
import com.kingdee.eas.fdc.basedata.client.FDCClientHelper;
import com.kingdee.eas.fdc.market.AreaSetFactory;
import com.kingdee.eas.fdc.market.AreaSetInfo;
import com.kingdee.eas.fdc.sellhouse.client.SHEHelper;
import com.kingdee.eas.framework.ICoreBase;
/**
* output class name
*/
public class AreaSetListUI extends AbstractAreaSetListUI
{
private static final Logger logger = CoreUIObject.getLogger(AreaSetListUI.class);
SaleOrgUnitInfo saleOrg = SHEHelper.getCurrentSaleOrg();
/**
* output class constructor
*/
public AreaSetListUI() throws Exception
{
super();
}
public void onLoad() throws Exception {
super.onLoad();
FDCClientHelper.addSqlMenu(this, this.menuEdit);
if (!saleOrg.getId().toString().equals(OrgConstants.DEF_CU_ID)){
actionAddNew.setEnabled(false);
actionEdit.setEnabled(false);
actionRemove.setEnabled(false);
}
}
/**
* output storeFields method
*/
public void storeFields()
{
super.storeFields();
}
protected FDCDataBaseInfo getBaseDataInfo() {
return new AreaSetInfo();
}
protected ICoreBase getBizInterface() throws Exception {
return AreaSetFactory.getRemoteInstance();
}
protected String getEditUIName() {
return com.kingdee.eas.fdc.market.client.AreaSetEditUI.class.getName();
}
protected String getEditUIModal() {
return UIFactoryName.MODEL;
}
} | [
"[email protected]"
] | |
b1ea88ef58807c06ac4883bb7bedf41aa432fe74 | c813e7bf34b0d19bf98fac1e0ff924a94a8f18e2 | /src/com/eby/mhs/MhsViewController.java | 3cf4a5cf1759d7209f56ff0548d6f65f31c779be | [] | no_license | kevinmel2000/BasicCRUDHibernateGenericDAO | 1789dc31f1e0f35e2a836bee8bc6e84d599cac7c | 3f67f8eb1d2d9a30730dc2d0f485a96924f4ef76 | refs/heads/master | 2020-04-12T12:23:25.172892 | 2015-08-24T11:55:43 | 2015-08-24T11:55:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,152 | 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 com.eby.mhs;
import com.eby.animations.FadeInLeftTransition;
import com.eby.animations.FadeOutRightTransition;
import com.eby.autocomplete.ComboBoxAuto;
import com.eby.frameworkConfig.Config;
import com.eby.orm.entity.Dosen;
import com.eby.orm.entity.Mahasiswa;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.util.converter.LocalDateStringConverter;
/**
* FXML Controller class
*
* @author eby
*/
public class MhsViewController implements Initializable {
@FXML
private GridPane gridPane;
@FXML
private TextField txtNIM;
@FXML
private TextField txtNama;
@FXML
private TextField txtKelas;
@FXML
private TextArea txtAlamat;
@FXML
private ComboBox<String> cbDosen;
@FXML
private DatePicker dateLahir;
@FXML
private TableView<Mahasiswa> tableMhs;
@FXML
private Button btTambah;
@FXML
private Button btUbah;
@FXML
private Button btHapus;
@FXML
private FontAwesomeIconView ubahIcon;
@FXML
private FontAwesomeIconView hapusIcon;
@FXML
private TextField txtCari;
@FXML
private FontAwesomeIconView cariIcon;
@FXML
private Text txtClose;
@FXML
private FontAwesomeIconView plusIcon;
@FXML
private AnchorPane paneView;
private MhsModel model;
private MhsTableModel tableModel;
private MhsComboBoxModel comboBoxModel;
private Config con;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
initModel();
initTable();
initComboBox();
fadeIn();
con = new Config();
Platform.runLater(() -> {
cbDosen.setOnKeyReleased(KeyEvent -> {
new ComboBoxAuto<>(cbDosen);
});
});
}
@FXML
private void tableClicked(MouseEvent event) {
int index = tableMhs.getSelectionModel().getSelectedIndex();
if (index != -1) {
Mahasiswa m = tableModel.getItem().get(index);
txtNIM.setText(m.getNim());
txtNama.setText(m.getNama());
txtKelas.setText(m.getKelas());
txtAlamat.setText(m.getAlamat());
LocalDateStringConverter ld = new LocalDateStringConverter();
dateLahir.setValue(ld.fromString(m.getTglLahir()));
cbDosen.getSelectionModel().select(m.getDosen().getNama());
} else {
System.out.println("index -1, pilih data");
}
}
@FXML
private void tambahAction(ActionEvent event) {
String nim = txtNIM.getText();
String nama = txtNama.getText();
String kelas = txtKelas.getText();
String alamat = txtAlamat.getText();
//Konversi localDate menjadi String
LocalDateStringConverter ld = new LocalDateStringConverter();
String tglLahir = ld.toString(dateLahir.getValue());
int dosen = cbDosen.getSelectionModel().getSelectedIndex();
if (nim.equals("") || nama.equals("") || kelas.equals("") || alamat.equals("") || tglLahir.isEmpty() || dosen == -1) {
con.dialog(Alert.AlertType.WARNING, "data tidak boleh kosong", null);
} else {
//megambil index pada combo box
int index = cbDosen.getSelectionModel().getSelectedIndex();
//menyimpan index pada object
Dosen d = comboBoxModel.get(index);
Mahasiswa m = new Mahasiswa(nim, d, nama, kelas, alamat, tglLahir);
model.save(m);
con.dialog(Alert.AlertType.INFORMATION, "data berhasil disimpan", null);
loadData();
loadComboBox();
reset();
}
}
@FXML
private void ubahAction(ActionEvent event) {
String nim = txtNIM.getText();
String nama = txtNama.getText();
String kelas = txtKelas.getText();
String alamat = txtAlamat.getText();
LocalDateStringConverter ld = new LocalDateStringConverter();
String tglLahir = ld.toString(dateLahir.getValue());
int dosen = cbDosen.getSelectionModel().getSelectedIndex();
if (nim.equals("") || nama.equals("") || kelas.equals("") || alamat.equals("") || tglLahir.isEmpty() || dosen == -1) {
con.dialog(Alert.AlertType.WARNING, "data tidak boleh kosong", null);
} else {
int index = cbDosen.getSelectionModel().getSelectedIndex();
Dosen d = comboBoxModel.get(index);
Mahasiswa m = new Mahasiswa(nim, d, nama, kelas, alamat, tglLahir);
model.update(m);
con.dialog(Alert.AlertType.INFORMATION, "data berhasil diupdate", null);
loadData();
loadComboBox();
reset();
}
}
@FXML
private void hapusAction(ActionEvent event) {
int index = tableMhs.getSelectionModel().getSelectedIndex();
if (index != -1) {
Mahasiswa m = tableModel.getItem().get(index);
model.delete(m);
con.dialog(Alert.AlertType.WARNING, "data berhasil dihapus", null);
loadData();
loadComboBox();
reset();
} else {
con.dialog(Alert.AlertType.WARNING, "Pilih data", null);
}
}
@FXML
private void onKeyReleased(KeyEvent event) {
String key = txtCari.getText();
if (key.equals("")) {
loadData();
} else {
tableModel.getItem().remove(0, tableModel.getItem().size());
tableMhs.setItems(tableModel.getItem());
tableModel.getItem().addAll(model.findData(key));
}
}
@FXML
private void closeAction(MouseEvent event) {
this.fadeOut();
}
public void fadeIn() {
new FadeInLeftTransition(gridPane).play();
new FadeInLeftTransition(btTambah).play();
new FadeInLeftTransition(btUbah).play();
new FadeInLeftTransition(btHapus).play();
new FadeInLeftTransition(plusIcon).play();
new FadeInLeftTransition(ubahIcon).play();
new FadeInLeftTransition(hapusIcon).play();
new FadeInLeftTransition(txtCari).play();
new FadeInLeftTransition(cariIcon).play();
new FadeInLeftTransition(tableMhs).play();
// new FadeInLeftTransition(paneView).play();
new FadeInLeftTransition(txtClose).play();
}
public void fadeOut() {
new FadeOutRightTransition(gridPane).play();
new FadeOutRightTransition(btTambah).play();
new FadeOutRightTransition(btUbah).play();
new FadeOutRightTransition(btHapus).play();
new FadeOutRightTransition(plusIcon).play();
new FadeOutRightTransition(ubahIcon).play();
new FadeOutRightTransition(hapusIcon).play();
new FadeOutRightTransition(txtCari).play();
new FadeOutRightTransition(cariIcon).play();
new FadeOutRightTransition(tableMhs).play();
new FadeOutRightTransition(paneView).play();
new FadeOutRightTransition(txtClose).play();
}
private void initModel() {
model = new MhsModel();
model.setController(this);
}
private void initTable() {
tableModel = new MhsTableModel();
tableMhs.getColumns().addAll(tableModel.getAllColumn());
tableMhs.setItems(tableModel.getItem());
tableModel.getItem().addAll(model.list());
}
public void initComboBox() {
comboBoxModel = new MhsComboBoxModel();
cbDosen.setItems(comboBoxModel.getItems());
comboBoxModel.add(model.listDosen());
}
public void loadData() {
tableModel.getItem().remove(0, tableModel.getItem().size());
tableMhs.setItems(tableModel.getItem());
tableModel.getItem().addAll(model.list());
}
public void loadComboBox() {
comboBoxModel.getItems().remove(0, comboBoxModel.getItems().size());
cbDosen.setItems(comboBoxModel.getItems());
comboBoxModel.add(model.listDosen());
}
public void reset() {
txtNIM.setText("");
txtNama.setText("");
txtKelas.setText("");
txtAlamat.setText("");
dateLahir.setValue(null);
cbDosen.getSelectionModel().clearSelection();
}
}
| [
"[email protected]"
] | |
372d83d338c4f31c99cfc1c087d306a885c72f52 | ee08098f08b3dad9bc80404c15209e91d632a486 | /src/main/java/com/example/htmlEventsController.java | f07582837b23ac8e65f588e833f808057043cd77 | [] | no_license | yusufcoban/GroupEventManagerSite | 6d7fdc79c13f735dd72ddb915a93a2714e4d7ef0 | c843f5f8fbde46c1b6d07ed6762491000bf7c9b9 | refs/heads/master | 2021-07-05T12:09:55.649373 | 2017-09-29T15:54:42 | 2017-09-29T15:54:42 | 105,289,614 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 8,240 | java | package com.example;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("events")
public class htmlEventsController {
@Autowired
public eventDao eventsController;
@Autowired
public userDao userController;
@Autowired
public sportartenDao sportController;
@RequestMapping(method = RequestMethod.GET)
public String user(ModelMap modelmap) {
user logged = getcurrentuser();
Iterable<events> eventtester = eventsController.findAll();
Set<events> kompletteListe = new HashSet<events>((Collection) eventtester);
Set<events> vergleichsListe = logged.getEventSet();
kompletteListe.removeAll(vergleichsListe);
modelmap.put("eventListe", kompletteListe);
int id = getcurrentuser().getUserid();
if (id <= 1) {
Iterable<sportarten> sportart = sportController.findAll();
modelmap.addAttribute("sportarten", sportart);
return "events_admin";
}
if (id == 4) {
return "events";
} else
return "events_user";
}
// Details รผber das Event
@RequestMapping("/details")
public String getinfos(@RequestParam int id, ModelMap modelmap) {
events event = eventsController.findOne(id);
modelmap.put("eventListe", event);
modelmap.put("userListe", event.getUser());
modelmap.put("infos", event.getInfos());
modelmap.put("austragen", "/events/invent?id=" + event.getEventid());
modelmap.put("eintragen", "/events/expend?id=" + event.getEventid());
user current = getcurrentuser();
// NEU
boolean syso=current.getEventSet().contains(event);
System.out.println(syso);
if (current.getEventSet().contains(event)) {
modelmap.put("status", "ja");
} else
modelmap.put("status", "nein");
int ids = getcurrentuser().getUserid();
if (ids <= 1) {
return "eventdetails_admin";
}
if (ids == 4) {
return "eventdetails";
}
return "eventdetails_user";
// GEHT LAKa
}
// Event lรถschen
@RequestMapping("/delete")
public String delete(@RequestParam int id, ModelMap modelmap) throws MessagingException {
events event = eventsController.findOne(id);
System.out.println(event.getEventid() + "gelรถscht!");
sendmail(event, "gelรถscht");
eventsController.delete(event);
modelmap.put("eventListe", event);
return "redirect://localhost:7777/events.html";
}
@RequestMapping("/update")
public String update(@RequestParam int id, ModelMap modelmap) {
events event = eventsController.findOne(id);
modelmap.put("eventListe", event);
return "eventdetails";
// GEHT LAK
}
// Eintragen
@RequestMapping(value = "/invent", method = RequestMethod.GET)
public String invevent(@RequestParam int id, ModelMap modelmap, HttpServletResponse http)
throws MessagingException {
user logged = getcurrentuser();
events event = eventsController.findOne(id);
Set<events> listetester = logged.getEventSet();
events naaa = eventsController.findOne(id);
// WENN VOLL DANN NIEMAND NEILASSEN
if (event.getmaxspieler() == event.getUser().size()) {
return "redirect://localhost:7777/events.html";
}
if (listetester.contains(naaa)) {
System.out.println("Bist schon Mitglied");
modelmap.put("eventListe", logged.getEventSet());
return "redirect://localhost:7777/events.html";
// Kann nicht mehr passieren
} else {
listetester.add(event);
logged.setEventSet(listetester);
userController.save(logged);
modelmap.put("eventListe", logged.getEventSet());
// sendmail(naaa, "hinzugefรผgt");
sendmail(event);
return "redirect://localhost:7777/events.html";
}
}
// Austragen
@RequestMapping(value = "/expend", method = RequestMethod.GET)
public String expend(@RequestParam int id, ModelMap modelmap, HttpServletResponse http,
HttpServletResponse httpServletResponse) {
user logged = getcurrentuser();
try {
sendmail_neg(eventsController.findOne(id));
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Set<events> neueliste = logged.getEventSet();
neueliste.remove(eventsController.findOne(id));
userController.save(logged);
return "redirect://localhost:7777/myevents.html";
}
// get logged User
public user getcurrentuser() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName();
user logged = userController.findOne(Integer.parseInt(name));
return logged;
}
// Mail Sender universal
public void sendmail(events events, String inhalt) throws MessagingException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AppConfig.class);
ctx.refresh();
JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
for (user a : events.getUserliste()) {
mailMsg.setFrom("[email protected]");
mailMsg.setTo(a.getEmail());
mailMsg.setSubject("Event wurde " + inhalt + "...");
mailMsg.setText("EVENT mit der ID: " + events.getEventid() + " wurde " + inhalt + "....");
mailSender.send(mimeMessage);
System.out.println("---Done---");
}
}
// Mail Sender eintragen
public void sendmail(events events) throws MessagingException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AppConfig.class);
ctx.refresh();
JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
for (user a : events.getUserliste()) {
mailMsg.setFrom("SPOGROMA");
mailMsg.setTo("[email protected]");
mailMsg.setSubject("Event " + events.getEventid() + " hat ein neues Mitglied");
mailMsg.setText("Benutzer mit der ID:" + getcurrentuser().getUserid() + "hat sich in das Event mit der ID: "
+ events.getEventid() + "eingetragen");
mailSender.send(mimeMessage);
System.out.println("---Done---");
}
}
// Mail Sender austragen
public void sendmail_neg(events events) throws MessagingException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AppConfig.class);
ctx.refresh();
JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
for (user a : events.getUserliste()) {
mailMsg.setFrom("SPOGROMA");
mailMsg.setTo("[email protected]");
mailMsg.setSubject("Event " + events.getEventid() + " hat einen Mitglied weniger");
mailMsg.setText("Benutzer mit der ID:" + getcurrentuser().getUserid()
+ "hat sich aus den Event mit der ID: " + events.getEventid() + " ausgetragen");
mailSender.send(mimeMessage);
System.out.println("---Done---");
}
}
// Daten Datum
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
dateFormat.setLenient(false);
webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
}
| [
"[email protected]"
] | |
07d56f2750721d5dbf06fc36f24c33d76063609c | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-13372-7-4-MOEAD-WeightedSum:TestLen:CallDiversity/org/xwiki/extension/xar/internal/handler/packager/Packager_ESTest.java | b0fa46d0ea1481a1e4a159d3db4feb1ebb386e5f | [] | 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 | 572 | java | /*
* This file was automatically generated by EvoSuite
* Wed Apr 08 06:07:10 UTC 2020
*/
package org.xwiki.extension.xar.internal.handler.packager;
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 Packager_ESTest extends Packager_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"[email protected]"
] | |
81ef999cbf04a5085c4d112daa08fbc86fb83572 | 4917bcfe0f4d1b8a974ca02ba1a28e0dcad7aaaf | /src/main/java/com/google/schemaorg/core/impl/MedicalTrialImpl.java | abbeff3d96abf95e0001c90e035a034382261045 | [
"Apache-2.0"
] | permissive | google/schemaorg-java | e9a74eb5c5a69014a9763d961103a32254e792b7 | d11c8edf686de6446c34e92f9b3243079d8cb76e | refs/heads/master | 2023-08-23T12:49:26.774277 | 2022-08-25T12:49:06 | 2022-08-25T12:49:06 | 58,669,416 | 77 | 48 | Apache-2.0 | 2022-08-06T11:35:15 | 2016-05-12T19:08:04 | Java | UTF-8 | Java | false | false | 14,267 | java | /*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.schemaorg.core;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.schemaorg.SchemaOrgType;
import com.google.schemaorg.SchemaOrgTypeImpl;
import com.google.schemaorg.ValueType;
import com.google.schemaorg.core.datatype.Text;
import com.google.schemaorg.core.datatype.URL;
import com.google.schemaorg.goog.GoogConstants;
import com.google.schemaorg.goog.PopularityScoreSpecification;
/** Implementation of {@link MedicalTrial}. */
public class MedicalTrialImpl extends MedicalStudyImpl implements MedicalTrial {
private static final ImmutableSet<String> PROPERTY_SET = initializePropertySet();
private static ImmutableSet<String> initializePropertySet() {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
builder.add(CoreConstants.PROPERTY_ADDITIONAL_TYPE);
builder.add(CoreConstants.PROPERTY_ALTERNATE_NAME);
builder.add(CoreConstants.PROPERTY_CODE);
builder.add(CoreConstants.PROPERTY_DESCRIPTION);
builder.add(CoreConstants.PROPERTY_GUIDELINE);
builder.add(CoreConstants.PROPERTY_IMAGE);
builder.add(CoreConstants.PROPERTY_MAIN_ENTITY_OF_PAGE);
builder.add(CoreConstants.PROPERTY_MEDICINE_SYSTEM);
builder.add(CoreConstants.PROPERTY_NAME);
builder.add(CoreConstants.PROPERTY_OUTCOME);
builder.add(CoreConstants.PROPERTY_PHASE);
builder.add(CoreConstants.PROPERTY_POPULATION);
builder.add(CoreConstants.PROPERTY_POTENTIAL_ACTION);
builder.add(CoreConstants.PROPERTY_RECOGNIZING_AUTHORITY);
builder.add(CoreConstants.PROPERTY_RELEVANT_SPECIALTY);
builder.add(CoreConstants.PROPERTY_SAME_AS);
builder.add(CoreConstants.PROPERTY_SPONSOR);
builder.add(CoreConstants.PROPERTY_STATUS);
builder.add(CoreConstants.PROPERTY_STUDY);
builder.add(CoreConstants.PROPERTY_STUDY_LOCATION);
builder.add(CoreConstants.PROPERTY_STUDY_SUBJECT);
builder.add(CoreConstants.PROPERTY_TRIAL_DESIGN);
builder.add(CoreConstants.PROPERTY_URL);
builder.add(GoogConstants.PROPERTY_DETAILED_DESCRIPTION);
builder.add(GoogConstants.PROPERTY_POPULARITY_SCORE);
return builder.build();
}
static final class BuilderImpl extends SchemaOrgTypeImpl.BuilderImpl<MedicalTrial.Builder>
implements MedicalTrial.Builder {
@Override
public MedicalTrial.Builder addAdditionalType(URL value) {
return addProperty(CoreConstants.PROPERTY_ADDITIONAL_TYPE, value);
}
@Override
public MedicalTrial.Builder addAdditionalType(String value) {
return addProperty(CoreConstants.PROPERTY_ADDITIONAL_TYPE, Text.of(value));
}
@Override
public MedicalTrial.Builder addAlternateName(Text value) {
return addProperty(CoreConstants.PROPERTY_ALTERNATE_NAME, value);
}
@Override
public MedicalTrial.Builder addAlternateName(String value) {
return addProperty(CoreConstants.PROPERTY_ALTERNATE_NAME, Text.of(value));
}
@Override
public MedicalTrial.Builder addCode(MedicalCode value) {
return addProperty(CoreConstants.PROPERTY_CODE, value);
}
@Override
public MedicalTrial.Builder addCode(MedicalCode.Builder value) {
return addProperty(CoreConstants.PROPERTY_CODE, value.build());
}
@Override
public MedicalTrial.Builder addCode(String value) {
return addProperty(CoreConstants.PROPERTY_CODE, Text.of(value));
}
@Override
public MedicalTrial.Builder addDescription(Text value) {
return addProperty(CoreConstants.PROPERTY_DESCRIPTION, value);
}
@Override
public MedicalTrial.Builder addDescription(String value) {
return addProperty(CoreConstants.PROPERTY_DESCRIPTION, Text.of(value));
}
@Override
public MedicalTrial.Builder addGuideline(MedicalGuideline value) {
return addProperty(CoreConstants.PROPERTY_GUIDELINE, value);
}
@Override
public MedicalTrial.Builder addGuideline(MedicalGuideline.Builder value) {
return addProperty(CoreConstants.PROPERTY_GUIDELINE, value.build());
}
@Override
public MedicalTrial.Builder addGuideline(String value) {
return addProperty(CoreConstants.PROPERTY_GUIDELINE, Text.of(value));
}
@Override
public MedicalTrial.Builder addImage(ImageObject value) {
return addProperty(CoreConstants.PROPERTY_IMAGE, value);
}
@Override
public MedicalTrial.Builder addImage(ImageObject.Builder value) {
return addProperty(CoreConstants.PROPERTY_IMAGE, value.build());
}
@Override
public MedicalTrial.Builder addImage(URL value) {
return addProperty(CoreConstants.PROPERTY_IMAGE, value);
}
@Override
public MedicalTrial.Builder addImage(String value) {
return addProperty(CoreConstants.PROPERTY_IMAGE, Text.of(value));
}
@Override
public MedicalTrial.Builder addMainEntityOfPage(CreativeWork value) {
return addProperty(CoreConstants.PROPERTY_MAIN_ENTITY_OF_PAGE, value);
}
@Override
public MedicalTrial.Builder addMainEntityOfPage(CreativeWork.Builder value) {
return addProperty(CoreConstants.PROPERTY_MAIN_ENTITY_OF_PAGE, value.build());
}
@Override
public MedicalTrial.Builder addMainEntityOfPage(URL value) {
return addProperty(CoreConstants.PROPERTY_MAIN_ENTITY_OF_PAGE, value);
}
@Override
public MedicalTrial.Builder addMainEntityOfPage(String value) {
return addProperty(CoreConstants.PROPERTY_MAIN_ENTITY_OF_PAGE, Text.of(value));
}
@Override
public MedicalTrial.Builder addMedicineSystem(MedicineSystem value) {
return addProperty(CoreConstants.PROPERTY_MEDICINE_SYSTEM, value);
}
@Override
public MedicalTrial.Builder addMedicineSystem(String value) {
return addProperty(CoreConstants.PROPERTY_MEDICINE_SYSTEM, Text.of(value));
}
@Override
public MedicalTrial.Builder addName(Text value) {
return addProperty(CoreConstants.PROPERTY_NAME, value);
}
@Override
public MedicalTrial.Builder addName(String value) {
return addProperty(CoreConstants.PROPERTY_NAME, Text.of(value));
}
@Override
public MedicalTrial.Builder addOutcome(Text value) {
return addProperty(CoreConstants.PROPERTY_OUTCOME, value);
}
@Override
public MedicalTrial.Builder addOutcome(String value) {
return addProperty(CoreConstants.PROPERTY_OUTCOME, Text.of(value));
}
@Override
public MedicalTrial.Builder addPhase(Text value) {
return addProperty(CoreConstants.PROPERTY_PHASE, value);
}
@Override
public MedicalTrial.Builder addPhase(String value) {
return addProperty(CoreConstants.PROPERTY_PHASE, Text.of(value));
}
@Override
public MedicalTrial.Builder addPopulation(Text value) {
return addProperty(CoreConstants.PROPERTY_POPULATION, value);
}
@Override
public MedicalTrial.Builder addPopulation(String value) {
return addProperty(CoreConstants.PROPERTY_POPULATION, Text.of(value));
}
@Override
public MedicalTrial.Builder addPotentialAction(Action value) {
return addProperty(CoreConstants.PROPERTY_POTENTIAL_ACTION, value);
}
@Override
public MedicalTrial.Builder addPotentialAction(Action.Builder value) {
return addProperty(CoreConstants.PROPERTY_POTENTIAL_ACTION, value.build());
}
@Override
public MedicalTrial.Builder addPotentialAction(String value) {
return addProperty(CoreConstants.PROPERTY_POTENTIAL_ACTION, Text.of(value));
}
@Override
public MedicalTrial.Builder addRecognizingAuthority(Organization value) {
return addProperty(CoreConstants.PROPERTY_RECOGNIZING_AUTHORITY, value);
}
@Override
public MedicalTrial.Builder addRecognizingAuthority(Organization.Builder value) {
return addProperty(CoreConstants.PROPERTY_RECOGNIZING_AUTHORITY, value.build());
}
@Override
public MedicalTrial.Builder addRecognizingAuthority(String value) {
return addProperty(CoreConstants.PROPERTY_RECOGNIZING_AUTHORITY, Text.of(value));
}
@Override
public MedicalTrial.Builder addRelevantSpecialty(MedicalSpecialty value) {
return addProperty(CoreConstants.PROPERTY_RELEVANT_SPECIALTY, value);
}
@Override
public MedicalTrial.Builder addRelevantSpecialty(String value) {
return addProperty(CoreConstants.PROPERTY_RELEVANT_SPECIALTY, Text.of(value));
}
@Override
public MedicalTrial.Builder addSameAs(URL value) {
return addProperty(CoreConstants.PROPERTY_SAME_AS, value);
}
@Override
public MedicalTrial.Builder addSameAs(String value) {
return addProperty(CoreConstants.PROPERTY_SAME_AS, Text.of(value));
}
@Override
public MedicalTrial.Builder addSponsor(Organization value) {
return addProperty(CoreConstants.PROPERTY_SPONSOR, value);
}
@Override
public MedicalTrial.Builder addSponsor(Organization.Builder value) {
return addProperty(CoreConstants.PROPERTY_SPONSOR, value.build());
}
@Override
public MedicalTrial.Builder addSponsor(String value) {
return addProperty(CoreConstants.PROPERTY_SPONSOR, Text.of(value));
}
@Override
public MedicalTrial.Builder addStatus(MedicalStudyStatus value) {
return addProperty(CoreConstants.PROPERTY_STATUS, value);
}
@Override
public MedicalTrial.Builder addStatus(String value) {
return addProperty(CoreConstants.PROPERTY_STATUS, Text.of(value));
}
@Override
public MedicalTrial.Builder addStudy(MedicalStudy value) {
return addProperty(CoreConstants.PROPERTY_STUDY, value);
}
@Override
public MedicalTrial.Builder addStudy(MedicalStudy.Builder value) {
return addProperty(CoreConstants.PROPERTY_STUDY, value.build());
}
@Override
public MedicalTrial.Builder addStudy(String value) {
return addProperty(CoreConstants.PROPERTY_STUDY, Text.of(value));
}
@Override
public MedicalTrial.Builder addStudyLocation(AdministrativeArea value) {
return addProperty(CoreConstants.PROPERTY_STUDY_LOCATION, value);
}
@Override
public MedicalTrial.Builder addStudyLocation(AdministrativeArea.Builder value) {
return addProperty(CoreConstants.PROPERTY_STUDY_LOCATION, value.build());
}
@Override
public MedicalTrial.Builder addStudyLocation(String value) {
return addProperty(CoreConstants.PROPERTY_STUDY_LOCATION, Text.of(value));
}
@Override
public MedicalTrial.Builder addStudySubject(MedicalEntity value) {
return addProperty(CoreConstants.PROPERTY_STUDY_SUBJECT, value);
}
@Override
public MedicalTrial.Builder addStudySubject(MedicalEntity.Builder value) {
return addProperty(CoreConstants.PROPERTY_STUDY_SUBJECT, value.build());
}
@Override
public MedicalTrial.Builder addStudySubject(String value) {
return addProperty(CoreConstants.PROPERTY_STUDY_SUBJECT, Text.of(value));
}
@Override
public MedicalTrial.Builder addTrialDesign(MedicalTrialDesign value) {
return addProperty(CoreConstants.PROPERTY_TRIAL_DESIGN, value);
}
@Override
public MedicalTrial.Builder addTrialDesign(String value) {
return addProperty(CoreConstants.PROPERTY_TRIAL_DESIGN, Text.of(value));
}
@Override
public MedicalTrial.Builder addUrl(URL value) {
return addProperty(CoreConstants.PROPERTY_URL, value);
}
@Override
public MedicalTrial.Builder addUrl(String value) {
return addProperty(CoreConstants.PROPERTY_URL, Text.of(value));
}
@Override
public MedicalTrial.Builder addDetailedDescription(Article value) {
return addProperty(GoogConstants.PROPERTY_DETAILED_DESCRIPTION, value);
}
@Override
public MedicalTrial.Builder addDetailedDescription(Article.Builder value) {
return addProperty(GoogConstants.PROPERTY_DETAILED_DESCRIPTION, value.build());
}
@Override
public MedicalTrial.Builder addDetailedDescription(String value) {
return addProperty(GoogConstants.PROPERTY_DETAILED_DESCRIPTION, Text.of(value));
}
@Override
public MedicalTrial.Builder addPopularityScore(PopularityScoreSpecification value) {
return addProperty(GoogConstants.PROPERTY_POPULARITY_SCORE, value);
}
@Override
public MedicalTrial.Builder addPopularityScore(PopularityScoreSpecification.Builder value) {
return addProperty(GoogConstants.PROPERTY_POPULARITY_SCORE, value.build());
}
@Override
public MedicalTrial.Builder addPopularityScore(String value) {
return addProperty(GoogConstants.PROPERTY_POPULARITY_SCORE, Text.of(value));
}
@Override
public MedicalTrial build() {
return new MedicalTrialImpl(properties, reverseMap);
}
}
public MedicalTrialImpl(
Multimap<String, ValueType> properties, Multimap<String, Thing> reverseMap) {
super(properties, reverseMap);
}
@Override
public String getFullTypeName() {
return CoreConstants.TYPE_MEDICAL_TRIAL;
}
@Override
public boolean includesProperty(String property) {
return PROPERTY_SET.contains(CoreConstants.NAMESPACE + property)
|| PROPERTY_SET.contains(GoogConstants.NAMESPACE + property)
|| PROPERTY_SET.contains(property);
}
@Override
public ImmutableList<SchemaOrgType> getPhaseList() {
return getProperty(CoreConstants.PROPERTY_PHASE);
}
@Override
public ImmutableList<SchemaOrgType> getTrialDesignList() {
return getProperty(CoreConstants.PROPERTY_TRIAL_DESIGN);
}
}
| [
"[email protected]"
] | |
ed5d89ee3be48b36ebc1a2bf45c042e1a1d68f37 | 295ba07d516ac19863691c923e811cceb63b4638 | /src/main/java/com/lzw/hrmsys/domain/Job.java | b24ea1dc08313099c129416305984183217d12ff | [] | no_license | 1987Mn/SSM-hrm | 8ddd52adcd046703e94f05dbd3b5480b36dbccb8 | a00d32925297ad1f489c187fd83354ae961da136 | refs/heads/master | 2022-12-21T11:48:38.571336 | 2020-03-18T02:03:08 | 2020-03-18T02:03:08 | 248,113,413 | 0 | 0 | null | 2022-12-16T11:36:32 | 2020-03-18T01:47:07 | JavaScript | UTF-8 | Java | false | false | 966 | java | package com.lzw.hrmsys.domain;
public class Job {
private Integer id;
private String name;
private String remark;
public Job() {
}
public Job(Integer id, String name, String remark) {
this.id = id;
this.name = name;
this.remark = remark;
}
@Override
public String toString() {
return "Job{" +
"id=" + id +
", name='" + name + '\'' +
", remark='" + remark + '\'' +
'}';
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
} | [
"[email protected]"
] | |
37cfa91c0aacf6fbb48d5f8cc4cdc35026ac306f | 106b4366e5be2acb5cec561b2cc0eacba33c90f6 | /CloneWorkbench/test/JUnitTestandoGroupBy.java | 87f5c03b1a23e2acd2062021f3797644cd73a52f | [] | no_license | eduardala/CloneWorkbench | 961a3504e82dd77aa31fbd6d76942770f17c3b21 | 5ca13f33e5e22551eb306d06bacf1e1e29c7a0f4 | refs/heads/master | 2020-06-13T06:39:10.930584 | 2019-07-08T20:26:52 | 2019-07-08T20:26:52 | 194,574,444 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,199 | 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.
*/
import com.eduarda.clone.Uteis.GroupBy;
import java.io.FileNotFoundException;
import junit.framework.TestCase;
/**
*
* @author eduardadelima
*/
public class JUnitTestandoGroupBy extends TestCase {
public JUnitTestandoGroupBy() {
}
GroupBy gb = new GroupBy();
public void testGroupMax() throws FileNotFoundException {
gb.comMax("Funcionarios", "5", "idCargo");
System.out.println(gb.gerador());
assertEquals("SELECT idCargo, MAX(5) FROM Funcionarios GROUP BY idCargo;", this);
gb.geraSQL("src/Arquivos/scriptGroupBy.sql");
}
public void testGroupCount() {
gb.Count("Funcionarios", "idCargo");
System.out.println(gb.gerador());
assertEquals("SELECT idCargo, COUNT(*) FROM Funcionarios GROUP BY idCargo;", this);
}
/*public void testConsultaseOperacoes() {
gp.GroupByMax("idCargo", "5", "Funcionario");
gp.GroupByCountSimples("idCargo", "Funcionario");
}*/
}
| [
"[email protected]"
] | |
71fc60695977232be2947799b9b951db4bd08c3c | 48fd0b689f9cdb660ad06a191107e14d47542fd8 | /ada97/src/Main.java | c98328bbf5e82f7c0674abf5f3bd866fc566851e | [
"MIT"
] | permissive | chiendarrendor/AlbertsAdalogicalAenigmas | 3dfc6616d47c361ad6911e2ee4e3a3ec24bb6b75 | c6f91d4718999089686f3034a75a11b312fa1458 | refs/heads/master | 2022-08-28T11:34:02.261386 | 2022-07-08T22:45:24 | 2022-07-08T22:45:24 | 115,220,665 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,912 | java | import grid.copycon.Deep;
import grid.puzzlebits.Direction;
import grid.puzzlebits.Path.Path;
import grid.puzzlebits.Turns;
import grid.solverrecipes.singleloopflatten.EdgeState;
import grid.spring.GridFrame;
import grid.spring.GridPanel;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
public class Main {
private static class MyListener implements GridPanel.GridListener, GridPanel.EdgeListener{
Board b;
String[] lines;
public MyListener(Board b,String[] lines) { this.b = b; this.lines = lines; }
@Override public int getNumXCells() { return b.getWidth(); }
@Override public int getNumYCells() { return b.getHeight(); }
@Override public boolean drawGridNumbers() { return true; }
@Override public boolean drawGridLines() { return true; }
@Override public boolean drawBoundary() { return true; }
@Override public String[] getAnswerLines() { return lines; }
private static EdgeDescriptor WALL = new EdgeDescriptor(Color.BLACK,5);
private static EdgeDescriptor INSIDE = new EdgeDescriptor(Color.BLACK,1);
private EdgeDescriptor getED(int x, int y, Direction d) {
Point op = d.delta(x,y,1);
return b.getRegion(x,y) == b.getRegion(op.x,op.y) ? INSIDE : WALL;
}
@Override public EdgeDescriptor onBoundary() { return WALL; }
@Override public EdgeDescriptor toEast(int x, int y) { return getED(x,y,Direction.EAST); }
@Override public EdgeDescriptor toSouth(int x, int y) { return getED(x,y,Direction.SOUTH); }
private void drawPath(BufferedImage bi,int x,int y, Direction d) {
Graphics2D g = (Graphics2D)bi.getGraphics();
int cenx = bi.getWidth()/2;
int ceny = bi.getHeight()/2;
EdgeState es = b.getEdge(x,y,d);
int ox = -1;
int oy = -1;
switch(d) {
case NORTH: ox = cenx; oy = 0; break;
case EAST: ox = bi.getWidth(); oy = ceny; break;
case SOUTH: ox = cenx; oy = bi.getHeight(); break;
case WEST: ox = 0; oy = ceny ; break;
}
switch(es) {
case UNKNOWN: return;
case PATH:
g.setColor(Color.BLUE);
g.setStroke(new BasicStroke(5));
g.drawLine(cenx,ceny,ox,oy);
break;
case WALL:
GridPanel.DrawStringInCorner(bi,Color.RED,"X",d);
break;
}
}
@Override public boolean drawCellContents(int cx, int cy, BufferedImage bi) {
if (b.hasLetter(cx,cy)) GridPanel.DrawStringInCorner(bi,Color.BLACK,""+b.getLetter(cx,cy),Direction.NORTHWEST);
if (b.hasNumber(cx,cy)) {
Graphics2D g = (Graphics2D)bi.getGraphics();
g.setColor(Color.BLACK);
g.setFont(g.getFont().deriveFont(g.getFont().getSize() * 3.0f));
GridPanel.DrawStringInCorner(g,0,0,bi.getWidth(),bi.getHeight(),""+b.getNumber(cx,cy),Direction.NORTHWEST);
}
drawPath(bi,cx,cy,Direction.NORTH);
drawPath(bi,cx,cy,Direction.SOUTH);
drawPath(bi,cx,cy,Direction.WEST);
drawPath(bi,cx,cy,Direction.EAST);
return true;
}
}
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Bad Command Line");
System.exit(1);
}
Board b = new Board(args[0]);
String[] lines = new String[] { "", "Adalogical Aenigma", "#97 solver"};
lines[0] = b.getTitle();
Solver s = new Solver(b);
s.Solve(b);
if (s.GetSolutions().size() == 1) {
System.out.println("Solution Found");
b = s.GetSolutions().get(0);
Path p = b.getPaths().iterator().next();
Point start = new Point(0,0);
Path.Cursor cursor = p.getCursor(0,0);
if (!cursor.getNext().equals(new Point(1,0))) {
p.reverse();
cursor = p.getCursor(0,0);
}
StringBuffer sb = new StringBuffer();
for( ; !cursor.getNext().equals(start) ; cursor.next()) {
Point cp = cursor.get();
if (!b.hasLetter(cp.x,cp.y)) continue;
if (Turns.makeTurn(cursor.getPrev(),cursor.get(),cursor.getNext()) != Turns.RIGHT) continue;
sb.append(b.getLetter(cp.x,cp.y));
}
lines[1] = sb.toString();
lines[2] = b.getSolution();
}
MyListener myl = new MyListener(b,lines);
GridFrame gf = new GridFrame("Adalogical Aenigma #97 solver",1200,800,myl,myl);
}
}
| [
"[email protected]"
] | |
f3646700d8c0f1c4dd448b7b02ce7216f97b12b5 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_eff11c3a1f96e8b48830f21eb670bed372f780ec/MessageSender/8_eff11c3a1f96e8b48830f21eb670bed372f780ec_MessageSender_s.java | d8c1d82c97735d7ae70dea6f74e394aa2abf1feb | [] | 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,997 | java | package freemail;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.Enumeration;
import freemail.fcp.HighLevelFCPClient;
import freemail.utils.EmailAddress;
import freemail.utils.DateStringFactory;
public class MessageSender implements Runnable {
public static final String OUTBOX_DIR = "outbox";
private static final int MIN_RUN_TIME = 60000;
public static final String NIM_KEY_PREFIX = "KSK@freemail-nim-";
private static final int MAX_TRIES = 10;
private final File datadir;
private Thread senderthread;
public MessageSender(File d) {
this.datadir = d;
}
public void send_message(String from_user, Vector to, File msg) throws IOException {
File user_dir = new File(this.datadir, from_user);
File outbox = new File(user_dir, OUTBOX_DIR);
Enumeration e = to.elements();
while (e.hasMoreElements()) {
EmailAddress email = (EmailAddress) e.nextElement();
this.copyToOutbox(msg, outbox, email.user + "@" + email.domain);
}
this.senderthread.interrupt();
}
private void copyToOutbox(File src, File outbox, String to) throws IOException {
File tempfile = File.createTempFile("fmail-msg-tmp", null, Freemail.getTempDir());
FileOutputStream fos = new FileOutputStream(tempfile);
FileInputStream fis = new FileInputStream(src);
byte[] buf = new byte[1024];
int read;
while ( (read = fis.read(buf)) > 0) {
fos.write(buf, 0, read);
}
fis.close();
fos.close();
this.moveToOutbox(tempfile, 0, to, outbox);
}
// save a file to the outbox handling name collisions and atomicity
private void moveToOutbox(File f, int tries, String to, File outbox) {
File destfile;
int prefix = 1;
synchronized (this.senderthread) {
do {
String filename = prefix + ":" + tries + ":" + to;
destfile = new File(outbox, filename);
prefix++;
} while (destfile.exists());
f.renameTo(destfile);
}
}
public void run() {
this.senderthread = Thread.currentThread();
while (true) {
long start = System.currentTimeMillis();
// iterate through users
File[] files = this.datadir.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].getName().startsWith("."))
continue;
File outbox = new File(files[i], OUTBOX_DIR);
if (!outbox.exists())
outbox.mkdir();
this.sendDir(files[i], outbox);
}
// don't spin around the loop if nothing's
// going on
long runtime = System.currentTimeMillis() - start;
if (MIN_RUN_TIME - runtime > 0) {
try {
Thread.sleep(MIN_RUN_TIME - runtime);
} catch (InterruptedException ie) {
}
}
}
}
private void sendDir(File accdir, File dir) {
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].getName().startsWith("."))
continue;
this.sendSingle(accdir, files[i]);
}
}
private void sendSingle(File accdir, File msg) {
String parts[] = msg.getName().split(":", 3);
EmailAddress addr;
int tries;
if (parts.length < 3) {
System.out.println("Warning invalid file in outbox - deleting.");
msg.delete();
return;
} else {
tries = Integer.parseInt(parts[1]);
addr = new EmailAddress(parts[2]);
}
if (addr.domain == null || addr.domain.length() == 0) {
msg.delete();
return;
}
if (addr.is_nim_address()) {
HighLevelFCPClient cli = new HighLevelFCPClient();
if (cli.SlotInsert(msg, NIM_KEY_PREFIX+addr.user+"-"+DateStringFactory.getKeyString(), 1, "") > -1) {
msg.delete();
}
} else {
if (this.sendSecure(accdir, addr, msg)) {
msg.delete();
} else {
tries++;
if (tries > MAX_TRIES) {
if (Postman.bounceMessage(msg, new MessageBank(accdir.getName()), "Tried too many times to deliver this message, but it doesn't apear that this address even exists. If you're sure that it does, check your Freenet connection.")) {
msg.delete();
}
} else {
this.moveToOutbox(msg, tries, parts[2], msg.getParentFile());
}
}
}
}
private boolean sendSecure(File accdir, EmailAddress addr, File msg) {
System.out.println("sending secure");
OutboundContact ct;
try {
ct = new OutboundContact(accdir, addr);
} catch (BadFreemailAddressException bfae) {
// bounce
return Postman.bounceMessage(msg, new MessageBank(accdir.getName()), "The address that this message was destined for ("+addr+") is not a valid Freemail address.");
} catch (OutboundContactFatalException obfe) {
// bounce
return Postman.bounceMessage(msg, new MessageBank(accdir.getName()), obfe.getMessage());
} catch (IOException ioe) {
// couldn't get the mailsite - try again if you're not ready
//to give up yet
return false;
}
return ct.sendMessage(msg);
}
}
| [
"[email protected]"
] | |
15ce217f4cfe953d386b76c3a55636f80351dec1 | ad99a913cca71d1e0bb94854ad51cfb206eec86a | /src/main/java/jp/powerbase/xquery/expr/Doc.java | d5323316acf361cc02511a79375ec03cc1630da1 | [
"Apache-2.0"
] | permissive | powerbase/powerbase-xq | d417f0aca46ff17a9fd8c1722ffcc11fed679f38 | 6fbb1c187eaf3c2e978ee01c01adee80746cc519 | refs/heads/master | 2021-01-23T12:22:09.616590 | 2017-05-29T10:27:47 | 2017-05-29T10:27:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,137 | java | /*
* @(#)$Id: Doc.java 1087 2011-05-25 05:28:29Z hirai $
*
* Copyright 2005-2011 Infinite Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contributors:
* Toshio HIRAI - initial implementation
*/
package jp.powerbase.xquery.expr;
public class Doc implements Expr {
private String document;
public Doc(String document) {
this.document = document;
}
@Override
public String toString() {
StringBuffer doc = new StringBuffer();
doc.append("doc(\"");
doc.append(document);
doc.append("\")");
return doc.toString();
}
@Override
public String display() {
return toString();
}
}
| [
"[email protected]"
] | |
b4f115e25015818f1de05be8a6994c8275372dd3 | 62eec6735a798eded9d50840c27a73fe8b83ea7a | /src/test/java/edu/jhuapl/exterminator/grammar/coq/ContainsTest.java | 4a3e75519b95f0b181f1f1cecbed03985259a284 | [
"BSD-3-Clause"
] | permissive | jhuapl-saralab/exterminator | 49a2fb2b3f8a9e2f41d65aa6d06df40243ebdeab | 98c44e82ae8ba8c6dfa1204428581a7c9ff78f56 | refs/heads/master | 2021-01-12T11:09:27.831847 | 2016-11-04T14:25:37 | 2016-11-04T14:25:37 | 72,854,767 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,222 | java | /*
* Copyright (c) 2016, Johns Hopkins University Applied Physics
* Laboratory All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package edu.jhuapl.exterminator.grammar.coq;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.BailErrorStrategy;
import org.antlr.v4.runtime.CommonTokenStream;
import org.junit.Assert;
import org.junit.Test;
import edu.jhuapl.exterminator.grammar.coq.term.Ident;
import edu.jhuapl.exterminator.grammar.coq.term.Name;
import edu.jhuapl.exterminator.grammar.coq.term.Qualid;
import edu.jhuapl.exterminator.grammar.coq.term.Term;
public class ContainsTest {
private static CoqFTParser parser(String str) {
CoqLexer lexer = new CoqLexer(new ANTLRInputStream(str));
CoqFTParser parser = new CoqFTParser(new CommonTokenStream(lexer));
parser.setErrorHandler(new BailErrorStrategy());
return parser;
}
private static Term parseTerm(String str) {
CoqFTParser parser = parser(str);
return Term.make(parser, parser.term());
}
private static Ident parseIdent(String str) {
CoqFTParser parser = parser(str);
return new Ident(parser, parser.ident());
}
private static Name parseName(String str) {
CoqFTParser parser = parser(str);
return new Name(parser, parser.name());
}
private static Qualid parseQualid(String str) {
CoqFTParser parser = parser(str);
return new Qualid(parser, parser.qualid());
}
@Test
public void testIDEquals() {
// ident x ident
{
Ident i1 = parseIdent("a");
Ident i2 = parseIdent("a");
Assert.assertTrue(i1.equals(i2));
Assert.assertTrue(i2.equals(i1));
Ident i3 = parseIdent("b");
Assert.assertFalse(i1.equals(i3));
Assert.assertFalse(i3.equals(i1));
}
// ident x name
{
Ident i1 = parseIdent("a");
Name n1 = parseName("a");
Name n2 = parseName("b");
Name n3 = parseName("_");
Assert.assertTrue(i1.equals(n1));
Assert.assertTrue(n1.equals(i1));
Assert.assertFalse(i1.equals(n2));
Assert.assertFalse(n2.equals(i1));
Assert.assertFalse(i1.equals(n3));
Assert.assertFalse(n3.equals(i1));
Ident i2 = parseIdent("_");
Assert.assertFalse(i2.equals(n1));
Assert.assertFalse(n1.equals(i2));
Assert.assertFalse(i2.equals(n2));
Assert.assertFalse(n2.equals(i2));
Assert.assertTrue(i2.equals(n3));
Assert.assertTrue(n3.equals(i2));
}
// ident x qualid
{
Ident i1 = parseIdent("a");
Qualid q1 = parseQualid("a");
Qualid q2 = parseQualid("b");
Qualid q3 = parseQualid("a.a");
Assert.assertTrue(i1.equals(q1));
Assert.assertTrue(q1.equals(i1));
Assert.assertFalse(i1.equals(q2));
Assert.assertFalse(q2.equals(i1));
Assert.assertFalse(i1.equals(q3));
Assert.assertFalse(q3.equals(i1));
}
// name x name
{
Name n1 = parseName("_");
Name n2 = parseName("_");
Name n3 = parseName("a");
Assert.assertTrue(n1.equals(n2));
Assert.assertTrue(n2.equals(n1));
Assert.assertFalse(n1.equals(n3));
Assert.assertFalse(n3.equals(n1));
}
// name x qualid
{
Name n1 = parseName("_");
Qualid q1 = parseQualid("_");
Qualid q2 = parseQualid("a");
Qualid q3 = parseQualid("_._");
Assert.assertTrue(n1.equals(q1));
Assert.assertTrue(q1.equals(n1));
Assert.assertFalse(n1.equals(q2));
Assert.assertFalse(q2.equals(n1));
Assert.assertFalse(n1.equals(q3));
Assert.assertFalse(q3.equals(n1));
Name n2 = parseName("a");
Qualid q4 = parseQualid("a.a");
Assert.assertFalse(n2.equals(q1));
Assert.assertFalse(q1.equals(n2));
Assert.assertTrue(n2.equals(q2));
Assert.assertTrue(q2.equals(n2));
Assert.assertFalse(n2.equals(q4));
Assert.assertFalse(q4.equals(n2));
}
// qualid x qualid
{
Qualid q1 = parseQualid("a");
Qualid q2 = parseQualid("a");
Assert.assertTrue(q1.equals(q2));
Assert.assertTrue(q2.equals(q1));
Qualid q3 = parseQualid("b");
Assert.assertFalse(q1.equals(q3));
Assert.assertFalse(q3.equals(q1));
Qualid q4 = parseQualid("a.b");
Qualid q5 = parseQualid("a.b");
Assert.assertFalse(q1.equals(q4));
Assert.assertFalse(q4.equals(q1));
Assert.assertTrue(q4.equals(q5));
Assert.assertTrue(q5.equals(q4));
Qualid q6 = parseQualid("b.b");
Assert.assertFalse(q1.equals(q6));
Assert.assertFalse(q6.equals(q1));
}
}
@Test
public void testContains1() {
Term term = parseTerm("(a b c)");
Ident i = parseIdent("a");
Assert.assertNotEquals(term, i);
Assert.assertTrue(term.contains(i));
i = parseIdent("b");
Assert.assertNotEquals(term, i);
Assert.assertTrue(term.contains(i));
i = parseIdent("c");
Assert.assertNotEquals(term, i);
Assert.assertTrue(term.contains(i));
}
}
| [
"[email protected]"
] | |
1d4dc9bd13538bbf8bfa0e9d9decb64b883385a9 | 963e8a65011aa3083d58b184697253732b675a0c | /src/main/java/com/sinmin/rest/solr/SolrClient.java | 8509c171edc0041def00b7e1d8ba45a7b1eb89bc | [
"Apache-2.0"
] | permissive | DImuthuUpe/SinminREST | 835318756f0b4a9ea7b54f5bd2b1777fdbaab195 | 9f2f74071b4a869572d7f6be277a4593903db1b9 | refs/heads/master | 2016-08-04T21:23:37.925090 | 2015-02-12T21:08:49 | 2015-02-12T21:08:49 | 27,870,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 792 | java | package com.sinmin.rest.solr;
import com.sinmin.rest.beans.response.WildCardR;
import corpus.sinhala.wildcard.search.SolrWildCardSearch;
import java.util.List;
/**
* Created by dimuthuupeksha on 1/8/15.
*/
public class SolrClient {
public WildCardR[] getWildCardWords(String val){
SolrWildCardSearch solrWildCardSearch = new SolrWildCardSearch();
List<String> wordList= solrWildCardSearch.searchWord(val, true);
if(wordList!=null){
WildCardR [] wordArr = new WildCardR[wordList.size()];
for(int i=0;i<wordList.size();i++){
WildCardR resp = new WildCardR();
resp.setValue(wordList.get(i));
wordArr[i]=resp;
}
return wordArr;
}
return null;
}
}
| [
"[email protected]"
] | |
d26d58321e0b4a1a6e0d0d73af913512fbf7298a | a25b0cf7fc632540d29875bfcf0489424f6ef839 | /YiBaoTong/libDialog/src/main/java/ybt/library/dialog/bean/CCountysBean.java | 2fee3aec5860fad7082b6a2c0270c5a68a7c7707 | [] | no_license | ILoveLin/YibaoTong | 6ace12e7d829e9680097c0b0e0b59ea0ae3e7f07 | a885b90a186e1fa3413a4b2c438c0721bdf428e8 | refs/heads/master | 2021-10-28T04:49:50.532101 | 2019-04-22T06:51:34 | 2019-04-22T06:51:34 | 182,638,313 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 535 | java | package ybt.library.dialog.bean;
import java.io.Serializable;
/**
* ๅฟ็บงๅๅธ
* Created by yang on 2017/01/05.
*/
public class CCountysBean implements Serializable {
private String county;
private String county_id;
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
public String getCounty_id() {
return county_id;
}
public void setCounty_id(String county_id) {
this.county_id = county_id;
}
}
| [
"[email protected]"
] | |
a029795cd0637df5f33780893e3d76e5cf630196 | 02b38767a1e59f4014c65f3fe17fd7ae5c51b013 | /media/src/main/java/com/chuncheng/sample/media/video/manager/mssage/player/ClearAbstractPlayerInstanceMessage.java | 55b227705c009f2c54c8b9f5409b59530895ce0e | [] | no_license | zhangchuncheng/ScalableMedia | 3256d354b0c0302fcf991c2e38c8b8289be5ff8b | e6ae656ca93034ce6f5d78a6a63920d46053c30a | refs/heads/master | 2021-06-28T21:12:21.060823 | 2020-10-12T03:20:51 | 2020-10-12T03:20:51 | 137,838,034 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,290 | java | package com.chuncheng.sample.media.video.manager.mssage.player;
import com.chuncheng.sample.media.video.manager.PlayerMessageState;
import com.chuncheng.sample.media.video.manager.VideoPlayerManagerCallback;
import com.chuncheng.sample.media.video.manager.mssage.AbstractPlayerMessage;
import com.chuncheng.sample.media.video.ui.VideoPlayerView;
/**
* Description:ๆธ
้คๆญๆพๅจๅฎไพๆถๆฏ
*
* @author: zhangchuncheng
* @date: 2017/3/22
*/
public class ClearAbstractPlayerInstanceMessage extends AbstractPlayerMessage {
private PlayerMessageState mPlayerMessageState;
public ClearAbstractPlayerInstanceMessage(VideoPlayerView playerView, VideoPlayerManagerCallback callback) {
super(playerView, callback);
}
@Override
protected void performAction(VideoPlayerView videoPlayerView) {
videoPlayerView.clearPlayerInstance();
mPlayerMessageState = PlayerMessageState.PLAYER_INSTANCE_CLEARED;
}
@Override
protected PlayerMessageState stateBefore() {
return PlayerMessageState.CLEARING_PLAYER_INSTANCE;
}
@Override
protected PlayerMessageState stateAfter() {
return mPlayerMessageState;
}
@Override
protected String getName() {
return "name:ClearPlayerInstanceMessage";
}
}
| [
"[email protected]"
] | |
1f58f4c942eba456895fc92cb8b0fe37d35ad017 | b82da3ad621b7fa7be7979cdc5974321d9421baa | /app/src/main/java/cs654/secureme/SendSms.java | 1bfd14e77f9b98e37b4db9587bcd8ecd404bf559 | [] | no_license | sunil12738/SecureMe | e0d8a7347f469b3d2c88e45d7124587ee0bac7d2 | 8104b7f634649b99e259b77d778106811f99a6d7 | refs/heads/master | 2021-01-01T05:22:45.103461 | 2016-04-29T03:21:04 | 2016-04-29T03:21:04 | 55,978,731 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,071 | java | package cs654.secureme;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.telephony.SmsManager;
import android.util.Log;
import android.widget.Toast;
/**
* Created by ViPul Sublaniya on 20-03-2016.
*/
public class SendSms {
Context context;
SharedPreferences sharedPreferences;
String phoneNo;
double latitude,longitude;
public SendSms(Context context) {
this.context = context;
}
protected void sendSMSMessage(String message, String phoneNo) {
Log.i("Send SMS", "");
// String phoneNo = "8560057004";
// sharedPreferences = context.getSharedPreferences("details", Context.MODE_PRIVATE);
// phoneNo = sharedPreferences.getString("helpMobile", "");
// GPS gps = new GPS(context);
// if (gps.canGetLocation()) {
// latitude = gps.getLatitude();
// longitude = gps.getLongitude();
// }
//
// String message = "i'm in trouble, help me at GPS location. Lat= "+latitude+" and Long= "+longitude;
try {
String SENT = "SMS_SENT";
PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT), 0);
context.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
int resultCode = getResultCode();
switch (resultCode) {
case Activity.RESULT_OK:
Toast.makeText(context, "SMS sent", Toast.LENGTH_LONG).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(context, "Generic failure", Toast.LENGTH_LONG).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(context, "No service", Toast.LENGTH_LONG).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(context, "Null PDU", Toast.LENGTH_LONG).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(context, "Radio off", Toast.LENGTH_LONG).show();
break;
}
}
}, new IntentFilter(SENT));
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(phoneNo, null, message, sentPI, null);
} catch (Exception e) {
Toast.makeText(context, e.getMessage() + "!\n" + "Failed to send SMS", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
7caf463518b0bedca86ad5cd9e4093686a3519f2 | d62222fea603c20b52318e1a0e9d964610b3cb76 | /inventory/src/test/java/com/inventory/InventoryApplicationTests.java | 511f88af929e0bee6a9f95ecf93eb7942b41ba20 | [] | no_license | dubidamdam/EAI_Shop | 09874116559c69844ca06f284b12dcb04ac82752 | 2a094b73e3c8af4b8e006e59742459e4233448ce | refs/heads/master | 2020-04-11T12:33:30.681956 | 2018-12-17T10:14:43 | 2018-12-17T10:14:43 | 161,784,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 342 | java | package com.inventory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class InventoryApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
a80cbd033413b4f362fd6a19a547ac4837213a04 | 1695529661fbcd37aba21493153393b78a146f68 | /Utilkhh/src/khh/db/connection/pool/ConnectionQueue.java | 40bcab47bb22e681721b69545d9406081855a46b | [] | no_license | visualkhh/lib-java | b3d33ac72b2c7d1923b580cde53a7ba7b94aa3c7 | 54a832881b58f7378b403be95be39dc8d6e66349 | refs/heads/master | 2021-06-11T18:27:21.846677 | 2016-11-04T00:39:55 | 2016-11-04T00:39:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,092 | java | package khh.db.connection.pool;
import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import khh.db.connection.ConnectionCreator_I;
import khh.debug.LogK;
public class ConnectionQueue extends Thread{
private int min = 1;
private int max = 10;
private long pollTimeoutms = 10000;
private ConnectionCreator_I creator;
private ArrayList<ConnectionPool_Connection> storege;
private LinkedBlockingQueue<ConnectionPool_Connection> queue;
private LogK log = LogK.getInstance();
public ConnectionQueue(ConnectionCreator_I creator, int max) {
this.creator = creator;
this.max = max;
init();
}
private void init() {
storege = new ArrayList<ConnectionPool_Connection>();
queue = new LinkedBlockingQueue<ConnectionPool_Connection>();
try {
storege.add(new ConnectionPool_Connection(getCreator().getMakeConnection()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public int getMin() {
return min;
}
public void setMin(int min) {
this.min = min;
}
public int getMax() {
return max;
}
public void setMax(int max) {
this.max = max;
}
public ConnectionCreator_I getCreator() {
return creator;
}
public void setCreator(ConnectionCreator_I creator) {
this.creator = creator;
}
public long getPollTimeoutms() {
return pollTimeoutms;
}
public void setPollTimeoutms(long pollTimeoutms) {
this.pollTimeoutms = pollTimeoutms;
}
public void run() {
//๊ณ์๋๋ฉด์ ๋ฃ์ด์ค์ผํจ
while(true){
try {Thread.sleep(100);} catch (InterruptedException e1) {e1.printStackTrace();}
for (int i = 0; i < storege.size(); i++){ //์ฌ์ฉ๊ฐ๋ฅํ๊ฒ์ด ์์๋ queue์ ๋ฃ๋๋ค.
try{
ConnectionPool_Connection c = storege.get(i);
//log.debug("Connection State:"+c+" storege.size("+storege.size()+") qsize:"+queue.size());
if(c.isClosed()){ //์ฌ์ฉ๊ฐ๋ฅํ๊ฒ์ด ์์๋ queue์ ๋ฃ๋๋ค.
c.open();
if(!queue.contains(c)){
queue.put(c);
log.debug("move BlockingQueue("+c+") storege.size("+storege.size()+") qsize:"+queue.size());
}
};
if(storege.size()<max && queue.size()<=0){
try {
storege.add(new ConnectionPool_Connection(getCreator().getMakeConnection()));
log.debug("Full Busy storege.size("+storege.size()+") qsize:"+queue.size()+" (setting -> min:"+getMin()+", max:"+getMax()+") -> add one Connection Create");
} catch (Exception e) {e.printStackTrace();}
}
}catch(Exception e){log.debug("queue Error",e);}
}
}
}
public ConnectionPool_Connection poll() throws InterruptedException{
return poll(getPollTimeoutms());
}
public ConnectionPool_Connection poll(long pollTimeoutms) throws InterruptedException {
ConnectionPool_Connection i = queue.poll(pollTimeoutms, TimeUnit.MILLISECONDS);
if(null==i){
log.debug("getConnection TimeOut wite mills: "+pollTimeoutms);
}
return i;
}
}
| [
"[email protected]"
] | |
a619af244a3e4c8f0be8b7f48519fe068d2f1bc2 | 23e01ee3ce3aa0857ce5987baaed8af99a3b5da2 | /user-services-basic/src/main/java/com/lgmn/userservices/basic/entity/LgmnFormControlPropsEntity.java | 3febc544d4d38af4f92909f90385e65cedc1b8e2 | [] | no_license | uma-511/lgmn-user-services | 0c23d468a033b4e91cf0c9b87f519f8f04c68276 | d65844aadc6e7f7ab683acd9031287ff512be0f1 | refs/heads/master | 2023-01-07T11:45:18.064793 | 2020-01-17T07:40:34 | 2020-01-17T07:40:34 | 312,195,788 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,775 | java | package com.lgmn.userservices.basic.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "lgmn_form_control_props", schema = "lgmn_user_services", catalog = "")
public class LgmnFormControlPropsEntity {
private int id;
private int lfcId;
private String key;
private String value;
private String type;
private String group;
private Integer multilang;
private Integer langId;
@Id
@Column(name = "id", nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Basic
@Column(name = "lfc_id", nullable = false)
public int getLfcId() {
return lfcId;
}
public void setLfcId(int lfcId) {
this.lfcId = lfcId;
}
@Basic
@Column(name = "key", nullable = false, length = 20)
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Basic
@Column(name = "value", nullable = true, length = 20)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Basic
@Column(name = "type", nullable = true, length = 20)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Basic
@Column(name = "group", nullable = true, length = 20)
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
@Basic
@Column(name = "multilang", nullable = true)
public Integer getMultilang() {
return multilang;
}
public void setMultilang(Integer multilang) {
this.multilang = multilang;
}
@Basic
@Column(name = "lang_id", nullable = true)
public Integer getLangId() {
return langId;
}
public void setLangId(Integer langId) {
this.langId = langId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LgmnFormControlPropsEntity that = (LgmnFormControlPropsEntity) o;
return id == that.id &&
lfcId == that.lfcId &&
Objects.equals(key, that.key) &&
Objects.equals(value, that.value) &&
Objects.equals(type, that.type) &&
Objects.equals(group, that.group) &&
Objects.equals(multilang, that.multilang) &&
Objects.equals(langId, that.langId);
}
@Override
public int hashCode() {
return Objects.hash(id, lfcId, key, value, type, group, multilang, langId);
}
} | [
"[email protected]"
] | |
c287d7a9aba4b08cde2f369fbb941f4a1fdfc827 | 534cd1ab7f20195bd101292c78a0301bc5b03dbe | /sop-framework/src/main/java/dwz/common/util/MD5Util.java | 4276a9982715c822e7558936b22e10f895253ecb | [
"Apache-2.0"
] | permissive | masonleung2016/sop | 83fb060622049a1c17f551576897d570bc0bf547 | 1f8629300ad164cb2940de04895b9b0b858d0d95 | refs/heads/master | 2022-12-27T01:37:13.917959 | 2020-05-11T13:05:40 | 2020-05-11T13:05:40 | 232,734,542 | 1 | 0 | Apache-2.0 | 2022-12-16T01:21:51 | 2020-01-09T06:03:32 | Java | UTF-8 | Java | false | false | 2,492 | java | package dwz.common.util;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.security.MessageDigest;
/**
* @Author: LCF
* @Date: 2020/1/8 16:03
* @Package: dwz.common.util
*/
public class MD5Util {
public static String MD5(String s) {
if (StringUtils.isEmpty(s) || StringUtils.isBlank(s)) {
return null;
}
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F'};
try {
byte[] btInput = s.getBytes();
MessageDigest mdInst = MessageDigest.getInstance("MD5");
mdInst.update(btInput);
byte[] md = mdInst.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
return null;
}
}
public static String getHashCode(Object object) throws IOException {
if (object == null) return "";
String ss = null;
ObjectOutputStream s = null;
ByteArrayOutputStream bo = new ByteArrayOutputStream();
try {
s = new ObjectOutputStream(bo);
s.writeObject(object);
s.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (s != null) {
s.close();
s = null;
}
}
ss = MD5(bo.toString());
return ss;
}
public static void main(String[] args) {
String str = "serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)serviceLocator = getDefaultClassLoader().loadClass(SERVICE_LOCATOR_CLASS)";
System.out.println(MD5(str));
}
}
| [
"[email protected]"
] | |
b12eb117ed3d36d297cb16e89218901e98d510ca | d9d882893fc26c1c45a525087f00c10a9ea02fb3 | /src/Demo/GetTupleFromRelationIterator.java | 71de59bbb4222685217508c608c9e1761f2757cd | [] | no_license | gbkjunior/SortingToCyDIW | 1e38203aa228453a5349588dbcd68b5713c0c426 | 7cd11fffb157bb15f41a72e57bfcae0b55e4fbe5 | refs/heads/master | 2021-05-01T20:11:49.948261 | 2018-02-09T22:42:05 | 2018-02-09T22:42:05 | 120,961,295 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,763 | java | package Demo;
import java.io.File;
import java.nio.ByteBuffer;
import PTCFramework.ProducerIterator;
import StorageManager.Storage;
import storagemanager.StorageConfig;
import storagemanager.StorageUtils;
import cysystem.diwGUI.gui.*;
import cycsx.csxpagination.util.Constant;
import storagemanager.StorageConfig;
import storagemanager.FileStorageManager;
import storagemanager.StorageManagerClient;
import storagemanager.StorageDirectoryDocument;
public class GetTupleFromRelationIterator implements ProducerIterator<byte []>{
String filename;
int tuplelength;
int currentpage;
int count = 0;
int nextPage;
int numbytesread;
int pagesize;
Storage s;
byte[] mainbuffer;
private StorageManagerClient xmlClient;
public GetTupleFromRelationIterator(String filename, int tuplelength, int currentpage){
this.filename = filename;
this.tuplelength = tuplelength;
this.nextPage = currentpage;
}
public void open() throws Exception{
s = new Storage();
//s.LoadStorage(filename);
StorageUtils su = new StorageUtils();
String fileName ="StorageConfig.xml" ;
File fStorageConfig = new File(fileName);
if (!fStorageConfig.exists()) {
System.out.println("Please make sure storage config exists");
}
// Please remember to set storageConfig first before createStorage and useStorage
StorageConfig temp = new StorageConfig(fStorageConfig);
su.loadStorage(temp);
this.pagesize = s.pageSize;
}
public void checkNextPage() throws Exception{
if(nextPage!=-1){
currentpage = nextPage;
byte[] buffer = new byte[pagesize];
//s.ReadPage(currentpage, buffer);
xmlClient.readPagewithoutPin(currentpage);
mainbuffer = buffer;
numbytesread = 8;
int size = 4;
byte[] countval = new byte[size];
for(int i=0; i<4; i++){
countval[i] = buffer[i];
}
count = ByteBuffer.wrap(countval).getInt();
for(int i=0; i<4; i++){
countval[i] = buffer[i+4];
}
nextPage = ByteBuffer.wrap(countval).getInt();
}
}
public boolean hasNext(){
if(count<=0){
try {
checkNextPage();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(count>0){
return true;
}
else{
return false;
}
}
return true;
}
public void prinnext(){
System.out.println(count);
count--;
}
public byte[] next(){
byte[] res = new byte[tuplelength];
for(int i=0; i<tuplelength; i++){
res[i] = mainbuffer[numbytesread+i];
}
numbytesread+=tuplelength;
count--;
return res;
}
@Override
public void close() throws Exception {
// TODO Auto-generated method stub
}
} | [
"[email protected]"
] | |
7cefe022a937ea8541beee2cbc90ea1c6834c65e | 75c4fbd316738f0bf1dcc350c8bfbcac4f94e68b | /luna-core/src/main/java/com/thrashplay/luna/math/Vector2D.java | 08dcc062c926397f16bceaebc2abd9da053b3dc3 | [] | no_license | skleinjung-archive/luna | 9793f4772b489231033d76158fdcc6ff4c5a34f8 | b880c71f10ed5bbf3370cc570a7310734a0a7111 | refs/heads/master | 2020-03-13T03:08:38.377112 | 2018-05-02T17:06:16 | 2018-05-02T17:06:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package com.thrashplay.luna.math;
/**
* TODO: Add class documentation
*
* @author Sean Kleinjung
*/
public class Vector2D {
private double x;
private double y;
public Vector2D() {
}
public Vector2D(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
| [
"[email protected]"
] | |
a884d95899c0e3aaf86cbf0b504548b4efe176c0 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /dds-20151201/src/main/java/com/aliyun/dds20151201/models/ModifyDBInstanceConnectionStringRequest.java | 579fc2c95a48bc8d3ca39d97ebca07a0be58eab2 | [
"Apache-2.0"
] | permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 4,672 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.dds20151201.models;
import com.aliyun.tea.*;
public class ModifyDBInstanceConnectionStringRequest extends TeaModel {
/**
* <p>The current connection string, which is to be modified.</p>
*/
@NameInMap("CurrentConnectionString")
public String currentConnectionString;
/**
* <p>The ID of the instance.</p>
* <br>
* <p>> If you set this parameter to the ID of a sharded cluster instance, you must also specify the **NodeId** parameter.</p>
*/
@NameInMap("DBInstanceId")
public String DBInstanceId;
/**
* <p>The new connection string. It must be 8 to 64 characters in length and can contain letters and digits. It must start with a lowercase letter.</p>
* <br>
* <p>> You need only to specify the prefix of the connection string. The content other than the prefix cannot be modified.</p>
*/
@NameInMap("NewConnectionString")
public String newConnectionString;
/**
* <p>this parameter can be used. The new port should be within the range of 1000 to 65535.</p>
* <p>>When the DBInstanceId parameter is passed in as a cloud disk instance ID</p>
*/
@NameInMap("NewPort")
public Integer newPort;
/**
* <p>The ID of the mongos in the specified sharded cluster instance. Only one mongos ID can be specified in each call.</p>
* <br>
* <p>> This parameter is valid only if you set the **DBInstanceId** parameter to the ID of a sharded cluster instance.</p>
*/
@NameInMap("NodeId")
public String nodeId;
@NameInMap("OwnerAccount")
public String ownerAccount;
@NameInMap("OwnerId")
public Long ownerId;
@NameInMap("ResourceOwnerAccount")
public String resourceOwnerAccount;
@NameInMap("ResourceOwnerId")
public Long resourceOwnerId;
@NameInMap("SecurityToken")
public String securityToken;
public static ModifyDBInstanceConnectionStringRequest build(java.util.Map<String, ?> map) throws Exception {
ModifyDBInstanceConnectionStringRequest self = new ModifyDBInstanceConnectionStringRequest();
return TeaModel.build(map, self);
}
public ModifyDBInstanceConnectionStringRequest setCurrentConnectionString(String currentConnectionString) {
this.currentConnectionString = currentConnectionString;
return this;
}
public String getCurrentConnectionString() {
return this.currentConnectionString;
}
public ModifyDBInstanceConnectionStringRequest setDBInstanceId(String DBInstanceId) {
this.DBInstanceId = DBInstanceId;
return this;
}
public String getDBInstanceId() {
return this.DBInstanceId;
}
public ModifyDBInstanceConnectionStringRequest setNewConnectionString(String newConnectionString) {
this.newConnectionString = newConnectionString;
return this;
}
public String getNewConnectionString() {
return this.newConnectionString;
}
public ModifyDBInstanceConnectionStringRequest setNewPort(Integer newPort) {
this.newPort = newPort;
return this;
}
public Integer getNewPort() {
return this.newPort;
}
public ModifyDBInstanceConnectionStringRequest setNodeId(String nodeId) {
this.nodeId = nodeId;
return this;
}
public String getNodeId() {
return this.nodeId;
}
public ModifyDBInstanceConnectionStringRequest setOwnerAccount(String ownerAccount) {
this.ownerAccount = ownerAccount;
return this;
}
public String getOwnerAccount() {
return this.ownerAccount;
}
public ModifyDBInstanceConnectionStringRequest setOwnerId(Long ownerId) {
this.ownerId = ownerId;
return this;
}
public Long getOwnerId() {
return this.ownerId;
}
public ModifyDBInstanceConnectionStringRequest setResourceOwnerAccount(String resourceOwnerAccount) {
this.resourceOwnerAccount = resourceOwnerAccount;
return this;
}
public String getResourceOwnerAccount() {
return this.resourceOwnerAccount;
}
public ModifyDBInstanceConnectionStringRequest setResourceOwnerId(Long resourceOwnerId) {
this.resourceOwnerId = resourceOwnerId;
return this;
}
public Long getResourceOwnerId() {
return this.resourceOwnerId;
}
public ModifyDBInstanceConnectionStringRequest setSecurityToken(String securityToken) {
this.securityToken = securityToken;
return this;
}
public String getSecurityToken() {
return this.securityToken;
}
}
| [
"[email protected]"
] | |
3b3f2467813be7bfa17c39bfaa78bac89c7b6e7d | 4d37505edab103fd2271623b85041033d225ebcc | /spring-aop/src/main/java/org/springframework/aop/target/PoolingConfig.java | d8a1dbe05b484de9aad9db610a61514e7ff857ff | [
"Apache-2.0"
] | permissive | huifer/spring-framework-read | 1799f1f073b65fed78f06993e58879571cc4548f | 73528bd85adc306a620eedd82c218094daebe0ee | refs/heads/master | 2020-12-08T08:03:17.458500 | 2020-03-02T05:51:55 | 2020-03-02T05:51:55 | 232,931,630 | 6 | 2 | Apache-2.0 | 2020-03-02T05:51:57 | 2020-01-10T00:18:15 | Java | UTF-8 | Java | false | false | 1,323 | java | /*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.aop.target;
/**
* Config interface for a pooling target source.
*
* @author Rod Johnson
* @author Juergen Hoeller
*/
public interface PoolingConfig {
/**
* Return the maximum size of the pool.
*/
int getMaxSize();
/**
* Return the number of active objects in the pool.
*
* @throws UnsupportedOperationException if not supported by the pool
*/
int getActiveCount() throws UnsupportedOperationException;
/**
* Return the number of idle objects in the pool.
*
* @throws UnsupportedOperationException if not supported by the pool
*/
int getIdleCount() throws UnsupportedOperationException;
}
| [
"[email protected]"
] | |
ae157c7d106e13e9b661b62bf43ce67ad333134c | 5eff90f7e633de76216e0dff9a0b5440d1e9ad5a | /E3.java | f936b8d745015e24cd36c98d277bb43519659bb5 | [] | no_license | amarulandap/Java_Semana2 | 07e504510431195896ff9681c90bb24485abaf3a | 6a58cb3af9c6a16f8698d917a01ab11abcc679d7 | refs/heads/main | 2023-07-12T06:55:58.977418 | 2021-08-11T15:55:35 | 2021-08-11T15:55:35 | 395,043,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 702 | java | package com.andres_marulanda.ejercicios_semana_2;
//@author Andres Marulanda
public class E3 {
//@param args the command line arguments
public static void main(String[] args) {
int [] vectorEntrada = {-8, 11, 13, 79, -2, 1};
double promedio = mean(vectorEntrada);
System.out.println("El promedio de los valores es: "+ promedio);
}
public static double mean(int [] vector){
double suma = 0.0;
double promedio;
for (int i=0; i<vector.length; i++){
suma += vector[i];
}
promedio = suma / vector.length;
return promedio;
}
}
| [
"[email protected]"
] | |
df26831c3aa5d2d41d95c76647f090a35311aec1 | fee4b7ff8a9172541639f280bbe52cc739d3a9c7 | /1_Gloves.java | d85b962fafa02922855a92dc694c3f96e9fd5228 | [] | no_license | andli0626/CodeEveryday | 2aa67c9953433378af2eb5e6732effbdd022c448 | 6d54e3af8c8077614a0b5f33dd4e6b5d22da225d | refs/heads/master | 2020-12-25T11:52:32.827465 | 2016-05-10T12:58:54 | 2016-05-10T12:58:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,344 | java | import java.util.*;
public class Gloves {
public static int findMinimum(int n, int[] left, int[] right) {
// write code here
int selectNum = 0;
if(n==0||left==null||right==null||left.length==0||right.length==0)
return selectNum;
int tmpSelectNum = 0;
tmpSelectNum = findOneColorCost(left,right)+getAllColorCost(left,right);
selectNum = findOneColorCost(right,left)+getAllColorCost(right,left);
if(tmpSelectNum<selectNum)
return tmpSelectNum;
return selectNum;
}
public static int findOneColorCost(int[] array1,int[] array2){
int cost = 0;
for(int i=0; i<array1.length; i++)
if(array2[i]==0)
cost += array1[i];
cost++;
return cost;
}
public static int getAllColorCost(int[] array1,int[] array2){
int min = -1;
int cost = 0;
for(int j=0; j<array1.length; j++){
if(min==-1&&array2[j]!=0)
min = array2[j];
else if(min!=-1&&array2[j]<min&&array2[j]!=0)
min = array2[j];
cost += array2[j];
}
if(min>1)
cost = cost - min + 1;
return cost;
}
public static void main(String[] args){
int [] left = {1,2,0,1,3,1};
int [] right= {0,0,0,2,0,1};
System.out.println(findMinimum(6,left,right));
}
} | [
"[email protected]"
] | |
1e62efb3d0fbd0ef9d6ab8252df22462be1e7a13 | d096f3647e0706da9374d45b89895cfc7980816a | /fherdelpino/src/com/example/fherdelpino/FherdelpinoServlet.java | 5a3d2c5a8af7ecda66c778c90b1a83adebf9e844 | [] | no_license | lalitnandandiwakar/fherdelpino-project | a9187aa21266709b2c1f4fe39e5744d69d7df39e | ada3b97fd70217ac96d0017c07cd0c11f808a120 | refs/heads/master | 2021-01-01T17:32:15.156206 | 2015-03-13T23:12:42 | 2015-03-13T23:12:42 | 37,964,754 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,967 | java | package com.example.fherdelpino;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.servlet.http.*;
import com.example.datastore.jdo.PMF;
import com.example.datastore.jdo.entities.Greeting;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Query;
@SuppressWarnings("serial")
public class FherdelpinoServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key guestbookKey = KeyFactory.createKey("Guestbook", "default");
// Run an ancestor query to ensure we see the most up-to-date
// view of the Greetings belonging to the selected Guestbook.
Query query = new Query("Greeting", guestbookKey).addSort("date", Query.SortDirection.DESCENDING);
List<Entity> greetings = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(10000));
// for (Entity greeting : greetings) {
// System.out.println(greeting.getProperty("user"));
// System.out.println(greeting.getProperty("content"));
// System.out.println(greeting.getProperty("date"));
//
// }
PersistenceManager pm = PMF.get().getPersistenceManager();
Key k = KeyFactory.createKey(Greeting.class.getSimpleName(), "[email protected]");
Object o = pm.getObjectsById(guestbookKey, 4573968371548160l);
// for(Object o : list) {
// System.out.println( o);
// }
}
}
| [
"[email protected]"
] | |
80795f2f5a5c84598f867e30c78a1ffd54e9b13b | 5dee48937a738bebbc5b6d4bda1175c954dbc4bc | /src/main/java/org/semux/gui/model/WalletDelegate.java | 53607359985813ccb0d296d96da39d9b34c5e004 | [
"MIT"
] | permissive | pelenthium/semux | 93e7472031d01bee763cacee1b94564621e4a9b3 | 174cd0460978020448862ddcda730ef2ae23dda1 | refs/heads/master | 2021-05-07T00:13:58.616152 | 2017-11-09T04:29:01 | 2017-11-09T04:29:01 | 110,088,883 | 0 | 0 | null | 2017-11-09T08:37:45 | 2017-11-09T08:37:44 | null | UTF-8 | Java | false | false | 1,364 | java | package org.semux.gui.model;
import org.semux.core.state.Delegate;
public class WalletDelegate extends Delegate {
protected long votesFromMe;
protected long numberOfBlocksForged;
protected long numberOfTurnsHit;
protected long numberOfTurnsMissed;
public WalletDelegate(Delegate d) {
super(d.getAddress(), d.getName(), d.getRegisteredAt(), d.getVotes());
}
public long getVotesFromMe() {
return votesFromMe;
}
public void setVotesFromMe(long votesFromMe) {
this.votesFromMe = votesFromMe;
}
public long getNumberOfBlocksForged() {
return numberOfBlocksForged;
}
public void setNumberOfBlocksForged(long numberOfBlocksForged) {
this.numberOfBlocksForged = numberOfBlocksForged;
}
public long getNumberOfTurnsHit() {
return numberOfTurnsHit;
}
public void setNumberOfTurnsHit(long numberOfTurnsHit) {
this.numberOfTurnsHit = numberOfTurnsHit;
}
public long getNumberOfTurnsMissed() {
return numberOfTurnsMissed;
}
public void setNumberOfTurnsMissed(long numberOfTurnsMissed) {
this.numberOfTurnsMissed = numberOfTurnsMissed;
}
public double getRate() {
long total = numberOfTurnsHit + numberOfTurnsMissed;
return total == 0 ? 0 : numberOfTurnsHit * 100.0 / total;
}
}
| [
"[email protected]"
] | |
84cb807c6001c6506ad88307ce4856d05b0676c4 | 4b9cbe7cc1cbe526454788aecbb2499cc59f0c8a | /support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/audit/SamlRequestAuditResourceResolver.java | c032ae00ae02c1cd61cd28bef29b92092d4cf2a7 | [
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | jimmytheneutrino/cas | e631b5ef878bfff2fdede7f596688f6f2b9ac8ae | 1a200a7122a343d3e463ff02872c49079e5dae0f | refs/heads/master | 2019-07-11T13:46:08.499721 | 2018-07-04T16:18:25 | 2018-07-04T16:18:25 | 114,123,654 | 0 | 0 | Apache-2.0 | 2018-07-04T16:18:26 | 2017-12-13T13:23:07 | Java | UTF-8 | Java | false | false | 2,251 | java | package org.apereo.cas.support.saml.web.idp.audit;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.tuple.Pair;
import org.apereo.inspektr.audit.spi.support.ReturnValueAsStringResourceResolver;
import org.aspectj.lang.JoinPoint;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.saml2.core.AuthnRequest;
import org.opensaml.saml.saml2.core.LogoutRequest;
/**
* This is {@link SamlRequestAuditResourceResolver}.
*
* @author Misagh Moayyed
* @since 5.3.0
*/
@Slf4j
public class SamlRequestAuditResourceResolver extends ReturnValueAsStringResourceResolver {
@Override
public String[] resolveFrom(final JoinPoint joinPoint, final Object returnValue) {
if (returnValue instanceof Pair) {
return getAuditResourceFromSamlRequest((Pair) returnValue);
}
return new String[]{};
}
private String[] getAuditResourceFromSamlRequest(final Pair result) {
final var returnValue = (XMLObject) result.getLeft();
if (returnValue instanceof AuthnRequest) {
return getAuditResourceFromSamlAuthnRequest((AuthnRequest) returnValue);
}
if (returnValue instanceof LogoutRequest) {
return getAuditResourceFromSamlLogoutRequest((LogoutRequest) returnValue);
}
return new String[]{};
}
private String[] getAuditResourceFromSamlLogoutRequest(final LogoutRequest returnValue) {
final var request = returnValue;
final var result =
new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE)
.append("issuer", request.getIssuer().getValue())
.toString();
return new String[]{result};
}
private String[] getAuditResourceFromSamlAuthnRequest(final AuthnRequest returnValue) {
final var request = returnValue;
final var result =
new ToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE)
.append("issuer", request.getIssuer().getValue())
.append("binding", request.getProtocolBinding())
.toString();
return new String[]{result};
}
}
| [
"[email protected]"
] | |
526513648436186f76bfd690afe1349b1edc419a | fdb4954bf2e93279f7ca0970a3f84a73accb064e | /src/ProductOfMinAndMax.java | cde690940cb3db461de1d55aadcb11f6d4e3528f | [] | no_license | tejas910/Competative-Programs | 6629a55e42be2ed028c3f42304dc3e9b43957d36 | 138439fb84ca711a228fc3cfb0dce3c33f99ba1f | refs/heads/master | 2023-08-15T09:59:23.036606 | 2021-10-15T09:31:20 | 2021-10-15T09:31:20 | 417,442,859 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | java | import java.util.*;
public class ProductOfMinAndMax {
public static void main(String[] args) {
int arr[] = {5, 7, 9, 3, 6, 2};
int arr1[] = {1, 2, 6, -1, 0, 9};
Arrays.sort(arr);
Arrays.sort(arr1);
int max = arr[arr.length-1];
int min = arr1[0];
long pro = max * min;
System.out.println(pro);
}
}
| [
"[email protected]"
] | |
5a3828e48306394bab45fb5af3e536b3d19e4c93 | c27a9ab18791cbcd5b99f24a90c9d33b02b84d99 | /src/main/java/io/github/juliandresbv/jhipster/mg/application/config/CloudDatabaseConfiguration.java | 7bd46af262ad26404e94a7ee79f4cfad833f89fe | [] | no_license | juliandresbv/JHMicroservicesGatewayApplication | 4f31241a50244d5773bf6641846fa53acdbd4f4f | ba958edf54166d27e365e4d886c26251bd25ecdf | refs/heads/master | 2021-08-23T11:16:32.627612 | 2017-12-04T17:04:09 | 2017-12-04T17:04:09 | 113,070,651 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,153 | java | package io.github.juliandresbv.jhipster.mg.application.config;
import com.github.mongobee.Mongobee;
import io.github.jhipster.config.JHipsterConstants;
import io.github.jhipster.domain.util.JSR310DateConverters.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cloud.Cloud;
import org.springframework.cloud.CloudException;
import org.springframework.cloud.config.java.AbstractCloudConfig;
import org.springframework.cloud.service.ServiceInfo;
import org.springframework.cloud.service.common.MongoServiceInfo;
import org.springframework.context.annotation.*;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.CustomConversions;
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableMongoRepositories("io.github.juliandresbv.jhipster.mg.application.repository")
@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
public class CloudDatabaseConfiguration extends AbstractCloudConfig {
private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);
@Bean
public MongoDbFactory mongoFactory() {
return connectionFactory().mongoDbFactory();
}
@Bean
public LocalValidatorFactoryBean validator() {
return new LocalValidatorFactoryBean();
}
@Bean
public ValidatingMongoEventListener validatingMongoEventListener() {
return new ValidatingMongoEventListener(validator());
}
@Bean
public CustomConversions customConversions() {
List<Converter<?, ?>> converterList = new ArrayList<>();
converterList.add(DateToZonedDateTimeConverter.INSTANCE);
converterList.add(ZonedDateTimeToDateConverter.INSTANCE);
return new CustomConversions(converterList);
}
@Bean
public Mongobee mongobee(MongoDbFactory mongoDbFactory, MongoTemplate mongoTemplate, Cloud cloud) {
log.debug("Configuring Cloud Mongobee");
List<ServiceInfo> matchingServiceInfos = cloud.getServiceInfos(MongoDbFactory.class);
if (matchingServiceInfos.size() != 1) {
throw new CloudException("No unique service matching MongoDbFactory found. Expected 1, found "
+ matchingServiceInfos.size());
}
MongoServiceInfo info = (MongoServiceInfo) matchingServiceInfos.get(0);
Mongobee mongobee = new Mongobee(info.getUri());
mongobee.setDbName(mongoDbFactory.getDb().getName());
mongobee.setMongoTemplate(mongoTemplate);
// package to scan for migrations
mongobee.setChangeLogsScanPackage("io.github.juliandresbv.jhipster.mg.application.config.dbmigrations");
mongobee.setEnabled(true);
return mongobee;
}
}
| [
"[email protected]"
] | |
7de1f2bec65e56cbf0ea3c5187b5bd6c0f3e25f7 | 8e24c354edf308a9fa48aa61ea15b489c65a4d1e | /src/main/java/com/neusoft/controller/TranTestController.java | fdc3f16f9c09e32c4afb98f62d4785416ee775d5 | [] | no_license | huang0843/powermanager | d7934ca4b1419b50bf02bde8a4604c7009846653 | 6d8d488fe1dc47b46ed2b4fa29fdec9890aa31de | refs/heads/master | 2022-12-26T17:14:24.860785 | 2020-02-29T03:11:46 | 2020-02-29T03:11:46 | 217,663,346 | 0 | 0 | null | 2022-12-16T05:46:46 | 2019-10-26T05:59:14 | JavaScript | UTF-8 | Java | false | false | 788 | java | package com.neusoft.controller;
import com.neusoft.bean.Manager;
import com.neusoft.service.IManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("index")
public class TranTestController {
@Autowired
private IManagerService service;
@ResponseBody
@RequestMapping("test1")
public Object test1(Manager manager){
service.saveManager(manager);
return manager;
}
@ResponseBody
@RequestMapping("test2")
public Object test2(Manager manager){
service.saveManager2(manager);
return manager;
}
}
| [
"[email protected]"
] | |
04991e85867009cfbfb3db3291dce069a3f9d351 | 648e697be9b56cb50aa1b455dcc1d2f6cfef099b | /src/main/java/fr/tolan/safetynetalerts/exceptions/CustomizedResponseEntityExceptionHandler.java | c28c827e75ebd87118b23c5bad98f297b4685243 | [] | no_license | xTbeniaminTx/SafetyNet-Alerts | b3d3cb7d6c66e5391b7b25e71652f96e5420a6ac | 9622381d4579a5f43c92f72657497919e70108cf | refs/heads/main | 2023-05-09T14:47:02.566531 | 2021-05-29T21:38:09 | 2021-05-29T21:38:09 | 370,968,274 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,883 | java | package fr.tolan.safetynetalerts.exceptions;
import java.util.Date;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
@ControllerAdvice
@RestController
public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(Exception.class)
public final ResponseEntity<Object> handleAllExceptions(Exception ex, WebRequest request) {
ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(),
request.getDescription(false));
return new ResponseEntity(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);
}
@ExceptionHandler(PersonNotFoundException.class)
public final ResponseEntity<Object> handlePersonNotFoundException(PersonNotFoundException ex, WebRequest request) {
ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), ex.getMessage(),
request.getDescription(false));
return new ResponseEntity(exceptionResponse, HttpStatus.NOT_FOUND);
}
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
HttpHeaders headers, HttpStatus status, WebRequest request) {
ExceptionResponse exceptionResponse = new ExceptionResponse(new Date(), "Validation Failed",
ex.getBindingResult().toString());
return new ResponseEntity(exceptionResponse, HttpStatus.BAD_REQUEST);
}
}
| [
"[email protected]"
] | |
f018af0791428a9e41dffc5e893058473d15f4ff | dac6b7b31fc729d566d391f5d99c9756e3d3ca5a | /src/test/java/com/library/customerinfo/CustomerinfoApplicationTests.java | f1335c82bb47477b61b7358242154c2cac3a6b05 | [] | no_license | Akhil1905/SpringProject | 0d0434fa20a00273c87d33abdbce038d120c31dc | b189f45ac3b0c4ffcbaa1e0ddc858a21a9093783 | refs/heads/main | 2023-03-08T23:19:51.194394 | 2021-02-13T03:55:10 | 2021-02-13T03:55:10 | 327,883,026 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 222 | java | package com.library.customerinfo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class CustomerinfoApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
db7947782138f540b45a3982e0fde8af4bcc86e9 | 972c92ef8d42ca405386a123fd8b160aa98291f0 | /chapter 11/Holding/11.27/E27_CommandQueue.java | 7fc400364fc1cb169681321d5c3b86935cadcfce | [] | no_license | zhwei5311/Think-in-Java-4th-Edition-Exercise | d60051e3377abdea0d96c4d2ccead494e1dd2053 | ae554b0b03124ab7cd79f51265872aa2cd23ce50 | refs/heads/master | 2020-03-07T22:55:40.195224 | 2018-04-02T14:30:02 | 2018-04-02T14:30:02 | 127,767,671 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,235 | java | //: holding/E27_CommandQueue.java
/****************** Exercise 27 *****************
* Write a class called Command that contains a
* String and has a method operation() that
* displays the String. Write a second class with
* a method that fills a Queue with Command objects
* and returns it. Pass the filled Queue to a method
* in a third class that consumes the objects in the
* Queue and calls their operation() methods.
***********************************************/
package holding;
import java.util.*;
class Command {
private final String cmd;
Command(String cmd) { this.cmd = cmd; }
public void operation() { System.out.println(cmd); }
}
class Producer {
public static void produce(Queue<Command> q) {
q.offer(new Command("load"));
q.offer(new Command("delete"));
q.offer(new Command("save"));
q.offer(new Command("exit"));
}
}
class Consumer {
public static void consume(Queue<Command> q) {
while(q.peek() != null)
q.remove().operation();
}
}
public class E27_CommandQueue {
public static void main(String[] args) {
Queue<Command> cmds = new LinkedList<Command>();
Producer.produce(cmds);
Consumer.consume(cmds);
}
} /* Output:
load
delete
save
exit
*///:~
| [
"[email protected]"
] | |
c7146e700a3baaef4d4c8d67c132607408f2465f | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_910dded9a0a2e350a681482a5a65a9031b6d74d3/TrackingLogger/2_910dded9a0a2e350a681482a5a65a9031b6d74d3_TrackingLogger_t.java | 9047d87c9dc2f3dfcf01f4d79775fe604a4dea7d | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 3,340 | java | /*
* Copyright 2006 Niclas Hedhman.
*
* 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.ops4j.pax.logging.internal;
import org.ops4j.pax.logging.DefaultServiceLog;
import org.ops4j.pax.logging.PaxLogger;
import org.ops4j.pax.logging.PaxLoggingService;
import org.osgi.framework.Bundle;
public class TrackingLogger
implements PaxLogger
{
private PaxLoggingService m_service;
private String m_category;
private Bundle m_bundle;
private PaxLogger m_delegate;
private String m_fqcn;
public TrackingLogger( PaxLoggingService service, String category, Bundle bundle, String fqcn )
{
m_fqcn = fqcn;
m_category = category;
m_bundle = bundle;
added( service );
}
public boolean isTraceEnabled()
{
return m_delegate.isTraceEnabled();
}
public boolean isDebugEnabled()
{
return m_delegate.isDebugEnabled();
}
public boolean isWarnEnabled()
{
return m_delegate.isWarnEnabled();
}
public boolean isInfoEnabled()
{
return m_delegate.isInfoEnabled();
}
public boolean isErrorEnabled()
{
return m_delegate.isErrorEnabled();
}
public boolean isFatalEnabled()
{
return m_delegate.isFatalEnabled();
}
public void trace( String message, Throwable t )
{
m_delegate.trace( message, t );
}
public void debug( String message, Throwable t )
{
m_delegate.debug( message, t );
}
public void inform( String message, Throwable t )
{
m_delegate.inform( message, t );
}
public void warn( String message, Throwable t )
{
m_delegate.warn( message, t );
}
public void error( String message, Throwable t )
{
m_delegate.error( message, t );
}
public void fatal( String message, Throwable t )
{
m_delegate.fatal( message, t );
}
public int getLogLevel()
{
return m_delegate.getLogLevel();
}
public String getName()
{
return m_delegate.getName();
}
public void added( PaxLoggingService service )
{
m_service = service;
if( m_service != null )
{
m_delegate = m_service.getLogger( m_bundle, m_category, m_fqcn );
}
else
{
m_delegate = new DefaultServiceLog( m_bundle, m_category );
}
}
/**
* Called by the tracker when there is no service available, and the reference should
* be dropped.
*/
public void removed()
{
m_service = null;
m_delegate = new DefaultServiceLog( m_bundle, m_category );
}
}
| [
"[email protected]"
] | |
283869ec4bff18955a81c6041d1cee06945b4e24 | 4e6311f196223dfe6c7443f732c0f8a184107b30 | /app/src/androidTest/java/br/com/mrcsfelipe/voo/ApplicationTest.java | e068304ce67cf3a9e624f25941835b08b06a6280 | [] | no_license | MarcosiOSdev/Android----ListAdpter-e-Parceble | e1550dff6b7741d61a6fcad01e2635f77c9261f7 | 902301447707b49522c953f50db034b230ab80fb | refs/heads/master | 2021-05-29T20:56:47.822806 | 2015-10-26T21:45:42 | 2015-10-26T21:45:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 352 | java | package br.com.mrcsfelipe.voo;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"[email protected]"
] | |
93881567fa7aff82848f5cab846c30569926f2f1 | 447520f40e82a060368a0802a391697bc00be96f | /apks/obfuscation_and_logging/com_advantage_RaiffeisenBank/source/com/thinkdesquared/banking/models/Biller.java | 55c5730631ae55401fbf7e023adc210ada6e8348 | [
"Apache-2.0"
] | permissive | iantal/AndroidPermissions | 7f3343a9c29d82dbcd4ecd98b3a50ddf8d179465 | d623b732734243590b5f004d167e542e2e2ae249 | refs/heads/master | 2023-07-19T01:29:26.689186 | 2019-09-30T19:01:42 | 2019-09-30T19:01:42 | 107,239,248 | 0 | 0 | Apache-2.0 | 2023-07-16T07:41:38 | 2017-10-17T08:22:57 | null | UTF-8 | Java | false | false | 1,547 | java | package com.thinkdesquared.banking.models;
import java.util.ArrayList;
public class Biller
{
private String highDefImage;
private String id;
private String logoPath;
private String lowDefImage;
private String mediumDefImage;
private String name;
private ArrayList<BillPaymentVariableField> variableFields;
public Biller() {}
public String getHighDefImage()
{
return this.highDefImage;
}
public String getId()
{
return this.id;
}
public String getLogoPath()
{
return this.logoPath;
}
public String getLowDefImage()
{
return this.lowDefImage;
}
public String getMediumDefImage()
{
return this.mediumDefImage;
}
public String getName()
{
return this.name;
}
public ArrayList<BillPaymentVariableField> getVariableFields()
{
return this.variableFields;
}
public void setHighDefImage(String paramString)
{
this.highDefImage = paramString;
}
public void setId(String paramString)
{
this.id = paramString;
}
public void setLogoPath(String paramString)
{
this.logoPath = paramString;
}
public void setLowDefImage(String paramString)
{
this.lowDefImage = paramString;
}
public void setMediumDefImage(String paramString)
{
this.mediumDefImage = paramString;
}
public void setName(String paramString)
{
this.name = paramString;
}
public void setVariableFields(ArrayList<BillPaymentVariableField> paramArrayList)
{
this.variableFields = paramArrayList;
}
}
| [
"[email protected]"
] | |
2f71917f6e7be9c3e565cd6ad91cd4fb2df5b745 | fc4c4962aa61ab102a3008cc91d587508b70165e | /src/Erie.java | f2de38ed25458518444aa67a1323178975a721dd | [] | no_license | afc1755/Erie | 21ebec0657d032ac9ec61a9be45cee1d47e907fc | 75460ae3011906b68bb169ead96e4f320e11b383 | refs/heads/master | 2020-04-22T06:00:04.719384 | 2019-02-13T21:38:20 | 2019-02-13T21:38:20 | 169,340,517 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 965 | java | /**
* @author Andrew Chabot
* @version 1.0
* Erie.java
* Main Class for the Erie program, COPADS project 1
* February 13, 2019
*/
/**
* Erie class, runnable class that mainly performs argument checking
*/
public class Erie {
/**
* usageMess: string to print if arguments are incorrect, shows proper usage
*/
static final String usageMess = "Usage: java Erie number-of-cars";
/**
* Main function, checks the arguments for correctness and then creates a new Bridge
* and starts the Bridge's execution if the given arguments are correct
* @param args input arguments from running the program
*/
public static void main(String[] args) {
if(args.length != 1 || !(args[0].matches("-?\\d+")) || Integer.parseInt(args[0]) < 1){
throw new Error(usageMess);
}else{
Bridge currBridge = new Bridge(Integer.parseInt(args[0]));
currBridge.startRun();
}
}
}
| [
"[email protected]"
] | |
44e7035f42633db47619debf75939b25fc97b083 | 5bbe3057508230e063e43a182a36613924d21ea7 | /android/app/src/main/java/com/prizy/MainActivity.java | f95e1657b1546f2577d8010e4c0b67271276c4b1 | [] | no_license | Larissa-Developers/prizy_mobile | 4ac104eabfbf4c538c08ab69d99af20864b74bc6 | 4059709105c883c233d893e0dd5270db2acbfafb | refs/heads/develop | 2021-07-14T18:05:20.140174 | 2019-02-23T15:53:02 | 2019-02-23T15:53:02 | 139,560,229 | 1 | 4 | null | 2019-02-23T14:38:51 | 2018-07-03T09:29:58 | JavaScript | UTF-8 | Java | false | false | 355 | java | package com.prizy;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Prizy";
}
}
| [
"[email protected]"
] | |
a9c164043257bac9e73657bb7dc8a77afd70a8bb | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/neo4j--neo4j/2023711f17b5c616aa93d72df8986377948c8275/before/CoreServerModule.java | cf05ff7d76ddd1e090f9cd71ec42fd2e7bc484ce | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,894 | java | /*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.coreedge.core.server;
import java.io.File;
import java.io.IOException;
import java.util.function.Supplier;
import org.neo4j.coreedge.ReplicationModule;
import org.neo4j.coreedge.catchup.CatchUpClient;
import org.neo4j.coreedge.catchup.CatchupServer;
import org.neo4j.coreedge.catchup.CheckpointerSupplier;
import org.neo4j.coreedge.catchup.DataSourceSupplier;
import org.neo4j.coreedge.catchup.storecopy.LocalDatabase;
import org.neo4j.coreedge.catchup.storecopy.StoreCopyClient;
import org.neo4j.coreedge.catchup.storecopy.StoreFetcher;
import org.neo4j.coreedge.catchup.tx.TransactionLogCatchUpFactory;
import org.neo4j.coreedge.catchup.tx.TxPullClient;
import org.neo4j.coreedge.core.CoreEdgeClusterSettings;
import org.neo4j.coreedge.core.consensus.ConsensusModule;
import org.neo4j.coreedge.core.consensus.ContinuousJob;
import org.neo4j.coreedge.core.consensus.RaftMessages;
import org.neo4j.coreedge.core.consensus.RaftServer;
import org.neo4j.coreedge.core.consensus.log.pruning.PruningScheduler;
import org.neo4j.coreedge.core.consensus.membership.MembershipWaiter;
import org.neo4j.coreedge.core.consensus.membership.MembershipWaiterLifecycle;
import org.neo4j.coreedge.core.state.CommandApplicationProcess;
import org.neo4j.coreedge.core.state.CoreState;
import org.neo4j.coreedge.core.state.CoreStateApplier;
import org.neo4j.coreedge.core.state.LongIndexMarshal;
import org.neo4j.coreedge.core.state.machines.CoreStateMachinesModule;
import org.neo4j.coreedge.core.state.snapshot.CoreStateDownloader;
import org.neo4j.coreedge.core.state.storage.DurableStateStorage;
import org.neo4j.coreedge.core.state.storage.StateStorage;
import org.neo4j.coreedge.discovery.CoreTopologyService;
import org.neo4j.coreedge.identity.MemberId;
import org.neo4j.coreedge.logging.MessageLogger;
import org.neo4j.coreedge.messaging.CoreReplicatedContentMarshal;
import org.neo4j.coreedge.messaging.LoggingInbound;
import org.neo4j.coreedge.messaging.address.ListenSocketAddress;
import org.neo4j.coreedge.messaging.routing.NotMyselfSelectionStrategy;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.factory.PlatformModule;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore;
import org.neo4j.kernel.impl.transaction.log.TransactionIdStore;
import org.neo4j.kernel.impl.util.Dependencies;
import org.neo4j.kernel.impl.util.JobScheduler;
import org.neo4j.kernel.internal.DatabaseHealth;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.logging.LogProvider;
import org.neo4j.time.Clocks;
import static org.neo4j.kernel.impl.util.JobScheduler.SchedulingStrategy.NEW_THREAD;
public class CoreServerModule
{
public final MembershipWaiterLifecycle membershipWaiterLifecycle;
public CoreServerModule( MemberId myself, final PlatformModule platformModule, ConsensusModule consensusModule,
CoreStateMachinesModule coreStateMachinesModule, ReplicationModule replicationModule,
File clusterStateDirectory, CoreTopologyService discoveryService,
LocalDatabase localDatabase, MessageLogger<MemberId> messageLogger )
{
final Dependencies dependencies = platformModule.dependencies;
final Config config = platformModule.config;
final LogService logging = platformModule.logging;
final FileSystemAbstraction fileSystem = platformModule.fileSystem;
final LifeSupport life = platformModule.life;
LogProvider logProvider = logging.getInternalLogProvider();
final Supplier<DatabaseHealth> databaseHealthSupplier = dependencies.provideDependency( DatabaseHealth.class );
StateStorage<Long> lastFlushedStorage;
lastFlushedStorage = life.add(
new DurableStateStorage<>( fileSystem, clusterStateDirectory, ReplicationModule.LAST_FLUSHED_NAME,
new LongIndexMarshal(), config.get( CoreEdgeClusterSettings.last_flushed_state_size ),
logProvider ) );
consensusModule.raftMembershipManager().setRecoverFromIndexSupplier( lastFlushedStorage::getInitialState );
ListenSocketAddress raftListenAddress = config.get( CoreEdgeClusterSettings.raft_listen_address );
RaftServer raftServer = new RaftServer( new CoreReplicatedContentMarshal(), raftListenAddress, logProvider );
LoggingInbound<RaftMessages.StoreIdAwareMessage> loggingRaftInbound =
new LoggingInbound<>( raftServer, messageLogger, myself );
CatchUpClient catchUpClient = life.add( new CatchUpClient( discoveryService, logProvider, Clocks.systemClock() ) );
StoreFetcher storeFetcher = new StoreFetcher( logProvider, fileSystem, platformModule.pageCache,
new StoreCopyClient( catchUpClient ), new TxPullClient( catchUpClient, platformModule.monitors ),
new TransactionLogCatchUpFactory() );
CoreStateApplier coreStateApplier = new CoreStateApplier( logProvider );
CoreStateDownloader downloader = new CoreStateDownloader( localDatabase, storeFetcher,
catchUpClient, logProvider );
NotMyselfSelectionStrategy someoneElse = new NotMyselfSelectionStrategy( discoveryService, myself );
CoreState coreState = new CoreState(
consensusModule.raftMachine(), localDatabase,
logProvider,
someoneElse, downloader,
new CommandApplicationProcess( coreStateMachinesModule.coreStateMachines, consensusModule.raftLog(),
config.get( CoreEdgeClusterSettings.state_machine_apply_max_batch_size ),
config.get( CoreEdgeClusterSettings.state_machine_flush_window_size ),
databaseHealthSupplier, logProvider, replicationModule.getProgressTracker(),
lastFlushedStorage, replicationModule.getSessionTracker(), coreStateApplier,
consensusModule.inFlightMap(), platformModule.monitors ) );
dependencies.satisfyDependency( coreState );
life.add( new PruningScheduler( coreState, platformModule.jobScheduler,
config.get( CoreEdgeClusterSettings.raft_log_pruning_frequency ), logProvider ) );
int queueSize = config.get( CoreEdgeClusterSettings.raft_in_queue_size );
int maxBatch = config.get( CoreEdgeClusterSettings.raft_in_queue_max_batch );
BatchingMessageHandler batchingMessageHandler =
new BatchingMessageHandler( coreState, queueSize, maxBatch, logProvider );
long electionTimeout = config.get( CoreEdgeClusterSettings.leader_election_timeout );
MembershipWaiter membershipWaiter =
new MembershipWaiter( myself, platformModule.jobScheduler, electionTimeout * 4, coreState, logProvider );
long joinCatchupTimeout = config.get( CoreEdgeClusterSettings.join_catch_up_timeout );
membershipWaiterLifecycle = new MembershipWaiterLifecycle( membershipWaiter,
joinCatchupTimeout, consensusModule.raftMachine(), logProvider );
loggingRaftInbound.registerHandler( batchingMessageHandler );
CatchupServer catchupServer = new CatchupServer( logProvider, localDatabase,
platformModule.dependencies.provideDependency( TransactionIdStore.class ),
platformModule.dependencies.provideDependency( LogicalTransactionStore.class ),
new DataSourceSupplier( platformModule ), new CheckpointerSupplier( platformModule.dependencies ),
coreState, config.get( CoreEdgeClusterSettings.transaction_listen_address ), platformModule.monitors );
life.add( coreState );
life.add( new ContinuousJob( platformModule.jobScheduler, new JobScheduler.Group( "raft-batch-handler", NEW_THREAD ),
batchingMessageHandler, logProvider ) );
life.add( raftServer );
life.add( catchupServer );
}
} | [
"[email protected]"
] | |
f6d404aa734a207f28860be51e578a65bc4c5cac | 348af9594bf4f23ca177c476e37303d7b9ee100d | /src/main/java/automation/examples/pages/AbstractLoadable.java | 766b77c2d3b8995e9301110957e5d2f1d760b655 | [] | no_license | TanyaSivnitska/gitHubTests | e12d2135a71f4252012cd9a9d45b842bb7a93e8d | 4e567ddebead9dcac5a71c0ce2be7c26ca0b65b7 | refs/heads/master | 2022-04-16T12:14:26.654846 | 2020-04-13T00:09:49 | 2020-04-13T00:09:49 | 255,066,848 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 533 | java | package automation.examples.pages;
import automation.examples.framework.driver.DriverProvider;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class AbstractLoadable {
private static final int DEFAULT_TIMEOUT = 10;
@Autowired
protected DriverProvider driverProvider;
public abstract void waitUntilLoaded();
protected WebDriverWait getDriverWait() {
return new WebDriverWait(driverProvider.getInstance(), DEFAULT_TIMEOUT);
}
}
| [
"[email protected]"
] | |
28e61a10f2eda751010bc9f5ed990eff2093d62f | ba139578e186deb18fd3bdfbdffc8a607bc7ca88 | /app/src/main/java/com/example/julio/my_coverage_taxi/control/NumberPicker.java | 65a5a2075b6c6365e51af7facd7b141e8aa1aa59 | [] | no_license | juliocsar13/My_Coverage_Taxi | 3cd4e09c0ce075cca9575f53e5d86aa1014038dc | e4f78dfe9e6af054df94b6e81fdf32efbb80c242 | refs/heads/master | 2020-05-30T03:32:21.977568 | 2015-07-03T01:29:14 | 2015-07-03T01:29:21 | 38,465,091 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,372 | java | /*
* Copyright (c) 2010, Jeffrey F. Cole
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the technologichron.net nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.example.julio.my_coverage_taxi.control;
import android.content.Context;
import android.os.Handler;
import android.text.InputType;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import com.example.julio.my_coverage_taxi.R;
/**
* A simple layout group that provides a numeric text area with two buttons to
* increment or decrement the value in the text area. Holding either button
* will auto increment the value up or down appropriately.
*
* @author Jeffrey F. Cole
*
*/
public class NumberPicker extends LinearLayout {
private final long REPEAT_DELAY = 50;
private final int ELEMENT_HEIGHT = 100;
private final int ELEMENT_WIDTH = ELEMENT_HEIGHT; // you're all squares, yo
private final int MINIMUM = 1;
private final int MAXIMUM = 3;
private final int TEXT_SIZE = 22;
public Integer value;
Button decrement;
Button increment;
/*decrement.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_coverage_design));*/
public EditText valueText;
private Handler repeatUpdateHandler = new Handler();
private boolean autoIncrement = false;
private boolean autoDecrement = false;
/**
* This little guy handles the auto part of the auto incrementing feature.
* In doing so it instantiates itself. There has to be a pattern name for
* that...
*
* @author Jeffrey F. Cole
*
*/
class RepetetiveUpdater implements Runnable {
public void run() {
if( autoIncrement ){
increment();
repeatUpdateHandler.postDelayed( new RepetetiveUpdater(), REPEAT_DELAY );
} else if( autoDecrement ){
decrement();
repeatUpdateHandler.postDelayed( new RepetetiveUpdater(), REPEAT_DELAY );
}
}
}
public NumberPicker(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.setLayoutParams( new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT ) );
LayoutParams elementParams = new LinearLayout.LayoutParams( ELEMENT_HEIGHT, ELEMENT_WIDTH );
// init the individual elements
initDecrementButton( context );
initValueEditText( context );
initIncrementButton( context );
// Can be configured to be vertical or horizontal
// Thanks for the help, LinearLayout!
if( getOrientation() == VERTICAL ){
addView( increment, elementParams );
addView( valueText, elementParams );
addView( decrement, elementParams );
} else {
addView( decrement, elementParams );
addView( valueText, elementParams );
addView( increment, elementParams );
}
}
private void initIncrementButton( Context context){
increment = new Button( context );
increment.setTextSize( TEXT_SIZE );
increment.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_coverage_design));
increment.setText( "+" );
// Increment once for a click
increment.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
increment();
}
});
// Auto increment for a long click
increment.setOnLongClickListener(
new View.OnLongClickListener(){
public boolean onLongClick(View arg0) {
autoIncrement = true;
repeatUpdateHandler.post( new RepetetiveUpdater() );
return false;
}
}
);
// When the button is released, if we're auto incrementing, stop
increment.setOnTouchListener( new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if( event.getAction() == MotionEvent.ACTION_UP && autoIncrement ){
autoIncrement = false;
}
return false;
}
});
}
private void initValueEditText( Context context){
value = new Integer( 0 );
valueText = new EditText( context );
valueText.setTextSize( TEXT_SIZE );
// Since we're a number that gets affected by the button, we need to be
// ready to change the numeric value with a simple ++/--, so whenever
// the value is changed with a keyboard, convert that text value to a
// number. We can set the text area to only allow numeric input, but
// even so, a carriage return can get hacked through. To prevent this
// little quirk from causing a crash, store the value of the internal
// number before attempting to parse the changed value in the text area
// so we can revert to that in case the text change causes an invalid
// number
valueText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int arg1, KeyEvent event) {
int backupValue = value;
try {
value = Integer.parseInt(((EditText) v).getText().toString());
} catch( NumberFormatException nfe ){
value = backupValue;
}
return false;
}
});
// Highlight the number when we get focus
valueText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if( hasFocus ){
((EditText)v).selectAll();
}
}
});
valueText.setGravity( Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL );
valueText.setText( value.toString() );
valueText.setInputType( InputType.TYPE_CLASS_NUMBER );
}
private void initDecrementButton( Context context){
decrement = new Button( context );
decrement.setTextSize( TEXT_SIZE );
decrement.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_coverage_design));
decrement.setText( "-" );
// Decrement once for a click
decrement.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
decrement();
}
});
// Auto Decrement for a long click
decrement.setOnLongClickListener(
new View.OnLongClickListener(){
public boolean onLongClick(View arg0) {
autoDecrement = true;
repeatUpdateHandler.post( new RepetetiveUpdater() );
return false;
}
}
);
// When the button is released, if we're auto decrementing, stop
decrement.setOnTouchListener( new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if( event.getAction() == MotionEvent.ACTION_UP && autoDecrement ){
autoDecrement = false;
}
return false;
}
});
}
public void increment(){
if( value < MAXIMUM ){
value = value + 1;
valueText.setText( value.toString() );
}
}
public void decrement(){
if( value > MINIMUM ){
value = value - 1;
valueText.setText( value.toString() );
}
}
public int getValue(){
return value;
}
public void setValue( int value ){
if( value > MAXIMUM ) value = MAXIMUM;
if( value >= 0 ){
this.value = value;
valueText.setText( this.value.toString() );
}
}
}
| [
"[email protected]"
] | |
85c5eef750835cc9b7d6c8761fc8133b29fe49b6 | c2f73f2f9d23d946f2c0ceeffe11710d0968cdec | /app/src/main/java/com/example/almacenamiento/fragmentos/SecondFragment.java | fd183da0f59f495525cc7df42ae8233d959d8069 | [] | no_license | aljofloro/Almacenamiento | fc0549a72204a30f414ac4be90469d809e9e0580 | 41d8c434e411c7a978ce3f78ad4f983d014941d1 | refs/heads/master | 2022-11-15T16:07:56.503785 | 2020-07-11T23:33:34 | 2020-07-11T23:33:34 | 278,958,374 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,806 | java | package com.example.almacenamiento.fragmentos;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
import com.example.almacenamiento.R;
import com.google.android.material.snackbar.Snackbar;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.util.Vector;
public class SecondFragment extends Fragment {
final File ruta = Environment.getExternalStorageDirectory();
final File fichero = new File(ruta.getAbsolutePath(),"externo.txt");
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
public static void verificarPermisosAlmacenamiento(Activity activity){
int permisos = ActivityCompat.checkSelfPermission(activity
,Manifest.permission.WRITE_EXTERNAL_STORAGE);
if(permisos != PackageManager.PERMISSION_GRANTED){
ActivityCompat
.requestPermissions(activity
,PERMISSIONS_STORAGE
,REQUEST_EXTERNAL_STORAGE);
}
}
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_second, container, false);
}
@Override
public void onResume(){
super.onResume();
actualizarEtiqueta();
((Button)getActivity().findViewById(R.id.btn_add)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
guardarArchivo(((EditText)getActivity()
.findViewById(R.id.edt_editar))
.getText().toString(),getContext());
((EditText)getActivity().findViewById(R.id.edt_editar))
.setText("");
actualizarEtiqueta();
}
});
}
public void guardarArchivo(String datos, Context context){
String estadoSD = Environment.getExternalStorageState();
if(!estadoSD.equals(Environment.MEDIA_MOUNTED)){
Snackbar.make(getView(),"No es posible escribir en la " +
"memoria externa", Snackbar.LENGTH_SHORT).show();
return;
}
try{
verificarPermisosAlmacenamiento(getActivity());
FileOutputStream stream = new FileOutputStream(fichero,true);
String texto = datos + "\n";
stream.write(texto.getBytes());
stream.close();
Snackbar.make(getView(),"Se guardรณ exitosamente"
,Snackbar.LENGTH_SHORT).show();
}catch (Exception e){
e.printStackTrace();
}
}
public Vector<String> obtenerDatos(Context context){
Vector<String> resultado = new Vector<>();
String estadoSD = Environment.getExternalStorageState();
if(!estadoSD.equals(Environment.MEDIA_MOUNTED)
&& !estadoSD.equals(Environment.MEDIA_MOUNTED_READ_ONLY)){
Snackbar.make(getView(),"No se puede leer" +
"el almacenamiento externo",Snackbar.LENGTH_SHORT).show();
return resultado;
}
try{
verificarPermisosAlmacenamiento(getActivity());
FileInputStream stream = new FileInputStream(fichero);
BufferedReader entrada
= new BufferedReader(new InputStreamReader(stream));
String linea;
do{
linea = entrada.readLine();
if(linea != null){
resultado.add(linea);
}
}while(linea != null);
stream.close();
Snackbar.make(getView(),"Fichero cargado!"
,Snackbar.LENGTH_SHORT).show();
}catch (Exception e){
e.printStackTrace();
}
return resultado;
}
public void actualizarEtiqueta(){
((TextView)getActivity().findViewById(R.id.txt_view))
.setText((obtenerDatos(getContext()).toString()));
}
} | [
"[email protected]"
] | |
efd88600a96b327d3229b608f8ee486fe14bdb19 | 2083486a106166bbde992ce99dab1a4b804572c1 | /src/Leetcode/array/MoveZeros.java | 4fe3f354de737181665b7c0a78ea07495b7f6704 | [] | no_license | SandyWKX/IntelliJSpace | 34f42c14a82dc9ced85870c268cb696ad19b0473 | 5e94e14dc15d766ed0cfcd45c0ab59030f677e78 | refs/heads/master | 2020-03-23T00:41:45.566502 | 2018-07-16T21:32:41 | 2018-07-16T21:32:41 | 140,879,713 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 611 | java | package Leetcode.array;
//No.283. Move Zeroes
public class MoveZeros {
public static void main(String[] args){
int[] A = {0,1,3,0,12};
MoveZeros obj = new MoveZeros();
int[]B = obj.moveZero(A);
for(int i =0; i< B.length;i++){
System.out.println(B[i]);
}
}
int[] moveZero(int[] A){
int j =0;
for(int i = 0; i<A.length;i++){
if(A[i] != 0){
A[j] = A[i];
j++;
}
}
for(int k = j; k<A.length;k++)
{
A[k] = 0;
}
return A;
}
}
| [
"[email protected]"
] | |
0a9161c431c0835f58e40a8924e8fd7b72ff3f64 | 5fa90bfe3eae44c61dd38449a6105d8da1133ef5 | /app/src/androidTest/java/com/example/haipingguo/rxjavademo/ExampleInstrumentedTest.java | 93b07a49c069ac51a66665237bb2e2470cb001e0 | [] | no_license | guohaiping521/RxJavaDemo | c5a779f090e1630d9f2a750f4184a7fc46d8d938 | 6298ce266e174e73ec2528b35cc25bc925a4039a | refs/heads/master | 2020-04-05T02:24:18.793890 | 2019-04-26T08:55:43 | 2019-04-26T08:55:43 | 156,475,725 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 750 | java | package com.example.haipingguo.rxjavademo;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.haipingguo.rxjavademo", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
c510a180d6def5c011b169cd46e5d4795ef5224f | 0529524c95045b3232f6553d18a7fef5a059545e | /app/src/androidTest/java/TestCase_01F43BBD70800267D46EDA936621C4DFFE292EBD59B3448689EBDE206501484E_1698085100.java | 160c378523535ecadd494c91565f9f6f1d0a6200 | [] | no_license | sunxiaobiu/BasicUnitAndroidTest | 432aa3e10f6a1ef5d674f269db50e2f1faad2096 | fed24f163d21408ef88588b8eaf7ce60d1809931 | refs/heads/main | 2023-02-11T21:02:03.784493 | 2021-01-03T10:07:07 | 2021-01-03T10:07:07 | 322,577,379 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 328 | java | import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class TestCase_01F43BBD70800267D46EDA936621C4DFFE292EBD59B3448689EBDE206501484E_1698085100 {
@Test
public void testCase() throws Exception {
// $FF: Couldn't be decompiled
}
}
| [
"[email protected]"
] | |
0b4b4321313d30f24449e6391a0d9d9bdb468416 | 945b270ea1e4b941d71f2b98d4405bcb730883b7 | /src/main/java/net/jodah/failsafe/DelayablePolicy.java | cb4ae927567fbcd44ae969d45edb5c66b10cddf3 | [
"Apache-2.0"
] | permissive | abhisheknishant138/failsafe | 7dea82e68928d57f35f99fe0f1697e0ddff760d7 | 3cf9e66db76bcd1adfc57f9bd1e4f0127be87776 | refs/heads/master | 2022-12-02T01:49:32.284162 | 2020-08-20T11:58:30 | 2020-08-20T11:58:30 | 286,497,593 | 0 | 0 | Apache-2.0 | 2020-08-10T14:28:23 | 2020-08-10T14:28:22 | null | UTF-8 | Java | false | false | 3,670 | java | package net.jodah.failsafe;
import net.jodah.failsafe.function.DelayFunction;
import net.jodah.failsafe.internal.util.Assert;
import java.time.Duration;
/**
* A policy that can be delayed between executions.
*
* @param <S> self type
* @param <R> result type
* @author Jonathan Halterman
*/
public abstract class DelayablePolicy<S, R> extends FailurePolicy<S, R> {
DelayFunction<R, ? extends Throwable> delayFn;
Object delayResult;
Class<? extends Throwable> delayFailure;
/**
* Returns the function that determines the next delay before allowing another execution.
*
* @see #withDelay(DelayFunction)
* @see #withDelayOn(DelayFunction, Class)
* @see #withDelayWhen(DelayFunction, Object)
*/
public DelayFunction<R, ? extends Throwable> getDelayFn() {
return delayFn;
}
/**
* Sets the {@code delayFunction} that computes the next delay before allowing another execution.
*
* @param delayFunction the function to use to compute the delay before a next attempt
* @throws NullPointerException if {@code delayFunction} is null
* @see DelayFunction
*/
@SuppressWarnings("unchecked")
public S withDelay(DelayFunction<R, ? extends Throwable> delayFunction) {
Assert.notNull(delayFunction, "delayFunction");
this.delayFn = delayFunction;
return (S) this;
}
/**
* Sets the {@code delayFunction} that computes the next delay before allowing another execution. Delays will only
* occur for failures that are assignable from the {@code failure}.
*
* @param delayFunction the function to use to compute the delay before a next attempt
* @param failure the execution failure that is expected in order to trigger the delay
* @param <F> failure type
* @throws NullPointerException if {@code delayFunction} or {@code failure} are null
* @see DelayFunction
*/
@SuppressWarnings("unchecked")
public <F extends Throwable> S withDelayOn(DelayFunction<R, F> delayFunction, Class<F> failure) {
withDelay(delayFunction);
Assert.notNull(failure, "failure");
this.delayFailure = failure;
return (S) this;
}
/**
* Sets the {@code delayFunction} that computes the next delay before allowing another execution. Delays will only
* occur for results that equal the {@code result}.
*
* @param delayFunction the function to use to compute the delay before a next attempt
* @param result the execution result that is expected in order to trigger the delay
* @throws NullPointerException if {@code delayFunction} or {@code result} are null
* @see DelayFunction
*/
@SuppressWarnings("unchecked")
public S withDelayWhen(DelayFunction<R, ? extends Throwable> delayFunction, R result) {
withDelay(delayFunction);
Assert.notNull(result, "result");
this.delayResult = result;
return (S) this;
}
/**
* Returns a computed delay for the {@code result} and {@code context} else {@code null} if no delay function is
* configured or the computed delay is invalid.
*/
@SuppressWarnings("unchecked")
protected Duration computeDelay(ExecutionContext context) {
Duration computed = null;
if (context != null && delayFn != null) {
Object exResult = context.getLastResult();
Throwable exFailure = context.getLastFailure();
if ((delayResult == null || delayResult.equals(exResult)) && (delayFailure == null || (exFailure != null
&& delayFailure.isAssignableFrom(exFailure.getClass())))) {
computed = ((DelayFunction<Object, Throwable>) delayFn).computeDelay(exResult, exFailure, context);
}
}
return computed != null && !computed.isNegative() ? computed : null;
}
}
| [
"[email protected]"
] | |
73fd46fa910fdbc620b59f2ae2cf7377e281e6d8 | 8da934c40dc0f326ed5e08369be0ff87ac98ed5e | /Crafts Beer Submission/source code/app/src/androidTest/java/com/kotiyaltech/craftsbeer/ExampleInstrumentedTest.java | b8f609cb9dc0c20a026389e3e62857c2b0b5a44e | [] | no_license | Abhishek92/CraftsBeer | fb138917227d40432605d1a6074125c0d0e376c9 | db03091ffa11c3d0a5d00187758c197e65c8e642 | refs/heads/master | 2020-03-22T16:09:35.135245 | 2018-07-09T15:44:46 | 2018-07-09T15:44:46 | 140,307,295 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 753 | java | package com.kotiyaltech.craftsbeer;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.kotiyaltech.craftsbeer", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
ef126b1b8fd607ddc1f71ce666e57c05f9deb50d | 006e02881583f537edff46e9422d0752ec1c1512 | /src/main/java/com/fred1900/lop/base/rpc/client/ProxyFactory.java | 75ef4c0905f3ac1669e1177743a52462d3072577 | [] | no_license | fred1900/lop-base | 7494a503d85546cbc3aef595b70f67dc2129335e | 702dac30c0340d0ee3cac321db31826fb44da6fd | refs/heads/master | 2021-01-23T22:06:28.151623 | 2017-06-20T15:15:24 | 2017-06-20T15:15:24 | 83,118,076 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 406 | java | package com.fred1900.lop.base.rpc.client;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
public class ProxyFactory {
@SuppressWarnings("unchecked")
public static <T> T create(Class<T> c, String ip, int port) {
InvocationHandler handler = new RpcProxy(ip, port, c);
return (T) Proxy.newProxyInstance(c.getClassLoader(), new Class[] { c }, handler);
}
}
| [
"[email protected]"
] | |
22d40c2b9b7e3b5ded0bb603963ec031805c49b8 | 82d16721dec40c5ea7705defc4fa73831f80a90b | /app/src/main/java/ansteph/com/lotto/app/GlobalRetainer.java | 7b402b09d72104f0d2f96d70ff02240532ffeb86 | [] | no_license | LNdame/lotto_project | dac974feb86b9dc0a73cae2818ca513a106f060b | 69d6adcf260a6ba605b3c131b7fb81ccb0dd90dc | refs/heads/master | 2021-01-12T15:13:09.012006 | 2016-10-07T21:26:42 | 2016-10-07T21:26:42 | 69,876,958 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 111 | java | package ansteph.com.lotto.app;
/**
* Created by loicStephan on 02/10/16.
*/
public class GlobalRetainer {
}
| [
"[email protected]"
] | |
fe8ce695fd737e178aaa4a6f85fae3ea81937581 | e2902e2a69fc790b1f6a9c1ddcbc49a00f6d7764 | /src/br/com/carlosemanuel/buzzreader/parsers/handlers/UserProfileHandler.java | 78fdce42872df391cf03e0770c425b8131cf520e | [] | no_license | carlosemanuel/Buzz-Reader | 4482bfdf223285bcb078d7bb0694042792d7b9e3 | 8c5154502e5be1dfba58f39cfef92c1e7749c5ac | refs/heads/master | 2021-01-10T20:55:53.962407 | 2011-03-16T01:33:59 | 2011-03-16T01:33:59 | 2,595,811 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 557 | java | package br.com.carlosemanuel.buzzreader.parsers.handlers;
import org.json.JSONObject;
import br.com.carlosemanuel.buzzreader.exception.BuzzParsingException;
import br.com.carlosemanuel.buzzreader.model.BuzzUserProfile;
/**
* Handler for element: <b>User Profile</b>
*
* @author roberto.estivill
*/
public class UserProfileHandler extends BaseHandler {
// TODO
public static BuzzUserProfile handle(JSONObject jsonObject)
throws BuzzParsingException {
BuzzUserProfile buzzUserProfile = new BuzzUserProfile();
return buzzUserProfile;
}
}
| [
"Carlos@.(none)"
] | Carlos@.(none) |
df6e6f85e583a3a5a34ef4301ca028fbef990386 | 8df236c519f655e68012f6962b89fe6a5b25e753 | /app/src/main/java/com/example/comp7082/comp7082photogallery/androidos/ExifUtility.java | 881c37431a3a8b5d23222f3bb80fd5af4698689d | [] | no_license | SahejBhatia/Comp7082FinalProject | 3b2dfb9603c80e86b81c6553e0bac16b6159f9ae | bba4845d9b2d5c4bf172cf8b4047b045a7fb47c4 | refs/heads/master | 2020-09-11T21:56:34.203172 | 2019-12-05T08:44:24 | 2019-12-05T08:44:24 | 222,203,304 | 0 | 0 | null | 2019-12-04T08:22:34 | 2019-11-17T05:46:49 | null | UTF-8 | Java | false | false | 3,135 | java | package com.example.comp7082.comp7082photogallery.androidos;
import android.media.ExifInterface;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
/**
* utility methods to read and write data to EXIF data tags
*
* Use with android version 24+
*
*/
public class ExifUtility {
public static final String EXIF_KEYWORDS_TAG = ExifInterface.TAG_MAKER_NOTE;
public static final String EXIF_CAPTION_TAG = ExifInterface.TAG_USER_COMMENT;
public static final String EXIF_DATETIME_TAG = ExifInterface.TAG_DATETIME_DIGITIZED;
/**
* reads a string based Exif Tag for the given file
*
* @param exifFile the File object to read from
* @param exifTagName the Exif tag to read from
* @return a string with the Exif tag data
*/
static public String getExifTagString(File exifFile, String exifTagName) {
String exifTagString;
try {
ExifInterface exif = new ExifInterface(exifFile.getCanonicalPath());
exifTagString = exif.getAttribute(exifTagName);
Log.d("getExifTagString", "Read " + exifTagName + ": " + (exifTagString == null ? "is null" : exifTagString));
} catch (IOException e) {
Log.d("getExifTagString", "IOException: " + e.getMessage());
exifTagString = null;
}
return exifTagString;
}
/**
* writes a string to the given Exif tag for the given file
*
* @param exifFile the File object to write to
* @param exifTagName the Exif tag to write to. Should be a string based tag
* @param exifTagValue the Exif string data to write
*/
static public void setExifTagString(File exifFile, String exifTagName, String exifTagValue) {
try {
ExifInterface exif = new ExifInterface(exifFile.getCanonicalPath());
exif.setAttribute(exifTagName, exifTagValue);
exif.saveAttributes();
Log.d("setExifTagString", "Write " + exifTagName + ": " + (exifTagValue == null ? "is null" : exifTagValue));
} catch (IOException e) {
Log.d("setExifTagString", "IOException: " + e.getMessage());
}
}
/**
* gets the latitude and longitude coordinates from the Exif tags
*
* @param exifFile the File object to read from
* @param location the float array to return the latitude and longitude coordinates through
* @return true if latitude and longitude are successfully retrieved, false otherwise
*/
static public boolean getExifLatLong(File exifFile, float[] location) {
boolean result = false;
try {
ExifInterface exif = new ExifInterface(exifFile.getCanonicalPath());
result = exif.getLatLong(location);
Log.d("getExifLatLong", "Read LatLong: " + result + (result ? ": lat: " + location[0] + ": long:" + location[1] : ""));
} catch (IOException e) {
Log.d("getExifLatLong", "IOException: " + e.getMessage());
}
return result;
}
}
| [
"[email protected]"
] | |
df34fab0be99eea3b62280139079859a0342e3fa | ee61434c64bb92be965c3dfc59843cc2ffa3c01b | /GenArView-FW/src/pro/pmmc/genarview/functional/consumer/CLabelComponentTypical.java | 80c6eb983a1836412713f8f7cad143ee80ebbb8e | [] | no_license | paulnetedu/genarview | 6041f68f6233faed5cc056676f90331e4fc75326 | 2b3712e16c25076114c04d907db7d604f10d744b | refs/heads/master | 2016-09-06T20:06:29.798492 | 2015-09-18T14:33:36 | 2015-09-18T14:33:36 | 42,727,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 853 | java | package pro.pmmc.genarview.functional.consumer;
import java.util.List;
import java.util.function.Consumer;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import pro.pmmc.genarview.util.GraphUtil;
public class CLabelComponentTypical implements Consumer<Node> {
private List<String> lstLabel;
public CLabelComponentTypical(List<String> lstLabel) {
this.lstLabel = lstLabel;
}
@Override
public void accept(Node t) {
Transaction tx = GraphUtil.getGraphService().beginTx();
if (t.getProperty("name").equals("SingletonBean")) {
String s = null;
s = null;
}
for (String label : lstLabel) {
t.addLabel(DynamicLabel.label(label));
}
t.setProperty("base", t.getProperty("fullName").toString());
tx.success();
tx.close();
}
}
| [
"[email protected]"
] | |
6156c0bcc6ea7c6d5df9be5867a0620d6f29c760 | 565f813e6950f66f4d9d8e642059cf6fb9b2ebe2 | /src/main/java/app/controllers/BloodDonationCenterController.java | 7632836d9c8308c3426afc02f458fe087ce0a93b | [] | no_license | PDraganovP/blood-donation-system | e484fe7b0d8aea72f36d2f9903743197f74bbdeb | d5d13d980f51b6866c5610575a5483e59d3dc2ff | refs/heads/master | 2020-04-13T08:28:30.077158 | 2019-02-16T14:14:47 | 2019-02-16T14:14:47 | 162,994,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,334 | java | package app.controllers;
import app.entities.Address;
import app.models.bindingModels.BloodDonationCenterRegistrationModel;
import app.models.bindingModels.BloodDonationCenterBindingModel;
import app.models.viewModels.BloodDonatorViewModel;
import app.services.BloodDonationCenterService;
import app.services.BloodDonatorService;
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.validation.FieldError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Set;
@Controller
public class BloodDonationCenterController {
@Autowired
private BloodDonatorService bloodDonatorService;
@Autowired
private BloodDonationCenterService bloodDonationCenterService;
@GetMapping("/blood-donation-center-register")
public String registrationBloodDonationCenter(@ModelAttribute BloodDonationCenterRegistrationModel bloodDonationCenterRegistrationModel) {
return "blood-donation-centers/blood-donation-center-register";
}
@PostMapping("/blood-donation-center-register")
public String registrationBloodDonationCenter(@Valid @ModelAttribute BloodDonationCenterRegistrationModel bloodDonationCenterRegistrationModel, BindingResult result, Model model) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (result.hasErrors()) {
for (FieldError err : fieldErrors) {
String field = err.getField();
String error = err.getDefaultMessage().toString();
String param = field + "Error";
model.addAttribute(param, error);
}
return "blood-donation-centers/blood-donation-center-register";
}
this.bloodDonationCenterService.save(bloodDonationCenterRegistrationModel);
return "redirect:/successfully-edited";
}
@GetMapping("/find-blood-donation-center-by-username")
public String findByUsername() {
return "blood-donation-centers/blood-donation-center";
}
@PostMapping("/find-blood-donation-center-by-username")
public String findByUsername(Model model, String username) {
BloodDonationCenterBindingModel bloodDonationCenter = this.bloodDonationCenterService.findBloodDonationCenterByUsername(username);
if (username == "" || bloodDonationCenter == null) {
return "blood-donation-centers/blood-donation-center";
}
Set<BloodDonatorViewModel> bloodDonators = bloodDonationCenter.getBloodDonators();
model.addAttribute("bloodDonationCenter", bloodDonationCenter);
model.addAttribute("bloodDonators", bloodDonators);
return "blood-donation-centers/blood-donation-center";
}
@RequestMapping("/blood-donation-center-info")
public String getBloodDonatorInfo(HttpServletRequest req, Model model) {
String username = req.getRemoteUser();
BloodDonationCenterBindingModel bloodDonationCenter = this.bloodDonationCenterService.findBloodDonationCenterByUsername(username);
model.addAttribute("bloodDonationCenter",bloodDonationCenter);
return "blood-donation-centers/blood-donation-center-info";
}
@GetMapping("/edit-blood-donation-center")
String edit() {
return "blood-donation-centers/edit-blood-donation-center";
}
@PostMapping("/edit-blood-donation-center")
String edit(String name , Address address, Model model,HttpServletRequest req) {
String user = req.getRemoteUser();
if(user==null){
return "blood-donation-centers/edit-blood-donation-center";
}
BloodDonationCenterBindingModel bloodDonationCenter = this.bloodDonationCenterService.findBloodDonationCenterByUsername(user);
long id = bloodDonationCenter.getId();
this.bloodDonationCenterService.editBloodDonationCenterById(name,address,id);
return "successfully-edited";
}
}
| [
"[email protected]"
] | |
de8ebab6568a3827a38bb09bcf9b96a32970cd2b | abe405c297ee3281d08e0a01138efe7cea76b331 | /src/Abilities/Bard_MassConfusion.java | 7933f1286b1a953c402d62077ef031a47556242b | [] | no_license | Skyman12/AdaptiveAI | 83363727e8d0fb314dbf790d44836b34d9c0ec19 | 4cceb5b8bfd913e356edf10f209aed470e8f3be2 | refs/heads/master | 2016-08-12T12:25:26.964146 | 2016-04-04T02:58:42 | 2016-04-04T02:58:42 | 54,614,223 | 1 | 1 | null | 2016-04-05T00:20:32 | 2016-03-24T04:19:31 | Java | UTF-8 | Java | false | false | 1,408 | java | package Abilities;
import java.util.ArrayList;
import java.util.Random;
import General.AttackType;
import General.Attacks;
import General.Class;
public class Bard_MassConfusion extends Attacks {
public Bard_MassConfusion(Class attacker) {
super(attacker);
attackType = AttackType.ABILITIES;
attackName = "Mass Confusion";
attackDescription = "Targets everyone on the board. 50% chance they choose random targets for the rest of this turn.";
damage = 5;
speed = 5;
cost = 60;
critChance = 0;
numOfTargets = 0;
}
@Override
protected String attack(Class target) {
String result = doBeginningActions(theAttacker, target);
if (!result.equals("Success")) return result;
Random random = new Random();
int confused = random.nextInt(2);
confuse(theAttacker, theTarget, damage, confused);
effectivness = confused * 30;
return "Used " + attackName + " on " + theTarget.name + " -- Confused for " + confused + " turns\n";
}
@Override
public void chooseTargetForAttack(Class target) {
theTargets.addAll(getAlivePlayers(theAttacker));
}
@Override
public boolean getSoftCap() {
ArrayList<Class> players = getAliveAllies(theAttacker);
for (Class p : players) {
if (p.currentHealth + p.currentShield < damage) {
return false;
}
}
return true;
}
@Override
public void chooseAITarget() {
chooseTargetForAttack(theAttacker);
}
}
| [
"[email protected]"
] | |
6e9d9e8983891f78118ae47c76efb7ed99544dc4 | d42f4ea723f12ebdd9fe218762704bac92665f85 | /Pre-Uni-Application/app/src/main/java/com/federation/masters/preuni/models/Assignment.java | 5991507407462b7e1183ebfe2a3779b7b73f34d4 | [] | no_license | kshbharati/Master-Project | ebb70aa3e0bb6a6371657dc9baf2c9d1b071490d | a2f750365b7dc14d737b35e8278da5220380332e | refs/heads/main | 2023-06-04T07:52:24.563911 | 2021-06-14T10:57:15 | 2021-06-14T10:57:15 | 357,791,806 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,384 | java | package com.federation.masters.preuni.models;
import com.google.gson.JsonObject;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class Assignment {
private int id;
private String assignmentTitle;
private String assignmentDesc;
private String assignmentSubmissionDate;
private int assignmentAddedBy;
private int courseId;
ArrayList<Submission> submissions=new ArrayList<Submission>();
public ArrayList<Submission> getSubmissions() {
return submissions;
}
public void setSubmissions(ArrayList<Submission> submissions) {
this.submissions = submissions;
}
public int getId() {
return id;
}
public void setId(int assignmentID) {
this.id = assignmentID;
}
public String getAssignmentTitle() {
return assignmentTitle;
}
public void setAssignmentTitle(String assignmentName) {
this.assignmentTitle = assignmentName;
}
public String getAssignmentDesc() {
return assignmentDesc;
}
public void setAssignmentDesc(String assignmentDesc) {
this.assignmentDesc = assignmentDesc;
}
public String getAssignmentSubmissionDate() {
return assignmentSubmissionDate;
}
public void setAssignmentSubmissionDate(String assignmentSubmissionDate) {
this.assignmentSubmissionDate = assignmentSubmissionDate;
}
public int getAssignmentAddedBy() {
return assignmentAddedBy;
}
public void setAssignmentAddedBy(int assignmentAddedBy) {
this.assignmentAddedBy = assignmentAddedBy;
}
public int getCourseId() {
return courseId;
}
public void setCourseId(int courseId) {
this.courseId = courseId;
}
public JSONObject getAssignmentPutObject()
{
JSONObject request=new JSONObject();
try {
request.put("assignmentTitle",getAssignmentTitle());
request.put("assignmentDesc",getAssignmentDesc());
request.put("assignmentSubmissionDate",getAssignmentSubmissionDate());
request.put("assignmentAddedBy",getAssignmentAddedBy());
request.put("courseId",getCourseId());
} catch (JSONException e) {
e.printStackTrace();
}
return request;
}
}
| [
"[email protected]"
] | |
9130208ba555da683813ce4f5339507cd6f20354 | 81be6755cff2e3166e45f3827dbb998e69bebb53 | /src/main/java/com/CIMthetics/jvulkan/Wayland/Objects/WaylandEventObject.java | 1dd8ac689b181c1b547e2a587229a4dd5ea63605 | [
"Apache-2.0"
] | permissive | dkaip/jvulkan | a48f461c42228c38f6f070e4e1be9962098e839a | ff3547ccc17b39e264b3028672849ccd4e59addc | refs/heads/master | 2021-07-06T23:21:57.192034 | 2020-09-13T23:04:46 | 2020-09-13T23:04:46 | 183,513,821 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,170 | java | /*
* Copyright 2019-2020 Douglas Kaip
*
* 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.CIMthetics.jvulkan.Wayland.Objects;
import com.CIMthetics.jvulkan.VulkanCore.Handles.VulkanHandle;
public class WaylandEventObject
{
private VulkanHandle vulkanHandle;
private boolean dieYaBastard = false;
public WaylandEventObject(VulkanHandle vulkanHandle)
{
this.vulkanHandle = vulkanHandle;
}
void killEventHandler()
{
dieYaBastard = true;
}
boolean isTimeToDie()
{
return dieYaBastard;
}
public VulkanHandle getHandle()
{
return vulkanHandle;
}
}
| [
"[email protected]"
] | |
b242b4fe12863209569905e8c66ef555edbfd74c | 902bcc09384a087787efdc224f1ed266039c5985 | /pcds/src/com/shuhao/clean/apps/model/ext/TextField.java | 756f6bcd5ea79a8c12da8ad6b8b61bcf74343501 | [] | no_license | dfjxpcxm/pcds | d0b80c69110211384bc7f9250067b051753a010c | c5964279f5bcc781423fff248b8dcd7ea78d7e62 | refs/heads/master | 2020-07-02T00:44:05.735317 | 2020-06-29T07:20:28 | 2020-06-29T07:20:28 | 201,363,363 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,158 | java | package com.shuhao.clean.apps.model.ext;
public class TextField extends BaseField {
protected boolean allowBlank = true;
protected String blankText = "่ฏฅ้กนไธ่ฝไธบ็ฉบ";
protected Integer minLength;
protected Integer maxLength;
protected String minLengthText;
protected String maxLengthText ;
public String output(){
StringBuffer buffer = new StringBuffer();
buffer.append("_"+this.name).append("Field = new Ext.form.TextField({").append(enter);
buffer.append(this.fieldParams()).append(",").append(enter);
buffer.append("allowBlank : ").append(this.allowBlank);
if(this.allowBlank){
buffer.append(",").append(enter);
buffer.append("blankText : '").append(this.blankText).append("'");
}
if(isNotNull(this.minLength)){
buffer.append(",").append(enter);
buffer.append("minLength : ").append(this.minLength).append(",").append(enter);
buffer.append("minLengthText : '").append(this.minLengthText).append("'");
}
if(isNotNull(this.maxLength)){
buffer.append(",").append(enter);
buffer.append("maxLength : ").append(this.maxLength).append(",").append(enter);
buffer.append("maxLengthText : '").append(this.maxLengthText).append("'");
}
buffer.append(enter);
buffer.append("})").append(enter);
return buffer.toString();
}
public boolean isAllowBlank() {
return allowBlank;
}
public void setAllowBlank(boolean allowBlank) {
this.allowBlank = allowBlank;
}
public String getBlankText() {
return blankText;
}
public void setBlankText(String blankText) {
this.blankText = blankText;
}
public Integer getMinLength() {
return minLength;
}
public void setMinLength(Integer minLength) {
this.minLength = minLength;
}
public Integer getMaxLength() {
return maxLength;
}
public void setMaxLength(Integer maxLength) {
this.maxLength = maxLength;
}
public String getMinLengthText() {
return minLengthText;
}
public void setMinLengthText(String minLengthText) {
this.minLengthText = minLengthText;
}
public String getMaxLengthText() {
return maxLengthText;
}
public void setMaxLengthText(String maxLengthText) {
this.maxLengthText = maxLengthText;
}
}
| [
"[email protected]"
] | |
655b7c6f0739a9a365055db4859ab3f30c6e90a6 | e0dc7b0066aedd07d54ae7f17a6d4bf590dbd58e | /JohanPersonnal/AndroidLearning/Dev/app/src/main/java/com/johan/dev/ApplicationProvider.java | f25a5f1308aded58c1027983ae4c238a68972e59 | [] | no_license | lanzrein/coms309projectISU | 4397ef87face546abb4c2756452d220fe83f6dc7 | b58c81534e58ff3e2536406eb5b84ac7b458e735 | refs/heads/master | 2021-10-21T15:03:27.098145 | 2019-03-04T16:18:56 | 2019-03-04T16:18:56 | 121,995,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 450 | java | package com.johan.dev;
import android.app.Application;
import android.content.Context;
/**
* Created by johan on 13.09.2017.
*/
public class ApplicationProvider extends Application {
private static Context sApplicationContext;
@Override
public void onCreate(){
super.onCreate();
sApplicationContext = getApplicationContext();
}
public static Context getContext(){
return sApplicationContext;
}
}
| [
"[email protected]"
] | |
04f49f21d0fbe5fc4a32c4cb1873893b422022d7 | 3a2c5f0f73f90b749ca324851b83e11de4195553 | /Day02_Spring01/src/main/java/cn/sust/service/impl/AccountServiceImpl.java | a6b5e9d6de2ed13e4c4ce9010dec19d334c95ede | [] | no_license | aikudezizizi/Spring | 358080ff0562bc401fbe36d1126179b227885936 | 30a2dcb2576938922ab3e6ac09c258c6c52cbbcb | refs/heads/master | 2022-06-26T09:46:56.039032 | 2019-12-07T12:34:07 | 2019-12-07T12:34:07 | 226,509,180 | 0 | 0 | null | 2022-06-21T02:24:02 | 2019-12-07T12:28:40 | Java | UTF-8 | Java | false | false | 863 | java | package cn.sust.service.impl;
import cn.sust.dao.AccountDao;
import cn.sust.domain.Account;
import cn.sust.service.AccountService;
import java.util.List;
public class AccountServiceImpl implements AccountService {
private AccountDao accountDao;
public void setAccountDao(AccountDao accountDao) {
this.accountDao = accountDao;
}
@Override
public void save(Account account) {
accountDao.save(account);
}
@Override
public void update(Account account) {
accountDao.update(account);
}
@Override
public void delete(Integer accountId) {
accountDao.delete(accountId);
}
@Override
public Account findById(Integer accountid) {
return accountDao.findById(accountid);
}
@Override
public List<Account> findAll() {
return accountDao.findAll();
}
}
| [
"[email protected]"
] | |
57eaa93bc578ac868c81eeb6ceeacebf8687eee3 | c534f1bf74397e7600c87b8fa13c756afff6e019 | /COMP3-ExercรญcioPresencial/Exercรญcio Presencial - Patrรญcia Wang/DO_SL_GATW/src/entidades/ComodoComposto.java | e67533b96a9763f3e4f39d2b742ed7a8d4e37d35 | [] | no_license | patywang/git-ufrrj | ffceac0b687774cbcd5b9533c8b4612463679c99 | 155df82e2b99bc37d6d63cc155e36d07a940bafe | refs/heads/master | 2021-01-11T20:45:28.729019 | 2017-01-17T02:50:34 | 2017-01-17T02:50:34 | 79,178,777 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,179 | java | package entidades;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import dao.ComodoDAO;
import dao.MobiliaDAO;
public class ComodoComposto extends Comodo{
private List<Comodo>comodos;
public ComodoComposto(){super();};
public ComodoComposto(String desc, String tipo){
super(desc,tipo);
}
public List<Comodo> getComodos() {
return comodos;
}
public void setComodos(List<Comodo> comodos) {
this.comodos = comodos;
}
@Override
public Map<Integer,String> listaMobiliaDisponivel() {
return null;
}
public static List<Mobilia> listarMobilias(int id) throws SQLException{
MobiliaDAO dao = new MobiliaDAO();
ComodoDAO comodoDAO = new ComodoDAO();
List<Mobilia>mob = new ArrayList<Mobilia>();
try {
List<Comodo>lista = comodoDAO.recuperarComodoComposto(id);
if(lista != null && !lista.isEmpty()){
for (Comodo comodo2 : lista) {
mob.addAll(listarMobilias(comodo2.getIdComodo()));
System.out.println(comodo2.getIdComodo());
}
}
} catch (SQLException e) {
e.printStackTrace();
}
mob.addAll(dao.listarMobiliasPorComodo(id));
return mob;
}
}
| [
"[email protected]"
] | |
72f6742835f5eff8b967d146c272e2d05474cf95 | 101b51235317a530229e0b47d69c897d5a004a74 | /master-detail/src/main/java/com/modelncode/crudpattern/domain/exception/DomainException.java | 5c4f3d73449c44216241d529c2eb0e5c557b836d | [] | no_license | modelandcode/java-crud-patterns | a8c4e456ca896ec9d524bbf82971cb2b02f66bd5 | 22ce290ed6410cf8682906cf347eb3655f344efd | refs/heads/master | 2021-01-25T11:27:59.980736 | 2017-12-12T14:50:23 | 2017-12-12T14:50:23 | 93,928,626 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | package com.modelncode.crudpattern.domain.exception;
/**
* Created by g on 2017-06-12.
*/
public class DomainException extends RuntimeException {
static final long serialVersionUID = 1;
private String errorMessage;
public DomainException() {
super();
}
public DomainException(Throwable throwable, String errorMessage){
super(errorMessage, throwable);
this.errorMessage = errorMessage;
}
public DomainException(String errorMessage){
super(errorMessage);
this.errorMessage = errorMessage;
}
public DomainException(Throwable throwable){
super(throwable);
}
public String getErrorMessage() {
return errorMessage;
}
}
| [
"[email protected]"
] | |
2f46ab29c5307c71ece7e1098dcd20a6d84c553b | 31cf98fc9e5f64f8529174e8afedf426f3c88af6 | /MissedCall2Sms/src/com/bitbee/android/missedcall2sms/MissedCallContentObserver.java | 44ed0ae72b5805631dae5adcd585ba733dd3e2fa | [] | no_license | leo4all/pangu | f0eba0e0732d1253a5ce73a0a11bbc2d298ddace | 51cc7d6abcb5ba67eb6550e0a7e6aab07e5d464b | refs/heads/master | 2016-09-11T02:53:17.203732 | 2011-08-04T08:16:45 | 2011-08-04T08:16:45 | 34,941,196 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,371 | java | package com.bitbee.android.missedcall2sms;
import java.text.SimpleDateFormat;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Handler;
import android.provider.CallLog.Calls;
import android.telephony.SmsManager;
import android.util.Log;
public class MissedCallContentObserver extends ContentObserver {
private Context ctx;
private String _phoneNumber;
private static Long lastTime = new Long(System.currentTimeMillis());
private static final String TAG = "MissedCallContentObserver";
public MissedCallContentObserver(Context context, Handler handler , String phone_number) {
super(handler);
ctx = context;
_phoneNumber = phone_number;
}
@Override
public void onChange(boolean selfChange) {
Cursor csr = ctx.getContentResolver().query(Calls.CONTENT_URI,
new String[] { Calls.NUMBER, Calls.TYPE, Calls.NEW, Calls.DATE, Calls.CACHED_NAME }, null,
null, Calls.DEFAULT_SORT_ORDER);
if (csr != null) {
if (csr.moveToFirst()) {
int type = csr.getInt(csr.getColumnIndex(Calls.TYPE));
switch (type) {
case Calls.MISSED_TYPE:
if(lastTime < csr.getLong(csr.getColumnIndex(Calls.DATE))){
Log.v(TAG, "missed type");
SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
String strMsg = "";
String _number = csr.getString(csr.getColumnIndex(Calls.NUMBER));
String _name = csr.getString(csr.getColumnIndex(Calls.CACHED_NAME));
if(_name == null){
strMsg = _number + "ไบ" + df.format(csr.getLong(csr.getColumnIndex(Calls.DATE))) + "็ปไฝ ๆ่ฟ็ต่ฏใ";
}else{
strMsg = _number + "(" + _name + ")ไบ" + df.format(csr.getLong(csr.getColumnIndex(Calls.DATE))) + "็ปไฝ ๆ่ฟ็ต่ฏใ";
}
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(_phoneNumber, null,strMsg, null, null);
lastTime = csr.getLong(csr.getColumnIndex(Calls.DATE));
}
break;
case Calls.INCOMING_TYPE:
Log.v(TAG, "incoming type");
break;
case Calls.OUTGOING_TYPE:
Log.v(TAG, "outgoing type");
break;
}
}
csr.close();
}
}
@Override
public boolean deliverSelfNotifications() {
return super.deliverSelfNotifications();
}
}
| [
"[email protected]@4d87f418-fb31-0410-b12f-21406559f0cb"
] | [email protected]@4d87f418-fb31-0410-b12f-21406559f0cb |
dc2d11b5f6710e6110ec13cfa1d0d0d2a3741a23 | ede8047f1c4a33f35f7ea5251f431ab87aef81b6 | /PrefuseDemo/src/Visualization/VisualizationComponent.java | fdaf28ba75f2f8f8b582838ce555cac47074a203 | [] | no_license | pi11e/PrefuseKinect | ac95c8322cd4a324d2c10421d5037f3a7d1a1c16 | 878d811c4541e10a80d9bc474610f9656c7a6c07 | refs/heads/master | 2016-08-06T16:13:10.665531 | 2013-02-11T09:37:13 | 2013-02-11T09:37:13 | 8,093,470 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,846 | java | package Visualization;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import prefuse.Constants;
import prefuse.Display;
import prefuse.Visualization;
import prefuse.action.ActionList;
import prefuse.action.GroupAction;
import prefuse.action.ItemAction;
import prefuse.action.RepaintAction;
import prefuse.action.animate.ColorAnimator;
import prefuse.action.animate.PolarLocationAnimator;
import prefuse.action.animate.QualityControlAnimator;
import prefuse.action.animate.VisibilityAnimator;
import prefuse.action.assignment.ColorAction;
import prefuse.action.assignment.FontAction;
import prefuse.action.layout.CollapsedSubtreeLayout;
import prefuse.action.layout.graph.RadialTreeLayout;
import prefuse.activity.SlowInSlowOutPacer;
import prefuse.controls.ControlAdapter;
import prefuse.controls.DragControl;
import prefuse.controls.FocusControl;
import prefuse.controls.HoverActionControl;
import prefuse.controls.PanControl;
import prefuse.controls.ZoomControl;
import prefuse.controls.ZoomToFitControl;
import prefuse.data.Graph;
import prefuse.data.Node;
import prefuse.data.Table;
import prefuse.data.Tuple;
import prefuse.data.event.TupleSetListener;
import prefuse.data.io.GraphMLReader;
import prefuse.data.query.SearchQueryBinding;
import prefuse.data.search.PrefixSearchTupleSet;
import prefuse.data.search.SearchTupleSet;
import prefuse.data.tuple.DefaultTupleSet;
import prefuse.data.tuple.TupleSet;
import prefuse.demos.TreeMap.NodeRenderer;
import prefuse.render.AbstractShapeRenderer;
import prefuse.render.DefaultRendererFactory;
import prefuse.render.EdgeRenderer;
import prefuse.render.LabelRenderer;
import prefuse.render.Renderer;
import prefuse.render.ShapeRenderer;
import prefuse.util.ColorLib;
import prefuse.util.FontLib;
import prefuse.util.ui.JFastLabel;
import prefuse.util.ui.JSearchPanel;
import prefuse.util.ui.UILib;
import prefuse.visual.VisualItem;
import prefuse.visual.expression.InGroupPredicate;
import prefuse.visual.sort.TreeDepthItemSorter;
/**
* Demonstration of a node-link tree viewer
*
* @version 1.0
* @author <a href="http://jheer.org">jeffrey heer</a>
*/
public class VisualizationComponent extends Display {
/**
*
*/
private static final long serialVersionUID = 1L;
private static VisualizationComponent instance;
public static final String DATA_FILE = "/data.xml";
private static final String tree = "tree";
private static final String treeNodes = "tree.nodes";
private static final String treeEdges = "tree.edges";
private static final String linear = "linear";
private LabelRenderer m_nodeRenderer;
private NodeRenderer m_customNodeRenderer;
private EdgeRenderer m_edgeRenderer;
private String m_label = "label";
public VisualizationComponent(Graph g, String label) {
super(new Visualization());
m_label = label;
// -- set up visualization --
m_vis.add(tree, g);
m_vis.setInteractive(treeEdges, null, false);
// -- set up renderers --
/* ORIGINAL CODE */
m_nodeRenderer = new LabelRenderer(m_label);
m_nodeRenderer.setRenderType(AbstractShapeRenderer.RENDER_TYPE_FILL);
m_nodeRenderer.setHorizontalAlignment(Constants.CENTER);
m_nodeRenderer.setRoundedCorner(8,8);
DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer);
rf.add(new InGroupPredicate(treeEdges), m_edgeRenderer);
m_vis.setRendererFactory(rf);
/* END OF ORIGINAL CODE */
/*
* Try to set up renderers that will display
* - nodes as circles (SLUB-red filled)
* - labels to the side of the circle (if possible, *outside*; i.e. facing away from center of radial graph)
*/
// label here is "name", referring to the "name" property given in the xml data file
/*
m_nodeRenderer = new ShapeRenderer();
m_nodeRenderer.setRenderType(AbstractShapeRenderer.RENDER_TYPE_FILL);
m_nodeRenderer.setBaseSize(20);
m_edgeRenderer = new EdgeRenderer();
DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer);
rf.add(new InGroupPredicate(treeEdges), m_edgeRenderer);
m_vis.setRendererFactory(rf);
*/
// -- set up processing actions --
// colors
ItemAction nodeColor = new NodeColorAction(treeNodes);
ItemAction textColor = new TextColorAction(treeNodes);
m_vis.putAction("textColor", textColor);
ItemAction edgeColor = new ColorAction(treeEdges,
VisualItem.STROKECOLOR, ColorLib.rgb(200,200,200));
FontAction fonts = new FontAction(treeNodes,
FontLib.getFont("Tahoma", 10));
fonts.add("ingroup('_focus_')", FontLib.getFont("Tahoma", 11));
// recolor
ActionList recolor = new ActionList();
recolor.add(nodeColor);
recolor.add(textColor);
m_vis.putAction("recolor", recolor);
// repaint
ActionList repaint = new ActionList();
repaint.add(recolor);
repaint.add(new RepaintAction());
m_vis.putAction("repaint", repaint);
// animate paint change
ActionList animatePaint = new ActionList(400);
animatePaint.add(new ColorAnimator(treeNodes));
animatePaint.add(new RepaintAction());
m_vis.putAction("animatePaint", animatePaint);
// create the tree layout action
RadialTreeLayout treeLayout = new RadialTreeLayout(tree);
//treeLayout.setAngularBounds(-Math.PI/2, Math.PI);
m_vis.putAction("treeLayout", treeLayout);
CollapsedSubtreeLayout subLayout = new CollapsedSubtreeLayout(tree);
m_vis.putAction("subLayout", subLayout);
// create the filtering and layout
ActionList filter = new ActionList();
filter.add(new TreeRootAction(tree));
filter.add(fonts);
filter.add(treeLayout);
filter.add(subLayout);
filter.add(textColor);
filter.add(nodeColor);
filter.add(edgeColor);
m_vis.putAction("filter", filter);
// animated transition
ActionList animate = new ActionList(1250);
animate.setPacingFunction(new SlowInSlowOutPacer());
animate.add(new QualityControlAnimator());
animate.add(new VisibilityAnimator(tree));
animate.add(new PolarLocationAnimator(treeNodes, linear));
animate.add(new ColorAnimator(treeNodes));
animate.add(new RepaintAction());
m_vis.putAction("animate", animate);
m_vis.alwaysRunAfter("filter", "animate");
// ------------------------------------------------
// initialize the display
this.setSize(600,600);
setItemSorter(new TreeDepthItemSorter());
addControlListener(new DragControl());
addControlListener(new ZoomToFitControl());
addControlListener(new ZoomControl());
addControlListener(new PanControl());
addControlListener(new FocusControl(1, "filter"));
addControlListener(new HoverActionControl("repaint"));
// ------------------------------------------------
// filter graph and perform layout
m_vis.run("filter");
// maintain a set of items that should be interpolated linearly
// this isn't absolutely necessary, but makes the animations nicer
// the PolarLocationAnimator should read this set and act accordingly
m_vis.addFocusGroup(linear, new DefaultTupleSet());
m_vis.getGroup(Visualization.FOCUS_ITEMS).addTupleSetListener(
new TupleSetListener() {
public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
TupleSet linearInterp = m_vis.getGroup(linear);
if ( add.length < 1 ) return; linearInterp.clear();
for ( Node n = (Node)add[0]; n!=null; n=n.getParent() )
linearInterp.addTuple(n);
}
}
);
SearchTupleSet search = new PrefixSearchTupleSet();
m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, search);
search.addTupleSetListener(new TupleSetListener() {
public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
m_vis.cancel("animatePaint");
m_vis.run("recolor");
m_vis.run("animatePaint");
}
});
}
public static JPanel createPanel()
{
Graph g = null;
try {
// construct graph instance from data given in DATA_FILE path (XML format)
g = new GraphMLReader().readGraph(DATA_FILE);
} catch ( Exception e ) {
e.printStackTrace();
System.exit(1);
}
return demo(g, "name");
}
public void updateSize()
{
m_vis.run("treeLayout");
}
public static VisualizationComponent getInstance()
{
return instance;
}
private static JPanel demo(Graph g, final String label) {
// create a new radial tree view
final VisualizationComponent gview = new VisualizationComponent(g, label);
VisualizationComponent.instance = gview;
Visualization vis = gview.getVisualization();
//
// // create a search panel for the tree map
// SearchQueryBinding sq = new SearchQueryBinding(
// (Table)vis.getGroup(treeNodes), label,
// (SearchTupleSet)vis.getGroup(Visualization.SEARCH_ITEMS));
// JSearchPanel search = sq.createSearchPanel();
// search.setShowResultCount(true);
// search.setBorder(BorderFactory.createEmptyBorder(5,5,4,0));
// search.setFont(FontLib.getFont("Tahoma", Font.PLAIN, 11));
//
// final JFastLabel title = new JFastLabel(" ");
// title.setPreferredSize(new Dimension(350, 20));
// title.setVerticalAlignment(SwingConstants.BOTTOM);
// title.setBorder(BorderFactory.createEmptyBorder(3,0,0,0));
// title.setFont(FontLib.getFont("Tahoma", Font.PLAIN, 16));
//
// gview.addControlListener(new ControlAdapter() {
// public void itemEntered(VisualItem item, MouseEvent e) {
// if ( item.canGetString(label) )
// title.setText(item.getString(label));
// }
// public void itemExited(VisualItem item, MouseEvent e) {
// title.setText(null);
// }
// });
//
// Box box = new Box(BoxLayout.X_AXIS);
// box.add(Box.createHorizontalStrut(10));
// box.add(title);
// box.add(Box.createHorizontalGlue());
// box.add(search);
// box.add(Box.createHorizontalStrut(3));
JPanel panel = new JPanel(new BorderLayout());
panel.add(gview, BorderLayout.CENTER);
// panel.add(box, BorderLayout.SOUTH);
Color BACKGROUND = Color.WHITE;
Color FOREGROUND = Color.DARK_GRAY;
UILib.setColor(panel, BACKGROUND, FOREGROUND);
return panel;
}
// ------------------------------------------------------------------------
/**
* Switch the root of the tree by requesting a new spanning tree
* at the desired root
*/
public static class TreeRootAction extends GroupAction {
public TreeRootAction(String graphGroup) {
super(graphGroup);
}
public void run(double frac) {
TupleSet focus = m_vis.getGroup(Visualization.FOCUS_ITEMS);
if ( focus==null || focus.getTupleCount() == 0 ) return;
Graph g = (Graph)m_vis.getGroup(m_group);
Node f = null;
Iterator tuples = focus.tuples();
while (tuples.hasNext() && !g.containsTuple(f=(Node)tuples.next()))
{
f = null;
}
if ( f == null ) return;
g.getSpanningTree(f);
}
}
/**
* Set node fill colors
*/
public static class NodeColorAction extends ColorAction {
public NodeColorAction(String group) {
super(group, VisualItem.FILLCOLOR, ColorLib.rgba(255,255,255,0));
add("_hover", ColorLib.gray(220,230));
add("ingroup('_search_')", ColorLib.rgb(255,190,190));
add("ingroup('_focus_')", ColorLib.rgb(198,229,229));
}
} // end of inner class NodeColorAction
/**
* Set node text colors
*/
public static class TextColorAction extends ColorAction {
public TextColorAction(String group) {
super(group, VisualItem.TEXTCOLOR, ColorLib.gray(0));
add("_hover", ColorLib.rgb(255,0,0));
}
} // end of inner class TextColorAction
} // end of class RadialGraphView
| [
"[email protected]"
] | |
ee160d6fb47cbfcdffb951b80e82106ec93a1d1a | 15e1aeed93809b3228ec2c24c7df68119dda3eba | /library/src/main/java/library/DictImpl.java | b75ebe6d1992fc3703ddd33acfabfa62957f18f6 | [] | no_license | NivShalmon/software-design-2 | 1d7ab1adf8cd2671e78535e7c9c23c7df345aeb2 | cd1a7cf7781393fc5cc4f0943c77c77f593968a3 | refs/heads/master | 2021-01-23T12:33:21.642662 | 2017-09-12T05:30:32 | 2017-09-12T05:30:32 | 93,169,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,842 | java | package library;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import il.ac.technion.cs.sd.buy.ext.FutureLineStorage;
import il.ac.technion.cs.sd.buy.ext.FutureLineStorageFactory;
/**
* The provided implementation of {@link Dict}, using {@link FutureLineStorage}
*
* @see {@link DictFactory} and {@link LibraryModule} for more info on how to
* create an instance
*/
public class DictImpl implements Dict {
private final FutureLineStorage storer;
private final Map<String, String> pairs = new HashMap<>();
@Inject
DictImpl(FutureLineStorageFactory factory, //
@Assisted String name) {
try {
storer = factory.open(name).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
public CompletableFuture<Void> store() {
return storeToStorage(pairs, storer).thenAccept(s -> {
});
}
static CompletableFuture<Void> storeToStorage(Map<String, String> map, FutureLineStorage store) {
try {
for (String key : map.keySet().stream().sorted().collect(Collectors.toList())) {
store.appendLine(key).get();
store.appendLine(map.get(key)).get();
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
return CompletableFuture.completedFuture(null);
}
@Override
public void add(String key, String value) {
pairs.put(key, value);
}
@Override
public void addAll(Map<String, String> ps) {
pairs.putAll(ps);
}
@Override
public CompletableFuture<Optional<String>> find(String key) {
return BinarySearch.valueOf(storer, key, 0, storer.numberOfLines());
}
}
| [
"[email protected]"
] | |
e350e5c04b44e416137daca9c3cac73296e4b032 | a00326c0e2fc8944112589cd2ad638b278f058b9 | /src/main/java/000/147/470/CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75a.java | a5248226ee7f75c5be27a357a356db39c347428d | [] | no_license | Lanhbao/Static-Testing-for-Juliet-Test-Suite | 6fd3f62713be7a084260eafa9ab221b1b9833be6 | b095b11c7cb6d4a5bb2b76181e35d6ee00e96e68 | refs/heads/master | 2020-08-24T13:34:04.004149 | 2019-10-25T09:26:00 | 2019-10-25T09:26:00 | 216,822,684 | 0 | 1 | null | 2019-11-08T09:51:54 | 2019-10-22T13:37:13 | Java | UTF-8 | Java | false | false | 6,906 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75a.java
Label Definition File: CWE89_SQL_Injection.label.xml
Template File: sources-sinks-75a.tmpl.java
*/
/*
* @description
* CWE: 89 SQL Injection
* BadSource: getParameter_Servlet Read data from a querystring using getParameter()
* GoodSource: A hardcoded string
* Sinks: executeUpdate
* GoodSink: Use prepared statement and executeUpdate (properly)
* BadSink : data concatenated into SQL statement used in executeUpdate(), which could result in SQL Injection
* Flow Variant: 75 Data flow: data passed in a serialized object from one method to another in different source files in the same package
*
* */
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import javax.servlet.http.*;
public class CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75a extends AbstractTestCaseServlet
{
public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
/* POTENTIAL FLAW: Read data from a querystring using getParameter */
data = request.getParameter("name");
/* serialize data to a byte array */
ByteArrayOutputStream streamByteArrayOutput = null;
ObjectOutput outputObject = null;
try
{
streamByteArrayOutput = new ByteArrayOutputStream() ;
outputObject = new ObjectOutputStream(streamByteArrayOutput) ;
outputObject.writeObject(data);
byte[] dataSerialized = streamByteArrayOutput.toByteArray();
(new CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75b()).badSink(dataSerialized , request, response );
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "IOException in serialization", exceptIO);
}
finally
{
/* clean up stream writing objects */
try
{
if (outputObject != null)
{
outputObject.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ObjectOutputStream", exceptIO);
}
try
{
if (streamByteArrayOutput != null)
{
streamByteArrayOutput.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ByteArrayOutputStream", exceptIO);
}
}
}
public void good(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
goodG2B(request, response);
goodB2G(request, response);
}
/* goodG2B() - use GoodSource and BadSink */
private void goodG2B(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
/* FIX: Use a hardcoded string */
data = "foo";
/* serialize data to a byte array */
ByteArrayOutputStream streamByteArrayOutput = null;
ObjectOutput outputObject = null;
try
{
streamByteArrayOutput = new ByteArrayOutputStream() ;
outputObject = new ObjectOutputStream(streamByteArrayOutput) ;
outputObject.writeObject(data);
byte[] dataSerialized = streamByteArrayOutput.toByteArray();
(new CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75b()).goodG2BSink(dataSerialized , request, response );
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "IOException in serialization", exceptIO);
}
finally
{
/* clean up stream writing objects */
try
{
if (outputObject != null)
{
outputObject.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ObjectOutputStream", exceptIO);
}
try
{
if (streamByteArrayOutput != null)
{
streamByteArrayOutput.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ByteArrayOutputStream", exceptIO);
}
}
}
/* goodB2G() - use BadSource and GoodSink */
private void goodB2G(HttpServletRequest request, HttpServletResponse response) throws Throwable
{
String data;
/* POTENTIAL FLAW: Read data from a querystring using getParameter */
data = request.getParameter("name");
/* serialize data to a byte array */
ByteArrayOutputStream streamByteArrayOutput = null;
ObjectOutput outputObject = null;
try
{
streamByteArrayOutput = new ByteArrayOutputStream() ;
outputObject = new ObjectOutputStream(streamByteArrayOutput) ;
outputObject.writeObject(data);
byte[] dataSerialized = streamByteArrayOutput.toByteArray();
(new CWE89_SQL_Injection__getParameter_Servlet_executeUpdate_75b()).goodB2GSink(dataSerialized , request, response );
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "IOException in serialization", exceptIO);
}
finally
{
/* clean up stream writing objects */
try
{
if (outputObject != null)
{
outputObject.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ObjectOutputStream", exceptIO);
}
try
{
if (streamByteArrayOutput != null)
{
streamByteArrayOutput.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing ByteArrayOutputStream", exceptIO);
}
}
}
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"[email protected]"
] | |
6ecaddac486dc0f9d1878bafaf2ef35291a551a4 | 35588ed2085b0d8cbd36c16e2ad2d860519f8158 | /addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/appmanager/HelperBase.java | aab5538497f41e4b0b13622f6626815fa11f7c8c | [
"Apache-2.0"
] | permissive | OlgaSaw/java_kurs | 36ec7202864471a78775116722bbf85b05bbd526 | e2de028b4c41be3af7ed200390f5ef2bc16f0f0f | refs/heads/master | 2020-04-07T03:05:04.885253 | 2019-03-28T18:59:58 | 2019-03-28T18:59:58 | 158,001,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,251 | java | package ru.stqa.pft.addressbook.appmanager;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import java.io.File;
public class HelperBase {
protected WebDriver wd;
public HelperBase(WebDriver wd) {
this.wd=wd;
}
protected void click(By locator) {
wd.findElement(locator).click();
}
protected void type(By locator, String text) {
click(locator);
if (text !=null) {
String existingText = wd.findElement(locator).getAttribute("value");
if (! text.equals(existingText)){
wd.findElement(locator).clear();
wd.findElement(locator).sendKeys(text);
}
}
}
protected void attach(By locator, File file) {
if (file !=null) {
wd.findElement(locator).sendKeys(file.getAbsolutePath());
}
}
public boolean isAlertPresent() {
try {
wd.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
protected boolean isElementPresent(By locator) {
try {
wd.findElement(locator);
return true;
} catch (NoSuchElementException ex) {
return false;
}
}
}
| [
"[email protected]"
] | |
392390e3d27a23efea2705144c1f9a76b6453298 | ac77a4f904b026a6c3abc23f102e32f99f12eb7a | /MyCassandra-0.2.1/src/java/org/apache/cassandra/tools/NodeCmd.java | cad3af9f7b326d42599f99607ddfe8b50244c8d3 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | sunsuk7tp/MyCassandra | 2e1075b09d472619b0e23195504213cc0c83ca0b | 5da67c4ab57a0a581e2ce639fb512b144a4bb203 | refs/heads/master | 2020-04-05T23:44:55.034171 | 2019-06-05T14:57:13 | 2019-06-05T14:57:13 | 693,666 | 14 | 4 | Apache-2.0 | 2023-03-20T11:53:48 | 2010-05-30T07:33:12 | Java | UTF-8 | Java | false | false | 32,957 | java | package org.apache.cassandra.tools;
/*
*
* 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.
*
*/
import java.io.IOException;
import java.io.PrintStream;
import java.lang.management.MemoryUsage;
import java.net.InetAddress;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import org.apache.cassandra.utils.Pair;
import org.apache.cassandra.config.ConfigurationException;
import org.apache.commons.cli.*;
import org.apache.cassandra.cache.JMXInstrumentedCacheMBean;
import org.apache.cassandra.concurrent.IExecutorMBean;
import org.apache.cassandra.db.ColumnFamilyStoreMBean;
import org.apache.cassandra.db.CompactionManagerMBean;
import org.apache.cassandra.dht.Token;
import org.apache.cassandra.net.MessagingServiceMBean;
import org.apache.cassandra.utils.EstimatedHistogram;
public class NodeCmd
{
private static final Pair<String, String> HOST_OPT = new Pair<String, String>("h", "host");
private static final Pair<String, String> PORT_OPT = new Pair<String, String>("p", "port");
private static final Pair<String, String> USERNAME_OPT = new Pair<String, String>("u", "username");
private static final Pair<String, String> PASSWORD_OPT = new Pair<String, String>("pw", "password");
private static final int DEFAULT_PORT = 8080;
private static ToolOptions options = null;
private NodeProbe probe;
static
{
options = new ToolOptions();
options.addOption(HOST_OPT, true, "node hostname or ip address", true);
options.addOption(PORT_OPT, true, "remote jmx agent port number");
options.addOption(USERNAME_OPT, true, "remote jmx agent username");
options.addOption(PASSWORD_OPT, true, "remote jmx agent password");
}
public NodeCmd(NodeProbe probe)
{
this.probe = probe;
}
public enum NodeCommand
{
RING, INFO, CFSTATS, SNAPSHOT, CLEARSNAPSHOT, VERSION, TPSTATS, FLUSH, DRAIN,
DECOMMISSION, MOVE, LOADBALANCE, REMOVETOKEN, REPAIR, CLEANUP, COMPACT, SCRUB,
SETCACHECAPACITY, GETCOMPACTIONTHRESHOLD, SETCOMPACTIONTHRESHOLD, NETSTATS, CFHISTOGRAMS,
COMPACTIONSTATS, DISABLEGOSSIP, ENABLEGOSSIP, INVALIDATEKEYCACHE, INVALIDATEROWCACHE,
DISABLETHRIFT, ENABLETHRIFT, JOIN
}
/**
* Prints usage information to stdout.
*/
private static void printUsage()
{
HelpFormatter hf = new HelpFormatter();
StringBuilder header = new StringBuilder();
header.append("\nAvailable commands:\n");
// No args
addCmdHelp(header, "ring", "Print informations on the token ring");
addCmdHelp(header, "join", "Join the ring");
addCmdHelp(header, "info", "Print node informations (uptime, load, ...)");
addCmdHelp(header, "cfstats", "Print statistics on column families");
addCmdHelp(header, "clearsnapshot", "Remove all existing snapshots");
addCmdHelp(header, "version", "Print cassandra version");
addCmdHelp(header, "tpstats", "Print usage statistics of thread pools");
addCmdHelp(header, "drain", "Drain the node (stop accepting writes and flush all column families)");
addCmdHelp(header, "decommission", "Decommission the node");
addCmdHelp(header, "loadbalance", "Loadbalance the node");
addCmdHelp(header, "compactionstats", "Print statistics on compactions");
addCmdHelp(header, "disablegossip", "Disable gossip (effectively marking the node dead)");
addCmdHelp(header, "enablegossip", "Reenable gossip");
addCmdHelp(header, "disablethrift", "Disable thrift server");
addCmdHelp(header, "enablethrift", "Reenable thrift server");
// One arg
addCmdHelp(header, "snapshot [snapshotname]", "Take a snapshot using optional name snapshotname");
addCmdHelp(header, "netstats [host]", "Print network information on provided host (connecting node by default)");
addCmdHelp(header, "move <new token>", "Move node on the token ring to a new token");
addCmdHelp(header, "removetoken status|force|<token>", "Show status of current token removal, force completion of pending removal or remove providen token");
// Two args
addCmdHelp(header, "flush [keyspace] [cfnames]", "Flush one or more column family");
addCmdHelp(header, "repair [keyspace] [cfnames]", "Repair one or more column family");
addCmdHelp(header, "cleanup [keyspace] [cfnames]", "Run cleanup on one or more column family");
addCmdHelp(header, "compact [keyspace] [cfnames]", "Force a (major) compaction on one or more column family");
addCmdHelp(header, "scrub [keyspace] [cfnames]", "Scrub (rebuild sstables for) one or more column family");
addCmdHelp(header, "invalidatekeycache [keyspace] [cfnames]", "Invalidate the key cache of one or more column family");
addCmdHelp(header, "invalidaterowcache [keyspace] [cfnames]", "Invalidate the key cache of one or more column family");
addCmdHelp(header, "getcompactionthreshold <keyspace> <cfname>", "Print min and max compaction thresholds for a given column family");
addCmdHelp(header, "cfhistograms <keyspace> <cfname>", "Print statistic histograms for a given column family");
// Four args
addCmdHelp(header, "setcachecapacity <keyspace> <cfname> <keycachecapacity> <rowcachecapacity>", "Set the key and row cache capacities of a given column family");
addCmdHelp(header, "setcompactionthreshold <keyspace> <cfname> <minthreshold> <maxthreshold>", "Set the min and max compaction thresholds for a given column family");
String usage = String.format("java %s --host <arg> <command>%n", NodeCmd.class.getName());
hf.printHelp(usage, "", options, "");
System.out.println(header.toString());
}
private static void addCmdHelp(StringBuilder sb, String cmd, String description)
{
sb.append(" ").append(cmd);
// Ghetto indentation (trying, but not too hard, to not look too bad)
if (cmd.length() <= 20)
for (int i = cmd.length(); i < 22; ++i) sb.append(" ");
sb.append(" - ").append(description).append("\n");
}
/**
* Write a textual representation of the Cassandra ring.
*
* @param outs the stream to write to
*/
public void printRing(PrintStream outs)
{
Map<Token, String> tokenToEndpoint = probe.getTokenToEndpointMap();
List<Token> sortedTokens = new ArrayList<Token>(tokenToEndpoint.keySet());
Collections.sort(sortedTokens);
Collection<String> liveNodes = probe.getLiveNodes();
Collection<String> deadNodes = probe.getUnreachableNodes();
Collection<String> joiningNodes = probe.getJoiningNodes();
Collection<String> leavingNodes = probe.getLeavingNodes();
Map<String, String> loadMap = probe.getLoadMap();
outs.printf("%-16s%-7s%-8s%-16s%-8s%-44s%n", "Address", "Status", "State", "Load", "Owns", "Token");
// show pre-wrap token twice so you can always read a node's range as
// (previous line token, current line token]
if (sortedTokens.size() > 1)
outs.printf("%-16s%-7s%-8s%-16s%-8s%-44s%n", "", "", "", "", "", sortedTokens.get(sortedTokens.size() - 1));
// Calculate per-token ownership of the ring
Map<Token, Float> ownerships = probe.getOwnership();
for (Token token : sortedTokens)
{
String primaryEndpoint = tokenToEndpoint.get(token);
String status = liveNodes.contains(primaryEndpoint)
? "Up"
: deadNodes.contains(primaryEndpoint)
? "Down"
: "?";
String state = joiningNodes.contains(primaryEndpoint)
? "Joining"
: leavingNodes.contains(primaryEndpoint)
? "Leaving"
: "Normal";
String load = loadMap.containsKey(primaryEndpoint)
? loadMap.get(primaryEndpoint)
: "?";
String owns = new DecimalFormat("##0.00%").format(ownerships.get(token));
outs.printf("%-16s%-7s%-8s%-16s%-8s%-44s%n", primaryEndpoint, status, state, load, owns, token);
}
}
public void printThreadPoolStats(PrintStream outs)
{
outs.printf("%-25s%10s%10s%15s%n", "Pool Name", "Active", "Pending", "Completed");
Iterator<Map.Entry<String, IExecutorMBean>> threads = probe.getThreadPoolMBeanProxies();
while (threads.hasNext())
{
Entry<String, IExecutorMBean> thread = threads.next();
String poolName = thread.getKey();
IExecutorMBean threadPoolProxy = thread.getValue();
outs.printf("%-25s%10s%10s%15s%n",
poolName, threadPoolProxy.getActiveCount(), threadPoolProxy.getPendingTasks(), threadPoolProxy.getCompletedTasks());
}
}
/**
* Write node information.
*
* @param outs the stream to write to
*/
public void printInfo(PrintStream outs)
{
boolean gossipInitialized = probe.isInitialized();
outs.println(probe.getToken());
outs.printf("%-17s: %s%n", "Gossip active", gossipInitialized);
outs.printf("%-17s: %s%n", "Load", probe.getLoadString());
if (gossipInitialized)
outs.printf("%-17s: %s%n", "Generation No", probe.getCurrentGenerationNumber());
else
outs.printf("%-17s: %s%n", "Generation No", 0);
// Uptime
long secondsUp = probe.getUptime() / 1000;
outs.printf("%-17s: %d%n", "Uptime (seconds)", secondsUp);
// Memory usage
MemoryUsage heapUsage = probe.getHeapMemoryUsage();
double memUsed = (double)heapUsage.getUsed() / (1024 * 1024);
double memMax = (double)heapUsage.getMax() / (1024 * 1024);
outs.printf("%-17s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax);
}
public void printReleaseVersion(PrintStream outs)
{
outs.println("ReleaseVersion: " + probe.getReleaseVersion());
}
public void printNetworkStats(final InetAddress addr, PrintStream outs)
{
outs.printf("Mode: %s%n", probe.getOperationMode());
Set<InetAddress> hosts = addr == null ? probe.getStreamDestinations() : new HashSet<InetAddress>(){{add(addr);}};
if (hosts.size() == 0)
outs.println("Not sending any streams.");
for (InetAddress host : hosts)
{
try
{
List<String> files = probe.getFilesDestinedFor(host);
if (files.size() > 0)
{
outs.printf("Streaming to: %s%n", host);
for (String file : files)
outs.printf(" %s%n", file);
}
else
{
outs.printf(" Nothing streaming to %s%n", host);
}
}
catch (IOException ex)
{
outs.printf(" Error retrieving file data for %s%n", host);
}
}
hosts = addr == null ? probe.getStreamSources() : new HashSet<InetAddress>(){{add(addr); }};
if (hosts.size() == 0)
outs.println("Not receiving any streams.");
for (InetAddress host : hosts)
{
try
{
List<String> files = probe.getIncomingFiles(host);
if (files.size() > 0)
{
outs.printf("Streaming from: %s%n", host);
for (String file : files)
outs.printf(" %s%n", file);
}
else
{
outs.printf(" Nothing streaming from %s%n", host);
}
}
catch (IOException ex)
{
outs.printf(" Error retrieving file data for %s%n", host);
}
}
MessagingServiceMBean ms = probe.getMsProxy();
outs.printf("%-25s", "Pool Name");
outs.printf("%10s", "Active");
outs.printf("%10s", "Pending");
outs.printf("%15s%n", "Completed");
int pending;
long completed;
pending = 0;
for (int n : ms.getCommandPendingTasks().values())
pending += n;
completed = 0;
for (long n : ms.getCommandCompletedTasks().values())
completed += n;
outs.printf("%-25s%10s%10s%15s%n", "Commands", "n/a", pending, completed);
pending = 0;
for (int n : ms.getResponsePendingTasks().values())
pending += n;
completed = 0;
for (long n : ms.getResponseCompletedTasks().values())
completed += n;
outs.printf("%-25s%10s%10s%15s%n", "Responses", "n/a", pending, completed);
}
public void printCompactionStats(PrintStream outs)
{
CompactionManagerMBean cm = probe.getCompactionManagerProxy();
outs.println("compaction type: " + (cm.getCompactionType() == null ? "n/a" : cm.getCompactionType()));
outs.println("column family: " + (cm.getColumnFamilyInProgress() == null ? "n/a" : cm.getColumnFamilyInProgress()));
outs.println("bytes compacted: " + (cm.getBytesCompacted() == null ? "n/a" : cm.getBytesCompacted()));
outs.println("bytes total in progress: " + (cm.getBytesTotalInProgress() == null ? "n/a" : cm.getBytesTotalInProgress() ));
outs.println("pending tasks: " + cm.getPendingTasks());
}
public void printColumnFamilyStats(PrintStream outs)
{
Map <String, List <ColumnFamilyStoreMBean>> cfstoreMap = new HashMap <String, List <ColumnFamilyStoreMBean>>();
// get a list of column family stores
Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies();
while (cfamilies.hasNext())
{
Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next();
String tableName = entry.getKey();
ColumnFamilyStoreMBean cfsProxy = entry.getValue();
if (!cfstoreMap.containsKey(tableName))
{
List<ColumnFamilyStoreMBean> columnFamilies = new ArrayList<ColumnFamilyStoreMBean>();
columnFamilies.add(cfsProxy);
cfstoreMap.put(tableName, columnFamilies);
}
else
{
cfstoreMap.get(tableName).add(cfsProxy);
}
}
// print out the table statistics
for (Entry<String, List<ColumnFamilyStoreMBean>> entry : cfstoreMap.entrySet())
{
String tableName = entry.getKey();
List<ColumnFamilyStoreMBean> columnFamilies = entry.getValue();
long tableReadCount = 0;
long tableWriteCount = 0;
int tablePendingTasks = 0;
double tableTotalReadTime = 0.0f;
double tableTotalWriteTime = 0.0f;
outs.println("Keyspace: " + tableName);
for (ColumnFamilyStoreMBean cfstore : columnFamilies)
{
long writeCount = cfstore.getWriteCount();
long readCount = cfstore.getReadCount();
if (readCount > 0)
{
tableReadCount += readCount;
tableTotalReadTime += cfstore.getTotalReadLatencyMicros();
}
if (writeCount > 0)
{
tableWriteCount += writeCount;
tableTotalWriteTime += cfstore.getTotalWriteLatencyMicros();
}
tablePendingTasks += cfstore.getPendingTasks();
}
double tableReadLatency = tableReadCount > 0 ? tableTotalReadTime / tableReadCount / 1000 : Double.NaN;
double tableWriteLatency = tableWriteCount > 0 ? tableTotalWriteTime / tableWriteCount / 1000 : Double.NaN;
outs.println("\tRead Count: " + tableReadCount);
outs.println("\tRead Latency: " + String.format("%s", tableReadLatency) + " ms.");
outs.println("\tWrite Count: " + tableWriteCount);
outs.println("\tWrite Latency: " + String.format("%s", tableWriteLatency) + " ms.");
outs.println("\tPending Tasks: " + tablePendingTasks);
// print out column family statistics for this table
for (ColumnFamilyStoreMBean cfstore : columnFamilies)
{
outs.println("\t\tColumn Family: " + cfstore.getColumnFamilyName());
outs.println("\t\tSSTable count: " + cfstore.getLiveSSTableCount());
outs.println("\t\tSpace used (live): " + cfstore.getLiveDiskSpaceUsed());
outs.println("\t\tSpace used (total): " + cfstore.getTotalDiskSpaceUsed());
outs.println("\t\tMemtable Columns Count: " + cfstore.getMemtableColumnsCount());
outs.println("\t\tMemtable Data Size: " + cfstore.getMemtableDataSize());
outs.println("\t\tMemtable Switch Count: " + cfstore.getMemtableSwitchCount());
outs.println("\t\tRead Count: " + cfstore.getReadCount());
outs.println("\t\tRead Latency: " + String.format("%01.3f", cfstore.getRecentReadLatencyMicros() / 1000) + " ms.");
outs.println("\t\tWrite Count: " + cfstore.getWriteCount());
outs.println("\t\tWrite Latency: " + String.format("%01.3f", cfstore.getRecentWriteLatencyMicros() / 1000) + " ms.");
outs.println("\t\tPending Tasks: " + cfstore.getPendingTasks());
JMXInstrumentedCacheMBean keyCacheMBean = probe.getKeyCacheMBean(tableName, cfstore.getColumnFamilyName());
if (keyCacheMBean.getCapacity() > 0)
{
outs.println("\t\tKey cache capacity: " + keyCacheMBean.getCapacity());
outs.println("\t\tKey cache size: " + keyCacheMBean.getSize());
outs.println("\t\tKey cache hit rate: " + keyCacheMBean.getRecentHitRate());
}
else
{
outs.println("\t\tKey cache: disabled");
}
JMXInstrumentedCacheMBean rowCacheMBean = probe.getRowCacheMBean(tableName, cfstore.getColumnFamilyName());
if (rowCacheMBean.getCapacity() > 0)
{
outs.println("\t\tRow cache capacity: " + rowCacheMBean.getCapacity());
outs.println("\t\tRow cache size: " + rowCacheMBean.getSize());
outs.println("\t\tRow cache hit rate: " + rowCacheMBean.getRecentHitRate());
}
else
{
outs.println("\t\tRow cache: disabled");
}
outs.println("\t\tCompacted row minimum size: " + cfstore.getMinRowSize());
outs.println("\t\tCompacted row maximum size: " + cfstore.getMaxRowSize());
outs.println("\t\tCompacted row mean size: " + cfstore.getMeanRowSize());
outs.println("");
}
outs.println("----------------");
}
}
public void printRemovalStatus(PrintStream outs)
{
outs.println("RemovalStatus: " + probe.getRemovalStatus());
}
private void printCfHistograms(String keySpace, String columnFamily, PrintStream output)
{
ColumnFamilyStoreMBean store = this.probe.getCfsProxy(keySpace, columnFamily);
// default is 90 offsets
long[] offsets = new EstimatedHistogram().getBucketOffsets();
long[] rrlh = store.getRecentReadLatencyHistogramMicros();
long[] rwlh = store.getRecentWriteLatencyHistogramMicros();
long[] sprh = store.getRecentSSTablesPerReadHistogram();
long[] ersh = store.getEstimatedRowSizeHistogram();
long[] ecch = store.getEstimatedColumnCountHistogram();
output.println(String.format("%s/%s histograms", keySpace, columnFamily));
output.println(String.format("%-10s%10s%18s%18s%18s%18s",
"Offset", "SSTables", "Write Latency", "Read Latency", "Row Size", "Column Count"));
for (int i = 0; i < offsets.length; i++)
{
output.println(String.format("%-10d%10s%18s%18s%18s%18s",
offsets[i],
(i < sprh.length ? sprh[i] : ""),
(i < rwlh.length ? rrlh[i] : ""),
(i < rrlh.length ? rwlh[i] : ""),
(i < ersh.length ? ersh[i] : ""),
(i < ecch.length ? ecch[i] : "")));
}
}
public static void main(String[] args) throws IOException, InterruptedException, ConfigurationException, ParseException
{
CommandLineParser parser = new PosixParser();
ToolCommandLine cmd = null;
try
{
cmd = new ToolCommandLine(parser.parse(options, args));
}
catch (ParseException p)
{
badUse(p.getMessage());
}
String host = cmd.getOptionValue(HOST_OPT.left);
int port = DEFAULT_PORT;
String portNum = cmd.getOptionValue(PORT_OPT.left);
if (portNum != null)
{
try
{
port = Integer.parseInt(portNum);
}
catch (NumberFormatException e)
{
throw new ParseException("Port must be a number");
}
}
String username = cmd.getOptionValue(USERNAME_OPT.left);
String password = cmd.getOptionValue(PASSWORD_OPT.left);
NodeProbe probe = null;
try
{
probe = username == null ? new NodeProbe(host, port) : new NodeProbe(host, port, username, password);
}
catch (IOException ioe)
{
err(ioe, "Error connection to remote JMX agent!");
}
NodeCommand command = null;
try
{
command = cmd.getCommand();
}
catch (IllegalArgumentException e)
{
badUse(e.getMessage());
}
NodeCmd nodeCmd = new NodeCmd(probe);
// Execute the requested command.
String[] arguments = cmd.getCommandArguments();
switch (command)
{
case RING : nodeCmd.printRing(System.out); break;
case INFO : nodeCmd.printInfo(System.out); break;
case CFSTATS : nodeCmd.printColumnFamilyStats(System.out); break;
case DECOMMISSION : probe.decommission(); break;
case LOADBALANCE : probe.loadBalance(); break;
case CLEARSNAPSHOT : probe.clearSnapshot(); break;
case TPSTATS : nodeCmd.printThreadPoolStats(System.out); break;
case VERSION : nodeCmd.printReleaseVersion(System.out); break;
case COMPACTIONSTATS : nodeCmd.printCompactionStats(System.out); break;
case DISABLEGOSSIP : probe.stopGossiping(); break;
case ENABLEGOSSIP : probe.startGossiping(); break;
case DISABLETHRIFT : probe.stopThriftServer(); break;
case ENABLETHRIFT : probe.startThriftServer(); break;
case DRAIN :
try { probe.drain(); }
catch (ExecutionException ee) { err(ee, "Error occured during flushing"); }
break;
case NETSTATS :
if (arguments.length > 0) { nodeCmd.printNetworkStats(InetAddress.getByName(arguments[0]), System.out); }
else { nodeCmd.printNetworkStats(null, System.out); }
break;
case SNAPSHOT :
if (arguments.length > 0) { probe.takeSnapshot(arguments[0]); }
else { probe.takeSnapshot(""); }
break;
case MOVE :
if (arguments.length != 1) { badUse("Missing token argument for move."); }
probe.move(arguments[0]);
break;
case JOIN:
if (probe.isJoined())
{
System.err.println("This node has already joined the ring.");
System.exit(1);
}
probe.joinRing();
break;
case REMOVETOKEN :
if (arguments.length != 1) { badUse("Missing an argument for removetoken (either status, force, or a token)"); }
else if (arguments[0].equals("status")) { nodeCmd.printRemovalStatus(System.out); }
else if (arguments[0].equals("force")) { nodeCmd.printRemovalStatus(System.out); probe.forceRemoveCompletion(); }
else { probe.removeToken(arguments[0]); }
break;
case CLEANUP :
case COMPACT :
case REPAIR :
case FLUSH :
case SCRUB :
case INVALIDATEKEYCACHE :
case INVALIDATEROWCACHE :
optionalKSandCFs(command, arguments, probe);
break;
case GETCOMPACTIONTHRESHOLD :
if (arguments.length != 2) { badUse("getcompactionthreshold requires ks and cf args."); }
probe.getCompactionThreshold(System.out, arguments[0], arguments[1]);
break;
case CFHISTOGRAMS :
if (arguments.length != 2) { badUse("cfhistograms requires ks and cf args"); }
nodeCmd.printCfHistograms(arguments[0], arguments[1], System.out);
break;
case SETCACHECAPACITY :
if (arguments.length != 4) { badUse("setcachecapacity requires ks, cf, keycachecap, and rowcachecap args."); }
probe.setCacheCapacities(arguments[0], arguments[1], Integer.parseInt(arguments[2]), Integer.parseInt(arguments[3]));
break;
case SETCOMPACTIONTHRESHOLD :
if (arguments.length != 4) { badUse("setcompactionthreshold requires ks, cf, min, and max threshold args."); }
int minthreshold = Integer.parseInt(arguments[2]);
int maxthreshold = Integer.parseInt(arguments[3]);
if ((minthreshold < 0) || (maxthreshold < 0)) { badUse("Thresholds must be positive integers"); }
if (minthreshold > maxthreshold) { badUse("Min threshold cannot be greater than max."); }
if (minthreshold < 2 && maxthreshold != 0) { badUse("Min threshold must be at least 2"); }
probe.setCompactionThreshold(arguments[0], arguments[1], minthreshold, maxthreshold);
break;
default :
throw new RuntimeException("Unreachable code.");
}
System.exit(0);
}
private static void badUse(String useStr)
{
System.err.println(useStr);
printUsage();
System.exit(1);
}
private static void err(Exception e, String errStr)
{
System.err.println(errStr);
e.printStackTrace();
System.exit(3);
}
private static void optionalKSandCFs(NodeCommand nc, String[] cmdArgs, NodeProbe probe) throws InterruptedException, IOException
{
// if there is one additional arg, it's the keyspace; more are columnfamilies
List<String> keyspaces = cmdArgs.length == 0 ? probe.getKeyspaces() : Arrays.asList(cmdArgs[0]);
for (String keyspace : keyspaces)
{
if (!probe.getKeyspaces().contains(keyspace))
{
System.err.println("Keyspace [" + keyspace + "] does not exist.");
System.exit(1);
}
}
// second loop so we're less likely to die halfway through due to invalid keyspace
for (String keyspace : keyspaces)
{
String[] columnFamilies = cmdArgs.length <= 1 ? new String[0] : Arrays.copyOfRange(cmdArgs, 1, cmdArgs.length);
switch (nc)
{
case REPAIR : probe.forceTableRepair(keyspace, columnFamilies); break;
case INVALIDATEKEYCACHE : probe.invalidateKeyCaches(keyspace, columnFamilies); break;
case INVALIDATEROWCACHE : probe.invalidateRowCaches(keyspace, columnFamilies); break;
case FLUSH :
try { probe.forceTableFlush(keyspace, columnFamilies); }
catch (ExecutionException ee) { err(ee, "Error occured during flushing"); }
break;
case COMPACT :
try { probe.forceTableCompaction(keyspace, columnFamilies); }
catch (ExecutionException ee) { err(ee, "Error occured during compaction"); }
break;
case CLEANUP :
if (keyspace.equals("system")) { break; } // Skip cleanup on system cfs.
try { probe.forceTableCleanup(keyspace, columnFamilies); }
catch (ExecutionException ee) { err(ee, "Error occured during cleanup"); }
break;
case SCRUB :
try { probe.scrub(keyspace, columnFamilies); }
catch (ExecutionException ee) { err(ee, "Error occured while scrubbing keyspace " + keyspace); }
break;
default:
throw new RuntimeException("Unreachable code.");
}
}
}
private static class ToolOptions extends Options
{
public void addOption(Pair<String, String> opts, boolean hasArgument, String description)
{
addOption(opts, hasArgument, description, false);
}
public void addOption(Pair<String, String> opts, boolean hasArgument, String description, boolean required)
{
addOption(opts.left, opts.right, hasArgument, description, required);
}
public void addOption(String opt, String longOpt, boolean hasArgument, String description, boolean required)
{
Option option = new Option(opt, longOpt, hasArgument, description);
option.setRequired(required);
addOption(option);
}
}
private static class ToolCommandLine
{
private final CommandLine commandLine;
public ToolCommandLine(CommandLine commands)
{
commandLine = commands;
}
public Option[] getOptions()
{
return commandLine.getOptions();
}
public boolean hasOption(String opt)
{
return commandLine.hasOption(opt);
}
public String getOptionValue(String opt)
{
return commandLine.getOptionValue(opt);
}
public NodeCommand getCommand()
{
if (commandLine.getArgs().length == 0)
throw new IllegalArgumentException("Command was not specified.");
String command = commandLine.getArgs()[0];
try
{
return NodeCommand.valueOf(command.toUpperCase());
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException("Unrecognized command: " + command);
}
}
public String[] getCommandArguments()
{
List params = commandLine.getArgList();
if (params.size() < 2) // command parameters are empty
return new String[0];
String[] toReturn = new String[params.size() - 1];
for (int i = 1; i < params.size(); i++)
toReturn[i - 1] = (String) params.get(i);
return toReturn;
}
}
}
| [
"[email protected]"
] | |
02e6aa1f6bcb56223c3014d7450d62af7499bbce | 44e7adc9a1c5c0a1116097ac99c2a51692d4c986 | /aws-java-sdk-codebuild/src/main/java/com/amazonaws/services/codebuild/model/ProjectSortByType.java | eb3b30f64828a2aa5c42b2e5d782e1c0750bb96c | [
"Apache-2.0"
] | permissive | QiAnXinCodeSafe/aws-sdk-java | f93bc97c289984e41527ae5bba97bebd6554ddbe | 8251e0a3d910da4f63f1b102b171a3abf212099e | refs/heads/master | 2023-01-28T14:28:05.239019 | 2020-12-03T22:09:01 | 2020-12-03T22:09:01 | 318,460,751 | 1 | 0 | Apache-2.0 | 2020-12-04T10:06:51 | 2020-12-04T09:05:03 | null | UTF-8 | Java | false | false | 1,847 | java | /*
* Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.codebuild.model;
import javax.annotation.Generated;
/**
*
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public enum ProjectSortByType {
NAME("NAME"),
CREATED_TIME("CREATED_TIME"),
LAST_MODIFIED_TIME("LAST_MODIFIED_TIME");
private String value;
private ProjectSortByType(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
/**
* Use this in place of valueOf.
*
* @param value
* real value
* @return ProjectSortByType corresponding to the value
*
* @throws IllegalArgumentException
* If the specified value does not map to one of the known values in this enum.
*/
public static ProjectSortByType fromValue(String value) {
if (value == null || "".equals(value)) {
throw new IllegalArgumentException("Value cannot be null or empty!");
}
for (ProjectSortByType enumEntry : ProjectSortByType.values()) {
if (enumEntry.toString().equals(value)) {
return enumEntry;
}
}
throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
}
}
| [
""
] | |
7ee10e6e194e9b74c33eecf5c0abb9b52f473a02 | c98824b25b2bdfdb28e85c8c4c3b4e0546004a21 | /weixin_sell/src/main/java/com/itguang/weixinsell/project_test/TestFormValidController.java | b58d1712d4b85b54a27b2e64b30e1d4e80067ab4 | [] | no_license | itguang/weixin_sell | 9a97017c1c6ff44dbc48d2a6b53265e89a970b0f | 7d0c1bdadbceb77490f2864dc273b1a7d133d6c1 | refs/heads/master | 2021-08-24T00:23:20.160243 | 2017-12-07T07:44:02 | 2017-12-07T07:44:02 | 112,056,941 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 928 | java | package com.itguang.weixinsell.project_test;
import com.itguang.weixinsell.project_test.pojo.User;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**
* @author itguang
* @create 2017-12-07 14:42
**/
@RestController
@RequestMapping("/test")
public class TestFormValidController {
@RequestMapping("/saveUser")
public void saveUser(@Valid User user, BindingResult result) {
System.out.println("user:"+user);
if(result.hasErrors()) {
List<ObjectError> list = result.getAllErrors();
for (ObjectError error : list) {
System.out.println(error.getCode() + "-" + error.getDefaultMessage());
}
}
}
}
| [
"[email protected]"
] | |
a4e289d12b2720594f71ba106da38e1e92658ff4 | d1eab95f28e9ffea20df4281f77f179f82c4f88f | /src/main/java/ru/ablog/megad/configurator/Megad2561Model.java | 40b7163760ff3caec9ee01a39877cf0a99591c94 | [] | no_license | Pshatsillo/megaConfigurator | 16fd80c1ea5f9f9b267f4bf16d96c331b5a7265b | f868cc123d77fe2b67f296784c3aaf7c8628006f | refs/heads/master | 2023-04-18T20:49:36.699130 | 2023-04-04T19:29:46 | 2023-04-04T19:29:46 | 237,795,201 | 0 | 0 | null | 2023-04-04T19:29:47 | 2020-02-02T15:52:53 | Java | UTF-8 | Java | false | false | 71 | java | package ru.ablog.megad.configurator;
public class Megad2561Model {
}
| [
"[email protected]"
] | |
6ffd30364b563c4b805f5c47b47700aa579a4113 | 3f9457963586b56ddbc979a8318abceb0296b87b | /app/src/main/java/com/aztlandev/abc/viewsFragments/About_abc.java | 53fc14aa49779413dd79e0270bf6b92abdc1ddb9 | [] | no_license | Dgiovan/123abc | d5bd483f2209def0b57c56091f3cfcd04b14d721 | 1373a482f9824c2eb6f9456cc749a5eff01cc9be | refs/heads/master | 2022-11-17T03:40:12.312413 | 2020-07-11T00:02:06 | 2020-07-11T00:02:06 | 278,506,583 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 769 | java | package com.aztlandev.abc.viewsFragments;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.aztlandev.Bases.BaseFragment;
import com.aztlandev.abc.R;
/**
* A simple {@link Fragment} subclass.
*/
public class About_abc extends BaseFragment {
public About_abc() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_about_abc, container, false);
}
@Override
public void setup(View rootView, Bundle savedInstanceState) {
}
}
| [
"[email protected]"
] | |
ae02303f48646bff1840b508976a079f1c855459 | 171ca73cd1e0ac38eb6fd610c8463735f2458682 | /library-base/src/main/java/com/zhulong/library_base/mvvm/model/BaseModel.java | 1dc5ff4464c2ac302ef5870a1052c83650befb66 | [] | no_license | caolinxing/MvvmEmptyProject | 24185f130f4255d291a97767cabe6022ea1893b9 | dfae7bd558b645be9173f8be19bb9f228a097bda | refs/heads/master | 2023-07-09T15:40:12.424487 | 2021-07-31T03:00:35 | 2021-07-31T03:00:35 | 380,462,840 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 218 | java | package com.zhulong.library_base.mvvm.model;
/**
* Created by goldze on 2017/6/15.
*/
public class BaseModel implements IModel {
public BaseModel() {
}
@Override
public void onCleared() {
}
}
| [
"[email protected]"
] | |
0116a8a439b31d06365ecf9e8579b832ea13791e | afab90e214f8cb12360443e0877ab817183fa627 | /bitcamp-java/src/main/java/com/eomcs/oop/ex12/Exam0140.java | f122c9f0ac805a1be40341a408536be81d4e3ea1 | [] | no_license | oreoTaste/bitcamp-study | 40a96ef548bce1f80b4daab0eb650513637b46f3 | 8f0af7cd3c5920841888c5e04f30603cbeb420a5 | refs/heads/master | 2020-09-23T14:47:32.489490 | 2020-05-26T09:05:40 | 2020-05-26T09:05:40 | 225,523,347 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 427 | java | // ๋๋ค(lambda) - ํ๋ผ๋ฏธํฐ
package com.eomcs.oop.ex12;
public class Exam0140 {
static interface Player {
void play(String name, int age);
}
public static void main(String[] args) {
Player p1 = (String name, int age) -> System.out.println(name + "(" + age + ")");
p1.play("ํ๊ธธ๋", 34);
p1 = (name, age) -> System.out.println(name + "\"" + age + "\"");
p1.play("ํ๊ธธ๋", 34);
}
}
| [
"[email protected]"
] | |
a7846f055309931dec2a45f52244e999f975585b | bae620be89738a2ec576006767fc9a8887f0997a | /app/src/main/java/com/example/newminerisk/tools/NameValuePair.java | f2f018b8d82eaf0537ab6326d48a2c470e3f38ff | [] | no_license | guojiandongs/NewMineRIsk | 47147e8c0b7004ef72cca27e4ad45b84a07309a7 | c0bdb0555ec050d76c57c4f189d1fdf3012b1677 | refs/heads/master | 2021-07-10T09:26:01.888813 | 2020-07-08T06:34:57 | 2020-07-08T06:34:57 | 161,507,281 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 229 | java | package com.example.newminerisk.tools;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
public interface NameValuePair {
String getName();
String getValue();
}
| [
"[email protected]"
] | |
c9f86c5c261455b7e5c69b1b20bad5f669778153 | 7365ae3cc2b333f0b831573b14e1ab44c049bc95 | /app/src/main/java/com/example/desktop/sr06/TextToSpeechStartupListener.java | 5a4efb007c2ee18bd5fdb9b5d6d653cc955baaad | [] | no_license | candidature/SR06 | 09e6c11ddd4ee18400c855113c19ca33bd33701d | 4a24ffeed0593590e59017d3aebcd1f71caa2de5 | refs/heads/master | 2021-01-01T08:21:11.998517 | 2015-08-03T10:21:36 | 2015-08-03T10:21:36 | 37,545,175 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 259 | java | package com.example.desktop.sr06;
import android.speech.tts.TextToSpeech;
/**
* Created by Desktop on 6/14/2015.
*/
public interface TextToSpeechStartupListener {
public void onSuccessfulInit(TextToSpeech tts);
public void onFailedToInit();
}
| [
"[email protected]"
] | |
be4fd70a74f7ecf9279a5c3437aff8f6064ab116 | c19cb77e3958a194046d6f84ca97547cc3a223c3 | /pkix/src/main/java/org/bouncycastle/pkcs/bc/BcPKCS12MacCalculatorBuilder.java | b9420793fcd15454e59cd5f83806605b83e36f51 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | bcgit/bc-java | 1b6092bc5d2336ec26ebd6da6eeaea6600b4c70a | 62b03c0f704ebd243fe5f2d701aef4edd77bba6e | refs/heads/main | 2023-09-04T00:48:33.995258 | 2023-08-30T05:33:42 | 2023-08-30T05:33:42 | 10,416,648 | 1,984 | 1,021 | MIT | 2023-08-26T05:14:28 | 2013-06-01T02:38:42 | Java | UTF-8 | Java | false | false | 1,823 | java | package org.bouncycastle.pkcs.bc;
import java.security.SecureRandom;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.pkcs.PKCS12MacCalculatorBuilder;
public class BcPKCS12MacCalculatorBuilder
implements PKCS12MacCalculatorBuilder
{
private ExtendedDigest digest;
private AlgorithmIdentifier algorithmIdentifier;
private SecureRandom random;
private int saltLength;
private int iterationCount = 1024;
public BcPKCS12MacCalculatorBuilder()
{
this(new SHA1Digest(), new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE));
}
public BcPKCS12MacCalculatorBuilder(ExtendedDigest digest, AlgorithmIdentifier algorithmIdentifier)
{
this.digest = digest;
this.algorithmIdentifier = algorithmIdentifier;
this.saltLength = digest.getDigestSize();
}
public BcPKCS12MacCalculatorBuilder setIterationCount(int iterationCount)
{
this.iterationCount = iterationCount;
return this;
}
public AlgorithmIdentifier getDigestAlgorithmIdentifier()
{
return algorithmIdentifier;
}
public MacCalculator build(final char[] password)
{
if (random == null)
{
random = new SecureRandom();
}
byte[] salt = new byte[saltLength];
random.nextBytes(salt);
return PKCS12PBEUtils.createMacCalculator(algorithmIdentifier.getAlgorithm(), digest, new PKCS12PBEParams(salt, iterationCount), password);
}
}
| [
"[email protected]"
] | |
de65e592711472e8fa21e23ca2c12af038766d48 | 05e39aad3514bba3165dab5ded834d3c8684cac6 | /src/main/java/com/felix/core/date/DateUtil.java | 9b9e92fa35069c67d10be3a3e37daa02d5ba72be | [] | no_license | felixmaomao/core | 7176ce6bfa017ae793e755baeba90e7459f32ce7 | 73e2b1304db9196028e901f29338f8b7160819b0 | refs/heads/master | 2021-09-05T09:23:22.657327 | 2018-01-26T02:15:50 | 2018-01-26T02:15:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 32,356 | java | package com.felix.core.date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Author shenwei
* @Date 2018/1/10 11:33
* @Description ๆฅๆๅทฅๅ
ท็ฑป
*/
public class DateUtil {
private final static Log log = LogFactory.getLog(DateUtil.class);
public final static int SECONDS_OF_MINITE = 60;
public final static int SECONDS_OF_HOUR = 3600;
public final static int MILLISECONDS_OF_MINITE = SECONDS_OF_MINITE * 1000;
public final static int MILLISECONDS_OF_HOUR = SECONDS_OF_HOUR * 1000;
//ไธๅคฉ
public final static long MILLISECONDS_OF_DAY = 24 * MILLISECONDS_OF_HOUR;
public final static int SECONDS_OF_DAY = 24 * SECONDS_OF_HOUR;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyy-MM-dd HH:mm:ss
*/
public final static int DATE_FORMAT_BY_TIME = 1;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyy-MM-dd
*/
public final static int DATE_FORMAT_BY_DATE = 2;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyy/MM/dd HH:mm:ss
*/
public final static int DATE_FORMAT_BY_OTHER_TIME = 3;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyy/MM/dd
*/
public final static int DATE_FORMAT_BY_OTHER_DATE = 4;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyyMMddHHmmss
*/
public final static int DATE_FORMAT_BY_SIAMPLE_TIME = 5;
/**
* ๆ ผๅผๅฆไธ๏ผ yyyyMMdd
*/
public final static int DATE_FORMAT_BY_SIAMPLE_DATE = 6;
public static SimpleDateFormat getTimeFormat() {
return new SimpleDateFormat(FormatConfig.TIME);
}
public static SimpleDateFormat getOtherTimeFormat() {
return new SimpleDateFormat(FormatConfig.OTHER_TIME);
}
public static SimpleDateFormat getOtherDateFormat() {
return new SimpleDateFormat(FormatConfig.OTHER_DATE);
}
public static SimpleDateFormat getDateFormat() {
return new SimpleDateFormat(FormatConfig.DATE);
}
public static SimpleDateFormat getSampleTimeFormat() {
return new SimpleDateFormat(FormatConfig.SAMPLE_TIME);
}
public static SimpleDateFormat getSampleDateFormat() {
return new SimpleDateFormat(FormatConfig.SAMPLE_DATE);
}
public static SimpleDateFormat getHourDateFormat() {
return new SimpleDateFormat(FormatConfig.HOUR_TIME);
}
public static SimpleDateFormat getHHmmFormat() {
return new SimpleDateFormat(FormatConfig.HH_MM);
}
/**
* ๆ ผๅผๆHH:mm
*
* @param date
* @return
*/
public static String formatHHmm(Date date) {
return getHHmmFormat().format(date);
}
private final static SimpleDateFormat rssDate = new SimpleDateFormat(
"EEE, d MMM yyyy HH:mm:ss z", Locale.US);
private final static SimpleTimeZone aZone = new SimpleTimeZone(8, "GMT");
static {
rssDate.setTimeZone(aZone);
}
/**
* ๅฐๆฅๆๅฏน่ฑก่ฝฌๆขไธบRSS็จ็ๅญ็ฌฆไธฒๆฅๆ
*
* @param d
* @return
*/
public static String dateToRssDate(Date d) {
return rssDate.format(d);
}
public static Date getNowMinuteDate() {
Calendar c = Calendar.getInstance();
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date getNowHourDate() {
Calendar c = Calendar.getInstance();
c.set(Calendar.SECOND, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date getHourDate(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date[] getPreDates(int days) {
Date[] dates = new Date[days];
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
dates[0] = c.getTime();
for (int i = 1; i < days; i++) {
c.add(Calendar.DAY_OF_YEAR, -1);
dates[i] = c.getTime();
}
return dates;
}
public static Date getYesterday() {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
c.add(Calendar.DAY_OF_YEAR, -1);
return c.getTime();
}
public static String hourTimeFormat(Date date) {
return getHourDateFormat().format(date);
}
public static String[] formats(SimpleDateFormat sdf, Date[] dates) {
String[] dateFormats = new String[dates.length];
try {
for (int i = 0; i < dates.length; i++) {
dateFormats[i] = sdf.format(dates[i]);
}
} catch (Exception e) {
log.error("formats " + dates[0], e);
}
return dateFormats;
}
public static String[] formats(SimpleDateFormat sdf, List<Date> dateList, int size) {
if (dateList == null || dateList.size() > size) {
log.error("formats error");
}
String[] dateFormats = new String[size];
try {
for (int i = 0; i < dateList.size(); i++) {
dateFormats[i] = sdf.format(dateList.get(i));
}
} catch (Exception e) {
log.error("formats " + dateList.get(0), e);
}
return dateFormats;
}
/**
* ๅฐRSSๆฅๆๅญ็ฌฆไธฒ่ฝฌๆขไธบๆฅๆๅฏน่ฑก
*
* @param
* @return
*/
public static Date rssDateToDate(String rd) {
boolean ret = false;
try {
Date d = rssDate.parse(rd);
ret = true;
return d;
} catch (Exception e) {
log.error("rssDateToDate date " + rd, e);
} finally {
if (!ret) {
log.error("rssDateToDate date " + rd);
}
}
return null;
}
/**
* ๅฐๆถ้ดๅฏน่ฑก่ฝฌๆขไธบyyyyMMddHHmmssๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆถ้ด
*
* @param date
* @return
*/
public static String sampleTimeFormat(Date date) {
return getSampleTimeFormat().format(date);
}
/**
* ๅฐๆถ้ดๅฏน่ฑก่ฝฌๆขไธบyyyyMMddๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆถ้ด
*
* @param date
* @return
*/
public static String sampleDateFormat(Date date) {
return getSampleDateFormat().format(date);
}
/**
* ๅฐๆถ้ดๅฏน่ฑก่ฝฌๆขไธบyyyy/MM/dd HH:mm:ssๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆถ้ด
*
* @param date
* @return
*/
public static String otherTimeFormat(Date date) {
return getOtherTimeFormat().format(date);
}
/**
* ๅฐๆถ้ดๅฏน่ฑก่ฝฌๆขไธบyyyy-mm-dd HH:mm:ssๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆถ้ด
*
* @param date
* @return
*/
public static String timeFormat(Date date) {
return getTimeFormat().format(date);
}
/**
* ๅฐๆฅๆๅฏน่ฑก่ฝฌๆขไธบyyyy-mm-dd ๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆฅๆ
*
* @param date
* @return
*/
public static String dateFormat(Date date) {
return getDateFormat().format(date);
}
/**
* ๅฐๆฅๆๅฏน่ฑก่ฝฌๆขไธบyyyy/mm/dd ๆ ผๅผ็จ็ๅญ็ฌฆไธฒๆฅๆ
*
* @param date
* @return
*/
public static String otherDateFormat(Date date) {
return getOtherDateFormat().format(date);
}
/**
* ๅฐๆ ผๅผไธบyyyy-mm-dd HH:mm:ssๅญ็ฌฆไธฒๆถ้ด่ฝฌๆขๆๆถ้ดๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseTime(String date) {
boolean ret = false;
try {
Date d = getTimeFormat().parse(date);
ret = true;
return d;
} catch (Exception e) {
log.error("parseTime date " + date, e);
} finally {
if (!ret) {
log.error("parseTime date " + date);
}
}
return null;
}
/**
* ๅฐๆ ผๅผไธบyyyyMMddHHmmssๅญ็ฌฆไธฒๆถ้ด่ฝฌๆขๆๆถ้ดๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseSampleTime(String date) {
boolean ret = false;
try {
Date d = getSampleTimeFormat().parse(date);
ret = true;
return d;
} catch (Exception e) {
log.error("parseSampleTime date " + date, e);
} finally {
if (!ret) {
log.error("parseSampleTime date " + date);
}
}
return null;
}
/**
* ๅฐๆ ผๅผไธบyyyyMMddๅญ็ฌฆไธฒๆถ้ด่ฝฌๆขๆๆถ้ดๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseSampleDate(String date) {
boolean ret = false;
try {
Date d = getSampleDateFormat().parse(date);
ret = true;
return d;
} catch (Exception e) {
log.error("parseSampleDate date " + date, e);
} finally {
if (!ret) {
log.error("parseSampleDate date " + date);
}
}
return null;
}
/**
* ๅฐๆ ผๅผไธบyyyy/mm/dd HH:mm:ssๅญ็ฌฆไธฒๆถ้ด่ฝฌๆขๆๆถ้ดๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseOtherTime(String date) {
boolean ret = false;
try {
Date d = getOtherTimeFormat().parse(date);
ret = true;
return d;
} catch (ParseException e) {
log.error("parseOtherTime date " + date, e);
} finally {
if (!ret) {
log.error("parseOtherTime date " + date);
}
}
return null;
}
/**
* ๅฐๆ ผๅผไธบyyyy-mm-ddๅญ็ฌฆไธฒๆฅๆ่ฝฌๆขๆๆฅๆๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseDate(String date) {
boolean ret = false;
try {
Date d = getDateFormat().parse(date);
ret = true;
return d;
} catch (Exception e) {
log.error("parseDate date " + date, e);
} finally {
if (!ret) {
log.error("parseDate date " + date);
}
}
return null;
}
/**
* ๅฐๆ ผๅผไธบyyyy/mm/ddๅญ็ฌฆไธฒๆฅๆ่ฝฌๆขๆๆฅๆๅฏน่ฑก
*
* @param date
* @return
*/
public static Date parseOtherDate(String date) {
boolean ret = false;
try {
Date d = getOtherDateFormat().parse(date);
return d;
} catch (ParseException e) {
log.error("parseOtherDate date " + date, e);
} finally {
if (!ret) {
log.error("parseOtherDate date " + date);
}
}
return null;
}
/**
* ่ทๅๅฝๅ็ณป็ปๆถ้ดyyyy/mm/dd HH:mm:ssๆ ผๅผ่กจ็คบ็ๅญ็ฌฆไธฒ
*
* @return
*/
public static String getOtherNowTime() {
return otherTimeFormat(new Date());
}
/**
* ่ทๅๅฝๅ็ณป็ปๆถ้ดyyyy-mm-dd HH:mm:ssๆ ผๅผ่กจ็คบ็ๅญ็ฌฆไธฒ
*
* @return
*/
public static String getNowTime() {
return timeFormat(new Date());
}
/**
* ่ทๅๅฝๅ็ณป็ปๆถๆyyyy-mm-ddๆ ผๅผ่กจ็คบ็ๅญ็ฌฆไธฒ
*
* @return
*/
public static String getNowDate() {
return dateFormat(new Date());
}
/**
* ๅฝๅ็งๆฐ
*
* @return
*/
public static long getNowSec() {
return System.currentTimeMillis() / 1000;
}
/**
* ๅฝๅๆฏซ็งๆฐ
*
* @return
*/
public static long getNowMillis() {
return System.currentTimeMillis();
}
/**
* ๅฝๅๆถ้ด
*
* @return(Timestamp)
*/
public static Timestamp nowTimestamp() {
return new Timestamp(System.currentTimeMillis());
}
/**
* ๆฏซ็งๆฐ่ฝฌDate
*
* @param timeMillis ๆฏซ็งๆฐ
* @return
*/
public static Date timeMillisToDate(long timeMillis) {
return new Date(timeMillis);
}
/**
* ็งๆฐ่ฝฌDate
*
* @param timeSeconds ็งๆฐ
* @return
*/
public static Date timeSecondsToDate(long timeSeconds) {
return timeMillisToDate(timeSeconds * 1000l);
}
/**
* ๆฏซ็งๆฐ่ฝฌTimestamp
*
* @param timeMillis ๆฏซ็งๆฐ
* @return
*/
public static Timestamp timeMillisToTimestamp(long timeMillis) {
return new Timestamp(timeMillis);
}
/**
* ็งๆฐ่ฝฌTimestamp
*
* @param timeSeconds ็งๆฐ
* @return
*/
public static Timestamp timeSecondsToTimestamp(long timeSeconds) {
return timeMillisToTimestamp(timeSeconds * 1000l);
}
/**
* ๅฝๅๆถ้ด
*
* @return(Date)
*/
public static Date nowDate() {
return new Date();
}
/**
* ่ทๅๅฝๅ็ณป็ปๆถๆyyyy-mm-ddๆ ผๅผ่กจ็คบ็ๅญ็ฌฆไธฒ
*
* @return
*/
public static Date getDate() {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date getDate(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date[] getDates() {
Date[] dates = new Date[2];
Calendar c = Calendar.getInstance();
dates[0] = c.getTime();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
dates[1] = c.getTime();
return dates;
}
public static Calendar getCalendar() {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c;
}
public static Date preDate(Date date, int subDay) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DAY_OF_YEAR, -subDay);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
/**
* ่ทๅไนๅ็ๅ ๅคฉ็ๆฅๆๅฏน่ฑก
*
* @param subDay
* @return
*/
public static Date preDate(int subDay) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -subDay);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
/**
* ่ทๅๅฝๅคฉไธไธชๆ็ๆฅๆ
*
* @return
*/
public static Date preMonthDate() {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
public static Date preWeekDate() {
return preDate(6);
}
/**
* ่ทๅๆฅๆไธบๆๆๅ
*
* @param date
* @return 1-ๆๆไธ 2-ๆๆไบ ...7-ๆๆๆฅ
*/
public static int getWeek(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int week = c.get(Calendar.DAY_OF_WEEK);
return week == 1 ? 7 : (week - 1);
}
/**
* ่ทๅๅฝๅๆๆๅ
*
* @return 1-ๆๆไธ 2-ๆๆไบ ...7-ๆๆๆฅ
*/
public static int getWeek() {
Calendar c = Calendar.getInstance();
int week = c.get(Calendar.DAY_OF_WEEK);
return week == 1 ? 7 : (week - 1);
}
/**
* timeๆฏๅฆๅคงไบๅฝๅๅฐๆถๆฐ
*
* @param hourOfDay
* @param time
* @return
*/
public static boolean isGreaterThan(int hourOfDay, Date time) {
Calendar c = Calendar.getInstance();
c.setTime(time);
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return time.getTime() >= c.getTimeInMillis();
}
/**
* ไธคไธชๆถ้ด็ธๅทฎๅคฉๆฐ(ๆๅฎๅฐๆถๆฐ)
*
* @param beginDate
* @param endDate
* @param hourOfDay
* @return
*/
public static int getDiffDaysByHour(Date beginDate, Date endDate, int hourOfDay) {
Calendar begin = Calendar.getInstance();
begin.setTime(beginDate);
begin.set(Calendar.HOUR_OF_DAY, hourOfDay);
begin.set(Calendar.MINUTE, 0);
begin.set(Calendar.SECOND, 0);
begin.set(Calendar.MILLISECOND, 0);
long bt = begin.getTimeInMillis();
begin.set(Calendar.HOUR_OF_DAY, 0);
//่ฏดๆไธๆฌก่ถ
่ฟๆญคๅฐๆถ
if (beginDate.getTime() >= bt) {
begin.add(Calendar.DAY_OF_YEAR, 1);
}
Calendar end = Calendar.getInstance();
end.setTime(endDate);
end.set(Calendar.HOUR_OF_DAY, hourOfDay);
end.set(Calendar.MINUTE, 0);
end.set(Calendar.SECOND, 0);
end.set(Calendar.MILLISECOND, 0);
long et = end.getTimeInMillis();
//่ฏดๆๆฌๆฌก่ถ
่ฟๆญคๅฐๆถ
end.set(Calendar.HOUR_OF_DAY, 0);
if (endDate.getTime() >= et) {
end.add(Calendar.DAY_OF_YEAR, 1);
}
return (int) ((end.getTimeInMillis() - begin.getTimeInMillis()) / MILLISECONDS_OF_DAY);
}
/**
* ไธคไธชๆถ้ด็ธๅทฎๅคฉๆฐ
*
* @param beginDate
* @param endDate
* @return
*/
public static int getDiffDays(Date beginDate, Date endDate) {
Calendar begin = Calendar.getInstance();
begin.setTime(beginDate);
begin.set(Calendar.HOUR_OF_DAY, 0);
begin.set(Calendar.MINUTE, 0);
begin.set(Calendar.SECOND, 0);
begin.set(Calendar.MILLISECOND, 0);
Calendar end = Calendar.getInstance();
end.setTime(endDate);
end.set(Calendar.HOUR_OF_DAY, 0);
end.set(Calendar.MINUTE, 0);
end.set(Calendar.SECOND, 0);
end.set(Calendar.MILLISECOND, 0);
return (int) ((end.getTimeInMillis() - begin.getTimeInMillis()) / MILLISECONDS_OF_DAY);
}
/**
* ๅฐHH:mmๆถ้ดๆ ผๅผ่ฝฌๅไธบๅ้
*
* @param time
* @return
*/
public static int parseTime2Int(String time) {
String[] hm = time.split(":");
return Integer.parseInt(hm[0]) * 60 + Integer.parseInt(hm[1]);
}
/**
* ่ทๅพ ๅคงไบtime็ๆ่ฟ็5ๅ้็ๅๆฐ็ๆถ้ด
*
* @return
*/
public static Date get5Multiple(long time) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(time));
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
int min = c.get(Calendar.MINUTE);
min = min + (5 - min % 5);
c.set(Calendar.MINUTE, min);
return c.getTime();
}
/**
* ่ทๅพไธคไธชๆถ้ด็ธๅทฎๅฐๆถๆฐ
*
* @param begin
* @param end
* @return
*/
public static int getDiffHour(Date begin, Date end) {
Calendar c0 = Calendar.getInstance();
c0.setTime(begin);
c0.set(Calendar.MINUTE, 0);
c0.set(Calendar.SECOND, 0);
c0.set(Calendar.MILLISECOND, 0);
Calendar c1 = Calendar.getInstance();
c1.setTime(end);
c1.set(Calendar.MINUTE, 0);
c1.set(Calendar.SECOND, 0);
c1.set(Calendar.MILLISECOND, 0);
return (int) ((c1.getTimeInMillis() - c0.getTimeInMillis()) / MILLISECONDS_OF_HOUR);
}
/**
* ่ทๅพไธคไธชๆถ้ด็ธๅทฎๅ้
*
* @param begin
* @param end
* @return
*/
public static int getDiffMinite(Date begin, Date end) {
Calendar c0 = Calendar.getInstance();
c0.setTime(begin);
c0.set(Calendar.SECOND, 0);
c0.set(Calendar.MILLISECOND, 0);
Calendar c1 = Calendar.getInstance();
c1.setTime(end);
c1.set(Calendar.SECOND, 0);
c1.set(Calendar.MILLISECOND, 0);
return (int) ((c1.getTimeInMillis() - c0.getTimeInMillis()) / MILLISECONDS_OF_MINITE);
}
/**
* ๅคๆญไธคไธชๆฅๆๆฏไธๆฏๅไธๅคฉ
*
* @param beginDate
* @param endDate
* @return
*/
public static boolean isSameDay(Date beginDate, Date endDate) {
return getDiffDays(beginDate, endDate) == 0;
}
/**
* ๅคๆญไธคไธชๆฅๆๆฏๅฆๅไธๅจ
*
* @param beginDate
* @param endDate
* @return
*/
public static boolean isSameWeek(Date beginDate, Date endDate) {
Calendar begin = Calendar.getInstance();
begin.setTime(beginDate);
Calendar end = Calendar.getInstance();
end.setTime(endDate);
//ๆข็ฎbeginDate็ๅจไธๆถ้ด
int beginDayOfWeek = begin.get(Calendar.DAY_OF_WEEK);
if (beginDayOfWeek == 1) {
begin.add(Calendar.DAY_OF_YEAR, -6);
} else if (beginDayOfWeek > 2) {
begin.add(Calendar.DAY_OF_YEAR, 2 - beginDayOfWeek);
}
//ๆข็ฎendDate็ๅจไธๆถ้ด
int endDayOfWeek = end.get(Calendar.DAY_OF_WEEK);
if (endDayOfWeek == 1) {
end.add(Calendar.DAY_OF_YEAR, -6);
} else if (endDayOfWeek > 2) {
end.add(Calendar.DAY_OF_YEAR, 2 - endDayOfWeek);
}
return ((end.get(Calendar.YEAR) == begin.get(Calendar.YEAR)) && (end.get(Calendar.DAY_OF_YEAR) == begin.get(Calendar.DAY_OF_YEAR)));
}
public static boolean isInTime(Date time, Date begin, Date end) {
long mill = time.getTime();
return begin.getTime() < mill && mill < end.getTime();
}
/**
* ๅคๆญๆๆถ้ดๆฏๅฆๅคๅจๆไธชๆถ้ดๆฎตๅ
*
* @param time ๆ ผๅผ hh:MM
* @param begin ๆ ผๅผ hh:MM
* @param end ๆ ผๅผ hh:MM
* @return
*/
public static boolean isInTime(String time, String begin, String end) {
try {
String[] timeArr = time.split(":");
if (timeArr.length != 2) return false;
byte hour = Byte.parseByte(timeArr[0]);
byte min = Byte.parseByte(timeArr[1]);
String[] beginArr = begin.split(":");
if (beginArr.length != 2) return false;
byte bHour = Byte.parseByte(beginArr[0]);
byte bMin = Byte.parseByte(beginArr[1]);
String[] endArr = end.split(":");
if (endArr.length != 2) return false;
byte eHour = Byte.parseByte(endArr[0]);
byte eMin = Byte.parseByte(endArr[1]);
return isInTime(hour, min, bHour, bMin, eHour, eMin);
} catch (Exception e) {
log.error("", e);
}
return false;
}
/**
* ๅคๆญ time ๆฏๅฆๆฏๅจcomp็ๆถ้ดๅบ้ดๅ
*
* @param time
* @param comp
* @param bHour
* @param bMin
* @param eHour
* @param eMin
* @return
*/
public static boolean isInTime(Date time, Date comp, int bHour, int bMin, int eHour, int eMin) {
Calendar c = Calendar.getInstance();
c.setTime(time);
int d0 = c.get(Calendar.DAY_OF_YEAR);
Calendar c1 = Calendar.getInstance();
c.setTime(comp);
int d1 = c1.get(Calendar.DAY_OF_YEAR);
if (d0 != d1) return false;
byte hour = (byte) c.get(Calendar.HOUR_OF_DAY);
byte min = (byte) c.get(Calendar.MINUTE);
return isInTime(hour, min, bHour, bMin, eHour, eMin);
}
/**
* ็ปๅฎๆถ้ดๆฏๅฆๅจๆถ้ดๆฎตๅ
*
* @param time ็ปๅฎ็ๆถ้ด
* @param bHour ๅผๅงๆถ้ด็ๅฐๆถ
* @param bMin ๅผๅงๆถ้ด็ๅ้
* @param eHour ็ปๆๆถ้ด็ๅฐๆถ
* @param eMin ็ปๆๆถ้ด็ๅ้
* @return
*/
public static boolean isInTime(Date time, int bHour, int bMin, int eHour, int eMin) {
Calendar c = Calendar.getInstance();
c.setTime(time);
byte hour = (byte) c.get(Calendar.HOUR_OF_DAY);
byte min = (byte) c.get(Calendar.MINUTE);
return isInTime(hour, min, bHour, bMin, eHour, eMin);
}
public static boolean isInTime(int hour, int min, int bHour, int bMin, int eHour, int eMin) {
int time = hour * 60 + min;
int begin = bHour * 60 + bMin;
int end = eHour * 60 + eMin;
return begin <= time && time <= end;
}
/**
* ็ปๅฎๆถ้ดๅจๆถ้ดๆฎตๅๅ
ๅ็ถๆ๏ผ-1ๅ 0ๅ
1ๅ๏ผ
*
* @param
* @param bHour
* @param bMin
* @param eHour
* @param eMin
* @return
*/
public static int getInTimeStatus(Date date, int bHour, int bMin, int eHour, int eMin) {
Calendar c = Calendar.getInstance();
c.setTime(date);
byte hour = (byte) c.get(Calendar.HOUR_OF_DAY);
byte min = (byte) c.get(Calendar.MINUTE);
int time = hour * 60 + min;
int begin = bHour * 60 + bMin;
int end = eHour * 60 + eMin;
if (time < begin) return -1;
else if (time > end) return 1;
else return 0;
}
/**
* ๅฐ hh:mm-hh:mmๆ ผๅผ็ๅญ็ฌฆไธฒ่ฝฌๅไธบ้ฟๅบฆไธบ4็ๅญ่ๆฐ็ป
*
* @param time
* @return
*/
public static byte[] parseTime2Array(String time) {
String[] fArr = time.split("\\-");
String[] fArr0 = fArr[0].split(":");
String[] fArr1 = fArr[1].split(":");
return new byte[]{Byte.parseByte(fArr0[0]),
Byte.parseByte(fArr0[1]),
Byte.parseByte(fArr1[0]),
Byte.parseByte(fArr1[1]),};
}
/**
* ๅฐdate ๅๅๆ่
ๅๅ็งปๅจๅ ๅคฉ
*
* @param date ๆๅฎ็ๆถ้ด
* @param dayNum ็งปๅจ็ๅคฉๆฐ
* @param clearTime true-ๆธ
้คๆถๅ็งๆฏซ็ง,false-ไธๆธ
้ค
* @return
*/
public static Date moveDate(Date date, int dayNum, boolean clearTime) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int curDay = c.get(Calendar.DAY_OF_YEAR);
c.set(Calendar.DAY_OF_YEAR, curDay + dayNum);
if (clearTime) {
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
}
return c.getTime();
}
/**
* ๆ นๆฎๅฐๆถๅๅ่ทๅพๅฝๅคฉๆถ้ด
*
* @param hour
* @param minute
* @return
*/
public static Date getDateByHm(int hour, int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
/**
* ๆ นๆฎๅฐๆถๅๅ่ทๅพๅไธๅคฉๆถ้ด
*
* @param hour
* @param minute
* @return
*/
public static Date getPreDateByHm(int hour, int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
c.add(Calendar.DAY_OF_YEAR, -1);
return c.getTime();
}
/**
* ๆ นๆฎๅฐๆถๅๅ่ทๅพๅไธๅคฉๆถ้ด
*
* @param hour
* @param minute
* @return
*/
public static Date getNextDateByHm(int hour, int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
c.add(Calendar.DAY_OF_YEAR, 1);
return c.getTime();
}
/**
* ๅฐdate ๅๅๆ่
ๅๅ็งปๅจๅ ๅฐๆถ
*
* @param date ๆๅฎ็ๆถ้ด
* @param housrNum ็งปๅจ็ๅฐๆถๆฐ
* @param clearTime true-ๆธ
้คๅ็งๆฏซ็ง,false-ไธๆธ
้ค
* @return
*/
public static Date moveHour(Date date, int housrNum, boolean clearTime) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int curHour = c.get(Calendar.HOUR_OF_DAY);
c.set(Calendar.HOUR_OF_DAY, curHour + housrNum);
if (clearTime) {
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
}
return c.getTime();
}
/**
* ๅฐdate ๅๅๆ่
ๅๅ็งปๅจๅ ๅ้
*
* @param date ๆๅฎ็ๆถ้ด
* @param minitNum ็งปๅจ็ๅ้ๆฐ
* @param clearTime true-ๆธ
้ค็งๆฏซ็ง,false-ไธๆธ
้ค
* @return
*/
public static Date moveMinit(Date date, int minitNum, boolean clearTime) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int curHour = c.get(Calendar.MINUTE);
c.set(Calendar.MINUTE, curHour + minitNum);
if (clearTime) {
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
}
return c.getTime();
}
/**
* ๅฐDate็ฑปๅ่ฝฌๆขไธบๅญ็ฌฆไธฒ
*
* @param date ๆฅๆ็ฑปๅ
* @return ๆฅๆๅญ็ฌฆไธฒ
*/
public static String format(Date date) {
return format(date, "yyyy-MM-dd HH:mm:ss");
}
/**
* ๅฐDate็ฑปๅ่ฝฌๆขไธบๅญ็ฌฆไธฒ
*
* @param date ๆฅๆ็ฑปๅ
* @param pattern ๅญ็ฌฆไธฒๆ ผๅผ
* @return ๆฅๆๅญ็ฌฆไธฒ
*/
public static String format(Date date, String pattern) {
if (date == null) {
return "null";
}
if (pattern == null || pattern.equals("") || pattern.equals("null")) {
pattern = "yyyy-MM-dd HH:mm:ss";
}
return new SimpleDateFormat(pattern).format(date);
}
/**
* ๅฐๅญ็ฌฆไธฒ่ฝฌๆขไธบDate็ฑปๅ
*
* @param date ๅญ็ฌฆไธฒ็ฑปๅ
* @return ๆฅๆ็ฑปๅ
*/
public static Date format(String date) {
return format(date, null);
}
/**
* ๅฐๅญ็ฌฆไธฒ่ฝฌๆขไธบDate็ฑปๅ
*
* @param date ๅญ็ฌฆไธฒ็ฑปๅ
* @param pattern ๆ ผๅผ
* @return ๆฅๆ็ฑปๅ
*/
public static Date format(String date, String pattern) {
if (pattern == null || pattern.equals("") || pattern.equals("null")) {
pattern = "yyyy-MM-dd HH:mm:ss";
}
if (date == null || date.equals("") || date.equals("null")) {
return new Date();
}
Date d = null;
try {
d = new SimpleDateFormat(pattern).parse(date);
} catch (ParseException pe) {
}
return d;
}
/**
* @param date ๆๅฎ็ๆฅๆ
* @return Date
* @Description ่ทๅๆๅฎๆถ้ดๆๅจๆฅๆ็ๅผๅงๆถ้ด
*/
public static Date getStartTimeOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* @param date ๆๅฎ็ๆฅๆ
* @return Date
* @Description ่ทๅๆๅฎๆถ้ดๆๅจๆฅๆ็็ปๆๆถ้ด
*/
public static Date getEndTimeOfDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTime();
}
/**
* @param date ้่ฆ่ฝฌๆข็ๆถ้ด
* @return ๆๅฎๆ ผๅผๆฅๆไธฒ
* @Description ๅฐๅฏนๅบๆถ้ด่ฝฌๆขไธบ.netๅๅ
ฅredis็ๆถๆๆ ผๅผ
*/
public static String transferNetDateString(Date date) {
if (date == null) {
return "";
}
return "/Date(" + date.getTime() + "-0000)/";
}
}
| [
"[email protected]"
] | |
281b0722fc5dfd272523ceabf63a52e9da02343e | f8405484c956d85a1bf6fce05b499790a6f2b0e2 | /src/main/java/astro/TreeNode/CheckJson.java | 77c0e6acdeb1f7316983889edf746ee68bb9aa8b | [] | no_license | Astropl/ToDoApp | 06c8ab9730a7f4d3304a207828e4c3ed8e0330c7 | 85367919d53258da9754728aaa4d1e75f5f204c9 | refs/heads/master | 2020-03-28T11:24:50.281025 | 2018-10-10T20:32:03 | 2018-10-10T20:32:03 | 148,210,297 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,607 | java | //package astro.TreeNode;
//
//import javax.json.*;
//import javax.json.stream.JsonGenerator;
//import javax.json.stream.JsonGeneratorFactory;
//import javax.json.stream.JsonParser;
//import javax.json.stream.JsonParserFactory;
//import java.io.ByteArrayInputStream;
//import java.io.OutputStream;
//import java.util.Collections;
//import java.util.Map;
//
//public class CheckJson
//{
//
//
// public static void main(String[] args) {
// objectModeWriting();
// objectModeReading();
// streamModeWriting();
// streamModeReading();
// }
//
// private static void streamModeWriting() {
// JsonGeneratorFactory generatorFactory = Json.createGeneratorFactory(Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true));
// JsonGenerator generator = generatorFactory.createGenerator(System.out);
// generator
// .writeStartObject()
// .write("imiฤ", "Marcin")
// .write("nazwisko", "Pietraszek")
// .writeStartObject("strona")
// .write("adres www", "http://www.samouczekprogramisty.pl")
// .writeStartArray("artykuลy")
// .writeStartObject()
// .write("tytuล", "Format JSON w jฤzyku Java")
// .writeStartObject("data publikacji")
// .write("rok", 2018)
// .write("miesiฤ
c", 9)
// .write("dzieล", 13)
// .writeEnd()
// .writeEnd()
// .writeEnd()
// .writeEnd()
// .writeEnd().flush();
// }
//
// private static void streamModeReading() {
// JsonParserFactory parserFactory = Json.createParserFactory(Collections.emptyMap());
// JsonParser parser = parserFactory.createParser(buildObject());
//
// while (parser.hasNext()) {
// JsonParser.Event event = parser.next();
// switch (event) {
// case START_OBJECT:
// System.out.println("{");
// break;
// case END_OBJECT:
// System.out.println("}");
// break;
// case START_ARRAY:
// System.out.println("[");
// break;
// case END_ARRAY:
// System.out.println("]");
// break;
// case KEY_NAME:
// System.out.print(String.format("\"%s\": ", parser.getString()));
// break;
// case VALUE_NUMBER:
// System.out.println(parser.getBigDecimal());
// break;
// case VALUE_STRING:
// System.out.println(String.format("\"%s\"", parser.getString()));
// break;
// default:
// System.out.println("true, false or null");
// }
// }
//
// }
//
// private static void objectModeWriting() {
// JsonObject authorObject = buildObject();
//
// System.out.println(authorObject.toString());
// write(authorObject, System.out);
// }
//
// private static void write(JsonObject jsonObject, OutputStream outputStream) {
// Map<String, ?> config = Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true);
// JsonWriterFactory writerFactory = Json.createWriterFactory(config);
// writerFactory.createWriter(outputStream).write(jsonObject);
// }
//
// private static void objectModeReading() {
// String jsonDocument = buildObject().toString();
//
// JsonReaderFactory readerFactory = Json.createReaderFactory(Collections.emptyMap());
// try (JsonReader jsonReader = readerFactory.createReader(new ByteArrayInputStream(jsonDocument.getBytes()))) {
// JsonStructure jsonStructure = jsonReader.read();
// System.out.println(jsonStructure.getValue("/strona/artykuลy/0/data publikacji"));
// }
//
// try (JsonReader jsonReader = readerFactory.createReader(new ByteArrayInputStream(jsonDocument.getBytes()))) {
// JsonObject jsonObject = jsonReader.readObject();
// System.out.println(jsonObject
// .getJsonObject("strona")
// .getJsonArray("artykuลy")
// .get(0).asJsonObject()
// .getJsonObject("data publikacji")
// );
// }
// }
//
// private static JsonObject buildObject() {
// JsonBuilderFactory builderFactory = Json.createBuilderFactory(Collections.emptyMap());
// JsonObject publicationDateObject = builderFactory.createObjectBuilder()
// .add("rok", 2018)
// .add("miesiฤ
c", 9)
// .add("dzieล", 13).build();
//
// JsonObject articleObject = builderFactory.createObjectBuilder()
// .add("tytuล", "Format JSON w jฤzyku Java")
// .add("data publikacji", publicationDateObject).build();
//
// JsonArray articlesArray = builderFactory.createArrayBuilder().add(articleObject).build();
//
// JsonObject webPageObject = builderFactory.createObjectBuilder()
// .add("adres www", "http://www.samouczekprogramisty.pl")
// .add("artykuลy", articlesArray).build();
//
// return builderFactory.createObjectBuilder()
// .add("imiฤ", "Marcin")
// .add("nazwisko", "Pietraszek")
// .add("strona", webPageObject).build();
// }
//
//
//}
| [
"[email protected]"
] | |
5be134a10597f7f93de3f6e4ab8dc5652032176b | 62d8278bb715a0c6f47312402d182ee08717a952 | /src/KMPTester.java | 1e047bdc6a168a7277285d1ab6aea33ef3af8138 | [] | no_license | shirleyyoung0812/Knuth-Morris-Pratt-Algorithm | 2eb37de7daf70d53f3ea3c11ab46dd42a7161b00 | 4c1fdf05dbf213ee36480451da8c1db63bfd6dcb | refs/heads/master | 2020-05-17T02:51:25.251308 | 2015-01-12T06:01:12 | 2015-01-12T06:01:12 | 29,121,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | import java.util.*;
public class KMPTester {
public static void main(String[] args) {
// TODO Auto-generated method stub
KMP k = new KMP();
String text = "bbaba";
String pattern = "bbb";
//k.searchSubString(text, pattern);
List<Integer> rst = k.searchSubString(text, pattern);
for (Integer i : rst)
System.out.println(i);
}
}
| [
"[email protected]"
] | |
cc2b1636dcdb2bb6375250ec86c858ddf535da20 | 9d09f0a59fe5087000ce4010737441357de9ae65 | /app/src/main/java/com/xsvideoLive/www/mvp/contract/ChiliOutlayContract.java | 66a294b5920146b904b6bbaf261e64e4b744f372 | [] | no_license | lgh990/XiuSe | 694e6fd078fec2c4ca537654f8d4aeef5037272d | b3d659c47fae10cf59b2a8fe1eeb65e68f82836f | refs/heads/master | 2023-03-01T13:14:19.763557 | 2021-02-02T04:53:38 | 2021-02-02T04:53:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,423 | java | package com.xsvideoLive.www.mvp.contract;
import com.xsvideoLive.www.base.BaseView;
import com.xsvideoLive.www.net.HttpObservable;
import com.xsvideoLive.www.net.bean.BaseResponse;
import com.xsvideoLive.www.net.bean.ChiliIncomeResult;
import com.xsvideoLive.www.net.bean.HomeRoomResult;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.List;
public interface ChiliOutlayContract {
interface View extends BaseView {
void onError(String msg);
/**
* ่ฎพ็ฝฎๆถ้ด
*
* @param date
*/
void setTime(String date);
/**
* ๅทๆฐๆๅ
* @param refresh
* @param incomeList
*/
void refreshSuccess(RefreshLayout refresh, List<ChiliIncomeResult> incomeList);
/**
* ๅ ่ฝฝๆๅ
* @param refresh
* @param incomeList
*/
void loadMoreSuccess(RefreshLayout refresh, List<ChiliIncomeResult> incomeList);
}
interface Presenter {
/**
* ๆถ้ด้ๆฉ
*/
void selectTime(String date);
/**
* ่ทๅๆถๅ
ฅๅ่กจ
* @param date
*/
void getOutlayList(RefreshLayout refresh, String date);
}
interface Model {
HttpObservable<BaseResponse<HomeRoomResult<List<ChiliIncomeResult>>>> getOutlayList(String current, String size, String date);
}
}
| [
"[email protected]"
] | |
06ca375581b6175cc27848f83882666dfe6e4af0 | b6e703be01f5019b395032ebef2263fdb38f8493 | /src/main/java/com/mikemyzhao/springbootdemo/entity/Student.java | 9f2a6417d804f82f4263f7c5f6c6cdf6462b2be0 | [] | no_license | tjzhaomengyi/SpringBootDemo | 0bbb9d243c72e3ce1c4c930b03dfc74a2bd5f9a9 | f8906bea691109d5d13eb2c4b0a9ae1d335daaf1 | refs/heads/master | 2020-07-16T18:01:54.399546 | 2019-09-03T09:20:06 | 2019-09-03T09:20:06 | 205,838,257 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,394 | java | package com.mikemyzhao.springbootdemo.entity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Auther: zhaomengyi
* @Date: 2019/9/2 16:19
* @Description:
*/
@Component
@ConfigurationProperties(prefix = "student")
//@PropertySource(value = {"classpath:confg.properties"})
public class Student {
// @Value("zl")
private String name;
private int age;
private boolean sex;
private Date birthday;
private Map<String,Object> location;
private String[] hobbies;
private List<String> skills;
private Pet pet;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Map<String, Object> getLocation() {
return location;
}
public void setLocation(Map<String, Object> location) {
this.location = location;
}
public String[] getHobbies() {
return hobbies;
}
public void setHobbies(String[] hobbies) {
this.hobbies = hobbies;
}
public List<String> getSkills() {
return skills;
}
public void setSkills(List<String> skills) {
this.skills = skills;
}
public Pet getPet() {
return pet;
}
public void setPet(Pet pet) {
this.pet = pet;
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", age=" + age +
", sex=" + sex +
", birthday=" + birthday +
", location=" + location +
", hobbies=" + Arrays.toString(hobbies) +
", skills=" + skills +
", pet=" + pet +
'}';
}
}
| [
"[email protected]"
] | |
df1ac2fa4c581e80aaa2540a7ed0067bff35b2a4 | 9df1918f9dc5f0fb45dfa67f89f7d232de9ac400 | /src/MultiFinished.java | e21cf769e487f54badc2679db6486b671a2a582f | [] | no_license | yhl452493373/multi-thread | 487c27594bdf7af72784309e600a093562135f51 | 5db8ff4077eedbc84f4df0ec7fcb133e81f46b94 | refs/heads/master | 2020-06-21T16:31:09.005479 | 2019-07-22T09:01:22 | 2019-07-22T09:01:22 | 197,502,797 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 189 | java | import java.util.Collection;
/**
* ็จไบๅจๆๆไปปๅกๆง่กๅฎๅ่ฎก็ฎ็ปๆ็ๆฅๅฃ
*/
public interface MultiFinished<ReturnType> {
void run(Collection<ReturnType> results);
}
| [
"[email protected]"
] | |
bb96371fcc97821f0289dbbc418464fc718aeaf4 | b16953fc909eea1116dd9ee7a9ee1a9d340ffb80 | /src/main/java/com/gioov/spiny/system/controller/ApiController.java | c207c820745da2ede81cb311d9c15098901fd569 | [] | no_license | tamutamu-archive/spiny | b166ab3fb1ce99e5977f7a27f6e18a286374b125 | 1bcc52e090593888130b4299cd0258b05970bc51 | refs/heads/master | 2021-09-20T06:27:41.278456 | 2018-08-06T00:29:22 | 2018-08-06T00:29:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 997 | java | package com.gioov.spiny.system.controller;
import com.gioov.spiny.common.constant.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import static com.gioov.spiny.user.service.UserService.SYSTEM_ADMIN;
/**
* @author godcheese
* @date 2018/5/18
*/
@Controller
@RequestMapping(Page.System.API)
public class ApiController {
@PreAuthorize("hasRole('" + SYSTEM_ADMIN + "') OR hasAuthority('/SYSTEM/API/PAGE_ALL')")
@RequestMapping("/page_all")
public String pageAll() {
return Page.System.API + "/page_all";
}
@PreAuthorize("isAuthenticated()")
@RequestMapping("/add_dialog")
public String addDialog() {
return Page.System.API + "/add_dialog";
}
@PreAuthorize("isAuthenticated()")
@RequestMapping("/edit_dialog")
public String editDialog() {
return Page.System.API + "/edit_dialog";
}
}
| [
"[email protected]"
] | |
ecd476db05c3662932659f478b5ede201aa1de7c | 4f09245c1ba239b831b9ce199bb9f962d5b2c080 | /jd1-08-class-task08/src/by/home/les08/entity/Customer.java | ae19a2789959090341247c10ae3d0ef4fce5848d | [] | no_license | alvishevaty/HW_Java_Fundamentals_Part4 | 06ef8ffc4c9b6aa3f057f287e4e795e00f229a19 | f705b785e3382f25b3f330f6acb0bc1feaf9acd2 | refs/heads/master | 2020-09-12T17:24:48.790825 | 2019-11-25T16:55:08 | 2019-11-25T16:55:08 | 222,491,801 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,043 | java | package by.home.les08.entity;
public class Customer {
private int id;
private String surname;
private String name;
private String patronymic;
private int cardNumber;
private int bankAccountNumber;
public Customer() {
this.id = 0;
this.surname = "";
this.name = "";
this.patronymic = "";
this.cardNumber = 000000000;
this.bankAccountNumber = 000000000;
}
public Customer(int id, String surname, String name, String patronymic, int cardNumber, int bankAccountNumber) {
this.id = id;
this.surname = surname;
this.name = name;
this.patronymic = patronymic;
this.cardNumber = cardNumber;
this.bankAccountNumber = bankAccountNumber;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPatronymic() {
return patronymic;
}
public void setPatronymic(String patronymic) {
this.patronymic = patronymic;
}
public int getCardNumber() {
return cardNumber;
}
public void setCardNumber(int cardNumber) {
this.cardNumber = cardNumber;
}
public int getBankAccountNumber() {
return bankAccountNumber;
}
public void setBankAccountNumber(int bankAccountNumber) {
this.bankAccountNumber = bankAccountNumber;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + bankAccountNumber;
result = prime * result + cardNumber;
result = prime * result + id;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((patronymic == null) ? 0 : patronymic.hashCode());
result = prime * result + ((surname == null) ? 0 : surname.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Customer other = (Customer) obj;
if (bankAccountNumber != other.bankAccountNumber)
return false;
if (cardNumber != other.cardNumber)
return false;
if (id != other.id)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (patronymic == null) {
if (other.patronymic != null)
return false;
} else if (!patronymic.equals(other.patronymic))
return false;
if (surname == null) {
if (other.surname != null)
return false;
} else if (!surname.equals(other.surname))
return false;
return true;
}
@Override
public String toString() {
return "Customer [id=" + id + ", surname=" + surname + ", name=" + name + ", patronymic=" + patronymic
+ ", cardNumber=" + cardNumber + ", bankAccountNumber=" + bankAccountNumber + "]";
}
}
| [
"[email protected]"
] | |
9198927fe17e87105de6456bf6e5241a69c2b5d1 | e561e4d2db78d42a01828ed759860447700a8be5 | /app/src/main/java/withdraw/presenter/IWithDrawPresenter.java | 3f0dc6d88c0903358bf53137cecaddd4fe498dd6 | [] | no_license | QwangShuai/o2o_android-master | 820f411223488ee81248d62b2237ea1e4d8d0219 | 34dcb7260c95f201419ce1ebac5b2d5a4c869d67 | refs/heads/master | 2020-03-08T01:34:02.911829 | 2018-04-03T01:39:09 | 2018-04-03T01:39:09 | 127,834,199 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 174 | java | package withdraw.presenter;
import com.gjzg.bean.WithDrawBean;
public interface IWithDrawPresenter {
void withdraw(WithDrawBean withDrawBean);
void destroy();
}
| [
"[email protected]"
] | |
7da3d88fcd28bf6d695ee35fbcff75b3e53de91c | 54e010e7511081bd3564b56f9ec5570a9a05c33a | /src/main/java/leetcode/code600/Code521.java | f03523a1fcbdee7fea26011d79a3fc320b6c5579 | [] | no_license | hanhauran/leetcode-java | f640c0a7f2623de283050676f5090e9dcad94f38 | 9099f2f011004152fc5a0a883e3644be6f415afa | refs/heads/master | 2021-10-11T00:40:26.197821 | 2019-01-20T05:33:39 | 2019-01-20T05:33:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 271 | java | package leetcode.code600;
/**
* @author hr.han
* @date 2018/12/5 20:34
*/
public class Code521 {
public int findLUSlength(String a, String b) {
return a.length() == b.length() ? (a.equals(b) ? -1 : a.length()) : Math.max(a.length(), b.length());
}
}
| [
"[email protected]"
] | |
5063468d7c2596dbfab17dfa75ebd4c559b40452 | 13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3 | /crash-reproduction-new-fitness/results/LANG-9b-1-14-Single_Objective_GGA-IntegrationSingleObjective-BasicBlockCoverage/org/apache/commons/lang3/time/FastDateParser_ESTest_scaffolding.java | 1b3c895fefdce041082449dbea1a647a5758e299 | [
"MIT",
"CC-BY-4.0"
] | permissive | STAMP-project/Botsing-basic-block-coverage-application | 6c1095c6be945adc0be2b63bbec44f0014972793 | 80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da | refs/heads/master | 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 448 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Sat May 16 11:40:00 UTC 2020
*/
package org.apache.commons.lang3.time;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class FastDateParser_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
| [
"[email protected]"
] | |
9b7daa6a539c4dd6485ffa139ef2b72b57aa78bf | 22646343df9ff211be29eadb5116feeb40cc7a21 | /app/src/main/java/de/gamedots/mindlr/mindlrfrontend/view/fragment/TutorialFragment.java | 6d5a33e84800f0001e438674891e1c3a331f1fc3 | [] | no_license | d1rkHH/MindlrFrontend | b33680309158b5046c30244c19e3995073e196de | da9ab5150db0bcaa0d8463f60b1f5210e5c8e4d8 | refs/heads/master | 2021-03-27T19:10:34.072454 | 2017-01-19T05:14:52 | 2017-01-19T05:14:52 | 42,356,593 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,499 | java | package de.gamedots.mindlr.mindlrfrontend.view.fragment;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.anton46.collectionitempicker.CollectionPicker;
import com.anton46.collectionitempicker.Item;
import com.anton46.collectionitempicker.OnItemClickListener;
import com.google.android.gms.common.SignInButton;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import de.gamedots.mindlr.mindlrfrontend.R;
import de.gamedots.mindlr.mindlrfrontend.auth.GoogleProvider;
import de.gamedots.mindlr.mindlrfrontend.auth.TwitterProvider;
import de.gamedots.mindlr.mindlrfrontend.data.MindlrContract.CategoryEntry;
import de.gamedots.mindlr.mindlrfrontend.helper.CategoryHelper;
import de.gamedots.mindlr.mindlrfrontend.view.customview.CustomTwitterLoginButton;
public class TutorialFragment extends Fragment {
public static final String PAGE_ARGUMENT = "page_argument";
public static final int MIN_SELECT_CATEGORIES = 3;
private boolean _skippedAlreadyAccount;
public TutorialFragment() {
}
public static TutorialFragment newInstance(int page) {
TutorialFragment fragmentFirst = new TutorialFragment();
Bundle args = new Bundle();
args.putInt(PAGE_ARGUMENT, page);
fragmentFirst.setArguments(args);
return fragmentFirst;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view;
if (getArguments() != null && getArguments().getInt(PAGE_ARGUMENT) == 3) {
view = inflater.inflate(R.layout.fragment_tutorial_end, container, false);
List<Item> items = new ArrayList<>();
Cursor catCursor = getContext().getContentResolver()
.query(CategoryEntry.CONTENT_URI, null, null, null, null);
final Set<Long> selectedCategories = CategoryHelper.getCategories();
// get all available categories from db
// and add theme to collection picker list
if (catCursor != null) {
while (catCursor.moveToNext()) {
long id = catCursor.getLong(catCursor.getColumnIndex(CategoryEntry._ID));
String name = catCursor.getString(catCursor.getColumnIndex(CategoryEntry.COLUMN_DISPLAY_NAME));
items.add(new Item(Long.toString(id), name));
}
catCursor.close();
}
/* add the authentication fragment to the activity and configure listener. */
final AuthFragment authFragment = AuthFragment.getInstance();
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.add(R.id.auth_button_container, authFragment, AuthFragment.TAG);
ft.commit();
final SignInButton googleLoginButton =
(SignInButton) view.findViewById(R.id.google_signIn_button);
final CustomTwitterLoginButton twitterLoginButton =
(CustomTwitterLoginButton) view.findViewById(R.id.twitter_login_button);
/* Provider Button handling, set provider according to pressed button and start auth flow */
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v instanceof CustomTwitterLoginButton) {
authFragment.setIdentityProvider(new TwitterProvider(getContext()));
} else if (v instanceof SignInButton) {
authFragment.setIdentityProvider(new GoogleProvider(getActivity()));
}
authFragment.startLogin();
}
};
twitterLoginButton.setOnClickListener(listener);
googleLoginButton.setOnClickListener(listener);
final TextView skippSelectionTV = (TextView)view.findViewById(R.id
.tutorial_skip_cat_selection_textview);
final TextView skipInfoTV = (TextView)view.findViewById(R.id.skip_info_textview);
skippSelectionTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// hide skip information and enable login buttons
skipInfoTV.setVisibility(View.GONE);
skippSelectionTV.setVisibility(View.GONE);
googleLoginButton.setVisibility(View.VISIBLE);
twitterLoginButton.setVisibility(View.VISIBLE);
// we skipped so set flag
_skippedAlreadyAccount = true;
}
});
CollectionPicker picker = (CollectionPicker) view.findViewById(R.id.collection_item_picker);
picker.setItems(items);
picker.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onClick(com.anton46.collectionitempicker.Item item, int position) {
long id = Long.parseLong(item.id);
if (selectedCategories.contains(id)) {
selectedCategories.remove(id);
} else {
selectedCategories.add(id);
}
if (!_skippedAlreadyAccount) {
int visibility = (selectedCategories.size() >= MIN_SELECT_CATEGORIES) ?
View.VISIBLE : View.GONE;
googleLoginButton.setVisibility(visibility);
twitterLoginButton.setVisibility(visibility);
int skipVisibility = (visibility == View.VISIBLE) ? View.GONE : View.VISIBLE;
skipInfoTV.setVisibility(skipVisibility);
skippSelectionTV.setVisibility(skipVisibility);
}
}
});
// end if page == 3
} else {
view = inflater.inflate(R.layout.fragment_tutorial, container, false);
TextView title = (TextView) view.findViewById(R.id.tutorial_title_textview);
TextView subhead = (TextView) view.findViewById(R.id.tutorial_subhead_textview);
ImageView slideImage = (ImageView) view.findViewById(R.id.tutorial_imageview);
int titleRes = R.string.slide_0_title;
int subheadRes = R.string.slide_0_desc;
int imageRes = R.drawable.ic_logo;
if (getArguments() != null) {
switch (getArguments().getInt(PAGE_ARGUMENT)) {
case 1:
titleRes = R.string.slide_1_title;
subheadRes = R.string.slide_1_desc;
break;
case 2:
titleRes = R.string.slide_2_title;
subheadRes = R.string.slide_2_desc;
break;
}
}
title.setText(titleRes);
subhead.setText(subheadRes);
slideImage.setImageResource(imageRes);
}
return view;
}
}
| [
"[email protected]"
] | |
42a65cf67472235adab66a1932071a00e69b5617 | 35d0c5dfa5337a2602d98aa51e8a3cac832b8793 | /app/src/main/java/ctrlcctrlv/happytraveller/alterDialogs/MainActivityAlterDialog.java | 7345c4e37a34182acfddcfc30ce1f2d0bcb30a5b | [
"Apache-2.0"
] | permissive | texnologiesLogismikou/HappyTraveller | 82b714a7cab4f082f91e5438cbeaa5a5fade38dd | ffbdb89b2962b1f744ec3b751595b075d445aeb4 | refs/heads/master | 2020-04-04T12:35:11.900021 | 2019-01-15T22:45:21 | 2019-01-15T22:45:21 | 155,931,617 | 0 | 4 | Apache-2.0 | 2019-01-15T22:45:07 | 2018-11-02T23:26:56 | Java | UTF-8 | Java | false | false | 2,923 | java | package ctrlcctrlv.happytraveller.alterDialogs;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.widget.Toast;
import java.util.ArrayList;
import ctrlcctrlv.happytraveller.R;
import ctrlcctrlv.happytraveller.model.PlaceData;
/**
* One function to serve MainActivity classes alter dialog
*/
public class MainActivityAlterDialog
{
ArrayList<PlaceData> suggestedSights;
/**
* Initialize the suggested Sights in order to display them to user
* @param suggestedSights
*/
public void setSuggestedSights(ArrayList<PlaceData> suggestedSights) {this.suggestedSights = suggestedSights;}
/**
* An alter dialog in order for user to know the suggested by this application sights and witch he has to follow
* @param context
*/
public void showSuggestedSights(final Context context)
{
if (suggestedSights == null)
Toast.makeText(context, "Set your available time below !", Toast.LENGTH_LONG).show();
else
{
StringBuilder sightsForSuggestion = new StringBuilder();
int counter = 1;
for (PlaceData sights:suggestedSights)
{
sightsForSuggestion.append(counter).append(". ").append(sights.getName()).append("\n Distance:").append(sights.getDistance()).append("m").append(", Time:").append(sights.getTimeTillArrival()).append("min").append("\n\n");
counter++;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
builder.setTitle("Suggested Sights");
builder.setMessage(sightsForSuggestion.toString());
builder.setCancelable(false);
builder.setPositiveButton("Great", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
builder.setTitle("Suggested Sights");
builder.setMessage("You must follow the route order as are shown bellow" +
"\n\nRed>Yellow>Green>Cyan>Blue"+"\n\n" +
"");
builder.setCancelable(false);
builder.setPositiveButton("Sure!", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
}
| [
"[email protected]"
] | |
a6b5aac7b2ac3ae6c19bfb8215d60983398986b9 | cb71e6d840f185e48e29024ab4401a5f221b2af4 | /src/test/java/com/gs/socket/request/TestRequestCase.java | 1228ae4a51c4c8f0a627a904895959a83f0b051d | [] | no_license | guoyu07/MovieCrawler | 1c3e937d0b1ac296d59fa51eaef17ac89c0c0ff6 | 04bcbac4b18565038c2708fb78236faa79ff6a38 | refs/heads/master | 2020-01-23T21:57:07.840556 | 2013-12-31T01:39:04 | 2013-12-31T01:39:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 970 | java | package com.gs.socket.request;
import java.io.IOException;
import java.util.Scanner;
import org.junit.Test;
import com.google.gson.JsonSyntaxException;
public class TestRequestCase {
@Test
public void test() throws JsonSyntaxException, ClassNotFoundException {
RequestDTO dto = RequestDTOProcesser.pack(new SearchRequest("HaHa",1), new RequestProperty(getCPUID(), "gaoshen"));
System.out.println(dto);
try {
System.out.println(RequestDTOProcesser.unpack(dto));
} catch (Exception e) {
e.printStackTrace();
}
}
public String getCPUID(){
Process process;
Scanner sc = null;
try {
process = Runtime.getRuntime().exec(
new String[] { "wmic", "cpu", "get", "ProcessorId" });
process.getOutputStream().close();
sc = new Scanner(process.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
sc.next();
String serial = sc.next();
sc.close();
return serial;
}
}
| [
"[email protected]"
] | |
f188a5ffc96248b7bd1093baf2a688223387e15a | 8c13899051cdcaaf06525ae6513964379b4fb9c3 | /app/src/main/java/com/example/hemaladani/photogallery/ThumbnailDownloader.java | 4b33ea4dabcb074b656d417100d0df0612b7c93d | [] | no_license | rohittechpro1/Feature-Test2 | 5c68fdcc2736a1a3d1e91e8cf695b758651f3d7d | 69e98cd7fdea8a535cb55b60568bbf38c903aaf9 | refs/heads/master | 2020-04-09T14:58:49.266040 | 2018-12-05T20:03:32 | 2018-12-05T20:04:25 | 160,412,817 | 0 | 0 | null | 2018-12-04T20:43:55 | 2018-12-04T20:09:30 | Java | UTF-8 | Java | false | false | 3,070 | java | package com.example.hemaladani.photogallery;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;
import java.io.IOException;
import java.lang.annotation.Target;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Created by hemaladani on 5/4/17.
*/
public class ThumbnailDownloader<T> extends HandlerThread {
private static final int MESSAGE_DOWNLOAD=0;
public static final String TAG="ThumbnailDownloader";
private boolean mHasQuit=false;
private Handler mRequestHandler;
private Handler mResponseHandler;
private ThumbnailDownloadListener<T> mThumnailDownloadListener;
private ConcurrentMap<T,String> mRequestMap=new ConcurrentHashMap<>();
public interface ThumbnailDownloadListener<T>{
void onThumbnailDownloaded(T target,Bitmap thumnai);
}
public void setThumbnailDownloadListener(ThumbnailDownloadListener<T> listener){
mThumnailDownloadListener=listener;
}
public ThumbnailDownloader(Handler responseHandler) {
super(TAG);
mResponseHandler=responseHandler;
}
@Override
public boolean quit() {
mHasQuit=true;
return super.quit();
}
public void queThumbnail(T target,String url){
Log.i(TAG,"Got url:"+url);
if(url==null){
mRequestMap.remove(target);
}else{
mRequestMap.put(target,url);
mRequestHandler.obtainMessage(MESSAGE_DOWNLOAD,target).sendToTarget();
}
}
public void clearQueue(){
mRequestHandler.removeMessages(MESSAGE_DOWNLOAD);
mRequestMap.clear();
}
@Override
protected void onLooperPrepared() {
mRequestHandler=new Handler(){
@Override
public void handleMessage(Message msg) {
if(msg.what==MESSAGE_DOWNLOAD){
T target=(T)msg.obj;
Log.i(TAG,"Got a request from url:"+mRequestMap.get(target));
handleRequest(target);
}
}
};
}
private void handleRequest(final T target){
try{
final String url=mRequestMap.get(target);
if(url==null){return;}
byte[]bitmapBytes=new FlickrFetchr().getUrlBytes(url);
final Bitmap bitmap= BitmapFactory.decodeByteArray(bitmapBytes,0,bitmapBytes.length);
Log.i(TAG,"Bitmap created");
mResponseHandler.post(new Runnable() {
@Override
public void run() {
if(mRequestMap.get(target)!=url||mHasQuit){
return;
}
mRequestMap.remove(target);
mThumnailDownloadListener.onThumbnailDownloaded(target,bitmap);
}
});
}
catch (IOException ioe){
Log.e(TAG,"Error Downloading",ioe);
}
}
}
| [
"[email protected]"
] | |
e618c90a2cc8aa1a8b0a468c1cbf977ab6e456f5 | be2ab2fb6f3a2cb7776d89e28601539f69b7326c | /High_java/GenericEnumTest/T08_ENUM.java | 7307b3a1dd5eff68fb42e6c08faecb4a9971ca44 | [] | no_license | answjd5794/JAVA | 4878d5ece18a8590fdd3f8d3b3bdf1439a110b18 | 892f45c640af872b58c50b66835224df91ee5920 | refs/heads/master | 2023-01-03T08:18:22.636542 | 2020-10-19T05:32:26 | 2020-10-19T05:32:26 | 295,599,173 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,053 | java | package kr.or.ddit.basic;
/**
* ์ด๊ฑฐํ => ์์๊ฐ๋ค์ ์ ์ธํ๋ ๋ฐฉ๋ฒ
*
* static final A = 0;
* static final B = 1;
* static final C = 2;
* static final D = 3;
*
* enum Data (A, B, C, D);
*
* ์ด๊ฑฐํ ๋ฐ์ดํฐ๋ฅผ ์ ์ธํ๋ ๋ฐฉ๋ฒ
* enum ์ด๊ฑฐํ ์ด๋ฆ { ์์1, ์์2 .... }
*
*/
public class T08_ENUM {
// City ์ด๊ฑฐํ ๊ฐ์ฒด ์ ์ธ (๊ธฐ๋ณธ๊ฐ์ ์ด์ฉํ๋ ์ด๊ฑฐํ)
public enum City { ์์ธ, ๋์ , ๋๊ตฌ, ๋ถ์ฐ , ๊ด์ฃผ };
// ๋ฐ์ดํฐ ๊ฐ์ ์์๋ก ์ง์ ํ ์ด๊ฑฐํ ๊ฐ์ฒด ์ ์ธ
// ๋ฐ์ดํฐ ๊ฐ์ ์ ํด์ค ๊ฒฝ์ฐ์๋ ์์ฑ์๋ฅผ ๋ง๋ค์ด์ ๊ดํธ์์ ๊ฐ์ด ๋ณ์์ ์ ์ฅ๋๋๋ก ํด์ผ ํ๋ค.
public enum Season {
๋ด("3์๋ถํฐ 5์๊น์ง"), ์ฌ๋ฆ("6์๋ถํฐ 8์๊น์ง"), ๊ฐ์("9์ ๋ถํฐ 11์ ๊น์ง"), ๊ฒจ์ธ("12์ ๋ถํฐ 2์ ๊น์ง");
// ๊ดํธ ์์ ๊ฐ์ด ์ ์ฅ๋ ๋ณ์ ์ ์ธ
private String str;
// ์์ฑ์ ๋ง๋ค๊ธฐ (์ด๊ฑฐํ์ ์์ฑ์๋ ์ ์ด์๊ฐ ๋ฌต์์ ์ผ๋ก 'private'๋ค.
Season(String data) {
str = data;
}
// ๊ฐ์ ๋ฐํํ๋ ๋ฉ์๋
public String getStr() {
return str;
}
}
public static void main(String[] args) {
/**
* ์ด๊ฑฐํ์ ์ฌ์ฉ๋๋ ๋ฉ์๋
* 1. name() -> ์ด๊ฑฐํ ์์์ ์ด๋ฆ์ ๋ฌธ์์ด๋ก ๋ฐํํ๋ค.
* 2. ordinal()-> ์ด๊ฑฐํ ์์ ์ ์๋ ์์๊ฐ์ ๋ฐํํ๋ค.(๊ธฐ๋ณธ์ ์ผ๋ก 0๋ถํฐ ์์)
* 3. valueOf("์ด๊ฑฐํ ์์๋ช
") -> ์ง์ ๋ ์ด๊ฑฐํ์์ "์ด๊ฑฐํ ์์๋ช
"๊ณผ ์ผ์นํ๋ ์ด๊ฑฐํ ์์๋ฅผ ๋ฐํํ๋ค.
*
*/
City myCity1; // ์ด๊ฑฐํ ๊ฐ์ฒด ๋ณ์ ์ ์ธ
City myCity2;
// ์ด๊ฑฐํ ๊ฐ์ฒด ๋ณ์์ ๊ฐ ์ ์ฅํ๊ธฐ
myCity2 = City.์์ธ;
myCity1 = City.valueOf("์์ธ"); // City Enum์์ '์์ธ' ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ด
System.out.println("myCity1" + myCity1);
System.out.println("myCity1์ ordinal" + " : " + myCity1.ordinal());
System.out.println();
System.out.println("myCity2" + myCity2);
System.out.println("myCity2์ ordinal" + " : " + myCity2.ordinal());
Season ss = Season.valueOf("์ฌ๋ฆ");
System.out.println("name => " + ss.name());
System.out.println("ordinal => " + ss.ordinal());
System.out.println("get๋ฉ์๋ => " + ss.getStr());
// ์ด๊ฑฐํ ์ด๋ฆ.valuesOf => ๋ฐ์ดํฐ๋ฅผ ๋ฐฐ์ด๋ก ๊ฐ์ง๊ณ ์จ๋ค.
Season[] enumArr = Season.values();
for (int i = 0; i < enumArr.length; i++) {
System.out.println(enumArr[i].name() + " : " + enumArr[i].getStr() );
}
System.out.println();
for (City city : City.values()) {
System.out.println(city + " : " + city.ordinal());
}
City city = City.๋๊ตฌ;
System.out.println(city == City.๋์ );
System.out.println(city == City.๋๊ตฌ);
System.out.println(" ๋๊ตฌ =-> " + city.compareTo(City.๋๊ตฌ));
System.out.println(" ์์ธ =-> " + city.compareTo(City.์์ธ));
System.out.println(" ๋์ =-> " + city.compareTo(City.๋์ ));
}
}
| [
"[email protected]"
] | |
28863dab8ca77f5b5a46216ce07e5d157e37e321 | c8a41184442e3f18502a8b548fec88a086239f00 | /version3/java/ROM_MS255E_64.java | 47fce1e4861a317991717f664c51ccbc0319fa25 | [
"Apache-2.0"
] | permissive | MRJCrunch/amcl | 9c27b4e1d5e131f6536e57fb7c6294327fd0c4cc | 36a2dcd5e3654595a65ebc10cf2f9046f7145426 | refs/heads/master | 2021-01-09T22:38:53.367897 | 2017-08-28T08:14:16 | 2017-08-28T08:14:16 | 92,737,402 | 0 | 2 | null | 2017-05-29T12:21:27 | 2017-05-29T12:21:26 | null | UTF-8 | Java | false | false | 1,502 | 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.
*/
/* Fixed Data in ROM - Field and Curve parameters */
package amcl.MS255E;
public class ROM
{
// 255MS Modulus
public static final long[] Modulus= {0xFFFFFFFFFFFD03L,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x7FFFFFFFL};
public static final long MConst=0x2FDL;
// MS255E Curve
public static final int CURVE_A = -1;
public static final long[] CURVE_B = {0xEA97L,0x0L,0x0L,0x0L,0x0L};
public static final long[] CURVE_Order={0x49D1ED0436EB75L,0xA785EDA6832EACL,0xFFFFFFFFFFDCF1L,0xFFFFFFFFFFFFFFL,0x1FFFFFFFL};
public static final long[] CURVE_Gx ={0x4L,0x0L,0x0L,0x0L,0x0L};
public static final long[] CURVE_Gy ={0x2A255BD08736A0L,0x4B8AED445A45BAL,0xDD8E0C47E55291L,0x4A7BB545EC254CL,0x26CB7853L};
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.