blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
62c44880b713617fb15c4b611123f81c0063bda9 | b4a601feaab2a87c5e603c911f1b5e59945f3f5a | /src/main/java/fantasygame/weathewear/Armour.java | 5534b2205ffd90bb8fae4f93cdab32d8ec366018 | []
| no_license | AndreyChaykin/FG | 0e4e93eba8caa3ae59d0763b0d1ad5b4ad37787d | 3502419ecf00fbb6aa4c424df6e1856515ee18f0 | refs/heads/master | 2020-04-10T21:07:41.179392 | 2015-10-23T22:40:17 | 2015-10-23T22:40:17 | 40,044,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 951 | java | package fantasygame.weathewear;
import org.apache.log4j.Logger;
import static fantasygame.ClassNameUtil.getCurrentClassName;
public abstract class Armour {
private static final Logger LOG = Logger.getLogger(getCurrentClassName());
private int protection;
public Armour(int protection) {
this.protection = protection;
}
public int getProtection() {
if(LOG.isDebugEnabled()) {
LOG.debug("Get armour protection " + protection);
}
return protection;
}
public void setProtection(int protection) {
if(LOG.isDebugEnabled()) {
LOG.debug("Set armour protection " + protection);
}
this.protection = protection;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder(Armour.this.getClass().getSimpleName().toLowerCase());
return result.toString();
}
}
| [
"[email protected]"
]
| |
5b9d585ca6ecce886a3f5f45d598cb75cdafb82d | 9accad6e42e0c9eec76ff123f6bf9664fd835637 | /view/MenuScreen.java | 8a96428a46755c0d04b2c10c5a2ac7bb16f99e34 | []
| no_license | Nikhithagaddam/creative-assignment03-Nikhitha | 2ecf6c23331e98e2937c32f6f81d69fff654f96d | 1ac95ce2ef7b2c23251d1490680f2fd7e09de74c | refs/heads/master | 2023-08-19T12:20:23.864002 | 2021-10-22T04:45:51 | 2021-10-22T04:45:51 | 419,967,876 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,040 | java | package view;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MenuScreen {
private JFrame window;
public MenuScreen(JFrame window){
this.window=window;
}
public void init(){
Container cp = window.getContentPane();
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(500,200));
panel.setLayout(new GridLayout(1,1));
JButton button = new JButton("Enter into Form Builder");
panel.add(button);
cp.add(BorderLayout.CENTER,panel);
button.addActionListener( action ->
{
System.out.println("Enter into Form Builder System");
window.getContentPane().removeAll();
var simulator = new Simulator(window);
simulator.init();
window.pack();
window.revalidate();
}
);
}
}
| [
"[email protected]"
]
| |
124bc4784b636cb7d2921f7be591033f52f78269 | 38bdd3c7110186e7a2bfbe26b1d56ddb851d2646 | /src/main/java/com/tongyuan/myAop/proxy/ProxyChain.java | df7bf562dcae5e5e369b5854e5aec24e67810a80 | []
| no_license | secondzc/zcy_spring | f498a90e8c5fb85c49dbd6942eabf131f2d356e6 | 58bb2307d2a28eaae0913db9edf9c8f3e7747de4 | refs/heads/master | 2021-04-09T17:39:07.999406 | 2018-03-26T09:06:54 | 2018-03-26T09:06:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,393 | java | package com.tongyuan.myAop.proxy;
import net.sf.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhangcy on 2018/3/26
*/
public class ProxyChain {
private Class<?> targetClass;
private Object targetObject;
private Object[] args;
private MethodProxy methodProxy;
private List<Proxy> proxyList = new ArrayList<Proxy>();
private Method targetMethod;
private int proxyIndex = 0;
public ProxyChain(Class<?> targetClass, Object targetObject, Object[] args, MethodProxy methodProxy, List<Proxy> proxyList, Method targetMethod) {
this.targetClass = targetClass;
this.targetObject = targetObject;
this.args = args;
this.methodProxy = methodProxy;
this.proxyList = proxyList;
this.targetMethod = targetMethod;
}
public Class<?> getTargetClass() {
return targetClass;
}
public Object getTargetObject() {
return targetObject;
}
public Method getTargetMethod() {
return targetMethod;
}
public Object doProxyChain() throws Throwable{
Object result;
if(proxyIndex<proxyList.size()){
result = proxyList.get(proxyIndex++).doProxy(this);
}else{
result = methodProxy.invokeSuper(targetObject,args);
}
return result;
}
}
| [
"[email protected]"
]
| |
8476e5ed547f4e0d5d3743e8ef16b0fcacda7148 | 415785363820e36578fc9330891173ea35df21e6 | /java_servlet_create/src/com/lixin/servlet/UserServlet.java | 1a7a0c13c9a296ee335b4080f2484178005f79f1 | []
| no_license | dagf113225/java- | 1d462fb13ed42e327bd5d076e2807203c40d8a7b | 57ab6ad2bd2e146a01f1d9440d749740cae4ed5c | refs/heads/master | 2020-04-12T10:45:24.423313 | 2019-01-02T08:41:50 | 2019-01-02T08:41:50 | 162,439,451 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 237 | java | package com.lixin.servlet;
public class UserServlet {
public void doGet()
{
System.out.println("UserServlet is doGet start...");
}
public void doPost()
{
System.out.println("UserServlet is doPost start...");
}
}
| [
"[email protected]"
]
| |
b53e8f6f75bc5f89641a4ed295b0d3286e7010a9 | aa9aa961b18fb9243162fc6344f9882734c40df9 | /CRM_ssh/src/com/gzucm/service/UserService.java | aafe9cfcddf87b708de15a009fcb2e60029a75a8 | []
| no_license | lzqwan20/SSM | 31345ea07d14b2f6228e83c6fc22bf034fb95877 | b292b451bb61bd78c5c043863ed8e14d819c3c3a | refs/heads/master | 2022-12-18T04:42:25.745632 | 2019-09-01T06:17:18 | 2019-09-01T06:17:18 | 205,635,180 | 1 | 0 | null | 2022-12-04T09:46:00 | 2019-09-01T05:50:13 | JavaScript | UTF-8 | Java | false | false | 149 | java | package com.gzucm.service;
import com.gzucm.domain.User;
public interface UserService {
User login(User user);
void saveUser(User user);
}
| [
"[email protected]"
]
| |
5d538b3aa7f5d091c8f50c3ebbaa42d23df32877 | a148ff72766670511af68862843f5434de592c14 | /app/src/androidTest/java/com/agrotic/sena/www/entrenosenasoft2018_pureba2/ExampleInstrumentedTest.java | 9e49f05675209aca0a0bdfcb1bd8e96a1c4c12ff | []
| no_license | jos3cort3s20/EntrenoSenaSoft2018_Pureba2 | f7d95caf98f9355c93a90122d8e9773d8b0c34fa | 31606b6e6de93c562e7f03358d152c6ef2f526f2 | refs/heads/master | 2020-03-23T22:53:27.628156 | 2018-07-24T22:48:16 | 2018-07-24T22:48:16 | 142,204,511 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package com.agrotic.sena.www.entrenosenasoft2018_pureba2;
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.agrotic.sena.www.entrenosenasoft2018_pureba2", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
7ea8b604dd9885f920c19cac37aa00a75e5edec1 | f73b581f363de907ea9a96a38611153a7ca5156c | /2021_Test/Chap1/src/MovieMiddle.java | fc9186117d795b665b834f92556171972d5e2411 | []
| no_license | seohyun319/Elderly_People_Kiosk_Project | 1cec1c10e8df8e6e7bfaefd7ac3f7c7ad34cf747 | 1aca90107cea185543e39533fe6bbd2bc4658a5d | refs/heads/master | 2023-06-05T04:11:11.725870 | 2021-06-22T00:48:26 | 2021-06-22T00:48:26 | 377,988,285 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 13,636 | java | import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MovieMiddle extends JFrame implements ActionListener {
JButton btOk, btHelp;
static JButton back;
JLabel labelMvPhoto, labelSelect, labelA1, labelA2, labelA3, labelANum1, labelANum2, labelANum3;
String nums[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
// JButton buttonsOld[] = new JButton[nums.length];
JButton buttonsOld[] = new JButton[nums.length];
JButton buttonsAdult[] = new JButton[nums.length];
JButton buttonsTeen[] = new JButton[nums.length];
JPanel panelNorth = new JPanel();
JPanel panelCenter = new JPanel();
JPanel panelSouth = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
Container c;
int[][] pstate = new int[3][9];
int[] previous = new int[3];
int[] pselect = new int[3];
Color col1 = new Color(232,250,255);
Color col2 = new Color(170,242,255);
Color col3 = new Color(170,216,255);
// Color col4 = new Color(107,163,255);
static int numOld, numAdult, numTeen;
PlayAudio p;
public MovieMiddle() {
setSize(650,830);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("인원선택화면");
c= getContentPane();
c.setLayout(new BorderLayout(3,1));
int[] pstate= {0,0,0};
labelMvPhoto = new JLabel(Poster.moviePhoto);
labelSelect = new JLabel("영화 관람 인원수를 선택하세요");
labelSelect.setHorizontalAlignment(JLabel.CENTER);
labelA1 = new JLabel(" 우대 ");
labelA2 = new JLabel(" 성인 ");
labelA3 = new JLabel("청소년 ");
labelANum1 = new JLabel(" 명 ");
labelANum2 = new JLabel(" 명 ");
labelANum3 = new JLabel(" 명 ");
btOk = new JButton("확인");
btHelp = new JButton("도움말");
btOk.setPreferredSize(new Dimension(300,80));
btHelp.setPreferredSize(new Dimension(300,80));
btOk.setBackground(col2);
btHelp.setBackground(col2);
btOk.addActionListener(this);
btHelp.addActionListener(this);
// setLayout(new GridLayout(8,1));
// panel1.setLayout(new GridLayout(1,2));
// panel2.setLayout(new GridLayout(1,2));
// panel3.setLayout(new GridLayout(1,2));
Font f = new Font("맑은 고딕", Font.CENTER_BASELINE,30);
Font f2 = new Font("고딕", Font.CENTER_BASELINE,28);
labelA1.setFont(f);
labelA2.setFont(f);
labelA3.setFont(f);
labelANum1.setFont(f); labelANum2.setFont(f); labelANum3.setFont(f);
labelSelect.setFont(f);
btOk.setFont(f); btHelp.setFont(f);
panel1.add(labelA1);
panel2.add(labelA2);
panel3.add(labelA3);
panel1.setLayout(new FlowLayout(FlowLayout.RIGHT,0,1));
panel1.setVisible(true);
panel2.setLayout(new FlowLayout(FlowLayout.RIGHT,0,1));
panel2.setVisible(true);
panel3.setLayout(new FlowLayout(FlowLayout.RIGHT,0,1));
panel3.setVisible(true);
for (int i=0; i<nums.length; i++) {
buttonsOld[i] = new JButton(nums[i]);
buttonsOld[i].setFont(f2);
buttonsOld[i].setBackground(Color.white);
buttonsOld[i].addActionListener(this);
// bgOld.add(buttonsOld[i]);
// buttons[i].setPreferredSize(new Dimension(40,35));
panel1.add(buttonsOld[i]);
}
for (int i=0; i<nums.length; i++) {
buttonsAdult[i] = new JButton(nums[i]);
buttonsAdult[i].setFont(f2);
buttonsAdult[i].setBackground(Color.white);
buttonsAdult[i].addActionListener(this);
// buttons[i].setPreferredSize(new Dimension(40,35));
panel2.add(buttonsAdult[i]);
}
for (int i=0; i<nums.length; i++) {
buttonsTeen[i] = new JButton(nums[i]);
buttonsTeen[i].setFont(f2);
buttonsTeen[i].setBackground(Color.white);
buttonsTeen[i].addActionListener(this);
// buttons[i].setPreferredSize(new Dimension(40,35));
panel3.add(buttonsTeen[i]);
}
panel1.add(labelANum1);
panel2.add(labelANum2);
panel3.add(labelANum3);
NorthPanel np = new NorthPanel();
back.addActionListener(this);
panelNorth.setLayout(new BorderLayout(3,1));
panelNorth.add(np, BorderLayout.NORTH);
panelNorth.add(labelMvPhoto, BorderLayout.CENTER);
panelNorth.add(labelSelect, BorderLayout.SOUTH);
panelCenter.setLayout(new GridLayout(3,1));
panelCenter.add(panel1, BorderLayout.NORTH);
panelCenter.add(panel2, BorderLayout.CENTER);
panelCenter.add(panel3, BorderLayout.SOUTH);
panelSouth.add(btOk,BorderLayout.WEST);
panelSouth.add(btHelp,BorderLayout.EAST);
panelNorth.setPreferredSize(new Dimension(500,430));
panelCenter.setPreferredSize(new Dimension(500,200));
panelSouth.setPreferredSize(new Dimension(500,100));
panelNorth.setBackground(col1);
panel1.setBackground(col1);
panel2.setBackground(col1);
panel3.setBackground(col1);
panelSouth.setBackground(col1);
// c.add(panelNorth);
// c.add(panelCenter);
// c.add(panelSouth);
c.add(panelNorth, BorderLayout.NORTH);
c.add(panelCenter, BorderLayout.CENTER);
c.add(panelSouth, BorderLayout.SOUTH);
setVisible(true);
try {
p= new PlayAudio("2021_Test/Chap1/src/sounds/sound4.wav");
p.Play();
} catch (Exception ex) {
ex.printStackTrace();
}
// panel3.add(new Button("1"));
// panel3.add(new Button("2"));
// panel3.add(new Button("3"));
// panel3.add(new Button("4"));
// panel3.add(new Button("5"));
// panel3.add(new Button("6"));
// panel3.add(new Button("7"));
// panel3.add(new Button("8"));
// panel3.add(new Button("9"));
// panel3.setSize(650, 200);
}
// static class NorthPanel extends JPanel{
// public NorthPanel() {
// setLayout(new BorderLayout());
// back = new JButton("뒤로 가기");
// JButton next = new JButton("다음으로 가기");
// back.setFont(new Font("맑은 고딕",0,30));
// next.setFont(new Font("맑은 고딕",0,30));
// setBackground(new Color(232,250,255));
// add(back,BorderLayout.WEST);
// add(next, BorderLayout.EAST);
// }
// }
static class NorthPanel extends JPanel{
public NorthPanel() {
setLayout(new BorderLayout());
back = new JButton(new ImageIcon("2021_Test/Chap1/src/backimg.png"));
back.setBorderPainted(false);
back.setContentAreaFilled(false);
back.setFocusPainted(false);
setBackground(new Color(232,250,255));
add(back,BorderLayout.WEST);
}
}
class dialog2 extends JDialog {
public dialog2() {
ImageIcon ai=new ImageIcon("help2.gif");
JLabel al = new JLabel(ai);
getContentPane().add(al,BorderLayout.CENTER);
this.setSize(600,800);
this.setVisible(true);
}
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==back) {
p.Stop();
new Poster();
setVisible(false);
}
if (e.getSource() == btOk) {
if (pselect[0] == 0 && pselect[1] == 0 && pselect[2] == 0) {
JOptionPane.showMessageDialog(c, "인원을 선택해주세요.", "인원 미선택", JOptionPane.ERROR_MESSAGE);
} else {
p.Stop();
new SelectSeats(numOld, numAdult, numTeen);
setVisible(false);
}
}
if (e.getSource() == btHelp) {
new dialog2();
}
for (int i = 0; i < nums.length; i++) {
if (pselect[0] == 0) {
if (e.getSource() == buttonsOld[i]) {
buttonsOld[i].setBackground(col3);
System.out.println("우대 " + e.getActionCommand() + "명");
pstate[0][i] = 1;
pselect[0] = 1;
previous[0] = i;
numOld = i+1;
}
} else if (pselect[0] == 1) {
if (e.getSource() == buttonsOld[i] && pstate[0][i] == 0) {
buttonsOld[previous[0]].setBackground(Color.white);
pstate[0][previous[0]] = 0;
buttonsOld[i].setBackground(col3);
System.out.println("우대 " + e.getActionCommand() + "명");
numOld = i+1;
pstate[0][i] = 1;
pselect[0] = 1;
previous[0] = i;
} else if (e.getSource() == buttonsOld[i] && pstate[0][i] == 1) {
buttonsOld[i].setBackground(Color.white);
pstate[0][i] = 0;
pselect[0] = 0;
numOld = 0;
}
}
if (pselect[1] == 0) {
if (e.getSource() == buttonsAdult[i]) {
buttonsAdult[i].setBackground(col3);
System.out.println("성인 " + e.getActionCommand() + "명");
pstate[1][i] = 1;
pselect[1] = 1;
previous[1] = i;
numAdult=i+1;
}
} else {//pselect[1]
if (e.getSource() == buttonsAdult[i] && pstate[1][i] == 0) {
buttonsAdult[previous[1]].setBackground(Color.white);
pstate[1][previous[1]] = 0;
buttonsAdult[i].setBackground(col3);
System.out.println("성인 " + e.getActionCommand() + "명");
numAdult=i+1;
pstate[1][i] = 1;
pselect[1] = 1;
previous[1] = i;
} else if (e.getSource() == buttonsAdult[i] && pstate[1][i] == 1) {
buttonsAdult[i].setBackground(Color.white);
pstate[1][i] = 0;
pselect[1] = 0;
numAdult=0;
}
}
if (pselect[2] == 0) {
if (e.getSource() == buttonsTeen[i]) {
buttonsTeen[i].setBackground(col3);
System.out.println("청소년 " + e.getActionCommand() + "명");
numTeen=i+1;
pstate[2][i] = 1;
pselect[2] = 1;
previous[2] = i;
}
} else {//pselect[2]==1
if (e.getSource() == buttonsTeen[i] && pstate[2][i] == 0) {
buttonsTeen[previous[2]].setBackground(Color.white);
pstate[2][previous[2]] = 0;
buttonsTeen[i].setBackground(col3);
System.out.println("청소년 " + e.getActionCommand() + "명");
pstate[2][i] = 1;
pselect[2] = 1;
previous[2] = i;
numTeen=i+1;
} else if (e.getSource() == buttonsTeen[i] && pstate[2][i] == 1) {
buttonsTeen[i].setBackground(Color.white);
pstate[2][i] = 0;
pselect[2] = 0;
numTeen=0;
}
}
}
System.out.println("우대:" + numOld + ", 성인:" + numAdult + ", 청소년:" + numTeen);
//
// public void actionPerformed(ActionEvent e) {
// if (e.getSource() == btOk) {
// new SelectSeat();
// setVisible(false);
// }
//
// for (int i=0; i<nums.length; i++) {
// if (e.getSource() == buttonsOld[i] &&pstate[0]==0) {
// buttonsOld[i].setBackground(col3);
// System.out.println("우대 " + e.getActionCommand() + "명");
// pstate[0]=1;
// numOld = i+1;
// }
// else if (e.getSource() == buttonsOld[i] &&pstate[0]==1) {
// buttonsOld[i].setBackground(Color.white);
// }
// if (e.getSource() == buttonsAdult[i] &&pstate[1]==0) {
// buttonsAdult[i].setBackground(col3);
// System.out.println("성인 " + e.getActionCommand() + "명");
// pstate[1]=1;
// numAdult=i+1;
// } else if (e.getSource() == buttonsAdult[i]&&pstate[1]==1) {
// buttonsAdult[i].setBackground(Color.white);
// }
// if (e.getSource() == buttonsTeen[i]&&pstate[2]==0) {
// buttonsTeen[i].setBackground(col3);
// System.out.println("청소년 " + e.getActionCommand() + "명");
// pstate[2]=0;
// numTeen=i+1;
// } else if (e.getSource() == buttonsTeen[i]&&pstate[2]==1) {
// buttonsTeen[i].setBackground(Color.white);
// }
// }
//
//
// System.out.println("우대:"+numOld +", 성인:"+numAdult+", 청소년:"+numTeen);
// }
}
} | [
"[email protected]"
]
| |
4a4b74c0f445e6cae32ee860785e168afcd2c8cc | c3ce754bd503364e3d945da0b6fc357cd13e7f3d | /app/src/main/java/com/example/pdfgenerate/MainActivity.java | 1654da5904173ccd27d794f30e86652c720dd8f0 | []
| no_license | elfaranadivaap/Library-2 | 58984b354c719d599fe9f9eebe05abba15a8908b | be490a41ffec8a46a107b8dc58ae27f956687cb3 | refs/heads/master | 2020-07-26T17:57:15.802599 | 2019-09-16T06:10:40 | 2019-09-16T06:12:46 | 208,726,034 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,560 | java | package com.example.pdfgenerate;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "PdfCreatorActivity";
private EditText mContentEditText;
private Button mCreateButton;
private File pdfFile;
final private int REQUEST_CODE_ASK_PERMISSIONS = 111;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContentEditText = (EditText) findViewById(R.id.edit_text_content);
mCreateButton = (Button) findViewById(R.id.button_create);
mCreateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContentEditText.getText().toString().isEmpty()){
mContentEditText.setError("Isi tulisan terlebih dahulu !");
mContentEditText.requestFocus();
return;
}
try {
createPdfWrapper();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
});
}
private void createPdfWrapper() throws FileNotFoundException,DocumentException{
int hasWriteStoragePermission = ActivityCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (hasWriteStoragePermission != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if
(!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_CONTACTS)) {
showMessageOKCancel("You need to allow access to Storage",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int
which) {
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.M) {
requestPermissions(new
String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
REQUEST_CODE_ASK_PERMISSIONS);
}
}
});
return;
}
requestPermissions(new
String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
REQUEST_CODE_ASK_PERMISSIONS);
}
return;
}else {
createPdf();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
switch (requestCode) {
case REQUEST_CODE_ASK_PERMISSIONS:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Permission Granted
try {
createPdfWrapper();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
} else {
// Permission Denied
Toast.makeText(this, "WRITE_EXTERNAL Permission Denied",
Toast.LENGTH_SHORT)
.show();
}
break;
default:
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
}
}
private void showMessageOKCancel(String message,
DialogInterface.OnClickListener okListener) {
new AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton("OK", okListener)
.setNegativeButton("Keluar", null)
.create()
.show();
}
private void createPdf() throws FileNotFoundException, DocumentException {
File docsFolder = new File(Environment.getExternalStorageDirectory() +
"/Documents");
if (!docsFolder.exists()) {
docsFolder.mkdir();
Log.i(TAG, "Buat Folder PDF Baru");
}
pdfFile = new File(docsFolder.getAbsolutePath(),"PDFgenerate.pdf");
OutputStream output = new FileOutputStream(pdfFile);
Document document = new Document();
PdfWriter.getInstance(document, output);
document.open();
document.add(new Paragraph(mContentEditText.getText().toString()));
document.close();
previewPdf();
}
private void previewPdf() {
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(pdfFile);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}else{
Toast.makeText(this,"Download aplikasi pdf viewer untuk melihat hasil generate",Toast.LENGTH_SHORT).show();
}
}
} | [
"[email protected]"
]
| |
0eb427c8efe150d5edf37880502e9718ca031461 | 109e95d999fa7da3f2b4d86bf48a2f13ac4b39f0 | /app/src/main/java/com/giulio/contentprovider/ContactComparator.java | a14c9f6d0a748b3e639b015f7f1652728cd02529 | []
| no_license | giuliohome/Contacts2Xls | 2e2074a1b36ffe2f3b91d79a673d457743b2f87e | a73c4d02de2ba7216e1c43cbda7134e73d44e67e | refs/heads/master | 2023-03-16T11:20:07.124547 | 2023-03-10T22:19:52 | 2023-03-10T22:19:52 | 79,085,193 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 300 | java | package com.giulio.contentprovider;
import java.util.Comparator;
public class ContactComparator implements Comparator<Contact> {
@Override
public int compare(Contact arg0, Contact arg1) {
// TODO Auto-generated method stub
return arg0.name.compareToIgnoreCase(arg1.name);
}
}
| [
"[email protected]"
]
| |
aa699cd195b05f310fd8d7d685b45f55972701a9 | 418d625b49d5f04f25990d408514646220a7e0bf | /src/si/ijs/its20/test/TestIO.java | 29d0f78bb44ef95897064262696fe72114cd99a1 | [
"Apache-2.0"
]
| permissive | tadejs/enrycher-its20 | 107c4335ec3d15448341e0d7b7b8cbb247b6ca45 | 5713cc05075373812b763023952a85038c8a6ade | refs/heads/master | 2016-09-06T03:41:58.042026 | 2013-03-15T12:55:30 | 2013-03-15T12:55:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,558 | java | package si.ijs.its20.test;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.TagNode;
import org.htmlcleaner.XPatherException;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import si.ijs.its20.DOMSnapshot;
import si.ijs.its20.XMLDialect;
public class TestIO {
@Test
public void testXpathHtml() {
String dir = "ITS-2.0-Testsuite/its2.0/inputdata/textanalysis/html/";
String file = "textanalysis1html.html";
CleanerProperties cp = new CleanerProperties();
//cp.setNamespacesAware(true);
//cp.set
try {
TagNode root = DOMSnapshot.getHtmlParser().clean(new File(dir + file));
Object[] nl = root.evaluateXPath("//body/p/*[@id='dublin']");
Assert.assertEquals(1, nl.length);
Document doc = new DomSerializer(cp).createDOM(root);
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
XPathExpression xpe = xpath.compile("//body/p/*[@id='dublin']");
NodeList nl2 = (NodeList) xpe.evaluate(doc, XPathConstants.NODESET);
Assert.assertEquals(xpe.toString(), 1, nl2.getLength());
/*xpe = xpath.compile("//h:body/h:p/h:*[@id='dublin']");
nl = (NodeList) xpe.evaluate(doc, XPathConstants.NODESET);
Assert.assertEquals(xpe.toString(), 1, nl.getLength());*/
} catch (ParserConfigurationException e) {
Assert.fail(e.getMessage());
e.printStackTrace();
} catch (XPathExpressionException e) {
Assert.fail(e.getMessage());
e.printStackTrace();
} catch (XPatherException e) {
Assert.fail(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Assert.fail(e.getMessage());
e.printStackTrace();
}
}
@Test
public void testWhoAmI() throws SAXException, IOException {
String dir = "ITS-2.0-Testsuite/its2.0/inputdata/textanalysis/xml/";
String file = "textanalysis1xml.xml";
Document doc = DOMSnapshot.getXMLParser().parse(new File(dir + file));
DOMSnapshot snap = new DOMSnapshot(doc, dir, new XMLDialect());
for (DOMSnapshot.ITSState state : snap.iterNodes()) {
Assert.assertEquals(state.nodePath, DOMSnapshot.whoAmI(state.node));
}
}
}
| [
"[email protected]"
]
| |
97c6e26cd97d48dac287ffb8af4c5912c4a9c675 | 7053d92a168bb0d03b4371a3eeeae32a745c329b | /src/com/mohsin/learning/pointers2/TripletSumCloseToTarget.java | f007e0663394e9dadef435029e7a99bb75a31e47 | []
| no_license | mohsiqba/Learning | bc96d187bbb187297f5002771f29e547f6e3653c | 81488535292e89963aab3be60f2f4f09c2d152d6 | refs/heads/master | 2023-08-10T19:53:03.195143 | 2021-09-13T15:46:37 | 2021-09-13T15:46:37 | 381,420,501 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,227 | java | package com.mohsin.learning.pointers2;
import java.util.Arrays;
/**
* @author : m0i005b ([email protected])
* Date : 17-May-2021
* Description :
*/
public class TripletSumCloseToTarget {
public static void main(String[] args) {
System.out.println(tripletSumCloseToTarget(new int[]{-2, 0, 1, 2},2));
System.out.println(tripletSumCloseToTarget(new int[]{-3, -1, 1, 2},1));
System.out.println(tripletSumCloseToTarget(new int[]{1, 0, 1, 1},100));
}
static int tripletSumCloseToTarget(int[] nums, int target){
Arrays.sort(nums);
int smallestDiff=Integer.MAX_VALUE;
for(int i=0;i<nums.length-2;i++){
int left=i+1,right=nums.length-1;
while(left<right){
int sum=nums[i]+nums[left]+nums[right];
if(Math.abs(target-sum)==0){
return sum;
}
if(Math.abs(target-sum)<Math.abs(smallestDiff)){
smallestDiff=target-sum;
}
if(sum<target){
left++;
} else{
right--;
}
}
}
return target-smallestDiff;
}
}
| [
"[email protected]"
]
| |
50fa29a1fb598cd802a8fc3f6554e585e6b3b823 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_fb5fb4e4ba2d07b6419a6c48c60791e6b4404755/AppSummaryPage/8_fb5fb4e4ba2d07b6419a6c48c60791e6b4404755_AppSummaryPage_s.java | a7f5cc13b194244f1c5f20bd8b9cd4c736ce9e89 | []
| 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 | 1,042 | java | package com.triposo.automator.itunesconnect;
import com.triposo.automator.Page;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
class AppSummaryPage extends Page {
@FindBy(css = ".left .app-icon")
WebElement leftHandSideVersionDetails;
// This has to work with both "Add Version" and "View Details".
@FindBy(xpath = "//div[contains(@class, 'right')]//div[contains(@class, 'app-icon')]/a")
WebElement rightHandSideVersionDetails;
public AppSummaryPage(WebDriver driver) {
super(driver);
}
public VersionDetailsPage clickNewVersionViewDetails() {
rightHandSideVersionDetails.click();
return new VersionDetailsPage(driver);
}
public VersionDetailsPage clickCurrentVersionViewDetails() {
rightHandSideVersionDetails.click();
return new VersionDetailsPage(driver);
}
public NewVersionPage clickAddVersion() {
rightHandSideVersionDetails.click();
return new NewVersionPage(driver);
}
}
| [
"[email protected]"
]
| |
5d7436840db9b04b247a4931d23e84e724ab5a15 | 92e1115c30805e38fb4e6466e64d986f52f2f6c8 | /src/com/company/EqualsInteger.java | 5fcd42e9d28393d60a0700f5ad6245b4321ab478 | []
| no_license | monegask1969/EnumsStrings | ac4bd778dd0e1a3b6d453bdfade9f874de9b467f | 62453be608c4712fdebd9f65607485695def88b2 | refs/heads/master | 2021-01-10T06:13:34.392825 | 2016-02-06T12:28:13 | 2016-02-06T12:28:13 | 51,200,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 460 | java | package com.company;
/**
* Created by uitschool JV on 2/6/2016.
*/
public class EqualsInteger {
public static void main(String[] args) {
Integer iOb = 100;
Integer kOb = 100;
if(iOb.equals(kOb))
System.out.println("equals");
else
System.out.println("no equals");
if(iOb == kOb)
System.out.println("==equal");
else
System.out.println("==no equal");
}
}
| [
"[email protected]"
]
| |
32ed6925dfc23ced52d0b9efc1fbfc8148d1695e | f7086c5400272c27db084a952496c41359865159 | /src/coordinates/Point.java | d05ebacff3897bca23ef3add12d3a17a2ec7255c | []
| no_license | odovhai/Guava_vs_Java | b0de5400672d947b544d365531f1c3181d847935 | d170c2d4d00a8e11f277d25442ab4afcb1705f7b | refs/heads/master | 2021-01-19T18:35:55.531509 | 2015-08-27T11:19:19 | 2015-08-27T11:19:19 | 41,360,949 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 914 | java | package coordinates;
public class Point {
private long x;
private long y;
public Point(long x, long y) {
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Point point = (Point) o;
if (x != point.x) return false;
return y == point.y;
}
@Override
public int hashCode() {
int result = (int) (x ^ (x >>> 32));
result = 31 * result + (int) (y ^ (y >>> 32));
return result;
}
@Override
public String toString() {
return "{" + x + ":" + y + "}";
}
public long getX() {
return x;
}
public void setX(long x) {
this.x = x;
}
public long getY() {
return y;
}
public void setY(long y) {
this.y = y;
}
}
| [
"[email protected]"
]
| |
063547cb77b5289f293c0ece9d4ecba667656cbd | 4a7c61b0989c8b9a8d1cc7c5e93815e475840242 | /springboot-study-service/src/main/java/com/cxn/zqsignature/support/RsaSign.java | 2862d4df3ed651460aa1183a4f15f650e0d947f6 | []
| no_license | boruishao/springboot-study | af4b45cbaf7784fd2a8ba4fcc1ffbc882efc64dc | 363a7cc8063a679863c0746623b74673e92d9ba3 | refs/heads/master | 2020-03-12T13:51:25.122277 | 2018-04-21T08:16:10 | 2018-04-21T08:16:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,020 | java | package com.cxn.zqsignature.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* RSA工具类
*/
public class RsaSign {
private static Log logger = LogFactory.getLog(RsaSign.class);
//编码集
public static final String CHARSET_ENCODER = "UTF-8";
/**
* <p>map参数排序</p>
* @param params
* @return
* @auther zzk
* 2017年1月12日下午4:29:45
*/
public static String createLinkString(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
String prestr = "";
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符
prestr = prestr + key + "=" + value;
} else {
prestr = prestr + key + "=" + value + "&";
}
}
return prestr;
}
/**
* 签名
* @param content
* @param privateKey
* @return
*/
public static String sign(String content, String privateKey) {
return sign(content, privateKey, null);
}
public static String sign(String content, String privateKey,String input_charset) {
String charset = isEmpty(input_charset)?CHARSET_ENCODER : input_charset;
try {
String s = RSAUtils.sign(content.getBytes(charset), privateKey);
return s;
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return null;
}
/**
* 验签
* @param content
* @param sign
* @param publicKey
* @return
*/
public static boolean verify(String content, String sign, String publicKey) {
return verify(content, sign, publicKey,null);
}
public static boolean verify(String content, String sign, String publicKey,String input_charset) {
String charset = isEmpty(input_charset)?CHARSET_ENCODER : input_charset;
try {
boolean b = RSAUtils.verify(content.getBytes(charset), publicKey, sign);
return b;
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
return false;
}
private static boolean isEmpty(String str){
return str==null||str.trim().length()==0||str.equals("null");
}
/*public static String sign(String content, String privateKey,String input_charset) {
String charset = isEmpty(input_charset)?CHARSET_ENCODER : input_charset;
try {
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(Base64.decode(privateKey));
KeyFactory keyf = KeyFactory.getInstance("RSA");
PrivateKey priKey = keyf.generatePrivate(priPKCS8);
java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS);
signature.initSign(priKey);
signature.update(content.getBytes(charset));
byte[] signed = signature.sign();
return Base64.encode(signed);
} catch (Exception e) {
logger.error(e);
}
return null;
}*/
/*public static boolean verify(String content, String sign, String publicKey,String input_charset) {
String charset = isEmpty(input_charset)?CHARSET_ENCODER : input_charset;
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
byte[] encodedKey = Base64.decode(publicKey);
PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS);
signature.initVerify(pubKey);
signature.update(content.getBytes(charset));
boolean bverify = signature.verify(Base64.decode(sign));
return bverify;
} catch (Exception e) {
logger.error(e);
}
return false;
}*/
public static void main(String[] args) {
String sign = RsaSign.sign("123zhan张三", "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL+xjjeKLMbTWME0LihovLHeJ5UD51nxQbmnuIGG/4HUlPt3bMPeoHOtu+fCqPPsaaN89ChNMxbeGv3jqe2xUotIamvjAGl3jiTUCNVWveURuxT7BjCHDQkgoF92X+EL5tcn+9YQSmgNHs3HFO6gKEwbLj75OgDdwHluz6xDuRilAgMBAAECgYAFTY8moC7u7SfWaHAidAtMTF4B9FKxHUh5L1eeVbK5z7yzXDFpFb6QlKzPE4aDAPZHLIzAlKomJszOWz73MWGcJoeOQFcdNMuRvVEarwLsdEuCDIhuVnt2lCtMHMwdZfOudz5iAv4HqfIMEcekZSwhCW6IXDYgqSdLPK1GiK6ZPQJBAOZw6p/qzyPXNapkZYq7MpWR/w0lspDbfjZ77HSekyoU04fdEjioK7+DJDalUGT0bIUq83U3SSftAFQmCMMf4H8CQQDU9HPczV8I6LQD0nf4Z08MMToSPUfAkJAw5vyGT+QcsMXKFCOGS5X4XNM+TAKnAduxv9Rgf/tynr/Zx0LtBfTbAkEAhs+gMxXnQIxydNBvJw4EtcPHdiWLpXsDB1TQLBlo9sFgTqdiNYsMrOlHkkB8G9NyeSV7cCN7xMO94Xyuu5g2eQJASM/sbaqqu9kU89mau4xXMswCFwps5iKHqrDP1vyp+kVW22lXXCur82eJsts6bO/ttjDo5LXdu6sb3dKLx48p0QJBANx9wJMLPhfhKPBpf3E9RY9/2CimL/eue8BEOLauD+F7LvBPGHqNW/tukbVKU7GxVXq+OYiPEw4o3cjkMt2v+QI=");
System.out.println(sign);
boolean b = RsaSign.verify("123zhan张三", sign, "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/sY43iizG01jBNC4oaLyx3ieVA+dZ8UG5p7iBhv+B1JT7d2zD3qBzrbvnwqjz7GmjfPQoTTMW3hr946ntsVKLSGpr4wBpd44k1AjVVr3lEbsU+wYwhw0JIKBfdl/hC+bXJ/vWEEpoDR7NxxTuoChMGy4++ToA3cB5bs+sQ7kYpQIDAQAB");
System.out.println(b);
}
}
| [
"[email protected]"
]
| |
609cef071c802fea2ebd51a90afcf87b40319fb1 | 3f6e460b112ffb7d5c6e03cef2e0d8b34a49b448 | /sfg-di-di-assignment/src/main/java/hari/springframework/pets/PetService.java | 7c3eee9de8c385cededa71eca3312994bacdcb06 | []
| no_license | harithab22/spring-framework-practice | 46aacabf353c06caa6ea72e022dea3f12da18d25 | 9054793511db9af1e76f28ff15acf95810ba6ee8 | refs/heads/main | 2023-04-10T18:44:43.158310 | 2021-04-23T02:45:51 | 2021-04-23T02:45:51 | 350,929,543 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 96 | java | package hari.springframework.pets;
public interface PetService {
String getPetType();
}
| [
"[email protected]"
]
| |
4124e80058a4fcb0f4f4b25b9549013d202a79ff | d9fdd43b70264105ad70f2ec4cefeb52885d5006 | /java/src/com/tadosoft/krowdit/test/AllTests.java | 6a7c6eaee7de28f949cb651983e32d7f1682eeec | []
| no_license | mebusw/krowdit | a9e99a0cebfce61c39761177b2b57097c603599f | 5bfc633729901bc0d9531541d16050376bcc8b44 | refs/heads/master | 2020-04-20T22:25:00.999149 | 2015-02-24T11:00:36 | 2015-02-24T11:00:36 | 31,255,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,401 | java | package com.tadosoft.krowdit.test;
import com.tadosoft.krowdit.test.dao.*;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
TestSuite suite = new TestSuite("Test for com.tadosoft.krowdit.test");
//$JUnit-BEGIN$
suite.addTest(new JUnit4TestAdapter(TestLoginServlet.class));
suite.addTest(new JUnit4TestAdapter(TestSignupServlet.class));
suite.addTest(new JUnit4TestAdapter(TestRecoverPasswordServlet.class));
suite.addTest(new JUnit4TestAdapter(TestListKrowdsServlet.class));
suite.addTest(new JUnit4TestAdapter(TestJoinKrowdServlet.class));
suite.addTest(new JUnit4TestAdapter(TestListLocationsServlet.class));
suite.addTest(new JUnit4TestAdapter(TestListKrowdTypesServlet.class));
suite.addTest(new JUnit4TestAdapter(TestListTeamsServlet.class));
suite.addTest(new JUnit4TestAdapter(TestCreateLocationServlet.class));
suite.addTest(new JUnit4TestAdapter(TestCreateKrowdServlet.class));
suite.addTest(new JUnit4TestAdapter(TestLogoutServlet.class));
suite.addTest(new JUnit4TestAdapter(TestTableKrowdDAO.class));
suite.addTest(new JUnit4TestAdapter(TestTableUserDAO.class));
suite.addTest(new JUnit4TestAdapter(TestTableJoinKrowdDAO.class));
suite.addTest(new JUnit4TestAdapter(TestKrowdSearchDAO.class));
//$JUnit-END$
return suite;
}
}
| [
"[email protected]"
]
| |
a6768d033928d52baf97933c3055805bd4d1cd55 | d7d997d7d2a50a85eaf2eae8b5bfebc6862cef55 | /src/main/java/invalue/core/repository/PlanOfYearRepositoryImpl.java | 0aea4438cda323d917440d9edd846f7c63d1cd9c | []
| no_license | datpt154/stock-filter-server | c5af00584b806ef25e1281f5c3de5a666a539bf6 | 77a8d586ed8ff77d318cef940424c54df4aad8fa | refs/heads/master | 2020-03-20T05:39:15.352908 | 2018-12-20T05:59:20 | 2018-12-20T05:59:20 | 134,129,441 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,476 | java | package invalue.core.repository;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by HUYNP4 on 15/09/2018.
*/
@Repository
@Transactional(readOnly = true)
public class PlanOfYearRepositoryImpl implements PlanOfYearRepositoryCustom {
@PersistenceContext
EntityManager entityManager;
@Override
public Long getPlanOfYearByCode(String stockCode) {
StringBuilder sql = new StringBuilder();
StringBuilder select = new StringBuilder();
StringBuilder where = new StringBuilder();
StringBuilder from = new StringBuilder();
List<Object> params = new ArrayList<Object>();
Query query = entityManager.createNativeQuery("");
select.append(" SELECT p.id");
from.append(" from plan_of_year p ");
where.append(" where 1 = 1 and p.STOCK_CODE = ? and p.status<> -1 ");
params.add(stockCode);
sql.append(select).append(from).append(where);
query = entityManager.createNativeQuery(sql.toString());
for(int i=0;i<params.size();i++){
query.setParameter(i+1, params.get(i));
}
List<Object> rs = query.getResultList();
if(!rs.isEmpty()) {
return Long.parseLong(rs.get(0).toString());
}
return null ;
}
} | [
"[email protected]"
]
| |
9baa780e4865cef8971b73b194d7a278274f7c8f | c2f00804d91e43fb11b30bd9a132d6cf6a97342b | /src/main/java/com/app/model/Maestro/Catalogo/Marca.java | b5db454ce249d588956cebdb0ba125e73566c1e5 | []
| no_license | Jass1321/MiBeatrizBACK | 15392ef74db52071db4f79d43c170e80efeac9bf | 1fd328b24dfc4c4c7cb85d33a76fcc9e886e67f5 | refs/heads/master | 2023-07-06T04:35:56.593275 | 2021-08-13T21:31:24 | 2021-08-13T21:31:24 | 372,569,675 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,495 | java | package com.app.model.Maestro.Catalogo;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import com.app.model.Inventario.Producto;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "marcas")
public class Marca implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Column(unique = true)
private String nombre;
//1 Sub-Familia -> N Productos*/
@OneToMany(mappedBy = "marca" )
@JsonIgnore
private Set<Producto> productos = new HashSet<>();
/* CONSTRUCTOR*/
public Marca() {
}
public Marca( @NotNull String nombre) {
super();
this.nombre = nombre;
}
/* GET & SET*/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public Set<Producto> getProductos() {
return productos;
}
public void setProductos(Set<Producto> productos) {
this.productos = productos;
}
}
| [
"[email protected]"
]
| |
55f4ebf2acfa72c6fa87d99a75bdae7d31d6a7b0 | 53a9beb1e504cc393b485aed4397732bc1f2ba7c | /app/src/main/java/edu/good9016csumb/projectreview/Helperobjects/Transactions_Table.java | 1b6fedae13b1992d0ba79db6e69d235a9c7c56c4 | []
| no_license | algoodwin/ProjectReview | 7540ad6c5d0943d0e649481427c1e809ab8f50f0 | 14b2219f1b595163c5af0f5f118c1330f46eb611 | refs/heads/master | 2021-01-20T13:23:08.037851 | 2017-05-11T23:35:37 | 2017-05-11T23:35:37 | 90,485,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,088 | java | package edu.good9016csumb.projectreview.Helperobjects;
/**
* Created by alyssiagoodwin on 5/9/17.
*/
public class Transactions_Table {
public static final String TABLE_TRANS = "trans"; //name of the table
//columns in the table
public static final String KEY_TYPE = "type";
public static final String KEY_USERNAME = "username";
public static final String KEY_TITLE = "title";
public static final String KEY_PICKUP = "pickup";
public static final String KEY_RETURN = "return";
public static final String KEY_RESERVATION = "reservation";
//bundles columns into the an array
public static final String[] COLUMNS = {KEY_TYPE, KEY_USERNAME, KEY_TITLE,KEY_PICKUP,KEY_RETURN, KEY_RESERVATION };
public static final String CREATE_TRANS_TABLE = "CREATE TABLE " + TABLE_TRANS + " ( " +
KEY_TYPE + " TEXT, " +
KEY_USERNAME+ " TEXT , " +
KEY_TITLE +" TEXT NOT NULL, "+
KEY_PICKUP +" TEXT , "+
KEY_RETURN + " TEXT, " +
KEY_RESERVATION + " INTEGER PRIMARY KEY AUTOINCREMENT)";
}
| [
"[email protected]"
]
| |
d4265e8e1f34ec7a1c9b10bbb4aaeb9f0ea39a9e | 96f5d2b663631c6727349da43b58045aa39df63b | /QuickBuild/src/main/java/com/gmmapowell/quickbuild/build/BuildContextAware.java | 4cefb7990282e694d4163407c677325eab915d51 | []
| no_license | gmmapowell/QuickBuild | 80f78b513fb3b982889496b8c46d3b068a22e933 | bfbe2e2e26ff96d9c389dc7bca0dcf014376f8d5 | refs/heads/master | 2020-05-31T17:46:43.937050 | 2020-02-15T08:38:37 | 2020-02-15T08:38:37 | 190,410,313 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 127 | java | package com.gmmapowell.quickbuild.build;
public interface BuildContextAware {
void provideBuildContext(BuildContext cxt);
}
| [
"[email protected]"
]
| |
685e37a0caf7f1fa83cb4fe334e4615ba472df71 | edb10a06f56d9bd19b0b60581728900a03d9732a | /Java/wordDictionary.java | 79e35e11890de65ade081b07d6ad909c7f9298ff | [
"MIT"
]
| permissive | darrencheng0817/AlgorithmLearning | 3ba19e6044bc14b0244d477903959730e9f9aaa8 | aec1ddd0c51b619c1bae1e05f940d9ed587aa82f | refs/heads/master | 2021-01-21T04:26:14.814810 | 2019-11-22T06:02:01 | 2019-11-22T06:02:01 | 47,100,767 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,236 | java | import java.util.LinkedList;
import java.util.Queue;
public class wordDictionary {
public static void main(String[] args) {
// TODO Auto-generated method stub
myWordDictionary test=new myWordDictionary();
test.addWord("bad");test.addWord("dad");test.addWord("mad");
System.out.println(test.search("pad"));
System.out.println(test.search("bad"));
System.out.println(test.search(".ad"));
System.out.println(test.search("b.."));
}
}
class myWordDictionary {
TrieNode root=new TrieNode();
// Adds a word into the data structure.
public void addWord(String word) {
TrieNode pointer=root;
for(int i=0;i<word.length();i++){
int index=word.charAt(i)-'a';
if(pointer.children[index]==null){
pointer.children[index]=new TrieNode();
}
pointer=pointer.children[index];
}
pointer.isWord=true;
}
// Returns if the word is in the data structure. A word could
// contain the dot character '.' to represent any one letter.
public boolean search(String word) {
Queue<TrieNode> queue=new LinkedList<TrieNode>();
queue.add(root);
for(int i=0;i<word.length();i++){
char c=word.charAt(i);
if(queue.isEmpty())
return false;
Queue<TrieNode> tempQueue=new LinkedList<TrieNode>();
while(!queue.isEmpty()){
TrieNode tempNode=queue.poll();
if(c=='.'){
for(int j=0;j<26;j++){
if(tempNode.children[j]!=null)
tempQueue.offer(tempNode.children[j]);
}
}
else{
if(tempNode.children[c-'a']!=null)
tempQueue.add(tempNode.children[c-'a']);
}
}
queue=tempQueue;
}
boolean res=false;
while(!queue.isEmpty()){
TrieNode tempNode=queue.poll();
res=res||tempNode.isWord;
}
return res;
}
}
class TrieNode{
public boolean isWord;
TrieNode[] children;
TrieNode(){
isWord=false;
children=new TrieNode[26];
}
} | [
"[email protected]"
]
| |
d94b88d4052a9e2f6eda0276c98acf5f75538e96 | ea1d84c9879063bf38b412c8742b27ff171e682e | /src/main/java/com/johnny/store/service/CollectionService.java | e7d4a61fece802cd8f7a963341752bead31eaf09 | []
| no_license | JohnnyStore/StoreService | 2ef51c5072896323c3e1df163909b9c2825ea461 | 7aff7472e01695863858b1169d762202061334c9 | refs/heads/master | 2020-03-27T08:31:36.027499 | 2019-05-24T06:47:20 | 2019-05-24T06:47:20 | 146,264,100 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 311 | java | package com.johnny.store.service;
import com.johnny.store.dto.UnifiedResponse;
public interface CollectionService extends BaseService {
UnifiedResponse findList(int pageNumber, int pageSize, int customerID, String status);
UnifiedResponse findListByItem(int customerID, int itemID, String status);
}
| [
"[email protected]"
]
| |
a6348561e5fa14626e96aa33bd83efbe80069356 | 6193f2aab2b5aba0fcf24c4876cdcb6f19a1be88 | /wds/src/public/nc/ui/wds/w80060602/MyClientUICheckRuleGetter.java | 02464bc68dcc2e2ba9e65d4cdce1557fe6569448 | []
| no_license | uwitec/nc-wandashan | 60b5cac6d1837e8e1e4f9fbb1cc3d9959f55992c | 98d9a19dc4eb278fa8aa15f120eb6ebd95e35300 | refs/heads/master | 2016-09-06T12:15:04.634079 | 2011-11-05T02:29:15 | 2011-11-05T02:29:15 | 41,097,642 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 586 | java | package nc.ui.wds.w80060602;
import java.io.Serializable;
import nc.vo.trade.pub.IBDGetCheckClass2;
/**
* <b> 前台校验类的Getter类 </b>
*
* <p>
* 在此处添加此类的描述信息
* </p>
*
*
* @author author
* @version tempProject 1.0
*/
public class MyClientUICheckRuleGetter implements IBDGetCheckClass2,Serializable {
/**
* 前台校验类
*/
public String getUICheckClass() {
return "nc.ui.wds.w80060602.MyClientUICheckRule";
}
/**
* 后台校验类
*/
public String getCheckClass() {
return null;
}
} | [
"[email protected]"
]
| |
e79075481020fca8daf20b3735534e9be1150cbe | c7b4d929f256438b26dac9c38a0e2763a7d5ba9b | /EVA Refactored/src/messages/CheckingMessageBox.java | bcffd08f1f16c6d0f14b6e776ef83b68de2a55da | []
| no_license | JohnQ00/Refactored-EVA | 57bd88d3b48d29ab100bcfc82710e4dc5b100e57 | ba45a8f2f2c77e13c84448c64e2f84a7e8843d4c | refs/heads/master | 2020-12-18T18:42:25.784109 | 2020-02-03T20:01:21 | 2020-02-03T20:01:21 | 235,487,187 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 711 | java | package messages;
import user.User;
import java.util.ArrayList;
public class CheckingMessageBox {
public void receivingMessage(ArrayList<User> users, int userId){
System.out.println("\nChecking messages...");
for (int i = 0; i < users.get(userId).getMessagesQuantity(); i++) {
for (int j = 0; j < 500; j++) {
if (users.get(userId).getMessages(i).getSenderUsername()[j] == null)
break;
else
System.out.println("Message from " + users.get(userId).getMessages(i).getSenderUsername()[j] + ": \n" + users.get(userId).getMessages(i).getMessageSent()[j]);
}
}
}
}
| [
"[email protected]"
]
| |
59f948fb957d78511559d4dc22b38d49c1c66ba7 | 033d65f1d1922deb3a17006f47167a0649a9cd98 | /services/CustomerServiceImpl.java | fa99b1de10105db4caa7fd983dd5e48339758eed | []
| no_license | ammarita/SpringAssignment | bb1cc77cf62f0bc099dbd9682a8dd9bb6343e4ad | ac66fd757defc2a1aa2968a2d8cfa00814091c60 | refs/heads/master | 2020-07-14T14:31:44.518384 | 2019-08-30T08:06:11 | 2019-08-30T08:06:11 | 205,334,888 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,281 | java | package com.example.springmvc.services;
import com.example.springmvc.domain.Customer;
import java.util.*;
public class CustomerServiceImpl implements CustomerService {
private Map<Integer, Customer> customers;
public CustomerServiceImpl() {
// loadCustomers();
}
@Override
public List<Customer> listAllCustomers() {
return new ArrayList<>(customers.values());
}
@Override
public Customer getCustomerById(Integer id) {
return customers.get(id);
}
private Integer getNextId() {
return Collections.max(customers.keySet()) + 1;
}
@Override
public Customer saveAndUpdateCustomer(Customer customer) {
if(customer != null) {
if(customer.getId() == null) {
customer.setId(getNextId());
}
customers.put(customer.getId(), customer);
return customer;
} else {
throw new RuntimeException("Customer can't be null!");
}
}
@Override
public void deleteCustomer(Integer id) {
customers.remove(id);
}
private void loadCustomers() {
customers = new HashMap<>();
Customer customer1 = new Customer();
customer1.setId(1);
customer1.setFirstName("John");
customer1.setLastName("Doe");
customer1.setEmail("[email protected]");
customer1.setPhoneNumber("12345678");
customer1.setAddress1("1st Spring street");
customer1.setAddress2("Framework district");
customer1.setCity("Spring Boot");
customer1.setState("SB");
customer1.setZip("1234");
customers.put(1, customer1);
Customer customer2 = new Customer();
customer2.setId(2);
customer2.setFirstName("Johny");
customer2.setLastName("Doey");
customer2.setEmail("[email protected]");
customer2.setPhoneNumber("87654321");
customer2.setAddress1("2nd Spring street");
customer2.setAddress2("Framework district");
customer2.setCity("Spring Boot");
customer2.setState("SB");
customer2.setZip("4321");
customers.put(2, customer1);
}
}
| [
"[email protected]"
]
| |
ba8b2a806ad3cd1c31e9eff224b71ae08dfc1a8b | 3714974b546f7fddeeea54d84b543c3b350a7583 | /myProjects/MGTV/src/com/starcor/xul/Graphics/XulSVGDrawable.java | 6d65e9483ae85cc90abbb831c57db2e89940791a | []
| no_license | lubing521/ideaProjects | 57a8dadea5c0d8fc3e478c7829e6897dce242bde | 5fd85e6dbe1ede8f094de65226de41321c1d0683 | refs/heads/master | 2022-01-18T23:10:05.057971 | 2018-10-26T12:27:00 | 2018-10-26T12:27:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,352 | java | package com.starcor.xul.Graphics;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;
import com.caverock.androidsvg.SVG;
import com.caverock.androidsvg.SVGParseException;
import com.starcor.xul.XulUtils;
import com.starcor.xul.XulUtils.ticketMarker;
import java.io.InputStream;
public class XulSVGDrawable extends XulDrawable
{
private Bitmap _cachedBmp;
private SVG _svg;
public static XulDrawable buildSVGDrawable(InputStream paramInputStream, String paramString1, String paramString2, int paramInt1, int paramInt2)
{
if (paramInputStream == null)
return null;
XulSVGDrawable localXulSVGDrawable = new XulSVGDrawable();
float f1;
float f2;
float f4;
int i;
int j;
while (true)
{
try
{
localXulSVGDrawable._svg = SVG.getFromInputStream(paramInputStream);
f1 = 0.0F;
f2 = 0.0F;
f3 = 1.0F;
f4 = 1.0F;
RectF localRectF = localXulSVGDrawable._svg.getDocumentViewBox();
if (localRectF == null)
{
float f7 = localXulSVGDrawable._svg.getDocumentWidth();
float f8 = localXulSVGDrawable._svg.getDocumentHeight();
if ((f7 <= 0.0F) && (f8 <= 0.0F))
{
f7 = 256.0F;
f8 = 256.0F;
localXulSVGDrawable._svg.setDocumentWidth(f7);
localXulSVGDrawable._svg.setDocumentHeight(f8);
}
localXulSVGDrawable._svg.setDocumentViewBox(0.0F, 0.0F, f7, f8);
localRectF = localXulSVGDrawable._svg.getDocumentViewBox();
}
i = XulUtils.roundToInt(localRectF.width());
j = XulUtils.roundToInt(localRectF.height());
if ((paramInt1 == 0) && (paramInt2 == 0))
{
paramInt1 = i;
paramInt2 = j;
XulUtils.ticketMarker localticketMarker = new XulUtils.ticketMarker("BENCH!!!", true);
localticketMarker.mark();
Bitmap.Config localConfig = Bitmap.Config.ARGB_8888;
localXulSVGDrawable._cachedBmp = Bitmap.createBitmap(paramInt1, paramInt2, localConfig);
Canvas localCanvas = new Canvas(localXulSVGDrawable._cachedBmp);
localCanvas.translate(-f1, -f2);
localCanvas.scale(f3, f4);
localXulSVGDrawable._svg.renderToCanvas(localCanvas, localRectF);
localticketMarker.mark("svg");
Log.d("BENCH", localticketMarker.toString());
localXulSVGDrawable._url = paramString1;
localXulSVGDrawable._key = paramString2;
return localXulSVGDrawable;
}
}
catch (SVGParseException localSVGParseException)
{
localSVGParseException.printStackTrace();
return null;
}
if (paramInt1 == 0)
{
f4 = paramInt2 / j;
f3 = f4;
paramInt1 = XulUtils.roundToInt(f3 * i);
f1 = 0.0F;
f2 = 0.0F;
}
else
{
if (paramInt2 != 0)
break;
f4 = paramInt1 / i;
f3 = f4;
paramInt2 = XulUtils.roundToInt(f3 * j);
f1 = 0.0F;
f2 = 0.0F;
}
}
float f5 = paramInt1 / i;
float f6 = paramInt2 / j;
int k;
int m;
if (f5 > f6)
{
k = (int)(f5 * i);
m = (int)(f5 * j);
f4 = f5;
}
for (float f3 = f5; ; f3 = f6)
{
f1 = (k - paramInt1) / 2.0F;
f2 = (m - paramInt2) / 2.0F;
break;
k = (int)(f6 * i);
m = (int)(f6 * j);
f4 = f6;
}
}
public boolean draw(Canvas paramCanvas, Rect paramRect1, Rect paramRect2, Paint paramPaint)
{
paramCanvas.drawBitmap(this._cachedBmp, paramRect1, paramRect2, paramPaint);
return true;
}
public boolean draw(Canvas paramCanvas, Rect paramRect, RectF paramRectF, Paint paramPaint)
{
paramCanvas.drawBitmap(this._cachedBmp, paramRect, paramRectF, paramPaint);
return true;
}
public int getHeight()
{
return this._cachedBmp.getHeight();
}
public int getWidth()
{
return this._cachedBmp.getWidth();
}
}
/* Location: C:\Users\THX\Desktop\aa\aa\反编译工具包\out\classes_dex2jar.jar
* Qualified Name: com.starcor.xul.Graphics.XulSVGDrawable
* JD-Core Version: 0.6.2
*/ | [
"[email protected]"
]
| |
b9fa7a2a7c62919b30c7c2ee7e8981167c886432 | 3da41d2cf7325872ab18fc5dc1bf4e377ee6f212 | /edu/buffalo/cse/irf14/analysis/FilterRules/CapitalizationRule.java | eda3320530b7c2eea0b6d491a1b0612c9295798d | []
| no_license | krnprdp/IR-project | d24c00318b8d115969cd7d10bd6632ba4b773a9a | c6d93c1dc86dff8652df21a8342ff16a356dbcb8 | refs/heads/master | 2020-12-28T20:42:29.184112 | 2014-10-18T14:53:44 | 2014-10-18T14:53:44 | 24,996,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,429 | java | package edu.buffalo.cse.irf14.analysis.FilterRules;
import edu.buffalo.cse.irf14.analysis.Token;
import edu.buffalo.cse.irf14.analysis.TokenStream;
import edu.buffalo.cse.irf14.analysis.TokenizerException;
import edu.buffalo.cse.irf14.analysis.TokenFilter;
public class CapitalizationRule extends TokenFilter {
TokenStream ts;
Token t1, t2;
int i = 0;
String s1, s2;
public CapitalizationRule(TokenStream stream) {
super(stream);
this.ts = stream;
while (stream.hasNext()) {
s1 = stream.next().toString();
i++;
if (i != stream.size) {
s2 = stream.tlist.get(i).toString();
}
// s2 = stream.tokenList.get(i);
System.out.println(s1);
System.out.println(s2);
if (s1.contains("\'")) {
// Do nothing
} else if (s1.equals(s1.toUpperCase())) {
// All caps, so do nothing
} else if (Character.isUpperCase(s1.charAt(0))
&& Character.isUpperCase(s2.charAt(0))) {
if (i == stream.size) {
// Do nothing for last word
} else {
String s3 = s1 + " " + s2;
stream.replace(s3);
stream.next();
stream.remove();
}
} else if (Character.isUpperCase(s1.charAt(0))
&& (s1.substring(1).equals(s1.substring(1).toLowerCase()))) {
s1 = s1.toLowerCase();
stream.replace(s1);
}
}
}
@Override
public boolean increment() throws TokenizerException {
return false;
}
@Override
public TokenStream getStream() {
return ts;
}
} | [
"[email protected]"
]
| |
fdef3e0c5e0b9b1d79217b941980fc005a4a5c22 | ec9dacd41c75346c05d836b4000a6eeadaa596e3 | /eopPay/src/main/java/net/ytoec/kernel/techcenter/api/SMSSearchCore.java | 40a7258698227552c371ba84645e4fed71c1c3e9 | []
| no_license | Pd1r/eop | 08295a8c2543c3f96470965fc9db90fcb186335a | 0c43b484de6f08e57a64b5194fc1413db0fd78f4 | refs/heads/master | 2020-06-07T17:31:56.208813 | 2018-11-28T05:57:59 | 2018-11-28T05:57:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,097 | java | package net.ytoec.kernel.techcenter.api;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.ytoec.kernel.common.HttpPostCore;
import net.ytoec.kernel.dataobject.SMSObject;
import net.ytoec.kernel.service.SMSObjectService;
import org.apache.commons.collections.CollectionUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SMSSearchCore {
protected static final Logger logger = LoggerFactory.getLogger(SMSSenderCore.class);
private SMSObjectService<SMSObject> SMSObjectService = SMSSender.getSMSObjectService();//发送短信历史记录表
private String sendSMSUrl = "http://58.32.246.70:8088/SMSInterface";//短信接口url
public void smsStatusSearch() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("limit", 200);
logger.error("=====================短信状态查询开始");
List<SMSObject> sMSObjectLis = SMSObjectService.getStatusList(map);
if (CollectionUtils.isNotEmpty(sMSObjectLis)) {
for (int i = 0; i < sMSObjectLis.size(); i++) {
SMSObject sMSObject = sMSObjectLis.get(i);
String searchXml = xmlSearch(sMSObject.getSmsBatchNum()); //xml 参数
String searchResult = new HttpPostCore().connect(sendSMSUrl, searchXml.trim(),2);// 短信状态查询
Map<String,String> mapValue = parseSMSsearchResult(searchResult);//xml解析
if(mapValue.size() == 0){
logger.error("解析出错...");
continue;
}
//判断短信发送是否异常 0 正常 , 其他异常
Integer Numstatus = Integer.parseInt(mapValue.get("Numreportstatus"));//短信状态
if(Integer.parseInt(mapValue.get("Numresponsestatus"))==0){
//短信发送成功 2成功 ,0失败
if(Numstatus == 0 || Numstatus == 2){
logger.error("==================短信"+sMSObject.getSendMobile()+"状态为"+Numstatus);
SMSSendSuccess success = new SMSSendSuccess();
success.smsStatusUpd(sMSObject.getId(),Numstatus,"DELIVRD");
}else if(Numstatus ==1){
logger.error("==================短信状态为等待");
}
}else{
SMSSendFailed failed=new SMSSendFailed();
failed.sendMSMFiled(sMSObject.getId(), mapValue.get("Vc2destmobile"), sMSObject.getSmsType());
}
}
}
logger.error("没有查询到要修改的短信");
}
/**
* 解析xml
* @param sendResult
* @return
*/
private Map<String,String> parseSMSsearchResult(String sendResult) {
Document document=loadDocument(sendResult);
Element employees=document.getRootElement();
Map<String,String> map = new HashMap<String, String>();
for (Iterator iterator = employees.elementIterator(); iterator.hasNext();) {
Element employee = (Element) iterator.next();
for (Iterator iterator2 = employee.elementIterator(); iterator2.hasNext();) {
Element node = (Element) iterator2.next();
System.err.println("node Text = "+node.elementText("Numresponsestatus"));
System.err.println("node Text = "+node.elementText("Numreportstatus"));
System.err.println("node Text = "+node.elementText("Vc2destmobile"));
map.put("Numresponsestatus", node.elementText("Numresponsestatus"));
map.put("Vc2destmobile", node.elementText("Vc2destmobile"));
map.put("Numreportstatus", node.elementText("Numreportstatus"));
}
}
return map;
}
/**
* 将xml字符串转变成Document
* @param obj
* @return
*/
public Document loadDocument(String xml) {
try{
Document document = (Document) DocumentHelper.parseText(xml.trim());
return document;
} catch (Exception e) {
logger.error("no excel.xml");
e.printStackTrace();
}
return null;
}
/**
* 短信状态查询xml参数
* @param num
* @return
*/
private String xmlSearch(Integer num) {
String xml="<?xml version='1.0' encoding='UTF-8'?>"+
"<ufinterface>"+
"<Result>"+
"<SmsStateInquiresInfo>"+
"<Numsendseqid>"+num+"</Numsendseqid>"+
"</SmsStateInquiresInfo>"+
"</Result>" +
"</ufinterface>";
return xml;
}
}
| [
"[email protected]"
]
| |
f6914a4752c3ded56afa9a3f515f30da26870d68 | 1c757bb0c860fd508585c420c18bc9470179bb72 | /app/src/main/java/projects/android/my/contextmenu/MainActivity.java | 9fd1355aee7e14451ff0ad680581bde0f0292aae | []
| no_license | VikramBaliga/Assignment9.4 | a28203545d54fd08461922922ad2523b44f55dbc | ff01998cf776939229576c09e2586594c25f2241 | refs/heads/master | 2021-07-10T10:55:05.834526 | 2017-10-10T17:25:08 | 2017-10-10T17:25:08 | 106,445,017 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,438 | java | package projects.android.my.contextmenu;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button contextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
contextView = (Button) findViewById(R.id.contextBtn);
registerForContextMenu(contextView);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.contextmenu,menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
super.onContextItemSelected(item);
switch (item.getItemId())
{
case R.id.opt1:
Toast.makeText(this,"Option 1",Toast.LENGTH_SHORT).show();
break;
case R.id.opt2:
Toast.makeText(this,"Option 2",Toast.LENGTH_SHORT).show();
break;
case R.id.opt3:
Toast.makeText(this,"Option 3",Toast.LENGTH_SHORT).show();
break;
}
return true;
}
}
| [
"[email protected]"
]
| |
00989d43788e3418ab9b80967ca23d89cf546815 | 3405d610452960326f9327a4ff2141d8416a9415 | /hacker-rank-tasks/src/main/java/recursion/ThePowerSum.java | 98b4f60ed3f588369d7a17c4f55dfd083fc08947 | [
"MIT"
]
| permissive | yaskovdev/sandbox | 3d856e181f54ea936f64fbac22be56c8c1e21826 | d38fde20ea727d73886859b8be86f19e7752010b | refs/heads/master | 2023-06-27T05:53:03.809710 | 2023-06-15T15:54:54 | 2023-06-15T15:54:54 | 98,095,123 | 0 | 0 | MIT | 2022-02-26T08:21:41 | 2017-07-23T12:05:33 | Java | UTF-8 | Java | false | false | 1,501 | java | package recursion;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* https://www.hackerrank.com/challenges/the-power-sum/problem
*/
public class ThePowerSum {
public static void main(final String[] args) {
final Scanner scanner = new Scanner(System.in);
final int number = scanner.nextInt();
final int power = scanner.nextInt();
System.out.println(solve(number, power));
}
private static long solve(final long number, final long power) {
final List<Long> coins = new ArrayList<>();
for (int i = 1; i <= root(number, power); i++) {
coins.add(pow(i, power));
}
return ways(number, coins);
}
private static long ways(final long number, final List<Long> numbers) {
if (number == 0) {
return 1;
} else if (number < 0 || numbers.isEmpty()) {
return 0;
} else {
return ways(number - head(numbers), tail(numbers)) + ways(number, tail(numbers));
}
}
private static long root(final long number, final long power) {
return (long) Math.pow(number, 1.0 / power);
}
private static long pow(final long number, final long power) {
return (long) Math.pow(number, power);
}
private static long head(final List<Long> list) {
return list.get(0);
}
private static List<Long> tail(final List<Long> list) {
return list.subList(1, list.size());
}
}
| [
"[email protected]"
]
| |
073a7a488e6df7593c35e04f5bb66d69b86f2b82 | a9d12240ba50a1fc52966ad689a38a9a083a6250 | /src/at/bischof/tasks/dao/GroupDAO.java | f523603dc1139d9a97c66767462ffe8736e66188 | []
| no_license | Bischi/jumumanager | f2bbefa2a0fcab73751488e930fda011be185002 | a15f2f792a1a37ad69e1234f996858cbd75f53d3 | refs/heads/master | 2021-01-23T04:09:56.748423 | 2015-04-17T10:15:21 | 2015-04-17T10:15:21 | 33,724,601 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,959 | java | package at.bischof.tasks.dao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import at.bischof.tasks.vo.Group;
public class GroupDAO {
public List<Group> getAllGroups() {
try {
List<Group> gList = new ArrayList<Group>();
String sql = "SELECT * from tbl_groups";
PreparedStatement ps = getConnection().prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if (!rs.first()) {
return gList;
}
while (!rs.isAfterLast()) {
Group g = new Group(rs.getInt(1), rs.getString(2));
gList.add(g);
rs.next();
}
return gList;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
public Group getGroupById(int mid) {
String selectStatement = "SELECT from tbl_groups WHERE id = ?";
PreparedStatement ps;
try {
ps = getConnection().prepareStatement(selectStatement);
ps.setInt(1, mid);
ResultSet rs = ps.executeQuery();
Group g = new Group(rs.getInt(1), rs.getString(2));
return g;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
public void insertGroup(Group g) {
String insertStatement = "Insert INTO tbl_groups (name)VALUES(?)";
PreparedStatement ps;
try {
ps = getConnection().prepareStatement(insertStatement);
ps.setString(1, g.getName());
ps.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void updateGroup(Group g, int mid) {
String updateStatement = "UPDATE tbl_groups SET name = ? WHERE id = ?";
PreparedStatement ps;
try {
ps = getConnection().prepareStatement(updateStatement);
ps.setString(1, g.getName());
ps.setInt(2, mid);
ps.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteGroup(int mid) {
String deleteStatement = "DELETE FROM tbl_groups WHERE id = ?";
PreparedStatement ps;
try {
ps = getConnection().prepareStatement(deleteStatement);
ps.setInt(1, mid);
ps.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Connection getConnection() {
try {
Connection conn;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager
.getConnection("jdbc:mysql://localhost/jumumanager?"
+ "user=root&password=root123");
return conn;
// Do something with the Connection
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
]
| |
ddd29c969afe860357f971900a0f8ab89fc4db46 | 2b6c5004b2f467d453f6a227306ae9830c1b834f | /archive/2018.02/2018.02.02 - February Challenge 2018/CarpalTunnel.java | f9840a18dc9bdc3894aade59dd97402797268cf0 | []
| no_license | gargoris/yaal | 83edf0bb36627aa96ce0e66c836d56f92ec5f842 | 4f927166577b16faa99c7d3e6d870f59d6977cb3 | refs/heads/master | 2020-12-21T04:48:30.470138 | 2020-04-19T11:25:19 | 2020-04-19T11:25:19 | 178,675,652 | 0 | 0 | null | 2019-03-31T10:54:25 | 2019-03-31T10:54:24 | null | UTF-8 | Java | false | false | 447 | java | package net.egork;
import net.egork.io.InputReader;
import net.egork.io.OutputWriter;
import static net.egork.misc.ArrayUtils.maxElement;
public class CarpalTunnel {
public void solve(int testNumber, InputReader in, OutputWriter out) {
int n = in.readInt();
int[] a = in.readIntArray(n);
int c = in.readInt();
in.readInt();
in.readInt();
out.printLine((long)maxElement(a) * (c - 1));
}
}
| [
"[email protected]"
]
| |
ad63d0263bba36a434ec3340e8c72c66b4b4a5d1 | c8af430a2890c226eb99d3b3c983dcc6e5824c2f | /Programa2.0/Controlador_Dades_Recurs.java | 5d6059d8abff95dd7343f5887a5cc87b394c438f | []
| no_license | JoRd118/PROP | c51c7c3829e368ed52a5d8806de9fae3c6010429 | df40b854922594dc67bbe31d2da9302ddc4c32da | refs/heads/master | 2021-01-23T06:44:23.139851 | 2014-06-08T20:46:36 | 2014-06-08T20:47:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,470 | java | //import java.util.*;
//import java.io.*;
//import java.nio.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
/**
*
*Controlador Dades Classe Recurs
*
*@author Claudi
*/
public class Controlador_Dades_Recurs{
final static Charset ENCODING = StandardCharsets.UTF_8;
public Controlador_Dades_Recurs(){}
public ArrayList<String> readTextFile(String nomFitxer) throws IOException {
ArrayList<String> s = new ArrayList<String>();
Path path = Paths.get(nomFitxer);
try (BufferedReader reader = Files.newBufferedReader(path, ENCODING)){
String line = null;
while ((line = reader.readLine()) != null) {
s.add(line);
//log(line);
}
}
return s;
}
public void writeTextFile(String nomFitxer, Iterable<String> aLines) throws IOException {
Path path = Paths.get(nomFitxer);
try (BufferedWriter writer = Files.newBufferedWriter(path, ENCODING)){
for(String line : aLines){
writer.write(line);
writer.newLine();
}
}
}
private static void log(Object aMsg){
System.out.println(String.valueOf(aMsg));
}
} | [
"[email protected]"
]
| |
1c70217eb73cc8bab014cba164ddd17916b38d85 | ee9997d2d264f8d62e595793d8456e3a8887a337 | /src/advent/Day7.java | f2f1950e77f9eb82d13e02843d0f1f7a36d9fa66 | []
| no_license | darisma/advent-of-code-2020 | 3b7c749bc54171f1292efb06bcb375f76bf616b6 | 121008be78663c9a454977fc3f616f699021dc2e | refs/heads/main | 2023-01-31T01:30:23.121486 | 2020-12-09T07:23:51 | 2020-12-09T07:23:51 | 319,006,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,343 | java | package advent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Day7 {
static AdventInputReader ir = new AdventInputReader();
static final String FN = "day7.txt";
public static void main (String[] args) {
System.out.println("Answer to 7a is: " + solveAdvent7a());
System.out.println("Answer to 7b is: " + solveAdvent7b());
}
private static long solveAdvent7a() {
List<String[]> rivit = ir.getStringStream(FN)
.map(s -> s.replace("bags", "bag")
.split("contain"))
.collect(Collectors.toList());
ArrayList<Bag> rules = new ArrayList<Bag>();
ArrayList<String> bagNames = new ArrayList<>();
for (String[] s : rivit) {
List<String> rule = Arrays.asList(s[1].split(",")).stream()
.map(e -> trimAmounts(e.trim()))
.collect(Collectors.toList());
Bag bag = new Bag(s[0].trim(), rule);
rules.add(bag);
bagNames.add(s[0].trim());
}
List<Bag> searchBag = Arrays.asList(new Bag("shiny gold bag"));
List<String> bigList = new ArrayList<>();
getParents(bigList, rules, searchBag, 0);
bigList = bigList.stream().distinct().collect(Collectors.toList());
return bigList.size();
}
private static long solveAdvent7b() {
List<String[]> rivit = ir.getStringStream(FN)
.map(s -> s.replace("bags", "bag")
.split("contain"))
.collect(Collectors.toList());
ArrayList<String> resultBags = new ArrayList<String>();
ArrayList<Bag> rules = new ArrayList<Bag>();
ArrayList<String> bagNames = new ArrayList<String>();
for (String[] s : rivit) {
List<String> rule = Arrays.asList(s[1].split(",")).stream()
.map(e -> e.trim())
.collect(Collectors.toList());;
Bag bag = new Bag(s[0].trim(), rule);
rules.add(bag);
bagNames.add(s[0].trim());
}
//shiny gold bags contain 5 pale brown bags, 2 light red bags, 3 drab lime bags.
Bag goldbag = rules.stream()
.filter(b -> b.getBagName().equalsIgnoreCase("shiny gold bag"))
.findFirst().get();
calculateChildren(resultBags, rules, goldbag);
return resultBags.size();
}
private static void calculateChildren(List<String> resultList, List<Bag> fullList, Bag bag) {
for(Bag b : bag.getBags()) {
Bag realBag =fullList.stream()
.filter(f -> f.getBagName().equalsIgnoreCase(b.getBagName()))
.findFirst().get();
resultList.add(realBag.getBagName());
calculateChildren(resultList, fullList, realBag);
}
}
private static String trimAmounts(String singleRule) {
if(singleRule.endsWith(".")) {
singleRule = singleRule.substring(0,singleRule.length()-1);
}
if(Character.isDigit(singleRule.charAt(0))){
return singleRule.substring(singleRule.indexOf(" ")+1, singleRule.length());
}
return singleRule;
}
private static int getParents(List<String> bigList, List<Bag> fullList, List<Bag> bags, int counter){
List<Bag> resultBags = new ArrayList<>();
for(Bag b : fullList) {
for(Bag r : bags) {
if(b.containsBagName(r.getBagName())) {
if(resultBags.stream()
.noneMatch(c -> c.getBagName().equalsIgnoreCase(b.getBagName()))) {
resultBags.add(b);
bigList.add(b.getBagName());
counter = counter +1;
}
}
}
}
if(!resultBags.isEmpty()) {
getParents(bigList, fullList, resultBags, counter);
}
return counter;
}
} | [
"[email protected]"
]
| |
e6e2b56c20ce7ab0a12005c2aaa314a90bf3c442 | 528fc4ee8012beccbc47c938bdbf71f652df7cc3 | /src/supply/cargo/SendAndWaitBehaviour.java | ed96e8c59df8a76b48bdfca7b46cc3f56652a8a6 | []
| no_license | Vovchikan/TPE-lab2-Agents | c283ce908ca0f1c0986a0835a85dc1727ac214eb | f5781c937d1f29367a520f2126c7d4980dd2d7dd | refs/heads/master | 2022-04-25T17:49:04.574349 | 2020-04-28T12:53:48 | 2020-04-28T12:53:48 | 249,673,032 | 0 | 0 | null | null | null | null | WINDOWS-1251 | Java | false | false | 3,126 | java | package supply.cargo;
import java.util.Arrays;
import java.util.Collections;
import jade.core.behaviours.*;
import jade.lang.acl.*;
import supply.delivery.DeliveryInfoForCargo;
public class SendAndWaitBehaviour extends SimpleBehaviour {
private boolean finished = false;
private String[] receiversNames;
private CargoAgent myAgent;
public SendAndWaitBehaviour(CargoAgent cargoAgent) {
super(cargoAgent);
receiversNames = cargoAgent.DeliveriesNames;
myAgent = cargoAgent;
}
@Override
public void action() {
DeliveryInfoForCargo info = null;
if (receiversNames.length > 0) {
receiversNames = shuffleArray(receiversNames);
for (int i = 0; i < receiversNames.length; i++) {
System.out.println(myAgent.getLocalName() + " is trying to find free deliverAgent.");
myAgent.SendInfo(receiversNames[i],
new CargoInfo(myAgent.getLocalName(), myAgent.GetWeight(), myAgent.GetDestinationAddress()));
MessageTemplate m = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
info = ReceiveMessage(m, 12000);
if (info == null)
System.out.println(myAgent.getLocalName() + ": empty message was received.");
else if (info.Success) {
System.out.println(myAgent.getLocalName() + ": " + receiversNames[i] + " will drive me.");
break;
} else {
String format = "%s: %s WON'T DRIVE ME. REASON IS \"%s\".";
System.out.println(String.format(format, myAgent.getLocalName(), receiversNames[i], info.Reason));
if(info.timeFail || info.weightFail) {
myAgent.DeliveriesNames = removeFromArray(receiversNames, receiversNames[i]);
break;
}
}
}
if (info == null || !info.Success) {
System.out.println("Idu na vtoroy krug".toUpperCase());
myAgent.blockingReceive(300);
myAgent.addBehaviour(new SendAndWaitBehaviour(myAgent));
}
}
finished = true;
}
@Override
public boolean done() {
return finished;
}
private DeliveryInfoForCargo ReceiveMessage(MessageTemplate m, int delay) {
ACLMessage msg = myAgent.blockingReceive(m, delay);
if (msg != null) {
System.out.println(
myAgent.getLocalName() + ": message from " + msg.getSender().getLocalName() + " was received.");
DeliveryInfoForCargo info = DeliveryInfoForCargo.CreateFromString(msg.getContent());
return info;
}
return null;
}
private String[] shuffleArray(String[] arr) {
var l = Arrays.asList(arr);
Collections.shuffle(l);
return l.toArray(new String[0]);
}
private String[] removeFromArray(String[] arr, String elem) {
if(arr.length == 0)
return new String[] {};
if(arr.length == 1)
if(arr[0] == elem)
return new String [] {};
else return arr;
var temp = new String[arr.length-1];
for (int i = 0, j = 0; i < arr.length; i++) {
if(arr[i] != elem) {
try {
temp[j] = arr[i];
j++;
} catch (IndexOutOfBoundsException e) {
System.out.println("Что-то не так с индексацией в классе поведения груза. Наверное не найден элемент для удаления.");
e.printStackTrace();
}
}
}
return temp;
}
}
| [
"[email protected]"
]
| |
3b5e8bd6dcecf0cd82e34286fab2ee0f083aeee3 | c4fb85c6bbd33fedada0bad2e2a44f63ec839b85 | /.svn/pristine/44/44ff10b9b8b6f875c48489377e4e9905c1bbc135.svn-base | f95cf94e0417b7fe7ef363dfc53f520aecf78482 | [
"Apache-2.0",
"MIT"
]
| permissive | KqSMea8/lbzgweb | 02a0487e256a45f9ac1dd8eba4e35c9e7676de68 | 42e5fa64231d9ca5c058c8fbc9307805852f2496 | refs/heads/master | 2020-04-13T18:19:18.233496 | 2018-12-28T05:09:52 | 2018-12-28T05:09:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,696 | package com.lyarc.tp.corp.outprocess.provider.service;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lyarc.tp.corp.UserHolder;
import com.lyarc.tp.corp.common.bean.PageResultBean;
import com.lyarc.tp.corp.login.form.LoginUser;
import com.lyarc.tp.corp.outprocess.provider.bean.OutProviderBean;
import com.lyarc.tp.corp.outprocess.provider.dao.OutProviderMapper;
@Service
public class OutProviderService {
@Autowired
private OutProviderMapper outProviderMapper;
@SuppressWarnings("rawtypes")
public PageResultBean query(OutProviderBean outProviderBean) {
List<OutProviderBean> outProviderList = outProviderMapper.query(outProviderBean);
Long outProviderCount = outProviderMapper.count(outProviderBean);
return PageResultBean.success(outProviderCount, outProviderList);
}
public OutProviderBean get(String providerId) {
return outProviderMapper.get(providerId);
}
public Integer add(OutProviderBean outProviderBean) {
LoginUser loginUser = UserHolder.getUser();
outProviderBean.setCreator(loginUser.getUserId());
return outProviderMapper.add(outProviderBean);
}
public Integer update(OutProviderBean outProviderBean) {
OutProviderBean oldOutProviderBean = outProviderMapper.get(outProviderBean.getProviderId());
outProviderBean.setCreator(oldOutProviderBean.getCreator());
outProviderBean.setCreateTime(oldOutProviderBean.getCreateTime());
outProviderBean.setUpdateTime(new Date());
outProviderBean.setTmstamp(oldOutProviderBean.getTmstamp());
Integer num = outProviderMapper.update(outProviderBean);
return num;
}
}
| [
"[email protected]"
]
| ||
881fb548bcc92dcba05a08089b8d35683d4c6cd8 | 978eb672f33d625f1eb29aed668e52a2364e7983 | /wechatOAweb/src/main/java/com/leyidai/web/weChat/MessageUtil.java | 385138768d41de11b6c731f03ebd294f195f0e61 | []
| no_license | truechuan/wechatOA | 72c77925c5a64e5cf3e8443eb2fdb7565dd3ba58 | 3c6372b923dd58a21cce1bece8c0dde59de4738c | refs/heads/master | 2022-12-23T09:36:03.499605 | 2021-05-07T09:13:28 | 2021-05-07T09:13:28 | 120,618,443 | 1 | 2 | null | 2022-12-16T02:27:19 | 2018-02-07T13:26:41 | Roff | UTF-8 | Java | false | false | 3,044 | java | package com.leyidai.web.weChat;
import java.io.InputStream;
import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.core.util.QuickWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XppDriver;
/**
* 消息工具类
* @author mikan
* @version 1.0
*
*/
public class MessageUtil {
/**
* 解析微信发来的请求(XML)
*
* @param request
* @return Map
* @throws Exception
*/
public static Map<String, String> parseXml(HttpServletRequest request) throws Exception {
// 将解析结果存储在HashMap中
Map<String, String> map = new HashMap<String, String>();
// 从request中取得输入流
InputStream inputStream = request.getInputStream();
// 读取输入流
SAXReader reader = new SAXReader();
Document document = reader.read(inputStream);
// 得到xml根元素
Element root = document.getRootElement();
// 得到根元素的所有子节点
@SuppressWarnings("unchecked")
List<Element> elementList = root.elements();
// 遍历所有子节点
for (Element e : elementList){
map.put(e.getName(), e.getText());
}
// 释放资源
inputStream.close();
inputStream = null;
return map;
}
/**
* 基本消息对象转换成xml
* @param message 消息对象
* @return xml
*/
public static String messageToXml(Object message){
xstream.alias("xml", message.getClass());
return xstream.toXML(message);
}
/**
* 文本消息对象转换成xml
*
* @param textMessage 文本消息对象
* @return xml
*/
public static String textMessageToXml(TextMessage textMessage) {
xstream.alias("xml", textMessage.getClass());
return xstream.toXML(textMessage);
}
/**
* 图文消息对象转换成xml
* @param newsMessage 图文消息对象
* @return xml
*/
public static String newsMessageToXml(NewsMessage newsMessage) {
xstream.alias("xml", newsMessage.getClass());
xstream.alias("item", new Article().getClass());
return xstream.toXML(newsMessage);
}
/**
* 扩展xstream,使其支持CDATA块
*/
private static XStream xstream = new XStream(new XppDriver() {
public HierarchicalStreamWriter createWriter(Writer out) {
return new PrettyPrintWriter(out) {
// 对所有xml节点的转换都增加CDATA标记
boolean cdata = true;
protected void writeText(QuickWriter writer, String text) {
if (cdata) {
writer.write("<![CDATA[");
writer.write(text);
writer.write("]]>");
} else {
writer.write(text);
}
}
};
}
});
/**
* emoji表情转换(hex to utf-16)
* @param hexEmoji
* @return String
*/
public static String emoji(int hexEmoji) {
return String.valueOf(Character.toChars(hexEmoji));
}
} | [
"[email protected]"
]
| |
04bae787c80f10ba789551580d4fb8dae2efb79e | d0f2b0e7bf9653f215c0e00915d3796bf8197677 | /mobile/src/main/java/com/robotemplates/cookbook/CookbookApplication.java | a9252fe0baf580295f5e34870092cfd9cba3276c | []
| no_license | melashry/cookbook-1.1.0 | 97c1234834fb8013ac8a562afcc8f2944fe9d34d | 179d53fce995ee0df153a5d7e9c771759b9be49b | refs/heads/master | 2021-06-27T15:04:32.434815 | 2017-09-17T12:39:52 | 2017-09-17T12:39:52 | 103,757,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,388 | java | package com.robotemplates.cookbook;
import android.app.Application;
import android.content.Context;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.utils.StorageUtils;
import java.io.File;
import java.io.IOException;
public class CookbookApplication extends Application
{
private static CookbookApplication mInstance;
private Tracker mTracker;
public CookbookApplication()
{
mInstance = this;
}
@Override
public void onCreate()
{
super.onCreate();
// force AsyncTask to be initialized in the main thread due to the bug:
// http://stackoverflow.com/questions/4280330/onpostexecute-not-being-called-in-asynctask-handler-runtime-exception
try
{
Class.forName("android.os.AsyncTask");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
// init image caching
File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
cacheDir.mkdirs(); // requires android.permission.WRITE_EXTERNAL_STORAGE
try
{
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.threadPoolSize(3)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
.diskCache(new LruDiscCache(cacheDir, new HashCodeFileNameGenerator(), 32 * 1024 * 1024))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.build();
ImageLoader.getInstance().init(config);
}
catch(IOException e)
{
e.printStackTrace();
}
}
public static Context getContext()
{
return mInstance;
}
public synchronized Tracker getTracker()
{
if(mTracker==null)
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
analytics.setDryRun(!CookbookConfig.ANALYTICS);
mTracker = analytics.newTracker(R.xml.analytics_app_tracker);
}
return mTracker;
}
}
| [
"[email protected]"
]
| |
de929e94318eab229f73262eb2753c6767633c1c | 0c9cd4c8ced08238b652438c8b8d80f5653a97a1 | /ask-app/src/main/java/com/androidstarterkit/util/FileUtils.java | 1cfb85f82533e4bd80938794ca63719507192c9c | [
"MIT"
]
| permissive | vaginessa/AndroidStarterKit | 6d6a91859ebc37b28f00034a2b7169d514812df8 | ed7e81947175a9d02e3880ade95469713b33dda2 | refs/heads/master | 2021-01-19T23:02:47.854032 | 2017-04-16T17:31:58 | 2017-04-16T17:31:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,045 | java | package com.androidstarterkit.util;
import com.androidstarterkit.SyntaxConstraints;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FileUtils {
public static final String CLASSES_PATH = "/ask-app/build/classes/main";
/**
* Get root path in this project
*
* @return the string for project root path
*/
public static String getRootPath() {
File rootPath = new File(".");
try {
return rootPath.getCanonicalPath().replace(CLASSES_PATH, "");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* Get file in directory
*
* @param dirPath to find the file by name in directory
* @param fileName to get the file
* @return the file was found in directory
*/
public static File getFileInDirectory(String dirPath, String fileName) {
File dir = new File(dirPath);
File file = new File(dir, fileName);
return file;
}
/**
* Adding a slash between arguments for new path
*
* @param args are paths which are needed to one path
* @return path was made by args
*/
public static String linkPathWithSlash(String... args) {
String path = "";
for (int i = 0, li = args.length; i < li; i++) {
path += args[i];
if (i != li - 1) {
path += "/";
}
}
return path;
}
public static void writeFile(File file, List<String> lineList) {
writeFile(file, getString(lineList));
}
/**
* Write content you want to file
*
* @param file is target file to importLayout
* @param content is the string you want to importLayout
*/
public static void writeFile(File file, String content) {
if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
return;
}
FileWriter fileWriter;
try {
fileWriter = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fileWriter);
bw.write(content);
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void writeFile(String pathName
, String fileName
, String content) {
File destDir = new File(pathName);
if (!destDir.exists() && !destDir.mkdirs()) {
return;
}
writeFile(FileUtils.linkPathWithSlash(pathName, fileName), content);
}
public static void writeFile(String filePath, String content) {
File file = new File(filePath);
try {
if (!file.exists()) {
file.createNewFile();
}
writeFile(file, content);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Read content from file
*
* @param file is target file to read
* @return content is the strings in file
*/
public static List<String> readFile(File file) {
Scanner scanner;
List<String> stringList = new ArrayList<>();
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String e = scanner.nextLine();
stringList.add(e);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return stringList;
}
public static String readFile(String filePath) throws IOException {
final String EoL = System.getProperty("line.separator");
List<String> lines = Files.readAllLines(Paths.get(filePath), Charset.defaultCharset());
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line).append(EoL);
}
return sb.toString();
}
/**
* Copy file of AndroidModule to file of source project.
*
* @param sourceFilePath is path of source
* @throws IOException
*/
public static void copyFile(File moduleFile,
String sourceFilePath) throws IOException {
File destDir = new File(sourceFilePath);
if (!destDir.exists() && !destDir.mkdirs()) {
return;
}
File sourceFile = moduleFile;
File destFile = new File(linkPathWithSlash(sourceFilePath, moduleFile.getName()));
if (!sourceFile.exists()) {
return;
}
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel sourceChannel;
FileChannel destinationChannel;
sourceChannel = new FileInputStream(sourceFile).getChannel();
destinationChannel = new FileOutputStream(destFile).getChannel();
if (destinationChannel != null && sourceChannel != null) {
destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
}
if (sourceChannel != null) {
sourceChannel.close();
}
if (destinationChannel != null) {
destinationChannel.close();
}
}
public static void copyDirectory(File src, File dest) throws IOException{
if (src.isDirectory()) {
if (!dest.exists()) {
dest.mkdirs();
}
String files[] = src.list();
for (String file : files) {
File srcFile = new File(src, file);
File destFile = new File(dest, file);
copyDirectory(srcFile,destFile);
}
} else {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
in.close();
out.close();
}
}
/**
* Get String from String List
*
* @param strList is a content of file
* @return String of a content
*/
public static String getString(List<String> strList) {
StringBuffer stringBuffer = new StringBuffer();
for (String str : strList) {
stringBuffer.append(FileUtils.addNewLine(str));
}
return stringBuffer.toString();
}
public static String changeDotToSlash(String str) {
return str.replaceAll("\\.", "/");
}
/**
* Get a string between double quotes (")
*
* @param str has withLayout double quotes
* @return string was removed double quotes
*/
public static String getStringBetweenQuotes(String str) {
Pattern pattern = Pattern.compile("\"([^\"]*)\"");
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
return matcher.group(1);
}
return null;
}
/**
* @param path is the string which is the path withLayout dot(.) delimeter such as com.ask.MainActivity
* @return is the string for file name
*/
public static String getFileNameForDotPath(String path) {
final String[] token = path.split("\\.");
final int lastIndex = token.length - 1;
return token[lastIndex];
}
/**
* Add intent to line
*
* @param line is a string
* @return new string withLayout indent
*/
public static String getIndentOfLine(String line) {
String intent = "";
for (int i = 0, li = line.length(); i < li; i++) {
if (line.toCharArray()[i] == ' ') {
intent += " ";
} else {
return intent;
}
}
return SyntaxConstraints.DEFAULT_INDENT;
}
/**
* Add '\n' to line
*
* @param line is a string without new-line character
* @return new string withLayout new-line character
*/
private static String addNewLine(String line) {
return line + "\n";
}
/**
* Remove extension
*
* @param filename String for file name withLayout extension
* @return String for file name
*/
public static String removeExtension(String filename) {
return filename.substring(0, filename.lastIndexOf('.'));
}
public static String removeFirstSlash(String path) {
if (path.length() > 0 && path.charAt(0) == '/') {
path = path.substring(1);
}
return path;
}
}
| [
"[email protected]"
]
| |
8827c78a5d3056e544f5fe36ad212d258da121fe | 3fae38b1701c319f89124a2434b5e98a99805f5f | /browser/src/nodes/LeafNode.java | a91cd5125f21c5e33074303e68bed777e53eb972 | []
| no_license | ibrahimAlabdullah/internet_browser | 654b7e3c90a1c103da3c5234c3b8df6d1cb8c097 | 02af07cd24163c88c1c83261951cb9e02ddf6759 | refs/heads/main | 2023-05-03T03:49:41.448940 | 2021-05-29T22:07:49 | 2021-05-29T22:07:49 | 372,078,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,188 | java | package nodes;
import java.util.Collections;
import java.util.List;
abstract class LeafNode extends Node {
private static final List<Node> EmptyNodes = Collections.emptyList();
Object value; // either a string value, or an attribute map (in the rare case multiple attributes are set)
protected final boolean hasAttributes() {
return value instanceof Attributes;
}
@Override
public final Attributes attributes() {
ensureAttributes();
return (Attributes) value;
}
private void ensureAttributes() {
if (!hasAttributes()) {
Object coreValue = value;
Attributes attributes = new Attributes();
value = attributes;
if (coreValue != null)
attributes.put(nodeName(), (String) coreValue);
}
}
String coreValue() {
return attr(nodeName());
}
void coreValue(String value) {
attr(nodeName(), value);
}
@Override
public String attr(String key) {
if (!hasAttributes()) {
return key.equals(nodeName()) ? (String) value : EmptyString;
}
return super.attr(key);
}
@Override
public Node attr(String key, String value) {
if (!hasAttributes() && key.equals(nodeName())) {
this.value = value;
} else {
ensureAttributes();
super.attr(key, value);
}
return this;
}
@Override
public boolean hasAttr(String key) {
ensureAttributes();
return super.hasAttr(key);
}
@Override
public Node removeAttr(String key) {
ensureAttributes();
return super.removeAttr(key);
}
@Override
public String absUrl(String key) {
ensureAttributes();
return super.absUrl(key);
}
@Override
public String baseUri() {
return hasParent() ? parent().baseUri() : "";
}
@Override
protected void doSetBaseUri(String baseUri) {
// noop
}
@Override
public int childNodeSize() {
return 0;
}
@Override
protected List<Node> ensureChildNodes() {
return EmptyNodes;
}
}
| [
"[email protected]"
]
| |
a8aaad2e3869ea600a9e2a0acf44d4cd4312e579 | 3a38508eb940e18cb05e4850136b56a4fde0e38f | /src/main/java/cn/com/thtf/cms/report/serviceimpl/InstockDetailServiceImpl.java | 9d52017fecf9df8e6cdee6609294cdfbea41af5d | []
| no_license | fairyhawk/thtf_05_report-Deprecated | 55322258fe211950b64130391e71780350616210 | bda520a2c1eae69b6903f0a3772561989ba1f437 | refs/heads/master | 2016-09-09T22:38:56.838567 | 2014-01-25T10:30:38 | 2014-01-25T10:30:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,350 | java | /**
* ClassName StockProductDetailServiceImpl
*
* History
* Create User: Lubo
* Create Date: 2010-12-20
* Update User:
* Update Date:
*/
package cn.com.thtf.cms.report.serviceimpl;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import cn.com.thtf.cms.report.dao.InstockDetailDao;
import cn.com.thtf.cms.report.dto.BaseQueryData;
import cn.com.thtf.cms.report.dto.InstockDetailDto;
import cn.com.thtf.cms.report.entity.InstockDetailEntity;
import cn.com.thtf.cms.report.service.InstockDetailService;
/**
* InstockDetailServiceImpl
*
* @author zhangzx
*/
public class InstockDetailServiceImpl implements InstockDetailService {
@Setter
@Getter
/** StockProductDetailDao */
private InstockDetailDao dao;
@Override
public void getInstockDetail(BaseQueryData<InstockDetailDto> queryParam) {
/* 检索数据 */
List<InstockDetailEntity> resultList = dao.getInstockDetail(queryParam);
long foundRows = dao.getFoundRows();
/* 封装返回参数 */
queryParam.setResultPage((int) foundRows);
queryParam.setDataList(resultList);
}
@Override
public InstockDetailDto getInstockDetailSumVal(BaseQueryData<InstockDetailDto> queryParam) {
return dao.getInstockDetailSumVal(queryParam);
}
}
| [
"[email protected]"
]
| |
774afff0c7c6b7864a2d87863e2a1f153a44ff2f | 5a3bb2d407d69397459d77c2e2dba6c451dc49df | /src/main/java/com/interview/weather/service/WeatherServiceImpl.java | b6a39c6e304f064391a8651422ca0b76c8784be1 | []
| no_license | balajidommaraju/WeatherService | d049cdd324b9e806d9c3cb0a68ddae8b1a994b34 | b5aa88d6a3687aef1eacab74b72de6e92ae68f5c | refs/heads/master | 2022-11-07T08:18:43.121205 | 2019-11-04T06:47:41 | 2019-11-04T06:47:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,426 | java | package com.interview.weather.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.interview.weather.bo.TemperatureBO;
import com.interview.weather.bo.WeatherAPIRespBO;
import com.interview.weather.bo.WeatherBO;
import com.interview.weather.controller.WeatherController;
import com.interview.weather.dto.Temperature;
import com.interview.weather.dto.WeatherDTO;
import com.interview.weather.utils.HttpUtils;
import com.interview.weather.utils.WeatherUtil;
@Service
public class WeatherServiceImpl implements WeatherService{
private static final Logger logger = LoggerFactory.getLogger(WeatherServiceImpl.class);
@Autowired
private RestTemplate restTemplate;
@Value("${weather.api.url}")
private String WEATHER_API_URL;
@Value("${weather.api_key}")
private String WEATHER_API_KEY;
private static final String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
public List<WeatherDTO> getWeatherDetails(String zipCode) {
// TODO Auto-generated method stub
String forecast_weather_url = WEATHER_API_URL+"?zip="+zipCode+",us&appid="+WEATHER_API_KEY+"";
SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
formatter.setTimeZone(TimeZone.getTimeZone("PST"));
List<WeatherDTO> list = new ArrayList<WeatherDTO>();
try {
// To limit the connections we can store the response in databse by zipcode reference and
// pre check date base for sub sequent calls.
JSONObject apiResp = HttpUtils.getConnetion(forecast_weather_url);
System.out.println(apiResp);
JSONArray arr = apiResp.getJSONArray("list");
for(int i=0;i<24;i++){ //based on the client selection we can change the value
WeatherDTO weatherDTO = new WeatherDTO();
JSONObject obj = arr.getJSONObject(i);
JSONObject mainObject = obj.getJSONObject("main");
String date_txt = obj.getString("dt_txt");
Date date = formatter.parse(date_txt);
Calendar cal = new GregorianCalendar();
cal.setTime(date);
System.out.println(date);
Double minTemp = mainObject.getDouble("temp_min");
Double maxTemp = mainObject.getDouble("temp_max");
Temperature temperatureF = new Temperature();
temperatureF.setMaxValue(WeatherUtil.convertTemp(maxTemp,'F'));
temperatureF.setMinValue(WeatherUtil.convertTemp(minTemp,'F'));
temperatureF.setScales('F');
Temperature temperatureC = new Temperature();
temperatureC.setMaxValue(WeatherUtil.convertTemp(maxTemp,'C'));
temperatureC.setMinValue(WeatherUtil.convertTemp(minTemp,'C'));
temperatureC.setScales('C');
weatherDTO.setTemperatureC(temperatureC);
weatherDTO.setTemperatureF(temperatureF);
weatherDTO.setTime(cal.get(Calendar.HOUR)+" "+WeatherUtil.getAMPM(cal.get(Calendar.AM_PM)));
list.add(weatherDTO);
}
} catch (Exception e) {
logger.error("Erro on Weather service implemetation ",e);
}
return list;
}
public List<WeatherDTO> getWeatherDetails1(String zipCode) {
// TODO Auto-generated method stub
String forecast_weather_url = WEATHER_API_URL+"?zip="+zipCode+",us&appid="+WEATHER_API_KEY+"";
SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
formatter.setTimeZone(TimeZone.getTimeZone("PST"));
List<WeatherDTO> list = new ArrayList<WeatherDTO>();
try {
// To limit the connections we can store the response in databse by zipcode reference and
// pre check date base for sub sequent calls.
WeatherAPIRespBO apiResp = restTemplate.getForObject(forecast_weather_url, WeatherAPIRespBO.class);
List<WeatherBO> arr = apiResp.getWeatherList();
for(int i=0;i<24;i++){ //based on the client selection we can change the value
WeatherDTO weatherDTO = new WeatherDTO();
WeatherBO weatherBO = arr.get(i);
String date_txt = weatherBO.getDt_txt();
Date date = formatter.parse(date_txt);
Calendar cal = new GregorianCalendar();
cal.setTime(date);
TemperatureBO temp = weatherBO.getMain();
Double minTemp = temp.getTemp_min();
Double maxTemp = temp.getTemp_max();
Temperature temperatureF = new Temperature();
temperatureF.setMaxValue(WeatherUtil.convertTemp(maxTemp,'F'));
temperatureF.setMinValue(WeatherUtil.convertTemp(minTemp,'F'));
temperatureF.setScales('F');
Temperature temperatureC = new Temperature();
temperatureC.setMaxValue(WeatherUtil.convertTemp(maxTemp,'C'));
temperatureC.setMinValue(WeatherUtil.convertTemp(minTemp,'C'));
temperatureC.setScales('C');
weatherDTO.setTemperatureC(temperatureC);
weatherDTO.setTemperatureF(temperatureF);
weatherDTO.setTime(cal.get(Calendar.HOUR)+" "+WeatherUtil.getAMPM(cal.get(Calendar.AM_PM)));
list.add(weatherDTO);
}
} catch (Exception e) {
logger.error("Erro on Weather service implemetation ",e);
}
return list;
}
}
| [
"[email protected]"
]
| |
2194068ae4b2b96074a29025be9498a0ff64cf85 | 0115368c9b9fc5741062bb115850a389bcf7abc8 | /core/trunk/utils/src/main/java/org/apache/myfaces/jtracc/renderkit/html/util/TableContext.java | ff17cbe9f0f9e8900a57ee77a67d1ab4f54c996b | []
| no_license | os890/jtracc | 879f645af9dcdea0941f45e9fbcf8e2b4cee7fd1 | 1df537337d7ace6a61f1454cf5ae1c34d1cfd8e4 | refs/heads/master | 2020-04-25T23:27:31.140301 | 2007-08-08T18:48:38 | 2007-08-08T18:48:38 | 37,475,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,207 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.myfaces.jtracc.renderkit.html.util;
import java.util.List;
import java.util.ArrayList;
/**
* @author Ernst Fastl
*/
public class TableContext
{
private List _rowInfos;
public List getRowInfos()
{
if ( _rowInfos == null )
{
_rowInfos = new ArrayList();
}
return _rowInfos;
}
}
| [
"thomas.spiegl@2f68b751-142f-0410-b4aa-05b97da1c307"
]
| thomas.spiegl@2f68b751-142f-0410-b4aa-05b97da1c307 |
60ebea2ffdcd5c862a5ab87d3de72661657b08bc | 07d63591ffd9982217d1bac899cf24abcdd580ef | /app/src/main/java/com/hokagelab/www/yodu/MainActivity.java | 9061ba312069507e2f743a7c23c99d60eb93c1a7 | []
| no_license | yayanberutu/betamarsiajar | 47c1bba164b8fa3856dd810f775143c374cc971f | f9ec89552c96822ecd77832365fdf6c4d69e1f41 | refs/heads/master | 2022-06-13T20:31:45.721344 | 2020-05-10T10:26:54 | 2020-05-10T10:26:54 | 262,761,869 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,591 | java | package com.hokagelab.www.yodu;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;
import com.hokagelab.www.yodu.activity.DosenActivity;
import com.hokagelab.www.yodu.activity.LoginActivity;
import com.hokagelab.www.yodu.activity.MainActivity1;
import com.hokagelab.www.yodu.activity.MatkulActivity;
import com.hokagelab.www.yodu.util.SharedPrefManager;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity {
private CardView alpha, angka, bentuk, hewan, buah, warna, membaca, menghitung, lagu, teman;
@BindView(R.id.tvResultNama)
TextView tvResultNama;
@BindView(R.id.btnLogout)
Button btnLogout;
SharedPrefManager sharedPrefManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
sharedPrefManager = new SharedPrefManager(this);
tvResultNama.setText(sharedPrefManager.getSPNama());
btnLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sharedPrefManager.saveSPBoolean(SharedPrefManager.SP_SUDAH_LOGIN, false);
startActivity(new Intent(MainActivity.this, LoginActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
finish();
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
alpha = (CardView) findViewById(R.id.alphabet);
angka = (CardView) findViewById(R.id.angka);
bentuk = (CardView) findViewById(R.id.bentuk);
hewan = (CardView) findViewById(R.id.hewan);
buah = (CardView) findViewById(R.id.buah);
warna = (CardView) findViewById(R.id.warna);
membaca = (CardView) findViewById(R.id.membaca);
menghitung = (CardView) findViewById(R.id.menghitung);
lagu = (CardView) findViewById (R.id.lagu);
teman = (CardView) findViewById(R.id.teman);
alpha.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, alphabet.class));
}
});
angka.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, angka.class));
}
});
bentuk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, bentuk.class));
}
});
hewan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, hewan.class));
}
});
buah.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, buah.class));
}
});
warna.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, warna.class));
}
});
membaca.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, MatkulActivity.class));
}
});
menghitung.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, menghitung.class));
}
});
lagu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, DosenActivity.class));
}
});
teman.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, MainActivity2.class));
}
});
setSupportActionBar(toolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
startActivity(new Intent(MainActivity.this, About.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"="
]
| = |
98e6538e71702bcaca717de3a619eeb238c9c5f0 | 4fd869f28a30a4259fc07ce7eb54d21ac5ae25bd | /src/com/kh/hp/myPage/controller/WithdrawalServlet.java | 610b0ea381a694f3b3dfbdaf3cbdf17097c3378e | []
| no_license | minheeha/semi-project | ced20c91f802927340e96b4b1735a7134995cd1d | 94003e5e9c5ea0f5f97dfb4674edbc67ace5e687 | refs/heads/master | 2020-07-15T22:56:41.133020 | 2019-08-06T18:13:04 | 2019-08-06T18:13:04 | 205,666,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,883 | java | package com.kh.hp.myPage.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.kh.hp.myPage.model.service.MyPageService_mh;
import com.kh.hp.myPage.model.vo.MyPageUserVO;
/**
* Servlet implementation class WithdrawalServlet
*/
@WebServlet("/withdrawal.mp")
public class WithdrawalServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public WithdrawalServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("탈퇴하기 페이지 들어옴!!!");
int userSeq = ((com.kh.hp.account.model.vo.UserVO) request.getSession().getAttribute("user")).getUserSeq();
MyPageUserVO mypageInfo = new MyPageService_mh().selectMyPageInfo(userSeq);
String page = "";
if(mypageInfo != null) {
page = "views/myPage/withdrawal.jsp";
request.setAttribute("mypageInfo", mypageInfo);
} else {
page = "views/common/errorPage.jsp";
request.setAttribute("msg", "서비스 탈퇴하기 호출 실패!");
}
request.getRequestDispatcher(page).forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"minhee@DESKTOP-NN94ADH"
]
| minhee@DESKTOP-NN94ADH |
53f7dee4c85fe5c3c2219c64db1a0b81e0f9e73f | 8bc5044b479141720d05434407d7efb9515ea99b | /easy/PalindromeNumber_20181008.java | abb136c966e671a3e5ebe68a3e6d49a3cb2cc39d | []
| no_license | RebeccaFeng/LeetcodePractice | 09c9d08485aea5993a22abce714af040e2ed5d3a | 514066ece58190a7845d381dbe8215a4e1eaf5ea | refs/heads/master | 2020-04-01T14:49:26.149971 | 2018-10-16T15:51:24 | 2018-10-16T15:51:24 | 153,309,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 895 | java | /**
* @author fengyuan
* problem:
* Determine whether an integer is a palindrome.
* An integer is a palindrome when it reads the same backward as forward.
* solution:
* Revert half of the number;
*/
package easy;
import java.util.ArrayList;
import java.util.List;
public class PalindromeNumber_20181008 {
public boolean isPalindrome(int x) {
if(x < 0)
return false;
List l = new ArrayList();
int count = 0;
while(x != 0) {
l.add(x%10);
x /= 10;
count++;
}
for(int i = 0; i < count; i++) {
System.out.println(l.get(i) + " " + i);
}
for(int i = 0; i < count/2; i++) {
if(l.get(i) != l.get(count - i - 1)) {
return false;
}
}
return true;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(new PalindromeNumber_20181008().isPalindrome(10));
}
}
| [
"[email protected]"
]
| |
36b79919cb7c39e07091278d03528956aa43c04e | 8f258098a8273f66703efb25da76c9bed3051325 | /app/src/main/java/com/alex/banner/verical/MainActivity.java | e849191de4da39ae26edff300d5fe45dd5f58ae2 | []
| no_license | alexchenopen/VerticalTipsBanner | a92c4e2fb998f449861cc4b58db72753d14f592a | a78249e18e908ee16c5e6ac82f8c4560f35b3315 | refs/heads/master | 2022-12-03T20:00:38.972636 | 2020-08-13T02:22:01 | 2020-08-13T02:22:01 | 111,679,937 | 11 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,807 | java | package com.alex.banner.verical;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.alex.widget.banner.tips.TipsBanner;
import com.alex.widget.banner.tips.listener.OnBottomTipsClickListener;
import com.alex.widget.banner.tips.listener.OnTopTipsClickListener;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity.class";
private TipsBanner tipsBanner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tipsBanner = (TipsBanner) findViewById(R.id.banner);
tipsBanner.setDelayTime(3000)
.setScrollTime(4000)
.setAutoPlay(true)
.setScroll(false);
List<String> tipsList = new ArrayList<>();
tipsList.add("贵州茅台接连出现折价大宗交易");
tipsList.add("创纪录!恒指刚刚突破三万点!");
tipsList.add("大众领先合资SUV集体下探");
tipsList.add("基金辣评 | 大象起舞");
tipsList.add("沪深百元股阵营扩编 达到23只");
tipsBanner.setTipsList(tipsList);
tipsBanner.start();
tipsBanner.setOnTopTipsClickListener(new OnTopTipsClickListener() {
@Override
public void OnTopTipsClick(int position) {
Log.d(TAG, "点击" + position);
}
});
tipsBanner.setOnBottomTipsClickListener(new OnBottomTipsClickListener() {
@Override
public void OnBottomTipsClick(int position) {
Log.d(TAG, "点击" + position);
}
});
}
}
| [
"[email protected]"
]
| |
5041d30427e8856b58833964ef2eb03666238ccb | cfd150c541b20c8673b41f9064e7635e5d0dc421 | /app/src/main/java/com/zzcar/zzc/utils/Utils.java | 391af5ef893e34551ccf122dab2987e06778bcbb | []
| no_license | ruhui/ZZC | 4423b9aecd0b6d9e6aadf3972b1342192495c3a4 | 5a605ee498640fba92fed9c6281c47bed05df3de | refs/heads/master | 2021-01-19T23:49:10.969284 | 2017-08-16T11:37:04 | 2017-08-16T11:37:04 | 89,010,031 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,148 | java | package com.zzcar.zzc.utils;
import android.content.Context;
import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 关于时间和数字的一些工具方法
*/
public class Utils {
static final String LOG_TAG = "PullToRefresh";
public static void warnDeprecation(String depreacted, String replacement) {
Log.w(LOG_TAG, "You're using the deprecated " + depreacted + " attr, please switch over to " + replacement);
}
public static int dip2px(Context context, float dipValue) {
float scale = context.getResources().getDisplayMetrics().density;
return (int) (dipValue * scale + 0.5f);
}
public static int px2dip(Context context, float pxValue) {
float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
/*
* 将时间转换为时间戳
*/
public static String date2TimeStamp(String date_str,String format){
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(date_str).getTime()/1000);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/*
* 将时间戳转换为时间
*/
public static String stampToDate(String s){
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
long lt = new Long(s);
long lcc_time = Long.valueOf(lt);
res = simpleDateFormat.format(new Date(lcc_time * 1000L));
return res;
}
/**
* 获取当前时间戳
*/
public static int getTimestamp(Date date){
String timestamp = String.valueOf(date.getTime());
int length = timestamp.length();
if (length > 3) {
return Integer.valueOf(timestamp.substring(0,length-3));
} else {
return 0;
}
}
/**
* 获取16位随机数
*/
public static String getStringRandom(int length) {
String val = "";
Random random = new Random();
//参数length,表示生成几位随机数
for(int i = 0; i < length; i++) {
String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
//输出字母还是数字
if( "char".equalsIgnoreCase(charOrNum) ) {
//输出是大写字母还是小写字母
int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
val += (char)(random.nextInt(26) + temp);
} else if( "num".equalsIgnoreCase(charOrNum) ) {
val += String.valueOf(random.nextInt(10));
}
}
return val;
}
/**
* 获取当前时间精确到毫秒
*/
public static String getMillSecond(){
return new SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date() );
}
/**
* 获取设备ID,此处为自己生成的
* 用户按装app时生成的随机串 格式如下
* 年份+日期+时间(精确到毫秒)+15位随机字符串
*/
public static String getDeviceId(){
return getMillSecond() + getStringRandom(15);
}
// 校验Tag Alias 只能是数字,英文字母和中文
public static boolean isValidTagAndAlias(String s) {
Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
Matcher m = p.matcher(s);
return m.matches();
}
}
| [
"[email protected]"
]
| |
08ff677853d8e1063e4a1c36c8d9af3610945aae | 6955ff2ae0ba412f2ecdabbd40f49a2190e6ac82 | /RestFulWS/src/com/reparo/post/restfulWS/client/NetClientPost.java | 8c0faa72b55aab71bddb2bf27703c3ac404c793a | []
| no_license | neeraj2027/RestWS | 89b79c1573f7836dd611da2550e16f471679bd5b | 9b6d76d9c9780776c2c126f32d7c44d15afeb06d | refs/heads/master | 2021-06-26T07:49:59.463539 | 2017-09-15T15:32:38 | 2017-09-15T15:32:38 | 103,571,705 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,665 | java | package com.reparo.post.restfulWS.client;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.bind.JAXB;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import com.reparo.restfulWS.User;
public class NetClientPost {
// http://localhost:8080/RESTfulExample/json/product/post
public static void main(String[] args) {
callPostMethod();
callGetMethod();
}
private static void callGetMethod() {
URL url;
try {
url = new URL("http://localhost:9090/RestFulWS/rest/UserService/user");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/xml");
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String apiOutput = br.readLine();
//System.out.println(apiOutput);
conn.disconnect();
User dd = JAXB.unmarshal(new StringReader(apiOutput), User.class);
/*JAXBContext jaxbContext = JAXBContext.newInstance(User.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
User users = (User) jaxbUnmarshaller.unmarshal(new StringReader(apiOutput));*/
System.out.println(conn.getResponseCode());
System.out.println(dd.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void callPostMethod() {
try {
URL url = new URL("http://localhost:9090/RestFulWS/rest/UserService/postJSON");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/xml");
User user = new User(1, "neeraj", "hello");
String xmlString = jaxbObjectToXML(user);
OutputStream os = conn.getOutputStream();
os.write(xmlString.getBytes());
os.flush();
/*
* if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) { throw new
* RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); }
*/
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/* A convenient option is to use javax.xml.bind.JAXB:
StringWriter sw = new StringWriter();
JAXB.marshal(customer, sw);
String xmlString = sw.toString();
The reverse process (unmarshal) would be:
Customer customer = JAXB.unmarshal(new StringReader(xmlString), Customer.class);*/
private static String jaxbObjectToXML(User customer) {
String xmlString = "";
try {
JAXBContext context = JAXBContext.newInstance(User.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // To format XML
StringWriter sw = new StringWriter();
m.marshal(customer, sw);
xmlString = sw.toString();
} catch (JAXBException e) {
e.printStackTrace();
}
return xmlString;
}
} | [
"Neeraj@SNSLI-050"
]
| Neeraj@SNSLI-050 |
5a440defe9b25712a9f4ddf6370e1d23f624f0f5 | 730ee8b45d3480ad69fc515d3801db51f3801d06 | /src/main/java/com/ExtenReport/ExtentReportBase.java | 5cfbe2597b1da23c6778fe5ccb607fbb5d89d6c4 | []
| no_license | gauravgupta2706/JD_OrangeHRM_Maven | 4056fd0b6d980ad48d2b97084dffc132b75fd61e | 9c207cf2ec741956d6701da3d7c3ae0f99e7667a | refs/heads/master | 2023-03-12T18:54:32.713674 | 2021-03-03T07:21:38 | 2021-03-03T07:21:38 | 344,007,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 832 | java | package com.ExtenReport;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import com.aventstack.extentreports.reporter.configuration.Theme;
public class ExtentReportBase {
static ExtentReports extent;
static ExtentSparkReporter reporter;
public static ExtentReports ExtentReportGenerator(){
reporter = new ExtentSparkReporter("./ExtentReport/SingleReport.html");
extent = new ExtentReports();
extent.attachReporter(reporter);
extent.setSystemInfo("OS", System.getProperty("os.name"));
extent.setSystemInfo("Browser", "Chrome");
reporter.config().setDocumentTitle("Consolidate ExtentReport Result");
reporter.config().setTheme(Theme.DARK);
reporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");
return extent;
}
}
| [
"[email protected]"
]
| |
d7be0c0f95a1ae8960b9363cb2d78e30283b37a8 | 8786168431ca25ec607c583da8e74bf05fcb1111 | /src/main/java/week3/day1/SmartPhone.java | d7e295e9176db02aa91a52d0c7c268270106928b | []
| no_license | suracebabu/SeleniumTestLeafCourse | a6a365dd1b52de8cac1587e954b91f5f72720b57 | d98ad8ee220f740c4da3a548c0289a26f63401f9 | refs/heads/master | 2023-08-28T06:35:35.646913 | 2021-10-05T20:51:57 | 2021-10-05T20:51:57 | 366,214,650 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 304 | java | package week3.day1;
public class SmartPhone extends AndriodPhone {
public void takeVideo() {
System.out.println("The method is used to takeVideo from SmartPhone class");
}
public void connectWhatsapp() {
System.out.println("The method is used to connectWhatsapp");
}
}
| [
"[email protected]"
]
| |
00932712265709890873efbf5d0842373b1e395d | 90780a3a61f8d62f64aa45ab6e6e2d769945e772 | /src/main/java/com/example/mail/service/UserService.java | 7d714b9af7de6567afc98bafd1b4543b270c4191 | []
| no_license | XHHuiL/MailDemo | 350dd41cdb2841732765df12cdf59c7d0bd11f01 | ee9a60361d285445b23930b87e62621f6ba0c105 | refs/heads/master | 2020-06-13T21:22:31.707843 | 2019-07-03T10:41:08 | 2019-07-03T10:41:08 | 194,791,724 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 176 | java | package com.example.mail.service;
public interface UserService {
boolean register(String username, String password, String email);
boolean activate(String code);
}
| [
"[email protected]"
]
| |
362928661d28c858862a57a17c6f54ad6d39ee31 | 41ba29c2bd4d6a13dd577d01facf0dff17991acf | /kates-atm-service-api/src/main/java/CardResponse.java | 769e069e0ab79a72b57d8bfb28f5929df5e3f6c2 | []
| no_license | KateGH/kates-atm-service | f657c6cefbdb5b250b4a7634c1a96fee50ada8f5 | 031523f516a581d45372568131510b2f7ed4fa48 | refs/heads/master | 2021-01-21T19:50:49.645654 | 2017-05-23T12:41:26 | 2017-05-23T12:41:26 | 92,161,273 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 634 | java | import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property = "class")
@JsonSubTypes({
@JsonSubTypes.Type(value = CreditCardResponse.class, name = "CreditCardResponse"),
@JsonSubTypes.Type(value = DebitCardResponse.class, name = "DebitCardResponse"),
})
public abstract class CardResponse extends TransportObject {
@JsonProperty("card")
public Card card;
}
| [
"[email protected]"
]
| |
a1f178ee468e1a62a04fb1e97108974f649cd378 | f6107624273145c172b45595a71ab21fd684a56e | /chapter_004/src/main/java/ru/job4j/collectionpro/list/Cycle.java | b1dfcfb084fc84f78a1a7226d72ab204b299f6f2 | [
"Apache-2.0"
]
| permissive | terrasan111/eshegay | 8367c44087d7643ce06f1ff3d1629664da30bfb2 | c5dfd5de27f4cce34dcc0d853b82c2640f7ba1fb | refs/heads/master | 2021-04-30T10:28:39.259121 | 2018-06-09T04:01:30 | 2018-06-09T04:01:30 | 121,334,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,545 | java | package ru.job4j.collectionpro.list;
/**
* Created by Evgeniy on 25.03.2018.
*/
public class Cycle<T> {
private int size = 0;
private Node<T> first;
public Node<T> getFirst() {
return first;
}
public void add(Object value) {
if (first == null) {
this.first = new Node(value);
} else {
Node temp = first;
while (temp.getNext() != null) {
temp = temp.getNext();
}
temp.setValue(new Node(value));
size++;
}
}
public T get(int index) {
Node<T> temp = first.getNext();
for (int i = 0; i < index; i++) {
temp = getNextElement(temp);
}
return temp.getValue();
}
private Node<T> getNextElement(Node<T> value) {
return value.getNext();
}
private class Node<T> {
T value;
Node<T> next;
public Node(T value) {
this.value = value;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
public Node<T> getNext() {
return next;
}
}
boolean hasCycle(Node first) {
Node tort = first;
Node hare = first.next;
while (true) {
if (tort.next == null) {
break;
}
if (tort == hare) {
return true;
}
tort = tort.next;
hare = hare.next.next;
}
return false;
}
}
| [
"[email protected]"
]
| |
c6a854b2d3e9c8ecdd9e0e14efe35b7886f76394 | e1cfc0c790fd322c02c80fdfd92fc9ccad5c141f | /src/main/java/com/arkandos/braincore/utility/compatibility/MekanismHandler.java | 61596381ce5d232b9ec65ff2a96e5b073cd55b09 | []
| no_license | Arkandos/BrainCore | 3d3b333df730bf4cf728a87bdfc37ea456b0bcc5 | 8a09a770ad99232df5205ac6d7ad3ac7298b20ad | refs/heads/master | 2021-01-18T14:57:56.923213 | 2015-01-20T13:42:20 | 2015-01-20T13:42:20 | 23,116,151 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,667 | java | package com.arkandos.braincore.utility.compatibility;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import mekanism.api.ChanceOutput;
import mekanism.api.RecipeHelper;
import mekanism.common.recipe.RecipeHandler;
import net.minecraft.item.ItemStack;
public class MekanismHandler
{
public static final String NAME = "Mekanism";
private static boolean isModLoaded = false;
public static ItemStack biofuel;
public static String getName()
{
return NAME;
}
public static boolean isLoaded()
{
return isModLoaded;
}
public static void preInit()
{
if (Loader.isModLoaded(NAME))
{
isModLoaded = true;
}
}
public static void init()
{
if (isLoaded())
{
getBlocks();
getItems();
}
}
public static void postInit()
{
if (isLoaded())
{
}
}
public static void getBlocks()
{
}
public static void getItems()
{
biofuel = GameRegistry.findItemStack(NAME, "BioFuel", 1);
}
public static void registerEnrichmentChamberRecipe(ItemStack input, ItemStack output)
{
if (isLoaded())
{
RecipeHandler.addEnrichmentChamberRecipe(input, output);
}
}
public static void registerOsmiumCompressorRecipe(ItemStack input, ItemStack output)
{
if (isLoaded())
{
RecipeHelper.addOsmiumCompressorRecipe(input, output);
}
}
public static void registerCombinerRecipe(ItemStack input, ItemStack output)
{
if (isLoaded())
{
RecipeHelper.addCombinerRecipe(input, output);
}
}
public static void registerCrusherRecipe(ItemStack input, ItemStack output)
{
if (isLoaded())
{
RecipeHelper.addCrusherRecipe(input, output);
}
}
public static void registerPurificationChamberRecipe(ItemStack input, ItemStack output)
{
if (isLoaded())
{
RecipeHelper.addPurificationChamberRecipe(input, output);
}
}
public static void registerPrecisionSawmillRecipe(ItemStack input, ChanceOutput output)
{
if (isLoaded())
{
RecipeHelper.addPrecisionSawmillRecipe(input, output);
}
}
public static void registerBiofuelRecipe(ItemStack input, int fuelAmount)
{
if (isLoaded() && fuelAmount > 0)
{
ItemStack b = biofuel.copy();
b.stackSize = fuelAmount;
registerCrusherRecipe(input, b);
}
}
}
| [
"[email protected]"
]
| |
4e0095d7aef24cf7b86d46cc67370b61795b4e0a | 18a7651cd5793e8ffdfe517f45b53b6c11d8156d | /ThiTracNghiem_Client/src/ui/AboutMe.java | 129ab91ef3a91240ae2c33817378770d03ad2b36 | []
| no_license | hungdh0x5e/Test-Quiz-Client-Server | c2a3140433ee5d5c426d769e49a5139167e5e30a | a04955c436f4aa653f2be640cba85f0598258579 | refs/heads/master | 2021-01-19T13:02:14.424079 | 2015-07-13T16:26:12 | 2015-07-13T16:26:12 | 39,016,281 | 0 | 1 | null | 2015-07-13T16:26:13 | 2015-07-13T14:14:48 | Java | UTF-8 | Java | false | false | 7,830 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ui;
/**
*
* @author Anonymous
*/
public class AboutMe extends javax.swing.JFrame {
/**
* Creates new form AboutMe
*/
public AboutMe() {
initComponents();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(240, 49, 130));
setResizable(false);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 0, 0));
jLabel1.setText("INFORMATION");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 0, 255));
jLabel2.setText("Product Name: Thi Trắc Nghiệm Online");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 0, 204));
jLabel3.setText("Create by: Nhóm 1 - AT9B");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel4.setForeground(new java.awt.Color(0, 0, 204));
jLabel4.setText("Member: Huy Hùng, Việt Hưng, Mạnh Duy");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel5.setForeground(new java.awt.Color(0, 0, 204));
jLabel5.setText("Contact: [email protected]");
jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setForeground(new java.awt.Color(255, 0, 0));
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel7.setForeground(new java.awt.Color(0, 0, 204));
jLabel7.setText("Thành Đạt, Doãn Mạnh, Văn Dũng");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(36, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel5))
.addGap(36, 36, 36))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(27, 27, 27))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(123, 123, 123)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(151, 151, 151)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(13, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @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(AboutMe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AboutMe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AboutMe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AboutMe.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 AboutMe().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel7;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
]
| |
3357c13e7983d3a7b9c3d273f8c40075c4d65ab9 | 6800cd3a9d335d25e4fe5dcfb4217c07c61e4d40 | /JavaCourse/PerfectNumber/src/PerfectNumber.java | 376ad03fce6208f1fd972a3c3db15ee50f4065f6 | []
| no_license | jurek21211/courses | e02fea62f9f502922d06a2dac6383c69a6f35714 | 754ae03cb8ef96935e9b1304738d85e0b6f9732a | refs/heads/master | 2022-06-20T03:36:13.538982 | 2020-05-06T08:04:24 | 2020-05-06T08:04:24 | 261,690,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 341 | java | public class PerfectNumber {
public static boolean isPerfectNumber(int number) {
if (number < 1)
return false;
int sumOfFactors = 0;
for (int i = 1; i <= number / 2; i++) {
if(number % i == 0)
sumOfFactors += i;
}
return sumOfFactors == number;
}
}
| [
"[email protected]"
]
| |
c86d1801c55edaef4e4c89f70e16da275d5171a8 | f4823b8eb0fffa3c471cfb7e4f136c894dc3e047 | /Sublists106B.java | 78f759a79bd76acd5946f7926f963e7558a10a2e | []
| no_license | puneet1024/Leetcode-Java | 2480ee524bb7832122bd8af40adc1987b779a575 | 49fa35bad875ed461f466ced47570bf94ab13078 | refs/heads/master | 2020-05-07T15:57:05.600849 | 2019-06-12T21:31:35 | 2019-06-12T21:31:35 | 180,660,926 | 0 | 0 | null | 2019-06-12T21:31:37 | 2019-04-10T20:43:11 | Java | UTF-8 | Java | false | false | 1,366 | java | import java.util.ArrayList;
import java.util.List;
public class Sublists106B {
private void sublists(List<String> str) {
ArrayList<ArrayList<String>> res = new ArrayList<>();
ArrayList<String> chosen = new ArrayList<>();
sublistsHelper(str, chosen,res);
System.out.println(res);
}
private void sublistsHelper(List<String> str, List<String> chosen, ArrayList<ArrayList<String>> res){
if(str.isEmpty()) {
//base case
res.add(new ArrayList<>(chosen));
// System.out.println(new ArrayList<>(chosen));
} else {
//recursive case
// for each possible choice :
String s = str.get(0);
str.remove(0);
//choose/ explore without s
sublistsHelper(str,chosen,res);
System.out.println("chosen " + chosen);
//choose/ explore with s
chosen.add(s);
sublistsHelper(str,chosen,res);
// -unchoose
str.add(0,s);
chosen.remove(chosen.size()-1);
}
}
public static void main(String[] args) {
Sublists106B sb = new Sublists106B();
List<String> arr = new ArrayList<>();
arr.add("Jane");
arr.add("Marty");
arr.add("Bob");
arr.add("Chotu");
sb.sublists(arr);
}
}
| [
"[email protected]"
]
| |
393ab19fc2635ad985d298c3f55056fba8e40a0a | 46e5264f05af55648cf254ae29f4a5ab2f118793 | /src/main/java/com/eryansky/modules/sys/service/ISerialNumService.java | 02cccec66da1079ab8e157ba6070862b1f76394f | []
| no_license | liyr752497331/essm-1 | 5710c7f840d4bfd38a9d01cd8bbf2041602599b7 | 1e1ceaf75ca896e9df07f1a0001102ba0893ff46 | refs/heads/master | 2020-03-19T05:41:47.953286 | 2018-06-01T08:01:30 | 2018-06-01T08:01:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 962 | java | package com.eryansky.modules.sys.service;
import com.eryansky.modules.sys.mapper.SystemSerialNumber;
/**
* 序列号service接口
* @author 温春平@wencp [email protected]
* @date 2016-07-14
*/
public interface ISerialNumService {
SystemSerialNumber find(SystemSerialNumber systemSerialNumber);
String generateSerialNumberByModelCode(String moduleCode);
/**
* 设置最小值
* @param value 最小值,要求:大于等于零
* @return 流水号生成器实例
*/
ISerialNumService setMin(int value);
/**
* 设置最大值
* @param value 最大值,要求:小于等于Long.MAX_VALUE ( 9223372036854775807 )
* @return 流水号生成器实例
*/
ISerialNumService setMax(long value);
/**
* 设置预生成流水号数量
* @param count 预生成数量
* @return 流水号生成器实例
*/
ISerialNumService setPrepare(int count);
} | [
"[email protected]"
]
| |
5ecc53a4f88a79545d1da587d19ad92514574313 | 82a820fc263415afa6681fe2a69f398e0369e8d3 | /src/org/jgentleframework/reflection/FieldIdentificationImpl.java | 982fb94421715a0140ee4c902c5cff0d8e03323e | [
"Apache-2.0"
]
| permissive | haint/jgentle | 8b8e05909f91c6187149e9f7b5ea176eed6cbea2 | 898ba402808763637b358f7a3be334de17a5a926 | refs/heads/master | 2020-06-01T10:51:18.765246 | 2011-06-09T08:40:43 | 2011-06-09T08:40:43 | 1,869,753 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,614 | java | /*
* Copyright 2007-2009 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.
*
* Project: JGentleFramework
*/
package org.jgentleframework.reflection;
import java.lang.reflect.Field;
import java.util.ArrayList;
import org.jgentleframework.utils.ReflectUtils;
/**
* This class implements the {@link FieldIdentification} interface, specify a
* field or a set of fields corresponding to declaring class and one regular
* expression of name.
*
* @author LE QUOC CHUNG - mailto: <a
* href="mailto:[email protected]">[email protected]</a>
* @date Jul 21, 2008
* @see MemberIdentification
* @see MethodIdentification
* @see SingleClassIdentification
*/
class FieldIdentificationImpl implements FieldIdentification {
/** The name. */
String name = null;
/** The declaring class. */
Class<?> declaringClass = null;
/** The found on superclass. */
boolean foundOnSuperclass = false;
/** The modifiers. */
int modifiers = Identification.NO_MODIFIERS;
/**
* Constructor.
*/
public FieldIdentificationImpl() {
}
/**
* Constructor.
*
* @param name
* the name of member.
*/
public FieldIdentificationImpl(String name) {
this.name = name;
}
/**
* Constructor.
*
* @param name
* the name of member.
* @param foundOnSuperclass
* the foundOnSuperclass boolean
*/
public FieldIdentificationImpl(String name, boolean foundOnSuperclass) {
this.name = name;
this.foundOnSuperclass = foundOnSuperclass;
}
/**
* The Constructor.
*
* @param name
* the name of member.
* @param foundOnSuperclass
* the foundOnSuperclass boolean
* @param modifiers
* the modifiers
*/
public FieldIdentificationImpl(String name, boolean foundOnSuperclass,
int modifiers) {
this.name = name;
this.foundOnSuperclass = foundOnSuperclass;
this.modifiers = modifiers;
}
/**
* Constructor.
*
* @param name
* the name of member.
* @param declaringClass
* the declaring class
* @param foundOnSuperclass
* the foundOnSuperclass boolean
* @param modifiers
* the modifiers
*/
public FieldIdentificationImpl(String name, Class<?> declaringClass,
boolean foundOnSuperclass, int modifiers) {
this.name = name;
this.declaringClass = declaringClass;
this.foundOnSuperclass = foundOnSuperclass;
this.modifiers = modifiers;
}
/*
* (non-Javadoc)
* @see
* org.jgentleframework.general.reflection.FieldIdentification#getModifiers
* ()
*/
@Override
public int getModifiers() {
return modifiers;
}
/*
* (non-Javadoc)
* @see
* org.jgentleframework.general.reflection.MemberIdentification#setModifiers
* (int)
*/
@Override
public void setModifiers(int modifiers) {
this.modifiers = modifiers;
}
/*
* (non-Javadoc)
* @see
* org.jgentleframework.general.reflection.FieldIdentification#getName()
*/
@Override
public String getName() {
return name;
}
/*
* (non-Javadoc)
* @see
* org.jgentleframework.general.reflection.Identification#setName(java.lang
* .String)
*/
@Override
public void setName(String name) {
this.name = name;
}
/*
* (non-Javadoc)
* @see
* org.jgentleframework.general.reflection.FieldIdentification#getDeclaringClass
* ()
*/
@Override
public Class<?> getDeclaringClass() {
return declaringClass;
}
/*
* (non-Javadoc)
* @seeorg.jgentleframework.general.reflection.MemberIdentification#
* setDeclaringClass(java.lang.Class)
*/
@Override
public void setDeclaringClass(Class<?> declaringClass) {
this.declaringClass = declaringClass;
}
/*
* (non-Javadoc)
* @see org.jgentleframework.general.reflection.Identification#getMember()
*/
@Override
public Field[] getMember() {
if (this.name == null || this.name.isEmpty()
|| this.declaringClass == null) {
throw new ReflectException(
"The identification data is not enough or invalid !");
}
Field[] lst = ReflectUtils.fields(this.name, this.declaringClass,
foundOnSuperclass);
ArrayList<Field> result = new ArrayList<Field>();
for (Field field : lst) {
if (this.modifiers != Identification.NO_MODIFIERS) {
if (field.getModifiers() == this.modifiers) {
result.add(field);
}
}
else
result.add(field);
}
return result.toArray(new Field[result.size()]);
}
/*
* (non-Javadoc)
* @seeorg.jgentleframework.general.reflection.MemberIdentification#
* setFoundOnSuperclass(boolean)
*/
@Override
public void setFoundOnSuperclass(boolean bool) {
this.foundOnSuperclass = bool;
}
/*
* (non-Javadoc)
* @seeorg.jgentleframework.general.reflection.FieldIdentification#
* isFoundOnSuperclass()
*/
@Override
public boolean isFoundOnSuperclass() {
return foundOnSuperclass;
}
}
| [
"Skydunkpro@a7ebbb46-954a-0410-af65-bbc69201c0ed"
]
| Skydunkpro@a7ebbb46-954a-0410-af65-bbc69201c0ed |
7027d661d3d2aab49fae8933bb6eb12920c4e54a | 8187af5870be93ca47f79274fbf682a673ccb5bf | /src/main/java/com/xtalk/server/xtalkserver/controller/Health.java | 1b8ed07ee30fcc9ec5e15496b624255f743b6705 | []
| no_license | zhangxin145/xtalk-server | fbe6a5c34ef6b4416b43f6378f6b393ea7902bb0 | 22d05cc1347808e58e067fe81fcbb6d345255295 | refs/heads/master | 2023-03-13T08:35:15.873200 | 2021-03-04T14:07:23 | 2021-03-04T14:07:23 | 343,725,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 619 | java | package com.xtalk.server.xtalkserver.controller;
import com.xtalk.server.xtalkserver.model.Response;
import com.xtalk.server.xtalkserver.repository.BaseRepository;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author xin.z
* @date 2021/1/20 4:08 下午
*/
@Api("健康检查")
@RestController
public class Health {
@GetMapping(value = "/check")
public Response<String> healthCheck() {
return Response.ok();
}
}
| [
"[email protected]"
]
| |
a8f82402414599d9cdf42e4f8c90aa93d4d922cf | 9252d058cac2763e231e3f52631943f081318e8f | /src/main/java/com/example/domain/Address.java | 146d8c85f8f1f4f64d2b1c772cc4debefe3a377f | []
| no_license | SunShibo/health | 446fa3c6045179742335fa0207a688cd0a3c2b90 | 5e29459050b087ba05503e19f2615997a958b9b5 | refs/heads/master | 2021-01-01T12:32:27.355897 | 2020-04-29T07:52:02 | 2020-04-29T07:52:02 | 239,280,879 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,085 | java | package com.example.domain;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* 患者地址
*/
@XmlRootElement(name = "PATAddress")
@XmlAccessorType(XmlAccessType.FIELD)
public class Address {
private Long id; //id
private Long patId;//患者id
@XmlElement(name = "PATAddressType")
private String PATAddressType;//地址类别代码
@XmlElement(name = "PATAddressDesc")
private String PATAddressDesc;//地址
@XmlElement(name = "PATHouseNum")
private String PATHouseNum;//地址-门牌号码
@XmlElement(name = "PATVillage")
private String PATVillage;//地址-村(街、路、弄等)
@XmlElement(name = "PATCountryside")
private String PATCountryside;//地址-乡(镇、街道办事处)
@XmlElement(name = "PATCountyCode")
private String PATCountyCode;//地址-县(区)代码
@XmlElement(name = "PATCountyDesc")
private String PATCountyDesc;//地址-县(区)描述
@XmlElement(name = "PATCityCode")
private String PATCityCode;//地址-市(地区)代码
@XmlElement(name = "PATCityDesc")
private String PATCityDesc;//地址-市(地区)代描述
@XmlElement(name = "PATProvinceCode")
private String PATProvinceCode;//地址-省(自治区、直辖市)代码
@XmlElement(name = "PATProvinceDesc")
private String PATProvinceDesc;//地址-省(自治区、直辖市)描述
@XmlElement(name = "PATPostalCode")
private String PATPostalCode;//地址邮政编码
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getPatId() {
return patId;
}
public void setPatId(Long patId) {
this.patId = patId;
}
public String getPATAddressType() {
return PATAddressType;
}
public void setPATAddressType(String PATAddressType) {
this.PATAddressType = PATAddressType;
}
public String getPATAddressDesc() {
return PATAddressDesc;
}
public void setPATAddressDesc(String PATAddressDesc) {
this.PATAddressDesc = PATAddressDesc;
}
public String getPATHouseNum() {
return PATHouseNum;
}
public void setPATHouseNum(String PATHouseNum) {
this.PATHouseNum = PATHouseNum;
}
public String getPATVillage() {
return PATVillage;
}
public void setPATVillage(String PATVillage) {
this.PATVillage = PATVillage;
}
public String getPATCountryside() {
return PATCountryside;
}
public void setPATCountryside(String PATCountryside) {
this.PATCountryside = PATCountryside;
}
public String getPATCountyCode() {
return PATCountyCode;
}
public void setPATCountyCode(String PATCountyCode) {
this.PATCountyCode = PATCountyCode;
}
public String getPATCountyDesc() {
return PATCountyDesc;
}
public void setPATCountyDesc(String PATCountyDesc) {
this.PATCountyDesc = PATCountyDesc;
}
public String getPATCityCode() {
return PATCityCode;
}
public void setPATCityCode(String PATCityCode) {
this.PATCityCode = PATCityCode;
}
public String getPATCityDesc() {
return PATCityDesc;
}
public void setPATCityDesc(String PATCityDesc) {
this.PATCityDesc = PATCityDesc;
}
public String getPATProvinceCode() {
return PATProvinceCode;
}
public void setPATProvinceCode(String PATProvinceCode) {
this.PATProvinceCode = PATProvinceCode;
}
public String getPATProvinceDesc() {
return PATProvinceDesc;
}
public void setPATProvinceDesc(String PATProvinceDesc) {
this.PATProvinceDesc = PATProvinceDesc;
}
public String getPATPostalCode() {
return PATPostalCode;
}
public void setPATPostalCode(String PATPostalCode) {
this.PATPostalCode = PATPostalCode;
}
}
| [
"[email protected]"
]
| |
80e7b367b4b5c6035220a5d8875343832c573311 | bc97f1d7a5d5b37fc785077a2f47b81f815025fe | /Core Java/RelationshipBWclasses/Association/Company.java | edd8ee166aba4d1716622defbbc94a69bce237f9 | []
| no_license | ramkurapati/javapracticles | 3cd3494e75bb8ecbf02b6f12aee9185c52f098e6 | a4988217d9c3a5baac02a28ead5036662bb661c6 | refs/heads/master | 2021-01-23T04:19:45.507721 | 2017-06-10T13:49:10 | 2017-06-10T13:50:16 | 92,924,434 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 475 | java | package Association;
public class Company
{
private String compname;
private int noofemps;
private String compaddress;
public Company(String compname, int noofemps, String compaddress) {
super();
this.compname = compname;
this.noofemps = noofemps;
this.compaddress = compaddress;
}
public String getCompname() {
return compname;
}
public int getNoofemps() {
return noofemps;
}
public String getCompaddress() {
return compaddress;
}
}
| [
"[email protected]"
]
| |
1510e0cd0fb3f69702e455eafda8f042f133e405 | 28d6bfef2793faba5f3584626d080655b5016d5e | /src/main/java/com/iot/service/StorageProperties.java | 7402128d458a50564cf00accea0ee6818b851992 | []
| no_license | zztttt/iot-backend | 8b9205eea5795e384ee2715bb8253a73b529ca9c | 733ede91e12017fd7d6eed14ee48d653768f06ed | refs/heads/master | 2023-01-22T17:36:51.825616 | 2020-12-01T14:35:38 | 2020-12-01T14:35:38 | 316,788,778 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 429 | java | package com.iot.service;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("storage")
public class StorageProperties {
/**
* Folder location for storing files
*/
private String location = "upload-dir";
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}
| [
"[email protected]"
]
| |
27dfbd68a490c2a2a6899d48e1713897f3178d73 | 7e2d999f0caf9dedc5e602c492392e113d6900fb | /src/test/java/com/bookmydoctor/test/feedback/GetFeedBackTests.java | c0f2b2b693cf9695b5ea3372f54361553e18c8cb | []
| no_license | Mridul-Krishnan/BookMyDoctor | 60c3559896a35f681cb5991b2410d7685e090300 | 2e7cb0e86639fb6e724fb381eae899e1ca499a50 | refs/heads/master | 2023-04-08T11:59:05.422075 | 2021-04-22T11:20:10 | 2021-04-22T11:20:10 | 352,954,901 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,038 | java | package com.bookmydoctor.test.feedback;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Optional;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import com.bookmydoctor.app.dao.IFeedbackDao;
import com.bookmydoctor.app.model.FeedBack;
import com.bookmydoctor.app.service.ImplFeedbackService;
@SpringBootTest
public class GetFeedBackTests {
@Autowired
private ImplFeedbackService service;
@MockBean
private IFeedbackDao dao;
@Test
@DisplayName("Test:Get by Id")
public void GetFeedBackByIdtests() {
Optional<FeedBack> getFeedback = Optional.of(new FeedBack("Average"));
Mockito.when(dao.findById(getFeedback.get().getFeedbackId())).thenReturn(getFeedback);
assertEquals(service.getFeedback(getFeedback.get().getFeedbackId()), getFeedback);
}
} | [
"[email protected]"
]
| |
c9a041a0f1005962b8370062f50db28b8dd3387f | 96336e5c55b8ffe076ba98d52db6f9052937ef32 | /CXFService/CXFRest/src/com/sdk/client/CloneAudience.java | bec9040927cacc105d5d179c971e778f97296435 | []
| no_license | mgipay/MGIPAY | 4a54a8ee29a4d7896033e88d002c270f1ea87f31 | 324a6835e36992eb9bd09cf42f0954eb05f1390f | HEAD | 2016-09-06T13:59:30.690864 | 2014-01-21T07:11:44 | 2014-01-21T07:11:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,430 | java |
package com.sdk.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="audienceId" type="{http://www.w3.org/2001/XMLSchema}int"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"audienceId"
})
@XmlRootElement(name = "cloneAudience", namespace = "uri:audience.ws.sdk.edialog.com")
public class CloneAudience {
@XmlElement(namespace = "uri:audience.ws.sdk.edialog.com")
protected int audienceId;
/**
* Gets the value of the audienceId property.
*
*/
public int getAudienceId() {
return audienceId;
}
/**
* Sets the value of the audienceId property.
*
*/
public void setAudienceId(int value) {
this.audienceId = value;
}
}
| [
"[email protected]"
]
| |
77a7581c2fa01b245ae5c86069ce97f33f5c8fc4 | 5836e58d99d46a6dbb2a1d3784715d3ac3d0dbae | /src/main/java/com/ticket/repository/TicketRepository.java | fc8e5d4bd23bbf24488fb2012035ccb263ae4f95 | []
| no_license | pizzaeueu/tp | 1643e0201437c9d7852463687eff61b6b18e96cd | 79a45de8aa314c14d1594534cb0985b49293454a | refs/heads/master | 2022-03-07T18:49:46.328885 | 2016-11-11T09:09:43 | 2016-11-11T09:09:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 502 | java | package com.ticket.repository;
import com.ticket.models.Event;
import com.ticket.models.Ticket;
import com.ticket.models.User;
import java.util.List;
/**
* Repository for {@link Ticket} entity
* extend {@link CRUDRepository}
*
* @author Artem Samosadov
* @version 1.0
*/
public interface TicketRepository extends CRUDRepository<Ticket> {
List<Ticket> findAllTicketsToEvent(Event event);
List<Ticket> findAllTicketsBySeller(User user);
void deleteTicketsToEvent(Event event);
}
| [
"[email protected]"
]
| |
5f2eaa6e0bd89d39b3ac8f9e6b9479a2d97bf04b | 320a13951e1860d6baf13295690021de4bb4c979 | /src/test/java/com/ryanair/booking/RyanairPaymentTest.java | 52568e012ac71b206e865f87d42311cf37e52f92 | []
| no_license | ugazda/selenium-cucumber | 3bfc5e0e6b47af5888dcdf0393c526149f0e6bbd | 5471564b88537802f79bc68bf258aa564c8fb2ba | refs/heads/master | 2021-01-20T08:38:16.968518 | 2017-08-29T20:02:16 | 2017-08-29T20:02:16 | 101,568,197 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 454 | java | package com.ryanair.booking;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
format = {
"json:target/cucumber/ryanair.json",
"html:target/cucumber/ryanair.html",
"pretty"
},
features = {"src/test/resources/features/ryanairpayment.feature"}
)
public class RyanairPaymentTest {
}
| [
"[email protected]"
]
| |
1efafb752597b200973558f680c581aae4048367 | 5b21036c389eccee4f1307db9b8effbcb1940537 | /app/src/main/java/com/example/fitnessapp/logger/LogView.java | c6b18c4c355668acc95209aedd37275f78eb6d29 | []
| no_license | tapanbasak12/Fit | fafed529c44481827755d5847fea6df4e5a405d1 | 5af4440beb439d7debf1cab845b7ce28f3d57579 | refs/heads/master | 2020-07-26T10:21:37.664472 | 2019-10-20T19:45:12 | 2019-10-20T19:45:12 | 208,615,167 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,107 | java | /*
* Copyright (C) 2014 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.fitnessapp.logger;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
/** Simple TextView which is used to output log data received through the LogNode interface.
*/
public class LogView extends TextView implements LogNode {
public LogView(Context context) {
super(context);
}
public LogView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LogView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* Formats the log data and prints it out to the LogView.
* @param priority Log level of the data being logged. Verbose, Error, etc.
* @param tag Tag for for the log data. Can be used to organize log statements.
* @param msg The actual message to be logged. The actual message to be logged.
* @param tr If an exception was thrown, this can be sent along for the logging facilities
* to extract and print useful information.
*/
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
String priorityStr = null;
// For the purposes of this View, we want to print the priority as readable text.
switch(priority) {
case android.util.Log.VERBOSE:
priorityStr = "VERBOSE";
break;
case android.util.Log.DEBUG:
priorityStr = "DEBUG";
break;
case android.util.Log.INFO:
priorityStr = "INFO";
break;
case android.util.Log.WARN:
priorityStr = "WARN";
break;
case android.util.Log.ERROR:
priorityStr = "ERROR";
break;
case android.util.Log.ASSERT:
priorityStr = "ASSERT";
break;
default:
break;
}
// Handily, the Log class has a facility for converting a stack trace into a usable string.
String exceptionStr = null;
if (tr != null) {
exceptionStr = android.util.Log.getStackTraceString(tr);
}
// Take the priority, tag, message, and exception, and concatenate as necessary
// into one usable line of text.
final StringBuilder outputBuilder = new StringBuilder();
String delimiter = "\t";
appendIfNotNull(outputBuilder, priorityStr, delimiter);
appendIfNotNull(outputBuilder, tag, delimiter);
appendIfNotNull(outputBuilder, msg, delimiter);
appendIfNotNull(outputBuilder, exceptionStr, delimiter);
// In case this was originally called from an AsyncTask or some other off-UI thread,
// make sure the update occurs within the UI thread.
((Activity) getContext()).runOnUiThread( (new Thread(new Runnable() {
@Override
public void run() {
// Display the text we just generated within the LogView.
appendToLog(outputBuilder.toString());
}
})));
if (mNext != null) {
mNext.println(priority, tag, msg, tr);
}
}
public LogNode getNext() {
return mNext;
}
public void setNext(LogNode node) {
mNext = node;
}
/** Takes a string and adds to it, with a separator, if the bit to be added isn't null. Since
* the logger takes so many arguments that might be null, this method helps cut out some of the
* agonizing tedium of writing the same 3 lines over and over.
* @param source StringBuilder containing the text to append to.
* @param addStr The String to append
* @param delimiter The String to separate the source and appended strings. A tab or comma,
* for instance.
* @return The fully concatenated String as a StringBuilder
*/
private StringBuilder appendIfNotNull(StringBuilder source, String addStr, String delimiter) {
if (addStr != null) {
if (addStr.length() == 0) {
delimiter = "";
}
return source.append(addStr).append(delimiter);
}
return source;
}
// The next LogNode in the chain.
LogNode mNext;
/** Outputs the string as a new line of log data in the LogView. */
public void appendToLog(String s) {
append("\n" + s);
}
}
| [
"[email protected]"
]
| |
3badb15a6a4b2e7209934999fa2dd00aa90850d6 | 77c4d4b6a82a513101c747f0d9178405309b32ed | /server/src/main/java/com/asura/monitor/util/MonitorUtil.java | a27a3e3b6a4e79360958d18c7036caa1c2335641 | [
"Apache-2.0"
]
| permissive | wajika/monitor | 0613ca43b8c6437e4181dedc24f85e82b8a3f5ff | 4f89ab9d83d4404aa8fb835e8f46c6ca792229ee | refs/heads/master | 2021-01-20T05:15:59.804346 | 2017-04-28T08:22:36 | 2017-04-28T08:22:36 | 89,770,246 | 1 | 0 | null | 2017-04-29T07:19:22 | 2017-04-29T07:19:22 | null | UTF-8 | Java | false | false | 3,894 | java | package com.asura.monitor.util;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.asura.monitor.graph.entity.PushEntity;
import com.asura.monitor.graph.util.FileRender;
import com.asura.monitor.graph.util.FileWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import static com.asura.monitor.graph.util.FileWriter.dataDir;
/**
* <p></p>
*
* <PRE>
* <BR> 修改记录
* <BR>-----------------------------------------------
* <BR> 修改日期 修改人 修改内容
* </PRE>
*
* @author zhaozq
* @version 1.0
* @since 1.0
*/
public class MonitorUtil {
public static final String separator = System.getProperty("file.separator");
public static final Logger logger = LoggerFactory.getLogger(MonitorUtil.class);
/**
*
* @param lentity
* @return
*/
public static List<PushEntity> getPushEntity(String lentity){
if( lentity!=null ) {
Type type = new TypeToken<ArrayList<PushEntity>>() {
}.getType();
List<PushEntity> list = new Gson().fromJson(lentity, type);
return list;
}
return new ArrayList<>();
}
/**
* @param lentity
*/
public static void writePush(String lentity, String writeType, String ip){
try {
List<PushEntity> list = getPushEntity(lentity);
for (PushEntity entity1 : list) {
if (entity1 == null) {
continue;
}
pushMonitorData(entity1, writeType, ip);
}
}catch (Exception e){
logger.error("解析数据失败" + lentity, e);
}
}
/**
* 记录每个指标的服务器地址
* @param entity
*/
static void writeIndexHosts(PushEntity entity){
// 拼接文件目录
String dir = dataDir + separator + "graph" + separator +"index" +separator;
dir = dir + entity.getGroups()+"."+entity.getName()+separator;
dir = FileRender.replace(dir);
FileWriter.makeDirs(dir);
File file = new File(dir + "id");
if ( !file.exists() ) {
FileWriter.writeFile(dir + "id", entity.getScriptId(), false);
}
}
/**
*
* @param entity
* @param writeType
* @param ipAddr
*/
public static void pushMonitorData(PushEntity entity, String writeType, String ipAddr) {
String historyName = FileRender.replace(entity.getName());
String name = FileRender.replace(entity.getScriptId() +"_"
+ FileRender.replace(entity.getStatus())) + "_"
+ FileRender.replace(entity.getGroups())+ "_"+ FileRender.replace(entity.getName());
if (entity.getStatus().equals("2")){
logger.info(name);
}
String groups = FileRender.replace(entity.getGroups());
String value = entity.getValue();
// 记录每个指标的服务器地址
writeIndexHosts(entity);
// 获取客户端IP
if (entity.getIp() != null && entity.getIp().length() > 7 ) {
ipAddr = FileRender.replace(entity.getIp());
}
// 只将数据写入到文件
if (name != null && value != null && value.length() > 0) {
// 画图数据生成
FileWriter.writeHistory(groups, ipAddr, historyName, value);
if(writeType.equals("success")) {
// 监控历史数据生成
if (entity.getServer() != null) {
FileWriter.writeMonitorHistory(FileRender.replace(entity.getServer()), name, entity);
}
}
}
}
}
| [
"root@proxy_nginx_4_35_236.(none)"
]
| root@proxy_nginx_4_35_236.(none) |
802b246a7c44408840ab1cb0d3ffbc41b241b608 | 687151058dc67a95755ba79577207566f3f19829 | /Exceptions/ExceptionEx2.java | 01d5c554f86bb9763cb6270315491c3431bdd464 | []
| no_license | patnala4321/MyRepository | 8b8067d7fec59735449de2ff2382607f923e1030 | d73721aaaf121c5911fde1d84a065f15790604a9 | refs/heads/master | 2020-06-19T05:37:18.393573 | 2019-07-12T13:38:13 | 2019-07-12T13:38:13 | 196,583,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package Exceptions;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.DataInputStream;
public class ExceptionEx2 {
public static void main(String[] args) throws IOException {
InputStream input = new FileInputStream("D:\\textout.txt");
DataInputStream inst = new DataInputStream(input);
int count = input.available();
byte[] ary = new byte[count];
inst.read(ary);
for (byte bt : ary) {
char k = (char) bt;
System.out.print(k);
}
}
}
| [
"[email protected]"
]
| |
8c6b379b45d0c6cdeb43effdde9eff3cff21ca7c | 5ea9152eb2bd5190961a845b29b10b3b2468b2fb | /app/src/main/java/com/example/atack08/ejemplo_juego/GameLoopThread.java | 8468353f702d84db46e606fa1cb573c137d419fc | []
| no_license | atack08/EJEMPLO_JUEGO | b0892f51da1fc92eb33cad9832a64c2a858cd8b3 | 266cf66e63e0b6216f1bbd60634757e9f6de750c | refs/heads/master | 2021-01-22T06:10:53.122443 | 2017-02-14T09:45:50 | 2017-02-14T09:45:50 | 81,739,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,367 | java | package com.example.atack08.ejemplo_juego;
import android.graphics.Canvas;
import android.provider.Settings;
/**
* Created by atack08 on 11/2/17.
*/
public class GameLoopThread extends Thread {
private VistaJuego view;
private boolean running;
static final long FPS = 10;
public GameLoopThread(VistaJuego view){
this.view = view;
this.running = false;
}
public void setRunnig(Boolean run){
this.running = run;
}
@Override
public void run() {
long ticksPS = 1000 / FPS;
long startTime = System.currentTimeMillis();
long sleepTime;
while (running){
Canvas c = null;
try {
c = view.getHolder().lockCanvas();
synchronized (view.getHandler()) {
view.onDraw(c);
}
}
finally {
if (c != null){
view.getHolder().unlockCanvasAndPost(c);
}
}
/*try {
sleepTime = ticksPS - (System.currentTimeMillis() - startTime);
if (sleepTime > 0)
sleep(sleepTime);
else
sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
}
}
}
| [
"[email protected]"
]
| |
6aa021a39a876fca43fe673d4be3f73e06ed91b3 | 8a086cf4735e315755f4d7f11d6cfbee6c1db154 | /ksqldb-streams/src/test/java/io/confluent/ksql/execution/streams/StreamSelectKeyBuilderV1Test.java | 708b7d39780934cb8b0386a5e1596f33db7ce268 | [
"LicenseRef-scancode-proprietary-license",
"Apache-2.0"
]
| permissive | vcrfxia/ksql | 489a8b69dbfa4d6651ed71038640b210364381ca | 4995684db13a7e29016c5a9142977ab7754fb4f8 | refs/heads/master | 2023-07-08T11:50:26.245934 | 2020-12-16T21:05:47 | 2020-12-16T21:05:47 | 151,648,605 | 0 | 1 | Apache-2.0 | 2018-10-04T23:34:41 | 2018-10-04T23:34:40 | null | UTF-8 | Java | false | false | 8,861 | java | /*
* Copyright 2020 Confluent Inc.
*
* Licensed under the Confluent Community License (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.confluent.io/confluent-community-license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.confluent.ksql.execution.streams;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import io.confluent.ksql.GenericKey;
import io.confluent.ksql.GenericRow;
import io.confluent.ksql.execution.builder.KsqlQueryBuilder;
import io.confluent.ksql.execution.context.QueryContext;
import io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp;
import io.confluent.ksql.execution.plan.ExecutionKeyFactory;
import io.confluent.ksql.execution.plan.ExecutionStep;
import io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1;
import io.confluent.ksql.execution.plan.PlanInfo;
import io.confluent.ksql.execution.plan.KStreamHolder;
import io.confluent.ksql.execution.plan.PlanBuilder;
import io.confluent.ksql.execution.plan.StreamSelectKeyV1;
import io.confluent.ksql.function.FunctionRegistry;
import io.confluent.ksql.name.ColumnName;
import io.confluent.ksql.schema.ksql.LogicalSchema;
import io.confluent.ksql.schema.ksql.PhysicalSchema;
import io.confluent.ksql.schema.ksql.SystemColumns;
import io.confluent.ksql.schema.ksql.types.SqlTypes;
import io.confluent.ksql.serde.FormatFactory;
import io.confluent.ksql.serde.FormatInfo;
import io.confluent.ksql.serde.SerdeFeatures;
import io.confluent.ksql.util.KsqlConfig;
import org.apache.kafka.streams.kstream.KStream;
import org.apache.kafka.streams.kstream.KeyValueMapper;
import org.apache.kafka.streams.kstream.Predicate;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class StreamSelectKeyBuilderV1Test {
private static final LogicalSchema SOURCE_SCHEMA = LogicalSchema.builder()
.keyColumn(ColumnName.of("k0"), SqlTypes.DOUBLE)
.valueColumn(ColumnName.of("BIG"), SqlTypes.BIGINT)
.valueColumn(ColumnName.of("BOI"), SqlTypes.BIGINT)
.build()
.withPseudoAndKeyColsInValue(false);
private static final UnqualifiedColumnReferenceExp KEY =
new UnqualifiedColumnReferenceExp(ColumnName.of("BOI"));
private static final LogicalSchema RESULT_SCHEMA = LogicalSchema.builder()
.keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.BIGINT)
.valueColumn(ColumnName.of("BIG"), SqlTypes.BIGINT)
.valueColumn(ColumnName.of("BOI"), SqlTypes.BIGINT)
.valueColumn(ColumnName.of(SystemColumns.ROWTIME_NAME.text()), SqlTypes.BIGINT)
.valueColumn(ColumnName.of("k0"), SqlTypes.DOUBLE)
.build();
private static final long A_BOI = 5000;
private static final long A_BIG = 3000;
private static final GenericKey SOURCE_KEY = GenericKey.genericKey("dre");
@Mock
private KStream<GenericKey, GenericRow> kstream;
@Mock
private KStream<GenericKey, GenericRow> rekeyedKstream;
@Mock
private KStream<GenericKey, GenericRow> filteredKStream;
@Mock
private ExecutionStep<KStreamHolder<GenericKey>> sourceStep;
@Mock
private KsqlQueryBuilder queryBuilder;
@Mock
private FunctionRegistry functionRegistry;
@Mock
private PlanInfo planInfo;
@Captor
private ArgumentCaptor<Predicate<GenericKey, GenericRow>> predicateCaptor;
@Captor
private ArgumentCaptor<KeyValueMapper<GenericKey, GenericRow, GenericKey>> keyValueMapperCaptor;
private final QueryContext queryContext =
new QueryContext.Stacker().push("ya").getQueryContext();
private PlanBuilder planBuilder;
private StreamSelectKeyV1 selectKey;
@Before
@SuppressWarnings("unchecked")
public void init() {
when(queryBuilder.getFunctionRegistry()).thenReturn(functionRegistry);
when(queryBuilder.getKsqlConfig()).thenReturn(new KsqlConfig(ImmutableMap.of()));
when(kstream.filter(any())).thenReturn(filteredKStream);
when(filteredKStream.selectKey(any(KeyValueMapper.class))).thenReturn(rekeyedKstream);
when(sourceStep.build(any(), eq(planInfo))).thenReturn(
new KStreamHolder<>(kstream, SOURCE_SCHEMA, mock(ExecutionKeyFactory.class)));
planBuilder = new KSPlanBuilder(
queryBuilder,
mock(SqlPredicateFactory.class),
mock(AggregateParamsFactory.class),
mock(StreamsFactories.class)
);
selectKey = new StreamSelectKeyV1(
new ExecutionStepPropertiesV1(queryContext),
sourceStep,
KEY
);
}
@Test
public void shouldRekeyCorrectly() {
// When:
final KStreamHolder<GenericKey> result = selectKey.build(planBuilder, planInfo);
// Then:
final InOrder inOrder = Mockito.inOrder(kstream, filteredKStream, rekeyedKstream);
inOrder.verify(kstream).filter(any());
inOrder.verify(filteredKStream).selectKey(any());
inOrder.verifyNoMoreInteractions();
assertThat(result.getStream(), is(rekeyedKstream));
}
@Test
public void shouldReturnCorrectSerdeFactory() {
// When:
final KStreamHolder<GenericKey> result = selectKey.build(planBuilder, planInfo);
// Then:
result.getExecutionKeyFactory().buildKeySerde(
FormatInfo.of(FormatFactory.JSON.name()),
PhysicalSchema.from(SOURCE_SCHEMA, SerdeFeatures.of(), SerdeFeatures.of()),
queryContext
);
verify(queryBuilder).buildKeySerde(
FormatInfo.of(FormatFactory.JSON.name()),
PhysicalSchema.from(SOURCE_SCHEMA, SerdeFeatures.of(), SerdeFeatures.of()),
queryContext);
}
@Test
public void shouldFilterOutNullValues() {
// When:
selectKey.build(planBuilder, planInfo);
// Then:
verify(kstream).filter(predicateCaptor.capture());
final Predicate<GenericKey, GenericRow> predicate = getPredicate();
assertThat(predicate.test(SOURCE_KEY, null), is(false));
}
@Test
public void shouldFilterOutNullKeyColumns() {
// When:
selectKey.build(planBuilder, planInfo);
// Then:
verify(kstream).filter(predicateCaptor.capture());
final Predicate<GenericKey, GenericRow> predicate = getPredicate();
assertThat(
predicate.test(SOURCE_KEY, value(A_BIG, null, 0, "dre")),
is(false)
);
}
@Test
public void shouldNotFilterOutNonNullKeyColumns() {
// When:
selectKey.build(planBuilder, planInfo);
// Then:
verify(kstream).filter(predicateCaptor.capture());
final Predicate<GenericKey, GenericRow> predicate = getPredicate();
assertThat(
predicate.test(SOURCE_KEY, value(A_BIG, A_BOI, 0, "dre")),
is(true)
);
}
@Test
public void shouldIgnoreNullNonKeyColumns() {
// When:
selectKey.build(planBuilder, planInfo);
// Then:
verify(kstream).filter(predicateCaptor.capture());
final Predicate<GenericKey, GenericRow> predicate = getPredicate();
assertThat(predicate.test(SOURCE_KEY, value(null, A_BOI, 0, "dre")), is(true));
}
@Test
public void shouldComputeCorrectKey() {
// When:
selectKey.build(planBuilder, planInfo);
// Then:
final KeyValueMapper<GenericKey, GenericRow, GenericKey> keyValueMapper = getKeyMapper();
assertThat(
keyValueMapper.apply(SOURCE_KEY, value(A_BIG, A_BOI, 0, "dre")),
is(GenericKey.genericKey(A_BOI))
);
}
@Test
public void shouldReturnCorrectSchema() {
// When:
final KStreamHolder<GenericKey> result = selectKey.build(planBuilder, planInfo);
// Then:
assertThat(result.getSchema(), is(RESULT_SCHEMA));
}
private KeyValueMapper<GenericKey, GenericRow, GenericKey> getKeyMapper() {
verify(filteredKStream).selectKey(keyValueMapperCaptor.capture());
return keyValueMapperCaptor.getValue();
}
private Predicate<GenericKey, GenericRow> getPredicate() {
verify(kstream).filter(predicateCaptor.capture());
return predicateCaptor.getValue();
}
private static GenericRow value(
final Long big,
final Long boi,
final int rowTime,
final String rowKey
) {
return GenericRow.genericRow(big, boi, rowTime, rowKey);
}
}
| [
"[email protected]"
]
| |
ba1e3170f91d0a8d3b799b9056aa415d3f1a0105 | b6acc51a78cc7638d05fb0dd9b4fe3a783c4755d | /MyApplication2/app/src/main/java/com/example/myapplication/PairActivity.java | f39a5441c74b00572723d3d490bffaeb64ba86ac | []
| no_license | sauravmittal001/VoxCo | 42b2165df811c5f81f7cb15d3d70a3c671c8e6ba | f1fa36d73807d16d93decc16b14370f13f86c630 | refs/heads/master | 2021-06-26T13:09:40.281893 | 2020-12-07T00:30:14 | 2020-12-07T00:30:14 | 184,913,873 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,751 | java | package com.example.myapplication;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Set;
public class PairActivity extends AppCompatActivity {
ListView listViewPaired;
ListView listViewDetected;
ArrayList<String> arrayListpaired;
Button buttonSearch,buttonOn,buttonDesc,buttonOff;
ArrayAdapter<String> adapter,detectedAdapter;
static HandleSeacrh handleSeacrh;
BluetoothDevice bdDevice;
BluetoothClass bdClass;
ArrayList<BluetoothDevice> arrayListPairedBluetoothDevices;
private ButtonClicked clicked;
ListItemClickedonPaired listItemClickedonPaired;
BluetoothAdapter bluetoothAdapter = null;
ArrayList<BluetoothDevice> arrayListBluetoothDevices = null;
ListItemClicked listItemClicked;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pair);
getWindow().getDecorView().setBackgroundColor(Color.WHITE);
listViewDetected = (ListView) findViewById(R.id.listViewDetected);
listViewPaired = (ListView) findViewById(R.id.listViewPaired);
buttonSearch = (Button) findViewById(R.id.buttonSearch);
buttonOn = (Button) findViewById(R.id.buttonOn);
buttonDesc = (Button) findViewById(R.id.buttonDesc);
buttonOff = (Button) findViewById(R.id.buttonOff);
arrayListpaired = new ArrayList<String>();
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
clicked = new ButtonClicked();
handleSeacrh = new HandleSeacrh();
arrayListPairedBluetoothDevices = new ArrayList<BluetoothDevice>();
/*
* the above declaration is just for getting the paired bluetooth devices;
* this helps in the removing the bond between paired devices.
*/
listItemClickedonPaired = new ListItemClickedonPaired();
arrayListBluetoothDevices = new ArrayList<BluetoothDevice>();
adapter= new ArrayAdapter<String>(PairActivity.this, android.R.layout.simple_list_item_1, arrayListpaired);
detectedAdapter = new ArrayAdapter<String>(PairActivity.this, android.R.layout.simple_list_item_single_choice);
listViewDetected.setAdapter(detectedAdapter);
listItemClicked = new ListItemClicked();
detectedAdapter.notifyDataSetChanged();
listViewPaired.setAdapter(adapter);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
getPairedDevices();
buttonOn.setOnClickListener(clicked);
buttonSearch.setOnClickListener(clicked);
buttonDesc.setOnClickListener(clicked);
buttonOff.setOnClickListener(clicked);
listViewDetected.setOnItemClickListener(listItemClicked);
listViewPaired.setOnItemClickListener(listItemClickedonPaired);
}
private void getPairedDevices() {
Set<BluetoothDevice> pairedDevice = bluetoothAdapter.getBondedDevices();
if(pairedDevice.size()>0)
{
for(BluetoothDevice device : pairedDevice)
{
arrayListpaired.add(device.getName()+"\n"+device.getAddress());
arrayListPairedBluetoothDevices.add(device);
}
}
adapter.notifyDataSetChanged();
}
class ListItemClicked implements AdapterView.OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
bdDevice = arrayListBluetoothDevices.get(position);
//bdClass = arrayListBluetoothDevices.get(position);
Log.i("Log", "The dvice : "+bdDevice.toString());
/*
* here below we can do pairing without calling the callthread(), we can directly call the
* connect(). but for the safer side we must usethe threading object.
*/
//callThread();
//connect(bdDevice);
Boolean isBonded = false;
try {
isBonded = createBond(bdDevice);
if(isBonded)
{
//arrayListpaired.add(bdDevice.getName()+"\n"+bdDevice.getAddress());
//adapter.notifyDataSetChanged();
getPairedDevices();
adapter.notifyDataSetChanged();
}
} catch (Exception e) {
e.printStackTrace();
}//connect(bdDevice);
Log.i("Log", "The bond is created: "+isBonded);
}
}
class ListItemClickedonPaired implements AdapterView.OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
bdDevice = arrayListPairedBluetoothDevices.get(position);
try {
Boolean removeBonding = removeBond(bdDevice);
if(removeBonding)
{
arrayListpaired.remove(position);
adapter.notifyDataSetChanged();
}
Log.i("Log", "Removed"+removeBonding);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*private void callThread() {
new Thread(){
public void run() {
Boolean isBonded = false;
try {
isBonded = createBond(bdDevice);
if(isBonded)
{
arrayListpaired.add(bdDevice.getName()+"\n"+bdDevice.getAddress());
adapter.notifyDataSetChanged();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//connect(bdDevice);
Log.i("Log", "The bond is created: "+isBonded);
}
}.play();
}*/
private Boolean connect(BluetoothDevice bdDevice) {
Boolean bool = false;
try {
Log.i("Log", "service method is called ");
Class cl = Class.forName("android.bluetooth.BluetoothDevice");
Class[] par = {};
Method method = cl.getMethod("createBond", par);
Object[] args = {};
bool = (Boolean) method.invoke(bdDevice);//, args);// this invoke creates the detected devices paired.
//Log.i("Log", "This is: "+bool.booleanValue());
//Log.i("Log", "devicesss: "+bdDevice.getName());
} catch (Exception e) {
Log.i("Log", "Inside catch of serviceFromDevice Method");
e.printStackTrace();
}
return bool.booleanValue();
};
public boolean removeBond(BluetoothDevice btDevice)
throws Exception
{
Class btClass = Class.forName("android.bluetooth.BluetoothDevice");
Method removeBondMethod = btClass.getMethod("removeBond");
Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}
public boolean createBond(BluetoothDevice btDevice)
throws Exception
{
Class class1 = Class.forName("android.bluetooth.BluetoothDevice");
Method createBondMethod = class1.getMethod("createBond");
Boolean returnValue = (Boolean) createBondMethod.invoke(btDevice);
return returnValue.booleanValue();
}
class ButtonClicked implements View.OnClickListener
{
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.buttonOn:
onBluetooth();
Toast toast1 = Toast.makeText(getApplicationContext(), "VoxCo Connection On", Toast.LENGTH_SHORT);
toast1.show();
break;
case R.id.buttonSearch:
arrayListBluetoothDevices.clear();
startSearching();
Toast toast2 = Toast.makeText(getApplicationContext(), "Searching", Toast.LENGTH_SHORT);
toast2.show();
break;
case R.id.buttonDesc:
makeDiscoverable();
break;
case R.id.buttonOff:
offBluetooth();
Toast toast3 = Toast.makeText(getApplicationContext(), "VoxCo Connection Off", Toast.LENGTH_SHORT);
toast3.show();
break;
default:
break;
}
}
}
private BroadcastReceiver myReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Message msg = Message.obtain();
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)){
Toast.makeText(context, "ACTION_FOUND", Toast.LENGTH_SHORT).show();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
try
{
//device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device, true);
//device.getClass().getMethod("cancelPairingUserInput", boolean.class).invoke(device);
}
catch (Exception e) {
Log.i("Log", "Inside the exception: ");
e.printStackTrace();
}
if(arrayListBluetoothDevices.size()<1) // this checks if the size of bluetooth device is 0,then add the
{ // device to the arraylist.
detectedAdapter.add(device.getName()+"\n"+device.getAddress());
arrayListBluetoothDevices.add(device);
detectedAdapter.notifyDataSetChanged();
}
else
{
boolean flag = true; // flag to indicate that particular device is already in the arlist or not
for(int i = 0; i<arrayListBluetoothDevices.size();i++)
{
if(device.getAddress().equals(arrayListBluetoothDevices.get(i).getAddress()))
{
flag = false;
}
}
if(flag == true)
{
detectedAdapter.add(device.getName()+"\n"+device.getAddress());
arrayListBluetoothDevices.add(device);
detectedAdapter.notifyDataSetChanged();
}
}
}
}
};
private void startSearching() {
Log.i("Log", "in the play searching method");
IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
PairActivity.this.registerReceiver(myReceiver, intentFilter);
bluetoothAdapter.startDiscovery();
}
private void onBluetooth() {
if(!bluetoothAdapter.isEnabled())
{
bluetoothAdapter.enable();
Log.i("Log", "Bluetooth is Enabled");
}
}
private void offBluetooth() {
if(bluetoothAdapter.isEnabled())
{
bluetoothAdapter.disable();
}
}
private void makeDiscoverable() {
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
Log.i("Log", "Discoverable ");
}
class HandleSeacrh extends Handler
{
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 111:
break;
default:
break;
}
}
}
}
| [
"[email protected]"
]
| |
d433d6a955c0887532728fdea95fbe8e1882baac | 04a68d578333c9d927cb62d64d0e97cf0ad73494 | /test2/src/main/java/com/vogella/example/controller/IssueController.java | 7cda8a84d7b52d4448c489817a9f071c3d9d5ae2 | []
| no_license | paulsm4/HelloSpringBoot | df308e7b1c3a4ae34aea208fc69fd65133431d5a | 9ffceabd5925ef4cb6963437c10c4968f77df5c8 | refs/heads/master | 2020-04-09T15:14:02.115688 | 2018-12-12T01:00:15 | 2018-12-12T01:00:15 | 160,420,267 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,513 | java | package com.vogella.example.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.vogella.example.entity.IssueReport;
import com.vogella.example.repositories.IssueRepository;
@Controller
public class IssueController {
IssueRepository issueRepository;
public IssueController(IssueRepository issueRepository) {
this.issueRepository = issueRepository;
}
@GetMapping("/issuereport")
public String getReport(Model model, @RequestParam(name = "submitted", required = false) boolean submitted) {
model.addAttribute("submitted", submitted);
model.addAttribute("issuereport", new IssueReport());
return "issues/issuereport_form";
}
@PostMapping(value="/issuereport")
public String submitReport(IssueReport issueReport, RedirectAttributes ra) {
this.issueRepository.save(issueReport);
ra.addAttribute("submitted", true);
return "redirect:/issuereport";
}
@GetMapping("/issues")
public String getIssues(Model model) {
model.addAttribute("issues", this.issueRepository.findAllButPrivate());
return "issues/issuereport_list";
}
}
| [
"[email protected]"
]
| |
719dd8ef13263c5a3d3979e4222ffc3223f7f2a5 | de7edd3fb3fd0ca27f2e011ef388dd710c71e55c | /Repartiteur/src/Repartiteur.java | 0cda1c4279c39b23f536a896b516df8365572841 | []
| no_license | M2DLProject/ARGEProject | 0663d6cee9b51f709f9837656586243e0a76457e | 4d53def089dad940704416a928181cd8e6510ed8 | refs/heads/master | 2021-01-10T17:00:21.913433 | 2016-05-16T13:48:30 | 2016-05-16T13:48:30 | 55,913,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,704 | java |
// import org.apache.xmlrpc.demo.webserver.proxy.impls.AdderImpl;
import java.net.MalformedURLException;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;
public class Repartiteur {
private static final int port = 8081;
private static RepartiteurHelper repartiteurHelper;
public static void main(String[] args) throws Exception {
System.out.println("Repartiteur staring....");
WebServer webServer = new WebServer(port);
XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
PropertyHandlerMapping phm = new PropertyHandlerMapping();
repartiteurHelper = new RepartiteurHelper();
System.out.println("Loading DB...");
repartiteurHelper.loadWNBase();
phm.addHandler("Repartiteur", Repartiteur.class);
xmlRpcServer.setHandlerMapping(phm);
XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
serverConfig.setEnabledForExtensions(true);
serverConfig.setContentLengthOptional(false);
webServer.start();
}
public int call(String method, int i1, int i2) throws MalformedURLException, XmlRpcException {
// make the a regular call
Object[] params = new Object[] { new Integer(i1), new Integer(i2) };
return repartiteurHelper.callMethod(method, params);
}
public int addWN(String ip, String port) {
repartiteurHelper.addWN(ip, port);
return 1;
}
public int delWN(String ip, String port) {
repartiteurHelper.delWN(ip, port);
return 1;
}
public int restart() {
repartiteurHelper.restart();
return 1;
}
} | [
"[email protected]"
]
| |
91ee837b8992c2c4043404784be64b7c64b994a5 | d14c137d841cafbb07248bd09523a85454e47e93 | /app/src/main/java/com/usermindarchive/h/internationalspacestationpasses/Model/Dagger/OpenNotifyComponent.java | 36161260357b44e0c7af994c75875b6111985bf1 | []
| no_license | KumarYDev/InternationalSpaceStationPasses | 5eda57f853d0feb3b3f9d0fc688b4276e93590fe | a603d1d61c1eae5b65ff7c0605483ae72db5a3cd | refs/heads/master | 2021-05-09T00:52:47.433452 | 2018-03-13T01:07:49 | 2018-03-13T01:07:49 | 119,762,793 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,029 | java | package com.usermindarchive.h.internationalspacestationpasses.Model.Dagger;
import com.usermindarchive.h.internationalspacestationpasses.MainActivity;
import com.usermindarchive.h.internationalspacestationpasses.Model.Retrofit.OpenNotifyDataParser;
import com.usermindarchive.h.internationalspacestationpasses.Presenter.MainFragmentPresenter;
import com.usermindarchive.h.internationalspacestationpasses.View.MainFragment;
import javax.inject.Singleton;
import dagger.Component;
/**
* OpenNotifyComponent Interface is the Dagger Component which is reposible for the collection of the Dagger Module classes
* and list of class where Dagger is being Used
*/
@Singleton
// List of module classes that contain Dagger provide methods
@Component(modules = {OpenNotifyModule.class})
public interface OpenNotifyComponent {
// Classes where Dagger is being Injected
void inject(MainFragmentPresenter mainFragment);
void inject(MainActivity mainActivity);
void inject(OpenNotifyDataParser openNotifyDataParser);
}
| [
"[email protected]"
]
| |
fdb03df73c85d3c0b73626943269ae985b9eaf55 | 17c28e3ac3b6ed3e20d45c95d812a3da4186cfc3 | /designPatterns/src/main/java/com/cctang/designModle/prototypePattern/Client.java | ff345d761210e3f9881c77fae7e90288c8130cd7 | []
| no_license | ZKHTYJ/SpringCloud | 8b1cb88aeb085e8dd258995a31ae3bc191908f3c | 46cd5391a322d9815260c2d33513bcef98e30fdc | refs/heads/master | 2023-09-04T03:10:55.877181 | 2021-10-19T15:12:41 | 2021-10-19T15:12:41 | 377,346,907 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 826 | java | package com.cctang.designModle.prototypePattern;
/**
* @author cctang
* @version 1.0
* @date 2021/8/2 22:30
* @description 现在为了快速复制同一工厂的不同手机,解决这一实际应用场景。
*/
public class Client {
public static void main(String[] args) {
Phone phone =new Phone();
phone.setName("华为Mate40pro");
phone.setPrice(6499);
phone.factory = new Factory();
phone.factory.setName("联发科");
Person person =new Person();
person.setName("任正非");
phone.factory.Manager=person;
Phone phone1 =phone.Clone();
phone1.setName("华为Mate40pro保时捷");
phone1.factory.setName("台积电");
System.out.println(phone.toString());
System.out.println(phone1.toString());
}
}
| [
"[email protected]"
]
| |
43cfc8f66362f826796e640b786bd2381b5e7059 | 0da587e78c86881de6fa0bde05599787671c5d94 | /771.宝石与石头.java | 7dc01f288ab6f108e1da8a8b80e733c7d5bc4bd5 | []
| no_license | sysuhuang/leetcode | 39da3b2d5ec0bedde1b01df3a085f82dd3ded8b8 | 384d53616f0b5603037941528abd7cae4da80d8b | refs/heads/master | 2020-12-02T15:13:26.470761 | 2020-04-03T03:32:36 | 2020-04-03T03:32:36 | 230,834,321 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,640 | java | import java.util.HashMap;
/*
* @lc app=leetcode.cn id=771 lang=java
*
* [771] 宝石与石头
*
* https://leetcode-cn.com/problems/jewels-and-stones/description/
*
* algorithms
* Easy (81.84%)
* Likes: 508
* Dislikes: 0
* Total Accepted: 70.8K
* Total Submissions: 86.5K
* Testcase Example: '"aA"\n"aAAbbbb"'
*
* 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。
*
* J 中的字母不重复,J 和 S中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。
*
* 示例 1:
*
* 输入: J = "aA", S = "aAAbbbb"
* 输出: 3
*
*
* 示例 2:
*
* 输入: J = "z", S = "ZZ"
* 输出: 0
*
*
* 注意:
*
*
* S 和 J 最多含有50个字母。
* J 中的字符不重复。
*
*
*/
// @lc code=start
class Solution {
public int numJewelsInStones(String J, String S) {
HashMap<Character, Integer> map = new HashMap<>();
int result = 0;
for(int i = 0; i < S.length(); i++){
Character ch = S.charAt(i);
if(map.containsKey(S.charAt(i))){
map.put(ch, map.get(ch)+1);
}
else{
map.put(ch,1);
}
}
for(int j = 0; j < J.length(); j++){
if(map.containsKey(J.charAt(j)))
result += map.get(J.charAt(j));
}
return result;
}
}
// @lc code=end
| [
"[email protected]"
]
| |
a261be26f91e0ed03fbdb213108890379d0bf737 | 57e4a99000b5cd99179678b3cfb75f38d724850f | /src/test/java/uk/q3c/krail/core/persist/inmemory/common/InMemoryContainerProviderTest_PatternAndOption.java | 8836e88349059c8469e7cf23928aa90cc9fab600 | [
"Apache-2.0"
]
| permissive | atistrcsn/krail | 17f8516ffcfad2953a5c6d67a13cd302dfbb2546 | 8026fe2a7dbe0bfe01b313c258bf93276d031b71 | refs/heads/master | 2021-01-21T13:26:13.984302 | 2017-08-30T08:01:45 | 2017-08-31T05:47:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,321 | java | /*
*
* * Copyright (c) 2016. David Sowerby
* *
* * 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 uk.q3c.krail.core.persist.inmemory.common;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.mycila.testing.junit.MycilaJunitRunner;
import com.mycila.testing.plugin.guice.GuiceContext;
import com.mycila.testing.plugin.guice.ModuleProvider;
import com.vaadin.data.Container;
import com.vaadin.data.util.BeanItemContainer;
import org.junit.Test;
import org.junit.runner.RunWith;
import uk.q3c.krail.core.persist.inmemory.VaadinInMemoryModule;
import uk.q3c.krail.persist.ContainerType;
import uk.q3c.krail.persist.InMemory;
import uk.q3c.krail.persist.VaadinContainerProvider;
import uk.q3c.krail.persist.inmemory.OptionEntity;
import uk.q3c.krail.persist.inmemory.entity.PatternEntity;
import static org.assertj.core.api.Assertions.*;
@RunWith(MycilaJunitRunner.class)
@GuiceContext({})
public class InMemoryContainerProviderTest_PatternAndOption {
@Inject
@InMemory
VaadinContainerProvider<BeanItemContainer> inMemoryContainerProvider;
/**
* This will fail if the INMemoryModule is not set to provide either the OptionDaoDelegate, PatternDao or both
*/
@Test
public void name() {
//given
//when
Container container1 = inMemoryContainerProvider.get(PatternEntity.class, ContainerType.CACHED);
Container container2 = inMemoryContainerProvider.get(OptionEntity.class, ContainerType.CACHED);
//then
assertThat(container1).isNotNull();
assertThat(container2).isNotNull();
}
@ModuleProvider
protected AbstractModule moduleProvider() {
return new VaadinInMemoryModule().providePatternDao()
.provideOptionDao();
}
} | [
"[email protected]"
]
| |
b2554ed946b6fe8e1741db14ae845a467717c14f | 3218afba74da25578ccc0f0209d2c26ec77f1124 | /src/main/java/org/jbrain/qlink/cmd/action/fdo/FDOResponse.java | b0d6e29181f85f8d8fe408706a52d67d61f2dec4 | []
| no_license | guybrush01/qlink | 3d191f78f2cdde3cdab42a1159b900810019b4b9 | 59be160ac33274714581e96f19f175dc604a185b | refs/heads/master | 2023-03-17T05:29:24.047751 | 2022-07-06T05:00:24 | 2022-07-06T05:00:24 | 161,571,163 | 0 | 0 | null | 2018-12-13T02:11:59 | 2018-12-13T02:11:58 | null | UTF-8 | Java | false | false | 948 | java | /*
Copyright Jim Brain and Brain Innovations, 2005.
This file is part of QLinkServer.
QLinkServer is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
QLinkServer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QLinkServer; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@author Jim Brain
Created on Oct 11, 2005
*/
package org.jbrain.qlink.cmd.action.fdo;
public interface FDOResponse extends FDOCommand {
public static final int RESP_SELECT = 0x01;
}
| [
"[email protected]"
]
| |
049e61c2b001c6a9bc97c1f2d17da29ff135eb21 | c7128917baeaa24e946911baec002a86077f99b0 | /MapsLambdaAndStreamAPI/src/exercises/StudentAcademy.java | 69e1cbc93bc07e07ae5476cfb7fff77123255282 | [
"MIT"
]
| permissive | DeianH94/JavaFundamentals2 | d5c8806a253f74fce5e9b35aba8aa126fd9a697a | bb845ba6ca0493f0438c96af1f93d64d11d23f25 | refs/heads/master | 2022-11-29T05:53:25.647553 | 2020-08-09T20:08:23 | 2020-08-09T20:08:23 | 286,308,055 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,478 | java | package exercises;
import java.util.*;
public class StudentAcademy {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<String, List<Double>> students = new LinkedHashMap<>();
int numOfGrades = Integer.parseInt(scanner.nextLine());
for (int i = 0; i < numOfGrades; i++) {
String studentName = scanner.nextLine();
double studentGrade = Double.parseDouble(scanner.nextLine());
students.putIfAbsent(studentName, new ArrayList<>());
students.get(studentName).add(studentGrade);
}
students.entrySet()
.stream()
.filter(student -> student.getValue()
.stream()
.mapToDouble(Double::valueOf)
.average()
.getAsDouble() >= 4.50)
.sorted((s1, s2) -> {
double first = s1.getValue().stream().mapToDouble(Double::doubleValue).average().getAsDouble();
double second = s2.getValue().stream().mapToDouble(Double::doubleValue).average().getAsDouble();
return Double.compare(second, first);
})
.forEach(s -> System.out.printf("%s -> %.2f%n", s.getKey(), s.getValue().stream()
.mapToDouble(Double::doubleValue)
.average()
.getAsDouble()));
}
}
| [
"[email protected]"
]
| |
708347b74e147f8dd2ec08fbb2a2cbde08989182 | 5043cc5f6ca343231d8e8cbd75c887f750d73154 | /spring-hibernate/src/com/spring/datetime/InstantExample.java | 384cfc765745969a8f1fb6a126389df35f78c051 | []
| no_license | thanhbv2/java_practice | 0a43224343063b9519c9db4bdeda31b4265b3e92 | 54c2f1bc2734a86cab25a55d1899d90bff17c438 | refs/heads/master | 2022-12-16T19:53:51.046985 | 2020-09-24T08:20:15 | 2020-09-24T08:20:15 | 279,198,140 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 191 | java | package com.spring.datetime;
import java.time.Instant;
public class InstantExample {
public static void main(String[] args) {
System.out.println("Instant: " + Instant.now());
}
}
| [
"[email protected]"
]
| |
538866c868147ca3d74224d8d9b8b5a9f357d08c | 7ce2a8b5e9957da145a46ffebfd510b2e9c4a8fe | /src/ie/gmit/sw/client/config/Context.java | 91c19f05cef29e4a37579af5f1461c48f912ed6e | []
| no_license | RobbieDeegan/Multi-Threaded-File-Server | 3906d3066516046aceb5ea9d67a5eb2cfc5ad85b | b2d19b91bc8c91f4d26c4b83853591887b1daa91 | refs/heads/master | 2021-04-29T04:16:43.699823 | 2017-01-08T00:20:40 | 2017-01-08T00:20:40 | 77,941,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 500 | java | package ie.gmit.sw.client.config;
public class Context {
public static final String CONFIG_FILE="config.xml";
private String host;
private int port;
public Context() {
super();
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
@Override
public String toString() {
return "Context [host=" + host + ", port=" + port + "]";
}
}
| [
"[email protected]"
]
| |
7eea7362a61e1168163df84d5a3591d1cdeb1e69 | 29a2a02155943af582784fc8f3e12c44daefc012 | /PHAS3459/src/module5/Minerals.java | d57200d41e2759f7318bcb02fffcb357fc27358c | []
| no_license | JosephWstn/PHAS3459 | bc8c3c800c5728d31f3e6516e1e1d99538fd7c5f | 14bf62484aa3059e0ab630b8de64ea162862eefd | refs/heads/master | 2021-03-19T11:35:48.193275 | 2018-01-17T16:38:31 | 2018-01-17T16:38:31 | 106,108,149 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,456 | java | package module5;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Minerals {
public static void main(String[] args) throws Exception {
/*
* Initialise HashMaps of mass and place information
*/
HashMap<Integer,Double> masses = new HashMap<Integer,Double>();
HashMap<Integer,String> places = new HashMap<Integer,String>();
//convert masses URL to BufferedReader
URL um = new URL ("http://www.hep.ucl.ac.uk/undergrad/3459/data/module5/module5-samples.txt");
InputStream ism = um.openStream();
InputStreamReader isrm = new InputStreamReader(ism);
BufferedReader brm = new BufferedReader(isrm);
String line;
//put Mass bufferedreader into HashMap masses
while ((line = brm.readLine()) != null){
Scanner sm = new Scanner(line);
masses.put(sm.nextInt(), sm.nextDouble());
sm.close();
}
//convert location URL to BufferedReader
URL ul = new URL ("http://www.hep.ucl.ac.uk/undergrad/3459/data/module5/module5-locations.txt");
InputStream isl = ul.openStream();
InputStreamReader isrl = new InputStreamReader(isl);
BufferedReader brl = new BufferedReader(isrl);
//put location bufferedreader into HashMap places
while ((line = brl.readLine()) != null){
Scanner sl = new Scanner(line);
String place = sl.next();
places.put(sl.nextInt(), place);
sl.close();
}
//initialise max and min maps as null
Map.Entry<Integer, Double> max = null;
Map.Entry<Integer, Double> min = null;
//loops over masses HashMap
for (Map.Entry<Integer, Double> entry : masses.entrySet()){
//update min Map if necessary
if(min == null || min.getValue() > entry.getValue()){
min = entry;
}
//update max Map if necessary
if(max == null || max.getValue() < entry.getValue()){
max = entry;
}
}
//Link up max and min code, mass and location
System.out.println("The heaviest sample is code " + max.getKey() + " which has a mass of " + max.getValue()+ "grammes. This was found at " + places.get(max.getKey()));
System.out.println("The lightest sample is code " + min.getKey() + " which has a mass of " + min.getValue()+ "grammes. This was found at " + places.get(min.getKey()));
}
} | [
"[email protected]"
]
| |
d87386a3fe2a8dfcd9c8ea855576bc28778af9dc | 35916b65388dd7b78aaa36142767e019d1b321b0 | /trend-trading-backtest-service/src/main/java/cn/how2j/trend/client/IndexDataClient.java | 8e9d96f23b908cc79c6398b84577a12a57fb292a | []
| no_license | JieJueSama/Trend | 178e0e809bf8e8075c42839424e5d3c0c97be27d | 63d2e646e100c632203b80f3d692684aa5785e68 | refs/heads/master | 2020-09-05T16:50:12.955205 | 2019-11-07T05:56:24 | 2019-11-07T05:56:24 | 218,212,923 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | package cn.how2j.trend.client;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.how2j.trend.pojo.IndexData;
@FeignClient(value = "INDEX-DATA-SERVICE", fallback = IndexDataClientFeignHystrix.class)
public interface IndexDataClient {
@GetMapping("/data/{code}")
public List<IndexData> getIndexData(@PathVariable("code") String code);
}
| [
"[email protected]"
]
| |
58f9120e0f1d420adf14e5de4189a9d9508fd21b | fd44f864349eb8b45d06ef04fa5f83cf0fb50689 | /src/main/java/com/drop/salary/SalaryApplication.java | 277dd5f444de193a5732b2c9106c697eba90b2b6 | []
| no_license | HvisionsLeo/salary | 9c1f12b0ae6418e4f2ac318838fce9e2eb6af55a | eb1655c85e8f5b2d4e8cb9e6112bba346695cdea | refs/heads/master | 2020-03-16T07:45:42.850819 | 2018-05-09T02:12:34 | 2018-05-09T02:12:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 468 | java | package com.drop.salary;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.io.IOException;
@SpringBootApplication
public class SalaryApplication {
public static void main(String[] args) {
SpringApplication.run(SalaryApplication.class, args);
try {
Runtime.getRuntime().exec("cmd /c start http://localhost:8080");
} catch (IOException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
6441494ea58c060b02d3dfe51d9134d09d77ae73 | 2ff73513e57d7e9ec972219224d74a9b6088da15 | /summer/day4_GreedyMethods/Q6_MountainWatching.java | b98a2c652df37901b3df1adad2a3fa6ad07ffd6b | []
| no_license | chuanqichen/usaco-silver-prep | 7ede4a978b3cdf496a6309284ae134d6812472c1 | 3d766bc0eb39f2451da47655afc168a50d9d520d | refs/heads/master | 2022-09-14T09:36:58.265188 | 2020-05-31T05:55:38 | 2020-05-31T05:55:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,489 | java | package day4_GreedyMethods;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Q6_MountainWatching {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int measurementCount = Integer.parseInt(in.readLine());
int change; //up or down (+ or -)
int width = 1;
int maxWidth = 0;
int oldHeight = Integer.parseInt(in.readLine());
int oldChange = 1;
int flat = 1;
for (int i = 1; i < measurementCount; i++) {
int height = Integer.parseInt(in.readLine());
change = height - oldHeight;
if (oldChange < 0 && change > 0) { //end of mountain, if there is a "\[flat lines]/"
maxWidth = Math.max(maxWidth, width);
width = 1 + flat; //includes all previous flat points and this point
} else {
width++;
}
if (change != 0) { //no use if flat doesn't add to new mountain, so reset
flat = 1;
oldChange = change;
} else {
flat++; //part of new mountain
}
if (i == measurementCount - 1) {
maxWidth = Math.max(maxWidth, width);
} //calculate final mountain that is cut off
oldHeight = height;
}
System.out.println(maxWidth);
}
}
| [
"[email protected]"
]
| |
96dc5dfca5f7b0226760a669e63504d3085b552e | d9aa7021e03a9076ba357142f6689610c612f548 | /app2/src/main/java/com/michaelfotiadis/mobiledota2/ui/core/animation/RevealAnimator.java | 917f5b69de1b03f543476f35431e8f84c80f2ba8 | []
| no_license | MikeFot/Android--Dota2-Mobile-Stats | 2368bf24a7e0a3f2110301b0a48535ce401bb740 | cd0c156f8b1271ce30b218e87b152792f39a1827 | refs/heads/master | 2020-12-02T22:18:50.133344 | 2017-08-21T13:15:44 | 2017-08-21T13:15:44 | 96,111,619 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,543 | java | package com.michaelfotiadis.mobiledota2.ui.core.animation;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.michaelfotiadis.mobiledota2.R;
public class RevealAnimator {
private static final boolean USE_REVEAL = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP;
public static void show(@NonNull final View myView) {
if (USE_REVEAL) {
// get the center for the clipping circle
final int cx = myView.getWidth() / 2;
final int cy = myView.getHeight() / 2;
// get the final radius for the clipping circle
final float finalRadius = (float) Math.hypot(cx, cy);
// create the animator for this view (the start radius is zero)
final Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();
} else {
final Animation anim = AnimationUtils.loadAnimation(myView.getContext(), R.anim.fade_in);
myView.startAnimation(anim);
}
}
public static void hide(@NonNull final View view) {
if (USE_REVEAL) {
// get the center for the clipping circle
final int cx = view.getWidth() / 2;
final int cy = view.getHeight() / 2;
// get the initial radius for the clipping circle
final float initialRadius = (float) Math.hypot(cx, cy);
// create the animation (the final radius is zero)
final Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.INVISIBLE);
}
});
// start the animation
anim.start();
} else {
final Animation anim = AnimationUtils.loadAnimation(view.getContext(), R.anim.fade_out);
view.startAnimation(anim);
}
}
}
| [
"[email protected]"
]
| |
237f7074c16048ed4c7b6b620fb31ad03dbad0fb | c2958f8c14d68e6bd2e732515de0f7daeb1f8e79 | /EscolaThiago 4.0/src/main/java/fullstack/ctrl/exception/OfertaException.java | 5e7b7e9e9ae96a31792f3378d7bc965d633862be | []
| no_license | ThiagoAnC/FSClass | 2412b1dbfe5d2c0debbfa19a0351cc23b1146588 | f62a1c3aa5db1908bb561334e43e8232cde1cc23 | refs/heads/main | 2023-04-22T18:11:33.732002 | 2021-05-07T18:48:24 | 2021-05-07T18:48:24 | 345,685,120 | 0 | 0 | null | 2021-04-23T21:13:49 | 2021-03-08T14:32:21 | Java | UTF-8 | Java | false | false | 196 | java | package br.fullstack.ctrl.exception;
public class OfertaException extends Exception {
private static final long serialVersionUID = 1L;
public OfertaException(String msg) {
super(msg);
}
}
| [
"[email protected]"
]
| |
710cedb5dbb797fc70ef9e7d6c4472da115f1e4e | 2af784ca9139f0efadc5b9ab227928bc0a3e429d | /eureka-server/src/main/java/com/udacity/EurekaServerApplication.java | 9de64a7e929d9211808cdfd812ac1b242ed4f953 | [
"MIT"
]
| permissive | abdulmateen-1/vehicle-api | 0f116dc25a86ea57df930f14436c51812f22816c | a7cba30539904f064291acaaeb0fda6080650800 | refs/heads/master | 2023-02-20T00:12:40.179325 | 2021-01-20T12:56:47 | 2021-01-20T12:56:47 | 331,131,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 421 | java | package com.udacity;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
| [
"[email protected]"
]
| |
ce1cc4a19469b0fc8fd79d25ba93b9d62a8915c8 | 5219ed8b830f2c39e481401ab794b192513ebd4f | /app/src/main/java/com/example/myshop/SnackActivity.java | f7f69d20ebbd1ef712e38fb137ee0ab7f8d06abc | []
| no_license | selowboi/MyShop | 6829c6b19f9defd238ee7d693454a9fea811a751 | 56c5a1d09abdb29a9ee22a8d6c668715812d7518 | refs/heads/master | 2023-09-04T07:19:29.463954 | 2021-10-26T09:33:17 | 2021-10-26T09:33:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,134 | java | package com.example.myshop;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Objects;
public class SnackActivity extends AppCompatActivity {
Button btnBack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_snack);
Objects.requireNonNull(getSupportActionBar()).hide();
initView();
String username = getIntent().getStringExtra("USERNAME");
onClickBack(username);
}
private void initView() {
btnBack = (Button) findViewById(R.id.btn_back_snacks);
}
private void onClickBack(String username) {
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SnackActivity.this, HomeActivity.class);
intent.putExtra("USERNAME", username);
startActivity(intent);
}
});
}
} | [
"[email protected]"
]
| |
056e243597756149c8a3d52b54258470fbd61a11 | 8a6a0827ad92829fb6afa1ecd7b84827d5d14ad4 | /ch04_di/src/com/java/aop04/MainClass.java | 499c73ea76e1bc843c1e9919f4c4c80108d37dd5 | []
| no_license | chanhok95/Spring | 7b53c991b72f7cc98132a347dcba57fefb4e1904 | a8bfbb422c37732be06da74b2077d4e46aeb4596 | refs/heads/master | 2022-12-21T10:00:59.101598 | 2019-11-27T18:46:23 | 2019-11-27T18:46:23 | 223,785,863 | 0 | 0 | null | 2022-12-16T01:08:05 | 2019-11-24T17:51:26 | JavaScript | UTF-8 | Java | false | false | 618 | java | package com.java.aop04;
import org.springframework.context.support.GenericXmlApplicationContext;
public class MainClass {
public static void main(String[] args) {
GenericXmlApplicationContext ctx = new
GenericXmlApplicationContext("classpath:com/java/aop04/appCTX.xml");
try {
Person student = (Person) ctx.getBean("student");
student.work();
System.out.println();
} catch (Throwable e) {}
// TODO: handle exception
try {
Person teacher = (Person) ctx.getBean("teacher");
teacher.work();
}catch (Throwable e) {}
// TODO: handle exception
ctx.close();
}
}
| [
"[email protected]"
]
| |
d9661f789526316bbf576ccc9d2950da606826f1 | 6f4bd865890c692f9efee7fa69b1a6b2e180b78c | /app/src/main/java/com/zlgspace/test/apttemplate/msgpraser/ParserManager.java | a4b6aae8c3dde2d14bcc372bdc8191f455ded26b | []
| no_license | zlgspace/APTTemplate | 94b8a2b9f3ec9d4ce78252d5622994f63fe92428 | a66d8aa6e9d621421d2357f184c7bbfff3cc0a67 | refs/heads/master | 2022-12-12T02:17:57.714832 | 2020-09-08T05:23:18 | 2020-09-08T05:23:18 | 287,859,394 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 666 | java | package com.zlgspace.test.apttemplate.msgpraser;
import com.zlgspace.msgpraser.MsgParser;
/**
* 对MsgParser进行了代理封装
*/
public class ParserManager {
//这里创建了一个callback 用来模拟收到消息
private static DemoCallback callback = msg -> MsgParser.parser(msg);
static{//必须在使用前设置消息解析器
MsgParser.init(new ParserAdapter());
}
public static DemoCallback getCallback() {
return callback;
}
public static void register(Object obj) {
MsgParser.register(obj);
}
public static void unRegister(Object obj) {
MsgParser.unRegister(obj);
}
}
| [
"[email protected]"
]
| |
611f51ff790c8d080962252663782d8c1ec07ea2 | 4fee5b3ac896e1d88ec94994126639186a96044a | /src/com/design/patten/template/Client.java | a1ab777f2ae30d386a09e265cb54b346dcb76ee8 | []
| no_license | tangShy/patten-master | 333b6975671e1f37f77a33703a9a980bf2c2762d | 6fe95876527a3a5390c5811079832b3d8d71bce5 | refs/heads/master | 2023-07-18T13:21:45.400120 | 2021-09-07T15:35:57 | 2021-09-07T15:36:17 | 266,457,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package com.design.patten.template;
/**
* 代理模式:解决豆浆制作问题
*/
public class Client {
public static void main(String[] args) {
//制作红豆豆浆
System.out.println("---------制作红豆豆浆----------");
SoyaMilk soyaMilk = new RedBeanSoyaMilk();
soyaMilk.make();
//制作花生豆浆
System.out.println("---------制作花生豆浆----------");
SoyaMilk soyaMilk1 = new PeanutSoyaMile();
soyaMilk1.make();
}
}
| [
"[email protected]"
]
| |
23dc74b0b4e3a607ff7c7dd424ed0cc9c10a057b | cd72a8d3cadfa48b2cf21ab1884a9a29d13ee9a3 | /app/src/main/java/com/example/taskmanager/CreateTaskActivity.java | 64e658a895402545ea8eecc2b61f347b6589b1f4 | []
| no_license | andrejpopordanoski/TaskManager | f48b8049399e9b9b10726cabc4b2df67f49eb2f8 | 0fa70712b694f22021491de9b3acec539249d9db | refs/heads/master | 2020-07-06T06:48:04.620873 | 2019-09-12T23:39:22 | 2019-09-12T23:39:22 | 202,929,274 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,477 | java | package com.example.taskmanager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.DialogFragment;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import com.example.taskmanager.Fragments.DatePickerFragment;
import com.example.taskmanager.Models.Collaborator;
import com.example.taskmanager.Models.Project;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class CreateTaskActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
private String mCurrentUserEmail;
private FirebaseAuth mAuth;
private FirebaseUser mCurrentUser;
private DatabaseReference mDatabaseUsers;
private DatabaseReference mDatabaseCurrentUser;
private DatabaseReference mDatabaseProjects;
private Project currentProject;
private Spinner spinner;
private LinearLayout dateHolder;
private TextView dateTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_task);
mAuth = FirebaseAuth.getInstance();
mCurrentUser = mAuth.getCurrentUser();
mCurrentUserEmail = mCurrentUser.getEmail();
mDatabaseCurrentUser = FirebaseDatabase.getInstance().getReference().child("users").child(mCurrentUser.getUid());
mDatabaseUsers = FirebaseDatabase.getInstance().getReference().child("users");
mDatabaseProjects = FirebaseDatabase.getInstance().getReference().child("projects");
spinner = (Spinner) findViewById(R.id.asignee_spinner);
currentProject = getIntent().getParcelableExtra("currentProject");
dateHolder = (LinearLayout) findViewById(R.id.date_holder);
dateTextView = (TextView) findViewById(R.id.chosen_date);
dateHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment datePicker = new DatePickerFragment();
datePicker.show(getSupportFragmentManager(), "date picker");
}
});
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Collaborator collab = (Collaborator) parent.getSelectedItem();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
// List<Collaborator>
}
public void changeSpinnerOptions(String collabType){
List<Collaborator> collabs = currentProject.getAllCollabsFromType(collabType);
ArrayAdapter<Collaborator> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, collabs);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.developer:
if (checked)
changeSpinnerOptions("Developer");
break;
case R.id.tester:
if (checked)
changeSpinnerOptions("Tester");
break;
}
}
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
String currentDate = DateFormat.getDateInstance(DateFormat.FULL).format(c.getTime());
dateTextView.setText(currentDate);
}
}
| [
"[email protected]"
]
| |
4916fb934964e70c64d4783d816cc271eefd4786 | 58a762615cf4981165fc3b72b3512c5da3004d03 | /src/main/java/life/jjk/community/mapper/UserMapper.java | ee8cb70647a1c8ccd26c1b572cfdd6a22fbcf223 | []
| no_license | pom7/community | 25558e4c91f313305a18ea13217c8e61d0e38489 | 51a3320f3ef70e4509f59905640ecaff77d832eb | refs/heads/master | 2022-06-22T04:15:37.500112 | 2020-02-19T06:30:30 | 2020-02-19T06:30:30 | 236,636,766 | 0 | 0 | null | 2022-06-17T02:53:12 | 2020-01-28T01:47:55 | Java | UTF-8 | Java | false | false | 579 | java | package life.jjk.community.mapper;
import life.jjk.community.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface UserMapper {
@Insert("insert into user (name,account_id,token,gmt_create,gmt_modified) values (#{name},#{accountid},#{token},#{gmtCreate},#{gmtModified})")
void insertuser(User user);
@Select("select * from user where token=#{token}")
User selectuser(@Param("token") String token);
} | [
"[email protected]"
]
| |
71a6ced6e2782a1c400c3b3317101fb0340d308b | 9260c013ab27fd71e629043bf998e1966bd2765b | /Proyecto-03/proyecto3/src/main/java/mx/unam/ciencias/edd/Diccionario.java | 055e3c2fca8e8450527d98bf911a1b45ecdf1c0c | []
| no_license | DavidHdezU/Data-Structures-Java | 5ce2382f35645c9753bb85c8c1846340b6afbf7d | 8b87df372c904eb5cb1e4b6b286a55c49f409353 | refs/heads/master | 2022-12-25T17:10:14.862805 | 2020-09-26T00:18:12 | 2020-09-26T00:18:12 | 298,704,965 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,826 | java | package mx.unam.ciencias.edd;
import java.lang.reflect.Array;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Clase para diccionarios (<em>hash tables</em>). Un diccionario generaliza el
* concepto de arreglo, mapeando un conjunto de <em>llaves</em> a una colección
* de <em>valores</em>.
*/
public class Diccionario<K, V> implements Iterable<V> {
/* Clase interna privada para entradas. */
private class Entrada {
/* La llave. */
public K llave;
/* El valor. */
public V valor;
/* Construye una nueva entrada. */
public Entrada(K llave, V valor) {
// Aquí va su código.
this.llave = llave;
this.valor = valor;
}
}
/* Clase interna privada para iteradores. */
private class Iterador {
/* En qué lista estamos. */
private int indice;
/* Iterador auxiliar. */
private Iterator<Entrada> iterador;
/* Construye un nuevo iterador, auxiliándose de las listas del
* diccionario. */
public Iterador() {
// Aquí va su código.
for(int i = 0; i < entradas.length; i++) {
if(entradas[i] != null && entradas[i].getLongitud() > 0) {
this.iterador = entradas[i].iterator();
this.indice = i;
break;
}
}
}
/* Nos dice si hay una siguiente entrada. */
public boolean hasNext() {
// Aquí va su código.
if(this.iterador == null)
return false;
return this.iterador.hasNext();
}
/* Regresa la siguiente entrada. */
public Entrada siguiente() {
// Aquí va su código.
if(this.iterador == null)
throw new NoSuchElementException();
Entrada iteradorE = this.iterador.next();
if(!this.iterador.hasNext()){
this.iterador = null;
mueveIterador();
}
return iteradorE;
}
/* Mueve el iterador a la siguiente entrada válida. */
private void mueveIterador() {
// Aquí va su código.
for(int i = this.indice + 1; i < entradas.length; i++) {
if(entradas[i] != null) {
this.indice = i;
this.iterador = entradas[i].iterator();
break;
}
}
}
}
/* Clase interna privada para iteradores de llaves. */
private class IteradorLlaves extends Iterador
implements Iterator<K> {
/* Regresa el siguiente elemento. */
@Override public K next() {
// Aquí va su código.
return this.siguiente().llave;
}
}
/* Clase interna privada para iteradores de valores. */
private class IteradorValores extends Iterador
implements Iterator<V> {
/* Regresa el siguiente elemento. */
@Override public V next() {
// Aquí va su código.
return this.siguiente().valor;
}
}
/** Máxima carga permitida por el diccionario. */
public static final double MAXIMA_CARGA = 0.72;
/* Capacidad mínima; decidida arbitrariamente a 2^6. */
private static final int MINIMA_CAPACIDAD = 64;
/* Dispersor. */
private Dispersor<K> dispersor;
/* Nuestro diccionario. */
private Lista<Entrada>[] entradas;
/* Número de valores. */
private int elementos;
/* Truco para crear un arreglo genérico. Es necesario hacerlo así por cómo
Java implementa sus genéricos; de otra forma obtenemos advertencias del
compilador. */
@SuppressWarnings("unchecked")
private Lista<Entrada>[] nuevoArreglo(int n) {
return (Lista<Entrada>[])Array.newInstance(Lista.class, n);
}
/**
* Construye un diccionario con una capacidad inicial y dispersor
* predeterminados.
*/
public Diccionario() {
this(MINIMA_CAPACIDAD, (K llave) -> llave.hashCode());
}
/**
* Construye un diccionario con una capacidad inicial definida por el
* usuario, y un dispersor predeterminado.
* @param capacidad la capacidad a utilizar.
*/
public Diccionario(int capacidad) {
this(capacidad, (K llave) -> llave.hashCode());
}
/**
* Construye un diccionario con una capacidad inicial predeterminada, y un
* dispersor definido por el usuario.
* @param dispersor el dispersor a utilizar.
*/
public Diccionario(Dispersor<K> dispersor) {
this(MINIMA_CAPACIDAD, dispersor);
}
/**
* Construye un diccionario con una capacidad inicial y un método de
* dispersor definidos por el usuario.
* @param capacidad la capacidad inicial del diccionario.
* @param dispersor el dispersor a utilizar.
*/
public Diccionario(int capacidad, Dispersor<K> dispersor) {
// Aquí va su código.
this.dispersor = dispersor;
if(capacidad < MINIMA_CAPACIDAD){
capacidad = MINIMA_CAPACIDAD;
}
int pot = 1;
while (pot < capacidad * 2) {
pot *= 2;
}
this.entradas = this.nuevoArreglo(pot);
this.elementos = 0;
}
/**
* Agrega un nuevo valor al diccionario, usando la llave proporcionada. Si
* la llave ya había sido utilizada antes para agregar un valor, el
* diccionario reemplaza ese valor con el recibido aquí.
* @param llave la llave para agregar el valor.
* @param valor el valor a agregar.
* @throws IllegalArgumentException si la llave o el valor son nulos.
*/
public void agrega(K llave, V valor) {
// Aquí va su código.
if(llave == null || valor == null){
throw new IllegalArgumentException();
}
int i = getMascara(llave);
Entrada entradaDispersor = new Entrada(llave, valor);
if(this.entradas[i] == null){
this.entradas[i] = new Lista<>();
}else{
for(Entrada en : this.entradas[i]){
if(en.llave.equals(llave)){
en.valor = valor;
return;
}
}
}
this.entradas[i].agrega(entradaDispersor);
this.elementos++;
if(this.carga() >= MAXIMA_CARGA){
doblarArreglo();
}
}
/**
* Regresa la mascara de la llave
* @param llave - llave a usar
* @return - la mascara de la llave
*/
private int getMascara(K llave){
int mascara = this.entradas.length - 1;
return this.dispersor.dispersa(llave) & mascara;
}
/**
* Método para duplicar la longitud del arreglo
*/
private void doblarArreglo(){
Lista<Entrada>[] listaAnterior = this.entradas;
this.entradas = nuevoArreglo(this.entradas.length * 2);
for(Lista<Entrada> listas: listaAnterior){
if(listas != null){
for(Entrada en : listas){
int llaves = getMascara(en.llave);
if(this.entradas[llaves] == null){
this.entradas[llaves] = new Lista<>();
}
this.entradas[llaves].agrega(en);
}
}
}
}
/**
* Regresa el valor del diccionario asociado a la llave proporcionada.
* @param llave la llave para buscar el valor.
* @return el valor correspondiente a la llave.
* @throws IllegalArgumentException si la llave es nula.
* @throws NoSuchElementException si la llave no está en el diccionario.
*/
public V get(K llave) {
// Aquí va su código.
if(llave == null)
throw new IllegalArgumentException();
int i = getMascara(llave);
if(this.entradas[i] == null)
throw new NoSuchElementException();
for(Entrada en : this.entradas[i]){
if(en.llave.equals(llave)){
return en.valor;
}
}
throw new NoSuchElementException();
}
/**
* Nos dice si una llave se encuentra en el diccionario.
* @param llave la llave que queremos ver si está en el diccionario.
* @return <code>true</code> si la llave está en el diccionario,
* <code>false</code> en otro caso.
*/
public boolean contiene(K llave) {
// Aquí va su código.
if(llave == null)
return false;
int i = getMascara(llave);
if(this.entradas[i] == null)
return false;
for(Entrada en : this.entradas[i]){
if(en.llave.equals(llave)){
return true;
}
}
return false;
}
/**
* Elimina el valor del diccionario asociado a la llave proporcionada.
* @param llave la llave para buscar el valor a eliminar.
* @throws IllegalArgumentException si la llave es nula.
* @throws NoSuchElementException si la llave no se encuentra en
* el diccionario.
*/
public void elimina(K llave) {
// Aquí va su código.
if(llave == null)
throw new IllegalArgumentException();
int i = getMascara(llave);
if(this.entradas[i] == null){
throw new NoSuchElementException();
}
for(Entrada en : this.entradas[i]){
if(en.llave.equals(llave)){
this.entradas[i].elimina(en);
this.elementos--;
}
}
}
/**
* Nos dice cuántas colisiones hay en el diccionario.
* @return cuántas colisiones hay en el diccionario.
*/
public int colisiones() {
// Aquí va su código.
int cont = 0;
for(Lista<Entrada> lista : this.entradas){
if(lista == null){
cont += 0;
}else{
cont += lista.getLongitud() - 1;
}
}
return cont;
}
/**
* Nos dice el máximo número de colisiones para una misma llave que tenemos
* en el diccionario.
* @return el máximo número de colisiones para una misma llave.
*/
public int colisionMaxima() {
// Aquí va su código.
if(this.elementos == 0){
return 0;
}
int maximo = 0;
int aux = 0;
for(Lista<Entrada> lista : this.entradas){
if(lista != null){
aux = lista.getLongitud() - 1;
if(aux > maximo){
maximo = aux;
}
}
}
return maximo;
}
/**
* Nos dice la carga del diccionario.
* @return la carga del diccionario.
*/
public double carga() {
// Aquí va su código.
return (double)this.elementos/this.entradas.length;
}
/**
* Regresa el número de entradas en el diccionario.
* @return el número de entradas en el diccionario.
*/
public int getElementos() {
// Aquí va su código.
return this.elementos;
}
/**
* Nos dice si el diccionario es vacío.
* @return <code>true</code> si el diccionario es vacío, <code>false</code>
* en otro caso.
*/
public boolean esVacia() {
// Aquí va su código.
return this.elementos == 0;
}
/**
* Limpia el diccionario de elementos, dejándolo vacío.
*/
public void limpia() {
// Aquí va su código.
this.entradas = nuevoArreglo(this.entradas.length);
this.elementos = 0;
}
/**
* Regresa una representación en cadena del diccionario.
* @return una representación en cadena del diccionario.
*/
@Override public String toString() {
// Aquí va su código.
String res = "{ ";
if(esVacia()){
return "{}";
}
Iterador ite = new Iterador();
while(ite.hasNext()){
Entrada en = ite.siguiente();
res += "'" + en.llave.toString() + "': " + "'" + en.valor.toString() + "', ";
}
res += "}";
return res;
}
/**
* Nos dice si el diccionario es igual al objeto recibido.
* @param o el objeto que queremos saber si es igual al diccionario.
* @return <code>true</code> si el objeto recibido es instancia de
* Diccionario, y tiene las mismas llaves asociadas a los mismos
* valores.
*/
@Override public boolean equals(Object o) {
if (o == null || getClass() != o.getClass())
return false;
@SuppressWarnings("unchecked") Diccionario<K, V> d =
(Diccionario<K, V>)o;
// Aquí va su código.
if(this.elementos != d.getElementos())
return false;
Iterator<K> ite = iteradorLlaves();
while(ite.hasNext()){
K llave = ite.next();
if( !d.contiene(llave)|| !d.get(llave).equals(get(llave))){
return false;
}
}
return true;
}
/**
* Regresa un iterador para iterar las llaves del diccionario. El
* diccionario se itera sin ningún orden específico.
* @return un iterador para iterar las llaves del diccionario.
*/
public Iterator<K> iteradorLlaves() {
return new IteradorLlaves();
}
/**
* Regresa un iterador para iterar los valores del diccionario. El
* diccionario se itera sin ningún orden específico.
* @return un iterador para iterar los valores del diccionario.
*/
@Override public Iterator<V> iterator() {
return new IteradorValores();
}
}
| [
"[email protected]"
]
| |
d661ec249233ce3d90f0ed3ad52abb125e303be6 | dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9 | /data_defect4j/preprossed_method_corpus/Lang/36/org/apache/commons/lang3/ArrayUtils_indexOf_1905.java | a056f6b538d54a6d1b01c4acb0e07274a6d5e0d8 | []
| no_license | hvdthong/NetML | dca6cf4d34c5799b400d718e0a6cd2e0b167297d | 9bb103da21327912e5a29cbf9be9ff4d058731a5 | refs/heads/master | 2021-06-30T15:03:52.618255 | 2020-10-07T01:58:48 | 2020-10-07T01:58:48 | 150,383,588 | 1 | 1 | null | 2018-09-26T07:08:45 | 2018-09-26T07:08:44 | null | UTF-8 | Java | false | false | 5,704 | java |
org apach common lang3
oper arrai primit arrai code code
primit wrapper arrai code integ code
handl code code input gracefulli
except thrown code code
arrai input object arrai code code
element except method document behaviour
author apach softwar foundat
author moritz petersen
author href mailto fredrik westermarck fredrik westermarck
author nikolai metchev
author matthew hawthorn
author tim brien o'brien
author pete gieser
author gari gregori
author href mailto equinus100 hotmail ashwin
author maarten coen
version
arrai util arrayutil
find index arrai start index
method index fall region
defin find valuetofind toler find valuetofind toler
method return link index found code code code code input arrai
neg start index startindex treat start index startindex larger arrai
length link index found code code
param arrai arrai search object code code
param find valuetofind find
param start index startindex index start search
param toler toler search
index arrai
link index found code code found code code arrai input
index indexof arrai find valuetofind start index startindex toler
arrai util arrayutil empti isempti arrai
index found
start index startindex
start index startindex
min find valuetofind toler
max find valuetofind toler
start index startindex arrai length
arrai min arrai max
index found
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.