blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2
values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 7 5.41M | extension stringclasses 11
values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f7d2a5bd0d9ad49b3f77e002958f8a1d96d19a67 | 4d3124f71d73d11dc156ddc2eac8e698280812ea | /src/com/class28/Vehicle.java | 508b8405f34b53c70f7785c3834eb7fe91068583 | [] | no_license | raafatali/JavaClass | 4937b8209d8699021b79fe96b52b2c63c1fcef4f | 00a79baf4dffb081ae73fcac0bb38c9eafb2e0b1 | refs/heads/master | 2020-05-03T00:09:22.516760 | 2019-05-03T02:01:15 | 2019-05-03T02:01:15 | 178,302,011 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,886 | java | package com.class28;
public abstract class Vehicle {
static int vehicleCount;
Vehicle() {
vehicleCount++;
}
// public static abstract void gps(); cannot have abstract methods as static
// (cannot override static)
// private abstract void speed();cannot have abstract methods as private (do not
// part of inheritance)
// public abstract final void break();cannot have abstract methods as final
// (cannot override)
public abstract void start();
public abstract void drive();
public void stop() {
System.out.println("Stop vehicle by pressing break");
}
public static void displayTotalVehicles() {
System.out.println("Total vehicles we build=" + vehicleCount);
}
}
abstract class Car extends Vehicle {
/*
* by default compiler will create a default constructor and by default inside
* the child constructor we call a parent class constructor
*
* Car(){ super();//added by default }
*/
public String make;// instance variables allowed in the abstract class
// we cannot create an Object of abstract class, but since we have an instance
// variables
// inside the class we need someone to initialize them--> performed by
// constructor
Car(String make) {
this.make = make;
}
}
class BMW extends Car {
/*
* by default compiler will create a default constructor and by default inside
* the child constructor we call a parent class constructor BMW(){ super(); }
*/
BMW(String make) {
super(make);
}
@Override
public void start() {
System.out.println("BMW car starts remote");
}
@Override
public void drive() {
System.out.println("BMW car drives fast");
}
}
class Toyota extends Car {
Toyota(String make) {
super(make);
}
@Override
public void start() {
System.out.println("Toyota car starts with push button");
}
@Override
public void drive() {
System.out.println("Toyota car drives safe");
}
}
| [
"rafattareq90@gmail.com"
] | rafattareq90@gmail.com |
106059fec81a49115f914d48974a4cf91bd0f834 | a9fb5d1d81f888a2d7dfff011ba6e61167f67cac | /it/src/main/java/testcases/T006_custom_qualifier_with_fields/CustomQualifier.java | 1ef9d8d0e68f8aaf1787dc5144eef02d2eabf489 | [
"Apache-2.0"
] | permissive | runningcode/motif | 0caa73b99491bbf96e66ae713e78022dd8c6773e | a18c9ebbea7b12f2feeee843bfe2370aac63884e | refs/heads/master | 2020-03-26T12:36:04.126256 | 2018-08-15T06:30:23 | 2018-08-15T19:35:05 | 144,900,253 | 0 | 0 | Apache-2.0 | 2018-08-15T20:28:58 | 2018-08-15T20:28:58 | null | UTF-8 | Java | false | false | 790 | java | /*
* Copyright (c) 2018 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package testcases.T006_custom_qualifier_with_fields;
import javax.inject.Qualifier;
@Qualifier
public @interface CustomQualifier {
String first();
String second();
}
| [
"leland@uber.com"
] | leland@uber.com |
7e476084beaf85f327ccdf05e5697326d31d11f0 | 8af867e47d4e3e33ffcee08feb09b3475fef30ee | /src/viewer/practicalExamDetails.java | 37d549b1c78a45e2ae40146b9bed933cd76cda8f | [] | no_license | TricanSolutions/VL2020 | 851d8d3225df2bfa04f18a4f735e54e60fb685d3 | 70ad28f91f644c9501c2768aa3ad17a87488985a | refs/heads/master | 2023-02-09T17:58:12.160869 | 2021-01-02T09:56:31 | 2021-01-02T09:56:31 | 300,795,196 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 50,625 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package viewer;
import com.Messages;
import com.userstatus;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Lasitha Ranawaka
*/
public class practicalExamDetails extends javax.swing.JDialog {
/**
* Creates new form template
*/
public practicalExamDetails(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
loadtabl();
txtadmissiono.grabFocus();
txtadmissiono.selectAll();
}
practicalExamDetails(String adno, String name, int id, boolean b) {
initComponents();
txtadmissiono.grabFocus();
txtadmissiono.selectAll();
// txtexamdate.grabFocus();
txtadmissiono.setText(adno);
txtname.setText(name);
cusid = id;
System.out.println(cusid);
loadtabl();
}
int cusid;
int writtenexamid;
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
txtadmissiono = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
txtname = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
txt_findByDMTBarcode = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tbl = new javax.swing.JTable();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
txtid = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtexamdate = new javax.swing.JFormattedTextField();
lbla = new javax.swing.JLabel();
cmba = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();
lblb = new javax.swing.JLabel();
cmbb = new javax.swing.JComboBox();
lblb1 = new javax.swing.JLabel();
cmbb1 = new javax.swing.JComboBox();
lblg = new javax.swing.JLabel();
cmbg = new javax.swing.JComboBox();
lbld = new javax.swing.JLabel();
cmbd = new javax.swing.JComboBox();
lblce = new javax.swing.JLabel();
cmbce = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
cmboptionall = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setBackground(new java.awt.Color(255, 51, 51));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 51));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Practical Exam Details");
jLabel1.setOpaque(true);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Search"));
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 153, 0));
jLabel3.setText("By Admission No");
txtadmissiono.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtadmissiono.setForeground(new java.awt.Color(0, 0, 204));
txtadmissiono.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtadmissionoActionPerformed(evt);
}
});
txtadmissiono.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtadmissionoKeyPressed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(0, 153, 0));
jLabel4.setText("Name");
txtname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtname.setForeground(new java.awt.Color(0, 0, 204));
jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton2.setForeground(new java.awt.Color(153, 0, 153));
jButton2.setText("Find");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel7.setForeground(new java.awt.Color(0, 153, 0));
jLabel7.setText("By DMT Barcode");
txt_findByDMTBarcode.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txt_findByDMTBarcode.setForeground(new java.awt.Color(0, 0, 204));
txt_findByDMTBarcode.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txt_findByDMTBarcodeKeyPressed(evt);
}
});
jButton3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton3.setForeground(new java.awt.Color(153, 0, 153));
jButton3.setText("Find");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(txtadmissiono, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(18, 18, 18)
.addComponent(txt_findByDMTBarcode)))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(164, 164, 164)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(txtname)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtadmissiono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txt_findByDMTBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3))
.addContainerGap(31, Short.MAX_VALUE))
);
tbl.setFont(new java.awt.Font("Times New Roman", 0, 16)); // NOI18N
tbl.setForeground(new java.awt.Color(0, 0, 204));
tbl.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ID", "Date", "A", "Status(A)", "B", "Status(B)", "B1", "Status(B1)", "G", "Status(G)", "D", "Status(D)", "CE", "Status(CE)"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false, false, false, false, true, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
tbl.getTableHeader().setReorderingAllowed(false);
tbl.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
tblMouseClicked(evt);
}
});
jScrollPane1.setViewportView(tbl);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Add Details"));
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel5.setForeground(new java.awt.Color(0, 153, 51));
jLabel5.setText("ID");
txtid.setEditable(false);
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel6.setForeground(new java.awt.Color(0, 153, 51));
jLabel6.setText("Exam Date");
txtexamdate.setForeground(new java.awt.Color(0, 0, 204));
try {
txtexamdate.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-##-##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
txtexamdate.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtexamdate.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtexamdateKeyPressed(evt);
}
});
lbla.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lbla.setForeground(new java.awt.Color(0, 0, 102));
lbla.setText("A");
cmba.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmba.setForeground(new java.awt.Color(153, 0, 153));
cmba.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmba.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbaKeyPressed(evt);
}
});
jButton1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButton1.setForeground(new java.awt.Color(204, 0, 0));
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
lblb.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblb.setForeground(new java.awt.Color(0, 0, 102));
lblb.setText("B");
cmbb.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmbb.setForeground(new java.awt.Color(153, 0, 153));
cmbb.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmbb.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbbKeyPressed(evt);
}
});
lblb1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblb1.setForeground(new java.awt.Color(0, 0, 102));
lblb1.setText("B1");
cmbb1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmbb1.setForeground(new java.awt.Color(153, 0, 153));
cmbb1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmbb1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbb1KeyPressed(evt);
}
});
lblg.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblg.setForeground(new java.awt.Color(0, 0, 102));
lblg.setText("G");
cmbg.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmbg.setForeground(new java.awt.Color(153, 0, 153));
cmbg.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmbg.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbgKeyPressed(evt);
}
});
lbld.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lbld.setForeground(new java.awt.Color(0, 0, 102));
lbld.setText("D");
cmbd.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmbd.setForeground(new java.awt.Color(153, 0, 153));
cmbd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmbd.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbdKeyPressed(evt);
}
});
lblce.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblce.setForeground(new java.awt.Color(0, 0, 102));
lblce.setText("CE");
cmbce.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmbce.setForeground(new java.awt.Color(153, 0, 153));
cmbce.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmbce.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
cmbceKeyPressed(evt);
}
});
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 153, 51));
jLabel2.setText("Select for All");
cmboptionall.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
cmboptionall.setForeground(new java.awt.Color(0, 0, 204));
cmboptionall.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select--", "None", "Waiting", "Pass", "Fail", "Absent", "Cancel" }));
cmboptionall.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
cmboptionallMouseClicked(evt);
}
});
cmboptionall.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cmboptionallItemStateChanged(evt);
}
});
cmboptionall.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmboptionallActionPerformed(evt);
}
});
cmboptionall.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
cmboptionallPropertyChange(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(txtid))
.addComponent(jLabel2))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(cmboptionall, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel6)
.addGap(18, 18, 18)
.addComponent(txtexamdate, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(lbla)
.addGap(18, 18, 18)
.addComponent(cmba, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(lblb)
.addGap(18, 18, 18)
.addComponent(cmbb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lblb1)
.addGap(18, 18, 18)
.addComponent(cmbb1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblg)
.addGap(18, 18, 18)
.addComponent(cmbg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lbld)
.addGap(18, 18, 18)
.addComponent(cmbd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lblce)
.addGap(18, 18, 18)
.addComponent(cmbce, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(96, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbld)
.addComponent(cmbd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblg)
.addComponent(cmbg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblb1)
.addComponent(cmbb1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblce)
.addComponent(cmbce, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(txtexamdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbla)
.addComponent(cmba, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblb)
.addComponent(cmbb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(cmboptionall, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
submit();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
loadtabl();
}//GEN-LAST:event_jButton2ActionPerformed
private void tblMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblMouseClicked
DefaultTableModel dtm = (DefaultTableModel) tbl.getModel();
writtenexamid = Integer.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 0).toString());
txtid.setText(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 0)));
txtexamdate.setText(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 1)));
cmba.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 3)));
cmbb.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 5)));
cmbb1.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 7)));
cmbg.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 9)));
cmbd.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 11)));
cmbce.setSelectedItem(String.valueOf(dtm.getValueAt(tbl.getSelectedRow(), 13)));
}//GEN-LAST:event_tblMouseClicked
private void txtadmissionoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtadmissionoActionPerformed
}//GEN-LAST:event_txtadmissionoActionPerformed
private void txtadmissionoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtadmissionoKeyPressed
if (evt.getKeyCode() == 10) {
loadtabl();
txtexamdate.grabFocus();
}
}//GEN-LAST:event_txtadmissionoKeyPressed
private void txtexamdateKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtexamdateKeyPressed
if (evt.getKeyCode() == 10) {
cmba.grabFocus();
}
}//GEN-LAST:event_txtexamdateKeyPressed
private void cmbaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbaKeyPressed
if (evt.getKeyCode() == 10) {
cmbb.grabFocus();
}
}//GEN-LAST:event_cmbaKeyPressed
private void cmbbKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbbKeyPressed
if (evt.getKeyCode() == 10) {
cmbb1.grabFocus();
}
}//GEN-LAST:event_cmbbKeyPressed
private void cmbb1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbb1KeyPressed
if (evt.getKeyCode() == 10) {
cmbg.grabFocus();
}
}//GEN-LAST:event_cmbb1KeyPressed
private void cmbgKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbgKeyPressed
if (evt.getKeyCode() == 10) {
cmbd.grabFocus();
}
}//GEN-LAST:event_cmbgKeyPressed
private void cmbdKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbdKeyPressed
if (evt.getKeyCode() == 10) {
cmbce.grabFocus();
}
}//GEN-LAST:event_cmbdKeyPressed
private void cmbceKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbceKeyPressed
if (evt.getKeyCode() == 10) {
submit();
}
}//GEN-LAST:event_cmbceKeyPressed
private void cmboptionallItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmboptionallItemStateChanged
if (cmboptionall.getSelectedIndex() == 1) {
cmba.setSelectedIndex(1);
cmbb.setSelectedIndex(1);
cmbb1.setSelectedIndex(1);
cmbce.setSelectedIndex(1);
cmbd.setSelectedIndex(1);
cmbg.setSelectedIndex(1);
} else if (cmboptionall.getSelectedIndex() == 2) {
cmba.setSelectedIndex(2);
cmbb.setSelectedIndex(2);
cmbb1.setSelectedIndex(2);
cmbce.setSelectedIndex(2);
cmbd.setSelectedIndex(2);
cmbg.setSelectedIndex(2);
} else if (cmboptionall.getSelectedIndex() == 3) {
cmba.setSelectedIndex(3);
cmbb.setSelectedIndex(3);
cmbb1.setSelectedIndex(3);
cmbce.setSelectedIndex(3);
cmbd.setSelectedIndex(3);
cmbg.setSelectedIndex(3);
} else if (cmboptionall.getSelectedIndex() == 4) {
cmba.setSelectedIndex(4);
cmbb.setSelectedIndex(4);
cmbb1.setSelectedIndex(4);
cmbce.setSelectedIndex(4);
cmbd.setSelectedIndex(4);
cmbg.setSelectedIndex(4);
} else if (cmboptionall.getSelectedIndex() == 5) {
cmba.setSelectedIndex(5);
cmbb.setSelectedIndex(5);
cmbb1.setSelectedIndex(5);
cmbce.setSelectedIndex(5);
cmbd.setSelectedIndex(5);
cmbg.setSelectedIndex(5);
} else if (cmboptionall.getSelectedIndex() == 6) {
cmba.setSelectedIndex(6);
cmbb.setSelectedIndex(6);
cmbb1.setSelectedIndex(6);
cmbce.setSelectedIndex(6);
cmbd.setSelectedIndex(6);
cmbg.setSelectedIndex(6);
}
}//GEN-LAST:event_cmboptionallItemStateChanged
private void cmboptionallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmboptionallActionPerformed
}//GEN-LAST:event_cmboptionallActionPerformed
private void cmboptionallPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_cmboptionallPropertyChange
// TODO add your handling code here:
}//GEN-LAST:event_cmboptionallPropertyChange
private void cmboptionallMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmboptionallMouseClicked
}//GEN-LAST:event_cmboptionallMouseClicked
private void txt_findByDMTBarcodeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_findByDMTBarcodeKeyPressed
if (evt.getKeyCode() == 10) {
findbyDMTBarcode();
}
}//GEN-LAST:event_txt_findByDMTBarcodeKeyPressed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
findbyDMTBarcode();
}//GEN-LAST:event_jButton3ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(practicalExamDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(practicalExamDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(practicalExamDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(practicalExamDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
practicalExamDetails dialog = new practicalExamDetails(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox cmba;
private javax.swing.JComboBox cmbb;
private javax.swing.JComboBox cmbb1;
private javax.swing.JComboBox cmbce;
private javax.swing.JComboBox cmbd;
private javax.swing.JComboBox cmbg;
private javax.swing.JComboBox cmboptionall;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
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.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lbla;
private javax.swing.JLabel lblb;
private javax.swing.JLabel lblb1;
private javax.swing.JLabel lblce;
private javax.swing.JLabel lbld;
private javax.swing.JLabel lblg;
private javax.swing.JTable tbl;
private javax.swing.JTextField txt_findByDMTBarcode;
private javax.swing.JTextField txtadmissiono;
private javax.swing.JFormattedTextField txtexamdate;
private javax.swing.JTextField txtid;
private javax.swing.JTextField txtname;
// End of variables declaration//GEN-END:variables
private void loadtabl() {
DefaultTableModel dtm = (DefaultTableModel) tbl.getModel();
dtm.setRowCount(0);
try {
ResultSet rs = model.db.getData("SELECT\n"
+ "practicalexam.id,\n"
+ "practicalexam.customer_register_id,\n"
+ "practicalexam.examDate,\n"
+ "practicalexam.a,\n"
+ "practicalexam.a_pass_or_fail,\n"
+ "practicalexam.b,\n"
+ "practicalexam.b_pass_or_fail,\n"
+ "practicalexam.bone,\n"
+ "practicalexam.bone_pass_or_fail,\n"
+ "practicalexam.g,\n"
+ "practicalexam.g_pass_or_fail,\n"
+ "practicalexam.d,\n"
+ "practicalexam.d_pass_or_fail,\n"
+ "practicalexam.ce,\n"
+ "practicalexam.ce_pass_or_fail,\n"
+ "uniquecustomerdetails.namewithinitial\n"
+ "FROM\n"
+ "practicalexam\n"
+ "INNER JOIN customer_register ON practicalexam.customer_register_id = customer_register.id\n"
+ "INNER JOIN uniquecustomerdetails ON customer_register.uniqueCustomerDetails_id = uniquecustomerdetails.id\n"
+ "WHERE\n"
+ "customer_register.admission_no = '" + txtadmissiono.getText() + "'");
while (rs.next()) {
txtname.setText(rs.getString(16));
int id = rs.getInt(1);
String date = rs.getString(3);
String a = rs.getString(4);
String apass = rs.getString(5);
String b = rs.getString(6);
String bpass = rs.getString(7);
String b1 = rs.getString(8);
String b1pass = rs.getString(9);
String g = rs.getString(10);
String gpass = rs.getString(11);
String d = rs.getString(12);
String dpass = rs.getString(13);
String ce = rs.getString(14);
String cepass = rs.getString(15);
Object o[] = {id, date, a, apass, b, bpass, b1, b1pass, g, gpass, d, dpass, ce, cepass};
dtm.addRow(o);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
ResultSet rs = model.db.getData("SELECT\n"
+ "customer_register.id,\n"
+ "uniquecustomerdetails.namewithinitial\n"
+ "FROM\n"
+ "customer_register\n"
+ "INNER JOIN uniquecustomerdetails ON customer_register.uniqueCustomerDetails_id = uniquecustomerdetails.id\n"
+ "WHERE\n"
+ "customer_register.admission_no = '" + txtadmissiono.getText().trim() + "'");
while (rs.next()) {
txtname.setText(rs.getString(2));
cusid = rs.getInt(1);
}
} catch (Exception e) {
e.printStackTrace();
}
// try {
// ResultSet rs = model.db.getData("SELECT\n"
// + "customer_register.vehicle_class\n"
// + "FROM\n"
// + "customer_register\n"
// + "WHERE\n"
// + "customer_register.admission_no = '" + txtadmissiono.getText().trim() + "'");
//
// while(rs.next()) {
// String vclass = rs.getString(1);
// String x1= vclass.substring(0);
// String x2 = vclass.substring(1);
// String x3 = vclass.substring(2);
//
// Messages.normaljoption(x1);
//
//
// }
//
// } catch (Exception e) {
// e.printStackTrace();
//
// }
txtexamdate.grabFocus();
}
private void clear() {
txtid.setText("");
txtexamdate.setText("");
cmba.setSelectedIndex(0);
cmbb.setSelectedIndex(0);
cmbb1.setSelectedIndex(0);
cmbce.setSelectedIndex(0);
cmbd.setSelectedIndex(0);
cmbg.setSelectedIndex(0);
}
String n;
private void submit() {
saveandothers();
}
private void saveandothers() {
if (cmba.getSelectedIndex() == 1) {
n = "";
} else {
n = lbla.getText();
}
if (cmbb.getSelectedIndex() == 1) {
n = "";
} else {
n = lblb.getText();
}
if (cmbb1.getSelectedIndex() == 1) {
n = "";
} else {
n = lblb1.getText();
}
if (cmbg.getSelectedIndex() == 1) {
n = "";
} else {
n = lblg.getText();
}
if (cmbd.getSelectedIndex() == 1) {
n = "";
} else {
n = lbld.getText();
}
if (cmbce.getSelectedIndex() == 1) {
n = "";
} else {
n = lblce.getText();
}
if (cmba.getSelectedIndex() == 0) {
com.Messages.errorjoption("Select Vehicle class!");
cmba.grabFocus();
return;
} else if (cmbb.getSelectedIndex() == 0) {
Messages.errorjoption("Select Vehicle class!");
cmbb.grabFocus();
return;
} else if (cmbb1.getSelectedIndex() == 0) {
Messages.errorjoption("Select Vehicle class!");
cmbb1.grabFocus();
return;
} else if (cmbg.getSelectedIndex() == 0) {
Messages.errorjoption("Select Vehicle class!");
cmbg.grabFocus();
return;
} else if (cmbd.getSelectedIndex() == 0) {
Messages.errorjoption("Select Vehicle class!");
cmbd.grabFocus();
return;
} else if (cmbce.getSelectedIndex() == 0) {
Messages.errorjoption("Select Vehicle class!");
cmbce.grabFocus();
return;
} else {
if (txtid.getText().isEmpty()) {
if (!isDateExist()) {
try {
model.db.putData("INSERT INTO practicalexam(customer_register_id,examDate,a,a_pass_or_fail,b,b_pass_or_fail,bone,bone_pass_or_fail,"
+ "g,g_pass_or_fail,d,d_pass_or_fail,ce,ce_pass_or_fail)"
+ "values('" + cusid + "','" + txtexamdate.getText() + "','" + lbla.getText() + "','" + cmba.getSelectedItem() + "',"
+ "'" + lblb.getText() + "','" + cmbb.getSelectedItem() + "','" + lblb1.getText() + "','" + cmbb1.getSelectedItem() + "',"
+ "'" + lblg.getText() + "','" + cmbg.getSelectedItem() + "','" + lbld.getText() + "','" + cmbd.getSelectedItem() + "',"
+ "'" + lblce.getText() + "','" + cmbce.getSelectedItem() + "')");
model.db.putData("INSERT INTO log(date,description,username)values(NOW(),'" + "Practicla exam add" + "',"
+ "'" + userstatus.LodUser + "')");
com.Messages.normaljoption("Data Saved!");
sendsms();
loadtabl();
} catch (Exception e) {
e.printStackTrace();
}
} else {
com.Messages.errorjoption("Date is already exist");
}
} else {
try {
model.db.putData("UPDATE practicalexam set examDate='" + txtexamdate.getText() + "',"
+ "a_pass_or_fail='" + cmba.getSelectedItem() + "',b_pass_or_fail='" + cmbb.getSelectedItem() + "',"
+ "bone_pass_or_fail='" + cmbb1.getSelectedItem() + "',g_pass_or_fail='" + cmbg.getSelectedItem() + "',"
+ "d_pass_or_fail='" + cmbd.getSelectedItem() + "',ce_pass_or_fail='" + cmbce.getSelectedItem() + "',"
+ "a='" + lbla.getText() + "',b='" + lblb.getText() + "',bone='" + lblb1.getText() + "',g='" + lblg.getText() + "',d='" + lbld.getText() + "',"
+ "ce='" + lblce.getText() + "' "
+ "WHERE id='" + txtid.getText() + "' ");
model.db.putData("INSERT INTO log(date,description,username)values(NOW(),'" + "practical exam updated" + "',"
+ "'" + userstatus.LodUser + "')");
com.Messages.normaljoption("Data Updated!");
loadtabl();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
clear();
}
private boolean isDateExist() {
boolean bol = false;
String selectDate = txtexamdate.getText();
for (int i = 0; i < tbl.getRowCount(); i++) {
String tblDate = tbl.getValueAt(i, 1).toString();
if (selectDate.equals(tblDate)) {
//System.out.println("ok "+tblDate);
bol = true;
break;
}
}
return bol;
}
private void findbyDMTBarcode() {
DefaultTableModel dtm = (DefaultTableModel) tbl.getModel();
dtm.setRowCount(0);
try {
ResultSet rs = model.db.getData("SELECT\n"
+ "practicalexam.id,\n"
+ "practicalexam.customer_register_id,\n"
+ "practicalexam.examDate,\n"
+ "practicalexam.a,\n"
+ "practicalexam.a_pass_or_fail,\n"
+ "practicalexam.b,\n"
+ "practicalexam.b_pass_or_fail,\n"
+ "practicalexam.bone,\n"
+ "practicalexam.bone_pass_or_fail,\n"
+ "practicalexam.g,\n"
+ "practicalexam.g_pass_or_fail,\n"
+ "practicalexam.d,\n"
+ "practicalexam.d_pass_or_fail,\n"
+ "practicalexam.ce,\n"
+ "practicalexam.ce_pass_or_fail,\n"
+ "uniquecustomerdetails.namewithinitial,\n"
+ "customer_register.admission_no \n"
+ "FROM\n"
+ "practicalexam\n"
+ "INNER JOIN customer_register ON practicalexam.customer_register_id = customer_register.id\n"
+ "INNER JOIN uniquecustomerdetails ON customer_register.uniqueCustomerDetails_id = uniquecustomerdetails.id\n"
+ "WHERE\n"
+ "customer_register.barcode = '" + txt_findByDMTBarcode.getText() + "'");
while (rs.next()) {
txtname.setText(rs.getString(16));
txtadmissiono.setText(rs.getString(17));
int id = rs.getInt(1);
String date = rs.getString(3);
String a = rs.getString(4);
String apass = rs.getString(5);
String b = rs.getString(6);
String bpass = rs.getString(7);
String b1 = rs.getString(8);
String b1pass = rs.getString(9);
String g = rs.getString(10);
String gpass = rs.getString(11);
String d = rs.getString(12);
String dpass = rs.getString(13);
String ce = rs.getString(14);
String cepass = rs.getString(15);
Object o[] = {id, date, a, apass, b, bpass, b1, b1pass, g, gpass, d, dpass, ce, cepass};
dtm.addRow(o);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
ResultSet rs = model.db.getData("SELECT\n"
+ "customer_register.id,\n"
+ "uniquecustomerdetails.namewithinitial\n"
+ "FROM\n"
+ "customer_register\n"
+ "INNER JOIN uniquecustomerdetails ON customer_register.uniqueCustomerDetails_id = uniquecustomerdetails.id\n"
+ "WHERE\n"
+ "customer_register.barcode = '" + txt_findByDMTBarcode.getText().trim() + "'");
while (rs.next()) {
txtname.setText(rs.getString(2));
cusid = rs.getInt(1);
}
} catch (Exception e) {
e.printStackTrace();
}
txtexamdate.grabFocus();
}
private void sendsms() {
String tp = null;
String datew = txtexamdate.getText();
try {
ResultSet rs = model.db.getData("SELECT\n"
+ "customer_register.tp1\n"
+ "FROM\n"
+ "customer_register\n"
+ "WHERE\n"
+ "customer_register.admission_no = '"+txtadmissiono.getText()+"'");
if (rs.next()) {
tp = rs.getString(1);
}
} catch (Exception e) {
e.printStackTrace();
}
String originalString = tp;
originalString = originalString.substring(1);
originalString = originalString.replaceAll("[-+.^:,]", "");
String neworiginalString = "0094" + originalString;
System.out.println(neworiginalString);
try {
// Construct data
String apiKey = "apikey=" + "TRSJWOBd7x8-R02dI4i1Q6uuoZVkg4zRGCihxtBQH5";
String message = "&message=" + "Your Trial date for Driving Licence is " + datew + " .Please be attend ontime. More info 0372223969. vijayalearners.com";
String sender = "&sender=" + "Viajaya Learners";
String numbers = "&numbers=" + neworiginalString;
// Send data
HttpURLConnection conn = (HttpURLConnection) new URL("https://api.txtlocal.com/send/?").openConnection();
String data = apiKey + numbers + message + sender;
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Length", Integer.toString(data.length()));
conn.getOutputStream().write(data.getBytes("UTF-8"));
final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
final StringBuffer stringBuffer = new StringBuffer();
String line;
while ((line = rd.readLine()) != null) {
//stringBuffer.append(line);
// JOptionPane.showMessageDialog(null, "message" + line);
}
rd.close();
//return stringBuffer.toString();
} catch (Exception e) {
System.out.println("Error SMS " + e);
//return "Error "+e;
// JOptionPane.showMessageDialog(null, e);
}
}
}
| [
"dalbsranawaka@gmail.com"
] | dalbsranawaka@gmail.com |
b320866d909fcc8445c03b3e11852d933b311004 | 4fa0e38bc77989c7f722e212014f475fd23e9e7e | /Assignment-6/src/main/java/Dao/ScoreDao.java | 4889a771b7dc6bef57c85cdbab48185609bf2ba4 | [] | no_license | TrouBleMaKerV/SOA-Development | 1c6815ddabc3d0da4667c5d8f207339dcaf18049 | 6730099f067cb1676cf30c46385dfec1cac67e31 | refs/heads/master | 2021-09-11T12:47:15.939351 | 2018-04-07T09:02:09 | 2018-04-07T09:02:09 | 113,416,206 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,786 | java | package Dao;
import SCORE.Edit;
import SCORE.Score;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
public class ScoreDao {
public ArrayList<Score> getScore(String sid) {
ArrayList<Score> scores=new ArrayList<Score>();
try {
File xmlfile=new File("D:\\chromeDownload\\onlineStockWebSample01\\Assignment-6\\src\\main\\XML文档3.xml");
SAXReader reader = new SAXReader();
Document doc = reader.read(xmlfile);
Node root=doc.selectSingleNode("/课程成绩列表");
List list=root.selectNodes("课程成绩");
for(Object o:list){
Element e = (Element) o;
String sid1=e.element("成绩").elementText("学号");
if (sid.equals(sid1)){
Score score=new Score();
score.setSid(sid1);
score.setScore(Integer.parseInt(e.element("成绩").elementText("得分")));
score.setCid(e.elementText("课程编号"));
score.setCname(e.elementText("课程名称"));
score.setType(e.elementText("成绩性质"));
scores.add(score);
}
}
} catch(Exception e) {
throw new RuntimeException(e);
}
return scores;
}
public String modifyScore(Edit edit) {
String message="";
String sid=edit.getSid();
String cid=edit.getCid();
String type=edit.getCourseType();
int temp=0;
int score=edit.getScore();
try {
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File("D:\\IDEAprojects\\Assignment-6\\src\\main\\XML文档3.xml"));
/** 修改内容之一: 如果book节点中show属性的内容为yes,则修改成no */
/** 先用xpath查找对象 */
Element nameElem=document.getRootElement().element("课程成绩");
if(nameElem.element("课程编号").getText().equals(cid)
&& nameElem.element("成绩性质").getText().equals(type)
&& nameElem.element("成绩").element("学号").getText().equals(sid)){
System.out.println("符合条件");
nameElem.element("成绩").element("得分").setText(String.valueOf(score));
temp++;
}
//指定文件输出的位置
FileOutputStream out =new FileOutputStream("D:\\IDEAprojects\\Assignment-6\\src\\main\\XML文档3.xml");
// 指定文本的写出的格式:
OutputFormat format= OutputFormat.createPrettyPrint(); //漂亮格式:有空格换行
format.setEncoding("UTF-8");
//1.创建写出对象
XMLWriter writer=new XMLWriter(out,format);
//2.写出Document对象
writer.write(document);
//3.关闭流
writer.close();
if(temp==0){
message="符合条件 学号="+sid+" 课程编号="+cid+" 成绩性质="+type+" 的成绩记录不存在";
}
else{
message="";
}
} catch (Exception ex) {
ex.printStackTrace();
}
return message;
}
public static void main(String[] args){
ScoreDao scoreDao=new ScoreDao();
Edit edit=new Edit("151250131","25010350","平时成绩",42);
String res=scoreDao.modifyScore(edit);
System.out.println(res);
}
}
| [
"731744067@qq.com"
] | 731744067@qq.com |
7497a53387972ec83768bc74c502f31dceab0ba8 | e9df7baef3b1fe35c36ec7840e55c8eef8f74558 | /src/main/java/com/drajer/sof/model/R4FhirData.java | e195f081691dbf5979a44b2f43b03121608e3611 | [
"Apache-2.0"
] | permissive | rgeimer/eCRNow | bb8c0bb4d7aab8a3f4dbbd94ed75dfebd04f2286 | 94ce1ef9697c227d6434ecc4972e9ede7ac49013 | refs/heads/master | 2022-08-10T17:07:45.445392 | 2020-05-15T19:00:48 | 2020-05-15T19:00:48 | 264,019,754 | 0 | 0 | Apache-2.0 | 2020-05-14T20:36:51 | 2020-05-14T20:36:50 | null | UTF-8 | Java | false | false | 243 | java | package com.drajer.sof.model;
import org.hl7.fhir.r4.model.Bundle;
public class R4FhirData extends FhirData {
private Bundle data;
public Bundle getData() {
return data;
}
public void setData(Bundle data) {
this.data = data;
}
}
| [
"nbashyam@localhost"
] | nbashyam@localhost |
09ff11253896517118ba4e736e746a218529f0c8 | 540d4be07f600c801e63c792fca99f3cc06d5de0 | /src/main/java/com/fanyo/oauth/bean/OAuthBean.java | f54565014f8707aac1a349c2337059a4982c5a0f | [
"Apache-2.0"
] | permissive | wangrain/fanyo | 39151c567dba352c14bc47aa644d338190cd556f | b0e9941077fc071cea87cfa8f7d92c13ad0bbad2 | refs/heads/master | 2021-01-11T19:58:57.083542 | 2017-01-19T14:43:44 | 2017-01-19T14:43:44 | 79,437,134 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 242 | java | package com.fanyo.oauth.bean;
import lombok.Data;
/**
* 名称: OAuthBean
* 作者: rain.wang
* 日期: 2016/9/16
* 简介:
*/
@Data
public class OAuthBean {
private String oauthToken;
private String oauthTokenSecret;
}
| [
"wyf23256@gmail.com"
] | wyf23256@gmail.com |
ab96b5699065c50e0ae4454efab7260d8d95e1fd | e8a3c0b3722cacdb99e15693bff0a4333b7ccf16 | /LeetCode/273. Integer to English Words.java | 67e7a2b8e8ad560907d3cf28986fceb2f53a4e46 | [] | no_license | piyush1146115/Competitive-Programming | 690f57acd374892791b16a08e14a686a225f73fa | 66c975e0433f30539d826a4c2aa92970570b87bf | refs/heads/master | 2023-08-18T03:04:24.680817 | 2023-08-12T19:15:51 | 2023-08-12T19:15:51 | 211,923,913 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,147 | java | class Solution {
private final String[] LESS_THAN_20 = {"", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
private final String[] TENS = {"", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
private final String[] THOUSANDS = {"", "Thousand", "Million", "Billion"};
public String numberToWords(int num) {
if (num == 0) return "Zero";
int i = 0;
String words = "";
while (num > 0) {
if (num % 1000 != 0)
words = helper(num % 1000) +THOUSANDS[i] + " " + words;
num /= 1000;
i++;
}
return words.trim();
}
private String helper(int num) {
if (num == 0)
return "";
else if (num < 20)
return LESS_THAN_20[num] + " ";
else if (num < 100)
return TENS[num / 10] + " " + helper(num % 10);
else
return LESS_THAN_20[num / 100] + " Hundred " + helper(num % 100);
}
}
| [
"piyush123kantidas@gmail.com"
] | piyush123kantidas@gmail.com |
52b2fd9b4b1afb315d6b1c9f23ad08e92112adb2 | b94870ad4a1880f7feb9ae0d4725c9d62cc00af1 | /LHP_Assignment04/src/Problem2.java | 32258d0b93d542a49dc202cecc43748ba4222115 | [] | no_license | Lukas-Pfalz/Computer-Science-1 | 6786387cbf77d05c14c1ec45f704473e95bd7496 | 4b54c48bc2afef9cb901a49fc80395d33bd8453c | refs/heads/master | 2023-02-10T16:51:14.528221 | 2021-01-14T04:26:17 | 2021-01-14T04:26:17 | 329,507,513 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,464 | java | /**
* Problem 2
*/
public class Problem2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Create a new CalenderDate object and initialize it to a date
CalenderDate cd1 = new CalenderDate(2001, 13, 31);
//Create a new CalenderDate object and initialize it to a date
CalenderDate cd2 = new CalenderDate(1960, 2, 29);
//Create a new CalenderDate object and initialize it to a date
CalenderDate cd3 = new CalenderDate(2001, 3, 31);
//Check object dates
System.out.printf("cd1 current date is %s\n", cd1);
System.out.printf("cd2 current date is %s\n", cd2);
System.out.printf("cd3 current date is %s\n", cd3);
//Add days to CalenderDate object
cd3.addDays(50);
System.out.printf("cd3 date is %s\n", cd3);
//Create a new CalenderDate object and initialize it to a date
CalenderDate cd4 = new CalenderDate(2001, 3, 31);
cd4.addWeeks(30);
System.out.println(cd4);
//Output CalenderDate object to console
CalenderDate cd5 = new CalenderDate(2001, 3, 31);
System.out.printf("cd2 is date is %s\n", cd2);
System.out.printf("Number of days between %s and %s is %d days\n", cd3, cd4, cd3.daysTo(cd4));
//Check if equal
String result = cd3.equals(cd5) ? "EQUAL" : "NOT EQUAL";
System.out.printf("cd3 and cd5 are %s\n", result);
}
}
| [
"lukas.h.pfalz@gmail.com"
] | lukas.h.pfalz@gmail.com |
1880a56e3fd6880f0034883864b22a32b19cca20 | 6cf845293a1a0c9d8c1d72de14c0a7e0b13d21fd | /persistence/src/main/java/com/lightbend/persistence/PersistentActorExample.java | 64ccf9e4dffe0250acad4b26c8a6e50794c3fa74 | [] | no_license | rudalson/akka-codes | f18f297b2485af39c87101cc0a53719a9b22b748 | da978999378dcbb9bb50ed214896f6b7b5ac7062 | refs/heads/master | 2020-04-02T06:50:52.161901 | 2018-10-22T15:47:59 | 2018-10-22T15:47:59 | 153,968,865 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,371 | java | package com.lightbend.persistence;
import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.persistence.AbstractPersistentActor;
import akka.persistence.SnapshotOffer;
import java.io.Serializable;
import java.util.ArrayList;
class Cmd implements Serializable {
private static final long serialVersionUID = 1L;
private final String data;
public Cmd(String data) {
this.data = data;
}
public String getData() {
return data;
}
}
class Evt implements Serializable {
private static final long serialVersionUID = 1L;
private final String data;
public Evt(String data) {
this.data = data;
}
public String getData() {
return data;
}
}
class ExampleState implements Serializable {
private static final long serialVersionUID = 1L;
private final ArrayList<String> events;
public ExampleState() {
this(new ArrayList<>());
}
public ExampleState(ArrayList<String> events) {
this.events = events;
}
public ExampleState copy() {
return new ExampleState(new ArrayList<>(events));
}
public void update(Evt evt) {
events.add(evt.getData());
}
public int size() {
return events.size();
}
@Override
public String toString() {
return events.toString();
}
}
class ExamplePersistentActor extends AbstractPersistentActor {
private ExampleState state = new ExampleState();
private int snapShotInterval = 1000;
public int getNumEvents() {
return state.size();
}
@Override
public String persistenceId() {
return "sample-id-1";
}
@Override
public AbstractActor.Receive createReceiveRecover() {
return receiveBuilder()
.match(Evt.class, state::update)
.match(SnapshotOffer.class, ss -> state = (ExampleState) ss.snapshot())
.build();
}
@Override
public AbstractActor.Receive createReceive() {
return receiveBuilder()
.match(Cmd.class, this::onCmd)
.matchEquals("print", s -> System.out.println(state))
.build();
}
private void onCmd(final Cmd cmd) {
final String data = cmd.getData();
final Evt evt = new Evt(data + "-" + getNumEvents());
persist(evt, (Evt e) -> {
state.update(e);
getContext().getSystem().eventStream().publish(e);
if (lastSequenceNr() % snapShotInterval == 0 && lastSequenceNr() != 0)
// IMPORTANT: create a copy of snapshot because ExampleState is mutable
saveSnapshot(state.copy());
});
}
}
public class PersistentActorExample {
public static void main(String... args) throws Exception {
final ActorSystem system = ActorSystem.create("example");
final ActorRef persistentActor = system.actorOf(Props.create(ExamplePersistentActor.class), "persistentActor-4-java8");
persistentActor.tell(new Cmd("foo"), null);
persistentActor.tell(new Cmd("baz"), null);
persistentActor.tell(new Cmd("bar"), null);
persistentActor.tell(new Cmd("buzz"), null);
persistentActor.tell("print", null);
Thread.sleep(10000);
system.terminate();
}
}
| [
"kmpak@coupang.com"
] | kmpak@coupang.com |
372bbc2467e8c0abc752cc962678d3c8e095fb53 | d1a2447bf903111f2774a91471378d4b5cf05e1b | /DataIntegration/DataIntegration/src/classification/ProcessOptymalization.java | 37e0a0e018eed3f2cc32c4cbe8e41691244fea54 | [] | no_license | asia132/DataIntegration | d67115f66a2ca74ce63a9b15094881b67f91b29d | 64acd4bd590c539e0581f5eef116e40350b3283c | refs/heads/master | 2020-03-10T23:25:59.962464 | 2018-06-24T16:45:44 | 2018-06-24T16:45:44 | 129,640,937 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,219 | java | package classification;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Hashtable;
public class ProcessOptymalization {
String basicPath = "C:\\Users\\Asia\\PycharmProjects\\DataIntegration\\outputs\\";
String communicateOutput = "C:\\Users\\Asia\\PycharmProjects\\DataIntegration\\input\\message";
String communicateInput = "C:\\Users\\Asia\\PycharmProjects\\DataIntegration\\input\\settings.conf";
ProductionData productionDataTrain;
ArrayList <String> paths;
// settings
String date;
Double [] tempPipes;
Double [] tempMaltoseBreak;
Double [] tempDextrinizationBreak;
Double [] tempMashOut;
Double [] tempBoiling;
public ProcessOptymalization() {
productionDataTrain = new ProductionData();
paths = new ArrayList<>();
File [] dirs = new File(basicPath).listFiles(File::isDirectory);
for (int i = 0; i < dirs.length; ++i) {
File [] dirsOfDate = new File(dirs[i].toString()).listFiles();
String seq = dirsOfDate[0].toString();
if (!seq.contains("archive")) {
paths.add(seq);
}
}
tempPipes = new Double [2];
tempMaltoseBreak = new Double [2];
tempDextrinizationBreak = new Double [2];
tempMashOut = new Double [2];
tempBoiling = new Double [2];
readSettings();
}
public void readSettings() {
try {
BufferedReader file = new BufferedReader(new FileReader(communicateInput));
date = file.readLine();
String [] pipes = file.readLine().split(" ");
String [] maltoseBreak = file.readLine().split(" ");
String [] dextrinizationBreak = file.readLine().split(" ");
String [] mashOut = file.readLine().split(" ");
String [] boiling = file.readLine().split(" ");
for(int i = 0; i < maltoseBreak.length; ++i) {
tempPipes[0] = Double.parseDouble(pipes[0]);
tempPipes[1] = Double.parseDouble(pipes[1]);
tempMaltoseBreak[0] = Double.parseDouble(maltoseBreak[0]);
tempMaltoseBreak[1] = Double.parseDouble(maltoseBreak[1]);
tempDextrinizationBreak[0] = Double.parseDouble(dextrinizationBreak[0]);
tempDextrinizationBreak[1] = Double.parseDouble(dextrinizationBreak[1]);
tempMashOut[0] = Double.parseDouble(mashOut[0]);
tempMashOut[1] = Double.parseDouble(mashOut[1]);
tempBoiling[0] = Double.parseDouble(boiling[0]);
tempBoiling[1] = Double.parseDouble(boiling[1]);
}
file.close();
}catch(FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private String getTagFromPath(String path) {
return path.substring(63, path.length() - 8);
}
public String getDateFromPath(String path) {
return path.substring(54, 61);
}
public void runOpt() {
System.out.println("-----------------------------------------");
for (int i = 0; i < paths.size(); ++i) {
productionDataTrain.stats(paths.get(i));
String tag = getTagFromPath(paths.get(i));
double [] clustTemp = productionDataTrain.clustering(paths.get(i));
System.out.println("CLUSTERING " + tag + " " + clustTemp[0] + ", " + clustTemp[1] + ", " + clustTemp[2] + ", " + clustTemp[3] + ", " + clustTemp[4]);
System.out.println("-----------------------------------------");
prepareMessage(clustTemp);
}
}
private void prepareMessage(double [] clustTemp) {
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(communicateOutput)))) {
int change = clustTemp[0] - tempPipes[0] < tempPipes[1] - clustTemp[0] ? 0 : 1;
writer.write(change + " " + clustTemp[0] + "\n");
change = clustTemp[0] - tempMaltoseBreak[0] < tempMaltoseBreak[1] - clustTemp[0] ? 0 : 1;
writer.write(change + " " + clustTemp[1] + "\n");
change = clustTemp[0] - tempDextrinizationBreak[0] < tempDextrinizationBreak[1] - clustTemp[0] ? 0 : 1;
writer.write(change + " " + clustTemp[2] + "\n");
change = clustTemp[0] - tempMashOut[0] < tempMashOut[1] - clustTemp[0] ? 0 : 1;
writer.write(change + " " + clustTemp[3] + "\n");
change = clustTemp[0] - tempBoiling[0] < tempBoiling[1] - clustTemp[0] ? 0 : 1;
writer.write(change + " " + clustTemp[4] + "\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void archivize() {
for (int i = 0; i < paths.size(); ++i) {
File file = new File(paths.get(i));
renameDir(file.getParent());
}
}
private void renameDir(String path) {
File dir = new File(path);
File parentdir = new File(dir.getParent());
if (!dir.isDirectory()) {
System.err.println("There is no directory @ given path");
} else {
StringBuilder sb = new StringBuilder (String.valueOf("archive_"));
sb.append(parentdir.listFiles().length);
String newDirName = sb.toString();
File newDir = new File(dir.getParent() + "\\" + newDirName);
dir.renameTo(newDir);
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
c9e7d3a542cae10903eebc7a39032c53da0d538d | 2c0aec486de77aff70a7fe072d49f1bef1f9b881 | /project-common/src/main/java/com/fans/common/utils/excel/convert/CustomStringDateConverter.java | 2eba57fb09677856b96bc6f852c855a8512e25f0 | [] | no_license | a576353201/springcloud-falsework | e9adb70b5ea798b61e03245c8313099861bfe508 | 7378c3a394b41d88721417f5c1f30f92e177418b | refs/heads/main | 2023-01-12T04:01:28.107916 | 2020-11-15T17:37:35 | 2020-11-15T17:37:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,780 | java | package com.fans.common.utils.excel.convert;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
/**
* className: CustomStringDateConverter
*
* @author k
* @version 1.0
* @description 字符串时间转化
* @date 2020-05-18 23:41
**/
@Slf4j
public class CustomStringDateConverter implements Converter<Date> {
@Override
public Class<Date> supportJavaTypeKey() {
return Date.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
/**
* 读的时候调用
*
* @param cellData 单元格数据
* @param contentProperty 上下文
* @param globalConfiguration 全局配置
* @return 日期
*/
@Override
public Date convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
//数据表中的时间 date类型
try {
String dateStr = cellData.getStringValue();
if (StringUtils.isNotBlank(dateStr) && !"第八列".equals(cellData.getStringValue())) {
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy年MM月dd日 HH时mm分ss秒");
DateTime dateTime = DateTime.parse(dateStr, dateTimeFormatter);
return dateTime.toDate();
}
} catch (Exception e) {
log.error("-->转化器读取出错:{}", e.getMessage(), e);
}
return null;
}
/**
* 这里写的时候调用
*
* @param value 值
* @param contentProperty 上下文
* @param globalConfiguration 全局配置
* @return 写入的值
*/
@Override
public CellData<String> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
//excel中的时间格式 2020年05月05日
try {
DateTime dateTime = new DateTime(value);
return new CellData<>(dateTime.toString("yyyy年MM月dd日 HH时mm分ss秒"));
} catch (Exception e) {
log.error("-->转化器写入出错:{}", e.getMessage(), e);
}
return new CellData<>(StringUtils.EMPTY);
}
}
| [
"5219824@qq.com"
] | 5219824@qq.com |
f375f5f7b0fa6939630a516723300effa67f1d68 | 1cb47a6ea030c7d3c4eb5dd361247846d7dd3d80 | /src/main/java/ik/secretcloset/exceptions/ApplicationException.java | d08a8df246c5801edbe5bf5ec03a84c348f198ef | [] | no_license | ikonovi/Android-App-Automation-L4 | 5b6b23c0f627855160b6087867fcab0f9fb5c23c | ad95f4cd3b79cb2df8e07d9d788ae91cbf3ecc05 | refs/heads/main | 2023-06-05T12:04:43.532710 | 2021-06-30T15:08:43 | 2021-06-30T15:08:43 | 378,995,044 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 401 | java | package ik.secretcloset.exceptions;
public class ApplicationException extends Exception{
public ApplicationException() {
}
public ApplicationException(String message) {
super(message);
}
public ApplicationException(String message, Throwable cause) {
super(message, cause);
}
public ApplicationException(Throwable cause) {
super(cause);
}
}
| [
"ikonovi@gmail.com"
] | ikonovi@gmail.com |
37facd5dc7cb330cbadaa9468624152ce8b423f4 | 4ea0b1ce97352b16284a10976650594866d4feae | /app/src/main/java/com/example/faultlog/FirstFragment.java | 4024a28817c483d0f30d16b09795517e86de6db7 | [] | no_license | dauda1995/faultyLog | 61b1af25c6193b3e9ba8ab1d84b50ea9d92531e4 | 62234b39d42f8db8e5d5388debd835c7fd30df92 | refs/heads/master | 2023-03-08T17:58:23.317350 | 2021-02-24T16:23:11 | 2021-02-24T16:23:11 | 341,963,775 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,297 | java | package com.example.faultlog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
public class FirstFragment extends Fragment implements View.OnClickListener {
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_first, container, false);
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.agbara).setOnClickListener(this);
view.findViewById(R.id.aiyetoro).setOnClickListener(this);
view.findViewById(R.id.oko_afo).setOnClickListener(this);
view.findViewById(R.id.igborosun).setOnClickListener(this);
view.findViewById(R.id.aradagun).setOnClickListener(this);
view.findViewById(R.id.badagry).setOnClickListener(this);
view.findViewById(R.id.om).setOnClickListener(this);
}
@Override
public void onClick(View v) {
// FirstFragmentDirections.ActionFirstFragmentToFaultList action ;
Intent i = new Intent(getActivity(), FormActivity.class);
switch (v.getId()){
case R.id.agbara:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("agbara");
// action.setZone("agbara");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.AGBARA);
startActivity(i);
break;
case R.id.aiyetoro:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("aiyetoro");
// action.setZone("aiyetoro");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.AIYETORO);
startActivity(i);
break;
case R.id.oko_afo:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("okoAfo");
// action.setZone("okoAfo");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.OKOAFO);
startActivity(i);
break;
case R.id.igborosun:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("igborosun");
// action.setZone("igborosun");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.IGBOROSUN);
startActivity(i);
break;
case R.id.aradagun:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("aradagun");
// action.setZone("aradagun");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.ARADAGUN);
startActivity(i);
break;
case R.id.badagry:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("badagry");
// action.setZone("badagry");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.BADAGRY);
startActivity(i);
break;
case R.id.om:
// action =
// FirstFragmentDirections.actionFirstFragmentToFaultList("om");
// action.setZone("om");
// Navigation.findNavController(v).navigate(action);
i.putExtra(Contracts.ZONE_ARGUMENT, Contracts.OM);
startActivity(i);
break;
}
}
} | [
"dauda933@gmail.com"
] | dauda933@gmail.com |
5ab37f02f5d15307223643627493b332b06a04b8 | 65cef4a30ee0846173b078f9a3e930e27c6b3af7 | /app/src/main/java/ru/drmarkes/funnyballs/SimpleBall.java | 2680642f18a3d40f691edeabc795cb438b82524f | [] | no_license | DrMarkes/FunnyBalls | 3bcfb2f6fe02d44468938f3deb2f88e6f46a005c | f2f3c19bc0509e2c88125bc266ffd31126d94ce4 | refs/heads/master | 2021-01-10T17:07:55.305659 | 2015-12-24T14:42:34 | 2015-12-24T14:42:34 | 48,183,835 | 0 | 0 | null | 2015-12-24T14:42:34 | 2015-12-17T15:56:10 | Java | UTF-8 | Java | false | false | 909 | java | package ru.drmarkes.funnyballs;
/**
* Created by Андрей on 21.12.2015.
*/
public class SimpleBall {
protected int x, y, radius;
private int color;
public SimpleBall(int x, int y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getRadius() {
return radius;
}
public void setRadius(int radius) {
this.radius = radius;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public SimpleBall getBallArea() {
return new SimpleBall(x, y, radius * 3);
}
public boolean isIntersect(SimpleBall ball) {
return radius + ball.radius >= Math.sqrt(Math.pow(x - ball.x, 2) + Math.pow(y - ball.y, 2));
}
}
| [
"markovandrew@yandex.ru"
] | markovandrew@yandex.ru |
4eff088261d46b597aa4ebcae23ebe9b8578ae9f | b80390c2ea926cf620b394bde307c101b467b22d | /level08/lesson08/task05/Solution.java | ab900790765a3db6db7f6592b5c967de1c8dbdfe | [] | no_license | Zvezd/Java | 63f21e648649f1aa9e867c3cfff0f2b31d763dbb | f7cabaef9db1731e64e51fde5c72440f16135076 | refs/heads/master | 2021-01-10T14:46:25.169983 | 2015-11-29T07:42:18 | 2015-11-29T07:42:18 | 47,054,924 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,953 | java | package com.javarush.test.level08.lesson08.task05;
import java.util.*;
/* Удалить людей, имеющих одинаковые имена
Создать словарь (Map<String, String>) занести в него десять записей по принципу «фамилия» - «имя».
Удалить людей, имеющих одинаковые имена.
*/
public class Solution
{
public static HashMap<String, String> createMap()
{
HashMap<String, String> m = new HashMap<String,String>();
m.put("Гулаева", "Анна");
m.put("Смердяков", "Алексей");
m.put("Попова", "Анна");
m.put("Попович", "Иван");
m.put("Пенькова", "Мария");
m.put("Пеньков", "Алёна");
m.put("Вострецова", "Анна");
m.put("Попов", "Алексей");
m.put("Звягин", "Алексей");
m.put("Долгушина", "Юлия");
removeTheFirstNameDuplicates(m);
return m;
}
public static void removeTheFirstNameDuplicates(HashMap<String, String> map)
{
HashMap<String, String> map1 = new HashMap<String, String>(map);
HashSet<String> map2 = new HashSet<String>();
for(String f: map1.values()) {
if (map2.contains(f)) {
removeItemFromMapByValue(map, f);
} else
map2.add(f);
}
}
public static void removeItemFromMapByValue(HashMap<String, String> map, String value)
{
HashMap<String, String> copy = new HashMap<String, String>(map);
for (Map.Entry<String, String> pair: copy.entrySet())
{
if (pair.getValue().equals(value))
map.remove(pair.getKey());
}
}
public static void main (String [] args) throws Exception {
System.out.println(createMap());
}
}
| [
"barcelonamars@gmail.com"
] | barcelonamars@gmail.com |
9b930d272303f9cc885f98d5546224b420ee19f3 | 59a32d99cfd413febcbcd81ff82c39e6bd2f4e95 | /HelloSpring/src/main/java/com/yiibai/tutorial/spring/helloworld/impl/SpringHelloWorld.java | 4e842931e0d618554d88c76220469c2926b636a8 | [] | no_license | cmsz-sugy/spirngDemo | 09a956af1eb287bcb48c43803d268cd7d04f8d4e | 065cbabb4ab7af07eb9daa62e49748323b5645f5 | refs/heads/master | 2021-01-19T23:00:36.295584 | 2017-08-24T06:37:24 | 2017-08-24T06:37:24 | 101,261,024 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 286 | java | package com.yiibai.tutorial.spring.helloworld.impl;
import com.yiibai.tutorial.spring.helloworld.HelloWorld;
public class SpringHelloWorld implements HelloWorld {
@Override
public void sayHello() {
System.out.println("Spring Say Hello!!");
}
} | [
"sugy@chinamobilesz.com"
] | sugy@chinamobilesz.com |
1b34f72c7c9efc57bbdbef9a59575e6e6c9970cd | c412b31b00abc996be84d530fb6474eeb6d9c9b6 | /src/com/thoughtworks/biblioteca/MovieLibrary.java | 2c516617605dbfb70b2897c0ff0ae038a6e771e0 | [] | no_license | abhisheksp/twu-biblioteca-abhisheksp | 7da8db6ce1c4fdd5fe15960306d9cb2771d51f12 | cf72e618a273833df19ee8b9d85ed9ce2298beec | refs/heads/master | 2020-05-30T07:02:51.570796 | 2015-09-18T16:36:47 | 2015-09-18T16:36:47 | 41,843,766 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 899 | java | package com.thoughtworks.biblioteca;
import java.util.ArrayList;
/* MovieLibrary has a list of movies and can do checkout operation and can format itself*/
public class MovieLibrary {
ArrayList<Movie> availableMovies;
public MovieLibrary(ArrayList<Movie> availableMovies) {
this.availableMovies = availableMovies;
}
public String format() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(String.format("%-30s%-30s%-30s%-30s\n", "Name", "Year", "Director", "Rating"));
for (Movie movie : availableMovies) {
stringBuilder.append(movie.toString() + "\n");
}
return stringBuilder.toString();
}
public boolean checkOut(Movie movie) {
if (availableMovies.contains(movie)) {
availableMovies.remove(movie);
return true;
}
return false;
}
}
| [
"abhisheksp1993@gmail.com"
] | abhisheksp1993@gmail.com |
d7f62cab9d250f48bb0e7a0115efd2a4c003a14b | bd9a097f3ec4dd2fa40e443ed5b30ffb68b11058 | /myssh/src/com/sc/tradmaster/controller/guideRecords/GuideRecordsController.java | 9b4f5bac81cde70255a76e96d272105777ec79a1 | [] | no_license | WangWangJunPeng/sanchong | c8c3cee33afd776f4a40137cce0d120413d325bd | 2ab74f162ce1f8a331af741c2d53f0f32317d826 | refs/heads/master | 2021-01-25T04:49:58.034679 | 2017-06-06T07:54:14 | 2017-06-06T07:54:14 | 93,489,861 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,930 | java | package com.sc.tradmaster.controller.guideRecords;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.sc.tradmaster.bean.User;
import com.sc.tradmaster.controller.BaseController;
import com.sc.tradmaster.service.guideRecords.GuideRecordsService;
import com.sc.tradmaster.service.guideRecords.impl.dto.GuideRecordsDTO;
@Controller("guideRecordsController")
public class GuideRecordsController extends BaseController{
@Resource(name = "guideRecordsService")
private GuideRecordsService guideRecordsService;
/**
* 增加备案记录表
* @throws IOException
*/
@RequestMapping("/addGuideRecords")
public ModelAndView addGuideRecords(String allProjectId,String customerName,String phone) throws Exception {
// 获取session中的用户信息
User user = (User) this.request.getSession().getAttribute("userInfo");
String[] projectId = allProjectId.split(",");
List<GuideRecordsDTO> grdtoList = guideRecordsService.addGuideRecords(user, customerName, phone, projectId);
int i = 0;
int j = 0;
for (GuideRecordsDTO guideRecordsDTO : grdtoList) {
if (guideRecordsDTO.getApplyStatus()==0){
i++;
}
if (guideRecordsDTO.getApplyStatus()==3){
j++;
}
}
ModelAndView model = new ModelAndView("app/house/spareResult");
model.addObject("data", grdtoList);
model.addObject("dataSuccess", i);
model.addObject("dataFail", j);
return model;
}
/**
* 备案客户表(申请状态的)
*/
@RequestMapping("/GuideRecordsList")
public ModelAndView selectGuideRecords(String startTime, String endTime, String projectId)throws ParseException {
// 获取session中的用户信息
User u = (User) this.request.getSession().getAttribute("userInfo");
List list = guideRecordsService.findGuideRecordsList(u, projectId, startTime, endTime);
ModelAndView model = new ModelAndView("app/house/recordCustomer");
model.addObject("data", list);
return model;
}
/**
* 将过期的客户表页面跳转控制器
*/
@RequestMapping("/to_goToNearOverdue")
public ModelAndView toGoToNearOverdue(String projectId){
ModelAndView model = new ModelAndView("app/house/upcomingCustomer");
model.addObject("dataInfo", projectId);
return model;
}
/**
* 将过期的客户表
*/
@RequestMapping("/to_nearOverdue")
public void selectnerOver(String projectId,String phone)throws ParseException {
// 获取session中的用户信息
User u = (User) this.request.getSession().getAttribute("userInfo");
Map<String, Object> map = guideRecordsService.findNearOver(u, projectId,phone);
this.outObjectString(map, null);
}
}
| [
"1152794567@qq.com"
] | 1152794567@qq.com |
ded00832e90b1f7cbd9333b33d5a82a22efb6944 | 17c47f50503984b3338df27666ad9d3445cc509e | /src/test/java/by/sasnouskikh/jcasino/service/AdminServiceTakePlayerTest.java | c421b3a1526e44e876bdce47f386e669702abddf | [] | no_license | jahstreet/JCasino | ff66b87d828e0dbd7aab2d9eec2e0756ca640e2f | 35df5fe9fd6a1b742817e1b0a3bfb419a591f455 | refs/heads/master | 2020-12-24T20:00:41.703749 | 2017-05-31T20:56:17 | 2017-05-31T20:56:17 | 86,226,113 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,915 | java | package by.sasnouskikh.jcasino.service;
import by.sasnouskikh.jcasino.dao.DAOException;
import by.sasnouskikh.jcasino.dao.UserDAO;
import by.sasnouskikh.jcasino.dao.impl.DAOHelper;
import by.sasnouskikh.jcasino.entity.bean.JCasinoUser;
import by.sasnouskikh.jcasino.entity.bean.Player;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.*;
import static org.powermock.api.mockito.PowerMockito.verifyNew;
import static org.powermock.api.mockito.PowerMockito.whenNew;
@PowerMockIgnore("javax.management.*")
@RunWith(PowerMockRunner.class)
@PrepareForTest({AdminService.class})
public class AdminServiceTakePlayerTest {
private static final JCasinoUser ANY_USER = new JCasinoUser();
private static final Player ANY_PLAYER = new Player();
@Mock
private DAOHelper daoHelper;
@Mock
private UserDAO userDAO;
@Mock
private UserService userService;
private AdminService adminService;
@Before
public void setUp() throws Exception {
adminService = new AdminService(daoHelper);
when(daoHelper.getUserDAO()).thenReturn(userDAO);
when(userDAO.takeUser(anyInt())).thenReturn(ANY_USER);
whenNew(UserService.class).withNoArguments().thenReturn(userService);
when(userService.initPlayer(any(JCasinoUser.class))).thenReturn(ANY_PLAYER);
}
@After
public void tearDown() {
adminService = null;
}
@Test
public void takePlayerReturnCheck() throws Exception {
int playerId = 1;
Assert.assertEquals(ANY_PLAYER, adminService.takePlayer(playerId));
}
@Test
public void takePlayerUserDAOCallCheck() throws Exception {
int playerId = 1;
adminService.takePlayer(playerId);
verify(userDAO).takeUser(anyInt());
}
@Test
public void takePlayerUserServiceCreateCheck() throws Exception {
int playerId = 1;
adminService.takePlayer(playerId);
verifyNew(UserService.class);
}
@Test
public void takePlayerUserServiceCallCheck() throws Exception {
int playerId = 1;
adminService.takePlayer(playerId);
verify(userService).initPlayer(any(JCasinoUser.class));
}
@Test
public void takePlayerDAOExceptionThrownReturnCheck() throws Exception {
int playerId = 1;
reset(userService);
when(userDAO.takeUser(anyInt())).thenThrow(new DAOException("Database connection error."));
Assert.assertNull(adminService.takePlayer(playerId));
}
} | [
"s-a100500"
] | s-a100500 |
3d29f952e8bb222e0a15498161392e85a5af063a | 92f7ba1ebc2f47ecb58581a2ed653590789a2136 | /src/com/infodms/dms/actions/crm/basedata/PcGroup.java | f69a67e0b7a82851fccc1dc3d8ada08d2a9437b0 | [] | no_license | dnd2/CQZTDMS | 504acc1883bfe45842c4dae03ec2ba90f0f991ee | 5319c062cf1932f8181fdd06cf7e606935514bf1 | refs/heads/master | 2021-01-23T15:30:45.704047 | 2017-09-07T07:47:51 | 2017-09-07T07:47:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,448 | java | package com.infodms.dms.actions.crm.basedata;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.infodms.dms.actions.sales.ordermanage.orderaudit.OrderResourceReserveFirst;
import com.infodms.dms.actions.util.LockControl;
import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.dao.crm.basedata.PcGroupDao;
import com.infodms.dms.dao.sales.financemanage.AccountBalanceDetailDao;
import com.infodms.dms.dao.sales.ordermanage.audit.OrderAuditDao;
import com.infodms.dms.dao.sales.ordermanage.orderreport.OrderReportDao;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.TPcGroupPO;
import com.infodms.dms.util.CommonUtils;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.po3.bean.PageResult;
public class PcGroup {
private Logger logger = Logger.getLogger(OrderResourceReserveFirst.class);
private ActionContext act = ActionContext.getContext();
RequestWrapper request = act.getRequest();
private final PcGroupDao dao = PcGroupDao.getInstance();
private final String GROUP_QUERY_URL = "/jsp/crm/basedata/pcGroupInit.jsp";// 经销商用户组维护查询页面
private final String GROUP_ADD_INIT = "/jsp/crm/basedata/pcGroupAdd.jsp";// 经销商用户组维护查询页面
private final String GROUP_UPDATE_INIT = "/jsp/crm/basedata/pcGroupUpdate.jsp";// 经销商用户组维护查询页面
public void doInit() {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
String funcStr=CommonUtils.judgeUserHasFunc(logonUser);
act.setOutData("funcStr", funcStr);
act.setForword(GROUP_QUERY_URL);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* FUNCTION : 查询经销商所有的组
* @param :
* @return :
* @throws :
* LastUpdate : 2010-8-30
*/
public void groupQueryList(){
AclUserBean logonUser = null;
try {
RequestWrapper request = act.getRequest();
logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
String status = CommonUtils.checkNull(request.getParamValue("status")); //经销商用户组的状态
String groupName = CommonUtils.checkNull(request.getParamValue("groupName")); //组名称
Map<String ,String > map=new HashMap<String,String>();
map.put("status", status);
map.put("groupName", groupName);
map.put("dealerId", logonUser.getDealerId());
String pageSize=CommonUtils.checkNull(request.getParamValue("pageSize"));
pageSize=pageSize==null||"".equals(pageSize)?"10":pageSize;
Integer curPage = request.getParamValue("curPage") != null ? Integer
.parseInt(request.getParamValue("curPage"))
: 1; // 处理当前页
PageResult<Map<String, Object>> ps = dao.getGroupQueryList(map, Integer.parseInt(pageSize), curPage);
act.setOutData("ps", ps);
} catch (Exception e) {
BizException e1 = new BizException(act, e,
ErrorCodeConstant.QUERY_FAILURE_CODE, "所有车辆资源查询");
logger.error(logonUser,e1);
act.setException(e1);
}
}
/**
* 用户组新增界面
*/
public void groupAddInit() {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
act.setForword(GROUP_ADD_INIT);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* 经销商用户组的添加
*/
public void groupAdd(){
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
String groupName=CommonUtils.checkNull(request.getParamValue("groupName"));
TPcGroupPO tgp=new TPcGroupPO();
String seq=SequenceManager.getSequence("");
tgp.setGroupId(new Long(seq));
tgp.setGroupName(groupName);
tgp.setCreateDate(new Date());
tgp.setCreateBy(logonUser.getUserId());
tgp.setDealerId(new Long(logonUser.getDealerId()));
tgp.setStatus(new Long(10011001));
int a=0;
try {
dao.insert(tgp);
a=1;
} catch (Exception e) {
a=0;
}
act.setOutData("flag", a);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* 用户组修改初始化界面
*/
public void groupUpdateInit() {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
String groupId=CommonUtils.checkNull(request.getParamValue("groupId"));
String status="";
TPcGroupPO tgp=new TPcGroupPO();
tgp.setGroupId(new Long(groupId));
tgp=(TPcGroupPO) dao.select(tgp).get(0);
act.setOutData("po", tgp);
status=CommonUtils.getCodeDesc(tgp.getStatus().toString());
act.setOutData("status", status);
act.setForword(GROUP_UPDATE_INIT);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
/**
* 经销商用户组的添加
*/
public void groupUpdate(){
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
String groupName=CommonUtils.checkNull(request.getParamValue("groupName"));
String status=CommonUtils.checkNull(request.getParamValue("status"));
String groupId=CommonUtils.checkNull(request.getParamValue("groupId"));
TPcGroupPO tgp=new TPcGroupPO();
tgp.setGroupName(groupName);
tgp.setUpdateDate(new Date());
tgp.setUpdateBy(logonUser.getUserId());
tgp.setStatus(new Long(status));
TPcGroupPO tgp0=new TPcGroupPO();
tgp0.setGroupId(new Long(groupId));
int a=0;
try {
a=dao.update(tgp0,tgp);
} catch (Exception e) {
a=0;
}
act.setOutData("flag", a);
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
//验证组名称
public void checkGroupName() {
AclUserBean logonUser = (AclUserBean) act.getSession().get(Constant.LOGON_USER);
try {
String groupName=request.getParamValue("groupName");
String groupId=request.getParamValue("groupId");
Map<String,String> map=new HashMap<String, String>();
map.put("groupName", groupName);
map.put("dealerId", logonUser.getDealerId());
map.put("groupId", groupId);
int count=dao.checkGroupName(map);
if(count<1){
act.setOutData("flag", "1");
}else{
act.setOutData("flag", "2");
}
} catch (Exception e) {
BizException e1 = new BizException(act, e, ErrorCodeConstant.QUERY_FAILURE_CODE, "经销商用户组查询");
logger.error(logonUser, e1);
act.setException(e1);
}
}
}
| [
"wanghanxiancn@gmail.com"
] | wanghanxiancn@gmail.com |
460b590c28b3fe874010d30ced2e094ac648db7e | bcd8c855c5e553359d0bbc824f9e31e4c53d22da | /JPA_Demo_Pr/src/main/java/com/pr/jpa/demo/repository/StudentRepository.java | b7161ad14ee6733c30baa0e347566bc6698bd9df | [] | no_license | Pruthweeraj/SpringBootJPA | 6ba8a614e89f4bff3094fb7960875bef36aab26b | f8d146c0b38d57d9544ad705a5b007e0e69a22ea | refs/heads/master | 2020-04-25T14:50:58.748801 | 2019-12-08T13:34:30 | 2019-12-08T13:34:30 | 172,856,392 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,808 | java | package com.pr.jpa.demo.repository;
import javax.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.pr.jpa.demo.entity.Passport;
import com.pr.jpa.demo.entity.Student;
@Repository
@Transactional
public class StudentRepository {
//private Logger logger = org.slf4j.LoggerFactory.getLogger(this.getClass());
@Autowired
EntityManager em;
//find student by id
public Student findById(long id) {
return em.find(Student.class, id);
}
//Delete a student
public void deleteById(long id) {
Student student = findById(id);
em.remove(student);
}
public Student save(Student student) {
if(student.getId() == 0) {
em.persist(student);
}else {
em.merge(student);
}
return student;
}
public void saveStudentWithPassport() {
Passport passport = new Passport("XM112233");
em.persist(passport);
Student student = new Student("Susu");
student.setPassport(passport);
em.persist(student);
}
public void someOperationToUnderstandTransactionalPersistenceContext() {
//Database operation 1 - Retrieve Student
Student student = em.find(Student.class, 2001L);
//Persistence Context(student)
//Database operation 2 - Retrieve passport
Passport passport = student.getPassport();
//Persistence Context(student,passport)
//Database operation 3 - Update passport
passport.setNumber("MM121212");
//Persistence Context(student,passport++)
//Database operation 4 - Update student
student.setName("Susu-Updated");
//Persistence Context(student++,passport++)
}
}
| [
"infinite"
] | infinite |
3238435ed77373213295153309094ef639d54ebd | f7ecc8b7061edaa4c9fc9c2f45356f74f84f5cfa | /src/main/java/com/fave100/server/exceptions/NotLoggedInException.java | 66f61ce5618994dd5343326c8babfaf069a91ac8 | [] | no_license | yissachar/fave100 | e50a12259c591ea2c80d02100a26237d9a53af34 | b37c6e83c01289953759b34aefd5905ab72997b8 | refs/heads/master | 2022-08-09T07:07:29.568614 | 2021-01-24T21:34:23 | 2021-01-24T21:34:23 | 5,497,782 | 1 | 2 | null | 2023-06-05T14:46:41 | 2012-08-21T16:28:44 | Java | UTF-8 | Java | false | false | 401 | java | package com.fave100.server.exceptions;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import com.fave100.server.api.ApiExceptions;
@SuppressWarnings("serial")
public class NotLoggedInException extends WebApplicationException {
public NotLoggedInException() {
super(Response.status(Response.Status.UNAUTHORIZED).entity(ApiExceptions.NOT_LOGGED_IN).build());
}
}
| [
"yissachar.radcliffe@caseware.com"
] | yissachar.radcliffe@caseware.com |
dc7b89c096a5ceb011aa2e085bd2515e75857be0 | c3702bbe4f5954e6cada88996bd814b82e9b2668 | /src/main/java/Hotel.java | ee0d5fc051ad47670d7a88eba18a3fe411e54be8 | [] | no_license | venkatavineela/BusinessGame | a5c8d453324e34ca70d7ec0b4d6c234b1f32f957 | 3d2ab3f43649d4980e2d91cb026df1e0407828fe | refs/heads/master | 2020-04-02T10:11:47.186908 | 2018-10-23T13:00:31 | 2018-10-23T13:00:31 | 154,328,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 842 | java | import java.util.Objects;
class Hotel implements Cell{
Player owner;
boolean isBooked = false;
public void doBusiness(Player player){
if(!isBooked) {
if (player.currentMoney >= 200) {
player.currentMoney -= 200;
owner = player;
isBooked = true;
}
} else {
player.currentMoney -= 50;
owner.currentMoney += 50;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Hotel hotel = (Hotel) o;
return isBooked == hotel.isBooked &&
Objects.equals(owner, hotel.owner);
}
@Override
public int hashCode() {
return Objects.hash(owner, isBooked);
}
}
| [
"vineela.vini421.vv@gmail.com"
] | vineela.vini421.vv@gmail.com |
19612533bde0f89c6c4ac48e61c7ee86bea979af | aca9bfd690b55b682475e6710ab361af9ac2709d | /services-hz/src/main/java/ru/taskurotta/service/hz/adapter/notification/tasks/UpdateSubscriptionRunnable.java | 7558c6c069ed85e8fcc879f87a19337a1a2241d8 | [
"MIT"
] | permissive | JLLeitschuh/taskurotta | fd838aa23a8f9afdef9bb2e9185579f58a8565db | 0e1f1eda2f93a723c6d77f3842e732c6c886c109 | refs/heads/master | 2021-01-02T21:12:32.682367 | 2020-01-16T08:24:28 | 2020-01-16T08:24:28 | 239,803,397 | 0 | 0 | null | 2020-11-17T18:51:04 | 2020-02-11T15:59:45 | null | UTF-8 | Java | false | false | 696 | java | package ru.taskurotta.service.hz.adapter.notification.tasks;
import ru.taskurotta.service.hz.adapter.notification.HzNotificationDaoAdapter;
import ru.taskurotta.service.notification.model.Subscription;
import java.io.Serializable;
/**
* Created on 15.06.2015.
*/
public class UpdateSubscriptionRunnable implements Runnable, Serializable {
private Subscription subscription;
private long id;
public UpdateSubscriptionRunnable(Subscription subscription, long id) {
this.subscription = subscription;
this.id = id;
}
@Override
public void run() {
HzNotificationDaoAdapter.getRealNotificationsDao().updateSubscription(subscription, id);
}
}
| [
"dimadin@gmail.com"
] | dimadin@gmail.com |
c75a52a904bf51ec86c73204de2ae602e1ef1919 | e4565f6eaa525a308ea3c43a6e05c933d537e3c5 | /src/simulation/Simulation.java | 03261e5eafa16886da343ac6a570eead040e894c | [] | no_license | wisdomleck/swen30006-assign-1 | d7c18dff62f4b6ec398cb80a9216d8abe499c80b | 2a85664564cf49f53a9b021bfcdc5adfa14ea300 | refs/heads/master | 2023-04-06T21:31:27.831993 | 2021-04-19T07:05:46 | 2021-04-19T07:05:46 | 357,838,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,854 | java | package simulation;
import exceptions.ExcessiveDeliveryException;
import exceptions.ItemTooHeavyException;
import exceptions.MailAlreadyDeliveredException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Properties;
import com.unimelb.swen30006.wifimodem.WifiModem;
import automail.Automail;
import automail.MailItem;
import automail.MailPool;
/**
* This class simulates the behaviour of AutoMail
*/
public class Simulation {
private static int NUM_ROBOTS;
private static double CHARGE_THRESHOLD;
private static boolean CHARGE_DISPLAY;
/** Constant for the mail generator */
private static int MAIL_TO_CREATE;
private static int MAIL_MAX_WEIGHT;
private static ArrayList<MailItem> MAIL_DELIVERED;
private static double total_delay = 0;
private static WifiModem wModem = null;
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
/** Load properties for simulation based on either default or a properties file.**/
Properties automailProperties = setUpProperties();
//An array list to record mails that have been delivered
MAIL_DELIVERED = new ArrayList<MailItem>();
/** This code section below is to save a random seed for generating mails.
* If a program argument is entered, the first argument will be a random seed.
* If not a random seed will be from a properties file.
* Otherwise, no a random seed. */
/** Used to see whether a seed is initialized or not */
HashMap<Boolean, Integer> seedMap = new HashMap<>();
if (args.length == 0 ) { // No arg
String seedProp = automailProperties.getProperty("Seed");
if (seedProp == null) { // and no property
seedMap.put(false, 0); // so randomise
} else { // Use property seed
seedMap.put(true, Integer.parseInt(seedProp));
}
} else { // Use arg seed - overrides property
seedMap.put(true, Integer.parseInt(args[0]));
}
Integer seed = seedMap.get(true);
System.out.println("#A Random Seed: " + (seed == null ? "null" : seed.toString()));
// Install the modem & turn on the modem
try {
System.out.println("Setting up Wifi Modem");
wModem = WifiModem.getInstance(Building.MAILROOM_LOCATION);
System.out.println(wModem.Turnon());
} catch (Exception mException) {
mException.printStackTrace();
}
/**
* This code section is for running a simulation
*/
/* Instantiate MailPool and Automail */
boolean chargeDisplayed = Boolean.parseBoolean(automailProperties.getProperty("ChargeDisplay"));
double markUpPercentage = Double.parseDouble(automailProperties.getProperty("markUpPercentage"));
double activityUnitPrice = Double.parseDouble(automailProperties.getProperty("activityUnitPrice"));
double chargeThreshold = Double.parseDouble(automailProperties.getProperty("ChargeThreshold"));
MailPool mailPool = new MailPool(NUM_ROBOTS, wModem, chargeDisplayed, markUpPercentage, activityUnitPrice, chargeThreshold);
Automail automail = new Automail(mailPool, new ReportDelivery(), NUM_ROBOTS);
MailGenerator mailGenerator = new MailGenerator(MAIL_TO_CREATE, MAIL_MAX_WEIGHT, mailPool, seedMap);
/** Generate all the mails */
mailGenerator.generateAllMail();
while(MAIL_DELIVERED.size() != mailGenerator.MAIL_TO_CREATE) {
// System.out.printf("Delivered: %4d; Created: %4d%n", MAIL_DELIVERED.size(), mailGenerator.MAIL_TO_CREATE);
mailGenerator.addToMailPool();
try {
automail.mailPool.loadItemsToRobot();
for (int i=0; i < NUM_ROBOTS; i++) {
automail.robots[i].operate();
}
} catch (ExcessiveDeliveryException|ItemTooHeavyException e) {
e.printStackTrace();
System.out.println("Simulation unable to complete.");
System.exit(0);
}
Clock.Tick();
}
printResults();
wModem.Turnoff();
System.out.print(mailPool.getCharge().getStats());
}
static private Properties setUpProperties() throws IOException {
Properties automailProperties = new Properties();
// Default properties
automailProperties.setProperty("Robots", "Standard");
automailProperties.setProperty("Floors", "10");
automailProperties.setProperty("Mail_to_Create", "80");
automailProperties.setProperty("ChargeThreshold", "0");
automailProperties.setProperty("ChargeDisplay", "false");
automailProperties.setProperty("markUpPercentage", "0.059");
automailProperties.setProperty("activityUnitPrice", "0.224");
// Read properties
FileReader inStream = null;
try {
inStream = new FileReader("automail.properties");
automailProperties.load(inStream);
} finally {
if (inStream != null) {
inStream.close();
}
}
// Floors
Building.FLOORS = Integer.parseInt(automailProperties.getProperty("Floors"));
System.out.println("#Floors: " + Building.FLOORS);
// Mail_to_Create
MAIL_TO_CREATE = Integer.parseInt(automailProperties.getProperty("Mail_to_Create"));
System.out.println("#Created mails: " + MAIL_TO_CREATE);
// Mail_to_Create
MAIL_MAX_WEIGHT = Integer.parseInt(automailProperties.getProperty("Mail_Max_Weight"));
System.out.println("#Maximum weight: " + MAIL_MAX_WEIGHT);
// Last_Delivery_Time
Clock.MAIL_RECEVING_LENGTH = Integer.parseInt(automailProperties.getProperty("Mail_Receving_Length"));
System.out.println("#Mail receiving length: " + Clock.MAIL_RECEVING_LENGTH);
// Robots
NUM_ROBOTS = Integer.parseInt(automailProperties.getProperty("Robots"));
System.out.print("#Robots: "); System.out.println(NUM_ROBOTS);
assert(NUM_ROBOTS > 0);
// Charge Threshold
CHARGE_THRESHOLD = Double.parseDouble(automailProperties.getProperty("ChargeThreshold"));
System.out.println("#Charge Threshold: " + CHARGE_THRESHOLD);
// Charge Display
CHARGE_DISPLAY = Boolean.parseBoolean(automailProperties.getProperty("ChargeDisplay"));
System.out.println("#Charge Display: " + CHARGE_DISPLAY);
return automailProperties;
}
static class ReportDelivery implements IMailDelivery {
/** Confirm the delivery and calculate the total score */
public void deliver(MailItem deliveryItem, String charges){
if(!MAIL_DELIVERED.contains(deliveryItem)){
MAIL_DELIVERED.add(deliveryItem);
System.out.printf("T: %3d > Delivered(%4d) [%s%s]%n", Clock.Time(), MAIL_DELIVERED.size(), deliveryItem.toString(), charges);
// Calculate delivery score
total_delay += calculateDeliveryDelay(deliveryItem);
}
else{
try {
throw new MailAlreadyDeliveredException();
} catch (MailAlreadyDeliveredException e) {
e.printStackTrace();
}
}
}
}
private static double calculateDeliveryDelay(MailItem deliveryItem) {
// Penalty for longer delivery times
final double penalty = 1.2;
double priority_weight = 0;
// Take (delivery time - arrivalTime)**penalty * (1+sqrt(priority_weight))
return Math.pow(Clock.Time() - deliveryItem.getArrivalTime(),penalty)*(1+Math.sqrt(priority_weight));
}
// Something we need to change for the added statistics
public static void printResults(){
System.out.println("T: "+Clock.Time()+" | Simulation complete!");
System.out.println("Final Delivery time: "+Clock.Time());
System.out.printf("Delay: %.2f%n", total_delay);
}
}
| [
"sharankrishnan6@gmail.com"
] | sharankrishnan6@gmail.com |
e2a78f403da8a3ec643ed8387750a836156b21c5 | 2939349e2509fb55f824166dc0ee394bd0dd378c | /curso-java/exercicios/src/controle/DesafioFor.java | e532049f330cf46e8e9ffe59eaec1d90675e0580 | [] | no_license | thiagofb84jp/coding-day-by-day | 5342fd5ab679c578d5fff171aca960a82c64b5ae | a0c9000b18fd4f8dfa70cf51f0c072c407a86a41 | refs/heads/master | 2022-12-26T07:07:53.165477 | 2020-08-31T11:58:15 | 2020-08-31T11:58:15 | 231,764,382 | 2 | 0 | null | 2022-12-11T01:51:35 | 2020-01-04T13:04:46 | HTML | IBM852 | Java | false | false | 397 | java | package controle;
public class DesafioFor {
public static void main(String[] args) {
String valor = "#";
System.out.println("Entrando no primeiro lašo...");
for (int i = 1; i <= 5; i++) {
System.out.println(valor);
valor+= "#";
}
System.out.println("Entrando no segundo lašo...");
for(String v = "#"; !v.equals("#####"); v += "#") {
System.out.println(v);
}
}
} | [
"thiagofb84jp@gmail.com"
] | thiagofb84jp@gmail.com |
02784bfde8c92a6f2f4fdde5aea3622a2953d36a | a4a39f1000c2bf44cb56cec71c7e217ecfb29531 | /team/simon/SimpleWiFiDirectChat/app/src/main/java/com/example/simplewifidirectchat/WiFiDirectBroadcastReceiver.java | 837c156bd057cd716f4197a7406ddfffefd160db | [
"MIT"
] | permissive | leontabak/network-notes | ca11272f0446db202f6f9b324a26a019036684f9 | c5ec22f30163b4dcea3f051d50008dc1902179d0 | refs/heads/master | 2021-01-13T10:17:26.473298 | 2016-10-29T18:32:05 | 2016-10-29T18:32:05 | 69,833,692 | 0 | 25 | null | 2016-10-29T18:33:01 | 2016-10-03T01:50:55 | HTML | UTF-8 | Java | false | false | 2,821 | java | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.simplewifidirectchat;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.p2p.WifiP2pDevice;
import android.net.wifi.p2p.WifiP2pManager;
import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.util.Log;
/**
* A BroadcastReceiver that notifies of important wifi p2p events.
*/
public class WiFiDirectBroadcastReceiver extends BroadcastReceiver {
private WifiP2pManager manager;
private Channel channel;
private MainActivity activity;
/**
* @param manager WifiP2pManager system service
* @param channel Wifi p2p channel
*/
public WiFiDirectBroadcastReceiver(WifiP2pManager manager, Channel channel, MainActivity activity) {
super();
this.manager = manager;
this.channel = channel;
this.activity = activity;
}
/*
* (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context,
* android.content.Intent)
*/
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
// UI update to indicate wifi p2p status.
int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
activity.setIsWifiP2pEnabled(true);
} else {
activity.setIsWifiP2pEnabled(false);
}
} else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
if (manager == null) {
return;
}
manager.requestConnectionInfo(channel, activity);
// we are connected with the other device, request connection
// info to find group owner IP
} else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
WifiP2pDevice device = (WifiP2pDevice) intent
.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE);
}
}
} | [
"Simon Fink"
] | Simon Fink |
52edd2d80b7eabdbf6db3c185d566ebadd38944c | 9b9a20351b032637c9be67b6b9fddda8c8dc1d91 | /src/gui/TakeCardDialog.java | 7026f713e7c66ff984b44c4d3a691f97acf4a4a6 | [] | no_license | hawkinscm/Munchkin | 623d870c53773e04e01df78a7e958eb600516c43 | 82f148420e422fad22042bad5cced80fa779d9e9 | refs/heads/master | 2020-12-30T14:56:21.862639 | 2015-07-25T22:04:18 | 2015-07-25T22:04:18 | 39,704,090 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,172 | java |
package gui;
import gui.components.CardPanel;
import gui.components.CustomButton;
import gui.components.CustomDialog;
import gui.components.Messenger;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import ai.AICardEvaluator;
import ai.AIManager;
import ai.AIValuedCard;
import model.GM;
import model.Player;
import model.PlayerType;
import model.Randomizer;
import model.card.Card;
import model.card.DoorCard;
import model.card.TreasureCard;
/**
* Dialog that allows a player to take a card from another player to either keep or discard.
*/
public class TakeCardDialog extends CustomDialog {
private static final long serialVersionUID = 1L;
// Enumerator of the possible locations or types to take from
public enum DrawLocation {
HAND,
CARRIED,
EITHER,
TREASURE;
}
// GUI controls for displaying information and getting user input
private CardPanel cardPanel;
private CustomButton takeButton;
private CustomButton doneButton;
private JLabel warningLabel;
// list of cards to choose from
private LinkedList<Card> cards;
// location where the card can be chosen from
private DrawLocation currentLocation;
// whether or not the taker needs to discard the taken card
private boolean isDiscard;
private Player victim;
private Player taker;
private DrawLocation location;
private boolean isHandVisible = false;
/**
* Creates a new TakeCardDialog dialog.
* @param victim the player who will lose a card
* @param taker the player who is taking a card
* @param location the location where the card may be taken from
* @param visibleCards whether or not the taker is allowed to see the cards when choosing what to take
* @param isDiscard whether or not the taker
*/
public TakeCardDialog(final Player v, final Player t, final DrawLocation loc, boolean visibleCards, boolean discard) {
super("Take A Card");
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
victim = v;
taker = t;
location = loc;
isHandVisible = visibleCards;
isDiscard = discard;
if (taker.isComputer())
return;
// initialize variables and display GUI controls
cardPanel = null;
c.gridwidth = 2;
// create a prompt to inform the taker what he is allowed to take
String type = "a card";
if (location == DrawLocation.CARRIED)
type = "an item";
else if (location == DrawLocation.EITHER)
type += " or item";
else if (location == DrawLocation.TREASURE)
type = "a Treasure card";
final JLabel infoLabel = new JLabel(taker.getName() + ", take " + type + " from " + victim.getName());
getContentPane().add(infoLabel, c);
c.gridy = 2;
// warn the taker about the restrictions on Big Items
warningLabel = new JLabel("WARNING: If you take a Big Item that you cannot carry, it will be discarded!");
getContentPane().add(warningLabel, c);
warningLabel.setVisible(false);
// Button that lets the taker take the selected Card
takeButton = new CustomButton("Take Card") {
private static final long serialVersionUID = 1L;
public void buttonPressed() {
Card card = cardPanel.getSelectedCard();
// if required, discard the taken card
if (isDiscard) {
victim.discard(card);
DisplayCardsDialog viewCardDialog = new DisplayCardsDialog(card, "Discarded");
viewCardDialog.setVisible(true);
}
else if (currentLocation == DrawLocation.HAND) {
victim.getHandCards().remove(card);
taker.getHandCards().add(card);
(new InHandDialog(taker, card)).setVisible(true);
}
else if (currentLocation == DrawLocation.CARRIED) {
if (!victim.removeEquipmentItem(card))
if (!victim.getCarriedItems().remove(card))
victim.setHirelingCard(null);
taker.addItem((TreasureCard)card);
}
else {
if (!victim.getHandCards().remove(card))
if (!victim.removeEquipmentItem(card))
if (!victim.getCarriedItems().remove(card))
victim.setHirelingCard(null);
taker.getHandCards().add(card);
(new InHandDialog(taker, card)).setVisible(true);
}
dispose();
}
};
// Button that signals that the taker is done taking and closes the dialog
doneButton = new CustomButton("Done") {
private static final long serialVersionUID = 1L;
public void buttonPressed() {
dispose();
}
};
doneButton.setEnabled(false);
c.gridwidth = 1;
c.gridy = 1;
c.insets.right = 0;
// If the taker can take from either the victim's hand or carried items,
// provides radio button options to select where card will be taken from.
JRadioButton handButton = new JRadioButton("Hand");
handButton.setSelected(true);
handButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Load Cards from the victim's hand
currentLocation = DrawLocation.HAND;
warningLabel.setVisible(false);
if (cardPanel != null)
getContentPane().remove(cardPanel);
cards = new LinkedList<Card>();
if (location == DrawLocation.TREASURE) {
for (Card handCard : victim.getHandCards())
if (handCard instanceof TreasureCard)
cards.add(handCard);
}
else
cards.addAll(victim.getHandCards());
if (isHandVisible)
cardPanel = new CardPanel(cards, 2, takeButton, doneButton);
else
setHiddenCardPanel(cards);
getContentPane().add(cardPanel, c);
refresh();
}
});
JRadioButton carriedButton = new JRadioButton("Carried");
carriedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Load Cards from the player's carried items
currentLocation = DrawLocation.CARRIED;
if (!isDiscard)
warningLabel.setVisible(true);
if (cardPanel != null)
getContentPane().remove(cardPanel);
cards = new LinkedList<Card>();
cards.addAll(victim.getAllItems());
if (location == DrawLocation.TREASURE && victim.hasHireling())
cards.add(victim.getHirelingCard());
cardPanel = new CardPanel(cards, 2, takeButton, doneButton);
getContentPane().add(cardPanel, c);
refresh();
}
});
ButtonGroup group = new ButtonGroup();
group.add(handButton);
group.add(carriedButton);
c.gridx = 0;
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(handButton);
radioPanel.add(carriedButton);
getContentPane().add(radioPanel, c);
radioPanel.setVisible(false);
c.gridx = 1;
// if the victim has no cards in the location where the card may be taken from, the taker gets nothing.
// If so inform the players and show only button to close dialog.
if (location == DrawLocation.HAND) {
currentLocation = DrawLocation.HAND;
if (victim.getHandCards().size() == 0) {
String resultMsg = taker.getName() + " gets nothing.";
if (isDiscard)
resultMsg = "nothing to discard.";
infoLabel.setText(victim.getName() + " ran out of cards; " + resultMsg);
c.gridy++;
getContentPane().add(doneButton, c);
doneButton.setEnabled(true);
}
else
handButton.doClick();
}
else if (location == DrawLocation.CARRIED) {
currentLocation = DrawLocation.CARRIED;
if (victim.getAllItems().size() == 0) {
String resultMsg = taker.getName() + " gets nothing.";
if (isDiscard)
resultMsg = "nothing to discard.";
infoLabel.setText(victim.getName() + " ran out of cards, " + resultMsg);
c.gridy++;
doneButton.setEnabled(true);
getContentPane().add(doneButton, c);
}
else
carriedButton.doClick();
}
else if (location == DrawLocation.EITHER || location == DrawLocation.TREASURE) {
radioPanel.setVisible(true);
if (location == DrawLocation.TREASURE) {
int numTreasureCards = 0;
for (Card handCard : victim.getHandCards())
if (handCard instanceof TreasureCard)
numTreasureCards++;
if (numTreasureCards == 0)
handButton.setEnabled(false);
}
else if (victim.getHandCards().size() == 0)
handButton.setEnabled(false);
if (victim.getAllItems().size() == 0)
carriedButton.setEnabled(false);
if (location == DrawLocation.TREASURE && victim.hasHireling())
carriedButton.setEnabled(true);
if (!handButton.isEnabled() && !carriedButton.isEnabled()) {
String resultMsg = taker.getName() + " gets nothing.";
if (isDiscard)
resultMsg = "nothing to discard.";
infoLabel.setText(victim.getName() + " ran out of cards, " + resultMsg);
c.gridy++;
doneButton.setEnabled(true);
getContentPane().add(doneButton, c);
}
else if (handButton.isEnabled())
handButton.doClick();
else
carriedButton.doClick();
}
if (isDiscard && !taker.isComputer()) {
warningLabel.setVisible(false);
takeButton.setText("Discard");
}
refresh();
}
@Override
public void setVisible(boolean b) {
if (taker.isComputer()) {
double playerFactor = 1.0;
if (taker.getPlayerType() == PlayerType.COMPUTER_HARD) {
playerFactor = GM.getPlayers().size() - AIManager.getRankedPlayers().indexOf(victim);
playerFactor /= (double)GM.getPlayers().size();
playerFactor *= 2.0;
}
// Get list of all possible cards that can be taken, sorted from greatest to least value
// Base card values on whether or not you can see the card, personal benefit, and a factored victim cost
LinkedList<AIValuedCard> mostValuedCards = new LinkedList<AIValuedCard>();
if (location == DrawLocation.HAND && !isHandVisible) {
// Take random card or nothing if hand is empty
if (!victim.getHandCards().isEmpty()) {
Card cardToTake = victim.getHandCards().get(Randomizer.getRandom(victim.getHandCards().size()));
if (isDiscard) {
victim.discard(cardToTake);
String message = taker + " chose to discard " + victim + "'s " + cardToTake + " card.";
Messenger.display(message, "Take A Card");
}
else {
String cardType = "door";
if (cardToTake instanceof TreasureCard)
cardType = "treasure";
String message = taker + " chose to take one of " + victim + "'s " + cardType + " cards.";
Messenger.display(message, "Take A Card");
victim.getHandCards().remove(cardToTake);
taker.getHandCards().add(cardToTake);
AIManager.playHandCard(taker, cardToTake);
}
}
return;
}
if (location != DrawLocation.CARRIED) {
for (Card handCard : victim.getHandCards()) {
if (location == DrawLocation.TREASURE && !(handCard instanceof TreasureCard))
continue;
int cardValue = 0;
if (!isDiscard) {
cardValue = AIManager.UNKNOWN_CARD_VALUE;
if (isHandVisible)
cardValue = AICardEvaluator.getCardValueToPlayer(handCard, taker, taker.getHandCards());
}
// only evaluate card value to victim, if victim is not dead and taker is a medium/hard computer
if (location != DrawLocation.EITHER) {
if (taker.getPlayerType() == PlayerType.COMPUTER_MEDIUM ||
taker.getPlayerType() == PlayerType.COMPUTER_HARD) {
if (isHandVisible)
cardValue += AICardEvaluator.getCardValueToPlayer(handCard, victim, victim.getHandCards()) * playerFactor;
else
cardValue += AIManager.UNKNOWN_CARD_VALUE * playerFactor;
}
}
else if (isDiscard) {
if (isHandVisible)
cardValue += AICardEvaluator.getCardValueToPlayer(handCard, victim, victim.getHandCards()) * playerFactor;
else
cardValue += AIManager.UNKNOWN_CARD_VALUE * playerFactor;
}
AIValuedCard valuedCard = new AIValuedCard(handCard, cardValue);
int cardIdx;
for (cardIdx = 0; cardIdx < mostValuedCards.size(); cardIdx++)
if (cardValue > mostValuedCards.get(cardIdx).getValue())
break;
mostValuedCards.add(cardIdx, valuedCard);
}
}
if (location != DrawLocation.HAND) {
for (Card item : victim.getAllItems()) {
int itemValue = 0;
if (!isDiscard)
itemValue = AICardEvaluator.getCardValueToPlayer(item, taker, taker.getHandCards());
// only evaluate card value to victim, if victim is not dead and taker is a medium/hard computer
if (location != DrawLocation.EITHER) {
if (taker.getPlayerType() == PlayerType.COMPUTER_MEDIUM ||
taker.getPlayerType() == PlayerType.COMPUTER_HARD) {
LinkedList<Card> handCards = null;
if (isHandVisible)
handCards = victim.getHandCards();
itemValue += AICardEvaluator.getCardValueToPlayer(item, victim, handCards) * playerFactor;
}
}
else if (isDiscard) {
LinkedList<Card> handCards = null;
if (isHandVisible)
handCards = victim.getHandCards();
itemValue += AICardEvaluator.getCardValueToPlayer(item, victim, handCards) * playerFactor;
}
AIValuedCard valuedCard = new AIValuedCard(item, itemValue);
int cardIdx;
for (cardIdx = 0; cardIdx < mostValuedCards.size(); cardIdx++)
if (itemValue > mostValuedCards.get(cardIdx).getValue())
break;
mostValuedCards.add(cardIdx, valuedCard);
}
}
if ((location == DrawLocation.EITHER || location == DrawLocation.TREASURE) && victim.hasHireling()) {
int cardValue = 0;
if (!isDiscard)
cardValue = AICardEvaluator.getCardValueToPlayer(victim.getHirelingCard(), taker, taker.getHandCards());
// only evaluate card value to victim, if victim is not dead and taker is a medium/hard computer
if (location != DrawLocation.EITHER) {
if (taker.getPlayerType() == PlayerType.COMPUTER_MEDIUM ||
taker.getPlayerType() == PlayerType.COMPUTER_HARD) {
LinkedList<Card> handCards = null;
if (isHandVisible)
handCards = victim.getHandCards();
cardValue += AICardEvaluator.getCardValueToPlayer(victim.getHirelingCard(), victim, handCards) * playerFactor;
}
}
else if (isDiscard) {
LinkedList<Card> handCards = null;
if (isHandVisible)
handCards = victim.getHandCards();
cardValue += AICardEvaluator.getCardValueToPlayer(victim.getHirelingCard(), victim, handCards) * playerFactor;
}
AIValuedCard valuedCard = new AIValuedCard(victim.getHirelingCard(), cardValue);
int cardIdx;
for (cardIdx = 0; cardIdx < mostValuedCards.size(); cardIdx++)
if (cardValue > mostValuedCards.get(cardIdx).getValue())
break;
mostValuedCards.add(cardIdx, valuedCard);
}
if (mostValuedCards.isEmpty())
return;
Card cardToTake = mostValuedCards.getFirst().getCard();
if (isDiscard) {
victim.discard(cardToTake);
String message = taker + " chose to discard " + victim + "'s " + cardToTake + " card";
Messenger.display(message, "Take A Card");
return;
}
String message = taker + " chose to take " + victim + "'s " + cardToTake + " card";
Messenger.display(message, "Take A Card");
if (location == DrawLocation.HAND) {
victim.getHandCards().remove(cardToTake);
taker.getHandCards().add(cardToTake);
AIManager.playHandCard(taker, cardToTake);
}
else if (location == DrawLocation.CARRIED) {
if (!victim.removeEquipmentItem(cardToTake))
if (!victim.getCarriedItems().remove(cardToTake))
victim.setHirelingCard(null);
taker.addItem((TreasureCard)cardToTake);
}
else {
if (!victim.getHandCards().remove(cardToTake))
if (!victim.removeEquipmentItem(cardToTake))
if (!victim.getCarriedItems().remove(cardToTake))
victim.setHirelingCard(null);
taker.getHandCards().add(cardToTake);
AIManager.playHandCard(taker, cardToTake);
}
}
else
super.setVisible(b);
}
/**
* If the taker is not allowed to see the cards when choosing from them, this method hides the card info from
* being displayed by overriding the display methods.
* @param cards the list of cards that can be taken
*/
private void setHiddenCardPanel(LinkedList<Card> cards) {
cardPanel = new CardPanel(cards, 2, takeButton, doneButton) {
private static final long serialVersionUID = 1L;
@Override
protected JLabel addNewImageLabel(Card card) {
Image image = null;
if (card instanceof DoorCard)
image = new ImageIcon(GUI.class.getResource("images/DoorCard.jpg")).getImage();
else
image = new ImageIcon(GUI.class.getResource("images/TreasureCard.jpg")).getImage();
return addNewImageLabel(image);
}
@Override
protected void setSelectedImageLabel(JLabel imageLabel) {
super.setSelectedImageLabel(imageLabel);
Card card = getSelectedCard();
if (card instanceof DoorCard)
mainImageLabel.setIcon(new ImageIcon(GUI.class.getResource("images/DoorCard.jpg")));
else
mainImageLabel.setIcon(new ImageIcon(GUI.class.getResource("images/TreasureCard.jpg")));
}
};
}
}
| [
"codyhawkins@hotmail.com"
] | codyhawkins@hotmail.com |
bca7a16f0298c0925acef92c0d77c52389e4e376 | 17e8438486cb3e3073966ca2c14956d3ba9209ea | /dso/tags/2.6-stable2/code/base/ui-eclipse/src/org/terracotta/dso/ResourceDeltaVisitor.java | adbe9cab6d6cb5b7b135abaec6e5936eb71f463d | [] | no_license | sirinath/Terracotta | fedfc2c4f0f06c990f94b8b6c3b9c93293334345 | 00a7662b9cf530dfdb43f2dd821fa559e998c892 | refs/heads/master | 2021-01-23T05:41:52.414211 | 2015-07-02T15:21:54 | 2015-07-02T15:21:54 | 38,613,711 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,089 | java | /*
* All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
*/
package org.terracotta.dso;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.terracotta.dso.actions.BuildBootJarAction;
import org.terracotta.dso.actions.ManageServerAction;
import org.terracotta.dso.dialogs.RelaunchDialog;
import com.tc.server.ServerConstants;
import com.terracottatech.config.Server;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Invoked when a project resource change occurs. First test to see if
* the config file content changed and, if so, clear the config session
* information. Next check if a module has been compiled and, if so, inspect
* the module for terracotta artifacts.
*
* @see org.eclipse.core.resources.IResourceDeltaVisitor
* @see org.eclipse.ui.IWorkbench.addResourceChangeListener
* @see TcPlugin.ResourceListener
*/
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
private static final boolean debug = Boolean.getBoolean("ResourceDeltaVisitor.debug");
boolean fIgnoreNextConfigChange;
public boolean visit(IResourceDelta delta) {
final TcPlugin plugin = TcPlugin.getDefault();
int kind = delta.getKind();
int flags = delta.getFlags();
IResource res = delta.getResource();
final IProject project = res.getProject();
if (debug) {
dump(delta);
}
if (plugin == null || !plugin.hasTerracottaNature(project)) { return true; }
switch (kind) {
case IResourceDelta.CHANGED: {
if ((flags & IResourceDelta.MARKERS) != 0) { return false; }
if ((flags & IResourceDelta.CONTENT) != 0) {
if (res instanceof IFile) {
IFile file = (IFile) res;
IPath path = file.getLocation();
String ext = path.getFileExtension();
int segmentCount = path.segmentCount();
if (segmentCount == 2 && path.segment(segmentCount - 1).equals(".classpath")) {
final IJavaProject javaProject = JavaCore.create(project);
if (BootClassHelper.canGetBootTypes(javaProject)) {
plugin.setBootClassHelper(project, new BootClassHelper(javaProject));
} else {
Job job = new Job("Building bootjar") {
public IStatus run(IProgressMonitor monitor) {
try {
new BuildBootJarAction(javaProject).run(monitor);
} catch (Exception e) {
plugin.openError("Building bootjar", e);
}
return Status.OK_STATUS;
}
};
job.schedule();
}
return false;
}
if (ext.equals("xml")) {
if (plugin.getConfigurationFile(project).equals(res)) {
final boolean queryRestart = plugin.getQueryRestartOption(project);
final boolean wasIgnoringChange = fIgnoreNextConfigChange;
if (fIgnoreNextConfigChange) {
fIgnoreNextConfigChange = false;
}
try {
if (!wasIgnoringChange) {
Job job = new Job("Reloading DSO Configuration") {
public IStatus run(IProgressMonitor monitor) {
plugin.reloadConfiguration(project);
if (queryRestart) {
queryRelaunchAll(project);
}
return Status.OK_STATUS;
}
};
job.schedule();
} else if (queryRestart) {
Job job = new Job("Restart?") {
public IStatus run(IProgressMonitor monitor) {
queryRelaunchAll(project);
return Status.OK_STATUS;
}
};
job.schedule();
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
}
}
break;
}
case IResourceDelta.ADDED: {
if ((flags & IResourceDelta.MOVED_FROM) != 0) {
if (res instanceof IFile) {
plugin.fileMoved((IFile) res, delta.getMovedFromPath());
}
} else if (res instanceof IProject) {
IProject aProject = (IProject) res;
if (plugin.getConfigurationFile(aProject) == null) {
plugin.staleProjectAdded(aProject);
}
}
break;
}
case IResourceDelta.REMOVED: {
if ((flags & IResourceDelta.MOVED_TO) == 0) {
if (res instanceof IFile) {
plugin.fileRemoved((IFile) res);
}
}
break;
}
}
return true;
}
private void queryRelaunchAll(final IProject project) {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
final List<ILaunch> launches = new ArrayList<ILaunch>();
final List<ILaunch> serverLaunches = new ArrayList<ILaunch>();
for (ILaunch launch : launchManager.getLaunches()) {
IProcess[] processes = launch.getProcesses();
if (launch.isTerminated() || processes == null || processes.length == 0) continue;
ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
try {
String mainClass = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
(String) null);
if (mainClass != null && mainClass.equals(ServerConstants.SERVER_MAIN_CLASS_NAME)) {
String projName = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
if (projName.equals(project.getName())) {
serverLaunches.add(launch);
}
} else {
ILaunchConfigurationType launchConfigType = launchConfig.getType();
String id = launchConfigType.getIdentifier();
if (id.equals("launch.configurationDelegate")) {
String projName = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
(String) null);
if (projName != null && projName.equals(project.getName())) {
launches.add(launch);
}
}
}
} catch (CoreException ce) {/**/
}
}
if (launches.size() > 0 || serverLaunches.size() > 0) {
final Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
final Shell shell = Display.getCurrent().getActiveShell();
RelaunchDialog relaunchDialog = new RelaunchDialog(shell, project, serverLaunches, launches);
final int returnCode = relaunchDialog.open();
if (returnCode == RelaunchDialog.CONTINUE_ID) { return; }
new Job("Restarting Terracotta") {
public IStatus run(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
ArrayList<ILaunch> allLaunches = new ArrayList<ILaunch>(launches);
allLaunches.addAll(serverLaunches);
for (ILaunch launch : allLaunches) {
safeTerminateLaunch(launch);
}
if (returnCode == RelaunchDialog.TERMINATE_ID) { return Status.OK_STATUS; }
for (Iterator<ILaunch> iter = serverLaunches.iterator(); iter.hasNext();) {
try {
ILaunch launch = iter.next();
Server server = TcPlugin.getDefault().getLaunchedServer(project, launch);
if(server != null) {
ManageServerAction msa = new ManageServerAction(JavaCore.create(project), server);
msa.run(monitor);
} else {
final String launchName = launch.getLaunchConfiguration().getName();
display.syncExec(new Runnable() {
public void run() {
String msg = "Unable to locate config element for server '"+launchName+".' Cancelling client restart.";
MessageDialog.openInformation(shell, "Terracotta", msg);
}
});
return Status.OK_STATUS;
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (ILaunch launch : launches) {
ILaunchConfiguration launchConfig = launch.getLaunchConfiguration();
try {
launchConfig.launch(launch.getLaunchMode(), monitor);
} catch (CoreException ce) {
ce.printStackTrace();
}
}
return Status.OK_STATUS;
}
}.schedule();
}
});
}
}
private static void safeTerminateLaunch(ILaunch launch) {
try {
launch.terminate();
} catch (DebugException de) {
/**/
}
}
private void dump(IResourceDelta delta) {
int kind = delta.getKind();
int flags = delta.getFlags();
StringBuffer sb = new StringBuffer();
sb.append(delta.getResource().getFullPath());
switch (kind) {
case IResourceDelta.NO_CHANGE:
sb.append(" NO_CHANGE");
break;
case IResourceDelta.ADDED:
sb.append(" ADDED");
break;
case IResourceDelta.REMOVED:
sb.append(" REMOVED");
break;
case IResourceDelta.CHANGED:
sb.append(" CHANGED");
break;
case IResourceDelta.ADDED_PHANTOM:
sb.append(" ADDED_PHANTOM");
break;
case IResourceDelta.REMOVED_PHANTOM:
sb.append(" REMOVED_PHANTOM");
break;
}
if ((flags & IResourceDelta.CONTENT) != 0) {
sb.append(" CONTENT");
}
if ((flags & IResourceDelta.MOVED_FROM) != 0) {
sb.append(" MOVED_FROM");
}
if ((flags & IResourceDelta.MOVED_TO) != 0) {
sb.append(" MOVED_TO");
}
if ((flags & IResourceDelta.OPEN) != 0) {
sb.append(" OPEN");
}
if ((flags & IResourceDelta.TYPE) != 0) {
sb.append(" TYPE");
}
if ((flags & IResourceDelta.SYNC) != 0) {
sb.append(" SYNC");
}
if ((flags & IResourceDelta.MARKERS) != 0) {
sb.append(" MARKERS");
}
if ((flags & IResourceDelta.REPLACED) != 0) {
sb.append(" REPLACED");
}
if ((flags & IResourceDelta.DESCRIPTION) != 0) {
sb.append(" DESCRIPTION");
}
if ((flags & IResourceDelta.ENCODING) != 0) {
sb.append(" ENCODING");
}
System.out.println(sb.toString());
}
}
| [
"hhuynh@7fc7bbf3-cf45-46d4-be06-341739edd864"
] | hhuynh@7fc7bbf3-cf45-46d4-be06-341739edd864 |
d703e195424d8258cd35800b7f78da8287ea61d0 | f0f794d2e7e8bc1acb8914b8359d6cf65b5eb6b6 | /simulationFund/src/Main.java | f4f7fe90f257a0a78987fad9da1c0f84620a99e3 | [] | no_license | sqlwp/lwpTest | daf62e9b325a1defd896aa06fdcd6f435a5cee07 | dc1bd612d25c28317fba0ddb469f582374135cc7 | refs/heads/master | 2021-05-19T03:52:37.840255 | 2020-04-28T10:40:56 | 2020-04-28T10:40:56 | 251,516,531 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,542 | java | /**
* @ClassName 模拟基金定投
* @Description 模拟基金定投
* @Author sq_lw
* @Date 2020/4/26 14:54
* @Version 1.0
*/
public class Main {
public static void main(String[] args) {
//投资本金
double myMoney = 1000.00;
//基础净值
double originalNetWorth = 1.00;
//累计增涨
double sumGroup = 0.00;
//累计下降
double sumDecline = 0.00;
//综合涨幅
double synthesizeGroup = 0.00;
//模拟天数
int days = 300;
//模拟涨跌项(增涨会多一些)
double[] randomGroup = {-0.01, -0.02, -0.02, -0.02, -0.02, -0.03, 0.01, 0.02, 0.02, 0.02, 0.02, 0.03, 0.03};
//昨日涨跌幅
double yesterday = 0.00;
//定投金额
double addMoney = 10.00;
//累计定投金额
double synthesizeaddMoney=0.00;
//模拟定投
for (int i = 1; i <= days; i++) {
//产生随机涨跌幅
int index = (int) (Math.random() * randomGroup.length);
double random = randomGroup[index];
yesterday = random;
//叠加累计涨幅
synthesizeGroup = synthesizeGroup + random;
synthesizeGroup = Double.parseDouble(String.format("%.2f", synthesizeGroup));
//叠加累计涨跌幅,并定投今日的金额
if (random > 0) {
sumGroup += random;
sumGroup = Double.parseDouble(String.format("%.2f", sumGroup));
} else {
sumDecline += random;
sumDecline = Double.parseDouble(String.format("%.2f", sumDecline));
addMoney = 20.00;
}
//计算截止昨日的本金+利润
myMoney = myMoney * (1 + yesterday);
myMoney = Double.parseDouble(String.format("%.2f", myMoney));
synthesizeaddMoney += addMoney;
synthesizeaddMoney = Double.parseDouble(String.format("%.2f", synthesizeaddMoney));
myMoney = myMoney + addMoney;
}
System.out.println("累计增涨:" + sumGroup);
System.out.println("累计下降:" + sumDecline);
System.out.println("综合涨幅:" + synthesizeGroup);
System.out.println("累计定投金额:" + synthesizeaddMoney);
System.out.println("毛利+本金:" + myMoney);
System.out.println("毛利:" + (myMoney-synthesizeaddMoney-100));
}
}
| [
"sq_lwp@163.com"
] | sq_lwp@163.com |
4efc50cf31438416e4a68224d41861d9a4ed9a14 | eb87a6874a3b1ceba4ec3418114e5edf88ac889a | /android/app/build/generated/not_namespaced_r_class_sources/debug/r/androidx/loader/R.java | 7412ed791db1aa77c9bb6b62fa214f9f601b244e | [] | no_license | poncho02/rn-movies | 34e1d93328403639a54c150039a7091f79ed800b | 6c302cdee16da5af9c3ca02f517d99d7fc12a3c8 | refs/heads/master | 2023-01-19T10:48:06.423916 | 2020-11-30T03:22:30 | 2020-11-30T03:22:30 | 317,094,372 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,446 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* gradle plugin from the resource data it found. It
* should not be modified by hand.
*/
package androidx.loader;
public final class R {
private R() {}
public static final class attr {
private attr() {}
public static final int alpha = 0x7f03002b;
public static final int font = 0x7f030120;
public static final int fontProviderAuthority = 0x7f030122;
public static final int fontProviderCerts = 0x7f030123;
public static final int fontProviderFetchStrategy = 0x7f030124;
public static final int fontProviderFetchTimeout = 0x7f030125;
public static final int fontProviderPackage = 0x7f030126;
public static final int fontProviderQuery = 0x7f030127;
public static final int fontStyle = 0x7f030128;
public static final int fontVariationSettings = 0x7f030129;
public static final int fontWeight = 0x7f03012a;
public static final int ttcIndex = 0x7f030272;
}
public static final class color {
private color() {}
public static final int notification_action_color_filter = 0x7f0500a6;
public static final int notification_icon_bg_color = 0x7f0500a7;
public static final int ripple_material_light = 0x7f0500b1;
public static final int secondary_text_default_material_light = 0x7f0500b3;
}
public static final class dimen {
private dimen() {}
public static final int compat_button_inset_horizontal_material = 0x7f060053;
public static final int compat_button_inset_vertical_material = 0x7f060054;
public static final int compat_button_padding_horizontal_material = 0x7f060055;
public static final int compat_button_padding_vertical_material = 0x7f060056;
public static final int compat_control_corner_material = 0x7f060057;
public static final int compat_notification_large_icon_max_height = 0x7f060058;
public static final int compat_notification_large_icon_max_width = 0x7f060059;
public static final int notification_action_icon_size = 0x7f06012e;
public static final int notification_action_text_size = 0x7f06012f;
public static final int notification_big_circle_margin = 0x7f060130;
public static final int notification_content_margin_start = 0x7f060131;
public static final int notification_large_icon_height = 0x7f060132;
public static final int notification_large_icon_width = 0x7f060133;
public static final int notification_main_column_padding_top = 0x7f060134;
public static final int notification_media_narrow_margin = 0x7f060135;
public static final int notification_right_icon_size = 0x7f060136;
public static final int notification_right_side_padding_top = 0x7f060137;
public static final int notification_small_icon_background_padding = 0x7f060138;
public static final int notification_small_icon_size_as_large = 0x7f060139;
public static final int notification_subtext_size = 0x7f06013a;
public static final int notification_top_pad = 0x7f06013b;
public static final int notification_top_pad_large_text = 0x7f06013c;
}
public static final class drawable {
private drawable() {}
public static final int notification_action_background = 0x7f070081;
public static final int notification_bg = 0x7f070082;
public static final int notification_bg_low = 0x7f070083;
public static final int notification_bg_low_normal = 0x7f070084;
public static final int notification_bg_low_pressed = 0x7f070085;
public static final int notification_bg_normal = 0x7f070086;
public static final int notification_bg_normal_pressed = 0x7f070087;
public static final int notification_icon_background = 0x7f070088;
public static final int notification_template_icon_bg = 0x7f070089;
public static final int notification_template_icon_low_bg = 0x7f07008a;
public static final int notification_tile_bg = 0x7f07008b;
public static final int notify_panel_notification_icon_bg = 0x7f07008c;
}
public static final class id {
private id() {}
public static final int action_container = 0x7f080038;
public static final int action_divider = 0x7f08003a;
public static final int action_image = 0x7f08003b;
public static final int action_text = 0x7f080041;
public static final int actions = 0x7f080042;
public static final int async = 0x7f080048;
public static final int blocking = 0x7f08004b;
public static final int chronometer = 0x7f080059;
public static final int forever = 0x7f080087;
public static final int icon = 0x7f080090;
public static final int icon_group = 0x7f080091;
public static final int info = 0x7f080094;
public static final int italic = 0x7f080095;
public static final int line1 = 0x7f08009a;
public static final int line3 = 0x7f08009b;
public static final int normal = 0x7f0800c1;
public static final int notification_background = 0x7f0800c2;
public static final int notification_main_column = 0x7f0800c3;
public static final int notification_main_column_container = 0x7f0800c4;
public static final int right_icon = 0x7f0800d4;
public static final int right_side = 0x7f0800d5;
public static final int tag_transition_group = 0x7f08010f;
public static final int tag_unhandled_key_event_manager = 0x7f080110;
public static final int tag_unhandled_key_listeners = 0x7f080111;
public static final int text = 0x7f080114;
public static final int text2 = 0x7f080115;
public static final int time = 0x7f08011f;
public static final int title = 0x7f080120;
}
public static final class integer {
private integer() {}
public static final int status_bar_notification_info_maxnum = 0x7f090016;
}
public static final class layout {
private layout() {}
public static final int notification_action = 0x7f0b004a;
public static final int notification_action_tombstone = 0x7f0b004b;
public static final int notification_template_custom_big = 0x7f0b004c;
public static final int notification_template_icon_group = 0x7f0b004d;
public static final int notification_template_part_chronometer = 0x7f0b004e;
public static final int notification_template_part_time = 0x7f0b004f;
}
public static final class string {
private string() {}
public static final int status_bar_notification_info_overflow = 0x7f0e0083;
}
public static final class style {
private style() {}
public static final int TextAppearance_Compat_Notification = 0x7f0f0161;
public static final int TextAppearance_Compat_Notification_Info = 0x7f0f0162;
public static final int TextAppearance_Compat_Notification_Line2 = 0x7f0f0163;
public static final int TextAppearance_Compat_Notification_Time = 0x7f0f0164;
public static final int TextAppearance_Compat_Notification_Title = 0x7f0f0165;
public static final int Widget_Compat_NotificationActionContainer = 0x7f0f024b;
public static final int Widget_Compat_NotificationActionText = 0x7f0f024c;
}
public static final class styleable {
private styleable() {}
public static final int[] ColorStateListItem = { 0x10101a5, 0x101031f, 0x7f03002b };
public static final int ColorStateListItem_android_color = 0;
public static final int ColorStateListItem_android_alpha = 1;
public static final int ColorStateListItem_alpha = 2;
public static final int[] FontFamily = { 0x7f030122, 0x7f030123, 0x7f030124, 0x7f030125, 0x7f030126, 0x7f030127 };
public static final int FontFamily_fontProviderAuthority = 0;
public static final int FontFamily_fontProviderCerts = 1;
public static final int FontFamily_fontProviderFetchStrategy = 2;
public static final int FontFamily_fontProviderFetchTimeout = 3;
public static final int FontFamily_fontProviderPackage = 4;
public static final int FontFamily_fontProviderQuery = 5;
public static final int[] FontFamilyFont = { 0x1010532, 0x1010533, 0x101053f, 0x101056f, 0x1010570, 0x7f030120, 0x7f030128, 0x7f030129, 0x7f03012a, 0x7f030272 };
public static final int FontFamilyFont_android_font = 0;
public static final int FontFamilyFont_android_fontWeight = 1;
public static final int FontFamilyFont_android_fontStyle = 2;
public static final int FontFamilyFont_android_ttcIndex = 3;
public static final int FontFamilyFont_android_fontVariationSettings = 4;
public static final int FontFamilyFont_font = 5;
public static final int FontFamilyFont_fontStyle = 6;
public static final int FontFamilyFont_fontVariationSettings = 7;
public static final int FontFamilyFont_fontWeight = 8;
public static final int FontFamilyFont_ttcIndex = 9;
public static final int[] GradientColor = { 0x101019d, 0x101019e, 0x10101a1, 0x10101a2, 0x10101a3, 0x10101a4, 0x1010201, 0x101020b, 0x1010510, 0x1010511, 0x1010512, 0x1010513 };
public static final int GradientColor_android_startColor = 0;
public static final int GradientColor_android_endColor = 1;
public static final int GradientColor_android_type = 2;
public static final int GradientColor_android_centerX = 3;
public static final int GradientColor_android_centerY = 4;
public static final int GradientColor_android_gradientRadius = 5;
public static final int GradientColor_android_tileMode = 6;
public static final int GradientColor_android_centerColor = 7;
public static final int GradientColor_android_startX = 8;
public static final int GradientColor_android_startY = 9;
public static final int GradientColor_android_endX = 10;
public static final int GradientColor_android_endY = 11;
public static final int[] GradientColorItem = { 0x10101a5, 0x1010514 };
public static final int GradientColorItem_android_color = 0;
public static final int GradientColorItem_android_offset = 1;
}
}
| [
"poncho.12@hotmail.com"
] | poncho.12@hotmail.com |
85788fea1757dbb235cbd42db4e053fe617ad914 | 17a65a05f7a84b27caccab83b66654d343a0aa4d | /src/main/java/assignment/service/SecurityService.java | 1124b6a3bee4b3a8832fe97d222209385f4876cc | [] | no_license | dasha1994/techassignment | 387a221ca019df540f143ada48b48448aa82b72e | 1c0fc38ded071c67a2f12177e3db3fe1820c327b | refs/heads/master | 2020-04-23T14:55:51.364683 | 2019-02-18T08:54:35 | 2019-02-18T08:54:35 | 171,248,408 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 120 | java | package assignment.service;
public interface SecurityService {
void autologin(String username, String password);
}
| [
"kozy.dasha@gmail.com"
] | kozy.dasha@gmail.com |
169a17ca43f0fa2ff3bc515b26771a081591eb92 | 19109ff2a3df6d6326680509ddd1b97ce4618f88 | /app/src/main/java/in/siteurl/www/saifinance/activities/ConnectivityReceiver.java | a3b4c082668a870f0c1338f3e1a76197d4fb6904 | [] | no_license | SowmyaSiteurl/SaiFinancials | 95945dbb12ea35bf1637f9787179f994585871a2 | 6dbbd1fe6aa073e42823a79c6ca646da68cd30ca | refs/heads/master | 2020-03-19T07:33:34.215267 | 2018-06-05T05:28:31 | 2018-06-05T05:28:31 | 136,124,605 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,591 | java | package in.siteurl.www.saifinance.activities;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* Created by siteurl on 10/5/18.
*/
public class ConnectivityReceiver extends BroadcastReceiver {
//to check internet connection
public static ConnectivityReceiverListener connectivityReceiverListener;
public ConnectivityReceiver() {
super();
}
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null
&& activeNetwork.isConnectedOrConnecting();
if (connectivityReceiverListener != null) {
connectivityReceiverListener.onNetworkConnectionChanged(isConnected);
}
}
//to check internet connection
public static boolean isConnected() {
ConnectivityManager
cm = (ConnectivityManager) MyApplication.getInstance().getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null
&& activeNetwork.isConnectedOrConnecting();
}
public interface ConnectivityReceiverListener {
void onNetworkConnectionChanged(boolean isConnected);
}
}
| [
"sowmya@siteurl.in"
] | sowmya@siteurl.in |
046c4b9e57b3bd716b6549b1d42c8c19b7bc408e | d1f6c96effd079e610e4b188c96e179165a5f1c9 | /src/test/java/com/gft/repository/HistoryDaoTest.java | 96ac3fa626a0d3a7bed12e7a9c4855ce85fb2ddc | [] | no_license | ivooz/Algo-Trader | 53f1f75f114773921bfe26078c40be1cbd09edb4 | 142793f08bda8d81e5c8b7d8151b5ea845c2174c | refs/heads/master | 2020-04-01T22:39:54.366197 | 2015-10-21T13:53:55 | 2015-10-21T13:53:55 | 44,163,774 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,295 | java | package com.gft.repository;
import com.gft.config.Application;
import com.gft.model.db.Stock;
import com.gft.model.db.StockHistory;
import com.gft.repository.data.StockHistoryRepository;
import com.gft.repository.data.StockRepository;
import com.gft.service.DataAccessException;
import com.gft.service.downloading.DataDownloadService;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static junit.framework.TestCase.*;
/**
* Created by iozi on 14/10/2015.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {Application.class})
@WebAppConfiguration
public class HistoryDaoTest {
private static final Logger logger = LoggerFactory.getLogger(HistoryDaoTest.class);
@Autowired
DataDownloadService dataDownloadService;
@Autowired
StockHistoryRepository stockHistoryRepository;
@Autowired
@Qualifier("databaseHistoryDao")
HistoryDAO databaseHistoryDao;
ForwardableHistoryDAO memoryHistoryDao;
@Autowired
StockRepository stockRepository;
Stock stock = new Stock();
@Before
public void init() {
memoryHistoryDao = new MemoryHistoryDao(dataDownloadService,stockHistoryRepository);
stock.setTicker("MSFT");
stock.setAlgorithms(new ArrayList<>());
stock.setType("equity");
stock.setFullName("Microsoft");
stockRepository.save(stock);
}
@Test
public void testMemoryDaoIntervalSafeguard() {
for(int i=0; i<9;i++) {
try {
memoryHistoryDao.forwardHistory();
List<StockHistory> historyList = memoryHistoryDao.obtainStockHistoryForPeriod(stock,11);
fail();
} catch (InsufficientDataException | DataAccessException ex) {
}
}
try {
List<StockHistory> historyList = memoryHistoryDao.obtainStockHistoryForPeriod(stock,10);
assertEquals(10,historyList.size());
} catch (InsufficientDataException | DataAccessException ex) {
logger.error("Test failed!",ex);
fail();
}
}
@Test
public void testDatabaseDao() {
List<StockHistory> stockHistories = null;
try {
memoryHistoryDao.obtainStockHistoryForPeriod(stock,1);
stockHistories = databaseHistoryDao.obtainStockHistoryForPeriod(stock, 10);
} catch (InsufficientDataException | DataAccessException ex) {
logger.error("Test failed!",ex);
fail();
}
assertEquals(10, stockHistories.size());
}
//TODO update tests below
// @Test
public void testCurrentDaysMemoryHistoryDao() {
try {
Date date = memoryHistoryDao.getCurrentDay(stock).getDate();
List<StockHistory> stockHistories = memoryHistoryDao.obtainStockHistoryForPeriod(stock, 1);
assertTrue(DateUtils.isSameDay(stockHistories.get(0).getDate(), date));
stockHistories = memoryHistoryDao.obtainStockHistoryForPeriod(stock, 1);
assertFalse(DateUtils.isSameDay(stockHistories.get(0).getDate(), date));
} catch (InsufficientDataException | DataAccessException ex) {
logger.error("Test failed!", ex);
fail();
}
}
// @Test
public void testCurrentDaysDatabaseHistoryDao() {
try {
memoryHistoryDao.obtainStockHistoryForPeriod(stock, 1);
assertTrue(DateUtils.isSameDay(databaseHistoryDao.getCurrentDay(stock).getDate(),
databaseHistoryDao.obtainStockHistoryForPeriod(stock, 1).get(0).getDate()));
} catch (InsufficientDataException | DataAccessException ex) {
logger.error("Test failed!", ex);
fail();
}
}
}
| [
"iozi@PCLLE124.gft.com"
] | iozi@PCLLE124.gft.com |
92c44e47200cd4717e02795cf664c4a93b8203fe | 3f2f49dc7c25858424e9e8947a8375d19ecdbf98 | /src/main/java/com/deepspc/arena/modular/system/mapper/RoleMapper.java | 74cf4f681332a10cf4f37084befdc3ba03f54ac8 | [] | no_license | didoguan/arena | 08f1488565f569cfbea307e1b187e232ebcd0d82 | 9c89236a141cd2549f95197e5013c07bb01d2fbf | refs/heads/master | 2022-10-27T13:27:52.235732 | 2019-06-18T12:16:15 | 2019-06-18T12:16:15 | 186,578,014 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,236 | java | package com.deepspc.arena.modular.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deepspc.arena.core.common.node.ZTreeNode;
import com.deepspc.arena.modular.system.entity.Role;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 角色表 Mapper 接口
* </p>
*/
public interface RoleMapper extends BaseMapper<Role> {
/**
* 根据条件查询角色列表
*
* @return
* @date 2017年2月12日 下午9:14:34
*/
Page<Map<String, Object>> selectRoles(@Param("page") Page page, @Param("condition") String condition);
/**
* 删除某个角色的所有权限
*
* @param roleId 角色id
* @return
* @date 2017年2月13日 下午7:57:51
*/
int deleteRolesById(@Param("roleId") Long roleId);
/**
* 获取角色列表树
*
* @return
* @date 2017年2月18日 上午10:32:04
*/
List<ZTreeNode> roleTreeList();
/**
* 获取角色列表树
*
* @return
* @date 2017年2月18日 上午10:32:04
*/
List<ZTreeNode> roleTreeListByRoleId(String[] roleId);
}
| [
"didoguan@163.com"
] | didoguan@163.com |
d963e457154e935b9326c9b3ebba1d9ab8a3d990 | f3bc507e7d57cb56efbb9a991aa961158af86fef | /src/tgcommon/src/com/alachisoft/tayzgrid/common/configuration/ConfigurationRootAnnotation.java | ea432027af75860f0c70c4ae0ba9755d439476c5 | [
"Apache-2.0"
] | permissive | Alachisoft/TayzGrid | 28163c092d246312393b56684f47d72ed8a25964 | 1cd2cdfff485a08f329c44150a5f02d8a98255cc | refs/heads/master | 2020-12-24T13:28:46.946083 | 2015-11-13T08:11:28 | 2015-11-13T08:11:28 | 37,905,036 | 11 | 10 | null | null | null | null | UTF-8 | Java | false | false | 1,030 | java | /*
* Copyright (c) 2015, Alachisoft. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alachisoft.tayzgrid.common.configuration;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.lang.model.element.Element;
@Target(value =
{
ElementType.TYPE, ElementType.METHOD
})
@Retention(RetentionPolicy.RUNTIME)
public @interface ConfigurationRootAnnotation
{
String value();
}
| [
"tayzgrid.dev@alachisoft.com"
] | tayzgrid.dev@alachisoft.com |
4ab40ef211a0120d7e8f2ef7cc17d9dd9e7b65d2 | 2142c24701dc8be506355b562d35c71d6a309f8f | /Uebung2SOLID/src/main/java/OpenClosedPrinciple/LogUtils.java | 504860fe900c0bb42e7526961a503e09194f8984 | [] | no_license | alexandertiedmann/Studium-SoftwareEngineering | 7868def5c5132061bfddec45155c05f189bc010b | 2b8c5cf0ef7ec8189557c5b52c003010d837ea58 | refs/heads/master | 2020-12-03T02:02:55.561782 | 2017-06-30T15:02:19 | 2017-06-30T15:02:19 | 95,898,067 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,398 | java | /*
* Log Utilities
* Code-Beispiel zum Buch Patterns Kompakt, Verlag Springer Vieweg
* Copyright 2013 Karl Eilebrecht
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package OpenClosedPrinciple;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Some utility methods related to java logging.
*
* @author <a href="mailto:Karl.Eilebrecht(a/t)web.de">Karl Eilebrecht</a>
*/
public final class LogUtils {
/**
* Utility class
*/
private LogUtils() {
// no instances
}
/**
* Adjust the console handler's log level, especially useful in some IDEs.
*
* @param level required level
*/
public static void setConsoleHandlerLogLevel(Level level) {
Logger rootLogger = java.util.logging.Logger.getLogger("");
// find console handler, if any
for (Handler handler : rootLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
handler.setLevel(level);
return;
}
}
// ok, we need a new console handler
ConsoleHandler consoleHandler = new ConsoleHandler();
rootLogger.addHandler(consoleHandler);
consoleHandler.setLevel(level);
}
/**
* Sets the log level related to multiple loggers.
*
* @param level new level to set
* @param loggers one or more loggers
*/
public static void setLogLevel(Level level, Logger... loggers) {
for (Logger logger : loggers) {
logger.setLevel(level);
}
}
/**
* Sets the log level related to multiple classes assuming the class name as the related logger's name.
*
* @param level new level to set
* @param classes one or more classes
*/
public static void setLogLevel(Level level, Class<?>... classes) {
for (Class<?> cls : classes) {
Logger.getLogger(cls.getName()).setLevel(level);
}
}
}
| [
"alexander@tiedmann.berlin"
] | alexander@tiedmann.berlin |
46482244d541a033c928319856b786303df733d6 | e34842c76654e515694d2c20e0ced225ebd8fab9 | /Module9/TowerOfHanoi3.java | 0b307c590623539fa52ab19c115a0fc10abc370e | [] | no_license | CS1112IS/Katherine | 8f0eb5b6e057c6e69614c25f24ea3f0479443f9a | dca73865216ade85f76568c3854b2d9c6eaaf5d3 | refs/heads/master | 2021-01-01T17:10:25.791447 | 2014-06-24T17:00:07 | 2014-06-24T17:00:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,588 | java |
public class TowerOfHanoi3 {
public static int x = 0;
public static void main (String[] argv)
{
// A 5-disk puzzle:
solveHanoi (4, 0, 1);
}
static void solveHanoi (int n, int i, int j)
{
// Bottom-out.
if (n == 0) {
// The smallest disk.
move (0, i, j);
return;
}
int k = other (i, j);
solveHanoi (n-1, i, k); // Step 1.
move (n, i, j); // Step 2.
solveHanoi (n-1, k, j); // Step 3.
}
static void move (int n, int i, int j)
{
char m = ' ';
switch(n) {
case 0: m = 'A';
break;
case 1: m = 'B';
break;
case 2: m = 'C';
break;
case 3: m = 'D';
break;
case 4: m = 'E';
break;
default: m = 'w';
break;
}
System.out.println("Day " + x + " - " + "use disk " + m);
x++;
// INSERT YOUR CODE HERE.
// Before printing, convert n=0 to 'A', n=1 to 'B' etc.
}
static int other (int i, int j)
{
// Given two towers, return the third.
if ( (i == 0) && (j == 1) ) {
return 2;
}
else if ( (i == 1) && (j == 0) ) {
return 2;
}
else if ( (i == 1) && (j == 2) ) {
return 0;
}
else if ( (i == 2) && (j == 1) ) {
return 0;
}
else if ( (i == 0) && (j == 2) ) {
return 1;
}
else if ( (i == 2) && (j == 0) ) {
return 1;
}
// We shouldn't reach here.
return -1;
}
}
| [
"katherine@katherines-mbp.gateway.2wire.net"
] | katherine@katherines-mbp.gateway.2wire.net |
4b35feddf7a094b29dca1a102ea2ca6270d2f258 | 6ceada0d6310f41ebd2387eed1413975f611ab55 | /icy/common/NotifyListener.java | a35b6f863efcc969b8079711c5c0a8cd21fa5b8e | [] | no_license | zeb/Icy-Kernel | 441484a5f862e50cf4992b5a06f35447cd748eda | d2b296e043c77da31d27b8f0242d007b3e5e17e2 | refs/heads/master | 2021-01-16T22:46:48.889696 | 2013-03-18T13:30:43 | 2013-03-18T13:30:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | /*
* Copyright 2010, 2011 Institut Pasteur.
*
* This file is part of ICY.
*
* ICY is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ICY is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ICY. If not, see <http://www.gnu.org/licenses/>.
*/
package icy.common;
/**
* @deprecated uses {@link icy.common.listener.NotifyListener} instead
*/
@Deprecated
public interface NotifyListener extends icy.common.listener.NotifyListener
{
}
| [
"stephane.dallongeville@pasteur.fr"
] | stephane.dallongeville@pasteur.fr |
2ec909a94ac444c34218f1b18c4ee6916e919a89 | 5cbdcaf1742c95bb20807fb15d95db7eadf253a6 | /src/main/java/org/sonar/plugins/findbugs/language/package-info.java | 99c015cda603d2d08a249e1d7dbc09c1cdd1f9b0 | [] | no_license | spotbugs/sonar-findbugs | bfdca28f8b3b730fdfe6296214be967cbd34c5f0 | 127466b8752c36cb1a1de8f9ed4b2928c392a70c | refs/heads/master | 2023-08-28T14:04:56.090991 | 2023-04-27T17:41:07 | 2023-04-27T17:41:07 | 21,345,670 | 267 | 122 | null | 2023-04-12T11:38:52 | 2014-06-30T09:16:02 | Java | UTF-8 | Java | false | false | 332 | java | /**
* This package and subpackage is reusing the lexer from the plugin Sonar-Web plugin.
*
* It is license under the GNU Lesser General Public License, Version 3.0
* https://github.com/SonarSource/sonar-web
* For special uses, contact the original owner. (see sonar-web/pom.xml)
*/
package org.sonar.plugins.findbugs.language; | [
"parteau@gosecure.ca"
] | parteau@gosecure.ca |
ddaf20750168b011fb35dac5cb99d015af383228 | b632d1119c77672131580585519bcf7600a57f39 | /src/main/java/com/spring/boot/apidoc/config/ItemDocEdit.java | acbc4cb2e5920872da7e0b1eb1911a7ffeb56536 | [] | no_license | yudr31/apiDoc | bbd62ff0aad37a598e4821778998b52677fe92f1 | 7e0d1b9056a8bb713bebaeb8ad09d7f004c34189 | refs/heads/master | 2021-03-30T21:03:55.360339 | 2018-03-12T09:11:04 | 2018-03-12T09:11:04 | 124,861,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package com.spring.boot.apidoc.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author yuderen
* @version 2018/3/12 11:16
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ItemDocEdit {
}
| [
"yuderen6312@163.com"
] | yuderen6312@163.com |
c4c80607b02c3580f3fad568bac653ed43450767 | 7ceb1a8c892ad088e785ae3d3c10af4d5c4d5dda | /core/java/android/view/WindowOrientationListener.java | 1837c8b1b5d1ce3af8287a52d1693f04ebc0cee6 | [
"LicenseRef-scancode-unicode",
"Apache-2.0"
] | permissive | iamcalledned/platform_frameworks_base_pre404 | d8c50fdf7ca95475036ceac7f053cb349456b152 | 45fa454fd70cb55125081b2c961f676391807d03 | refs/heads/master | 2020-04-06T04:48:17.531468 | 2012-03-22T03:31:38 | 2012-03-22T03:31:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 28,491 | java | /*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import android.util.Slog;
/**
* A special helper class used by the WindowManager
* for receiving notifications from the SensorManager when
* the orientation of the device has changed.
*
* NOTE: If changing anything here, please run the API demo
* "App/Activity/Screen Orientation" to ensure that all orientation
* modes still work correctly.
*
* You can also visualize the behavior of the WindowOrientationListener by
* enabling the window orientation listener log using the Development Settings
* in the Dev Tools application (Development.apk)
* and running frameworks/base/tools/orientationplot/orientationplot.py.
*
* More information about how to tune this algorithm in
* frameworks/base/tools/orientationplot/README.txt.
*
* @hide
*/
public abstract class WindowOrientationListener {
private static final String TAG = "WindowOrientationListener";
private static final boolean DEBUG = false;
private static final boolean localLOGV = DEBUG || false;
private SensorManager mSensorManager;
private boolean mEnabled;
private int mRate;
private Sensor mSensor;
private SensorEventListenerImpl mSensorEventListener;
boolean mLogEnabled;
int mCurrentRotation = -1;
/**
* Creates a new WindowOrientationListener.
*
* @param context for the WindowOrientationListener.
*/
public WindowOrientationListener(Context context) {
this(context, SensorManager.SENSOR_DELAY_UI);
}
/**
* Creates a new WindowOrientationListener.
*
* @param context for the WindowOrientationListener.
* @param rate at which sensor events are processed (see also
* {@link android.hardware.SensorManager SensorManager}). Use the default
* value of {@link android.hardware.SensorManager#SENSOR_DELAY_NORMAL
* SENSOR_DELAY_NORMAL} for simple screen orientation change detection.
*
* This constructor is private since no one uses it.
*/
private WindowOrientationListener(Context context, int rate) {
mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
mRate = rate;
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (mSensor != null) {
// Create listener only if sensors do exist
mSensorEventListener = new SensorEventListenerImpl(this);
}
}
/**
* Enables the WindowOrientationListener so it will monitor the sensor and call
* {@link #onOrientationChanged} when the device orientation changes.
*/
public void enable() {
if (mSensor == null) {
Log.w(TAG, "Cannot detect sensors. Not enabled");
return;
}
if (mEnabled == false) {
if (localLOGV) Log.d(TAG, "WindowOrientationListener enabled");
mSensorManager.registerListener(mSensorEventListener, mSensor, mRate);
mEnabled = true;
}
}
/**
* Disables the WindowOrientationListener.
*/
public void disable() {
if (mSensor == null) {
Log.w(TAG, "Cannot detect sensors. Invalid disable");
return;
}
if (mEnabled == true) {
if (localLOGV) Log.d(TAG, "WindowOrientationListener disabled");
mSensorManager.unregisterListener(mSensorEventListener);
mEnabled = false;
}
}
/**
* Sets the current rotation.
*
* @param rotation The current rotation.
*/
public void setCurrentRotation(int rotation) {
mCurrentRotation = rotation;
}
/**
* Gets the proposed rotation.
*
* This method only returns a rotation if the orientation listener is certain
* of its proposal. If the rotation is indeterminate, returns -1.
*
* @return The proposed rotation, or -1 if unknown.
*/
public int getProposedRotation() {
if (mEnabled) {
return mSensorEventListener.getProposedRotation();
}
return -1;
}
/**
* Returns true if sensor is enabled and false otherwise
*/
public boolean canDetectOrientation() {
return mSensor != null;
}
/**
* Called when the rotation view of the device has changed.
*
* This method is called whenever the orientation becomes certain of an orientation.
* It is called each time the orientation determination transitions from being
* uncertain to being certain again, even if it is the same orientation as before.
*
* @param rotation The new orientation of the device, one of the Surface.ROTATION_* constants.
* @see Surface
*/
public abstract void onProposedRotationChanged(int rotation);
/**
* Enables or disables the window orientation listener logging for use with
* the orientationplot.py tool.
* Logging is usually enabled via Development Settings. (See class comments.)
* @param enable True to enable logging.
*/
public void setLogEnabled(boolean enable) {
mLogEnabled = enable;
}
/**
* This class filters the raw accelerometer data and tries to detect actual changes in
* orientation. This is a very ill-defined problem so there are a lot of tweakable parameters,
* but here's the outline:
*
* - Low-pass filter the accelerometer vector in cartesian coordinates. We do it in
* cartesian space because the orientation calculations are sensitive to the
* absolute magnitude of the acceleration. In particular, there are singularities
* in the calculation as the magnitude approaches 0. By performing the low-pass
* filtering early, we can eliminate high-frequency impulses systematically.
*
* - Convert the acceleromter vector from cartesian to spherical coordinates.
* Since we're dealing with rotation of the device, this is the sensible coordinate
* system to work in. The zenith direction is the Z-axis, the direction the screen
* is facing. The radial distance is referred to as the magnitude below.
* The elevation angle is referred to as the "tilt" below.
* The azimuth angle is referred to as the "orientation" below (and the azimuth axis is
* the Y-axis).
* See http://en.wikipedia.org/wiki/Spherical_coordinate_system for reference.
*
* - If the tilt angle is too close to horizontal (near 90 or -90 degrees), do nothing.
* The orientation angle is not meaningful when the device is nearly horizontal.
* The tilt angle thresholds are set differently for each orientation and different
* limits are applied when the device is facing down as opposed to when it is facing
* forward or facing up.
*
* - When the orientation angle reaches a certain threshold, consider transitioning
* to the corresponding orientation. These thresholds have some hysteresis built-in
* to avoid oscillations between adjacent orientations.
*
* - Wait for the device to settle for a little bit. Once that happens, issue the
* new orientation proposal.
*
* Details are explained inline.
*/
static final class SensorEventListenerImpl implements SensorEventListener {
// We work with all angles in degrees in this class.
private static final float RADIANS_TO_DEGREES = (float) (180 / Math.PI);
// Indices into SensorEvent.values for the accelerometer sensor.
private static final int ACCELEROMETER_DATA_X = 0;
private static final int ACCELEROMETER_DATA_Y = 1;
private static final int ACCELEROMETER_DATA_Z = 2;
private final WindowOrientationListener mOrientationListener;
/* State for first order low-pass filtering of accelerometer data.
* See http://en.wikipedia.org/wiki/Low-pass_filter#Discrete-time_realization for
* signal processing background.
*/
private long mLastTimestamp = Long.MAX_VALUE; // in nanoseconds
private float mLastFilteredX, mLastFilteredY, mLastFilteredZ;
// The current proposal. We wait for the proposal to be stable for a
// certain amount of time before accepting it.
//
// The basic idea is to ignore intermediate poses of the device while the
// user is picking up, putting down or turning the device.
private int mProposalRotation;
private long mProposalAgeMS;
// A historical trace of tilt and orientation angles. Used to determine whether
// the device posture has settled down.
private static final int HISTORY_SIZE = 20;
private int mHistoryIndex; // index of most recent sample
private int mHistoryLength; // length of historical trace
private final long[] mHistoryTimestampMS = new long[HISTORY_SIZE];
private final float[] mHistoryMagnitudes = new float[HISTORY_SIZE];
private final int[] mHistoryTiltAngles = new int[HISTORY_SIZE];
private final int[] mHistoryOrientationAngles = new int[HISTORY_SIZE];
// The maximum sample inter-arrival time in milliseconds.
// If the acceleration samples are further apart than this amount in time, we reset the
// state of the low-pass filter and orientation properties. This helps to handle
// boundary conditions when the device is turned on, wakes from suspend or there is
// a significant gap in samples.
private static final float MAX_FILTER_DELTA_TIME_MS = 1000;
// The acceleration filter time constant.
//
// This time constant is used to tune the acceleration filter such that
// impulses and vibrational noise (think car dock) is suppressed before we
// try to calculate the tilt and orientation angles.
//
// The filter time constant is related to the filter cutoff frequency, which is the
// frequency at which signals are attenuated by 3dB (half the passband power).
// Each successive octave beyond this frequency is attenuated by an additional 6dB.
//
// Given a time constant t in seconds, the filter cutoff frequency Fc in Hertz
// is given by Fc = 1 / (2pi * t).
//
// The higher the time constant, the lower the cutoff frequency, so more noise
// will be suppressed.
//
// Filtering adds latency proportional the time constant (inversely proportional
// to the cutoff frequency) so we don't want to make the time constant too
// large or we can lose responsiveness.
private static final float FILTER_TIME_CONSTANT_MS = 100.0f;
/* State for orientation detection. */
// Thresholds for minimum and maximum allowable deviation from gravity.
//
// If the device is undergoing external acceleration (being bumped, in a car
// that is turning around a corner or a plane taking off) then the magnitude
// may be substantially more or less than gravity. This can skew our orientation
// detection by making us think that up is pointed in a different direction.
//
// Conversely, if the device is in freefall, then there will be no gravity to
// measure at all. This is problematic because we cannot detect the orientation
// without gravity to tell us which way is up. A magnitude near 0 produces
// singularities in the tilt and orientation calculations.
//
// In both cases, we postpone choosing an orientation.
private static final float MIN_ACCELERATION_MAGNITUDE =
SensorManager.STANDARD_GRAVITY * 0.5f;
private static final float MAX_ACCELERATION_MAGNITUDE =
SensorManager.STANDARD_GRAVITY * 1.5f;
// Maximum absolute tilt angle at which to consider orientation data. Beyond this (i.e.
// when screen is facing the sky or ground), we completely ignore orientation data.
private static final int MAX_TILT = 75;
// The tilt angle range in degrees for each orientation.
// Beyond these tilt angles, we don't even consider transitioning into the
// specified orientation. We place more stringent requirements on unnatural
// orientations than natural ones to make it less likely to accidentally transition
// into those states.
// The first value of each pair is negative so it applies a limit when the device is
// facing down (overhead reading in bed).
// The second value of each pair is positive so it applies a limit when the device is
// facing up (resting on a table).
// The ideal tilt angle is 0 (when the device is vertical) so the limits establish
// how close to vertical the device must be in order to change orientation.
private static final int[][] TILT_TOLERANCE = new int[][] {
/* ROTATION_0 */ { -20, 70 },
/* ROTATION_90 */ { -20, 60 },
/* ROTATION_180 */ { -20, 50 },
/* ROTATION_270 */ { -20, 60 }
};
// The gap angle in degrees between adjacent orientation angles for hysteresis.
// This creates a "dead zone" between the current orientation and a proposed
// adjacent orientation. No orientation proposal is made when the orientation
// angle is within the gap between the current orientation and the adjacent
// orientation.
private static final int ADJACENT_ORIENTATION_ANGLE_GAP = 45;
// The number of milliseconds for which the device posture must be stable
// before we perform an orientation change. If the device appears to be rotating
// (being picked up, put down) then we keep waiting until it settles.
private static final int SETTLE_TIME_MS = 100;
// The maximum change in magnitude that can occur during the settle time.
// Tuning this constant particularly helps to filter out situations where the
// device is being picked up or put down by the user.
private static final float SETTLE_MAGNITUDE_MAX_DELTA =
SensorManager.STANDARD_GRAVITY * 0.2f;
// The maximum change in tilt angle that can occur during the settle time.
private static final int SETTLE_TILT_ANGLE_MAX_DELTA = 5;
// The maximum change in orientation angle that can occur during the settle time.
private static final int SETTLE_ORIENTATION_ANGLE_MAX_DELTA = 5;
public SensorEventListenerImpl(WindowOrientationListener orientationListener) {
mOrientationListener = orientationListener;
}
public int getProposedRotation() {
return mProposalAgeMS >= SETTLE_TIME_MS ? mProposalRotation : -1;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent event) {
final boolean log = mOrientationListener.mLogEnabled;
// The vector given in the SensorEvent points straight up (towards the sky) under ideal
// conditions (the phone is not accelerating). I'll call this up vector elsewhere.
float x = event.values[ACCELEROMETER_DATA_X];
float y = event.values[ACCELEROMETER_DATA_Y];
float z = event.values[ACCELEROMETER_DATA_Z];
if (log) {
Slog.v(TAG, "Raw acceleration vector: " +
"x=" + x + ", y=" + y + ", z=" + z);
}
// Apply a low-pass filter to the acceleration up vector in cartesian space.
// Reset the orientation listener state if the samples are too far apart in time
// or when we see values of (0, 0, 0) which indicates that we polled the
// accelerometer too soon after turning it on and we don't have any data yet.
final long now = event.timestamp;
final float timeDeltaMS = (now - mLastTimestamp) * 0.000001f;
boolean skipSample;
if (timeDeltaMS <= 0 || timeDeltaMS > MAX_FILTER_DELTA_TIME_MS
|| (x == 0 && y == 0 && z == 0)) {
if (log) {
Slog.v(TAG, "Resetting orientation listener.");
}
clearProposal();
skipSample = true;
} else {
final float alpha = timeDeltaMS / (FILTER_TIME_CONSTANT_MS + timeDeltaMS);
x = alpha * (x - mLastFilteredX) + mLastFilteredX;
y = alpha * (y - mLastFilteredY) + mLastFilteredY;
z = alpha * (z - mLastFilteredZ) + mLastFilteredZ;
if (log) {
Slog.v(TAG, "Filtered acceleration vector: " +
"x=" + x + ", y=" + y + ", z=" + z);
}
skipSample = false;
}
mLastTimestamp = now;
mLastFilteredX = x;
mLastFilteredY = y;
mLastFilteredZ = z;
final int oldProposedRotation = getProposedRotation();
if (!skipSample) {
// Calculate the magnitude of the acceleration vector.
final float magnitude = (float) Math.sqrt(x * x + y * y + z * z);
if (magnitude < MIN_ACCELERATION_MAGNITUDE
|| magnitude > MAX_ACCELERATION_MAGNITUDE) {
if (log) {
Slog.v(TAG, "Ignoring sensor data, magnitude out of range: "
+ "magnitude=" + magnitude);
}
clearProposal();
} else {
// Calculate the tilt angle.
// This is the angle between the up vector and the x-y plane (the plane of
// the screen) in a range of [-90, 90] degrees.
// -90 degrees: screen horizontal and facing the ground (overhead)
// 0 degrees: screen vertical
// 90 degrees: screen horizontal and facing the sky (on table)
final int tiltAngle = (int) Math.round(
Math.asin(z / magnitude) * RADIANS_TO_DEGREES);
// If the tilt angle is too close to horizontal then we cannot determine
// the orientation angle of the screen.
if (Math.abs(tiltAngle) > MAX_TILT) {
if (log) {
Slog.v(TAG, "Ignoring sensor data, tilt angle too high: "
+ "magnitude=" + magnitude + ", tiltAngle=" + tiltAngle);
}
clearProposal();
} else {
// Calculate the orientation angle.
// This is the angle between the x-y projection of the up vector onto
// the +y-axis, increasing clockwise in a range of [0, 360] degrees.
int orientationAngle = (int) Math.round(
-Math.atan2(-x, y) * RADIANS_TO_DEGREES);
if (orientationAngle < 0) {
// atan2 returns [-180, 180]; normalize to [0, 360]
orientationAngle += 360;
}
// Find the nearest rotation.
int nearestRotation = (orientationAngle + 45) / 90;
if (nearestRotation == 4) {
nearestRotation = 0;
}
// Determine the proposed orientation.
// The confidence of the proposal is 1.0 when it is ideal and it
// decays exponentially as the proposal moves further from the ideal
// angle, tilt and magnitude of the proposed orientation.
if (!isTiltAngleAcceptable(nearestRotation, tiltAngle)
|| !isOrientationAngleAcceptable(nearestRotation,
orientationAngle)) {
if (log) {
Slog.v(TAG, "Ignoring sensor data, no proposal: "
+ "magnitude=" + magnitude + ", tiltAngle=" + tiltAngle
+ ", orientationAngle=" + orientationAngle);
}
clearProposal();
} else {
if (log) {
Slog.v(TAG, "Proposal: "
+ "magnitude=" + magnitude
+ ", tiltAngle=" + tiltAngle
+ ", orientationAngle=" + orientationAngle
+ ", proposalRotation=" + mProposalRotation);
}
updateProposal(nearestRotation, now / 1000000L,
magnitude, tiltAngle, orientationAngle);
}
}
}
}
// Write final statistics about where we are in the orientation detection process.
final int proposedRotation = getProposedRotation();
if (log) {
final float proposalConfidence = Math.min(
mProposalAgeMS * 1.0f / SETTLE_TIME_MS, 1.0f);
Slog.v(TAG, "Result: currentRotation=" + mOrientationListener.mCurrentRotation
+ ", proposedRotation=" + proposedRotation
+ ", timeDeltaMS=" + timeDeltaMS
+ ", proposalRotation=" + mProposalRotation
+ ", proposalAgeMS=" + mProposalAgeMS
+ ", proposalConfidence=" + proposalConfidence);
}
// Tell the listener.
if (proposedRotation != oldProposedRotation && proposedRotation >= 0) {
if (log) {
Slog.v(TAG, "Proposed rotation changed! proposedRotation=" + proposedRotation
+ ", oldProposedRotation=" + oldProposedRotation);
}
mOrientationListener.onProposedRotationChanged(proposedRotation);
}
}
/**
* Returns true if the tilt angle is acceptable for a proposed
* orientation transition.
*/
private boolean isTiltAngleAcceptable(int proposedRotation,
int tiltAngle) {
return tiltAngle >= TILT_TOLERANCE[proposedRotation][0]
&& tiltAngle <= TILT_TOLERANCE[proposedRotation][1];
}
/**
* Returns true if the orientation angle is acceptable for a proposed
* orientation transition.
*
* This function takes into account the gap between adjacent orientations
* for hysteresis.
*/
private boolean isOrientationAngleAcceptable(int proposedRotation, int orientationAngle) {
// If there is no current rotation, then there is no gap.
// The gap is used only to introduce hysteresis among advertised orientation
// changes to avoid flapping.
final int currentRotation = mOrientationListener.mCurrentRotation;
if (currentRotation >= 0) {
// If the proposed rotation is the same or is counter-clockwise adjacent,
// then we set a lower bound on the orientation angle.
// For example, if currentRotation is ROTATION_0 and proposed is ROTATION_90,
// then we want to check orientationAngle > 45 + GAP / 2.
if (proposedRotation == currentRotation
|| proposedRotation == (currentRotation + 1) % 4) {
int lowerBound = proposedRotation * 90 - 45
+ ADJACENT_ORIENTATION_ANGLE_GAP / 2;
if (proposedRotation == 0) {
if (orientationAngle >= 315 && orientationAngle < lowerBound + 360) {
return false;
}
} else {
if (orientationAngle < lowerBound) {
return false;
}
}
}
// If the proposed rotation is the same or is clockwise adjacent,
// then we set an upper bound on the orientation angle.
// For example, if currentRotation is ROTATION_0 and proposed is ROTATION_270,
// then we want to check orientationAngle < 315 - GAP / 2.
if (proposedRotation == currentRotation
|| proposedRotation == (currentRotation + 3) % 4) {
int upperBound = proposedRotation * 90 + 45
- ADJACENT_ORIENTATION_ANGLE_GAP / 2;
if (proposedRotation == 0) {
if (orientationAngle <= 45 && orientationAngle > upperBound) {
return false;
}
} else {
if (orientationAngle > upperBound) {
return false;
}
}
}
}
return true;
}
private void clearProposal() {
mProposalRotation = -1;
mProposalAgeMS = 0;
}
private void updateProposal(int rotation, long timestampMS,
float magnitude, int tiltAngle, int orientationAngle) {
if (mProposalRotation != rotation) {
mProposalRotation = rotation;
mHistoryIndex = 0;
mHistoryLength = 0;
}
final int index = mHistoryIndex;
mHistoryTimestampMS[index] = timestampMS;
mHistoryMagnitudes[index] = magnitude;
mHistoryTiltAngles[index] = tiltAngle;
mHistoryOrientationAngles[index] = orientationAngle;
mHistoryIndex = (index + 1) % HISTORY_SIZE;
if (mHistoryLength < HISTORY_SIZE) {
mHistoryLength += 1;
}
long age = 0;
for (int i = 1; i < mHistoryLength; i++) {
final int olderIndex = (index + HISTORY_SIZE - i) % HISTORY_SIZE;
if (Math.abs(mHistoryMagnitudes[olderIndex] - magnitude)
> SETTLE_MAGNITUDE_MAX_DELTA) {
break;
}
if (angleAbsoluteDelta(mHistoryTiltAngles[olderIndex],
tiltAngle) > SETTLE_TILT_ANGLE_MAX_DELTA) {
break;
}
if (angleAbsoluteDelta(mHistoryOrientationAngles[olderIndex],
orientationAngle) > SETTLE_ORIENTATION_ANGLE_MAX_DELTA) {
break;
}
age = timestampMS - mHistoryTimestampMS[olderIndex];
if (age >= SETTLE_TIME_MS) {
break;
}
}
mProposalAgeMS = age;
}
private static int angleAbsoluteDelta(int a, int b) {
int delta = Math.abs(a - b);
if (delta > 180) {
delta = 360 - delta;
}
return delta;
}
}
}
| [
"iamcalledned@gmail.com"
] | iamcalledned@gmail.com |
0f83f35dda4944b80ce190a5bb2be4b43466a25a | 86a257b82d3504d4b6a3b4d050d72baa6b2cbd33 | /src/main/java/Server/MessagingServerInterface.java | ef4b1d0e01da9fdcd36f7289b56ca43b46b59006 | [] | no_license | OkaMoez/CMPT275_Project | d03a9b0578b10b7f509f9400e3707a9473601f81 | 6dcd833a03ff41cfae0e83a5b41e417813eedfef | refs/heads/master | 2023-01-28T12:46:27.896790 | 2020-12-12T06:51:48 | 2020-12-12T06:51:48 | 310,386,359 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 459 | java | package Server;
import Messaging.ChatMessage;
import Messaging.ConversationID;
import Users.UserID;
import java.util.Vector;
public interface MessagingServerInterface {
Vector<ConversationID> getConversationList(UserID currentUser);
Vector<ChatMessage> getConversationHistory(ConversationID conversationID);
void sendMessage(ConversationID conversationID, ChatMessage message);
void createNewConversation(ConversationID newConversation);
}
| [
"43766412+OkaMoez@users.noreply.github.com"
] | 43766412+OkaMoez@users.noreply.github.com |
79c2243997bf9254f14d35a0bb0711ad253966cf | 67ead592a05a445be561677131c1e7426c68187a | /src/main/java/com/example/speed/SpeedApplication.java | 76e5abcd3f81369cb4b1eb3907539d3b82339a95 | [] | no_license | kuzco77/speed | d7cc2493905830bd2936e75403f16017b4482771 | 16ced2bba8e72c45f240a7271700afee64efe042 | refs/heads/master | 2023-06-19T11:40:34.831379 | 2021-07-17T06:57:02 | 2021-07-17T06:57:02 | 386,275,201 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 754 | java | package com.example.speed;
import com.example.speed.repository.LogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
@SpringBootApplication
@EnableJpaAuditing
@ConfigurationPropertiesScan
public class SpeedApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpeedApplication.class, args);
}
}
| [
"anhcn@ghdmedia.com"
] | anhcn@ghdmedia.com |
78c76546eba7ad1941d2320db034c2f710a1c992 | d2f96ef11329a501bf57320d4d61256c1457248c | /src/main/java/sample/reactive/s5/rx/repository/ReactiveRepository.java | 7c7469ec467e444e68df11d0e3698968cd91fb31 | [] | no_license | ziqew/s5 | 61ab708c257e86d06804fcb8246707336eeba6e0 | cd96412afc6ab5417892d6d6b64c406bfa7f9f6b | refs/heads/master | 2020-03-28T00:56:18.855532 | 2018-09-07T09:07:29 | 2018-09-07T09:07:29 | 147,462,459 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 341 | java | package sample.reactive.s5.rx.repository;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public interface ReactiveRepository<T> {
Mono<Void> save(Publisher<T> publisher);
Mono<T> findFirst();
Flux<T> findAll();
Mono<T> findById(String id);
}
| [
"gongwenwei@kedacom.com"
] | gongwenwei@kedacom.com |
04a39a6d6bf3832117989d1ef9f79177e4af6094 | 85502cbfdf6dc0b002d6496357526d595b328c28 | /src/main/java/com/leetcode/problems/mergeIntervals/Interval.java | 482ea448ef4525934f22cf34a8b3c9b1fc2deac2 | [] | no_license | pbelevich/leetcode | e4e74f31a2a23e69b4618052d87a9016a0d2a364 | 7031ed13f337d2dbd7d7e08c54bd83f6b08d9f51 | refs/heads/master | 2021-01-13T12:49:14.411852 | 2017-06-05T02:30:27 | 2017-06-05T02:30:27 | 72,327,640 | 1 | 0 | null | 2016-10-30T05:17:24 | 2016-10-30T05:00:17 | Java | UTF-8 | Java | false | false | 900 | java | package com.leetcode.problems.mergeIntervals;
/**
* @author Pavel Belevich
*/
public class Interval {
int start;
int end;
Interval() {
start = 0;
end = 0;
}
Interval(int s, int e) {
start = s;
end = e;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Interval interval = (Interval) o;
if (start != interval.start) return false;
if (end != interval.end) return false;
return true;
}
@Override
public int hashCode() {
int result = start;
result = 31 * result + end;
return result;
}
@Override
public String toString() {
return "Interval{" +
"start=" + start +
", end=" + end +
'}';
}
}
| [
"belevichp@gmail.com"
] | belevichp@gmail.com |
adc069ccd663e836655745331c5165743899c0e1 | 864a2e7a1fce8a659cfb6620939fa43cb5a68328 | /src/trolsoft/words/tools/MobileGenerator.java | 3a1d32872b8f54c1290b4f34d0091e83806e0e78 | [] | no_license | trol73/words | 82c6e4ffea3d6c11c0fc63b14e3a6925243ae962 | d6edc528eb9a83c7461affc14168c359e73b3c4f | refs/heads/master | 2021-01-23T08:10:10.482984 | 2017-01-31T16:03:14 | 2017-01-31T16:03:14 | 80,536,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,031 | java | package trolsoft.words.tools;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import trolsoft.dict.Dictionary;
import trolsoft.utils.FileJournalMaker;
import trolsoft.utils.Utils;
public class MobileGenerator {
private static final String FILE_WORDS_DATA = "words.bin";
private static final String PATH_LIST_FILES = "/res/j2me/words.lst";
private static final String PATH_JAR_FILES = "/res/j2me/jar/";
private static final String PATH_JAD_FILE = "/res/j2me/words.jad";
private Dictionary dict;
// private String pathRoot; // корневой каталог, в котором будет строится мидлет, со слешем в конце
private String pathTemp; // временный каталог для архивации jar-ки
private String midletName;
private int fontSize; // 0, 1, 2
private String jarFileName;
private String jadFileName;
private FileJournalMaker fMaker = new FileJournalMaker();
/**
*
*/
public MobileGenerator(String pathRoot, String midletName, int fontSize) {
this.midletName = midletName;
pathRoot = pathRoot.trim();
char pathRootLast = pathRoot.charAt(pathRoot.length()-1);
if ( pathRootLast != '\\' && pathRootLast != '/' ) {
pathRoot += File.separatorChar;
}
// this.pathRoot = pathRoot;
pathTemp = pathRoot + "_temp_";
fMaker.setBasePath(pathTemp);
this.fontSize = fontSize;
jarFileName = pathRoot + midletName + ".jar";
jadFileName = pathRoot + midletName + ".jad";
}
/**
*
* @return
*/
public boolean generate() {
try {
// extract midlet files from jar
List<String> jarFilesList = Utils.createTextFileFromJar(PATH_LIST_FILES);
String[] filesToJar = new String[jarFilesList.size()+1];
int i = 0;
for ( String fn : jarFilesList ) {
fn = fn.trim();
if ( fn.length() == 0 ) {
continue;
}
if ( fn.indexOf("[%FONT_SIZE%]") >= 0 ) {
String fss;
switch ( fontSize ) {
case 0:
fss = "128";
break;
case 1:
fss = "176";
break;
case 2:
fss = "240";
break;
default:
fss = "";
}
fn = fn.replace("[%FONT_SIZE%]", fss);
}
InputStream is = Utils.getResourceFromJar(PATH_JAR_FILES + fn);
filesToJar[i++] = fn;
fMaker.mkfile(fn, is);
}
// create data file
String dataFileName = pathTemp + File.separatorChar + FILE_WORDS_DATA;
createDataFile(dataFileName);
fMaker.getCreatedFilesList().add(dataFileName);
filesToJar[i++] = FILE_WORDS_DATA;
// pack midlet files into jar
String manifestFileName = pathTemp + File.separatorChar + filesToJar[0];
patchManifestFile(manifestFileName, 0);
InputStream manifesIS = new FileInputStream(manifestFileName);
Manifest manifest = new Manifest(manifesIS);
manifesIS.close();
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jarFileName), manifest);
for ( i = 1; i < filesToJar.length; i++ ) {
String fn = filesToJar[i];
if ( fn == null ) {
continue;
}
JarEntry jarEntry = new JarEntry(fn);
jarOut.putNextEntry(jarEntry);
Utils.writeFileToStream(pathTemp + File.separatorChar + fn, jarOut);
}
jarOut.close();
// clear and delete temporary directory
fMaker.undo();
// create jad-file
List<String> jadFileLines = Utils.createTextFileFromJar(PATH_JAD_FILE);
patchManifestFile(jadFileName, jadFileLines, new File(jarFileName).length());
} catch ( Exception e ) {
e.printStackTrace();
return false;
}
return true;
}
/**
*
* @param fileName
* @throws IOException
*/
private void createDataFile(String fileName) throws IOException {
// calculating offsets of words
int size = dict.size();
int pos = 2 + size*3 + 2;
int posEng[] = new int[size];
int posRus[] = new int[size];
for ( int i = 0; i < size; i++ ) {
String eng = dict.getKey(i);
String rus = dict.getValue(i);
posEng[i] = pos;
pos += eng.getBytes("utf-8").length;
posRus[i] = pos;
pos += rus.getBytes("utf-8").length;
}
if ( pos >= 0xffff ) {
throw new RuntimeException("Words file is to big!");
}
RandomAccessFile f = new RandomAccessFile(fileName, "rw");
// header
//f.writeShort(size);
f.writeByte(size & 0xff);
f.writeByte((size >> 8) & 0xff);
for ( int i = 0; i < size; i++ ) {
int posEn = posEng[i];
f.writeByte(posEn & 0xff);
f.writeByte((posEn >> 8) & 0xff);
if ( posRus[i] - posEng[i] >= 0xff ) {
throw new RuntimeException("To large word: " + dict.getKey(i) + "!");
}
f.writeByte((posRus[i] - posEng[i]) & 0xff);
}
f.writeByte(pos & 0xff);
f.writeByte((pos >> 8) & 0xff);
// words
for ( int i = 0; i < size; i++ ) {
String eng = dict.getKey(i);
String rus = dict.getValue(i);
f.write(eng.getBytes("utf-8"));
f.write(rus.getBytes("utf-8"));
//f.writeUTF(eng);
//f.writeUTF(rus);
}
f.close();
}
/**
*
* @param fileName
* @throws IOException
*/
private void patchManifestFile(String fileName, long jarSize) throws IOException {
List<String> lines = Utils.readTextFile(fileName);
patchManifestFile(fileName, lines, jarSize);
}
/**
*
* @param fileName
* @param lines
* @param jarSize
* @throws IOException
*/
private void patchManifestFile(String fileName, List<String> lines, long jarSize) throws IOException {
String jarSizeStr = Long.toString(jarSize);
for ( int i = 0; i < lines.size(); i++ ) {
String s = lines.get(i);
s = s.replace("%NAME%", midletName);
s = s.replace("%SIZE%", jarSizeStr);
lines.set(i, s);
}
Utils.writeTextToFile(fileName, lines);
}
/**
*
* @param dict
*/
public void setDict(Dictionary dict) {
System.out.println("setDict " + dict.size());
this.dict = dict;
}
}
| [
"otrifonow@gmail.com"
] | otrifonow@gmail.com |
59550269d202185882bd544867d7527a5fdb7939 | c38a74b136601dcfb798e9f220e627ec5647466f | /src/hapitas/Pc_Hapitas_All_Main.java | b61b1ec9f505e88f5e8843b4450c0f0f516a0012 | [] | no_license | Kim20110119/point | 9c4638b3bbbe7eefe28268f8add623b8615cd2a1 | 7c52137e86f8ba08338883f0a61157e8ae071450 | refs/heads/master | 2021-06-16T19:01:30.793735 | 2017-03-15T06:13:03 | 2017-03-15T06:13:03 | 75,719,658 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 874 | java | package hapitas;
import hapitas.ad_areas.Hapitas_Enquete;
import hapitas.ad_areas.Hapitas_LocalQuizs;
import hapitas.ad_areas.Hapitas_Reados;
/**
* =====================================================================================================================
* 【ハピタス】:クマクマ調査団
* =====================================================================================================================
*
* @author kimC
*
*/
public class Pc_Hapitas_All_Main {
// 【ハピタス】:クマクマ調査団
public static void main(String[] args) {
Hapitas_Enquete enquete = new Hapitas_Enquete();
enquete.execute();
Hapitas_LocalQuizs localQuizs = new Hapitas_LocalQuizs();
localQuizs.execute();
Hapitas_Reados reados = new Hapitas_Reados();
reados.execute();
System.out.println("ハッピータス自動化完了");
}
}
| [
"kim-keitetsu@shinbus.jp"
] | kim-keitetsu@shinbus.jp |
b4fc64888c51d3017a2d77ee42224f6171b408bc | 04aea65d58b03b57b7fdebdd5e9833f561f183ee | /app/src/main/java/com/tencent/devicedemo/VideoChatActivityHW.java | 23051a156705f447518a640c49b12837043ed775 | [] | no_license | Dev-Wiki/DeviceDemo | 26cdcdf7e54f54e8ef630fd682504403eb935c3f | d68f7a40f802ff1881588543658e95c63a9ca3fb | refs/heads/master | 2020-12-31T08:09:10.067960 | 2016-06-29T06:20:59 | 2016-06-29T06:20:59 | 62,194,063 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,122 | java | package com.tencent.devicedemo;
import java.util.List;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import com.tencent.av.VideoController;
import com.tencent.av.core.VideoConstants;
import com.tencent.av.mediacodec.surface2buffer.VideoDecoder;
import com.tencent.av.mediacodec.surface2buffer.VideoDrawer;
import com.tencent.av.mediacodec.surface2buffer.VideoEncoder;
import com.tencent.av.opengl.GLVideoView;
import com.tencent.av.opengl.GraphicRenderMgr;
import com.tencent.av.opengl.ui.GLRootView;
import com.tencent.av.opengl.ui.GLView;
import com.tencent.device.QLog;
import com.tencent.device.TXBinderInfo;
import com.tencent.device.TXDeviceService;
import com.tencent.devicedemo.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.TextureView;
import android.view.TextureView.SurfaceTextureListener;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ImageView.ScaleType;
public class VideoChatActivityHW extends Activity implements Renderer, SurfaceTexture.OnFrameAvailableListener{
private static final String TAG = "VideoChatActivityHW";
String mPeerId;
String mSelfDin;
boolean mIsReceiver = false;
boolean mVideoConnected = false;
TextView mLogInfo;
Button mAccept;
Button mReject;
Button mClose;
BroadcastHandler mBroadcastHandler;
//===============================================
private VideoEncoder mVideoEncoder = null;
private VideoDecoder mVideoDecoder = null;
private VideoDrawer mVideoDrawer = null;
private Object mObjectMutex = new Object();
private boolean mResetEncoder = false;
private GLSurfaceView mGLSurfaceView;
private SurfaceTexture mSurfaceTexture;
private int mTextureID = -1;
private TextureView mPeerTextureView;
private ImageView mPeerViewBkg;
private int mPeerVideoAngle = -1;
private Camera mCamera;
// parameters for the encoder
private static final String MIME_TYPE = "video/avc";
private static int encWidth = 640;
private static int encHeight = 480;
private static int encBitRate = 1000*350;
private static int encFrameRate = 10;
private static int encIFrameInterval = 5;
//==================================================
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
super.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.setContentView(R.layout.activity_videochat_hardcodec);
super.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
super.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
super.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Intent intent = super.getIntent();
mPeerId = intent.getStringExtra("peerid");
mSelfDin = VideoController.getInstance().GetSelfDin();
mIsReceiver = intent.getBooleanExtra("receive", false);
mBroadcastHandler = new BroadcastHandler();
IntentFilter filter = new IntentFilter();
filter.addAction(VideoConstants.ACTION_STOP_VIDEO_CHAT);
filter.addAction(VideoController.ACTION_NETMONIOTR_INFO);
filter.addAction(VideoController.ACTION_CHANNEL_READY);
filter.addAction(VideoController.ACTION_VIDEOFRAME_INCOME);
filter.addAction(VideoController.ACTION_VIDEO_QOS_NOTIFY);
filter.addAction(VideoDecoder.VIDEO_ASPECT_RATIO_CHANGE);
filter.addAction(VideoDecoder.VIDEO_RENDER_FIRST_FRAME);
filter.addAction(TXDeviceService.BinderListChange);
filter.addAction(TXDeviceService.OnEraseAllBinders);
registerReceiver(mBroadcastHandler, filter);
//local view
mGLSurfaceView = (GLSurfaceView)findViewById(R.id.camera_textureview);
mGLSurfaceView.setEGLContextClientVersion(2);
mGLSurfaceView.setRenderer(this);
mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
//peer view
if (VideoController.isHardwareDecoderEnabled()) {
initPeerTextureView();
}
else {
initPeerQQGlView();
}
mLogInfo = (TextView) findViewById(R.id.logInfo_surface);
mAccept = (Button) findViewById(R.id.av_video_accept_surface);
mReject = (Button) findViewById(R.id.av_video_reject_surface);
mClose = (Button) findViewById(R.id.av_video_close_surface);
if (mIsReceiver) {
mAccept.setVisibility(View.VISIBLE);
mReject.setVisibility(View.VISIBLE);
}
else {
mClose.setVisibility(View.VISIBLE);
mClose.setText("取消");
if (Long.parseLong(mPeerId) != 0) {
VideoController.getInstance().request(mPeerId);
}
}
}
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume");
//startRing必须和stopRing成对调用(使用MediaPlayer); startRing2必须和stopRing2成对调用(使用SoundPool);
if (mIsReceiver) {
VideoController.getInstance().startRing(R.raw.qav_video_incoming, -1, null);
//VideoController.getInstance().startRing2(R.raw.qav_video_incoming, -1);
} else {
VideoController.getInstance().startRing(R.raw.qav_video_request, -1, null);
//VideoController.getInstance().startRing2(R.raw.qav_video_request, -1);
}
}
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause");
if (mIsReceiver) {
if (mVideoConnected) {
VideoController.getInstance().closeVideo(mPeerId);
}
else {
VideoController.getInstance().rejectRequest(mPeerId);
}
}
else {
VideoController.getInstance().closeVideo(mPeerId);
}
closeCamera();
stopEncoder();
stopDecoder();
VideoController.getInstance().stopRing();
//VideoController.getInstance().stopRing2();
GraphicRenderMgr.getInstance().setGlRender(mPeerId, null);
mVideoConnected = false;
VideoController.getInstance().exitProcess();
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy");
super.unregisterReceiver(mBroadcastHandler);
}
@Override
public void finish() {
Log.i(TAG, "VideoActivity:finish");
super.finish();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
showQuitDialog();
return true;
case KeyEvent.KEYCODE_SEARCH:
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:
break;
case KeyEvent.KEYCODE_VOLUME_UP:
break;
case KeyEvent.KEYCODE_MENU:
break;
}
return super.onKeyDown(keyCode, event);
}
void showQuitDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("确认退出吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
VideoChatActivityHW.this.finish();
}
});
builder.setNegativeButton("取消", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
private long mTimeClick = 0;
private View.OnTouchListener mTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
// TODO Auto-generated method stub
long timeNow = System.currentTimeMillis();
if(MotionEvent.ACTION_DOWN == event.getAction()){
if(timeNow - mTimeClick < 600){
if (mLogInfo != null) {
mLogInfo.setVisibility(View.VISIBLE);
}
}
else {
if (mLogInfo != null) {
mLogInfo.setVisibility(View.INVISIBLE);
}
}
mTimeClick = timeNow;
}
return true;
}
};
void initPeerQQGlView() {
if (QLog.isColorLevel()) {
QLog.d(TAG, QLog.CLR, "initQQGlView");
}
GLRootView glRootView = (GLRootView) findViewById(R.id.peer_gl_root_view);
glRootView.setVisibility(View.VISIBLE);
glRootView.setOnTouchListener(mTouchListener);
GLVideoView glPeerVideoView = new GLVideoView(this);
glRootView.setContentPane(glPeerVideoView);
glPeerVideoView.setIsPC(false);
glPeerVideoView.enableLoading(false);
glPeerVideoView.setMirror(true);
glPeerVideoView.setNeedRenderVideo(true);
glPeerVideoView.setVisibility(GLView.VISIBLE);
glPeerVideoView.setScaleType(ScaleType.CENTER_CROP);
glPeerVideoView.setBackground(R.drawable.qav_video_bg_s);
GraphicRenderMgr.getInstance().setGlRender(mPeerId, glPeerVideoView.getYuvTexture());
}
void initPeerTextureView() {
RelativeLayout layout = (RelativeLayout)findViewById(R.id.layout_peer_textureView);
layout.setVisibility(View.VISIBLE);
mPeerViewBkg = (ImageView)findViewById(R.id.imageView_peer_textureView);
mPeerTextureView = (TextureView)findViewById(R.id.peer_textureView);
mPeerTextureView.setOnTouchListener(mTouchListener);
mPeerTextureView.setSurfaceTextureListener(new SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture arg0,
int arg1, int arg2) {
// TODO Auto-generated method stub
mVideoDecoder = new VideoDecoder(new Surface(arg0));
mVideoDecoder.resetDecoder(MIME_TYPE, encWidth, encHeight);
adjustVideoAspectRatio(encWidth, encHeight);
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture arg0,
int arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture arg0) {
// TODO Auto-generated method stub
}
});
}
class BroadcastHandler extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(VideoConstants.ACTION_STOP_VIDEO_CHAT)) {
int reason = intent.getIntExtra("reason", VideoConstants.VOIP_REASON_OTHERS);
if (reason == VideoConstants.VOIP_REASON_REJECT_BY_FRIEND) {
//发起视频请求之后,对方拒绝
} else if (reason == VideoConstants.VOIP_REASON_SELF_WAIT_RELAYINFO_TIMEOUT) {
//发起视频请求之后,对方一直不接听,最后超时
} else if (reason == VideoConstants.VOIP_REASON_CLOSED_BY_FRIEND) {
//连通之后,对方主动关闭
} else {
//其它原因
}
Log.d(TAG, "recv broadcast : AVSessionClose reason = " + reason);
finish();
} else if (intent.getAction().equalsIgnoreCase(VideoController.ACTION_CHANNEL_READY)) {
VideoController.getInstance().stopRing();
//VideoController.getInstance().stopRing2();
VideoController.getInstance().stopShake();
VideoController.getInstance().startShake();
mVideoConnected = true;
mClose.setText("关闭");
} else if (intent.getAction().equalsIgnoreCase(VideoController.ACTION_NETMONIOTR_INFO)) {
String msg = intent.getStringExtra("msg");
if (mLogInfo != null) {
mLogInfo.setText("Video Info \r\n" + msg);
mLogInfo.invalidate();
}
} else if (intent.getAction().equalsIgnoreCase(VideoController.ACTION_VIDEOFRAME_INCOME)) {
if (mPeerTextureView != null && mVideoDecoder != null) {
int peerVideoAngle = intent.getIntExtra("angle", 0);
if (mPeerVideoAngle != peerVideoAngle) {
mPeerVideoAngle = peerVideoAngle;
mPeerTextureView.setRotation(peerVideoAngle * 90);
}
mVideoDecoder.onFrameAvailable(intent.getByteArrayExtra("buffer"));
}
} else if (intent.getAction().equalsIgnoreCase(VideoDecoder.VIDEO_ASPECT_RATIO_CHANGE)) {
int width = intent.getIntExtra("width", 0);
int height = intent.getIntExtra("height", 0);
adjustVideoAspectRatio(width, height);
} else if (intent.getAction().equalsIgnoreCase(VideoDecoder.VIDEO_RENDER_FIRST_FRAME)) {
if (mPeerViewBkg != null) {
mPeerViewBkg.setVisibility(View.INVISIBLE);
}
} else if (intent.getAction().equalsIgnoreCase(VideoController.ACTION_VIDEO_QOS_NOTIFY)) {
int width = intent.getIntExtra("width", 0);
int height = intent.getIntExtra("height", 0);
int bitrate = intent.getIntExtra("bitrate", 0) * 1000;
int fps = intent.getIntExtra("fps", 0);
if (width != 0 && height != 0 && bitrate != 0 && fps != 0) {
if (encWidth != width || encHeight != height || encBitRate != bitrate || encFrameRate != fps) {
encWidth = width;
encHeight = height;
encBitRate = bitrate;
encFrameRate = fps;
synchronized (mObjectMutex) {
if (mVideoEncoder != null) {
mResetEncoder = true;
}
}
}
}
} else if (intent.getAction() == TXDeviceService.BinderListChange) {
boolean bFind = false;
Parcelable[] listBinder = intent.getExtras().getParcelableArray("binderlist");
for (int i = 0; i < listBinder.length; ++i){
TXBinderInfo binder = (TXBinderInfo)(listBinder[i]);
if (binder.tinyid == Long.parseLong(mPeerId)) {
bFind = true;
break;
}
}
if (bFind == false) {
finish();
}
} else if (intent.getAction() == TXDeviceService.OnEraseAllBinders) {
finish();
}
}
}
public void onBtnClose(View view) {
finish();
}
public void onBtnReject(View view) {
finish();
}
public void onBtnAccept(View view) {
VideoController.getInstance().stopRing();
if (Long.parseLong(mPeerId) != 0) {
VideoController.getInstance().acceptRequest(mPeerId);
mAccept.setVisibility(View.GONE);
mReject.setVisibility(View.GONE);
mClose.setVisibility(View.VISIBLE);
}
}
//==========================================================================
//==========================================================================
//==========================================================================
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// TODO Auto-generated method stub
Log.i(TAG, "onSurfaceCreated...");
mTextureID = VideoEncoder.createTextureID();
mSurfaceTexture = new SurfaceTexture(mTextureID);
mSurfaceTexture.setOnFrameAvailableListener(this);
mVideoDrawer = new VideoDrawer(mTextureID);
openCamera(encWidth, encHeight);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
// TODO Auto-generated method stub
Log.i(TAG, "onSurfaceChanged...");
mVideoDrawer.adjustTextureCoord(width, height, encWidth, encHeight);
//mVideoDrawer.rotateTextureCoordHorizontal(); 这一行可以在水平方向上旋转本地画面,必须在adjustTextureCoord之后调用
//mVideoDrawer.rotateTextureCOordVertical(); 这一行可以在垂直方向上旋转本地画面,必须在adjustTextureCoord之后调用
GLES20.glViewport(0, 0, width, height);
}
@Override
public void onDrawFrame(GL10 gl) {
// TODO Auto-generated method stub
Log.i(TAG, "onDrawFrame...");
GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
mSurfaceTexture.updateTexImage();
float[] mtx = new float[16];
mSurfaceTexture.getTransformMatrix(mtx);
mVideoDrawer.draw(mtx);
if (mVideoConnected == true) {
synchronized (mObjectMutex) {
if (mVideoEncoder == null) {
mVideoEncoder = new VideoEncoder(Long.parseLong(mPeerId));
mVideoEncoder.prepareEncoder(MIME_TYPE, encWidth, encHeight, encBitRate, encFrameRate, encIFrameInterval);
mVideoEncoder.startEncoder(EGL14.eglGetCurrentContext(), mTextureID);
}
if (mResetEncoder){
mVideoEncoder.stopEncode();
mVideoEncoder.prepareEncoder(MIME_TYPE, encWidth, encHeight, encBitRate, encFrameRate, encIFrameInterval);
mVideoEncoder.startEncoder(EGL14.eglGetCurrentContext(), mTextureID);
mResetEncoder = false;
}
mVideoEncoder.onFrameAvailable(mSurfaceTexture);
}
}
}
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
// TODO Auto-generated method stub
Log.i(TAG, "onFrameAvailable...");
mGLSurfaceView.requestRender();
}
public void openCamera(int encWidth, int encHeight) {
if (mCamera != null) {
throw new RuntimeException("camera already initialized");
}
Camera.CameraInfo info = new Camera.CameraInfo();
// Try to find a front-facing camera (e.g. for videoconferencing).
int numCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numCameras; i++) {
Camera.getCameraInfo(i, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
mCamera = Camera.open(i);
break;
}
}
if (mCamera == null) {
Log.d(TAG, "No front-facing camera found; opening default");
mCamera = Camera.open(); // opens first back-facing camera
}
if (mCamera == null) {
throw new RuntimeException("Unable to open camera");
}
Camera.Parameters parms = mCamera.getParameters();
choosePreviewSize(parms, encWidth, encHeight);
chooseFrameRate(parms, encFrameRate * 1000);
parms.setRecordingHint(true);
mCamera.setParameters(parms);
mCamera.setDisplayOrientation(0);
Camera.Size size = parms.getPreviewSize();
Log.d(TAG, "Camera preview size is " + size.width + "x" + size.height);
try {
mCamera.setPreviewTexture(mSurfaceTexture);
mCamera.startPreview();
}
catch (Exception e) {
Log.d(TAG, "Camera startPreview failed");
}
}
private static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
// We should make sure that the requested MPEG size is less than the preferred
// size, and has the same aspect ratio.
Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
if (ppsfv != null) {
Log.d(TAG, "Camera preferred preview size for video is " + ppsfv.width + "x" + ppsfv.height);
}
for (Camera.Size size : parms.getSupportedPreviewSizes()) {
if (size.width == width && size.height == height) {
parms.setPreviewSize(width, height);
return;
}
}
Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
if (ppsfv != null) {
parms.setPreviewSize(ppsfv.width, ppsfv.height);
}
}
private static void chooseFrameRate(Camera.Parameters parms, int frameRate) {
List<int[]> fpsRanges = parms.getSupportedPreviewFpsRange();
for (int i = 0; i < fpsRanges.size(); ++i) {
int [] range = fpsRanges.get(i);
if (range != null) {
int fpsMin = range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
int fpsMax = range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
if (fpsMin <= frameRate && frameRate <= fpsMax) {
parms.setPreviewFpsRange(fpsMin, fpsMax);
return;
}
}
}
if (fpsRanges.size() > 0) {
int [] range = fpsRanges.get(0);
if (range != null) {
parms.setPreviewFpsRange(range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX], range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
return;
}
}
parms.setPreviewFpsRange(frameRate, frameRate);
}
private void closeCamera() {
Log.d(TAG, "closing camera");
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
}
private void stopEncoder() {
Log.d(TAG, "stoping encoder");
synchronized (mObjectMutex) {
if (mVideoEncoder != null) {
mVideoEncoder.stopEncode();
mVideoEncoder = null;
}
}
}
private void stopDecoder() {
if (mVideoDecoder != null) {
mVideoDecoder.releaseDecoder();
mVideoDecoder = null;
}
}
private void adjustVideoAspectRatio(int videoWidth, int videoHeight) {
if (videoWidth == 0 || videoHeight == 0) {
return ;
}
int viewWidth = mPeerTextureView.getWidth();
int viewHeight = mPeerTextureView.getHeight();
double aspectRatio = (double) videoHeight / videoWidth;
Log.d(TAG, "adjustVideoAspectRatio: videoWidth = " + videoWidth + " videoHeight = " + videoHeight + "viewWidth = " + viewWidth + " viewHeight = " + viewHeight);
int newWidth, newHeight;
if (viewHeight > (int) (viewWidth * aspectRatio)) {
newWidth = viewWidth;
newHeight = (int) (viewWidth * aspectRatio);
} else {
newWidth = (int) (viewHeight / aspectRatio);
newHeight = viewHeight;
}
int xoffset = (viewWidth - newWidth) / 2;
int yoffset = (viewHeight - newHeight) / 2;
Matrix txform = new Matrix();
mPeerTextureView.getTransform(txform);
txform.setScale((float) newWidth / viewWidth, (float) newHeight / viewHeight);
txform.postTranslate(xoffset, yoffset);
mPeerTextureView.setTransform(txform);
// mPeerTextureView.setScaleX((float) newWidth / viewWidth);
// mPeerTextureView.setScaleY((float) newHeight / viewHeight);
}
} | [
"674952098@qq.com"
] | 674952098@qq.com |
8641c13452af96ac98a8a044be98953514b1e52a | cc6b608d19bc62e1314f9157c9edd1fc3379771a | /src/stack/easy/leetcode155.java | b3f43b2eed8aa79c77470beeca7666e02523a640 | [] | no_license | hxiaoxian/Leetcode | 8ceced01aca14da4bc5857ab80357a609e8045f6 | 0d56b8cec7af8dd05ca2fc34cd565f6488470427 | refs/heads/master | 2020-04-27T16:31:56.964784 | 2020-01-18T09:41:08 | 2020-01-18T09:41:08 | 174,485,092 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,112 | java | package stack.easy;
import java.util.Stack;
/**
* 设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。
*
* push(x) -- 将元素 x 推入栈中。
* pop() -- 删除栈顶的元素。
* top() -- 获取栈顶元素。
* getMin() -- 检索栈中的最小元素。
* 示例:
*
* MinStack minStack = new MinStack();
* minStack.push(-2);
* minStack.push(0);
* minStack.push(-3);
* minStack.getMin(); --> 返回 -3.
* minStack.pop();
* minStack.top(); --> 返回 0.
* minStack.getMin(); --> 返回 -2.
*
*/
public class leetcode155 {
Stack<Integer> stack = new Stack<>();
int min = Integer.MAX_VALUE;
public void push(int x) {
if (x <= min) {
stack.push(min);
min = x;
}
stack.push(x);
}
public void pop() {
if (stack.peek() == min) {
stack.pop();
min = stack.pop();
} else {
stack.pop();
}
}
public int top() {
return stack.peek();
}
public int getMin() {
return min;
}
}
| [
"h15521115180@163.com"
] | h15521115180@163.com |
0b8486f23b344a0bbd0ac6874689a33937df4fd1 | adcf9584a16a614dc4d975770c8cb0ab2d10b058 | /cityList/src/test/java/com/company/cityList/controller/CityListControllerTest.java | 3b7046e24bb41ae14d4e5177bca9cd457dc93221 | [] | no_license | Mattlomet/cityList | a24072a3f55705b642b0c072c28c4fb4e3990e63 | dadf7bf7a7f53326ca7069ee125e7a2989c4826a | refs/heads/master | 2020-08-20T22:25:30.243276 | 2019-10-18T17:15:35 | 2019-10-18T17:15:35 | 216,072,867 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,458 | java | package com.company.cityList.controller;
import com.company.cityList.models.City;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import java.util.ArrayList;
import java.util.List;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@RunWith(SpringRunner.class)
@WebMvcTest(CityListController.class)
public class CityListControllerTest {
@Autowired
private MockMvc mockMvc;
private ObjectMapper mapper = new ObjectMapper();
private List<City> cityList;
@Before
public void setUp(){
cityList = new ArrayList<>();
cityList.add(new City("New York","New York",8000000,false));
cityList.add(new City("Newark","New Jersey",500000,false));
cityList.add(new City("Miami","Florida",2000000,false));
cityList.add(new City("Trenton","New Jersey",400000,true));
}
@Test
public void shouldReturnListOfCities() throws Exception {
String outPutList = mapper.writeValueAsString(cityList);
mockMvc.perform(get("/city"))
}
}
| [
"mattlomet@live.com"
] | mattlomet@live.com |
df9befd6e925f861d7bef50bf8bcc5b377a6fb83 | 7175acfe15de173ac68a675bb560114cc3bb5bf8 | /src/main/java/apollo/dataadapter/ensj19/OtterAnnotationSourceChooser.java | 5924b88d8b135f4372da239134ce637d00c7c8e5 | [] | no_license | ylzheng/BatchAmpTargetSeqSearch | 5762fef6cc4c86330e20d5325f3ec32f4acb507c | a68caea55130b0a97b8ec5b641a742a026c879d5 | refs/heads/master | 2021-01-10T01:10:02.392330 | 2016-02-05T06:09:26 | 2016-02-05T06:09:26 | 50,147,790 | 0 | 1 | null | 2016-02-05T06:09:26 | 2016-01-22T01:00:43 | Java | UTF-8 | Java | false | false | 2,327 | java | package apollo.dataadapter.ensj19;
import java.util.*;
import java.io.*;
import java.net.*;
/**
* Uses otter database to fetch the datasets for a server URL.
**/
public final class
OtterAnnotationSourceChooser
extends
AnnotationSourceChooser
{
public OtterAnnotationSourceChooser(){
super();
}
public OtterAnnotationSourceChooser(
Vector inputFileHistory,
Vector inputServerHistory,
Vector outputFileHistory,
Vector outputServerHistory
){
super(
inputFileHistory,
inputServerHistory,
outputFileHistory
);
}//end OtterAnnotationSourceChooser
/**
* I expect the following response from the otter server:
* (1) A line which says "Datasets".
* (2) One or more lines listing the annotation datasets you can edit.
**/
protected final List getDataSetsForServer(String serverURLString, String portString){
ArrayList returnList = new ArrayList();
URL uRL = null;
String serverQueryString =
"http://"+
serverURLString+":"+
portString+
"/perl/get_datasets";
DataInputStream inputStream;
String inputLine;
try{
uRL = new URL(serverQueryString);
inputStream = new DataInputStream(uRL.openStream());
inputLine = inputStream.readLine();
if(
inputLine != null &&
inputLine.trim().indexOf("Datasets")>=0
){
inputLine = inputStream.readLine();
while(inputLine != null){
if(
inputLine.trim().length() > 0 &&
!inputLine.equals("Datasets")
){
returnList.add(inputLine.trim());
inputLine = inputStream.readLine();
}else{
inputLine = inputStream.readLine();
}//end if
}//end while
}else{
javax.swing.JOptionPane.showMessageDialog(
this,
"Unable to find otter annotation datasets for server at "+serverQueryString+"\n"
);
return returnList;
}//end if
}catch(IOException exception){
javax.swing.JOptionPane.showMessageDialog(
this,
"Unable to open URL: "+serverQueryString+" for annotations\n"+
exception.getMessage()
);
}//end try
return returnList;
}//end getDataSetsForServer
}//end AnnotationSourceChooser
| [
"zhengyueli@gmail.com"
] | zhengyueli@gmail.com |
ede6163b15c81cfe961c88847e887fa7bb565fd4 | e86eb2f6f6966ff33478f83e5c9be0fe1d8e3319 | /src/test/java/example/conversationapi/MessagesExamples.java | 66607ea6e2c67c5b7f91493616e37996c959e611 | [] | no_license | pabmar68hotmail/sinch-java | 091777f006d3aa232ba0c641b8e82427014cfc84 | 132cda1c5733d45b30d5f9a404d0e850a6ec6792 | refs/heads/master | 2023-07-03T01:42:00.991526 | 2021-08-02T11:22:03 | 2021-08-02T11:22:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,556 | java | package example.conversationapi;
import static com.sinch.sdk.api.conversationapi.factory.ChoiceFactory.choice;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.callMessage;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.cardMessage;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.locationMessage;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.mediaMessage;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.textMessage;
import static com.sinch.sdk.api.conversationapi.factory.MessageFactory.urlMessage;
import com.sinch.sdk.Sinch;
import com.sinch.sdk.api.conversationapi.factory.RecipientFactory;
import com.sinch.sdk.api.conversationapi.model.ListMessagesParams;
import com.sinch.sdk.api.conversationapi.model.request.message.CardMessageRequest;
import com.sinch.sdk.api.conversationapi.model.request.message.CarouselMessageRequest;
import com.sinch.sdk.api.conversationapi.service.Messages;
import com.sinch.sdk.model.Region;
import com.sinch.sdk.model.conversationapi.AppMessage;
import com.sinch.sdk.model.conversationapi.CallMessage;
import com.sinch.sdk.model.conversationapi.CardMessage;
import com.sinch.sdk.model.conversationapi.CarouselMessage;
import com.sinch.sdk.model.conversationapi.Choice;
import com.sinch.sdk.model.conversationapi.ConversationChannel;
import com.sinch.sdk.model.conversationapi.ConversationMessage;
import com.sinch.sdk.model.conversationapi.Coordinates;
import com.sinch.sdk.model.conversationapi.ListMessagesResponse;
import com.sinch.sdk.model.conversationapi.LocationMessage;
import com.sinch.sdk.model.conversationapi.MediaMessage;
import com.sinch.sdk.model.conversationapi.SendMessageRequest;
import com.sinch.sdk.model.conversationapi.SendMessageResponse;
import com.sinch.sdk.model.conversationapi.TextMessage;
import com.sinch.sdk.model.conversationapi.TranscodeMessageRequest;
import com.sinch.sdk.model.conversationapi.UrlMessage;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@Slf4j
@Tag("example")
public class MessagesExamples {
private static final String MESSAGE_ID = "message-id";
private static Messages messages;
@BeforeAll
static void beforeAll() {
// Initialized from system properties, see README.MD in this folder for details.
messages = Sinch.conversationApi(Region.EU).messages(AppsExamples.APP_ID);
}
@Test
void deleteMessage() {
messages.delete(MESSAGE_ID);
}
@Test
void getMessage() {
final ConversationMessage response = messages.get(MESSAGE_ID);
log.info("{}", response);
}
@Test
void listMessages() {
final ListMessagesResponse response =
messages.list(new ListMessagesParams().contactId(ContactsExamples.CONTACT_ID));
log.info("{}", response);
}
@Test
void sendMessage() {
final SendMessageResponse response =
messages.send(
new SendMessageRequest()
.message(
new AppMessage()
.carouselMessage(
new CarouselMessage()
.addCardsItem(
new CardMessage()
.title("This is the card 1 title")
.description("This is the card 1 description")
.mediaMessage(
new MediaMessage()
.url(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
new Choice()
.textMessage(
new TextMessage()
.text("Suggested Reply 1 Text")))
.addChoicesItem(
new Choice()
.textMessage(
new TextMessage()
.text("Suggested Reply 2 Text")))
.addChoicesItem(
new Choice()
.textMessage(
new TextMessage()
.text("Suggested Reply 3 Text"))))
.addCardsItem(
new CardMessage()
.title("This is the card 2 title")
.description("This is the card 2 description")
.mediaMessage(
new MediaMessage()
.url(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
new Choice()
.urlMessage(
new UrlMessage()
.title("URL Choice Message:")
.url("https://www.sinch.com"))))
.addCardsItem(
new CardMessage()
.title("This is the card 3 title")
.description("This is the card 3 description")
.mediaMessage(
new MediaMessage()
.url(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
new Choice()
.callMessage(
new CallMessage()
.title("Call Choice Message:")
.phoneNumber("46732000000"))))
.addCardsItem(
new CardMessage()
.title("This is the card 4 title")
.description("This is the card 4 description")
.mediaMessage(
new MediaMessage()
.url(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
new Choice()
.locationMessage(
new LocationMessage()
.title("Location Choice Message")
.label("Enriching Engagement")
.coordinates(
new Coordinates()
.latitude(55.610479f)
.longitude(13.002873f)))))))
.recipient(RecipientFactory.fromContactId(ContactsExamples.CONTACT_ID))
.addChannelPriorityOrderItem(ConversationChannel.SMS));
log.info("{}", response);
}
/**
* This message is identical to the message above except for the channel priority, to add that
* simply convert it to the raw request by calling '.getRequest()' and add it before sending.
*/
@Test
void sendSimpleMessage() {
final SendMessageResponse response =
messages.send(
new CarouselMessageRequest()
.addCard( // Here I use the CardMessageRequest as a builder for the card message
new CardMessageRequest("This is the card 1 title")
.description("This is the card 1 description")
.media(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png")
.addTextChoice("Suggested Reply 1 Text")
.addTextChoice("Suggested Reply 2 Text")
.addTextChoice("Suggested Reply 3 Text")
.getMessage())
.addCard( // Here I use the factory methods directly
cardMessage("This is the card 2 title")
.description("This is the card 2 description")
.mediaMessage(
mediaMessage(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
choice(urlMessage("URL Choice Message:", "https://www.sinch.com"))))
.addCard(
cardMessage("This is the card 3 title")
.description("This is the card 3 description")
.mediaMessage(
mediaMessage(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(choice(callMessage("Call Choice Message:", "46732000000"))))
.addCard(
cardMessage("This is the card 4 title")
.description("This is the card 4 description")
.mediaMessage(
mediaMessage(
"https://1vxc0v12qhrm1e72gq1mmxkf-wpengine.netdna-ssl.com/wp-content/uploads/2019/05/Sinch-logo-Events.png"))
.addChoicesItem(
choice(
locationMessage("Location Choice Message", 13.002873f, 55.610479f)
.label("Enriching Engagement"))))
.contactRecipient(ContactsExamples.CONTACT_ID));
log.info("{}", response);
}
@Test
void transcodeMessage() {
final Map<String, String> response =
messages.transcode(
new TranscodeMessageRequest()
.appMessage(new AppMessage().textMessage(textMessage("SDK text message")))
.addChannelsItem(ConversationChannel.VIBER)
.addChannelsItem(ConversationChannel.WHATSAPP));
log.info("{}", response);
}
}
| [
"fredrik.kratzer@sinch.com"
] | fredrik.kratzer@sinch.com |
64f0197e7a041ed481206c12f4c5c41a2ed559bd | df34d09de062ddc48214a17d17411979d83239c6 | /src/TCPServerEmiel.java | 0e148e2d5be618846e96debfcd538a8b990f626b | [] | no_license | beemihae/ICTM2A | b4dcad38d207ad22b7229b4c9289a34dde19fe48 | a31c5021dc91fa6e0aed6434d0599fd351523279 | refs/heads/master | 2021-01-18T22:22:30.718799 | 2017-05-17T13:38:18 | 2017-05-17T13:38:18 | 87,048,756 | 0 | 0 | null | 2017-04-22T22:26:29 | 2017-04-03T07:29:18 | Java | UTF-8 | Java | false | false | 2,007 | java |
import java.io.*;
import java.net.*;
import java.util.ArrayList;
class TCPServerEmiel {
public static void main(String argv[]) throws Exception {
System.out.println("En de server is gestart eh.");
//String clientSentence;
//String capitalizedSentence;
String stringArray;
ArrayList<Integer> array = new ArrayList<Integer>();
// Make the array
int[] ints = {1,2,3,40,5,6,7,8,9,1,0,2,3,4,5,6,7,8,9,5,6,8,9,65,2,3,1,5,6,4,8,5,6,5,5,2,1,3};
for (int index = 0; index < ints.length; index++)
{
array.add(ints[index]);
}
ServerSocket welcomeSocket = new ServerSocket(2005);
try {
while (true) {
Socket connectionSocket = welcomeSocket.accept();
System.out.println("Connection made");
try {
BufferedReader inFromClient = new BufferedReader(
new InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
//clientSentence = inFromClient.readLine();
//System.out.println("En de server is gestart eh.");
//System.out.println("Received: " + clientSentence);
//System.out.println("En de server is gestart eh.");
//capitalizedSentence = clientSentence.toUpperCase() + '\n';
//System.out.println(capitalizedSentence);
//System.out.println("En de server is gestart eh.");
//ImageProcessor2 image = new ImageProcessor2();
stringArray = convertArrayListToString(array);
System.out.println(stringArray);
outToClient.writeBytes(stringArray);
} finally {
connectionSocket.close();
}
}
} finally {
welcomeSocket.close();
System.exit(0);
}
}
public static String convertArrayListToString(ArrayList<Integer> array) {
String stringArray = "";
int term;
for(int i=0; i<array.size(); i++){
term=array.get(i);
stringArray = stringArray+Integer.toString(term)+" ";
}
return stringArray;
}
} | [
"beemihae@w159h022.wireless.ugent.be"
] | beemihae@w159h022.wireless.ugent.be |
da3196993a53ef79038577cadb2adff45d96cf12 | af6dd5a45fc89748a641c82594486c499fe610b1 | /src/com/whiterabbit/checkers/boards/SimpleCross2.java | 8c1be37c0d3838d13f21740c828150b214018540 | [
"Apache-2.0"
] | permissive | fedepaol/DroidChineseCheckers | b98e22be9ff7b652b15685cbba063d0473787d09 | 4314b1484f8583a2c9c7a8daebb33576e88fe78a | refs/heads/master | 2020-05-30T11:37:30.124302 | 2013-03-31T21:09:47 | 2013-03-31T21:09:47 | 1,243,708 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,712 | java | /*******************************************************************************
* Copyright 2011 Federico Paolinelli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.whiterabbit.checkers.boards;
import com.whiterabbit.checkers.R;
public class SimpleCross2 extends BoardKind {
public final static String NAME = "SimpleCross2";
private final char[][] map = {
{'0', '0', '1', '1', '1','0','0'},
{'0', '0', '1', '1', '1','0','0'},
{'0', '1', '1', '1', '1','1','1'},
{'0', '1', '1', 'X', '1','1','1'},
{'0', '1', '1', '1', '1','1','1'},
{'0', '0', '1', '1', '1','0','0'},
{'0', '0', '1', '1', '1','0','0'}};
@Override
public String getName() {
return NAME;
}
@Override
public int getImageResource() {
return R.drawable.simple_cross_2;
}
@Override
char[][] getMap() {
return map;
}
@Override
public
int getMode() {
return 14;
}
@Override
public String getAchievement() {
return "com.pegdroid.simplecross2";
}
}
| [
"fedepaol@gmail.com"
] | fedepaol@gmail.com |
108830bd98e73592707a4384cffe52fc15a3af6b | 89be44270846bd4f32ca3f51f29de4921c1d298a | /bitcamp-project/src/main/java/com/eomcs/lms/GreetingListener.java | c7c1667136f7daf2d37c319fdb93a7465ead3803 | [] | no_license | nayoung00/bitcamp-study | 931b439c40a8fe10bdee49c0aaf449399d8fe801 | b3d3c9135114cf17c7afd3ceaee83b5c2cedff29 | refs/heads/master | 2020-09-28T17:39:04.332086 | 2020-04-30T23:57:45 | 2020-04-30T23:57:45 | 226,825,309 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 466 | java | package com.eomcs.lms;
import java.util.Map;
import com.eomcs.lms.context.ApplicationContextListener;
public class GreetingListener implements ApplicationContextListener {
@Override
public void contextInitialized(Map<String, Object> context) {
System.out.println("[수업 관리 시스템]에 오신걸 환영합니다!");
}
@Override
public void contextDestroyed(Map<String, Object> context) {
System.out.println("안녕히가세요!");
}
}
| [
"invin1201@gmail.com"
] | invin1201@gmail.com |
ecd9566ab21e93b0b93c6253e0e6e8d41e329909 | 6c553459bfc3fac679716da09a8576d015289f01 | /src/structuraldp/sdp01_adapter/TranslatorAdapter.java | 63289bc9a477137f06bb8595ba63c6540e45bd01 | [] | no_license | hieuhth/DesignPatternStudy | d5c57effdc4728debf0d922bc1f080bfe368670a | a3f35ec8e37362ca3d96660eb13c123454cd8666 | refs/heads/master | 2023-07-17T23:14:43.388862 | 2021-08-28T10:50:41 | 2021-08-28T10:50:41 | 400,767,768 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 747 | java | package structuraldp.sdp01_adapter;
public class TranslatorAdapter implements VietnameseTarget {
private JapaneseAdaptee adaptee;
public TranslatorAdapter(JapaneseAdaptee adaptee) {
// TODO Auto-generated constructor stub
this.adaptee = adaptee;
}
@Override
public void send(String message) {
// TODO Auto-generated method stub
System.out.println("Reading Words ...");
System.out.println(message);
String vietnameseWords = this.translate(message);
System.out.println("Sending Words ...");
adaptee.receive(vietnameseWords);
}
private String translate(String message) {
System.out.println("Translated!");
return "Message in Japanese " + message;
}
}
| [
"trunghieubk@gmail.com"
] | trunghieubk@gmail.com |
839d609f263b6d03eec869725a3e43a95e3b1c6c | 1201983ea3ed42014de85d9134f7174fe77f3f35 | /yuicompressor-2.4.2/rhino1_6R7/src/org/yuimozilla/javascript/UintMap.java | 1024da3df2a1cdbd4a74daa2759a78daf75f9898 | [
"BSD-3-Clause"
] | permissive | thegreatape/slim | f398175a2b0b6a39c0ab5103e8904c19591b5534 | b188c1a0a10871d9654b41487050afe794e6d974 | refs/heads/master | 2016-09-05T17:02:01.575534 | 2009-08-07T14:53:54 | 2009-08-07T14:53:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 21,289 | java | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1997-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License Version 2 or later (the "GPL"), in which
* case the provisions of the GPL are applicable instead of those above. If
* you wish to allow use of your version of this file only under the terms of
* the GPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replacing
* them with the notice and other provisions required by the GPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* ***** END LICENSE BLOCK ***** */
package org.yuimozilla.javascript;
import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* Map to associate non-negative integers to objects or integers.
* The map does not synchronize any of its operation, so either use
* it from a single thread or do own synchronization or perform all mutation
* operations on one thread before passing the map to others.
*
* @author Igor Bukanov
*
*/
public class UintMap implements Serializable
{
static final long serialVersionUID = 4242698212885848444L;
// Map implementation via hashtable,
// follows "The Art of Computer Programming" by Donald E. Knuth
public UintMap() {
this(4);
}
public UintMap(int initialCapacity) {
if (initialCapacity < 0) Kit.codeBug();
// Table grow when number of stored keys >= 3/4 of max capacity
int minimalCapacity = initialCapacity * 4 / 3;
int i;
for (i = 2; (1 << i) < minimalCapacity; ++i) { }
power = i;
if (check && power < 2) Kit.codeBug();
}
public boolean isEmpty() {
return keyCount == 0;
}
public int size() {
return keyCount;
}
public boolean has(int key) {
if (key < 0) Kit.codeBug();
return 0 <= findIndex(key);
}
/**
* Get object value assigned with key.
* @return key object value or null if key is absent
*/
public Object getObject(int key) {
if (key < 0) Kit.codeBug();
if (values != null) {
int index = findIndex(key);
if (0 <= index) {
return values[index];
}
}
return null;
}
/**
* Get integer value assigned with key.
* @return key integer value or defaultValue if key is absent
*/
public int getInt(int key, int defaultValue) {
if (key < 0) Kit.codeBug();
int index = findIndex(key);
if (0 <= index) {
if (ivaluesShift != 0) {
return keys[ivaluesShift + index];
}
return 0;
}
return defaultValue;
}
/**
* Get integer value assigned with key.
* @return key integer value or defaultValue if key does not exist or does
* not have int value
* @throws RuntimeException if key does not exist
*/
public int getExistingInt(int key) {
if (key < 0) Kit.codeBug();
int index = findIndex(key);
if (0 <= index) {
if (ivaluesShift != 0) {
return keys[ivaluesShift + index];
}
return 0;
}
// Key must exist
Kit.codeBug();
return 0;
}
/**
* Set object value of the key.
* If key does not exist, also set its int value to 0.
*/
public void put(int key, Object value) {
if (key < 0) Kit.codeBug();
int index = ensureIndex(key, false);
if (values == null) {
values = new Object[1 << power];
}
values[index] = value;
}
/**
* Set int value of the key.
* If key does not exist, also set its object value to null.
*/
public void put(int key, int value) {
if (key < 0) Kit.codeBug();
int index = ensureIndex(key, true);
if (ivaluesShift == 0) {
int N = 1 << power;
// keys.length can be N * 2 after clear which set ivaluesShift to 0
if (keys.length != N * 2) {
int[] tmp = new int[N * 2];
System.arraycopy(keys, 0, tmp, 0, N);
keys = tmp;
}
ivaluesShift = N;
}
keys[ivaluesShift + index] = value;
}
public void remove(int key) {
if (key < 0) Kit.codeBug();
int index = findIndex(key);
if (0 <= index) {
keys[index] = DELETED;
--keyCount;
// Allow to GC value and make sure that new key with the deleted
// slot shall get proper default values
if (values != null) { values[index] = null; }
if (ivaluesShift != 0) { keys[ivaluesShift + index] = 0; }
}
}
public void clear() {
int N = 1 << power;
if (keys != null) {
for (int i = 0; i != N; ++i) {
keys[i] = EMPTY;
}
if (values != null) {
for (int i = 0; i != N; ++i) {
values[i] = null;
}
}
}
ivaluesShift = 0;
keyCount = 0;
occupiedCount = 0;
}
/** Return array of present keys */
public int[] getKeys() {
int[] keys = this.keys;
int n = keyCount;
int[] result = new int[n];
for (int i = 0; n != 0; ++i) {
int entry = keys[i];
if (entry != EMPTY && entry != DELETED) {
result[--n] = entry;
}
}
return result;
}
private static int tableLookupStep(int fraction, int mask, int power) {
int shift = 32 - 2 * power;
if (shift >= 0) {
return ((fraction >>> shift) & mask) | 1;
}
else {
return (fraction & (mask >>> -shift)) | 1;
}
}
private int findIndex(int key) {
int[] keys = this.keys;
if (keys != null) {
int fraction = key * A;
int index = fraction >>> (32 - power);
int entry = keys[index];
if (entry == key) { return index; }
if (entry != EMPTY) {
// Search in table after first failed attempt
int mask = (1 << power) - 1;
int step = tableLookupStep(fraction, mask, power);
int n = 0;
do {
if (check) {
if (n >= occupiedCount) Kit.codeBug();
++n;
}
index = (index + step) & mask;
entry = keys[index];
if (entry == key) { return index; }
} while (entry != EMPTY);
}
}
return -1;
}
// Insert key that is not present to table without deleted entries
// and enough free space
private int insertNewKey(int key) {
if (check && occupiedCount != keyCount) Kit.codeBug();
if (check && keyCount == 1 << power) Kit.codeBug();
int[] keys = this.keys;
int fraction = key * A;
int index = fraction >>> (32 - power);
if (keys[index] != EMPTY) {
int mask = (1 << power) - 1;
int step = tableLookupStep(fraction, mask, power);
int firstIndex = index;
do {
if (check && keys[index] == DELETED) Kit.codeBug();
index = (index + step) & mask;
if (check && firstIndex == index) Kit.codeBug();
} while (keys[index] != EMPTY);
}
keys[index] = key;
++occupiedCount;
++keyCount;
return index;
}
private void rehashTable(boolean ensureIntSpace) {
if (keys != null) {
// Check if removing deleted entries would free enough space
if (keyCount * 2 >= occupiedCount) {
// Need to grow: less then half of deleted entries
++power;
}
}
int N = 1 << power;
int[] old = keys;
int oldShift = ivaluesShift;
if (oldShift == 0 && !ensureIntSpace) {
keys = new int[N];
}
else {
ivaluesShift = N; keys = new int[N * 2];
}
for (int i = 0; i != N; ++i) { keys[i] = EMPTY; }
Object[] oldValues = values;
if (oldValues != null) { values = new Object[N]; }
int oldCount = keyCount;
occupiedCount = 0;
if (oldCount != 0) {
keyCount = 0;
for (int i = 0, remaining = oldCount; remaining != 0; ++i) {
int key = old[i];
if (key != EMPTY && key != DELETED) {
int index = insertNewKey(key);
if (oldValues != null) {
values[index] = oldValues[i];
}
if (oldShift != 0) {
keys[ivaluesShift + index] = old[oldShift + i];
}
--remaining;
}
}
}
}
// Ensure key index creating one if necessary
private int ensureIndex(int key, boolean intType) {
int index = -1;
int firstDeleted = -1;
int[] keys = this.keys;
if (keys != null) {
int fraction = key * A;
index = fraction >>> (32 - power);
int entry = keys[index];
if (entry == key) { return index; }
if (entry != EMPTY) {
if (entry == DELETED) { firstDeleted = index; }
// Search in table after first failed attempt
int mask = (1 << power) - 1;
int step = tableLookupStep(fraction, mask, power);
int n = 0;
do {
if (check) {
if (n >= occupiedCount) Kit.codeBug();
++n;
}
index = (index + step) & mask;
entry = keys[index];
if (entry == key) { return index; }
if (entry == DELETED && firstDeleted < 0) {
firstDeleted = index;
}
} while (entry != EMPTY);
}
}
// Inserting of new key
if (check && keys != null && keys[index] != EMPTY)
Kit.codeBug();
if (firstDeleted >= 0) {
index = firstDeleted;
}
else {
// Need to consume empty entry: check occupation level
if (keys == null || occupiedCount * 4 >= (1 << power) * 3) {
// Too litle unused entries: rehash
rehashTable(intType);
keys = this.keys;
return insertNewKey(key);
}
++occupiedCount;
}
keys[index] = key;
++keyCount;
return index;
}
private void writeObject(ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
int count = keyCount;
if (count != 0) {
boolean hasIntValues = (ivaluesShift != 0);
boolean hasObjectValues = (values != null);
out.writeBoolean(hasIntValues);
out.writeBoolean(hasObjectValues);
for (int i = 0; count != 0; ++i) {
int key = keys[i];
if (key != EMPTY && key != DELETED) {
--count;
out.writeInt(key);
if (hasIntValues) {
out.writeInt(keys[ivaluesShift + i]);
}
if (hasObjectValues) {
out.writeObject(values[i]);
}
}
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
int writtenKeyCount = keyCount;
if (writtenKeyCount != 0) {
keyCount = 0;
boolean hasIntValues = in.readBoolean();
boolean hasObjectValues = in.readBoolean();
int N = 1 << power;
if (hasIntValues) {
keys = new int[2 * N];
ivaluesShift = N;
}else {
keys = new int[N];
}
for (int i = 0; i != N; ++i) {
keys[i] = EMPTY;
}
if (hasObjectValues) {
values = new Object[N];
}
for (int i = 0; i != writtenKeyCount; ++i) {
int key = in.readInt();
int index = insertNewKey(key);
if (hasIntValues) {
int ivalue = in.readInt();
keys[ivaluesShift + index] = ivalue;
}
if (hasObjectValues) {
values[index] = in.readObject();
}
}
}
}
// A == golden_ratio * (1 << 32) = ((sqrt(5) - 1) / 2) * (1 << 32)
// See Knuth etc.
private static final int A = 0x9e3779b9;
private static final int EMPTY = -1;
private static final int DELETED = -2;
// Structure of kyes and values arrays (N == 1 << power):
// keys[0 <= i < N]: key value or EMPTY or DELETED mark
// values[0 <= i < N]: value of key at keys[i]
// keys[N <= i < 2N]: int values of keys at keys[i - N]
private transient int[] keys;
private transient Object[] values;
private int power;
private int keyCount;
private transient int occupiedCount; // == keyCount + deleted_count
// If ivaluesShift != 0, keys[ivaluesShift + index] contains integer
// values associated with keys
private transient int ivaluesShift;
// If true, enables consitency checks
private static final boolean check = false;
/* TEST START
public static void main(String[] args) {
if (!check) {
System.err.println("Set check to true and re-run");
throw new RuntimeException("Set check to true and re-run");
}
UintMap map;
map = new UintMap();
testHash(map, 2);
map = new UintMap();
testHash(map, 10 * 1000);
map = new UintMap(30 * 1000);
testHash(map, 10 * 100);
map.clear();
testHash(map, 4);
map = new UintMap(0);
testHash(map, 10 * 100);
}
private static void testHash(UintMap map, int N) {
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
map.put(i, i);
check(i == map.getInt(i, -1));
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
map.put(i, i);
check(i == map.getInt(i, -1));
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
map.put(i, new Integer(i));
check(-1 == map.getInt(i, -1));
Integer obj = (Integer)map.getObject(i);
check(obj != null && i == obj.intValue());
}
check(map.size() == N);
System.out.print("."); System.out.flush();
int[] keys = map.getKeys();
check(keys.length == N);
for (int i = 0; i != N; ++i) {
int key = keys[i];
check(map.has(key));
check(!map.isIntType(key));
check(map.isObjectType(key));
Integer obj = (Integer) map.getObject(key);
check(obj != null && key == obj.intValue());
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
check(-1 == map.getInt(i, -1));
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
map.put(i * i, i);
check(i == map.getInt(i * i, -1));
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
check(i == map.getInt(i * i, -1));
}
System.out.print("."); System.out.flush();
for (int i = 0; i != N; ++i) {
map.put(i * i, new Integer(i));
check(-1 == map.getInt(i * i, -1));
map.remove(i * i);
check(!map.has(i * i));
map.put(i * i, i);
check(map.isIntType(i * i));
check(null == map.getObject(i * i));
map.remove(i * i);
check(!map.isObjectType(i * i));
check(!map.isIntType(i * i));
}
int old_size = map.size();
for (int i = 0; i != N; ++i) {
map.remove(i * i);
check(map.size() == old_size);
}
System.out.print("."); System.out.flush();
map.clear();
check(map.size() == 0);
for (int i = 0; i != N; ++i) {
map.put(i * i, i);
map.put(i * i + 1, new Double(i+0.5));
}
checkSameMaps(map, (UintMap)writeAndRead(map));
System.out.print("."); System.out.flush();
map = new UintMap(0);
checkSameMaps(map, (UintMap)writeAndRead(map));
map = new UintMap(1);
checkSameMaps(map, (UintMap)writeAndRead(map));
map = new UintMap(1000);
checkSameMaps(map, (UintMap)writeAndRead(map));
System.out.print("."); System.out.flush();
map = new UintMap(N / 10);
for (int i = 0; i != N; ++i) {
map.put(2*i+1, i);
}
checkSameMaps(map, (UintMap)writeAndRead(map));
System.out.print("."); System.out.flush();
map = new UintMap(N / 10);
for (int i = 0; i != N; ++i) {
map.put(2*i+1, i);
}
for (int i = 0; i != N / 2; ++i) {
map.remove(2*i+1);
}
checkSameMaps(map, (UintMap)writeAndRead(map));
System.out.print("."); System.out.flush();
map = new UintMap();
for (int i = 0; i != N; ++i) {
map.put(2*i+1, new Double(i + 10));
}
for (int i = 0; i != N / 2; ++i) {
map.remove(2*i+1);
}
checkSameMaps(map, (UintMap)writeAndRead(map));
System.out.println(); System.out.flush();
}
private static void checkSameMaps(UintMap map1, UintMap map2) {
check(map1.size() == map2.size());
int[] keys = map1.getKeys();
check(keys.length == map1.size());
for (int i = 0; i != keys.length; ++i) {
int key = keys[i];
check(map2.has(key));
check(map1.isObjectType(key) == map2.isObjectType(key));
check(map1.isIntType(key) == map2.isIntType(key));
Object o1 = map1.getObject(key);
Object o2 = map2.getObject(key);
if (map1.isObjectType(key)) {
check(o1.equals(o2));
}else {
check(map1.getObject(key) == null);
check(map2.getObject(key) == null);
}
if (map1.isIntType(key)) {
check(map1.getExistingInt(key) == map2.getExistingInt(key));
}else {
check(map1.getInt(key, -10) == -10);
check(map1.getInt(key, -11) == -11);
check(map2.getInt(key, -10) == -10);
check(map2.getInt(key, -11) == -11);
}
}
}
private static void check(boolean condition) {
if (!condition) Kit.codeBug();
}
private static Object writeAndRead(Object obj) {
try {
java.io.ByteArrayOutputStream
bos = new java.io.ByteArrayOutputStream();
java.io.ObjectOutputStream
out = new java.io.ObjectOutputStream(bos);
out.writeObject(obj);
out.close();
byte[] data = bos.toByteArray();
java.io.ByteArrayInputStream
bis = new java.io.ByteArrayInputStream(data);
java.io.ObjectInputStream
in = new java.io.ObjectInputStream(bis);
Object result = in.readObject();
in.close();
return result;
}catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException("Unexpected");
}
}
// TEST END */
}
| [
"tmayfield@axiomsoftwareinc.com"
] | tmayfield@axiomsoftwareinc.com |
8c073091e0aa9a4875b156f4d3078faba837f864 | 850641e11eaf7f610b17801bfdce8dd3da704b8e | /src/java/src/test/java/web/TestSeleniumBase.java | 90dbbc8681be355f6c726722d096e3f75516536c | [] | no_license | pollseed/rubbish-heap-code | 37601938e1dcbca6057924415a17d963ac1f23f7 | cc2a6a8f4a05fddc27927efcbf091704a42e2c7f | refs/heads/master | 2021-01-10T04:36:33.847234 | 2016-03-15T03:33:47 | 2016-03-15T03:33:47 | 52,257,676 | 0 | 0 | null | 2016-03-02T07:01:04 | 2016-02-22T08:12:49 | HTML | UTF-8 | Java | false | false | 459 | java | package TestCode.TestCode;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestSeleniumBase extends TestBaseStandard {
protected static final WebDriver[] DRIVERS;
static {
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver.exe");
DRIVERS = new WebDriver[] { new ChromeDriver(), new FirefoxDriver() };
}
}
| [
"cb.so.devope+0001@gmail.com"
] | cb.so.devope+0001@gmail.com |
01b5368e0986b9eea203a43036729a58e1efb3cf | 6236e26a8e40306d9c8a369de59f58c5d19431ed | /httpsnippet/src/test/resources/output/java/jsoup/headers.java | 79398695ce65742743b2ea1c26d40b3359ec95f4 | [
"Apache-2.0"
] | permissive | atkawa7/httpsnippet | 1f137eb6ba779788a98d1640dc08ce8ce42c88c1 | 6a951c9157b890073da2235a5f0f8b198d3fe3ef | refs/heads/master | 2023-01-04T23:33:02.762501 | 2021-04-21T17:15:47 | 2021-04-21T17:15:47 | 173,534,034 | 19 | 6 | Apache-2.0 | 2022-12-30T17:23:36 | 2019-03-03T05:17:59 | Java | UTF-8 | Java | false | false | 162 | java | String response = Jsoup.connect("http://mockbin.com/har")
.method(Method.GET)
.header("x-foo", "Bar")
.header("accept", "application/json")
.execute().body(); | [
"atkawa7@yahoo.com"
] | atkawa7@yahoo.com |
56e2429166bcc2ca61e0f1214b4131179cb44ca9 | b55d8d2e9581179fd146febbc8766d526a6745f9 | /src/main/java/lgystudy/flink/flink_20210413/HotPages.java | 1ce153afefdf3d20fa7d3eacb7e3dc125afbf14c | [
"Apache-2.0"
] | permissive | liguangyuaaa/bigdatajava | 07765ce53da711b21e52f092685b80a73e28ff02 | 607dafb501e26c890c95ebddcef108c113a47a5b | refs/heads/master | 2023-04-29T11:36:14.735930 | 2021-05-09T16:15:30 | 2021-05-09T16:15:30 | 351,970,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,261 | java | package lgystudy.flink.flink_20210413;
import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.common.state.MapState;
import org.apache.flink.api.common.state.MapStateDescriptor;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.shaded.guava18.com.google.common.collect.Lists;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.streaming.api.functions.timestamps.BoundedOutOfOrdernessTimestampExtractor;
import org.apache.flink.streaming.api.functions.windowing.WindowFunction;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.util.Collector;
import java.net.URL;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
public class HotPages {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
env.setParallelism(1);
URL resource = HotPages.class.getResource("/apache.log");
DataStream<String> inputStream = env.readTextFile(resource.getPath());
DataStream<ApacheLogEvent> dataStream = inputStream.map(line -> {
String[] fields = line.split(" ");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy:HH:mm:ss");
Long timestamp = simpleDateFormat.parse(fields[3]).getTime();
return new ApacheLogEvent(fields[0], fields[1], timestamp, fields[5], fields[6]);
}).assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor<ApacheLogEvent>(Time.seconds(1)) {
@Override
public long extractTimestamp(ApacheLogEvent element) {
return element.getTimestamp();
}
});
//分组开窗聚合
SingleOutputStreamOperator<PageViewCount> windowAggStream = dataStream.filter(data -> "GET".equals(data.getMethod()))
.keyBy(ApacheLogEvent::getUrl) //按照URL分组
.timeWindow(Time.minutes(10), Time.seconds(5))
.aggregate(new PageCountAgg(), new PageCountResult());
//收集同一窗口count数据,排序输出
DataStream<String> resultStream = windowAggStream.keyBy(PageViewCount::getWindowEnd)
.process(new TopNHotPages(3));
resultStream.print();
env.execute("hot page job");
}
//自定义预聚合函数
public static class PageCountAgg implements AggregateFunction<ApacheLogEvent, Long, Long> {
@Override
public Long createAccumulator() {
return 0L;
}
@Override
public Long add(ApacheLogEvent value, Long accumulator) {
return accumulator + 1;
}
@Override
public Long getResult(Long accumulator) {
return accumulator;
}
@Override
public Long merge(Long a, Long b) {
return a + b;
}
}
//实现自定义的窗口函数
public static class PageCountResult implements WindowFunction<Long, PageViewCount, String, TimeWindow>{
@Override
public void apply(String url, TimeWindow window, Iterable<Long> input, Collector<PageViewCount> out) throws Exception {
out.collect(new PageViewCount(url, window.getEnd(), input.iterator().next()));
}
}
// 实现自定义的处理函数
public static class TopNHotPages extends KeyedProcessFunction<Long, PageViewCount, String> {
private Integer topSize;
public TopNHotPages(Integer topSize) {
this.topSize = topSize;
}
// 定义状态,保存当前所有PageViewCount到Map中
// ListState<PageViewCount> pageViewCountListState;
MapState<String, Long> pageViewCountMapState;
@Override
public void open(Configuration parameters) throws Exception {
// pageViewCountListState = getRuntimeContext().getListState(new ListStateDescriptor<PageViewCount>("page-count-list", PageViewCount.class));
pageViewCountMapState = getRuntimeContext().getMapState(new MapStateDescriptor<String, Long>("page-count-map", String.class, Long.class));
}
@Override
public void processElement(PageViewCount value, Context ctx, Collector<String> out) throws Exception {
// pageViewCountListState.add(value);
pageViewCountMapState.put(value.getUrl(), value.getCount());
ctx.timerService().registerEventTimeTimer(value.getWindowEnd() + 1);
// 注册一个1分钟之后的定时器,用来清空状态
ctx.timerService().registerEventTimeTimer(value.getWindowEnd() + 60 * 1000L);
}
@Override
public void onTimer(long timestamp, OnTimerContext ctx, Collector<String> out) throws Exception {
// 先判断是否到了窗口关闭清理时间,如果是,直接清空状态返回
if( timestamp == ctx.getCurrentKey() + 60 * 1000L ){
pageViewCountMapState.clear();
return;
}
ArrayList<Map.Entry<String, Long>> pageViewCounts = Lists.newArrayList(pageViewCountMapState.entries());
pageViewCounts.sort(new Comparator<Map.Entry<String, Long>>() {
@Override
public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> o2) {
if(o1.getValue() > o2.getValue())
return -1;
else if(o1.getValue() < o2.getValue())
return 1;
else
return 0;
}
});
// 格式化成String输出
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.append("===================================\n");
resultBuilder.append("窗口结束时间:").append(new Timestamp(timestamp - 1)).append("\n");
// 遍历列表,取top n输出
for (int i = 0; i < Math.min(topSize, pageViewCounts.size()); i++) {
Map.Entry<String, Long> currentItemViewCount = pageViewCounts.get(i);
resultBuilder.append("NO ").append(i + 1).append(":")
.append(" 页面URL = ").append(currentItemViewCount.getKey())
.append(" 浏览量 = ").append(currentItemViewCount.getValue())
.append("\n");
}
resultBuilder.append("===============================\n\n");
// 控制输出频率
Thread.sleep(1000L);
out.collect(resultBuilder.toString());
// pageViewCountListState.clear();
}
}
}
| [
"guangyu05@126.com"
] | guangyu05@126.com |
fd88cf23f73021ec2ad1089903aee72f68ba8a32 | c18eeb5a25eb9753126595bc0920f2febeaee74c | /HomeWork-2/HelloSpringCloud/gateway/src/test/java/hellospringcloud/gateway/GatewayApplicationTests.java | b4fce1cb4da06353624202bf6657c12770dd006b | [] | no_license | yevheniy-vasylenko/spring_homeworks | 3dd019fc820212910b39db5876c78f0f73a781c6 | abc924226d7747604a79dcc779a52384bcafc59f | refs/heads/master | 2020-04-21T08:47:45.558315 | 2019-02-27T10:35:10 | 2019-02-27T10:35:10 | 169,429,897 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 343 | java | package hellospringcloud.gateway;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class GatewayApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"Yevheniy.Vasylenko@nice.com"
] | Yevheniy.Vasylenko@nice.com |
938d536b758efea4182ad1331bee2948a88de0af | e054c1e6903e4b5eb166d107802c0c2cadd2eb03 | /modules/datex-serializer/src/generated/java/eu/datex2/schema/_3/common/HeaviestAxleWeightCharacteristic.java | 4f4a9ef82c81901e9a7cc02503005d98eb3bf1cc | [
"MIT"
] | permissive | svvsaga/gradle-modules-public | 02dc90ad2feb58aef7629943af3e0d3a9f61d5cf | e4ef4e2ed5d1a194ff426411ccb3f81d34ff4f01 | refs/heads/main | 2023-05-27T08:25:36.578399 | 2023-05-12T14:15:47 | 2023-05-12T14:33:14 | 411,986,217 | 2 | 1 | MIT | 2023-05-12T14:33:15 | 2021-09-30T08:36:11 | Java | UTF-8 | Java | false | false | 3,285 | java |
package eu.datex2.schema._3.common;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
/**
* <p>Java class for HeaviestAxleWeightCharacteristic complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="HeaviestAxleWeightCharacteristic">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="comparisonOperator" type="{http://datex2.eu/schema/3/common}_ComparisonOperatorEnum"/>
* <element name="heaviestAxleWeight" type="{http://datex2.eu/schema/3/common}Tonnes"/>
* <element name="_heaviestAxleWeightCharacteristicExtension" type="{http://datex2.eu/schema/3/common}_ExtensionType" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "HeaviestAxleWeightCharacteristic", propOrder = {
"comparisonOperator",
"heaviestAxleWeight",
"_HeaviestAxleWeightCharacteristicExtension"
})
public class HeaviestAxleWeightCharacteristic {
@XmlElement(required = true)
protected _ComparisonOperatorEnum comparisonOperator;
protected float heaviestAxleWeight;
@XmlElement(name = "_heaviestAxleWeightCharacteristicExtension")
protected _ExtensionType _HeaviestAxleWeightCharacteristicExtension;
/**
* Gets the value of the comparisonOperator property.
*
* @return
* possible object is
* {@link _ComparisonOperatorEnum }
*
*/
public _ComparisonOperatorEnum getComparisonOperator() {
return comparisonOperator;
}
/**
* Sets the value of the comparisonOperator property.
*
* @param value
* allowed object is
* {@link _ComparisonOperatorEnum }
*
*/
public void setComparisonOperator(_ComparisonOperatorEnum value) {
this.comparisonOperator = value;
}
/**
* Gets the value of the heaviestAxleWeight property.
*
*/
public float getHeaviestAxleWeight() {
return heaviestAxleWeight;
}
/**
* Sets the value of the heaviestAxleWeight property.
*
*/
public void setHeaviestAxleWeight(float value) {
this.heaviestAxleWeight = value;
}
/**
* Gets the value of the _HeaviestAxleWeightCharacteristicExtension property.
*
* @return
* possible object is
* {@link _ExtensionType }
*
*/
public _ExtensionType get_HeaviestAxleWeightCharacteristicExtension() {
return _HeaviestAxleWeightCharacteristicExtension;
}
/**
* Sets the value of the _HeaviestAxleWeightCharacteristicExtension property.
*
* @param value
* allowed object is
* {@link _ExtensionType }
*
*/
public void set_HeaviestAxleWeightCharacteristicExtension(_ExtensionType value) {
this._HeaviestAxleWeightCharacteristicExtension = value;
}
}
| [
"geir.sagberg@gmail.com"
] | geir.sagberg@gmail.com |
4dff900bbcf69572cf3644aba4c9bc4a2bb13d7a | 0154c39153e57d3af5da4a33f8799c0badde83c5 | /src/lk-share-service/src/main/java/com/linekong/share/service/utils/IPUtils.java | 90aeab47ff7ef47fa762c9a14c107ec0379e6874 | [] | no_license | allworldall/activity | e3ba1bb4a6f2cae968779c996818b5b9e1d8c994 | b837d06638afec0cdcf9daffce61532f86ce94f5 | refs/heads/master | 2020-03-18T08:41:16.200882 | 2018-05-23T06:16:13 | 2018-05-23T06:16:13 | 134,522,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,185 | java | package com.linekong.share.service.utils;
import javax.servlet.http.HttpServletRequest;
import com.linekong.share.service.utils.log.LoggerUtil;
public class IPUtils {
/**
* ip地址转成long型数字
* 将IP地址转化成整数的方法如下:
* 1、通过String的split方法按.分隔得到4个长度的数组
* 2、通过左移位操作(<<)给每一段的数字加权,第一段的权为2的24次方,第二段的权为2的16次方,第三段的权为2的8次方,最后一段的权为1
* @param strIp
* @return
*/
public static long ipToLong(String strIp) {
long result = 0;
try {
String[]ip = strIp.split("\\.");
result = (Long.parseLong(ip[0]) << 24) + (Long.parseLong(ip[1]) << 16) + (Long.parseLong(ip[2]) << 8) + Long.parseLong(ip[3]);
} catch (Exception e) {
LoggerUtil.error(IPUtils.class, "request ip "+strIp+" error:");
result = ipToLong("127.0.0.1");
}
return result;
}
/**
* 将十进制整数形式转换成127.0.0.1形式的ip地址
* 将整数形式的IP地址转化成字符串的方法如下:
* 1、将整数值进行右移位操作(>>>),右移24位,右移时高位补0,得到的数字即为第一段IP。
* 2、通过与操作符(&)将整数值的高8位设为0,再右移16位,得到的数字即为第二段IP。
* 3、通过与操作符吧整数值的高16位设为0,再右移8位,得到的数字即为第三段IP。
* 4、通过与操作符吧整数值的高24位设为0,得到的数字即为第四段IP。
* @param longIp
* @return
*/
public static String longToIP(long longIp) {
StringBuffer sb = new StringBuffer("");
// 直接右移24位
sb.append(String.valueOf((longIp >>> 24)));
sb.append(".");
// 将高8位置0,然后右移16位
sb.append(String.valueOf((longIp & 0x00FFFFFF) >>> 16));
sb.append(".");
// 将高16位置0,然后右移8位
sb.append(String.valueOf((longIp & 0x0000FFFF) >>> 8));
sb.append(".");
// 将高24位置0
sb.append(String.valueOf((longIp & 0x000000FF)));
return sb.toString();
}
/**
* 获取真实IP
* @param request
* @return
*/
public static String getTrueIP(HttpServletRequest request){
//因原方式获取到的是nginx转发的服务器Ip,所以将ip设置为nginx配置在Header中的实际用户的值
String ip="";
String xRealIp = request.getHeader("X-Real-IP") ;
String XForwardedIp = request.getHeader("X-Forwarded-For") ;
if(XForwardedIp != null && !"".equals(XForwardedIp)){
ip = XForwardedIp.split(",")[0];
}else if(xRealIp != null && !"".equals(xRealIp)){
ip = xRealIp;
}else{
ip = request.getRemoteAddr();
}
return ip;
}
/**
* 获取用户的UA
*/
public static String getUserAgent(HttpServletRequest request) {
String userAgent = request.getHeader("User-Agent");
return userAgent;
}
public static void main(String[] args) {
System.out.println(ipToLong("127.0.0.1"));
}
}
| [
"panpan@panpan.linekongdomain.com"
] | panpan@panpan.linekongdomain.com |
b12489f0f357a0a369961c67b124f3b8939f3dc4 | 85423ae7916ae5a6f26fac22e8f83dd54f589e0d | /dcat-suite-server/src/main/java/org/aksw/trash/RdfFileEntity.java | 3727a6ce8b72fb042df2df1ed1406536296f6ed7 | [
"Apache-2.0"
] | permissive | SmartDataAnalytics/dcat-suite | e4c8b411170332fedf453fa5fc34e102ca0646ae | 9f87eb846955a738da135be00007298c640ddad3 | refs/heads/develop | 2023-04-15T04:12:09.494005 | 2023-04-01T22:19:31 | 2023-04-01T22:19:31 | 127,953,651 | 11 | 0 | Apache-2.0 | 2023-03-06T15:51:55 | 2018-04-03T18:46:46 | Java | UTF-8 | Java | false | false | 289 | java | package org.aksw.trash;
import java.nio.file.Path;
import org.apache.jena.rdf.model.Resource;
/**
* A bundle of a file and rdf metadata
* @author raven
*
*/
public interface RdfFileEntity {
Path getPath();
Resource getInfo();
boolean canWriteInfo();
void writeInfo();
}
| [
"cstadler@informatik.uni-leipzig.de"
] | cstadler@informatik.uni-leipzig.de |
b1ee32ccedca1fd95190658d086457d3dcc47ef2 | a63aa3506e3b8a83b457a185b8d985f807b53156 | /code/src/main/java/Players/Fighters/Fighter.java | 0b02c9694ead0ca8df644dd1442e9d55141dc12d | [] | no_license | elipinska/codeclan_week07_fantasy_game_lab | 6d56fbb0998e3a5a72f87de8ae9026585df69a7c | 339edb5010755951bc19a088ca402d8621ee74f3 | refs/heads/master | 2020-03-11T20:09:12.473683 | 2018-05-16T17:28:44 | 2018-05-16T17:28:44 | 130,229,006 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 779 | java | package Players.Fighters;
import CombatItems.Weapon;
import Players.Player;
import Surprises.Enemy;
import Surprises.ISurprise;
import java.util.Random;
public abstract class Fighter extends Player implements IFight {
private Weapon weapon;
public Fighter(String name, Weapon weapon) {
super(name);
this.weapon = weapon;
}
public Weapon getWeapon() {
return weapon;
}
public int dealDamage() {
return getWeapon().getDamage();
}
public int dealRandomDamage() {
Random rand = new Random();
return rand.nextInt(dealDamage() + 1);
}
public String attack(Enemy enemy) {
(enemy).setHp((enemy).getHp() - dealRandomDamage());
return "You've dealt a nasty blow!";
}
}
| [
"ewa.lipinska@hotmail.com"
] | ewa.lipinska@hotmail.com |
64540f393298e516967353e346d11ee8c44367d3 | 34f8d4ba30242a7045c689768c3472b7af80909c | /jdk-12/src/java.base/java/nio/DirectCharBufferS.java | 2313d47b98335d9ddf97d1b4581345f4ccebe1ec | [
"Apache-2.0"
] | permissive | lovelycheng/JDK | 5b4cc07546f0dbfad15c46d427cae06ef282ef79 | 19a6c71e52f3ecd74e4a66be5d0d552ce7175531 | refs/heads/master | 2023-04-08T11:36:22.073953 | 2022-09-04T01:53:09 | 2022-09-04T01:53:09 | 227,544,567 | 0 | 0 | null | 2019-12-12T07:18:30 | 2019-12-12T07:18:29 | null | UTF-8 | Java | false | false | 10,271 | java | /*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
// -- This file was mechanically generated: Do not edit! -- //
package java.nio;
import java.io.FileDescriptor;
import java.lang.ref.Reference;
import jdk.internal.misc.VM;
import jdk.internal.ref.Cleaner;
import sun.nio.ch.DirectBuffer;
class DirectCharBufferS
extends CharBuffer
implements DirectBuffer
{
// Cached array base offset
private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset(char[].class);
// Cached unaligned-access capability
protected static final boolean UNALIGNED = Bits.unaligned();
// Base address, used in all indexing calculations
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
// protected long address;
// An object attached to this buffer. If this buffer is a view of another
// buffer then we use this field to keep a reference to that buffer to
// ensure that its memory isn't freed before we are done with it.
private final Object att;
public Object attachment() {
return att;
}
public Cleaner cleaner() { return null; }
// For duplicates and slices
//
DirectCharBufferS(DirectBuffer db, // package-private
int mark, int pos, int lim, int cap,
int off)
{
super(mark, pos, lim, cap);
address = db.address() + off;
Object attachment = db.attachment();
att = (attachment == null ? db : attachment);
}
@Override
Object base() {
return null;
}
public CharBuffer slice() {
int pos = this.position();
int lim = this.limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
int off = (pos << 1);
assert (off >= 0);
return new DirectCharBufferS(this, -1, 0, rem, rem, off);
}
public CharBuffer duplicate() {
return new DirectCharBufferS(this,
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
0);
}
public CharBuffer asReadOnlyBuffer() {
return new DirectCharBufferRS(this,
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
0);
}
public long address() {
return address;
}
private long ix(int i) {
return address + ((long)i << 1);
}
public char get() {
try {
return (Bits.swap(UNSAFE.getChar(ix(nextGetIndex()))));
} finally {
Reference.reachabilityFence(this);
}
}
public char get(int i) {
try {
return (Bits.swap(UNSAFE.getChar(ix(checkIndex(i)))));
} finally {
Reference.reachabilityFence(this);
}
}
char getUnchecked(int i) {
try {
return (Bits.swap(UNSAFE.getChar(ix(i))));
} finally {
Reference.reachabilityFence(this);
}
}
public CharBuffer get(char[] dst, int offset, int length) {
if (((long)length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
checkBounds(offset, length, dst.length);
int pos = position();
int lim = limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
if (length > rem)
throw new BufferUnderflowException();
long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << 1);
try {
if (order() != ByteOrder.nativeOrder())
UNSAFE.copySwapMemory(null,
ix(pos),
dst,
dstOffset,
(long)length << 1,
(long)1 << 1);
else
UNSAFE.copyMemory(null,
ix(pos),
dst,
dstOffset,
(long)length << 1);
} finally {
Reference.reachabilityFence(this);
}
position(pos + length);
} else {
super.get(dst, offset, length);
}
return this;
}
public CharBuffer put(char x) {
try {
UNSAFE.putChar(ix(nextPutIndex()), Bits.swap((x)));
} finally {
Reference.reachabilityFence(this);
}
return this;
}
public CharBuffer put(int i, char x) {
try {
UNSAFE.putChar(ix(checkIndex(i)), Bits.swap((x)));
} finally {
Reference.reachabilityFence(this);
}
return this;
}
public CharBuffer put(CharBuffer src) {
if (src instanceof DirectCharBufferS) {
if (src == this)
throw createSameBufferException();
DirectCharBufferS sb = (DirectCharBufferS)src;
int spos = sb.position();
int slim = sb.limit();
assert (spos <= slim);
int srem = (spos <= slim ? slim - spos : 0);
int pos = position();
int lim = limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
if (srem > rem)
throw new BufferOverflowException();
try {
UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << 1);
} finally {
Reference.reachabilityFence(sb);
Reference.reachabilityFence(this);
}
sb.position(spos + srem);
position(pos + srem);
} else if (src.hb != null) {
int spos = src.position();
int slim = src.limit();
assert (spos <= slim);
int srem = (spos <= slim ? slim - spos : 0);
put(src.hb, src.offset + spos, srem);
src.position(spos + srem);
} else {
super.put(src);
}
return this;
}
public CharBuffer put(char[] src, int offset, int length) {
if (((long)length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
checkBounds(offset, length, src.length);
int pos = position();
int lim = limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
if (length > rem)
throw new BufferOverflowException();
long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << 1);
try {
if (order() != ByteOrder.nativeOrder())
UNSAFE.copySwapMemory(src,
srcOffset,
null,
ix(pos),
(long)length << 1,
(long)1 << 1);
else
UNSAFE.copyMemory(src,
srcOffset,
null,
ix(pos),
(long)length << 1);
} finally {
Reference.reachabilityFence(this);
}
position(pos + length);
} else {
super.put(src, offset, length);
}
return this;
}
public CharBuffer compact() {
int pos = position();
int lim = limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
try {
UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << 1);
} finally {
Reference.reachabilityFence(this);
}
position(rem);
limit(capacity());
discardMark();
return this;
}
public boolean isDirect() {
return true;
}
public boolean isReadOnly() {
return false;
}
public String toString(int start, int end) {
if ((end > limit()) || (start > end))
throw new IndexOutOfBoundsException();
try {
int len = end - start;
char[] ca = new char[len];
CharBuffer cb = CharBuffer.wrap(ca);
CharBuffer db = this.duplicate();
db.position(start);
db.limit(end);
cb.put(db);
return new String(ca);
} catch (StringIndexOutOfBoundsException x) {
throw new IndexOutOfBoundsException();
}
}
// --- Methods to support CharSequence ---
public CharBuffer subSequence(int start, int end) {
int pos = position();
int lim = limit();
assert (pos <= lim);
pos = (pos <= lim ? pos : lim);
int len = lim - pos;
if ((start < 0) || (end > len) || (start > end))
throw new IndexOutOfBoundsException();
return new DirectCharBufferS(this,
-1,
pos + start,
pos + end,
capacity(),
offset);
}
public ByteOrder order() {
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
}
ByteOrder charRegionOrder() {
return order();
}
}
| [
"zeng255@163.com"
] | zeng255@163.com |
ff3ede0e7ea0cb117dac58186237d7cd5b6ff3ce | 016b048395ec218dae8728cc08175309302375a9 | /src/ua/com/uectech/wmysoft/SerTest.java | 7841f39522d8eea796391a479e69e2393fe28fa9 | [] | no_license | veitsi/lab03-manager-serializing | 36bb7de9286ae91afa9290b4d6edae1c80ac966d | f90b95a7e6bf10752a0be1a2f829a3bcad587fd2 | refs/heads/master | 2021-01-10T20:28:16.859465 | 2014-12-04T14:05:42 | 2014-12-04T14:05:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,396 | java | package ua.com.uectech.wmysoft;
import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.junit.Test;
public class SerTest {
@Test
public void test() {
//fail("Not yet implemented");
}
@Test
public void testManager() {
System.out.println("about manager");
//fail("Not yet implemented");
}
@Test
public void testSaveManager(){
//Integer I=273;
Manager m=new Manager("Kushnir");
try {
ObjectOutputStream cs=new ObjectOutputStream(new FileOutputStream("ms.ser"));
cs.writeObject(m);
cs.flush();
cs.close();
} catch (IOException e){
System.out.println("Wrong on manager saving");
}
finally {
System.out.println("saved? ");
}
}
@Test
public void testLoadManager(){
System.out.println("-------------------");
System.out.println("Let's try to restore manager");
try {
ObjectInputStream cs=new ObjectInputStream(new FileInputStream("ms.ser"));
Manager m = (Manager) cs.readObject();
cs.close();
System.out.println("after restoring m="+m.name);
} catch (IOException | ClassNotFoundException e){
System.out.println("something wrong in restoring");
}
finally {
System.out.println("loaded? ");
}
}
}
| [
"xtfkpi@yandex.ru"
] | xtfkpi@yandex.ru |
913862e49468a0b4f1d7b676b99322d50d5bcb4e | 5e0fa126b4c098e118816fee3d33b53b2dcdcb10 | /src/main/java/model/MasterBuilderUnit.java | e55f15a0976a8383330aa369ff3d0048cf391d82 | [] | no_license | patrikperko/civilization_2016 | 5cf470d011ca6030508b88176e7d64a8e3adc95c | 198cd1bb40ecb0241780a16c6d9b82e95ddb2d3a | refs/heads/master | 2021-04-29T07:21:52.308072 | 2017-01-04T18:58:45 | 2017-01-04T18:58:45 | 77,953,556 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 762 | java | package model;
import controller.TileType;
import javafx.scene.image.Image;
public class MasterBuilderUnit extends Unit implements Convertable {
public MasterBuilderUnit(Civilization owner) {
super(owner);
}
@Override
public Building convert() {
return getOwner().getLandmark();
}
@Override
public boolean canConvert(TileType type) {
return type == TileType.PLAINS;
}
@Override
public char symbol() {
return 'm';
}
@Override
public String toString() {
return "Master Builders. " + super.toString();
}
@Override
public Image getImage() {
return new Image(
"File:./src/main/java/view/Civ_Icon/master_builder_icon.PNG");
}
}
| [
"Patrik Posobiec Perko"
] | Patrik Posobiec Perko |
d31423d769c72f26afe85557ae9ccb2b2e1211b9 | 0bc1c533325874dd755b245e215ec41622e1c6bb | /basic-cxf/src/main/java/cn/itsource/service/client2/WeatherWSHttpPost.java | a91d1aaf3ad9e58ee8021245980d92455ef13a02 | [] | no_license | GgBoom996/Cashier-Purchase-SaleAndDeposit | ccd6aeedc6a0c1eb9218a55981d1917b4333a133 | 51c8d091199863c6d14fff306237381b29ad783a | refs/heads/master | 2022-12-22T13:56:05.407702 | 2019-08-05T03:22:34 | 2019-08-05T03:22:34 | 200,573,594 | 0 | 0 | null | 2022-12-16T04:50:24 | 2019-08-05T03:10:36 | JavaScript | UTF-8 | Java | false | false | 3,200 | java | package cn.itsource.service.client2;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 3.2.7
* 2019-07-11T16:47:08.622+08:00
* Generated source version: 3.2.7
*
*/
@WebService(targetNamespace = "http://WebXml.com.cn/", name = "WeatherWSHttpPost")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface WeatherWSHttpPost {
/**
* <br /><h3>获得中国省份、直辖市、地区;国家名称(国外)和与之对应的ID</h3><p>输入参数:无,返回数据:DataSet。</p><br />
*/
@WebMethod
@WebResult(name = "DataSet", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public DataSet getRegionDataset();
/**
* <br /><h3>获得国外国家名称和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br />
*/
@WebMethod
@WebResult(name = "ArrayOfString", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public ArrayOfString getRegionCountry();
/**
* <br /><h3>获得天气预报数据</h3><p>输入参数:城市/地区ID或名称,返回数据:一维字符串数组。</p><br />
*/
@WebMethod
@WebResult(name = "ArrayOfString", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public ArrayOfString getWeather(
@WebParam(partName = "theCityCode", name = "theCityCode", targetNamespace = "http://WebXml.com.cn/")
java.lang.String theCityCode,
@WebParam(partName = "theUserID", name = "theUserID", targetNamespace = "http://WebXml.com.cn/")
java.lang.String theUserID
);
/**
* <br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:DataSet。</p><br />
*/
@WebMethod
@WebResult(name = "DataSet", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public DataSet getSupportCityDataset(
@WebParam(partName = "theRegionCode", name = "theRegionCode", targetNamespace = "http://WebXml.com.cn/")
java.lang.String theRegionCode
);
/**
* <br /><h3>获得中国省份、直辖市、地区和与之对应的ID</h3><p>输入参数:无,返回数据:一维字符串数组。</p><br />
*/
@WebMethod
@WebResult(name = "ArrayOfString", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public ArrayOfString getRegionProvince();
/**
* <br /><h3>获得支持的城市/地区名称和与之对应的ID</h3><p>输入参数:theRegionCode = 省市、国家ID或名称,返回数据:一维字符串数组。</p><br />
*/
@WebMethod
@WebResult(name = "ArrayOfString", targetNamespace = "http://WebXml.com.cn/", partName = "Body")
public ArrayOfString getSupportCityString(
@WebParam(partName = "theRegionCode", name = "theRegionCode", targetNamespace = "http://WebXml.com.cn/")
java.lang.String theRegionCode
);
}
| [
"979156668@qq.com"
] | 979156668@qq.com |
6d238002c1a001546ab90eb665ac7add81a7f4f5 | d77a1b9c5009cb30881a49ec493c43b1e2cac674 | /bookaholic3/src/main/java/com/example/bookaholic3/model/exception/UserNotFoundException.java | ec98292844bf0a9e2e91f1cca453a11f9d9abcb1 | [] | no_license | vericajanakeva/autism-app | 877cbaff15254bcff97021dfdea561bbeb165436 | 26354f69a9091b8018018e86f00e1f28745a9a1a | refs/heads/master | 2023-04-19T16:51:53.050407 | 2021-05-09T21:31:30 | 2021-05-09T21:31:30 | 310,632,031 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 428 | java | package com.example.bookaholic3.model.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.NOT_FOUND)
public class UserNotFoundException extends RuntimeException {
public UserNotFoundException(String userId) {
super(String.format("Корисничкото име %s не е пронајдено", userId));
}
}
| [
"vericajanakeva97@gmail.com"
] | vericajanakeva97@gmail.com |
63cd619e9585fd236ff0da4d5f01b42f756f0d19 | 94d2cf0cbbd46db75d7ade4cac9767f34e3aebc9 | /src/test/java/com/attilavarga/employee/relationship/manager/rest/api/ErmRestApiApplicationTests.java | e7508e939fc4b8ae452c11d6c0989544e5e98937 | [] | no_license | vattila96/employee-relationship-manager-rest-api-spring-boot | 56a426121983dcb9ab9b5b6a75e718b96204a6a0 | e3b8da35354193e8e7e6f2f0356101d3896068e9 | refs/heads/master | 2023-02-24T15:40:39.358906 | 2021-01-22T11:25:11 | 2021-01-22T11:25:11 | 330,966,886 | 1 | 1 | null | 2021-01-21T16:33:55 | 2021-01-19T12:06:36 | Java | UTF-8 | Java | false | false | 250 | java | package com.attilavarga.employee.relationship.manager.rest.api;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ErmRestApiApplicationTests {
@Test
void contextLoads() {
}
}
| [
"noreply@github.com"
] | noreply@github.com |
7b3daa20c1ea91e45bfb46b6d7053684b16df779 | 16435878ec235617cce6b6422eeaeb27d3009131 | /src/main/java/com/opencart/test/rest/OcApiSessionResource.java | 0f8ddadd9584c1f248a0d90d3e6379b43b12001f | [] | no_license | gmai2006/opencarttest | fa2207f35046ba636ffef8107a4a6e9ffc57b1bb | b73df234af5bd431b56d038c4aec7aa5383ff1ce | refs/heads/main | 2023-09-02T20:01:51.767075 | 2021-10-16T07:40:18 | 2021-10-16T07:40:18 | 417,754,843 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,099 | java | /**
* %% Copyright (C) 2021 DataScience 9 LLC %% Licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License. #L%
*
* <p>This code is 100% AUTO generated. Please do not modify it DIRECTLY If you need new features or
* function or changes please update the templates then submit the template through our web
* interface.
*/
package com.opencart.test.rest;
import static java.util.Objects.requireNonNull;
import com.opencart.test.entity.OcApiSession;
import com.opencart.test.service.OcApiSessionService;
import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/ocapisession")
@Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON})
public class OcApiSessionResource {
@Inject private OcApiSessionService service;
public OcApiSessionResource() {}
public OcApiSessionResource(final OcApiSessionService service) {
requireNonNull(service);
this.service = service;
}
/**
* hello.
*
* @return a hello.
*/
@GET
@Path("")
public Response hello() {
return Response.status(Response.Status.OK).entity(this.getClass().getName()).build();
}
/**
* InIdempotent method. Update existing OcApiSession.
*
* @param obj - instance of OcApiSession.
* @return OcApiSession.
*/
@Consumes(MediaType.APPLICATION_JSON)
@POST
public OcApiSession update(OcApiSession obj) {
return this.service.update(obj);
}
/**
* Delete existing OcApiSession.
*
* @param id instance of OcApiSession.
* @return OcApiSession.
*/
/**
* Select all OcApiSession with limit of returned records.
*
* @param max - number of records.
* @return a list OcApiSession.
*/
@GET
@Path("select/{max}")
public Response findWithLimit(@PathParam("max") String max) {
Integer input = null;
try {
input = Integer.valueOf(max);
} catch (NumberFormatException ex) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
List<OcApiSession> result = service.select(input);
return Response.status(Response.Status.OK)
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Credentials", "true")
.header(
"Access-Control-Allow-Headers",
"origin, content-type, accept, authorization")
.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD")
.entity(result)
.build();
}
/**
* Select all OcApiSession records.
*
* @return a list OcApiSession.
*/
@GET
@Path("selectAll")
public Response selectAll() {
List<OcApiSession> result = service.selectAll();
return Response.status(Response.Status.OK)
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Credentials", "true")
.header(
"Access-Control-Allow-Headers",
"origin, content-type, accept, authorization")
.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD")
.entity(result)
.build();
}
}
| [
"gmai2006@gmail.com"
] | gmai2006@gmail.com |
b0c5f9efa96e37cdfbe6ea515c8be809c9e1c5f9 | f9bf88fc81dc5f0c0da4b4c25c56a35dd39f55fd | /workspace/Herencia/src/Abstract/Test.java | 100babdbdddbb64877b2372b026cf675e578fa6c | [] | no_license | Danybs/Java1DAM | 80ebad1600e7c026c2bdf55a0d59960496efdfa4 | d4ce7ac518a5d603f543940b93a6fd5df7e3da9e | refs/heads/master | 2021-07-04T11:17:46.838559 | 2017-09-28T00:38:01 | 2017-09-28T00:38:01 | 104,946,630 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 2,679 | java | package Abstract;
public class Test{
static int numEmpleados;
static double importeTotal;
static void Factura(Trabajadores tt){
numEmpleados++;
importeTotal+=tt.calcularSueldo();
System.out.println(tt.toString());
}
public static void main(String[] args) {
Trabajadores t1 = new Salariados("Juan lopez","calle1","NS231321",1300.2);
Trabajadores t2 = new Salariados("alvaro lopez","calle2","NS231321",1100.2);
Trabajadores t3 = new Autonomos("pepe lopez","calle3",160,15);
Trabajadores t4 = new Autonomos("luis lopez","calle4",120,13);
/*System.out.println(t1);
System.out.println(t2);
System.out.println(t3);
System.out.println(t4);*/
Factura(t1);
Factura(t2);
Factura(t3);
Factura(t4);
System.out.println("El número de empleados es de: "+numEmpleados+" y el importe total es de: "+importeTotal);
}
}
abstract class Trabajadores {
String nombre, direccion, num_seg;
double sueldo,tarifa;
int horas;
/**
* @param nombre
* @param direccion
* @param num_seg
* @param sueldo
*/
public Trabajadores(String nombre, String direccion, String num_seg, double sueldo) {
super();
this.nombre = nombre;
this.direccion = direccion;
this.num_seg = num_seg;
this.sueldo = sueldo;
}
public Trabajadores(String nombre, String direccion, int horas, double tarifa){
this.nombre = nombre;
this.direccion = direccion;
this.horas = horas;
this.tarifa= tarifa;
}
public double getSueldo() {
return sueldo;
}
public void setSueldo(double sueldo) {
this.sueldo = sueldo;
}
abstract double calcularSueldo();
@Override
public String toString() {
return "Trabajadores [nombre=" + nombre + ", direccion=" + direccion + ", num_seg=" + num_seg + ", sueldo="
+ sueldo + "]";
}
}
class Salariados extends Trabajadores {
private final double impuesto = 0.19;
public Salariados(String nombre, String direccion, String num_seg, double sueldo) {
super(nombre, direccion, num_seg, sueldo);
// TODO Auto-generated constructor stub
}
@Override
double calcularSueldo() {
// TODO Auto-generated method stub
return getSueldo() - getSueldo() * impuesto;
}
public String toString(){
return super.toString() + " sueldo neto " + calcularSueldo() + "€";
}
}
class Autonomos extends Trabajadores {
public Autonomos(String nombre, String direccion, int horas, double tarifa) {
super(nombre, direccion, horas, tarifa);
// TODO Auto-generated constructor stub
}
@Override
double calcularSueldo() {
// TODO Auto-generated method stub
return tarifa*horas;
}
public String toString(){
sueldo=calcularSueldo();
return super.toString() + "importe a cobrar " + calcularSueldo() + "€";
}
}
| [
"d_blanco70@hotmail.com"
] | d_blanco70@hotmail.com |
16635345a7e9d142ca3b606dc469b4249fe391b7 | bc672d436529afc48d96a4945f406f44794d8576 | /src/main/java/test/test.java | bf469a4b0f4ee0a30b69cdd8ce527d3a49fa2c1c | [] | no_license | KDanila/Codewars | fa2997ae1a6099c5e5c8c4deac32ba4be1a83e5a | 28f11037ffb1c569857b95694a24eee99b5fa2d5 | refs/heads/master | 2021-10-21T09:11:20.151237 | 2021-10-19T08:16:17 | 2021-10-19T08:49:33 | 140,859,135 | 0 | 0 | null | 2020-10-12T18:50:56 | 2018-07-13T14:47:10 | Java | UTF-8 | Java | false | false | 1,721 | java | package test;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.*;
public class test {
public static void main(String[] args) {
List<Borrower> borrowers = createBorrower();
Map<Integer, List<Borrower>> bo = borrowers.stream()
.collect(groupingBy(borrower -> borrower.getIdCa(), mapping(borrower1 -> borrower1, toList())));
System.out.println(bo);
System.out.println(bo.get(1));
System.out.println(bo.get(3));
System.out.println(bo.get(4));
}
static List<Borrower> createBorrower(){
Borrower on1 = Borrower.builder()
.idCa(1)
.name("first")
.build();
Borrower on2 = Borrower.builder()
.idCa(2)
.name("second")
.build();
Borrower on3 = Borrower.builder()
.idCa(1)
.name("third")
.build();
Borrower on4 = Borrower.builder()
.idCa(4)
.name("fourth")
.build();
Borrower on5 = Borrower.builder()
.idCa(2)
.name("fifth")
.build();
List<Borrower> borrowers = new ArrayList<>();
borrowers.add(on1);
borrowers.add(on2);
borrowers.add(on3);
borrowers.add(on4);
borrowers.add(on5);
return borrowers;
}
@Getter
@Builder
@ToString
static class Borrower{
int idCa;
String name;
}
}
| [
"DVasKuzmin@sberbank.ru"
] | DVasKuzmin@sberbank.ru |
f5802fde40c5a75308993c4c1c7f698c0498239e | 6f36eb7fe5dfd876a65e787a0c88d0db147cd610 | /Pandora/CordovaLib/src/org/apache/cordova/CordovaWebViewImpl.java | d00fca4806a1549cc2ed7a901501b976c1ec07e2 | [] | no_license | Emmptee/dounat | 34eda9879f21598dd594f22cf54b63402662ee13 | 9d601fdee54dc0e5ffacff8635685df3c542f154 | refs/heads/master | 2020-03-18T21:24:10.004883 | 2018-06-25T17:40:36 | 2018-06-25T17:40:36 | 135,278,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 21,475 | java | /*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import org.apache.cordova.engine.SystemWebViewEngine;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Main class for interacting with a Cordova webview. Manages plugins, events, and a CordovaWebViewEngine.
* Class uses two-phase initialization. You must call init() before calling any other methods.
*/
public class CordovaWebViewImpl implements CordovaWebView {
public static final String TAG = "CordovaWebViewImpl";
private PluginManager pluginManager;
protected final CordovaWebViewEngine engine;
private CordovaInterface cordova;
// Flag to track that a loadUrl timeout occurred
private int loadUrlTimeout = 0;
private CordovaResourceApi resourceApi;
private CordovaPreferences preferences;
private CoreAndroid appPlugin;
private NativeToJsMessageQueue nativeToJsMessageQueue;
private EngineClient engineClient = new EngineClient();
private boolean hasPausedEver;
// The URL passed to loadUrl(), not necessarily the URL of the current page.
String loadedUrl;
/** custom view created by the browser (a video player for example) */
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private Set<Integer> boundKeyCodes = new HashSet<Integer>();
public static CordovaWebViewEngine createEngine(Context context, CordovaPreferences preferences) {
String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName());
try {
Class<?> webViewClass = Class.forName(className);
Constructor<?> constructor = webViewClass.getConstructor(Context.class, CordovaPreferences.class);
return (CordovaWebViewEngine) constructor.newInstance(context, preferences);
} catch (Exception e) {
throw new RuntimeException("Failed to create webview. ", e);
}
}
public CordovaWebViewImpl(CordovaWebViewEngine cordovaWebViewEngine) {
this.engine = cordovaWebViewEngine;
}
// Convenience method for when creating programmatically (not from Config.xml).
public void init(CordovaInterface cordova) {
init(cordova, new ArrayList<PluginEntry>(), new CordovaPreferences());
}
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences) {
if (this.cordova != null) {
throw new IllegalStateException();
}
this.cordova = cordova;
this.preferences = preferences;
pluginManager = new PluginManager(this, this.cordova, pluginEntries);
resourceApi = new CordovaResourceApi(engine.getView().getContext(), pluginManager);
nativeToJsMessageQueue = new NativeToJsMessageQueue();
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.LoadUrlBridgeMode(engine, cordova));
if (preferences.getBoolean("DisallowOverscroll", false)) {
engine.getView().setOverScrollMode(View.OVER_SCROLL_NEVER);
}
engine.init(this, cordova, engineClient, resourceApi, pluginManager, nativeToJsMessageQueue);
// This isn't enforced by the compiler, so assert here.
assert engine.getView() instanceof CordovaWebViewEngine.EngineView;
pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
pluginManager.init();
}
@Override
public boolean isInitialized() {
return cordova != null;
}
@Override
public void loadUrlIntoView(final String url, boolean recreatePlugins) {
LOG.d(TAG, ">>> loadUrl(" + url + ")");
if ("about:blank".equals(url) || url.startsWith("javascript:")) {
engine.loadUrl(url, false);
return;
}
recreatePlugins = recreatePlugins || (loadedUrl == null);
if (recreatePlugins) {
// Don't re-initialize on first load.
if (loadedUrl != null) {
appPlugin = null;
pluginManager.init();
}
loadedUrl = url;
}
// Create a timeout timer for loadUrl
final int currentLoadUrlTimeout = loadUrlTimeout;
final int loadUrlTimeoutValue = preferences.getInteger("LoadUrlTimeoutValue", 20000);
// Timeout error method
final Runnable loadError = new Runnable() {
@Override
public void run() {
stopLoading();
LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
// Handle other errors by passing them to the webview in JS
JSONObject data = new JSONObject();
try {
data.put("errorCode", -6);
data.put("description", "The connection to the server was unsuccessful.");
data.put("url", url);
} catch (JSONException e) {
// Will never happen.
}
pluginManager.postMessage("onReceivedError", data);
}
};
// Timeout timer method
final Runnable timeoutCheck = new Runnable() {
@Override
public void run() {
try {
synchronized (this) {
wait(loadUrlTimeoutValue);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
// If timeout, then stop loading and handle error
if (loadUrlTimeout == currentLoadUrlTimeout) {
cordova.getActivity().runOnUiThread(loadError);
}
}
};
final boolean _recreatePlugins = recreatePlugins;
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (loadUrlTimeoutValue > 0) {
cordova.getThreadPool().execute(timeoutCheck);
}
engine.loadUrl(url, _recreatePlugins);
}
});
}
@Override
public void loadUrl(String url) {
loadUrlIntoView(url, true);
}
@Override
public void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params) {
LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap)", url, openExternal, clearHistory);
// If clearing history
if (clearHistory) {
engine.clearHistory();
}
// If loading into our webview
if (!openExternal) {
// Make sure url is in whitelist
if (pluginManager.shouldAllowNavigation(url)) {
// TODO: What about params?
// Load new URL
loadUrlIntoView(url, true);
} else {
LOG.w(TAG, "showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=" + url);
}
}
if (!pluginManager.shouldOpenExternalUrl(url)) {
LOG.w(TAG, "showWebPage: Refusing to send intent for URL since it is not in the <allow-intent> whitelist. URL=" + url);
return;
}
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
// To send an intent without CATEGORY_BROWSER, a custom plugin should be used.
intent.addCategory(Intent.CATEGORY_BROWSABLE);
Uri uri = Uri.parse(url);
// Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
// Adding the MIME type to http: URLs causes them to not be handled by the downloader.
if ("file".equals(uri.getScheme())) {
intent.setDataAndType(uri, resourceApi.getMimeType(uri));
} else {
intent.setData(uri);
}
cordova.getActivity().startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
LOG.e(TAG, "Error loading url " + url, e);
}
}
@Override
@Deprecated
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
LOG.d(TAG, "showing Custom View");
// if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
// Store the view and its callback for later (to kill it properly)
mCustomView = view;
mCustomViewCallback = callback;
// Add the custom view to its container.
ViewGroup parent = (ViewGroup) engine.getView().getParent();
parent.addView(view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.CENTER));
// Hide the content view.
engine.getView().setVisibility(View.GONE);
// Finally show the custom view container.
parent.setVisibility(View.VISIBLE);
parent.bringToFront();
}
@Override
@Deprecated
public void hideCustomView() {
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
if (mCustomView == null) {
return;
}
LOG.d(TAG, "Hiding Custom View");
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
ViewGroup parent = (ViewGroup) engine.getView().getParent();
parent.removeView(mCustomView);
mCustomView = null;
mCustomViewCallback.onCustomViewHidden();
// Show the content view.
engine.getView().setVisibility(View.VISIBLE);
}
@Override
@Deprecated
public boolean isCustomViewShowing() {
return mCustomView != null;
}
@Override
@Deprecated
public void sendJavascript(String statement) {
nativeToJsMessageQueue.addJavaScript(statement);
}
@Override
public void sendPluginResult(PluginResult cr, String callbackId) {
nativeToJsMessageQueue.addPluginResult(cr, callbackId);
}
@Override
public PluginManager getPluginManager() {
return pluginManager;
}
@Override
public CordovaPreferences getPreferences() {
return preferences;
}
@Override
public ICordovaCookieManager getCookieManager() {
return engine.getCookieManager();
}
@Override
public CordovaResourceApi getResourceApi() {
return resourceApi;
}
@Override
public CordovaWebViewEngine getEngine() {
return engine;
}
@Override
public View getView() {
return engine.getView();
}
@Override
public Context getContext() {
return engine.getView().getContext();
}
private void sendJavascriptEvent(String event) {
if (appPlugin == null) {
appPlugin = (CoreAndroid)pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME);
}
if (appPlugin == null) {
LOG.w(TAG, "Unable to fire event without existing plugin");
return;
}
appPlugin.fireJavascriptEvent(event);
}
@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
// TODO: Why are search and menu buttons handled separately?
if (override) {
boundKeyCodes.add(keyCode);
} else {
boundKeyCodes.remove(keyCode);
}
return;
default:
throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
}
}
@Override
public boolean isButtonPlumbedToJs(int keyCode) {
return boundKeyCodes.contains(keyCode);
}
@Override
public Object postMessage(String id, Object data) {
return pluginManager.postMessage(id, data);
}
// Engine method proxies:
@Override
public String getUrl() {
return engine.getUrl();
}
@Override
public void stopLoading() {
// Clear timeout flag
loadUrlTimeout++;
}
@Override
public boolean canGoBack() {
return engine.canGoBack();
}
@Override
public void clearCache() {
engine.clearCache();
}
@Override
@Deprecated
public void clearCache(boolean b) {
engine.clearCache();
}
@Override
public void clearHistory() {
engine.clearHistory();
}
@Override
public boolean backHistory() {
return engine.goBack();
}
/////// LifeCycle methods ///////
@Override
public void onNewIntent(Intent intent) {
if (this.pluginManager != null) {
this.pluginManager.onNewIntent(intent);
}
}
@Override
public void handlePause(boolean keepRunning) {
if (!isInitialized()) {
return;
}
hasPausedEver = true;
pluginManager.onPause(keepRunning);
sendJavascriptEvent("pause");
// If app doesn't want to run in background
if (!keepRunning) {
// Pause JavaScript timers. This affects all webviews within the app!
engine.setPaused(true);
}
}
@Override
public void handleResume(boolean keepRunning) {
if (!isInitialized()) {
return;
}
// Resume JavaScript timers. This affects all webviews within the app!
engine.setPaused(false);
this.pluginManager.onResume(keepRunning);
// In order to match the behavior of the other platforms, we only send onResume after an
// onPause has occurred. The resume event might still be sent if the Activity was killed
// while waiting for the result of an external Activity once the result is obtained
if (hasPausedEver) {
sendJavascriptEvent("resume");
}
}
@Override
public void handleStart() {
if (!isInitialized()) {
return;
}
pluginManager.onStart();
}
@Override
public void handleStop() {
if (!isInitialized()) {
return;
}
pluginManager.onStop();
}
@Override
public void handleDestroy() {
if (!isInitialized()) {
return;
}
// Cancel pending timeout timer.
loadUrlTimeout++;
// Forward to plugins
this.pluginManager.onDestroy();
// TODO: about:blank is a bit special (and the default URL for new frames)
// We should use a blank data: url instead so it's more obvious
this.loadUrl("about:blank");
// TODO: Should not destroy webview until after about:blank is done loading.
engine.destroy();
hideCustomView();
}
protected class EngineClient implements CordovaWebViewEngine.Client {
@Override
public void clearLoadTimeoutTimer() {
loadUrlTimeout++;
}
@Override
public void onPageStarted(String newUrl) {
LOG.d(TAG, "onPageDidNavigate(" + newUrl + ")");
boundKeyCodes.clear();
pluginManager.onReset();
pluginManager.postMessage("onPageStarted", newUrl);
}
@Override
public void onReceivedError(int errorCode, String description, String failingUrl) {
clearLoadTimeoutTimer();
JSONObject data = new JSONObject();
try {
data.put("errorCode", errorCode);
data.put("description", description);
data.put("url", failingUrl);
} catch (JSONException e) {
e.printStackTrace();
}
pluginManager.postMessage("onReceivedError", data);
}
@Override
public void onPageFinishedLoading(String url) {
LOG.d(TAG, "onPageFinished(" + url + ")");
clearLoadTimeoutTimer();
// Broadcast message that page has loaded
pluginManager.postMessage("onPageFinished", url);
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
if (engine.getView().getVisibility() != View.VISIBLE) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
pluginManager.postMessage("spinner", "stop");
}
});
} catch (InterruptedException e) {
}
}
});
t.start();
}
// Shutdown if blank loaded
if ("about:blank".equals(url)) {
pluginManager.postMessage("exit", null);
}
}
@Override
public Boolean onDispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
boolean isBackButton = keyCode == KeyEvent.KEYCODE_BACK;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (isBackButton && mCustomView != null) {
return true;
} else if (boundKeyCodes.contains(keyCode)) {
return true;
} else if (isBackButton) {
return engine.canGoBack();
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (isBackButton && mCustomView != null) {
hideCustomView();
return true;
} else if (boundKeyCodes.contains(keyCode)) {
String eventName = null;
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
eventName = "volumedownbutton";
break;
case KeyEvent.KEYCODE_VOLUME_UP:
eventName = "volumeupbutton";
break;
case KeyEvent.KEYCODE_SEARCH:
eventName = "searchbutton";
break;
case KeyEvent.KEYCODE_MENU:
eventName = "menubutton";
break;
case KeyEvent.KEYCODE_BACK:
eventName = "backbutton";
break;
}
if (eventName != null) {
sendJavascriptEvent(eventName);
return true;
}
} else if (isBackButton) {
return engine.goBack();
}
}
return null;
}
@Override
public boolean onNavigationAttempt(String url) {
// Give plugins the chance to handle the url
if (pluginManager.onOverrideUrlLoading(url)) {
return true;
} else if (pluginManager.shouldAllowNavigation(url)) {
return false;
} else if (pluginManager.shouldOpenExternalUrl(url)) {
showWebPage(url, true, false, null);
return true;
}
LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
return true;
}
}
}
| [
"dds.c@163.com"
] | dds.c@163.com |
a556afc18d684d315ee37839530f31efa611903c | c19a1b4335e0716a7d8cb869610d7384962bd47e | /Server/UCGOPS/src/npc/spawn/EfBoss.java | 8b2ea0d9bc8fe2370cfcda419458c04fb2261f1b | [] | no_license | Coldreader88/UCGO-Archive | 827ac7cf65b335315e182feb9a22a8a94780ea9f | 8f25cbd9df3ad953b617516e015d72d08de4e488 | refs/heads/master | 2022-12-05T11:37:28.748522 | 2020-07-28T23:27:05 | 2020-07-28T23:27:05 | 291,826,570 | 2 | 0 | null | 2020-08-31T21:17:03 | 2020-08-31T21:17:02 | null | UTF-8 | Java | false | false | 16,420 | java | package npc.spawn;
import npc.Template;
/**
*
* @author UCGOSERVER.COM
*
* Denne klassen brukes til å holde templates for EF boss NPCs.
*
*/
public class EfBoss {
/**
* Standard Midea NPC boss.
*/
public static Template MIDEA;
/**
* Som standard Midea NPC boss med bedre.
*/
public static Template MIDEA_STRONG;
/**
* Standard Midea i grå NPC boss.
*/
public static Template MIDEA_GRAY;
/**
* Strong grå midea NPC boss.
*/
public static Template MIDEA_GRAY_STRONG;
/**
* Big tray NPC boss.
*/
public static Template BIG_TRAY;
/**
* Pegasus class NPC boss.
*/
public static Template PEGASUS;
/**
* Salamis Boss NPC brukt til å representere en ICF.
*/
public static Template ICF_SALAMIS;
/**
* Magellan Boss NPC brukt til å representere en ICF.
*/
public static Template ICF_MAGELLAN;
/**
* Pegasus Boss NPC brukt til å representere en ICF.
*/
public static Template ICF_PEGASUS;
static {
//Standard Midea NPC boss.
MIDEA = new Template(0xF424A, Template.npcType.Boss, 8);
MIDEA.setCombatStats(120000, 130, 20);
MIDEA.setMobility(50, 50, true);
MIDEA.setWeaponA(0x4465C, 4000, 1400, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
MIDEA.setFlying(true, 400, 800);
MIDEA.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS);
MIDEA.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4A); //Dobbel sjanse for å få L4 TJ.
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA.addDropItem(CommonDrops.HG_100MM);
MIDEA.addDropItem(CommonDrops.HG_MPBG);
MIDEA.addDropItem(CommonDrops.HG_MTC);
MIDEA.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEN);
MIDEA.addDropItem(CommonDrops.CLOTHES_TSHIRT_ARTSOH);
//Strong Midea NPC Boss.
MIDEA_STRONG = new Template(0xF424A, Template.npcType.Boss, 9);
MIDEA_STRONG.setCombatStats(150000, 150, 20);
MIDEA_STRONG.setMobility(50, 50, true);
MIDEA_STRONG.setWeaponA(0x4465C, 5000, 1600, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
MIDEA_STRONG.setFlying(true, 400, 800);
MIDEA_STRONG.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS);
MIDEA_STRONG.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A); //Trippel sjanse for å få L4 TJ.
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_STRONG.addDropItem(CommonDrops.HG_ZAKU_BAZOOKA);
MIDEA_STRONG.addDropItem(CommonDrops.HG_100MM);
MIDEA_STRONG.addDropItem(CommonDrops.HG_MS_TORPEDO);
MIDEA_STRONG.addDropItem(EFdrops.WEAPON_RX79G_BEAMRIFLE_EX);
MIDEA_STRONG.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEN);
MIDEA_STRONG.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEON);
MIDEA_STRONG.addDropItem(CommonDrops.CLOTHES_TSHIRT_ARTSOH);
//Grå midea NPC boss.
MIDEA_GRAY = new Template(0xF4242, Template.npcType.Boss, 9);
MIDEA_GRAY.setCombatStats(150000, 130, 20);
MIDEA_GRAY.setMobility(50, 50, true);
MIDEA_GRAY.setWeaponA(0x4465C, 4000, 1500, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
MIDEA_GRAY.setFlying(true, 400, 800);
MIDEA_GRAY.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS);
MIDEA_GRAY.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_TANK_L4A);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_TANK_L4B);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_TANK_L4C);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_TANK_L4D);
MIDEA_GRAY.addDropItem(CommonDrops.ENGINE_TANK_L4E);
MIDEA_GRAY.addDropItem(CommonDrops.HG_MS_CANNON);
MIDEA_GRAY.addDropItem(CommonDrops.HG_180MM);
MIDEA_GRAY.addDropItem(CommonDrops.HG_MPBG);
MIDEA_GRAY.addDropItem(CommonDrops.HG_MS_TORPEDO);
MIDEA_GRAY.addDropItem(CommonDrops.HG_MMP78);
MIDEA_GRAY.addDropItem(CommonDrops.HG_GUNLAUNCHER);
MIDEA_GRAY.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEN);
MIDEA_GRAY.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEON);
//Strong grå Midea NPC boss.
MIDEA_GRAY_STRONG = new Template(0xF4242, Template.npcType.Boss, 10);
MIDEA_GRAY_STRONG.setCombatStats(200000, 180, 20);
MIDEA_GRAY_STRONG.setMobility(50, 50, true);
MIDEA_GRAY_STRONG.setWeaponA(0x4465C, 6000, 1600, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
MIDEA_GRAY_STRONG.setFlying(true, 400, 800);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A); //Dobbel sjanse for å få L4.
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_HB_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_TANK_L4A);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_TANK_L4B);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_TANK_L4C);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_TANK_L4D);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.ENGINE_TANK_L4E);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_GIANT_BAZOOKA);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MS_CANNON);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MTC);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MPBG);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_GUNLAUNCHER);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MS_TORPEDO);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_100MM);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MMP78);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.HG_MS14_BEAMRIFLE);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEN);
MIDEA_GRAY_STRONG.addDropItem(CommonDrops.CLOTHES_TSHIRT_ZEON);
//Big tray NPC boss.
BIG_TRAY = new Template(1030001, Template.npcType.Boss, 11);
BIG_TRAY.setCombatStats(300000, 180, 20);
BIG_TRAY.setMobility(25, 25, true);
BIG_TRAY.setWeaponA(0x4465C, 6000, 1600, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4A);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4B);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4C);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4D);
BIG_TRAY.addDropItem(CommonDrops.ENGINE_HB_L4E);
BIG_TRAY.addDropItem(CommonDrops.HG_MS14_BEAMRIFLE);
BIG_TRAY.addDropItem(CommonDrops.HG_GIANT_BAZOOKA);
BIG_TRAY.addDropItem(CommonDrops.HG_MMP78);
BIG_TRAY.addDropItem(CommonDrops.HG_MPBG);
BIG_TRAY.addDropItem(CommonDrops.HG_MS_TORPEDO);
BIG_TRAY.addDropItem(CommonDrops.HG_MTC);
BIG_TRAY.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS2);
BIG_TRAY.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS2);
//Pegasus class NPC boss.
PEGASUS = new Template(1030005, Template.npcType.Boss, 12);
PEGASUS.setCombatStats(400000, 180, 20);
PEGASUS.setMobility(50, 50, true);
PEGASUS.setWeaponA(0x4465C, 6000, 1600, 30); //Angriper hvert 15. sekund. 30=15 sekunder for boss NPC.
PEGASUS.setFlying(true, 200, 400);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4A);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4B);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4C);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4D);
PEGASUS.addDropItem(CommonDrops.ENGINE_HB_L4E);
PEGASUS.addDropItem(CommonDrops.HG_180MM);
PEGASUS.addDropItem(CommonDrops.HG_MS14_BEAMRIFLE);
PEGASUS.addDropItem(CommonDrops.HG_79L_BEAMRIFLE);
PEGASUS.addDropItem(CommonDrops.HG_MPBG);
PEGASUS.addDropItem(CommonDrops.HG_MMP78);
PEGASUS.addDropItem(CommonDrops.HG_ZAKU_BAZOOKA);
PEGASUS.addDropItem(CommonDrops.HG_GIANT_BAZOOKA);
PEGASUS.addDropItem(CommonDrops.GREAT_HEAT_HAWK);
PEGASUS.addDropItem(CommonDrops.GIANT_HEAT_HAWK);
PEGASUS.addDropItem(CommonDrops.MATERIAL_FINETCC_BOSS2);
PEGASUS.addDropItem(CommonDrops.MATERIAL_JUNKPART_BOSS2);
PEGASUS.addDropItem(CommonDrops.CLOTHES_UNIFORM_AMURO);
PEGASUS.addDropItem(CommonDrops.CLOTHES_UNIFORM_CHAR);
ICF_SALAMIS = new Template(1030015, Template.npcType.Boss, 0);
ICF_SALAMIS.setCombatStats(1000000, 90, 0);
ICF_SALAMIS.setMobility(50, 50, true);
ICF_SALAMIS.setWeaponA(0x44662, 1000, 0, 40);
ICF_MAGELLAN = new Template(1030016, Template.npcType.Boss, 0);
ICF_MAGELLAN.setCombatStats(1500000, 90, 0);
ICF_MAGELLAN.setMobility(50, 50, true);
ICF_MAGELLAN.setWeaponA(0x44662, 1000, 0, 40);
ICF_PEGASUS = new Template(1030005, Template.npcType.Boss, 0);
ICF_PEGASUS.setCombatStats(2000000, 90, 0);
ICF_PEGASUS.setMobility(50, 50, true);
ICF_PEGASUS.setWeaponA(0x44662, 1000, 0, 40);
}
}
| [
"peterrose1994@gmail.com"
] | peterrose1994@gmail.com |
2a8348998a79c09c87042725c1aba1747f7b277f | 2c47aa19b712395a0c72f79d3be61abc2e5ea4bb | /containers/src/main/java/SimpleHashMap.java | dbb43a16a2625fb1fdb12b7ad444a19b41bb707a | [] | no_license | XJ2017/TIJ4-code | 0213046c9e4902ee5a8b3073e3318c09b3be1143 | 367ab160a3bd51bb09e8220a2ddb08324a554eb2 | refs/heads/master | 2021-01-20T18:52:36.726726 | 2016-06-28T09:23:28 | 2016-06-28T09:23:28 | 62,103,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,969 | java | //: containers/SimpleHashMap.java
// A demonstration hashed Map.
import java.util.*;
import mindview.util.*;
public class SimpleHashMap<K,V> extends AbstractMap<K,V> {
// Choose a prime number for the hash table
// size, to achieve a uniform distribution:
static final int SIZE = 997;
// You can't have a physical array of generics,
// but you can upcast to one:
@SuppressWarnings("unchecked")
LinkedList<MapEntry<K,V>>[] buckets =
new LinkedList[SIZE];
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<MapEntry<K,V>>();
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); // Replace old with new
found = true;
break;
}
}
if(!found)
buckets[index].add(pair);
return oldValue;
}
public V get(Object key) {
int index = Math.abs(key.hashCode()) % SIZE;
if(buckets[index] == null) return null;
for(MapEntry<K,V> iPair : buckets[index])
if(iPair.getKey().equals(key))
return iPair.getValue();
return null;
}
public Set<Entry<K,V>> entrySet() {
Set<Entry<K,V>> set= new HashSet<Entry<K,V>>();
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> m =
new SimpleHashMap<String,String>();
m.putAll(Countries.capitals(25));
System.out.println(m);
System.out.println(m.get("ERITREA"));
System.out.println(m.entrySet());
}
} /* Output:
{CAMEROON=Yaounde, CONGO=Brazzaville, CHAD=N'djamena, COTE D'IVOIR (IVORY COAST)=Yamoussoukro, CENTRAL AFRICAN REPUBLIC=Bangui, GUINEA=Conakry, BOTSWANA=Gaberone, BISSAU=Bissau, EGYPT=Cairo, ANGOLA=Luanda, BURKINA FASO=Ouagadougou, ERITREA=Asmara, THE GAMBIA=Banjul, KENYA=Nairobi, GABON=Libreville, CAPE VERDE=Praia, ALGERIA=Algiers, COMOROS=Moroni, EQUATORIAL GUINEA=Malabo, BURUNDI=Bujumbura, BENIN=Porto-Novo, BULGARIA=Sofia, GHANA=Accra, DJIBOUTI=Dijibouti, ETHIOPIA=Addis Ababa}
Asmara
[CAMEROON=Yaounde, CONGO=Brazzaville, CHAD=N'djamena, COTE D'IVOIR (IVORY COAST)=Yamoussoukro, CENTRAL AFRICAN REPUBLIC=Bangui, GUINEA=Conakry, BOTSWANA=Gaberone, BISSAU=Bissau, EGYPT=Cairo, ANGOLA=Luanda, BURKINA FASO=Ouagadougou, ERITREA=Asmara, THE GAMBIA=Banjul, KENYA=Nairobi, GABON=Libreville, CAPE VERDE=Praia, ALGERIA=Algiers, COMOROS=Moroni, EQUATORIAL GUINEA=Malabo, BURUNDI=Bujumbura, BENIN=Porto-Novo, BULGARIA=Sofia, GHANA=Accra, DJIBOUTI=Dijibouti, ETHIOPIA=Addis Ababa]
*///:~
| [
"504283451@qq.com"
] | 504283451@qq.com |
67f4215554a8184ae5772be98f1d92f1455c4ed2 | 7f20b1bddf9f48108a43a9922433b141fac66a6d | /corelibs/tags/Cyto-2.8.0-alpha1/equations/src/main/java/org/cytoscape/equations/parse_tree/StringConstantNode.java | 7e8f0440a81bb17dc18189ebc0268f23486431b0 | [] | no_license | ahdahddl/cytoscape | bf783d44cddda313a5b3563ea746b07f38173022 | a3df8f63dba4ec49942027c91ecac6efa920c195 | refs/heads/master | 2020-06-26T16:48:19.791722 | 2013-08-28T04:08:31 | 2013-08-28T04:08:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,395 | java | /*
File: StringConstantNode.java
Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
documentation provided hereunder is on an "as is" basis, and the
Institute for Systems Biology and the Whitehead Institute
have no obligations to provide maintenance, support,
updates, enhancements or modifications. In no event shall the
Institute for Systems Biology and the Whitehead Institute
be liable to any party for direct, indirect, special,
incidental or consequential damages, including lost profits, arising
out of the use of this software and its documentation, even if the
Institute for Systems Biology and the Whitehead Institute
have been advised of the possibility of such damage. See
the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
package org.cytoscape.equations.parse_tree;
import java.util.Stack;
import org.cytoscape.equations.CodeAndSourceLocation;
/**
* A node in the parse tree representing an integer constant.
*/
public class StringConstantNode extends Node {
private final String value;
public StringConstantNode(final int sourceLocation, final String value) {
super(sourceLocation);
this.value = value;
}
public String toString() { return "StringConstantNode: " + value; }
public Class getType() { return String.class; }
/**
* @return null, This type of node never has any children!
*/
public Node getLeftChild() { return null; }
/**
* @return null, This type of node never has any children!
*/
public Node getRightChild() { return null; }
public String getValue() { return value; }
public void genCode(final Stack<CodeAndSourceLocation> codeStack) {
codeStack.push(new CodeAndSourceLocation(value, getSourceLocation()));
}
}
| [
"mes@0ecc0d97-ab19-0410-9704-bfe1a75892f5"
] | mes@0ecc0d97-ab19-0410-9704-bfe1a75892f5 |
a2dc20197c0ec7d3cea7f5329e48049c18cdac6c | b551e104ff1da8fd473ae71f89ed4fddae668f78 | /BackEnd/src/main/java/com/relaciones/model/Cliente.java | 92a9c4320c59d765913100eaa809814818f370aa | [] | no_license | juanCR44/interestcost-store | a6910b1dd63dfd79574e19459c70ec643c9f3712 | 74e098b0cf401a8e0216ef7aba94c99b74649190 | refs/heads/master | 2023-06-17T13:24:43.485954 | 2021-07-12T22:56:21 | 2021-07-12T22:56:21 | 385,403,567 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,133 | java | package com.relaciones.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import ch.qos.logback.core.subst.Token.Type;
@Entity
@Table(name = "TP_CLIENTE")
public class Cliente implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;
@Column(name = "NOMBRE")
private String nombre;
@Column(name = "APELLIDO")
private String apellido;
@Column(name = "DNI", unique = true)
private String dni;
@Column(name = "PASSWORD", unique = true)
private String password;
@OneToMany(mappedBy = "cliente", fetch = FetchType.LAZY)
@JsonIgnoreProperties("cliente")
private List<CuentaCredito> cuentaCredito;
@ManyToOne
@JoinColumn(name = "ID_BODEGUERO")
@JsonIgnoreProperties("cliente")
private Bodeguero bodeguero;
public Cliente(Long id, String nombre, String apellido, String dni, String password,
List<CuentaCredito> cuentaCredito, Bodeguero bodeguero) {
super();
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
this.dni = dni;
this.password = password;
this.cuentaCredito = cuentaCredito;
this.bodeguero = bodeguero;
}
public Cliente() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getDni() {
return dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public Bodeguero getBodeguero() {
return bodeguero;
}
public void setBodeguero(Bodeguero bodeguero) {
this.bodeguero = bodeguero;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<CuentaCredito> getCuentaCredito() {
return cuentaCredito;
}
public void setCuentaCredito(List<CuentaCredito> cuentaCredito) {
this.cuentaCredito = cuentaCredito;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Cliente other = (Cliente) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
| [
"juancastror.1235@gmail.com"
] | juancastror.1235@gmail.com |
3ea1a2242ce85f5cb8f35264c1f2468415277571 | abfa0e44e8e33175181e43f9598dd62091c73931 | /eyes.blue.lamrimreader.core/src/eyes/blue/lamrimreader/core/PLIndex.java | 2c71f4b0382b77a19a0bcf24a1c59bea884e2bb4 | [] | no_license | eyesblue/lamrimreader.core | 1f4926efd35ef06247ab64fa29546a6d2162b0f8 | 9eca6aea597211f7ca8e37e57434dd88b227cab6 | refs/heads/master | 2021-01-01T04:34:48.970071 | 2016-05-23T11:49:10 | 2016-05-23T11:49:10 | 59,212,354 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package eyes.blue.lamrimreader.core;
/**
* 代表頁(Page)、行(Line)、位置(Index)的物件
* Created by father on 16/5/18.
*/
public class PLIndex {
public int page=-1, line=-1, index=-1;
public int length = -1;
public PLIndex(int page, int line, int index){
this.page=page;
this.line=line;
this.index=index;
}
public PLIndex(int page, int line, int index, int length){
this(page,line,index);
this.length=length;
}
@Override
public boolean equals(Object obj){
PLIndex pli=(PLIndex)obj;
return (page == pli.page && line == pli.line && index == pli.index);
}
}
| [
"eyesblue@eyes-blue.com"
] | eyesblue@eyes-blue.com |
2cc1e319d0a717b2fad6a38e94f90f262758a6dd | 0a59ae5d67dd485af99870291df6766a8d141e29 | /LiteralnoUdruzenje/src/main/java/tim22/upp/LiteralnoUdruzenje/repository/ReviewRepository.java | 3dccf274b03361b70a7a407e10b82a0739de8c50 | [] | no_license | tim-master2020/LiteralnoUdruzenje | e401ae44566c92f6dec47938d9e667740079b961 | d15f2ecda6ec1eda4413c2c573b91cc142c145a3 | refs/heads/master | 2023-02-25T08:06:15.741396 | 2021-02-02T20:14:38 | 2021-02-02T20:14:38 | 319,450,413 | 0 | 0 | null | 2021-02-02T20:14:40 | 2020-12-07T21:35:52 | Java | UTF-8 | Java | false | false | 456 | java | package tim22.upp.LiteralnoUdruzenje.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import tim22.upp.LiteralnoUdruzenje.model.Review;
import tim22.upp.LiteralnoUdruzenje.model.Writer;
import java.util.List;
import java.util.Optional;
public interface ReviewRepository extends JpaRepository<Review, Long> {
Optional<Review> findById(Long id);
List<Review> findByWriter(Writer writer);
Review save(Review review);
}
| [
"noreply@github.com"
] | noreply@github.com |
e4f368dd512f9a79576b89ef03df6b74a81d81e6 | 118f16aff64fd08b534d6be7b3aca3e2f396dbca | /src/main/java/com/api/pizza/model/CrustSize.java | 912da34347bd7f752c13044dba02cd4f08d61472 | [] | no_license | mmukeshkumar/pizza-api | dbbaded95c94b9cb17e8929cadadee492b83aef8 | 7524473f63cc8115e7fbd886a8382925ca4a5817 | refs/heads/master | 2020-04-15T06:21:31.695195 | 2019-02-10T19:37:15 | 2019-02-10T19:37:15 | 164,457,924 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 267 | java | package com.api.pizza.model;
public enum CrustSize {
SMALL(2.50), MEDIUM(4.50), LARGE(6.50);
private final double price;
private CrustSize(double price) {
this.price = price;
}
public double getPrice(){
return price;
}
}
| [
"mkmanirajkumar@gmail"
] | mkmanirajkumar@gmail |
d6c4420f79d4d5f418aae8958ad4d5afa21fba63 | 3efc1f27362b4bf61f289524e5c4e0d210ee0a08 | /hql-builder/hibernate/hibernate-5.4/src/main/java/org/tools/hqlbuilder/common/validation/JavaxValidationConverter.java | 3af01293664afb5daf6c932292aa8e82068e15b7 | [
"MIT"
] | permissive | jurgendl/hql-builder | 4ab12eeda3d3593339bcc5ff0e09eac944ebd3f8 | a2371a03f82314ce2dd2ab331b07bb5c740a129a | refs/heads/master | 2023-03-11T05:44:19.515319 | 2023-03-07T22:13:49 | 2023-03-07T22:13:49 | 32,464,675 | 4 | 1 | MIT | 2022-06-30T16:11:27 | 2015-03-18T14:45:41 | Java | UTF-8 | Java | false | false | 1,955 | java | package org.tools.hqlbuilder.common.validation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.validation.ConstraintViolationException;
import javax.validation.Path;
import org.tools.hqlbuilder.common.exceptions.ValidationException;
import org.tools.hqlbuilder.common.interfaces.ValidationExceptionConverter;
public class JavaxValidationConverter implements ValidationExceptionConverter {
/**
* @see org.tools.hqlbuilder.common.interfaces.ValidationExceptionConverter#convert(java.lang.Exception)
*/
@Override
public ValidationException convert(Exception e) {
javax.validation.ConstraintViolationException ex = (ConstraintViolationException) e;
List<org.tools.hqlbuilder.common.exceptions.ValidationException.InvalidValue> ivs = new ArrayList<org.tools.hqlbuilder.common.exceptions.ValidationException.InvalidValue>();
for (javax.validation.ConstraintViolation<?> iv : ex.getConstraintViolations()) {
Object bean = iv.getLeafBean();
Class<?> beanClass = iv.getRootBeanClass();
String message = iv.getMessage();
Path path = iv.getPropertyPath();
Iterator<javax.validation.Path.Node> it = path.iterator();
Path.Node node = it.next();
while (it.hasNext()) {
node = it.next();
}
String propertyName = String.valueOf(node);
String propertyPath = String.valueOf(path);
Object rootBean = iv.getRootBean();
Object value = iv.getInvalidValue();
org.tools.hqlbuilder.common.exceptions.ValidationException.InvalidValue tmp = new org.tools.hqlbuilder.common.exceptions.ValidationException.InvalidValue(
bean, beanClass, message, propertyName, propertyPath, rootBean, value);
ivs.add(tmp);
}
return new ValidationException(ex.getMessage(), ivs);
}
}
| [
"jurgen.de.landsheer@gmail.com"
] | jurgen.de.landsheer@gmail.com |
af280965df7d510df8ef3429b99312dafb1dd68d | b74f2c19ea8e730b93e3da8842fc0ca3db9639dd | /aws-java-sdk-health/src/main/java/com/amazonaws/services/health/model/EventDescription.java | 52fc83912b6615b60c11b17a272bf4c48b345009 | [
"Apache-2.0"
] | permissive | mgivney/aws-sdk-java | 2de4a597beeda68735ba5bb822f45e924de29d14 | 005db50a80c825dc305306a0633cac057b95b054 | refs/heads/master | 2021-05-02T04:51:13.281576 | 2016-12-16T01:48:44 | 2016-12-16T01:48:44 | 76,672,974 | 1 | 0 | null | 2016-12-16T17:36:09 | 2016-12-16T17:36:09 | null | UTF-8 | Java | false | false | 3,655 | java | /*
* Copyright 2011-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.health.model;
import java.io.Serializable;
/**
* <p>
* The detailed description of the event. Included in the information returned by the <a>DescribeEventDetails</a>
* operation.
* </p>
*/
public class EventDescription implements Serializable, Cloneable {
/**
* <p>
* The most recent description of the event.
* </p>
*/
private String latestDescription;
/**
* <p>
* The most recent description of the event.
* </p>
*
* @param latestDescription
* The most recent description of the event.
*/
public void setLatestDescription(String latestDescription) {
this.latestDescription = latestDescription;
}
/**
* <p>
* The most recent description of the event.
* </p>
*
* @return The most recent description of the event.
*/
public String getLatestDescription() {
return this.latestDescription;
}
/**
* <p>
* The most recent description of the event.
* </p>
*
* @param latestDescription
* The most recent description of the event.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public EventDescription withLatestDescription(String latestDescription) {
setLatestDescription(latestDescription);
return this;
}
/**
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getLatestDescription() != null)
sb.append("LatestDescription: " + getLatestDescription());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof EventDescription == false)
return false;
EventDescription other = (EventDescription) obj;
if (other.getLatestDescription() == null ^ this.getLatestDescription() == null)
return false;
if (other.getLatestDescription() != null && other.getLatestDescription().equals(this.getLatestDescription()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getLatestDescription() == null) ? 0 : getLatestDescription().hashCode());
return hashCode;
}
@Override
public EventDescription clone() {
try {
return (EventDescription) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}
| [
""
] | |
9aa270e0c72a2b7f4e252dc48d0f9a7aada1512a | 0eadcd1c12046b18c06fdab9a7f5860f7572252c | /innerclass/src/innerclass/TestStaticNestedClass.java | 2114517ede0cbd75e01c2f7919b933ab6e6e5689 | [] | no_license | ergunbaris/oraclecertstudy | b2cf57dff88b668e573fc5a452ebd889294ba8e7 | 403b2607d0c63e68dbcb6c1cb9c5a71543372802 | refs/heads/master | 2021-01-25T05:16:38.869570 | 2017-04-09T20:32:51 | 2017-04-09T20:32:51 | 25,186,560 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 458 | java | package innerclass;
class OuterClass{
public static class StaticNestedClass{
public void talk(){
System.out.println("I am not a Static Inner Class! call me either Static Nested Class or Top-level Nested Class");
}
}
}
public class TestStaticNestedClass{
public static void main(String...args){
OuterClass.StaticNestedClass nested = new OuterClass.StaticNestedClass();
nested.talk();
}
}
| [
"barisergun75@gmail.com"
] | barisergun75@gmail.com |
eb4e226a7ab37860a5c809ea636a715f6654bce5 | 1ea8bdfa5934531a547a299b0a983ae28a570605 | /src/main/java/com/epam/mentoring/web/service/UserService.java | 71c938bc61a87e4d86eed7b43a1ee1766a38dcec | [] | no_license | karsakou/2017W-D2D3-DK-Karsakou-Volkau | 6254a2dec8ee30eb6202a558319d175f4e4f1ce9 | 11c668c533d091611ef2b6eae8d8bcbe4ac35314 | refs/heads/master | 2021-01-14T10:30:30.383013 | 2017-04-17T11:47:35 | 2017-04-17T11:47:35 | 82,035,619 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 308 | java | package com.epam.mentoring.web.service;
import java.util.Collection;
import com.epam.mentoring.web.model.User;
public interface UserService {
User getUserById(Long id);
Collection<User> getAllUsers();
void deleteUser(Long id);
Long createUser(User user);
void updateUser(Long id, User user);
}
| [
"raman.volkau@gmail.com"
] | raman.volkau@gmail.com |
53130f577009c3ad1144dbf86387e0c0f11172f8 | 279125c067e9192a765d8b4bc2fd86139b74a039 | /kylin-datasource/src/main/java/com/wengyingjian/kylin/datasource/transaction/TransactionTemplateConfiguration.java | f657adcf466b930d8300d5da6e7b5a79b79a556a | [] | no_license | wengyingjian/kylin | 659b812d9a0b54c59fae38999c16a989651e115c | c149f1d5f75e293e6abd67c4fc77248857c6be3f | refs/heads/master | 2021-01-10T02:17:08.560397 | 2016-02-26T16:19:14 | 2016-02-26T16:19:14 | 50,170,968 | 9 | 10 | null | null | null | null | UTF-8 | Java | false | false | 843 | java | /**
* Copyright (c) 2015, 59store. All rights reserved.
*/
package com.wengyingjian.kylin.datasource.transaction;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
import com.wengyingjian.kylin.datasource.factory.MasterDB;
/**
* {@link TransactionTemplate}配置.
*
* @author <a href="mailto:zhuzm@59store.com">天河</a>
* @version 2.0 2015年11月23日
* @since 2.0
*/
@Configuration
public class TransactionTemplateConfiguration {
/**
* @see MasterDB
*/
@Bean
public TransactionTemplate transactionTemplate(PlatformTransactionManager txManager) {
return new TransactionTemplate(txManager);
}
}
| [
"q291611265@gmail.com"
] | q291611265@gmail.com |
3ef22e4af36e065fa8e06b9b73231a65be3b956b | 07a1a77e9b4737b7f50af024cb5e88fee0f3f372 | /Amazone/src/day8Methods/Method2.java | 95ef81c7302c8012fc5481313debf1b1df2731ec | [] | no_license | tejkumari/Te_My_Repo | 61ae834142f50e30e8fa3653908108e2accc67be | 6524e7a1d6060cfd85f444d07d982616e98e6fb3 | refs/heads/master | 2023-08-21T08:21:17.225446 | 2021-10-28T12:34:42 | 2021-10-28T12:34:42 | 422,195,375 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 794 | java | package day8Methods;
public class Method2 {
double a=50;
static double b=10;
public static void addition() {
Method2 obj = new Method2();
double add= obj.a+b;
System.out.println("Addition is: " +add);
}
public double subtraction(int a, int b) {
int res= a-b;
System.out.println("subtract b from a: " +res);
double sub=a-Method2.b;
System.out.println("Subtraction of a and b: " +sub);
return(res);
}
public static void multiply(int x, int y) {
int mult= x*y;
System.out.println("Multiplication is: " +mult);
}
public static void main(String[] args) {
Method2.addition();
Method2 obj1 = new Method2();
double res= obj1.subtraction(55, 20);
System.out.println("Subtraction is: " +res);
Method2.multiply(20, 50);
}
}
| [
"tejkumari123@gmail.com"
] | tejkumari123@gmail.com |
3c4ddce806f1eafc6419b61443f8874bb796ec93 | 560311c07eaccbe09a4ac1565b1e8f62e785b212 | /src/main/java/logarithmic/Log5.java | 27298cd6ba689cc51237773eea9608cb572a29c0 | [] | no_license | Daniel-ND/IntegrationTesting | 965f5309f438fdb3eecee312c5ccde6811210d44 | cd8ff02a1828752eddf558723b7ec356ae417ef8 | refs/heads/master | 2023-04-05T09:08:01.736392 | 2021-04-19T14:15:43 | 2021-04-19T14:15:43 | 345,131,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 485 | java | package logarithmic;
import util.Functions;
public class Log5 extends Ln{
public Log5(double precision) {
super(precision);
this.function = Functions.LOG_5;
super.setFuncIsStub(true);
}
@Override
public double getFunctionValue(double x){
return super.getFunctionValue(x) / super.getFunctionValue(5);
}
@Override
public double getStubValue(double x) {
return super.getStubValue(x) / super.getStubValue(5);
}
}
| [
"darya-nikolskaya@mail.ru"
] | darya-nikolskaya@mail.ru |
5a6aaf2aff97722728ce2cb8241379022e484426 | 3cd49691808e867ca5ab8b879622b62b2e390d94 | /Android Project/DateMe/src/com/dateme/managers/ServiceManager.java | 4a1fa531f4f50293d38e6a03353d990b92a04253 | [] | no_license | nirav-bhandari/onlinedate | 8d6f6cd179194c98610f321067410cf917fe16f1 | 01b3002dbbf05fd240c5b5474b6c52db9587bf83 | refs/heads/master | 2022-08-13T03:33:29.813548 | 2015-08-07T07:33:14 | 2015-08-07T07:33:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,326 | java | package com.dateme.managers;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import android.content.Context;
import android.util.Log;
import com.dateme.asynctask.AsyncTaskForNetworkManager;
import com.dateme.callback.ParseListener;
import com.dateme.callback.ResponseListener;
import com.dateme.config.AppConstants;
import com.dateme.config.JSONConstants;
import com.dateme.entities.RegistrationResponseEntity;
import com.dateme.entities.UserInfo;
import com.dateme.fragment.network.RequestType;
public class ServiceManager {
private static final ServiceManager INSTANCE = new ServiceManager();
private ServiceManager() {
}
public static ServiceManager getInstance() {
return INSTANCE;
}
public void init() {
Log.d(AppConstants.DEBUG, "INIT ServiceManager MANAGER");
}
public void RegisterUser(final Context context, String url,
UserInfo userInfo, final ResponseListener listener) {
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair(JSONConstants.GetRegistration.EMAIL, userInfo.getEmail()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.USERNAME,
userInfo.getUsername()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.NAME,
userInfo.getName()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.PASSWORD,
userInfo.getEmail()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.BIRTHDAY,
userInfo.getBirthday()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.GENDER,
userInfo.getGender()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.HERE_FOR,
userInfo.getHere_for()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.LOOKING_FOR,userInfo.getLookingfor()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.LOCATION,userInfo.getLocation()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.INTEREST,userInfo.getInterests()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.ABOUTME,userInfo.getAboutme()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.RELATIONSHIP,userInfo.getRelationship()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.SEXUALITY,userInfo.getSexuality()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.HEIGHT,userInfo.getHeight()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.WEIGHT,userInfo.getWeight()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.BODY_TYPE,userInfo.getBody_type()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.EYE_COLOR,userInfo.getEyecolor()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.HAIR_COLOR,userInfo.getHair_color()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.LIVING,userInfo.getLiving()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.CHILDREN,userInfo.getChildren()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.SMOKING,userInfo.getSmoking()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.DRINKING,userInfo.getDrinking()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.EDUCATION,userInfo.getEducation()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.LANGUAGE,userInfo.getLanguage()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.JOB,userInfo.getJob()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.COMPANY,userInfo.getCompany()));
nameValuePair.add(new BasicNameValuePair(
JSONConstants.GetRegistration.INCOME,userInfo.getIncome()));
ParseListener parseListener = new ParseListener() {
@Override
public Object onParse(String jsonString) {
RegistrationResponseEntity registrationResponseEntity = null;
try {
registrationResponseEntity = (RegistrationResponseEntity) ParseManager
.parse(RequestType.GET_REGISTRATION, jsonString);
} catch (JSONException e) {
registrationResponseEntity = new RegistrationResponseEntity();
Log.e(AppConstants.EXCEPTION, e.toString(), e);
} catch (Exception e) {
registrationResponseEntity = new RegistrationResponseEntity();
Log.e(AppConstants.EXCEPTION, e.toString(), e);
}
return registrationResponseEntity;
}
};
new AsyncTaskForNetworkManager(context, nameValuePair, url,
AppConstants.TERMINALKEYFLAG, parseListener) {
@Override
protected void onPostExecute(Object object) {
super.onPostExecute(object);
try {
RegistrationResponseEntity terminalNumberResponseEntity = (RegistrationResponseEntity) object;
listener.onResponse(terminalNumberResponseEntity);
} catch (Exception e) {
Log.e(AppConstants.EXCEPTION, e.toString(), e);
}
}
}.execute();
}
}
| [
"mitu@1103"
] | mitu@1103 |
01dcb6e2bc9239710d06f19d0d863bd877733e89 | 3f4f035f0778c80a25ffa99ae4fc13631f533707 | /src/Algorithm/sortex/Zheban.java | 073a1d2e7a8ab55bb11fe86d6914210a92a40266 | [] | no_license | nnzhuilian/Exercise01 | c286421dd716b62886ad3f3dd236a080220c6662 | d485a6f608ae957d0534404884ee6547ad9b0beb | refs/heads/master | 2022-11-23T07:18:01.434126 | 2022-11-14T12:17:41 | 2022-11-14T12:17:41 | 149,427,501 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 942 | java | package Algorithm.sortex;
public class Zheban {
public static int find(int a[], int b) {
int fp = 0;
int lp = a.length - 1;
int mid = (fp + lp) / 2;
while (true) {
if (b < a[mid]) {
lp = mid;
mid = (fp + lp) / 2;
} else if (b > a[mid]) {
fp = mid;
mid = (fp + lp) / 2;
} else if (b == a[mid]) {
return mid+1;
}
if (lp <= fp) {
return -1;
}
}
}
public static int find(int a[], int b, int fp, int lp) {//ÕÛ°ë
int mid = (fp + lp) / 2;
if (lp < fp) {
return -1;
}
if (b == a[mid]) {
return mid + 1;
} else if (b > a[mid]) {
return find(a, b, mid+1, lp);
} else if (b < a[mid]) {
return find(a, b, fp, mid-1);
}
return -1;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[] = { 1, 4, 5, 8 };
int b = 5;
System.out.println(find(a, b, 0, a.length - 1));//µÝ¹é
System.out.println(find(a, b));//ÆÕͨ
}
}
| [
"609117168@qq.com"
] | 609117168@qq.com |
a14b207ad74a9a6d60847f7b197d75ced373b287 | cb3eec0540116222930cf34482672ed879cf36b2 | /book-service/src/main/java/br/com/bookservice/controller/BookController.java | 6d0dedb61cfe0824c433e39852fdb28f6568ba6f | [] | no_license | leo95h/microservice | 57a978f7f753dd6a5e2cd6073817387a319092f3 | 89a58562bebb82f80161dfa3c3f7ff3c97925d10 | refs/heads/main | 2023-08-26T12:15:03.450742 | 2021-10-13T03:41:52 | 2021-10-13T03:41:52 | 415,712,295 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,526 | java | package br.com.bookservice.controller;
import java.util.HashMap;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import br.com.bookservice.model.Book;
import br.com.bookservice.proxy.CambioProxy;
import br.com.bookservice.repository.BookRepository;
@RestController
@RequestMapping("/book-service")
public class BookController {
@Autowired
private Environment environment;
@Autowired
private BookRepository bookRepository;
@Autowired
private CambioProxy cambioProxy;
//
// Estrutura usando a interface Feign
//
@GetMapping(value = "/{id}/{currency}")
public Optional<Book> findBook(@PathVariable("id") Long id, @PathVariable("currency") String currency) {
var book = bookRepository.findById(id);
if (book == null) {
throw new RuntimeException("Book not found");
}
HashMap<String, String> params = new HashMap<>();
params.put("amount", book.get().getPrice().toString());
params.put("from", "USD");
params.put("to", currency);
var cambio = cambioProxy.getCambio(book.get().getPrice(), "USD", currency);
var port = environment.getProperty("local.server.port");
book.get().setEnvironment(port);
book.get().setCurrency(currency);
book.get().setPrice(cambio.getConvertedValue());
return book;
}
//
// Estrutura sem usar a interface Feign
//
// @GetMapping(value = "/{id}/{currency}")
// public Optional<Book> findBook(@PathVariable("id") Long id, @PathVariable("currency") String currency) {
//
// var book = bookRepository.findById(id);
//
// if (book == null) {
// throw new RuntimeException("Book not found");
// }
//
// HashMap<String, String> params = new HashMap<>();
//
// params.put("amount", book.get().getPrice().toString());
// params.put("from", "USD");
// params.put("to", currency);
//
// var response = new RestTemplate().getForEntity("http://localhost:8000/cambio-service/{amount}/{from}/{to}", Cambio.class, params);
// var cambio = response.getBody();
//
// var port = environment.getProperty("local.server.port");
// book.get().setEnvironment(port);
// book.get().setCurrency(currency);
// book.get().setPrice(cambio.getConvertedValue());
//
// return book;
// }
}
| [
"leonardo.lhpr@gmail.com"
] | leonardo.lhpr@gmail.com |
3a6cb7935597001de704eea59b5eeff372f9d2fa | 129855d705414ebc83cb96a48db1a16b335cd511 | /src/main/java/jp/co/iacsol/bl/BLSugawara.java | ba09607fb4d9c0bc9016d77bd315901b784ab2e3 | [] | no_license | akashi-iacsol/Personnel-evaluation | 9a1886d6f0d956584b0451a16f96ad6da6bee685 | c2e5a77584571350911de9b23d8c85b97e8e7873 | refs/heads/master | 2023-05-08T13:52:28.703121 | 2021-06-01T02:32:58 | 2021-06-01T02:32:58 | 372,676,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,236 | java | package jp.co.iacsol.bl;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import jp.co.iacsol.dao.ListingDAO;
import jp.co.iacsol.to.ListingTO;
import jp.co.iacsol.to.OtherEvaluationTO;
import jp.co.iacsol.util.DBInfoSugawara;
public class BLSugawara {
Connection con = DBInfoSugawara.getConnection();
public ArrayList<ListingTO> findByListing(String employeeName, int fiscalYear) {
ArrayList<ListingTO> listingArray = new ArrayList<ListingTO>();
try {
ListingDAO dao = new ListingDAO(con);
listingArray = dao.findByListing(employeeName, fiscalYear);
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return listingArray;
}
public ArrayList<OtherEvaluationTO> findByEmployeeName() {
ArrayList<OtherEvaluationTO> otherEvaluationArray = new ArrayList<OtherEvaluationTO>();
try {
ListingDAO dao = new ListingDAO(con);
otherEvaluationArray = dao.findByEmployeeName();
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return otherEvaluationArray;
}
} | [
"yuusuke_akashi@LAPTOP-DTE3RJFG.iacsol.local"
] | yuusuke_akashi@LAPTOP-DTE3RJFG.iacsol.local |
a3409ff27b4798f6f532cf3b7d4783f74f327f99 | 2113952519f3df50c13d7747581dc9843d05b433 | /src/graphs/DijkastrasAlgo.java | 1c4905e25126caf6be06a04fba7056dea23825da | [] | no_license | urwithsumit/algorithms | 19eed5f30311dd171c1096d2b8200fd58c799ebf | e86a4a59688e0a17b165658c21227b7f190810c1 | refs/heads/master | 2021-01-15T15:32:43.202350 | 2016-08-27T01:43:21 | 2016-08-27T01:43:21 | 62,487,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,733 | java | package graphs;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
/**
* Dijasktra's Algorithm for Single Source Shortest Path.
* Time Complexity : O((|E|+|V|)\log |V|)
* Sample input:
*
* 1
* 4 4
* 1 2 24
* 1 4 20
* 3 1 3
* 4 3 12
* 1
*
* @author sumitkumar
*
*/
public class DijkastrasAlgo {
private PriorityQueue<Node>[] graph;
private int[] dist; // holds the calculated distances
private static Queue<Integer> queue; // holds the vertex that are adjacent
// to the current vertex.
private int INFINITY = Integer.MAX_VALUE;
/**
* Node to be comparable, as Priority Queue will sort it in order of minimum
* weight
*
* @author sumitkumar
*
*/
class Node implements Comparable<Node> {
int end;
int wt;
public Node(int end, int wt) {
this.end = end;
this.wt = wt;
}
@Override
public int compareTo(Node node) {
boolean flag = this.wt > ((Node) node).wt;
return flag ? 1 : -1;
}
}
@SuppressWarnings("unchecked")
public DijkastrasAlgo(int vertex) {
queue = new LinkedList<Integer>();
this.graph = new PriorityQueue[vertex + 1];
this.dist = new int[vertex + 1];
for (int i = 1; i <= vertex; i++) {
graph[i] = new PriorityQueue<Node>();
dist[i] = INFINITY;
}
}
/**
* Refer to https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
* for algorithm
*
* @param source
*/
public void dijakstra(int source) {
queue.add(source);
dist[source] = 0;
while (!queue.isEmpty()) {
int qElement = queue.poll();
PriorityQueue<Node> list = graph[qElement];
for (Node node : list) {
if ((dist[qElement] + node.wt) < dist[node.end]) {
dist[node.end] = dist[qElement] + node.wt;
queue.add(node.end); // Node to consider for next iteration
}
}
}
}
public void addEdge(int st, int end, int wt) {
graph[st].add(new Node(end, wt));
graph[end].add(new Node(st, wt));
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
for (int i = 0; i < T; i++) {
int N = scan.nextInt();
int M = scan.nextInt();
DijkastrasAlgo sol = new DijkastrasAlgo(N);
for (int j = 0; j < M; j++) {
sol.addEdge(scan.nextInt(), scan.nextInt(), scan.nextInt());
}
int source = scan.nextInt();
sol.dijakstra(source);
System.out.println("Shortest Distance Result using Dijkastra's Algorithm: ");
for (int j = 1; j <= N; j++) {
if (sol.dist[j] != 0) {
if (sol.dist[j] == sol.INFINITY) {
System.out.print(-1 + " ");
} else {
System.out.println(source + " -> " + j + " is " + sol.dist[j] + " ");
}
}
}
System.out.println("");
}
}
} | [
"sumitkumar@192.168.0.14"
] | sumitkumar@192.168.0.14 |
7e172b1bac9d522eb6016bcb397297c5a544d8b0 | be507323471368396b44b2182182981ad73710f4 | /src/main/java/com/china317/core/codec/jtt809_2011/bodyPartImpl/upExgMsg/UpExgMsgApplyHistoryDataReq_0x1209.java | fce47cfb864ed6487239c7261643cbc05f3497bf | [] | no_license | kamikakushi/GPS | ae2fa367a8570f8b0395e4e183025ac77b60121b | 7069dbe24f50e28e29590f2f2cb806683942ac57 | refs/heads/master | 2023-03-19T00:36:04.111329 | 2015-07-10T10:00:56 | 2015-07-10T10:00:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,476 | java | /* */ package com.china317.core.codec.jtt809_2011.bodyPartImpl.upExgMsg;
/* */
/* */ import org.apache.mina.core.buffer.IoBuffer;
/* */
/* */ public class UpExgMsgApplyHistoryDataReq_0x1209 extends UpExgMsgHead
/* */ {
/* */ private long startTime;
/* */ private long endTime;
/* */
/* */ public UpExgMsgApplyHistoryDataReq_0x1209()
/* */ {
/* */ }
/* */
/* */ public UpExgMsgApplyHistoryDataReq_0x1209(int msgId)
/* */ {
/* 12 */ setDataType(msgId);
/* */ }
/* */
/* */ public byte[] buildBody() throws Exception
/* */ {
/* 17 */ IoBuffer buffer = IoBuffer.allocate(64).setAutoExpand(true);
/* 18 */ setDatalength(16);
/* 19 */ buildFirstBody(buffer);
/* */
/* 21 */ buffer.putLong(getStartTime());
/* 22 */ buffer.putLong(getEndTime());
/* */
/* 24 */ buffer.flip();
/* 25 */ byte[] bytes = new byte[buffer.remaining()];
/* 26 */ buffer.get(bytes);
/* 27 */ return bytes;
/* */ }
/* */
/* */ public int getCommand()
/* */ {
/* 33 */ return 4617;
/* */ }
/* */
/* */ public void parseBody(byte[] bytes) throws Exception
/* */ {
/* 38 */ IoBuffer buffer = IoBuffer.wrap(bytes);
/* 39 */ parseFirstBody(buffer);
/* */
/* 41 */ parseLocationBody(buffer);
/* */ }
/* */
/* */ public void parseLocationBody(IoBuffer buffer)
/* */ {
/* 47 */ setStartTime(buffer.getLong());
/* 48 */ setEndTime(buffer.getLong());
/* */ }
/* */
/* */ public long getStartTime()
/* */ {
/* 56 */ return this.startTime;
/* */ }
/* */
/* */ public void setStartTime(long startTime) {
/* 60 */ this.startTime = startTime;
/* */ }
/* */
/* */ public long getEndTime() {
/* 64 */ return this.endTime;
/* */ }
/* */
/* */ public void setEndTime(long endTime) {
/* 68 */ this.endTime = endTime;
/* */ }
/* */ public String toString() {
/* 71 */ return super.toString() + ",startTime=" + this.startTime +
/* 72 */ ",endTime=" + this.endTime;
/* */ }
/* */ }
/* Location: C:\Users\Administrator\Desktop\UpMessageProcessor\新建文件夹\core-1.2beta\
* Qualified Name: com.china317.core.codec.jtt809_2011.bodyPartImpl.upExgMsg.UpExgMsgApplyHistoryDataReq_0x1209
* JD-Core Version: 0.6.1
*/ | [
"linhu.li2012@hotmail.com"
] | linhu.li2012@hotmail.com |
e721d1240f81467b6f8c852c7e639d6f7f95006e | 7a0f1215c564ea6217e84b024fab4d0de8253d6b | /Proxy/src/main/java/demo2/GamePlayerProxy.java | ccd88ad73960844ec949f296c092dd590007fe1b | [] | no_license | westear/DesignModel | f86c31e5b75c59416bed9ba96fd4a5b8d0ac9aeb | e4f6e30c2144b98ecf6a6e88aae03ce7ba8d68c0 | refs/heads/master | 2023-01-12T03:02:30.587636 | 2020-04-08T09:29:40 | 2020-04-08T09:29:40 | 313,571,951 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 672 | java | package demo2;
/**
* 玩游戏代理类
*/
public class GamePlayerProxy implements IGamePlayer {
private IGamePlayer gamePlayer;
//通过构造函数传递要对谁进行代练
public GamePlayerProxy(String name){
try {
gamePlayer = new GamePlayer(this, name);
} catch (Exception e) {
//TODO 异常处理
}
}
@Override
public void login(String user, String password) {
this.gamePlayer.login(user, password);
}
@Override
public void killBoss() {
this.gamePlayer.killBoss();
}
@Override
public void upgrade() {
this.gamePlayer.upgrade();
}
}
| [
"xyq667129@163.com"
] | xyq667129@163.com |
c70fd47bb655a635ac118687d1413af9c6972689 | 0ed985262cbf1580a2eb870352eac21248b00402 | /prototype/src/main/java/com/example/prototype/ui/main/PlaceholderFragment.java | 2cb6e59e49f45562ac1ecc81e45b1a9ffee415b8 | [] | no_license | areej1012/HSMB | beb26fd6300ab3856f6350c6b2d87b4f4ef414b8 | 91cb1292b2405f5029b4e3495dc6f0757975655c | refs/heads/master | 2023-07-07T02:45:29.985659 | 2021-08-12T14:09:08 | 2021-08-12T14:09:08 | 331,016,208 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,566 | java | package com.example.prototype.ui.main;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.example.prototype.R;
/**
* A placeholder fragment containing a simple view.
*/
public class PlaceholderFragment extends Fragment {
private static final String ARG_SECTION_NUMBER = "section_number";
private PageViewModel pageViewModel;
public static PlaceholderFragment newInstance(int index) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle bundle = new Bundle();
bundle.putInt(ARG_SECTION_NUMBER, index);
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pageViewModel = new ViewModelProvider(this).get(PageViewModel.class);
int index = 1;
if (getArguments() != null) {
index = getArguments().getInt(ARG_SECTION_NUMBER);
}
pageViewModel.setIndex(index);
}
@Override
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, container, false);
return root;
}
} | [
"s437012308@st.uqu.edu.sa"
] | s437012308@st.uqu.edu.sa |
2f38f0cdd1240c963c6b993817b62475c3d08f95 | b1d94fa10a6be51f543558d4f767140cdabe09ff | /src/main/java/view/TrainerProfileView.java | c7e051261b886359c08d4f02c0f7892339aa3b3d | [] | no_license | colceriutudor/fitness_application | 8bd1133602949fb6e6561d443a8e6cb94989c0ec | 14b25b565f22c5ea01b1d26056ec3f7e8a5db5aa | refs/heads/main | 2023-02-05T05:58:41.299841 | 2020-12-30T11:41:46 | 2020-12-30T11:41:46 | 325,535,332 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,972 | java | package view;
import controller.TrainerController;
import utils.FrameDesign;
import javax.swing.*;
import java.awt.*;
public class TrainerProfileView extends JFrame{
private JFrame frame;
private JLabel labelProfile = new JLabel("Your Profile");
private JLabel idLabel = new JLabel();
private JLabel nameLabel = new JLabel();
private JLabel certificationLabel = new JLabel();
private JLabel ratingLabel = new JLabel();
private final String idTrainer;
private final TrainerController trainerController;
private final Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
public TrainerProfileView(String idTrainer) {
trainerController = new TrainerController();
this.idTrainer = idTrainer;
frame = new JFrame("Trainer Profile");
setFrameDesign();
initializeTrainerProfileView();
frame.setVisible(true);
}
private void initializeTrainerProfileView(){
frame.getContentPane().setBackground(FrameDesign.NAVY_BLUE);
frame.setLocation(dimension.width / 2 - frame.getSize().width / 2, dimension.height / 2 - frame.getSize().height / 2);
labelProfile.setBounds(170, 10, 100, 20);
idLabel.setBounds(75, 70, 300, 30);
nameLabel.setBounds(75, 130, 250, 30);
certificationLabel.setBounds(75,190,250,30);
ratingLabel.setBounds(75,250,250,30);
frame.setSize(420, 500);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setResizable(false);
addItemsToFrame();
}
private void addItemsToFrame() {
frame.getContentPane().add(labelProfile)
.getParent().add(idLabel)
.getParent().add(nameLabel)
.getParent().add(certificationLabel)
.getParent().add(ratingLabel);
}
private void setFrameDesign(){
ImageIcon img = new ImageIcon("dumbbell.png");
frame.setIconImage(img.getImage());
String[][] data = trainerController.getTrainerProfileData(idTrainer);
labelProfile.setForeground(FrameDesign.DARK_PINK);
labelProfile.setFont(FrameDesign.CALIBRI_BOLD_16);
idLabel.setText("ID: " + data[0][0]);
idLabel.setForeground(FrameDesign.CREAM);
idLabel.setFont(FrameDesign.CALIBRI_BOLD_14);
nameLabel.setText("Name: " + data[0][1]);
nameLabel.setForeground(FrameDesign.CREAM);
nameLabel.setFont(FrameDesign.CALIBRI_BOLD_14);
certificationLabel.setText("Certification: " + (data[0][2] == null ? "None" : data[0][2]));
certificationLabel.setForeground(FrameDesign.CREAM);
certificationLabel.setFont(FrameDesign.CALIBRI_BOLD_14);
ratingLabel.setText("Rating: " + data[0][3]);
ratingLabel.setForeground(FrameDesign.CREAM);
ratingLabel.setFont(FrameDesign.CALIBRI_BOLD_14);
}
}
| [
"colceriu.tudor@yahoo.com"
] | colceriu.tudor@yahoo.com |
48fc69ed2fa45daa275d947e5597f11ae96a490f | 03efa18779813817e00d0e4094c292143fbae430 | /Camel-Rest-Get-Post/src/main/java/com/ashok/example/service/OrderService.java | 2a9436be160d6510e89ea03efa1ab48bf539bc09 | [] | no_license | ashoakskumar/Exercising-Camel-Java | f4e3def9709d0f66b77eadac91f7f4784882e849 | 19f6c6aad7e40800669ff75650800bd0d3dcdcfd | refs/heads/master | 2023-06-18T02:10:23.967969 | 2021-07-19T07:28:45 | 2021-07-19T07:28:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 672 | java | package com.ashok.example.service;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Service;
import com.ashok.example.dto.Order;
@Service
public class OrderService {
private List<Order> orderList = new ArrayList<>();
@PostConstruct
public void initDB() {
orderList.add(new Order(67,"Mobile",5000));
orderList.add(new Order(89,"Book",400));
orderList.add(new Order(45,"AC",15000));
orderList.add(new Order(67,"Shoes",1000));
}
public Order addOrder(Order order) {
orderList.add(order);
return order;
}
public List<Order> getOrderList() {
return orderList;
}
}
| [
"mail2ashokid@gmail.com"
] | mail2ashokid@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.