blob_id
stringlengths 40
40
| language
stringclasses 1
value | repo_name
stringlengths 5
132
| path
stringlengths 2
382
| src_encoding
stringclasses 34
values | length_bytes
int64 9
3.8M
| score
float64 1.5
4.94
| int_score
int64 2
5
| detected_licenses
listlengths 0
142
| license_type
stringclasses 2
values | text
stringlengths 9
3.8M
| download_success
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
e075b45c03e281980770cfe0cdf1100e22ce4e32
|
Java
|
Aymanov1/otome-backend
|
/src/main/java/com/hrdatabank/otome/repositories/JobRepository.java
|
UTF-8
| 3,893
| 2.03125
| 2
|
[] |
no_license
|
package com.hrdatabank.otome.repositories;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.hrdatabank.otome.domain.Job;
// TODO: Auto-generated Javadoc
/**
* The Interface JobRepository.
*/
@Repository
public interface JobRepository extends JpaRepository<Job, Serializable>, JpaSpecificationExecutor<Job> {
/**
* Copyright (c) 2019 by HRDatabank. All rights reserved.
*
* @author Aymanov
*
* Using JRE: 1.8
*
* Project Name: otome-backend
*
* Class Name: JobRepository.java
*
* Gets the checked jsen jobs by id job detail.
* @param idJobDetail the id job detail
* @return the checked jsen jobs by id job detail
*/
@Query(value = "SELECT j FROM Job j where (lower(j.interviewType) like lower('affiliate')) and j.status = TRUE and j.idJobDetail =:idJobDetail and j.jobURL LIKE CONCAT('%','j-sen','%')")
public List<Job> getCheckedJsenJobsByIdJobDetail(@Param("idJobDetail") String idJobDetail);
/**
* Copyright (c) 2019 by HRDatabank. All rights reserved.
*
* @author Aymanov
*
* Using JRE: 1.8
*
* Project Name: otome-backend
*
* Class Name: JobRepository.java
*
* Gets the checked lacotto jobs by id job detail.
* @param idJobDetail the id job detail
* @return the checked lacotto jobs by id job detail
*/
@Query(value = "SELECT j FROM Job j where (lower(j.interviewType) like lower('affiliate')) and j.status = TRUE and j.idJobDetail =:idJobDetail and j.jobURL LIKE CONCAT('%','lacotto','%')")
public List<Job> getCheckedLacottoJobsByIdJobDetail(@Param("idJobDetail") String idJobDetail);
/**
* Copyright (c) 2019 by HRDatabank. All rights reserved.
*
* @author Aymanov
*
* Using JRE: 1.8
*
* Project Name: otome-backend
*
* Class Name: JobRepository.java
*
* Find all jobs by affiliate injection date.
* @param affiliateType the affiliate type
* @param injectionDate the injection date
* @param pageable the pageable
* @return the page
*/
@Query(value = "SELECT j FROM Job j where j.affiliateType like %:type% and j.injectionDate = :injectionDate")
public Page<Job> findAllJobsByAffiliateInjectionDate(@Param("type") String affiliateType,
@Param("injectionDate") LocalDate injectionDate, Pageable pageable);
/**
* Copyright (c) 2019 by HRDatabank. All rights reserved.
*
* @author Aymanov
*
* Using JRE: 1.8
*
* Project Name: otome-backend
*
* Class Name: JobRepository.java
*
* Find all jobs by affiliate injection date.
* @param affiliateType the affiliate type
* @param injectionDate the injection date
* @return the list
*/
@Query(value = "SELECT j FROM Job j where j.affiliateType like %:type% and j.injectionDate = :injectionDate")
public List<Job> findAllJobsByAffiliateInjectionDate(@Param("type") String affiliateType,
@Param("injectionDate") LocalDate injectionDate);
/**
* Copyright (c) 2019 by HRDatabank. All rights reserved.
*
* @author Aymanov
*
* Using JRE: 1.8
*
* Project Name: otome-backend
*
* Class Name: JobRepository.java
*
* Count all jobs by affiliate injection date.
* @param affiliateType the affiliate type
* @param injectionDate the injection date
* @return the int
*/
@Query(value = "SELECT count(j) FROM Job j where j.affiliateType like %:type% and j.injectionDate = :injectionDate")
public int countAllJobsByAffiliateInjectionDate(@Param("type") String affiliateType,
@Param("injectionDate") LocalDate injectionDate);
}
| true
|
c70acf4c4d49c70571cb121759001c3f8f70fd86
|
Java
|
Bisharp/AppliedJava
|
/DigIt3/src/com/dig/www/start/Switch/SwitchMenu.java
|
UTF-8
| 3,138
| 2.609375
| 3
|
[] |
no_license
|
package com.dig.www.start.Switch;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import com.dig.www.MultiPlayer.State.SwitchState;
import com.dig.www.character.GameCharacter;
import com.dig.www.start.Board;
import com.dig.www.util.Statics;
public class SwitchMenu extends JFrame{
private Board owner;
private DefaultListModel<String>listMod=new DefaultListModel<String>();
private JList<String>list=new JList<String>(listMod);
public SwitchMenu(Board owner){
this.owner=owner;
setSize(400,300);
setLocation(Statics.BOARD_WIDTH/2-this.getWidth()/2,0);
setAlwaysOnTop(true);
setFocusable(false);
//requestFocus();
setUndecorated(true);
String[]alive=owner.getCharacters();
for(String element:alive)
listMod.addElement(element);
setLayout(new BorderLayout());
JPanel south=new JPanel();
JButton switchB=new JButton("switch");
switchB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Board b=SwitchMenu.this.owner;
if(list.getSelectedIndex()>=0){
int des=b.getFriend(list.getSelectedValue());
GameCharacter temp=b.getCharacter();
if (b.getCurrentState() != null)
b.getCurrentState().getActions().add(new SwitchState(temp.getType().charName(), list.getSelectedValue()));
temp.setPlayer(false);
b.setCharacter(b.getFriends().get(des));
b.getFriends().set(des, temp);
b.getCharacter().setPlayer(true);
b.scroll(Statics.BOARD_WIDTH / 2 - 50 - b.getCharacter().getX(), (int) Statics.BOARD_HEIGHT / 2 - 50 - b.getCharacter().getY());
b.getCharacter().stop();
Collections.sort(b.getFriends());
b.setFocusable(true);
b.requestFocus();
b.setSwitchingMenu(null);
SwitchMenu.this.dispose();
}}
});
south.add(switchB);
JButton cancel=new JButton("cancel");
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Board b=SwitchMenu.this.owner;
b.setFocusable(true);
b.requestFocus();
b.setSwitchingMenu(null);
SwitchMenu.this.dispose();
}
});
south.add(cancel);
this.add(list,BorderLayout.CENTER);
this.add(south,BorderLayout.SOUTH);
owner.setSwitchingMenu(this);
setVisible(true);
list.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
// TODO Auto-generated method stub
SwitchMenu.this.owner.requestFocus();
}
});
if(listMod.size()>0){
list.setSelectedIndex(0);
}
}
public void updateList(){
String selected=list.getSelectedValue();
listMod.clear();
String[]alive=owner.getCharacters();
for(String element:alive)
listMod.addElement(element);
if(listMod.contains(selected))
list.setSelectedValue(selected, true);
}
}
| true
|
1d105fc55f1fa8dcca6f4c47681760ab66fa4a98
|
Java
|
sachith94-lion/solace-library
|
/solace library project/src/solace/library/Members.java
|
UTF-8
| 68,638
| 2.21875
| 2
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package solace.library;
import AppPackage.AnimationClass;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.util.Timer;
import java.util.TimerTask;
import net.proteanit.sql.DbUtils;
/**
*
* @author sachith
*/
public class Members extends javax.swing.JPanel {
/**
* Creates new form Members
*/
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
private String M_Type;
private String MM_Type;
static Timer t;
static TimerTask task;
public Members() {
initComponents();
cardpanel.setBackground(new Color(0,0,0,0));
pnl_regmem.setVisible(false);
pnl_editmem.setVisible(false);
lbl_member_white.setVisible(true);
lbl_memwhite.setVisible(true);
pnl_IDprint.setVisible(false);
btn_regmember.setEnabled(true);
btn_editmem.setEnabled(true);
btn_memC.setEnabled(true);
lbl_back2.setVisible(false);
lbl_reset.setVisible(false);
//connect to DB
con = DBconnection.connect();
member_table.getTableHeader().setReorderingAllowed(false);
tableload();
memid();
}
public void memid(){
try {
String selectq="select count(Member_ID) from members";
pst = con.prepareStatement(selectq);
rs=pst.executeQuery();
while(rs.next()){
String sum=rs.getString("count(Member_ID)");
int c = Integer.parseInt(sum);
txt_regmemberid.setText("sol-0"+(c+1));
}
} catch (Exception e) {
}
}
// Method For To Print Panel Contents
private void printRecord(JPanel panel){
// Create PrinterJob Here
PrinterJob printerJob = PrinterJob.getPrinterJob();
// Set Printer Job Name
printerJob.setJobName("Print Record");
// Set Printable
printerJob.setPrintable(new Printable() {
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
// Check If No Printable Content
if(pageIndex > 0){
return Printable.NO_SUCH_PAGE;
}
// Make 2D Graphics to map content
Graphics2D graphics2D = (Graphics2D)graphics;
// Set Graphics Translations
// A Little Correction here Multiplication was not working so I replaced with addition
graphics2D.translate(pageFormat.getImageableX()+10, pageFormat.getImageableY()+10);
// This is a page scale. Default should be 0.3 I am using 0.5
graphics2D.scale(0.5, 0.5);
// Now paint panel as graphics2D
panel.paint(graphics2D);
// return if page exists
return Printable.PAGE_EXISTS;
}
});
// Store printerDialog as boolean
boolean returningResult = printerJob.printDialog();
// check if dilog is showing
if(returningResult){
// Use try catch exeption for failure
try{
// Now call print method inside printerJob to print
printerJob.print();
}catch (PrinterException printerException){
JOptionPane.showMessageDialog(this, "Print Error: " + printerException.getMessage());
}
}
}
public void time(){
t = new Timer();
task = new TimerTask() {
@Override
public void run() {
btn_regmember.setEnabled(true);
btn_editmem.setEnabled(true);
btn_memC.setEnabled(true);
System.out.println("done");
}
};
t.schedule(task, 1500);
}
public void backtime(){
t = new Timer();
task = new TimerTask() {
@Override
public void run() {
lbl_back2.setVisible(true);
System.out.println("Back Done");
}
};
t.schedule(task, 1500);
}
public void clear(){
txt_memberid.setText("");
txt_telno.setText("");
txt_name.setText("");
txt_address.setText("");
txt_email.setText("");
txt_idno.setText("");
rad_MStaff.setSelected(false);
rad_MStudent1.setSelected(false);
}
public void tableload(){
try {
String selectq = "select Member_ID,Name,Telephone,Address,Email,ID_No,Member_Type,Registered_Date,Registered_admin from members";
pst = con.prepareStatement(selectq);
rs=pst.executeQuery();
member_table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
}
}
void out(){
AnimationClass anim = new AnimationClass();
//member reg
anim.jButtonXLeft(250, -130, 1, 2, btn_regmember);
anim.jLabelXLeft(190, -260, 1, 2, lbl_memregwhite);
//Edit member
anim.jButtonXRight(630, 1000, 1, 2, btn_editmem);
anim.jLabelXRight(610, 1000, 1, 2, lbl_editmem);
//member card
anim.jButtonYDown(370, 600, 1, 2, btn_memC);
anim.jLabelYDown(470, 650, 1, 2, lbl_memc);
anim.jLabelXLeft(0, -1000, 1, 4, lbl_blue);
anim.jLabelXLeft(0, -1000, 2, 4, lbl_blue2);
anim.jLabelXLeft(0, -1000, 3, 4, lbl_blue3);
anim.jLabelXRight(0, 1000, 1, 4, lbl_green);
anim.jLabelXRight(0, 1000, 2, 4, lbl_green2);
anim.jLabelXRight(0, 1000, 3, 4, lbl_green3);
}
void in(){
AnimationClass anim = new AnimationClass();
//member reg
anim.jButtonXRight(-130,250, 5, 2, btn_regmember);
anim.jLabelXRight(-260, 190, 5, 2, lbl_memregwhite);
//Edit member
anim.jButtonXLeft(1000, 630, 4, 2, btn_editmem);
anim.jLabelXLeft(1000, 610, 4, 2, lbl_editmem);
//member card
anim.jButtonYUp(600, 370, 5, 2, btn_memC);
anim.jLabelYUp(650, 470, 6, 2, lbl_memc);
anim.jLabelXRight(-1000, 0, 3, 4, lbl_blue);
anim.jLabelXRight(-1000, 0, 2, 4, lbl_blue2);
anim.jLabelXRight(-1000, 0, 1, 4, lbl_blue3);
anim.jLabelXLeft(1000, 0, 3, 4, lbl_green);
anim.jLabelXLeft(1000, 0, 2, 4, lbl_green2);
anim.jLabelXLeft(1000, 0, 1, 4, lbl_green3);
}
/**
* 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() {
lbl_memc = new javax.swing.JLabel();
lbl_reset = new javax.swing.JLabel();
btn_memC = new javax.swing.JButton();
btn_editmem = new javax.swing.JButton();
lbl_editmem = new javax.swing.JLabel();
lbl_memregwhite = new javax.swing.JLabel();
lbl_member_white = new javax.swing.JLabel();
lbl_memwhite = new javax.swing.JLabel();
btn_regmember = new javax.swing.JButton();
lbl_blue = new javax.swing.JLabel();
lbl_blue2 = new javax.swing.JLabel();
lbl_blue3 = new javax.swing.JLabel();
lbl_green = new javax.swing.JLabel();
lbl_green2 = new javax.swing.JLabel();
lbl_green3 = new javax.swing.JLabel();
lbl_back2 = new javax.swing.JLabel();
lbl_dashicon = new javax.swing.JLabel();
lbl_Dashboard2 = new javax.swing.JLabel();
pnl_editmem = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
lbl_name7 = new javax.swing.JLabel();
lbl_name8 = new javax.swing.JLabel();
txt_name = new javax.swing.JTextField();
jSeparator9 = new javax.swing.JSeparator();
btn_reset = new javax.swing.JButton();
lbl_name9 = new javax.swing.JLabel();
txt_idno = new javax.swing.JTextField();
jSeparator10 = new javax.swing.JSeparator();
lbl_name10 = new javax.swing.JLabel();
txt_email = new javax.swing.JTextField();
jSeparator11 = new javax.swing.JSeparator();
lbl_name11 = new javax.swing.JLabel();
txt_telno = new javax.swing.JTextField();
jSeparator12 = new javax.swing.JSeparator();
lbl_name12 = new javax.swing.JLabel();
txt_address = new javax.swing.JTextField();
jSeparator13 = new javax.swing.JSeparator();
lbl_name13 = new javax.swing.JLabel();
txt_memberid = new javax.swing.JTextField();
jSeparator14 = new javax.swing.JSeparator();
btn_update = new javax.swing.JButton();
btn_delete = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
member_table = new javax.swing.JTable();
jPanel2 = new javax.swing.JPanel();
lbl_Dashboard14 = new javax.swing.JLabel();
txt_search_memid = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
rad_MStudent1 = new javax.swing.JRadioButton();
rad_MStaff = new javax.swing.JRadioButton();
lbl_name16 = new javax.swing.JLabel();
pnl_regmem = new javax.swing.JPanel();
lbl_name = new javax.swing.JLabel();
jSeparator3 = new javax.swing.JSeparator();
txt_regname = new javax.swing.JTextField();
jSeparator4 = new javax.swing.JSeparator();
txt_regidno = new javax.swing.JTextField();
lbl_name1 = new javax.swing.JLabel();
txt_regemail = new javax.swing.JTextField();
jSeparator5 = new javax.swing.JSeparator();
jSeparator6 = new javax.swing.JSeparator();
txt_regtel = new javax.swing.JTextField();
lbl_name3 = new javax.swing.JLabel();
jSeparator7 = new javax.swing.JSeparator();
txt_regaddress = new javax.swing.JTextField();
lbl_name4 = new javax.swing.JLabel();
lbl_name5 = new javax.swing.JLabel();
txt_regmemberid = new javax.swing.JTextField();
jSeparator8 = new javax.swing.JSeparator();
btn_regmembers = new javax.swing.JButton();
lbl_name6 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
rad_Staff = new javax.swing.JRadioButton();
rad_Student1 = new javax.swing.JRadioButton();
lbl_name14 = new javax.swing.JLabel();
lbl_name15 = new javax.swing.JLabel();
btn_mem_card = new javax.swing.JButton();
pnl_IDprint = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
txt_isbn_print = new javax.swing.JTextField();
lbl_Dashboard16 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
cardpanel = new javax.swing.JPanel();
lbl_add = new javax.swing.JLabel();
lbl_namep = new javax.swing.JLabel();
lbl_NIC = new javax.swing.JLabel();
lbl_memID1 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
btn_printID = new javax.swing.JButton();
lbl_Dashboard15 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
btn_backtoReg = new javax.swing.JButton();
setBackground(new java.awt.Color(242, 242, 242));
setPreferredSize(new java.awt.Dimension(930, 590));
setLayout(null);
lbl_memc.setBackground(new java.awt.Color(255, 255, 255));
lbl_memc.setFont(new java.awt.Font("Century Gothic", 0, 24)); // NOI18N
lbl_memc.setForeground(new java.awt.Color(255, 255, 255));
lbl_memc.setText("Membership Card");
add(lbl_memc);
lbl_memc.setBounds(140, 470, 230, 60);
lbl_reset.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
lbl_reset.setForeground(new java.awt.Color(0, 0, 0));
lbl_reset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/settings.png"))); // NOI18N
lbl_reset.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
lbl_reset.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl_resetMouseClicked(evt);
}
});
add(lbl_reset);
lbl_reset.setBounds(880, 530, 40, 60);
btn_memC.setBackground(new java.awt.Color(0, 85, 127));
btn_memC.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/mem card.png"))); // NOI18N
btn_memC.setBorder(null);
btn_memC.setBorderPainted(false);
btn_memC.setContentAreaFilled(false);
btn_memC.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
btn_memC.setDefaultCapable(false);
btn_memC.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/mem card.png"))); // NOI18N
btn_memC.setDoubleBuffered(true);
btn_memC.setFocusable(false);
btn_memC.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/mem card black.png"))); // NOI18N
btn_memC.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_memCActionPerformed(evt);
}
});
add(btn_memC);
btn_memC.setBounds(180, 370, 140, 120);
btn_editmem.setBackground(new java.awt.Color(0, 85, 127));
btn_editmem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/management (1).png"))); // NOI18N
btn_editmem.setBorder(null);
btn_editmem.setBorderPainted(false);
btn_editmem.setContentAreaFilled(false);
btn_editmem.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
btn_editmem.setDefaultCapable(false);
btn_editmem.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/management (1).png"))); // NOI18N
btn_editmem.setDoubleBuffered(true);
btn_editmem.setFocusable(false);
btn_editmem.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btn_editmem.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/management.png"))); // NOI18N
btn_editmem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_editmemActionPerformed(evt);
}
});
add(btn_editmem);
btn_editmem.setBounds(630, 240, 128, 128);
lbl_editmem.setBackground(new java.awt.Color(255, 255, 255));
lbl_editmem.setFont(new java.awt.Font("Century Gothic", 0, 24)); // NOI18N
lbl_editmem.setForeground(new java.awt.Color(255, 255, 255));
lbl_editmem.setText("Edit Members");
add(lbl_editmem);
lbl_editmem.setBounds(610, 380, 170, 20);
lbl_memregwhite.setBackground(new java.awt.Color(255, 255, 255));
lbl_memregwhite.setFont(new java.awt.Font("Century Gothic", 0, 24)); // NOI18N
lbl_memregwhite.setForeground(new java.awt.Color(255, 255, 255));
lbl_memregwhite.setText("Member Registration");
add(lbl_memregwhite);
lbl_memregwhite.setBounds(190, 240, 260, 20);
lbl_member_white.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
lbl_member_white.setForeground(new java.awt.Color(105, 105, 105));
lbl_member_white.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/multiple-users-white.png"))); // NOI18N
add(lbl_member_white);
lbl_member_white.setBounds(10, 10, 40, 40);
lbl_memwhite.setBackground(new java.awt.Color(255, 255, 255));
lbl_memwhite.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
lbl_memwhite.setForeground(new java.awt.Color(255, 255, 255));
lbl_memwhite.setText("Members");
add(lbl_memwhite);
lbl_memwhite.setBounds(50, 20, 110, 20);
btn_regmember.setBackground(new java.awt.Color(0, 85, 127));
btn_regmember.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add member over.png"))); // NOI18N
btn_regmember.setBorder(null);
btn_regmember.setBorderPainted(false);
btn_regmember.setContentAreaFilled(false);
btn_regmember.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
btn_regmember.setDefaultCapable(false);
btn_regmember.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add member over.png"))); // NOI18N
btn_regmember.setDoubleBuffered(true);
btn_regmember.setFocusable(false);
btn_regmember.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btn_regmember.setPreferredSize(new java.awt.Dimension(128, 128));
btn_regmember.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add member black.png"))); // NOI18N
btn_regmember.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_regmemberActionPerformed(evt);
}
});
add(btn_regmember);
btn_regmember.setBounds(250, 110, 128, 128);
lbl_blue.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/regcolorpnl.png"))); // NOI18N
add(lbl_blue);
lbl_blue.setBounds(0, 0, 930, 590);
lbl_blue2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/regcolorpnl2.png"))); // NOI18N
add(lbl_blue2);
lbl_blue2.setBounds(0, 0, 930, 590);
lbl_blue3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/regcolorpnl3.png"))); // NOI18N
add(lbl_blue3);
lbl_blue3.setBounds(0, 0, 930, 590);
lbl_green.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/managecolorpnl.png"))); // NOI18N
add(lbl_green);
lbl_green.setBounds(0, 0, 930, 590);
lbl_green2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/managecolorpnl2.png"))); // NOI18N
add(lbl_green2);
lbl_green2.setBounds(0, 0, 930, 590);
lbl_green3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/managecolorpnl3.png"))); // NOI18N
add(lbl_green3);
lbl_green3.setBounds(0, 0, 930, 590);
lbl_back2.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
lbl_back2.setForeground(new java.awt.Color(30, 25, 24));
lbl_back2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/back-arrow.png"))); // NOI18N
lbl_back2.setText("Back");
lbl_back2.setToolTipText("");
lbl_back2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
lbl_back2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lbl_back2MouseClicked(evt);
}
});
add(lbl_back2);
lbl_back2.setBounds(40, 530, 71, 24);
lbl_dashicon.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
lbl_dashicon.setForeground(new java.awt.Color(105, 105, 105));
lbl_dashicon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/multiple-users-silhouette.png"))); // NOI18N
add(lbl_dashicon);
lbl_dashicon.setBounds(10, 10, 40, 40);
lbl_Dashboard2.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
lbl_Dashboard2.setForeground(new java.awt.Color(105, 105, 105));
lbl_Dashboard2.setText("Members");
add(lbl_Dashboard2);
lbl_Dashboard2.setBounds(50, 20, 110, 20);
pnl_editmem.setBackground(new java.awt.Color(242, 242, 242));
pnl_editmem.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/editmembers.png"))); // NOI18N
pnl_editmem.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 0, 40, 40));
lbl_name7.setFont(new java.awt.Font("Century Gothic", 0, 22)); // NOI18N
lbl_name7.setForeground(new java.awt.Color(105, 105, 105));
lbl_name7.setText("Edit Members");
lbl_name7.setToolTipText("");
pnl_editmem.add(lbl_name7, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 0, 170, -1));
lbl_name8.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name8.setForeground(new java.awt.Color(105, 105, 105));
lbl_name8.setText("Name:");
lbl_name8.setToolTipText("");
pnl_editmem.add(lbl_name8, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 310, 60, -1));
txt_name.setBackground(new java.awt.Color(242, 242, 242));
txt_name.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_name.setForeground(new java.awt.Color(0, 0, 0));
txt_name.setBorder(null);
pnl_editmem.add(txt_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 330, 300, 30));
jSeparator9.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator9, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 360, 300, 10));
btn_reset.setBackground(new java.awt.Color(0, 167, 250));
btn_reset.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
btn_reset.setForeground(new java.awt.Color(255, 255, 255));
btn_reset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/reset button.png"))); // NOI18N
btn_reset.setText("Reset");
btn_reset.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_resetMouseClicked(evt);
}
});
pnl_editmem.add(btn_reset, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 500, 150, 40));
lbl_name9.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name9.setForeground(new java.awt.Color(105, 105, 105));
lbl_name9.setText("ID No:");
lbl_name9.setToolTipText("");
pnl_editmem.add(lbl_name9, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 390, 60, -1));
txt_idno.setBackground(new java.awt.Color(242, 242, 242));
txt_idno.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_idno.setForeground(new java.awt.Color(0, 0, 0));
txt_idno.setBorder(null);
pnl_editmem.add(txt_idno, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 410, 300, 30));
jSeparator10.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator10, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 440, 300, 10));
lbl_name10.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name10.setForeground(new java.awt.Color(105, 105, 105));
lbl_name10.setText("Member Type:");
lbl_name10.setToolTipText("");
pnl_editmem.add(lbl_name10, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 450, 120, -1));
txt_email.setBackground(new java.awt.Color(242, 242, 242));
txt_email.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_email.setForeground(new java.awt.Color(0, 0, 0));
txt_email.setBorder(null);
pnl_editmem.add(txt_email, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 400, 300, 30));
jSeparator11.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator11, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 430, 300, 10));
lbl_name11.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name11.setForeground(new java.awt.Color(105, 105, 105));
lbl_name11.setText("Telephone No:");
lbl_name11.setToolTipText("");
pnl_editmem.add(lbl_name11, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 250, 130, -1));
txt_telno.setBackground(new java.awt.Color(242, 242, 242));
txt_telno.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_telno.setForeground(new java.awt.Color(0, 0, 0));
txt_telno.setBorder(null);
pnl_editmem.add(txt_telno, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 270, 300, 30));
jSeparator12.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator12, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 300, 300, 10));
lbl_name12.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name12.setForeground(new java.awt.Color(105, 105, 105));
lbl_name12.setText("Address:");
lbl_name12.setToolTipText("");
pnl_editmem.add(lbl_name12, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 320, 90, -1));
txt_address.setBackground(new java.awt.Color(242, 242, 242));
txt_address.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_address.setForeground(new java.awt.Color(0, 0, 0));
txt_address.setBorder(null);
pnl_editmem.add(txt_address, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 340, 300, 30));
jSeparator13.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator13, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 370, 300, 10));
lbl_name13.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name13.setForeground(new java.awt.Color(105, 105, 105));
lbl_name13.setText("Member ID:");
lbl_name13.setToolTipText("");
pnl_editmem.add(lbl_name13, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 250, 110, -1));
txt_memberid.setBackground(new java.awt.Color(242, 242, 242));
txt_memberid.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_memberid.setForeground(new java.awt.Color(0, 0, 0));
txt_memberid.setBorder(null);
txt_memberid.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txt_memberidKeyReleased(evt);
}
});
pnl_editmem.add(txt_memberid, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 270, 300, 30));
jSeparator14.setForeground(new java.awt.Color(60, 63, 65));
pnl_editmem.add(jSeparator14, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 300, 300, 10));
btn_update.setBackground(new java.awt.Color(115, 150, 0));
btn_update.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
btn_update.setForeground(new java.awt.Color(255, 255, 255));
btn_update.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/updatebtn.png"))); // NOI18N
btn_update.setText("Update");
btn_update.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_updateMouseClicked(evt);
}
});
pnl_editmem.add(btn_update, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 500, 150, 40));
btn_delete.setBackground(new java.awt.Color(255, 50, 59));
btn_delete.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
btn_delete.setForeground(new java.awt.Color(255, 255, 255));
btn_delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/user-with-cross-sign.png"))); // NOI18N
btn_delete.setText("Delete");
btn_delete.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_deleteMouseClicked(evt);
}
});
pnl_editmem.add(btn_delete, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 500, 150, 40));
member_table.setBackground(new java.awt.Color(255, 255, 255));
member_table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
member_table.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
member_tableMouseClicked(evt);
}
});
jScrollPane1.setViewportView(member_table);
pnl_editmem.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 910, 150));
jPanel2.setBackground(new java.awt.Color(242, 242, 242));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 12), new java.awt.Color(102, 102, 102))); // NOI18N
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
lbl_Dashboard14.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_Dashboard14.setForeground(new java.awt.Color(102, 102, 102));
lbl_Dashboard14.setText("Member ID:");
jPanel2.add(lbl_Dashboard14, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 110, 20));
txt_search_memid.setBackground(new java.awt.Color(255, 255, 255));
txt_search_memid.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_search_memid.setForeground(new java.awt.Color(69, 73, 74));
txt_search_memid.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(105, 105, 105), 1, true));
txt_search_memid.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txt_search_memidKeyReleased(evt);
}
});
jPanel2.add(txt_search_memid, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 20, 240, -1));
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/magnifier.png"))); // NOI18N
jPanel2.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 20, 30, 30));
pnl_editmem.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 40, 430, 50));
rad_MStudent1.setBackground(new java.awt.Color(242, 242, 242));
rad_MStudent1.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
rad_MStudent1.setForeground(new java.awt.Color(105, 105, 105));
rad_MStudent1.setText("Student");
rad_MStudent1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rad_MStudent1ActionPerformed(evt);
}
});
pnl_editmem.add(rad_MStudent1, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 450, -1, -1));
rad_MStaff.setBackground(new java.awt.Color(242, 242, 242));
rad_MStaff.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
rad_MStaff.setForeground(new java.awt.Color(105, 105, 105));
rad_MStaff.setText("Staff");
rad_MStaff.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rad_MStaffActionPerformed(evt);
}
});
pnl_editmem.add(rad_MStaff, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 450, -1, -1));
lbl_name16.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name16.setForeground(new java.awt.Color(105, 105, 105));
lbl_name16.setText("Email:");
lbl_name16.setToolTipText("");
pnl_editmem.add(lbl_name16, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 380, 80, -1));
add(pnl_editmem);
pnl_editmem.setBounds(0, 50, 930, 540);
pnl_regmem.setBackground(new java.awt.Color(242, 242, 242));
pnl_regmem.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
lbl_name.setFont(new java.awt.Font("Century Gothic", 0, 24)); // NOI18N
lbl_name.setForeground(new java.awt.Color(105, 105, 105));
lbl_name.setText("Member Registration");
lbl_name.setToolTipText("");
pnl_regmem.add(lbl_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 60, 250, -1));
jSeparator3.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 180, 300, 10));
txt_regname.setBackground(new java.awt.Color(242, 242, 242));
txt_regname.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regname.setForeground(new java.awt.Color(0, 0, 0));
txt_regname.setBorder(null);
pnl_regmem.add(txt_regname, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 150, 300, 30));
jSeparator4.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 250, 300, 10));
txt_regidno.setBackground(new java.awt.Color(242, 242, 242));
txt_regidno.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regidno.setForeground(new java.awt.Color(0, 0, 0));
txt_regidno.setBorder(null);
pnl_regmem.add(txt_regidno, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 220, 300, 30));
lbl_name1.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name1.setForeground(new java.awt.Color(105, 105, 105));
lbl_name1.setText("ID No:");
lbl_name1.setToolTipText("");
pnl_regmem.add(lbl_name1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 200, 60, -1));
txt_regemail.setBackground(new java.awt.Color(242, 242, 242));
txt_regemail.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regemail.setForeground(new java.awt.Color(0, 0, 0));
txt_regemail.setBorder(null);
pnl_regmem.add(txt_regemail, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 290, 300, 30));
jSeparator5.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator5, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 320, 300, 10));
jSeparator6.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator6, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 180, 300, 10));
txt_regtel.setBackground(new java.awt.Color(242, 242, 242));
txt_regtel.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regtel.setForeground(new java.awt.Color(0, 0, 0));
txt_regtel.setBorder(null);
txt_regtel.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
txt_regtelKeyTyped(evt);
}
});
pnl_regmem.add(txt_regtel, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 150, 300, 30));
lbl_name3.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name3.setForeground(new java.awt.Color(105, 105, 105));
lbl_name3.setText("Telephone No:");
lbl_name3.setToolTipText("");
pnl_regmem.add(lbl_name3, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 130, 130, -1));
jSeparator7.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator7, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 250, 300, 10));
txt_regaddress.setBackground(new java.awt.Color(242, 242, 242));
txt_regaddress.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regaddress.setForeground(new java.awt.Color(0, 0, 0));
txt_regaddress.setBorder(null);
pnl_regmem.add(txt_regaddress, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 220, 300, 30));
lbl_name4.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name4.setForeground(new java.awt.Color(105, 105, 105));
lbl_name4.setText("Address:");
lbl_name4.setToolTipText("");
pnl_regmem.add(lbl_name4, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 200, 90, -1));
lbl_name5.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name5.setForeground(new java.awt.Color(105, 105, 105));
lbl_name5.setText("Member ID:");
lbl_name5.setToolTipText("");
pnl_regmem.add(lbl_name5, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 280, 110, -1));
txt_regmemberid.setBackground(new java.awt.Color(242, 242, 242));
txt_regmemberid.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_regmemberid.setForeground(new java.awt.Color(0, 0, 0));
txt_regmemberid.setBorder(null);
pnl_regmem.add(txt_regmemberid, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 300, 300, 30));
jSeparator8.setForeground(new java.awt.Color(60, 63, 65));
pnl_regmem.add(jSeparator8, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 330, 300, 10));
btn_regmembers.setBackground(new java.awt.Color(255, 255, 255));
btn_regmembers.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
btn_regmembers.setForeground(new java.awt.Color(0, 85, 127));
btn_regmembers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/add-contact.png"))); // NOI18N
btn_regmembers.setText("Register");
btn_regmembers.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_regmembersMouseClicked(evt);
}
});
pnl_regmem.add(btn_regmembers, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 430, 150, 40));
lbl_name6.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name6.setForeground(new java.awt.Color(105, 105, 105));
lbl_name6.setText("Name:");
lbl_name6.setToolTipText("");
pnl_regmem.add(lbl_name6, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 130, 60, -1));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/add-contact2.png"))); // NOI18N
pnl_regmem.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 60, 40, 40));
rad_Staff.setBackground(new java.awt.Color(242, 242, 242));
rad_Staff.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
rad_Staff.setForeground(new java.awt.Color(105, 105, 105));
rad_Staff.setText("Staff");
rad_Staff.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rad_StaffActionPerformed(evt);
}
});
pnl_regmem.add(rad_Staff, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 360, -1, -1));
rad_Student1.setBackground(new java.awt.Color(242, 242, 242));
rad_Student1.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
rad_Student1.setForeground(new java.awt.Color(105, 105, 105));
rad_Student1.setText("Student");
rad_Student1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rad_Student1ActionPerformed(evt);
}
});
pnl_regmem.add(rad_Student1, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 360, -1, -1));
lbl_name14.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name14.setForeground(new java.awt.Color(105, 105, 105));
lbl_name14.setText("Email:");
lbl_name14.setToolTipText("");
pnl_regmem.add(lbl_name14, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 270, 80, -1));
lbl_name15.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_name15.setForeground(new java.awt.Color(105, 105, 105));
lbl_name15.setText("Member Type:");
lbl_name15.setToolTipText("");
pnl_regmem.add(lbl_name15, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 360, 120, -1));
btn_mem_card.setBackground(new java.awt.Color(255, 255, 255));
btn_mem_card.setForeground(new java.awt.Color(0, 85, 127));
btn_mem_card.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/id-card blue.png"))); // NOI18N
btn_mem_card.setText("Membership Card");
btn_mem_card.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_mem_cardMouseClicked(evt);
}
});
pnl_regmem.add(btn_mem_card, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 430, 170, 40));
add(pnl_regmem);
pnl_regmem.setBounds(0, 50, 930, 540);
pnl_IDprint.setBackground(new java.awt.Color(242, 242, 242));
pnl_IDprint.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel3.setBackground(new java.awt.Color(242, 242, 242));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 12), new java.awt.Color(102, 102, 102))); // NOI18N
jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
txt_isbn_print.setBackground(new java.awt.Color(255, 255, 255));
txt_isbn_print.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
txt_isbn_print.setForeground(new java.awt.Color(69, 73, 74));
txt_isbn_print.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(105, 105, 105), 1, true));
txt_isbn_print.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txt_isbn_printKeyReleased(evt);
}
});
jPanel3.add(txt_isbn_print, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 20, 240, -1));
lbl_Dashboard16.setFont(new java.awt.Font("Century Gothic", 0, 16)); // NOI18N
lbl_Dashboard16.setForeground(new java.awt.Color(102, 102, 102));
lbl_Dashboard16.setText("Member ID:");
jPanel3.add(lbl_Dashboard16, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 110, 20));
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/magnifier.png"))); // NOI18N
jPanel3.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 20, 30, 30));
pnl_IDprint.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 100, 430, 50));
cardpanel.setBackground(new java.awt.Color(242, 242, 242));
cardpanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
lbl_add.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
lbl_add.setForeground(new java.awt.Color(0, 0, 0));
cardpanel.add(lbl_add, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 170, 170, 30));
lbl_namep.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
cardpanel.add(lbl_namep, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 100, 170, 30));
lbl_NIC.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
lbl_NIC.setForeground(new java.awt.Color(0, 0, 0));
cardpanel.add(lbl_NIC, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 130, 110, 20));
lbl_memID1.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
lbl_memID1.setForeground(new java.awt.Color(0, 0, 0));
cardpanel.add(lbl_memID1, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 60, 110, 20));
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/member card.png"))); // NOI18N
cardpanel.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 310, 220));
pnl_IDprint.add(cardpanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 160, 310, 250));
btn_printID.setBackground(new java.awt.Color(255, 255, 255));
btn_printID.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
btn_printID.setForeground(new java.awt.Color(0, 85, 125));
btn_printID.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/id-card blue.png"))); // NOI18N
btn_printID.setText("Card Print ");
btn_printID.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_printIDMouseClicked(evt);
}
});
pnl_IDprint.add(btn_printID, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 420, 150, 40));
lbl_Dashboard15.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
lbl_Dashboard15.setForeground(new java.awt.Color(102, 102, 102));
lbl_Dashboard15.setText("Membership Card ");
pnl_IDprint.add(lbl_Dashboard15, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 40, 170, 20));
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/id-card gray.png"))); // NOI18N
pnl_IDprint.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 30, 50, 40));
btn_backtoReg.setBackground(new java.awt.Color(255, 255, 255));
btn_backtoReg.setFont(new java.awt.Font("Century Gothic", 1, 14)); // NOI18N
btn_backtoReg.setForeground(new java.awt.Color(0, 85, 125));
btn_backtoReg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/back blue.png"))); // NOI18N
btn_backtoReg.setText("Back");
btn_backtoReg.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btn_backtoRegMouseClicked(evt);
}
});
pnl_IDprint.add(btn_backtoReg, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 470, 150, 40));
add(pnl_IDprint);
pnl_IDprint.setBounds(0, 50, 930, 540);
}// </editor-fold>//GEN-END:initComponents
private void lbl_back2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbl_back2MouseClicked
time();
lbl_back2.setVisible(false);
in();
pnl_regmem.setVisible(false);
pnl_editmem.setVisible(false);
pnl_IDprint.setVisible(false);
lbl_member_white.setVisible(true);
lbl_memwhite.setVisible(true);
clear();
lbl_memID1.setText("");
lbl_NIC.setText("");
lbl_namep.setText("");
lbl_add.setText("");
txt_isbn_print.setText("");
txt_regname.setText("");
txt_regidno.setText("");
txt_regemail.setText("");
txt_regtel.setText("");
txt_regaddress.setText("");
txt_regmemberid.setText("");
rad_Staff.setSelected(false);
rad_Student1.setSelected(false);
}//GEN-LAST:event_lbl_back2MouseClicked
private void lbl_resetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbl_resetMouseClicked
in();
btn_regmember.setEnabled(true);
btn_editmem.setEnabled(true);
btn_memC.setEnabled(true);
pnl_regmem.setVisible(false);
pnl_editmem.setVisible(false);
lbl_member_white.setVisible(true);
lbl_memwhite.setVisible(true);
pnl_IDprint.setVisible(false);
}//GEN-LAST:event_lbl_resetMouseClicked
private void btn_regmembersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_regmembersMouseClicked
String reg_admin = String.valueOf(Library.lib);
Date d = new Date();
SimpleDateFormat s = new SimpleDateFormat("dd-MM-yyyy");
String reg_date =(s.format(d));
if(txt_regmemberid.getText().isEmpty() || txt_regname.getText().isEmpty() || txt_regtel.getText().isEmpty() || txt_regaddress.getText().isEmpty() || txt_regemail.getText().isEmpty() || txt_regidno.getText().isEmpty() || M_Type==null){
JOptionPane.showMessageDialog(null,"Please complete the form corectly");
}
else{
int p = JOptionPane.showConfirmDialog(null, "Are you sure you want to add record?","Add Record",JOptionPane.YES_NO_OPTION);
if(p==0){
try {
String sql="insert into members(Member_ID,Name,Telephone,Address,Email,ID_No,Member_Type,Registered_Date,Registered_admin) values(?,?,?,?,?,?,?,?,?)";
pst=con.prepareStatement(sql);
pst.setString(1,txt_regmemberid.getText());
pst.setString(2,txt_regname.getText());
pst.setString(3,txt_regtel.getText());
pst.setString(4,txt_regaddress.getText());
pst.setString(5,txt_regemail.getText());
pst.setString(6,txt_regidno.getText());
pst.setString(7,M_Type);
pst.setString(8,reg_date);
pst.setString(9,reg_admin);
pst.execute();
JOptionPane.showMessageDialog(null,"Member registration is successful.");
//txt_regmemberid.setText("");
txt_regname.setText("");
txt_regtel.setText("");
txt_regaddress.setText("");
txt_regemail.setText("");
txt_address.setText("");
txt_regidno.setText("");
rad_Staff.setSelected(false);
rad_Student1.setSelected(false);
memid();
} catch (SQLException e) {
JOptionPane.showMessageDialog(null,"This member ID is already exist. \n\n\n If you need any clarifications, please contact the developer with below message.\n\n --------------------------------------------------------------------only for the developer-----------------------------------------------------------------------------\n"+e+"\n--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
}
}
}
}//GEN-LAST:event_btn_regmembersMouseClicked
private void rad_StaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_StaffActionPerformed
M_Type ="Staff";
rad_Student1.setSelected(false);
rad_Staff.setSelected(true);
}//GEN-LAST:event_rad_StaffActionPerformed
private void rad_Student1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_Student1ActionPerformed
M_Type ="Student";
rad_Student1.setSelected(true);
rad_Staff.setSelected(false);
}//GEN-LAST:event_rad_Student1ActionPerformed
private void txt_regtelKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_regtelKeyTyped
char c=evt.getKeyChar();
String text=txt_telno.getText();
if (c == 43 && text.indexOf('+') != -1)
{
evt.consume();
}
if (!Character.isDigit(c) && c != 8 && c != 43)
{
evt.consume();
}
}//GEN-LAST:event_txt_regtelKeyTyped
private void rad_MStaffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_MStaffActionPerformed
MM_Type ="Staff";
rad_MStudent1.setSelected(false);
rad_MStaff.setSelected(true);
}//GEN-LAST:event_rad_MStaffActionPerformed
private void rad_MStudent1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_MStudent1ActionPerformed
MM_Type ="Student";
rad_MStudent1.setSelected(true);
rad_MStaff.setSelected(false);
}//GEN-LAST:event_rad_MStudent1ActionPerformed
private void member_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_member_tableMouseClicked
int r = member_table.getSelectedRow();
String memberid = member_table.getValueAt(r, 0).toString();
String name = member_table.getValueAt(r, 1).toString();
String telno = member_table.getValueAt(r, 2).toString();
String address = member_table.getValueAt(r, 3).toString();
String email = member_table.getValueAt(r, 4).toString();
String idno = member_table.getValueAt(r, 5).toString();
MM_Type = member_table.getValueAt(r, 6).toString();
//String password = table_users.getValueAt(r, 7).toString();
if(MM_Type.equals("Staff")){
rad_MStudent1.setSelected(false);
rad_MStaff.setSelected(true);
}
if(MM_Type.equals("Student")) {
rad_MStudent1.setSelected(true);
rad_MStaff.setSelected(false);
}
txt_memberid.setText(memberid);
txt_name.setText(name);
txt_telno.setText(telno);
txt_address.setText(address);
txt_email.setText(email);
txt_idno.setText(idno);
}//GEN-LAST:event_member_tableMouseClicked
private void btn_resetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_resetMouseClicked
clear();
txt_search_memid.setText("");
}//GEN-LAST:event_btn_resetMouseClicked
private void btn_updateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_updateMouseClicked
if(txt_name.getText().isEmpty() || txt_idno.getText().isEmpty() || txt_address.getText().isEmpty() || txt_telno.getText().isEmpty() || txt_email.getText().isEmpty() || txt_memberid.getText().isEmpty() || MM_Type==null){
JOptionPane.showMessageDialog(null,"Please select your member ID from the table");
}
else{
int x = JOptionPane.showConfirmDialog(null,"Do you really want to update");
if(x==0){
String name=txt_name.getText();
String idno=txt_idno.getText();
String address=txt_address.getText();
String telno=txt_telno.getText();
String email=txt_email.getText();
String member_id=txt_memberid.getText();
String reg_admin = String.valueOf(Library.lib);
Date d = new Date();
SimpleDateFormat s = new SimpleDateFormat("dd-MM-yyyy");
String reg_date =(s.format(d));
try {
String updateq="update members set Member_ID='"+member_id+"',Name='"+name+"',Telephone='"+telno+"',Address='"+address+"',Email='"+email+"',ID_No='"+idno+"',Member_Type='"+MM_Type+"',Registered_Date='"+reg_date+"',Registered_admin='"+reg_admin+"' where Member_ID='"+member_id+"'";
pst = con.prepareStatement(updateq);
pst.execute();
//load table
tableload();
clear();
} catch (Exception e) {
}
}
}
}//GEN-LAST:event_btn_updateMouseClicked
private void btn_deleteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_deleteMouseClicked
if(txt_name.getText().isEmpty() || txt_idno.getText().isEmpty() || txt_address.getText().isEmpty() || txt_telno.getText().isEmpty() || txt_email.getText().isEmpty() || txt_memberid.getText().isEmpty() || MM_Type==null){
JOptionPane.showMessageDialog(null,"Please select your member ID from the table");
}
else{
int x = JOptionPane.showConfirmDialog(null,"Do you want to delete this");
if(x==0){
String id = txt_memberid.getText();
try {
String deleteq="delete from members where Member_ID='"+id+"'";
pst = con.prepareStatement(deleteq);
pst.execute();
//load table
tableload();
clear();
} catch (Exception e) {
}
}
}
}//GEN-LAST:event_btn_deleteMouseClicked
private void txt_search_memidKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_search_memidKeyReleased
String name= txt_search_memid.getText();
try {
String selectq="select Member_ID,Name,Telephone,Address,Email,ID_No,Member_Type,Registered_Date,Registered_admin from members where Name like'%"+name+"%' or Member_ID like'%"+name+"%'";
pst = con.prepareStatement(selectq);
rs=pst.executeQuery();
member_table.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
}
}//GEN-LAST:event_txt_search_memidKeyReleased
private void txt_memberidKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_memberidKeyReleased
if(txt_memberid.getText().equals("")){
clear();
txt_search_memid.setText("");
}
}//GEN-LAST:event_txt_memberidKeyReleased
private void txt_isbn_printKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_isbn_printKeyReleased
String isbn= txt_isbn_print.getText();
if(txt_isbn_print.getText().equals("")){
lbl_memID1.setText("");
lbl_NIC.setText("");
lbl_namep.setText("");
lbl_add.setText("");
}
try {
String selectq="select Member_ID,Name,Address,ID_No from members where Member_ID='"+isbn+"'";
Statement st =con.createStatement();
rs= st.executeQuery(selectq);
while(rs.next()){
String memid=rs.getString("Member_ID");
lbl_memID1.setText(memid);
String name=rs.getString("Name");
lbl_namep.setText("<html>"+name+"</html>");
String address=rs.getString("Address");
lbl_add.setText("<html>"+address+"</html>");
String nic=rs.getString("ID_No");
lbl_NIC.setText(nic);
}
} catch (Exception e) {
}
}//GEN-LAST:event_txt_isbn_printKeyReleased
private void btn_printIDMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_printIDMouseClicked
if(txt_isbn_print.getText().isEmpty()){
JOptionPane.showMessageDialog(null,"Please search your member ID");
}
else{
printRecord(cardpanel);
}
lbl_memID1.setText("");
lbl_NIC.setText("");
lbl_namep.setText("");
lbl_add.setText("");
txt_isbn_print.setText("");
}//GEN-LAST:event_btn_printIDMouseClicked
private void btn_mem_cardMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_mem_cardMouseClicked
pnl_regmem.setVisible(false);
pnl_editmem.setVisible(false);
lbl_member_white.setVisible(true);
lbl_memwhite.setVisible(true);
pnl_IDprint.setVisible(true);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
lbl_back2.setVisible(false);
}//GEN-LAST:event_btn_mem_cardMouseClicked
private void btn_backtoRegMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_backtoRegMouseClicked
lbl_memID1.setText("");
lbl_NIC.setText("");
lbl_namep.setText("");
lbl_add.setText("");
txt_isbn_print.setText("");
pnl_regmem.setVisible(true);
pnl_editmem.setVisible(false);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
pnl_IDprint.setVisible(false);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
lbl_back2.setVisible(true);
}//GEN-LAST:event_btn_backtoRegMouseClicked
private void btn_regmemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_regmemberActionPerformed
backtime();
memid();
btn_regmember.setEnabled(false);
btn_editmem.setEnabled(false);
btn_memC.setEnabled(false);
out();
pnl_regmem.setVisible(true);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
pnl_editmem.setVisible(false);
pnl_IDprint.setVisible(false);
btn_backtoReg.setVisible(true);
tableload();
}//GEN-LAST:event_btn_regmemberActionPerformed
private void btn_editmemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_editmemActionPerformed
backtime();
btn_regmember.setEnabled(false);
btn_editmem.setEnabled(false);
btn_memC.setEnabled(false);
out();
pnl_editmem.setVisible(true);
pnl_regmem.setVisible(false);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
pnl_IDprint.setVisible(false);
tableload();
}//GEN-LAST:event_btn_editmemActionPerformed
private void btn_memCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_memCActionPerformed
backtime();
btn_regmember.setEnabled(false);
btn_editmem.setEnabled(false);
btn_memC.setEnabled(false);
out();
pnl_regmem.setVisible(false);
lbl_member_white.setVisible(false);
lbl_memwhite.setVisible(false);
pnl_editmem.setVisible(false);
pnl_IDprint.setVisible(true);
btn_backtoReg.setVisible(false);
}//GEN-LAST:event_btn_memCActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn_backtoReg;
private javax.swing.JButton btn_delete;
private javax.swing.JButton btn_editmem;
private javax.swing.JButton btn_memC;
private javax.swing.JButton btn_mem_card;
private javax.swing.JButton btn_printID;
private javax.swing.JButton btn_regmember;
private javax.swing.JButton btn_regmembers;
private javax.swing.JButton btn_reset;
private javax.swing.JButton btn_update;
private javax.swing.JPanel cardpanel;
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 jLabel6;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator10;
private javax.swing.JSeparator jSeparator11;
private javax.swing.JSeparator jSeparator12;
private javax.swing.JSeparator jSeparator13;
private javax.swing.JSeparator jSeparator14;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private javax.swing.JSeparator jSeparator5;
private javax.swing.JSeparator jSeparator6;
private javax.swing.JSeparator jSeparator7;
private javax.swing.JSeparator jSeparator8;
private javax.swing.JSeparator jSeparator9;
private javax.swing.JLabel lbl_Dashboard14;
private javax.swing.JLabel lbl_Dashboard15;
private javax.swing.JLabel lbl_Dashboard16;
private javax.swing.JLabel lbl_Dashboard2;
private javax.swing.JLabel lbl_NIC;
private javax.swing.JLabel lbl_add;
private javax.swing.JLabel lbl_back2;
private javax.swing.JLabel lbl_blue;
private javax.swing.JLabel lbl_blue2;
private javax.swing.JLabel lbl_blue3;
private javax.swing.JLabel lbl_dashicon;
private javax.swing.JLabel lbl_editmem;
private javax.swing.JLabel lbl_green;
private javax.swing.JLabel lbl_green2;
private javax.swing.JLabel lbl_green3;
private javax.swing.JLabel lbl_memID1;
private javax.swing.JLabel lbl_member_white;
private javax.swing.JLabel lbl_memc;
private javax.swing.JLabel lbl_memregwhite;
private javax.swing.JLabel lbl_memwhite;
private javax.swing.JLabel lbl_name;
private javax.swing.JLabel lbl_name1;
private javax.swing.JLabel lbl_name10;
private javax.swing.JLabel lbl_name11;
private javax.swing.JLabel lbl_name12;
private javax.swing.JLabel lbl_name13;
private javax.swing.JLabel lbl_name14;
private javax.swing.JLabel lbl_name15;
private javax.swing.JLabel lbl_name16;
private javax.swing.JLabel lbl_name3;
private javax.swing.JLabel lbl_name4;
private javax.swing.JLabel lbl_name5;
private javax.swing.JLabel lbl_name6;
private javax.swing.JLabel lbl_name7;
private javax.swing.JLabel lbl_name8;
private javax.swing.JLabel lbl_name9;
private javax.swing.JLabel lbl_namep;
private javax.swing.JLabel lbl_reset;
private javax.swing.JTable member_table;
private javax.swing.JPanel pnl_IDprint;
private javax.swing.JPanel pnl_editmem;
private javax.swing.JPanel pnl_regmem;
private javax.swing.JRadioButton rad_MStaff;
private javax.swing.JRadioButton rad_MStudent1;
private javax.swing.JRadioButton rad_Staff;
private javax.swing.JRadioButton rad_Student1;
private javax.swing.JTextField txt_address;
private javax.swing.JTextField txt_email;
private javax.swing.JTextField txt_idno;
private javax.swing.JTextField txt_isbn_print;
private javax.swing.JTextField txt_memberid;
private javax.swing.JTextField txt_name;
private javax.swing.JTextField txt_regaddress;
private javax.swing.JTextField txt_regemail;
private javax.swing.JTextField txt_regidno;
private javax.swing.JTextField txt_regmemberid;
private javax.swing.JTextField txt_regname;
private javax.swing.JTextField txt_regtel;
private javax.swing.JTextField txt_search_memid;
private javax.swing.JTextField txt_telno;
// End of variables declaration//GEN-END:variables
}
| true
|
daa1a938d38736aff573f52ddd70c5f15e1ed904
|
Java
|
dkdhodkseho/project
|
/src/main/java/kr/co/subway/headOffice/dao/MenuDAO.java
|
UTF-8
| 1,080
| 2.015625
| 2
|
[] |
no_license
|
package kr.co.subway.headOffice.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import kr.co.subway.headOffice.vo.ApplyMenuPageBound;
import kr.co.subway.ingreManage.vo.IngreVo;
@Repository("menuDao")
public class MenuDAO {
@Autowired
private SqlSession session;
//메뉴목록
public List<IngreVo> menuList() {
return session.selectList("ingre.ingreMainList");
}
//할인 및 할인율 수정
public int updateIngre(IngreVo ingre) {
return session.update("ingre.updateIngre",ingre);
}
//메인재료 list 개수
public int menuListTotalCount(String keyword) {
Map<String, String> map = new HashMap<String, String>();
map.put("keyword", keyword);
return session.selectOne("ingre.menuListTotalCount",map);
}
//메뉴(메인재료) list 페이징
public List<IngreVo> menuListPaging(ApplyMenuPageBound pb) {
return session.selectList("ingre.menuListPaging",pb);
}
}
| true
|
af0e7aa384a7ec61201802719ec10887d570090c
|
Java
|
haninfisal/SmashAndroidA202SGI
|
/app/src/main/java/com/example/smash/bookingApp/MainActivity.java
|
UTF-8
| 4,096
| 2.109375
| 2
|
[] |
no_license
|
package com.example.smash.bookingApp;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
TextView textView;
EditText mEmail, mPassword;
Button registerBtn;
TextView tvLogin;
FirebaseAuth mAuth;
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text);
getSupportActionBar().setTitle("Register");
mAuth = FirebaseAuth.getInstance();
mEmail = (EditText)findViewById(R.id.email);
mPassword = (EditText)findViewById(R.id.password);
tvLogin = findViewById(R.id.textViewLogin);
registerBtn = findViewById(R.id.registerButton);
registerBtn.setOnClickListener(v -> {
String userEmail = mEmail.getText().toString();
String userPass = mPassword.getText().toString();
// User Register Validation
if(userEmail.isEmpty()) {
mEmail.setError("Email is Required");
mEmail.requestFocus();
}
else if (userPass.isEmpty()) {
mPassword.setError("Please enter your password");
mPassword.requestFocus();
}
else if (userPass.length() < 6 ) {
mPassword.setError("Password must be at least 8 characters");
mPassword.requestFocus();
}
else if (userEmail.isEmpty() && userPass.isEmpty()) {
Toast.makeText(MainActivity.this, "Fields are empty", Toast.LENGTH_SHORT).show();
}
else if (!(userEmail.isEmpty() && userPass.isEmpty())) {
mAuth.createUserWithEmailAndPassword(userEmail, userPass).addOnCompleteListener(MainActivity.this, task -> {
if(!task.isSuccessful()){
Toast.makeText(MainActivity.this, "Failed to register", Toast.LENGTH_SHORT).show();
}
else if (task.isSuccessful()){
User user = new User(userEmail, userPass);
// Insert User registration data Into Database
FirebaseDatabase.getInstance().getReference("Users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
startActivity(new Intent(MainActivity.this, loginActivity.class));
}
}
});
}
// else {
// startActivity(new Intent(MainActivity.this, loginActivity.class));
// }
});
}
else {
Toast.makeText(MainActivity.this, "Error Occurred", Toast.LENGTH_SHORT).show();
}
});
tvLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, loginActivity.class);
startActivity(i);
}
});
}
}
| true
|
4a0db75d6f0379696ee5fdd12ca55fa84628b17f
|
Java
|
rus-techie/Java_Proj
|
/JavaForTesters/src/JavaBasics/AddWithoutPlusMinus.java
|
UTF-8
| 174
| 2.984375
| 3
|
[] |
no_license
|
package JavaBasics;
public class AddWithoutPlusMinus {
public int addingWithoutPlusMinus(int a, int b) {
int sum = 0;
sum = Math.addExact(a, b);
return sum;
}
}
| true
|
faab0f48c99d08b570259925c6c66a254d38768a
|
Java
|
dakusui/pcond
|
/src/test/java/com/github/dakusui/pcond/ut/fluent4/Fluent4Example.java
|
UTF-8
| 8,472
| 2.1875
| 2
|
[
"Apache-2.0"
] |
permissive
|
package com.github.dakusui.pcond.ut.fluent4;
import com.github.dakusui.pcond.core.fluent.builtins.StringTransformer;
import com.github.dakusui.pcond.core.fluent.CustomTransformer;
import com.github.dakusui.pcond.forms.Functions;
import com.github.dakusui.pcond.forms.Predicates;
import com.github.dakusui.pcond.forms.Printables;
import com.github.dakusui.shared.ReportParser;
import org.junit.ComparisonFailure;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import java.util.function.Predicate;
import static com.github.dakusui.pcond.forms.Functions.length;
import static com.github.dakusui.pcond.forms.Predicates.*;
import static com.github.dakusui.pcond.internals.InternalUtils.makeSquashable;
import static com.github.dakusui.thincrest.TestFluents.assertAll;
import static com.github.dakusui.thincrest.TestFluents.assertStatement;
@RunWith(Enclosed.class)
public class Fluent4Example {
public static class Done {
@Test(expected = ComparisonFailure.class)
public void test() {
assertStatement(stringTransformer("INPUT_VALUE")
.parseBoolean()
.then()
.isTrue());
}
@Test//(expected = ComparisonFailure.class)
public void test_b() {
assertAll(
stringTransformer("INPUT_VALUE")
.toLowerCase()
.parseBoolean()
.then()
.isTrue());
}
@Test//(expected = ComparisonFailure.class)
public void test_c() {
assertAll(
stringTransformer("INPUT_VALUE")
.parseBoolean()
.then()
.isTrue());
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen() {
assertStatement(stringTransformer("INPUT_VALUE")
.parseBoolean()
.then()
.isTrue()
.isTrue());
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_2() {
assertStatement(stringTransformer("INPUT_VALUE")
.parseBoolean()
.then()
.addCheckPhrase(v -> v.checkWithPredicate(Predicates.isNotNull()).toPredicate())
.addCheckPhrase(v -> v.checkWithPredicate(Predicates.isTrue()).toPredicate()));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_3() {
assertStatement(stringTransformer("INPUT_VALUE")
.parseBoolean()
.then()
.check(v -> v.isTrue().toPredicate())
.check(v -> v.isTrue().toPredicate()));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_4() {
assertStatement(stringTransformer("INPUT_VALUE")
.toLowerCase()
.then()
.check(v -> v.contains("XYZ1").toPredicate())
.check(v -> v.contains("ABC1").toPredicate()));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_5() {
assertStatement(stringTransformer("INPUT_VALUE")
.toLowerCase()
.parseBoolean()
.then()
.check(v -> v.isTrue().toPredicate())
.check(v -> v.isTrue().toPredicate()));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_7() {
assertStatement(stringTransformer("INPUT_VALUE")
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue()
.toPredicate())
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue()
.toPredicate()));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_6() {
assertStatement(stringTransformer("INPUT_VALUE")
.transform(
tx -> {
Predicate<String> stringPredicate = tx.toLowerCase()
.parseBoolean()
.then()
.isTrue()
.toPredicate();
System.out.println(stringPredicate);
return stringPredicate;
}));
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_6a() {
assertStatement(stringTransformer("INPUT_VALUE")
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue()
.toPredicate())
.checkWithPredicate(Predicates.transform(length()).check(isEqualTo(10))));
}
}
@Ignore
public static class OnGoing {
@Test
public void test_allOf_inWhen_6a() {
assertStatement(stringTransformer("helloWorld1")
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue()
.toPredicate())
.checkWithPredicate(Predicates.transform(length()).check(isEqualTo(10))));
}
@Test(expected = IllegalStateException.class)
public void test_allOf_inWhen_6b() {
assertStatement(stringTransformer("helloWorld2")
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue().done())
.checkWithPredicate(Predicates.transform(length()).check(isEqualTo(10)))
.then());
}
@Test(expected = ComparisonFailure.class)
public void test_allOf_inWhen_6c() {
assertStatement(stringTransformer("helloWorld2")
.transform(
tx -> tx.toLowerCase()
.parseBoolean()
.then()
.isTrue().done())
.checkWithPredicate(Predicates.transform(length()).check(isEqualTo(10))));
}
@Test
public void givenBook_whenCheckTitleAndAbstract_thenTheyAreNotNullAndAppropriateLength() {
try {
Book book = new Book(
"De Bello Gallico",
"Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, "
+ "aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.");
assertAll(
new BookTransformer(book)
.transform(tx -> tx.title()
.transform(ty -> ty
.then()
.checkWithPredicate(not(isNotNull())).done())
.transform(ty -> ty
.parseInt()
.then()
.greaterThanOrEqualTo(10)
.lessThan(40)
.done())
.done())
.transform(tx -> tx.abstractText()
.transform(ty -> ty
.then()
.isNotNull().done())
.transform(ty -> ty
.length()
.then()
.greaterThanOrEqualTo(200)
.lessThan(400).done())
.done()));
} catch (ComparisonFailure e) {
ReportParser reportParser = new ReportParser(e.getActual());
reportParser.summary().records().forEach(each -> System.out.println(each.toString()));
throw e;
}
}
public static class Book {
private final String abstractText;
private final String title;
public Book(String title, String abstractText) {
this.abstractText = abstractText;
this.title = title;
}
String title() {
return title;
}
String abstractText() {
return abstractText;
}
@Override
public String toString() {
return "Book:[title:<" + title + ">, abstract:<" + abstractText + ">]";
}
}
public static class BookTransformer extends CustomTransformer<BookTransformer, Book> {
public BookTransformer(Book rootValue) {
super(rootValue);
}
public StringTransformer<Book> title() {
return toString(Printables.function("title", Book::title));
}
public StringTransformer<Book> abstractText() {
return toString(Printables.function("abstractText", Book::abstractText));
}
}
}
private static StringTransformer.Impl<String> stringTransformer(String value) {
return new StringTransformer.Impl<>(() -> value, makeSquashable(Functions.identity()));
}
}
| true
|
7fe78ad5fd5595d02e2c955e56cb9387295cd67f
|
Java
|
lelmarir/krail
|
/src/main/java/uk/q3c/krail/core/user/opt/UserOption.java
|
UTF-8
| 1,620
| 2.40625
| 2
|
[] |
no_license
|
package uk.q3c.krail.core.user.opt;
/**
* Created by David Sowerby on 03/12/14.
*/
public interface UserOption {
void configure(UserOptionContext consumer, Class<? extends Enum> keys);
void configure(Class<? extends UserOptionContext> consumerClass, Class<? extends Enum> keys);
/**
* @param key
* the option specific key, for example SHOW_ALL_SECTIONS
* @param qualifiers
* optional, these are usually dynamically generated qualifier(s) to make a complete unique identity where
* the same option may be used several times within a consumer. If for example you have an array of
* dynamically generated buttons, which you want the user to be able to individually choose the colours
* of, you may have consumer=com.example.FancyButtonForm, key=BUTTON_COLOUR, qualifiers="2,3"
* <p>
* where "2,3" is the grid position of the button
* @param <T>
* a type determined by the sampleValue. An implementation should assume that an object of any type can be
* passed. *
* @param defaultValue
* the default value to be returned if no value is found in the store. Also determines the type of the
* return value
* @param <T>
* a type determined by the defaultValue.
*
* @return
*/
<T> T get(T defaultValue, Enum<?> key, String... qualifiers);
<T> void set(T value, Enum<?> key, String... qualifiers);
/**
* Flushes the cache of the associated option store, for the current user
*/
void flushCache();
}
| true
|
f06e6b6aee96adbe96df48b55e351081eafe0605
|
Java
|
pablogrisafi1975/upa-framework
|
/upa-sample-0/src/main/java/org/upasample2/app/controllers/FileController.java
|
UTF-8
| 3,178
| 2.953125
| 3
|
[] |
no_license
|
package org.upasample2.app.controllers;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.upasample2.app.file.HugeUpaFile;
import org.upasample2.app.file.StringUpaFile;
import org.upasample2.app.file.UpaFile;
import org.upasample2.app.file.UpaUploadFile;
public class FileController {
/*-
* http://localhost:8080/upa-sample-0/upa/File/stringUpaFile?fileName=my+FileName%20with%20spaces.txt&&content=myFileContent
*/
public UpaFile stringUpaFile(String fileName, String content) {
StringUpaFile stringUpaFile = new StringUpaFile(fileName);
stringUpaFile.append(content);
stringUpaFile.append("\r\n");
stringUpaFile.append("á (aacute)\r\n");
stringUpaFile.append("ñ (ntilde)\r\n");
return stringUpaFile;
}
/*-
* http://localhost:8080/upa-sample-0/upa/File/hugeUpaFile4M
*/
public UpaFile hugeUpaFile4M() {
HugeUpaFile hugeUpaFile = new HugeUpaFile("HugeUpaFile4M.txt", new HugeUpaFile.ContentGenerator() {
int i = 0;
@Override
public byte[] generate() {
i++;
if (i < 60_000) {
return (i + "\t a b c ch d e f g h i j k l ll m n ñ o p q r s t u v w x y z \r\n")
.getBytes(StandardCharsets.UTF_8);
}
return new byte[] {};
}
});
return hugeUpaFile;
}
/*-
* http://localhost:8080/upa-sample-0/upa/File/hugeUpaFile600M
*/
public UpaFile hugeUpaFile600M() {
HugeUpaFile hugeUpaFile = new HugeUpaFile("HugeUpaFile600M.txt", new HugeUpaFile.ContentGenerator() {
int i = 0;
@Override
public byte[] generate() {
i++;
if (i < 8_500_000) {
return (i + "\t a b c ch d e f g h i j k l ll m n ñ o p q r s t u v w x y z \r\n")
.getBytes(StandardCharsets.UTF_8);
}
return new byte[] {};
}
});
return hugeUpaFile;
}
// http://localhost:8080/upa-sample-0/FileUploadSimple.html
// http://localhost:8080/upa-sample-0/FileUploadAjax.html
public Map<String, String> uploadOneFile(UpaUploadFile file) {
Map<String, String> map = new HashMap<>();
map.put("fileName", file.getName());
byte[] bytes = file.getContent().length < 200 ? file.getContent() : Arrays.copyOfRange(file.getContent(), 0,
200);
map.put("fileContent", new String(bytes, StandardCharsets.UTF_8));
return map;
}
// http://localhost:8080/upa-sample-0/FileUploadAjaxArray.html
public Map<String, String> uploadManyFiles(UpaUploadFile[] files) {
Map<String, String> map = new HashMap<>();
for (UpaUploadFile file : files) {
byte[] bytes = file.getContent().length < 200 ? file.getContent() : Arrays.copyOfRange(file.getContent(),
0, 200);
map.put(file.getName(), new String(bytes, StandardCharsets.UTF_8));
}
return map;
}
// http://localhost:8080/upa-sample-0/FileUploadAjaxList.html
public Map<String, String> uploadManyFilesList(List<UpaUploadFile> files) {
Map<String, String> map = new HashMap<>();
for (UpaUploadFile file : files) {
byte[] bytes = file.getContent().length < 200 ? file.getContent() : Arrays.copyOfRange(file.getContent(),
0, 200);
map.put(file.getName(), new String(bytes, StandardCharsets.UTF_8));
}
return map;
}
}
| true
|
35fd462fff1bea4048a02287a371e4d0b8aea5a3
|
Java
|
sandexp/LeetCodeRecord
|
/子集2.java
|
UTF-8
| 863
| 2.734375
| 3
|
[] |
no_license
|
class Solution {
List<List<Integer>> ans=new ArrayList();
List<Integer> template=new ArrayList();
Set<String> set=new HashSet();
public List<List<Integer>> subsetsWithDup(int[] nums) {
if(nums==null)
return null;
Arrays.sort(nums);
dfs(nums,0);
return ans;
}
public void dfs(int[] nums,int index){
if(index==nums.length){
StringBuffer sb=new StringBuffer();
for(int i=0;i<template.size();i++)
sb.append(template.get(i));
if(!set.contains(sb.toString())){
ans.add(new ArrayList(template));
set.add(sb.toString());
}
return;
}
template.add(nums[index]);
dfs(nums,index+1);
template.remove(template.size()-1);
dfs(nums,index+1);
}
}
| true
|
72d78db01a54e231066562a6ee2518470d32a093
|
Java
|
aliufw/rab-framework
|
/src/com/rab/framework/web/dynamicsession/DynamicSessionTest.java
|
WINDOWS-1252
| 1,663
| 2.53125
| 3
|
[] |
no_license
|
package com.rab.framework.web.dynamicsession;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
*
* <P>Title: DynamicSessionTest</P>
* <P>Description: </P>
* <P>˵</P>
* <P></P>
*
* <P>Copyright: Copyright (c) 2011 </P>
* <P>@author lfw</P>
* <P>version 1.0</P>
* <P>2010-12-3</P>
*
*/
public class DynamicSessionTest {
public void setData(HttpServletRequest request, String key, Object value){
DynamicSessionManager.singleton().setData(request, key, value);
}
public void test(){
Map<String, MemorySession> pool = DynamicSessionManager.singleton().getDataCachePool();
Iterator<String> memorySessionIter = pool.keySet().iterator();
while(memorySessionIter.hasNext()){
String sessionid = "" + memorySessionIter.next();
System.out.println(sessionid + "------------------------------------------");
MemorySession memorySession = (MemorySession)pool.get(sessionid);
Map<String,SessionData> memoryPool = memorySession.getPool();
Iterator<String> sessionDataIter = memoryPool.keySet().iterator();
while(sessionDataIter.hasNext()){
String key = "" + sessionDataIter.next();
SessionData sessionData = (SessionData)memoryPool.get(key);
Object data = sessionData.getValue();
long lastAccess = sessionData.getLastAccess();
System.out.println(key + " = " + key);
if(data == null){
System.out.println(data + " = " + data);
}
else{
System.out.println(data + " (class)= " + data.getClass());
}
System.out.println("lastAccess = " + lastAccess);
}
}
}
public static void main(String[] args) {
}
}
| true
|
7deb52d461a70a97c4efb6773dca3318050f465e
|
Java
|
Eric021/TripAdvisorFlightWebService
|
/TripAdvisorWebServices/src/com/tripAdvisorIR/main/TripAdvisorIRMain.java
|
UTF-8
| 774
| 2.453125
| 2
|
[] |
no_license
|
package com.tripAdvisorIR.main;
import java.awt.EventQueue;
import com.tripAdvisorIR.cli.CommandLineInterface;
import com.tripAdvisorIR.gui.MainFrame;
public class TripAdvisorIRMain {
static long startTime, endTime;
public static void main(String[] args) {
startTime = System.currentTimeMillis();
runCLI();
// runGUI();
endTime = System.currentTimeMillis();
}
private static void runGUI(){
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainFrame frame = new MainFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
private static void runCLI(){
CommandLineInterface commandLineInterface = new CommandLineInterface();
commandLineInterface.run();
}
}
| true
|
0df8b16d8135bb2caca99a9b2104b69d4d05ef0e
|
Java
|
LauraSaraiva10/globoplay-desafio-mobile
|
/app/src/main/java/com/example/globoplay_desafio_mobile/viewmodels/account/AccountViewModel.java
|
UTF-8
| 1,374
| 2.25
| 2
|
[] |
no_license
|
package com.example.globoplay_desafio_mobile.viewmodels.account;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.example.globoplay_desafio_mobile.models.account.LoginModel;
import com.example.globoplay_desafio_mobile.models.account.UserModel;
import com.example.globoplay_desafio_mobile.repositories.AccountRepository;
import com.example.globoplay_desafio_mobile.response.account.LoginResponse;
public class AccountViewModel extends ViewModel {
private AccountRepository accountRepository;
//Constructor
public AccountViewModel(){
accountRepository = AccountRepository.getInstance();
}
//Getter login response
public MutableLiveData<LoginModel> getLoginResponse() {
return accountRepository.getLoginResponse();
}
public MutableLiveData<UserModel> getDetailsUser() {
return accountRepository.getDetailsUser();
}
//Setter
public void setNullLoginResponse() {
accountRepository.setNullLoginResponse();
}
// Call the method createToken in AccountRepository
public void login(String username,String password){
accountRepository.login(username,password);
}
// Call the method getDetailsUser in AccountRepository
public void getDetailsUser(String sessionId){
accountRepository.getDetailsUser(sessionId);
}
}
| true
|
c31809b3dccff84bc67e78a1d5b58411877e9e90
|
Java
|
Naman26/Data-Structures-Assignments
|
/calc.java
|
UTF-8
| 12,000
| 3.71875
| 4
|
[] |
no_license
|
import java.util.*;
/**
*1)This program takes an expression as String (infix notation). The the expression is
* converted to postfix notation. If there are any variables inside the expression then
* the user is prompted to give integer values to those varible. Then the expression is
* evaluated. The program keeps asking for input until "q" is entered to quit. After
* entering "q" the porgram prints invalid expression then quits.
*
*2)There are three important methods that complete this program. infixToPostfix,
* convertVar, and soln. These methods convert the expression to postfix, replaces variables,
* and evaluates expression respectively. There are no specific algorithms used, it's just
* manipulation on String data types.
*
*3)Stack of characters is used extensively throughout the program. Especially in two of
* the three important methods discussed above.
*
*4)This program catches the errors that are specified as constraints in the assignment.
* Although, space between characters is recommended for clearity and efficiency.
*
*5)There is only one class that achieves main purpose of the program. This class has a
* main method that prompts the user for input and evaluates the output.
*
* @author Naman Kanwar
* @version 3/14/17
*/
public class calc
{
public static void main(String[]args){ //Main method
Scanner console= new Scanner(System.in);
System.out.println("Enter q to quit.");
String s= ""; //For user input
while (!s.equals("q")){
System.out.println("Enter infix Expression: "); //Prompt for input
s= console.nextLine();
boolean b= checkInput(s);
if(b==false)
System.out.println("Invalid expression"); //if expression is invalid
else{
System.out.println("Converted Expression: "+infixToPostfix(s)); //converted expression
String n= convertVar(infixToPostfix(s));
System.out.println("Answer to Expression: "+ soln(n)); //solved solution
}
}
}
public static boolean checkInput(String k){ //Takes a string parameter k and returns boolean
int paren=0; //for index of right parenthesis
int flag=0;
char m= k.charAt(k.length()-1); //last character
for(int i=0;i<k.length();i++){
k=k.replaceAll(" ",""); //remove spaces
char c= k.charAt(i);
if(m=='(') //if last charaacter is an opening brace
return false;
else if(c=='*'||c=='/'||c=='+'||c=='-'||c=='%'){ //if character is an operator then check operator befor and after
if((k.charAt(i-1)>47 && k.charAt(i-1)<58) || (k.charAt(i-1)>64 && k.charAt(i-1)<91) || (k.charAt(i-1)>96 && k.charAt(i-1)<123)&&
(k.charAt(i+1)>47 && k.charAt(i+1)<58) || (k.charAt(i+1)>64 && k.charAt(i+1)<91) || (k.charAt(i+1)>96 && k.charAt(i+1)<123))
return true;
}
else if(!((c>47 && c<58) || (c>64 && c<91) || (c>96 && c<123))) //if chatacter is neither operator nor operand
return false;
else if(c=='('){ //if an ( is found
flag=1;
for(int j=i;j<k.length();j++){ //checking for closing pranthesis
if(k.charAt(j)==')' && j>paren){ //checking for pairs of parenthesis
flag=0;
paren=j;
}
}
}
}
if(m!=')'|| !((m>47 && m<58) || (m>64 && m<91) || (m>96 && m<123)))
return false;
if(flag!=1) //if parenthesis pair is found
return true;
return true;
}
public static String infixToPostfix(String exp){ //Takes String parameter and returns String as result
String postfix=""; //For postfix expression
Stack <Character>s= new Stack<Character>(); //Stack for concersion
for(int i=0;i<exp.length();i++){
if(exp.charAt(i)==' '){ //if wide space is encountered
postfix+=" ";
}
else if((exp.charAt(i)>47 && exp.charAt(i)<58) || (exp.charAt(i)>64 && exp.charAt(i)<91) || (exp.charAt(i)>96 && exp.charAt(i)<123))
postfix+=exp.substring(i,i+1); //character is an operator
else if((exp.charAt(i)>39 && exp.charAt(i)<48) && !closingP(exp.charAt(i))&&(exp.charAt(i)!=44 || exp.charAt(i)!=46 || exp.charAt(i)!=41) || exp.charAt(i)==37){
if(openingP(exp.charAt(i))){
s.push(exp.charAt(i)); //if character is an operator or parenthesis
continue;
}
while(!s.isEmpty() && !openingP(s.peek())&& precedence(s.peek(),exp.charAt(i))){
postfix+=s.peek(); //if pushing an operator with higher precedence than top
s.pop();
}
s.push(exp.charAt(i)); //if precedence of current is equal or lower that top
}
else if(openingP(exp.charAt(i)))
s.push(exp.charAt(i)); //if current is opening parnthesis
else if(closingP(exp.charAt(i))){ //if closing parenthesis is encountered
while(!s.isEmpty() && !openingP(s.peek())){
postfix+=s.peek();
s.pop();
}
s.pop();
}
}
while(!s.isEmpty()){
postfix+=s.peek(); //After iterating through the string postfix evlauation
s.pop();
}
return postfix; //Returning postfix expression
}
public static boolean precedence(char a,char b ){ //takes two char(s) and returns a boolean
int a1=0;
int b1=0;
while(a1==0 & b1==0){ //assign values according to the precedence of th operators
if(a=='*'||a=='/'||a=='%')
a1=3;
else if(b=='*'||b=='/'||b=='%')
b1=3;
else if(a=='+'||a=='-')
a1=1;
else if(b=='+'||b=='-')
b1=1;
else if(a=='('||a==')')
a1=2;
else if(b=='('||b==')')
b1=2;
}
if(a1>b1) //if character a > character b
return true;
return false;
}
public static boolean openingP(char a){ //takes 1 char parameter and returns a boolean value
if(a=='(') //checks for opening parenthesis
return true;
return false;
}
public static boolean closingP(char a){ //takes 1 char parameter and returns a boolean value
if(a==')') //checks for closing parenthesis
return true;
return false;
}
//After Conversion
public static String convertVar(String var){ //takes 1 String parameter and returns a String
Scanner console= new Scanner(System.in);
String val= var;
for(int i=0;i<var.length();i++){
if((var.charAt(i)>64 && var.charAt(i)<91)||(var.charAt(i)>96 && var.charAt(i)<123)){
System.out.printf("Enter the value of %s: ",var.charAt(i)); //Finds the variables and prompts the user for values
String n= console.next();
for(int j=0; j<var.length();j++){
if(var.charAt(j)==var.charAt(i)){
val=val.replace(val.substring(j,j+1),n); //replaces variables with values(String)
}
}
}
}
return val; //returns converted expression
}
public static int soln(String exp){ //takes 1 String parameter and returns an int value
Stack<Integer> in= new Stack<Integer>(); //Stack for operands
int right;
int left;
int temp=0;
int j=1;
for(int i=0;i<exp.length();i++){
char c= exp.charAt(i);
if(c=='*' || c=='/' || c=='%' || c=='+' || c=='-'){ //When an operator is found
switch(c){
case'*':
right= in.pop();
left= in.pop();
in.push(left*right);
break;
case'/':
right= in.pop();
left= in.pop();
in.push(left/right);
break;
case'%':
right= in.pop();
left= in.pop();
in.push(left%right);
break;
case'+':
right= in.pop();
left= in.pop();
in.push(left+right);
break;
case'-':
right= in.pop();
left= in.pop();
in.push(left-right);
break;
}
}
else if(c==' '){ //When wide space is found
continue;
}
else if(c>47 && c<58){ //if integer value is found
int count=0;
temp=0;
for(j=i; exp.charAt(j)>47 && exp.charAt(j)<58;j++){
count++;
}
j=i;
while(count>0){
temp+=Integer.parseInt(exp.substring(j,j+1))*Math.pow(10,count-1);
count--;
j++;
}
in.push(temp);
i=j-1;
}
}
return in.pop(); //returns the final value
}
}
| true
|
71a4de58208fa602abe67fe123981df139ef7c6d
|
Java
|
eGovFramework/egovframe-development
|
/net.java.amateras.db/src/net/java/amateras/db/dialect/DefaultSchemaLoader.java
|
UTF-8
| 10,591
| 2.09375
| 2
|
[
"Apache-2.0"
] |
permissive
|
package net.java.amateras.db.dialect;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.java.amateras.db.util.NameConverter;
import net.java.amateras.db.visual.model.AbstractDBConnectionModel;
import net.java.amateras.db.visual.model.AbstractDBEntityModel;
import net.java.amateras.db.visual.model.ColumnModel;
import net.java.amateras.db.visual.model.ForeignKeyMapping;
import net.java.amateras.db.visual.model.ForeignKeyModel;
import net.java.amateras.db.visual.model.IndexModel;
import net.java.amateras.db.visual.model.RootModel;
import net.java.amateras.db.visual.model.TableModel;
import org.eclipse.draw2d.geometry.Rectangle;
/**
* A default implementation of {@link ISchemaLoader}.
*
* @author Naoki Takezoe
*/
public class DefaultSchemaLoader implements ISchemaLoader {
public void loadSchema(RootModel root, IDialect dialect, Connection conn,
String[] tables, String catalog, String schema, boolean autoConvert) throws SQLException {
if(tables.length==0){
return;
}
for(int i=0;i<tables.length;i++){
TableModel table = getTableInfo(tables[i], dialect, conn, catalog, schema, autoConvert);
// merge
java.util.List<AbstractDBEntityModel> children = root.getChildren();
for(int j=0;j<children.size();j++){
AbstractDBEntityModel obj = children.get(j);
if(obj instanceof TableModel){
TableModel tableModel = (TableModel) obj;
if(tableModel.getTableName().equals(table.getTableName())){
table.setLogicalName(tableModel.getLogicalName());
table.setDescription(tableModel.getDescription());
table.setConstraint(tableModel.getConstraint());
ColumnModel[] columns = table.getColumns();
for(int k=0;k<columns.length;k++){
ColumnModel columnModel = tableModel.getColumn(columns[k].getColumnName());
if(columnModel != null){
columns[k].setLogicalName(columnModel.getLogicalName());
columns[k].setDescription(columnModel.getDescription());
}
}
root.removeChild(tableModel);
break;
}
}
}
if(table.getConstraint()==null){
table.setConstraint(new Rectangle(10 + i * 50, 10 + i * 50, -1, -1));
}
root.addChild(table);
}
setForeignKeys(root, conn, catalog, schema);
// // remove indices which defined as foreign keys
// List<IndexModel> indexModels = new ArrayList<IndexModel>();
// for(AbstractDBEntityModel entity: root.getChildren()){
// if(entity instanceof TableModel){
// TableModel table = ((TableModel) entity);
// for(IndexModel indexModel: table.getIndices()){
// boolean match = true;
// LOOP: for(AbstractDBConnectionModel fkConn: table.getModelSourceConnections()){
// if(fkConn instanceof ForeignKeyModel){
// ForeignKeyMapping[] mappings = ((ForeignKeyModel) fkConn).getMapping();
// if(mappings.length == indexModel.getColumns().size()){
// for(ForeignKeyMapping mapping: mappings){
// if(!indexModel.getColumns().contains(mapping.getTarget().getColumnName())){
// match = false;
// break LOOP;
// }
// }
// }
// }
// }
// if(!match){
// indexModels.add(indexModel);
// }
// }
// table.setIndices(indexModels.toArray(new IndexModel[indexModels.size()]));
// }
// }
}
protected TableModel getTableInfo(String tableName, IDialect dialect,
Connection conn, String catalog, String schema, boolean autoConvert) throws SQLException {
TableModel table = new TableModel();
table.setTableName(tableName);
if(autoConvert){
table.setLogicalName(NameConverter.physical2logical(table.getTableName()));
} else {
table.setLogicalName(table.getTableName());
}
DatabaseMetaData meta = conn.getMetaData();
List<ColumnModel> list = new ArrayList<ColumnModel>();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(dialect.getColumnMetadataSQL(tableName));
ResultSetMetaData rm = rs.getMetaData();
ResultSet columns = meta.getColumns(catalog, schema, tableName, "%");
while(columns.next()){
IColumnType type = dialect.getColumnType(columns.getString("TYPE_NAME"));
if(type == null){
type = dialect.getColumnType(columns.getInt("DATA_TYPE"));
if(type == null){
type = dialect.getDefaultColumnType();
}
}
ColumnModel column = new ColumnModel();
column.setColumnName(columns.getString("COLUMN_NAME"));
if(autoConvert){
column.setLogicalName(NameConverter.physical2logical(column.getColumnName()));
} else {
column.setLogicalName(column.getColumnName());
}
column.setColumnType(type);
column.setSize(columns.getString("COLUMN_SIZE"));
column.setNotNull(columns.getString("IS_NULLABLE").equals("NO"));
int rmIndex = getResultSetMetaDataIndex(rm, column.getColumnName());
if(rmIndex > 0){
column.setAutoIncrement(rm.isAutoIncrement(rmIndex));
}
list.add(column);
}
columns.close();
ResultSet keys = meta.getPrimaryKeys(catalog, schema, tableName);
while(keys.next()){
String columnName = keys.getString("COLUMN_NAME");
for(int i=0;i<list.size();i++){
ColumnModel column = (ColumnModel)list.get(i);
if(column.getColumnName().equals(columnName)){
column.setPrimaryKey(true);
}
}
}
keys.close();
rs.close();
stmt.close();
table.setColumns(list.toArray(new ColumnModel[list.size()]));
List<IndexModel> indices = loadIndexModels(tableName, dialect, conn, catalog, schema, list);
table.setIndices(indices.toArray(new IndexModel[indices.size()]));
return table;
}
protected List<IndexModel> loadIndexModels(String tableName, IDialect dialect,
Connection conn, String catalog, String schema, List<ColumnModel> columns) throws SQLException {
List<IndexModel> result = new ArrayList<IndexModel>();
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getIndexInfo(catalog, schema, tableName, false, true);
while(rs.next()){
String indexName = rs.getString("INDEX_NAME");
if(indexName != null){
IndexModel indexModel = null;
for(IndexModel index: result){
if(index.getIndexName().equals(indexName)){
indexModel = index;
break;
}
}
if(indexModel == null){
indexModel = new IndexModel();
indexModel.setIndexName(indexName);
indexModel.setIndexName(rs.getString("INDEX_NAME"));
if(rs.getBoolean("NON_UNIQUE")){
indexModel.setIndexType(new IndexType("INDEX"));
} else {
indexModel.setIndexType(new IndexType("UNIQUE"));
}
result.add(indexModel);
}
indexModel.getColumns().add(rs.getString("COLUMN_NAME"));
}
}
rs.close();
List<IndexModel> removeIndexModels = new ArrayList<IndexModel>();
for(IndexModel indexModel: result){
List<String> pkColumns = new ArrayList<String>();
for(ColumnModel columnModel: columns){
if(columnModel.isPrimaryKey()){
pkColumns.add(columnModel.getColumnName());
}
}
if(indexModel.getColumns().size() == pkColumns.size()){
boolean isNotPk = false;
for(int i=0;i<indexModel.getColumns().size();i++){
if(!indexModel.getColumns().get(i).equals(pkColumns.get(i))){
isNotPk = true;
break;
}
}
if(!isNotPk){
removeIndexModels.add(indexModel);
}
}
}
result.removeAll(removeIndexModels);
return result;
}
/**
* Return the index in the <code>ResultSetMetaData</code> for the given column.
*/
protected int getResultSetMetaDataIndex(
ResultSetMetaData rm, String columnName) throws SQLException {
for(int i=1;i<rm.getColumnCount();i++){
if(rm.getColumnName(i).equals(columnName)){
return i;
}
}
return 0;
}
protected void setForeignKeys(RootModel root, Connection conn,
String catalog, String schema) throws SQLException {
for(int i=0;i<root.getChildren().size();i++){
TableModel table = (TableModel)root.getChildren().get(i);
for(AbstractDBConnectionModel connModel: table.getModelSourceConnections().toArray(
new AbstractDBConnectionModel[table.getModelSourceConnections().size()])){
if(connModel instanceof ForeignKeyModel){
connModel.detachSource();
connModel.detachTarget();
}
}
}
DatabaseMetaData meta = conn.getMetaData();
for(int i=0;i<root.getChildren().size();i++){
TableModel table = (TableModel)root.getChildren().get(i);
ResultSet rs = meta.getImportedKeys(catalog, schema, table.getTableName());
Map<String, Map<String, Object>> map = new HashMap<String, Map<String, Object>>();
while(rs.next()){
String pkTable = rs.getString("PKTABLE_NAME");
String pkColumn = rs.getString("PKCOLUMN_NAME");
String fkTable = rs.getString("FKTABLE_NAME");
String fkColumn = rs.getString("FKCOLUMN_NAME");
String keyName = rs.getString("FK_NAME");
if(root.getTable(pkTable)!=null && root.getTable(fkTable)!=null){
if(map.get(keyName)==null){
Map<String, Object> entry = new HashMap<String, Object>();
entry.put("fkTable", fkTable);
entry.put("pkTable", pkTable);
entry.put("mappings", new ArrayList<ForeignKeyMapping>());
map.put(keyName, entry);
}
@SuppressWarnings("unchecked")
List<ForeignKeyMapping> mappings =
(List<ForeignKeyMapping>) map.get(keyName).get("mappings");
ForeignKeyMapping mapping = new ForeignKeyMapping();
mapping.setRefer(root.getTable(fkTable).getColumn(fkColumn));
mapping.setTarget(root.getTable(pkTable).getColumn(pkColumn));
mappings.add(mapping);
}
}
rs.close();
Iterator<Map.Entry<String, Map<String, Object>>> ite = map.entrySet().iterator();
while(ite.hasNext()){
Map.Entry<String, Map<String, Object>> entry = ite.next();
Map<String, Object> entryMap = entry.getValue();
@SuppressWarnings("unchecked")
List<ForeignKeyMapping> mappings =
(List<ForeignKeyMapping>) entryMap.get("mappings");
ForeignKeyModel fkeyModel = new ForeignKeyModel();
fkeyModel.setForeignKeyName(entry.getKey());
fkeyModel.setMapping(mappings.toArray(new ForeignKeyMapping[mappings.size()]));
fkeyModel.setSource(root.getTable((String)entryMap.get("fkTable")));
fkeyModel.setTarget(root.getTable((String)entryMap.get("pkTable")));
fkeyModel.attachSource();
fkeyModel.attachTarget();
}
}
}
}
| true
|
b67857a1f55933d1dc6722c2c19a6d4415d9b24d
|
Java
|
lifeModder19135/Springboot_Layered_API_Template
|
/src/main/java/com/ntolb/layeredapi/SpringbootLayeredApiTemplateApplication.java
|
UTF-8
| 357
| 1.578125
| 2
|
[] |
no_license
|
package com.ntolb.layeredapi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootLayeredApiTemplateApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootLayeredApiTemplateApplication.class, args);
}
}
| true
|
32c7c628f7e9897e755282abd03a52aad56144a1
|
Java
|
Stefan-Mitic/Solid-Bank-Application
|
/app/src/main/java/com/bank/databasehelper/DatabaseDeserializeUserInfo.java
|
UTF-8
| 4,605
| 2.25
| 2
|
[] |
no_license
|
package com.bank.databasehelper;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.bank.database.android.DatabaseDriverA;
import com.bank.databasehelper.DatabaseDriverHelper;
import com.bank.security.PasswordHelpers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class DatabaseDeserializeUserInfo extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "bank.db";
public DatabaseDeserializeUserInfo(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE ROLES "
+ "(ID INTEGER PRIMARY KEY NOT NULL,"
+ "NAME TEXT NOT NULL)");
sqLiteDatabase.execSQL("CREATE TABLE ACCOUNTTYPES "
+ "(ID INTEGER PRIMARY KEY NOT NULL,"
+ "NAME TEXT NOT NULL,"
+ "INTERESTRATE TEXT)");
sqLiteDatabase.execSQL("CREATE TABLE ACCOUNTS "
+ "(ID INTEGER PRIMARY KEY NOT NULL,"
+ "NAME TEXT NOT NULL,"
+ "BALANCE TEXT,"
+ "TYPE INTEGER NOT NULL,"
+ "FOREIGN KEY(TYPE) REFERENCES ACCOUNTTYPES(ID))");
sqLiteDatabase.execSQL("CREATE TABLE USERS "
+ "(ID INTEGER PRIMARY KEY NOT NULL,"
+ "NAME TEXT NOT NULL,"
+ "AGE INTEGER NOT NULL,"
+ "ADDRESS CHAR(100),"
+ "ROLEID INTEGER,"
+ "FOREIGN KEY(ROLEID) REFERENCES ROLE(ID))");
sqLiteDatabase.execSQL("CREATE TABLE USERACCOUNT "
+ "(USERID INTEGER NOT NULL,"
+ "ACCOUNTID INTEGER NOT NULL,"
+ "FOREIGN KEY(USERID) REFERENCES USER(ID),"
+ "FOREIGN KEY(ACCOUNTID) REFERENCES ACOUNT(ID),"
+ "PRIMARY KEY(USERID, ACCOUNTID))");
sqLiteDatabase.execSQL("CREATE TABLE USERPW "
+ "(USERID INTEGER NOT NULL,"
+ "PASSWORD CHAR(64),"
+ "FOREIGN KEY(USERID) REFERENCES USER(ID))");
sqLiteDatabase.execSQL("CREATE TABLE USERMESSAGES "
+ "(ID INTEGER PRIMARY KEY NOT NULL,"
+ "USERID INTEGER NOT NULL,"
+ "MESSAGE CHAR(512) NOT NULL,"
+ "VIEWED CHAR(1) NOT NULL,"
+ "FOREIGN KEY(USERID) REFERENCES USER(ID))");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS USERMESSAGES");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS USERPW");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS USERACCOUNT");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS USERS");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS ACCOUNTS");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS ACCOUNTTYPES");
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS ROLES");
onCreate(sqLiteDatabase);
}
/**
* Connects and inserts a User into the database with the corresponding info and a hashed
* password. Returns the User Id if the insertion was successful, otherwise returns -1.
*
* @param name is the name of the user
* @param age is the age of the user
* @param address is the address of the user
* @param roleId is the roleId of the user
* @param hashedPassword is the hashed password of the user
* @return the id of the user that was inserted
*/
protected long insertUserHashed(String name, int age, String address, int roleId,
String hashedPassword) {
long id = insertUser(name, age, address, roleId);
insertPassword(hashedPassword, (int) id);
return id;
}
private void insertPassword(String hashedPassword, int userId) {
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("USERID", userId);
contentValues.put("PASSWORD", hashedPassword);
sqLiteDatabase.insert("USERPW", null, contentValues);
}
private long insertUser(String name, int age, String address, int roleId) {
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("NAME", name);
contentValues.put("AGE", age);
contentValues.put("ADDRESS", address);
contentValues.put("ROLEID", roleId);
return sqLiteDatabase.insert("USERS", null, contentValues);
}
}
| true
|
bfd0d10d8c6e50ef31b1974282fb29e6ec32ddd8
|
Java
|
deft1991/Telegram_Bots
|
/src/main/java/ru/golitsyn/telegram/domain/User.java
|
UTF-8
| 1,050
| 2.390625
| 2
|
[] |
no_license
|
package ru.golitsyn.telegram.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Класс пользователя для хранения айди чата,
* что бы по айди чата рассылать уведомления
* Created by Sergey Golitsyn (deft) on 07.10.2018
*/
@Entity
@Data
@NoArgsConstructor
@Table(name = "users", schema = "telegram")
public class User {
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Column(name = "chat_id")
private Long chatId;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "is_bot")
private Boolean isBot;
public User(Long chatId, String firstName
, String lastName, boolean isBot) {
this.chatId = chatId;
this.firstName = firstName;
this.lastName = lastName;
this.isBot = isBot;
}
}
| true
|
5756fe7a137f220a103188258c100e9fe09fb6a3
|
Java
|
xuanye-li/spoontacular-api-design
|
/src/cmu/edu/andrew/spoonacular/AmountTest.java
|
UTF-8
| 492
| 2.71875
| 3
|
[] |
no_license
|
package cmu.edu.andrew.spoonacular;
import org.junit.Test;
import static cmu.edu.andrew.spoonacular.Amount.Unit.GRAMS;
import static cmu.edu.andrew.spoonacular.Amount.Unit.KILOGRAMS;
import static junit.framework.TestCase.assertEquals;
public class AmountTest {
@Test
public void weightConversionTest() {
Amount test = new Amount(10, GRAMS);
Amount converted = test.convertUnit(KILOGRAMS);
assertEquals(test.quantity(), converted.quantity() * 1000);
}
}
| true
|
2885c27cdd512633cdd4f2c69f5b2a930f4a711d
|
Java
|
csjxing/im_stockop
|
/code/web/inter/src/main/java/com/doucome/stockop/web/inter/interceptor/AuthzInterceptor.java
|
UTF-8
| 1,368
| 1.90625
| 2
|
[] |
no_license
|
package com.doucome.stockop.web.inter.interceptor;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import com.doucome.stockop.biz.core.constant.Constant;
import com.doucome.stockop.web.common.action.BasicAction;
import com.doucome.stockop.web.inter.authz.InterAuthz;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
/**
*
* @author langben 2013-7-4
*
*/
@SuppressWarnings("serial")
public class AuthzInterceptor extends AbstractInterceptor {
@Autowired
private InterAuthz interAuthz ;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
if (!interAuthz.isLogin()) {
// HttpServletRequest request = ServletActionContext.getRequest() ;
// String toUrl = request.getRequestURL().toString();
// String requestQueryString = request.getQueryString();
// if (StringUtils.isNotBlank(requestQueryString)) {
// toUrl += "?" + requestQueryString;
// }
// toUrl = URLEncoder.encode(toUrl, Constant.CHARSET_UTF8);
//
// invocation.getStack().set("redirectURL", toUrl) ;
//
return BasicAction.INTER_LOGIN ;
}
return invocation.invoke();
}
}
| true
|
eadf3efedf7f71656ebb9c8b52acce8af10c9b38
|
Java
|
chaitanyakakarala/cron-conversion-util
|
/src/main/java/com/ck/converter/cron/cnvrsns/impl/DayOfMonthConverter.java
|
UTF-8
| 3,134
| 2.984375
| 3
|
[] |
no_license
|
package com.ck.converter.cron.cnvrsns.impl;
import com.ck.converter.cron.ConversionFactory;
public class DayOfMonthConverter {
short category = 0;
public DayOfMonthConverter(String daysOfMonthStr) {
if ("*".equals(daysOfMonthStr) || "?".equalsIgnoreCase(daysOfMonthStr)) {
category = 0;
} else if (daysOfMonthStr.contains("/")) {
category = 1;
} else if (daysOfMonthStr.contains("-")) {
category = 2;
}
}
public String convert(String[] inputsExpAsArray, String inputTimeZone) {
try {
switch (category) {
case 1:
return conversion4rSlashSeparation(inputsExpAsArray, inputTimeZone);
case 2:
return conversion4rHyphenSeparation(inputsExpAsArray, inputTimeZone);
default:
return withoutConversion(inputsExpAsArray, inputTimeZone);
}
}catch(Exception exp) {
System.err.println(exp.getMessage());
throw new RuntimeException(exp);
}
}
public String withoutConversion(String[] inar, String timeZone) {
return inar[3];
}
public String conversion4rHyphenSeparation(String[] inar, String inputTimeZone) throws Exception {
StringBuffer monthOfDay = new StringBuffer();
String[] tmp = inar;
String[] days = inar[3].split("-");
for (int i = 0; i < days.length; i++) {
tmp[3] = days[i];
String tmpExp = buildExpressionFromArray(tmp);
ConversionFactory factory = ConversionFactory.getConversionFactory(tmpExp, inputTimeZone);
if (i == 0) {
monthOfDay.append(factory.getDaysOfMonth());
} else {
monthOfDay.append("-").append(factory.getDaysOfMonth());
}
}
return monthOfDay.toString();
}
public String conversion4rSlashSeparation(String[] inputarray, String inputTimeZone) throws Exception {
StringBuffer monthOfDay = new StringBuffer();
String[] tmp = inputarray;
String[] days = inputarray[3].split("/"); // if - is provided ... get them from calander object
for (int i = 0; i < days.length; i++) {
tmp[3] = days[i];
String tmpExp = buildExpressionFromArray(tmp);
ConversionFactory factory = ConversionFactory.getConversionFactory(tmpExp, inputTimeZone);
if (i == 0) {
monthOfDay.append(factory.getDaysOfMonth());
} else if (i == days.length - 1) {
monthOfDay.append("/").append(factory.getDaysOfMonth());
} else {
monthOfDay.append("/").append(factory.getDaysOfMonth());
}
}
return monthOfDay.toString();
}
private static String buildExpressionFromArray(String[] ar) {
String exp = "";
for (int i = 0; i < ar.length; i++) {
if (i != ar.length - 1) {
exp = exp + ar[i] + " ";
} else {
exp = exp + ar[i];
}
}
return exp;
}
}
| true
|
fde41ec163c871144bf717b002cfdb0b258c087c
|
Java
|
MathiasMonstrey/fosil_decompiled
|
/com/misfit/frameworks/buttonservice/model/WrapperSleepStateChange$$Parcelable$Creator$$4.java
|
UTF-8
| 635
| 1.796875
| 2
|
[] |
no_license
|
package com.misfit.frameworks.buttonservice.model;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import org.parceler.IdentityCollection;
public final class WrapperSleepStateChange$$Parcelable$Creator$$4 implements Creator<WrapperSleepStateChange$$Parcelable> {
public WrapperSleepStateChange$$Parcelable createFromParcel(Parcel parcel) {
return new WrapperSleepStateChange$$Parcelable(WrapperSleepStateChange$$Parcelable.read(parcel, new IdentityCollection()));
}
public WrapperSleepStateChange$$Parcelable[] newArray(int i) {
return new WrapperSleepStateChange$$Parcelable[i];
}
}
| true
|
6aa0ef078bb813eb8e002e49fbba445384986971
|
Java
|
KimNguyen2018/example
|
/Faculty.java
|
UTF-8
| 536
| 3.265625
| 3
|
[] |
no_license
|
/** Author: Kim Nguyen
Practise on extending class
*/
package chapter11;
public class Faculty extends Employee {
int officeHours;
String rank;
public Faculty(){};
public Faculty(int officeHours, String rank){
this.officeHours = officeHours;
this.rank = rank;
}
public String toString(){
return ("Name: " + this.name +
"\nPosition: " + this.rank +
"\nOffice Hours : " + this.officeHours);
}
}
| true
|
1aa30bba5b88baabf955d9f2228ad5348526be2a
|
Java
|
Phenix-Collection/unionman_apps
|
/UMSettings/src/com/unionman/settings/wifi/WifiEvent.java
|
UTF-8
| 930
| 1.578125
| 2
|
[] |
no_license
|
package com.unionman.settings.wifi;
public class WifiEvent
{
public static final String CONFIGURED_NETWORKS_CHANGED_ACTION = "android.net.wifi.CONFIGURED_NETWORKS_CHANGE";
public static final String ERROR_ACTION = "android.net.wifi.ERROR";
public static final String LINK_CONFIGURATION_CHANGED_ACTION = "android.net.wifi.LINK_CONFIGURATION_CHANGED";
public static final String NETWORK_IDS_CHANGED_ACTION = "android.net.wifi.NETWORK_IDS_CHANGED";
public static final String NETWORK_STATE_CHANGED_ACTION = "android.net.wifi.STATE_CHANGE";
public static final String RSSI_CHANGED_ACTION = "android.net.wifi.RSSI_CHANGED";
public static final String SCAN_RESULTS_AVAILABLE_ACTION = "android.net.wifi.SCAN_RESULTS";
public static final String SUPPLICANT_STATE_CHANGED_ACTION = "android.net.wifi.supplicant.STATE_CHANGE";
public static final String WIFI_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_STATE_CHANGED";
}
| true
|
a3dd4c24f04ab8665c4d4540bc28cd4de4948685
|
Java
|
JSLobo/TDDCodeBreaker
|
/src/main/java/co/edu/udea/service/codeBreakerService.java
|
UTF-8
| 486
| 2.296875
| 2
|
[] |
no_license
|
package co.edu.udea.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import co.edu.udea.codeBreaker.CodeBreaker;
@Path("/game")
public class codeBreakerService {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String gameRest(@QueryParam("numero") int numero){
CodeBreaker codebreaker=new CodeBreaker();
return codebreaker.game(numero);
}
}
| true
|
c6d15246adc536291300462d9dc8182245300927
|
Java
|
yusan123/yboot
|
/yboot-plus-back-modules/yboot-common/src/main/java/com/yboot/common/common/vo/Result.java
|
UTF-8
| 598
| 2.0625
| 2
|
[
"MIT"
] |
permissive
|
package com.yboot.common.common.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author 田培融
* 前后端交互数据标准
*/
@Data
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 成功标志
*/
private boolean success;
/**
* 消息
*/
private String message;
/**
* 返回代码
*/
private Integer code;
/**
* 时间戳
*/
private long timestamp = System.currentTimeMillis();
/**
* 结果对象
*/
private T result;
}
| true
|
3bc6096f7167814d61c4213907720170f39a847d
|
Java
|
getcloudcherry/cloudcherry-android-sdk
|
/src/main/java/com/getcloudcherry/survey/model/SurveyResponse.java
|
UTF-8
| 579
| 1.648438
| 2
|
[
"MIT"
] |
permissive
|
package com.getcloudcherry.survey.model;
import java.util.ArrayList;
/**
* Created by riteshdubey on 7/30/16.
*/
public class SurveyResponse {
public String logoURL;
public String backgroundURL;
public String colorCode1;
public String colorCode2;
public String colorCode3;
public String welcomeText;
public String welcomeImage;
public String thankyouText;
public String thankyouImage;
public ArrayList<SurveyQuestions> questions;
public boolean skipWelcome;
public String disclaimerText;
public String partialResponseId;
}
| true
|
055032303028a1554f5d3d8d28b29a19bc82414b
|
Java
|
Jrebel-i/LeetCode-Nowcoder-DataStruct
|
/src/BUFFcode/NewCodeTest4/BuyApples.java
|
UTF-8
| 2,309
| 3.6875
| 4
|
[] |
no_license
|
package BUFFcode.NewCodeTest4;
import java.util.Scanner;
/**
* 链接:https://www.nowcoder.com/questionTerminal/61cfbb2e62104bc8aa3da5d44d38a6ef
* 来源:牛客网
*
* 小易去附近的商店买苹果,奸诈的商贩使用了捆绑交易,只提供6个每袋和8个每袋的包装(包装不可拆分)。 可是小易现在只想购买恰好n个苹果,小易想购买尽量少的袋数方便携带。如果不能购买恰好n个苹果,小易将不会购买。
*
* 输入描述:
* 输入一个整数n,表示小易想购买n(1 ≤ n ≤ 100)个苹果
*
*
* 输出描述:
* 输出一个整数表示最少需要购买的袋数,如果不能买恰好n个苹果则输出-1
* 示例1
* 输入
* 20
* 输出
* 3
*
*
*
* 链接:https://www.nowcoder.com/questionTerminal/61cfbb2e62104bc8aa3da5d44d38a6ef
* 来源:牛客网
*
* 对数字特征进行分析。
*
* 首先,6和8都是偶数。因此,能凑出的个数也一定是偶数。程序中若苹果总数是奇数,可以直接返回-1。
*
* 再次,偶数个苹果数对8取模,其结果只可能为0,2,4,6。若余数为6或者0,则可以直接用6包装情况处理,不需要回溯购买8包装的情况。若余数为4,只需回溯1次即可,因为8+4=12, 12%6 = 0。若余数为2,只需回溯2次即可,因为8+8+2=18, 18%6 = 0。
*
* 综上,可以采用如下思路进行处理。(由于数字6和8的特征,本方法只适用于本题)
*
* 情况1:若num不是偶数,则直接返回-1
* 情况2:若num%8 = 0,则返回num/8
* 情况3:若num%8 != 0,则只需回溯1次或者2次8包装购买个数,就可以求解。回溯1次,其结果为n/8-1+2 = n/8+1;回溯1次,其结果为n/8-2+3 = n/8+1。因此,可以情况3下,可以返回n/8+1
*/
public class BuyApples {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
while(scanner.hasNext()){
int appleNum = scanner.nextInt();
if(appleNum%2!=0||appleNum<6||appleNum==10){
System.out.println(-1);
}
else if(appleNum%8==0){
System.out.println(appleNum/8);
}
else {
System.out.println(1+appleNum/8);
}
}
}
}
| true
|
27db7be1b20926cc48b79284367944ac6e5dc4be
|
Java
|
viniciusteixeiradias/fcrh-back-end
|
/src/main/java/br/gov/prodemge/seplag/fcrhprova/OpenApiConfig.java
|
UTF-8
| 1,092
| 2.078125
| 2
|
[] |
no_license
|
package br.gov.prodemge.seplag.fcrhprova;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
@Configuration
public class OpenApiConfig {
@Value("${br.gov.prodemge.ambiente}")
private String ambiente;
@Value("${info.app.versao}")
private String appVersion;
@Value("${info.java.version}")
private String infoJavaVersion;
@Value("${server.servlet.context-path}")
private String contextPath;
@Value("${server.port}")
private String serverPort;
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.addServersItem(new Server().url(contextPath))
.info(new Info()
.title(contextPath)
.description(ambiente + " - " + serverPort + " - " + infoJavaVersion)
.version(appVersion));
}
}
| true
|
96972f644ccbdc144d74fee0592590107d300107
|
Java
|
mpiotrowski97/2d-platform-game
|
/core/src/pl/psk/gkproject/sprites/InteractiveSprite.java
|
UTF-8
| 364
| 2.234375
| 2
|
[] |
no_license
|
package pl.psk.gkproject.sprites;
import com.badlogic.gdx.maps.tiled.TiledMap;
/**
* Interfejs obiektu, który może miec kolizję z głową Maria
*/
public interface InteractiveSprite {
/**
* Akcja, ktora jest wykonywana podczas kolizji z głową maria
*
* @param tiledMap aktualna mapa gry
*/
void onHeadHit(TiledMap tiledMap);
}
| true
|
560c46c0568ec6c54634e758853768baf816f533
|
Java
|
Nedelosk/Leviathan
|
/src/main/java/leviathan/api/properties/PropertyType.java
|
UTF-8
| 1,502
| 2.265625
| 2
|
[
"MIT"
] |
permissive
|
package leviathan.api.properties;
import javax.annotation.Nullable;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import leviathan.api.properties.serializer.IElementSerializer;
public class PropertyType<V, P> implements IPropertyType<V, P> {
final IPropertyCollector<P> collector;
@Nullable
private final V defaultValue;
private final BiFunction<P, V, P> valueModifier;
private final BiConsumer<IPropertyProvider<P>, P> defaultUser;
private final Function<V, V> validator;
@Nullable
private final IElementSerializer<V> serializer;
public PropertyType(IPropertyCollector<P> collector, @Nullable V defaultValue, BiFunction<P, V, P> valueModifier, BiConsumer<IPropertyProvider<P>, P> defaultUser, Function<V, V> validator, @Nullable IElementSerializer<V> serializer) {
this.collector = collector;
this.valueModifier = valueModifier;
this.defaultValue = defaultValue;
this.defaultUser = defaultUser;
this.validator = validator;
this.serializer = serializer;
}
@Override
public IPropertyBuilder<V, P> startProp(String name, Function<P, V> valueProducer) {
return new PropertyBuilder<>(this, name, valueProducer, valueModifier, defaultValue, defaultUser, validator, serializer);
}
@Override
public IPropertyType<V, P> create(String name, Function<P, V> valueProducer) {
return startProp(name, valueProducer).endProperty();
}
@Override
public IPropertyCollector<P> endType() {
return collector;
}
}
| true
|
7894d64b7d31375769cef189ecacb15d57dbaaeb
|
Java
|
xie-summer/analytics
|
/analytics-web/src/test/java/com/orienttech/statics/service/TestFixedNumberService.java
|
UTF-8
| 659
| 1.671875
| 2
|
[] |
no_license
|
package com.orienttech.statics.service;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.orienttech.statics.service.fixednum.FixednumService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class TestFixedNumberService {
@Autowired
private FixednumService fixednumService;
@org.junit.Test
public void testName() throws Exception {
//fixednumService.initDatas(false, "7", "201412");
}
}
| true
|
9ea152ef84933c55a169df32997b8d3f8d50748f
|
Java
|
paul-arthurthiery/Monopoly
|
/src/monopoly/MyImage.java
|
UTF-8
| 639
| 2.875
| 3
|
[] |
no_license
|
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
public class MyImage extends JLayeredPane {
BufferedImage image;
public MyImage(String source) throws IOException
{
this.image = ImageIO.read(new File(source));
}
@Override
protected void paintComponent(Graphics g)
{
g.drawImage(this.image , 0, 0, this.getWidth(), this.getHeight(), null);
}
@Override
public Dimension getPreferredSize()
{
return new Dimension(310, 310);
}
}
| true
|
0e0599dd9bd0c746494682e62106acd3964e7fa4
|
Java
|
kenny-project/KMR
|
/K-FileManager2.0/src/com/framework/interfaces/OnConfigurationChangedAble.java
|
UTF-8
| 304
| 2.015625
| 2
|
[] |
no_license
|
package com.framework.interfaces;
import android.content.res.Configuration;
/**
* @author aimery
* 配置改变,如屏幕切换
* */
public interface OnConfigurationChangedAble
{
/**
* 配置发生改变,如屏幕切换
* */
public void onConfigurationChanged(Configuration newConfig);
}
| true
|
13f9630d9cb7f6785410767ab6bd092d2d4f6346
|
Java
|
wordpython/text
|
/src/main/java/com/wordpython/leetbook/只出现一次的数字.java
|
UTF-8
| 1,477
| 3.9375
| 4
|
[] |
no_license
|
package com.wordpython.leetbook;
import org.junit.Test;
/*
只出现一次的数字
给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。
说明:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?
示例 1:
输入: [2,2,1]
输出: 1
示例2:
输入: [4,1,2,1,2]
输出: 4
*/
public class 只出现一次的数字 {
public int singleNumber(int[] nums) {
for(int i=0;i<nums.length;i++){
if(i==nums.length-1){
return nums[i];
}
for(int x=i+1;x<nums.length;x++){
if(nums[i]==0){
x=nums.length;
}else if(nums[i]==nums[x]){
nums[x]=0;
x=nums.length;
}else if(nums[i]!=nums[x]&&x==nums.length-1){
return nums[i];
}
}
}
return 0;
}
/*
异或有交换律定理,相当于将相同的数字先异或,这样两两异或就只剩0了,
然后0再和最后的一个数字异或得到最终值,膜拜大佬
*/
public int singleNumber1(int[] nums) {
int ans = nums[0];
if (nums.length > 1) {
for (int i = 1; i < nums.length; i++) {
ans = ans ^ nums[i];//位运算符,异或
}
}
return ans;
}
}
| true
|
699acdf59b08ed198ac8a61533a9d1944cf30891
|
Java
|
nalpari/spiring-boot-practice
|
/src/main/java/net/nalpari/travisci/web/controller/TestController.java
|
UTF-8
| 481
| 2
| 2
|
[] |
no_license
|
package net.nalpari.travisci.web.controller;
import lombok.RequiredArgsConstructor;
import net.nalpari.travisci.web.service.TestService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
public class TestController {
private final TestService service;
@GetMapping(value = {"", "/"})
public long test() {
return service.calculator(1, 2);
}
}
| true
|
91bb01867f21432bd020ee07fb329f4fd9b8b2e8
|
Java
|
rhale2/FinalProject-1
|
/src/build/GraphicsPanel.java
|
UTF-8
| 2,053
| 3.25
| 3
|
[] |
no_license
|
/**
* The GraphicsPanel for the code. It declares if there is a winner based on if the image is touching the side. It also
* draws the images onto the panel
* CPSC 224, Fall 2019
*Final Project
* No sources to cite.
*
* @author Kat Sotelo, Zac Foteff, Rebekah Hale
* @version v1.0 12/12/19
*/
package build;
import javax.swing.*;
import java.awt.*;
public class GraphicsPanel extends JPanel
{
/**
* Fields
*/
protected View targetView;
protected Background backgroundImage;
protected Doggos players;
/**
*Constructor
* @param view connects to the View
*/
public GraphicsPanel(View view)
{
targetView = view;
setBackground(Color.WHITE);
backgroundImage = new Background();
players = new Doggos();
requestFocusInWindow();
}
/**
*declares if there is a winner based on if it has touched the background edge
*/
public int isWinner()
{
int backgroundRightEdge = backgroundImage.getW();
int backgroundLeftEdge = 0;
int playerPosition = players.getX();
int playerWidth = players.getW();
if (playerPosition <= backgroundLeftEdge)
return 2;
else if (playerPosition + playerWidth >= backgroundRightEdge)
return 1;
else
return 0;
}
/**
*resets the player position
*/
public void reset()
{
players.resetPosition();
}
/**
*draws the image by getting the background image and the player image
*/
private void drawSprites(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
g2.drawImage(backgroundImage.getImage(), backgroundImage.getX(), backgroundImage.getY(), this);
g2.drawImage(players.getImage(), players.getX(), players.getY(), this);
}
/**
*the paint component that draws the sprites
* @param g the graphics
*/
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
drawSprites(g);
}
}
| true
|
3553644f8c22b3ee65b3bb3f4a2676c7e8a654d3
|
Java
|
iinux/ExpressionCalc
|
/src/main/java/com/mycompany/helloworld/springboot/EnhancerStudy.java
|
UTF-8
| 9,313
| 2.953125
| 3
|
[] |
no_license
|
package com.mycompany.helloworld.springboot;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
// import jdk.internal.org.objectweb.asm.Type;
import lombok.AllArgsConstructor;
import org.junit.Test;
import org.springframework.cglib.core.DebuggingClassWriter;
import org.springframework.cglib.proxy.*;
import java.lang.reflect.Method;
@AllArgsConstructor
public class EnhancerStudy {
static class Car {
void print() {
System.out.println("I am a car");
}
final void printFinal() {
System.out.println("I am a final car");
}
String returnString() {
return "I am a return string car";
}
}
// https://www.cnblogs.com/micrari/p/7565632.html
public static void main(String[] args) {
System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, System.getProperty("user.dir") + "/cglibclass");
}
@Test
public void modifyMethod() {
Car car = new Car();
car.print();
try {
ClassPool pool = new ClassPool(true);
CtClass ct = pool.getCtClass(car.getClass().getName());// 加载这个类
// 获取被修改的方法
CtMethod m = ct.getDeclaredMethod("print");
m.setBody("System.out.println(\"I am a fake car\");"); // 直接修改方法体
// 转为class
ct.toClass();
// 释放对象
ct.detach();
} catch (Exception e) {
e.printStackTrace();
}
car.print();
}
@Test
public void case1() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
enhancer.setCallback(new MethodInterceptor() {
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy)
throws Throwable {
System.out.println("before");
Object res = methodProxy.invokeSuper(obj, args);
System.out.println("after");
// System.out.println(Type.getMethodDescriptor(method));
return res;
}
});
Car car = (Car) enhancer.create();
car.print();
car.printFinal();
}
@Test
public void case2() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
enhancer.setCallback(new LazyLoader() {
@Override
public Object loadObject() {
System.out.println("prepare loading");
Car car = new Car();
System.out.println("after loading");
System.out.println(car);
return car;
}
});
Car car = (Car) enhancer.create();
System.out.println(car);
car.print();
car.print();
}
@Test
public void case3() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
enhancer.setCallback(new Dispatcher() {
@Override
public Object loadObject() throws Exception {
System.out.println("prepare loading");
Car car = new Car();
System.out.println("after loading");
System.out.println(car);
return car;
}
});
Car car = (Car) enhancer.create();
System.out.println(car);
car.print();
car.print();
}
@Test
public void case4() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
enhancer.setCallback(new InvocationHandler() {
@Override
public Object invoke(Object obj, Method method, Object[] args) throws Throwable {
if (method.getReturnType() == void.class) {
System.out.println("hack");
}
return null;
}
});
Car car = (Car) enhancer.create();
car.returnString();
car.print();
}
@Test
public void case5() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
enhancer.setCallback(new FixedValue() {
@Override
public Object loadObject() throws Exception {
return "hack!";
}
});
Car car = (Car) enhancer.create();
System.out.println(car.returnString());
}
@Test
public void case6() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Car.class);
CallbackHelper helper = new CallbackHelper(Car.class, new Class[0]) {
@Override
protected Object getCallback(Method method) {
if (method.getReturnType() == void.class) {
return new MethodInterceptor() {
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy)
throws Throwable {
System.out.println("before invocation");
Object res = methodProxy.invokeSuper(obj, args);
System.out.println("after invocation");
return res;
}
};
} else if (method.getReturnType() == String.class) {
return new FixedValue() {
@Override
public Object loadObject() throws Exception {
return "a hacked car";
}
};
} else return NoOp.INSTANCE;
}
};
enhancer.setCallbacks(helper.getCallbacks());
enhancer.setCallbackFilter(helper);
Car car = (Car) enhancer.create();
car.print();
System.out.println(car.returnString());
}
@Test
public void case7() {
HelloWorld hello = new HelloWorld();
Enhancer enhancer = new Enhancer();
//设置代理目标
enhancer.setSuperclass(hello.getClass());
//设置调用过滤器
CallbackFilter filter = new CallBackFilterTest();
enhancer.setCallbackFilter(filter);
//创建各个目标代理方法的回调,回调的顺序要与过滤器索引一致
Callback[] callbacks = new Callback[]{new MethodInterceptor() {
/**
*
* 方法描述 当对基于代理的方法回调时,在调用原方法之前会调用该方法
* 拦截对目标方法的调用
*
* @param obj 代理对象
* @param method 拦截的方法
* @param args 拦截的方法的参数
* @param proxy 代理
* @return
* @throws Throwable
*/
@Override
public Object intercept(Object obj, Method method, Object[] args,
MethodProxy proxy) throws Throwable {
Object result = null;
try {
// 前置通知
before();
result = proxy.invokeSuper(obj, args);
// 后置通知
after();
} catch (Exception e) {
// 异常通知
exception();
} finally {
// 方法返回前通知
beforeReturning();
}
return result;
}
private void before() {
System.out.println("before method invoke...");
}
private void after() {
System.out.println("after method invoke...");
}
private void exception() {
System.out.println("exception method invoke...");
}
private void beforeReturning() {
System.out.println("beforeReturning method invoke...");
}
}, NoOp.INSTANCE};
// 设置单一回调对象,在调用中拦截对目标方法的调用
// enhancer.setCallback(NoOp.INSTANCE);
enhancer.setCallbacks(callbacks);
// 设置类加载器
enhancer.setClassLoader(hello.getClass().getClassLoader());
HelloWorld obj = (HelloWorld) enhancer.create();
System.out.println(obj.update());
System.out.println("=============");
System.out.println(obj.save());
}
public static class HelloWorld {
public String save() {
System.out.println("save...");
return "save";
}
public String update() {
System.out.println("update...");
return "update";
}
}
public static class CallBackFilterTest implements CallbackFilter {
/**
* 方法返回的值是和callback回调接口数组一一对应的数组下标
*/
@Override
public int accept(Method method) {
String name = method.getName();
if ("save".equals(name)) {
return 0;
}
return 1;
}
}
}
| true
|
23ecdc0bed9f92914d692eb34817f2d2839e3cc4
|
Java
|
lkwdzh/SuperAndroid
|
/app/src/main/java/com/example/wytings/widget/SuperScrollView.java
|
UTF-8
| 3,091
| 2.515625
| 3
|
[
"MIT"
] |
permissive
|
package com.example.wytings.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;
/**
* Created by Rex on 2016/3/12.
* https://github.com/wytings
*/
public class SuperScrollView extends ScrollView {
private int lastScrollY = 0;
private int SCROLL_EVENT = 1 << 5;
private Handler handler;
private OnScrollChangeListener scrollChangeListener;
private View contentView;
public SuperScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public SuperScrollView(Context context) {
super(context);
initialize();
}
public SuperScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initialize();
}
@SuppressLint("HandlerLeak")
private void initialize() {
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == SCROLL_EVENT) {
if (contentView == null) {
contentView = getChildAt(0);
}
if (lastScrollY == getScrollY()) {
if (scrollChangeListener != null) {
if (getScrollY() == 0) {
scrollChangeListener.onScrollChanged(SuperScrollView.this, ScrollState.TOP);
} else if (contentView != null && contentView.getMeasuredHeight() <= getScrollY() + getHeight()) {
scrollChangeListener.onScrollChanged(SuperScrollView.this, ScrollState.BOTTOM);
} else {
scrollChangeListener.onScrollChanged(SuperScrollView.this, ScrollState.IDLE);
}
}
} else {
lastScrollY = getScrollY();
handler.sendEmptyMessageDelayed(SCROLL_EVENT, 100);
}
}
}
};
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (scrollChangeListener != null) {
scrollChangeListener.onScrollChanged(this, ScrollState.SCROLLING);
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
handler.sendEmptyMessage(SCROLL_EVENT);
}
return super.onTouchEvent(ev);
}
public void setOnScrollChangeListener(OnScrollChangeListener listener) {
scrollChangeListener = listener;
}
public enum ScrollState {
IDLE, SCROLLING, TOP, BOTTOM
}
public interface OnScrollChangeListener {
void onScrollChanged(ScrollView view, ScrollState state);
}
}
| true
|
05c318c4578e46b6a7b5d59d2f009bb96c6b7ef3
|
Java
|
PeterZhan/heights_java
|
/astFastAgi1.8/src/heightsre/java/fastagi/client/validateSupVdr.java
|
UTF-8
| 1,014
| 1.695313
| 2
|
[] |
no_license
|
package heightsre.java.fastagi.client;
import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;
public class validateSupVdr extends BaseAgiScript {
@Override
public void service(AgiRequest request, AgiChannel channel)
throws AgiException {
// TODO Auto-generated method stub
String vdr = getVariable("EXTEN");
if (vdr.endsWith("#"))
vdr = vdr.substring(0, vdr.length()-1);
String vdrNum = getVariable("vdrnum");
int ivdr = Integer.parseInt(vdr);
int ivdrNum = Integer.parseInt(vdrNum);
if (ivdr > ivdrNum)
{
setExtension("i");
setPriority("1");
return;
}
String vdrname = getVariable("vdr" + ivdr);
String vdrnick = getVariable("vdrnick" + ivdr);
setVariable("VENDOR", vdrname);
setVariable("VENDORNICK", vdrnick);
// setVariable("JOBCATE", jobCat);
}
}
| true
|
e225320fec7152561e6b4b7d7717cd31aa481545
|
Java
|
SebastianBodzak/pointofsale
|
/src/main/java/pl/com/sebastianbodzak/application/FileCreator.java
|
UTF-8
| 982
| 3.078125
| 3
|
[] |
no_license
|
package pl.com.sebastianbodzak.application;
import pl.com.sebastianbodzak.domain.DataAccessException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
/**
* Created by Dell on 2016-08-10.
*/
public class FileCreator {
private final String path;
private File file;
public FileCreator(String path) {
this.path = path;
this.file = new File(path);
}
public void create(String ...singleString) throws DataAccessException, FileNotFoundException {
try (PrintWriter pw = new PrintWriter(new FileOutputStream(file, true), true)){
for (String s : singleString)
pw.print(s + "\n");
} catch (Exception ex) {
throw new DataAccessException("Can not create file", FileCreator.class);
}
}
public String getPath() {
return path;
}
public File getFile() {
return file;
}
}
| true
|
983a443d80133c3150ec4bc939f1f6ab7ce5c57d
|
Java
|
Sonat-Consulting/RxFruit
|
/src/main/java/no/sonat/rxfruit/RetryFruitException.java
|
UTF-8
| 222
| 2.0625
| 2
|
[] |
no_license
|
package no.sonat.rxfruit;
/**
* Created by lars on 23.11.14.
*/
public class RetryFruitException extends Exception {
public RetryFruitException(String s, Throwable throwable) {
super(s, throwable);
}
}
| true
|
1a63f5593862e998c15daaf811ac1e8c5f762ac5
|
Java
|
nastjast/JavaModul1
|
/src/day11/hw/HoWRe.java
|
UTF-8
| 401
| 2.984375
| 3
|
[] |
no_license
|
package day11.hw;
public class HoWRe {
public static void main(String[] args) {
System.out.println(exercise3000(3000));
}
private static String exercise3000(int range) {
String result = "";
for (int j = 0; j < range; j++) {
if (j % 32 == 30 && j % 58 == 44) {
result += " " + j;
}
}
return result;
}
}
| true
|
2464a787ca8dfd2dd828ff5be934603f8be613d3
|
Java
|
xyf2847670338/java_base
|
/RemoteSystemsTempFiles/RemoteSystemsTempFiles/RemoteSystemsTempFiles/src/第五章/Ssq.java
|
GB18030
| 570
| 3.125
| 3
|
[] |
no_license
|
package ;
import java.util.Random;
public class Ssq {
public static void main(String[] args) throws InterruptedException {
System.out.println("˫ɫ:");
System.out.println(":");
Random r = new Random();
int hq;
for (int i = 0; i < 6; i++) {
hq = r.nextInt(33) + 1;
System.out.print(hq + " ");
Thread.sleep(1000);
}
Thread.sleep(1000);
System.out.println("\nһ:");
Thread.sleep(1000);
int lq = r.nextInt(16) + 1;
System.out.println(lq + " ");
}
}
| true
|
bbfd9fe28e858801b34901186545a9db10116c1d
|
Java
|
SuchFNS/kettering
|
/cs102_inc/Homework 3/Assignment1/StudentGrades/StudentGradesClient.java
|
UTF-8
| 1,142
| 3.765625
| 4
|
[] |
no_license
|
/*
* Name:Hayvin Bolton
* Date:1/19/2020
* Question number: 3
* Description: Client Class to test the StudentGrades program
*/
package StudentGrades;
import java.util.*;
public class StudentGradesClient
{
public static void main(String[] args)
{
//create a grades classes
StudentGrades Grades1 = new StudentGrades(50);
StudentGrades Grades2 = new StudentGrades(50);
//check sorting method
Grades1.sortScores();
System.out.println("Sorted Scores are: " + Grades1.toString() + "\n");
//check if objects equality works
System.out.println("Checking if Grades1 is the same as Grades2: " + Grades1.equals(Grades2));
System.out.println("Checking if Grades1 is the same as Grades1: " + Grades1.equals(Grades1) + "\n");
//print highest grade
System.out.println("The highest score was: " + Grades1.getHighest());
//print the mean, median, and mode
System.out.println("Score mean: " + Grades1.getAverage()
+ "\nScore median: " + Grades1.getMedian() + "\nScore mode(s): " + Arrays.toString(Grades1.getModes()));
}
}
| true
|
a5e25e9c4a8fe7fb405b2f0320788fbceebc4fb3
|
Java
|
meprabu/restapi
|
/src/main/java/com/cdr/bc/restApiBC/domain/LicenseId.java
|
UTF-8
| 2,132
| 2.25
| 2
|
[] |
no_license
|
package com.cdr.bc.restApiBC.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class LicenseId implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="org_code")
private int orgCode;
@Column(name="modify_user")
private String modifyUser;
@Column(name="bed_type")
private String bedType;
@Column(name="location_code")
private String locationCode;
public String getModifyUser() {
return this.modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public int getOrgCode() {
return this.orgCode;
}
public void setOrgCode(int orgCode) {
this.orgCode = orgCode;
}
public String getLocationCode() {
return this.locationCode;
}
public void setLocationCode(String locationCode) {
this.locationCode = locationCode;
}
public String getBedType() {
return this.bedType;
}
public void setBedType(String bedType) {
this.bedType = bedType;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((bedType == null) ? 0 : bedType.hashCode());
result = prime * result + ((locationCode == null) ? 0 : locationCode.hashCode());
result = prime * result + ((modifyUser == null) ? 0 : modifyUser.hashCode());
result = prime * result + orgCode;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
LicenseId other = (LicenseId) obj;
if (bedType == null) {
if (other.bedType != null)
return false;
} else if (!bedType.equals(other.bedType))
return false;
if (locationCode == null) {
if (other.locationCode != null)
return false;
} else if (!locationCode.equals(other.locationCode))
return false;
if (modifyUser == null) {
if (other.modifyUser != null)
return false;
} else if (!modifyUser.equals(other.modifyUser))
return false;
if (orgCode != other.orgCode)
return false;
return true;
}
}
| true
|
dd6a4af1a60a98e4f176a691a4f2def984d5ee7c
|
Java
|
phillip-groves/aphl
|
/aphl/src/com/pgrvs/aphl/util/Lz77CompressionUtil.java
|
WINDOWS-1250
| 3,821
| 2.625
| 3
|
[] |
no_license
|
/****************************************************************************\
* *
* ADVANCED POKMON HACKING LIBRARY *
* *
* A Java library for helping developers modify Pokemon game data *
* *
* Copyright (C) 2017 Phillip Groves *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT- *
* ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
/****************************************************************************/
package com.pgrvs.aphl.util;
import com.pgrvs.aphl.GbaRom;
/**
* This class is responsible for providing utility methods for Lz77 compression, which is used throughout GBA
* games for palettes, images, and other purposes. All methods within this class are static for easy access.
*
* @author Phillip Groves
*
*/
public class Lz77CompressionUtil {
private static final int LZ77_OPCODE = 0x10;
/**
* <p>Decompresses Lz77 data at the given address, and then returns the result.</p>
* <p>This algorithm was originally developed by CUE @ dsdcmp, but it has been optimized and edited
* for our purposes. </p>
*
* @param rom
* @param address Address to read
* @return Decompressed data
*/
public static int[] decompress(GbaRom rom, int address) {
if (rom.getByte(address) != LZ77_OPCODE)
throw new IllegalStateException("Invalid Lz77 compression opcode.");
int[] data = new int[getDecompLength(rom)];
int destination, flags, offset, length, value, position = 0;
boolean flagged;
while (position < data.length) {
flags = rom.getByte();
for (int i = 0; i < 8; i++) {
flagged = (flags & ( 0x80 >> i) ) > 0;
if ( flagged ) {
value = rom.getByte();
length = (value >> 4) + 3;
offset = ((value & 0x0F) << 8) | rom.getByte();
destination = position;
if (offset > position)
throw new IllegalStateException("Cannot go back more than already written.");
for (int j = 0; j < length; j++)
data[position++] = data[destination - offset - 1 + j];
} else {
value = rom.getByte();
if (position < data.length)
data[position++] = value;
else if (value == 0)
break;
}
if (position > data.length)
break;
}
}
return data;
}
/**
* Calculates the length of compressed data
*
* @param rom
* @return Amount to read
*/
private static int getDecompLength(GbaRom rom) {
int length = 0;
for (int i = 0; i < 3; i++)
length |= (rom.getByte() << ( i * 8));
if (length == 0)
length = rom.getInt();
return length;
}
}
| true
|
ab8ca277709cab1cc39ec30c1a70373493ef5871
|
Java
|
ajayhada/typehandlers-encrypt
|
/src/test/java/com/github/trang/typehandlers/test/converalls/TestCrypt.java
|
UTF-8
| 346
| 2.15625
| 2
|
[
"Apache-2.0"
] |
permissive
|
package com.github.trang.typehandlers.test.converalls;
import com.github.trang.typehandlers.crypt.Crypt;
/**
* @author trang
*/
public class TestCrypt implements Crypt {
@Override
public String encrypt(String content) {
return "1";
}
@Override
public String decrypt(String content) {
return "3";
}
}
| true
|
a9a960cef828c52c6dbb1ca54a13314bc5e2bfd4
|
Java
|
huangdgm/android-development-tutorial
|
/Navigation/app/src/main/java/nz/ac/aut/navigation/SMSActivity.java
|
UTF-8
| 5,472
| 2.328125
| 2
|
[
"Apache-2.0"
] |
permissive
|
package nz.ac.aut.navigation;
import android.Manifest;
import android.content.ContentResolver;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
public class SMSActivity extends AppCompatActivity {
private static final int SEND_SMS_PERMISSIONS_REQUEST = 0;
private static final int READ_SMS_PERMISSIONS_REQUEST = 1;
ArrayList<String> messages = new ArrayList<>();
ArrayAdapter arrayAdapter;
private static SMSActivity instance;
Button sendBtn;
ListView listView;
EditText txtPhoneNo;
EditText txtMessage;
String phoneNo;
String message;
public static SMSActivity instance() {
return instance;
}
@Override
public void onStart() {
super.onStart();
instance = this;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sms);
sendBtn = (Button) findViewById(R.id.buttonSendMessage);
listView = (ListView) findViewById(R.id.listView);
txtPhoneNo = (EditText) findViewById(R.id.editTextPhoneNumber);
txtMessage = (EditText) findViewById(R.id.editTextMessage);
arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, messages);
listView.setAdapter(arrayAdapter);
sendBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ContextCompat.checkSelfPermission(SMSActivity.this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED) {
getPermissionToSendSMS();
} else {
sendSMS();
}
}
});
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) {
getPermissionToReadSMS();
} else {
refreshSmsInbox();
}
}
private void getPermissionToReadSMS() {
if (!(ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_SMS))) {
Toast.makeText(this, "Please allow permission for reading messages.", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_SMS}, READ_SMS_PERMISSIONS_REQUEST);
}
}
private void getPermissionToSendSMS() {
if (!(ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.SEND_SMS))) {
Toast.makeText(this, "Please allow permission for sending messages.", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SEND_SMS_PERMISSIONS_REQUEST);
}
}
public void sendSMS() {
phoneNo = txtPhoneNo.getText().toString();
message = txtMessage.getText().toString();
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, message, null, null);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case SEND_SMS_PERMISSIONS_REQUEST:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
sendSMS();
Toast.makeText(getApplicationContext(), "SMS sent successfully.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "SMS sent failed! Please try again.", Toast.LENGTH_LONG).show();
}
break;
case READ_SMS_PERMISSIONS_REQUEST:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), "Read SMS permission granted.", Toast.LENGTH_LONG).show();
refreshSmsInbox();
} else {
Toast.makeText(getApplicationContext(), "Read SMS permission denied.", Toast.LENGTH_LONG).show();
}
break;
}
}
public void refreshSmsInbox() {
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(Uri.parse("content://sms/inbox"), null, null, null, null);
int indexOfAddress = cursor.getColumnIndex("address");
int indexOfBody = cursor.getColumnIndex("body");
if (!(indexOfBody < 0 || !cursor.moveToFirst())) {
arrayAdapter.clear();
do {
String string = "From: " + cursor.getString(indexOfAddress) + "\n" + cursor.getString(indexOfBody) + "\n";
arrayAdapter.add(string);
} while (cursor.moveToNext());
}
}
public void updateInbox(final String message) {
arrayAdapter.insert(message, 0);
arrayAdapter.notifyDataSetChanged();
}
}
| true
|
38fc4aa08ed6ae8937b4fe2564587952f8809082
|
Java
|
ashwin2990/batterypool
|
/app/src/main/java/com/example/ashwinshankar/batterypool/PickUpTimer.java
|
UTF-8
| 6,235
| 1.851563
| 2
|
[] |
no_license
|
package com.example.ashwinshankar.batterypool;
import android.app.Dialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.MutableData;
import com.google.firebase.database.Transaction;
import com.google.firebase.database.ValueEventListener;
import static android.R.attr.countDown;
import static com.example.ashwinshankar.batterypool.R.id.textView;
import static com.example.ashwinshankar.batterypool.R.id.textView4;
public class PickUpTimer extends AppCompatActivity {
TextView textView4;
TextView mbatteryID;
TextView mAddress;
Button mCancelBattery;
Button mPayNow;
CountDownTimer timer;
Dialog dialog,dialog_payment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_count_down_timer);
textView4 = (TextView)findViewById(R.id.textView4);
mbatteryID = (TextView)findViewById(R.id.textView6);
mAddress = (TextView)findViewById(R.id.textView13);
mCancelBattery = (Button)findViewById(R.id.button3);
mPayNow = (Button)findViewById(R.id.button4);
final String batteryID = getIntent().getStringExtra("BatteryID");
final String batteryType = getIntent().getStringExtra("BatteryType");
final String swapStation = getIntent().getStringExtra("PetrolStation");
final Intent mIntent1 = new Intent(PickUpTimer.this, ReservationRelease.class);
final Intent mIntent2 = new Intent(PickUpTimer.this,PaidPage.class);
DatabaseReference firebase = FirebaseDatabase.getInstance().getReference().child("batterylocations");
final DatabaseReference transacref = FirebaseDatabase.getInstance().getReference().child("batterylocations/"+swapStation);
firebase.child(swapStation).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String address = dataSnapshot.child("address").getValue().toString();
mAddress.setText(address);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
mbatteryID.setText(batteryType);
timer = new CountDownTimer(600000, 1000){
public void onTick(long millisUntilFinished) {
textView4.setText(millisUntilFinished / 1000 + "s");
}
public void onFinish() {
transacref.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData mutableData) {
Integer count=mutableData.child("count").getValue(Integer.class);
mutableData.child(batteryID + "/status").setValue(0);
count++;
mutableData.child("count").setValue(count);
mIntent1.putExtra("Message","Reservation Time's Up!");
startActivity(mIntent1);
return Transaction.success(mutableData);
}
@Override
public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
}
});
}
}.start();
mCancelBattery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
timer.cancel();
transacref.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData mutableData) {
Integer count=mutableData.child("count").getValue(Integer.class);
mutableData.child(batteryID + "/status").setValue(0);
count++;
mutableData.child("count").setValue(count);
return Transaction.success(mutableData);
}
@Override
public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
}
});
dialog = new Dialog(PickUpTimer.this);
dialog.setContentView(R.layout.dialogbox);
dialog.setTitle("BatteryPool");
Button reserve = (Button) dialog.findViewById(R.id.reserve_button);
reserve.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent mIntent1 = new Intent(PickUpTimer.this, MapsActivity.class);
startActivity(mIntent1);
}
});
dialog.show();
}
});
mPayNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
timer.cancel();
dialog_payment = new Dialog(PickUpTimer.this);
dialog_payment.setContentView(R.layout.dialogbox_payment);
dialog_payment.setTitle("BatteryPool");
Button reserve = (Button) dialog_payment.findViewById(R.id.reserve_button);
reserve.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent mIntent1 = new Intent(PickUpTimer.this, MapsActivity.class);
startActivity(mIntent1);
}
});
dialog_payment.show();
}
});
}
}
| true
|
7ff3865ce3fadaec9cb6467581e26f74404656c3
|
Java
|
bellmit/Advance-1
|
/realproject/QingGuoRead/app/src/main/java/com/quduquxie/base/listener/BillboardListener.java
|
UTF-8
| 164
| 1.640625
| 2
|
[] |
no_license
|
package com.quduquxie.base.listener;
/**
* Created on 17/8/8.
* Created by crazylei.
*/
public interface BillboardListener {
String loadBillboardDate();
}
| true
|
ab989942bb975b100a2a245fb4c519511ee99783
|
Java
|
cristianhoyos66/Clean-Architecture
|
/Infrastructure/src/main/java/co/com/taskmanagement/infrastructure/board/BoardAdapter.java
|
UTF-8
| 1,698
| 2.40625
| 2
|
[] |
no_license
|
package co.com.taskmanagement.infrastructure.board;
import co.com.taskmanagement.domain.board.Board;
import co.com.taskmanagement.infrastructure.cardlist.CardListAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
public class BoardAdapter {
@Autowired
CardListAdapter cardListAdapter;
public Board boardEntityToBoard(BoardEntity boardEntity) {
return Board.builder()
.id(boardEntity.getId())
.name(boardEntity.getName())
.description(boardEntity.getDescription())
.cardLists(cardListAdapter.cardListEntitiesToCardLists(boardEntity.getCardLists()))
.creationDate(boardEntity.getCreationDate())
.modificationDate(boardEntity.getModificationDate())
.build();
}
public BoardEntity boardToBoardEntity(Board board) {
return BoardEntity.builder()
.name(board.getName())
.description(board.getDescription())
.creationDate(board.getCreationDate())
.modificationDate(board.getModificationDate())
.build();
}
public Board boardRequestDTOToBoard(BoardRequestDTO boardRequestDTO) {
return Board.builder()
.name(boardRequestDTO.getName())
.description(boardRequestDTO.getDescription())
.build();
}
public BoardResponseDTO boardToBoardResponseDTO(Board board) {
return BoardResponseDTO.builder()
.id(Optional.ofNullable(board.getId()).orElse(0L))
.name(board.getName())
.description(board.getDescription())
.cardLists(cardListAdapter.cardListsToCardListResponses(board.getCardLists()))
.build();
}
}
| true
|
b00cd4bc315dc28d48a1eb1e14742b3803661e33
|
Java
|
zohirbenslama/code-g
|
/code-g-core/trunk/src/main/java/org/abstractmeta/code/g/core/config/loader/LoadedSourceImpl.java
|
UTF-8
| 1,301
| 1.9375
| 2
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
package org.abstractmeta.code.g.core.config.loader;
import org.abstractmeta.code.g.code.CompiledJavaType;
import org.abstractmeta.code.g.code.JavaType;
import org.abstractmeta.code.g.config.loader.LoadedSource;
import org.abstractmeta.toolbox.compilation.compiler.JavaSourceCompiler;
import org.abstractmeta.toolbox.compilation.compiler.registry.JavaFileObjectRegistry;
import java.util.Collection;
/**
* Represents LoadedSourceImpl
* <p>
* </p>
*
* @author Adrian Witas
*/
public class LoadedSourceImpl implements LoadedSource {
private ClassLoader classLoader;
private Collection<JavaType> javaTypes;
private Collection<CompiledJavaType> compiledJavaTypes;
public ClassLoader getClassLoader() {
return classLoader;
}
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
public Collection<JavaType> getJavaTypes() {
return javaTypes;
}
public void setJavaTypes(Collection<JavaType> javaTypes) {
this.javaTypes = javaTypes;
}
public Collection<CompiledJavaType> getCompiledJavaTypes() {
return compiledJavaTypes;
}
public void setCompiledJavaTypes(Collection<CompiledJavaType> compiledJavaTypes) {
this.compiledJavaTypes = compiledJavaTypes;
}
}
| true
|
1c9b2fc76a940c6decfa59969ae1938d358a4a0b
|
Java
|
chuchro3/Blackjack
|
/src/com/blackjack/player/DealerPlayer.java
|
UTF-8
| 1,257
| 3.25
| 3
|
[] |
no_license
|
package com.blackjack.player;
import com.blackjack.util.Card;
/**
* represents the rules followed by the dealer player
*/
public class DealerPlayer extends Player {
public DealerPlayer(String name) {
super(name, 1);
}
@Override
public Player split() {
return null;
}
public void resetState() {
super.resetState();
this.hasHidden = true;
}
public String toString() {
StringBuilder nameBuilder = new StringBuilder();
nameBuilder.append(name);
for(int i=0;i<currentHand.size();i++) {
Card card = currentHand.get(i);
nameBuilder.append(" ");
if (i == currentHand.size()-1 && hasHidden) {
//don't reveal last card
nameBuilder.append("--");
} else {
nameBuilder.append(card.toString());
}
}
return nameBuilder.toString();
}
@Override
public void placeBet() {}
@Override
public String getIntention() {
String intention = "stand";
if (Card.getScore(currentHand) < 17) {
intention = "hit";
}
System.out.println("Dealer decides to " + intention);
return intention;
}
}
| true
|
0f151c751bd40a977842d1f8131c1cb920675a9d
|
Java
|
proelbtn/spigot-notify2discord
|
/src/main/java/com/proelbtn/Main.java
|
UTF-8
| 812
| 2.28125
| 2
|
[] |
no_license
|
package com.proelbtn;
import com.proelbtn.interfaces.Emitter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public void initialize(FileConfiguration config) {
String webhook_uri = config.getString("uri");
String name = config.getString("name");
Emitter emitter = new DiscordEmitter(webhook_uri, name);
Listener listener = new EventListener(emitter);
getServer().getPluginManager().registerEvents(listener, this);
}
@Override
public void onEnable() {
this.saveDefaultConfig();
FileConfiguration config = this.getConfig();
initialize(config);
}
@Override
public void onDisable() {
}
}
| true
|
82943417fc7a9489990094dbc142b1b1d1e23662
|
Java
|
SriRaamMehtalia/Computer-Sci-AP-Java
|
/DeckTester_LodhaA.java
|
UTF-8
| 6,999
| 3.96875
| 4
|
[] |
no_license
|
import java.util.List;
import java.util.ArrayList;
/**
* This is a class that tests the Deck class.
*/
public class DeckTester_LodhaA {
/**
* The main method in this class checks the Deck operations for consistency.
* @param args is not used.
*/
public static void main(String[] args) {
System.out.println("Question 2: 6 cards");
String[] normalRanks = {"ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king"};
String[] normalSuits = {"hearts","clubs","diamonds","spades"};
int[] normalValues = {1,2,3,4,5,6,7,8,9,10,11,12,13};
Deck normalDeck = new Deck(normalRanks, normalSuits,normalValues);
System.out.println("Initial size: " + normalDeck.size() + "\tIs empty: " + normalDeck.isEmpty() + "\nFirst card dealt: " + normalDeck.deal());
System.out.println("Usual deck:" + normalDeck);
String[] heroRanks = {"paliden","mage","warrior","rogue"};
String[] heroSuits = {"yellow","blue","red"};
int[] heroValues = {3,10,1,7};
Deck heroDeck = new Deck(heroRanks, heroSuits, heroValues);
System.out.println("Initial size: " + heroDeck.size() + "\tIs empty: " + heroDeck.isEmpty() + "\nFirst card dealt: " + heroDeck.deal());
System.out.println("Hero deck:\n" + heroDeck);
//#2 answer is 6
}
}
/**
* The Deck class represents a shuffled deck of cards.
* It provides several operations including
* initialize, shuffle, deal, and check if empty.
*/
class Deck {
/**
* cards contains all the cards in the deck.
*/
private List<Card> cards;
/**
* size is the number of not-yet-dealt cards.
* Cards are dealt from the top (highest index) down.
* The next card to be dealt is at size - 1.
*/
private int size;
/**
* Creates a new <code>Deck</code> instance.<BR>
* It pairs each element of ranks with each element of suits,
* and produces one of the corresponding card.
* @param ranks is an array containing all of the card ranks.
* @param suits is an array containing all of the card suits.
* @param values is an array containing all of the card point values.
*/
public Deck(String[] ranks, String[] suits, int[] values) {
int x = 0;
cards = new ArrayList<Card>();
for(x = 0; x < ranks.length; x++)
{
for(String suit : suits)
{
cards.add(new Card(ranks[x], suit, values[x]));
}
}
size = cards.size();
}
/**
* Determines if this deck is empty (no undealt cards).
* @return true if this deck is empty, false otherwise.
*/
public boolean isEmpty() {
return size == 0;
}
/**
* Accesses the number of undealt cards in this deck.
* @return the number of undealt cards in this deck.
*/
public int size() {
return size;
}
/**
* Randomly permute the given collection of cards
* and reset the size to represent the entire deck.
*/
public void shuffle() {
/* *** TO BE IMPLEMENTED IN ACTIVITY 4 *** */
}
/**
* Deals a card from this deck.
* @return the card just dealt, or null if all the cards have been
* previously dealt.
*/
public Card deal() {
if(size>0)
{
size--;
return cards.get(size);
}
return null;
}
/**
* Generates and returns a string representation of this deck.
* @return a string representation of this deck.
*/
@Override
public String toString() {
String rtn = "size = " + size + "\nUndealt cards: \n";
for (int k = size - 1; k >= 0; k--) {
rtn = rtn + cards.get(k);
if (k != 0) {
rtn = rtn + ", \n";
}
if ((size - k) % 2 == 0) {
// Insert carriage returns so entire deck is visible on console.
rtn = rtn;
}
}
rtn = rtn + "\nDealt cards: \n";
for (int k = cards.size() - 1; k >= size; k--) {
rtn = rtn + cards.get(k);
if (k != size) {
rtn = rtn + ", ";
}
if ((k - cards.size()) % 2 == 0) {
// Insert carriage returns so entire deck is visible on console.
rtn = rtn + "\n";
}
}
rtn = rtn + "\n";
return rtn;
}
}
class Card {
/**
* String value that holds the suit of the card
*/
private String suit;
/**
* String value that holds the rank of the card
*/
private String rank;
/**
* int value that holds the point value.
*/
private int pointValue;
/**
* Creates a new <code>Card</code> instance.
*
* @param cardRank a <code>String</code> value
* containing the rank of the card
* @param cardSuit a <code>String</code> value
* containing the suit of the card
* @param cardPointValue an <code>int</code> value
* containing the point value of the card
*/
public Card(String cardRank, String cardSuit, int cardPointValue) {
rank = cardRank;
suit = cardSuit;
pointValue = cardPointValue;
}
/**
* Accesses this <code>Card's</code> suit.
* @return this <code>Card's</code> suit.
*/
public String suit() {
return suit;
}
/**
* Accesses this <code>Card's</code> rank.
* @return this <code>Card's</code> rank.
*/
public String rank() {
return rank;
}
/**
* Accesses this <code>Card's</code> point value.
* @return this <code>Card's</code> point value.
*/
public int pointValue() {
return pointValue;
}
/** Compare this card with the argument.
* @param otherCard the other card to compare to this
* @return true if the rank, suit, and point value of this card
* are equal to those of the argument;
* false otherwise.
*/
public boolean matches(Card otherCard) {
if(this.suit().equals(otherCard.suit()) && this.rank().equals(otherCard.rank()) && this.pointValue() == otherCard.pointValue())
{
return true;
}
return false;
}
/**
* Converts the rank, suit, and point value into a string in the format
* "[Rank] of [Suit] (point value = [PointValue])".
* This provides a useful way of printing the contents
* of a <code>Deck</code> in an easily readable format or performing
* other similar functions.
*
* @return a <code>String</code> containing the rank, suit,
* and point value of the card.
*/
@Override
public String toString() {
return "[" + rank + "] of [" + suit + "] (point value = [" + pointValue + "])";
}
}
| true
|
cace751c2a0100824e23794854835b9a0484ebff
|
Java
|
XiGuangKai/MyAndroidProjectExercise
|
/HSTCMD/cqatest/src/com/motorola/motocit/Test_SequenceMode.java
|
UTF-8
| 10,824
| 1.765625
| 2
|
[
"Apache-2.0"
] |
permissive
|
/*
* Copyright (c) 2012 - 2016 Motorola Mobility, Inc.
* All Rights Reserved
*
* The contents of this file are Motorola Confidential Restricted (MCR).
*/
package com.motorola.motocit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.widget.Toast;
import com.motorola.motocit.mmc.MMC;
public class Test_SequenceMode extends Test_Base
{
private static List<ResolveInfo> ResolveInfoList = new ArrayList<ResolveInfo>();
@Override
protected void onCreate(Bundle savedInstanceState)
{
TAG = "Test_Sequence_Mode";
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String path = intent.getStringExtra("com.motorola.motocit.Path");
if (path == null)
{
path = "";
this.setTitle("CQATest version: ");
}
else
{
this.setTitle("CQA Test/" + path);
}
// set flag to false
isCQASeqResolveInfoListCleared = false;
// If Odm device, check whether external sdcard is available for test
// result copy at the end of test
if (TestUtils.isOdmDevice())
{
MMC sdcard = new MMC();
String sdcardPath = sdcard.getExternalStorageMountPath();
if (sdcardPath == null)
{
Toast.makeText(this, "EXTERNAL SD CARD IS NOT SUPPORTED!", Toast.LENGTH_SHORT).show();
}
else if (searchSDcard(sdcardPath) == false)
{
Toast.makeText(this, "EXTERNAL SD CARD IS NOT MOUNTED!", Toast.LENGTH_SHORT).show();
}
else
{
dbgLog(TAG, "External sdcard is mounted at " + sdcardPath, 'd');
}
}
TestUtils.setSequenceFileInUse(TestUtils.getfactoryOrAltConfigFileInUse());
testResultInit();
// Setup Display Settings
TestUtils.setCQASettingsFromConfig();
// If list is empty assuming that use wants to start a new sequence
// session.
if (ResolveInfoList.isEmpty())
{
getSeqModeList();
}
}
@Override
protected void onResume()
{
super.onResume();
// The activity has become visible (it is now "resumed").
dbgLog(TAG, "onResume called", 'i');
// In case the test was stopped by accident. Restart the new test
if (ResolveInfoList.isEmpty() && isCQASeqResolveInfoListCleared)
{
getSeqModeList();
}
// Sequence mode is implemented by having the sequenceMode
// activity launch an activity and which should cause the
// sequenceMode activity to enter the paused state. When
// the launched activity calls finish() the sequenceMode
// activity should be resumed and the OnResume() called which
// will then launch the next activity.
if (ResolveInfoList.size() > 0)
{
ResolveInfo info = ResolveInfoList.remove(0);
dbgLog(TAG, "onResume started " + info.activityInfo.name, 'i');
startActivity(activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
}
else
{
dbgLog(TAG, "onResume called and ResolveInfoList is empty.. calling finish()", 'i');
finish();
}
}
@Override
protected void onDestroy()
{
super.onDestroy();
dbgLog(TAG, "onDestroy", 'd');
if (ResolveInfoList.isEmpty() == false)
{
ResolveInfoList.clear();
isCQASeqResolveInfoListCleared = true;
}
}
protected void getSeqModeList()
{
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
PackageManager pm = getPackageManager();
// get test result activity at first then put it in the list.
mainIntent.addCategory("com.motorola.motocit.SequentialMode.ITEM");
List<ResolveInfo> tempTestResultList = pm.queryIntentActivities(mainIntent, 0);
if (tempTestResultList.size() == 0)
{
dbgLog(TAG, "No SequentialMode items found", 'e');
// generate toast
Context context = getApplicationContext();
CharSequence text = "No SequentialMode items found!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
finish();
}
ResolveInfo test_result = null;
for (ResolveInfo info : tempTestResultList)
{
if (!TestUtils.activityFilter(info.activityInfo.name))
{
if (info.activityInfo.name.contains("Test_Result"))
{
// find test result activity, exit loop
dbgLog(TAG, "Get test result activity!", 'i');
test_result = info;
break;
}
}
}
if (test_result != null)
{
// add test result activity, make sure it's the last activity in
// sequential mode
dbgLog(TAG, "ResolveInfoList Add " + test_result.activityInfo.name, 'i');
ResolveInfoList.add(test_result);
}
// Get optional sequential test activities
mainIntent.removeCategory("com.motorola.motocit.SequentialMode.ITEM");
mainIntent.addCategory("com.motorola.motocit.SequentialMode.Optional");
List<ResolveInfo> optionalList = pm.queryIntentActivities(mainIntent, 0);
if (optionalList.size() == 0)
{
dbgLog(TAG, "No optional sequential test items found", 'i');
}
else
{
for (ResolveInfo info : optionalList)
{
// Optional activity name must be configed in the config file as
// below format:
// "optional:<activity name>"
// e.g optional:com.motorola.motocit.cosmetic.CosmeticTest
if (TestUtils.activityFilter("optional:" + info.activityInfo.name))
{
if (info.activityInfo.name.toLowerCase().contains("fingerprint"))
{
// Affinity 16MP hw has Fingerprint but 13MP does not
// so still need to check it even it's the same product
// config
if (TestUtils.hasFingerprintSensor())
{
ResolveInfoList.add(info);
dbgLog(TAG, "ResolveInfoList Add optional activity " + info.activityInfo.name, 'i');
}
}
else
{
ResolveInfoList.add(info);
dbgLog(TAG, "ResolveInfoList Add optional activity " + info.activityInfo.name, 'i');
}
}
}
}
mainIntent.removeCategory("com.motorola.motocit.SequentialMode.Optional");
mainIntent.addCategory("com.motorola.motocit.SequentialMode.ITEM");
List<ResolveInfo> tempList = pm.queryIntentActivities(mainIntent, 0);
// filter list by activityFilter()
if (tempList.size() == 0)
{
dbgLog(TAG, "No SequentialMode items found", 'e');
// generate toast
Context context = getApplicationContext();
CharSequence text = "No SequentialMode items found!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
finish();
}
for (ResolveInfo info : tempList)
{
if (!TestUtils.activityFilter(info.activityInfo.name))
{
if (info.activityInfo.name.contains("Test_Result"))
{
continue;
}
else
{
dbgLog(TAG, "ResolveInfoList Add " + info.activityInfo.name, 'i');
ResolveInfoList.add(info);
}
}
}
if (ResolveInfoList.size() == 0)
{
dbgLog(TAG, "No SequentialMode items found", 'e');
// generate toast
Context context = getApplicationContext();
CharSequence text = "No SequentialMode items found!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
finish();
}
// reverse the list to maintain original implementation order
Collections.reverse(ResolveInfoList);
return;
}
protected Intent activityIntent(String pkg, String componentName)
{
Intent result = new Intent();
result.setClassName(pkg, componentName);
return result;
}
@Override
public void onPause()
{
super.onPause();
}
@Override
protected void handleTestSpecificActions() throws CmdFailException, CmdPassException
{
if (strRxCmd.equalsIgnoreCase("NO_VALID_COMMANDS"))
{
}
else
{
// Generate an exception to send FAIL result and mesg back to
// CommServer
List<String> strErrMsgList = new ArrayList<String>();
strErrMsgList.add(String.format("Activity '%s' does not recognize command '%s'", TAG, strRxCmd));
dbgLog(TAG, strErrMsgList.get(0), 'i');
throw new CmdFailException(nRxSeqTag, strRxCmd, strErrMsgList);
}
}
@Override
protected void printHelp()
{
List<String> strHelpList = new ArrayList<String>();
strHelpList.add("Test Sequence Mode");
strHelpList.add("");
strHelpList.add("This activity brings up the CQA Test Sequence Mode");
strHelpList.add("");
strHelpList.addAll(getBaseHelp());
strHelpList.add("Activity Specific Commands");
strHelpList.add(" ");
CommServerDataPacket infoPacket = new CommServerDataPacket(nRxSeqTag, strRxCmd, TAG, strHelpList);
sendInfoPacketToCommServer(infoPacket);
}
@Override
public boolean onSwipeRight()
{
return false;
}
@Override
public boolean onSwipeLeft()
{
return false;
}
@Override
public boolean onSwipeUp()
{
return false;
}
@Override
public boolean onSwipeDown()
{
return false;
}
}
| true
|
94c6a662f14bc5a1fc7d13c5fec0e0b68c5cfbf1
|
Java
|
jeffreyyjp/algs4solutions
|
/src/fundamentals/dataabstraction/Exercise1_2_11.java
|
UTF-8
| 513
| 3.234375
| 3
|
[] |
no_license
|
package fundamentals.dataabstraction;
import edu.princeton.cs.algs4.StdIn;
import edu.princeton.cs.algs4.StdOut;
public class Exercise1_2_11 {
public static void main(String[] args) {
StdOut.print("Input month number: ");
int m = StdIn.readInt();
StdOut.print("Input day number: ");
int d = StdIn.readInt();
StdOut.print("Input year number: ");
int y = StdIn.readInt();
SmartDate date = new SmartDate(m, d, y);
StdOut.println(date);
}
}
| true
|
43cf3d2948eeab9ad15486443442d1742490ed6a
|
Java
|
jli9056/dx
|
/ProjectSrc/src/com/dixin/action/overflow/DeleteOverflowAction.java
|
UTF-8
| 467
| 1.921875
| 2
|
[] |
no_license
|
/**
*
*/
package com.dixin.action.overflow;
import com.dixin.action.GenericDeleteAction;
import com.dixin.business.impl.OverflowHelper;
import com.dixin.hibernate.Overflow;
/**
* Delete Action For JDO Overflow
*
* @author Luo
*
*/
public class DeleteOverflowAction extends GenericDeleteAction<Overflow> {
public DeleteOverflowAction() {
super(Overflow.class, OverflowHelper.class);
uniqueKeys = new String[] { "", "id", "orderNo", "customer" };
}
}
| true
|
744c9792d299f817ac87967a03ab3d8ff51f9466
|
Java
|
ErpProcess/25121981
|
/softProcess/src/ERP/Process/Commerciale/TypeFamille/service/TypeFamilleService.java
|
UTF-8
| 2,612
| 1.898438
| 2
|
[] |
no_license
|
package ERP.Process.Commerciale.TypeFamille.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;
import ERP.Process.Commerciale.TypeFamille.dao.TypeFamilleDAO;
import ERP.Process.Commerciale.TypeFamille.model.TypeFamilleBean;
import ERP.Process.Commerciale.TypeFamille.template.TypeFamilleTemplate;
import ERP.eXpertSoft.wfsi.Administration.Outils_Parametrage.Generic.GenericWeb;
@Service
public class TypeFamilleService extends GenericWeb {
private TypeFamilleDAO daoTypeFamille;
@Autowired
public void setDaoTypeFamille(TypeFamilleDAO daoTypeFamille) {
this.daoTypeFamille = daoTypeFamille;
}
@Transactional(readOnly=true)
public List<TypeFamilleBean> doFetchDatafromServer(TypeFamilleBean beanSearch) throws Exception {
return daoTypeFamille.doFindListTypeFamille(beanSearch);
}
@Transactional
public Boolean doCreateRowData(TypeFamilleBean insertBean) throws Exception {
boolean result = false;
try {
if(daoTypeFamille.doSaveTypeFamille(insertBean)){
result = true;
}else{
result = false;
}
} catch (Exception e) {
result = false;
throw e;
}
return result;
}
@Transactional
public Boolean doUpdateRowData(TypeFamilleBean updateBean) throws Exception {
boolean result = false;
try {
if(daoTypeFamille.doUpdateTypeFamille(updateBean)){
String indexo = (String) getObjectValueModel(INDEX_ROW);
List list = (List) getObjectValueModel(TypeFamilleTemplate.LIST_DATA);
list.remove(Integer.parseInt(indexo));
list.add(updateBean);
setObjectValueModel(TypeFamilleTemplate.LIST_DATA, list);
result = true;
}else{
result = false;
}
} catch (Exception e) {
result = false;
throw e;
}
return result;
}
@Transactional
public Boolean doDeleteRowData(TypeFamilleBean deleteBean) throws Exception {
boolean result = false;
try {
if(daoTypeFamille.doDeleteTypeFamille(deleteBean)){
String indexo = (String) getObjectValueModel(INDEX_ROW);
List list = (List) getObjectValueModel((String) getObjectValueModel(NAME_LIST_G));
list.remove(Integer.parseInt(indexo));
setObjectValueModel((String) getObjectValueModel(NAME_LIST_G), list);
result = true;
}else{
result = false;
}
} catch (Exception e) {
result = false;
throw e;
}
return result;
}
}
| true
|
c5055901f8a7322e1f6ea5d9738b660e9992ca00
|
Java
|
yukyongsoo/algorithm
|
/src/main/java/com/yuk/algorithm/maths/Maths.java
|
UTF-8
| 1,429
| 3.421875
| 3
|
[] |
no_license
|
package com.yuk.algorithm.maths;
public class Maths {
public void makeCatalanNum(StringBuilder sb, int num, int open, int close) {
if (open == 0 && close == 0) {
return;
}
if (open > 0) {
sb.append("{");
makeCatalanNum(sb, num + 1, open - 1, close + 1);
}
if (close > 0) {
sb.append("}");
makeCatalanNum(sb, num + 1, open, close - 1);
}
}
public void permutation(int[] arr, int depth, int legth, int size) {
if (depth == size) {
for (int i = 0; i < size; i++) {
if (i == size - 1)
System.out.println(arr[i]);
else
System.out.print(arr[i] + ",");
}
return;
}
for (int i = depth; i < legth; i++) {
int temp = arr[i];
arr[i] = arr[depth];
arr[depth] = temp;
permutation(arr, depth + 1, legth, size);
temp = arr[i];
arr[i] = arr[depth];
arr[depth] = temp;
}
}
public void combination(int arr[], int data[], int start, int end, int index, int size) {
if (index == size) {
for (int j = 0; j < size; j++)
System.out.print(data[j] + " ");
System.out.println("");
return;
}
for (int i = start; i <= end && end - i + 1 >= size - index; i++) {
data[index] = arr[i];
combination(arr, data, i + 1, end, index + 1, size);
}
}
public long fibo(int val) {
long val1=1;
long val2=0;
long valnew = 0;
for(int i = 0 ; i < val; i++) {
valnew = val1 + val2;
val2 = val1;
val1= valnew;
}
return valnew;
}
}
| true
|
6d8510260b60b3a278b74c46e3708e4fe89ee4c4
|
Java
|
codecrafts/java.fundamentals
|
/Tracks/Zaqwesx/lesson10/TestsLesson10.java
|
UTF-8
| 1,743
| 2.84375
| 3
|
[] |
no_license
|
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class TestsLesson10 {
public static void doMockTests() {
System.out.println("==========================================");
System.out.println("Running tests with mock data.");
System.out.println("==========================================");
String dataString = "21.08.2018;100000;Аванс;Зарплата,27.08.2018;-300;Бизнес-ланч;Еда,28.08.2018;-100;Перекус;Еда";
MockTransactionLoader mockTransactionLoader = new MockTransactionLoader(dataString);
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
TransactionList transactionList = null;
try {
transactionList = new TransactionList(mockTransactionLoader.getMockData(), formatter.parse("21.08.2018"));
} catch (ParseException e) {
e.printStackTrace();
}
mockTransactionLoader.addObserver(transactionList);
mockTransactionLoader.addTransaction("21.08.2018;-1000;Продукты в Ашане;Еда");
mockTransactionLoader.removeTransaction("21.08.2018;100000;Аванс;Зарплата");
mockTransactionLoader.addTransaction("21.08.2018;-1000Продукты в Ашане;Еда");
mockTransactionLoader.addTransaction("21.15.2018");
mockTransactionLoader.addTransaction("-1000Продукты в Ашане;Еда");
mockTransactionLoader.addTransaction("21.15.2018;;;Еда");
System.out.println("Number of exceptions thrown: " + transactionList.getTotalExceptions());
if (transactionList.getTotalExceptions() == 4)
System.out.println("Тест пройден.");
}
}
| true
|
ba0d46f0031d5e93da5aa894699b83e8df3a4b29
|
Java
|
Ashish-kumar-pradhan/DSA-450-Questions-By-Love-babbar
|
/array/KthSmalestElement.java
|
UTF-8
| 1,415
| 3.46875
| 3
|
[] |
no_license
|
package array;
import java.util.PriorityQueue;
public class KthSmalestElement {
public static int kthMin(int[] arr, int l, int r, int k)
{
//Your code here
int ans = 0;
int index = 0 ;
for(int i = 0 ; i < k ; i++ ){
int minValue = Integer.MAX_VALUE;
int j = i;
for( ; j < r+1 ; j++ ){
if (arr[j] < minValue){
minValue = arr[j];
index = j ;
}
}
arr[index] = arr[i];
arr[i] = minValue;
if (i == k-1) {
ans = minValue;
}
}
return ans;
}
public static int kthMin2(int arr[] , int k) {
int kthelem = 0;
PriorityQueue<Integer> hp = new PriorityQueue<Integer>();
for(int i : arr) {
hp.add(i);
}
for(int i = 0 ; i < k ; i++) {
kthelem = hp.remove();
}
return kthelem;
}
public static int kthMax2(int arr[] , int k) {
int kthelem = 0;
PriorityQueue<Integer> hp = new PriorityQueue<Integer>();
for(int i : arr) {
hp.add(i);
}
for(int i = 0 ; i < arr.length + 1 - k ; i++) {
kthelem = hp.remove();
}
return kthelem;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = {7 ,10 ,4 ,3 ,20 ,15};
System.out.println( kthMax2(arr , 2));
System.out.println( kthMin2(arr , 2));
}
}
| true
|
644582e74c466cfbc0f68ff6d6cabdea822a2706
|
Java
|
LilianaEverett/w12_d4_java_fantasy_adventure_lab
|
/src/main/java/weapons/Weapon.java
|
UTF-8
| 318
| 3.09375
| 3
|
[] |
no_license
|
package weapons;
import behaviours.IWeapon;
public abstract class Weapon implements IWeapon {
private String name;
public int damage;
public Weapon(String name, int damage) {
this.name = name;
this.damage = damage;
}
public String getName() {
return this.name;
}
}
| true
|
4a882cc1e3311de533b05fd555e320e9effa6c65
|
Java
|
AlexandrBrytskyi/Freelance
|
/AnreevWebProject/src/main/java/app/services/WorkerManimulationService.java
|
UTF-8
| 840
| 1.945313
| 2
|
[] |
no_license
|
package app.services;
import app.model.Posada;
import java.util.List;
public interface WorkerManimulationService {
boolean addPosadaToExistingUser(String token,
int posadaId,
int userId);
boolean fireUser(String token,
int userId,
int posadaId);
boolean growSalary(String token,
int userId,
int posadaId,
String description,
double growVal);
boolean dischargeSalary(String token,
int userId,
int posadaId,
String description,
double dischargeVal);
List<Posada> getWorkOfOtdel(int otdel);
}
| true
|
acc9b7ee7dee9ef8f27888f587aa1594cab65c02
|
Java
|
XpreeYU/design-mode
|
/src/bridge/Oracle.java
|
UTF-8
| 163
| 1.984375
| 2
|
[] |
no_license
|
package bridge;
public class Oracle implements Driver {
@Override
public void connect() {
System.out.println("获取Oracle数据库驱动");
}
}
| true
|
f60a0461686b2685ab7599bf43d37f9d629d0171
|
Java
|
ScruffyFurn/CritterTap_Android
|
/CritterTap/src/com/crittertap/World.java
|
UTF-8
| 1,111
| 3.03125
| 3
|
[
"MIT"
] |
permissive
|
package com.crittertap;
import java.util.ArrayList;
import java.util.List;
public class World {
private static final float TICK_INITIAL = 0.5f;
//private static final float TICK_DECREMENT = 0.05f;
private float tickTime;
private float tick;
public boolean gameOver;
public int score;
public List<Creature> creaturesArray = new ArrayList<Creature>();
public World() {
Setup();
}
public void Setup() {
tickTime = 0.0f;
tick = TICK_INITIAL;
gameOver = false;
score = 0;
for(int i=0; i <=8; i++) {
if(i <= 2){
Creature tempCreature = new Creature((96 * i) + 19, 86 );
creaturesArray.add(tempCreature);
}
if(i >= 3 && i <= 5){
Creature tempCreature = new Creature((96 * (i-3)) + 19, 180);
creaturesArray.add(tempCreature);
}
if(i >= 6 && i <= 8){
Creature tempCreature = new Creature((96 * (i-6)) + 19, 276);
creaturesArray.add(tempCreature);
}
}
}
public void update(float deltaTime) {
if(gameOver) {
return;
}
tickTime += deltaTime;
while(tickTime > tick) {
tickTime -= tick;
}
}
}
| true
|
4c428f895079236c553b6d39f343596e17f36da8
|
Java
|
geetools/geeCommerce-Java-Shop-Software-and-PIM
|
/modules/core/catalog/price/src-api/com/geecommerce/price/helper/PriceHelper.java
|
UTF-8
| 496
| 1.757813
| 2
|
[
"Apache-2.0"
] |
permissive
|
package com.geecommerce.price.helper;
import java.util.List;
import com.geecommerce.core.service.api.Helper;
import com.geecommerce.core.type.Id;
import com.geecommerce.price.model.Price;
import com.geecommerce.price.pojo.PricingContext;
public interface PriceHelper extends Helper {
public PricingContext getPricingContext();
public PricingContext getPricingContext(boolean createIfNotExists);
public List<Price> filterPrices(List<Price> pricesToFilter, Id... forProductIds);
}
| true
|
c9d05f706c98025ff4d1bca36e10deff25538e60
|
Java
|
zhiji6/VendingMachine
|
/src/main/java/vend/entity/VendMachineInt.java
|
UTF-8
| 4,544
| 2.21875
| 2
|
[] |
no_license
|
package vend.entity;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.NotEmpty;
public class VendMachineInt {
private Integer id;
private Integer belongMachine;
private Integer goodsId;
private String goodsName;
private String wareName;
private String hotStatus;
private Integer waterOutTime;
private Integer grainOutTime;
private Date createTime;
private Date updateTime;
private String extend1;
private String extend2;
private String extend3;
private String extend4;
private String extend5;
private String extend6;
private String extend7;
private String extend8;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@NotNull(message="所属机器不能为空")
public Integer getBelongMachine() {
return belongMachine;
}
public void setBelongMachine(Integer belongMachine) {
this.belongMachine = belongMachine;
}
@NotNull(message="商品Id不能为空")
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
@NotEmpty(message="商品名不能为空")
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName == null ? null : goodsName.trim();
}
public String getWareName() {
return wareName;
}
public void setWareName(String wareName) {
this.wareName = wareName == null ? null : wareName.trim();
}
@NotEmpty(message="冷热状态不能为空")
public String getHotStatus() {
return hotStatus;
}
public void setHotStatus(String hotStatus) {
this.hotStatus = hotStatus == null ? null : hotStatus.trim();
}
@NotNull(message="出水时间不能为空")
@Pattern(regexp="^\\+?[1-9][0-9]*$",message="只能输入正整数")
public Integer getWaterOutTime() {
return waterOutTime;
}
public void setWaterOutTime(Integer waterOutTime) {
this.waterOutTime = waterOutTime;
}
@NotNull(message="出料时间不能为空")
@Pattern(regexp="^\\+?[1-9][0-9]*$",message="只能输入正整数")
public Integer getGrainOutTime() {
return grainOutTime;
}
public void setGrainOutTime(Integer grainOutTime) {
this.grainOutTime = grainOutTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getExtend1() {
return extend1;
}
public void setExtend1(String extend1) {
this.extend1 = extend1 == null ? null : extend1.trim();
}
public String getExtend2() {
return extend2;
}
public void setExtend2(String extend2) {
this.extend2 = extend2 == null ? null : extend2.trim();
}
public String getExtend3() {
return extend3;
}
public void setExtend3(String extend3) {
this.extend3 = extend3 == null ? null : extend3.trim();
}
public String getExtend4() {
return extend4;
}
public void setExtend4(String extend4) {
this.extend4 = extend4 == null ? null : extend4.trim();
}
public String getExtend5() {
return extend5;
}
public void setExtend5(String extend5) {
this.extend5 = extend5 == null ? null : extend5.trim();
}
public String getExtend6() {
return extend6;
}
public void setExtend6(String extend6) {
this.extend6 = extend6 == null ? null : extend6.trim();
}
public String getExtend7() {
return extend7;
}
public void setExtend7(String extend7) {
this.extend7 = extend7 == null ? null : extend7.trim();
}
public String getExtend8() {
return extend8;
}
public void setExtend8(String extend8) {
this.extend8 = extend8 == null ? null : extend8.trim();
}
}
| true
|
ac1ae871f6b006f6b3816b913b1a222a52caea38
|
Java
|
MyUserNameHSW/HSW_XL_LYF_DXW
|
/src/com/lyy/know/activities/KnowProblemActivity.java
|
UTF-8
| 3,530
| 2
| 2
|
[] |
no_license
|
package com.lyy.know.activities;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.lyy.bean.Esort2Bean;
import com.lyy.know.adapter.KnowEsortProAdapter;
import com.lyy.project.R;
import com.lyy.util.MyApplication;
public class KnowProblemActivity extends Activity {
ListView listView;
List<Esort2Bean> list=new ArrayList<Esort2Bean>();
KnowEsortProAdapter adapter;
HttpUtils httpUtils;
private String url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyApplication appState = (MyApplication)this.getApplication();
appState.addActivity(this);
setContentView(R.layout.activity_know_problem);
initViews();
initDatas();
}
private void initViews() {
listView=(ListView) findViewById(R.id.bk_pro_lv);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Intent intent=new Intent();
intent.setClass(KnowProblemActivity.this, KnowProblemDetailActivity.class);
Esort2Bean esort2Bean=list.get(position);
int Es2_id=esort2Bean.getEs2_id();
Log.e("Es2_id",esort2Bean.toString());
intent.putExtra("es2_id", Es2_id);
startActivity(intent);
}
});
}
private void initDatas() {
adapter=new KnowEsortProAdapter(KnowProblemActivity.this, list);
listView.setAdapter(adapter);
httpUtils=new HttpUtils();
url="http://"+MyApplication.IP+":8080/MyProject/BaikeServlet";
RequestParams params=new RequestParams();
params.addBodyParameter("key","2");
Intent intent=getIntent();
int Es1_id=intent.getIntExtra("es1_id",1);
params.addBodyParameter("Es1_id",""+Es1_id);
httpUtils.send(HttpMethod.POST, url,params,
new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result=responseInfo.result;
Log.e("bbb", result);
JSONArray array;
try {
array=new JSONArray(result);
for (int i = 0; i < array.length(); i++) {
JSONObject object=array.getJSONObject(i);
int Es2_id=object.getInt("es2_id");
int Es1_id=object.getInt("es1_id");
String Es2_name=object.getString("es2_name");
Esort2Bean esort2Bean=new Esort2Bean(Es2_id,Es1_id,Es2_name);
list.add(esort2Bean);
Log.e("aaa", esort2Bean.toString());
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
adapter.notifyDataSetChanged();
}
});
}
public void ComeBack(View v){
KnowProblemActivity.this.finish();
}
}
| true
|
a97dfd17bfb12d36b39957bb506ef0347a410aef
|
Java
|
zongshuo/IntegratedManagementSystem
|
/core/src/main/java/com/zongshuo/util/IdentifyingCode.java
|
UTF-8
| 5,535
| 3.109375
| 3
|
[] |
no_license
|
package com.zongshuo.util;
import java.io.*;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @Author: zongShuo
* @Version: 1.0
* @Date: 2021-5-23
* @Time: 19:32
* @Description:
*/
public final class IdentifyingCode {
private static Random random;
static {
try {
random = SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
random = new Random();
}
}
private IdentifyingCode(){}
public enum CodeType{
NUMBER(0, "NUMBER"),
UPPER_CASE_LETTER(1, "UPPER_CASE_LETTER"),
LOWER_CASE_LATTER(2, "LOWER_CASE_LATTER"),
UPPER_AND_LOWER_LETTER(3, "UPPER_AND_LOWER_LETTER"),
NUMBER_AND_UPPER_LETTER(4, "NUMBER_AND_UPPER_LETTER"),
NUMBER_AND_LOWER_LETTER(5, "NUMBER_AND_LOWER_LETTER"),
NUMBER_AND_LETTER(6, "NUMBER_AND_LETTER");
private int key;
private String value;
CodeType(int key, String value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
protected void setKey(int key) {
this.key = key;
}
public String getValue() {
return value;
}
protected void setValue(String value) {
this.value = value;
}
}
/**
* 返回size个scope范围内的随机数
* 个数和范围应大于0
* @param size 个数
* @param scope 范围
* @return ArrayList
*/
public static List<Integer> createRandomNum(int size, int scope){
List<Integer> integers = new ArrayList<>(size);
if (size <=0 || scope <=0) return integers;
for (int i=0 ; i<size ; i++){
integers.add(random.nextInt(scope));
}
return integers;
}
/**
* 获取纯数字验证码
* @param size 数字个数
* @param scope 数字范围
* @return
*/
public static String getNumberCode(int size, int scope){
StringBuilder code = new StringBuilder();
for (Integer integer : createRandomNum(size, scope)){
code.append(integer);
}
return code.toString();
}
public static String getCode(int size, CodeType type){
String code = "";
if (type == CodeType.NUMBER){
return getNumberCode(size, 10);
}
List<Integer> integers = createRandomNum(size, 26);
switch (type) {
case LOWER_CASE_LATTER:
code = getLatterCode(integers, 97);
break;
case UPPER_CASE_LETTER:
code = getLatterCode(integers, 65);
break;
case UPPER_AND_LOWER_LETTER:
code = getLatterCode(integers);
break;
case NUMBER_AND_LOWER_LETTER:
code = getNumberAndLatterCode(integers, 97);
break;
case NUMBER_AND_UPPER_LETTER:
code = getNumberAndLatterCode(integers, 65);
break;
case NUMBER_AND_LETTER:
code = getNumberAndLatterCode(integers, 0);
break;
default: code = "" ;
}
return code;
}
/**
* 根据随机数组和类型,返回大写字母或小写字母字符串
* @param integers 随机数组
* @param type 类型
* @return
*/
private static String getLatterCode(List<Integer> integers, int type){
StringBuilder builder = new StringBuilder();
for (Integer integer : integers){
builder.append((char)(integer.intValue()+type));
}
return builder.toString();
}
/**
* 根据随机数组返回大小写字母混合的字符串
* @param integers 随机数组
* @return
*/
private static String getLatterCode(List<Integer> integers){
StringBuilder builder = new StringBuilder();
for (Integer integer : integers){
builder.append((char)((random.nextInt() & 1) == 1 ? integer.intValue() + 65 : integer.intValue() + 97));
}
return builder.toString();
}
/**
* 根据随机数组和类型返回数字和大小写字母组合的字符串
* 可能出现情况:1、全是数字;2、全是字母;3、二者混合
* @param integers
* @param type
* @return
*/
private static String getNumberAndLatterCode(List<Integer> integers, int type){
StringBuilder builder = new StringBuilder();
for (Integer integer : integers){
if ((random.nextInt() & 1) == 1){
builder.append(integer.intValue()/10);
continue;
}
if (type == 0){
builder.append((char)((random.nextInt() & 1 ) == 1 ? integer.intValue() + 65 : integer.intValue() + 97));
continue;
}
builder.append((char) integer.intValue() + type);
}
return builder.toString();
}
public static void getCodeImage(String code, int width, int height, OutputStream stream) throws IOException {
GenerateImage image = new GenerateImage();
image.setWidth(width);
image.setHeight(height);
image.setLineNum(20);
image.setFontSize(30);
image.setFontName("黑体");
image.generateImage(code, stream);
}
}
| true
|
e4e02b9f39648d14e1566bfb508b065196f51e3f
|
Java
|
williams-ivan/Homework9
|
/Homework9/src/classesInheritance/Student.java
|
UTF-8
| 843
| 3.921875
| 4
|
[] |
no_license
|
package classesInheritance;
public class Student extends Person {
// ToDo 1: Make this class a child of Person
// ToDo 2: Fix the resulting errors
public Student(String name, short age) { //constructor
super(name, age); //sets the name and age variables for the parent class
}
public String getAddress() { //override method from the parent class
return null;
}
public void setAddress(String address) {} //override method from the parent class
// ToDo 3: Add a field for GPA and create setter and getter
private double gpa; //double variable for gpa
public double getGPA() { //getter
return gpa;
}
public void setGPA(double gpa) { //setter
this.gpa = gpa;
}
// ToDo 4: Add comments to your code
public String toString() {
return "Name: " + getName() + "\nAge: " + getAge() + "\nGPA: " + getGPA();
}
}
| true
|
0805ba4ab003578e256e97d014dfc8ff8bbce6ee
|
Java
|
Kazuya79/BetterDiving
|
/src/main/java/meldexun/better_diving/structure/modules/Wall.java
|
UTF-8
| 4,116
| 2.390625
| 2
|
[] |
no_license
|
package meldexun.better_diving.structure.modules;
import java.util.ArrayList;
import java.util.List;
import meldexun.better_diving.block.BlockStructure;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
public class Wall {
public final World world;
protected BlockPos startPos;
protected BlockPos endPos;
protected EnumFacing facing;
protected SeabaseModule module;
protected BlockStructure block;
public Wall(World world, SeabaseModule module) {
this.world = world;
this.module = module;
}
public Wall(World world, SeabaseModule module, BlockStructure block, BlockPos startPos, BlockPos endPos, EnumFacing facing) {
this.world = world;
this.module = module;
this.block = block;
BlockPos minPos = new BlockPos(Math.min(startPos.getX(), endPos.getX()), Math.min(startPos.getY(), endPos.getY()), Math.min(startPos.getZ(), endPos.getZ()));
BlockPos maxPos = new BlockPos(Math.max(startPos.getX(), endPos.getX()), Math.max(startPos.getY(), endPos.getY()), Math.max(startPos.getZ(), endPos.getZ()));
this.startPos = minPos;
this.endPos = maxPos.subtract(minPos);
this.facing = facing;
}
@Override
public String toString() {
return "Wall(x=" + this.startPos.getX() + ", y=" + this.startPos.getY() + ", z=" + this.startPos.getZ() + ")";
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("start", NBTUtil.createPosTag(this.startPos));
compound.setTag("end", NBTUtil.createPosTag(this.endPos));
compound.setInteger("face", this.facing.getIndex());
compound.setString("block", this.block.getRegistryName().toString());
return compound;
}
public void readFromNBT(NBTTagCompound compound) {
this.startPos = NBTUtil.getPosFromTag(compound.getCompoundTag("start"));
this.endPos = NBTUtil.getPosFromTag(compound.getCompoundTag("end"));
this.facing = EnumFacing.getFront(compound.getInteger("face"));
this.block = (BlockStructure) ForgeRegistries.BLOCKS.getValue(new ResourceLocation(compound.getString("block")));
}
public List<BlockPos> getBlockPosList() {
if (!this.world.isRemote) {
List<BlockPos> list = new ArrayList<>();
BlockPos pos = this.module.getBlockPos().add(this.startPos);
for (int x = 0; x <= this.endPos.getX(); x++) {
for (int y = 0; y <= this.endPos.getY(); y++) {
for (int z = 0; z <= this.endPos.getZ(); z++) {
list.add(pos.add(x, y, z));
}
}
}
return list;
}
return new ArrayList<>();
}
public boolean canGenerate() {
if (!this.world.isRemote) {
BlockPos pos = this.module.getBlockPos().add(this.startPos);
for (int x = 0; x <= this.endPos.getX(); x++) {
for (int y = 0; y <= this.endPos.getY(); y++) {
for (int z = 0; z <= this.endPos.getZ(); z++) {
BlockPos position = pos.add(x, y, z);
if (!this.world.getBlockState(position).getBlock().isReplaceable(this.world, position)) {
return false;
}
}
}
}
return true;
}
return false;
}
public void generate() {
if (!this.world.isRemote) {
this.place();
}
}
public void delete() {
if (!this.world.isRemote) {
this.clear();
}
}
protected void place() {
if (!this.world.isRemote) {
BlockPos pos = this.module.getBlockPos().add(this.startPos);
for (int x = 0; x <= this.endPos.getX(); x++) {
for (int y = 0; y <= this.endPos.getY(); y++) {
for (int z = 0; z <= this.endPos.getZ(); z++) {
this.block.placeBlock(this.world, pos.add(x, y, z), 3, this.module, false);
}
}
}
}
}
protected void clear() {
if (!this.world.isRemote) {
BlockPos pos = this.module.getBlockPos().add(this.startPos);
for (int x = 0; x <= this.endPos.getX(); x++) {
for (int y = 0; y <= this.endPos.getY(); y++) {
for (int z = 0; z <= this.endPos.getZ(); z++) {
this.world.setBlockToAir(pos.add(x, y, z));
}
}
}
}
}
}
| true
|
f7a63112e83ddd54b0e3d1a77d4b0d577320058b
|
Java
|
treken/CinemaStreamApplication
|
/app/src/main/java/com/akshay/cinemastream/models/PersonDetails.java
|
UTF-8
| 1,147
| 2.71875
| 3
|
[] |
no_license
|
package com.akshay.cinemastream.models;
/**
* Created by AKSHAY on 02-10-2015.
*/
public class PersonDetails implements Comparable<PersonDetails>{
/**
* Id : 25e02bee
* Name : Farida Jalal
* Gender : F
* ProfilePath : https://s3-ap-southeast-1.amazonaws.com/cinemalytics/person/EED9EF016477198DD513A50D107FDB70.JPG
*/
private String Id;
private String Name;
private String Gender;
private String ProfilePath;
public void setId(String Id) {
this.Id = Id;
}
public void setName(String Name) {
this.Name = Name;
}
public void setGender(String Gender) {
this.Gender = Gender;
}
public void setProfilePath(String ProfilePath) {
this.ProfilePath = ProfilePath;
}
public String getId() {
return Id;
}
public String getName() {
return Name;
}
public String getGender() {
return Gender;
}
public String getProfilePath() {
return ProfilePath;
}
@Override
public int compareTo(PersonDetails another) {
return this.getName().compareTo(another.getName());
}
}
| true
|
fef3f8a133bda49afd389b357e558ec4114d287d
|
Java
|
lipeng5679/store
|
/src/main/java/com/example/demo/service/CityService.java
|
UTF-8
| 426
| 1.8125
| 2
|
[] |
no_license
|
package com.example.demo.service;
import com.example.demo.domain.City;
import com.example.demo.domain.User;
import java.io.Serializable;
import java.util.List;
/**
* Created by Administrator on 2017/6/16.
*/
public interface CityService {
City findById(Serializable cid);
List<City> findAll();
void insert(City city);
City getByCityname(String cityname);
List<City> getByCityping(String ping);
}
| true
|
a7f6efb0b12d6ceb4e61807a070fa13c93ac2e47
|
Java
|
porofesorsad/CS202
|
/QueueDemo.java
|
UTF-8
| 436
| 2.90625
| 3
|
[] |
no_license
|
public class QueueDemo {
public static void main(String[] args)
{
QueueInterface<String> myQueue = new ImprovedQ<String>();
myQueue.enqueue("A");
myQueue.enqueue("B");
myQueue.enqueue("C");
myQueue.enqueue("D");
String discard = myQueue.dequeue();
discard = myQueue.dequeue();
while(!(myQueue.isEmpty()))
{
String front = myQueue.dequeue();
System.out.println(front);
}
}
}
| true
|
e0e499ed3acebafb7047c7446e0210d386a6ec7a
|
Java
|
qzztf/solo
|
/solo-core/src/main/java/cn/sexycode/util/core/file/JarFileEntryUrlAdjuster.java
|
UTF-8
| 704
| 2.375
| 2
|
[] |
no_license
|
package cn.sexycode.util.core.file;
import java.net.URL;
/**
* Optional contract for ArchiveDescriptorFactory implementations to implement
* to be able to adjust {@code <jar-file/>} URL's defined in {@code persistence.xml}
* files. The intent is to account for relative URLs in a protocol specific way
* according to the protocol(s) handled by the ArchiveDescriptorFactory.
*
* @author Steve Ebersole
*/
public interface JarFileEntryUrlAdjuster {
/**
* Adjust the given URL, if needed.
*
* @param url The url to adjust
* @param rootUrl The root URL, for resolving relative URLs
* @return The adjusted url.
*/
URL adjustJarFileEntryUrl(URL url, URL rootUrl);
}
| true
|
7495f97ee8d58d5fb5d3ee35ac6f7238bbf64afd
|
Java
|
cckmit/Product4DM
|
/srm-purchasing/src/main/java/com/huiju/srm/purchasing/entity/StdSendScheduleDetailVo.java
|
UTF-8
| 6,549
| 1.820313
| 2
|
[] |
no_license
|
package com.huiju.srm.purchasing.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Calendar;
/**
* 同步sapvo
*
* @author CWQ
*/
public class StdSendScheduleDetailVo implements Serializable {
private static final long serialVersionUID = 3930916482773908553L;
/** 采购组织编码 */
protected String purchasingOrgCode;
/** 采购组织名称 */
protected String purchasingOrgName;
/** 来自主单排程单号编码 */
protected String sendScheduleNo;
/** 来自主单采购订单号编码 */
protected String purchaseOrderNo;
/** sap采购订单号 */
protected String erpPurchaseOrderNo;
/** 行号 */
protected Long rowNo;
/** 订单明细行号 */
protected Integer rowIds;
/** 供应商编码 */
protected String vendorCode;
/** 供应商名称 */
protected String vendorName;
/** 送货标识 */
protected Integer sendFlag;
/** 物料ID */
protected Long materialId;
/** 物料编码 */
protected String materialCode;
/** 物料名称 */
protected String materialName;
/** 单位编码 */
protected String unitCode;
/** 单位名称 */
protected String unitName;
/** 需求时间 */
protected Calendar scheduleTime;
/** 需求数量 */
protected BigDecimal scheduleQty;
/** 订单数量 */
protected BigDecimal sendQty;
/** 送货量 */
protected BigDecimal deliveryQty;
/** 在途量 */
protected BigDecimal onWayQty;
/** 收货量 */
protected BigDecimal receiptQty;
/** 退货量 */
protected BigDecimal returnGoodsQty;
/** 可送货量 */
protected BigDecimal canSendQty;
/** 工厂编码 */
protected String plantCode;
/** 工厂名称 */
protected String factoryName;
/** 库存地点 */
protected String stockLocal;
/** 行项目类别 */
protected String lineItemTypeCode;
/** 未税价 */
protected BigDecimal taxPrice;
/** 旧的需求时间 */
protected Calendar oldScheduleTime;
/** 旧的需求数量 */
protected BigDecimal oldScheduleQty;
public String getPurchasingOrgCode() {
return purchasingOrgCode;
}
public void setPurchasingOrgCode(String purchasingOrgCode) {
this.purchasingOrgCode = purchasingOrgCode;
}
public String getPurchasingOrgName() {
return purchasingOrgName;
}
public void setPurchasingOrgName(String purchasingOrgName) {
this.purchasingOrgName = purchasingOrgName;
}
public String getSendScheduleNo() {
return sendScheduleNo;
}
public void setSendScheduleNo(String sendScheduleNo) {
this.sendScheduleNo = sendScheduleNo;
}
public String getPurchaseOrderNo() {
return purchaseOrderNo;
}
public void setPurchaseOrderNo(String purchaseOrderNo) {
this.purchaseOrderNo = purchaseOrderNo;
}
public String getErpPurchaseOrderNo() {
return erpPurchaseOrderNo;
}
public void setErpPurchaseOrderNo(String erpPurchaseOrderNo) {
this.erpPurchaseOrderNo = erpPurchaseOrderNo;
}
public Long getRowNo() {
return rowNo;
}
public void setRowNo(Long rowNo) {
this.rowNo = rowNo;
}
public Integer getRowIds() {
return rowIds;
}
public void setRowIds(Integer rowIds) {
this.rowIds = rowIds;
}
public String getVendorCode() {
return vendorCode;
}
public void setVendorCode(String vendorCode) {
this.vendorCode = vendorCode;
}
public String getVendorName() {
return vendorName;
}
public void setVendorName(String vendorName) {
this.vendorName = vendorName;
}
public Integer getSendFlag() {
return sendFlag;
}
public void setSendFlag(Integer sendFlag) {
this.sendFlag = sendFlag;
}
public Long getMaterialId() {
return materialId;
}
public void setMaterialId(Long materialId) {
this.materialId = materialId;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public Calendar getScheduleTime() {
return scheduleTime;
}
public void setScheduleTime(Calendar scheduleTime) {
this.scheduleTime = scheduleTime;
}
public BigDecimal getScheduleQty() {
return scheduleQty;
}
public void setScheduleQty(BigDecimal scheduleQty) {
this.scheduleQty = scheduleQty;
}
public BigDecimal getSendQty() {
return sendQty;
}
public void setSendQty(BigDecimal sendQty) {
this.sendQty = sendQty;
}
public BigDecimal getDeliveryQty() {
return deliveryQty;
}
public void setDeliveryQty(BigDecimal deliveryQty) {
this.deliveryQty = deliveryQty;
}
public BigDecimal getOnWayQty() {
return onWayQty;
}
public void setOnWayQty(BigDecimal onWayQty) {
this.onWayQty = onWayQty;
}
public BigDecimal getReceiptQty() {
return receiptQty;
}
public void setReceiptQty(BigDecimal receiptQty) {
this.receiptQty = receiptQty;
}
public BigDecimal getReturnGoodsQty() {
return returnGoodsQty;
}
public void setReturnGoodsQty(BigDecimal returnGoodsQty) {
this.returnGoodsQty = returnGoodsQty;
}
public BigDecimal getCanSendQty() {
return canSendQty;
}
public void setCanSendQty(BigDecimal canSendQty) {
this.canSendQty = canSendQty;
}
public String getPlantCode() {
return plantCode;
}
public void setPlantCode(String plantCode) {
this.plantCode = plantCode;
}
public String getFactoryName() {
return factoryName;
}
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
public String getStockLocal() {
return stockLocal;
}
public void setStockLocal(String stockLocal) {
this.stockLocal = stockLocal;
}
public String getLineItemTypeCode() {
return lineItemTypeCode;
}
public void setLineItemTypeCode(String lineItemTypeCode) {
this.lineItemTypeCode = lineItemTypeCode;
}
public BigDecimal getTaxPrice() {
return taxPrice;
}
public void setTaxPrice(BigDecimal taxPrice) {
this.taxPrice = taxPrice;
}
public Calendar getOldScheduleTime() {
return oldScheduleTime;
}
public void setOldScheduleTime(Calendar oldScheduleTime) {
this.oldScheduleTime = oldScheduleTime;
}
public BigDecimal getOldScheduleQty() {
return oldScheduleQty;
}
public void setOldScheduleQty(BigDecimal oldScheduleQty) {
this.oldScheduleQty = oldScheduleQty;
}
}
| true
|
dd24ad6ee39d53b0574f54dedfadfe49024ffbcf
|
Java
|
yknext/CentosLoginLog
|
/src/main/java/microserver/model/IPInfo.java
|
UTF-8
| 825
| 2.046875
| 2
|
[] |
no_license
|
package microserver.model;
import java.io.Serializable;
public class IPInfo implements Serializable{
// {
// "code" : 0,
// "data" : {
// "country" : "中国",
// "country_id" : "CN",
// "area" : "西南",
// "area_id" : "500000",
// "region" : "四川省",
// "region_id" : "510000",
// "city" : "成都市",
// "city_id" : "510100",
// "county" : "",
// "county_id" : "-1",
// "isp" : "电信",
// "isp_id" : "100017",
// "ip" : "182.139.168.246"
// }
// }
/**
*
*/
private static final long serialVersionUID = 1L;
int code;
Data data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
}
| true
|
765a12c7cd65d9c1085f1492902b62346e824e8b
|
Java
|
DEVTIRIA/proyectoFinal
|
/src/main/java/com/proyectosena/controller/tienda/CTienda.java
|
UTF-8
| 2,519
| 1.859375
| 2
|
[] |
no_license
|
package com.proyectosena.controller.tienda;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import com.proyectosena.service.tienda.TiendaService;
import com.proyectosena.repository.tienda.Tienda;
@Controller
@RequestMapping("/Tienda")
public class CTienda {
@Autowired
private TiendaService tiendaService;
public CTienda() {
super();
}
@RequestMapping("/")
public String index() {
return "proyectosena/tienda/Tienda";
}
@RequestMapping(value = "/{tienda_tienda}.json", method = RequestMethod.GET, produces={"application/json"})
@ResponseBody
public String list(@PathVariable("tienda_tienda") Long tienda_tienda){
return this.tiendaService.list(tienda_tienda);
}
@RequestMapping(value = "/listAll.json", params = {"page","pageSize"}, method = RequestMethod.GET, produces={"application/json"})
@ResponseBody
public String listAll(@RequestParam("pageSize") int pageSize, @RequestParam("page") int page){
return this.tiendaService.listAll(pageSize, page);
}
@RequestMapping(value = "/update", method = RequestMethod.POST, produces={"application/json"})
@ResponseStatus( HttpStatus.OK )
@ResponseBody
public String update(@RequestBody Tienda tienda, HttpServletRequest request){
return this.tiendaService.update(tienda);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces={"application/json"})
@ResponseStatus( HttpStatus.OK )
@ResponseBody
public String delete(@RequestBody Tienda tienda, HttpServletRequest request){
//tienda.setesta("B");
return this.tiendaService.update(tienda);
}
@RequestMapping(value = "/insert", method = RequestMethod.POST, produces={"application/json"})
@ResponseStatus( HttpStatus.CREATED )
@ResponseBody
public String insert(@RequestBody Tienda tienda, HttpServletRequest request){
return this.tiendaService.insert(tienda);
}
}
| true
|
8f70e43adaaedf0e450e5ec5eec1c4239bfdecc5
|
Java
|
dmilotz/MachineLearning
|
/MachineLearning/MachineLearningPractice/src/Input.java
|
UTF-8
| 2,495
| 3.859375
| 4
|
[] |
no_license
|
import java.util.Scanner;
public class Input
{
public Input()
{
}
/**
* This method prompts the user to state how many rounds they would
* like to distinguish each match to be. It then returns that information
* to the class that uses it.
*
* @return numThrows; which is the number of throws to constitute a match.
*/
public int getNumThrows()
{
Scanner in = new Scanner(System.in);
int numThrows = 0;
int temporary = 0;
if(in.hasNextInt()){
temporary = in.nextInt();
if(temporary >= 0 && temporary <= 100){
numThrows = temporary;
}
else{
getNumThrows();
}
}
else{
getNumThrows();
}
return numThrows;
}
/**
* This method prompts the user to enter a throw, or to request for help
* regarding the rules of the game, or how to play the game.
*
* @return char: 'r', char: 'p', or char: 's'.
* r for rock, p for paper, and s for scissors.
*/
public char getThrow()
{
//if(in.hasNext("r") || in.hasNext("p") || in.hasNext("s")
//|| in.hasNext("rules") || in.hasNext("help"))
Display display = new MainMenu();
Scanner in = new Scanner(System.in);
String stringThrow = "h";
char charThrow = 'n';
if (in.hasNext())
{
stringThrow = in.next().toLowerCase();
if(stringThrow.equals("r")){
charThrow = 'r';
}
else if(stringThrow.equals("p")){
charThrow = 'p';
}
else if(stringThrow.equals("s")){
charThrow = 's';
}
else if(stringThrow.equals("rules")){
display.displayRules();
charThrow = getThrow();
}
else if(stringThrow.equals("help")){
display.displayHelp();
charThrow = getThrow();
}
else {
display.invalidSelection();
display.displayHelp();
charThrow = getThrow();
}
}
else{
charThrow = getThrow();
}
return charThrow;
}
}
| true
|
c1e66d1b1fb5fc2ec5bea5728212bea85458bccf
|
Java
|
googalAmbition/designer
|
/src/com/ambition/behavioral/mediator/ChartGroup.java
|
UTF-8
| 838
| 3.15625
| 3
|
[] |
no_license
|
package com.ambition.behavioral.mediator;
import java.util.Hashtable;
public class ChartGroup extends AbstractChartroom{
private Hashtable<String, Member> members = new Hashtable<String, Member>();
@Override
public void register(Member member) {
if (!members.contains(member)) {
members.put(member.getName(),member);
member.setChartroom(this);
}
}
@Override
public void sendText(String from, String to, String message) {
Member member = members.get(to);
String newMesaage = message;
newMesaage = message.replaceAll("sex", "***");
member.receiveText(from, newMesaage);
}
@Override
public void sendImage(String from, String to, String image) {
Member member = members.get(to);
if (image.length()>5) {
System.out.println("image is too big!");
}else {
member.receiveImage(from, image);
}
}
}
| true
|
391de4e406afbf73620b05d2b5dcd3518096bbb9
|
Java
|
mikecodingmike/Personalbuero_GUI_Datenbank
|
/src/model/PersonalException.java
|
UTF-8
| 163
| 2.109375
| 2
|
[] |
no_license
|
package model;
@SuppressWarnings("serial")
public class PersonalException extends Exception
{
public PersonalException(String message)
{
super(message);
}
}
| true
|
063e0e462d75cf1af387746817e5b2086f699e83
|
Java
|
zhang1990zxc/deep-in-java
|
/stage-1/stage-1-lesson-4/src/main/java/com/zhang/deep/in/java/fucntional/FunctionDesignDemo.java
|
UTF-8
| 500
| 3.453125
| 3
|
[] |
no_license
|
package com.zhang.deep.in.java.fucntional;
import java.util.function.Function;
/**
* @ClassName FunctionDesignDemo
* @Description 整条街最靓的仔,写点注释吧
* @Author 天涯
* @Date 2020/4/8 0:40
* @Version 1.0
**/
public class FunctionDesignDemo {
public static void main(String[] args) {
Function function = a -> a;
//Function可以用同类型转换
Function<Integer, Integer> div = a -> a/2;
System.out.println(div.apply(2));
}
}
| true
|
67e6852e5b3d4b3c4dbc8f6616dbc4c970e6b69c
|
Java
|
javier3448/-IPC1-Proyecto2-Semestre12017
|
/Proyecto2/src/calculoDeCeldas/LectorDeCeldas.java
|
UTF-8
| 18,901
| 3.046875
| 3
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calculoDeCeldas;
import Calculadora.Calculadora;
import Enums.FORMATO;
import Enums.FORMULAS;
import Listas.ListaDoble;
import Ventanas.Celda;
import Ventanas.ventanaPrincipal;
import java.awt.Dimension;
import java.text.DecimalFormat;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
/**
*
* @author Alvarez
*/
public class LectorDeCeldas {
private ListaDoble celdasConError =new ListaDoble();
private Celda[][] celdas;
private Calculadora calc=new Calculadora();
public LectorDeCeldas(Celda[][] celdas){
this.celdas = celdas;
}
/**
* Se utiliza este constructo si no se deseen utilizar los metodos realacionados con la matriz de celdas
*/
public LectorDeCeldas(){
this.celdas=ventanaPrincipal.celdas;
}
/**
* Revisa si todos los valores dados en el rango de celdas son numeros
* @param celdaInicial
* @param celdaFinal
* @return
*/
public boolean isNumero(Celda celdaInicial, Celda celdaFinal) {
boolean temp=true;
System.out.println("Celdas con problema:");
for(int i=celdaInicial.getPosicionY(); i<celdaFinal.getPosicionY()+1; i++){
for(int e=celdaInicial.getPosicionX()+1; e<celdaFinal.getPosicionX()+1;e++){
if(!celdas[i][e].isNumber()){
celdasConError.addFin("Columna: "+i+1+", Fila: "+e+1);
temp=false;
}
}
}
celdasConError.mostrarInicioAfin();
return temp;
}
/**
* Revisa si todos los valores en el rango son numero, si es asi. Los mete en una lista de valores
* @param y
* @param x
* @param yFinal
* @param xFinal
* @return
*/
public ListaDoble valores (Celda celdaInicial, Celda celdaFinal){
ListaDoble valores=new ListaDoble();
if(isNumero(celdaInicial, celdaFinal)){
for(int i=celdaInicial.getPosicionY(); i<celdaFinal.getPosicionY()+1; i++){
for(int e=celdaInicial.getPosicionX(); e<celdaFinal.getPosicionX()+1;e++){
if(!celdas[i][e].isNumber()){
valores.addFin(Double.valueOf(celdas[i][e].getResultado()));
}
}
}
}
return valores;
}
public boolean isNumero(int y, int x, int yFinal, int xFinal) {
boolean temp=true;
System.out.println("Celdas con problema:");
for(int i=y; i<yFinal+1; i++){
for(int e=x; e<xFinal+1;e++){
if(!celdas[i][e].isNumber()){
celdasConError.addFin("Columna: "+String.valueOf(i+1)+", Fila: "+String.valueOf(e+1));
temp=false;
}
}
}
celdasConError.mostrarInicioAfin();
return temp;
}
/**
* Revisa si todos los valores en el rango son numero, si es asi. Los mete en una lista de valores
* @param y
* @param x
* @param yFinal
* @param xFinal
* @return
*/
public ListaDoble valores (int y, int x, int yFinal, int xFinal){
ListaDoble valores=new ListaDoble();
if(isNumero(y,x,yFinal,xFinal)){
for(int i=y; i<yFinal+1; i++){
for(int e=x; e<xFinal+1;e++){
valores.addFin(Double.valueOf(celdas[i][e].getResultado()));
}
}
}
return valores;
}
public double suma(ListaDoble valores){
double resultado=0;
for(int i=0; i<valores.getSize();i++){
resultado=resultado+(double)valores.get(i);
}
return resultado;
}
public double suma(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
return suma(valores);
}
public double resta(ListaDoble valores){
double resultado=0;
for(int i=0; i<valores.getSize();i++){
resultado=resultado-(double)valores.get(i);
}
return resultado;
}
public double resta(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
return resta(valores);
}
public double promedio(ListaDoble valores){
double resultado=0;
for(int i=0; i<valores.getSize();i++){
resultado=resultado+(double)valores.get(i);
}
resultado=resultado/valores.getSize();
return resultado;
}
public double promedio(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
return promedio(valores);
}
public double min(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
double min=(double)valores.get(0);
for(int i=0; i<valores.getSize();i++){
if((double)valores.get(i)<min){
min=(double)valores.get(i);
}
}
return min;
}
public double max(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
double max=(double)valores.get(0);
for(int i=0; i<valores.getSize();i++){
if((double)valores.get(i)>max){
max=(double)valores.get(i);
}
}
return max;
}
public double multiplicacion(ListaDoble valores){
double resultado=0;
for(int i=0; i<valores.getSize();i++){
resultado=resultado*(double)valores.get(i);
}
return resultado;
}
public double multiplicacion(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
return suma(valores);
}
public double division(ListaDoble valores){
double resultado=0;
for(int i=0; i<valores.getSize();i++){
resultado=resultado/(double)valores.get(i);
}
return resultado;
}
public double division(int y, int x, int yFinal, int xFinal){
ListaDoble valores=valores(y,x,yFinal,xFinal);
return suma(valores);
}
DecimalFormat df = new DecimalFormat("#.##");
/**
*
* @return
*/
public String operarCelda(Celda celda){
String temp = celda.getValor();
if(temp.length()==0){}
else if(String.valueOf(temp.charAt(0)).equals("=")){
temp=temp.substring(1);
if(temp==""){
temp="0";
}
else if(isFormula(temp)==FORMULAS.No){
temp=convertirRefs(temp);
temp=calc.resolver(temp);
}
else if(isFormula(temp).equals(FORMULAS.Suma)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return String.valueOf(suma(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Resta)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return String.valueOf(resta(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Promedio)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return df.format(promedio(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Multiplicacion)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return df.format(multiplicacion(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Division)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return df.format(division(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Min)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return String.valueOf(min(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
else if(isFormula(temp).equals(FORMULAS.Max)){
ListaDoble posiciones = getPosiciones(temp, ":");
String sTemp=temp;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] coordenadas1;
coordenadas1=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int [] coordenadas2;
coordenadas2=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(2)))+1, Integer.valueOf(String.valueOf(posiciones.get(3)))));
return String.valueOf(max(coordenadas1[0],coordenadas1[1],coordenadas2[0],coordenadas2[1]));
}
}
}
return temp;
}
/**
* Revisa si un String empieza con SUMA RESTA MULTIPLICACION DIVISION MAX MIN o ninguno
* @return el valor formula correspondiente
*/
public FORMULAS isFormula(String string){
String temp=string.toUpperCase();
try {
temp = temp.substring(0, 3);
} catch (Exception e) {
return FORMULAS.No;
}
System.out.println(temp);
if (null == temp) {
return FORMULAS.No;
} else switch (temp) {
case "SUM":
return FORMULAS.Suma;
case "RES":
return FORMULAS.Resta;
case "PRO":
return FORMULAS.Promedio;
case "MUL":
return FORMULAS.Multiplicacion;
case "DIV":
return FORMULAS.Division;
case "MAX":
return FORMULAS.Max;
case "MIN":
return FORMULAS.Min;
default:
return FORMULAS.No;
}
}
/**
* Convierte todas las referencias de celdas a sus resultados NO INCLUIR EL = EN EL PARAMETRO
* @param operacion
* @return
*/
public String convertirRefs(String operacion){
ListaDoble posiciones = getPosiciones(operacion, ":");
String sTemp=operacion;
if((posiciones.getSize()%2)!=0){
JOptionPane.showMessageDialog(null, "ERROR EN LA SINTAXIS");
celdas[ventanaPrincipal.posicionActualY][ventanaPrincipal.posicionActualX].requestFocus();
}
else{
int [] temp;
posiciones.mostrarInicioAfin();
while(posiciones.getSize()>=2){
temp=stringACoordenada(sTemp.substring(Integer.valueOf(String.valueOf(posiciones.get(0)))+1, Integer.valueOf(String.valueOf(posiciones.get(1)))));
int a=Integer.valueOf(String.valueOf(posiciones.get(0)));
int b=Integer.valueOf(String.valueOf(posiciones.get(1)));
String c=celdas[temp[0]][temp[1]].getResultado();
sTemp=insertarString(a,b,c,sTemp);
posiciones=getPosiciones(sTemp, ":");
int i=1;
System.out.println("ciclo numero: "+i);
}
}
return sTemp;
}
/**
* Consigue las posiciones de todos los : del estring dado
* @param string solo puede ser de un caracter
* @return
*/
public ListaDoble getPosiciones(String string, String separador){
ListaDoble posiciones = new ListaDoble();
for(int i=0; i<string.length();i++){
if(String.valueOf(string.charAt(i)).equals(separador)){
posiciones.addFin(i);
}
}
return posiciones;
}
/**
* Recive un string que tiene dos enteros separados por una coma. Devuelve el valor de cada uno de los enteros -1
* @param string
* @return
*/
public int[] stringACoordenada(String string){
int[] temp=new int[2];
StringTokenizer token=new StringTokenizer(string,",");
int e=0;
while(token.hasMoreElements()){
temp[e]=Integer.valueOf(token.nextToken())-1;
e++;
}
return temp;
}
/**
* Inserta un string en otro, todo lo que este entre inicio y fin (inclusivo)sera reemplazado por aInsertar
* @param inicio
* @param fin
* @param aInsertar
* @param string
* @return
*/
public String insertarString(int inicio, int fin, String aInsertar, String string){
String temp = "";
for(int i=0; i<inicio;i++){
temp=temp+String.valueOf(string.charAt(i));
}
for(int i=0;i<aInsertar.length();i++){
temp=temp+String.valueOf(aInsertar.charAt(i));
}
for(int i=fin+1;i<string.length();i++){
temp=temp+String.valueOf(string.charAt(i));
}
return temp;
}
public static void main(String args[]){
LectorDeCeldas l = new LectorDeCeldas();
System.out.println(l.isFormula("SUMA565656565656"));
}
}
| true
|
d023be67b459ba8c7e5fc7b143189d2e5f9457bf
|
Java
|
zhoudy-github/e3mall
|
/taotao-item/taotao-item-interface/src/main/java/com/taotao/itemservice/service/ItemCategoryService.java
|
UTF-8
| 560
| 1.835938
| 2
|
[] |
no_license
|
package com.taotao.itemservice.service;
import java.util.List;
import com.taotao.itemservice.model.ItemCategory;
public interface ItemCategoryService {
public void addItemCategory(ItemCategory itemCategory ,String queueType);
public void deleteItemCategory(long id ,String queueType);
public void updateItemCategory(ItemCategory itemCategory ,String queueType);
public ItemCategory findItemCategoryById(long id);
public List<ItemCategory> findItemCategoryByParentId(long parentId);
public List<ItemCategory> findItemCategorys(String ids);
}
| true
|
3393be60dedac92a2691489d608e0a8f166d83b9
|
Java
|
Eric1235/Thinking-In-Java
|
/src/collection/SimpleHashMap.java
|
UTF-8
| 2,074
| 3.4375
| 3
|
[] |
no_license
|
package collection;
import java.util.*;
/**
* Created by EricLi on 2016/12/18.
* Email me : EricLi1235@gmail.com.
*/
public class SimpleHashMap<K, V> extends AbstractMap<K, V> {
static final int SIZE = 997;
//桶位
@SuppressWarnings("unchecked")
LinkedList<MapEntry<K, V>>[] buckets = new LinkedList[SIZE];
@Override
public V put(K key, V value) {
V oldValue = null;
int index = Math.abs(key.hashCode()) % SIZE;//计算散列码
if(buckets[index] == null){
buckets[index] = new LinkedList<>();
}
LinkedList<MapEntry<K, V>> bucket = buckets[index];
MapEntry<K, V> pair = new MapEntry<K, V>(key,value);
boolean found = false;
ListIterator<MapEntry<K, V>> it = bucket.listIterator();
while (it.hasNext()){
MapEntry<K, V> iPair = it.next();
if(iPair.getKey().equals(key)){
oldValue = iPair.getValue();
it.set(pair);
found = true;
break;
}
}
if(!(found)){
buckets[index].add(pair);
}
return oldValue;
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = new HashSet<>();
for(LinkedList<MapEntry<K ,V>> bucket: buckets){
if(bucket == null){
continue;
}
for(MapEntry<K, V> mpair : bucket){
set.add(mpair);
}
}
return set;
}
public static void main(String[] args){
SimpleHashMap<String,String> map = new SimpleHashMap<>();
map.put("Eric", "Good");
System.out.println(map);
System.out.println(map.get("Eric"));
System.out.println(map.entrySet());
System.out.println(map.get("A"));
//对于String而言,生成的散列码是和内容有关的
String s = "Hello World";
String[] hello = s.split(" ");
System.out.println(hello[0].hashCode());
System.out.println(hello[1].hashCode());
}
}
| true
|
bc21df97a68270de12b8256f2864f55c7c39281e
|
Java
|
IneegoMontoya/FantasySports-StatKeeper
|
/StatTracker/src/bjha43nflstattracker/MainPageController.java
|
UTF-8
| 11,170
| 2.15625
| 2
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bjha43nflstattracker;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.ResourceBundle;
import static javafx.application.Platform.exit;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.Region;
/**
*
* @author Byron Hammann - bjha43
*/
public class MainPageController extends Switchable implements Initializable {
@FXML
private TableView<QbStats> table;
@FXML
private Label errorLabel;
@FXML
private TextField statText;
@FXML
private ChoiceBox<String> positionOption = new ChoiceBox<>();
@FXML
private ChoiceBox<String> yearOption = new ChoiceBox<>();
@FXML
private ChoiceBox<String> playerName = new ChoiceBox<>();
@FXML
private ChoiceBox<Integer> yearChoice = new ChoiceBox<>();
@FXML
private ChoiceBox<String> statChoice = new ChoiceBox<>();
@FXML
private TableColumn<QbStats, String> col_fname;
@FXML
private TableColumn<QbStats, String> col_lname;
@FXML
private TableColumn<QbStats, Integer> col_3;
@FXML
private TableColumn<QbStats, Integer> col_4;
@FXML
private TableColumn<QbStats, Integer> col_5;
@FXML
private TableColumn<QbStats, Integer> col_6;
private ObservableList<QbStats> qbStatList = FXCollections.observableArrayList();
private ArrayList<String> players = new ArrayList<>();
private ArrayList<Player> player = new ArrayList<>();
private Player plays;
private Integer DBStat;
private Integer userInput;
private String startingValue = "";
@FXML
private Button updateButton;
@FXML
private Button filterButton;
@FXML
private void filterAction(ActionEvent event){
table.getItems().clear();
qbStatList.clear();
if(positionOption.getValue().equals("QB")){
col_4.textProperty().set("Passing TD");
col_3.textProperty().set("Passing Yards");
if(yearOption.getValue().equals("Career")){
try{
DBQBData qb = new DBQBData();
ResultSet set = qb.getResults();
while(set.next()) {
qbStatList.add(new QbStats(set.getString("p.fname"),
set.getString("p.lname"),
set.getInt("Passing_TD"),
set.getInt("Rushing_TD"),
set.getInt("Passing_Yards"),
set.getInt("Rushing_yards")));
}
set.close();
qb.closer();
}catch(Exception ex){
System.out.println("Error");
}
}else{
try{
DBQBYearStats qb = new DBQBYearStats(yearOption.getValue().toString());
ResultSet set = qb.getResults();
while(set.next()) {
qbStatList.add(new QbStats(set.getString("p.fname"),
set.getString("p.lname"),
set.getInt("Passing_TD"),
set.getInt("Rushing_TD"),
set.getInt("Passing_Yards"),
set.getInt("Rushing_yards")));
}
set.close();
qb.closer();
}catch(Exception ex){
System.out.println("Error");
}}}
if(positionOption.getValue().equals("Skill")){
col_4.textProperty().set("Receiving TD");
col_3.textProperty().set("Receiving Yards");
if(yearOption.getValue().equals("Career")){
try{
DBSkillData qb = new DBSkillData();
ResultSet set = qb.getResults();
while(set.next()) {
qbStatList.add(new QbStats(set.getString("p.fname"),
set.getString("p.lname"),
set.getInt("Passing_TD"),
set.getInt("Rushing_TD"),
set.getInt("Passing_Yards"),
set.getInt("Rushing_yards")));
}
set.close();
qb.closer();
}catch(Exception ex){
System.out.println("Error");
}
}else{
try{
DBSkillYearStats qb = new DBSkillYearStats(yearOption.getValue().toString());
ResultSet set = qb.getResults();
while(set.next()) {
qbStatList.add(new QbStats(set.getString("p.fname"),
set.getString("p.lname"),
set.getInt("Passing_TD"),
set.getInt("Rushing_TD"),
set.getInt("Passing_Yards"),
set.getInt("Rushing_yards")));
}
set.close();
qb.closer();
}catch(Exception ex){
System.out.println("Error");
}}}
}
@FXML
private void updateAction(ActionEvent event){
errorLabel.setText(startingValue);
int x;
int playerID;
x = players.indexOf(playerName.getValue().toString());
players.get(x);
playerID = player.get(x).getPlayerID();
try{
StatValue getStat = new StatValue(statChoice.getValue().toString(),playerID,yearChoice.getValue());
ResultSet statResult = getStat.getResults();
if(statResult.next()==false){
DBStat = 0;
}
else {
do{
DBStat = statResult.getInt("stat_value");
}while(statResult.next());
}
}catch(SQLException ex){
errorLabel.setText("Error! Please make valid selections before updating stats.");
}
try{
userInput = Integer.parseInt(statText.getText());
statText.setText("0");
}catch(Exception ex){
errorLabel.setText("Non-Numeric input is not allowed");
statText.setText("0");
}
userInput += DBStat;
if(DBStat.equals(0)){
DBCreateStat createStat = new DBCreateStat(statChoice.getValue(), userInput, yearChoice.getValue(), playerID);
}else{
DBUpdateStat updateStat = new DBUpdateStat(statChoice.getValue(), userInput, yearChoice.getValue(), playerID);
}
statText.setText("0");
}
@FXML
private void exitAction(ActionEvent event){
exit();
}
@FXML
private void logoutAction(ActionEvent event){
Switchable.switchTo("LoginScene");
}
@FXML
private void aboutAction(ActionEvent event){
Alert alert = new Alert(Alert.AlertType.INFORMATION,
"This application was developed and written by Byron Hammann as a means of tracking sports statistics \n "
+ "The idea is to be able to add this application into a fantasy sports application in the future.",
ButtonType.OK);
alert.setTitle("About");
alert.setHeaderText("NFL Stat Tracker");
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.show();
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
yearOption.getItems().addAll("Career", "2018", "2017", "2016", "2015" );
positionOption.getItems().addAll("QB", "Skill");
yearOption.setValue("2018");
positionOption.setValue("QB");
DBQBYearStats qb = new DBQBYearStats(yearOption.getValue().toString());
PlayerNames play = new PlayerNames();
try{
ResultSet set = qb.getResults();
while(set.next()) {
qbStatList.add(new QbStats(set.getString("p.fname"),
set.getString("p.lname"),
set.getInt("Passing_TD"),
set.getInt("Rushing_TD"),
set.getInt("Passing_Yards"),
set.getInt("Rushing_yards")));
}
set.close();
qb.closer();
}catch(Exception ex){
System.out.println("Error");
}
try{
ResultSet rs = play.getResults();
while(rs.next()){
plays = new Player(rs.getInt("playerid"), rs.getString("fname"), rs.getString("lname"));
player.add(plays);
players.add(plays.getName());
}
rs.close();
play.closer();
}catch(Exception ex){
System.out.println("Error loading Names");
}
playerName.getItems().addAll(players);
yearChoice.getItems().addAll(2015,2016,2017,2018);
statChoice.getItems().addAll("Passing_Yards", "Passing_TD", "Rushing_Yards", "Rushing_TD", "Receiving_Yards", "Receiving_TD");
col_fname.setCellValueFactory(new PropertyValueFactory<>("firstName"));
col_lname.setCellValueFactory(new PropertyValueFactory<>("lastName"));
col_3.setCellValueFactory(new PropertyValueFactory<>("passingYards"));
col_4.setCellValueFactory(new PropertyValueFactory<>("passingTD"));
col_5.setCellValueFactory(new PropertyValueFactory<>("rushingYards"));
col_6.setCellValueFactory(new PropertyValueFactory<>("rushingTD"));
table.setItems(qbStatList);
}
}
| true
|
e2fa4351d4f247588622a7111d9e7ea98b02265b
|
Java
|
kashifrizwan5/canteenmgmtsystem
|
/src/main/java/com/canteenmanagement/dao/CanteenDao.java
|
UTF-8
| 223
| 1.976563
| 2
|
[
"MIT"
] |
permissive
|
package com.canteenmanagement.dao;
import java.util.List;
public interface CanteenDao<T> {
void add(T t);
void update(T t);
void delete(T t);
void delete(Integer id);
List<T> get();
T get(Integer id);
}
| true
|
ac5537440cbb31042e95079440e20a5c24c1e041
|
Java
|
mkaouer/Code-Smells-Detection-in-JavaScript
|
/JS-CS-Detection-byExample/Dataset (ALERT 5 GB)/356782/jPOS-1_5_0/jpos/src/test/space/TestJDBM.java
|
UTF-8
| 4,046
| 2.28125
| 2
|
[
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-2-Clause"
] |
permissive
|
package space;
import junit.framework.*;
import java.io.*;
import java.util.*;
import org.jpos.space.*;
import org.jpos.util.*;
public class TestJDBM extends TestCase {
public static final int COUNT = 1000;
JDBMSpace sp;
public TestJDBM (String name) {
super (name);
sp = JDBMSpace.getSpace ("space-test");
}
public void testSimpleOut() throws Exception {
Object o = new Boolean (true);
sp.out ("Key1", o);
Object o1 = sp.in ("Key1");
assertTrue (o.equals (o1));
}
public void testOutRdpInpRdp() throws Exception {
Object o = new Boolean (true);
String k = "key";
sp.out (k, o);
assertTrue (o.equals (sp.rdp (k)));
assertTrue (o.equals (sp.rd (k)));
assertTrue (o.equals (sp.rd (k, 1000)));
assertTrue (o.equals (sp.inp (k)));
assertTrue (sp.rdp (k) == null);
assertTrue (sp.rd (k, 100) == null);
}
public void testMultiKeyLoad() throws Exception {
String s = "The quick brown fox jumped over the lazy dog";
Profiler prof = new Profiler ();
for (int i=0; i<COUNT; i++) {
sp.out ("Key" + Integer.toString (i), s);
if (i % 100 == 0)
prof.checkPoint ("out " + i);
}
prof.dump (System.out, "MultiKeyLoad out >");
prof = new Profiler ();
for (int i=0; i<COUNT; i++) {
assertTrue (s.equals (sp.in ("Key" + Integer.toString (i))));
if (i % 100 == 0)
prof.checkPoint ("in " + i);
}
prof.dump (System.out, "MultiKeyLoad in >");
}
public void testNoAutoCommit () throws Exception {
String s = "The quick brown fox jumped over the lazy dog";
Profiler prof = new Profiler ();
synchronized (sp) {
sp.setAutoCommit (false);
for (int i=0; i<COUNT; i++) {
sp.out ("Key" + Integer.toString (i), s);
if (i % 100 == 0)
prof.checkPoint ("out " + i);
}
prof.checkPoint ("pre-commit");
sp.commit();
sp.setAutoCommit (true);
prof.checkPoint ("commit");
}
prof.dump (System.out, "NoAutoCommit out >");
prof = new Profiler ();
synchronized (sp) {
sp.setAutoCommit (false);
for (int i=0; i<COUNT; i++) {
assertTrue (s.equals (sp.in ("Key" + Integer.toString (i))));
if (i % 100 == 0)
prof.checkPoint ("in " + i);
}
prof.checkPoint ("pre-commit");
sp.commit();
sp.setAutoCommit (true);
prof.checkPoint ("commit");
}
prof.dump (System.out, "NoAutoCommit in >");
}
public void testSingleKeyLoad() throws Exception {
String s = "The quick brown fox jumped over the lazy dog";
String k = "SingleKey";
Profiler prof = new Profiler ();
for (int i=0; i<COUNT; i++) {
sp.out (k, s);
if (i % 100 == 0)
prof.checkPoint ("out " + i);
}
prof.dump (System.out, "SingleKeyLoad out >");
prof = new Profiler ();
for (int i=0; i<COUNT; i++) {
assertTrue (s.equals (sp.in (k)));
if (i % 100 == 0)
prof.checkPoint ("in " + i);
}
prof.dump (System.out, "SingleKeyLoad in >");
assertTrue (sp.rdp (k) == null);
}
public void testTemplate () throws Exception {
String key = "TemplateTest";
sp.out (key, "Value 1");
sp.out (key, "Value 2");
sp.out (key, "Value 3");
String k2r = (String)sp.rdp (new MD5Template (key, "Value 2"));
assertEquals (k2r, "Value 2");
String k2i = (String)sp.inp (new MD5Template (key, "Value 2"));
assertEquals (k2i, "Value 2");
assertEquals ("Value 1", (String) sp.inp (key));
assertEquals ("Value 3", (String) sp.inp (key));
}
}
| true
|
0258050b9421da117895b379dea2fa3979d5cdb3
|
Java
|
rohusemer/Proyecto2_EstructuraDatos
|
/AnimalGuess/src/animalguess/AnimalGuess.java
|
UTF-8
| 3,449
| 2.859375
| 3
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package animalguess;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
*
* @author Luis A. Sarango-Parrales
*/
public class AnimalGuess extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("/Vista/inicio.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add("/Vista/css/style.css");
primaryStage.setTitle("Adivinador");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
/*
System.out.println("Avance 1");
System.out.println("Preguntas");
for (String pregunta : p.getPreguntas()) {
System.out.println(pregunta);
}
System.out.println();*/
/* List<BinaryTree<DecisionContent>> results = arbolDecision.getResults("Si");
System.out.println("Results of: Si");
for (BinaryTree<DecisionContent> node : results) {
System.out.println("animal: " + node);
}
System.out.println("Mapa de Animales-Respuestas");
for (String animal : p.getAnimalesRptas().keySet()) {
System.out.println("ANIMAL: " + animal + " RESPUESTAS: " + p.getAnimalesRptas().get(animal));
}
*/
/*
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
System.out.println("Piensa en un animal!!!");
System.out.println("");
int nroPreguntas = 0;
boolean condicion = true;
do {
System.out.println("Ingrese la cantidad de preguntas (1-3): ");
String input = sc.next();
if (Extra.isNumeric(input)) {
int n = Integer.parseInt(input);
if (n >= 1 && n <= 3) {
nroPreguntas = Integer.parseInt(input);
condicion = false;
}
}
} while (condicion);
System.out.println("");
boolean condicion2 = true;
Partida p = new Partida(nroPreguntas, "", "");
String[] preguntas = p.getPreguntas();
for (int i = 0; i < nroPreguntas; i++) {
condicion2 = true;
String rpta = "";
do {
System.out.println(preguntas[i] + " (Si/No)");
rpta = sc.next();
System.out.println("");
if (Extra.isBooleanAnswer(rpta)) {
condicion2 = false;
}
} while (condicion2);
sb.append(rpta + " ");
}
BinaryTree<DecisionContent> arbolDecision = p.getArbolDecision();
List<String> results = arbolDecision.getResults(sb.toString().trim());
System.out.println("Resultados:");
System.out.println("");
for (String animal : results) {
System.out.println("animal: " + animal);
}
if (results.isEmpty()) {
System.out.println("Sin resultados");
}
*/
}
}
| true
|
b4a824c9261f4a4498199506e8602c44dc8af272
|
Java
|
iDubbbzTV3/GameNews
|
/app/src/main/java/gamenews/fragment/ContrasenaFrag.java
|
UTF-8
| 4,137
| 2.140625
| 2
|
[] |
no_license
|
package gamenews.fragment;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import gamenews.R;
import gamenews.viewmodel.GamesNewsViewModel;
public class ContrasenaFrag extends Fragment {
EditText old_password, new_password, confirm_password;
Button save;
private GamesNewsViewModel gamesNewsViewModel;
private SharedPreferences sp;
public ContrasenaFrag() {
}
public static ContrasenaFrag newInstance() {
ContrasenaFrag fragment = new ContrasenaFrag();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_new_password, container, false);
old_password = v.findViewById(R.id.old_password_txt);
new_password = v.findViewById(R.id.new_password_txt);
confirm_password = v.findViewById(R.id.confirm_password_txt);
save = v.findViewById(R.id.save_buttton);
gamesNewsViewModel = ViewModelProviders.of(this).get(GamesNewsViewModel.class);
sp = getActivity().getSharedPreferences(getActivity().getPackageName(), Context.MODE_PRIVATE);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String new_password_txt = new_password.getText().toString();
String confirm_password_txt = confirm_password.getText().toString();
if (TextUtils.isEmpty(new_password_txt)) {
new_password.setError(getString(R.string.empty_field));
}
if (TextUtils.isEmpty(confirm_password_txt)) {
confirm_password.setError(getString(R.string.empty_field));
}
if (!new_password_txt.equals(confirm_password_txt)) {
confirm_password.setError(getString(R.string.not_match));
}
if (!TextUtils.isEmpty(new_password_txt) && !TextUtils.isEmpty(confirm_password_txt) && new_password_txt.equals(confirm_password_txt)) {
doInBackground task = new doInBackground();
String token = sp.getString("token", "");
String user = sp.getString("userId", "");
task.execute("Bearer " + token, user, new_password_txt);
}
}
});
return v;
}
public void onButtonPressed(Uri uri) {
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
public interface OnFragmentInteractionListener {
void onFragmentInteraction(Uri uri);
}
public class doInBackground extends AsyncTask<String, Void, Boolean> {
@Override
protected Boolean doInBackground(String... strings) {
return gamesNewsViewModel.updatePassword(strings[0], strings[1], strings[2]);
}
@Override
protected void onPostExecute(Boolean b) {
if (b) {
new_password.setText("");
old_password.setText("");
confirm_password.setText("");
Toast.makeText(getContext(), R.string.password_updated, Toast.LENGTH_SHORT).show();
} else
Toast.makeText(getContext(), R.string.password_updated, Toast.LENGTH_SHORT).show();
super.onPostExecute(b);
}
}
}
| true
|
199e6149d8c910317cd79b39de85d8f977a83d3c
|
Java
|
biglllyyy/svn
|
/src/main/java/com/cm/export/HistoryToExcel2.java
|
UTF-8
| 66,801
| 1.976563
| 2
|
[] |
no_license
|
package com.cm.export;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.cm.common.utils.DateTimeUtils;
import com.cm.mongo.entity.CarInfoHistoryMongo;
import com.cm.tbox.packet.CanDataNewPacket;
import com.cm.tbox.packet.CanDataPacket;
import com.cm.tbox.packet.CarCellTempPacket;
import com.cm.tbox.packet.CarCellTempSinglePacket;
import com.cm.tbox.packet.CarCellVoltagePacket;
import com.cm.tbox.packet.CarCellVoltageSinglePacket;
import com.cm.tbox.packet.CarDoorStatusPacket;
import com.cm.tbox.packet.CarExpandMorePacket;
import com.cm.tbox.packet.CarExpandOtherStatusPacket;
import com.cm.tbox.packet.CarExpandPacket;
import com.cm.tbox.packet.CarExtremumPacket;
import com.cm.tbox.packet.CarHGExpandPacket;
import com.cm.tbox.packet.CarInfoPacket;
import com.cm.tbox.packet.CarLHXNExpandPacket;
import com.cm.tbox.packet.CarLocationPacket;
import com.cm.tbox.packet.CarOtherStatusPacket;
import com.cm.tbox.packet.CarWarnPacket;
import com.cm.tbox.packet.ChargeDeviceTempPacket;
import com.cm.tbox.packet.ChargeDeviceVoltagePacket;
import com.cm.tbox.packet.DriveMotorInfoPacket;
import com.cm.tbox.packet.DriveMotorPacket;
import com.cm.tbox.packet.ExtremumPacket;
import com.cm.tbox.packet.FuelCellsPacket;
import com.cm.tbox.packet.LocationPacket;
import com.cm.tbox.packet.MotorPacket;
import com.cm.tbox.packet.SingleChargeDeviceTempPacket;
import com.cm.tbox.packet.SingleChargeDeviceVoltagePacket;
import com.cm.tbox.packet.warn.CarInfoWarnPacket;
import com.cm.tbox.packet.warn.CarWarnCommonPacket;
import com.cm.tbox.packet.warn.CellWarnPacket;
import com.cm.tbox.packet.warn.ChargerWarnPacket;
import com.cm.tbox.packet.warn.DCWarnPacket;
import com.cm.tbox.packet.warn.LHXNWarnPacket;
import com.cm.tbox.packet.warn.MotorWarnPacket;
import com.cm.tbox.packet.warn.PowerCellWarnPacket;
/**
* 历史数据导出为excel
* @author yunlu
*
*/
@SuppressWarnings("unchecked")
public class HistoryToExcel2 {
private static final String NA="N/A";
/**
* 包类型
* @author yunlu
*
*/
public static enum Type{
location,
cellTemp,
cellVoltage,
carInfo,
extremum,
expand,
hgExpand,
zxExpand,
expand1,
expand2,
powerCellWarn,
cellWarn,
carInfoWarn,
chargerWarn,
motorWarn,
dcWarn,
lhxnWarn,
lhxnExpand,
//2016-12-20新增
driveMotorRecord,
fuelCellsRecord,
motorPacket,
carWarnCommon,
chargeDeviceVoltage,
chargeDeviceTemp,
//2017-03-06新增,导出车辆和终端信息
vehilceAndTerminal,
//2018-06-27新增
canData
}
/**
* 通用值有效范围判断
* @param value
* @param min
* @param max
*/
private static String checkValue(Integer value,Integer min,Integer max){
if(value!=null){
if(min<=value&&value<=max){
return value.toString();
}else{
return NA;
}
}else{
return "";
}
}
/**
* 通用值有效范围判断
* @param value
* @param min
* @param max
*/
private static String checkValue(Double value,Double min,Double max){
if(value!=null){
if(min<=value&&value<=max){
return value.toString();
}else{
return NA;
}
}else{
return "";
}
}
/**
* 增加空数据
* @param list
* @param num
*/
private static void addEmpty(List list, int num) {
for (int i = 0; i < num; i++) {
list.add("");
}
}
/**
* 通用值判断
* @param node
* @param oneValue 如果值为1的描述
* @param zeroValue 如果值为0的描述
* @return
*/
private static String checkValue(Integer value,String oneValue,String zeroValue){
if(value==null){
return "";
}else{
if(value==0){
return zeroValue;
}else if(value==1){
return oneValue;
}else{
return NA;
}
}
}
/**
* 通用值判断
* @param node
* @param zeroValue 如果值为0的描述
* @param oneValue 如果值为1的描述
* @param twoValue 如果值为2的描述
* @param treeValue 如果值为3的描述
* @return
*/
private static String checkValue(Integer value,String zeroValue,String oneValue,String twoValue,String treeValue){
if(value==null){
return "";
}else{
if(value==0){
return zeroValue;
}else if(value==1){
return oneValue;
}else if(value==2){
return twoValue;
}else if(value==3){
return treeValue;
}else{
return NA;
}
}
}
/**
* 通用值判断
* @param node
* @return
*/
private static Object checkValue(Object node){
if(node==null){
return "";
}else{
return node;
}
}
/**
* 生成临时下载文件 返回文件地址
* @param result
* @return
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public static void exportReportHistoryData(File file,List<CarInfoHistoryMongo> result) throws Exception{
//定义所有包的sheet对象
ExcelSheet carInfoSheet = new ExcelSheet("基本",ExcelHeaderUtil2.getHeader(Type.carInfo),new ArrayList<List>());
//2016-12-20新增
ExcelSheet driveMotorRecordSheet = new ExcelSheet("驱动电机信息",ExcelHeaderUtil2.getHeader(Type.driveMotorRecord),new ArrayList<List>());
ExcelSheet fuelCellsRecordSheet = new ExcelSheet("燃料电池信息",ExcelHeaderUtil2.getHeader(Type.fuelCellsRecord),new ArrayList<List>());
ExcelSheet motorPacketSheet = new ExcelSheet("发动机数据",ExcelHeaderUtil2.getHeader(Type.motorPacket),new ArrayList<List>());
ExcelSheet chargeDeviceVoltageSheet = new ExcelSheet("可充电储能装置电压数据",ExcelHeaderUtil2.getHeader(Type.chargeDeviceVoltage),new ArrayList<List>());
ExcelSheet chargeDeviceTempSheet = new ExcelSheet("可充电储能装置温度数据",ExcelHeaderUtil2.getHeader(Type.chargeDeviceTemp),new ArrayList<List>());
ExcelSheet extremumSheet = new ExcelSheet("极值",ExcelHeaderUtil2.getHeader(Type.extremum),new ArrayList<List>());
ExcelSheet locationSheet = new ExcelSheet("位置",ExcelHeaderUtil2.getHeader(Type.location),new ArrayList<List>());
ExcelSheet cellTempSheet = new ExcelSheet("电池温度",ExcelHeaderUtil2.getHeader(Type.cellTemp),new ArrayList<List>());
ExcelSheet cellVoltageSheet = new ExcelSheet("电池电压",ExcelHeaderUtil2.getHeader(Type.cellVoltage),new ArrayList<List>());
// ExcelSheet expandSheet = new ExcelSheet("扩展",ExcelHeaderUtil2.getHeader(Type.expand),new ArrayList<List>());
ExcelSheet powerCellWarnSheet = new ExcelSheet("报警-动力蓄电池",ExcelHeaderUtil2.getHeader(Type.powerCellWarn),new ArrayList<List>());
//2016-12-20新增
ExcelSheet carWarnCommonSheet = new ExcelSheet("通用报警",ExcelHeaderUtil2.getHeader(Type.carWarnCommon),new ArrayList<List>());
ExcelSheet cellWarnheet = new ExcelSheet("报警-电池",ExcelHeaderUtil2.getHeader(Type.cellWarn),new ArrayList<List>());
ExcelSheet carInfoWarnSheet = new ExcelSheet("报警-整车",ExcelHeaderUtil2.getHeader(Type.carInfoWarn),new ArrayList<List>());
ExcelSheet chargerWarnSheet = new ExcelSheet("报警-充电机",ExcelHeaderUtil2.getHeader(Type.chargerWarn),new ArrayList<List>());
ExcelSheet motorWarnSheet = new ExcelSheet("报警-电机",ExcelHeaderUtil2.getHeader(Type.motorWarn),new ArrayList<List>());
ExcelSheet dcWarnSheet = new ExcelSheet("报警-DC",ExcelHeaderUtil2.getHeader(Type.dcWarn),new ArrayList<List>());
ExcelSheet canDataSheet = new ExcelSheet("can报文",ExcelHeaderUtil2.getHeader(Type.canData),new ArrayList<List>());
// ExcelSheet hgExpandSheet = new ExcelSheet("HG扩展",ExcelHeaderUtil2.getHeader(Type.hgExpand),new ArrayList<List>());
// ExcelSheet expand1Sheet = new ExcelSheet("扩展一",ExcelHeaderUtil2.getHeader(Type.expand1),new ArrayList<List>());
// ExcelSheet expand2Sheet = new ExcelSheet("扩展二",ExcelHeaderUtil2.getHeader(Type.expand2),new ArrayList<List>());
// ExcelSheet lhxnWarnSheet = new ExcelSheet("蓝海新能告警",ExcelHeaderUtil2.getHeader(Type.lhxnWarn),new ArrayList<List>());
// ExcelSheet lhxnExpandSheet = new ExcelSheet("蓝海新能扩展",ExcelHeaderUtil2.getHeader(Type.lhxnExpand),new ArrayList<List>());
List<ExcelSheet> sheetList = new ArrayList<ExcelSheet>();
sheetList.add(carInfoSheet);
//2016-12-20新增
sheetList.add(driveMotorRecordSheet);
sheetList.add(fuelCellsRecordSheet);
sheetList.add(motorPacketSheet);
sheetList.add(chargeDeviceVoltageSheet);
sheetList.add(chargeDeviceTempSheet);
sheetList.add(extremumSheet);
sheetList.add(locationSheet);
sheetList.add(cellTempSheet);
sheetList.add(cellVoltageSheet);
// sheetList.add(expandSheet);
sheetList.add(powerCellWarnSheet);
sheetList.add(carWarnCommonSheet);
sheetList.add(cellWarnheet);
sheetList.add(carInfoWarnSheet);
sheetList.add(chargerWarnSheet);
sheetList.add(motorWarnSheet);
sheetList.add(dcWarnSheet);
sheetList.add(canDataSheet);
// sheetList.add(hgExpandSheet);
// sheetList.add(expand1Sheet);
// sheetList.add(expand2Sheet);
// sheetList.add(cellWarnheet);
// sheetList.add(carInfoWarnSheet);
// sheetList.add(chargerWarnSheet);
// sheetList.add(lhxnWarnSheet);
// sheetList.add(lhxnExpandSheet);
// 得到输出流
for(int i=0;i<result.size();i++){
CarInfoHistoryMongo carHistory = result.get(i);
String dateTime = DateTimeUtils.formatDate(carHistory.getUpdateTime());
String receiveTime = DateTimeUtils.formatDate(carHistory.getReceiveTime());
String type = carHistory.getType()==0?"实时数据":"补发数据";
carInfo(carInfoSheet,carHistory,dateTime,receiveTime,type);
//2016-12-20新增
driveMotorRecord(driveMotorRecordSheet,carHistory,dateTime,receiveTime,type);
fuelCellsRecord(fuelCellsRecordSheet,carHistory,dateTime,receiveTime,type);
motorPacket(motorPacketSheet,carHistory,dateTime,receiveTime,type);
chargeDeviceVoltage(chargeDeviceVoltageSheet,carHistory,dateTime,receiveTime,type);
chargeDeviceTemp(chargeDeviceTempSheet,carHistory,dateTime,receiveTime,type);
extreme(extremumSheet,carHistory,dateTime,receiveTime,type);
location(locationSheet,carHistory,dateTime,receiveTime,type);
cellTemp(cellTempSheet,carHistory,dateTime,receiveTime,type);
cellVoltage(cellVoltageSheet,carHistory,dateTime,receiveTime,type);
// carExpandMore(expandSheet,carHistory,dateTime);
//
// carHGExpand(hgExpandSheet,carHistory,dateTime);
// carExpandMore1(expand1Sheet,carHistory,dateTime);
// carExpandMore2(expand2Sheet,carHistory,dateTime);
CarWarnPacket carWarn = carHistory.getCarWarn();
if(carWarn!=null){
//2016-12-20新增
carWarnCommon(carWarnCommonSheet,carWarn,dateTime,receiveTime,type);
cellWarn(cellWarnheet, carWarn, dateTime,receiveTime,type);
carInfoWarn(carInfoWarnSheet, carWarn, dateTime,receiveTime,type);
chargerWarn(chargerWarnSheet, carWarn, dateTime,receiveTime,type);
powerCellWarn(powerCellWarnSheet, carWarn, dateTime,receiveTime,type);
motorWarn(motorWarnSheet, carWarn, dateTime,receiveTime,type);
dcWarn(dcWarnSheet, carWarn, dateTime,receiveTime,type);
// lhxnWarn(lhxnWarnSheet, carWarn, dateTime);
}
// lhxnExpand(lhxnExpandSheet,carHistory,dateTime);
// expand(expandSheet,carHistory,dateTime);
canData(canDataSheet,carHistory,dateTime,receiveTime,type);
}
ListToExcel.exportExcelForSheet(sheetList, file);
}
private static void canData(ExcelSheet canDataSheet, CarInfoHistoryMongo carHistory, String dateTime,
String receiveTime, String type) {
CanDataNewPacket canDataNewRecord = carHistory.getCanDataNewRecord();
CanDataPacket canDataRecord = carHistory.getCanDataRecord();
Map<String, List<String>> data=null;
if(canDataNewRecord!=null) {
data= canDataNewRecord.getData();
}else if(canDataRecord!=null) {
data = canDataRecord.getData();
}
if(null==data) {
return;
}
if(data.size()>canDataSheet.getHeaderList().size()-3) {
for(String key:data.keySet()) {
if(!canDataSheet.getHeaderList().contains(key)) {
canDataSheet.getHeaderList().add(key);
}
}
}
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
for(int i=3;i<canDataSheet.getHeaderList().size();i++) {
temp.add(data.get(canDataSheet.getHeaderList().get(i)));
}
canDataSheet.addData(temp);
}
/**
* 定位信息
* @param temp
* @param carHistory
* @return
*/
private static void location(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
LocationPacket carLocation =carHistory.getCarLocationRecord();
List temp = new ArrayList();
if(carLocation !=null){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(carLocation.getStatus(), "无效", "有效"));
temp.add(checkValue(carLocation.getLonType(), "西经", "东经")+":"+checkValue(carLocation.getLon()));
temp.add(checkValue(carLocation.getLatType(), "南纬", "北纬")+":"+checkValue(carLocation.getLat()));
sheet.addData(temp);
}
}
/**
* 车辆扩展信息
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void expand(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarExpandPacket expand =carHistory.getCarExpandRecord();
CarExpandMorePacket expandMore = carHistory.getCarExpandMoreRecord();
List temp = new ArrayList();
if(expand !=null){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
CarDoorStatusPacket carDoor=expand.getCarDoorStatus();
CarExpandOtherStatusPacket carOtherStatus = expand.getCarOtherStatus();
temp.add(checkValue(expand.getDumpEnergy()));
temp.add(checkValue(expand.getRange(),0.0,6553.4));
temp.add(checkValue(carDoor.getDoorStatus(), "有效","无效"));
temp.add(checkValue(expand.getAccStatus(),"点火","熄火"));
temp.add(checkValue(carDoor.getSkyLightStatus(),"开门" , "关门"));
temp.add(checkValue(carDoor.getTrunkStatus() ,"开门" , "关门"));
temp.add(checkValue(carDoor.getLeftBackDoorStatus() ,"开门" , "关门"));
temp.add(checkValue(carDoor.getRightBackDoorStatus(),"开门" , "关门"));
temp.add(checkValue(carDoor.getLeftFrontDoorStatus() ,"开门" , "关门"));
temp.add(checkValue(carDoor.getRightFrontDoorStatus(),"开门" , "关门"));
// temp.add(checkValue(expand.getAccStatus(),"点火","熄火"));
temp.add(checkValue(expand.getStorageCellVoltage(),0.0,25.4));
temp.add(checkValue(expand.getSpeed(),0.0,220.0));
temp.add(checkValue(expand.getMileage(),0.0,999999.9));
temp.add(checkValue(expand.getNetworkStrength(),0,31));
temp.add(checkValue(carOtherStatus.getOtherStatus(),"有效","无效"));
temp.add(checkValue(carOtherStatus.getCarType(),"燃油车","电动车"));
temp.add(checkValue(carOtherStatus.getChargeStatus(),"充电","未充电"));
temp.add(checkValue(carOtherStatus.getTrunkLockStatus(),"开锁","关锁"));
temp.add(checkValue(carOtherStatus.getLeftBackDoorLockStatus(),"开锁","关锁"));
temp.add(checkValue(carOtherStatus.getRightBackDoorLockStatus(),"开锁","关锁"));
temp.add(checkValue(carOtherStatus.getLeftFrontDoorLockStatus(),"开锁","关锁"));
temp.add(checkValue(carOtherStatus.getRightFrontDoorLockStatus(),"开锁","关锁"));
sheet.addData(temp);
}
}
/**
* 整车信息
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void carInfo(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarInfoPacket carInfo =carHistory.getCarInfoRecord();
List temp = new ArrayList();
if(carInfo !=null){
//时间
temp.add(dateTime);
//数据类型
temp.add(receiveTime);
//服务器接受时间
temp.add(type);
//速度
temp.add(checkValue(carInfo.getSpeed(),0.0,220.0));
//里程
temp.add(checkValue(carInfo.getMileage(),0.0,999999.9));
//档位
if(carInfo.getGears() !=null){
if(carInfo.getGears()==0){
temp.add("空挡");
}else if(carInfo.getGears()<7){
temp.add(carInfo.getGears());
}else if(carInfo.getGears()==14){
temp.add("自动挡");
}else if(carInfo.getGears()==13){
temp.add("倒挡");
}else if (carInfo.getGears()==15){
temp.add("P挡");
}else{
temp.add("N/A");
}
}else{
temp.add("");
}
//加速形成踏板
temp.add(checkValue(carInfo.getAccelTripValue()));
//刹车形成踏板
temp.add(checkValue(carInfo.getBrakeTripValue()));
//充电状态 (2016-12-20国标)
//0x01:停车充电;0x02:行驶充电;0x03:未充电状态;0x04:充电完成;“0xFE”表示异常,“0xFF”表示无效。
if(carInfo.getChargeStatus() !=null){
if(carInfo.getChargeStatus()==1){
temp.add("停车充电");
}else if(carInfo.getChargeStatus()==2){
temp.add("行驶充电");
}else if(carInfo.getChargeStatus()==3){
temp.add("未充电状态");
}else if(carInfo.getChargeStatus()==4){
temp.add("充电完成");
}else if(carInfo.getChargeStatus()==0xFE){
temp.add("异常");
}else if(carInfo.getChargeStatus()==0xFF){
temp.add("无效");
}else{
temp.add("");
}
}else{
temp.add("");
}
temp.add(checkValue(carInfo.getDriveStatus(), "有效" ,"无效"));
temp.add(checkValue(carInfo.getBrakeStatus(), "有效" ,"无效"));
//国标新增 (2016-12-20国标)
//carStatus 车辆状态 0x01:车辆启动状态;0x02:熄火;0x03:其他状态;“0xFE”表示异常,“0xFF”表示无效。
if(null != carInfo.getCarStatus()){
if(carInfo.getCarStatus()==0x01){
temp.add("启动");
}else if(carInfo.getCarStatus()==0x02){
temp.add("熄火");
}else if(carInfo.getCarStatus()==0x03){
temp.add("其他状态");
}else if(carInfo.getCarStatus()==0xFE){
temp.add("异常");
}else if(carInfo.getCarStatus()==0xFF){
temp.add("无效");
}
}else{
temp.add("");
}
//runModel int 运行模式 0x01: 纯电;0x02:混动;0x03:燃油;0xFE表示异常;0xFF表示无效
if(null != carInfo.getRunModel()){
if(carInfo.getRunModel()==0x01){
temp.add("纯电");
}else if(carInfo.getRunModel()==0x02){
temp.add("混动");
}else if(carInfo.getRunModel()==0x03){
temp.add("燃油");
}else if(carInfo.getRunModel()==0xFE){
temp.add("异常");
}else if(carInfo.getRunModel()==0xFF){
temp.add("无效");
}
}else{
temp.add("");
}
//totalVoltage double 总电压 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效。 单元:V 范围:0至1000
temp.add(checkValue(carInfo.getTotalVoltage(),0.0,1000.0));
//totalCurrent double 总电流 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效。 单元:A 范围:-1000至1000
temp.add(checkValue(carInfo.getTotalCurrent(),-1000.0,1000.0));
//soc int soc “0xFE”表示异常,“0xFF”表示无效 范围:0至100
temp.add(checkValue(carInfo.getSoc(),0,100));
//dcStatus int dc状态 0x01:工作;0x02:断开,“0xFE”表示异常,“0xFF”表示无
if(null != carInfo.getDcStatus()){
if(carInfo.getDcStatus()==0x01){
temp.add("工作");
}else if(carInfo.getDcStatus()==0x02){
temp.add("断开");
}else if(carInfo.getDcStatus()==0xFE){
temp.add("异常");
}else if(carInfo.getDcStatus()==0xFF){
temp.add("无效");
}
}else{
temp.add("");
}
//resistance int 绝缘电阻 单元:KΩ 范围:0至60000
temp.add(checkValue(carInfo.getResistance(),0,60000));
sheet.addData(temp);
}
}
/**
* 极值信息
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void extreme(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
ExtremumPacket extreme =carHistory.getCarExtremum();
List temp = new ArrayList();
if (extreme != null) {
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
//最高电压
temp.add(checkValue(extreme.getHighestVoltageCellNo(),1,254));
temp.add(checkValue(extreme.getHighestVoltageSingle(),0.0,15.0));
temp.add(checkValue(extreme.getHighestVoltageCellsNo(),1,254));
//最低电压
temp.add(checkValue(extreme.getLowestVoltageCellsNo(),1,254));
temp.add(checkValue(extreme.getLowestVoltageSingle(),0.0,15.0 ));
temp.add(checkValue(extreme.getLowestVoltageCellNo(),1,254));
//最高温度
temp.add(checkValue(extreme.getHighestTemp(),-40,125));
temp.add(checkValue(extreme.getHighestTempCellsNo(),1,254));
temp.add(checkValue(extreme.getHighestTempProbeNo(),1,254));
//最低温度
temp.add(checkValue(extreme.getLowestTempCellsNo(),1,254));
temp.add(checkValue(extreme.getLowestTempProbeNo(),1,254));
temp.add(checkValue(extreme.getLowestTemp(),-40,125));
sheet.addData(temp);
}
}
/**
* 中兴
* @param sheet
* @param carHistory
* @param dateTime
*/
private static List carExpandMore(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarExpandMorePacket carExpandMore = carHistory.getCarExpandMoreRecord();
List temp = new ArrayList();
if (carExpandMore != null) {
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(carExpandMore.getMotorTorque(),-2000.0,2000.0));
temp.add(checkValue(carExpandMore.getChargeCurrent(),0.0,500.0));
temp.add(checkValue(carExpandMore.getChargeVoltage(),0.0,600.0));
temp.add(checkValue(carExpandMore.getMotorAcCurrent()));
temp.add(checkValue(carExpandMore.getMotorAcVoltage()));
temp.add(checkValue(carExpandMore.getDcVoltage()));
temp.add(checkValue(carExpandMore.getDcStatus(),"工作" ,"停止"));
temp.add(checkValue(carExpandMore.getDcOutCurrent()));
temp.add(checkValue(carExpandMore.getDcOutVoltage()));
temp.add(checkValue(carExpandMore.getDcTemp()));
temp.add(checkValue(carExpandMore.getCellBoxTemp()));
temp.add(checkValue(carExpandMore.getHighOutCurrentAllow()));
temp.add(checkValue(carExpandMore.getHighInCurrentAllow()));
temp.add(checkValue(carExpandMore.getHighChargeVoltageAllow(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getHighChargeCurrentAllow(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getChargerOutVoltage(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getChargerOutCurrent(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getPositiveInsulationResistance(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getCathodeInsulatingResistance(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getHighDriverTorque(),-32000,33534));
temp.add(checkValue(carExpandMore.getHighDriverSpeed(),-32000,33534));
temp.add(checkValue(carExpandMore.getMotorTargetOutTorque(),-32000,33534));
temp.add(checkValue(carExpandMore.getMotorTargetOutSpeed(),-32000,33534));
temp.add(checkValue(carExpandMore.getContactorFrontVoltage(),-32000,33534));
temp.add(checkValue(carExpandMore.getContactorBackVoltage(),-32000,33534));
temp.add(checkValue(carExpandMore.getSoh()));
switch (carExpandMore.getSteeringSystemFaultCode()){
case 0:
temp.add("正常");
break;
case 1:
temp.add("自检异常");
break;
case 17:
temp.add("过压(输入端)");
break;
case 18:
temp.add("欠压(输入端)");
break;
case 19:
temp.add("过流/短路(输出端)");
break;
case 20:
temp.add("转速过高");
break;
case 21:
temp.add("开路检测异常");
break;
case 22:
temp.add("控制器温度过高");
break;
default:
temp.add(NA);
break;
}
temp.add(checkValue(carExpandMore.getWarmUpControl(),"开启" , "关闭"));
if (carExpandMore.getCellWorkStatus() != null) {
if (carExpandMore.getCellWorkStatus() == 0) {
temp.add("充电完成");
} else if (carExpandMore.getCellWorkStatus() ==1) {
temp.add("放电");
} else if (carExpandMore.getCellWorkStatus() ==2) {
temp.add("充电");
} else if (carExpandMore.getCellWorkStatus() == 3) {
temp.add("充电故障");
} else {
temp.add(NA);
}
} else {
temp.add("");
}
temp.add(checkValue(carExpandMore.getDischargeRelayStatus(), "吸合", "断开"));
temp.add(checkValue(carExpandMore.getChargeRelayStatus(), "吸合", "断开"));
temp.add(checkValue(carExpandMore.getIdleMachine(), "无扭矩输出", "无效"));
if (carExpandMore.getCanAcc() != null) {
if (carExpandMore.getCanAcc() == 1) {
temp.add("can控制");
} else if (carExpandMore.getCanAcc() == 2) {
temp.add("油门控制");
} else {
temp.add(NA);
}
} else {
temp.add("");
}
temp.add(checkValue(carExpandMore.getPreChargeContactor(), "吸合" , "断开"));
temp.add(checkValue(carExpandMore.getPwmWave(), "开pwm波", "关pwm波"));
temp.add(checkValue(carExpandMore.getMotorSchema(),"转速控制" , "转矩控制"));
temp.add(checkValue(carExpandMore.getMainContactorStatus(),"吸合" ,"断开"));
sheet.addData(temp);
}
return temp;
}
/**
* 中兴
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void carExpandMore1(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarExpandMorePacket carExpandMore = carHistory.getCarExpandMoreRecord();
List temp = new ArrayList();
if (carExpandMore != null) {
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(carExpandMore.getMotorTorque(),-2000.0,2000.0));
temp.add(checkValue(carExpandMore.getChargeCurrent(),0.0,500.0));
temp.add(checkValue(carExpandMore.getChargeVoltage(),0.0,600.0));
temp.add(checkValue(carExpandMore.getHighChargeVoltageAllow(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getHighChargeCurrentAllow(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getChargerOutVoltage(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getChargerOutCurrent(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getPositiveInsulationResistance(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getCathodeInsulatingResistance(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getHighDriverTorque(),-32000,33534));
// temp.add(checkValue(carExpandMore.getHighDriverSpeed(),-32000,33534));
// temp.add(checkValue(carExpandMore.getMotorTargetOutTorque(),-32000,33534));
// temp.add(checkValue(carExpandMore.getMotorTargetOutSpeed(),-32000,33534));
// temp.add(checkValue(carExpandMore.getContactorFrontVoltage(),-32000,33534));
// temp.add(checkValue(carExpandMore.getContactorBackVoltage(),-32000,33534));
// temp.add(checkValue(carExpandMore.getWarmUpControl(),"开启" , "关闭"));
// if (carExpandMore.getCellWorkStatus() != null) {
// if (carExpandMore.getCellWorkStatus() == 0) {
// temp.add("充电完成");
// } else if (carExpandMore.getCellWorkStatus() ==1) {
// temp.add("放电");
// } else if (carExpandMore.getCellWorkStatus() ==2) {
// temp.add("充电");
// } else if (carExpandMore.getCellWorkStatus() == 3) {
// temp.add("充电故障");
// } else {
// temp.add(NA);
// }
// } else {
// temp.add("");
// }
// temp.add(checkValue(carExpandMore.getDischargeRelayStatus(), "关闭", "打开"));
// temp.add(checkValue(carExpandMore.getChargeRelayStatus(), "关闭" , "打开"));
// temp.add(checkValue(carExpandMore.getIdleMachine(), "无扭矩输出", "无效"));
// if (carExpandMore.getCanAcc() != null) {
// if (carExpandMore.getCanAcc() == 1) {
// temp.add("can控制");
// } else if (carExpandMore.getCanAcc() == 2) {
// temp.add("油门控制");
// } else {
// temp.add(NA);
// }
// } else {
// temp.add("");
// }
// temp.add(checkValue(carExpandMore.getPreChargeContactor(), "吸合" , "断开"));
// temp.add(checkValue(carExpandMore.getPwmWave(), "开pwm波", "关pwm波"));
// temp.add(checkValue(carExpandMore.getMotorSchema(),"转速控制" , "转矩控制"));
// temp.add(checkValue(carExpandMore.getMainContactorStatus(),"吸合" ,"断开"));
temp.add(checkValue(carExpandMore.getDumpTime(),0,65534));
sheet.addData(temp);
}
}
/**
* 中兴
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void carExpandMore2(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarExpandMorePacket carExpandMore = carHistory.getCarExpandMoreRecord();
List temp = new ArrayList();
if (carExpandMore != null) {
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
// temp.add(checkValue(carExpandMore.getMotorTorque(),-2000.0,2000.0));
// temp.add(checkValue(carExpandMore.getChargeCurrent(),0.0,500.0));
// temp.add(checkValue(carExpandMore.getChargeVoltage(),0.0,600.0));
// temp.add(checkValue(carExpandMore.getHighChargeVoltageAllow(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getHighChargeCurrentAllow(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getChargerOutVoltage(),0.0,6553.4));
// temp.add(checkValue(carExpandMore.getChargerOutCurrent(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getPositiveInsulationResistance(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getCathodeInsulatingResistance(),0.0,6553.4));
temp.add(checkValue(carExpandMore.getHighDriverTorque(),-32000,33534));
temp.add(checkValue(carExpandMore.getHighDriverSpeed(),-32000,33534));
temp.add(checkValue(carExpandMore.getMotorTargetOutTorque(),-32000,33534));
temp.add(checkValue(carExpandMore.getMotorTargetOutSpeed(),-32000,33534));
temp.add(checkValue(carExpandMore.getContactorFrontVoltage(),-32000,33534));
temp.add(checkValue(carExpandMore.getContactorBackVoltage(),-32000,33534));
temp.add(checkValue(carExpandMore.getSoh()));
temp.add(checkValue(carExpandMore.getWarmUpControl(),"开启" , "关闭"));
if (carExpandMore.getCellWorkStatus() != null) {
if (carExpandMore.getCellWorkStatus() == 0) {
temp.add("充电完成");
} else if (carExpandMore.getCellWorkStatus() ==1) {
temp.add("放电");
} else if (carExpandMore.getCellWorkStatus() ==2) {
temp.add("充电");
} else if (carExpandMore.getCellWorkStatus() == 3) {
temp.add("充电故障");
} else {
temp.add(NA);
}
} else {
temp.add("");
}
temp.add(checkValue(carExpandMore.getDischargeRelayStatus(), "关闭", "开启"));
temp.add(checkValue(carExpandMore.getChargeRelayStatus(), "关闭" , "开启"));
temp.add(checkValue(carExpandMore.getIdleMachine(), "无扭矩输出", "无效"));
temp.add(checkValue(carExpandMore.getCanAcc(), "can控制", "油门控制"));
temp.add(checkValue(carExpandMore.getPreChargeContactor(), "吸合" , "断开"));
temp.add(checkValue(carExpandMore.getPwmWave(), "开pwm波", "关pwm波"));
temp.add(checkValue(carExpandMore.getMotorSchema(),"转速控制" , "转矩控制"));
temp.add(checkValue(carExpandMore.getMainContactorStatus(),"吸合" ,"断开"));
sheet.addData(temp);
}
}
/**
* 电池温度
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void cellTemp(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarCellTempPacket cellTemp =carHistory.getCarCellTemp();
if (cellTemp != null) {
List<CarCellTempSinglePacket> children = cellTemp.getChildren();
for(int i=0;i<children.size();i++){
List temp = new ArrayList();
if(i==0){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(cellTemp.getTempProbeNum()));
temp.add(checkValue(cellTemp.getCellsNum()));
}else{
addEmpty(temp, 5);
}
temp.add(checkValue(children.get(i).getCellsNo()));
temp.add(checkValue(children.get(i).getTempProbeNum()));
temp.add(checkValue(children.get(i).getTempList()));
sheet.addData(temp);
}
}
}
/**
* 电池电压
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void cellVoltage(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarCellVoltagePacket cellVoltage = carHistory.getCarCellVoltage();
if (cellVoltage != null) {
List<CarCellVoltageSinglePacket> children = cellVoltage.getChildren();
for(int i=0;i<children.size();i++){
List temp = new ArrayList();
if(i==0){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(cellVoltage.getSingleCellNum()));
temp.add(checkValue(cellVoltage.getCellsNum()));
}else{
addEmpty(temp, 5);
}
temp.add(checkValue(children.get(i).getCellsNo()));
temp.add(checkValue(children.get(i).getCellNum()));
temp.add(checkValue(children.get(i).getCellVoltageList()));
sheet.addData(temp);
}
}
}
/**
* 华冠扩展
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void carHGExpand(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
CarHGExpandPacket carHGExpand = carHistory.getCarHGExpandRecord();
if (carHGExpand != null) {
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(carHGExpand.getOrderChargeVoltage(),0.0,1200.0));
temp.add(checkValue(carHGExpand.getDumpTime(),0,65535));
temp.add(checkValue(carHGExpand.getRange(),0.0,600.0));
temp.add(checkValue(carHGExpand.getCellWaterTemp(),-50,+200));
switch (carHGExpand.getFrontMotorFaultLevel()){
case 0:
temp.add("无故障");
break;
case 1:
temp.add("警告");
break;
case 2:
temp.add("故障");
break;
case 3:
temp.add("比较严重故障");
break;
case 4:
temp.add("严重故障");
break;
default:
temp.add(NA);
break;
}
temp.add(checkValue(carHGExpand.getFrontMotorFaultCode(),0,65535));
temp.add(checkValue(carHGExpand.getFrontMotorHFaultCodes()));
switch (carHGExpand.getBackMotorFaultLevel()){
case 0:
temp.add("无故障");
break;
case 1:
temp.add("警告");
break;
case 2:
temp.add("故障");
break;
case 3:
temp.add("比较严重故障");
break;
case 4:
temp.add("严重故障");
break;
default:
temp.add(NA);
break;
}
temp.add(checkValue(carHGExpand.getBackMotorFaultCode(),0,65535));
temp.add(checkValue(carHGExpand.getBackMotorHFaultCodes()));
temp.add(checkValue(carHGExpand.getBMSChargeFaultLevel()));
temp.add(checkValue(carHGExpand.getBMSChargeFaultCode(),0,65535));
if(carHGExpand.getOtherStatus() !=null){
CarOtherStatusPacket carOtherStatus=carHGExpand.getOtherStatus();
temp.add(checkValue(carOtherStatus.getStatus(),"无效","有效"));
temp.add(checkValue(carOtherStatus.getpGearsStatus(),"f否","是"));
temp.add(checkValue(carOtherStatus.getChargeLicence(),"许可","不许可"));
temp.add(checkValue(carOtherStatus.getThermalManageLicence(),"许可","不许可"));
temp.add(checkValue(carOtherStatus.getChargeStatus(),"许可","不许可"));
temp.add(checkValue(carOtherStatus.getChargeGunStatus(),"插入","未插入"));
temp.add(checkValue(carOtherStatus.getRapidSwtichStatus(),"急停开始","急停关闭"));
temp.add(checkValue(carOtherStatus.getWarnLightStatus(),"开启","关闭"));
temp.add(checkValue(carOtherStatus.getLowBeamLightStatus(),"开启","关闭"));
}else{
addEmpty(temp, 9);
}
sheet.addData(temp);
}
}
/**
* 动力蓄电池故障
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void powerCellWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
PowerCellWarnPacket powerCellWarn = carWarn.getPowerCellWarn();
if(powerCellWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(powerCellWarn.getWarnTempDiff(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnHighTemp(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellsHighVoltage(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellsLowVoltage(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnSocLow(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellHighVoltage() ,"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellLowVoltage(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnSocLower(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnSocHigher(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellsNoMatch(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnCellsLowMatch(),"报警" , "正常"));
temp.add(checkValue(powerCellWarn.getWarnInsulation(),"报警" , "正常"));
sheet.addData(temp);
}
}
/**
*
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void cellWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
CellWarnPacket cellWarn = carWarn.getCellWarn();
if(cellWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
if (cellWarn.getWarnFlag() != null) {
if (cellWarn.getWarnFlag()==0) {
temp.add("正常");
} else if (cellWarn.getWarnFlag()==1) {
temp.add("一级");
} else if (cellWarn.getWarnFlag()==2) {
temp.add("二级");
} else {
temp.add(NA);
}
} else {
temp.add("");
}
if (cellWarn.getWarnCellSystem()!= null) {
if (cellWarn.getWarnCellSystem()==0) {
temp.add("正常");
} else if (cellWarn.getWarnCellSystem()==1) {
temp.add("一级");
} else if (cellWarn.getWarnCellSystem()==2) {
temp.add("二级");
} else {
temp.add(NA);
}
} else {
temp.add("");
}
temp.add(checkValue(cellWarn.getCellTotalVoltageHigher(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getCellTotalVoltageLower(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getInsulationLow(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleVoltageLower(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleVoltageHigher(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempLower(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempHigher() ,"异常" , "正常"));
temp.add(checkValue(cellWarn.getPlugInFlower(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getOutCurrentHigher(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleVoltageDiffHigher(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempDiffHigher(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getCellTotalVoltageHigh(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getCellTotalVoltageLow(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getInsulationLower() ,"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempLow() ,"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempHigh() ,"异常" , "正常"));
temp.add(checkValue(cellWarn.getPlugInFlow(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getOutCurrentHigh(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleVoltageDiffHigh(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getNetworkInside(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getVoltageCollect(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getCurrentCollect(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleInOver(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getSingleOutOver(),"异常" , "正常"));
temp.add(checkValue(cellWarn.getTempUpFast() ,"异常" , "正常"));
temp.add(checkValue(cellWarn.getShortOutProtect(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
*
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void carInfoWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
CarInfoWarnPacket carInfoWarn = carWarn.getCarInfoWarn();
if(carInfoWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(carInfoWarn.getPowerCellStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorHot(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getDcStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getCarStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getPowerCellCutLight(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getRunReadyStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getGearsStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getAcceleratorStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorHoter(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getPreChargeStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMainContactorStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getIgbtStatus(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorFlow(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorVoltageHigher(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorVoltageLower(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorSpeedOver(),"异常" , "正常"));
temp.add(checkValue(carInfoWarn.getMotorStatus(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
*
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void chargerWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
ChargerWarnPacket chargerWarn = carWarn.getChargerWarn();
if(chargerWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(chargerWarn.getHardwareStatus(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getCommunicationOvertime(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getChargerTempHighWarn(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getChargerTempHighProtect(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getInVoltageStatus(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getOverFlow(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getLeakage(),"异常" , "正常"));
temp.add(checkValue(chargerWarn.getCellElectrodeReverse(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
*
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void motorWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
MotorWarnPacket motorWarn = carWarn.getMotorWarn();
if(motorWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(motorWarn.getOverCurrentSpeedUp(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getOverCurrentSpeedDown(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getOverCurrentSpeedConstant() ,"异常" , "正常"));
temp.add(checkValue(motorWarn.getOverVoltageSpeedUp(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getOverVoltageSpeedDown(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getOverVoltageSpeedConstant() ,"异常" , "正常"));
temp.add(checkValue(motorWarn.getLowVoltageStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getDriverOverload(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getMotorOverload(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getOutputPhase(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getDriverHot(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getDriverHotPre(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getEepormRWStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getMotorGroundShortOutStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getFastLimitCurrent(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getMotorSpeedOver(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getSpeedDiffHigh(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getMotorHotPre(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getCanInitStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getCanCommunicationStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getEncoderStatus(),"异常" , "正常"));
temp.add(checkValue(motorWarn.getCurrentCollect(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
*
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void dcWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
DCWarnPacket dcWarn = carWarn.getDcWarn();
if(dcWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(dcWarn.getDcTempStatus(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcOutFlowHigh(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcOutVoltageHigh(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcOutVoltageLow(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcInVoltageHigh(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcInVoltageLow(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcOutShortOutStatus(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getDcHardwareStatus(),"异常" , "正常"));
temp.add(checkValue(dcWarn.getCommunicationOvertime(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
* 蓝海新能告警
* @param sheet
* @param carWarn
* @param dateTime
*/
@SuppressWarnings("rawtypes")
private static void lhxnWarn(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
LHXNWarnPacket lhxnWarn = carWarn.getLhxnWarn();
if(lhxnWarn!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(lhxnWarn.getLowVoltagePowerLow(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getLowVoltagePowerHigh(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorSysCheck(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorRotary(),"过流" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorControlOverFlow(),"过压" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorControlOverVoltage(),"欠压" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorControlLowVoltage(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getVacuumWarn(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getSysStatus(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getEps(),"正常" , "一路失效","两路失效","两路不回位"));
temp.add(checkValue(lhxnWarn.getAccelTrip(),"正常" , "丢帧","掉线","not used"));
temp.add(checkValue(lhxnWarn.getMotorControl(),"正常" , "丢帧","掉线","not used"));
temp.add(checkValue(lhxnWarn.getCellSys(),"正常" , "丢帧","掉线","not used"));
temp.add(checkValue(lhxnWarn.getTcu(),"正常" , "丢帧","掉线","not used"));
temp.add(checkValue(lhxnWarn.getFloatPlug(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getMotorEnableFeedback(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getMasterContactorFeedback(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getTorqueFeedback(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getAbs(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getBms(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getHighVoltageControl(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getVcu(),"异常" , "正常"));
temp.add(checkValue(lhxnWarn.getRepair(),"异常" , "正常"));
sheet.addData(temp);
}
}
/**
* 蓝海新能扩展
* @param sheet
* @param carHistory
* @param dateTime
* @throws Exception
*/
private static void lhxnExpand(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type) throws Exception{
CarLHXNExpandPacket LHXNExpand = carHistory.getCarLHXNExpandRecord();
if (LHXNExpand != null) {
List temp = new ArrayList();
temp.add(checkValue(LHXNExpand.getSimStatus(),"未连接" , "已连接"));
temp.add(checkValue(LHXNExpand.getTfStatus(),"未连接" , "已连接"));
temp.add(checkValue(LHXNExpand.getGsmStatus(),"未连接" , "已连接"));
temp.add(checkValue(LHXNExpand.getGpsStatus(),"未连接" , "已连接"));
temp.add(checkValue(LHXNExpand.getSimStatus(),"无效","正常工作模式","跛行模式","待机模式"));
temp.add(checkValue(LHXNExpand.getTboxVersion()));
temp.add(checkValue(LHXNExpand.getTorqueFeedback(),-300.0 , 300.0));
temp.add(checkValue(LHXNExpand.getMotorControlVersion()));
temp.add(checkValue(LHXNExpand.getTorqueCommand(),-300.0 , 300.0));
temp.add(checkValue(LHXNExpand.getVcuVersion()));
temp.add(checkValue(LHXNExpand.getVacuum(),-3000.0,3000.0));
temp.add(checkValue(LHXNExpand.getPtcTemp(),-100,155));
temp.add(checkValue(LHXNExpand.getSingleMileage(),0.0,6000.0));
temp.add(checkValue(LHXNExpand.getChargeDumpTime(),0.0,25.5));
temp.add(checkValue(LHXNExpand.getCellsMileage(),0.0,1677721.5));
temp.add(checkValue(LHXNExpand.getCellsAvgTemp(),-100,155));
temp.add(checkValue(LHXNExpand.getBmsVersion()));
temp.add(checkValue(LHXNExpand.getCellsChargeTimes()));
temp.add(checkValue(LHXNExpand.getSingleVoltageDiff(),0.0000,6.5535));
temp.add(checkValue(LHXNExpand.getDumpMileage(),0,250));
temp.add(checkValue(LHXNExpand.getCellMaxVolume()));
temp.add(checkValue(LHXNExpand.getCellProducerNo()));
temp.add(checkValue(LHXNExpand.getCellsNo()));
temp.add(checkValue(LHXNExpand.getAllowOutVoltageHigh(),0.00,655.35));
temp.add(checkValue(LHXNExpand.getAllowOutCurrentHigh(),0.00,655.35));
temp.add(checkValue(LHXNExpand.getSlowChargeControlModel(),"默认值","电加热模式","充电模式",""));
temp.add(checkValue(LHXNExpand.getSlowChargeControlStatus(),"启动","关闭输出"));
temp.add(checkValue(LHXNExpand.getFastChargeControl(),"启动","关闭输出"));
temp.add(checkValue(LHXNExpand.getAllowChargeVoltageHigh(),0.00,655.35));
temp.add(checkValue(LHXNExpand.getAllowChargeCurrentHigh(),0.00,655.35));
temp.add(checkValue(LHXNExpand.getCellsStandardAH()));
temp.add(checkValue(LHXNExpand.getCellsRealAH()));
temp.add(checkValue(LHXNExpand.getCellsNum()));
temp.add(checkValue(LHXNExpand.getSingleProtectVoltageLow(),0.000,65.535));
temp.add(checkValue(LHXNExpand.getFanStatus(),"开启","关闭"));
temp.add(checkValue(LHXNExpand.getHeaterStatus(),"断开","闭合"));
temp.add(checkValue(LHXNExpand.getRepairSwitch(),"未连接","连接"));
temp.add(checkValue(LHXNExpand.getMinusAssistSignal(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getPlusAssistSignal(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getPlusChargeContactor(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getMinusContactor(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getPlusContactor(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getVoltageThermalAssistSignal(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getFastChargeContactor(),"闭合","断开"));
temp.add(checkValue(LHXNExpand.getFastChargeAssistSignal(),"有效","无效"));
temp.add(checkValue(LHXNExpand.getBmsProducer(),"预留","亿能"));
sheet.addData(temp);
}
}
/**
* 2016-12-20新增 驱动电机信息
* @param sheet
* @param carHistory
* @param dateTime
*/
private static void driveMotorRecord(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type){
DriveMotorPacket driveMotorPacket = carHistory.getDriveMotorRecord();
if (driveMotorPacket != null) {
List<DriveMotorInfoPacket> children = driveMotorPacket.getInfos();
for(int i=0;i<children.size();i++){
List temp = new ArrayList();
if(i==0){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(driveMotorPacket.getNum()));
}else{
addEmpty(temp, 4);
}
temp.add(checkValue(children.get(i).getMotorNo(),1,253));
// 驱动电机状态 0x01:耗电;0x02:发电;0x03:关闭状态;0x04:准备状态“0xFE”表示异常,“0xFF”表示无效。 范围:0至65531
if(null!=children.get(i).getMotorStatus()){
if(children.get(i).getMotorStatus()==1){
temp.add("耗电");
}else if(children.get(i).getMotorStatus()==2){
temp.add("发电");
}else if(children.get(i).getMotorStatus()==3){
temp.add("关闭");
}else if(children.get(i).getMotorStatus()==4){
temp.add("准备");
}else if(children.get(i).getMotorStatus()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorStatus()==0xFF){
temp.add("无效");
}
}else{
temp.add("");
}
//驱动电机控制器温度 “0xFE”表示异常,“0xFF”表示无效 单元:℃ 范围:-40至210
if(null!=children.get(i).getMotorControlTemp()){
if(children.get(i).getMotorControlTemp()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorControlTemp()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorControlTemp(),-40,210));
}
}else{
temp.add("");
}
//驱动电机转速 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:rmin 范围:-20000至45531
if(null!=children.get(i).getMotorSpeed()){
if(children.get(i).getMotorSpeed()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorSpeed()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorSpeed(),-20000,45531));
}
}else{
temp.add("");
}
//驱动电机转矩 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:Nm 范围:-2000至4553.1
if(null!=children.get(i).getMotorTorque()){
if(children.get(i).getMotorTorque()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorTorque()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorTorque(),-2000.0,4553.1));
}
}else{
temp.add("");
}
//驱动电机温度 “0xFE”表示异常,“0xFF”表示无效 单元:℃ 范围:-40至210
if(null!=children.get(i).getMotorTemp()){
if(children.get(i).getMotorTemp()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorTemp()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorTemp(),-40,210));
}
}else{
temp.add("");
}
//电机控制器输入电压 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:V 范围:0至6000
if(null!=children.get(i).getMotorControlVoltage()){
if(children.get(i).getMotorControlVoltage()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorControlVoltage()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorControlVoltage(),0.0,6000.0));
}
}else{
temp.add("");
}
//电机控制器直流母线电流 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:A 范围:-1000至1000
if(null!=children.get(i).getMotorControlCurrent()){
if(children.get(i).getMotorControlCurrent()==0xFE){
temp.add("异常");
}else if(children.get(i).getMotorControlCurrent()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(children.get(i).getMotorControlCurrent(),-1000.0,1000.0));
}
}else{
temp.add("");
}
sheet.addData(temp);
}
}
}
/**
* 2016-12-20 燃料电池信息
* @param sheet
* @param carHistory
* @param dateTime
* @throws Exception
*/
private static void fuelCellsRecord(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type) throws Exception{
FuelCellsPacket fuelCellsPacket = carHistory.getFuelCellsRecord();
if (null != fuelCellsPacket) {
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(fuelCellsPacket.getVoltage(),0.0,2000.0));
temp.add(checkValue(fuelCellsPacket.getCurrent(),0.0,2000.0));
temp.add(checkValue(fuelCellsPacket.getFuelUse(),0.0,600.0));
temp.add(checkValue(fuelCellsPacket.getTempProbeNum(),0,65531));
temp.add(checkValue(fuelCellsPacket.getProbeTempList()));
temp.add(checkValue(fuelCellsPacket.getHyHighestTemp(),-40.0,200.0));
temp.add(checkValue(fuelCellsPacket.getHyHighestTempProbeNo()));
temp.add(checkValue(fuelCellsPacket.getHyHighestThickness(),0,60000));
temp.add(checkValue(fuelCellsPacket.getHyHighestThicknessNo()));
temp.add(checkValue(fuelCellsPacket.getHyHighestPressure(),0.0,100.0));
temp.add(checkValue(fuelCellsPacket.getHyHighestPressureNo()));
if(null!=fuelCellsPacket.getDcStatus()){
if(fuelCellsPacket.getDcStatus()==0){
temp.add("工作");
}else if(fuelCellsPacket.getDcStatus()==1){
temp.add("断开");
}
}else{
temp.add("");
}
sheet.addData(temp);
}
}
private static void motorPacket(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type) throws Exception{
MotorPacket motorPacket = carHistory.getMotorPacket();
if (null != motorPacket) {
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
//motorStatus int 发动机状态 0x01:启动状态;0x02:关闭状态,“0xFE”表示异常,“0xFF”表示无效
if(null!=motorPacket.getMotorStatus()){
if(motorPacket.getMotorStatus()==1){
temp.add("启动");
}else if(motorPacket.getMotorStatus()==2){
temp.add("关闭");
}else if(motorPacket.getMotorStatus()==0xFE){
temp.add("异常");
}else if(motorPacket.getMotorStatus()==0xFF){
temp.add("无效");
}
}else{
temp.add("");
}
//crankshaftSpeed int 曲轴转速 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:rpm 范围:0至60000
if(null!=motorPacket.getCrankshaftSpeed()){
if(motorPacket.getCrankshaftSpeed()==0xFE){
temp.add("异常");
}else if(motorPacket.getCrankshaftSpeed()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(motorPacket.getCrankshaftSpeed(),0,60000));
}
}else{
temp.add("");
}
//fuelUse double 燃料消耗率 “0xFF,0xFE”表示异常,“0xFF,0xFF”表示无效 单元:L100km 范围:0至600
if(null!=motorPacket.getFuelUse()){
if(motorPacket.getFuelUse()==0xFE){
temp.add("异常");
}else if(motorPacket.getFuelUse()==0xFF){
temp.add("无效");
}else{
temp.add(checkValue(motorPacket.getFuelUse(),0.0,600.0));
}
}else{
temp.add("");
}
sheet.addData(temp);
}
}
/**
* 2016-12-20新增
* @param sheet
* @param carWarn
* @param dateTime
*/
private static void carWarnCommon(ExcelSheet sheet,CarWarnPacket carWarn ,String dateTime,String receiveTime,String type){
CarWarnCommonPacket carWarnCommon = carWarn.getCommonWarn();
if(carWarnCommon!=null){
List temp = new ArrayList();
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(carWarn.getWarnLevel());
if (carWarnCommon.getTempDiff() != null) {
if (carWarnCommon.getTempDiff()==0) {
temp.add("正常");
} else if (carWarnCommon.getTempDiff()==1) {
temp.add("温度差异报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getHighTemp() != null) {
if (carWarnCommon.getHighTemp()==0) {
temp.add("正常");
} else if (carWarnCommon.getHighTemp()==1) {
temp.add("电池差异报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getEnergyDeviceOverVoltage() != null) {
if (carWarnCommon.getEnergyDeviceOverVoltage()==0) {
temp.add("正常");
} else if (carWarnCommon.getEnergyDeviceOverVoltage()==1) {
temp.add("车载储能装置类型过压报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getEnergyDeviceUnderVoltage() != null) {
if (carWarnCommon.getEnergyDeviceUnderVoltage()==0) {
temp.add("正常");
} else if (carWarnCommon.getEnergyDeviceUnderVoltage()==1) {
temp.add("车载储能装置类型欠压报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSocLow() != null) {
if (carWarnCommon.getSocLow()==0) {
temp.add("正常");
} else if (carWarnCommon.getSocLow()==1) {
temp.add("SOC低报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSingleCellOverVoltage() != null) {
if (carWarnCommon.getSingleCellOverVoltage()==0) {
temp.add("正常");
} else if (carWarnCommon.getSingleCellOverVoltage()==1) {
temp.add("单体电池过压报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSingleCellUnderVoltage() != null) {
if (carWarnCommon.getSingleCellUnderVoltage()==0) {
temp.add("正常");
} else if (carWarnCommon.getSingleCellUnderVoltage()==1) {
temp.add("单体电池欠压报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSocHigh() != null) {
if (carWarnCommon.getSocHigh()==0) {
temp.add("正常");
} else if (carWarnCommon.getSocHigh()==1) {
temp.add("SOC过高报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSocHop() != null) {
if (carWarnCommon.getSocHop()==0) {
temp.add("正常");
} else if (carWarnCommon.getSocHop()==1) {
temp.add("SOC跳变报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getEnergyDeviceNoMatch() != null) {
if (carWarnCommon.getEnergyDeviceNoMatch()==0) {
temp.add("正常");
} else if (carWarnCommon.getEnergyDeviceNoMatch()==1) {
temp.add("可充电储能系统不匹配报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getSingleCellLowMatch() != null) {
if (carWarnCommon.getSingleCellLowMatch()==0) {
temp.add("正常");
} else if (carWarnCommon.getSingleCellLowMatch()==1) {
temp.add("电池单体一致性差报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getInsulation() != null) {
if (carWarnCommon.getInsulation()==0) {
temp.add("正常");
} else if (carWarnCommon.getInsulation()==1) {
temp.add("绝缘报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getDcTemp() != null) {
if (carWarnCommon.getDcTemp()==0) {
temp.add("正常");
} else if (carWarnCommon.getDcTemp()==1) {
temp.add("DC-DC温度报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getBrakeSys() != null) {
if (carWarnCommon.getBrakeSys()==0) {
temp.add("正常");
} else if (carWarnCommon.getBrakeSys()==1) {
temp.add("D制动系统报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getDcStatus() != null) {
if (carWarnCommon.getDcStatus()==0) {
temp.add("正常");
} else if (carWarnCommon.getDcStatus()==1) {
temp.add("DC-DC状态报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getMotorControlTemp() != null) {
if (carWarnCommon.getDcStatus()==0) {
temp.add("正常");
} else if (carWarnCommon.getMotorControlTemp()==1) {
temp.add("驱动电机控制器温度报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getHighVoltageEachLock() != null) {
if (carWarnCommon.getHighVoltageEachLock()==0) {
temp.add("正常");
} else if (carWarnCommon.getHighVoltageEachLock()==1) {
temp.add("高压互锁状态报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getMotorTemp() != null) {
if (carWarnCommon.getMotorTemp()==0) {
temp.add("正常");
} else if (carWarnCommon.getMotorTemp()==1) {
temp.add("驱动电机温度报警");
}
} else {
temp.add("");
}
if (carWarnCommon.getEnergyDeviceOverCharge() != null) {
if (carWarnCommon.getEnergyDeviceOverCharge()==0) {
temp.add("正常");
} else if (carWarnCommon.getEnergyDeviceOverCharge()==1) {
temp.add("车载储能装置类型过充");
}
} else {
temp.add("");
}
sheet.addData(temp);
}
}
/**
* 2016-12-21新增 可充电储能装置电压数据
* @param sheet
* @param carHistory
* @param dateTime
* @throws Exception
*/
private static void chargeDeviceVoltage(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type) throws Exception{
ChargeDeviceVoltagePacket charge=carHistory.getChargeDeviceVoltage();
if (null != charge) {
List<SingleChargeDeviceVoltagePacket> children = charge.getVoltageInfos();
for(int i=0;i<children.size();i++){
List temp = new ArrayList();
if(i==0){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(charge.getSysNum()));
}else{
addEmpty(temp, 4);
}
temp.add(children.get(i).getSysNo());
temp.add(children.get(i).getVoltage());
temp.add(children.get(i).getCurrent());
temp.add(children.get(i).getAllCellsNum());
temp.add(children.get(i).getCellsNo());
temp.add(children.get(i).getCellsNum());
temp.add(children.get(i).getVoltages());
sheet.addData(temp);
}
}
}
/**
* 2016-12-21 新增 可充电储能装置温度数据
* @param sheet
* @param carHistory
* @param dateTime
* @throws Exception
*/
private static void chargeDeviceTemp(ExcelSheet sheet,CarInfoHistoryMongo carHistory,String dateTime,String receiveTime,String type) throws Exception{
ChargeDeviceTempPacket tempPack=carHistory.getChargeDeviceTemp();
if (null != tempPack) {
List<SingleChargeDeviceTempPacket> children = tempPack.getTempInfos();
for(int i=0;i<children.size();i++){
List temp = new ArrayList();
if(i==0){
temp.add(dateTime);
temp.add(receiveTime);
temp.add(type);
temp.add(checkValue(tempPack.getSysNum()));
}else{
addEmpty(temp, 4);
}
temp.add(children.get(i).getSysNo());
temp.add(children.get(i).getProbeNum());
temp.add(children.get(i).getTemps());
sheet.addData(temp);
}
}
}
}
| true
|
d299e8b238aaa703952fcc2566b6ae7da5cad809
|
Java
|
mridul090/My-JAVA-Project-Office-management-system-
|
/src/General_LogIn.java
|
UTF-8
| 4,633
| 2.40625
| 2
|
[] |
no_license
|
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.jar.Attributes.Name;
import javax.lang.model.element.Element;
import javax.swing.*;
import org.w3c.dom.css.ElementCSSInlineStyle;
public class General_LogIn{
JFrame j;
String pass="";
String PassWord;
String name,Id;
General_LogIn(){
j = new JFrame();
j.setSize(560,417);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.getContentPane().setLayout(null);
JLabel p1= new JLabel("Name:");
p1.setBounds(56,104,100,30);
p1.setFont(new Font("Tahoma", Font.BOLD, 20));
j.getContentPane().add(p1);
JTextField t1= new JTextField(30);
t1.setBounds(185,93,200,30);
j.getContentPane().add(t1);
JLabel p2= new JLabel("Password:");
p2.setBounds(43,180,117,39);
p2.setFont(new Font("Tahoma", Font.BOLD, 20));
j.getContentPane().add(p2);
JPasswordField pasw = new JPasswordField(30);
pasw.setBounds(185,188,200,30);
j.getContentPane().add(pasw);
JLabel p3= new JLabel("or,cread new Account;");
p3.setBounds(185,227,200,39);
p3.setFont(new Font("Tahoma", Font.BOLD, 12));
j.getContentPane().add(p3);
JButton b1 = new JButton("Login");
b1.setBounds(75,277,100,50);
b1.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 16));
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
MainProfile profile = new MainProfile();
try {
FileReader R= new FileReader("ID.txt");
FileReader R1= new FileReader("Password.txt");
BufferedReader bReader = new BufferedReader(R);
BufferedReader bReader1 = new BufferedReader(R1);
name = bReader.readLine();
String pass1 = bReader1.readLine();
Id = t1.getText().trim();
PassWord = pasw.getText().trim();
while(name!=null && pass1!= null){
String[] aStrings = pass1.split("");
for(int i=0;i<aStrings.length;i++){
int a = Integer.parseInt(aStrings[i]);
int b = a-1;
pass += b;
}
if((!Id.equals("")&& !Id.equals(" ")) && (!PassWord.equals("") && !PassWord.equals(" ")))
{
//System.out.println("pass"+pass+"PassWord"+PassWord);
if((Id.equals(name)) && (PassWord.equals(pass))){
profile.showingMainProfile(name);
j.dispose();
}
}
else {
JOptionPane.showMessageDialog(null, "Faild to loge in");
}
name = bReader.readLine();
pass1 = bReader1.readLine();
pass="";
}
System.out.println(name);
System.out.println(pass);
System.out.println(PassWord);
}
catch (IOException e1) {
System.out.println("The file location is not found");
e1.printStackTrace();
}
}
});
j.getContentPane().add(b1);
JButton b2 = new JButton("Create an account");
b2.setBounds(185,277,200,50);
b2.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 16));
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
new Creat_An_Account();
j.dispose();
}
});
j.getContentPane().add(b2);
JLabel lblNewLabel = new JLabel("Welcom To Office Monitoring Apps @2017");
lblNewLabel.setBackground(Color.LIGHT_GRAY);
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setFont(new Font("Rockwell Extra Bold", Font.BOLD | Font.ITALIC, 18));
lblNewLabel.setBounds(43, 54, 490, 39);
j.getContentPane().add(lblNewLabel);
JMenuBar menuBar = new JMenuBar();
menuBar.setBounds(0, 0, 544, 21);
j.getContentPane().add(menuBar);
JMenu mnNewMenu = new JMenu("Options");
menuBar.add(mnNewMenu);
JMenuItem mntmAdminLogein = new JMenuItem("Admin LogeIn");
mnNewMenu.add(mntmAdminLogein);
mntmAdminLogein.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
Admin_Account admin_Account= new Admin_Account();
admin_Account.initialize();
j.dispose();
}
});
JMenuItem mntmExit = new JMenuItem("Exit");
mnNewMenu.add(mntmExit);
j.setVisible(true);}
}
| true
|
5ba5f842606824e2c0428ad4e2619a29acb67f60
|
Java
|
cenbow/fuxiaofengfugib
|
/cqliving-online/src/main/java/com/cqliving/cloud/online/topic/manager/TopicInfoManager.java
|
UTF-8
| 2,809
| 1.914063
| 2
|
[] |
no_license
|
package com.cqliving.cloud.online.topic.manager;
import java.util.List;
import com.cqliving.cloud.online.topic.domain.TopicInfo;
import com.cqliving.framework.common.dao.support.ScrollPage;
import com.cqliving.framework.common.service.EntityService;
/**
* 话题表 Manager
* Date: 2016-07-14 09:45:12
* @author Code Generator
*/
public interface TopicInfoManager extends EntityService<TopicInfo> {
/**
* 逻辑删除
* @param id
* @return
*/
public int deleteLogic(Long[] id);
/**
* 修改状态
* @param status 状态
* @param ids ID
* @return
*/
public int updateStatus(Byte status,Long... ids);
/**
* Title:修改置顶状态
* <p>Description:</p>
* @author DeweiLi on 2016年7月15日
* @param status
* @param id
* @param imageUrl
* @param userId
* @param userName
* @return
*/
public void updateTopStatus(Byte status,Long id, String imageUrl, Long userId, String userName);
/**
* Title:推荐到首页、取消推荐到首页
* <p>Description:</p>
* @author DeweiLi on 2016年7月18日
* @param status
* @param id
* @param imageUrl
* @return
*/
public void updateRecommendStatus(Byte status, Long id, String imageUrl);
/**
* Title:cms保存话题
* <p>Description:</p>
* @author DeweiLi on 2016年7月15日
* @param topicInfo
* @param imageUrls
*/
public void saveByAdmin(TopicInfo topicInfo, String[] imageUrls);
/**
* <p>Description: 获取置顶话题列表</p>
* @author Tangtao on 2016年7月26日
* @param appId
* @return
*/
List<TopicInfo> getTopList(Long appId);
/**
* <p>Description: 获取话题列表</p>
* @author Tangtao on 2016年7月26日
* @param scrollPage
* @param appId
* @param type
* @param name
* @param isRecommend
* @return
*/
ScrollPage<TopicInfo> queryForScrollPage(ScrollPage<TopicInfo> scrollPage, Long appId, Long type, String name, Byte isRecommend);
/**
* <p>Description: 获取我的话题列表</p>
* @author Tangtao on 2016年7月27日
* @param scrollPage
* @param appId
* @param sessionId
* @param token
* @return
*/
ScrollPage<TopicInfo> queryMyScrollPage(ScrollPage<TopicInfo> scrollPage, Long appId, String sessionId, String token);
/**
* <p>Description: 发布话题</p>
* @author Tangtao on 2016年7月27日
* @param appId
* @param sessionId
* @param token
* @param name
* @param content
* @param imgs
* @param typeIds
* @return
*/
Byte add(Long appId, String sessionId, String token, String name, String content, String imgs, String typeIds);
/**
* <p>Description: 删除我的话题</p>
* @author Tangtao on 2016年7月28日
* @param appId
* @param sessionId
* @param token
* @param id
* @return
*/
Boolean remove(Long appId, String sessionId, String token, Long id);
}
| true
|
4fc0d101229e30bc18bde012bd6b1d39b5223c4c
|
Java
|
MinorGlitch/Java-Fundamentals
|
/Java Advanced/Problems/StringProcessing - Exercises/src/SumBigNumbers.java
|
UTF-8
| 1,406
| 3.34375
| 3
|
[] |
no_license
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class SumBigNumbers {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String firstNumber = reader.readLine();
String secondNumber = reader.readLine();
if (firstNumber.length() > secondNumber.length()) {
secondNumber = String.format("%1$" + firstNumber.length() + "s", secondNumber).replace(' ', '0');
} else {
firstNumber = String.format("%1$" + secondNumber.length() + "s", firstNumber).replace(' ', '0');
}
StringBuilder sb = new StringBuilder();
int remainder = 0;
for (int i = firstNumber.length() - 1; i >= 0 ; i--) {
int sum = firstNumber.charAt(i) - 48 + secondNumber.charAt(i) - 48 + remainder;
int number = sum % 10;
remainder = sum / 10;
sb.append(number);
if (i == 0 && remainder > 0)
{
sb.append(remainder);
}
}
char[] output = sb.toString().replaceAll("0+$", "").toCharArray();
for (int i = output.length - 1; i >= 0; i--) {
char c = output[i];
System.out.print(c);
}
}
}
| true
|
b16e3a0a3ba84da97c7cb80c7f94846acdbc7a80
|
Java
|
LSCGit/AndroidDemo
|
/designpattern/src/main/java/com/lsc/designpattern/lkp/Client.java
|
UTF-8
| 487
| 2.21875
| 2
|
[] |
no_license
|
package com.lsc.designpattern.lkp;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
/**
* Created by lsc on 2020-04-18 02:39.
* E-Mail:2965219926@qq.com
*/
public class Client {
public static void main(String[] args) {
List<Girl> listGirls = new ArrayList<>();
for (int i=0;i<20;i++){
listGirls.add(new Girl());
}
Teacher teacher = new Teacher();
teacher.commond(new GroupLeader(listGirls));
}
}
| true
|
ce054d6bfb745d61ad5be7f4522cd4bc90fa0800
|
Java
|
Oskitaa/Programacion
|
/2º Trimestre/Tema 7/Tienda/src/Tienda/Tienda.java
|
UTF-8
| 1,620
| 3.0625
| 3
|
[] |
no_license
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Tienda;
import Excepcion.*;
/**
*
* @author ese_b
*/
/**
* CLASE QUE CONTIENE UNA LISTA CON LOS ARTICULOS EN VENTA EN UNA TIENDA
*
*/
public class Tienda {
/**
* Constructor al que se le pasa el nombre de la tienda y que deja la lista
* vacía
*/
public Tienda(String nombre) {
}
/**
* Añade un artículo a la lista
*/
public void inserta(Articulo a) {
}
/**
* Busca y devuelve el artículo cuyo nombre se indica. Lanza
* NoExisteException si no se encuentra.
*/
public Articulo busca(String nombre) throws NoExisteException {
return new Articulo();
}
/**
* Vende un número de unidades del artículo del nombre indicado. Para ello
* busca el articulo en la lista y usa su método vende. Si no encuentra el
* artículo lanza NoExisteException. Si la cantidad queda a cero o no hay
* cantidades suficientes, o si se ha lanzado NoDisponibleException, elimina
* el artículo de la lista. Devuelve el valor total de las unidades
* vendidas.
*/
public double vende(String nombre, int num) throws NoExisteException {
return 0;
}
/**
* Muestra por pantalla aquellos articulos de la lista de los que queden
* menos del minimo de unidades que se indica. Se escribe uno por línea, y
* cada uno con sus tres datos. / public void escribePedido(int min)
*/
}
| true
|
f11651a0ec252b5ae61aa467015fb49ef0224ad9
|
Java
|
icgeass/java
|
/src/main/java/com/zeroq6/java/middleware/zookeeper/TestZookeeperBase.java
|
UTF-8
| 2,053
| 2.640625
| 3
|
[
"Apache-2.0"
] |
permissive
|
package com.zeroq6.java.middleware.zookeeper;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
import java.util.concurrent.CountDownLatch;
/**
* @author
*/
public class TestZookeeperBase implements Watcher {
protected static CountDownLatch connectedSemaphore = new CountDownLatch(1);
protected static boolean watchAgain;
protected static ZooKeeper zk;
protected static Stat stat = new Stat();
protected void connect() {
try {
//连接zookeeper并且注册一个默认的监听器
zk = new ZooKeeper("127.0.0.1:2181", 5000, new TestZookeeperBase());
//等待zk连接成功的通知
connectedSemaphore.await();
} catch (Exception e) {
e.printStackTrace();
} finally {
System.out.println("-------------------");
}
}
public void process(WatchedEvent event) {
System.out.println("EventType=" + event.getType().name());
System.out.println("KeeperState=" + event.getState().name());
if (KeeperState.SyncConnected == event.getState()) { //zk连接成功通知事件
if (EventType.None == event.getType() && null == event.getPath()) {
connectedSemaphore.countDown();
} else if (event.getType() == EventType.NodeDataChanged) { //zk目录节点数据变化通知事件
try {
if (watchAgain) {
System.out.println("配置已修改,新值为:" + new String(zk.getData(event.getPath(), true, stat)));
} else {
System.out.println("配置已修改,路径为:" + event.getPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
| true
|
a4550c191b5e274602225e185d5e6cc439d82c57
|
Java
|
Peanut-Butter-OSS/pboss-ccm-src
|
/pboss-ccm-model/src/main/java/org/pboss/ccm/model/api/request/ApiCredentials.java
|
UTF-8
| 907
| 2
| 2
|
[
"Apache-2.0"
] |
permissive
|
/**
*
*/
package org.pboss.ccm.model.api.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* @author gregf
*
*/
@JsonTypeName("api_credentials")
@JsonInclude(Include.NON_NULL)
public class ApiCredentials {
@JsonProperty("account_name")
private String accountName;
@JsonProperty("api_key")
private String apiKey;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
@Override
public String toString() {
return "ApiCredentials [accountName=" + accountName + ", apiKey=" + apiKey + "]";
}
}
| true
|