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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
96656ca11fc05d5a660eec56ec0db78829f7374c | 2f617e2e27e0ef6fb938bf45f47dc8bea1f3d0de | /app/src/main/java/com/udacity/stockhawk/sync/QuoteSyncJob.java | c2b7e64ea2b1a6c40c57c476f8644595c308e862 | [] | no_license | kheirus/StockHawk | f4e22718d47fc99ac1db3fb5f3a6a11a42aa1fe1 | 9d1c4fc290cd91b7135b6f26248b1afc4836ca24 | refs/heads/master | 2021-01-21T17:23:53.141365 | 2017-05-21T17:06:21 | 2017-05-21T17:06:21 | 85,330,726 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,387 | java | package com.udacity.stockhawk.sync;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.annotation.IntDef;
import android.util.Log;
import com.udacity.stockhawk.R;
import com.udacity.stockhawk.data.Contract;
import com.udacity.stockhawk.data.PrefUtils;
import com.udacity.stockhawk.mock.MockUtils;
import com.udacity.stockhawk.utils.Utils;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import timber.log.Timber;
import yahoofinance.Stock;
import yahoofinance.YahooFinance;
import yahoofinance.histquotes.HistoricalQuote;
import yahoofinance.histquotes.Interval;
import yahoofinance.quotes.stock.StockQuote;
import static com.udacity.stockhawk.data.PrefUtils.setStockStatus;
public final class QuoteSyncJob {
private static final int ONE_OFF_ID = 2;
public static final String ACTION_DATA_UPDATED = "com.udacity.stockhawk.ACTION_DATA_UPDATED";
private static final int PERIOD = 300000;
private static final int INITIAL_BACKOFF = 10000;
private static final int PERIODIC_ID = 1;
private static final int YEARS_OF_HISTORY = 2;
private static boolean validSymbol = true;
/** Integration points and error cases **/
public static final int STOCK_STATUS_OK = 0;
public static final int STOCK_STATUS_SERVER_DOWN = 1;
public static final int STOCK_STATUS_SERVER_INVALID = 2;
public static final int STOCK_STATUS_INVALID = 3;
public static final int STOCK_STATUS_EMPTY = 4;
public static final int STOCK_STATUS_UNKNOWN = 5;
@Retention(RetentionPolicy.SOURCE)
@IntDef({STOCK_STATUS_OK, STOCK_STATUS_SERVER_DOWN, STOCK_STATUS_SERVER_INVALID,
STOCK_STATUS_INVALID, STOCK_STATUS_EMPTY, STOCK_STATUS_UNKNOWN})
public @interface StockStatus{}
private QuoteSyncJob() {
}
static void getQuotes(final Context context) {
Timber.d("Running sync job");
String symbol = null;
try {
Set<String> stockPref = PrefUtils.getStocks(context);
Set<String> stockCopy = new HashSet<>();
stockCopy.addAll(stockPref);
String[] stockArray = stockPref.toArray(new String[stockPref.size()]);
Timber.d(stockCopy.toString());
if (stockArray.length == 0) {
setStockStatus(context, STOCK_STATUS_EMPTY);
return;
}
Map<String, Stock> quotes = YahooFinance.get(stockArray);
Iterator<String> iterator = stockCopy.iterator();
if (quotes.isEmpty()){
setStockStatus(context, STOCK_STATUS_SERVER_DOWN);
}
Timber.d(quotes.toString());
ArrayList<ContentValues> quoteCVs = new ArrayList<>();
while (iterator.hasNext()) {
symbol = iterator.next();
StockQuote quote;
Stock stock = quotes.get(symbol);
List<HistoricalQuote> history;
float price, change, percentChange;
String name;
StringBuilder historyBuilder = new StringBuilder();
try {
quote = stock.getQuote();
price = quote.getPrice().floatValue();
change = quote.getChange().floatValue();
percentChange = quote.getChangeInPercent().floatValue();
name = quotes.get(symbol).getName();
} catch (NullPointerException npe) {
String errorMsg = context.getString(R.string.error_invalid_symbol)+": "+symbol;
Utils.showLongToastHandler(context, errorMsg);
PrefUtils.removeStock(context, symbol);
validSymbol = false;
continue;
}
// WARNING! Don't request historical data for a stock that doesn't exist!
// The request will hang forever X_x
Calendar from = Calendar.getInstance();
Calendar to = Calendar.getInstance();
from.add(Calendar.YEAR, -YEARS_OF_HISTORY);
//history = stock.getHistory(from, to, Interval.WEEKLY);
// Note for reviewer:
// Due to problems with Yahoo API we have commented the line above
// and included this one to fetch the history from MockUtils
// This should be enough as to develop and review while the API is down
history = MockUtils.getHistory();
for (HistoricalQuote it : history) {
historyBuilder.append(it.getDate().getTimeInMillis());
historyBuilder.append(", ");
historyBuilder.append(it.getClose());
historyBuilder.append("\n");
}
ContentValues quoteCV = new ContentValues();
quoteCV.put(Contract.Quote.COLUMN_SYMBOL, symbol);
quoteCV.put(Contract.Quote.COLUMN_PRICE, price);
quoteCV.put(Contract.Quote.COLUMN_PERCENTAGE_CHANGE, percentChange);
quoteCV.put(Contract.Quote.COLUMN_ABSOLUTE_CHANGE, change);
quoteCV.put(Contract.Quote.COLUMN_NAME, name);
quoteCV.put(Contract.Quote.COLUMN_HISTORY, historyBuilder.toString());
quoteCVs.add(quoteCV);
context.getContentResolver()
.bulkInsert(
Contract.Quote.URI,
quoteCVs.toArray(new ContentValues[quoteCVs.size()]));
// Update the widget with sending a Broadcast
Intent dataUpdatedIntent = new Intent(ACTION_DATA_UPDATED);
context.sendBroadcast(dataUpdatedIntent);
setStockStatus(context, STOCK_STATUS_OK);
}
} catch (IOException exception) {
Timber.e(exception, "Error fetching stock quotes : "+symbol);
PrefUtils.removeStock(context, symbol);
setStockStatus(context, STOCK_STATUS_SERVER_DOWN);
} catch (Exception unknownException){
Timber.e(unknownException, "Unknown Error");
setStockStatus(context, STOCK_STATUS_UNKNOWN);
}
}
private static void schedulePeriodic(Context context) {
Timber.d("Scheduling a periodic task");
JobInfo.Builder builder = new JobInfo.Builder(PERIODIC_ID, new ComponentName(context, QuoteJobService.class));
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPeriodic(PERIOD)
.setBackoffCriteria(INITIAL_BACKOFF, JobInfo.BACKOFF_POLICY_EXPONENTIAL);
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(builder.build());
}
public static synchronized void initialize(final Context context) {
schedulePeriodic(context);
syncImmediately(context);
}
public static synchronized void syncImmediately(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
Intent nowIntent = new Intent(context, QuoteIntentService.class);
context.startService(nowIntent);
} else {
JobInfo.Builder builder = new JobInfo.Builder(ONE_OFF_ID, new ComponentName(context, QuoteJobService.class));
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setBackoffCriteria(INITIAL_BACKOFF, JobInfo.BACKOFF_POLICY_EXPONENTIAL);
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(builder.build());
}
}
}
| [
"kheirus@hotmail.com"
] | kheirus@hotmail.com |
bd718b8b4a7654e66def583877827287bad8bebe | b481557b5d0e85a057195d8e2ed85555aaf6b4e7 | /src/main/java/com/jlee/leetcodesolutions/LeetCode0849.java | 7af11fd0d192867b5dd8080e4733a8f38b183f98 | [] | no_license | jlee301/leetcodesolutions | b9c61d7fbe96bcb138a2727b69b3a39bbe153911 | 788ac8c1c95eb78eda27b21ecb7b29eea1c7b5a4 | refs/heads/master | 2021-06-05T12:27:42.795124 | 2019-08-11T23:04:07 | 2019-08-11T23:04:07 | 113,272,040 | 0 | 1 | null | 2020-10-12T23:39:27 | 2017-12-06T05:16:39 | Java | UTF-8 | Java | false | false | 1,347 | java | package com.jlee.leetcodesolutions;
import java.util.TreeSet;
public class LeetCode0849 {
/*
* In a row of seats, 1 represents a person sitting in that seat, and 0
* represents that the seat is empty.
*
* There is at least one empty seat, and at least one person sitting.
*
* Alex wants to sit in the seat such that the distance between him and the
* closest person to him is maximized.
*
* Return that maximum distance to closest person.
*
* https://leetcode.com/contest/weekly-contest-88/problems/maximize-distance-to-closest-person/
*/
public int maxDistToClosest(int[] seats) {
// Store location of every seat taken
TreeSet<Integer> set = new TreeSet<>();
for(int i = 0; i < seats.length; i++) {
if(seats[i] == 1)
set.add(i);
}
int max = 0;
// Scan each empty seat for distance to nearest person
for(int i = 0; i < seats.length; i++) {
if(seats[i] == 0) {
int dist = 0;
Integer floor = set.floor(i);
Integer ceil = set.ceiling(i);
if(floor == null)
dist = ceil - i;
else if (ceil == null)
dist = i - floor;
else // Take the closest of the two
dist = Math.min(ceil-i, i-floor);
max = Math.max(max, dist);
}
}
return max;
}
}
| [
"john.m.lee@gmail.com"
] | john.m.lee@gmail.com |
9e9a2f6689d081dbc167b8c9045db92dc76f95da | 3a3cec57017b8fc73f720ce493c89238bfd242a6 | /app/src/main/java/com/mertpolat/detection/env/BorderedText.java | 14fc0a0d9c92ad09cf38bf2b7ffbb31a5edd913a | [] | no_license | polatmert/SEARCH-OBJECT-WITH-INTELLIGENT-SMARTPHONE-AND-FINDING-OBJECT-RECOGNITION | 1598c75b533b336459c71636dd742c4bcc9c594c | c692a6343489cdac295cda3efe9c683c7856d3a3 | refs/heads/master | 2020-03-24T17:23:52.018113 | 2018-07-30T09:57:55 | 2018-07-30T09:57:55 | 142,857,975 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,093 | java | package com.mertpolat.detection.env;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.Typeface;
import java.util.Vector;
/**
* A class that encapsulates the tedious bits of rendering legible, bordered text onto a canvas.
*/
public class BorderedText {
private final Paint interiorPaint;
private final Paint exteriorPaint;
private final float textSize;
/**
* Creates a left-aligned bordered text object with a white interior, and a black exterior with
* the specified text size.
*
* @param textSize text size in pixels
*/
public BorderedText(final float textSize) {
this(Color.WHITE, Color.BLACK, textSize);
}
/**
* Create a bordered text object with the specified interior and exterior colors, text size and
* alignment.
*
* @param interiorColor the interior text color
* @param exteriorColor the exterior text color
* @param textSize text size in pixels
*/
public BorderedText(final int interiorColor, final int exteriorColor, final float textSize) {
interiorPaint = new Paint();
interiorPaint.setTextSize(textSize);
interiorPaint.setColor(interiorColor);
interiorPaint.setStyle(Style.FILL);
interiorPaint.setAntiAlias(false);
interiorPaint.setAlpha(255);
exteriorPaint = new Paint();
exteriorPaint.setTextSize(textSize);
exteriorPaint.setColor(exteriorColor);
exteriorPaint.setStyle(Style.FILL_AND_STROKE);
exteriorPaint.setStrokeWidth(textSize / 8);
exteriorPaint.setAntiAlias(false);
exteriorPaint.setAlpha(255);
this.textSize = textSize;
}
public void setTypeface(Typeface typeface) {
interiorPaint.setTypeface(typeface);
exteriorPaint.setTypeface(typeface);
}
public void drawText(final Canvas canvas, final float posX, final float posY, final String text) {
canvas.drawText(text, posX, posY, exteriorPaint);
canvas.drawText(text, posX, posY, interiorPaint);
}
}
| [
"husnumertpolatt@gmail.com"
] | husnumertpolatt@gmail.com |
bbae1f8f5e12033b7de7df896c91b8c14229dd49 | b19843969066b1b8fd08bb5bf78125adab0e9f19 | /projeto-base/src/main/java/com/projeto/security/util/GeradorSenha.java | d09b8cef0dc265bf4bb0b67f4d48330f5aab5c14 | [] | no_license | bilhares/Spring-boot-services | 343bb8a1a23da9b42474953ed70268431aac6739 | 034cd9af9599172576ebe4c8fe0799a13954e485 | refs/heads/master | 2021-08-31T08:40:42.062021 | 2017-12-20T20:01:46 | 2017-12-20T20:01:46 | 113,078,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 296 | java | package com.projeto.security.util;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
public class GeradorSenha {
public static void main(String[] args) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
System.out.println(encoder.encode("admin"));
}
}
| [
"felipe.bilhares@hotmail.com"
] | felipe.bilhares@hotmail.com |
ab637ccae0213ccdc89e5752cafa164371255bf7 | a506d52fd1e8304cdbc2a71614aa079ccbca2fa7 | /src/forms/form_ingr.java | 3c852ce9c8d91b27b33d1fef7c4bbce079d8fd2d | [] | no_license | victorgabrielbilis/BomBocadoSystem | f77ce6365e323594a6b8f96247b662dcf902fa1c | 2e523c97c6991e45599b954d45ebd783ba6314e5 | refs/heads/master | 2021-09-09T13:04:24.783010 | 2018-03-16T12:26:01 | 2018-03-16T12:26:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,952 | 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 forms;
import java.awt.Color;
import javax.swing.border.LineBorder;
/**
*
* @author i14584i
*/
public class form_ingr extends javax.swing.JFrame {
/**
* Creates new form form_ingr
*/
public form_ingr() {
initComponents();
this.setLocationRelativeTo(null);
}
/**
* 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() {
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Logo para prin.png"))); // NOI18N
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/barrinhas-divisorias-cute-kawaii-photoscape-shopping-by-thataschultz20110925-scallop_beige.png"))); // NOI18N
jLabel2.setText("jLabel2");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 170, 810, 40));
jButton7.setBackground(new java.awt.Color(255, 228, 196));
jButton7.setFont(new java.awt.Font("Monotype Corsiva", 0, 24)); // NOI18N
jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/strawberry (1).png"))); // NOI18N
jButton7.setText("Recheio");
jButton7.setToolTipText("Recheio");
jButton7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 102, 255)));
jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton7MouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
jButton7MouseExited(evt);
}
});
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
getContentPane().add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 260, 240, 120));
jButton8.setBackground(new java.awt.Color(255, 228, 196));
jButton8.setFont(new java.awt.Font("Monotype Corsiva", 0, 24)); // NOI18N
jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/cake.png"))); // NOI18N
jButton8.setText("Tipos");
jButton8.setToolTipText("Tipos");
jButton8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 102, 255)));
jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton8MouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
jButton8MouseExited(evt);
}
});
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
getContentPane().add(jButton8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 260, 240, 120));
jButton9.setBackground(new java.awt.Color(255, 228, 196));
jButton9.setFont(new java.awt.Font("Monotype Corsiva", 0, 24)); // NOI18N
jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/chocolate.png"))); // NOI18N
jButton9.setText("Massa");
jButton9.setToolTipText("Massa");
jButton9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 102, 255)));
jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton9MouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
jButton9MouseExited(evt);
}
});
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
getContentPane().add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 260, 240, 120));
jLabel8.setFont(new java.awt.Font("Monotype Corsiva", 0, 100)); // NOI18N
jLabel8.setForeground(new java.awt.Color(102, 51, 0));
jLabel8.setText("Ingredientes");
getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 30, 450, -1));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Bg/Fundo bisque.png"))); // NOI18N
jLabel1.setText("Endereço");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 810, 430));
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton7MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseEntered
jButton7.setBorder(new LineBorder(new Color(102, 51, 0), 3, false));
}//GEN-LAST:event_jButton7MouseEntered
private void jButton7MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseExited
jButton7.setBorder(new LineBorder(new Color(51, 102, 255), 1, false));
}//GEN-LAST:event_jButton7MouseExited
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton7ActionPerformed
private void jButton8MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseEntered
jButton8.setBorder(new LineBorder(new Color(102, 51, 0), 3, false));
}//GEN-LAST:event_jButton8MouseEntered
private void jButton8MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseExited
jButton8.setBorder(new LineBorder(new Color(51, 102, 255), 1, false));
}//GEN-LAST:event_jButton8MouseExited
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton9MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseEntered
jButton9.setBorder(new LineBorder(new Color(102, 51, 0), 3, false));
}//GEN-LAST:event_jButton9MouseEntered
private void jButton9MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseExited
jButton9.setBorder(new LineBorder(new Color(51, 102, 255), 1, false));
}//GEN-LAST:event_jButton9MouseExited
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton9ActionPerformed
/**
* @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(form_ingr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(form_ingr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(form_ingr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(form_ingr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new form_ingr().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel8;
// End of variables declaration//GEN-END:variables
}
| [
"victor.bilis@github.com"
] | victor.bilis@github.com |
9d597ecb34e468dd2789bf6bcfdcb6cf3e62af38 | 7f33114bf04efed7f0d99e423f9d6d8145414a90 | /ieas/src/util_core/DateTime.java | 4fcf789bd32a489b26269027373fa96b57a2c377 | [] | no_license | tjdudwlsdl/sw_engi_uias | ff51436b804a46a256d6f0a10d40507b18ae16a9 | fc42b13123abb5c18f7c0180373b4ad76388bb26 | refs/heads/master | 2020-06-14T15:21:36.822445 | 2016-12-07T20:25:46 | 2016-12-07T20:25:46 | 75,166,094 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 667 | java | package util_core;
import java.sql.Date;
import java.sql.Time;
import java.util.Calendar;
import java.util.TimeZone;
public class DateTime {
private Date date;
private Time time;
private long datetime;
public static long getLocalDateTime(String timeZoneID) {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID));
return calendar.getTimeInMillis();
}
public DateTime(String timeZoneID) {
this.datetime = getLocalDateTime(timeZoneID);
this.date = new Date(datetime);
this.time = new Time(datetime);
}
public Date getDate() {
return date;
}
public Time getTime() {
return time;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
5a7b6ff38524971f57ac3e06e238e1e089ae4c19 | 39b9a9d749c890137cb3d4783acb54516fa2c248 | /src/org/usfirst/frc3824/PromoBot2018/commands/ShiftGear.java | b62fcebdda58d61be3eaaefa56633c410f90d95d | [] | no_license | HVA-FRC-3824/PromoBot2018 | 7dfc7ba3b28075393b8e0e8543e39997df9e28d9 | 47acbcec7d74989eab883057141ac71a0a91d3cb | refs/heads/master | 2020-03-23T02:39:17.891190 | 2018-08-19T00:03:29 | 2018-08-19T00:03:29 | 140,984,638 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,035 | java | // RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
package org.usfirst.frc3824.PromoBot2018.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc3824.PromoBot2018.Robot;
/**
*
*/
public class ShiftGear extends Command
{
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_DECLARATIONS
private boolean m_gear;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_DECLARATIONS
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
public ShiftGear(boolean gear)
{
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING
m_gear = gear;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
}
// Called just before this Command runs the first time
@Override
protected void initialize()
{
Robot.chassis.shiftGears(m_gear);
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute()
{
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished()
{
return true;
}
// Called once after isFinished returns true
@Override
protected void end()
{
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted()
{
end();
}
}
| [
"brysongullett@gmail.com"
] | brysongullett@gmail.com |
441380237e38f82b75f1db4b43d0d313566b6e7d | 95d7fd3076cedb519c712e03fdbefd52c2c141e1 | /src/main/java/com/gr/jiang/remoting/CommonSender.java | d6fa6f25c92de43d694093f3e5dd11b783a791b6 | [] | no_license | jiangshouqiang/springBootRabbitmq | b474067d54155fc7e1b5e81f4cd3e0453d412566 | 4ef12db24cb38ddbe053ea185f4fa977c3709993 | refs/heads/master | 2021-04-29T05:40:35.556812 | 2017-01-05T03:44:31 | 2017-01-05T03:44:31 | 78,006,151 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 626 | java | package com.gr.jiang.remoting;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gr.jiang.message.CommonMessage;
/**
* Created by jiang on 2017/1/4.
*/
@Component
public class CommonSender {
@Autowired
private RabbitTemplate rabbitTemplate;
public void notify(String queueName, String className, String methodName, Object... args){
CommonMessage message = new CommonMessage(className,methodName,args);
rabbitTemplate.convertAndSend(queueName,message);
}
}
| [
"284923424@qq.com"
] | 284923424@qq.com |
7f09fa89adc751f35cbc2f1bc421822be48978c8 | b83c55c905097bdb420b015dfdef92354d2df700 | /app/src/main/java/com/example/taskmanager/controller/fragment/LoginFragment.java | 5e765d503b4552eb590acc604bc39472b42f0831 | [] | no_license | MostafaDabbagh/TaskManager | c0cedb52f473b4fd2786658aec896fdc5906951f | 165e6032f01721326d1055f3744a470055a1ce4a | refs/heads/master | 2022-12-13T15:56:54.751677 | 2020-09-08T17:53:24 | 2020-09-08T17:53:24 | 283,345,112 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,222 | java | package com.example.taskmanager.controller.fragment;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.taskmanager.R;
import com.example.taskmanager.Repository.UserRepository;
import com.example.taskmanager.controller.activity.TaskPagerActivity;
import com.example.taskmanager.model.User;
public class LoginFragment extends Fragment {
public static final int REQUEST_CODE_SIGN_UP_DIALOG = 0;
private UserRepository mUserRepository;
private EditText mEditTextUsername;
private EditText mEditTextPassword;
private Button mButtonLogin;
private Button mButtonSignUp;
public static LoginFragment newInstance() {
LoginFragment fragment = new LoginFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUserRepository = UserRepository.getInstance(getActivity());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_login, container, false);
findViews(view);
setListeners();
return view;
}
private void findViews(View view) {
mEditTextUsername = view.findViewById(R.id.edit_text_username);
mEditTextPassword = view.findViewById(R.id.edit_text_password);
mButtonLogin = view.findViewById(R.id.button_login);
mButtonSignUp = view.findViewById(R.id.button_signup);
}
private void setListeners() {
mButtonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mUserRepository.userExists(mEditTextUsername.getText().toString())) {
User user = mUserRepository.get(mEditTextUsername.getText().toString());
String password = user.getPassword();
String enteredPassword = mEditTextPassword.getText().toString();
if (password.equals(enteredPassword)) {
// Start TaskPagerActivity
User currentUser = mUserRepository.get(mEditTextUsername.getText().toString());
UserRepository.getInstance(getActivity()).setCurrentUser(currentUser);
Intent intent = TaskPagerActivity.newIntent(getActivity());
startActivity(intent);
} else
Toast.makeText(getActivity(), "Password is incorrect!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), "User is not found. Please sign up first.", Toast.LENGTH_SHORT).show();
}
}
});
mButtonSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startSignUpDialog();
}
});
}
private void startSignUpDialog() {
SignUpDialogFragment signUpDialogFragment = SignUpDialogFragment.newInstance();
signUpDialogFragment.setTargetFragment(LoginFragment.this, REQUEST_CODE_SIGN_UP_DIALOG);
signUpDialogFragment.show(getFragmentManager(), "signUpDialog");
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
User user = (User) data.getSerializableExtra(SignUpDialogFragment.EXTRA_CREATED_USER);
UserRepository.getInstance(getActivity()).add(user);
mEditTextUsername.setText(user.getUsername(), TextView.BufferType.EDITABLE);
mEditTextPassword.setText(user.getPassword(), TextView.BufferType.EDITABLE);
}
} | [
"mostafadabbagh@gmail.com"
] | mostafadabbagh@gmail.com |
32a838386df33bd147b6efd0cf99131572b9e555 | 5fe68e59503b4fc033843b0a96bb2bb505fb3417 | /src/main/java/nl/sogeti/petshop/service/OrderService.java | 32c129fe920daa995053d3a2f9fd125a1afabb35 | [] | no_license | willemhustinx/petsupplies | 9d10562835dcf58cfca1fb81ccc1076bb967a7d5 | c8c87022936ced6fcc13773d6bb2da6e4650994e | refs/heads/master | 2021-01-17T18:42:17.507952 | 2016-06-21T13:44:14 | 2016-06-21T13:44:14 | 61,627,376 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 793 | java | package nl.sogeti.petshop.service;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import nl.sogeti.petshop.model.OrderProduct;
import nl.sogeti.petshop.model.PetShopOrder;
@Stateless
public class OrderService extends AbstractCrudRepository<PetShopOrder> {
@Override
protected Class<PetShopOrder> getEntityClass() {
return PetShopOrder.class;
}
public List<List<OrderProduct>> findOrders(String email) {
List<PetShopOrder> pso = entityManager.createQuery("Select e From PetShopOrder e Where EMAIL = '" + email + "'")
.getResultList();
List<List<OrderProduct>> op = new ArrayList<>();
for (PetShopOrder p : pso) {
op.add(p.getOrderProducts());
}
return op;
}
} | [
"willemhustinx@gmail.com"
] | willemhustinx@gmail.com |
7671e0b350c3a48ae9fc61ab73ac63baceabc43e | 192cf9fd9dca6c1eec4532804efd8a01025143da | /app/src/main/java/com/example/chat_application/SettingActivity.java | 7e4969e2980afa01af36db319644ce3f5043d24d | [] | no_license | adil-m00/Chat-Application | 648a9320c328b23e6d94f19160b82846e8b8c816 | 5f0d789a2c080794325b148b7b11a916fa37c677 | refs/heads/master | 2022-12-25T10:25:04.633606 | 2020-09-22T06:33:43 | 2020-09-22T06:33:43 | 297,544,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,272 | java | package com.example.chat_application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import com.squareup.picasso.Picasso;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import java.util.HashMap;
import de.hdodenhof.circleimageview.CircleImageView;
public class SettingActivity extends AppCompatActivity {
private Button updateAccountSettings;
private EditText userName,userStatus;
private CircleImageView userPofileImage;
private FirebaseAuth firebaseAuth;
private DatabaseReference RootRef;
String currentUserID;
private Toolbar toolbar;
private ProgressDialog progressDialog,loadingBar;
private static final int gallerypict=1;
private StorageReference userProfileImagesReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
toolbar = findViewById(R.id.setting_app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Settings");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Please Wait");
progressDialog.show();
loadingBar = new ProgressDialog(this);
updateAccountSettings = findViewById(R.id.updateSetitngButton);
userName = findViewById(R.id.set_user_name);
userStatus = findViewById(R.id.set_user_status);
userPofileImage = findViewById(R.id.profile_image);
firebaseAuth= FirebaseAuth.getInstance();
currentUserID = firebaseAuth.getCurrentUser().getUid().toString();
userProfileImagesReference = FirebaseStorage.getInstance().getReference("Profile Images");
RootRef = FirebaseDatabase.getInstance().getReference();
updateAccountSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateSetting();
}
});
retrieveUserInformation();
userPofileImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,gallerypict);
}
});
}
private void retrieveUserInformation() {
RootRef.child("Users").child(currentUserID)
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists() && dataSnapshot.hasChild("name") && dataSnapshot.hasChild("image"))
{
progressDialog.dismiss();
String Name = dataSnapshot.child("name").getValue().toString();
String Status = dataSnapshot.child("status").getValue().toString();
userName.setVisibility(View.INVISIBLE);
userName.setText(Name);
userStatus.setText(Status);
String image = dataSnapshot.child("image").getValue().toString();
Picasso.get().load(image).into(userPofileImage);
}
else if(dataSnapshot.exists() && dataSnapshot.hasChild("name"))
{
userName.setVisibility(View.INVISIBLE);
progressDialog.dismiss();
String Name = dataSnapshot.child("name").getValue().toString();
String Status = dataSnapshot.child("status").getValue().toString();
userName.setText(Name);
userStatus.setText(Status);
}
else
{
progressDialog.dismiss();
Toast.makeText(SettingActivity.this, "Please set & update profile", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
progressDialog.dismiss();
}
});
}
private void updateSetting() {
String UserName = userName.getText().toString();
String Status = userStatus.getText().toString();
if(UserName.isEmpty())
{
userName.setError("Please Enter Name");
return;
}
if(Status.isEmpty())
{
userStatus.setError("Please enter status");
return;
}
else {
HashMap<String,Object> parameter = new HashMap<>();
parameter.put("uid",currentUserID);
parameter.put("name",UserName);
parameter.put("status",Status);
RootRef.child("Users").child(currentUserID).updateChildren(parameter).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
{
Toast.makeText(SettingActivity.this, "Profile updated", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(SettingActivity.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
String message = task.getException().toString();
Toast.makeText(SettingActivity.this, message, Toast.LENGTH_SHORT).show();
}
}
});
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==gallerypict && resultCode==RESULT_OK && data!=null)
{
Uri imageUri = data.getData();
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setAspectRatio(1,1)
.start(this);
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if(resultCode== RESULT_OK)
{
loadingBar.setTitle("Profile Image");
loadingBar.setMessage("Updating");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
final Uri resutlUri = result.getUri();
StorageReference filePath = userProfileImagesReference.child(currentUserID + ".jpg");
filePath.putFile(resutlUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Task task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
task.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Object o) {
String uril = o.toString();
RootRef.child("Users").child(currentUserID).child("image").setValue(uril).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
{
loadingBar.dismiss();
Toast.makeText(SettingActivity.this, "image has been uploaded", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.dismiss();
Toast.makeText(SettingActivity.this, "Error in image uploading", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
});
}
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
8ef7e673fcf214e8c61e8bf818447662dd8c9a3f | 4ef431684e518b07288e8b8bdebbcfbe35f364e4 | /fld/tas-tests/flows/src/main/java/com/ca/apm/systemtest/fld/util/selenium/SeleniumHelperBase.java | 65dc88b22fd9b0930d3b9f9ec498cd4bc351ee38 | [] | no_license | Sarojkswain/APMAutomation | a37c59aade283b079284cb0a8d3cbbf79f3480e3 | 15659ce9a0030c2e9e5b992040e05311fff713be | refs/heads/master | 2020-03-30T00:43:23.925740 | 2018-09-27T23:42:04 | 2018-09-27T23:42:04 | 150,540,177 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,500 | java | package com.ca.apm.systemtest.fld.util.selenium;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ca.apm.systemtest.fld.common.ErrorUtils;
/*
* code based on
* selenium-plugin/src/main/java/com/ca/apm/systemtest/fld/plugin/selenium/SeleniumPluginAbs.java
*/
public abstract class SeleniumHelperBase implements SeleniumHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(SeleniumHelperBase.class);
private static final int IMPLICIT_WAIT_SECONDS = 5;
private static final AtomicLong nextId = new AtomicLong(1000);
private Map<String, WebDriver> driverMap = new HashMap<>();
protected SeleniumHelperBase() {}
public abstract void initialize();
@Override
public String openUrl(String sessionId, String url) {
LOGGER.info("Session {}, opening URL {}", sessionId, url);
WebDriver driver = getWebDriver(sessionId);
driver.get(url);
return driver.getWindowHandle();
}
@Override
public boolean waitForElement(String sessionId, String windowId, SelectionBy selectionBy,
String id, int timeOutInSeconds) {
WebDriver driver = getWebDriver(sessionId);
By by = makeBy(selectionBy, id);
try {
WebElement dynamicElement =
new WebDriverWait(driver, timeOutInSeconds).until(ExpectedConditions
.presenceOfElementLocated(by));
LOGGER.trace("dynamicElement = {}", dynamicElement);
} catch (org.openqa.selenium.TimeoutException e) {
LOGGER.warn("element {} has not appeared within {} seconds", by, timeOutInSeconds);
return false;
}
LOGGER.info("element {} has appeared within less than {} seconds", by, timeOutInSeconds);
return true;
}
@Override
public boolean fillTextField(String sessionId, String windowId, SelectionBy selectionBy,
String id, String newText) {
WebDriver driver = getWebDriver(sessionId);
if (windowId != null) {
driver.switchTo().window(windowId);
}
By by = makeBy(selectionBy, id);
WebElement element = driver.findElement(by);
if (element == null) {
LOGGER.error("Failed to find element {} in window {} session {}", by, windowId,
sessionId);
return false;
}
element.clear();
element.sendKeys(newText);
return true;
}
@Override
public boolean click(String sessionId, String windowId, SelectionBy selectionBy, String id) {
WebDriver driver = getWebDriver(sessionId);
if (windowId != null) {
driver.switchTo().window(windowId);
}
By by = makeBy(selectionBy, id);
WebElement element = driver.findElement(by);
if (element == null) {
LOGGER.error("Failed to find element {} in window {} session {}", by, windowId,
sessionId);
return false;
}
LOGGER.info("clicking at {} in window {} session {}", by, windowId, sessionId);
element.click();
return true;
}
public void closeSession(String sessionid) {
WebDriver driver = driverMap.remove(sessionid);
if (driver != null) {
Set<String> windows = driver.getWindowHandles();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Open windows in session {}: {}", sessionid, windows);
}
for (String windowId : windows) {
try {
driver.switchTo().window(windowId);
driver.close();
} catch (Exception e) {
ErrorUtils.logExceptionFmt(LOGGER, e,
"Failed to close web driver for {1}, session {2}, window {3}."
+ " Exception: {0}", driver.getCurrentUrl(), sessionid, windowId);
}
}
try {
driver.quit();
} catch (Throwable e) {
ErrorUtils.logExceptionFmt(LOGGER, e,
"Failed to quit web driver for {1}, session {2}. Exception: {0}",
driver.getCurrentUrl(), sessionid);
}
}
}
protected String startSession(WebDriver driver, String prefix) {
driver.manage().timeouts().implicitlyWait(IMPLICIT_WAIT_SECONDS, TimeUnit.SECONDS);
String id = prefix + getNextId();
driverMap.put(id, driver);
return id;
}
protected final long getNextId() {
return nextId.getAndIncrement();
}
private WebDriver getWebDriver(String sessionId) {
WebDriver driver = driverMap.get(sessionId);
if (driver == null) {
String msg =
MessageFormat.format("Driver for session id {0} does not exist", sessionId);
LOGGER.error(msg);
throw new RuntimeException(msg);
}
return driver;
}
protected static boolean isWindowsOS() {
return System.getProperty("os.name").toLowerCase().indexOf("win") != -1;
}
/**
* Convert SelectionBy and value to Selenium's By object.
*
* @param selectionBy selection criterion
* @param id criterion value
* @return new By instance
*/
protected static By makeBy(SelectionBy selectionBy, String id) {
switch (selectionBy) {
case ID:
return By.id(id);
case XPATH:
return By.xpath(id);
case NAME:
return By.name(id);
case TAG_NAME:
return By.tagName(id);
case LINK:
return By.linkText(id);
case PARTIAL_LINK:
return By.partialLinkText(id);
case CLASS:
return By.className(id);
default:
String msg =
MessageFormat.format("Selection type not recognized: {0}", selectionBy);
LOGGER.error(msg);
throw new RuntimeException(msg);
}
}
}
| [
"sarojkswain@gmail.com"
] | sarojkswain@gmail.com |
b2f90f2f98b8df06384066c5ee832fae9b8ed99d | c239bb73c2e771541d509346b0a422a8089257ce | /src/main/java/at/stefan_huber/tunneltool/ui/tools/FileNameReplacer.java | d2f859408a2f4575510c93288c8aa5df2d533dc1 | [
"Apache-2.0"
] | permissive | Laess3r/tunneltool | 0d5820b63fceac755d92ceee50cc3d5f5e84ef4f | 1d71b94dd917e1c3c1d110e9dfd9f36c8c0700a1 | refs/heads/master | 2021-06-11T11:57:24.859340 | 2017-01-04T14:17:09 | 2017-01-04T14:17:09 | 77,897,926 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 696 | java | package at.stefan_huber.tunneltool.ui.tools;
/**
* @author Stefan Huber
*/
public class FileNameReplacer {
public static final String PLACEHOLDER = "%FILENAME%";
public static final String PUTTY_PLACEHOLDER = "%PUTTYFILE%";
public static String placeFileName(String scriptToReplace, String fileName) {
if(scriptToReplace == null){
return null;
}
return scriptToReplace.replace(PLACEHOLDER, fileName);
}
public static String placePuttyFile(String scriptToReplace, String fileName) {
if(scriptToReplace == null){
return null;
}
return scriptToReplace.replace(PUTTY_PLACEHOLDER, fileName);
}
}
| [
"extern.stefan.huber@porscheinformatik.at"
] | extern.stefan.huber@porscheinformatik.at |
95abbdbbc541502bfc9de16d6acf83984a7b83e2 | bce504e580563605233c49d98ddc8ba03918b5cd | /src/com/cosylab/vdct/vdb/MacroDescriptionProperty.java | be53018d0218fa253f5da2555f8eb92519b5ba5b | [] | no_license | epicsdeb/visualdct | c871c5f3be7ffce843449019fe53414b3510dc25 | 0df74c73a81852665420ac4141ad391d85867ea5 | refs/heads/master | 2021-06-04T16:19:09.468840 | 2016-01-26T22:43:08 | 2016-01-26T22:43:08 | 10,111,384 | 1 | 2 | null | 2019-08-27T09:23:04 | 2013-05-16T21:56:27 | Java | UTF-8 | Java | false | false | 5,200 | java | package com.cosylab.vdct.vdb;
/**
* Copyright (c) 2002, Cosylab, Ltd., Control System Laboratory, www.cosylab.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the Cosylab, Ltd., Control System Laboratory nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import java.util.regex.Pattern;
import com.cosylab.vdct.inspector.InspectableProperty;
/**
* Insert the type's description here.
* @author Matej Sekoranja
*/
public class MacroDescriptionProperty implements InspectableProperty {
private static final String defaultDescription = "";
private static final String name = "Description";
private static final String helpString = "Port description";
private VDBMacro macro = null;
/**
* Constructor
*/
public MacroDescriptionProperty(VDBMacro macro)
{
this.macro=macro;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#allowsOtherValues()
*/
public boolean allowsOtherValues()
{
return false;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getEditPattern()
*/
public Pattern getEditPattern()
{
return null;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getHelp()
*/
public String getHelp()
{
return helpString;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getInitValue()
*/
public String getInitValue()
{
return null;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getName()
*/
public String getName()
{
return name;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getSelectableValues()
*/
public String[] getSelectableValues()
{
return null;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getToolTipText()
*/
public String getToolTipText()
{
return null;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getValue()
*/
public String getValue()
{
String val = macro.getDescription();
if (val==null)
return defaultDescription;
else
return val;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#getVisibility()
*/
public int getVisibility()
{
return InspectableProperty.UNDEFINED_VISIBILITY;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#isEditable()
*/
public boolean isEditable()
{
return true;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#isSeparator()
*/
public boolean isSeparator()
{
return false;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#isValid()
*/
public boolean isValid()
{
return true;
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#popupEvent(Component, int, int)
*/
public void popupEvent(java.awt.Component component, int x, int y)
{
macro.popupEvent(component, x, y);
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#setValue(String)
*/
public void setValue(String value)
{
macro.setDescription(value);
}
/**
* @see com.cosylab.vdct.inspector.InspectableProperty#toString(String)
*/
public String toString()
{
return name;
}
/* (non-Javadoc)
* @see com.cosylab.vdct.inspector.InspectableProperty#hasDefaultValue()
*/
public boolean hasDefaultValue() {
return false;
}
/* (non-Javadoc)
* @see com.cosylab.vdct.inspector.InspectableProperty#hasValidity()
*/
public boolean hasValidity() {
return false;
}
/* (non-Javadoc)
* @see com.cosylab.vdct.inspector.InspectableProperty#checkValueValidity(java.lang.String)
*/
public String checkValueValidity(String value) {
return null;
}
/* (non-Javadoc)
* @see com.cosylab.vdct.inspector.InspectableProperty#getGuiGroup()
*/
public Integer getGuiGroup() {
return null;
}
}
| [
"mdavidsaver@bnl.gov"
] | mdavidsaver@bnl.gov |
8bf9cb6ffecb1682d646f4ee36199629bcd82250 | 7957a2e04d3239ebf43ddb1940946c147129d676 | /TheTownProject/src/Code/Healer.java | 020c99fe4b4b04cbfc775b5deff2d6d4a08ab7a8 | [
"Apache-2.0"
] | permissive | FreezeHeat/TheTownJava | ea9c2ad74335ce456ece19321753b9752538c173 | a6efe1647908fd45aa3d85ca9babaf7a4edd5a24 | refs/heads/master | 2021-01-23T06:16:07.669986 | 2020-03-09T13:05:25 | 2020-03-09T13:05:25 | 86,350,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,147 | java | package Code;
import static Code.ClientConnection.client;
import Interface.IHealer;
import java.io.IOException;
import java.io.Serializable;
/**
* {@code Healer} class a role within the game
* <p>The healer heals other users and keeps them from dying</p>
* @author Ben Gilad and Asaf Yeshayahu
* @version %I%
* @since 1.0
*/
public class Healer extends User implements IHealer, Serializable{
/**
* Constructor for Healer, convert a User to Healer
* @param a The user to be converted
*/
public Healer(User a){
this.setUsername(a.getUsername());
this.setPassword(a.getPassword());
this.setHeales(a.getHeales());
this.setKills(a.getKills());
this.setLost(a.getLost());
this.setWon(a.getWon());
}
/**
* Heal the target specified (Healer option)
* @param user The user to be healed
*/
public void heal(User user){
try {
client.out.writeObject(Commands.HEAL);
client.out.writeObject(user);
client.out.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
| [
"asafyeshayahu@gmail.com"
] | asafyeshayahu@gmail.com |
d03b8a195be687daa0a5a02add4ea802b3b0f97a | ba4a89ae81de0c4ad3b705d84b7c3204fdaff78d | /app/src/main/java/com/myvision/khoyapaya/control/GameLevels/level1.java | 2155380b7ee10d14d8e52357667e48299152ae72 | [] | no_license | successfulmanrb/KhoyaPaya | 57683475ba2a170cb34af9ff32f1d2d38935820e | 00b7039987bfa7fc75e72947750420effe0c950c | refs/heads/master | 2020-03-17T01:52:10.666949 | 2018-05-12T17:43:16 | 2018-05-12T17:43:16 | 133,169,335 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,202 | java | package com.myvision.khoyapaya.control.GameLevels;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.myvision.khoyapaya.R;
import com.myvision.khoyapaya.control.Control;
/**
* Created by Rahul BANSAL on 2/17/2017.
*/
public class level1 extends Fragment {
AudioManager audio;
Dialog d;
Handler handler;
int currentVolume,maxVolume ;
// static int count=1;
Context context;
Runnable r1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.level1, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
handler = new Handler();
audio = (AudioManager)getActivity().getSystemService(Context.AUDIO_SERVICE);
maxVolume=audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
Toast.makeText(getActivity(), String.valueOf(currentVolume), Toast.LENGTH_SHORT).show();
if (currentVolume ==maxVolume)
{audio.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume-5, 0);
doTheAutoRefresh();
}else{doTheAutoRefresh();}
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)){
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
if(audio.getStreamVolume(AudioManager.STREAM_MUSIC)==maxVolume)
{
if (Control.leveltime.getBoolean("is_first_time_level1", true)) {
Control.levellock.edit().putInt("lock" , 2).apply();
//the app is being launched for first time, do something
Log.d("TAG", "First time");
int cointemp;
cointemp= Control.coin.getInt("coin",0)+10;
Control.coin.edit().putInt("coin",cointemp).apply();
Control.coinv.setText(String.valueOf(Control.coin.getInt("coin",0)));
((Control)getActivity()).oncrose(2);
// first time task
// record the fact that the app has been started at least once
Control.leveltime.edit().putBoolean("is_first_time_level1", false).apply();
}
else
{((Control)getActivity()).oncrose(2);
Toast.makeText(getActivity(),"Coin provided 1st time only",Toast.LENGTH_SHORT).show();
//second time launch..
}
}
}
return true;
}
private void doTheAutoRefresh() {
r1=new Runnable() {
@Override
public void run() {
try {
audio = (AudioManager)getActivity().getSystemService(Context.AUDIO_SERVICE);
} catch (Exception e) {
e.printStackTrace();
}
int currentVolume1 = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
//Toast.makeText(Main2Activity.this,String.valueOf(screen_brightness), Toast.LENGTH_SHORT).show();
if(currentVolume1==maxVolume)
{
if (Control.leveltime.getBoolean("is_first_time_level1", true)) {
//the app is being launched for first time, do something
Log.d("TAG", "First time");
Control.levellock.edit().putInt("lock" , 2).apply();
int cointemp;
cointemp= Control.coin.getInt("coin",0)+10;
Control.coin.edit().putInt("coin",cointemp).apply();
Control.coinv.setText(String.valueOf(Control.coin.getInt("coin",0)));
((Control)getActivity()).oncrose(2);
// first time task
// record the fact that the app has been started at least once
Control.leveltime.edit().putBoolean("is_first_time_level1", false).apply();
}
else
{ ((Control)getActivity()).oncrose(2);
Toast.makeText(getActivity(),"Coin provided 1st time only",Toast.LENGTH_SHORT).show();
//second time launch..
}
}
// Write code for your refresh logic
else{doTheAutoRefresh();}
}
};
handler.postDelayed(r1,500);
}
@Override
public void onStop() {
handler.removeCallbacks(r1);
Log.d("2", "onDestroy: ");
super.onStop();
}
}
| [
"successfulmanrb@gmail.com"
] | successfulmanrb@gmail.com |
97080fe6f3c884096cb3652f03dacc5eeb9056ff | 7e0f4e7c5d18dab4516b6d9c5513ce12abac8ef0 | /src/main/java/com/openclassrooms/shop/repository/ProductRepository.java | 8aca50247915fb02214e9be1ae360754991bf0dd | [] | no_license | Musapa/OC_Project2 | e87288f60deae12ac2bc92dec7d1531cec2c9e3b | a169d21797860b7eb88a7e94649a402c07061c22 | refs/heads/master | 2022-01-29T19:37:44.485102 | 2019-05-15T19:00:22 | 2019-05-15T19:00:22 | 188,063,172 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,065 | java | package com.openclassrooms.shop.repository;
import com.openclassrooms.shop.domain.Product;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author stanlick
*
*/
@Repository
public class ProductRepository {
private static List<Product> products;
public ProductRepository()
{
products = new ArrayList<>();
generateProductData();
}
/**
* Generate the default list of products
*/
private void generateProductData()
{
long id = 0;
products.add(new Product(++id, 10, 92.50, "Echo Dot", "(2nd Generation) - Black"));
products.add(new Product(++id, 20, 9.99, "Anker 3ft / 0.9m Nylon Braided", "Tangle-Free Micro USB Cable"));
products.add(new Product(++id, 30, 69.99, "JVC HAFX8R Headphone", "Riptidz, In-Ear"));
products.add(new Product(++id, 40, 32.50, "VTech CS6114 DECT 6.0", "Cordless Phone"));
products.add(new Product(++id, 50, 895.00, "NOKIA OEM BL-5J", "Cell Phone "));
}
/**
* @return All products from the inventory
*/
public List<Product> findAll() {
return products.stream().filter(p -> p.getStock() > 0).sorted(Comparator.comparing(Product::getName)).collect(Collectors.toList());
}
/**
* @param productId ID of the getProductById
* @param quantityToRemove Quantity of the getProductById
*/
public Product getProductById(Long productId) {
for (Product p : products) {
if (p.getId() == productId) {
return p;
}
}
return null;
}
public void updateProductStocks(int productId, int quantityToRemove) {
Product product = products.stream().filter(p -> p.getId() == productId).findFirst().get();
product.setStock(product.getStock() - quantityToRemove);
if (product.getStock() == 0){
products.remove(product);
}
}
}
| [
"Toncy@192.168.1.3"
] | Toncy@192.168.1.3 |
4e4aad5a44ade9fec5c94fa1cd5c84ea73b475cc | 2ffdf18e5862d4d68d17c2ae1bdcc87cda50c47f | /app/src/androidTest/java/com/gjn/bluetoothutils/ExampleInstrumentedTest.java | db9d921cdae648a67ec98a643280877a209d65a3 | [] | no_license | Gaojianan2016/BluetoothUtils | b25a2b704dc7445f321c665bd1e009b1eeed50c4 | e5bba9ed10378e555f6337dac6ec26de3533058f | refs/heads/master | 2020-04-29T01:29:20.765671 | 2019-07-19T02:19:41 | 2019-07-19T02:19:41 | 175,732,013 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 745 | java | package com.gjn.bluetoothutils;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.gjn.bluetoothutils", appContext.getPackageName());
}
}
| [
"732879625@qq.com"
] | 732879625@qq.com |
ef56b08c45179d6d087c68c08abcd570552c1ec2 | 45ed6deadd05772d72f700e5c66978ecfa1c2ac3 | /app/src/androidTest/java/com/appsbymonil/calculator/ExampleInstrumentedTest.java | 945c75501da9fc6e1954ac78dab584afe08bd274 | [] | no_license | monil-pixels/Calculator | d0933fa0817a128109dda1ba4b6b70ba258e294a | d62367104eaaee0703c2ba947b7e7dfbf98a131b | refs/heads/master | 2020-03-22T09:22:52.728898 | 2018-07-05T10:22:21 | 2018-07-05T10:22:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 756 | java | package com.appsbymonil.calculator;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.appsbymonil.calculator", appContext.getPackageName());
}
}
| [
"monilsaraswat@gmail.com"
] | monilsaraswat@gmail.com |
1d1b31de1574be4cc8c81ca07de5334dc0067ee1 | a2a3636287f5037a4d0a2ffccd6ed74e6105b901 | /Testing Pheonix sl/src/org/usfirst/frc/team7178/robot/commands/ExampleCommand.java | df2cf1389f2c071c45bfa4563a460c31e8b67640 | [] | no_license | Monsters-308/FRC2018_7178 | 9e055b579535e65dbccf6fb8031da114c12a97eb | ebb061a89335251edb1da71ca2d6d9dcd222cc4e | refs/heads/master | 2021-05-09T20:25:36.996827 | 2018-01-27T14:59:13 | 2018-01-27T14:59:13 | 118,689,292 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,470 | java | /*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package org.usfirst.frc.team7178.robot.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc.team7178.robot.Robot7178;
/**
* An example command. You can replace me with your own command.
*/
public class ExampleCommand extends Command {
public ExampleCommand() {
// Use requires() here to declare subsystem dependencies
requires(Robot7178.kExampleSubsystem);
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
@Override
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
}
| [
"rileythomp25@gmail.com"
] | rileythomp25@gmail.com |
250a9fe33523d66b6b6e070e33d1d2c13c61c997 | c43f1d92ae1046754e55e5479ea03b84d81ffb42 | /trainingfulfilmentprocess/testsrc/org/training/fulfilmentprocess/test/beans/QueueService.java | 5461eac676b4817e5cff9950d21c25274367b718 | [] | no_license | Ojasmodi/training-hybris | 9296b5d2e8e710bd027eff9cebef94a1423a529f | dcd292935bf08b3d4c6e4b50ee17085026f6f472 | refs/heads/master | 2020-12-20T04:29:44.707635 | 2020-02-24T18:17:06 | 2020-02-24T18:17:06 | 235,962,253 | 0 | 1 | null | 2020-04-30T14:15:25 | 2020-01-24T08:05:05 | Java | UTF-8 | Java | false | false | 722 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
*
* This software is the confidential and proprietary information of SAP
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with SAP.
*/
package org.training.fulfilmentprocess.test.beans;
public interface QueueService
{
// void init();
//
// ActionExecution pollQueue(final BusinessProcessModel process) throws InterruptedException;
//
// void actionExecuted(final BusinessProcessModel process, final AbstractAction action) throws Exception;
//
// void destroy();
}
| [
"ojas.modi@nagarro.com"
] | ojas.modi@nagarro.com |
2f59ba784ec0e3227e63aaace9c4f147125f2fcf | 364275591badce2f43a927a8bb2e92d822687e95 | /src/de/jvw/fourwins/FourWinsTest.java | 0987cd82c565ab4bcb97b39b4e1e25ba5be18ed6 | [] | no_license | ajaguar/AGI_FourWins | 73aa959ab0acae0f143f116a34d94801141f1c67 | 1e776d1b38f3f496eb1b23820d6e70dc32fa7ef7 | refs/heads/master | 2021-01-17T16:45:12.985570 | 2015-11-03T10:05:09 | 2015-11-03T10:05:09 | 45,254,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,058 | java | package de.jvw.fourwins;
import org.junit.Test;
import junit.framework.TestCase;
public class FourWinsTest extends TestCase {
@Test
public void testThrowChipLeft() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 0));
assertEquals(Result.WON, fourWins.throwChip(Chip.BLUE, 0));
}
@Test
public void testThrowChipRight() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.WON, fourWins.throwChip(Chip.BLUE, 6));
}
@Test
public void testThrowChipColumnFull() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
}
@Test
public void testThrowChipColumnOverflow() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.INVALID, fourWins.throwChip(Chip.BLUE, 6));
}
@Test
public void testThrowChipLeftTop() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 0));
}
@Test
public void testThrowChipRightTop() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 6));
}
@Test
public void testThrowChipHorizontalLeft() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 3));
}
@Test
public void testThrowChipHorizontalRight() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 4));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 5));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 6));
}
@Test
public void testThrowChipHorizontalRightOverflow() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.INVALID, fourWins.throwChip(Chip.RED, 7));
}
@Test
public void testThrowChipHorizontalLeftMinimumOverflow() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.INVALID, fourWins.throwChip(Chip.RED, -1));
}
@Test
public void testThrowChipHorizontalMiddle() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 5));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 4));
}
@Test
public void testThrowChipHorizontalMiddleMoreThanFour() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 4));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 5));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 3));
}
@Test
public void testThrowChipHorizontalLeftTop() {
FourWinsLogic fourWins = new MiniGame();
for (int i = 0; i < 3; i++) {
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
}
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.WON, fourWins.throwChip(Chip.BLUE, 3));
}
@Test
public void testThrowChipHorizontalRightTop() {
FourWinsLogic fourWins = new MiniGame();
for (int i = 6; i > 3; i--) {
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, i));
}
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.WON, fourWins.throwChip(Chip.BLUE, 3));
}
@Test
public void testThrowChipDiagonalBottomLeft() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 3));
}
@Test
public void testThrowChipDiagonalBottomLeftMiddle() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 0));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 1));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 2));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 2));
}
@Test
public void testThrowChipDiagonalBottomRightMiddle() {
FourWinsLogic fourWins = new MiniGame();
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 6));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 5));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 5));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.BLUE, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 3));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 4));
assertEquals(Result.UNDECIDED, fourWins.throwChip(Chip.RED, 4));
assertEquals(Result.WON, fourWins.throwChip(Chip.RED, 4));
}
}
| [
"weber.jonas@gmail.com"
] | weber.jonas@gmail.com |
a4566474b1662d4ca9a1ccb2537485c1f79c1457 | aad2479bc3b7096f1cb6fd117519ee9a879736f1 | /src/Logic/Bullet.java | e4c2e11fce145311982cf5c9b1b1a5de374d511f | [] | no_license | GlebZelensky/ProgrammingLabTask3 | e63fef8606f2d193d2329550a48dffcad7290bd0 | 830c82733c2f704ce3b535b4f081d8df7d23d72b | refs/heads/master | 2020-03-12T16:40:50.542478 | 2018-09-09T19:57:23 | 2018-09-09T19:57:23 | 130,721,422 | 0 | 0 | null | 2018-04-23T15:52:28 | 2018-04-23T15:52:28 | null | UTF-8 | Java | false | false | 449 | java | package Logic;
import javax.swing.*;
import java.awt.*;
public class Bullet {
public Image image = new ImageIcon("resourses/bullet.png").getImage();
public int position;
public boolean isFlyRight;
public Bullet(int position, boolean isFlyRight) {
this.position = position;
this.isFlyRight = isFlyRight;
}
public void step() {
if (isFlyRight) position += 15;
else position -= 15;
}
} | [
"gleblordex@gmail.com"
] | gleblordex@gmail.com |
e3c523cbbd5edcac64dee721167842dcf85be255 | a7d45d0708d6756188534512a07b50556bbf10f2 | /src/main/java/org/lyncc/bazinga/rx/bazinga/delayqueue/FgwGlobalExecutorHolder.java | 0b6f2884180c5ee47e42be62cabf2cb2dcf3b1ae | [] | no_license | yyccygit/RxBazinga | 216fd397744193a2e8cd853caefa96fffdaa3642 | 10ae76a143138ad1d6b8941b269ef1ea91bd76bd | refs/heads/master | 2022-04-06T12:12:41.073685 | 2019-09-09T12:02:12 | 2019-09-09T12:02:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,072 | java | package org.lyncc.bazinga.rx.bazinga.delayqueue;
import org.lyncc.bazinga.rx.bazinga.sofa.bolt.NamedThreadFactory;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* fgw全局线程执行器持有者
*
* @author liguolin
* @create 2018-08-07 10:10
**/
public class FgwGlobalExecutorHolder {
private static Integer maxCpuCount = Runtime.getRuntime().availableProcessors() * 2;
private static ThreadPoolExecutor executor = new ThreadPoolExecutor(1, maxCpuCount, 60, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(16),
new NamedThreadFactory("fgw-process-pool"));
public static ThreadPoolExecutor getFgwGlobalExecutors(){
return executor;
}
public static ThreadPoolExecutor getFgwCustomExecutors(int maxCpu,String threadName){
return new ThreadPoolExecutor(1, maxCpu, 60, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(16),
new NamedThreadFactory(threadName));
}
}
| [
"liguolin@"
] | liguolin@ |
89cf691c25726fa9c5739de3c11811760df49c6b | e5786c2e0d59cf5fa0a66802d88b0ba99f10e262 | /LetterGame/src/main/java/fr/esiea/unique/binome/name/Play/Player.java | bf5aedcdfdf9b1c6dcd82fe4c76f2eaf2d8d74fa | [
"MIT"
] | permissive | acorolus/LetterGame | 5cf91ce890c4c3cd9cdb9b26a51e61e5a7a990d8 | 7c40163fb0544bc36b65335c1f59897f3a51cfc3 | refs/heads/master | 2021-01-22T03:57:46.169036 | 2017-03-02T21:31:35 | 2017-03-02T21:31:35 | 81,478,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,141 | java | package fr.esiea.unique.binome.name.Play;
import java.util.ArrayList;
import java.util.Scanner;
public class Player {
private String id;
private String name;
public ArrayList<Character> currentLetters;
public ArrayList<String> wordsfound;
public boolean bWordFound;
public Player (String id, String name){
currentLetters=new ArrayList<Character>();
wordsfound= new ArrayList<String>();
this.id = id;
this.name = name;
this.bWordFound =false;
}
public String toString(){
return name;
}
public boolean getbWordFound(){
return(this.bWordFound);
}
public void setbWordFound(boolean b){
this.bWordFound = b;
}
public ArrayList<String> getWordsFound(){
return wordsfound;
}
public void addword(String pword){
wordsfound.add(pword);
}
public char pick(LetterGenerated g){
return(g.pickLetter());
}
public String makeword(LetterBag sharedbag, ArrayList<String> lListPlayer) {
String entry="";
System.out.println("Your list : "+getWordsFound());
System.out.println("enter the word : ");
Scanner scan=new Scanner(System.in);
entry=scan.next();
return entry;
}
}
| [
"a.corolus@gmail.com"
] | a.corolus@gmail.com |
ff583bcb661516edee9f9207d027055cdf2b66bb | c696bcfecd8a9c1ab96a6303dbac927818afc01c | /video_recorder/src/main/java/com/plx/video/view/CameraHolder.java | 24581f16102f70276240bd32785cabdc304f44b9 | [] | no_license | panliangxiao/VideoProject | badf61d498c3ab84257673e2d5bd54c47db382c1 | dcac90840af84355db06c48a2cc7d90f04138cc2 | refs/heads/master | 2022-11-30T23:57:15.162844 | 2020-08-14T16:35:43 | 2020-08-14T16:35:43 | 287,569,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,502 | java | package com.plx.video.view;
import java.io.IOException;
import java.util.List;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.hardware.Camera.Size;
import android.view.SurfaceHolder;
import com.plx.video.utils.CamParaUtil;
import com.plx.video.utils.FileUtil;
import com.plx.video.utils.ImageUtil;
import com.plx.video.utils.Logger;
public class CameraHolder {
private static final String TAG = CameraHolder.class.getSimpleName();
private Camera mCamera;
private Camera.Parameters mParams;
private boolean isPreviewing = false;
private float mPreviwRate = -1f;
private static CameraHolder mCameraInterface;
public interface CamOpenOverCallback{
void cameraHasOpened();
}
private CameraHolder(){
}
public static synchronized CameraHolder getInstance(){
if(mCameraInterface == null){
mCameraInterface = new CameraHolder();
}
return mCameraInterface;
}
/**
* 打开Camera
* @param callback
*/
public void doOpenCamera(CamOpenOverCallback callback){
Logger.i(TAG, "Camera open....");
if(mCamera == null){
mCamera = Camera.open();
Logger.i(TAG, "Camera open over....");
if(callback != null){
callback.cameraHasOpened();
}
}else{
Logger.i(TAG, "Camera open �쳣!!!");
doStopCamera();
}
}
/**
* @param holder
* @param previewRate
*/
public void doStartPreview(SurfaceHolder holder, float previewRate){
Logger.i(TAG, "doStartPreview...");
if(isPreviewing){
mCamera.stopPreview();
return;
}
if(mCamera != null){
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException e) {
e.printStackTrace();
}
initCamera(previewRate);
}
}
/**
* 预览摄像头数据
* @param surface
* @param previewRate
*/
public void doStartPreview(SurfaceTexture surface, float previewRate){
Logger.i(TAG, "doStartPreview...");
if(isPreviewing){
mCamera.stopPreview();
return;
}
if(mCamera != null){
try {
mCamera.setPreviewTexture(surface);
} catch (IOException e) {
e.printStackTrace();
}
initCamera(previewRate);
}
}
/**
* 结束预览Camera
*/
public void doStopCamera(){
if(null != mCamera)
{
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
isPreviewing = false;
mPreviwRate = -1f;
mCamera.release();
mCamera = null;
}
}
/**
* 拍照
*/
public void doTakePicture(){
if(isPreviewing && (mCamera != null)){
mCamera.takePicture(mShutterCallback, null, mJpegPictureCallback);
}
}
public boolean isPreviewing(){
return isPreviewing;
}
private void initCamera(float previewRate){
if(mCamera != null){
mParams = mCamera.getParameters();
mParams.setPictureFormat(PixelFormat.JPEG);
// CamParaUtil.getInstance().printSupportPictureSize(mParams);
// CamParaUtil.getInstance().printSupportPreviewSize(mParams);
Size pictureSize = CamParaUtil.getInstance().getPropPictureSize(
mParams.getSupportedPictureSizes(),previewRate, 800);
mParams.setPictureSize(pictureSize.width, pictureSize.height);
Size previewSize = CamParaUtil.getInstance().getPropPreviewSize(
mParams.getSupportedPreviewSizes(), previewRate, 800);
mParams.setPreviewSize(previewSize.width, previewSize.height);
mCamera.setDisplayOrientation(90);
// CamParaUtil.getInstance().printSupportFocusMode(mParams);
List<String> focusModes = mParams.getSupportedFocusModes();
if(focusModes.contains("continuous-video")){
mParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
mCamera.setParameters(mParams);
mCamera.startPreview();//����Ԥ��
mCamera.setPreviewCallback(new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Logger.i(TAG, "摄像头回调!");
}
});
isPreviewing = true;
mPreviwRate = previewRate;
mParams = mCamera.getParameters();
Logger.i(TAG, "PreviewSize--With = " + mParams.getPreviewSize().width
+ "Height = " + mParams.getPreviewSize().height);
Logger.i(TAG, "PictureSize--With = " + mParams.getPictureSize().width
+ "Height = " + mParams.getPictureSize().height);
}
}
ShutterCallback mShutterCallback = new ShutterCallback()
//���Ű��µĻص������������ǿ����������Ʋ��š����ꡱ��֮��IJ�����Ĭ�ϵľ������ꡣ
{
public void onShutter() {
Logger.i(TAG, "myShutterCallback:onShutter...");
}
};
PictureCallback mRawCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
Logger.i(TAG, "myRawCallback:onPictureTaken...");
}
};
PictureCallback mJpegPictureCallback = new PictureCallback()
//��jpegͼ�����ݵĻص�,����Ҫ��һ���ص�
{
public void onPictureTaken(byte[] data, Camera camera) {
Logger.i(TAG, "myJpegCallback:onPictureTaken...");
Bitmap b = null;
if(null != data){
b = BitmapFactory.decodeByteArray(data, 0, data.length);
mCamera.stopPreview();
isPreviewing = false;
}
if(null != b) {
Bitmap rotaBitmap = ImageUtil.getRotateBitmap(b, 90.0f);
FileUtil.saveBitmap(rotaBitmap);
}
mCamera.startPreview();
isPreviewing = true;
}
};
}
| [
"panliangxiao@58.com"
] | panliangxiao@58.com |
87aea8f005867209d24f6ba7662aeb41b39c6828 | 46c4f3e78ac72d227fc49414d8a349ae26460ac0 | /repository/src/main/java/com/sira/api/repository/WorkRepository.java | a564961d1fe44572822f44a8c22387ae886d433e | [] | no_license | YaredNegede/Up-api | ab46f9f356c0f85b5331baccf4734870292d1c06 | 4987ad375f324a15ea85b9c2c1a6d1cb8948f20a | refs/heads/master | 2020-04-05T07:24:26.919994 | 2018-11-08T08:28:32 | 2018-11-08T08:28:32 | 156,674,482 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package com.sira.api.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.sira.model.stateschema.workbase.WorkBase;
/**
*
* @author Yared
*
*/
@Repository("workRepository")
public interface WorkRepository extends JpaRepository<WorkBase, Long> {} | [
"yaredngd@gmail.com"
] | yaredngd@gmail.com |
8cfa00defb6131e80e185329c2dac9b0f53e82bf | bd33c426d9372a5a450f53afa164a93dcf41dfc8 | /activiti-cloud-service-common/activiti-cloud-services-common-security/src/main/java/org/activiti/cloud/services/common/security/jwt/JwtAccessTokenValidator.java | 211a53aeeca31d31a8942f1a7bd6d3fe5aaf4b0d | [
"Apache-2.0"
] | permissive | Activiti/activiti-cloud | 46a182e97d73fd32a0dc68225ed202d765db33c5 | d516cf07b6b7d6a64f90f39c8aab66e7968593c4 | refs/heads/develop | 2023-08-24T11:40:27.558201 | 2023-08-23T07:28:46 | 2023-08-23T07:28:46 | 236,473,664 | 68 | 43 | Apache-2.0 | 2023-09-14T15:56:40 | 2020-01-27T11:13:42 | Java | UTF-8 | Java | false | false | 2,022 | java | /*
* Copyright 2017-2020 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.cloud.services.common.security.jwt;
import java.util.List;
import java.util.Optional;
import org.activiti.cloud.services.common.security.jwt.validator.ValidationCheck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNull;
import org.springframework.security.oauth2.jwt.Jwt;
public class JwtAccessTokenValidator {
private static final Logger LOGGER = LoggerFactory.getLogger(JwtAccessTokenValidator.class);
private final List<ValidationCheck> validationChecks;
public JwtAccessTokenValidator(List<ValidationCheck> validationChecks) {
this.validationChecks = validationChecks;
}
public boolean isValid(@NonNull JwtAdapter jwtAdapter) {
return Optional
.ofNullable(jwtAdapter)
.map(JwtAdapter::getJwt)
.map(this::isValid)
.orElseThrow(() -> new SecurityException("Invalid access token instance"));
}
public boolean isValid(Jwt accessToken) {
return !validationChecks
.stream()
.map(check -> {
boolean valid = check.isValid(accessToken);
if (!valid) {
LOGGER.error("Token invalid because the {} validation has failed.", check.getClass().toString());
}
return valid;
})
.anyMatch(b -> b.equals(false));
}
}
| [
"noreply@github.com"
] | noreply@github.com |
85c74cdd983cb413b0aa15ca7ad92abff0b72986 | 7e697e493613c096d76b28f5af647e2ab74936d9 | /app/src/androidTest/java/a13_12solutions/touchless/ExampleInstrumentedTest.java | 92ec8a77acd11a6749edb790d656c95198122a5f | [] | no_license | 13120dde/IotaPProject | 9031bf71b4306d0bfe62296104e9f215b3aec82f | 334a3563bea630184f8b600667ae915f7337ec59 | refs/heads/master | 2021-09-03T20:11:16.558269 | 2018-01-11T16:59:11 | 2018-01-11T16:59:11 | 113,988,437 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 754 | java | package a13_12solutions.touchless;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("a13_12solutions.touchless", appContext.getPackageName());
}
}
| [
"13120dde@gmail.com"
] | 13120dde@gmail.com |
3900a34a1d671d9497c7b74647633057d3c2f1e3 | 70e59c0e35859d07e3765610967a09f7409107d0 | /app/src/main/java/app/utils/MD5Util.java | d54ab4b317e6aec65db0388006f199f95e6e933a | [] | no_license | miweikeji/ourwork | cf069a3588ed5a6340b1118e616650b02aabad64 | 6e3a48f09d12ff44122c63a964beb12c26831e2e | refs/heads/master | 2021-01-10T06:42:43.416766 | 2015-11-17T15:36:54 | 2015-11-17T15:36:54 | 43,386,769 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,167 | java | package app.utils;
import java.security.MessageDigest;
/**
* Created by Administrator on 2015/11/6.
*/
public class MD5Util {
public final static String getMD5String(String s) {
char hexDigits[] = {'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'};
try {
byte[] btInput = s.getBytes();
//获得MD5摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance("MD5");
//使用指定的字节更新摘要
mdInst.update(btInput);
//获得密文
byte[] md = mdInst.digest();
//把密文转换成十六进制的字符串形式
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
} | [
"2256191718@qq.com"
] | 2256191718@qq.com |
5bcf74adba82c054bc913171ca9dbb20b8352b58 | 0742c50cc62752b86d5eab4799204b9300e562d5 | /xchange-bibox/src/main/java/org/knowm/xchange/bibox/dto/trade/BiboxOrderSide.java | 6fe92f3d0c1cba96ebce995ba9a971d692c4ef07 | [
"MIT"
] | permissive | evdubs/XChange | 884c38bc28ba4f9987fbcd579c5612bbac4b9cfe | 30091498346355cb0762c3b316fd28e58b372b36 | refs/heads/develop | 2021-01-14T08:56:49.564403 | 2018-03-02T02:43:07 | 2018-03-02T02:43:07 | 15,303,342 | 0 | 1 | MIT | 2018-03-02T02:43:08 | 2013-12-19T05:36:59 | Java | UTF-8 | Java | false | false | 1,227 | java | package org.knowm.xchange.bibox.dto.trade;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.exceptions.ExchangeException;
import com.fasterxml.jackson.annotation.JsonCreator;
/**
* @author odrotleff
*/
public enum BiboxOrderSide {
BID(1, OrderType.BID),
ASK(2, OrderType.ASK);
private int orderSide;
private OrderType orderType;
private BiboxOrderSide(int orderSide, OrderType orderType) {
this.orderSide = orderSide;
this.orderType = orderType;
}
public int asInt() {
return orderSide;
}
public OrderType getOrderType() {
return orderType;
}
public static BiboxOrderSide fromOrderType(OrderType orderType) {
switch (orderType) {
case BID:
return BiboxOrderSide.BID;
case ASK:
return BiboxOrderSide.ASK;
default:
throw new ExchangeException("Order type " + orderType + " unsupported.");
}
}
@JsonCreator
public static BiboxOrderSide fromInt(int orderSide) {
switch (orderSide) {
case 1:
return BID;
case 2:
return ASK;
default:
throw new ExchangeException("Unexpected Bibox order side.");
}
}
}
| [
"oliver.drotleff@gmail.com"
] | oliver.drotleff@gmail.com |
6bbef33bd84b4ce22084d1db771ba71aea1b6acb | 33dde579d15ff6cb3b9406ecec56c656ebe9c9de | /JPA/jpa-lock/src/test/java/com/josue/jpa/lock/LockUserRespositoryTest.java | 63d786602e90b27a426925fc7e8bf74e18ce7874 | [] | no_license | joshgontijo/Java-EE | 460307f708b81a62818e1d2c530d60c482cc9b05 | 81d28b8c51e4a52c19d8658cde21f0aa4a440d9f | refs/heads/master | 2022-11-06T03:32:07.832562 | 2017-01-22T17:43:14 | 2017-01-22T17:43:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,977 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.josue.jpa.lock;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.enterprise.concurrent.ManagedExecutorService;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.LockModeType;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceContext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
*
* @author jgontijo
*/
@RunWith(Arquillian.class)
public class LockUserRespositoryTest {
private static final Logger logger = Logger.getLogger(LockUserRespositoryTest.class.getName());
private volatile AssertionError assertionError;
@PersistenceContext
EntityManager em;
@Resource(lookup = "java:comp/DefaultManagedExecutorService")
private ManagedExecutorService executor;
@Inject
LockUserRepository repository;
@Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "lock-test.war")
.addPackage(LockUser.class.getPackage())
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
// 1- THREAD #1 READS THE DATA
// 2- THREAD #2 READS THE DATA
// 3- THREAD #2 UPDATE THE DATA ( UPDATE VERSION )
// 4- THREAD #1 UPDATE THE DATA ( EXCEPTION )
@Test
public void testOptimisticLockException() throws Exception {
final CountDownLatch testLatch = new CountDownLatch(2);
final CountDownLatch threadsLatch = new CountDownLatch(1);
LockUser lockUser = new LockUser("josue");
repository.persist(lockUser);
assertNotNull(lockUser.getId());
final int userId = lockUser.getId();
final ThreadExceptionWrapper exceptionWrapperThread1 = new ThreadExceptionWrapper();
final ThreadExceptionWrapper exceptionWrapperThread2 = new ThreadExceptionWrapper();
//THREAD #1
executor.execute(new Runnable() {
final Logger tLogger = Logger.getLogger(Thread.currentThread().getName());
@Override
public void run() {
try {
LockUser foundUser = repository.optmisticLock(userId, LockModeType.OPTIMISTIC);
if (foundUser == null) {
throw new Exception("USER NOT FOUND");
}
tLogger.info(":: HANGING... ::");
threadsLatch.await();
tLogger.info(":: RELEASED... ::");
foundUser.setName("should not save");
repository.merge(foundUser);
testLatch.countDown();
} catch (Exception ex) {
exceptionWrapperThread1.setException(ex);
tLogger.severe(ex.getMessage());
} finally {
testLatch.countDown();
}
}
});
//THREAD #2
executor.execute(new Runnable() {
final Logger tLogger = Logger.getLogger(Thread.currentThread().getName());
@Override
public void run() {
try {
LockUser foundUser = repository.optmisticLock(userId, LockModeType.OPTIMISTIC);
if (foundUser == null) {
throw new Exception("USER NOT FOUND");
}
foundUser.setName("name2");
repository.merge(foundUser);
tLogger.info(":: MERGED - VERSION SHOULD BE INCREMENTED ::");
} catch (Exception ex) {
tLogger.severe(ex.getMessage());
exceptionWrapperThread2.setException(ex);
} finally {
tLogger.info(":: THREADS LATCH... ::");
threadsLatch.countDown();
tLogger.info(":: TEST LATCH... ::");
testLatch.countDown();
}
}
});
logger.info("WAITING FOR TERMINATION");
testLatch.await(10, TimeUnit.SECONDS);
logger.info("TERMINATED");
if (exceptionWrapperThread1.getException() != null) {
Assert.assertEquals(OptimisticLockException.class, exceptionWrapperThread1.getException().getClass());
} else {
Assert.fail("SHOULD HAVE THROWN OPTIMISTICLOCKEXCEPTION");
}
if (exceptionWrapperThread2.getException() != null) {
Assert.fail("SHOULDNT HAVE THROWED AN EXCEPTION... EX: " + exceptionWrapperThread2.getException().getMessage());
}
}
// @Test
// public void testOptimisticLockExceptionForceIncrement() throws Exception {
// final CountDownLatch testLatch = new CountDownLatch(2);
// final CountDownLatch threadsLatch = new CountDownLatch(1);
//
// LockUser lockUser = new LockUser("josue");
// repository.persist(lockUser);
// assertNotNull(lockUser.getId());
// final int userId = lockUser.getId();
//
// final ThreadExceptionWrapper exceptionWrapperThread1 = new ThreadExceptionWrapper();
// final ThreadExceptionWrapper exceptionWrapperThread2 = new ThreadExceptionWrapper();
//
// //THREAD #1
// executor.execute(new Runnable() {
// final Logger tLogger = Logger.getLogger(Thread.currentThread().getName());
//
// @Override
// public void run() {
// try {
// LockUser foundUser = repository.optmisticLock(userId, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
// if (foundUser == null) {
// throw new Exception("USER NOT FOUND");
// }
// if (foundUser.getVersion() != 1) {
// throw new Exception("VERSION SHOULD BE INCREMENTED");
// }
//
// tLogger.info(":: HANGING... ::");
//
// tLogger.info(":: RELEASED... ::");
//
// foundUser.setName("should not save");
// repository.merge(foundUser);
//
// testLatch.countDown();
// } catch (Exception ex) {
// exceptionWrapperThread1.setException(ex);
// tLogger.severe(ex.getMessage());
// } finally {
// testLatch.countDown();
// }
// }
// });
//
// //THREAD #2
// executor.execute(new Runnable() {
// final Logger tLogger = Logger.getLogger(Thread.currentThread().getName());
//
// @Override
// public void run() {
// try {
// threadsLatch.await();
// LockUser foundUser = repository.optmisticLock(userId, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
// if (foundUser == null) {
// throw new Exception("USER NOT FOUND");
// }
//
// foundUser.setName("name2");
// repository.merge(foundUser);
// tLogger.info(":: MERGED - VERSION SHOULD BE INCREMENTED ::");
//
// } catch (Exception ex) {
// tLogger.severe(ex.getMessage());
// exceptionWrapperThread2.setException(ex);
// } finally {
// tLogger.info(":: THREADS LATCH... ::");
// threadsLatch.countDown();
// tLogger.info(":: TEST LATCH... ::");
// testLatch.countDown();
// }
// }
// });
//
// logger.info("WAITING FOR TERMINATION");
// testLatch.await(10, TimeUnit.SECONDS);
// logger.info("TERMINATED");
//
// if (exceptionWrapperThread1.getException() != null) {
// Assert.assertEquals(OptimisticLockException.class, exceptionWrapperThread1.getException().getClass());
// } else {
// Assert.fail("SHOULD HAVE THROWN OPTIMISTICLOCKEXCEPTION");
// }
//
// if (exceptionWrapperThread2.getException() != null) {
// Assert.fail("SHOULDNT HAVE THROWED AN EXCEPTION... EX: " + exceptionWrapperThread2.getException().getMessage());
// }
// }
}
| [
"jgontijo@CSD006209-DW7.caci.co.uk"
] | jgontijo@CSD006209-DW7.caci.co.uk |
b7cb23110e1101f3c6fde473b14ae29c845c9bae | c0429e190c182065ed3c384a23d1b09ea43aa603 | /app/src/main/java/com/txt/animation/Rotate3dAnimation.java | 851014dfb23189aa876215e44d2aef48ea11d8f8 | [] | no_license | tianyasifan/MyDemo | fad43c0fb72df6a05ef9c1c213022c805d799607 | 3261c9f69591062f1817efd5adcfc88fd9b644b5 | refs/heads/master | 2021-01-21T02:01:48.223504 | 2020-04-07T02:50:56 | 2020-04-07T02:50:56 | 62,270,527 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,853 | java | package com.txt.animation;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.animation.Animation;
import android.view.animation.Transformation;
/**
* An animation that rotates the view on the Y axis between two specified angles.
* This animation also adds a translation on the Z axis (depth) to improve the effect.
*/
public class Rotate3dAnimation extends Animation {
private final float mFromDegrees;
private final float mToDegrees;
private final float mCenterX;
private final float mCenterY;
private final float mDepthZ;
private final boolean mReverse;
private Camera mCamera;
/**
* Creates a new 3D rotation on the Y axis. The rotation is defined by its
* start angle and its end angle. Both angles are in degrees. The rotation
* is performed around a center point on the 2D space, definied by a pair
* of X and Y coordinates, called centerX and centerY. When the animation
* starts, a translation on the Z axis (depth) is performed. The length
* of the translation can be specified, as well as whether the translation
* should be reversed in time.
*
* @param fromDegrees the start angle of the 3D rotation
* @param toDegrees the end angle of the 3D rotation
* @param centerX the X center of the 3D rotation
* @param centerY the Y center of the 3D rotation
* @param reverse true if the translation should be reversed, false otherwise
*/
public Rotate3dAnimation(float fromDegrees, float toDegrees,
float centerX, float centerY, float depthZ, boolean reverse) {
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mCenterX = centerX;
mCenterY = centerY;
mDepthZ = depthZ;
mReverse = reverse;
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mCamera = new Camera();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
if (mReverse) {
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
} | [
"tianyasifan@126.com"
] | tianyasifan@126.com |
df5643e225f820b17656b1492cad3b4cf390d11d | ae0b4b478affc409ffc7d14717f4e286b704c248 | /CharacterComparator.java | b6e260c1d771faed086d81d10c6c5557681f1c95 | [] | no_license | cameron612/Data-Structures-and-Algorithms | 1a1825f30f78514df608556c5594cd7657fc8d43 | 69219e74416cc8d3efa1604ce952af53ce95b819 | refs/heads/master | 2022-01-19T09:42:11.960800 | 2019-05-08T23:17:33 | 2019-05-08T23:17:33 | 185,691,371 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,129 | java | import java.util.Comparator;
/**
* Comparator that allows for comparison of characters and
* counting said comparisons.
*
* This MUST BE USED for character comparisons. Using any other form of
* comparison for characters will result in test failures.
*
* DO NOT CREATE ANOTHER INSTANCE OF THIS CLASS
*/
public class CharacterComparator implements Comparator<Character> {
private int comparisonCount;
/**
* To be used when comparing characters. Keeps count of
* how many times this method has been called.
*
* @param a first character to be compared
* @param b second character to be compared
* @return negative value if a is less than b, positive
* if a is greater than b, and 0 otherwise
*/
@Override
public int compare(Character a, Character b) {
comparisonCount++;
return a - b;
}
/**
* Returns the number of times compare has been used
* @return the number of times compare has been used
*/
public int getComparisonCount() {
return comparisonCount;
}
} | [
"noreply@github.com"
] | noreply@github.com |
df9484172fbe76286c92b73dea075a6cce03d272 | e5158caed9effe8feb13d77306b0104293b7c929 | /Terreno.java | b1e3a25ffc17cc9164e219f8703737a355a37089 | [] | no_license | carlospalma-sistemas/Terrenos | a2647442499232b09520793333b965827a1c267a | c2d7baf55cd018e827482f522cc63707a058bac2 | refs/heads/master | 2023-07-03T15:36:37.857255 | 2021-08-10T12:50:32 | 2021-08-10T12:50:32 | 390,160,323 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,186 | java | public abstract class Terreno implements ContratoTerreno
{
protected int id;
protected String direccion;
protected String ciudad;
protected String sector;
protected double largo;
protected double ancho;
public Terreno()
{
this.largo = 0;
this.ancho = 0;
this.sector = "";
}
public Terreno(double largo, double ancho, String sector)
{
this.largo = largo;
this.ancho = ancho;
this.sector = sector;
}
public Terreno(String direccion, String ciudad, String sector, double largo, double ancho)
{
this.direccion = direccion;
this.ciudad = ciudad;
this.sector = sector;
this.largo = largo;
this.ancho = ancho;
}
public void setId(int id)
{
this.id = id;
}
public int getId()
{
return this.id;
}
public String getDireccion()
{
return this.direccion;
}
public void setDireccion(String direccion)
{
this.direccion = direccion;
}
public String getCiudad()
{
return this.ciudad;
}
public void setCiudad(String ciudad)
{
this.ciudad = ciudad;
}
public void setSector(String sector)
{
this.sector = sector;
}
public String getSector()
{
return this.sector;
}
public void setLargo(double largo)
{
this.largo = largo;
}
public double getLargo()
{
return this.largo;
}
public void setAncho(double ancho)
{
this.ancho = ancho;
}
public double getAncho()
{
return this.ancho;
}
public abstract double getArea();
public double getValorXm2()
{
double valorXm2 = sector.toLowerCase().equals("urbano") ? 3000000 : 1800000;
return valorXm2;
}
public double getPrecio()
{
double precio = getValorXm2() * getArea();
return precio;
}
public abstract String toString();
}
| [
"34041415+carlospalma-sistemas@users.noreply.github.com"
] | 34041415+carlospalma-sistemas@users.noreply.github.com |
da054edad2c727d7bf1d797c2fc20e1984b99a8d | 9129879e14515da0f44107575532f1adb5d9d864 | /2day/DialogTest.java | 562a97cad43efe0d59b30c106d2c7c884006e45c | [] | no_license | myh9410/Java | d1922c4eaec69fa3a21ee23fa03d9dae4c5d5f63 | 31eca042ee817a3a451713e35a36f45bb6afc719 | refs/heads/master | 2022-12-24T07:22:24.552156 | 2022-12-23T13:41:04 | 2022-12-23T13:41:04 | 115,339,119 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 910 | java | package dialogex;
import javax.swing.JOptionPane;
/*
대화상자 부르기 -> 문자열로 입력받는다.
String sss = JOptionPane.showInputDialog();
때에 따라서는 정수, 실수 등으로 파싱해서 가져와야 한다.
int i = Integer.parseInt( sss );
double d = Double.parseDouble( sss );
*/
public class DialogTest {
public static void main(String[] args) {
String name = JOptionPane.showInputDialog("이름 입력");
String age = JOptionPane.showInputDialog("나이 입력");
String frAge = JOptionPane.showInputDialog("짝 나이 입력");
int ageInt = Integer.parseInt(age);
int frAgeInt = Integer.parseInt(frAge);
int totAge = ageInt + frAgeInt;
//출력
System.out.println("이름 : "+name);
System.out.println("나이 : "+age);
System.out.println("짝 나이 : "+frAge);
System.out.println("합 : "+totAge);
}
}
| [
"mjskks94@naver.com"
] | mjskks94@naver.com |
6502e4e600dcf1cc508c3e8a5144f9623f893a1f | 5e024312356992bfb07cc2576540381ce29dc41c | /vault-totp-pattern/java-app/src/main/java/app/model/TOTPCreateRequest.java | 0d27d52c50411e3a3abc07ca175e012127ecc3bf | [] | no_license | fschaell/vault-developer-patterns | 37eb0ce0022cf07f4974b2ed48a95b3eb6de955a | 1ddfbd7a57ca69070dc10230f604fc88535f1b10 | refs/heads/main | 2023-03-14T16:24:49.314891 | 2021-04-02T23:14:55 | 2021-04-02T23:14:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 636 | java | package app.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class TOTPCreateRequest {
private Boolean generate;
private String issuer;
private String accountName;
public TOTPCreateRequest() {
this.generate = true;
}
@JsonProperty("account_name")
public String getAccountName() {
return accountName;
}
public Boolean getGenerate() {
return generate;
}
public String getIssuer() {
return issuer;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setIssuer(String issuer) {
this.issuer = issuer;
}
} | [
"jackson.nic@gmail.com"
] | jackson.nic@gmail.com |
750a6662148b67b41d9ae2518e9682f1d5d97ae3 | 0917a6cefcc3c3d6766080e58e83cd027522d0a8 | /src/main/java/leetcode/RemoveDuplicatesfromSortedArrayII.java | 99330e6a36e6c8ff200798175877aeb49c266f59 | [] | no_license | lyk4411/untitled1_intellij | 19bb583c8e631c4fab5826573fe30a61dff9d2d4 | 7a3e9ff784faa03c04a40cfdc0ba53af3344bb09 | refs/heads/master | 2022-12-22T13:58:32.218291 | 2020-01-22T08:58:04 | 2020-01-22T08:58:04 | 62,300,156 | 0 | 0 | null | 2022-12-16T03:16:30 | 2016-06-30T09:56:05 | Java | UTF-8 | Java | false | false | 611 | java | package leetcode;
/**
* Created by lyk on 2017/3/16.
* Package name: leetcode
* Porject name: untitled1
*/
public class RemoveDuplicatesfromSortedArrayII {
public static void main(String[] args) {
RemoveDuplicatesfromSortedArrayII rdsaii = new RemoveDuplicatesfromSortedArrayII();
int[] nums = new int[]{1,2,2,3,3,3,3,3,4,6,6,6,7};
System.out.println(rdsaii.removeDuplicates(nums));
}
public int removeDuplicates(int[] nums) {
int i = 0;
for (int n : nums)
if (i < 2 || n > nums[i-2])
nums[i++] = n;
return i;
}
}
| [
"moneyflying_2006@hotmail.com"
] | moneyflying_2006@hotmail.com |
c4e8b530cc80a5980806f54041081877f8af2db6 | 4b4f018be8df5ffed3e3c5df7ba1bd03c40fcf1a | /src/POSHI/ItemListPanel.java | 3e351318cc986cb9afc613bf200eaa368cb07870 | [] | no_license | BlaiseMahoro/POS | 8e1ad8b4d6241ce715eb09e8261db220e49c927d | 1b34f76eab241691cd116bd0fc0846d7ed89450c | refs/heads/master | 2020-07-28T08:55:00.814595 | 2019-09-18T17:56:26 | 2019-09-18T17:56:26 | 209,372,191 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,638 | java | package POSHI;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import POSPD.*;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;
/**
*
* @author Blaise Mahoro
*
*/
public class ItemListPanel extends JPanel {
private DefaultListModel listModel;
/**
* Create the item list panel.
*/
public ItemListPanel(JFrame currentFrame, Store store) {
setLayout(null);
JLabel lblSelectItem = new JLabel("Select Item:");
lblSelectItem.setBounds(170, 13, 76, 16);
add(lblSelectItem);
listModel= new DefaultListModel();
for(Item item:store.getItems().values())
listModel.addElement(item);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(12, 67, 386, 114);
add(scrollPane);
JList<Item> list = new JList<Item>(listModel);
JButton btnEdit = new JButton("Edit");
btnEdit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentFrame.getContentPane().removeAll();
currentFrame.getContentPane().add(new ItemEditPanel(currentFrame,store,list.getSelectedValue(),false));
currentFrame.getContentPane().revalidate();
}
});
btnEdit.setBounds(12, 233, 97, 25);
add(btnEdit);
JButton btnDelete = new JButton("Delete");
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
store.removeItem(list.getSelectedValue());
listModel.removeElement(list.getSelectedValue());
btnEdit.setEnabled(false);
btnDelete.setEnabled(false);
}
});
btnDelete.setBounds(322, 233, 97, 25);
add(btnDelete);
JButton btnAdd = new JButton("Add");
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentFrame.getContentPane().removeAll();
currentFrame.getContentPane().add(new ItemEditPanel(currentFrame,store,new Item(),true));
currentFrame.getContentPane().revalidate();
}
});
btnAdd.setBounds(170, 233, 97, 25);
add(btnAdd);
btnEdit.setEnabled(false);
btnDelete.setEnabled(false);
scrollPane.setViewportView(list);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (list.getSelectedValue() != null)
{
btnEdit.setEnabled(true);
btnDelete.setEnabled(true);
}
}
});
}
}
| [
"Blaise Mahoro@BLAISEPC"
] | Blaise Mahoro@BLAISEPC |
4a5e80d74fd52a61b2efa52117454d220b9cd16b | 7d79e6d08de0bfb5e736568700e591b100d3c0f7 | /RS_Spacewars/src/pack/Strategy.java | 171d1ce0f96ab3ad91a242706ec105a1508efc57 | [] | no_license | rchicoria/swing_spawars | ddabdda2b1ea1f8cad608a70c3032e686277b321 | ef188547fe83d073006bc71b89f4ecc16b321274 | refs/heads/master | 2016-09-05T11:49:55.080379 | 2012-01-04T18:25:24 | 2012-01-04T18:25:24 | 2,798,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 259 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pack;
import spaceship.UserSpaceship;
/**
*
* @author alpha
*/
public interface Strategy {
public void activate(UserSpaceship spaceship);
}
| [
"alpha.sh4rk@gmail.com"
] | alpha.sh4rk@gmail.com |
937ff8147a0c4449433db6ad4000e1829d26d63e | b34654bd96750be62556ed368ef4db1043521ff2 | /online_review_phases/tags/RPI_merge2_version-1.6.2.1/src/java/main/com/cronos/onlinereview/phases/AppealsResponsePhaseHandler.java | 269ab9528b50828e5725ff8a221eef1879bb464e | [] | no_license | topcoder-platform/tcs-cronos | 81fed1e4f19ef60cdc5e5632084695d67275c415 | c4ad087bb56bdaa19f9890e6580fcc5a3121b6c6 | refs/heads/master | 2023-08-03T22:21:52.216762 | 2019-03-19T08:53:31 | 2019-03-19T08:53:31 | 89,589,444 | 0 | 1 | null | 2019-03-19T08:53:32 | 2017-04-27T11:19:01 | null | UTF-8 | Java | false | false | 19,919 | java | /*
* Copyright (C) 2009-2011 TopCoder Inc., All Rights Reserved.
*/
package com.cronos.onlinereview.phases;
import com.topcoder.management.deliverable.Submission;
import com.topcoder.management.deliverable.SubmissionStatus;
import com.topcoder.management.deliverable.persistence.UploadPersistenceException;
import com.topcoder.management.phase.OperationCheckResult;
import com.topcoder.management.phase.PhaseHandlingException;
import com.topcoder.management.project.PersistenceException;
import com.topcoder.management.project.Project;
import com.topcoder.management.project.ValidationException;
import com.topcoder.management.resource.Resource;
import com.topcoder.management.resource.persistence.ResourcePersistenceException;
import com.topcoder.management.review.data.Comment;
import com.topcoder.management.review.data.Item;
import com.topcoder.management.review.data.Review;
import com.topcoder.management.review.scoreaggregator.AggregatedSubmission;
import com.topcoder.management.review.scoreaggregator.InconsistentDataException;
import com.topcoder.management.review.scoreaggregator.RankedSubmission;
import com.topcoder.management.review.scoreaggregator.ReviewScoreAggregator;
import com.topcoder.project.phases.Phase;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.DecimalFormat;
/**
* <p>
* This class implements PhaseHandler interface to provide methods to check if a phase can be executed and to add
* extra logic to execute a phase. It will be used by Phase Management component. It is configurable using an input
* namespace. The configurable parameters include database connection and email sending. This class handle the
* appeals response phase. If the input is of other phase types, PhaseNotSupportedException will be thrown.
* </p>
* <p>
* The appeals response phase can start as soon as the dependencies are met and can stop when the following
* conditions met: The dependencies are met and all appeals are resolved.
* </p>
* <p>
* The additional logic for executing this phase is:<br>
* When Appeals Response is stopping:
* <ul>
* <li>All submissions with failed review scores will be set to the status "Failed Review".</li>
* <li>Overall score for the passing submissions will be calculated and saved to the submitters’ resource
* properties together with their placements. The property names are "Final Score" and
* "Placement".</li>
* <li>The winner and runner-up will be populated in the project properties. The property names are "Winner
* External Reference ID" and "Runner-up External Reference ID".</li>
* <li>Submissions that do not win will be set to the status "Completed Without Win".</li>
* </ul>
* </p>
* <p>
* Thread safety: This class is thread safe because it is immutable.
* </p>
* <p>
* version 1.1 change notes: Modify the method <code>perform</code> to add a post-mortem phase if there is no
* submission passes review after appeal response.
* </p>
* <p>
* Version 1.2 changes note:
* <ul>
* <li>Added capability to support different email template for different role (e.g. Submitter, Reviewer, Manager,
* etc).</li>
* <li>Support for more information in the email generated: for start/stop, puts the submissions info/scores into
* the values map for email generation.</li>
* </ul>
* </p>
* <p>
* Version 1.3 (Online Review End Of Project Analysis Assembly 1.0) Change notes:
* <ol>
* <li>Updated {@link #perform(Phase, String)} method to use updated
* PhasesHelper#insertPostMortemPhase(com.topcoder.project.phases.Project, Phase, ManagerHelper, String) method for
* creating <code>Post-Mortem</code> phase.</li>
* </ol>
* </p>
* <p>
* Version 1.4 Change notes:
* <ol>
* <li>Updated {@link #perform(Phase, String)} method to calculate the number of aggregators for project and bind
* it to map used for filling email template.</li>
* </ol>
* </p>
* <p>
* Version 1.6 Change notes:
* <ol>
* <li>Refactor breakTies and getSubmissionById methods to PhaseHelper to reduce code redundancy.</li>
* <li>Change to use getUploads().get(0) to retrieve the only upload for software competitions.</li>
* </ol>
* </p>
* <p>
* Version 1.7 (Online Review Replatforming Release 2 ) Change notes:
* <ol>
* <li>Change submission.getUploads() to submission.getUpload().</li>
* </ol>
* </p>
* <p>
* Version 1.6.1 (Component development) changes note:
* <ul>
* <li>canPerform() method was updated to return not only true/false value, but additionally an explanation message
* in case if operation cannot be performed.</li>
* </ul>
* </p>
*
* <p>
* Version 1.7.1 (BUGR-4779) Change notes:
* <ol>
* <li>Updated {@link #updateSubmissions(Phase, String, Map)} method to populate contest prizes for submissions.</li>
* </ol>
* </p>
*
* @author tuenm, bose_java, argolite, waits, isv, microsky, flexme
* @version 1.7.1
*/
public class AppealsResponsePhaseHandler extends AbstractPhaseHandler {
/**
* Represents the default namespace of this class. It is used in the default
* constructor to load configuration settings.
*/
public static final String DEFAULT_NAMESPACE = "com.cronos.onlinereview.phases.AppealsResponsePhaseHandler";
/** constant for appeals response phase type. */
private static final String PHASE_TYPE_APPEALS_RESPONSE = "Appeals Response";
/**
* Create a new instance of AppealsResponsePhaseHandler using the default
* namespace for loading configuration settings.
* @throws ConfigurationException if errors occurred while loading
* configuration settings.
*/
public AppealsResponsePhaseHandler() throws ConfigurationException {
super(DEFAULT_NAMESPACE);
}
/**
* Create a new instance of AppealsResponsePhaseHandler using the given
* namespace for loading configuration settings.
* @param namespace the namespace to load configuration settings from.
* @throws ConfigurationException if errors occurred while loading
* configuration settings.
* @throws IllegalArgumentException if the input is null or empty string.
*/
public AppealsResponsePhaseHandler(String namespace) throws ConfigurationException {
super(namespace);
}
/**
* <p>
* Check if the input phase can be executed or not. This method will check the phase status to see what will be
* executed. This method will be called by canStart() and canEnd() methods of PhaseManager implementations in
* Phase Management component.
* </p>
* <p>
* If the input phase status is Scheduled, then it will check if the phase can be started using the following
* conditions: The dependencies are met
* </p>
* <p>
* If the input phase status is Open, then it will check if the phase can be stopped using the following
* conditions: The dependencies are met and All appeals are resolved.
* </p>
* <p>
* If the input phase status is Closed, then PhaseHandlingException will be thrown.
* </p>
* <p>
* Version 1.6.1 changes note:
* <ul>
* <li>The return changes from boolean to OperationCheckResult.</li>
* </ul>
* </p>
* @param phase The input phase to check.
* @return the validation result indicating whether the associated operation can be performed, and if not,
* providing a reasoning message (not null)
* @throws PhaseNotSupportedException if the input phase type is not
* "Appeals Response" type.
* @throws PhaseHandlingException if there is any error occurred while
* processing the phase.
* @throws IllegalArgumentException if the input is null.
*/
public OperationCheckResult canPerform(Phase phase) throws PhaseHandlingException {
PhasesHelper.checkNull(phase, "phase");
PhasesHelper.checkPhaseType(phase, PHASE_TYPE_APPEALS_RESPONSE);
// will throw exception if phase status is neither "Scheduled" nor "Open"
boolean toStart = PhasesHelper.checkPhaseStatus(phase.getPhaseStatus());
if (toStart) {
// return true if all dependencies have stopped and start time has been reached.
return PhasesHelper.checkPhaseCanStart(phase);
} else {
OperationCheckResult result = PhasesHelper.checkPhaseDependenciesMet(phase, false);
if (!result.isSuccess()) {
return result;
}
if (!allAppealsResolved(phase)) {
return new OperationCheckResult("Not all appeals are resolved");
}
return OperationCheckResult.SUCCESS;
}
}
/**
* <p>
* Provides additional logic to execute a phase. This method will be called by start() and end() methods of
* PhaseManager implementations in Phase Management component. This method can send email to a group of users
* associated with timeline notification for the project. The email can be send on start phase or end phase
* base on configuration settings.
* </p>
* <p>
* If the input phase status is Scheduled, then it will do nothing.
* </p>
* <p>
* If the input phase status is Open, then it will perform the following additional logic to stop the phase:
* </p>
* <ul>
* <li>All submissions with failed review scores will be set to the status "Failed Review".</li>
* <li>Overall score for the passing submissions will be calculated and saved to the submitters’ resource
* properties together with their placements. The property names are "Final Score" and
* "Placement".</li>
* <li>The winner and runner-up will be populated in the project properties. The property names are
* "Winner External Reference ID" and "Runner-up External Reference ID".</li>
* <li>Submissions that do not win will be set to the status "Completed Without Win".</li>
* </ul>
* <p>
* If the input phase status is Closed, then PhaseHandlingException will be thrown.
* </p>
* <p>
* Version 1.1. change notes: Add a post-mortem phase after this phase if there is no submission passes review
* after appeal response.
* </p>
* <p>
* version 1.2. change notes: put the scores of the submissions/submitter handle into the values map. for each
* submission, there will be a sub-map, all in a list with key 'SUBMITTER'.
* </p>
* @param phase The input phase to check.
* @param operator The operator that execute the phase.
* @throws PhaseNotSupportedException if the input phase type is not
* "Appeals Response" type.
* @throws PhaseHandlingException if there is any error occurred while
* processing the phase.
* @throws IllegalArgumentException if the input parameters is null or empty
* string.
*/
public void perform(Phase phase, String operator) throws PhaseHandlingException {
PhasesHelper.checkNull(phase, "phase");
PhasesHelper.checkString(operator, "operator");
PhasesHelper.checkPhaseType(phase, PHASE_TYPE_APPEALS_RESPONSE);
Connection conn = createConnection();
try {
boolean toStart = PhasesHelper.checkPhaseStatus(phase.getPhaseStatus());
Map<String, Object> values = new HashMap<String, Object>();
if (toStart) {
// for start phase, puts the submission info/initial score
values.put("SUBMITTER", PhasesHelper.getSubmitterValueArray(conn,
getManagerHelper(), phase.getProject().getId(), false));
} else {
// it is going to calculate the final score for every submission
// and put the scores into the values after calculation
updateSubmissions(phase, operator, values);
Submission[] subs = PhasesHelper.searchActiveSubmissions(getManagerHelper().getUploadManager(), conn,
phase.getProject().getId(), PhasesHelper.CONTEST_SUBMISSION_TYPE);
if (subs==null || subs.length == 0) {
// if there is no active submissions after appeal response, insert the post-mortem phase
PhasesHelper.insertPostMortemPhase(phase.getProject(), phase, getManagerHelper(), operator);
}
Resource[] aggregators = getAggregators(PhasesHelper.locatePhase(phase, "Aggregation", true, true));
values.put("N_AGGREGATOR", aggregators.length);
}
sendEmail(phase, values);
} finally {
PhasesHelper.closeConnection(conn);
}
}
/**
* <p>
* Gets the list of resources assigned <code>Aggregator</code> role.
* </p>
* @param aggregationPhase a <code>Phase</code> providing the details for <code>Aggregation</code> phase.
* @return a <code>Resource</code> array listing the resources granted <code>Aggregator</code> role.
* @throws PhaseHandlingException if an unexpected error occurs while accessing the data store.
* @since 1.4
*/
private Resource[] getAggregators(Phase aggregationPhase) throws PhaseHandlingException {
Resource[] aggregators;
Connection conn = createConnection();
try {
aggregators = PhasesHelper.searchResourcesForRoleNames(getManagerHelper(), conn,
new String[] {"Aggregator" }, aggregationPhase.getId());
} finally {
PhasesHelper.closeConnection(conn);
}
return aggregators;
}
/**
* This method is called from perform method when phase is stopping. It does
* the following:
* <ul>
* <li>all submissions with failed review scores are set to the status Failed Review.</li>
* <li>Overall score for the passing submissions are calculated and saved.</li>
* <li>The winner and runner-up are populated in the project properties.</li>
* <li>Submissions that do not win are set to the status Completed Without Win.</li>
* </ul>
* <p>
* version 1.1. change notes: Change return type from void to boolean, returning true indicates there is at
* least one submission passes review after appeal response, false otherwise.
* </p>
* <p>
* version 1.2. change notes: put the scores of the submissions/submitter handle into the values map. for each
* submission, there will be a sub-map, all in a list with key 'SUBMITTER'.
* </p>
* @param phase the phase instance.
* @param operator operator name.
* @param values the values map
* @throws PhaseHandlingException if there was an error updating data.
* @version 1.2
*/
private void updateSubmissions(Phase phase, String operator, Map<String, Object> values)
throws PhaseHandlingException {
Connection conn = createConnection();
try {
// locate previous review phase
Phase reviewPhase = PhasesHelper.locatePhase(phase, PhasesHelper.REVIEW, false, true);
Submission[] subs = PhasesHelper.updateSubmissionsResults(getManagerHelper(), conn, reviewPhase,
operator, false, false, true);
// Order submissions by placement for the notification messages
Arrays.sort(subs, new Comparator<Submission>() {
public int compare(Submission sub1, Submission sub2) {
return (int) (sub1.getPlacement() - sub2.getPlacement());
}
});
// For each submission, get the submitter and its scores
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
DecimalFormat df = new DecimalFormat("#.##");
for (Submission submission : subs) {
Map<String, Object> infos = new HashMap<String, Object>();
Resource submitter = getManagerHelper().getResourceManager().getResource(submission.getUpload().getOwner());
infos.put("SUBMITTER_HANDLE", PhasesHelper.notNullValue(submitter.getProperty(PhasesHelper.HANDLE)));
infos.put("SUBMITTER_PRE_APPEALS_SCORE", df.format(submission.getInitialScore()));
infos.put("SUBMITTER_POST_APPEALS_SCORE", df.format(submission.getFinalScore()));
infos.put("SUBMITTER_RESULT", submission.getPlacement());
result.add(infos);
}
values.put("SUBMITTER", result);
} catch (ResourcePersistenceException e) {
throw new PhaseHandlingException("Problem with resource persistence", e);
} finally {
PhasesHelper.closeConnection(conn);
}
}
/**
* This method returns true if all the appeals have been responded to.
* @param phase phase instance.
* @return true if all appeals are resolved, false otherwise.
* @throws PhaseHandlingException if an error occurs when retrieving data.
*/
private boolean allAppealsResolved(Phase phase) throws PhaseHandlingException {
// Find appeals : Go back to the nearest Review phase
Phase reviewPhase = PhasesHelper.locatePhase(phase, PhasesHelper.REVIEW, false, false);
if (reviewPhase == null) {
return false;
}
long reviewPhaseId = reviewPhase.getId();
Connection conn = createConnection();
try {
// Get all reviews
Review[] reviews = PhasesHelper.searchReviewsForResourceRoles(conn,
getManagerHelper(), reviewPhaseId, PhasesHelper.REVIEWER_ROLE_NAMES, null);
// for each review
for (int i = 0; i < reviews.length; i++) {
int appealCount = 0;
int responseCount = 0;
Comment[] comments = reviews[i].getAllComments();
for (int c = 0; c < comments.length; c++) {
String commentType = comments[c].getCommentType().getName();
if ("Appeal".equals(commentType)) {
appealCount++;
} else if ("Appeal Response".equals(commentType)) {
responseCount++;
}
}
Item[] items = reviews[i].getAllItems();
for (int j = 0; j < items.length; ++j) {
comments = items[j].getAllComments();
for (int c = 0; c < comments.length; c++) {
String commentType = comments[c].getCommentType().getName();
if ("Appeal".equals(commentType)) {
appealCount++;
} else if ("Appeal Response".equals(commentType)) {
responseCount++;
}
}
}
// if appeals count does not match response count, return false.
if (appealCount != responseCount) {
return false;
}
}
return true;
} finally {
PhasesHelper.closeConnection(conn);
}
}
}
| [
"HumbleSunflower@fb370eea-3af6-4597-97f7-f7400a59c12a"
] | HumbleSunflower@fb370eea-3af6-4597-97f7-f7400a59c12a |
c48688aac271bee3c2f1395156159e0d7a075734 | 2b9e2a5d21dab72c6cb804306bfb22d80013a9a8 | /odataV4/src/main/java/odataservice/odatav4/service/EntityMetaDataContainer.java | 5112ebcedcdc958d177669a9160444576e703bc4 | [] | no_license | Scan85/oDataV4 | d255bf09fa9db6b501d4a5959823503b96a4089e | a11355e6bdc86cfc0fd6fe0e36b3c92a40265bdf | refs/heads/master | 2020-03-22T17:53:17.438335 | 2018-07-10T20:18:26 | 2018-07-10T20:18:26 | 140,422,322 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,139 | java | package odataservice.odatav4.service;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import lombok.Getter;
/**
* @author Seyit Can
* This class holds all meta data of multiple entities.
*/
public class EntityMetaDataContainer {
@Getter
private final String serviceNamespace;
@Getter
private final String edmContainerName;
/**
* List of meta data for multiple entities.
*/
@Getter
private final Set<EntityMetaData<?>> allEntityMetaData;
public EntityMetaDataContainer(String serviceNamespace, String edmContainerName, Set<EntityMetaData<?>> allEntityMetaData) {
this.serviceNamespace = serviceNamespace;
this.edmContainerName = edmContainerName;
this.allEntityMetaData = Collections.synchronizedSet(allEntityMetaData);
}
/**
* Returns the meta entity data of the given type set name. If no set with
* this name found, the method returns <code>null</code>.
*
* @param entityTypeSetName the name of the type set
* @return the meta data of the entity or <code>null</code> if no set found
*/
public EntityMetaData<?> getEntityMetaDataByTypeSetName(String entityTypeSetName) {
EntityMetaData<?> entity = null;
for (EntityMetaData<?> meta : this.allEntityMetaData) {
if (meta.getEntityTypeSetName() != null && meta.getEntityTypeSetName().equals(entityTypeSetName)) {
entity = meta;
break;
}
}
return entity;
}
/**
* Returns the meta entity data of the given full qualified type name. If no
* meta data with this name found, the method returns <code>null</code>.
*
* @param serviceNamespace the service namespace
* @param entityTypeName the name of the type name
* @return the meta data of the entity or <code>null</code> if no meta data
* found
*/
public EntityMetaData<?> getEntityMetaDataByTypeName(String serviceNamespace, String entityTypeName) {
EntityMetaData<?> entity = null;
if (this.serviceNamespace.equals(serviceNamespace)) {
for (EntityMetaData<?> meta : this.allEntityMetaData) {
if (meta.getEntityTypeName().equals(entityTypeName)) {
entity = meta;
break;
}
}
}
return entity;
}
public EntityMetaProperty getEntityMetaPropertyDataByTypeName(String serviceNamespace, String propertyTypeName) {
EntityMetaProperty propData = null;
if (this.serviceNamespace.equals(serviceNamespace)) {
for (EntityMetaData<?> meta : this.allEntityMetaData) {
List<EntityMetaProperty> enumPropertyDataList = meta.getEnumPropertyData();
for (EntityMetaProperty propEntry : enumPropertyDataList) {
if (propEntry.getFieldType().getSimpleName().equals(propertyTypeName)) {
propData = propEntry;
break;
}
}
}
}
return propData;
}
}
| [
"seyitca@live.de"
] | seyitca@live.de |
8055647c27483cf0b907d437a7e6a4a65a06c609 | 116d2e55767a256f58d41bfb1d33e19fb8c0d391 | /springexample/src/test/java/com/springboot/basics/springexample/SpringexampleApplicationTests.java | c600cff80a96abbd0acb4bc09cb543d2ac1cb5d4 | [] | no_license | polarTurtle/java | e6c3a910ff0f80c322aad5f43f2ac0013a2373ae | 59fdacf81b89d89c6e9cb4f09674c8b49dde8015 | refs/heads/main | 2023-04-14T21:37:17.261331 | 2021-04-20T12:15:08 | 2021-04-20T12:15:08 | 342,137,801 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,148 | java | package com.springboot.basics.springexample;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringexampleApplicationTests {
@Test
void contextLoads() {
}
@Test
public void test1() {
OptimizedDiskCache optimisedDiskCache = new OptimizedDiskCache();
Cache cache = (Cache) optimisedDiskCache;
}
@Test
public void test2() {
MemoryCache memoryCache = new MemoryCache();
Cache cache = (Cache) memoryCache;
DiskCache diskCache = (DiskCache) cache;
}
@Test
public void test3() {
DiskCache diskCache = new DiskCache();
OptimizedDiskCache optimizedDiskCache = (OptimizedDiskCache) diskCache;
}
@Test
public void test4() {
OptimizedDiskCache optimizedDiskCache = new OptimizedDiskCache();
DiskCache diskCache = (DiskCache) optimizedDiskCache;
}
@Test
public void test5() {
Cache cache = new Cache();
MemoryCache memoryCache = (MemoryCache) cache;
}
@Test
public void test6() {
OptimizedDiskCache optimizedDiskCache = new OptimizedDiskCache();
Cache cache = (Cache) optimizedDiskCache;
DiskCache diskCache = (DiskCache) cache;
}
}
| [
"76888013+polarTurtle@users.noreply.github.com"
] | 76888013+polarTurtle@users.noreply.github.com |
2af31b9a14cd93d18e6020650e379662e25e08d8 | 1d3ba2d198c09f4551279ab50002f39de415524d | /app/src/main/java/com/example/helloworld/huaruanshopping/api/HttpMethods.java | 53ab80e7178952c5409f0ed227d3a61dc7a2e416 | [] | no_license | HRShopping/HRShopping | 4d8469a3a54ff21e9a848543a688d354b9d48b74 | af87ca035566a1e6b06f6a1bb2c2a09056b9aa0c | refs/heads/master | 2021-01-23T02:47:56.722933 | 2017-03-24T03:46:02 | 2017-03-24T03:46:02 | 86,022,300 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,297 | java | package com.example.helloworld.huaruanshopping.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import com.example.helloworld.huaruanshopping.api.updateInfoService;
/**
* Created by helloworld on 2017/2/22.
*/
public class HttpMethods {
public static final String BASE_URL = "http://www.chjcal.cc";
private static final int DEFAULT_TIMEOUT = 5;
public HomeProductService homeProductApi;
public CategoryService categoryService;
public SortProductService sortProductService;
public ProductDescribeService productDescribeService;
public postProductService mPostProductService;
public CartService cartService;
public FindAllOrderService findAllOrderService;
public updateInfoService updateInfoService;
public OkHttpClient client;
private Gson gson;
//构造方法是有
private HttpMethods() {
//手动创建一个OKHttpClient 并设置超时时间
client = new OkHttpClient.Builder()
.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
.build();
gson = new GsonBuilder()
.setLenient()
.create();
}
//获取单例
public static HttpMethods getInstance() {
return SingletonHolder.INSTANCE;
}
//内部类 访问HttpMethods 时创建单例
private static class SingletonHolder {
private static final HttpMethods INSTANCE = new HttpMethods();
}
public HomeProductService getHomeProductApi() {
if (homeProductApi == null) {
homeProductApi = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build().create(HomeProductService.class);
}
return homeProductApi;
}
public CategoryService getCategoryService() {
if (categoryService == null) {
categoryService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(CategoryService.class);
}
return categoryService;
}
public SortProductService getSortProductService() {
if (sortProductService == null) {
sortProductService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(SortProductService.class);
}
return sortProductService;
}
public ProductDescribeService getProductDescribeService() {
if (null == productDescribeService) {
productDescribeService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(ProductDescribeService.class);
}
return productDescribeService;
}
public postProductService getPostProductService() {
if (null == mPostProductService) {
mPostProductService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(postProductService.class);
}
return mPostProductService;
}
public CartService getCartService() {
if (null == cartService) {
cartService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build().create(CartService.class);
}
return cartService;
}
public FindAllOrderService getFindAllOrderService() {
if (null == findAllOrderService) {
findAllOrderService = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(FindAllOrderService.class);
}
return findAllOrderService;
}
public updateInfoService getUpdateInfoService() {
if (null == updateInfoService) {
updateInfoService = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BASE_URL)
.build().create(updateInfoService.class);
}
return updateInfoService;
}
} | [
"122094709@qq.com"
] | 122094709@qq.com |
c81a513081897d6ca3e9358eedef2732dbb19434 | a48651f3b5eb86398c5f42be5c78775e9ccda668 | /Dhiva/moviecatalogue-sub2/app/src/main/java/id/dhiva/moviecatalogue/viewmodel/ViewModelFactory.java | 019f2d344fbbde5e226350afb1b799cc5ff18550 | [] | no_license | cikalT/Dicoding-Academies-129 | 1b795c24fe9cfc8b814d8096192a63913e08ccb6 | e6f093ef8aaccf5d0a7549aef753c3830215bfb0 | refs/heads/master | 2022-03-31T17:45:39.402255 | 2020-02-06T07:00:46 | 2020-02-06T07:00:46 | 237,137,109 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,835 | java | package id.dhiva.moviecatalogue.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import id.dhiva.moviecatalogue.data.DataRepository;
import id.dhiva.moviecatalogue.data.di.Injection;
import id.dhiva.moviecatalogue.ui.detail.DetailViewModel;
import id.dhiva.moviecatalogue.ui.movie.MovieViewModel;
import id.dhiva.moviecatalogue.ui.tv.TvViewModel;
public class ViewModelFactory extends ViewModelProvider.NewInstanceFactory {
private static volatile ViewModelFactory INSTANCE;
private final DataRepository dataRepository;
private ViewModelFactory(DataRepository dataRepository){
this.dataRepository = dataRepository;
}
public static ViewModelFactory getInstance(Application application) {
if (INSTANCE == null) {
synchronized (ViewModelFactory.class) {
if (INSTANCE == null) {
INSTANCE = new ViewModelFactory(Injection.provideRepository(application));
}
}
}
return INSTANCE;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
if (modelClass.isAssignableFrom(MovieViewModel.class)) {
//noinspection unchecked
return (T) new MovieViewModel(dataRepository);
} else if (modelClass.isAssignableFrom(DetailViewModel.class)) {
//noinspection unchecked
return (T) new DetailViewModel(dataRepository);
} else if (modelClass.isAssignableFrom(TvViewModel.class)) {
//noinspection unchecked
return (T) new TvViewModel(dataRepository);
}
throw new IllegalArgumentException("Unknown ViewModel class: " + modelClass.getName());
}
}
| [
"cikaltaruna@gmail.com"
] | cikaltaruna@gmail.com |
b0aa2f07604bbfaa37ddede72ef888b6cb9b7d93 | 38e9aad01b032c3160c17001b9e5b85b5a46b198 | /src/main/java/kz/kaps/resort/entrypoints/html/utils/Utils.java | 78a21dbae7d239430f2cd452084621e89c644563 | [] | no_license | happy-robot/resortcodedemo | 69c36e9a509d7fa5dc996933e78c8fd2e802fa1e | a34e470a8517d803b9e73bfef23c6c3cca31e33a | refs/heads/master | 2023-03-02T03:43:01.090610 | 2021-02-10T10:03:02 | 2021-02-10T10:03:02 | 337,303,228 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,393 | java | package kz.kaps.resort.entrypoints.html.utils;
import kz.kaps.resort.entrypoints.rest.landlord.*;
import org.springframework.hateoas.mvc.ControllerLinkBuilder;
import java.net.URI;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
public class Utils {
private Utils(){}
public static URI getUploadImageMethodURL(String adId){
ControllerLinkBuilder uploadImageLinkBuilder = ControllerLinkBuilder.linkTo(methodOn(ImageUploadRestEndPoint.class)
.upload(adId, null, null));
return uploadImageLinkBuilder.toUri();
}
public static URI getDeleteImageMethodURL(String adId){
ControllerLinkBuilder deleteImageLinkBuilder = ControllerLinkBuilder.linkTo(methodOn(ImageDeleteRestEndPoint.class)
.delete(adId, null, null));
return deleteImageLinkBuilder.toUri();
}
public static URI getImageListMethodURL(String adId){
ControllerLinkBuilder listImageLinkBuilder = ControllerLinkBuilder.linkTo(methodOn(ImageListRestEndPoint.class)
.getImages(adId, null));
return listImageLinkBuilder.toUri();
}
public static String getFileExtension(String fileName){
String extension = "";
int i = fileName.lastIndexOf('.');
if (i > 0) {
extension = fileName.substring(i+1);
}
return extension;
}
}
| [
"a.kapsatarov@kazdream.kz"
] | a.kapsatarov@kazdream.kz |
0c04dc100818b250926a0c226f604e2416ba9cbc | cafc89933f226c3175c98ebb3072c710bafe892a | /xedbxh/src/com/scder/utils/FileCurrentUp.java | e776930c7705badf89fd95b97e74740f69674026 | [] | no_license | givking/xedbxh | e28c8754f71e70bd250f971f6a3c6a090842b3e9 | 8f8610c6a01cc074873fb6f5d128a6e0575b5542 | refs/heads/master | 2021-10-02T19:13:08.348113 | 2018-11-30T09:09:14 | 2018-11-30T09:09:14 | 159,638,734 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,599 | java | package com.scder.utils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
public class FileCurrentUp {
public static void fileUpLoad(MultipartFile upfile,HttpServletRequest req) throws Exception{
String dir="document";
Object obj = req.getAttribute("dir");
if(obj!=null){
dir = dir+(String)obj;
}
String realfilepath=req.getSession().getServletContext().getRealPath("");
if(upfile.getOriginalFilename()!=null&&!upfile.getOriginalFilename().trim().equals("")){
String ftype=upfile.getOriginalFilename().substring(upfile.getOriginalFilename().lastIndexOf(".")+1);
String fname=upfile.getOriginalFilename().substring(0, upfile.getOriginalFilename().lastIndexOf("."));
String fpa=FileUpLoad.upLoadFile(upfile.getInputStream(), realfilepath, dir, AleTools.getFileName()+"."+ftype);
req.setAttribute("ftype", ftype);
req.setAttribute("fname", fname);
req.setAttribute("fpa", fpa);
req.setAttribute("realfpa", realfilepath+"\\"+fpa);
}
}
public static Boolean copyfile(String realpath,String oupath,String filename){
try{
File f= new File(realpath);
if(f.exists()){
File fo = new File(oupath);
if(!fo.exists()){
fo.mkdirs();
}
FileInputStream in = new FileInputStream(f);
FileOutputStream ou = new FileOutputStream(oupath+filename);
byte[] b = new byte[100];
int i= 0;
while((i=in.read())!=-1){
ou.write(i);
}
in.close();
ou.close();
}
return true;
}catch(Exception e){
e.printStackTrace();
}
return null;
}
/*下载文件*/
public static void downfile(String realpath,String filename,String filetype,HttpServletResponse response) throws Exception{
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
// String path = req.getSession().getServletContext().getRealPath("/")+"uploadFile";
filename= new String(filename.getBytes("utf-8"), "ISO8859-1" );
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("application/octet-stream;charset=UTF-8");
//2.设置文件头:最后一个参数是设置下载文件名(假如我们叫a.pdf)
response.setHeader("Content-Disposition", "attachment;fileName="+filename+"."+filetype);
ServletOutputStream out;
//通过文件路径获得File对象(假如此路径中有一个icon.png文件)
File file = new File(realpath);
try {
FileInputStream inputStream = new FileInputStream(file);
//3.通过response获取ServletOutputStream对象(out) 只能用一次
out = response.getOutputStream();
int b = 0;
byte[] buffer = new byte[512];
while (b != -1){
b = inputStream.read(buffer);
//4.写到输出流(out)中
if(b==-1) break;
out.write(buffer,0,b);
}
inputStream.close();
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/*文件删除*/
public static void delfile(String filename,String filepath){
File file = new File(filepath);
if(file.exists()){
file.delete();
}
}
}
| [
"125311899@qq.com"
] | 125311899@qq.com |
f28da289a5ea40e4cc9dd4d6e606157cd3316cc5 | 9b585e5702aafb7d6352ab11e8f62b1aea6674b4 | /src/main/java/es/upm/miw/rest_controllers/ArticleResource.java | 0db4ab9cbbd793d040e937cf2ed50fef9070278d | [] | no_license | tfm-microservicios/articleUniqueDBMicroserviceTFM | 6d28015616975635f2bfae19d642b893060ef074 | 9d9ca93270a5aa44bf332a02746968c2cc04f638 | refs/heads/master | 2020-06-03T04:09:15.226332 | 2019-06-18T12:42:06 | 2019-06-18T12:42:06 | 191,432,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,954 | java | package es.upm.miw.rest_controllers;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import es.upm.miw.business_controllers.ArticleController;
import es.upm.miw.dtos.ArticleDto;
import es.upm.miw.dtos.ArticleMinimumDto;
import es.upm.miw.dtos.ArticleSearchOutputDto;
@PreAuthorize("hasRole('ADMIN') or hasRole('MANAGER') or hasRole('OPERATOR')")
@RestController
@RequestMapping(ArticleResource.ARTICLES)
public class ArticleResource {
public static final String ARTICLES = "/articles";
public static final String CODE_ID = "/{code}";
public static final String MINIMUM = "/minimum";
public static final String SEARCH = "/search";
@Autowired
private ArticleController articleController;
@PostMapping
public ArticleDto createArticle(@Valid @RequestBody ArticleDto articleDto) {
return this.articleController.createArticle(articleDto);
}
@GetMapping
public List<ArticleSearchOutputDto> readAll() {
return this.articleController.readAll();
}
@GetMapping(value = CODE_ID)
public ArticleDto readArticle(@PathVariable String code) {
return this.articleController.readArticle(code);
}
@GetMapping(value = MINIMUM)
public List<ArticleMinimumDto> readArticlesMinimum() {
return this.articleController.readArticlesMinimum();
}
} | [
"jd.liriano@alumnos.upm.es"
] | jd.liriano@alumnos.upm.es |
e57a49fc26a9607d269a054d4f92cf003541b4cf | 9c47cbe036a6a15d9b37687bb8587aa40fb96d98 | /Baekjoon10250.java | 2ff0381055a1423694ed5e0d6a67663568ebc42f | [] | no_license | junwoochoi/Algorithms | d5df35f9c30c29516f756d7cca6f7b81df0f86b6 | 21c31c0ab72e84f56905860d02d4d05a3c101439 | refs/heads/master | 2020-04-14T04:54:08.939544 | 2019-05-29T02:10:25 | 2019-05-29T02:10:25 | 163,648,519 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | package Algorithms;
import java.util.Scanner;
/**
* https://www.acmicpc.net/problem/10250
* 백준 10250번 ACM호텔
*/
public class Baekjoon10250 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int testCase = Integer.parseInt(sc.nextLine());
while (testCase-- > 0) {
solution(sc.nextInt(), sc.nextInt(), sc.nextInt());
}
}
private static void solution(int H, int W, int N) {
int n = 0;
int floor = 0;
int number = 0;
for (int i = 1; i <= W ; i++) {
for (int j = 1; j <= H; j++) {
n++;
if(n==N) {
floor = j;
number = i;
}
}
}
StringBuilder sb = new StringBuilder();
sb.append(floor);
if (number < 10) {
sb.append(0);
}
sb.append(number);
System.out.println(sb.toString());
}
}
| [
"cjw4690@gmail.com"
] | cjw4690@gmail.com |
5f3412f30ab3f5605820d0f9fbf6c2bc8c11777e | 1d72a0f3ff74260609e627785cb984ce56615d81 | /InheritanceChallenge/src/Bartosz/wieczorek/Car.java | c396e659b0717af81ebeade00642370b0a5d0f6c | [] | no_license | Morksil/Java-Courses-Udemy- | 46bab2f9339e6ccb7250fbfc16885a3804eaec5a | 92b13b3e5cd8718ab9b7affe8592406cf07f136e | refs/heads/master | 2020-03-17T14:48:31.180234 | 2018-05-22T17:51:46 | 2018-05-22T17:51:46 | 133,686,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 569 | java | package Bartosz.wieczorek;
public class Car extends Vehicle {
private String gear;
private int seats;
public Car( int windows, int doors, int lights, String gear, int seats) {
super(4, 1, windows, doors, lights);
this.gear = gear;
this.seats = seats;
}
public String getGear() {
return gear;
}
public int getSeats() {
return seats;
}
public void ride(int speed) {
System.out.println("Car is moving at speed: " + speed);
super.move(speed);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
a02ec11679b6a2a46b5c1464bd44a74ddd67435d | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.minihd.qq/assets/exlibs.1.jar/classes.jar/kap.java | c8df3964bd64c8149d04c1d918268a10bc2df9e3 | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 8,556 | java | import android.os.SystemClock;
import com.tencent.mobileqq.highway.api.ITransactionCallback;
import com.tencent.mobileqq.transfile.BaseTransProcessor.StepInfo;
import com.tencent.mobileqq.transfile.FileMsg;
import com.tencent.mobileqq.transfile.NearbyPeoplePhotoUploadProcessor;
import com.tencent.mobileqq.transfile.TransferRequest;
import com.tencent.qphone.base.util.QLog;
import java.nio.ByteBuffer;
import java.util.HashMap;
public class kap
implements ITransactionCallback
{
public kap(NearbyPeoplePhotoUploadProcessor paramNearbyPeoplePhotoUploadProcessor, long paramLong) {}
public void onFailed(int paramInt, byte[] paramArrayOfByte, HashMap paramHashMap)
{
long l1 = SystemClock.uptimeMillis();
long l2 = Long.valueOf((String)paramHashMap.get("upFlow_WiFi")).longValue();
long l3 = Long.valueOf((String)paramHashMap.get("dwFlow_WiFi")).longValue();
long l4 = Long.valueOf((String)paramHashMap.get("upFlow_Xg")).longValue();
long l5 = Long.valueOf((String)paramHashMap.get("dwFlow_Xg")).longValue();
paramArrayOfByte = (String)paramHashMap.get("tc_p:");
String str1 = (String)paramHashMap.get("rep_bdhTrans");
String str2 = (String)paramHashMap.get("segspercnt");
String str3 = (String)paramHashMap.get("param_conf_segSize");
String str4 = (String)paramHashMap.get("param_conf_segNum");
paramHashMap = (String)paramHashMap.get("param_conf_connNum");
if (QLog.isColorLevel()) {
QLog.d("NearbyPeoplePhotoUploadProcessor", 2, "<BDH_LOG> Transaction End : Failed. New : SendTotalCost:" + (l1 - this.jdField_a_of_type_Long) + "ms");
}
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("X-piccachetime", paramArrayOfByte);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_BdhTrans", str1);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_segspercnt", str2);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_segSize", str3);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_segNum", str4);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_connNum", paramHashMap);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.a(l2, l3, l4, l5);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.a(paramInt, "OnFailed.", "", this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.b);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.d();
}
public void onSuccess(byte[] paramArrayOfByte, HashMap paramHashMap)
{
long l1 = SystemClock.uptimeMillis();
long l2 = Long.valueOf((String)paramHashMap.get("upFlow_WiFi")).longValue();
long l3 = Long.valueOf((String)paramHashMap.get("dwFlow_WiFi")).longValue();
long l4 = Long.valueOf((String)paramHashMap.get("upFlow_Xg")).longValue();
long l5 = Long.valueOf((String)paramHashMap.get("dwFlow_Xg")).longValue();
String str1 = (String)paramHashMap.get("tc_p:");
String str2 = (String)paramHashMap.get("rep_bdhTrans");
String str3 = (String)paramHashMap.get("segspercnt");
String str4 = (String)paramHashMap.get("param_conf_segSize");
String str5 = (String)paramHashMap.get("param_conf_segNum");
paramHashMap = (String)paramHashMap.get("param_conf_connNum");
if (QLog.isColorLevel()) {
QLog.d("NearbyPeoplePhotoUploadProcessor", 2, "<BDH_LOG> Transaction End : Success. New : SendTotalCost:" + (l1 - this.jdField_a_of_type_Long) + "ms ,fileSize:" + this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_ComTencentMobileqqTransfileFileMsg.jdField_a_of_type_Long + " transInfo:" + str2);
}
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("X-piccachetime", str1);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_BdhTrans", str2);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_segspercnt", str3);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_segSize", str4);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_segNum", str5);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_JavaUtilHashMap.put("param_conf_connNum", paramHashMap);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.b.b();
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.b.a = 1;
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.h = this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_Long;
paramHashMap = ByteBuffer.wrap(paramArrayOfByte);
int i = paramHashMap.get();
if (QLog.isColorLevel()) {
QLog.d("NearbyPeoplePhotoUploadProcessor", 2, "NearbyPeoplePhotoUploadProcessor.ITransactionCallback.onSuccess(), business result code = " + i);
}
if (i == 0)
{
int j = 1;
i = j;
if (this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_ComTencentMobileqqTransfileTransferRequest.b == 8) {
paramArrayOfByte = new String(paramArrayOfByte, 2, paramHashMap.get());
}
try
{
NearbyPeoplePhotoUploadProcessor.aP = Integer.parseInt(paramArrayOfByte);
i = j;
}
catch (NumberFormatException paramArrayOfByte)
{
for (;;)
{
if (QLog.isDevelopLevel()) {
QLog.w("NearbyPeoplePhotoUploadProcessor", 4, paramArrayOfByte.getMessage());
}
i = 0;
continue;
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.d();
}
}
if (i != 0) {
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.e();
}
}
for (;;)
{
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.a(l2, l3, l4, l5);
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_ComTencentMobileqqTransfileFileMsg.b();
return;
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.d();
}
}
public void onSwitch2BackupChannel() {}
public void onTransStart()
{
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.c("<BDH_LOG> onTransStart()");
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.b.a();
}
public void onUpdateProgress(int paramInt)
{
NearbyPeoplePhotoUploadProcessor localNearbyPeoplePhotoUploadProcessor = this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor;
FileMsg localFileMsg = this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_ComTencentMobileqqTransfileFileMsg;
long l = paramInt;
localFileMsg.e = l;
localNearbyPeoplePhotoUploadProcessor.h = l;
if ((paramInt < this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.jdField_a_of_type_Long) && (!this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.i) && (!this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.e)) {
this.jdField_a_of_type_ComTencentMobileqqTransfileNearbyPeoplePhotoUploadProcessor.f();
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.minihd.qq\assets\exlibs.1.jar\classes.jar
* Qualified Name: kap
* JD-Core Version: 0.7.0.1
*/ | [
"98632993+tsuzcx@users.noreply.github.com"
] | 98632993+tsuzcx@users.noreply.github.com |
5ea1ee3d1885053653d7b3dc5622be003461e3d0 | a2d16082a387f6e80c81e5bb32e7fec3bb825d0e | /En01EnumDayApp/src/com/mahmud/En01EnumDayAppPackage/classes/EnumTest.java | 88c83f91226fe3f4ae54432cd3ac7b07ed6210c6 | [] | no_license | csemahmud/Java_SE | 7ab11fb9591b1c4c9fc29af548f20614a362023a | b4047dafb1201cf77521e7f0646915718dbef80d | refs/heads/master | 2021-01-19T03:59:19.907566 | 2017-04-05T18:40:17 | 2017-04-05T18:40:17 | 87,342,760 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | java | /**
*
*/
package com.mahmud.En01EnumDayAppPackage.classes;
/**
* @author Mahmudul Hasan Khan CSE
*
*/
public class EnumTest {
/**
* @author Mahmudul Hasan Khan CSE
*
*/
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
private final Day day;
/**
* @param day
*/
public EnumTest(Day day) {
this.day = day;
}
/**
*
*/
public EnumTest() {
// TODO Auto-generated constructor stub
this(null);
}
public void tellItLikeItIs() {
try{
switch (day) {
case MONDAY:
System.out.println("\tMondays are bad.");
break;
case FRIDAY:
System.out.println("\tFridays are better.");
break;
case SATURDAY: case SUNDAY:
System.out.println("\tWeekends are best.");
break;
default:
System.out.println("\tMidweek days are so-so.");
break;
}
} catch (NullPointerException ex) {
// TODO: handle exception
System.err.println("\t" + ex + " : " + ex.getMessage());
}
}
}
| [
"cse.mahmudul@gmail.com"
] | cse.mahmudul@gmail.com |
540fd07dac1e516e19921f26a538dc14149b951d | f93780122205be3a1daabc92d22d06b19377bb33 | /src/main/java/com/wolf/course/repositories/OrderItemRepository.java | e1f6b196aef9f6b9ad9dab222481a54a54ce3195 | [] | no_license | mlobo-dev/course-springboot-2-java-11 | 096072c7cb0e664eb309e755c297aa6893c4552a | 609ac9e032bf0f372701f1909416e555d0e9524e | refs/heads/master | 2020-09-07T15:32:38.142038 | 2019-11-15T15:29:12 | 2019-11-15T15:29:12 | 220,828,361 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 226 | java | package com.wolf.course.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import com.wolf.course.entities.OrderItem;
public interface OrderItemRepository extends JpaRepository<OrderItem, Long>{
}
| [
"mlobo.dev@gmail.com"
] | mlobo.dev@gmail.com |
f6c6d327c8fccdba32528f90cb8a0928b0c01c86 | b0de5f0df6b53f0938252433537a0ed0d85db531 | /Str.java | 1cbba5cb885081cbf94de27b773f22482c6c22c6 | [] | no_license | ayush04sep/java-programs | 92b484906d294954a846680bab65b04780b5c166 | e04bb2778e5491d6c0a84daf956d3ee80faa89b0 | refs/heads/master | 2020-08-05T00:56:00.513866 | 2016-09-17T05:08:02 | 2016-09-17T05:08:02 | 66,964,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 371 | java | import java.io.*;
class Str
{
public static void main(String []ar)throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter any string- yes or no");
String s=br.readLine();
switch(s)
{
case "yes": {System.out.println("choice: yes");
break;}
case "no": System.out.println("choice : no");
}
}
} | [
"noreply@github.com"
] | noreply@github.com |
65e19b8ceb4357c993b2147bf9596ce7645d7a26 | 3279a6d291f5be5eb036160d5ee8ba338aae8cf1 | /src/java/CSDL/tbsanpham.java | fe8ae263872458c578df67f5158e3de3982dcab7 | [] | no_license | HoangKimToi/Webbanhang | dea1a1b0df061c46e922d228c56fadcdda0412eb | 7f0ac68d8700b76a97bf386e10426f2cbbd895d5 | refs/heads/master | 2020-08-30T19:40:57.175861 | 2019-10-30T08:05:25 | 2019-10-30T08:05:25 | 218,471,462 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,075 | 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 CSDL;
import Models.clsSanpham;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Hoàng Kim Tới
*/
public class tbsanpham {
public Vector<clsSanpham> LayDSSP() {
Vector<clsSanpham> dssp = new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if (cnn != null) {
String sql = "SELECT * FROM tbsanpham";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while (rs.next()) {
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setSukien(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dssp.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
public Vector<clsSanpham> SP(int masp)
{
Vector<clsSanpham> dssp= new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if(cnn!=null)
{
String sql = "SELECT * FROM tbsanpham where masp='"+masp+"'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while(rs.next())
{
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setSukien(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dssp.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
public Vector<clsSanpham> SPNew(String sukien)
{
Vector<clsSanpham> dssp= new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if(cnn!=null)
{
String sql = "SELECT * FROM tbsanpham where sukien='"+sukien+"'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while(rs.next())
{
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setSukien(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dssp.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
public Vector<clsSanpham> LayPK(int mapk)
{
Vector<clsSanpham> dssp= new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if(cnn!=null)
{
String sql = "SELECT * FROM tbsanpham where mapk='"+mapk+"'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while(rs.next())
{
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setSukien(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dssp.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
public clsSanpham LaySP(int masp) {
clsSanpham dssp = new clsSanpham();
Connection cnn = Database.KetnoiCSDL();
if (cnn != null) {
String sql = "SELECT * FROM tbsanpham where masp='" + masp + "'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while (rs.next()) {
//clsSanpham dssp = new clsSanpham();
dssp.setMasp(rs.getInt("masp"));
dssp.setTensp(rs.getString("tensp"));
dssp.setGia(rs.getDouble("gia"));
dssp.setAnh(rs.getString("anh"));
dssp.setGioithieu(rs.getString("gioithieu"));
dssp.setSukien(rs.getString("sukien"));
dssp.setMaPK(rs.getInt("mapk"));
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
public int ThemSP(clsSanpham sp) {
Connection cnn = Database.KetnoiCSDL();
if (cnn == null) {
return -1;
} else {
String sql = "INSERT INTO tbsanpham VALUES(?,?,?,?,?,?,?)";
try {
PreparedStatement stm = cnn.prepareStatement(sql);
stm.setInt(1, sp.getMasp());
stm.setString(2, sp.getTensp());
stm.setDouble(3, sp.getGia());
stm.setString(4, sp.getAnh());
stm.setString(5, sp.getGioithieu());
stm.setString(6, sp.getSukien());
stm.setInt(7, sp.getMaPK());
int n = stm.executeUpdate();
if (n <= 0) {
return 0;
} else {
return 1;
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
return 0;
}
}
}
public int XoaSP(int masp) {
Connection cnn = Database.KetnoiCSDL();
if (cnn == null) {
return -1;
}else
{
String sql = "DELETE FROM tbsanpham WHERE masp=?";
try {
PreparedStatement stm = cnn.prepareStatement(sql);
stm.setInt(1, masp);
int n = stm.executeUpdate();
if (n <= 0) {
return 0;
} else {
return 1;
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
return 0;
}
}
}
public int SuaSP(clsSanpham sp) {
Connection cnn = Database.KetnoiCSDL();
if (cnn == null) {
return -1;
} else {
String sql
= "UPDATE tbsanpham SET tensp=?,gia=?,anh=?,gioithieu=?,sukien=?,mapk=? WHERE masp=?";
try {
PreparedStatement stm = cnn.prepareStatement(sql);
stm.setString(1, sp.getTensp());
stm.setDouble(2, sp.getGia());
stm.setString(3, sp.getAnh());
stm.setString(4, sp.getGioithieu());
stm.setString(5, sp.getSukien());
stm.setInt(6, sp.getMaPK());
stm.setInt(7, sp.getMasp());
int n = stm.executeUpdate();
if (n <= 0) {
return 0;
} else {
return 1;
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
return 0;
}
}
}
public Vector<clsSanpham> TimKiemSP(String ten) {
Vector<clsSanpham> dsSP = new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if (cnn != null) {
String sql = "SELECT * FROM tbsanpham WHERE tensp like '%" + ten + "%'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while (rs.next())//duyệt từng bản ghi kết quả select
{
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setGioithieu(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dsSP.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dsSP;
}
//Lấy danh sách sản phẩm phân trang
public Vector<clsSanpham> getListProductByNav(int mapk, int firstResult,int maxResult){
Vector<clsSanpham> dssp= new Vector<clsSanpham>();
Connection cnn = Database.KetnoiCSDL();
if (cnn != null) {
String sql = "SELECT * FROM tbsanpham where mapk='" + mapk + "' limit ?,?";
try {
PreparedStatement ps = cnn.prepareCall(sql);
ps.setInt(1, firstResult);
ps.setInt(2, maxResult);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
clsSanpham sp = new clsSanpham();
sp.setMasp(rs.getInt("masp"));
sp.setTensp(rs.getString("tensp"));
sp.setGia(rs.getDouble("gia"));
sp.setAnh(rs.getString("anh"));
sp.setGioithieu(rs.getString("gioithieu"));
sp.setSukien(rs.getString("sukien"));
sp.setMaPK(rs.getInt("mapk"));
dssp.add(sp);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return dssp;
}
//Tính tổng sản phẩm
public int countProductCategory(int mapk){
Connection cnn = Database.KetnoiCSDL();
int count = 0;
if (cnn != null) {
String sql = "SELECT count(masp) FROM tbsanpham where mapk='" + mapk + "'";
try {
Statement stm = cnn.createStatement();
ResultSet rs = stm.executeQuery(sql);
while (rs.next()) {
count = rs.getInt(1);
}
} catch (SQLException ex) {
Logger.getLogger(tbsanpham.class.getName()).log(Level.SEVERE, null, ex);
}
}
return count;
}
// public static void main(String[] args) {
// tbsanpham sp = new tbsanpham();
// System.out.println(sp.getListProductByNav(0,8,19));
// }
}
| [
"="
] | = |
cdd3ed6fe7183fbfc29e9e228562e5f6460d9945 | d84d0d585598b1147bfae15f067339ea36e367c5 | /pfb_subsysmt_biz/src/main/java/com/pfb/biz/vo/outer/refundquery/OuterRefundDetailResponse.java | 319779578f26cb0114627945142d16d803ac9f23 | [] | no_license | hxdcts/subsysmt_test | 6537b5cb3fdd17b7059e220a309297d47b66ce0b | ce8ecd0b97579119066de6eee91b54c2cc10a85b | refs/heads/master | 2018-12-25T04:03:02.404074 | 2018-10-22T01:46:22 | 2018-10-22T01:46:22 | 114,979,031 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 812 | java | package com.pfb.biz.vo.outer.refundquery;
import com.pfb.biz.vo.base.OuterResponseBase;
@SuppressWarnings("serial")
public class OuterRefundDetailResponse extends OuterResponseBase {
/**
* 平台退款单号
*/
private String refundNum;
/**
* 申请退款金额
*/
private String refundFee;
/**
* 退款状态
*/
private String refundStatus;
public String getRefundNum() {
return refundNum;
}
public void setRefundNum(String refundNum) {
this.refundNum = refundNum;
}
public String getRefundFee() {
return refundFee;
}
public void setRefundFee(String refundFee) {
this.refundFee = refundFee;
}
public String getRefundStatus() {
return refundStatus;
}
public void setRefundStatus(String refundStatus) {
this.refundStatus = refundStatus;
}
}
| [
"caotieshuan1986@163.com"
] | caotieshuan1986@163.com |
7d8697fa5fb0ef96c016ff0b8942e229a58af60e | 6f1a7f872eb5661c9069100f3f27fed9b7fe8139 | /DesignPatterns/TemplateDesignPattern/src/TemplateDesignPatternDemo.java | 27a74076029e373f982b16824f1c45dc37908764 | [] | no_license | manvigupta1987/Java-Programs | 321e2d0803350d2ef35ac0badedd9ef7dd34da1b | 01cbc5e46d9f95353f5cb5af65545b11cf15e18c | refs/heads/master | 2020-12-02T10:10:23.412112 | 2017-08-22T10:17:54 | 2017-08-22T10:17:54 | 96,696,888 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 711 | java | /** Template design pattern defines the sequence of algorithm. Child class can override the
* implementation of the steps but it can not change the sequence. So, parent class is a abstract clas
* with methods and child class provides implementation of them.
* Here, we have to two games (child class) cricket and football. The sequence to play the game is
* decided by abstract class game (Parent class). The sequence can not be changed hence we have made the play
* method as final.
* @author manvi
*
*/
public class TemplateDesignPatternDemo {
public static void main(String[] args) {
Game game = new Cricket();
game.play();
Game football = new Football();
football.play();
}
}
| [
"manvigupta1987@gmail.com"
] | manvigupta1987@gmail.com |
ec56ca4cb0230ad1350509defb42f73c5954e5d2 | 0f8cad4d956ee67bfdc0351032b5846f70d448d1 | /hybridframework/src/main/java/com/qspiders/hybridframework/App.java | a1b303b175e04923eb84112703452d29689a2678 | [] | no_license | chandraqspiders/webdriverproject | 4e419af710e8f9ccbf2eff86390aac1d5e1d1957 | f1033b8dced3ca18f8b5179714110e8a5da936d1 | refs/heads/master | 2020-05-03T13:00:12.196795 | 2013-11-21T06:43:01 | 2013-11-21T06:43:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 191 | java | package com.qspiders.hybridframework;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| [
"chandrashekar.kn@3icube.com"
] | chandrashekar.kn@3icube.com |
17565c11d72d9e1df0753ec915114af7a25f4337 | 48823af9002516e9f8e033c30dffe399d5f1e218 | /src/Chp1Integer2BinaryString.java | e64d6356a0fc2110641600c64a6a9bbb4d0ea984 | [] | no_license | ChuishiMeng/SolutionAlgorithms | f0da4d8e870680531880b426d798d2b00e58405e | 3b33296aad5ca11a9f66ca902bb35ac2cb5262cb | refs/heads/master | 2021-05-27T07:28:58.972957 | 2014-04-24T23:18:03 | 2014-04-24T23:18:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 471 | java |
public class Chp1Integer2BinaryString {
public static void main(String[] args) {
// TODO Auto-generated method stub
Chp1Integer2BinaryString i2s = new Chp1Integer2BinaryString();
System.out.printf("%8s%8s\n","Number","Binary");
for(int i=0; i<8;i++){
System.out.printf("%8d%8s\n", i, i2s.toBinaryString(i));
}
}
public String toBinaryString(int N){
String s = "";
for(int i=N; i>0; i/=2){
s = i%2 + s;
}
return s;
}
}
| [
"chuishimeng@gmail.com"
] | chuishimeng@gmail.com |
a726131b09d6380ab98bc3a123d8c68aca7c0a63 | cc9583cef334b5252883ad53dc60455b6ff143a5 | /Echecs/src/View/EchecTextual.java | 095babc68638d6ed576435f4bcc5d91d3a979da7 | [] | no_license | Statyfix/echecs | 970c0336d77c5bd49072143ebe0b742e30e226fa | 4061c1d98d69d9e026abac61667a35960a5573c9 | refs/heads/master | 2021-09-07T10:10:26.599536 | 2018-02-21T13:19:08 | 2018-02-21T13:19:08 | 117,549,643 | 0 | 0 | null | 2018-01-17T13:04:38 | 2018-01-15T13:35:03 | Java | UTF-8 | Java | false | false | 1,619 | 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 View;
import Class.Case;
import Class.Echiquier;
import Class.Piece;
import Controller.EchecController;
/**
*
* @author UTILISATEUR
*/
public class EchecTextual implements Observateur {
private final EchecController echec_c;
private final char rangee[] = {'8', '7', '6', '5', '4', '3', '2', '1'};
private final char colonne[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'};
public EchecTextual(EchecController _echec_c) {
this.echec_c = _echec_c;
}
@Override
public void avertirMajEchiquier(Echiquier echiquier) {
}
@Override
public void avertirFinPartie() {
System.out.println("Echec et Mat !");
}
@Override
public void avertirEnDeplacement(Case caseEnDeplacement) {
}
@Override
public void avertirDeplacementsPossible(boolean[][] deplacementsPossible) {
}
@Override
public void avertirEffacerDeplacementsPossible() {
}
@Override
public void avertir(Case caseReferente) {
Piece piece = caseReferente.getPiece();
System.out.println(piece.getNom() + " "
+ (piece.getCouleur() == 0 ? "blanc" : "noir") + " en "
+ colonne[caseReferente.getColonne()]
+ rangee[caseReferente.getRangee()]);
}
@Override
public void avertirEchec() {
System.out.println("Echec !");
}
}
| [
"UTILISATEUR@DESKTOP-7V2EF54.home"
] | UTILISATEUR@DESKTOP-7V2EF54.home |
587009f6e555ef91f882b70e569aa19f60ea0e35 | dd57154bafcd8a358b93a2ca93bb4af98491ab47 | /plugins/src/main/java/com/game/qs/process/impl/UploadPackageService.java | 7958f4c35b6c8dd3bde55e442e1d024967df9003 | [
"Apache-2.0"
] | permissive | zunzhuowei/auto-deploy-maven-plugin | 4a49d7d9cd4db2268d8a695d33ac015d144a86b4 | b484adf60fa9bd5a7c2a42565dcf9fff14489d6a | refs/heads/master | 2022-12-30T15:45:54.418226 | 2019-07-05T07:17:11 | 2019-07-05T07:17:11 | 195,347,108 | 0 | 0 | Apache-2.0 | 2022-12-14T20:35:00 | 2019-07-05T05:55:22 | Java | UTF-8 | Java | false | false | 3,539 | java | package com.game.qs.process.impl;
import com.game.qs.process.IUploadPackageService;
import com.game.qs.sh.SftpConnect;
import com.game.qs.yaml.AppPackage;
import com.game.qs.yaml.Deploy;
import com.game.qs.yaml.Server;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* Created by zun.wei on 2019/5/18 17:53.
* Description:
*/
public class UploadPackageService implements IUploadPackageService {
@Override
public void uploadApps(Deploy deploy) {
List<AppPackage> appPackages = deploy.getUploadPackages();
if (Objects.isNull(appPackages)) {
System.out.println("upload application cfg not config!");
return;
}
List<Server> servers = deploy.getServers();
if (Objects.isNull(servers) || servers.isEmpty()) {
System.out.println("servers not config, can't backups remote server application!");
return;
}
appPackages.forEach(appPackage -> {
String serverId = appPackage.getServerId();
String localPackagePath = appPackage.getLocalPackagePath();
String remoteDest = appPackage.getRemoteDest();
String packageName = appPackage.getPackageName();
if (StringUtils.isNotBlank(serverId)
&& StringUtils.isNotBlank(localPackagePath)
&& StringUtils.isNotBlank(packageName)
&& StringUtils.isNotBlank(remoteDest)) {
// 获取配置的与备份配置的serverId 匹配的server
Optional<Server> optionalServer = servers.stream()
.filter(e -> StringUtils.equalsIgnoreCase(e.getId(), serverId)).findFirst();
optionalServer.ifPresent(server -> {
String serverHost = server.getHost();
int serverPort = server.getPort();
String serverUserName = server.getUserName();
String serverPassWord = server.getPassWord();
if (StringUtils.isBlank(serverHost)
|| (StringUtils.isBlank(serverUserName)
|| (StringUtils.isBlank(serverPassWord)))) {
System.out.println("server config error2 !");
return;
}
// 创建连接
SftpConnect sftpConnect = new SftpConnect(serverUserName, serverPassWord, serverHost, serverPort);
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(new File(localPackagePath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// 上传文件
sftpConnect.upLoadFile(remoteDest, packageName, fileInputStream);
if (Objects.nonNull(fileInputStream)) {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
sftpConnect.disconnect();
System.out.println("uploadApps complete !");
});
}
});
}
}
| [
"1808862723@qq.com"
] | 1808862723@qq.com |
a916f499f0c341944ed78a8c5793b08b02fa21a0 | 1e8f96bae9938ed2dc2c6d6684d52f255362c3f6 | /SeamCarving.java | 3952e782a9bd1a2c839cfff6497aaa301dbde39d | [] | no_license | tripleooo21/graphicsEx1 | a2a198b39710a756479745fb77e1c845cb755ac6 | 4d51d9998bce3a965b0299f2dc3f23eee9d4c3e9 | refs/heads/master | 2021-01-19T08:30:40.759281 | 2017-04-08T14:10:56 | 2017-04-08T14:10:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,163 | java | import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class SeamCarving {
public static double[][] computeEnergy(BufferedImage img) {
int h = img.getHeight();
int w = img.getWidth();
double sumNeighbors;
double numOfNeighbors;
Color selfColor;
double[][] energyMat = new double[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
sumNeighbors = 0;
Pixel p = new Pixel(i, j);
List<Pixel> neighborsList = p.getNeighbors(w, h);
numOfNeighbors = neighborsList.size();
selfColor = new Color(img.getRGB(j, i));
while (neighborsList.size() > 0) {
Pixel neighbor = neighborsList.remove(0);
Color colorNeighbor = new Color(img.getRGB(neighbor.getY(), neighbor.getX()));
sumNeighbors += (Math.abs(colorNeighbor.getRed() - selfColor.getRed())
+ Math.abs(colorNeighbor.getBlue() - selfColor.getBlue())
+ Math.abs(colorNeighbor.getGreen() - selfColor.getGreen())) / 3;
}
energyMat[i][j] = sumNeighbors / numOfNeighbors; //normalizing
}
}
return energyMat;
}
public static double[][] computeEntropy(BufferedImage img) {
int h = img.getHeight();
int w = img.getWidth();
double[][] entropyMat = new double[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
Pixel p = new Pixel(i, j);
List<Pixel> pixelsList = p.getEnthropyMembers(w, h);
int sumGrey = 0;
Iterator<Pixel> it = pixelsList.iterator();
while (it.hasNext()) {
Pixel pGrey = it.next();
Color colorNeighbor = new Color(img.getRGB(pGrey.getY(), pGrey.getX()));
sumGrey += getGrayFromRGB(colorNeighbor);
}
it = pixelsList.iterator();
double H = 0;
while (it.hasNext()) {
Pixel neighbor = it.next();
Color colorNeighbor = new Color(img.getRGB(neighbor.getY(), neighbor.getX()));
double P_mn = getGrayFromRGB(colorNeighbor) / sumGrey;
H -= (P_mn * Math.log(P_mn));
}
entropyMat[i][j] = H;
}
}
return entropyMat;
}
public static double getGrayFromRGB(Color c) {
return (c.getBlue() + c.getGreen() + c.getRed()) / 3;
}
public static double[][] transposeMat(double[][] mat) {
int h = mat.length;
int w = mat[1].length;
double[][] res = new double[w][h];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
res[j][i] = mat[i][j];
}
}
return res;
}
public static int straightSeam(double[][] energyMat) {
int h = energyMat.length;
int w = energyMat[1].length;
int indexSeam = -1; // index for the seam colum
double minSum = Double.POSITIVE_INFINITY, tempSum = 0;
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++)
tempSum += energyMat[i][j];
if (tempSum < minSum) {
minSum = tempSum;
indexSeam = j;
}
tempSum = 0;
}
return indexSeam;
}
public static double[][] dynamicEnergyMat(double[][] energyMat) {
int h = energyMat.length;
int w = energyMat[1].length;
for (int i = 1; i < h; i++) {
for (int j = 0; j < w; j++) {
double leftNeighbor = (j == 0) ? Double.POSITIVE_INFINITY : energyMat[i - 1][j - 1];
double rightNeighbor = (j == w - 1) ? Double.POSITIVE_INFINITY : energyMat[i - 1][j + 1];
energyMat[i][j] = energyMat[i][j]
+ Math.min(leftNeighbor, Math.min(energyMat[i - 1][j], rightNeighbor));
}
}
return energyMat;
}
public static List<Pixel> pickNextSeam(double[][] dynamicMat) {
int h = dynamicMat.length;
int w = dynamicMat[1].length;
int minIndex = -1;
double minLastRow = Double.POSITIVE_INFINITY;
List<Pixel> pixelsList = new ArrayList<>();
// find the minimum in the last line
for (int j = 0; j < w; j++) {
if (dynamicMat[h - 1][j] < minLastRow) {
minLastRow = dynamicMat[h - 1][j];
minIndex = j;
}
}
pixelsList.add(new Pixel(h - 1, minIndex));
int curr = minIndex;
for (int i = h - 1; i > 0; i--) {
double leftNeighbor = (curr == 0) ? Double.POSITIVE_INFINITY : dynamicMat[i - 1][curr - 1];
double rightNeighbor = (curr == w - 1) ? Double.POSITIVE_INFINITY : dynamicMat[i - 1][curr + 1];
double nextMinPixel = Math.min(leftNeighbor, Math.min(dynamicMat[i - 1][curr], rightNeighbor));
if (nextMinPixel == dynamicMat[i - 1][curr - 1])
curr--;
else if (nextMinPixel == dynamicMat[i - 1][curr + 1])
curr++;
pixelsList.add(new Pixel(i - 1, curr));
}
return pixelsList;
}
public static double[][] computeEnergyFromImage(BufferedImage img, EnergyTypes type) {
int w = img.getWidth();
int h = img.getHeight();
double[][] combinedMat = new double[h][w];
double[][] energyMat = computeEnergy(img);
if (type == EnergyTypes.REGULAR)
return computeEnergy(img);
else {
if (type == EnergyTypes.ENTROPY) {
double[][] entropyMat = computeEntropy(img);
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
combinedMat[i][j] = energyMat[i][j] + 3 * entropyMat[i][j];
}
}
} else {
// return forward;
}
}
return combinedMat;
}
public static void saveImage(String path, BufferedImage inputImg) {
try {
ImageIO.write(inputImg, "png", new File(path));
} catch (IOException e) {
System.out.println("Error in saving file: " + e.getMessage());
}
}
public static BufferedImage deepCopy(BufferedImage img) {
ColorModel cm = img.getColorModel();
boolean isAlpha = cm.isAlphaPremultiplied();
WritableRaster raster = img.copyData(null);
return new BufferedImage(cm, raster, isAlpha, null);
}
public enum EnergyTypes {
REGULAR, FORWARD, ENTROPY
}
// TODO removeSeamFromImage
// TODO addSeamFromImage
// TODO forward
}
| [
"noreply@github.com"
] | noreply@github.com |
dc1de957e78357322fe7449481b1ef0520f551a4 | b4e4ab3fdaf818b8a48fe945391ae1be74b4008f | /source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientSettings.java | 9c4fa89fd505c424340f746d8f622952187b3c8a | [
"Apache-2.0"
] | permissive | Spark3122/jdchain | 78ef86ffdec066a1514c3152b35a42955fa2866d | 3378c0321b2fcffa5b91eb9739001784751742c5 | refs/heads/master | 2020-07-27T20:27:35.258501 | 2019-09-04T17:51:15 | 2019-09-04T17:51:15 | 209,207,377 | 1 | 0 | Apache-2.0 | 2019-09-18T03:17:36 | 2019-09-18T03:17:36 | null | UTF-8 | Java | false | false | 507 | java | package com.jd.blockchain.consensus.client;
import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.PubKey;
/**
* 共识客户端的配置参数;
*
* @author huanghaiquan
*
*/
public interface ClientSettings {
/**
* 客户端ID;
*
* @return
*/
int getClientId();
/**
* 客户端的公钥;
*
* @return
*/
PubKey getClientPubKey();
/**
* 共识网络的配置参数;
*
* @return
*/
ConsensusSettings getConsensusSettings();
}
| [
"huanghaiquan@jd.com"
] | huanghaiquan@jd.com |
8d398ed4085db60928c059c0bf4987f44b26fdd5 | b236acdc22137b7260639b468c3945758eeae27f | /app/src/main/java/com/ilham/mp_produk/MainActivity.java | 475f9e75491e30be36153273fc8397df23b95631 | [] | no_license | commitunuja/riset-api-produk | f5dce6e2e339beb20a313dafb381ae3f62030dd6 | 1a0da09bd11c4e80bfc49b3bd0b82f30f6831e3c | refs/heads/master | 2020-12-10T08:21:38.898428 | 2020-01-13T08:21:55 | 2020-01-13T08:21:55 | 233,544,721 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,886 | java | package com.ilham.mp_produk;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.widget.Toast;
import com.ilham.mp_produk.adapter.ProdukAdapter;
import com.ilham.mp_produk.model.Model;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private ProdukAdapter produkAdapter;
private List<Model> tvDataProduk;
private LinearLayoutManager linearLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView=(RecyclerView)findViewById(R.id.recyclerview);
linearLayoutManager=new LinearLayoutManager(MainActivity.this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
APIInterface service= ServiceGenerator.getRetrofit().create(APIInterface.class);
Call<List<Model>> call=service.getProduk();
call.enqueue(new Callback<List<Model>>() {
@Override
public void onResponse(Call<List<Model>> call, Response<List<Model>> response) {
tvDataProduk = response.body();
produkAdapter = new ProdukAdapter(MainActivity.this,tvDataProduk);
recyclerView.setAdapter(produkAdapter);
}
@Override
public void onFailure(Call<List<Model>> call, Throwable t) {
// result.setText(t.getMessage());
Toast.makeText(MainActivity.this, String.valueOf(t), Toast.LENGTH_LONG).show();
}
});
}
}
| [
"ilhamsuryapratama.github@gmail.com"
] | ilhamsuryapratama.github@gmail.com |
5b998489ef4660dfbb3982c812378fa46095d56f | 9e9b124922a8fe8d399795eaeef0b23bd71b765d | /src/main/java/com/sgs/vision/common/constants/ItemStatusEnum.java | 95f62848344de6f7b1930b7b5d024fc396566832 | [] | no_license | erielmarimon-sato/Driftwood | b768f2607ce8f8f82b303672001514c7bbed4d8e | 9e60a797c76d5d17adb2efa8fc3f6b58b7368b58 | refs/heads/master | 2021-01-21T09:55:52.500632 | 2017-02-28T19:18:59 | 2017-02-28T19:18:59 | 83,353,500 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 796 | java | package com.sgs.vision.common.constants;
import com.sgs.vision.common.exceptions.InvalidItemStatusException;
public enum ItemStatusEnum {
UNKNOWN(1),
READ(2),
SOLD(3),
RETURNED(4);
private Integer id;
private ItemStatusEnum(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public static ItemStatusEnum getById(Integer id) {
for(ItemStatusEnum i : values()) {
if(i.id.equals(id)) return i;
}
return null;
}
public static ItemStatusEnum getByCode(String status) throws InvalidItemStatusException{
ItemStatusEnum itemStatus = null;
if (status != null){
try{
itemStatus = valueOf(status.toUpperCase());
}catch(Exception ex){
throw new InvalidItemStatusException(status);
}
}
return itemStatus;
}
}
| [
"eriel.marimon@sato-global.com"
] | eriel.marimon@sato-global.com |
e80cc0efc661dc11dca973d17429451ae74a81a6 | 46c7acaf5c239c35673e1681de815a7cd4bac06d | /src/com/randi/dyned3/tools/ProgressListener.java | 7f7ecfccf232f137b85c31d371b03180d066dfe2 | [] | no_license | randiw/DynEdBBGE3 | 9e38aded4312671a2bdaeec976e272199c028c90 | af7f6e01ece2c700afda5213acabded7d084fcdf | refs/heads/master | 2016-08-04T08:03:10.055920 | 2014-08-17T01:35:39 | 2014-08-17T01:35:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | package com.randi.dyned3.tools;
/**
* A listener to notify progress.
* @author Randi Waranugraha
*
*/
public interface ProgressListener {
/**
* Invoked when progress is complete.
* @param message Message posted when progress completed.
*/
public void onPost(String message);
/**
* Invoked to measure progress.
* @param currentProgress
* @param totalProgress
*/
public void onProgress(int currentProgress, int totalProgress);
} | [
"randi.waranugraha@gmail.com"
] | randi.waranugraha@gmail.com |
694257fcf4228a0f334245ab89f2bd689023d656 | 597a979c7ed579f6a41489edbbec6feac45c7bac | /state/src/main/java/com/gmail/lifeofreilly/state/State.java | 3f63097135c34c24038f6b29f60c249880517222 | [] | no_license | lifeofreilly/design-patterns | 55c6bd144e086a490919381113914e9604e936ff | f35e47f2baae91e7a4a71e10d78282e01250ba82 | refs/heads/master | 2020-04-12T05:41:55.276279 | 2015-01-19T19:23:15 | 2015-01-19T19:23:15 | 27,968,002 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 192 | java | package com.gmail.lifeofreilly.state;
public interface State {
public void insertQuarter();
public void ejectQuarter();
public void turnCrank();
public void dispense();
}
| [
"lifeofreilly@gmail.com"
] | lifeofreilly@gmail.com |
1aa4910775e903a8a5e339ad626aa1a2416aed9a | 39764ebf37ceb2a18cdc471e6abc1c2a8d68216e | /src/test/java/tests/day7/TestNgCalisma.java | 3cd854011ef65284385571161eb9b1c04122fe75 | [] | no_license | nurancebe/MyFirstSeleniumProject | a8c8358f6861b31be2908c5c2d02011b0966199c | 32d3d76f2f2bf0225385b7cc711afdd4b081f4cc | refs/heads/master | 2023-05-12T13:51:34.392953 | 2020-01-01T23:59:37 | 2020-01-01T23:59:37 | 230,491,027 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,364 | java | package tests.day7;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.BrowserFactory;
public class TestNgCalisma {
// @Test
// public void test (){
//Assert.assertEquals("appl","apple" ,"Word is not correct! should be apple");}
//driver.quit();
@Test(description = "Verifying title of the practice website")
public void verifyTitle() {
WebDriver driver = BrowserFactory.getDriver("chrome");
driver.get("http://practice.cybertekschool.com/");
String expectedTitle = "Practice";
String actualTitle = driver.getTitle();
Assert.assertEquals(actualTitle, expectedTitle, "Title is wrong");
driver.quit();
}
@Test(description = "Verify that heading is displayed") //=====>>>>> Annotation @Test
public void verifyHeadingIsDisplayed(){
WebDriver driver = BrowserFactory.getDriver("chrome");
driver.get("http://practice.cybertekschool.com/");
WebElement heading = driver.findElement(By.xpath("//span[text()='Test Automation Practice']"));
Assert.assertTrue(heading.isDisplayed(),"Element is not visible"); // ===========>>>Assertion
driver.quit();
}
}
| [
"nurancebe@gmail.com"
] | nurancebe@gmail.com |
59841a444057605cf2d4d08c0bcb92bc0c42b703 | 8643a3eed82acddf80f93378fc1bca426bfd7a42 | /subprojects/core/src/main/java/org/gradle/internal/classpath/InstrumentedClosuresTracker.java | f5027d7819855390bdff56b2260ed9f57611d88a | [
"BSD-3-Clause",
"LGPL-2.1-or-later",
"LicenseRef-scancode-mit-old-style",
"EPL-2.0",
"CDDL-1.0",
"MIT",
"LGPL-2.1-only",
"Apache-2.0",
"MPL-2.0",
"EPL-1.0"
] | permissive | gradle/gradle | f5666240739f96166647b20f9bc2d57e78f28ddf | 1fd0b632a437ae771718982ef2aa1c3b52ee2f0f | refs/heads/master | 2023-09-04T02:51:58.940025 | 2023-09-03T18:42:57 | 2023-09-03T18:42:57 | 302,322 | 15,005 | 4,911 | Apache-2.0 | 2023-09-14T21:08:58 | 2009-09-09T18:27:19 | Groovy | UTF-8 | Java | false | false | 1,591 | java | /*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.internal.classpath;
import org.gradle.api.NonNullApi;
/**
* Tracks the closures that are currently present in the call stack.
* An instrumented closure must invoke {@link InstrumentedClosuresTracker#enterClosure} when it starts executing and {@link InstrumentedClosuresTracker#leaveClosure}
* right before it leaves the call stack. <p>
*
* {@link InstrumentedClosuresTracker#hitInstrumentedDynamicCall} is invoked by the instrumentation infrastructure on every invocation that is dynamically dispatched
* to the current closures chain and can potentially be intercepted. The implementation must ensure that all the closures in the scope are processed in a way that
* ensures call interception if a call is dispatched to them.
*/
@NonNullApi
public interface InstrumentedClosuresTracker {
void enterClosure(InstrumentableClosure thisClosure);
void leaveClosure(InstrumentableClosure thisClosure);
void hitInstrumentedDynamicCall();
}
| [
"sigushkin@gradle.com"
] | sigushkin@gradle.com |
dbd417bcc4760ad73551c2223ac4a4160d74b1c7 | fa1d8731480a4ba7034ce5dcd71f3ae5551aafe9 | /commons-validator-1.4.1-src/src/main/java/org/apache/commons/validator/routines/checkdigit/ISINCheckDigit.java | 2ecf1d33e348cf1f7eb9e15ce8812d6a7386d521 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | jonkiky/validation-experiement | 89393078249f30baf35c73edf149dd1bc4619efe | 454657d42537a2f7547f09cd1ee23bd2719f3515 | refs/heads/master | 2020-06-23T19:22:07.433864 | 2017-08-01T18:36:19 | 2017-08-01T18:36:19 | 98,650,681 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,401 | 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.commons.validator.routines.checkdigit;
/**
* Modulus 10 <b>ISIN</b> (International Securities Identifying Number) Check Digit calculation/validation.
*
* <p>
* ISIN Numbers are 12 character alphanumeric codes used
* to identify Securities.
* </p>
*
* <p>
* Check digit calculation uses the <i>Modulus 10 Double Add Double</i> technique
* with every second digit being weighted by 2. Alphabetic characters are
* converted to numbers by their position in the alphabet starting with A being 10.
* Weighted numbers greater than ten are treated as two separate numbers.
* </p>
*
* <p>
* See <a href="http://en.wikipedia.org/wiki/ISIN">Wikipedia - ISIN</a>
* for more details.
* </p>
*
* @version $Revision: 1649191 $
* @since Validator 1.4
*/
public final class ISINCheckDigit extends ModulusCheckDigit {
private static final long serialVersionUID = -1239211208101323599L;
/** Singleton ISIN Check Digit instance */
public static final CheckDigit ISIN_CHECK_DIGIT = new ISINCheckDigit();
/** weighting given to digits depending on their right position */
private static final int[] POSITION_WEIGHT = new int[] {2, 1};
/**
* Construct an ISIN Indetifier Check Digit routine.
*/
public ISINCheckDigit() {
super(10);
}
/**
* Calculate the modulus for an ISIN code.
*
* @param code The code to calculate the modulus for.
* @param includesCheckDigit Whether the code includes the Check Digit or not.
* @return The modulus value
* @throws CheckDigitException if an error occurs calculating the modulus
* for the specified code
*/
protected int calculateModulus(String code, boolean includesCheckDigit) throws CheckDigitException {
StringBuffer transformed = new StringBuffer(code.length() * 2);
if (includesCheckDigit) {
char checkDigit = code.charAt(code.length()-1); // fetch the last character
if (!Character.isDigit(checkDigit)){
throw new CheckDigitException("Invalid checkdigit["+ checkDigit+ "] in " + code);
}
}
for (int i = 0; i < code.length(); i++) {
int charValue = Character.getNumericValue(code.charAt(i));
if (charValue < 0 || charValue > 35) {
throw new CheckDigitException("Invalid Character[" +
(i + 1) + "] = '" + charValue + "'");
}
// this converts alphanumerics to two digits
// so there is no need to overload toInt()
transformed.append(charValue);
}
return super.calculateModulus(transformed.toString(), includesCheckDigit);
}
/**
* <p>Calculates the <i>weighted</i> value of a charcter in the
* code at a specified position.</p>
*
* <p>For Luhn (from right to left) <b>odd</b> digits are weighted
* with a factor of <b>one</b> and <b>even</b> digits with a factor
* of <b>two</b>. Weighted values > 9, have 9 subtracted</p>
*
* @param charValue The numeric value of the character.
* @param leftPos The position of the character in the code, counting from left to right
* @param rightPos The positionof the character in the code, counting from right to left
* @return The weighted value of the character.
*/
protected int weightedValue(int charValue, int leftPos, int rightPos) {
int weight = POSITION_WEIGHT[rightPos % 2];
int weightedValue = (charValue * weight);
return ModulusCheckDigit.sumDigits(weightedValue);
}
}
| [
"jonkiky@gmail.com"
] | jonkiky@gmail.com |
971864babd6bda41599ce316672bd1ece9b4ca1f | af6ee6e6ef6f246e6e3ca7ad1a9f42a6b35455df | /Mathematics/Number Theory/Identify Smith Numbers.java | 5708305afa37b0ef2d76c4db21f60b4884ac9076 | [] | no_license | ktp-forked-repos/HackerRank-Solution-To-Algorithms | 20aecad2a1958f14a0910c47d985ba7cd89430ec | ba22d2ad33a975075f5a0dfd370ac76fdc5a552c | refs/heads/master | 2020-05-25T19:21:33.362891 | 2018-08-16T17:03:24 | 2018-08-16T17:03:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 874 | java | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int s=0;
int b=a;
for(int x=2;x<=a;x++)
{
while(a%x==0)
{
a=a/x;
int q=x;
while(q>0)
{
s=s+q%10;
q=q/10;
}
}
}
int u=0;
while(b>0)
{
u=u+b%10;
b=b/10;
}
if(u==s)
{
System.out.println("1");
}
else
{
System.out.println("0");
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
}
}
| [
"noreply@github.com"
] | noreply@github.com |
681acff91748abd9c33373211c08cfd51318f112 | 1bd72541ed6611d9edc229cb0ccbe10e83931826 | /app/src/main/java/com/owo/phlurtyz002/database/DatabaseHandler.java | 797ec6a5f0c9f4d8c2a5f8186e8ee2221ece7c97 | [] | no_license | diodit/android-flirtyz-free | 5da7a652e6ee020b8c321683e1e0088e53c4e11a | 29672c4266d0e574c7aba089a38c216d4ffad35a | refs/heads/master | 2022-04-21T01:47:30.242886 | 2020-04-23T23:43:59 | 2020-04-23T23:43:59 | 258,359,417 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,677 | java | package com.owo.phlurtyz002.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.owo.phlurtyz002.model.GridItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* Created by kibrom on 6/6/17.
*/
public class DatabaseHandler extends SQLiteOpenHelper {
// Database Version
private static final int DATABASE_VERSION = 4;
// Database Name
private static final String DATABASE_NAME = "emoji";
// Table Names
private static final String TABLE_FAVORITE = "favorite";
private static final String TABLE_RECENT = "recent";
//Common column names
private static final String KEY_ID = "id";
private static final String KEY_ASSET_PATH = "asset_path";
private static final String KEY_ASSET_NAME = "asset_name";
private static final int RECENT_EMOJI_LIMIT = 12;
//////////////////////////////////////
// Table Create Statements //
//////////////////////////////////////
//Favorite table create statement
private static final String CREATE_TABLE_FAVORITE = "CREATE TABLE "
+ TABLE_FAVORITE + "(" + KEY_ID + " INTEGER PRIMARY KEY, " + KEY_ASSET_NAME
+ " TEXT, " + KEY_ASSET_PATH + " TEXT" + ")";
//Recent table create statement
private static final String CREATE_TABLE_RECENT = "CREATE TABLE "
+ TABLE_RECENT + "(" + KEY_ID + " INTEGER PRIMARY KEY, " + KEY_ASSET_NAME
+ " TEXT, " + KEY_ASSET_PATH + " TEXT" + ")";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_FAVORITE);
db.execSQL(CREATE_TABLE_RECENT);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// on upgrade drop older tables
db.execSQL("DROP TABLE IF EXISTS " + TABLE_FAVORITE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_RECENT);
// create new tables
onCreate(db);
}
/////////////////////////////
// Favorite CRUD //
/////////////////////////////
public long addFavorite(GridItem gridItem){
if(!isFavoriteItemExists(gridItem.getAssetPath())){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ASSET_NAME,gridItem.getAssetName());
values.put(KEY_ASSET_PATH,gridItem.getAssetPath());
return db.insert(TABLE_FAVORITE,null,values);
}
return 0;
}
public void addFavoriteInBulk(List<GridItem> items){
for(GridItem item : items){
addFavorite(item);
}
}
public Boolean isFavoriteItemExists(String itemPath){
String query = "SELECT * FROM " + TABLE_FAVORITE + " WHERE "
+ KEY_ASSET_PATH + " = '" + itemPath +"'";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query,null);
return cursor.moveToNext();
}
public List<GridItem> getFavoriteList(){
List<GridItem> gridItems = new ArrayList<>();
String query = "SELECT * FROM " + TABLE_FAVORITE;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query,null);
if(cursor.moveToFirst()){
do{
GridItem gridItem = new GridItem();
gridItem.setAssetName(cursor.getString(cursor.getColumnIndex(KEY_ASSET_NAME)));
gridItem.setAssetPath(cursor.getString(cursor.getColumnIndex(KEY_ASSET_PATH)));
gridItems.add(gridItem);
}while (cursor.moveToNext());
}
return gridItems;
}
/////////////////////////////
// Recent CRUD //
// ///////////////////////////
public Boolean IsRecentItemExists(String itemPath){
String query = "SELECT * FROM " + TABLE_RECENT + " WHERE "
+ KEY_ASSET_PATH + " = '" + itemPath +"'";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query,null);
return cursor.moveToNext();
}
public long addRecent(GridItem gridItem){
if(!IsRecentItemExists(gridItem.getAssetPath())){
Stack<GridItem> items = getRecentList();
if(items.size() > RECENT_EMOJI_LIMIT){
}
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ASSET_NAME,gridItem.getAssetName());
values.put(KEY_ASSET_PATH,gridItem.getAssetPath());
return db.insert(TABLE_RECENT,null,values);
}
return 0;
}
public Stack<GridItem> getRecentList(){
Stack<GridItem> gridItems = new Stack<>();
String query = "SELECT * FROM " + TABLE_RECENT;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query,null);
if(cursor.moveToFirst()){
do{
GridItem gridItem = new GridItem();
gridItem.setAssetName(cursor.getString(cursor.getColumnIndex(KEY_ASSET_NAME)));
gridItem.setAssetPath(cursor.getString(cursor.getColumnIndex(KEY_ASSET_PATH)));
gridItems.push(gridItem);
}while (cursor.moveToNext());
}
return gridItems;
}
}
| [
"mac@macs-MacBook-Pro.local"
] | mac@macs-MacBook-Pro.local |
7b7889f61fda35e4b2f5e3f4102809410125cda1 | c8e208b800182d0c37b8668cade0e414b68d62e4 | /app/src/main/java/com/example/zcc/lxtxvideodownload/base/readapter/recyclerview/CommonAdapter.java | a1b526d5405f0591a6d00f5855250de6b0eb8f3f | [] | no_license | zcc2/DownLoader | 94d364b78c95bf1cd13ec8a2e49579db59ac7fed | efbd43f01c2c2a73f0024c511d4f01705812f22b | refs/heads/master | 2022-11-19T11:57:17.485203 | 2020-07-15T09:23:23 | 2020-07-15T09:23:23 | 278,772,366 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,459 | java | package com.example.zcc.lxtxvideodownload.base.readapter.recyclerview;
import android.content.Context;
import android.view.LayoutInflater;
import com.example.zcc.lxtxvideodownload.base.readapter.recyclerview.base.ItemViewDelegate;
import com.example.zcc.lxtxvideodownload.base.readapter.recyclerview.base.ViewHolder;
import java.util.List;
/**
* Created by zhy on 16/4/9.
*/
public abstract class CommonAdapter<T> extends MultiItemTypeAdapter<T>
{
protected Context mContext;
protected int mLayoutId;
protected List<T> mDatas;
protected LayoutInflater mInflater;
public CommonAdapter(final Context context, final int layoutId, List<T> datas)
{
super(context, datas);
mContext = context;
mInflater = LayoutInflater.from(context);
mLayoutId = layoutId;
mDatas = datas;
addItemViewDelegate(new ItemViewDelegate<T>()
{
@Override
public int getItemViewLayoutId()
{
return layoutId;
}
@Override
public boolean isForViewType( T item, int position)
{
return true;
}
@Override
public void convert(ViewHolder holder, T t, int position)
{
CommonAdapter.this.convert(holder, t, position);
}
});
}
protected abstract void convert(ViewHolder holder, T t, int position);
}
| [
"m15632271759_1@163.com"
] | m15632271759_1@163.com |
c1bc2b4809a37fb44aa85612ef849b959da6c056 | aebfeebe806f8187eec91cc80b1f755f74bd408b | /library/src/test/java/com/datatorrent/lib/io/fs/HdfsFileDataOutputOperatorTest.java | 1ef0e5e7ce40fbc47fce8f4bdd8a20cc454cf789 | [
"Apache-2.0"
] | permissive | andypern/Malhar | 32a5ac8281ef3117279a696fe11339d699e243e1 | e9cb86f3eb059317530473b6c5e219e50f394589 | refs/heads/master | 2021-01-16T00:27:36.997053 | 2014-06-20T02:31:22 | 2014-06-20T02:31:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,015 | java | /*
* Copyright (c) 2014 DataTorrent, Inc. ALL Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datatorrent.lib.io.fs;
import java.io.*;
import java.util.Calendar;
import org.junit.Assert;
import org.junit.Test;
import com.datatorrent.lib.helper.OperatorContextTestHelper;
import com.datatorrent.lib.io.fs.HdfsFileDataOutputOperator.FileData;
/**
* Functional test for {@link HdfsFileDataOutputOperator}
*/
public class HdfsFileDataOutputOperatorTest
{
@Test
public void testFileOutputOperator()
{
HdfsFileDataOutputOperator oper = new HdfsFileDataOutputOperator();
oper.setFilePath("target");
oper.setAppend(false);
oper.setup(new OperatorContextTestHelper.TestIdOperatorContext(0));
oper.beginWindow(0);
FileData fileData1 = new FileData();
fileData1.info.name = "file1";
fileData1.data = "data1";
oper.input.process(fileData1);
FileData fileData2 = new FileData();
fileData2.info.name = "file2";
fileData2.data = "data2";
oper.input.process(fileData2);
FileData fileData3 = new FileData();
fileData3.info.name = "file1";
fileData3.data = "data2";
oper.input.process(fileData3);
oper.endWindow();
oper.teardown();
Assert.assertEquals("The number of lines in file target/file-0-0", 1, readFile("target/file1", "data2"));
Assert.assertEquals("The number of lines in file target/file-0-1", 1, readFile("target/file2", "data2"));
Assert.assertEquals("Checking the file target/file-0-0", true, checkFile("target/file1"));
Assert.assertEquals("Checking the file target/file-0-1", true, checkFile("target/file2"));
}
private int readFile(String path, final String val)
{
BufferedReader br = null;
try {
FileInputStream fstream = new FileInputStream(path);
DataInputStream in = new DataInputStream(fstream);
br = new BufferedReader(new InputStreamReader(in));
String strLine;
int count = 0;
while ((strLine = br.readLine()) != null) {
Assert.assertEquals("Comparing the values", val, strLine);
count++;
}
return count;
}
catch (Exception e) {
return -1;
}
finally {
if (br != null) {
try {
br.close();
}
catch (IOException e) {
}
}
}
}
private boolean checkFile(String path)
{
File file = new File(path);
if (file.exists()) {
file.delete();
return true;
}
return false;
}
}
| [
"ashwin@datatorrent.com"
] | ashwin@datatorrent.com |
bdd3b21e71cdc5df44f628b4cae156ca1d5a999c | 60e89dad96e7fb6b1580a316909493bc678ae905 | /src/main/java/fr/polytech/info4/web/rest/vm/package-info.java | a3af23fcb0720d6acca9f07af7793c285df08dbb | [] | no_license | CDLK/JHipster_app | d762031fb53e672d2d35a4f465e38c628e3de276 | 01293521d8b4eb327efea6fecf06edc8ae78a8c3 | refs/heads/main | 2023-05-08T00:39:47.294022 | 2021-05-27T15:19:06 | 2021-05-27T15:19:06 | 356,917,444 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 99 | java | /**
* View Models used by Spring MVC REST controllers.
*/
package fr.polytech.info4.web.rest.vm;
| [
"popoto38697@gmail.com"
] | popoto38697@gmail.com |
53317fc8d53c1660b2e133a2dd4d52941f0b6f23 | de344db5faa290b855da0e20b19c38ea372a3d21 | /utils_app_rx/src/main/java/com/cily/utils/app/rx/fg/BaseOkHttpLazyFragment.java | d412e269b2364ef36b7e39fd8d9e659e670b9543 | [] | no_license | cilys/Utils | 55dc1670878c891f46c51081111a644b4b1e72a6 | b891683939fb57fc5d548090ef13c4be6d2f209e | refs/heads/master | 2021-06-23T04:46:02.356456 | 2017-08-28T02:21:36 | 2017-08-28T02:21:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,311 | java | package com.cily.utils.app.rx.fg;
import android.os.Bundle;
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.cily.utils.app.fg.BaseLazyFragment;
import com.cily.utils.log.L;
import com.trello.rxlifecycle.LifecycleProvider;
import com.trello.rxlifecycle.LifecycleTransformer;
import com.trello.rxlifecycle.RxLifecycle;
import com.trello.rxlifecycle.android.FragmentEvent;
import com.trello.rxlifecycle.android.RxLifecycleAndroid;
import rx.Observable;
import rx.subjects.BehaviorSubject;
/**
* user:cily
* time:2017/2/20
* desc: okhttp + retrofit + rxjava + lazyload
*/
public abstract class BaseOkHttpLazyFragment extends BaseLazyFragment implements LifecycleProvider<FragmentEvent> {
private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();
@Override
@NonNull
@CheckResult
public final Observable<FragmentEvent> lifecycle() {
return lifecycleSubject.asObservable();
}
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
}
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindFragment(lifecycleSubject);
}
@Override
public void onAttach(android.app.Activity activity) {
super.onAttach(activity);
lifecycleSubject.onNext(FragmentEvent.ATTACH);
L.i(TAG, "<--->onAttach");
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifecycleSubject.onNext(FragmentEvent.CREATE);
L.i(TAG, "<--->onCreate");
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
L.i(TAG, "<--->onViewCreated");
}
@Override
public void onStart() {
super.onStart();
lifecycleSubject.onNext(FragmentEvent.START);
L.i(TAG, "<--->onStart");
}
@Override
public void onResume() {
super.onResume();
lifecycleSubject.onNext(FragmentEvent.RESUME);
L.i(TAG, "<--->onResume");
}
@Override
public void onPause() {
lifecycleSubject.onNext(FragmentEvent.PAUSE);
super.onPause();
L.i(TAG, "<--->onPause");
}
@Override
public void onStop() {
lifecycleSubject.onNext(FragmentEvent.STOP);
super.onStop();
L.i(TAG, "<--->onStop");
}
@Override
public void onDestroyView() {
lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);
super.onDestroyView();
L.i(TAG, "<--->onDestroyView");
}
@Override
public void onDestroy() {
lifecycleSubject.onNext(FragmentEvent.DESTROY);
super.onDestroy();
L.i(TAG, "<--->onDestroy");
}
@Override
public void onDetach() {
lifecycleSubject.onNext(FragmentEvent.DETACH);
super.onDetach();
L.i(TAG, "<--->onDetach");
}
}
| [
"1321851830@qq.com"
] | 1321851830@qq.com |
7a4d3d4f1d366efd99ba3b6246608adff81f8736 | 494d111b18b8368072ae9e3cb3a5aac597e5c396 | /app/src/main/java/com/ir/android/networking/PoliceOfficersRetrievingResource/PoliceOfficersRetrievingResource.java | ff8d4ea255b352bdb34813edaf83152faf4407ef | [] | no_license | HalaEmad/CoJ | b2a236a9bd1213ae233a2bed7d5cb63f42f9e3ce | 989612ff1a98ce87961f845e5ac3bc295054db09 | refs/heads/master | 2021-01-21T01:56:16.926513 | 2016-07-31T21:37:20 | 2016-07-31T21:37:20 | 54,468,008 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,157 | java | package com.ir.android.networking.PoliceOfficersRetrievingResource;
import android.content.Context;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ir.android.networking.FeatureModels.Feature;
import com.ir.android.networking.FeatureModels.mapping.DynamicPropertiesResolver;
import com.ir.android.networking.basicimplementation.WLResource;
import com.ir.android.networking.login.UserResource;
import com.worklight.wlclient.api.WLResponse;
import java.util.ArrayList;
/**
* Created by Henawey on 7/11/16.
*/
public class PoliceOfficersRetrievingResource extends WLResource {
private String type;
private int id;
private long lastUpdateDate;
private ArrayList<Feature> features;
private boolean moreDataAvailable;
private ArrayList<String> messages;
public ArrayList<Feature> getFeatures() {
return features;
}
public void setFeatures(ArrayList<Feature> features) {
this.features = features;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public long getLastUpdateDate() {
return lastUpdateDate;
}
public void setLastUpdateDate(long lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}
public boolean isMoreDataAvailable() {
return moreDataAvailable;
}
public void setMoreDataAvailable(boolean moreDataAvailable) {
this.moreDataAvailable = moreDataAvailable;
}
public ArrayList<String> getMessages() {
return messages;
}
public void setMessages(ArrayList<String> messages) {
this.messages = messages;
}
public PoliceOfficersRetrievingResource(Context context) {
super(context);
}
@Override
public String getAdapterName() {
return "Datasources";
}
@Override
public String getProcedureName() {
return "getEvents";
}
@Override
public void invoke() throws PoliceOfficersRetrievingFailedException {
try {
addParameter(12);//datasourceID
addParameter(UserResource.getBase64(getContext()));//base64
addParameter(UserResource.getJSessionID(getContext()));//sessionID
WLResponse response = process();
if(isSuccessed(response)){
ObjectMapper objectMapper = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.readerForUpdating(this).readValue(response.getResponseJSON().toString());
DynamicPropertiesResolver dynamicPropertiesResolver=new DynamicPropertiesResolver(getContext(),12,getFeatures());
dynamicPropertiesResolver.invoke();
}else{
throw new PoliceOfficersRetrievingFailedException(response.getResponseText());
}
}catch (Exception e){
throw new PoliceOfficersRetrievingFailedException(e);
}
}
}
| [
"henawey@gmail.com"
] | henawey@gmail.com |
5a74f54311c7562398b5c62e105963c35d51cb84 | 7016cec54fb7140fd93ed805514b74201f721ccd | /ui/web/main/src/java/com/echothree/ui/web/main/action/warehouse/location/DescriptionAddAction.java | 31b78ff68313088dcbcd469b35e50ec3eedc796d | [
"MIT",
"Apache-1.1",
"Apache-2.0"
] | permissive | echothreellc/echothree | 62fa6e88ef6449406d3035de7642ed92ffb2831b | bfe6152b1a40075ec65af0880dda135350a50eaf | refs/heads/master | 2023-09-01T08:58:01.429249 | 2023-08-21T11:44:08 | 2023-08-21T11:44:08 | 154,900,256 | 5 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,365 | java | // --------------------------------------------------------------------------------
// Copyright 2002-2023 Echo Three, 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
//
// 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.echothree.ui.web.main.action.warehouse.location;
import com.echothree.control.user.warehouse.common.WarehouseUtil;
import com.echothree.control.user.warehouse.common.form.CreateLocationDescriptionForm;
import com.echothree.ui.web.main.framework.AttributeConstants;
import com.echothree.ui.web.main.framework.ForwardConstants;
import com.echothree.ui.web.main.framework.MainBaseAction;
import com.echothree.ui.web.main.framework.ParameterConstants;
import com.echothree.util.common.command.CommandResult;
import com.echothree.view.client.web.struts.CustomActionForward;
import com.echothree.view.client.web.struts.sprout.annotation.SproutAction;
import com.echothree.view.client.web.struts.sprout.annotation.SproutForward;
import com.echothree.view.client.web.struts.sprout.annotation.SproutProperty;
import com.echothree.view.client.web.struts.sslext.config.SecureActionMapping;
import java.util.HashMap;
import java.util.Map;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
@SproutAction(
path = "/Warehouse/Location/DescriptionAdd",
mappingClass = SecureActionMapping.class,
name = "LocationDescriptionAdd",
properties = {
@SproutProperty(property = "secure", value = "true")
},
forwards = {
@SproutForward(name = "Display", path = "/action/Warehouse/Location/Description", redirect = true),
@SproutForward(name = "Form", path = "/warehouse/location/descriptionAdd.jsp")
}
)
public class DescriptionAddAction
extends MainBaseAction<ActionForm> {
@Override
public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
String forwardKey = null;
String warehouseName = request.getParameter(ParameterConstants.WAREHOUSE_NAME);
String locationName = request.getParameter(ParameterConstants.LOCATION_NAME);
try {
if(forwardKey == null) {
DescriptionAddActionForm actionForm = (DescriptionAddActionForm)form;
if(wasPost(request)) {
CreateLocationDescriptionForm commandForm = WarehouseUtil.getHome().getCreateLocationDescriptionForm();
if(warehouseName == null)
warehouseName = actionForm.getWarehouseName();
if(locationName == null)
locationName = actionForm.getLocationName();
commandForm.setWarehouseName(warehouseName);
commandForm.setLocationName(locationName);
commandForm.setLanguageIsoName(actionForm.getLanguageChoice());
commandForm.setDescription(actionForm.getDescription());
CommandResult commandResult = WarehouseUtil.getHome().createLocationDescription(getUserVisitPK(request), commandForm);
if(commandResult.hasErrors()) {
setCommandResultAttribute(request, commandResult);
forwardKey = ForwardConstants.FORM;
} else {
forwardKey = ForwardConstants.DISPLAY;
}
} else {
actionForm.setWarehouseName(warehouseName);
actionForm.setLocationName(locationName);
forwardKey = ForwardConstants.FORM;
}
}
} catch (NamingException ne) {
forwardKey = ForwardConstants.ERROR_500;
}
CustomActionForward customActionForward = new CustomActionForward(mapping.findForward(forwardKey));
if(forwardKey.equals(ForwardConstants.FORM)) {
request.setAttribute(AttributeConstants.WAREHOUSE_NAME, warehouseName);
request.setAttribute(AttributeConstants.LOCATION_NAME, locationName);
} else if(forwardKey.equals(ForwardConstants.DISPLAY)) {
Map<String, String> parameters = new HashMap<>(2);
parameters.put(ParameterConstants.WAREHOUSE_NAME, warehouseName);
parameters.put(ParameterConstants.LOCATION_NAME, locationName);
customActionForward.setParameters(parameters);
}
return customActionForward;
}
} | [
"rich@echothree.com"
] | rich@echothree.com |
164dd1265498be224ce25c460d015a0ada8d421e | d4b17a1dde0309ea8a1b2f6d6ae640e44a811052 | /lang_interface/java/com/intel/daal/algorithms/kmeans/init/InitParameter.java | d28ff6488fdb78bf8059b1ff0d4babb7f1861750 | [
"Apache-2.0",
"Intel"
] | permissive | h2oai/daal | c50f2b14dc4a9ffc0b7f7bcb40b599cadac6d333 | d49815df3040f3872a1fdb9dc99ee86148e4494e | refs/heads/daal_2018_beta_update1 | 2023-05-25T17:48:44.312245 | 2017-09-29T13:30:10 | 2017-09-29T13:30:10 | 96,125,165 | 2 | 3 | null | 2017-09-29T13:30:11 | 2017-07-03T15:26:26 | C++ | UTF-8 | Java | false | false | 5,686 | java | /* file: InitParameter.java */
/*******************************************************************************
* Copyright 2014-2017 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/**
* @ingroup kmeans_init
* @{
*/
package com.intel.daal.algorithms.kmeans.init;
import com.intel.daal.services.DaalContext;
/**
* <a name="DAAL-CLASS-ALGORITHMS__KMEANS__INIT__INITPARAMETER"></a>
* @brief Parameters for computing initial clusters for the K-Means method
*/
public class InitParameter extends com.intel.daal.algorithms.Parameter {
/** @private */
static {
System.loadLibrary("JavaAPI");
}
/** @private */
public InitParameter(DaalContext context, long cParameter, long nClusters, long offset) {
super(context);
this.cObject = cParameter;
}
/**
* Constructs a parameter
* @param context Context to manage the parameter for computing initial clusters for the K-Means algorithm
* @param nClusters Number of clusters
* @param offset Offset in the total data set specifying the start of a block stored on a given local node
*/
public InitParameter(DaalContext context, long nClusters, long offset) {
super(context);
initialize(nClusters, offset);
}
/**
* Constructs a parameter
* @param context Context to manage the parameter for computing initial clusters for the K-Means algorithm
* @param nClusters Number of clusters
*/
public InitParameter(DaalContext context, long nClusters) {
super(context);
initialize(nClusters, 0);
}
private void initialize(long nClusters, long offset) {
this.cObject = init(nClusters, offset);
}
/**
* Retrieves the number of clusters
* @return Number of clusters
*/
public long getNClusters() {
return cGetNClusters(this.cObject);
}
/**
* Retrieves the total number of rows in the distributed processing mode
* @return Total number of rows
*/
public long getNRowsTotal() {
return cGetNRowsTotal(this.cObject);
}
/**
* Retrieves the offset in the total data set specifying the start of a block stored on a given local node
* @return Offset in the total data set
*/
public long getOffset() {
return cGetOffset(this.cObject);
}
/**
* Kmeans|| only. Retrieves fraction of nClusters being chosen in each of nRounds of kmeans||.
* L = nClusters* oversamplingFactor points are sampled in a round.
* @return Fraction of nClusters
*/
public double getOversamplingFactor() {
return cGetOversamplingFactor(this.cObject);
}
/**
* Kmeans|| only. Retrieves the number of rounds for k-means||.
* (oversamplingFactor*nRounds) > 1 is a requirement.
* @return Number of rounds
*/
public long getNRounds() {
return cGetNRounds(this.cObject);
}
/**
* Sets the number of clusters
* @param nClusters Number of clusters
*/
public void setNClusters(long nClusters) {
cSetNClusters(this.cObject, nClusters);
}
/**
* Sets the total number of rows in the distributed processing mode
* @param nRowsTotal Total number of rows
*/
public void setNRowsTotal(long nRowsTotal) {
cSetNRowsTotal(this.cObject, nRowsTotal);
}
/**
* Sets the offset in the total data set specifying the start of a block stored on a given local node
* @param offset Offset in the total data set specifying the start of a block stored on a given local node
*/
public void setOffset(long offset) {
cSetOffset(this.cObject, offset);
}
/**
* Kmeans|| only. Sets fraction of nClusters being chosen in each of nRounds of kmeans||.
* L = nClusters* oversamplingFactor points are sampled in a round.
* @param factor Fraction of nClusters
*/
public void setOversamplingFactor(double factor) {
cSetOversamplingFactor(this.cObject, factor);
}
/**
* Kmeans|| only. Sets the number of rounds for k-means||.
* (L*nRounds) > 1 is a requirement.
* @param nRounds Number of rounds
*/
public void setNRounds(long nRounds) {
cSetNRounds(this.cObject, nRounds);
}
private native long init(long nClusters, long maxIterations);
private native long cGetNClusters(long parameterAddress);
private native long cGetNRowsTotal(long parameterAddress);
private native long cGetOffset(long parameterAddress);
private native double cGetOversamplingFactor(long parameterAddress);
private native long cGetNRounds(long parameterAddress);
private native void cSetNClusters(long parameterAddress, long nClusters);
private native void cSetNRowsTotal(long parameterAddress, long nClusters);
private native void cSetOffset(long parameterAddress, long offset);
private native void cSetOversamplingFactor(long parameterAddress, double factor);
private native void cSetNRounds(long parameterAddress, long nRounds);
}
/** @} */
| [
"vasily.rubtsov@intel.com"
] | vasily.rubtsov@intel.com |
a903a6c6f72a0ca419a22d05ac9280356c5ddb1e | 3de9120ed98838de03797256a1e0e232478e1f17 | /src/main/java/mk/ukim/finki/univds/EvaluationConsoleApplicationRunner.java | ba4b74beae0ff208e1088d61d4bd163898e49cbd | [] | no_license | ristes/univ-datasets | e54395cf0d7bba7756eb2b4d6e256235c6d25cea | 684b6ead335213141a461d943c4597092aa28c09 | refs/heads/master | 2021-01-22T19:09:39.908724 | 2017-07-29T17:45:13 | 2017-07-29T17:45:13 | 85,172,281 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 592 | java | package mk.ukim.finki.univds;
import mk.ukim.finki.univds.testrealm.MainTestCaseEvaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* Test evaluations runner.
*/
//@Component
public class EvaluationConsoleApplicationRunner implements CommandLineRunner {
@Autowired
private MainTestCaseEvaluationService evaluationService;
@Override
public void run(String... args) throws Exception {
evaluationService.processScenario();
}
}
| [
"karate.manija@gmail.com"
] | karate.manija@gmail.com |
d1b54412d28ae0fa089e67913283352a988701df | 785cdb564f7d476dbfb784b5f8e0466245d6fe26 | /src/main/java/assignment3/schema/aggregate/SchemaCount.java | ed691b757440b693e376bf036328e57031d0d948 | [] | no_license | MightyCupcakes/CS3219-Assignment-3 | 4667bdba87b410bc3ddcf2068faf96845b824d7a | 1e7b3e0a8a44ee77dc636237565cd37efc23c4b4 | refs/heads/master | 2021-08-11T08:34:58.630578 | 2017-11-13T12:11:57 | 2017-11-13T12:11:57 | 104,436,855 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | package assignment3.schema.aggregate;
import assignment3.datarepresentation.SerializedJournalCitation;
import assignment3.schema.SchemaBase;
import assignment3.schema.SchemaComparable;
public class SchemaCount extends SchemaAggregate {
private int count;
public SchemaCount(SchemaComparable column) {
super(column);
count = 0;
}
@Override
public String getNameOfAttribute() {
return (!hasBeenRenamed) ? "COUNT(" + nameOfAttribute + ")" : nameOfAttribute;
}
@Override
public void accumulate(SerializedJournalCitation row) {
count ++;
}
@Override
public int getResult() {
int result = count;
count = 0;
return result;
}
@Override
public SchemaBase copy() {
return new SchemaCount(column);
}
}
| [
"gohydj2003@gmail.com"
] | gohydj2003@gmail.com |
7be62afb8475b310747b32026a2861d54ebc9bca | 012e9bd5bfbc5ceca4e36af55a7ddf4fce98b403 | /code/app/src/main/java/com/yzb/card/king/ui/travel/adapter/TravelLineAdapter.java | fc1909bd3071bad845d5414dc2b3307f3c0fcf05 | [] | no_license | litliang/ms | a7152567c2f0e4d663efdda39503642edd33b4b6 | d7483bc76d43e060906c47acc1bc2c3179838249 | refs/heads/master | 2021-09-01T23:51:50.934321 | 2017-12-29T07:30:49 | 2017-12-29T07:30:49 | 115,697,248 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,988 | java | package com.yzb.card.king.ui.travel.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.yzb.card.king.R;
import com.yzb.card.king.bean.travel.TravelLineBean;
import com.yzb.card.king.ui.base.BaseRecyAdapter;
import java.util.List;
/**
* 功能:旅游详情航线列表;
*
* @author:gengqiyun
* @date: 2016/11/16
*/
public class TravelLineAdapter extends BaseRecyAdapter<TravelLineBean>
{
private String[] letterArray;
public TravelLineAdapter(List<TravelLineBean> mList, Context context)
{
super(mList, context);
letterArray = context.getResources().getStringArray(R.array.cap_letters);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View itemView = inflater.inflate(R.layout.travel_detail_line_item, parent, false);
return new LineViewHolder(itemView);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position)
{
LineViewHolder viewHolder = (LineViewHolder) holder;
final TravelLineBean lineBean = mList.get(position);
viewHolder.tvLineName.setText(letterArray[position] + "线");
//卢浮宫/直飞
String scenic = "";
String trafficType = "";
//取经典景点描述的第一个
String classicSpots = lineBean.getClassicSpotDesc();
if (!TextUtils.isEmpty(classicSpots))
{
String[] spotsArray = classicSpots.split(",");
scenic = spotsArray != null && spotsArray.length > 0 ? spotsArray[0] : "";
}
List<TravelLineBean.Schedule> schedules = lineBean.getScheduleList();
if (schedules != null && schedules.size() > 0)
{
List<TravelLineBean.MyPlan> planList = schedules.get(0).getPlanList();
if (planList != null && planList.size() > 0)
{
//交通工具类型 0无、1直飞、2中转
switch (planList.get(0).getTrafficType())
{
case "0":
trafficType = "无";
break;
case "1":
trafficType = "直飞";
break;
case "2":
trafficType = "中转";
break;
}
}
}
viewHolder.tvLineType.setText(TextUtils.isEmpty(scenic) ? trafficType : scenic + "/" + trafficType);
holder.itemView.setSelected(lineBean.isSelct());
viewHolder.tvLineName.setSelected(lineBean.isSelct());
viewHolder.tvLineType.setSelected(lineBean.isSelct());
//线路点击;
viewHolder.itemView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if (lineClick != null)
{
lineClick.getClickLine(position);
}
}
});
}
private ILineClick lineClick;
public void setLineClick(ILineClick lineClick)
{
this.lineClick = lineClick;
}
public int getSelectItemPos()
{
if (mList != null)
{
for (int i = 0; i < mList.size(); i++)
{
if (mList.get(i).isSelct())
{
return i;
}
}
}
return -1;
}
public interface ILineClick
{
/**
* 选中的bean;
*
* @param bean
*/
void getClickLine(int bean);
}
/**
* 选中item;
*
* @param lineBean
*/
public void selectItem(TravelLineBean lineBean)
{
if (lineBean != null)
{
for (int i = 0; i < mList.size(); i++)
{
if (mList.get(i).isSelct())
{
mList.get(i).setIsSelct(false);
}
}
lineBean.setIsSelct(true);
notifyDataSetChanged();
}
}
public TravelLineBean getSelectItem()
{
if (mList != null)
{
for (int i = 0; i < mList.size(); i++)
{
if (mList.get(i).isSelct())
{
return mList.get(i);
}
}
}
return null;
}
class LineViewHolder extends RecyclerView.ViewHolder
{
public TextView tvLineName;
public TextView tvLineType;
public LineViewHolder(View itemView)
{
super(itemView);
tvLineName = (TextView) itemView.findViewById(R.id.tvLineName);
tvLineType = (TextView) itemView.findViewById(R.id.tvLineType);
}
}
}
| [
"864631546@qq.com"
] | 864631546@qq.com |
672cb596724b9f73177b60a23df16ddfcda59e3a | 0db42e350a31477dbaacb20669bd14a7b67ad643 | /src/com/vv/time/TimeClient.java | 8d173f73ee5e929abecbcd3cda8168cc9b656191 | [] | no_license | ivyzvh/NettyDemo | ebf3a9c6729ba1aa30a74da65f92bb5091f1abbe | 2fb41c5988c7af20e1ca0c565ab6ec84700ac938 | refs/heads/master | 2021-05-06T13:21:37.907352 | 2017-12-24T07:40:06 | 2017-12-24T07:40:06 | 113,260,697 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,186 | java | package com.vv.time;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
/**
* Netty 5
*/
public class TimeClient {
public void connect(int port, String host) throws Exception {
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer<SocketChannel>(){
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new TimeClientHandler());
}
});
ChannelFuture f = b.connect(host, port).sync();
f.channel().closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}
public static void main(String[] args) throws Exception {
new TimeClient().connect(7879, "127.0.0.1");
}
}
| [
"ivyzvh@qq.com"
] | ivyzvh@qq.com |
5b14f4a874507e044b632515bd415a7204ef3a72 | 0076dbb2b804805b89c046f04bc7e4b61c5a4631 | /exercicios/src/classe/excecao/personalizadaB/Validar.java | df2451e907e69e893a273d26b33981054dd5c7a7 | [] | no_license | FlavioLimas/curso-java | 50c2dce96ad212e137e5e25b26329385d3c303d3 | d1a1ab1fe7b114d215708ddd7712a6f40aef8b94 | refs/heads/master | 2023-04-20T02:12:03.261889 | 2021-04-29T01:20:17 | 2021-04-29T01:20:17 | 307,748,034 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 592 | java | package excecao.personalizadaB;
import excecao.Aluno;
public class Validar {
private Validar() {}
public static void validarAluno(Aluno aluno) throws StringVaziaException, NumeroForaIntervaloException {
if(aluno == null) {
throw new IllegalArgumentException("O aluno está null!");
}
if (aluno.nome == null || aluno.nome.trim().isEmpty()) {
throw new StringVaziaException("nome");
}
if (aluno.nota < 0 || aluno.nota > 10) {
throw new NumeroForaIntervaloException("nota");
}
}
}
| [
"flaviolima.s@live.com"
] | flaviolima.s@live.com |
f43a147e91cc0a0f00b36c18fe20983025c5661e | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/26/26_db50e3d4d99aeaac969ceba653d1c54082bfea17/TextureKey/26_db50e3d4d99aeaac969ceba653d1c54082bfea17_TextureKey_t.java | 8a72db1be1870e76069cd059d07d0ba59e72d02c | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 6,480 | java | /*
* Copyright (c) 2003-2006 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme.util;
import java.io.IOException;
import java.net.URL;
import com.jme.util.export.InputCapsule;
import com.jme.util.export.JMEExporter;
import com.jme.util.export.JMEImporter;
import com.jme.util.export.OutputCapsule;
import com.jme.util.export.Savable;
/**
*
* <code>TextureKey</code> provides a way for the TextureManager to cache and
* retrieve <code>Texture</code> objects.
*
* @author Joshua Slack
* @version $Id: TextureKey.java,v 1.12 2006-05-17 19:09:28 nca Exp $
*/
final public class TextureKey implements Savable {
protected URL m_location = null;
protected int m_minFilter, m_maxFilter;
protected float m_anisoLevel;
protected boolean m_flipped;
protected int code = Integer.MAX_VALUE;
protected int imageType;
private static URL overridingLocation;
public TextureKey() {
}
public TextureKey(URL location, int minFilter, int maxFilter,
float anisoLevel, boolean flipped, int imageType) {
m_location = location;
m_minFilter = minFilter;
m_maxFilter = maxFilter;
m_flipped = flipped;
m_anisoLevel = anisoLevel;
this.imageType = imageType;
}
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (!(other instanceof TextureKey)) {
return false;
}
TextureKey that = (TextureKey) other;
if(this.m_location == null && !(that.m_location == null)) {
return false;
}
if (this.m_location == null)
if (that.m_location != null)
return false;
else if (!this.m_location.equals(that.m_location))
return false;
if (this.m_minFilter != that.m_minFilter)
return false;
if (this.m_maxFilter != that.m_maxFilter)
return false;
if (this.m_anisoLevel != that.m_anisoLevel)
return false;
if (this.m_flipped != that.m_flipped)
return false;
if (this.imageType != that.imageType)
return false;
return true;
}
// TODO: make this better?
public int hashCode() {
if (code == Integer.MAX_VALUE) {
if(m_location != null) {
code = m_location.hashCode();
}
code += (int) (m_anisoLevel * 100);
code += m_maxFilter;
code += m_minFilter;
code += imageType;
code += (m_flipped ? 1 : 0);
}
return code;
}
public void write(JMEExporter e) throws IOException {
OutputCapsule capsule = e.getCapsule(this);
capsule.write(m_location.getProtocol(), "protocol", null);
capsule.write(m_location.getHost(), "host", null);
capsule.write(m_location.getFile(), "file", null);
capsule.write(m_minFilter, "minFilter", 0);
capsule.write(m_maxFilter, "maxFilter", 0);
capsule.write(m_anisoLevel, "anisoLevel", 0);
capsule.write(m_flipped, "flipped", false);
capsule.write(imageType, "imageType", 0);
}
public void read(JMEImporter e) throws IOException {
InputCapsule capsule = e.getCapsule(this);
String protocol = capsule.readString("protocol", null);
String host = capsule.readString("host", null);
String file = capsule.readString("file", null);
if(overridingLocation != null && "file".equals(protocol)) {
int index = file.lastIndexOf('/');
if(index == -1) {
index = file.lastIndexOf('\\');
}
index+=1;
String loc = file.substring(0, index);
if(!overridingLocation.equals(loc)) {
file = file.substring(index);
m_location = new URL(overridingLocation, file);
} else {
m_location = new URL(protocol, host, file);
}
} else {
m_location = new URL(protocol, host, file);
}
m_minFilter = capsule.readInt("minFilter", 0);
m_maxFilter = capsule.readInt("maxFilter", 0);
m_anisoLevel = capsule.readFloat("anisoLevel", 0);
m_flipped = capsule.readBoolean("flipped", false);
imageType = capsule.readInt("imageType", 0);
}
public int getImageType() {
return imageType;
}
public void setImageType(int imageType) {
this.imageType = imageType;
}
public static URL getOverridingLocation() {
return overridingLocation;
}
public static void setOverridingLocation(URL overridingLocation) {
TextureKey.overridingLocation = overridingLocation;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
83bf47b3bc773a6f2306a4afd07adadcb621493c | 7df4df572c011505d061f9d32f3e4c090da2ebd6 | /src/main/java/sample/FormModel.java | ef746ae6f81e306d5b8636b161a4d4de2481d8ce | [] | no_license | n-tos/SparkForm2Model | 1dcb971b0c2a3eddfc519066dec73c5a9ea7a88f | 3d43e9c457ea488ce53c1f3736137553b511ec98 | refs/heads/master | 2021-01-23T02:10:00.370487 | 2017-03-24T12:26:56 | 2017-03-24T12:26:56 | 85,969,197 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 850 | 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 sample;
/**
*
* @author n.tos
*/
public class FormModel {
private String id;
private String text;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text the text to set
*/
public void setText(String text) {
this.text = text;
}
@Override
public String toString() {
return ("id : " + this.id + " , " + "text : " + this.text);
}
}
| [
"n.tos@futureantiques.co.jp"
] | n.tos@futureantiques.co.jp |
76d6c583346c6aadf081857036a2ccb0698ad0fd | eaa3e3c6caf6ef85955b7092534d910e5617c21a | /Positive or Negative/Main.java | 3f559a13080fd5ebdeae87d83c0198e02725dcea | [] | no_license | vanshi-jain/Playground | 36c4c7f7b5857d9cf171f9248365be7926ed5078 | d0f5db7d556eeaa95267731942d9539c02db8e7c | refs/heads/master | 2022-10-02T13:08:12.294449 | 2020-05-20T18:53:01 | 2020-05-20T18:53:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 155 | java | #include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>=0) cout<<a<<" is a positive number.";
else cout<<a<<" is a negative number.";
} | [
"52538805+EXPLORER-ON-BOARD@users.noreply.github.com"
] | 52538805+EXPLORER-ON-BOARD@users.noreply.github.com |
a79d7c4d911263f5f370785356b98ec1a7a4afc9 | 876b3194efba0b7a0fab783ac77e9dbb3da9f981 | /app/src/androidTest/java/com/example/huu/firestoreexampleproject/ExampleInstrumentedTest.java | 55c4aee5d4da2b705b7e959dd7a9ec4a54d8ae74 | [] | no_license | huuphong91/FirestoreExampleProject | fa37b5bb95592b4896966552b0100003f6c93707 | ef9c4b58e43441622d49049bf00585fec125daab | refs/heads/master | 2020-04-21T15:52:23.037040 | 2019-02-08T03:57:12 | 2019-02-08T03:57:12 | 169,681,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 762 | java | package com.example.huu.firestoreexampleproject;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.huu.firestoreexampleproject", appContext.getPackageName());
}
}
| [
"huuphong91@gmail.com"
] | huuphong91@gmail.com |
bdadbaa75e7aa11d6c150f2960ed5b88291579a6 | faaa22f6562de6cdf6105e3633fc85e23739f66b | /Comanda/app/src/main/java/br/com/wp/Util/CriptografarSenha.java | f885295d58935ca9461315c09d6c8c9062d2a7e1 | [] | no_license | Wilson-Ferreira/comanda | c32850a40ea70737fa79612502652a71c2a4f041 | b46aa94925c8f67e8baeee99a315374069821f00 | refs/heads/master | 2021-01-11T21:56:38.967750 | 2017-03-21T16:35:35 | 2017-03-21T16:35:35 | 78,883,442 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,223 | java | package br.com.wp.Util;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Created by User on 10/01/2017.
*/
public class CriptografarSenha {
String senhaCriptografada;
public String criptografarSenha(String senha){
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
byte byteHash[] = null;
try {
byteHash = messageDigest.digest(senha.getBytes("UTF-8"));
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(CriptografarSenha.class.getName()).log(Level.SEVERE, null, ex);
}
StringBuilder hexHash = new StringBuilder();
for (byte b : byteHash) {
hexHash.append(String.format("%02X", 0xFF & b));
}
senhaCriptografada = hexHash.toString();
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(CriptografarSenha.class.getName()).log(Level.SEVERE, null, ex);
}
return senhaCriptografada;
}
}
| [
"wfflorindo@gmail.com"
] | wfflorindo@gmail.com |
44e40aa39eed07926e45277a9d1aecbbbb54dd93 | a8c782105d28bb66e2eb19bad16709702be130f1 | /src/supplment_examples/字符大小写.java | 5dd3a8bbe540fd14e5ddad3c28a4c9d8616eabe5 | [] | no_license | naruto227/JZOF | a2c678f30bc7fa72c2b9d10cb67d4a6f1b219d03 | 18d4e924eda3ee9255b3cb7acabb71c37884d4ae | refs/heads/master | 2020-06-10T15:52:08.542924 | 2017-01-26T15:00:26 | 2017-01-26T15:00:26 | 75,946,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 865 | java | package supplment_examples;
import java.util.Scanner;
/**
* Created by hzq on 17-1-10.
*/
public class 字符大小写 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String next = scanner.next();
System.out.println(toUpperCase(next));
}
}
private static String toUpperCase(String str) {
StringBuffer s = new StringBuffer();
if (str != null) {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
// isUpperCase isLowerCase
if (c >= 'a' && c <= 'z') {
c -= 32;
}
s.append(c);//sb.append(Character.toUpperCase(c));
}
}
return s.toString()/*String.valueOf(s)*/;
}
}
| [
"huangzq30@163.com"
] | huangzq30@163.com |
5e51110b1eaccc9de656ffcca19057f3857e0264 | 55301fd7aa09311b46c20b8e4a22b18310d4356f | /AmaroTest/app/src/test/java/com/test/amaro/amarotest/util/ProductsUtilTest.java | bc5577a1defe535481c889b4711fa70abb49ee9d | [] | no_license | fabiohxcx/mobile-android-challenge | f621137dcb701e89c50ef5dcad8eb335c9fa5bc0 | 90f1fa4904df4cf5066db805abcc6e1586989c15 | refs/heads/master | 2020-03-17T01:47:49.534256 | 2018-05-21T01:00:48 | 2018-05-21T01:00:48 | 133,166,663 | 0 | 0 | null | 2018-05-12T17:07:44 | 2018-05-12T17:07:44 | null | UTF-8 | Java | false | false | 1,633 | java | package com.test.amaro.amarotest.util;
import com.test.amaro.amarotest.model.Product;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class ProductsUtilTest {
List<Product> products = new ArrayList<>();
@Before
public void setUp() {
Product product1 = new Product();
product1.setName("Prod1");
product1.setOnSale(true);
product1.setActualPrice("R$ 199,90");
products.add(product1);
Product product2 = new Product();
product2.setName("Prod2");
product2.setOnSale(false);
product2.setActualPrice("R$ 129,90");
products.add(product2);
}
@Test
public void getOnSale() {
List<Product> productsSale = ProductsUtil.getOnSale(products);
for (int i = 0; i < productsSale.size(); i++) {
Assert.assertTrue("Product: " + productsSale.get(i).getName() + " is on sale: " + productsSale.get(0).isOnSale(), productsSale.get(0).isOnSale());
}
}
@Test
public void getOrderByPrice() {
List<Product> productsOrdered = ProductsUtil.getOrderByPrice(products);
for (int i = 0; i < productsOrdered.size() - 1; i++) {
double price = ProductsUtil.parseCurrencyPtBR(productsOrdered.get(i).getActualPrice());
double price2 = ProductsUtil.parseCurrencyPtBR(productsOrdered.get(i + 1).getActualPrice());
Assert.assertTrue("prod: " + productsOrdered.get(i).getName() + " - prod: " + productsOrdered.get(i + 1).getName(), price < price2);
}
}
} | [
"hideki.fabio@gmail.com"
] | hideki.fabio@gmail.com |
e7f523a3127f34986d38d004524030c27a75a1f1 | 00c03f6015bbd281ca04608c64f71727b6dc8409 | /src/com/rehansqapoint/variables/DifferentWaysToCreateVariable.java | 1703bc00397ebe62d92ea3c5f7b182de06b4a1db | [] | no_license | prathapSEDT/java_SDET_Program | 7340c21cce6139230a45483a2abad9b48811512a | d10db6d6a1f66dff657840f65a0f39a1ef9fbcfd | refs/heads/master | 2022-12-05T01:42:10.398717 | 2020-08-29T01:51:11 | 2020-08-29T01:51:11 | 288,060,971 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 295 | java | package com.rehansqapoint.variables;
public class DifferentWaysToCreateVariable {
public static void main(String[] args) {
int a,b,c,d;
a=20;
b=50;
c=60;
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
| [
"prathap.ufttest@gmail.com"
] | prathap.ufttest@gmail.com |
da8f196cf6493abfc1fc936da591f1e92ad9d213 | af3cf021d9c7a1f5d4464699589990b5cec26ad1 | /src/SessionManagerImpl.java | d1147e0b6656f2bb30891184d6002184b0d9f194 | [] | no_license | Srujan16/webSockets | aa2882322975baeb942af4f40ee40063334229ed | 8609bd4eb1113d0babad6c3f9cfcf06517aac251 | refs/heads/master | 2021-01-19T22:04:36.342275 | 2016-12-22T18:24:20 | 2016-12-22T18:24:20 | 69,320,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,493 | java | import javax.websocket.RemoteEndpoint;
import javax.websocket.Session;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by srujant on 26/9/16.
*/
public class SessionManagerImpl implements SessionManager {
private static final ConcurrentHashMap<String, RemoteEndpoint.Basic> userSessions = new ConcurrentHashMap<>();
static {
Thread t=new Thread(new Runnable() {
@Override
public void run() {
try {
while(true) {
if (userSessions.size() != 0) {
String message;
Map.Entry<String, RemoteEndpoint.Basic> entry = userSessions.entrySet().iterator().next();
RemoteEndpoint.Basic user = entry.getValue();
FileReader fileReader = new FileReader(new File("/home/srujant/Desktop/java/websocket"));
BufferedReader bufferedReader = new BufferedReader(fileReader);
while ((message = bufferedReader.readLine()) != null) {
System.out.println("Size :"+message.length());
user.sendText(message, false);
Thread.sleep(1000);
}
user.sendText("EndOfFile", true);
break;
}
}
} catch (IOException e) {
throw new RuntimeException("Exception while reading data");
} catch (InterruptedException e) {
throw new RuntimeException("Exception in thread sleep");
}
}
});
t.start();
}
@Override
public void addSession(Session session, String type) {
RemoteEndpoint.Basic user = session.getBasicRemote();
userSessions.put(session.getId(), user);
System.out.println(session.getId() + " Connected to network");
try {
if ("text".equalsIgnoreCase(type)) {
user.sendText("Connection Established");
} else {
user.sendBinary(ByteBuffer.wrap("Connection Established".getBytes()));
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void broadCastMessage(String message, String type) {
int opcode;
if ("text".equalsIgnoreCase(type)) {
opcode = 1;
} else {
opcode = 2;
}
for (Map.Entry<String, RemoteEndpoint.Basic> user : userSessions.entrySet()) {
try {
if (opcode == 1) {
user.getValue().sendText("from " + user.getKey() + " Message " + message);
} else {
message = "from " + user.getKey() + " Message " + message;
user.getValue().sendBinary(ByteBuffer.wrap(message.getBytes()));
}
} catch (IOException e) {
throw new RuntimeException("failed to send data to " + user.toString());
}
}
}
@Override
public void removeSession(String id) {
userSessions.remove(id);
System.out.println(id + " ended the session");
}
}
| [
"srujan.thammisetty@wavemaker.com"
] | srujan.thammisetty@wavemaker.com |
1b9d6576c775e2ab7434968ac19a91588b8cd083 | c0ce3df127c5d09ec464e5b50bb4a9686e59eced | /nakadi-producer-spring-boot-starter/src/test/java/org/zalando/nakadiproducer/LockingIT.java | 7cced86c310e726faa94bb93985e2fc022618ea2 | [
"MIT"
] | permissive | fbrns/nakadi-producer-spring-boot-starter | 0e803858f626ed22d508335b00a2f9ee335aeb4f | 304b72a4af6606c112de686ddbe07005f42ef090 | refs/heads/master | 2022-12-01T15:29:06.282773 | 2022-11-25T15:50:57 | 2022-11-25T15:50:57 | 175,577,609 | 0 | 0 | MIT | 2022-11-29T15:34:53 | 2019-03-14T08:15:37 | Java | UTF-8 | Java | false | false | 2,743 | java | package org.zalando.nakadiproducer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.zalando.nakadiproducer.eventlog.EventLogWriter;
import org.zalando.nakadiproducer.eventlog.impl.EventLog;
import org.zalando.nakadiproducer.transmission.MockNakadiPublishingClient;
import org.zalando.nakadiproducer.transmission.impl.EventTransmissionService;
import org.zalando.nakadiproducer.transmission.impl.EventTransmitter;
import org.zalando.nakadiproducer.util.Fixture;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
import java.util.Collection;
import java.util.List;
import static java.time.temporal.ChronoUnit.MINUTES;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class LockingIT extends BaseMockedExternalCommunicationIT {
private static final String MY_EVENT_TYPE = "myEventType";
@Autowired
private EventLogWriter eventLogWriter;
@Autowired
private EventTransmitter eventTransmitter;
@Autowired
private EventTransmissionService eventTransmissionService;
@Autowired
private MockNakadiPublishingClient nakadiClient;
@Before
@After
public void clearNakadiEvents() {
eventTransmitter.sendEvents();
nakadiClient.clearSentEvents();
}
@Test
public void eventsShouldNotBeSentTwiceWhenLockExpiresDuringTransmission() {
// Given that there is an event to be sent...
eventLogWriter.fireBusinessEvent(MY_EVENT_TYPE, Fixture.mockPayload(1, "code123"));
// ... and given one job instance locked it for sending...
Instant timeOfInitialLock = Instant.now();
mockServiceClock(timeOfInitialLock);
Collection<EventLog> eventLogsLockedFirst = eventTransmissionService.lockSomeEvents();
// ... and given that so much time passed in the meantime that the lock already expired...
mockServiceClock(timeOfInitialLock.plus(11, MINUTES));
// ... so that another job could have locked the same events ...
Collection<EventLog> eventLogsLockedSecond = eventTransmissionService.lockSomeEvents();
// when both job instances try to send their locked events
eventTransmissionService.sendEvents(eventLogsLockedFirst);
eventTransmissionService.sendEvents(eventLogsLockedSecond);
// Then the event should have been sent only once.
List<String> value = nakadiClient.getSentEvents(MY_EVENT_TYPE);
assertThat(value.size(), is(1));
}
private void mockServiceClock(Instant ins) {
eventTransmissionService.overrideClock(Clock.fixed(ins, ZoneId.systemDefault()));
}
}
| [
"benjamin.gehrels.extern@zalando.de"
] | benjamin.gehrels.extern@zalando.de |
cdbe52155f5758f8dcc4e0257aa8dfee9e0ba19f | 8eba1430f15356553f30c3a6192f9ba24df42817 | /src/main/java/com/poly/controller/CartController.java | 5aa92c26d7772b0b50fa70a940e6bdd7b25acff3 | [] | no_license | huyducvo972001/Java5ShoppingCart | 4df4efc023f8979ae658cce6bd7eb0f4d796d81f | 4f816582cf1991314893b7131a0c1b78f17ab900 | refs/heads/main | 2023-08-30T01:17:23.464380 | 2021-11-04T02:29:01 | 2021-11-04T02:29:01 | 424,443,728 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,504 | java | package com.poly.controller;
import com.poly.dao.DeliveryInfoDAO;
import com.poly.dao.OrderDAO;
import com.poly.dao.OrderDetailDAO;
import com.poly.entity.DeliveryInfo;
import com.poly.entity.Order;
import com.poly.entity.OrderDetail;
import com.poly.entity.User;
import com.poly.service.CartService;
import com.poly.service.MailerService;
import com.poly.service.SessionService;
import com.poly.service.UseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.mail.MessagingException;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@Controller
public class CartController {
@Autowired
CartService cartService;
@Autowired
MailerService mailer;
@Autowired
SessionService sessionService;
@Autowired
DeliveryInfoDAO deliveryInfoDAO;
@Autowired
OrderDAO orderDAO;
@Autowired
OrderDetailDAO orderDetailDAO;
@Autowired
UseService useService;
@RequestMapping("/home/cart")
public String cart(Model model) {
Collection<OrderDetail> listOrder = cartService.getItems();
double total = 0;
for(OrderDetail o: listOrder){
total += o.getQuantity()*(o.getProduct().getPrice()-o.getProduct().getDiscount());
}
DecimalFormat df = new DecimalFormat("###,###,###");
model.addAttribute("totalMoney",df.format(total));
model.addAttribute("totalMoneyShip",df.format(total+80000));
model.addAttribute("listOrder", listOrder);
return "/home/cart";
}
@RequestMapping("/home/cart/pay")
public String pay(Model model) {
DeliveryInfo deliveryInfo = new DeliveryInfo();
model.addAttribute("deliveryInfo", deliveryInfo);
return "/home/delivery";
}
@RequestMapping("/home/cart/order")
public String order(@ModelAttribute("deliveryInfo") DeliveryInfo deliveryInfo) {
DecimalFormat df = new DecimalFormat("###,###,###");
User u = sessionService.getAttribute("user_Login");
deliveryInfo.setEmail(u.getEmail());
deliveryInfoDAO.save(deliveryInfo);
Order order = new Order();
order.setCustomer(u);
order.setNote("");
order.setDeliveryInfo(deliveryInfo);
order.setPurchaseDate(new Date());
orderDAO.save(order);
Collection<OrderDetail> orderList = cartService.getItems();
String mailCart = "";
int i=1;
double totalMoney = 0;
for (OrderDetail od : orderList) {
mailCart += "<tr>\n" +
" <th scope=\"row\" style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">"+(i++)+"</th>\n" +
" <td style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">"+od.getProduct().getName()+"</td" +
">\n" +
" <td style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">"+od.getQuantity()+"</td>\n" +
" <td style=\"border: 1px solid rgb(173," +
" 171, 171); padding: 10px;\">"+df.format((od.getProduct().getPrice()-od.getProduct().getDiscount())*od.getQuantity())+"</td>\n" +
" </tr>";
totalMoney += (od.getProduct().getPrice()-od.getProduct().getDiscount())*od.getQuantity();
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrder(order);
orderDetail.setProduct(od.getProduct());
orderDetail.setQuantity(od.getQuantity());
orderDetail.setPrice(od.getProduct().getPrice());
orderDetailDAO.save(orderDetail);
}
try {
mailer.send(u.getEmail(), "Xác nhận đơn đặt hàng", "Chúng tôi đã " +
"nhận được đơn hàng của bạn, đơn hàng của bạn gồm:" +
" " +
"<br> " +
"<table " +
"style=\"width: 100%;\">"+"<tr >\n" +
" <th scope=\"row\" style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">#</th>\n" +
" <td style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">Sản phẩm</td>\n" +
" <td style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">Số lượng</td>\n" +
" <td style=\"border: 1px solid rgb(173, 171, 171); padding: 10px;\">Giá</td>\n" +
" \n" +
" </tr> "+mailCart+"</table> <br> " +
"Tổng " +
"tiền cần thanh toán là: "+df.format(totalMoney+80000));
} catch (MessagingException e) {
return e.getMessage();
}
cartService.clear();
System.out.println(cartService.getItems());
return "redirect:/home/index";
}
@ModelAttribute("total")
public Integer dsa() {
return cartService.quantityProductInCart();
}
@ModelAttribute("isLogin")
public Boolean getUseService(Model model) {
return useService.isLogin(model);
}
}
| [
"70436685+huyducvo972001@users.noreply.github.com"
] | 70436685+huyducvo972001@users.noreply.github.com |
d6328fd02a58ce2548c50d03b86bec8edec5e798 | 71e3d397e8884601e9326a0888fd08b4f069d8de | /java-musbands-admin.application.test/src/main/java/org/sylrsykssoft/java/musbands/admin/application/test/function/member/MusbandsAdminTestFunctionMemberController.java | d4f3039c9c04e5bfa3b8185234cab973ab1c2175 | [
"Apache-2.0"
] | permissive | sylarsykes/java-musbands-admin | f90a0d380cdc6ae94b335dcb5594b506909f90ea | 1ac5248b5c36e2a2b9e52f51022e8ed528a0382d | refs/heads/master | 2020-07-05T07:12:09.106795 | 2020-03-28T15:56:20 | 2020-03-28T15:56:20 | 202,566,916 | 0 | 2 | Apache-2.0 | 2020-03-28T15:56:21 | 2019-08-15T15:33:10 | Java | UTF-8 | Java | false | false | 4,520 | java | package org.sylrsykssoft.java.musbands.admin.application.test.function.member;
import static org.sylrsykssoft.java.musbands.admin.application.test.configuration.MusbandsAdminTestConstants.CONTROLLER_ADMIN_REQUEST_MAPPING_FUNCTION_MEMBER;
import static org.sylrsykssoft.java.musbands.admin.application.test.configuration.MusbandsAdminTestConstants.CONTROLLER_REQUEST_NAME_FUNCTION_MEMBER;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import org.sylrsykssoft.coreapi.framework.api.resource.ListAdminResource;
import org.sylrsykssoft.coreapi.framework.database.exception.NotFoundEntityException;
import org.sylrsykssoft.coreapi.framework.library.util.LoggerUtil;
import org.sylrsykssoft.coreapi.framework.library.util.LoggerUtil.LogMessageLevel;
import org.sylrsykssoft.coreapi.framework.web.rest.BaseAdminSimpleRestController;
import org.sylrsykssoft.coreapi.framework.web.rest.BaseAdminSimpleRestTemplateController;
import org.sylrsykssoft.java.musbands.admin.client.FunctionMemberRestTemplateController;
import org.sylrsykssoft.java.musbands.admin.function.member.domain.FunctionMember;
import org.sylrsykssoft.java.musbands.admin.function.member.resource.FunctionMemberResource;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
/**
* MusbandsAdminTestFunctionMemberController
*
* @author juan.gonzalez.fernandez.jgf
*/
@RestController
@RequestMapping(CONTROLLER_ADMIN_REQUEST_MAPPING_FUNCTION_MEMBER)
public class MusbandsAdminTestFunctionMemberController
extends BaseAdminSimpleRestController<FunctionMemberResource, FunctionMember> {
@Value("${coreapi.framework.rest.base-path}")
private String basePath;
@Value("${coreapi.framework.simple.rest.base-path}")
private String baseSimplePath;
@Value("${coreapi.framework.audit.rest.base-path}")
private String baseAuditPath;
@Autowired
private FunctionMemberRestTemplateController functionMemberControllerRestTemplate;
@PostMapping(produces = { MediaTypes.HAL_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public List<FunctionMemberResource> createAll() {
final List<FunctionMemberResource> result = new ArrayList<>();
// https://www.baeldung.com/java-snake-yaml
final Yaml yaml = new Yaml(new Constructor(ListAdminResource.class));
final InputStream inputStream = this.getClass()
.getClassLoader()
.getResourceAsStream("yaml/functionMembers.yaml");
final ListAdminResource<FunctionMemberResource> sources = yaml.load(inputStream);
final UriComponents url = UriComponentsBuilder.fromHttpUrl(basePath)
.path("/" + CONTROLLER_REQUEST_NAME_FUNCTION_MEMBER).build();
sources.getAdminResources().stream()
.forEach(resource -> result.add(functionMemberControllerRestTemplate.create(url.toString(), resource)));
return result;
}
/**
* Find all entries.
*
* @return Iterable<T> entries.
*
* @throws NotFoundEntityException
*/
@GetMapping(produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
@ResponseStatus(HttpStatus.FOUND)
public Iterable<FunctionMemberResource> findAll() throws NotFoundEntityException {
LoggerUtil.message(LogMessageLevel.INFO, "BaseAdminSimpleRestController::findAll Finding all entries");
final UriComponents url = UriComponentsBuilder.fromHttpUrl(basePath)
.path("/" + CONTROLLER_REQUEST_NAME_FUNCTION_MEMBER).build();
final Iterable<FunctionMemberResource> result = getRestTemplateController().findAll(url.toString());
LoggerUtil.message(LogMessageLevel.INFO, "BaseAdminSimpleRestController::findAll Result -> {}", result);
return result;
}
/**
* {@inheritDoc}
*/
@Override
public BaseAdminSimpleRestTemplateController<FunctionMemberResource, FunctionMember> getRestTemplateController() {
return functionMemberControllerRestTemplate;
}
}
| [
"sylar.sykes@gmail.com"
] | sylar.sykes@gmail.com |
f9895dee53b513f4cd6e0fbbf3abb89a0c11e7ae | 8bc83886613c5327d82d22131ee172f91ecb2a0b | /src/main/java/com/dinglicom/order/service/impl/UserAddressServiceImpl.java | 4189a0aac7e2312082bac94283477f02a029c0c9 | [
"Apache-2.0"
] | permissive | pzjack/webframe | a6e9cc62c9f2db7e8849424f40c2e53be4fcd41b | 0b6fdecf6fd5e6f7948b7b5d834c1f79f5da1dda | refs/heads/master | 2021-01-21T21:54:28.716018 | 2016-03-23T11:09:20 | 2016-03-23T11:09:20 | 31,644,044 | 0 | 1 | null | 2016-03-23T11:09:20 | 2015-03-04T07:30:35 | Java | UTF-8 | Java | false | false | 2,070 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dinglicom.order.service.impl;
import com.dinglicom.order.entity.UserAddress;
import com.dinglicom.order.repository.UserAddressDao;
import com.dinglicom.order.service.UserAddressService;
import java.util.Iterator;
import javax.annotation.Resource;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/**
*
* @author panzhen
*/
@Component
@Transactional
@CacheConfig(cacheNames = {"dataCache"})
public class UserAddressServiceImpl implements UserAddressService {
@Resource
private UserAddressDao userAddressDao;
@Override
@Transactional(readOnly = true)
@Cacheable
public UserAddress read(long id) {
return userAddressDao.findOne(id);
}
@Override
@Cacheable
public UserAddress save(UserAddress userAddress) {
return userAddressDao.save(userAddress);
}
@Override
@CacheEvict
public void delete(UserAddress userAddress) {
userAddressDao.delete(userAddress);
}
@Override
@CacheEvict
public void delete(long id) {
userAddressDao.delete(id);
}
@Override
@Transactional(readOnly = true)
public Iterable<UserAddress> findByUserId(Long userId) {
Page<UserAddress> page = userAddressDao.findByUserInfoId(new PageRequest(0, 20), false, userId);
return page.getContent();
}
@Override
public UserAddress findFirstByUserId(Long userId) {
Iterator<UserAddress> it = findByUserId(userId).iterator();
if(it.hasNext()) {
return it.next();
}
return null;
}
} | [
"panzhen.jack@gmail.com"
] | panzhen.jack@gmail.com |
2f7a383fdd3c6040ddfefd6d584e9d7e6068575a | b73050e41bfe33953b08d0b0b635f448ef982adb | /src/main/java/com/huayin/common/util/RSASignatureHelper.java | 133b76a9757be606ce1ba4639d3fcb1331156069 | [] | no_license | ty4cheung/print-common | d2f7ff5bf1415bf3eb758fd17af16d24832c3fdb | ba0dc8de158753496c31ac7586ebca12dba23798 | refs/heads/master | 2021-06-18T19:51:34.086323 | 2017-06-15T08:11:00 | 2017-06-15T08:11:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,718 | java | /**
* <pre>
* Title: SignatureHelper.java
* Author: linriqing
* Create: 2010-5-18 下午03:18:51
* Copyright: Copyright (c) 2010
* Company: Shenzhen Helper
* <pre>
*/
package com.huayin.common.util;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import javax.crypto.Cipher;
/**
* <pre>
* RSA签名加密解密工具类
* </pre>
* @author linriqing
* @version 1.0, 2010-5-18
* @version 1.1, 2013-3-26
*/
public class RSASignatureHelper
{
private static final String KEY_ALGORITHM = "RSA";
private static final int KEY_ALGORITHM_BLOCK_SIZE = 1024;
private static final String RSA_NONE_PKCS1_PADDING = "RSA/ECB/PKCS1Padding";
private static final String SIGNATURE_ALGORITHM = "SHA1withRSA";
/**
* 解密<br>
* 用私钥解密
* @param data
* @param key
* @return
* @throws Exception
*/
public static String decryptByPrivateKey(String dec, String priKey, String encoding)
throws GeneralSecurityException
{
// 对密钥解密
byte[] keyBytes = HexStringHelper.hexStrToBytes(priKey.trim());
// 取得私钥
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
// 对数据解密
Cipher cipher = Cipher.getInstance(RSA_NONE_PKCS1_PADDING);
cipher.init(Cipher.DECRYPT_MODE, privateKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
return new String(cipher.doFinal(HexStringHelper.hexStrToBytes(dec)), encoding);
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
}
/**
* 解密<br>
* 用公钥解密
* @param data
* @param key
* @return
* @throws Exception
*/
public static String decryptByPublicKey(String dec, String pubkey, String encoding) throws GeneralSecurityException
{
// 对密钥解密
byte[] keyBytes = HexStringHelper.hexStrToBytes(pubkey.trim());
// 取得公钥
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key publicKey = keyFactory.generatePublic(x509KeySpec);
// 对数据解密
Cipher cipher = Cipher.getInstance(RSA_NONE_PKCS1_PADDING);
cipher.init(Cipher.DECRYPT_MODE, publicKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
return new String(cipher.doFinal(HexStringHelper.hexStrToBytes(dec)), encoding);
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
}
/**
* 加密<br>
* 用私钥加密
* @param data
* @param key
* @return
* @throws Exception
*/
public static String encryptByPrivateKey(String src, String priKey, String encoding)
throws GeneralSecurityException
{
// 对密钥解密
byte[] keyBytes = HexStringHelper.hexStrToBytes(priKey.trim());
// 取得私钥
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(RSA_NONE_PKCS1_PADDING);
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
return HexStringHelper.bytesToHexStr(cipher.doFinal(src.getBytes(encoding)));
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
}
/**
* 加密<br>
* 用公钥加密
* @param data
* @param key
* @return
* @throws Exception
*/
public static String encryptByPublicKey(String src, String pubkey, String encoding) throws GeneralSecurityException
{
// 对公钥解密
byte[] keyBytes = HexStringHelper.hexStrToBytes(pubkey.trim());
// 取得公钥
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key publicKey = keyFactory.generatePublic(x509KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(RSA_NONE_PKCS1_PADDING);
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
return HexStringHelper.bytesToHexStr(cipher.doFinal(src.getBytes(encoding)));
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
}
/**
* <pre>
* 生成1024位RSA公私钥对
* </pre>
* @return 公私钥对数组,第一个元素是公钥,第二个是私钥
* @throws GeneralSecurityException 签名异常
*/
public static String[] genKeyPair() throws GeneralSecurityException
{
KeyPairGenerator rsaKeyGen = null;
KeyPair rsaKeyPair = null;
rsaKeyGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
SecureRandom random = new SecureRandom();
String valueOf = String.valueOf(System.currentTimeMillis());
List<String> list = new ArrayList<String>();
for (int i = 0; i < valueOf.length(); i++)
{
list.add(String.valueOf(valueOf.charAt(i)));
}
Collections.shuffle(list, new Random(System.currentTimeMillis()));
StringBuffer sb = new StringBuffer();
for (String string : list)
{
sb.append(string);
}
random.setSeed(sb.toString().getBytes());
rsaKeyGen.initialize(KEY_ALGORITHM_BLOCK_SIZE, random);
rsaKeyPair = rsaKeyGen.genKeyPair();
PublicKey rsaPublic = rsaKeyPair.getPublic();
PrivateKey rsaPrivate = rsaKeyPair.getPrivate();
String[] keys = new String[2];
keys[0] = HexStringHelper.bytesToHexStr(rsaPublic.getEncoded());
keys[1] = HexStringHelper.bytesToHexStr(rsaPrivate.getEncoded());
return keys;
}
/**
* <pre>
* 使用SHA1withRSA签名算法进行签名
* </pre>
* @param priKey 签名时使用的私钥(16进制编码)
* @param src 签名的原字符串
* @param encoding 字符编码
* @return 签名的返回结果(16进制编码)
* @throws GeneralSecurityException
*/
public static String signature(String priKey, String src, String encoding) throws GeneralSecurityException
{
Signature sigEng = Signature.getInstance(SIGNATURE_ALGORITHM);
byte[] pribyte = HexStringHelper.hexStrToBytes(priKey.trim());
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pribyte);
KeyFactory fac = KeyFactory.getInstance(KEY_ALGORITHM);
RSAPrivateKey privateKey = (RSAPrivateKey) fac.generatePrivate(keySpec);
sigEng.initSign(privateKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
sigEng.update(src.getBytes(encoding));
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
byte[] signature = sigEng.sign();
return HexStringHelper.bytesToHexStr(signature);
}
/**
* <pre>
* 使用RSA签名算法验证签名
* </pre>
* @param pubKey 验证签名时使用的公钥(16进制编码)
* @param sign 签名结果(16进制编码)
* @param src 签名的原字符串
* @param encoding 字符编码
* @return 签名的返回结果(16进制编码)
* @throws GeneralSecurityException 签名异常
*/
public static boolean verify(String pubKey, String sign, String src, String encoding)
throws GeneralSecurityException
{
Signature sigEng = Signature.getInstance(SIGNATURE_ALGORITHM);
byte[] pubbyte = HexStringHelper.hexStrToBytes(pubKey.trim());
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(pubbyte);
KeyFactory fac = KeyFactory.getInstance(KEY_ALGORITHM);
RSAPublicKey rsaPubKey = (RSAPublicKey) fac.generatePublic(keySpec);
sigEng.initVerify(rsaPubKey);
if (encoding == null)
{
encoding = "ISO-8859-1";
}
try
{
sigEng.update(src.getBytes(encoding));
}
catch (UnsupportedEncodingException e)
{
throw new GeneralSecurityException(e);
}
byte[] sign1 = HexStringHelper.hexStrToBytes(sign);
return sigEng.verify(sign1);
}
}
| [
"Administrator@172.31.2.75"
] | Administrator@172.31.2.75 |
6c1be1ba9fd1a59d69575c391bcb7ff5bda0d7b8 | 40c15e0c8ffa5ea08c5cf2972bc210ee9673aa96 | /app/src/main/java/com/androiduniverse/coquardmassard/androiduniverse/CustomList.java | 6d34f0eb8cf2d8d776764664d7b392079fe1624d | [] | no_license | tbobm/TIC-MOBI | 2708829ce2c6b817a7d7ff3369f3c1f66bcdc7d4 | 21248e4ac45ebdfbc64668a28acfe5fc411453c6 | refs/heads/master | 2021-03-27T08:40:07.397159 | 2017-09-30T13:16:25 | 2017-09-30T13:16:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,268 | java | package com.androiduniverse.coquardmassard.androiduniverse;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
/**
* Created by alexiscoquard on 19/04/2017.
*/
public class CustomList extends ArrayAdapter<String> {
private final Activity context;
private final List<String> artists;
private final List<String> pictures;
public CustomList(Activity context, List<String> artists, List<String> pictures) {
super(context, R.layout.picture_list, artists);
this.context = context;
this.artists = artists;
this.pictures = pictures;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.picture_list, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.txt);
final ImageView imageView = (ImageView) rowView.findViewById(R.id.img);
//txtTitle.setText(web[position]);
txtTitle.setText(artists.get(position));
URL url = null;
try {
url = new URL(pictures.get(position));
} catch (MalformedURLException e) {
e.printStackTrace();
}
final Bitmap[] bmp = {null};
final URL finalUrl = url;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
try {
bmp[0] = BitmapFactory.decodeStream(finalUrl.openConnection().getInputStream());
imageView.setImageBitmap(bmp[0]);
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
return rowView;
}
} | [
"coquar_a@etna-alternance.net"
] | coquar_a@etna-alternance.net |
52c470f3ecacf92ffc17d533df2719e69bcd60e5 | 04dd0a5d51889fb26611e88f1c143f98362efc55 | /src/test/java/GeneGroupId1/GeneMavenTestProj1/AppTest.java | 3bb3e25acf5709125284ebacb51de595d559bc4a | [] | no_license | GeneChuang1/GeneMavenTestProj1 | ce14d7e42889e1e5faf2e2657af1f0de09e6fcfc | d8c9306e37ff422b172ce4402c8c5baff8e05aad | refs/heads/master | 2021-04-09T12:53:25.033323 | 2016-07-12T23:01:27 | 2016-07-12T23:01:27 | 63,104,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 659 | java | package GeneGroupId1.GeneMavenTestProj1;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| [
"gc.genechuang@gmail.com"
] | gc.genechuang@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.