blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
132
path
stringlengths
2
382
src_encoding
stringclasses
34 values
length_bytes
int64
9
3.8M
score
float64
1.5
4.94
int_score
int64
2
5
detected_licenses
listlengths
0
142
license_type
stringclasses
2 values
text
stringlengths
9
3.8M
download_success
bool
1 class
cd584abe9752d1504f09ffd92ae50a65708e149f
Java
abrasset-esiee/PekaPizZ
/project/src/controller/AdresseController.java
UTF-8
3,079
2.75
3
[]
no_license
package controller; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import Model.Adresse; import Model.Client; import dao.JDBConnection; import dao.AdresseDAO; public class AdresseController implements AdresseDAO { private static final String FIND_ADDRESS_REQ = "SELECT id_adresse, Numero_rue, nom_rue, code_postal, ville FROM Adresse WHERE id_adresse = ?"; private static final String FIND_ADDRESS_C_REQ = "SELECT id_adresse, Numero_rue, nom_rue, code_postal, ville FROM Adresse WHERE Numero_rue = ? AND nom_rue = ? AND code_postal = ? AND ville = ?"; private static final String CREATE_ADRESSE = "INSERT INTO Adresse (Numero_rue, nom_rue, code_postal, ville) VALUES (?, ?, ?, ?)"; @Override public Adresse findByCriterias(Adresse adresse) throws SQLException { Connection con = null; Adresse a1 = null; try { con = JDBConnection.getConnection(); PreparedStatement stmt = con.prepareStatement(FIND_ADDRESS_C_REQ); stmt.setString(1, adresse.getNumero_rue()); stmt.setString(2, adresse.getNom_rue()); stmt.setString(3, adresse.getCode_postal()); stmt.setString(4, adresse.getVille()); // émet une requête de type Select ResultSet result = stmt.executeQuery(); // affiche les lignes/colonnes du résultat // (result.next() permet de passer à la ligne de résultat suivant) result.next(); a1 = new Adresse( result.getInt("id_adresse"), result.getString("Numero_rue"), result.getString("nom_rue"), result.getString("code_postal"), result.getString("ville") ); } catch (SQLException e) { System.err.println("Erreur d'exécution: " + e.getMessage()); } return a1; } @Override public Adresse findByID(int id) throws SQLException { Connection con = null; Adresse a1 = null; try { con = JDBConnection.getConnection(); PreparedStatement stmt = con.prepareStatement(FIND_ADDRESS_REQ); stmt.setInt(1, id); // émet une requête de type Select ResultSet result = stmt.executeQuery(); // affiche les lignes/colonnes du résultat // (result.next() permet de passer à la ligne de résultat suivant) result.next(); a1 = new Adresse( result.getInt("id_adresse"), result.getString("Numero_rue"), result.getString("nom_rue"), result.getString("code_postal"), result.getString("ville") ); } catch (SQLException e) { System.err.println("Erreur d'exécution: " + e.getMessage()); } return a1; } @Override public Adresse create(Adresse obj) { Connection con = null; try { con = JDBConnection.getConnection(); PreparedStatement stmt = con.prepareStatement(CREATE_ADRESSE); stmt.setString(1, obj.getNumero_rue()); stmt.setString(2, obj.getNom_rue()); stmt.setString(3, obj.getCode_postal()); stmt.setString(4, obj.getVille()); stmt.executeUpdate(); } catch (SQLException e) { System.err.println("Erreur d'exécution: " + e.getMessage()); } return obj; } }
true
0f12b844aa83bb6d05e04611ecae3f906f284640
Java
csys-fresher-batch-2021/foodapp-core-ramesh
/src/main/java/in/ramesh/servlet/DisplayAllDetailsServlet.java
UTF-8
1,776
2.296875
2
[]
no_license
package in.ramesh.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import in.ramesh.model.PaymentModel; import in.ramesh.service.PaymentService; import in.ramesh.util.Logger; /** * Servlet implementation class DisplayAllDetailsServlet */ @WebServlet("/DisplayAllDetailsServlet") public class DisplayAllDetailsServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Logger log = new Logger(); HttpSession session = request.getSession(); log.print("############### Display servlet works#################"); String finalAmount = (String) session.getAttribute("amount"); String hotelName = (String) session.getAttribute("hotelName"); String status = (String) session.getAttribute("status"); String username = (String) session.getAttribute("LOGGED_IN_USER"); log.print(username); PaymentModel payment = new PaymentModel(); payment.setHotelName(hotelName); payment.setAmount(finalAmount); payment.setStatus(status); payment.setUsername(username); boolean isCorrect = PaymentService.addPaymentDetails(payment); if (isCorrect) { String message = "Successfully Added"; response.sendRedirect("DisplayAllDetails.jsp?message=" + message); } else { String errorMessage = "Unable to update status"; response.sendRedirect("BillGenerator.jsp?errorMessage=" + errorMessage); } } }
true
fdbcaf9ccf809fb38dca63a49a8b92e551607113
Java
ArthurGerasimov/alfamind
/Activity/TarikViaAlfamartActivity.java
UTF-8
1,393
1.820313
2
[]
no_license
package id.meteor.alfamind.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.widget.ImageView; import android.widget.TextView; import id.meteor.alfamind.Base.BaseActivity; import id.meteor.alfamind.R; public class TarikViaAlfamartActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_tarik_via_alfamart); TextView next = findViewById(R.id.next); ImageView back_btn = findViewById(R.id.back_btn); back_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(TarikViaAlfamartActivity.this, SaldoWebViewActivity.class); i.putExtra("DATA", "GENERATE TOKEN"); startActivity(i); overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); } }); } }
true
d1ff135caedc40784816bebcb03d8798868f5dcf
Java
kavt/feiniu_pet
/pet_public/src/main/java/com/lvmama/pet/fin/dao/FinanceDepositDAO.java
UTF-8
3,817
2.34375
2
[]
no_license
package com.lvmama.pet.fin.dao; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.stereotype.Repository; import com.lvmama.comm.BaseIbatisDAO; import com.lvmama.comm.pet.po.fin.FinDeposit; import com.lvmama.comm.pet.po.fin.FinSupplierMoney; import com.lvmama.comm.pet.vo.Page; /** * 押金管理/预警 * @author zhangwenjun * */ @Repository @SuppressWarnings("unchecked") public class FinanceDepositDAO extends BaseIbatisDAO { /** * 查询流水记录 * * @param type * 类型 押金/担保函 * @param supplierId * 供应商ID * @return */ public List<FinDeposit> searchDepositRecord(Map<String,Object> map) { return super.queryForList("FINANCE_DEPOSIT.searchDepositRecord", map); } public Long searchDepositRecordCount(Map<String,Object> map) { return (Long)super.queryForObject("FINANCE_DEPOSIT.searchDepositRecordCount", map); } /** * 更新供应商押金金额 * * @param supplierId * 供应商ID * @param amount * 金额 */ public void updateSupplierDepositAmount(Long supplierId, Long amount) { Map<String, Long> map = new HashMap<String, Long>(); map.put("amount", amount); map.put("supplierId", supplierId); super.update("FINANCE_DEPOSIT.updateSupplierDepositAmount", map); } /** * 更新供应商担保函额度 * * @param supplierId * 供应商ID * @param amount * 金额 */ public void updateSupplierGuaranteeLimit(Long supplierId, Long amount) { Map<String, Long> map = new HashMap<String, Long>(); map.put("amount", amount); map.put("supplierId", supplierId); super.update("FINANCE_DEPOSIT.updateSupplierGuaranteeLimit", map); } /** * 新增流水记录 * * @param fincDeposit * 押金信息 */ public void insertFincDeposit(FinDeposit fincDeposit) { super.insert("FINANCE_DEPOSIT.insertFincDeposit", fincDeposit); } /** * 查询押金、担保函金额 * * @param type * 类型 * @param supplierId * 供应商ID */ public Double searchAmount(String type, Long supplierId) { Map<String,Object> map = new HashMap<String,Object>(); map.put("type", type); map.put("supplierId", supplierId); return (Double) super.queryForObject("FINANCE_DEPOSIT.searchAmount",map); } /** * 查询供应商押金预警 * * @return */ public Page<FinSupplierMoney> searchDepositWarning(Map<String,Object> map) { return super.queryForPage("FINANCE_DEPOSIT.searchDepositWarning", map); } /** * 查询供应商的预存款余额 * * @param supplierId * 供应商ID * @return */ public FinSupplierMoney searchSupplier(Long supplierId) { return (FinSupplierMoney)super.queryForObject("FINANCE_DEPOSIT.searchSupplierCash",supplierId); } /** * 更新供应商押金币种 * * @param supplierId * 供应商ID * @param amount * 金额 */ public void updateSupplierCurrency(Long supplierId, String currency) { Map<String, Object> map = new HashMap<String, Object>(); map.put("currency", currency); map.put("supplierId", supplierId); super.update("FINANCE_DEPOSIT.updateSupplierCurrency", map); } /** * 更新供应商押金币种 * * @param supplierId * 供应商ID * @param amount * 金额 */ public void updateSupplierForecurrency(Long supplierId, String advcurrency) { Map<String,Object> map = new HashMap<String,Object>(); map.put("advcurrency", advcurrency); map.put("supplierId", supplierId); super.update("FINANCE_DEPOSIT.updateSupplierCurrency", map); } }
true
9a77a66477d5d743a1c963de71048d2cfa23b9d4
Java
chourabi/javaahmed
/Tuto/src/Cat.java
UTF-8
528
3.578125
4
[]
no_license
public class Cat extends Animal { String name; public Cat(String name) throws ErrException{ if( name.length() >=3 ){ this.name= name; }else{ throw new ErrException("Sorry cat name cannot be less than 3 chas"); } } public void animalSleep(){ System.out.print("Cat is zZzZz"); } public void animalSleep(int hours) throws SleepException { if( hours <= 5 ){ System.out.print("Cat is zZzZz"); }else{ throw new SleepException("Sorry cat cannot sleep more than 5 hours"); } } }
true
74f2cbc317afe7f2d50ca483f779f822495245a5
Java
XDFHTY/oil
/excle-check/src/main/java/com/cj/exclecheck/service/ExamineService.java
UTF-8
719
1.726563
2
[]
no_license
package com.cj.exclecheck.service; import com.cj.core.domain.ApiResult; import javax.servlet.http.HttpServletRequest; import java.util.Map; /** * Created by XD on 2018/10/23. */ public interface ExamineService { //提交审核 ApiResult submit(Map map, HttpServletRequest request); //审核 通过或驳回 ApiResult examine(Map map, HttpServletRequest request); //查询审核结果 ApiResult examineResult(String year, HttpServletRequest request); /** * 查询待审核 */ ApiResult unaudited(String year, HttpServletRequest request,int currentPage); //查询提交信息详情 ApiResult getInfo(String year, Long stationId, HttpServletRequest request); }
true
c79a38e510d37604ad82195e638feec7b66e2646
Java
EstebanDalelR/tinderAnalysis
/apk/decompiled/com.tinder_2018-07-26_source_from_JADX/sources/com/tinder/managers/az.java
UTF-8
1,352
1.828125
2
[]
no_license
package com.tinder.managers; import com.android.volley.Response.ErrorListener; import com.android.volley.VolleyError; import com.tinder.listeners.ListenerPhoto; import com.tinder.model.ProfilePhoto; final /* synthetic */ class az implements ErrorListener { /* renamed from: a */ private final ManagerProfile f39041a; /* renamed from: b */ private final boolean f39042b; /* renamed from: c */ private final ListenerPhoto f39043c; /* renamed from: d */ private final int f39044d; /* renamed from: e */ private final ProfilePhoto f39045e; /* renamed from: f */ private final int f39046f; /* renamed from: g */ private final String f39047g; /* renamed from: h */ private final int f39048h; az(ManagerProfile managerProfile, boolean z, ListenerPhoto listenerPhoto, int i, ProfilePhoto profilePhoto, int i2, String str, int i3) { this.f39041a = managerProfile; this.f39042b = z; this.f39043c = listenerPhoto; this.f39044d = i; this.f39045e = profilePhoto; this.f39046f = i2; this.f39047g = str; this.f39048h = i3; } public void onErrorResponse(VolleyError volleyError) { this.f39041a.a(this.f39042b, this.f39043c, this.f39044d, this.f39045e, this.f39046f, this.f39047g, this.f39048h, volleyError); } }
true
45ba6822b681be2d816321af1bc066a3804a6e6a
Java
colacod/rest-project-campeonato
/src/main/java/br/com/project/service/impl/PlayoffServiceImpl.java
UTF-8
2,597
2.15625
2
[]
no_license
package br.com.project.service.impl; import javax.transaction.Transactional; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.hateoas.Link; import org.springframework.stereotype.Service; import br.com.project.constantes.ApplicationConstantes; import br.com.project.entity.PlayoffEntity; import br.com.project.exception.RecordAlreadyExistsException; import br.com.project.exception.RegisterNotFoundException; import br.com.project.repository.PlayoffRepository; import br.com.project.resource.Playoff; import br.com.project.service.PlayoffService; @Service @Transactional public class PlayoffServiceImpl implements PlayoffService { @Autowired private PlayoffRepository repository; @Autowired private ModelMapper modelMapper; @Override public Page<PlayoffEntity> get(Playoff playoff, Pageable page, Link link) { PlayoffEntity entity = getPlayoffEntityBuilder(playoff); Page<PlayoffEntity> playoffs = repository.findAll(Example.of(entity), page); if (playoffs.isEmpty()) { throw new RegisterNotFoundException(playoff, ApplicationConstantes.LOG_REGISTER_NOT_FOUND_EXCEPTION, link); } return playoffs; } @Override public Playoff save(Playoff playoff, Link link) { repository.findById(playoff.getIdPlayoff()).ifPresent(entity -> { throw new RecordAlreadyExistsException(playoff, ApplicationConstantes.LOG_RECORD_ALREADY_EXISTS_EXCEPTION, link); }); PlayoffEntity entity = getPlayoffEntityBuilder(playoff); return modelMapper.map(repository.saveAndFlush(entity), Playoff.class); } @Override public Playoff update(Playoff playoff, Link link) { return repository.findById(playoff.getIdPlayoff()).map(entity -> { return modelMapper.map(repository.save(getPlayoffEntityBuilder(playoff)), Playoff.class); }).orElseThrow(() -> new RegisterNotFoundException(playoff, ApplicationConstantes.LOG_REGISTER_NOT_FOUND_EXCEPTION, link)); } @Override public Boolean delete(Long id, Link link) { return repository.findById(id).map(entity -> { repository.delete(entity); return Boolean.TRUE; }).orElseThrow( () -> new RegisterNotFoundException(id, ApplicationConstantes.LOG_REGISTER_NOT_FOUND_EXCEPTION, link)); } private PlayoffEntity getPlayoffEntityBuilder(Playoff playoff) { return modelMapper.map(playoff, PlayoffEntity.class); } }
true
8c60b33e7b7d085965d0fd955d5dfbd66418e53c
Java
vnSasa/DOCKER_Air-companies-Management-System
/src/main/java/com/air/companies/management/system/repository/AirCompanyRepository.java
UTF-8
363
1.976563
2
[]
no_license
package com.air.companies.management.system.repository; import com.air.companies.management.system.model.AirCompany; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository public interface AirCompanyRepository extends CrudRepository<AirCompany, Long> { AirCompany findByName(String name); }
true
2f1947960a5a9724f6b88607c6212f6d3ab5c0a6
Java
lmk1010/MKCommonSDK
/MK-Common/src/main/java/com/mk/common/utils/network/NetUtils.java
UTF-8
3,414
2.53125
3
[]
no_license
package com.mk.common.utils.network; import com.google.common.base.Charsets; import com.mk.common.constant.ErrCodeContant; import com.mk.common.exception.MKException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.IOException; import java.net.URISyntaxException; import java.util.List; /** * @Author liumingkang * @Date 2019-09-06 20:10 * @Destcription TODO HTTP请求工具类 * @Version 1.0 **/ public class NetUtils { public static String getRequest(String path, List<NameValuePair> parametersBody) throws Exception { URIBuilder uriBuilder = new URIBuilder(path); uriBuilder.setParameters(parametersBody); HttpGet get = new HttpGet(uriBuilder.build()); CloseableHttpClient client = HttpClientBuilder.create().build(); try { HttpResponse response = client.execute(get); int code = response.getStatusLine().getStatusCode(); if (code >= 400) throw new RuntimeException((new StringBuilder()).append("Could not access protected resource. Server returned http code: ").append(code).toString()); return EntityUtils.toString(response.getEntity()); } catch (Exception e) { throw new MKException(ErrCodeContant.SERVER_FAILED,e); } finally { get.releaseConnection(); } } // 发送POST请求(普通表单形式) public static String postForm(String path, List<NameValuePair> parametersBody) throws Exception{ HttpEntity entity = new UrlEncodedFormEntity(parametersBody, Charsets.UTF_8); return postRequest(path, "application/x-www-form-urlencoded", entity); } // 发送POST请求(JSON形式) public static String postJSON(String path, String json) throws Exception { StringEntity entity = new StringEntity(json, Charsets.UTF_8); return postRequest(path, "application/json", entity); } // 发送POST请求 public static String postRequest(String path, String mediaType, HttpEntity entity) throws Exception { HttpPost post = new HttpPost(path); post.addHeader("Content-Type", mediaType); post.addHeader("Accept", "application/json"); post.setEntity(entity); try { CloseableHttpClient client = HttpClientBuilder.create().build(); HttpResponse response = client.execute(post); int code = response.getStatusLine().getStatusCode(); if (code >= 400) throw new Exception(EntityUtils.toString(response.getEntity())); return EntityUtils.toString(response.getEntity()); } catch (Exception e) { throw new MKException("postRequest -- Client protocol exception!", e); } finally { post.releaseConnection(); } } }
true
0cc84b4949a1a7f4dbbb54d9346acc90004055eb
Java
bpjoshi/rest
/src/main/java/com/bpjoshi/fxservice/service/FxServiceEvent.java
UTF-8
498
1.84375
2
[]
no_license
package com.bpjoshi.fxservice.service; import org.springframework.context.ApplicationEvent; /** * @author bpjoshi(Bhagwati Prasad) * Publishing application events, like to inject events into the Spring * Boot audit management */ public class FxServiceEvent extends ApplicationEvent { private static final long serialVersionUID = 1L; public FxServiceEvent(Object source) { super(source); } public String toString() { return "FxService Event"; } }
true
0afb19d0bd4cdcc6f193de455cfc7b864ad19975
Java
AlphaRishi1229/Admission-And-Railway-Concession-Android-Application
/app/src/main/java/com/example/rishivijaygajelli/pillaiadmissionconcession/AdminSignUpActivity.java
UTF-8
4,162
2.265625
2
[]
no_license
package com.example.rishivijaygajelli.pillaiadmissionconcession; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; public class AdminSignUpActivity extends AppCompatActivity { EditText etnewusername, etnewpassword, etnewphone; Button btnsignup; Connection connect; String ConnectionResult = ""; Boolean isSuccess = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_admin_sign_up); etnewusername = (EditText)findViewById(R.id.etnewusername); etnewpassword = (EditText)findViewById(R.id.etnewpassword); etnewphone = (EditText)findViewById(R.id.etnewphone); btnsignup = (Button)findViewById(R.id.btnsignup); btnsignup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = etnewusername.getText().toString(); String password = etnewpassword.getText().toString(); String phone = etnewphone.getText().toString(); if(username.equals("") || password.equals("") || phone.equals("")) { Toast.makeText(getApplicationContext(), "Please fill all the details!", Toast.LENGTH_SHORT).show(); } else { Send objSend = new Send(); objSend.execute(""); } } }); } private class Send extends AsyncTask<String, String, String> { String msg = ""; String username = etnewusername.getText().toString(); String password = etnewpassword.getText().toString(); String phone = etnewphone.getText().toString(); @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... strings) { try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); ConnectionHelper conStr = new ConnectionHelper(); connect = conStr.connection(); if (connect == null) { msg = "Check connection"; Toast.makeText(getApplicationContext(), "Check Connection", Toast.LENGTH_SHORT).show(); } else { String query = "Insert into dbo.admin_authentication(AdminID, AdminPwd, AdminPhone)" + "values ('"+username+"','"+password+"','"+phone+"')"; Statement statement = connect.createStatement(); statement.executeUpdate(query); msg = "Successfully inserted data"; } connect.close(); } catch (SQLException se) { msg = "Sql Exception"; // Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_LONG).show(); Log.e("error here 1 : ", se.getMessage()); } catch (ClassNotFoundException e) { msg = "Class Not Found"; // Toast.makeText(getActivity(),msg,Toast.LENGTH_LONG).show(); Log.e("error here 2 : ", e.getMessage()); } return msg; } @Override protected void onPostExecute(String s) { String otpPhone = "7977052177"; Intent otpIntent = new Intent(AdminSignUpActivity.this, AdminAuthActivity.class); Bundle bundle = new Bundle(); bundle.putString("username",username); bundle.putString("phone",otpPhone); otpIntent.putExtras(bundle); startActivity(otpIntent); } } }
true
7cf69e7c86619e5fdcae5b3ad319ea5d8988f916
Java
bcarrascoi/Practica-de-laboratorio-02-Agenda-Telefonica-en-JEE
/AgendaTelefonica/src/ec/edu/ups/servlets/ControladorValidacionLogin.java
UTF-8
1,270
2.25
2
[]
no_license
package ec.edu.ups.servlets; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet Filter implementation class ControladorValidacionLogin */ @WebFilter("/ControladorValidacionLogin") public class ControladorValidacionLogin implements Filter { public ControladorValidacionLogin() { } public void init(FilterConfig fConfig) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession sesion = ((HttpServletRequest) request).getSession(); if (sesion.getAttribute("usuario") != null) { chain.doFilter(request, response); } else { ((HttpServletResponse) response).sendRedirect("/Calculadora/error.html"); destroy(); } } public void destroy() { System.out.println("Se ha destruido el filtro..."); } }
true
d8dd7e49dc0dfa8391e2d2e3451bbf7e7206cbdd
Java
njinuann/VFC-Nida
/src/java/DAO/DBManager.java
UTF-8
1,542
2.609375
3
[]
no_license
package DAO; import java.io.Serializable; import java.util.ArrayList; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author neptune */ public class DBManager implements Serializable { static ArrayList<TDClient> dBUtilities = new ArrayList<>(); static int connectinPoolSize = 10; public static void initialise() { for (int i = 0; i < connectinPoolSize; i++) { TDClient dBUtility = new TDClient(); dBUtilities.add(dBUtility); } } public static synchronized TDClient fetchDBUtility() { TDClient DBUtility = null; if (dBUtilities.size() > 0) { DBUtility = dBUtilities.get(0); dBUtilities.remove(DBUtility); } else { DBUtility = new TDClient(); } return DBUtility; } public static synchronized void releaseDBUtility(TDClient DBUtility) { if (dBUtilities.size() < connectinPoolSize) { dBUtilities.add(DBUtility); } else { DBUtility.dispose(); } } public static synchronized void disposeProcessors() { for (TDClient dbUtility : dBUtilities) { try { dbUtility.dispose(); } catch (Exception ex) { } } } }
true
fc289bbb58ba6c72a151475c05f4bb31549382ee
Java
spotify/hdfs2cass
/src/main/java/com/spotify/hdfs2cass/LegacyHdfsToThrift.java
UTF-8
2,184
2.15625
2
[ "Apache-2.0" ]
permissive
/* * Copyright 2014 Spotify AB. All rights reserved. * * The contents of this file are 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.spotify.hdfs2cass; import com.google.common.base.Objects; import com.spotify.hdfs2cass.cassandra.utils.CassandraRecordUtils; import com.spotify.hdfs2cass.crunch.thrift.ThriftRecord; import org.apache.cassandra.thrift.Mutation; import org.apache.crunch.MapFn; import org.joda.time.DateTimeUtils; import java.nio.ByteBuffer; /** * {@link org.apache.crunch.MapFn} implementation used to transform outdated hdfs2cass source format * into records suitable for being inserted into non-CQL/Thrift Cassandra table. * * @deprecated Prefer CQL, see {@link LegacyHdfsToCQL} */ @Deprecated public class LegacyHdfsToThrift extends MapFn<ByteBuffer, ThriftRecord> { /** * Thrift-based import requires us to provide {@link org.apache.cassandra.thrift.Mutation}. * Therefore we convert each input line into one. * * @param inputRow byte representation of the input row as it was read from Avro file * @return wraps the record into something that blends nicely into Crunch */ @Override public ThriftRecord map(ByteBuffer inputRow) { LegacyInputFormat row = LegacyInputFormat.parse(inputRow); ByteBuffer key = CassandraRecordUtils.toByteBuffer(row.getRowkey()); long ts = Objects.firstNonNull(row.getTimestamp(), DateTimeUtils.currentTimeMillis()); int ttl = Objects.firstNonNull(row.getTtl(), 0l).intValue(); Mutation mutation = CassandraRecordUtils.createMutation( row.getColname(), row.getColval(), ts, ttl); return ThriftRecord.of(key, mutation); } }
true
f3ec6124a26fd08e7eb21205edc95ec00458f9b3
Java
Shalini8/Employee-payroll
/src/test/java/com/bridgelabz/EmployeePayrollServiceTest.java
UTF-8
7,414
2.734375
3
[]
no_license
package com.bridgelabz; import com.bridgelabz.Exceptions.EmployeePayrollException; import com.bridgelabz.Model.EmployeePayrollData; import com.bridgelabz.Service.EmployeePayrollDBService; import com.bridgelabz.Service.EmployeePayrollService; import org.junit.jupiter.api.Test; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; public class EmployeePayrollServiceTest { @Test public void given3EmployeeWhenWrittenToFileShouldMatchEmployeeEntries() { EmployeePayrollData[] arrayofEmps = { new EmployeePayrollData(1,"shalini",1000000.0), new EmployeePayrollData(2,"shyam",8000000.0), new EmployeePayrollData(3,"shatanu",6000000.0) }; EmployeePayrollService employeePayrollService; employeePayrollService = new EmployeePayrollService(Arrays.asList(arrayofEmps)); employeePayrollService.writeEmployeeData(EmployeePayrollService.IOService.FILE_IO); employeePayrollService.printData(EmployeePayrollService.IOService.FILE_IO); long entries = employeePayrollService.countEntries(EmployeePayrollService.IOService.FILE_IO); assertEquals(3,entries); } @Test public void givenEmployeePayrollInDB_WhenRetrieved_ShouldMatchEmployeeCount() { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); List<EmployeePayrollData> employeePayrollData = employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); assertEquals(5, employeePayrollData.size()); } @Test public void givenNewSalaryForEmployee_WhenUpdated_ShouldSyncWithDatabase() throws EmployeePayrollException { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); List<EmployeePayrollData> employeePayrollData = employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); employeePayrollService.updateEmployeeSalary("Meena",3000000.00, EmployeePayrollDBService.StatementType.STATEMENT, EmployeePayrollService.NormalisationType.DENORMALISED); boolean result = employeePayrollService.checkEmployeePayrollInSyncWithDB("Meena", EmployeePayrollService.NormalisationType.DENORMALISED); assertTrue(result); } @Test public void givenNewSalaryForEmployee_WhenUpdatedUsingPreparedStatement_ShouldSyncWithDatabase() throws EmployeePayrollException { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); List<EmployeePayrollData> employeePayrollData = employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); employeePayrollService.updateEmployeeSalary("Meena",3000000.00, EmployeePayrollDBService.StatementType.PREPARED_STATEMENT, EmployeePayrollService.NormalisationType.DENORMALISED); boolean result = employeePayrollService.checkEmployeePayrollInSyncWithDB("Meena", EmployeePayrollService.NormalisationType.DENORMALISED); assertTrue(result); } @Test public void givenDateRangeForEmployee_WhenRetrievedUsingStatement_ShouldReturnProperData() throws EmployeePayrollException { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); List<EmployeePayrollData> employeePayrollData = employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); List<EmployeePayrollData> employeeDataInGivenDateRange = employeePayrollService.getEmployeesInDateRange("2020-03-04","2021-05-19"); assertEquals(5, employeeDataInGivenDateRange.size()); } @Test public void givenPayrollData_WhenAverageSalaryRetrievedByGender_ShouldReturnProperValue() { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); Map<String,Double> averageSalaryByGender = employeePayrollService.readAverageSalaryByGender(EmployeePayrollService.IOService.DB_IO); System.out.println(averageSalaryByGender); assertTrue(averageSalaryByGender.get("M").equals( 32250.0000)&& averageSalaryByGender.get("F").equals( 1416666.6667)); } @Test public void givenNewEmployee_WhenAdded_ShouldSyncWithDB() { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); employeePayrollService.addEmployeeToPayroll("Zoya",50000000.00, LocalDate.now(),"F"); boolean result = employeePayrollService.checkEmployeePayrollInSyncWithDB("Zoya", EmployeePayrollService.NormalisationType.DENORMALISED); assertTrue(result); } @Test public void given6Employees_WhenAddedToDB_ShouldMatchEmployeeEntries() { EmployeePayrollData[] arrayOfEmps = { new EmployeePayrollData(0,"Jeff Bezos","M",100000.0,LocalDate.now()), new EmployeePayrollData(0,"Bill Gates","M",200000.0,LocalDate.now()), new EmployeePayrollData(0,"Mark Zuckerberg","M",300000.0,LocalDate.now()), new EmployeePayrollData(0,"Sunder","M",600000.0,LocalDate.now()), new EmployeePayrollData(0,"Mukesh","M",100000.0,LocalDate.now()), new EmployeePayrollData(0,"Anil","M",200000.0,LocalDate.now()) }; EmployeePayrollService employeePayrollService = new EmployeePayrollService(); employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); Instant start = Instant.now(); employeePayrollService.addEmployeesToPayroll(Arrays.asList(arrayOfEmps)); Instant end = Instant.now(); Instant threadStart = Instant.now(); employeePayrollService.addEmployeesToPayrollWithThreads(Arrays.asList(arrayOfEmps)); Instant threadEnd = Instant.now(); System.out.println("Duration with thread: "+ Duration.between(threadStart, threadEnd)); System.out.println("Duration without thread: "+Duration.between(start, end)); employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.DENORMALISED); assertEquals(11, employeePayrollService.countEntries(EmployeePayrollService.IOService.DB_IO)); } @Test public void givenEmployeePayrollInNormalisedDB_WhenRetrieved_ShouldMatchEmployeeCount() { EmployeePayrollService employeePayrollService = new EmployeePayrollService(); List<EmployeePayrollData> employeePayrollData = employeePayrollService.readData(EmployeePayrollService.IOService.DB_IO, EmployeePayrollService.NormalisationType.NORMALISED); System.out.println(employeePayrollData); for(EmployeePayrollData emp : employeePayrollData ) { emp.printDepartments(); } assertEquals(3, employeePayrollData.size()); } }
true
88e18ece91f2bb57d34a1c2ee2ea24d977870a46
Java
FreshersDemo/java8
/TypeInference/src/com/java8/typeinference/TypeInferenceExample.java
UTF-8
272
3.078125
3
[]
no_license
package com.java8.typeinference; public class TypeInferenceExample <x,y> { private x first; private y second; public TypeInferenceExample(x a, y b) { first=a; second=b; } public x getFirst() { return first; } public y getSecond() { return second; } }
true
513d881edfa9e7ff0d878d750da9e821fa6d9dc9
Java
ZoneMo/com.tencent.mm
/src/com/tencent/mm/storage/s.java
UTF-8
2,240
1.726563
2
[]
no_license
package com.tencent.mm.storage; import com.tencent.mm.d.b.aq; public final class s extends com.tencent.mm.i.a implements com.tencent.mm.dbsupport.newcursor.a { public s() {} public s(String paramString) { super(paramString); } private void o(int paramInt, long paramLong) { switch (paramInt) { case 4: case 5: case 6: case 8: case 9: default: return; case 0: bf((int)paramLong); return; case 1: setStatus((int)paramLong); return; case 2: bh((int)paramLong); return; case 3: r(paramLong); return; case 7: s(paramLong); return; } bk((int)paramLong); } public final void aGD() { setStatus(0); bh(0); setContent(""); cb("0"); bf(0); super.cc(""); super.cd(""); } public final void c(int paramInt, byte[] paramArrayOfByte) {} public final void f(int paramInt, long paramLong) { o(paramInt, paramLong); } public final void g(int paramInt, long paramLong) { o(paramInt, paramLong); } public final void i(int paramInt, String paramString) { switch (paramInt) { case 7: case 10: default: return; case 4: setUsername(paramString); return; case 5: setContent(paramString); return; case 6: cb(paramString); return; case 8: cc(paramString); return; case 9: cd(paramString); return; } cf(paramString); } public final void qG() {} public final void x(ar paramar) { setStatus(field_status); bh(field_isSend); if (paramar.aHG()) {} label80: for (;;) { long l = field_createTime; for (s locals = this;; locals = this) { locals.r(l); if (!paramar.aHA()) { break; } setContent(paramar.aHS()); return; if (field_status != 1) { break label80; } l = Long.MAX_VALUE; } setContent(field_content); return; } } } /* Location: * Qualified Name: com.tencent.mm.storage.s * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */
true
2022c9a20dd5097a8dda96b7e4bff72d4ebf19c7
Java
MihirKale89/Hackathon
/app/src/main/java/app/hackathon/csusm/hackathon/Adapters/CategoryResultRankAdapter.java
UTF-8
2,602
2.21875
2
[]
no_license
package app.hackathon.csusm.hackathon.Adapters; import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; import java.util.List; import app.hackathon.csusm.hackathon.Classes.CategoryResult; import app.hackathon.csusm.hackathon.Classes.JudgeTeamScore; import app.hackathon.csusm.hackathon.R; /** * Created by Mihir on 23-Apr-15. */ public class CategoryResultRankAdapter extends ArrayAdapter<CategoryResult> { private LayoutInflater inflater; ArrayList<CategoryResult> categoryResult_Items = new ArrayList<CategoryResult>(); private int viewResourceId; private Context Mycontext; public CategoryResultRankAdapter(Context context, int viewResourceId, ArrayList<CategoryResult> categoryResult_Items) { super(context, viewResourceId, categoryResult_Items); inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.categoryResult_Items = categoryResult_Items; this.viewResourceId = viewResourceId; } @Override public int getCount() { return categoryResult_Items.size(); } @Override public CategoryResult getItem(int position) { return categoryResult_Items.get(position); } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { convertView = inflater.inflate(viewResourceId, null); LinearLayout categoryRankLinearLayout = (LinearLayout) convertView.findViewById(R.id.categoryRankListLayout); if(position%2 != 0){ categoryRankLinearLayout.setBackgroundColor(Color.GRAY); } TextView textViewCategoryResultTeamName = (TextView) convertView.findViewById(R.id.textViewCategoryResultTeamNameRank); textViewCategoryResultTeamName.append(" " + categoryResult_Items.get(position).getTeamName()); TextView textViewCategoryResultScore = (TextView) convertView.findViewById(R.id.textViewCategoryResultCategoryScoreRank); textViewCategoryResultScore.append(" " + categoryResult_Items.get(position).getTotal_score()); return convertView; } }
true
4b369aabe1d29c61bb5490bee26655ac99de106c
Java
Vlad04/Swing
/MyFrame.java
UTF-8
1,233
3.203125
3
[]
no_license
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyFrame extends JFrame implements ActionListener{ private JButton button1; private JTextField text1; private JCheckBox check1; public MyFrame(String name){ super(name); setSize(640, 480); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); button1 = new JButton("Boton"); text1 = new JTextField(); check1 = new JCheckBox("checkbox"); Container c = getContentPane(); GridLayout gl = new GridLayout(2,2); c.setLayout(gl); c.add(button1); c.add(text1); c.add(check1); button1.addActionListener(this); text1.addActionListener(this); check1.addActionListener(this); } @Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals(button1.getText())){ if(check1.isSelected()){ System.out.println("Presiono el boton 1, check selected"); System.out.println(text1.getText()); } else { System.out.println("Presiono el boton 1, check not selected"); } } else if(command.equals(check1.getText())){ System.out.println("Presiono checkbox 1"); } } }
true
6f8880e5eb0f76d8a8b3b5535e9a2f8c828e224d
Java
erwah/scimproxy
/scimproxy/src/main/java/info/simplecloud/scimproxy/authentication/Authenticator.java
UTF-8
2,054
2.609375
3
[]
no_license
package info.simplecloud.scimproxy.authentication; import info.simplecloud.scimproxy.config.Config; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Authenticator { private Config config = null; private AuthenticateUser authUser = null; public Authenticator(Config config) { this.config = config; } public boolean authenticate(HttpServletRequest req, HttpServletResponse resp) { boolean authStatus = false; // check if BASIC authentication is configured if (config.getAuthenticationMethods().contains(Config.AUTH_BASIC)) { String basicAuth = req.getHeader("Authorization"); if (basicAuth != null && basicAuth.indexOf("Basic ") == 0) { Basic basic = new Basic(); authStatus = basic.authenticate(basicAuth); this.authUser = basic.getAuthUser(); } } if (!authStatus && config.getAuthenticationMethods().contains(Config.AUTH_OAUTH2) || config.getAuthenticationMethods().contains(Config.AUTH_OAUTH2_V10)) { String oauthAuth = req.getHeader("Authorization"); if (oauthAuth != null && oauthAuth.indexOf("Bearer ") == 0) { String token = oauthAuth.substring("Bearer ".length()); OAuth2 oauth2 = new OAuth2(); authStatus = oauth2.authenticate(token); this.authUser = oauth2.getAuthUser(); } if (oauthAuth != null && oauthAuth.indexOf("OAuth ") == 0) { String token = oauthAuth.substring("OAuth ".length()); OAuth2 oauth2 = new OAuth2(); authStatus = oauth2.authenticate(token); this.authUser = oauth2.getAuthUser(); } } return authStatus; } public void setAuthUser(AuthenticateUser cred) { this.authUser = cred; } public AuthenticateUser getAuthUser() { return authUser; } }
true
1cb6d0ce30978d388299da8aa16ed6420539c122
Java
xiaofeidao/blade
/web/src/main/java/com/blade/web/Bootstrap.java
UTF-8
921
1.6875
2
[]
no_license
package com.blade.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; /** * * @author xiaofeidao * @date 2019/4/1 */ @SpringBootApplication(scanBasePackages = "com.blade.web", exclude ={PersistenceExceptionTranslationAutoConfiguration.class, ValidationAutoConfiguration.class, DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) public class Bootstrap { public static void main(String[] args) { SpringApplication.run(Bootstrap.class, args); } }
true
74c597a2d66f5cf6b4d702f8d0a10853230d6322
Java
CJUnderhill/CS3733TeamF
/src/main/java/Controllers/iter2applicationController.java
UTF-8
14,141
2.25
2
[]
no_license
package Controllers; import DBManager.DBManager; import Form.Form; import javafx.collections.FXCollections; import javafx.embed.swing.SwingFXUtils; import javafx.fxml.FXML; import javafx.scene.Group; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; import javafx.stage.FileChooser; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.sql.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import static Form.StringParsing.*; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; public class iter2applicationController extends UIController { private String uid; private String image_name; @FXML public void initialize(){ createApplicantForm(); source_combobox.setItems(FXCollections.observableArrayList("Imported", "Domestic")); alcohol_type_combobox.setItems(FXCollections.observableArrayList("Malt Beverages", "Wine", "Distilled Spirits")); } public void setUID(String uid) { System.out.println("UID SENT IS " + uid); this.uid = uid; } @FXML public Button submit_button; public Button browse_button; public TextField repID; public TextField permitNO; public TextField serialNO; public Text ttbid; // Source and Alcohol Type ComboBoxes + their TextFields for Agent Review @FXML public ComboBox source_combobox; public ComboBox alcohol_type_combobox; public TextField brandName; public TextField fancifulName; public TextField alcoholContent; public TextField formula; public TextArea extraLabelInfo; // Wine only @FXML public TextField vintageYear; public TextField phLevel; public TextField grapeVarietals; public TextField wineAppellation; public Label vintageYearLabel; public Label phLevelLabel; public Label grapeVarietalsLabel; public Label wineAppellationLabel; public Rectangle wineRec; // CheckBoxes and TextFields for the Type of Application @FXML public CheckBox option_1_checkbox; public CheckBox option_2_checkbox; public TextField option_2_text; //For sale in <state> only public CheckBox option_3_checkbox; public TextField option_3_text; //Bottle capacity before closure public CheckBox option_4_checkbox; public TextField option_4_text; // Applicant Info // Addresses // street1 and street2 correspond to applicant_street @FXML public TextField otherStreet; public TextField otherCity; public TextField otherState; public TextField otherZip; public TextField otherCountry; public Label otherCityLabel; public Label otherStateLabel; public Label otherZipcodeLabel; public Label otherCountryLabel; public Label otherStreetLabel; @FXML public TextField applicantStreet; public TextField applicantCity; public TextField applicantState; public TextField applicantZip; public TextField applicantCountry; //Mailing Address @FXML public CheckBox sameAsApplicantBox; public TextField phoneNo; public TextField signature; public TextField email; public ImageView label_image; public Group wineInfo; private DBManager db = new DBManager(); private loginPageController lpc = new loginPageController(); private Form form = new Form(); //TODO Gut this funciton, it is never used and I need to do other things instead public void createApplicantForm() { form.setttb_id(form.makeUniqueID()); ttbid.setText(form.getttb_id()); } /** * Function acts upon clicking submission button, checks whether page is valid to submit. * TODO Add tooltips to FXML after imported. On mouse over, shows user proper format. * If throwing null pointer exception, look to other form data, as well as if loginPageErrorLabel is present * TODO Check for other fields being null, throw error and message on label. */ @FXML public void submitAction(){ removeValidityError(); if (isValid()){ submitForm(); loginPageErrorLabel.setText(""); } else {displayValidityError();} } @FXML public void submitForm() { int pH_level; String grape_varietals = ""; String wine_appellation = ""; String vintage_year = ""; // String ttb_id = ttb_id_label.getText(); String rep_id = repID.getText(); String permit_no = permitNO.getText(); String serial_no = serialNO.getText(); String source = (String) source_combobox.getValue(); String alcohol_type = (String) alcohol_type_combobox.getValue(); // Determine which checkboxes were selected // Make a temporary array to store the boolean values set them to the Form object, same with string array ArrayList<Boolean> application_type = new ArrayList<Boolean>(); for (int i = 0; i < 5; i++) { application_type.add(false); } ArrayList<String> application_type_text = new ArrayList<String>(); for (int i = 0; i < 5; i++) { application_type_text.add("hello"); } if (option_1_checkbox.isSelected()) {//choice 0 application_type.set(0, true); } else if (option_2_checkbox.isSelected()) { application_type_text.set(1, option_2_text.getText()); application_type.set(1, true); } else if (option_3_checkbox.isSelected()) { application_type_text.set(2, option_3_text.getText()); application_type.set(2, true); } else if (option_4_checkbox.isSelected()) { application_type_text.set(3, option_4_text.getText()); application_type.set(3, true); } String brand_name = brandName.getText(); String fanciful_name = (fancifulName.getText()); Double alcohol_content = (Double.parseDouble(alcoholContent.getText())); String formula = (this.formula.getText()); String labeltext = extraLabelInfo.getText(); // Wines only if (alcohol_type_combobox.getValue().toString().equalsIgnoreCase("Wine")) { System.out.println("IS WINE BITHCESSSSSSSSS"); pH_level = (Integer.parseInt(phLevel.getText())); grape_varietals = (grapeVarietals.getText()); wine_appellation = (wineAppellation.getText()); vintage_year = (vintageYear.getText()); } else { System.out.println("NOT WINE "); pH_level = -1; } String applicant_street = (applicantStreet.getText()); String applicant_city = (applicantCity.getText()); String applicant_state = (applicantState.getText()); String applicant_zip = (applicantZip.getText()); String applicant_country = (applicantCountry.getText()); String mailing_address; if (sameAsApplicantBox.isSelected()) { mailing_address = ""; } else { mailing_address = (otherStreet.getText() + "\n" + otherCity.getText() + " " + otherState.getText() + "," + otherZip.getText() + "\n" + otherCountry.getText()); } String signature = (this.signature.getText()); String phone_no = (phoneNo.getText()); String email = (this.email.getText()); Date submitdate = new Date(System.currentTimeMillis()); if(image_name== null){ image_name = ""; } //TODO Update image when adding image display things //TODO check if label_image.getId() pulls right value form = new Form(rep_id, permit_no, source, serial_no, alcohol_type, brand_name, fanciful_name, alcohol_content, applicant_street, applicant_city, applicant_state, applicant_zip, applicant_country, mailing_address, formula, phone_no, email, labeltext, image_name, submitdate, signature, "Pending", null, menuBarSingleton.getInstance().getGlobalData().getUserInformation().getUid(), null, null, vintage_year, pH_level, grape_varietals, wine_appellation, application_type, application_type_text, null); db.persistForm(form); // System.out.println(form.getsubmit_date()); try { super.returnToMainPage(); }catch (Exception e){ } //TODO return to applicant's application list page } @FXML public void browseForFile() { FileChooser fc = new FileChooser(); String currentDir = System.getProperty("user.dir"); // System.out.println(currentDir); fc.setInitialDirectory(new File(currentDir)); fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Image Files (.jpg .png)", "*.jpg", "*.png")); File selectedFile = fc.showOpenDialog(null); if (selectedFile != null) { try { BufferedImage bufferedImage = ImageIO.read(selectedFile); Image image = SwingFXUtils.toFXImage(bufferedImage, null); label_image.setImage(image); } catch (Exception e) { e.printStackTrace(); } } else { System.out.println("Invalid File"); } Date date = new Date(System.currentTimeMillis()); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss"); String newFileName = selectedFile.getName().split("\\.")[0] + dateFormat.format(date) + "." + selectedFile.getName().split("\\.")[1]; File destInSys = new File(System.getProperty("user.dir") + "/images/" + newFileName); try { Files.copy(selectedFile.toPath(), destInSys.toPath(), StandardCopyOption.REPLACE_EXISTING, NOFOLLOW_LINKS); } catch (Exception e) { e.printStackTrace(); } form.setlabel_image(newFileName); try { System.out.println("here"); String path = (System.getProperty("user.dir") + "/src/mainData/resources/Controllers/images/" + newFileName); image_name = path; File file = new File(path); String localURL = file.toURI().toURL().toString(); Image image = new Image(localURL); System.out.println("Now here"); System.out.println("down"); } catch (Exception e) { e.printStackTrace(); } } @FXML public void showSecondAddress() { System.out.println("Showing second address"); if (sameAsApplicantBox.isSelected()) { otherCityLabel.setVisible(true); otherStateLabel.setVisible(true); otherStreetLabel.setVisible(true); otherZipcodeLabel.setVisible(true); otherCityLabel.setVisible(true); otherCountry.setVisible(true); otherCountryLabel.setVisible(true); otherZip.setVisible(true); otherState.setVisible(true); otherStreet.setVisible(true); otherCity.setVisible(true); } else { otherCityLabel.setVisible(false); otherStateLabel.setVisible(false); otherStreetLabel.setVisible(false); otherZipcodeLabel.setVisible(false); otherCityLabel.setVisible(false); otherCountry.setVisible(false); otherCountryLabel.setVisible(false); otherZip.setVisible(false); otherState.setVisible(false); otherStreet.setVisible(false); otherCity.setVisible(false); } } @FXML public void checkType(){ System.out.println("in checkType"); if(alcohol_type_combobox.getValue().toString().equalsIgnoreCase("Wine")){ wineRec.setVisible(true); grapeVarietals.setVisible(true); grapeVarietalsLabel.setVisible(true); wineAppellation.setVisible(true); wineAppellationLabel.setVisible(true); phLevel.setVisible(true); phLevelLabel.setVisible(true); vintageYear.setVisible(true); vintageYearLabel.setVisible(true); } else{ wineRec.setVisible(false); grapeVarietals.setVisible(false); grapeVarietalsLabel.setVisible(false); wineAppellation.setVisible(false); wineAppellationLabel.setVisible(false); phLevel.setVisible(false); phLevelLabel.setVisible(false); vintageYear.setVisible(false); vintageYearLabel.setVisible(false); } } /** * Helper function for checking boxes that need validation * @return */ private boolean isValid(){ return (emailValidation(email.getText()) & repIDValidation(repID.getText()) & permitValidation(permitNO.getText()) & phoneNmbrValidation(phoneNo.getText()) & serialValidation(serialNO.getText())); } private void displayValidityError(){ if (!emailValidation(email.getText())){setRed(email);} if (!repIDValidation(repID.getText())){setRed(repID);} if (!permitValidation(permitNO.getText())){setRed(permitNO);} if (!phoneNmbrValidation(phoneNo.getText())){setRed(phoneNo);} if (!serialValidation(serialNO.getText())){setRed(serialNO);} loginPageErrorLabel.setText("Please correct mistakes highlighted in red"); } private void removeValidityError(){ TextField[] items = {email,repID,permitNO,phoneNo,serialNO}; for (TextField item : items) { removeRed(item); } } private void setRed(TextField text){ text.setStyle("-fx-text-fill:red"); } private void removeRed(TextField text){ text.setStyle("-fx-text-fill: green"); } }
true
72f7f27c37d9e15e99f30d3eb8ef985572468988
Java
GoWithAI/CoreJava
/src/collections/SortHashMapByKey1.java
UTF-8
2,463
3.6875
4
[]
no_license
package collections; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import java.util.function.BiConsumer; import java.util.function.BinaryOperator; import java.util.function.Supplier; import java.util.stream.Collectors; // HashMap do not maintain insertion order public class SortHashMapByKey1 { static Comparator<Entry<String, Integer>> compareKey = (i1, i2) -> i1.getKey().compareTo(i2.getKey()); static Supplier<LinkedHashMap<String, Integer>> mapSupplierForObjectInsertion = LinkedHashMap::new; static BinaryOperator<Integer> mergeFunction = (e1, e2) -> e1;// Pending ? static BiConsumer<String, Integer> display = (x, y) -> System.out.println(x + " " + y); // This map stores unsorted values static Map<String, Integer> map = new HashMap<>(); public static void main(String[] args) { map.put("Jayant", 80); map.put("Abhishek", 90); map.put("Anushka", 80); map.put("Amit", 75); map.put("Danish", 40); // Calling the function to sortbyKey sortbykeyJava8Stream(); System.out.println("**************"); sortbykeyTreeMap(); System.out.println("********sortbykeyJava8******"); sortbykeyJava8(); } private static void sortbykeyTreeMap() { TreeMap<String, Integer> treeMap = new TreeMap<String, Integer>(); // naturally sorted by key in Below Both Cases // TreeMap<String, Integer> treeMap = new TreeMap<String, Integer>(map); treeMap.putAll(map); treeMap.forEach(display); } private static void sortbykeyJava8() { List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>(map.entrySet()); // Sort the list using lambda expression Collections.sort(list, (i1, i2) -> i1.getKey().compareTo(i2.getKey())); // put data from sorted list to hashmap HashMap<String, Integer> temp = new LinkedHashMap<String, Integer>(); for (Map.Entry<String, Integer> aa : list) { temp.put(aa.getKey(), aa.getValue()); } temp.forEach(display); } private static void sortbykeyJava8Stream() { LinkedHashMap<String, Integer> collect = map.entrySet().stream().sorted(compareKey) .collect(Collectors.toMap(Map.Entry<String, Integer>::getKey, Map.Entry<String, Integer>::getValue, mergeFunction, mapSupplierForObjectInsertion)); collect.forEach(display); } }
true
c66094f18a2c261f8bd5223777c2b13a9868438b
Java
shivanshsoni/my_codes
/codes1.java
UTF-8
595
2.890625
3
[]
no_license
import java.io.*; class codes1 { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); int T,N,c,i,j; String word,s="abcdefghijklmnopqrstuvwxyz"; System.out.println(); T=Integer.parseInt(br.readLine()); for(i=0;i<T;i++) { N=Integer.parseInt(br.readLine()); word=""; c=N/26; for(j=0;j<c;j++) { word+=s; } c=N%26; word+=s.substring(0,c); System.out.println(word); } } }
true
5c39d5ebde8bfb95959fc37685721ff37daaf52d
Java
relaxmax68/algoTriomino
/Plateau.java
UTF-8
5,585
3.515625
4
[]
no_license
/** * classe Plateau modelise un plan triangulaire * sur lequel poser les triominos */ public class Plateau{ //largeur du plateau en nombre de colonnes int largeur; //tableau représentant toutes les positions possibles sur le plateau PositionPlateau[] pos; /** * constructeur general * @param largeur du plateau */ Plateau(int largeur){ //le Plateau reprend la largeur du jeu this.largeur=largeur; //on crée toutes les positions possibles dans le plateau pos=new PositionPlateau[largeur*largeur]; int i=0; int milieu=largeur-1; for(int r=0;r<largeur;r++){ for(int c=0;c<r*2+1;c++){ //cas généraux if(c%2==0) //colonne paires pos[i]=new PositionPlateau(r,c+milieu,13,i); else //colonnes impaires pos[i]=new PositionPlateau(r,c+milieu,11,i); //cas particuliers if(r==0) //première rangée pos[i].setType(4); else if(r==largeur-1){//dernière rangée if(c%2>0) //colonnes impaires pos[i].setType(11); else //colonnes paires pos[i].setType(9); if(c==0) pos[i].setType(1); if(c==r*2) pos[i].setType(8); }else{ //toutes les autres rangées if(c==0) pos[i].setType(5); if(c==r*2) pos[i].setType(12); } i++; } milieu--; } } /** * methode d acces a l attribut largeur du plateau * @return largeur */ public int getLargeur() { return largeur; } /** * methode de placement d un triomino * @param int index de la position du triomino * @param Triomino t triomino a placer * @param int r rang dans lequel placer le triomino * @param int c colonne dans laquelle placer le triomino */ public void set(Triomino t,int index,int r,int c){ t.setPlace(r,c); pos[index].setTriomino(t); } /** * methode d acces a un triomino deja place * @param int r rang du triomino * @param int c colonne du Triomino * @return triomino */ public Triomino get(int r,int c){ int rep=0; for(int i=0;i<largeur*largeur;i++){ if(pos[i].getTriomino().getRangee()==r && pos[i].getTriomino().getColonne()==c) rep=i; } return pos[rep].getTriomino(); } /** * methode pour placer un Triomino sur le plateau */ public void placer(Triomino t, PositionPlateau pos){ pos.setTriomino(t); } /** * methode enlever * enleve un triomino du plateau * typiquement s il y a un probleme de placement * @param PositionPlateau p position du triomino a enlever */ public void enlever(PositionPlateau p) { p.setTriomino(null); } /** * dernierePosition verifie si la position * est la derniere du plateau * @param PositionPlateau p position d'origine * @return true si la position est la derniere, false autrement */ public boolean dernierePosition(PositionPlateau p) { if(p==null) return true; else return false; } /** * methode nextPosition retourne la position suivante sur le plateau * @param PositionPlateau p position d'origine * @return PositionPlateau p positionPlateau suivante */ public PositionPlateau nextPosition(PositionPlateau p){ if(p.getIndex()+1<largeur*largeur) return pos[p.getIndex()+1]; else return null; } /** * methode pour verifier le respect des contraintes *@param Triomino t triomino à tester *@param PositionPlateau p position où est placé le triomino */ public boolean contraintes(Triomino t, PositionPlateau p){ boolean test=true; //rappel : la PositionPlateau p ne contient aucun Triomino / triomino=null //test à gauche = test du bit 4 if((p.getType()&8)==8){ if(pos[p.getIndex()-1].getTriomino()==null) test=true; else test=(t.getGauche()==pos[p.getIndex()-1].getTriomino().getDroite());//on compare la valeur de gauche avec celle de la droite du voisin } //test à droite = test du bit 1 if((p.getType()&1)==1){ if(pos[p.getIndex()+1].getTriomino()==null)//test si un triomino est à côté test=test&&true; else test=test&&(t.getDroite()==pos[p.getIndex()+1].getTriomino().getGauche()); } //test en haut = test du bit 2 if((p.getType()&2)==2){ int i=p.getIndex()-1; while(p.getColonne()!=pos[i].getColonne()){ i--;//on recule jusqu'à retrouver la même rangée au dessus } test=test&&(t.getBase()==pos[i].getTriomino().getBase()); //on considere qu'il y aura toujours un triomino deja place... } //test en bas = test du bit 3 if((p.getType()&4)==4){ int i=p.getIndex()+1; while(p.getColonne()!=pos[i].getColonne()){ // System.out.print(p.getColonne()+":"+pos[i].getColonne()+"/"); i++;//on avance jusqu'à retrouver la même rangée en dessous } if(pos[i].getTriomino()==null)//test si un triomino en dessous test=test&&true; else test=test&&(t.getBase()==pos[i].getTriomino().getBase()); } //on retourne la valeur de test, true si tests satisfaits return test; } /** * affiche toute la liste des triominos posés sur le plateau */ public void affiche(){ for(int i=0;i<largeur*largeur;i++){ System.out.print(pos[i].getTriomino().getBase()); System.out.print(pos[i].getTriomino().getGauche()); System.out.print(pos[i].getTriomino().getDroite()+"/"); } } /** * vide le plateau de tous ses triominos */ public void vider(){ for(int i=0;i<largeur*largeur;i++) pos[i].setTriomino(null); } }
true
823e260f87e626797f33b81e40e3e942bdabc856
Java
Guilhermebrune/Guilhermebrune
/src/entidade/AcaiHasProduto.java
UTF-8
815
2.25
2
[]
no_license
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package entidade; /** * * @author guilherme */ public class AcaiHasProduto { private int idacai; private int idProduto; private String observacao; public int getIdacai() { return idacai; } public void setIdacai(int idacai) { this.idacai = idacai; } public int getIdProduto() { return idProduto; } public void setIdProduto(int idProduto) { this.idProduto = idProduto; } public String getObservacao() { return observacao; } public void setObservacao(String observacao) { this.observacao = observacao; } }
true
cdeecc2e8c34a6a0e04db5486885daad5dbc44be
Java
odairviol/agendasqlite
/app/src/main/java/br/edu/ifspsaocarlos/agenda/data/ContatoDAO.java
UTF-8
4,469
2.5
2
[]
no_license
package br.edu.ifspsaocarlos.agenda.data; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.strictmode.SqliteObjectLeakedViolation; import br.edu.ifspsaocarlos.agenda.adapter.ContatoAdapter; import br.edu.ifspsaocarlos.agenda.model.Contato; import java.util.ArrayList; import java.util.List; public class ContatoDAO { private SQLiteDatabase database; private SQLiteHelper dbHelper; public ContatoDAO(Context context) { this.dbHelper = new SQLiteHelper(context); } public List<Contato> buscaTodosContatos() { database = dbHelper.getReadableDatabase(); List<Contato> contatos = new ArrayList<>(); Cursor cursor; String[] cols = new String[]{SQLiteHelper.KEY_ID, SQLiteHelper.KEY_NAME, SQLiteHelper.KEY_FONE, SQLiteHelper.KEY_EMAIL, SQLiteHelper.KEY_FONE2, SQLiteHelper.KEY_DATA_NASC, SQLiteHelper.KEY_FAVORITO}; cursor = database.query(SQLiteHelper.DATABASE_TABLE, cols, null, null, null, null, SQLiteHelper.KEY_NAME); while (cursor.moveToNext()) { Contato contato = new Contato(); contato.setId(cursor.getInt(0)); contato.setNome(cursor.getString(1)); contato.setFone(cursor.getString(2)); contato.setEmail(cursor.getString(3)); contato.setCelular(cursor.getString(4)); contato.setDataNascimento(cursor.getString(5)); contato.setFavorito(cursor.getInt(6)); contatos.add(contato); } cursor.close(); database.close(); return contatos; } public List<Contato> buscaContato(String nome, boolean favoritos) { database = dbHelper.getReadableDatabase(); List<Contato> contatos = new ArrayList<>(); Cursor cursor; String[] cols = new String[]{SQLiteHelper.KEY_ID, SQLiteHelper.KEY_NAME, SQLiteHelper.KEY_FONE, SQLiteHelper.KEY_EMAIL, SQLiteHelper.KEY_FONE2, SQLiteHelper.KEY_DATA_NASC, SQLiteHelper.KEY_FAVORITO}; String where = ""; String args[] = new String[0]; if (nome != null) { where = where +"("+ SQLiteHelper.KEY_NAME + " like @name OR " + SQLiteHelper.KEY_EMAIL + " like @name)"; args = new String[]{nome + "%"}; } if (favoritos && nome == null) { where = where + SQLiteHelper.KEY_FAVORITO + " = 1"; } else if (favoritos && nome != null) { where = where + " AND " + SQLiteHelper.KEY_FAVORITO + " = ?"; args = new String[]{nome + "%", Integer.toString(1)}; } cursor = database.query(SQLiteHelper.DATABASE_TABLE, cols, where, args, null, null, SQLiteHelper.KEY_NAME); while (cursor.moveToNext()) { Contato contato = new Contato(); contato.setId(cursor.getInt(0)); contato.setNome(cursor.getString(1)); contato.setFone(cursor.getString(2)); contato.setEmail(cursor.getString(3)); contato.setCelular(cursor.getString(4)); contato.setDataNascimento(cursor.getString(5)); contato.setFavorito(cursor.getInt(6)); contatos.add(contato); } cursor.close(); database.close(); return contatos; } public void salvaContato(Contato c) { database = dbHelper.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(SQLiteHelper.KEY_NAME, c.getNome()); values.put(SQLiteHelper.KEY_FONE, c.getFone()); values.put(SQLiteHelper.KEY_EMAIL, c.getEmail()); values.put(SQLiteHelper.KEY_FONE2, c.getCelular()); values.put(SQLiteHelper.KEY_DATA_NASC, c.getDataNascimento()); values.put(SQLiteHelper.KEY_FAVORITO, c.getFavorito()); if (c.getId() > 0) { database.update(SQLiteHelper.DATABASE_TABLE, values, SQLiteHelper.KEY_ID + "=" + c.getId(), null); } else { database.insert(SQLiteHelper.DATABASE_TABLE, null, values); } database.close(); } public void apagaContato(Contato c) { database = dbHelper.getWritableDatabase(); database.delete(SQLiteHelper.DATABASE_TABLE, SQLiteHelper.KEY_ID + "=" + c.getId(), null); database.close(); } }
true
f26c8c9881d4cc65e5af30289ca13bce37f50c03
Java
JacksonZhangHuaQuan/weixing
/src/main/java/org/lanqiao/dao/AttractionDao.java
UTF-8
336
1.789063
2
[]
no_license
package org.lanqiao.dao; import org.lanqiao.entity.Attraction; import java.util.List; public interface AttractionDao { //插入景点 int insertAttraction(Attraction attraction); //更改景点 int updateAttraction(Attraction attraction); //查询 List<Attraction> selectAttraction(String strategy_id); }
true
a32ef8571e9d36376a240085600063f739587516
Java
WarnerWang/WJBaseProjectAndroid
/app/src/main/java/com/hx/wjbaseproject/ui/statusView/StatusLayout.java
UTF-8
10,950
2.0625
2
[ "Apache-2.0" ]
permissive
package com.hx.wjbaseproject.ui.statusView; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import com.hx.wjbaseproject.R; import androidx.fragment.app.Fragment; public class StatusLayout extends FrameLayout { private static final String TAG = "StatusLayout"; private Context context; private View mLoadingView;// 正在加载界面 private View mRetryView;// 返回数据错误 private View mContentView;// 正常的内容页面 private View mSettingView;// 一般是无网络状态,需要去设置 private View mEmptyView;// 返回数据是0个 private View mNeedVipView;//需要普通会员 private View mNeedSVipView;//需要至尊会员 private View mOddsSettingView;//盘赔模型设置 private boolean isInit = false; private static int LOADING = 1; private static int RETRY = 2; private static int CONTENT = 3; private static int SETTING = 4; private static int EMPTY = 5; private static int NEEDVIP = 6; private static int NEEDSVIP = 7; private static int ODDSSETTING = 8; private LayoutParams layoutParams; private StatusView statusView; public static StatusLayout getInstance(View view, StatusView statusView) { return new StatusLayout.Builder().setContentView(view).setStatusView(statusView).build(); } public static StatusLayout getInstance(Activity activity, StatusView statusView) { return new StatusLayout.Builder().setContentView(activity).setStatusView(statusView).build(); } public static StatusLayout getInstance(Fragment fragment, StatusView statusView) { return new StatusLayout.Builder().setContentView(fragment).setStatusView(statusView).build(); } public StatusLayout(Context context) { super(context); this.context = context; } public StatusLayout(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; } public StatusLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.context = context; } @SuppressLint("InflateParams") private void initStatusLayout() { if (isInit) { return; } isInit = true; int countNum = getChildCount(); if (countNum != 1) { return; } log(getChildAt(0).getClass().getName()); mContentView = getChildAt(0); mContentView.setTag(R.id.tag_empty_add_type, CONTENT); layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); // setStatusView(new DefaultStatusView(context)); } public StatusLayout setStatusView(StatusView mStatusView) { this.statusView = mStatusView; setLoadingView(); setRetryView(); setEmptyView(); setSettingView(); showContent(); return this; } /** * 设置加载页面 * * @return */ public StatusLayout setLoadingView() { removeView(mLoadingView); mLoadingView = statusView.getLoadingView(); if (mLoadingView != null) { mLoadingView.setTag(R.id.tag_empty_add_view, true); mLoadingView.setTag(R.id.tag_empty_add_type, LOADING); addView(mLoadingView, layoutParams); mLoadingView.setVisibility(View.GONE); } return this; } /** * 设置重试界面 * * @return */ public StatusLayout setRetryView() { removeView(mRetryView); mRetryView = statusView.getRetryView(); if (mRetryView != null) { mRetryView.setTag(R.id.tag_empty_add_view, true); mRetryView.setTag(R.id.tag_empty_add_type, RETRY); addView(mRetryView, layoutParams); mRetryView.setVisibility(View.GONE); } return this; } /** * 设置空的页面 * * @return */ public StatusLayout setEmptyView() { removeView(mEmptyView); mEmptyView = statusView.getEmptyView(); if (mEmptyView != null) { mEmptyView.setTag(R.id.tag_empty_add_view, true); mEmptyView.setTag(R.id.tag_empty_add_type, EMPTY); addView(mEmptyView, layoutParams); mEmptyView.setVisibility(View.GONE); } return this; } /** * 设置设置网络界面 * * @return */ public StatusLayout setSettingView() { removeView(mSettingView); mSettingView = statusView.getSettingView(); if (mSettingView != null) { mSettingView.setTag(R.id.tag_empty_add_view, true); mSettingView.setTag(R.id.tag_empty_add_type, SETTING); addView(mSettingView, layoutParams); mSettingView.setVisibility(View.GONE); } return this; } public View getmLoadingView() { return mLoadingView; } public View getmRetryView() { return mRetryView; } public View getmContentView() { return mContentView; } public View getmSettingView() { return mSettingView; } public View getmEmptyView() { return mEmptyView; } public View getmNeedVipView() { return mNeedVipView; } public View getmNeedSVipView() { return mNeedSVipView; } public View getmOddsSettingView(){ return mOddsSettingView; } @Override public void addView(View child, int index, ViewGroup.LayoutParams params) { boolean isAddEmpty = false; if (child.getTag(R.id.tag_empty_add_view) != null) { isAddEmpty = (Boolean) child.getTag(R.id.tag_empty_add_view); } if (!isAddEmpty) { if (getChildCount() > 0) { throw new IllegalStateException( "StatusLayout can host only one direct child"); } } super.addView(child, index, params); initStatusLayout(); } private void log(String string) { Log.e(TAG, string); } public void showLoading() { log("showLoading"); show(LOADING); // statusView.showLoading(); } public void showRetry() { log("showRetry"); show(RETRY); } public void showContent() { log("showContent"); show(CONTENT); } public void showEmpty() { log("showEmpty"); show(EMPTY); } public void showSetting() { log("showSetting"); show(SETTING); } public void showNeedVip(){ log("showNeedVip"); show(NEEDVIP); } public void showNeedSVip(){ log("showNeedSVip"); show(NEEDSVIP); } public void showOddsSetting(){ log("showOddsSetting"); show(ODDSSETTING); } private void show(int type) { for (int i = 0; i < getChildCount(); i++) { int mType; if (getChildAt(i).getTag(R.id.tag_empty_add_type) != null) { mType = (Integer) getChildAt(i).getTag(R.id.tag_empty_add_type); if (type == mType) { getChildAt(i).setVisibility(VISIBLE); } else { getChildAt(i).setVisibility(GONE); } } } } public static final class Builder { private int index; private ViewGroup mParentView; private View mContentView;// 正常的内容页面 private StatusLayout statusLayout; private boolean isRegister = false; private StatusView statusView; public Builder setContentView(Activity activity) { mParentView = (ViewGroup) activity .findViewById(android.R.id.content); index = 0; return this; } public Builder setContentView(Fragment fragment) { mParentView = (ViewGroup) fragment.getView().getParent(); index = 0; return this; } public Builder setContentView(View view) { mParentView = (ViewGroup) view.getParent(); for (int i = 0; i < mParentView.getChildCount(); i++) { if (mParentView.getChildAt(i) == view) { index = i; break; } } return this; } public StatusLayout build() { View view = mParentView.getChildAt(index); // 父类本分就是StatusLayout if (mParentView != null && mParentView instanceof StatusLayout) { statusLayout = (StatusLayout) mParentView; } // 内容本分就是StatusLayout else if (view != null && view instanceof StatusLayout) { statusLayout = (StatusLayout) view; } // 其他情况 else { mContentView = view; statusLayout = new StatusLayout( mParentView.getContext()); register(); } if (statusView != null) { statusLayout.setStatusView(statusView); } return statusLayout; } public Builder setStatusView(StatusView statusView) { this.statusView = statusView; return this; } /** * @描述:只需要注册一次 */ public void register() { Log.d(TAG, "register: 添加布局"); if (isRegister) { return; } if (mParentView == null || mContentView == null || statusLayout == null) { return; } mParentView.removeView(mContentView); ViewGroup.LayoutParams lp = mContentView.getLayoutParams(); statusLayout.addView(mContentView); mParentView.addView(statusLayout, index, lp); isRegister = true; } /** * @描述:无所谓的调用 */ // public void unRegister() { // if (isRegister) { // if (mParentView == null || mContentView == null // || statusLayout == null) { // return; // } // mParentView.setTag(R.id.tag_empty_layout_manager, null); // mParentView.removeView(statusLayout); // ViewGroup.LayoutParams lp = statusLayout.getLayoutParams(); // mParentView.addView(mContentView, index, lp); // mContentView.setVisibility(View.VISIBLE); // } // // } } }
true
f18595b6448a350063a9d4acd5dcf7cc3123a029
Java
jdbide/trem
/src/main/java/com/avancial/socle/utils/StringToDate.java
UTF-8
5,674
3.203125
3
[]
no_license
package com.avancial.socle.utils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; /** * * @author ismael.yahiani * cette class permet de transformer une date : d'un Type String vers un Type Date */ public class StringToDate { public static Date toDate(String date) throws ParseException { String format = "ddMMMyy" ; SimpleDateFormat sdf = new SimpleDateFormat(format,Locale.ENGLISH) ; Date d = sdf.parse(date); return d; } public static String JavaDays2FrenchDays (Calendar date) { String chaine; switch (date.get(Calendar.DAY_OF_WEEK)) { case 1: chaine="7"; break; default: chaine=String.valueOf(date.get(Calendar.DAY_OF_WEEK)-1); break; } return chaine; } public static Date getDateFromString(String date, String format) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(format,Locale.ENGLISH) ; Date d = sdf.parse(date); return d; } /** * * @param date * @return date sous format jjMMMyy * @throws ParseException */ public static String toString(Date date) { //DateFormat df = new SimpleDateFormat("ddMMMyy") ; String format = "ddMMMyy" ; SimpleDateFormat df = new SimpleDateFormat(format,Locale.ENGLISH) ; String myDate = df.format(date); return myDate.toUpperCase() ; } public static String toFormatedString(Date date) { //DateFormat df = new SimpleDateFormat("ddMMMyy") ; String format = "HHmm" ; SimpleDateFormat df = new SimpleDateFormat(format,Locale.ENGLISH) ; String myDate = df.format(date); return myDate; } /** * * @param date * @return date sous format HH:mm */ public static String toFormatedString2(Date date) { //DateFormat df = new SimpleDateFormat("ddMMMyy") ; String format = "HH:mm" ; SimpleDateFormat df = new SimpleDateFormat(format,Locale.ENGLISH) ; String myDate = df.format(date); return myDate; } /** * * @param date * @return date sous format */ public static String toFormatedString3(Date date) { //DateFormat df = new SimpleDateFormat("ddMMMyy") ; String format = "HH:mm" ; SimpleDateFormat df = new SimpleDateFormat(format,Locale.ENGLISH) ; String myDate = df.format(date); return myDate; } /** * * @param date * @return date en chaine de caratctere dd/MM/yyyy */ public static String toFormatedStringddMMyyyy(Date date) { //DateFormat df = new SimpleDateFormat("ddMMMyy") ; String format = "dd/MM/yyyy" ; SimpleDateFormat df = new SimpleDateFormat(format,Locale.ENGLISH) ; String myDate = df.format(date); return myDate; } /** * * @param date * @param format * @return date sous format : * dateBySlashSansHeure dd/MM/yyyy * dateSlashAvecHeure dd/MM/yyyy HH:mm * dateTireSansHeure dd-MM-yyyy HH:mm * dateFrenchSansHeure dd MMM yyyy * dateEnglishSansHeure dd MMM yyyy * dateEnglishAvecHeure dd MMM yyyy HH:mm * dateFrenchAffichage MMM yyyy * dateSansSeparateurs ddMMyyyy * @throws Exception */ public static String toStringByFormat(Date date, String format) throws Exception { SimpleDateFormat formatDate = null; // dd/mm/yyyy if (format.equals("dateBySlashSansHeure")) { formatDate = new SimpleDateFormat("dd/MM/yyyy"); } else if (format.equals("dateSlashAvecHeure")) { formatDate = new SimpleDateFormat("dd/MM/yyyy HH:mm"); } else if (format.equals("dateTireSansHeure")) { formatDate = new SimpleDateFormat("dd-MM-yyyy"); } else if (format.equals("dateTireAvecHeure")) { formatDate = new SimpleDateFormat("dd-MM-yyyy HH:mm"); } else if (format.equals("dateFrenchSansHeure")) { formatDate = new SimpleDateFormat("dd MMM yyyy", Locale.FRENCH); }else if (format.equals("dateFrenchAvecHeure")) { formatDate = new SimpleDateFormat("dd MMM yyyy : HH:mm", Locale.FRENCH); } else if (format.equals("dateEnglishSansHeure")) { formatDate = new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH); } else if (format.equals("dateEnglishAvecHeure")) { formatDate = new SimpleDateFormat("dd MMM yyyy HH:mm", Locale.ENGLISH); } else if (format.equals("dateFrenchAffichage")) { formatDate = new SimpleDateFormat("MMM yyyy", Locale.FRENCH); } else if (format.equals("jour")) { formatDate = new SimpleDateFormat("dd", Locale.FRENCH); } else if (format.equals("dateSansSeparateurs")) { formatDate = new SimpleDateFormat("ddMMyyyy", Locale.FRENCH); }else { return null; } String myDate = formatDate.format(date); return myDate; } /** * * @param date * @param mois * @return le mois +1 */ public static Date moisSuivant(final Date date, final int mois) { try { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.add(Calendar.MONTH, mois); return gc.getTime(); } catch (Exception e) { e.printStackTrace(); return null; } } /** * * @param date * @return dd MMM yyyy : HH:mm format */ public static Date toFormatedDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy : HH:mm", Locale.FRENCH) ; Date temp= new Date(); try { temp = sdf.parse(date.toString()); } catch (ParseException e) { e.printStackTrace(); } return temp ; } }
true
bb79fe966034bd5c2d45e4f95770feb28dc203c1
Java
y-polek/TransmissionRemote
/app/src/main/java/net/yupol/transmissionremote/app/model/Dir.java
UTF-8
3,812
2.609375
3
[ "Apache-2.0" ]
permissive
package net.yupol.transmissionremote.app.model; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.common.base.Function; import com.google.common.collect.FluentIterable; import net.yupol.transmissionremote.app.model.json.File; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; public final class Dir implements Comparable<Dir> { private String name; private List<Dir> dirs = new LinkedList<>(); private List<Integer> fileIndices = new LinkedList<>(); public Dir(String name) { this.name = name; } public String getName() { return name; } public List<Dir> getDirs() { return dirs; } public List<Integer> getFileIndices() { return fileIndices; } @Nullable public Dir findDir(@NonNull String name) { for (Dir dir : dirs) { if (name.equals(dir.name)) return dir; } return null; } @NonNull public static Dir createFileTree(@NonNull File[] files) { Dir root = new Dir("/"); for (int i=0; i<files.length; i++) { File file = files[i]; List<String> pathParts = Arrays.asList(file.getPath().split("/")); if (pathParts.get(0).isEmpty()) pathParts = pathParts.subList(1, pathParts.size()); parsePath(pathParts, root, i); } List<String> fileNames = FluentIterable.from(files) .transform(new Function<File, String>() { @Override public String apply(@NonNull File file) { String[] segments = file.getPath().split("/"); if (segments.length == 0) return ""; return segments[segments.length - 1]; } }).toList(); sortRecursively(root, fileNames); return root; } private static void sortRecursively(Dir dir, final List<String> fileNames) { Collections.sort(dir.dirs); Collections.sort(dir.fileIndices, new Comparator<Integer>() { @Override public int compare(Integer idx1, Integer idx2) { String fileName1 = fileNames.get(idx1); String fileName2 = fileNames.get(idx2); return fileName1.compareToIgnoreCase(fileName2); } }); for (Dir subDir : dir.dirs) { sortRecursively(subDir, fileNames); } } public static List<Integer> filesInDirRecursively(Dir dir) { List<Integer> fileIndices = new LinkedList<>(); collectFilesInDir(dir, fileIndices); return fileIndices; } private static void collectFilesInDir(Dir dir, List<Integer> fileIndices) { fileIndices.addAll(dir.getFileIndices()); for (Dir subDir : dir.getDirs()) { collectFilesInDir(subDir, fileIndices); } } private static void parsePath(List<String> pathParts, Dir parentDir, int fileIndex) { if (pathParts.size() == 1) { parentDir.fileIndices.add(fileIndex); return; } String dirName = pathParts.get(0); Dir dir = findDirWithName(dirName, parentDir.dirs); if (dir == null) { dir = new Dir(dirName); parentDir.dirs.add(dir); } parsePath(pathParts.subList(1, pathParts.size()), dir, fileIndex); } private static Dir findDirWithName(String name, List<Dir> dirs) { for (Dir dir : dirs) { if (dir.name.equals(name)) return dir; } return null; } @Override public int compareTo(@NonNull Dir dir) { return name.compareToIgnoreCase(dir.name); } }
true
7f75ef0f624c68d687aede38ee9f37394fff167d
Java
vanadium/java
/lib/src/main/java/io/v/v23/vdl/ClientSendStream.java
UTF-8
1,584
2.28125
2
[ "BSD-3-Clause" ]
permissive
// Copyright 2015 The Vanadium Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package io.v.v23.vdl; import com.google.common.util.concurrent.ListenableFuture; import javax.annotation.CheckReturnValue; import io.v.v23.OutputChannel; /** * Represents the send side of the client bidirectional stream. * * @param <SendT> type of values that the client is sending to the server * @param <FinishT> type of the final return value from the server */ public interface ClientSendStream<SendT, FinishT> extends OutputChannel<SendT> { /** * Returns a new {@link ListenableFuture} that performs the equivalent of {@link #close}, * then waits until the server is done and returns the call return value. * <p> * Calling {@link #finish} is mandatory for releasing stream resources, unless the call context * has been canceled or any of the other methods threw an exception. * <p> * Must be called at most once. * <p> * The returned future is guaranteed to be executed on an {@link java.util.concurrent.Executor} * specified in the context used for creating this stream (see {@link io.v.v23.V#withExecutor}). * <p> * The returned future will fail with {@link java.util.concurrent.CancellationException} if the * context used for creating this stream has been canceled. * * @return a new {@link ListenableFuture} whose result is the call return value */ @CheckReturnValue ListenableFuture<FinishT> finish(); }
true
5d7e9919e391c1d748450f1301f3b17d54cd7682
Java
danielgek/DistributedSystems
/TCPServer/src/server/Action.java
UTF-8
2,014
2.25
2
[]
no_license
package server; import java.io.Serializable; /** * Created by danielgek on 11/10/15. */ public class Action implements Serializable { private int action; public static final int LOGIN = 0; public static final int SIGUP = 1; public static final int GET_PROJECT = 2; public static final int GET_PROJECTS = 3; public static final int GET_OLD_PROJECTS = 4; public static final int CREATE_PROJECT = 5; public static final int REMOVE_PROJECT = 6; public static final int GET_PROJECT_BY_ADMIN = 7; public static final int ADD_LEVEL = 8; public static final int GET_LEVELS_BY_PROJECT = 9; public static final int REMOVE_REWARD = 11; public static final int GET_REWARDS_BY_PROJECT = 12; public static final int GET_CURRENT_REWARDS = 13; public static final int ADD_REWARD = 14; public static final int ADD_POLL = 15; public static final int GET_POLL = 16; public static final int GET_POLL_BY_PROJECT = 17; public static final int ADD_VOTE = 18; public static final int GET_VOTES_BY_POLL = 19; public static final int PLEDGE = 20; public static final int SEND_MESSAGE = 21; public static final int GET_MESSAGES = 22; public static final int GET_USER = 23; private Object object; public Action(int action) { this.action = action; } public Action(int action, Object object) { this.action = action; this.object = object; } public int getAction() { return action; } public void setAction(int action) { this.action = action; } public Object getObject() { return object; } public void setObject(Object object) { this.object = object; } @Override public String toString() { return "server.Action{" + "action=" + this.getClass().getDeclaredFields()[action + 1].getName() + ", object= " + (object == null ? "null" : object.toString()) + '}'; } }
true
a11e937575788443cc0ed4c148705dd141cec114
Java
gautambisht/craftsvillla_assignment
/app/src/main/java/com/craftvilla/craftsvillatest/ui/adapter/viewholder/ParcelViewHolder.java
UTF-8
1,061
2.34375
2
[]
no_license
package com.craftvilla.craftsvillatest.ui.adapter.viewholder; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.TextView; import com.craftvilla.craftsvillatest.R; public class ParcelViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView applicantNameTextView; public TextView addressTextView; private OnClickListener listener; public ParcelViewHolder(View itemView) { super(itemView); applicantNameTextView = (TextView) itemView.findViewById(R.id.tv_applicant_name); addressTextView = (TextView) itemView.findViewById(R.id.tv_applicant_address); itemView.setOnClickListener(this); } @Override public void onClick(View v) { if (listener != null) listener.onClick(v, getAdapterPosition()); } public void setOnClickListener(OnClickListener listener) { this.listener = listener; } public interface OnClickListener { void onClick(View v, int position); } }
true
c4852fbe2aef41802ccf124e03de2259e4875965
Java
Veglad/Financemanager
/app/src/main/java/com/example/vlad/financemanager/moneyCalculator.java
UTF-8
11,571
1.992188
2
[]
no_license
package com.example.vlad.financemanager; import android.annotation.SuppressLint; import android.app.DatePickerDialog; import android.content.Intent; import android.content.res.Resources; import android.database.sqlite.SQLiteDatabase; import android.graphics.ColorFilter; import android.support.v4.app.DialogFragment; import android.graphics.Color; import android.graphics.PorterDuff; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; public class moneyCalculator extends AppCompatActivity implements IMoneyCalculation, DatePickerDialog.OnDateSetListener{ private PresenterMoneyCalc presenter; private TextView resultText; private EditText comment; private Spinner spinnerAccounts; private Spinner spinnerCategories; private Button setDateButton; private Date operDate; final SimpleDateFormat sdf = new SimpleDateFormat("E, dd MMMM"); final SimpleDateFormat sdfWithYear = new SimpleDateFormat("E, MMMM dd, yyyy"); private boolean isOperationInput; private boolean opernForChange; private Operation operationForChange; private int accountId; private int categoryId; private ArrayList<SpinnerItem> spinnerCategoriesItems; private ArrayList<SpinnerItem> spinnerAccountsItems; @SuppressLint("ResourceAsColor") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_money_calculator); presenter = new PresenterMoneyCalc(this, this); operDate = new Date(); opernForChange = false; //Setting long clear button press; Button btnBack = (Button)findViewById(R.id.btnBack); btnBack.getBackground().setColorFilter(R.color.darkGrey, PorterDuff.Mode.SRC_ATOP); btnBack.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { presenter.clearNumber(); return true; } }); //main views resultText = (TextView)findViewById(R.id.tvResultText); comment = (EditText)findViewById(R.id.etComment); initSpinners(); //datePicker Button setDateButton = (Button)findViewById(R.id.btnOperDate); setDateButton.setText(sdf.format( new Date())); setDateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerFragment df = new DatePickerFragment(); if(opernForChange) df.setCalendar(operationForChange.getOperationDate()); else df.setCalendar(operDate); DialogFragment datePicker = df; datePicker.show(getSupportFragmentManager(),"date picker"); } }); //Toolbar settings Toolbar toolbar = (Toolbar)findViewById(R.id.calc_toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.getNavigationIcon().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ finish(); } }); //Getting intent extras Bundle extras = getIntent().getExtras(); String str = (String)extras.get("msg"); initDateTimePicker(extras); if(str.equals("operation")){ str = OperationChange(); opernForChange = true; } TextView toolbarTitle = (TextView)findViewById(R.id.toolbatTitle); toolbarTitle.setText(str); isOperationInput = str.equals("Income"); } private void initDateTimePicker(Bundle extras) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(extras.getLong("currDate")); if(calendar != null){ operDate = calendar.getTime(); if(calendar.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) setDateButton.setText(sdfWithYear.format(calendar.getTime())); else setDateButton.setText(sdf.format(calendar.getTime())); } } //Methods that implements interface /** * Method - getting value in the category's name input * @return category's name value */ @Override public int getCategoryId() { return categoryId; } /** * Method - getting value in the account's name input * @return account's name value */ @Override public int getAccountId() { return accountId; } /** * Method - getting date when the operation performed * @return date */ @Override public Date getOperationDate() { return operDate; } /** * Method - getting users's comment for this operation * @return comment as string */ @Override public String getComment() { return comment.getText().toString(); } @Override public boolean getIsOperationInput() { return isOperationInput; } /** * Method - updating the value in the calculator * @param result - new number */ @Override public void setCalcResultText(String result) { this.resultText.setText(result); } /** * Handler for input buttons click in the calculator * @param v - View representation of the sender */ public void calculatorBtnOnClick(View v){ Button btn = (Button)v; presenter.calculatorBtnOnClick(v.getId(), btn.getText().toString()); } /** * Handler for 'save' button click * @param v - View representation of the sender */ public void btnSaveOnClick(View v){ presenter.btnSaveOnClick(); } /** * Finish this activity */ public void finishActivity(){ finish(); } /** * Method - Signals to the user that calculation failed */ public void calculationErrorSignal(){ Toast.makeText(this,"Incorrect input", Toast.LENGTH_SHORT).show(); } public void calculationErrorSignal(String msg){ Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } @Override public void sendNewOperation(Operation operation) { Intent intent = new Intent(); String amount = operation.getAmount().toString(); Bundle extras = new Bundle(); extras.putString("amount", amount); extras.putSerializable("operation",operation); intent.putExtras(extras); setResult(0, intent); } @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH,dayOfMonth); operDate = calendar.getTime(); String selectedDate; if(calendar.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) selectedDate = sdfWithYear.format(calendar.getTime()); else selectedDate = sdf.format(calendar.getTime()); setDateButton.setText(selectedDate); } public String OperationChange(){ Bundle extras = getIntent().getExtras(); Operation operation = (Operation)extras.getSerializable("operation"); operation.setAmount(new BigDecimal(getIntent().getExtras().get("amount").toString())); operationForChange = operation; comment.setText(operation.getComment()); resultText.setText(operation.getAmount().toString()); presenter.settingResultText(operation.getAmount()); //Setting category & account for(int i= 0; i < spinnerCategoriesItems.size(); i++){ if(spinnerCategoriesItems.get(i).getId() == operation.getCategory().getId()) spinnerCategories.setSelection(i); } for(int i= 0; i < spinnerAccountsItems.size(); i++){ if(spinnerAccountsItems.get(i).getId() == operation.getAccountId()) spinnerAccounts.setSelection(i); } Calendar calendar = Calendar.getInstance(); calendar.setTime(operation.getOperationDate()); if(calendar.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) setDateButton.setText(sdfWithYear.format(operation.getOperationDate())); else setDateButton.setText(sdf.format(operation.getOperationDate())); return operation.getIsOperationIncome()?"Income":"Outcome"; } public void initSpinners(){ Bundle extras = getIntent().getExtras(); spinnerAccountsItems = (ArrayList<SpinnerItem>) extras.getSerializable("accounts"); spinnerAccountsItems.remove(0); spinnerCategoriesItems = (ArrayList<SpinnerItem>) extras.getSerializable("categories"); if(spinnerCategoriesItems == null || spinnerAccountsItems == null){ calculationErrorSignal("Error with getting categories and accounts"); return; } spinnerAccounts = (Spinner)findViewById(R.id.spinnerAccount); spinnerCategories = (Spinner)findViewById(R.id.spinnerCategory); spinnerAccounts.getBackground().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); spinnerCategories.getBackground().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); CustomSpinnerAdapter adapter_Account = new CustomSpinnerAdapter(this,R.layout.spinner_item, spinnerAccountsItems); CustomSpinnerAdapter adapter_Categories = new CustomSpinnerAdapter(this,R.layout.spinner_item, spinnerCategoriesItems); spinnerAccounts.setAdapter(adapter_Account); spinnerCategories.setAdapter(adapter_Categories); //OnItemAccountSelected spinnerAccounts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View itemSelected, int selectedItemPosition, long selectedId) { accountId =((SpinnerItem)parent.getItemAtPosition(selectedItemPosition)).getId(); } public void onNothingSelected(AdapterView<?> parent) { } }); //OnItemCategorySelected spinnerCategories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View itemSelected, int selectedItemPosition, long selectedId) { categoryId =((SpinnerItem)parent.getItemAtPosition(selectedItemPosition)).getId(); } public void onNothingSelected(AdapterView<?> parent) { } }); } }
true
d06b297e5aaa9f7c6c0069a7b712684ef96defb3
Java
OussemaTouaibi/Quiz_Microservices
/blog-service/src/main/java/com/quizmanagement/blog/service/services/IblogService.java
UTF-8
375
1.867188
2
[]
no_license
package com.quizmanagement.blog.service.services; import java.util.List; import java.util.Optional; import com.quizmanagement.blog.service.entities.Blog; public interface IblogService { public void ajouterBlog(Blog blog); public List<Blog> getAll(); public Optional<Blog> getById(int id); public void modifyBlog(Blog blog); public void deleteBlogById(int BlogId); }
true
b7d0a6746682f5c1c781357442c82efbd51d70b9
Java
chodongsuk/shuttle_tracker
/app/src/main/java/com/viktorjankov/shuttletracker/singletons/FirebaseProvider.java
UTF-8
361
2.171875
2
[]
no_license
package com.viktorjankov.shuttletracker.singletons; import com.firebase.client.Firebase; public class FirebaseProvider { private static final String FIREBASE_URL = "https://shuttletracker.firebaseio.com"; private static final Firebase FIREBASE = new Firebase(FIREBASE_URL); public static Firebase getInstance() { return FIREBASE; } }
true
7b9a4c3a7f78b142f08b02bddd00375ee5a144dd
Java
geraldpereira/memeduel
/core/src/main/java/fr/byob/game/memeduel/core/GameSound.java
UTF-8
2,158
2.90625
3
[]
no_license
package fr.byob.game.memeduel.core; import java.util.Collection; import java.util.HashMap; import java.util.Map; import playn.core.PlayN; import playn.core.Sound; public class GameSound { private final static int AMOUNT = 3; private final static Map<String, GameSound> allSounds = new HashMap<String, GameSound>(); private static boolean mute = true; private Sound[] sounds; private int currentSoundIndex; public GameSound(final String name, final String path) { this(name, path, 1.0f); } public GameSound(final String name, final String path, final float volume) { this(name, path, volume, false, AMOUNT); } public GameSound(final String name, final String path, final float volume, final int amount) { this(name, path, volume, false, amount); } public GameSound(final String name, final String path, final float volume, final boolean looping) { this(name, path, volume, looping, AMOUNT); } public GameSound(final String name, final String path, final float volume, final boolean looping, final int amount) { if (allSounds.containsKey(name)) { PlayN.log().warn("GameSound" + name + " has already been created!"); } allSounds.put(name, this); sounds = new Sound[amount]; for (int i = 0; i < amount; i++) { final Sound sound = PlayN.assets().getSound(path); sound.setVolume(volume); sound.setLooping(looping); sounds[i] = sound; } currentSoundIndex = 0; } public Sound[] getSounds() { return this.sounds; } private Sound getCurrentSound() { return sounds[currentSoundIndex]; } public void play() { if (mute) { return; } final Sound sound = getCurrentSound(); if (sound.isPlaying()) { currentSoundIndex++; if (currentSoundIndex >= sounds.length) { currentSoundIndex = 0; } } else { sound.play(); } } public void stop() { for (final Sound sound : sounds) { sound.stop(); } } public static Collection<GameSound> values() { return allSounds.values(); } public static GameSound valueOf(final String name) { return allSounds.get(name); } public static void mute() { mute = true; } public static void unmute() { mute = false; } }
true
79653c92fdd6a5702f2b14c856f7b724cadc1f18
Java
sijver/ProteinSecondaryStructurePredictor
/src/main/statistics/AminoAcidStatistics.java
UTF-8
2,512
2.96875
3
[]
no_license
package main.statistics; import main.core.AminoAcid; import main.core.Protein; import java.util.EnumMap; import java.util.List; /** * Created with IntelliJ IDEA. */ public class AminoAcidStatistics { private static EnumMap<AminoAcid, Double> getAminoAcidFrequency(List<Protein> proteinList) { EnumMap<AminoAcid, Double> aminoAcidFrequency = new EnumMap<AminoAcid, Double>(AminoAcid.class); for (AminoAcid aminoAcid : AminoAcid.values()) { aminoAcidFrequency.put(aminoAcid, 0.0); } int totalAminoAcidsNumber = 0; for (Protein protein : proteinList) { for (AminoAcid aminoAcid : protein.getProteinSequence()) { if (aminoAcid != null) { aminoAcidFrequency.put(aminoAcid, aminoAcidFrequency.get(aminoAcid) + 1); totalAminoAcidsNumber++; } } } for (AminoAcid aminoAcid : AminoAcid.values()) { aminoAcidFrequency.put(aminoAcid, aminoAcidFrequency.get(aminoAcid) / totalAminoAcidsNumber); } return aminoAcidFrequency; } public static String getAminoAcidFreqSortStats(List<Protein> proteinList) { EnumMap<AminoAcid, Double> aminoAcidFrequency = getAminoAcidFrequency(proteinList); StringBuilder statsString = new StringBuilder(); for (int i = 0; i < AminoAcid.values().length; i++) { AminoAcid maxFreqAcid = null; double maxFrequency = Double.MIN_VALUE; for (AminoAcid aminoAcid : AminoAcid.values()) { if (aminoAcidFrequency.containsKey(aminoAcid) && maxFrequency < aminoAcidFrequency.get(aminoAcid)) { maxFrequency = aminoAcidFrequency.get(aminoAcid); maxFreqAcid = aminoAcid; } } aminoAcidFrequency.remove(maxFreqAcid); statsString.append(String.format("%1$s %2$.3f%%\n", maxFreqAcid, maxFrequency * 100)); } return statsString.toString(); } public static String getAminoAcidNameSortStats(List<Protein> proteinList) { EnumMap<AminoAcid, Double> aminoAcidFrequency = getAminoAcidFrequency(proteinList); StringBuilder statsString = new StringBuilder(); for (AminoAcid aminoAcid : AminoAcid.values()) { statsString.append(String.format("%1$s %2$.3f%%\n", aminoAcid, aminoAcidFrequency.get(aminoAcid) * 100)); } return statsString.toString(); } }
true
df17edc7b961f61fb829bebff0a4e92960658ea9
Java
yuercl/MyUtils
/src/test/java/com/yuer/test/CrawCarLogoTest.java
UTF-8
1,661
2.328125
2
[]
no_license
package com.yuer.test; import java.io.IOException; import java.net.SocketTimeoutException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.yuer.utils.HttpUtils; public class CrawCarLogoTest { private Logger logger = LoggerFactory.getLogger(CrawCarLogoTest.class); @Test public void start() { try { Document doc = Jsoup.connect("http://www.car-logos.org/").get(); Elements elements = doc.getElementsByClass("ngg-gallery-thumbnail-box"); if (elements != null) { for (int i = 0; i < elements.size(); i++) { Elements imgs = elements.get(i).getElementsByTag("a"); if (imgs != null) { logger.info(imgs.get(1).toString()); String detailUrl = imgs.get(1).attr("href"); Document detailDoc = Jsoup.connect("http://www.car-logos.org" + detailUrl).get(); Element tr = detailDoc.getElementById("content").getElementsByTag("table").get(0).getElementsByTag("tr").get(0); Element img = tr.getElementsByClass("size-full").get(0); String logo = img.attr("src"); logger.info("[" + logo + "]"); String[] names = logo.split("/"); String name = names[names.length - 1]; HttpUtils httpUtils = new HttpUtils(); String path = "C:\\cars\\" + name; httpUtils.getImg(logo, path); logger.info("[save to =" + path + "]"); } } } } catch (SocketTimeoutException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
true
26ea6ceacaf689b6b3e77b02c66df8b9f1f1a3b3
Java
wick3dshadow/uom-fitbit
/uom-fitbit-api/src/main/java/tec/uom/client/fitbit/model/device/ScaleVersion.java
UTF-8
169
1.53125
2
[ "Apache-2.0" ]
permissive
package tec.uom.client.fitbit.model.device; /** * Created by IntelliJ IDEA. * User: Anakar Parida * Date: 5/2/15 * Time: 7:16 PM */ public enum ScaleVersion { Aria }
true
3a9acbc622052e90089b693e32090f510564a86f
Java
um41r254/starting_again
/app/src/main/java/com/mid_banchers/starting_again/SignUp.java
UTF-8
2,547
2.203125
2
[]
no_license
package com.mid_banchers.starting_again; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.Toast; import com.google.android.gms.tasks.OnSuccessListener; import com.google.firebase.Timestamp; import com.google.firebase.firestore.FirebaseFirestore; import com.mid_banchers.starting_again.databinding.ActivitySignUpBinding; import java.util.HashMap; import java.util.Map; public class SignUp extends AppCompatActivity { ActivitySignUpBinding binding; FirebaseFirestore db = FirebaseFirestore.getInstance(); private static final String TAG = "SignUp De"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivitySignUpBinding.inflate(getLayoutInflater()); View view = binding.getRoot(); setContentView(view); binding.progressBarS.setVisibility(View.GONE); binding.newSignUpBtn.setOnClickListener(v -> { Map<String,Object> data = new HashMap<>(); data.put("password",binding.newPassword.getText().toString()); data.put("addedOn",Timestamp.now()); data.put("email",binding.newEmail.getText().toString()); data.put("user",binding.newUserName.getText().toString()); binding.progressBarS.setVisibility(View.VISIBLE); String newPassword = binding.newPassword.getText().toString(); String confirmPassword =binding.confirmPassword.getText().toString(); if (TextUtils.equals(newPassword,confirmPassword)) { Log.d(TAG, "password: equals"); db.collection("Password") .document(binding.newEmail.getText().toString()) .set(data).addOnSuccessListener(aVoid -> { binding.progressBarS.setVisibility(View.GONE); Log.d(TAG, "Data Added"); Toast.makeText(this, "Account Created", Toast.LENGTH_SHORT).show(); Intent intent =new Intent(this,Login.class); startActivity(intent); }); } else { binding.progressBarS.setVisibility(View.GONE); Toast.makeText(this, "Password Not Matched", Toast.LENGTH_SHORT).show(); Log.e(TAG, "Password Not Matched" ); } }); } }
true
2ff3f8235877d4de211e42d7bcc60c1a17fdb5ce
Java
ggierlik/eBookDeals
/Android/eBookDeals/src/com/ggierlik/ebookdeals/AlarmReceiver.java
UTF-8
1,226
2.34375
2
[]
no_license
/* package com.ggierlik.ebookdeals; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class AlarmReceiver extends BroadcastReceiver { public static final String ACTION_REFRESH_ALARM = "com.ggierlik.ebookdeals.REFRESH_ALARM"; public void onReceive(Context context, Intent intent) { try { //Bundle bundle = intent.getExtras(); //String message = "Updating feeds..."; //bundle.getString(""); Toast.makeText(context, "Updating feeds...", Toast.LENGTH_SHORT ).show(); //AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); //PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); //mgr.setInexactRepeating (AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), PERIOD, pi); //based on http://stackoverflow.com/questions/3599351/android-broadcast-receiver //based on Professional Android Development Intent startIntent = new Intent(context, FeedUpdaterService.class); context.startService(startIntent); } catch (Exception ex) { Toast.makeText(context, "Something went wrong", Toast.LENGTH_SHORT).show(); } } } */
true
68a9c0267f13894d48fffc1cde372156aeca7575
Java
BlackWish/GitPracticeOne
/Navigation/app/src/main/java/com/teamtreehouse/oslist/MainActivity.java
UTF-8
7,918
2.390625
2
[]
no_license
package com.teamtreehouse.oslist; import android.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import android.widget.ArrayAdapter; import android.widget.AdapterView; import android.view.View; import android.widget.Toast; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.content.res.Configuration; import android.app.FragmentManager; import android.app.FragmentTransaction; public class MainActivity extends ActionBarActivity { private ListView mDrawerList; private ArrayAdapter<String> mAdapter; private ActionBarDrawerToggle mDrawerToggle; private DrawerLayout mDrawerLayout; private String mActivityTitle; private int selectedPosition; private String[] drawerArray= { "Home", "Recipe List", "Recipes", "Timer", "Linux" }; private boolean objectControl=false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Connecting ID for DrawerList mDrawerList = (ListView)findViewById(R.id.navList); mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); //returns the title of this activity as a string mActivityTitle = getTitle().toString(); //Drawer Items addDrawerItems(); //Listener mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Toast.makeText(MainActivity.this, "Time for an upgrade!", Toast.LENGTH_SHORT).show(); selectedPosition = position; //Replace fragment content updateFragment(); mDrawerLayout.closeDrawer(mDrawerList); } }); //Customizes action bar to show up icon getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); //Drawer setup setupDrawer(); } //*** Helper method *** // //Items in Drawer public void addDrawerItems() { String[] osArray = { "Home", "Recipe List", "Recipes", "Timer", "Linux" }; mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, osArray); mDrawerList.setAdapter(mAdapter); } //Setup drawer public void setupDrawer() { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle("Menu"); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); //getSupportActionBar().setTitle(mActivityTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerLayout.setDrawerListener(mDrawerToggle); } //Update the Fragment public void updateFragment() { //Fragment objFragment= null; //Choosing Fragment switch (selectedPosition){ case 0: Fragment objFragmentOne= null; getSupportActionBar().setTitle("Home"); objFragmentOne=new Home(); FragmentManager fragmentManagerOne = getFragmentManager(); FragmentTransaction ftOne = fragmentManagerOne.beginTransaction(); ftOne.replace(R.id.mainlayout, objFragmentOne); ftOne.commit(); break; case 1: Fragment objFragmentTwo= null; getSupportActionBar().setTitle("Recipe List"); objFragmentTwo=new RecipeList(); FragmentManager fragmentManagerTwo = getFragmentManager(); FragmentTransaction ftTwo = fragmentManagerTwo.beginTransaction(); ftTwo.replace(R.id.mainlayout, objFragmentTwo); ftTwo.commit(); break; case 2: Fragment objFragmentThree= null; getSupportActionBar().setTitle("Recipe"); objFragmentThree=new Recipes(); FragmentManager fragmentManagerThree = getFragmentManager(); FragmentTransaction ftThree = fragmentManagerThree.beginTransaction(); ftThree.replace(R.id.mainlayout, objFragmentThree); ftThree.commit(); break; case 3: objectControl=true; Fragment objFragmentFour= null; getSupportActionBar().setTitle("Timer"); objFragmentFour=new Timer(); FragmentManager fragmentManagerFour = getFragmentManager(); FragmentTransaction ftFour = fragmentManagerFour.beginTransaction(); ftFour.replace(R.id.mainlayout, objFragmentFour); ftFour.commit(); break; case 4: if(objectControl){ Toast.makeText(MainActivity.this, "Timer is running behind", Toast.LENGTH_SHORT).show(); }else if (!objectControl){ Toast.makeText(MainActivity.this, "Timer is not running behind", Toast.LENGTH_SHORT).show(); } break; } /*FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.mainlayout, objFragment); ft.commit();*/ //WebViewFragment rFragment = new WebViewFragment(); // Passing selected item information to fragment //Bundle data = new Bundle(); //data.putString("title", drawerArray[selectedPosition]); /*data.putString("url", getUrl()); rFragment.setArguments(data);*/ //Replace fragment /* FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, rFragment); ft.commit();*/ } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } //handle opening and closing the drawer depending on if it is open or not if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } return super.onOptionsItemSelected(item); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); mDrawerToggle.syncState(); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); } }
true
929cdff8693fa176b228817491870dedec298eec
Java
jasonkoo/PriestSQL
/src/main/java/com/lenovo/priestsql/task/package-info.java
UTF-8
828
2.4375
2
[]
no_license
/** * */ /** * @author luojiang2 * */ package com.lenovo.priestsql.task; /** * Package scope interface.Only <code>AbstractTask</code> implements it. * Specific task class can only extends <code>AbstractTask</code>. * @author luojiang2 */ interface Task extends Runnable,Comparable<AbstractTask>{ /** * Get task name */ String getName(); /** * Get task id * @return */ String getId(); /** * Get task state * @return */ com.lenovo.priestsql.task.TaskState getTaskState(); /** * Get task start time * @return */ long getStartTime(); /** * Get task finish time * @return */ long getFinishTime(); /** * Get task throws <code>Exception</code> or <code>Error</code> when task is running. * @return */ Throwable getThrowable(); /** * Run task */ void run(); }
true
0fb2850985f45d68f8ab1da3d71b2d7d79ceb160
Java
MathieuM44/Aeroportspringweb
/AeroportSpringBoot/src/main/java/aeroportSpringBoot/repositories/ClientRepository.java
UTF-8
483
2
2
[]
no_license
package aeroportSpringBoot.repositories; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.query.Param; import aeroportSpringBoot.model.Client; public interface ClientRepository extends JpaRepository<Client, Long> { Optional<Client> clientGetReservation(@Param("idC") Long id); Client clientGetPassager(@Param("idC") Long id); List<Client> clientWithReservation(); }
true
ce45ea8f1bdc7dac4d4df21a0ee92db8f4ff4c7f
Java
kyocoolcool/Java-Notes
/Chapter10/Extend/HW10_13.java
UTF-8
550
3.15625
3
[ "MIT" ]
permissive
package Chris.Chapter10.Extend; class W{ public W() { num1=1; num2=1; } public W(int a,int b) { num1=a; num2=b; } public int num1; public int num2; } class O extends W{ public O() { super(); } public O(int a,int b) { super(a,b); } public void set_num(int a,int b) { num1=a; num2=b; } public void show() { System.out.println("num1="+num1+" num2="+num2); } } public class HW10_13 { public static void main(String[] args) { O b1=new O(); b1.show(); }}
true
d73192e301f962c3ea3e1374f412cb081ec57800
Java
1510M-20k/code-dunzhuangzhuang
/wcy_dao/src/main/java/com/wcy/dao/goodsType/GoodsTypeDao.java
UTF-8
519
1.96875
2
[]
no_license
package com.wcy.dao.goodsType; import java.util.List; import com.wcy.model.goodsType.GoodsType; public interface GoodsTypeDao { //新增 public int insert(GoodsType goodsType); //修改 public int update(GoodsType goodsType); //删除 public int delete(String id); //根据Id查询单条记录 public GoodsType getById(String id); //分页查询列表 public List<GoodsType> getList(GoodsType goodsType); //分页查询数量 public int getCount(GoodsType goodsType); }
true
0ad5ee92385d40a28c7a54017e7415375f7e9b1d
Java
PYJAH/PYJAH_Email_Application
/PYJAH_Email_Application/PYJAH_Software_Project_vc/src/pyjah/server/pkg/ServerController.java
UTF-8
1,410
2.4375
2
[]
no_license
package pyjah.server.pkg; import javafx.scene.control.TextArea; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.stage.Stage; public class ServerController implements Initializable { @FXML TextArea console; @FXML private Button sendButton; @FXML private TextField textInput; Server pyjahServer = new Server(console); public void displayText() { Platform.runLater(new Runnable(){ @Override public void run() { // Update your GUI here. console.appendText("Connection made"); } }); } public void handleServerButtonClick() { Platform.runLater(new Runnable(){ @Override public void run() { // Update your GUI here. console.appendText("Hello! You are now connected to PYJAH Email Server"); } }); } Thread thread1 = new Thread () { public void run () { pyjahServer.startServer(); } }; @Override public void initialize(URL arg0, ResourceBundle arg1) { pyjahServer.setConsole(console); thread1.start(); } }
true
4241c645e51dafd341bc91050245f86b3e079835
Java
CS2103-AY1819S1-W14-4/main
/src/main/java/seedu/inventory/logic/parser/purchaseorder/AddPurchaseOrderCommandParser.java
UTF-8
3,080
2.53125
3
[ "MIT" ]
permissive
package seedu.inventory.logic.parser.purchaseorder; import static seedu.inventory.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.inventory.logic.parser.CliSyntax.PREFIX_QUANTITY; import static seedu.inventory.logic.parser.CliSyntax.PREFIX_REQDATE; import static seedu.inventory.logic.parser.CliSyntax.PREFIX_SKU; import static seedu.inventory.logic.parser.CliSyntax.PREFIX_SUPPLIER; import java.util.stream.Stream; import seedu.inventory.logic.commands.purchaseorder.AddPurchaseOrderCommand; import seedu.inventory.logic.parser.ArgumentMultimap; import seedu.inventory.logic.parser.ArgumentTokenizer; import seedu.inventory.logic.parser.Parser; import seedu.inventory.logic.parser.ParserUtil; import seedu.inventory.logic.parser.Prefix; import seedu.inventory.logic.parser.exceptions.ParseException; import seedu.inventory.model.item.Quantity; import seedu.inventory.model.item.Sku; import seedu.inventory.model.purchaseorder.PurchaseOrder; import seedu.inventory.model.purchaseorder.RequiredDate; import seedu.inventory.model.purchaseorder.Supplier; /** * Parses input arguments and creates a new AddPurchaseOrderCommand object */ public class AddPurchaseOrderCommandParser implements Parser<AddPurchaseOrderCommand> { /** * Parses the given {@code String} of arguments in the context of the AddPurchaseOrderCommand * and returns an AddPurchaseOrderCommand object for execution. * * @throws ParseException if the user input does not conform the expected format */ public AddPurchaseOrderCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_SKU, PREFIX_QUANTITY, PREFIX_REQDATE, PREFIX_SUPPLIER); if (!arePrefixesPresent(argMultimap, PREFIX_SKU, PREFIX_QUANTITY, PREFIX_REQDATE, PREFIX_SUPPLIER) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddPurchaseOrderCommand.MESSAGE_USAGE)); } Sku sku = ParserUtil.parseSku(argMultimap.getValue(PREFIX_SKU).get()); Quantity quantity = ParserUtil.parseQuantity(argMultimap.getValue(PREFIX_QUANTITY).get()); RequiredDate reqDate = ParserUtil.parseReqDate(argMultimap.getValue(PREFIX_REQDATE).get()); Supplier supplier = ParserUtil.parseSupplier(argMultimap.getValue(PREFIX_SUPPLIER).get()); PurchaseOrder.Status status = PurchaseOrder.Status.DEFAULT_STATUS; PurchaseOrder purchaseOrder = new PurchaseOrder(sku, quantity, reqDate, supplier, status); return new AddPurchaseOrderCommand(purchaseOrder); } /** * Returns true if none of the prefixes contains empty {@code Optional} values in the given * {@code ArgumentMultimap}. */ private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); } }
true
5141fa5d080da7ca5cb9eeba8d31a3599dc096f0
Java
SeongJunKang/BitCamp-data-project
/BitcampJava80/SJ/java01/src/step03$String/Exam01.java
UTF-8
1,899
4.15625
4
[]
no_license
/* 주제: 사칙연산자 사용*/ package step03$String; public class Exam01 { public static void main(String[] args) { int v[]= new int[2]; for(int i=1;i<3;i++) v[i-1]=i*10; int result = v[0]+v[1]; System.out.println(result); byte b=10; // 리터럴 값 예외 규칙에 의해 컴파일 OK! //byte b=v[0]; // 오류! 변수의 경우 비록 작은 수라 할 지라도 허락하지 않는다. byte b1=10; byte b2=20; //byte b3=b1+b2; // 컴파일 오류! //byte b3 =10 + 20; // OK!! //byte b3 =b1 + 20; // 컴파일 오류! //byte b3 =10 + b2; // 컴파일 오류! short s1=20; //short s3=b1+s1; // 컴파일 오류! 이유 ? byte, short 메모리는 // 무조건 int 메모리로 취급된다. } } /* * 4byte 리터럴 값을 byte, short 메모리에 저장할 때, 저장이 가능하면 허락한다. 4byte 변수의 값을 byte, short 메모리에 저장할 때, 값을 저장할 수 있더라도 <무조건> 컴파일 오류 * 리터럴 값들의 연산 결과는 리터럴 값으로 취급한다. - 리터럴은 값이 연산을 하더라도 변하지 않는다. -> 컴파일(번역) 과정에서 검증할 수 있다. - 기존의 법칙 : 리터럴 값이 비록 4바이트라고 하더라도 메모리에 저장할 수 있다면, 허락 *byte 변수와 byte 변수의 연산 결과는 ? - int 이다. short와 short 연산도 동일. - 자바에서는 byte, short, int 메모리의 값을 다룰 떄 int 로 취급한다. * 리터럴과 변수의 연산 결과는 변수로 취급. -> 변수의 값에 따라 연산 결과가 달라지기 때문에 메모리에 저장할 수 있는지 확실하지 않다. 그래서 기본 크기 보다 작은 메모리에 저장하는 것을 허락하지 않는다. */
true
605a53feece00cf23ef52feaef3f9b11b1823dc0
Java
sparsh1999/esperAssignment
/app/src/main/java/com/example/esperassisgnment/Database/AppDatabase.java
UTF-8
1,387
2.1875
2
[]
no_license
package com.example.esperassisgnment.Database; import android.content.Context; import androidx.room.Database; import androidx.room.Room; import androidx.room.RoomDatabase; import com.example.esperassisgnment.Database.dao.ExclusionDAO; import com.example.esperassisgnment.Database.dao.FeatureDAO; import com.example.esperassisgnment.Database.dao.OptionsDAO; import com.example.esperassisgnment.Database.dao.SelectionDAO; import com.example.esperassisgnment.Models.Entities.Exclusions; import com.example.esperassisgnment.Models.Entities.Feature; import com.example.esperassisgnment.Models.Entities.Options; import com.example.esperassisgnment.Models.Entities.Selection; @Database(entities = {Feature.class, Options.class, Exclusions.class, Selection.class}, version = 1, exportSchema = false) public abstract class AppDatabase extends RoomDatabase { public static final String TAG = "AppDatabase"; public abstract FeatureDAO getFeatureDAO(); public abstract OptionsDAO getOptionsDAO(); public abstract ExclusionDAO getExclusionsDAO(); public abstract SelectionDAO getSelectionDAO(); //DB Connections public static AppDatabase databaseConnection(Context context){ return Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, "db-esper") .allowMainThreadQueries() .build(); } }
true
3b447a63e18c1bd70933d8a501c670b359c9ebd0
Java
googleapis/google-api-java-client-services
/clients/google-api-services-contentwarehouse/v1/2.0.0/com/google/api/services/contentwarehouse/v1/model/AssistantApiClockCapabilities.java
UTF-8
7,331
2.0625
2
[ "Apache-2.0" ]
permissive
/* * 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. */ /* * This code was generated by https://github.com/googleapis/google-api-java-client-services/ * Modify at your own risk. */ package com.google.api.services.contentwarehouse.v1.model; /** * Used to describe clock capabilities of the device (for example, capabilities related to maximum * number of supported alarms and timers that can be created on the device). Fields may be populated * by clients or be backfilled by SAL (in case of Timon, for example). * * <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is * transmitted over HTTP when working with the Document AI Warehouse API. For a detailed explanation * see: * <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a> * </p> * * @author Google, Inc. */ @SuppressWarnings("javadoc") public final class AssistantApiClockCapabilities extends com.google.api.client.json.GenericJson { /** * Maximum number of alarms that can be created on the client. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer maxSupportedAlarms; /** * Maximum extended timer duration supported by the client. The extended timer duration is the * total start-to-finish duration after an AddTimeToTimer operation. E.g. if a user sets a timer * for 30 minutes, and later adds 10 minutes, the extended duration is 40 minutes. * The value may be {@code null}. */ @com.google.api.client.util.Key private AssistantApiDuration maxSupportedExtendedTimerDuration; /** * Maximum duration of timers that can be created on the client. * The value may be {@code null}. */ @com.google.api.client.util.Key private AssistantApiDuration maxSupportedTimerDuration; /** * Maximum number of timers that can be created on the client. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer maxSupportedTimers; /** * The preferred provider to use for stopwatch related functionality. * The value may be {@code null}. */ @com.google.api.client.util.Key private AssistantApiCoreTypesProvider preferredStopwatchProvider; /** * Whether the client restricts alarms to ring within the next 24 hours. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Boolean restrictAlarmsToNext24h; /** * Maximum number of alarms that can be created on the client. * @return value or {@code null} for none */ public java.lang.Integer getMaxSupportedAlarms() { return maxSupportedAlarms; } /** * Maximum number of alarms that can be created on the client. * @param maxSupportedAlarms maxSupportedAlarms or {@code null} for none */ public AssistantApiClockCapabilities setMaxSupportedAlarms(java.lang.Integer maxSupportedAlarms) { this.maxSupportedAlarms = maxSupportedAlarms; return this; } /** * Maximum extended timer duration supported by the client. The extended timer duration is the * total start-to-finish duration after an AddTimeToTimer operation. E.g. if a user sets a timer * for 30 minutes, and later adds 10 minutes, the extended duration is 40 minutes. * @return value or {@code null} for none */ public AssistantApiDuration getMaxSupportedExtendedTimerDuration() { return maxSupportedExtendedTimerDuration; } /** * Maximum extended timer duration supported by the client. The extended timer duration is the * total start-to-finish duration after an AddTimeToTimer operation. E.g. if a user sets a timer * for 30 minutes, and later adds 10 minutes, the extended duration is 40 minutes. * @param maxSupportedExtendedTimerDuration maxSupportedExtendedTimerDuration or {@code null} for none */ public AssistantApiClockCapabilities setMaxSupportedExtendedTimerDuration(AssistantApiDuration maxSupportedExtendedTimerDuration) { this.maxSupportedExtendedTimerDuration = maxSupportedExtendedTimerDuration; return this; } /** * Maximum duration of timers that can be created on the client. * @return value or {@code null} for none */ public AssistantApiDuration getMaxSupportedTimerDuration() { return maxSupportedTimerDuration; } /** * Maximum duration of timers that can be created on the client. * @param maxSupportedTimerDuration maxSupportedTimerDuration or {@code null} for none */ public AssistantApiClockCapabilities setMaxSupportedTimerDuration(AssistantApiDuration maxSupportedTimerDuration) { this.maxSupportedTimerDuration = maxSupportedTimerDuration; return this; } /** * Maximum number of timers that can be created on the client. * @return value or {@code null} for none */ public java.lang.Integer getMaxSupportedTimers() { return maxSupportedTimers; } /** * Maximum number of timers that can be created on the client. * @param maxSupportedTimers maxSupportedTimers or {@code null} for none */ public AssistantApiClockCapabilities setMaxSupportedTimers(java.lang.Integer maxSupportedTimers) { this.maxSupportedTimers = maxSupportedTimers; return this; } /** * The preferred provider to use for stopwatch related functionality. * @return value or {@code null} for none */ public AssistantApiCoreTypesProvider getPreferredStopwatchProvider() { return preferredStopwatchProvider; } /** * The preferred provider to use for stopwatch related functionality. * @param preferredStopwatchProvider preferredStopwatchProvider or {@code null} for none */ public AssistantApiClockCapabilities setPreferredStopwatchProvider(AssistantApiCoreTypesProvider preferredStopwatchProvider) { this.preferredStopwatchProvider = preferredStopwatchProvider; return this; } /** * Whether the client restricts alarms to ring within the next 24 hours. * @return value or {@code null} for none */ public java.lang.Boolean getRestrictAlarmsToNext24h() { return restrictAlarmsToNext24h; } /** * Whether the client restricts alarms to ring within the next 24 hours. * @param restrictAlarmsToNext24h restrictAlarmsToNext24h or {@code null} for none */ public AssistantApiClockCapabilities setRestrictAlarmsToNext24h(java.lang.Boolean restrictAlarmsToNext24h) { this.restrictAlarmsToNext24h = restrictAlarmsToNext24h; return this; } @Override public AssistantApiClockCapabilities set(String fieldName, Object value) { return (AssistantApiClockCapabilities) super.set(fieldName, value); } @Override public AssistantApiClockCapabilities clone() { return (AssistantApiClockCapabilities) super.clone(); } }
true
b1d02a69107589549436c968e4a65f8fb820d483
Java
josefloso/FunsoftHMIS
/com/afrisoftech/hospital/BedsChargesintfr.java
UTF-8
108,183
1.992188
2
[]
no_license
/* * offintfr.java * * Created on August 13, 2002, 1:55 AM */ package com.afrisoftech.hospital; /** * * @author root */ public class BedsChargesintfr extends javax.swing.JInternalFrame { private javax.swing.JComboBox cmbox; com.afrisoftech.lib.DBObject dbObject; java.sql.Connection connectDB = null; javax.swing.table.TableModel tableModel = null; org.netbeans.lib.sql.pool.PooledConnectionSource pConnDB = null; public BedsChargesintfr(java.sql.Connection connDb, org.netbeans.lib.sql.pool.PooledConnectionSource pconnDB) { dbObject = new com.afrisoftech.lib.DBObject(); connectDB = connDb; pConnDB = pconnDB; initComponents(); } /** * 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jSeparator1 = new javax.swing.JSeparator(); jLabel4 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jPanel21 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new com.afrisoftech.dbadmin.JTable(); datePicker1 = new com.afrisoftech.lib.DatePicker(); jLabel1 = new javax.swing.JLabel(); jCheckBox1 = new javax.swing.JCheckBox(); jLabel2 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); try { java.lang.Class.forName("org.postgresql.Driver"); }catch (java.lang.ClassNotFoundException sl){ System.out.println(sl.getMessage()); } jButton1 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); setClosable(true); setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); setIconifiable(true); setMaximizable(true); setResizable(true); setTitle("Bed Charges"); setVisible(true); getContentPane().setLayout(new java.awt.GridBagLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jSeparator1, gridBagConstraints); jLabel4.setFont(new java.awt.Font("Utopia", 3, 18)); // NOI18N jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; getContentPane().add(jLabel4, gridBagConstraints); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("")); jPanel2.setLayout(new java.awt.GridBagLayout()); jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder("")); jPanel21.setLayout(new java.awt.GridBagLayout()); tableModel = jTable1.getModel(); tableModel.addTableModelListener(new javax.swing.event.TableModelListener() { public void tableChanged(javax.swing.event.TableModelEvent evt) { tableModelTableChanged(evt); } }); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null} }, new String [] { "Admission No.", "Name", "Ward", "Bed No.", "Days not Charged", "Amount", "Nursing", "Visit Id" } ) { Class[] types = new Class [] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jScrollPane1.setViewportView(jTable1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel21.add(jScrollPane1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 5; gridBagConstraints.gridheight = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 10.0; gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); jPanel2.add(jPanel21, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; jPanel2.add(datePicker1, gridBagConstraints); jLabel1.setText("Date"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); jPanel2.add(jLabel1, gridBagConstraints); jCheckBox1.setText("View all IN-Patients"); jCheckBox1.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); jCheckBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.weightx = 1.0; jPanel2.add(jCheckBox1, gridBagConstraints); jLabel2.setText("View IN-Patients by ward (select ward name)"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0); jPanel2.add(jLabel2, gridBagConstraints); jComboBox1.setModel(com.afrisoftech.lib.ComboBoxModel.ComboBoxModel(connectDB, "SELECT ward_name FROM hp_wards ORDER BY 1")); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel2.add(jComboBox1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 6; gridBagConstraints.gridheight = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 50.0; gridBagConstraints.insets = new java.awt.Insets(0, 2, 2, 2); getContentPane().add(jPanel2, gridBagConstraints); jButton1.setMnemonic('O'); jButton1.setText("Post Bed/Nursing Charges"); jButton1.setToolTipText("Click here enter data"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 14; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jButton1, gridBagConstraints); jButton3.setMnemonic('l'); jButton3.setText("Clear form"); jButton3.setToolTipText("Click here to clear textfields"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 14; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jButton3, gridBagConstraints); jButton4.setMnemonic('C'); jButton4.setText("Close form"); jButton4.setToolTipText("Click here to close window"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 14; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jButton4, gridBagConstraints); jButton2.setText("Remove row"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 14; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jButton2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 14; gridBagConstraints.gridwidth = 2; gridBagConstraints.weightx = 200.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jLabel3, gridBagConstraints); setBounds(0, 0, 814, 396); }// </editor-fold>//GEN-END:initComponents private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed int rows2Delete = jTable1.getSelectedRowCount(); int[] selectedRows = jTable1.getSelectedRows(); if (rows2Delete < 1) { java.awt.Toolkit.getDefaultToolkit().beep(); javax.swing.JOptionPane.showMessageDialog(this, "There are no selected rows to delete!"); } else { if (rows2Delete > 1) { for (int i = 0; i < selectedRows.length; i++) { javax.swing.table.DefaultTableModel defTableModel = (javax.swing.table.DefaultTableModel) jTable1.getModel(); defTableModel.removeRow(selectedRows[i]); } } else { javax.swing.table.DefaultTableModel defTableModel = (javax.swing.table.DefaultTableModel) jTable1.getModel(); defTableModel.removeRow(jTable1.getSelectedRow()); } } // Add your handling code here: }//GEN-LAST:event_jButton2ActionPerformed public void tableModelTableChanged(javax.swing.event.TableModelEvent evt) { } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed this.setVisible(false); // Add your handling code here: }//GEN-LAST:event_jButton4ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // Add your handling code here: }//GEN-LAST:event_jButton3ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // this.setCursor(new java.awt.Cursor()); try { String billNo = null; String transNo = null; String payMode = null; String patientAcc = null; String cardNo = null; String AccDesc = null; String scheme = null; String cardName = null; String isurer = null; String expDate = null; String staffNo = null; String glAcc = null; String mainAcc = null; String user = null; String patientCat = ""; String mainService = null; String service = null; double rate = 0.00; String visitid = null; String glcodesc = null; int patno = 0; java.sql.Savepoint registerSavePoint = null; try { connectDB.setAutoCommit(false); registerSavePoint = connectDB.setSavepoint("registration"); } catch (java.sql.SQLException ex) { ex.printStackTrace(); } try { java.util.Date periodFrom = null; java.util.Date periodTo = null; java.sql.Statement stmtf = connectDB.createStatement(); java.sql.ResultSet rsetf = stmtf.executeQuery("SELECT period_from,period_to FROM period_setup WHERE period_status ilike 'Open' AND '" + datePicker1.getDate() + "' BETWEEN period_from AND period_to"); while (rsetf.next()) { periodFrom = rsetf.getDate(1); periodTo = rsetf.getDate(2); } if (datePicker1.getDate().before(periodFrom) || datePicker1.getDate().after(periodTo)) { javax.swing.JOptionPane.showMessageDialog(this, "You cannot save before or after the accounting period set \n Contact head of accounts".toUpperCase(), "Caution Message", javax.swing.JOptionPane.INFORMATION_MESSAGE); } else { java.sql.Statement stm12q1 = connectDB.createStatement(); java.sql.ResultSet rse12q1 = stm12q1.executeQuery("select current_user"); while (rse12q1.next()) { user = rse12q1.getString(1); } user = "postgres"; java.sql.Statement stm12 = connectDB.createStatement(); java.sql.ResultSet rse12 = stm12.executeQuery("select code,activity from pb_activity where activity_category = 'PR'"); while (rse12.next()) { patientAcc = rse12.getObject(1).toString(); AccDesc = rse12.getObject(2).toString(); } java.sql.Statement ps = connectDB.createStatement(); java.sql.ResultSet rst = ps.executeQuery("select nextval('transaction_no_seq')"); while (rst.next()) { rst.getObject(1).toString(); transNo = rst.getObject(1).toString(); } for (int i = 0; i < jTable1.getRowCount(); i++) { if (jTable1.getValueAt(i, 0) != null) { java.sql.Statement stm121 = connectDB.createStatement(); System.err.println("Ward considered" + jTable1.getValueAt(i, 2).toString()); java.sql.ResultSet rse121 = stm121.executeQuery("SELECT revcode,revdesc FROM hp_wards WHERE ward_name ILIKE '" + jTable1.getValueAt(i, 2).toString()/*jComboBox1.getSelectedItem()*/ + "'"); while (rse121.next()) { glAcc = rse121.getObject(1).toString(); mainAcc = rse121.getObject(2).toString(); } if (jTable1.getModel().getValueAt(i, 0) != null) { java.sql.Statement stm12q = connectDB.createStatement(); java.sql.ResultSet rse12q = stm12q.executeQuery("select count(description) from hp_patient_card where date::date = '" + datePicker1.getDate().toString() + "' AND service ilike 'DAILY BED CHARGES%' AND patient_no = '" + jTable1.getValueAt(i, 0).toString() + "'"); while (rse12q.next()) { patno = rse12q.getInt(1); } if (patno > 0) { javax.swing.JOptionPane.showMessageDialog(this, "Beds have been Charged for '" + datePicker1.getDate().toString() + "'", "Comfirmation Message", javax.swing.JOptionPane.INFORMATION_MESSAGE); } else { // java.sql.Statement stmtz = connectDB.createStatement(); // java.sql.ResultSet rset = stmtz.executeQuery("select visit_id from hp_admission where patient_no = '" + jTable1.getValueAt(i, 0).toString() + "' and discharge = false AND visit_id IS NOT NULL"); // while (rset.next()) { visitid = jTable1.getValueAt(i, 7).toString(); // } java.sql.Statement stm1 = connectDB.createStatement(); java.sql.ResultSet rse1 = stm1.executeQuery("select pay_mode,account_no,description,payer,payer,expiry_date,account_no from hp_inpatient_register where patient_no ='" + jTable1.getValueAt(i, 0).toString() + "'"); //java.sql.ResultSet rse1 = stm1.executeQuery("select pay_mode,payer,account_no,description,category,expiry_date from hp_inpatient_register where patient_no = '"+jTable1.getValueAt(i,0).toString()+"'"); java.sql.Statement stm11 = connectDB.createStatement(); java.sql.ResultSet rse11 = stm11.executeQuery("SELECT nursing_revcode, nursing_revdesc,'Nursing Daily Charges','" + jTable1.getValueAt(i, 5) + "' FROM hp_wards WHERE ward_name ILIKE '" + jTable1.getValueAt(i, 2).toString()/* * jComboBox1.getSelectedItem() */ + "'"); while (rse11.next()) { mainService = rse11.getObject(2).toString(); service = rse11.getObject(3).toString(); rate = rse11.getDouble(4); glcodesc = rse11.getObject(1).toString(); } while (rse1.next()) { payMode = dbObject.getDBObject(rse1.getObject(1), "-"); cardNo = dbObject.getDBObject(rse1.getObject(2), "-"); scheme = dbObject.getDBObject(rse1.getObject(3), "-"); cardName = dbObject.getDBObject(rse1.getObject(4), "-"); isurer = dbObject.getDBObject(rse1.getObject(5), "-"); expDate = dbObject.getDBObject(rse1.getObject(6), "'now'"); staffNo = dbObject.getDBObject(rse1.getObject(7), "-"); } java.sql.PreparedStatement pstmt = connectDB.prepareStatement("insert into hp_patient_card values(?,?,?,?,?,?,?,?,?, ?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)"); pstmt.setObject(1, jTable1.getValueAt(i, 0).toString()); pstmt.setObject(2, "Daily Bed Charges"); pstmt.setString(3, patientCat); pstmt.setString(4, payMode); pstmt.setString(5, transNo); pstmt.setString(7, scheme); pstmt.setString(6, cardNo); pstmt.setString(8, cardName); pstmt.setString(9, isurer); pstmt.setDate(10, null); pstmt.setString(11, ""); pstmt.setDouble(12, java.lang.Double.valueOf(jTable1.getValueAt(i, 5).toString())); pstmt.setDouble(13, 0.00); pstmt.setDate(14, com.afrisoftech.lib.SQLDateFormat.getSQLDate(datePicker1.getDate())); pstmt.setObject(15, patientAcc); pstmt.setString(16, com.afrisoftech.lib.GLCodesFactory.getActivityDescription(connectDB, com.afrisoftech.lib.WardGLAccountsFactory.getBedChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString())));//mainAcc); pstmt.setDouble(17, java.lang.Double.valueOf(jTable1.getValueAt(i, 4).toString())); pstmt.setObject(18, staffNo); pstmt.setBoolean(19, false); pstmt.setString(20, "Billing"); pstmt.setBoolean(21, false); pstmt.setString(22, AccDesc); pstmt.setString(23, visitid); pstmt.setString(24, user); pstmt.setString(25, billNo); pstmt.setString(26, "IP"); pstmt.setTimestamp(27, new java.sql.Timestamp(java.util.Calendar.getInstance().getTimeInMillis())); pstmt.setString(28, visitid); pstmt.executeUpdate(); java.sql.PreparedStatement pstmt2 = connectDB.prepareStatement("insert into ac_ledger values(?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"); pstmt2.setString(1, com.afrisoftech.lib.WardGLAccountsFactory.getBedChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString())); pstmt2.setObject(2, com.afrisoftech.lib.GLCodesFactory.getActivityDescription(connectDB, com.afrisoftech.lib.WardGLAccountsFactory.getBedChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString()))); pstmt2.setObject(3, jTable1.getValueAt(i, 0).toString()); pstmt2.setObject(4, jTable1.getValueAt(i, 1).toString()); pstmt2.setString(5, ""); pstmt2.setString(6, ""); pstmt2.setString(7, ""); pstmt2.setString(8, "IP"); pstmt2.setString(9, ""); pstmt2.setString(10, payMode); pstmt2.setString(11, ""); pstmt2.setString(12, ""); pstmt2.setString(13, ""); pstmt2.setString(14, "Daily Bed Charges"); pstmt2.setString(15, "Billing"); pstmt2.setDouble(16, 0.00); pstmt2.setDouble(17, java.lang.Double.valueOf(jTable1.getValueAt(i, 5).toString())); pstmt2.setDate(18, com.afrisoftech.lib.SQLDateFormat.getSQLDate(datePicker1.getDate())); pstmt2.setString(19, transNo); pstmt2.setBoolean(20, false); pstmt2.setBoolean(21, false); pstmt2.setBoolean(22, false); pstmt2.setString(23, user); pstmt2.executeUpdate(); if (rate > 0) { java.sql.PreparedStatement pstmtr = connectDB.prepareStatement("insert into hp_patient_card values(?,?,?,?,?,?,?,?,?, ?,?,?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?,?,?,?,?,?)"); pstmtr.setObject(1, jTable1.getValueAt(i, 0).toString()); pstmtr.setObject(2, service); pstmtr.setString(3, patientCat); pstmtr.setString(4, payMode); pstmtr.setString(5, transNo); pstmtr.setString(7, scheme); pstmtr.setString(6, cardNo); pstmtr.setString(8, cardName); pstmtr.setString(9, isurer); pstmtr.setDate(10, null); pstmtr.setString(11, ""); pstmtr.setDouble(12, Double.parseDouble(jTable1.getValueAt(i, 6).toString())); pstmtr.setDouble(13, 0.00); pstmtr.setDate(14, com.afrisoftech.lib.SQLDateFormat.getSQLDate(datePicker1.getDate())); pstmtr.setObject(15, patientAcc); pstmtr.setString(16, com.afrisoftech.lib.GLCodesFactory.getActivityDescription(connectDB, com.afrisoftech.lib.WardGLAccountsFactory.getNursingChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString()))); pstmtr.setDouble(17, Double.parseDouble(jTable1.getValueAt(i, 4).toString())); pstmtr.setObject(18, staffNo); pstmtr.setBoolean(19, false); pstmtr.setString(20, "Billing"); pstmtr.setBoolean(21, false); pstmtr.setString(22, AccDesc); pstmtr.setString(23, visitid); pstmtr.setString(24, user); pstmtr.setString(25, billNo); pstmtr.setString(26, "IP"); pstmtr.setTimestamp(27, new java.sql.Timestamp(java.util.Calendar.getInstance().getTimeInMillis())); pstmtr.setString(28, visitid); pstmtr.executeUpdate(); java.sql.PreparedStatement pstmt2r = connectDB.prepareStatement("insert into ac_ledger values(?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"); pstmt2r.setString(1, com.afrisoftech.lib.WardGLAccountsFactory.getNursingChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString())); pstmt2r.setObject(2, com.afrisoftech.lib.GLCodesFactory.getActivityDescription(connectDB, com.afrisoftech.lib.WardGLAccountsFactory.getNursingChargesGLAccount(connectDB, jTable1.getValueAt(i, 2).toString()))); pstmt2r.setObject(3, jTable1.getValueAt(i, 0).toString()); pstmt2r.setString(4, jTable1.getValueAt(i, 1).toString()); pstmt2r.setString(5, ""); pstmt2r.setString(6, ""); pstmt2r.setString(7, ""); pstmt2r.setString(8, "IP"); pstmt2r.setString(9, ""); pstmt2r.setString(10, payMode); pstmt2r.setString(11, ""); pstmt2r.setString(12, ""); pstmt2r.setString(13, ""); pstmt2r.setString(14, service); pstmt2r.setString(15, "Billing"); pstmt2r.setDouble(16, 0.00); pstmt2r.setDouble(17, Double.parseDouble(jTable1.getValueAt(i, 6).toString())); pstmt2r.setDate(18, com.afrisoftech.lib.SQLDateFormat.getSQLDate(datePicker1.getDate())); pstmt2r.setString(19, transNo); pstmt2r.setBoolean(20, false); pstmt2r.setBoolean(21, false); pstmt2r.setBoolean(22, false); pstmt2r.setString(23, user); pstmt2r.executeUpdate(); } } } } } } connectDB.commit(); connectDB.setAutoCommit(true); javax.swing.JOptionPane.showMessageDialog(this, "Bed/Nursing charges done successfully", "Comfirmation Message", javax.swing.JOptionPane.INFORMATION_MESSAGE); for (int k = 0; k < jTable1.getRowCount(); k++) { for (int r = 0; r < jTable1.getColumnCount(); r++) { jTable1.getModel().setValueAt(null, k, r); } } } catch (java.sql.SQLException sq) { sq.printStackTrace(); try { connectDB.rollback(registerSavePoint); } catch (java.sql.SQLException sql) { javax.swing.JOptionPane.showMessageDialog(this, sql.getMessage(), "Error Message!", javax.swing.JOptionPane.ERROR_MESSAGE); } sq.printStackTrace(); System.out.println(sq.getMessage()); javax.swing.JOptionPane.showMessageDialog(this, sq.getMessage(), "Error", javax.swing.JOptionPane.ERROR_MESSAGE); } } catch (java.lang.Exception ex) { ex.printStackTrace(); System.out.println(ex.getMessage()); javax.swing.JOptionPane.showMessageDialog(this, "TRANSACTION ERROR : Please double check your entries.", "Error", javax.swing.JOptionPane.ERROR_MESSAGE); } // Add your handling code here: }//GEN-LAST:event_jButton1ActionPerformed private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed java.util.Vector bedsRowVector = new java.util.Vector(1, 1); java.util.Vector bedsHeaderRowVector = new java.util.Vector(1, 1); bedsHeaderRowVector.addElement("Admission No."); bedsHeaderRowVector.addElement("Name"); bedsHeaderRowVector.addElement("Ward"); bedsHeaderRowVector.addElement("Bed No."); bedsHeaderRowVector.addElement("Days"); bedsHeaderRowVector.addElement("Bed Fee"); bedsHeaderRowVector.addElement("Nursing Fee"); bedsHeaderRowVector.addElement("Visit ID"); int j = 0; int i = 0; for (int k = 0; k < jTable1.getRowCount(); k++) { for (int r = 0; r < jTable1.getColumnCount(); r++) { jTable1.setValueAt(null, k, r); } } try { float noofDays = 0; float amount = 0; float totalAmt = 0; float bedCharged = 0; java.sql.Statement stmtTable1 = connectDB.createStatement(); java.sql.ResultSet rsetTable1 = stmtTable1.executeQuery("SELECT" + " patient_no,upper(patient_name) as name ,ward,bed_no,deposit,nursing,visit_id " + " FROM hp_admission WHERE discharge = false " + " ORDER BY visit_id"); while (rsetTable1.next()) { // String visitId = null; java.sql.Statement pss111 = connectDB.createStatement(); java.sql.ResultSet rss111 = pss111.executeQuery("select (CURRENT_DATE::date - date_admitted::date),deposit" + " FROM hp_admission WHERE visit_id = '" + rsetTable1.getString(7) + "' ORDER BY visit_id DESC LIMIT 1"); while (rss111.next()) { noofDays = rss111.getFloat(1); amount = rss111.getFloat(2); totalAmt = /* * noofDays */ 1 * amount; } java.sql.Statement pss1111 = connectDB.createStatement(); java.sql.ResultSet rss1111 = pss1111.executeQuery("SELECT SUM(dosage) FROM hp_patient_card" + " WHERE visit_id = '" + rsetTable1.getString(7) + "' AND service ILIKE '%bed%' AND debit > 0"); while (rss1111.next()) { bedCharged = rss1111.getFloat(1); } totalAmt = /* * (noofDays - bedCharged) */ 1 * amount; // jTextField23.setText(java.lang.String.valueOf(totalAmt)); if (totalAmt > 0) { java.util.Vector columnDataVector = new java.util.Vector(1, 1); System.out.println("Working at table row " + i); columnDataVector.addElement(rsetTable1.getObject(1)); columnDataVector.addElement(rsetTable1.getObject(2)); columnDataVector.addElement(rsetTable1.getObject(3)); columnDataVector.addElement(rsetTable1.getObject(4)); columnDataVector.addElement(/* * (noofDays - bedCharged) */1); columnDataVector.addElement(totalAmt); columnDataVector.addElement(rsetTable1.getObject(6)); columnDataVector.addElement(rsetTable1.getObject(7)); /* System.out.println("Working at table row " + i); jTable1.setValueAt(rsetTable1.getObject(1), i, 0); jTable1.setValueAt(rsetTable1.getObject(2), i, 1); jTable1.setValueAt(rsetTable1.getObject(3), i, 2); jTable1.setValueAt(rsetTable1.getObject(4), i, 3); jTable1.setValueAt(/* * (noofDays - bedCharged) *//*1, i, 4); jTable1.setValueAt(totalAmt, i, 5); jTable1.setValueAt(rsetTable1.getObject(6), i, 6); jTable1.setValueAt(rsetTable1.getObject(7), i, 7); */ i++; bedsRowVector.addElement(columnDataVector); } } javax.swing.table.DefaultTableModel bedsTableModel = new javax.swing.table.DefaultTableModel(bedsRowVector, bedsHeaderRowVector); jTable1.setModel(bedsTableModel); } catch (java.sql.SQLException sqlExec) { javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getMessage()); } // Add your handling code here: }//GEN-LAST:event_jCheckBox1ActionPerformed private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed int j = 0; int i = 0; for (int k = 0; k < jTable1.getRowCount(); k++) { for (int r = 0; r < jTable1.getColumnCount(); r++) { jTable1.setValueAt(null, k, r); } } //try { // } catch (java.sql.SQLException sqlex) { // System.out.println(sqlex.getMessage()); // } try { float noofDays = 0; float amount = 0; float totalAmt = 0; float bedCharged = 0; float professionalAmount = 0; java.sql.Statement stmtTable1 = connectDB.createStatement(); java.sql.ResultSet rsetTable1 = stmtTable1.executeQuery("SELECT" + " patient_no,upper(patient_name) as name ,ward,bed_no,deposit,nursing,visit_id " + "FROM hp_admission WHERE discharge = false AND ward " + "ILIKE '" + jComboBox1.getSelectedItem() + "' ORDER BY visit_id"); while (rsetTable1.next()) { // String visitId = null; java.sql.Statement pss111 = connectDB.createStatement(); java.sql.ResultSet rss111 = pss111.executeQuery("select (CURRENT_DATE::date - date_admitted::date),deposit" + " FROM hp_admission WHERE visit_id = '" + rsetTable1.getString(7) + "' ORDER BY visit_id DESC LIMIT 1"); while (rss111.next()) { noofDays = rss111.getFloat(1); amount = rss111.getFloat(2); totalAmt = /*noofDays **/ amount; //professionalAmount = noofDays * } java.sql.Statement pss1111 = connectDB.createStatement(); java.sql.ResultSet rss1111 = pss1111.executeQuery("SELECT SUM(dosage) FROM hp_patient_card" + " WHERE visit_id = '" + rsetTable1.getString(7) + "' AND service ILIKE '%bed%' AND debit > 0"); while (rss1111.next()) { bedCharged = rss1111.getFloat(1); } totalAmt = /*(noofDays - bedCharged) **/ amount; if (totalAmt > 0) { // jTextField23.setText(java.lang.String.valueOf(totalAmt)); System.out.println("Working at table row " + i); jTable1.setValueAt(rsetTable1.getObject(1), i, 0); jTable1.setValueAt(rsetTable1.getObject(2), i, 1); jTable1.setValueAt(rsetTable1.getObject(3), i, 2); jTable1.setValueAt(rsetTable1.getObject(4), i, 3); //// jTable1.setValueAt((noofDays - bedCharged), i, 4); jTable1.setValueAt((1), i, 4); jTable1.setValueAt(totalAmt, i, 5); jTable1.setValueAt(Double.parseDouble(rsetTable1.getObject(6).toString())/* * (noofDays)*/, i, 6); jTable1.setValueAt(rsetTable1.getObject(7), i, 7); i++; } } } catch (java.sql.SQLException sqlExec) { javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getMessage()); } // TODO add your handling code here: }//GEN-LAST:event_jComboBox1ActionPerformed private void cmboxActionPerformed(java.awt.event.ActionEvent evt) { int i = jTable1.getSelectedRow(); /* * try { //java.sql.Connection con = * java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/hospital","postgres","pilsiner"); * java.sql.Statement pstmt = connectDB.createStatement(); * java.sql.ResultSet rs = pstmt.executeQuery("select first_name||' * '||middle_name||' '||last_name from member where m_number = * '"+cmbox.getSelectedItem()+"'"); while (rs.next()){ * //jTextField4.setText(rs.getObject(1).toString()); * jTable1.setValueAt(rs.getObject(1),i,1); } } * catch(java.sql.SQLException sqlex){ * System.out.println(sqlex.getMessage()); } */ } // Variables declaration - do not modify//GEN-BEGIN:variables private com.afrisoftech.lib.DatePicker datePicker1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; public javax.swing.JButton jButton4; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel21; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables }
true
03ee74a8b5001ef8edd435ccfd31db7d78080a70
Java
unisorsebastian/home-automation
/src/main/java/ro/jmind/model/Room.java
UTF-8
1,235
2.734375
3
[]
no_license
package ro.jmind.model; import java.io.Serializable; public class Room implements Serializable{ private static final long serialVersionUID = 4061426358307070670L; private String name; private Thermometer thermometer; public String getName() { return name; } public void setName(String name) { this.name = name; } public Thermometer getThermometer() { return thermometer; } public void setThermometer(Thermometer thermometer) { this.thermometer = thermometer; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((thermometer == null) ? 0 : thermometer.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Room other = (Room) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (thermometer == null) { if (other.thermometer != null) return false; } else if (!thermometer.equals(other.thermometer)) return false; return true; } }
true
aba195a6dd6f47eb85a96649b5dfe52ad35a6929
Java
MHH7/SocialNetwork
/Phase2/src/main/java/Event/Settings/PrivacySettings/LastSeenTypeChangeEvent.java
UTF-8
266
2.171875
2
[]
no_license
package Event.Settings.PrivacySettings; public class LastSeenTypeChangeEvent { private final String type; public LastSeenTypeChangeEvent(String type){ this.type = type; } public String getType() { return type; } }
true
e99dd380b3b82487f42e0f4baf773b540140f6e2
Java
orisuchy/SPL-Ass2
/release/src/main/java/bgu/spl/a2/sim/actions/RemoveCourseFromGradesSheet.java
UTF-8
1,006
2.765625
3
[]
no_license
package bgu.spl.a2.sim.actions; import bgu.spl.a2.Action; import bgu.spl.a2.Promise; import bgu.spl.a2.sim.privateStates.StudentPrivateState; public class RemoveCourseFromGradesSheet extends Action<Boolean> { private StudentPrivateState studentState; private String course; /** * Constructor * @param course - String of course's name */ public RemoveCourseFromGradesSheet(String course) { super(); setActionName("Remove Course " + course + " From Grades Sheet"); this.course = course; } /** * Remove the course from the grade sheet of the student */ @Override protected void start() { throwExceptionForInvalidActorStateType(StudentPrivateState.class); studentState = (StudentPrivateState)getCurrentPrivateState(); Boolean courseGradeRemoved = studentState.removeGrade(course); complete(courseGradeRemoved); } @Override public String toString() { return "RemoveCourseFromGradesSheet [course=" + course + "]"; } }
true
371610b628d4e6ffe86c71b9ca0a8352158b508c
Java
suevip/smart-device
/darma/app/co/darma/daos/implspringjdbc/UserUpdateTimeDaoImpl.java
UTF-8
984
2.296875
2
[]
no_license
package co.darma.daos.implspringjdbc; import co.darma.daos.UserUpdateTimeDao; import co.darma.daos.implspringjdbc.init.JDBCTemplateFactory; import co.darma.daos.implspringjdbc.rowmappers.SittingMapper; import co.darma.daos.implspringjdbc.rowmappers.UserUpdateTimeMapper; import org.springframework.jdbc.core.JdbcTemplate; import java.util.List; /** * Created by frank on 15/12/10. */ public class UserUpdateTimeDaoImpl implements UserUpdateTimeDao { public static final UserUpdateTimeDao INSTANCE = new UserUpdateTimeDaoImpl(); private JdbcTemplate t = JDBCTemplateFactory.getJdbcTemplate(); @Override public Long queryUserLastUpdateTime(long memberId) { String sql = "select member_id , last_update_time from v_user_udpate_time t where t.member_id = ? "; List<Long> times = t.query(sql, new Object[]{memberId}, new UserUpdateTimeMapper()); if (times.size() > 0) { return times.get(0); } return 0L; } }
true
449bf42dfb4aa55d429322fd2ff351c1e32acd69
Java
heianxing/gflow
/gflow-core/src/main/java/com/gsralex/gflow/core/config/GFlowConfig.java
UTF-8
787
1.789063
2
[]
no_license
package com.gsralex.gflow.core.config; import com.gsralex.gflow.core.util.PropertyName; import java.util.Date; /** * @author gsralex * @date 2018/2/18 */ public class GFlowConfig { @PropertyName(name = "gflow.db.driver") public String dbDriver; @PropertyName(name = "gflow.db.url") public String dbUrl; @PropertyName(name = "gflow.db.username") public String dbUserName; @PropertyName(name = "gflow.db.password") public String dbUserPass; @PropertyName(name = "gflow.db.dbPrefix1") public int dbPrefix1; @PropertyName(name = "gflow.db.dbPrefix2") public long dbPrefix2; @PropertyName(name = "gflow.db.dbPrefix3") public double dbPrefix3; @PropertyName(name = "gflow.db.dbPrefix4") public Date dbPrefix4; }
true
a5b061a59fb1bc01bf37c4ef5b06db9f90b4fa14
Java
nadineabdallahmohamed/Stream_lab
/Main.java
UTF-8
188
2.046875
2
[]
no_license
package Stream_lab; public class Main { public static void main(String[] args) { String first_str = "Test example"; System.out.print(Stream.Test_str(first_str)); } }
true
90721b964882b42cdaba5c564c414da832e66dfa
Java
KwlEntmt/mcorelib
/src/de/timc/mcorelib/event/InventoryClickListener.java
UTF-8
636
2.03125
2
[]
no_license
package de.timc.mcorelib.event; import org.bukkit.event.EventHandler; import org.bukkit.event.inventory.InventoryClickEvent; import de.timc.mcorelib.core.MCore; import de.timc.mcorelib.plugin.MCoreLibPlugin; import de.timc.mcorelib.plugin.MCorePlayer; public class InventoryClickListener extends ListenerProperty { protected InventoryClickListener(MCoreLibPlugin plugin) { super(plugin); } @EventHandler public void onInventoryClick(InventoryClickEvent e) { MCorePlayer p = MCore.get().getMCorePlayer(e.getWhoClicked().getName()); e.setCancelled(p.getInventoryNameBlacklist().contains(e.getInventory().getTitle())); } }
true
01c199c82c90422154946595cbec6021ba2b4a4b
Java
zeroAone/testgit
/demo01_success2/src/main/java/com/gx/dao/impl/ArticleManagerDaoImpl.java
UTF-8
2,404
2.296875
2
[]
no_license
package com.gx.dao.impl; import java.util.ArrayList; import java.util.List; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.hibernate5.HibernateTemplate; import com.gx.dao.ArticleManagerDao; import com.gx.po.WebArticle; public class ArticleManagerDaoImpl implements ArticleManagerDao { @Autowired private HibernateTemplate hibernateTemplate; public void insertArticle(WebArticle article) { // TODO Auto-generated method stub hibernateTemplate.save(article); } public List<WebArticle> selectAllArticle() { // TODO Auto-generated method stub return (List<WebArticle>) hibernateTemplate.find("from WebArticle"); } public WebArticle findArticleByID(int id) { // TODO Auto-generated method stub WebArticle article=hibernateTemplate.get(WebArticle.class, id); return article; } public void updateArticle(WebArticle webArticle) { hibernateTemplate.update(webArticle); } public void deleteArticle(WebArticle webArticle) { // TODO Auto-generated method stub hibernateTemplate.delete(webArticle); } public List<WebArticle> selectArticleByMultipleConditionsCombined(WebArticle webArticle) { String hql="from WebArticle where 1=1"; List<Object> prams=new ArrayList<Object>(); if(webArticle.getAttributes().getBasicAttributesId()!=0){ hql+=" and attributes.basicAttributesId=?"; prams.add(webArticle.getAttributes().getBasicAttributesId()); } if(!webArticle.getWTitle().equals("")){ hql+=" and WTitle like ?"; prams.add("%"+webArticle.getWTitle()+"%"); } List<WebArticle> articleList=(List<WebArticle>) hibernateTemplate.find(hql,prams.toArray()); //多条件组合查询-离线对象方式实现 /* DetachedCriteria criteria=DetachedCriteria.forClass(WebArticle.class); if(webArticle.getAttributes().getBasicAttributesId()!=0){ criteria.add(Restrictions.eq("WebArticle.attributes.basicAttributesId", webArticle.getAttributes().getBasicAttributesId())); } if(!webArticle.getWTitle().equals("")){ criteria.add(Restrictions.eq("WebArticle.WTitle like", "%"+webArticle.getWTitle()+"%")); } List<WebArticle> articleList=(List<WebArticle>) hibernateTemplate.findByCriteria(criteria);*/ return articleList; } }
true
679355799641ac5e41655c7d9656295db63dfe61
Java
fpeterek/PJP-Language
/src/main/java/org/fpeterek/pjp/generated/ASTAssignment.java
UTF-8
544
1.679688
2
[ "MIT" ]
permissive
/* Generated By:JJTree: Do not edit this line. ASTAssignment.java Version 7.0 */ /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.fpeterek.pjp.generated; public class ASTAssignment extends SimpleNode { public ASTAssignment(int id) { super(id); } public ASTAssignment(Parser p, int id) { super(p, id); } } /* JavaCC - OriginalChecksum=03c87258061335b7601e2f4950201da6 (do not edit this line) */
true
b1e839566dc917e35cb2e62b724d0cd0bfaf7dcc
Java
lferreiro/eis_201901c_tp_grupal
/src/test/java/jUnit/BombermanExplosionTest.java
UTF-8
5,124
2.5625
3
[]
no_license
package jUnit; import bomberman.*; import javafx.util.Pair; import org.junit.Before; import org.junit.Test; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; public class BombermanExplosionTest { private Controlador controlador; private Pair<Integer, Integer> coordenada; private Celda celda; private Posicion posicion; private Bomberman bomberman; @Before public void setUp() { controlador = new Controlador(5); coordenada = new Pair<>(0, 0); celda = new Celda(); posicion = new Posicion(0, 0); bomberman = controlador.getBomberman(); } @Test public void testBombermanPoneUnaBombaEnUnaCeldaConUnaParedYLaExplota() { celda.setContenido(new ParedMelamina()); posicion.setCoordenada(new Pair<>(1, 0)); controlador.getMapa().setCelda(posicion, celda); Celda celdaExplotada = controlador.getMapa().getCelda(posicion); assertTrue(celdaExplotada.getContenido() instanceof ParedMelamina); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(celdaExplotada.getContenido() instanceof ContenidoVacio); } @Test public void testBombermanPoneBombaYExplotanEnemigoYPared(){ celda.setContenido(new Enemigo(bomberman)); posicion.setCoordenada(new Pair<>(2, 2)); controlador.getMapa().setCelda(posicion, celda); Celda celdaEnPosicionx1y0 = controlador.getMapa().getCelda(new Posicion(1,0)); Celda celdaExplotada = controlador.getMapa().getCelda(posicion); assertTrue(celdaEnPosicionx1y0.getContenido() instanceof ParedMelamina); assertTrue(celdaExplotada.getContenido() instanceof Enemigo); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(celdaEnPosicionx1y0.getContenido() instanceof ContenidoVacio); assertTrue(celdaExplotada.getContenido() instanceof ContenidoVacio); } @Test public void hayUnaParedDeAceroEnRangoDeExplosionPeroQuedaIntacta(){ celda.setContenido(new ParedAcero()); posicion.setCoordenada(new Pair<>(1, 0)); controlador.getMapa().setCelda(posicion, celda); Celda celdaExplotada = controlador.getMapa().getCelda(posicion); assertTrue(celdaExplotada.getContenido() instanceof ParedAcero); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(celdaExplotada.getContenido() instanceof ParedAcero); } @Test public void testBombermanMataABagulaaConUnaBombaYTieneElPoderNuevo(){ celda.setContenido(new Bagulaa(bomberman)); posicion.setCoordenada(new Pair<>(3, 1)); controlador.getMapa().setCelda(posicion, celda); Celda celdaExplotada = controlador.getMapa().getCelda(posicion); assertTrue(celdaExplotada.getContenido() instanceof Bagulaa); assertTrue(bomberman.getPoder() instanceof Poder); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(celdaExplotada.getContenido() instanceof ContenidoVacio); assertTrue(bomberman.getPoder() instanceof PoderLanzar); } @Test public void testBombermanMataAProtoMaxJrConUnaBombaYObtienePoderParaSaltarParedes() { Celda celdaConProtoMaxJr = new Celda(); celdaConProtoMaxJr.setContenido(new ProtoMaxJr(bomberman)); Posicion posicionCeldaJr = new Posicion(2,2); controlador.getMapa().setCelda(posicionCeldaJr, celdaConProtoMaxJr); celda.setContenido(new ParedAcero()); posicion.setCoordenada(new Pair<>(2, 1)); controlador.getMapa().setCelda(posicion, celda); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(bomberman.getPoder() instanceof PoderSaltar); controlador.moverEnDireccion(Direccion.DERECHA); assertEquals(new Pair<>(3,1), bomberman.getPoisicion().getCoordenada()); } @Test public void testBombermanMataAProtoMaxUnitsConUnaBombaYObtienePoderSaltarYLanzar(){ Celda celdaConProtoMaxUnits = new Celda(); celdaConProtoMaxUnits.setContenido(new ProtoMaxUnits(bomberman)); Posicion posicionCeldaUnits = new Posicion(2,2); Celda celdaMelamina = new Celda(); celdaMelamina.setContenido(new ParedMelamina()); Posicion posicionMelamina = new Posicion(4,3); controlador.getMapa().setCelda(posicionMelamina, celdaMelamina); controlador.getMapa().setCelda(posicionCeldaUnits, celdaConProtoMaxUnits); celda.setContenido(new ParedAcero()); posicion.setCoordenada(new Pair<>(2, 1)); controlador.getMapa().setCelda(posicion, celda); controlador.sembrarBomba(Direccion.ARRIBA); assertTrue(bomberman.getPoder() instanceof PoderLanzarYSaltar); assertTrue(celdaMelamina.getContenido() instanceof ParedMelamina); controlador.moverEnDireccion(Direccion.DERECHA); controlador.sembrarBomba(Direccion.ARRIBA); assertEquals(new Pair<>(3,1), bomberman.getPoisicion().getCoordenada()); assertTrue(celdaMelamina.getContenido() instanceof ContenidoVacio); } }
true
0d730babc3ee53897b71b047d77594f89821eb81
Java
FrolovOlegVladimirovich/job4j
/chapter_002/src/test/java/ru/job4j/pseudo/TestTriangle.java
UTF-8
814
3.203125
3
[ "Apache-2.0" ]
permissive
package ru.job4j.pseudo; import org.junit.Test; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** * Тест реализации треугольника в виде символов. * * @author Oleg Frolov (frolovolegvladimirovich@gmail.com) * @since 13.06.2019 * @version 1.0 */ public class TestTriangle { @Test public void whenDrawTriangle() { Triangle triangle = new Triangle(); assertThat(triangle.draw(), is( new StringBuilder() .append(" - \n") .append(" / \\ \n") .append(" / \\ \n") .append(" / \\ \n") .append(" --------- \n") .toString() ) ); } }
true
9ae3cf767d11b70549d52aded39bd9c49e56e58a
Java
mark3835/SHMS
/SHMS/src/tcb/shms/module/entity/Menu.java
UTF-8
1,727
2.0625
2
[]
no_license
package tcb.shms.module.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import tcb.shms.core.entity.GenericEntity; /** * 使用者 * @author Mark Huang * @version 2020/3/13 */ @Entity @Table(name="MENU") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class Menu extends GenericEntity{ /** * */ private static final long serialVersionUID = 5804311089729989927L; /** * menu名稱 */ @Column(name="MENU_NAME") private String menuName; /** * menu連結 */ @Column(name="MENU_URL") private String menuUrl; /** * 功能api URL 權限控管用 */ @Column(name="MENU_API_URL") private String menuApiUrl; /** * menu如果是第二層會有植 放第一層的MenuId */ @Column(name="MENU_TIER_TWO") private Long menuTierTwo; /** * menu順序 */ @Column(name="MENU_ORDER") private Integer menuOrder; public String getMenuName() { return menuName; } public void setMenuName(String menuName) { this.menuName = menuName; } public String getMenuUrl() { return menuUrl; } public void setMenuUrl(String menuUrl) { this.menuUrl = menuUrl; } public Long getMenuTierTwo() { return menuTierTwo; } public void setMenuTierTwo(Long menuTierTwo) { this.menuTierTwo = menuTierTwo; } public Integer getMenuOrder() { return menuOrder; } public void setMenuOrder(Integer menuOrder) { this.menuOrder = menuOrder; } public String getMenuApiUrl() { return menuApiUrl; } public void setMenuApiUrl(String menuApiUrl) { this.menuApiUrl = menuApiUrl; } }
true
85745fbf17cd6df348003973c3515593fcff67a7
Java
suelitonoliveira/livroComoProgramar
/src/metodos/TestCarro.java
WINDOWS-1252
626
3.296875
3
[]
no_license
package metodos; public class TestCarro { public static void main(String[] args) { Carro van = new Carro(); van.marca = "Fiat"; van.modelo = "Ducato"; van.numPassageiros = 10; van.capCombustivel = 100; van.consumoCombustivel = 0.20; System.out.println(van.marca); System.out.println(van.modelo); van.exibirAutonomia(); double total = van.obterAutonomia(); System.out.println("A autonomia do carro com parametros : " + total + " KM"); double calc = van.calcularCombustivel(10.0); System.out.println(" Quantidade de combustivel: "+calc); } }
true
7ece93b801ff28b6921a6a423c2dd25f8e0f889f
Java
RyanTech/call-taxi
/src/main/java/com/greenisland/taxi/manager/FeedbackService.java
UTF-8
364
1.851563
2
[]
no_license
package com.greenisland.taxi.manager; import org.springframework.stereotype.Component; import com.greenisland.taxi.common.BaseHibernateDao; import com.greenisland.taxi.domain.FeedBack; @Component("feedbackService") public class FeedbackService extends BaseHibernateDao { public void save(FeedBack feedback) { this.getHibernateTemplate().save(feedback); } }
true
9c8766581d8c7338d7e9da29bbfff64fc610a7cd
Java
letrait/magenta
/src/test/java/org/magenta/core/automagic/generation/DynamicGeneratorFactoryEnumUseCaseTest.java
UTF-8
1,126
2.484375
2
[ "MIT" ]
permissive
package org.magenta.core.automagic.generation; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.junit.Test; import org.magenta.DataKey; import org.magenta.FixtureFactory; import org.magenta.Magenta; import org.magenta.core.GenerationStrategy; import com.google.common.collect.Lists; public class DynamicGeneratorFactoryEnumUseCaseTest extends AbstractDynamicGeneratorFactoryTest { @Test public void testGenerationOfAValueObjectWithAnEnum() { // setup fixture FixtureFactory fixture = Magenta.newFixture(); DynamicGeneratorFactory sut = buildDynamicGeneratorFactory(); // exercise sut List<Car> actual = Lists.newArrayList(); GenerationStrategy<Car> gen= sut.buildGeneratorOf(DataKey.of(Car.class),fixture, sut).get(); for (int i = 0; i < 3; i++) { actual.add(gen.generate(fixture)); } // verify outcome assertThat(actual).extracting("color").containsExactly(Color.RED, Color.BLUE, Color.GREEN); } public static enum Color { RED, BLUE, GREEN; } public static class Car { private Color color; } }
true
e4da863c158bc1001eaf2a9290ebddc4e1f085b1
Java
456chenxigang/LogTool
/app/src/main/java/dsppa/com/logtool/MainActivity.java
UTF-8
2,314
2.296875
2
[]
no_license
package dsppa.com.logtool; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.TextView; import dsppa.com.library.LogManager; public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; private MyHandler handler = new MyHandler(); private static final int MSG_TYPE_E = 19; private static final int MSG_TYPE_I = 20; private class MyHandler extends Handler { @Override public void handleMessage(Message msg) { //annotation super.handleMessage(msg); switch (msg.what) { case MSG_TYPE_E: Log.e(TAG, "is error log"); handler.sendEmptyMessageDelayed(MSG_TYPE_E, 4000); break; case MSG_TYPE_I: Log.i(TAG, "is info log"); handler.sendEmptyMessageDelayed(MSG_TYPE_I, 2000); break; default: break; } } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //8888 handler.sendEmptyMessageDelayed(MSG_TYPE_E, 4000); handler.sendEmptyMessageDelayed(MSG_TYPE_I, 2000); TextView openTv = findViewById(R.id.openTv); openTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (LogManager.getInstance().isShowing()){ LogManager.getInstance().close(); }else { LogManager.getInstance().show(); //LogManager.getInstance().setLogTag("MainActivity"); } } }); // 465465456465 openTv.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { startActivity(new Intent(MainActivity.this,OtherActivity.class)); return false; } }); } }
true
6d191b256551e68ad94a8bbf55dc92fffce4a596
Java
SurbhiAggarwal04/Secure-Banking-System
/sbsbanking/src/main/java/com/sbs/internetbanking/utilities/PasswordResetTokenGenerator.java
UTF-8
494
2.625
3
[]
no_license
package com.sbs.internetbanking.utilities; import java.util.UUID; import com.sbs.internetbanking.model.User; public class PasswordResetTokenGenerator { public static String getPasswordResetTokenForUser(User user){ String random = UUID.randomUUID().toString(); String[] tokens = random.split("-"); System.out.println(tokens); String temp = tokens[0]+tokens[1]+tokens[2]; System.out.println(temp); System.out.println(temp.substring(3,13)); return temp.substring(3,13); } }
true
893fdfdb75a0cd673cdd5ec7ef7bd6fa86a7aef1
Java
school-days/pandora
/src/main/java/com/pandora/loadservice/config/Config.java
UTF-8
1,447
2.171875
2
[ "Apache-2.0" ]
permissive
package com.pandora.loadservice.config; import com.pandora.loadservice.entity.TableDetail; import lombok.Getter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.sql.SQLException; import java.util.Map; /** * @author apple * @version 1.0 * @date 2018-08-25 */ public class Config { private static final Logger LOG = LoggerFactory.getLogger(Config.class); /** * 文件队列长度,超过该长度时则不扫描文件 */ @Getter private static int fileQueueSize; /** * 每个记录集包含的记录条数 {@link com.pandora.loadservice.handle.FileHandler#handleRecord(String)} */ @Getter private static int recordNumPerSet; /** * 记录集缓存队列大小,超过该大小时则不允许提交记录集 {@link com.pandora.loadservice.handle.RecordWriterPool#accept(int)} */ @Getter private static int recordSetQueueSize; /** * 表信息MAP,key为表名,value为表详细信息 {@link HiveConfig#init()} * 注意权限 */ @Getter static Map<String, TableDetail> protocolInfoMap; /** * pattern到表名的MAP,key为文件pattern,value为对应的表名 {@link HiveConfig#init()} * 注意权限 */ @Getter static Map<String, String> patternToTableName; public static void init() throws SQLException, IOException { HiveConfig.init(); } }
true
1e153aa1a063c3a60109a3f66ca6e12e001459d0
Java
alexandraback/datacollection
/solutions_2645486_0/java/indy256/B.java
UTF-8
1,133
2.96875
3
[]
no_license
import java.io.File; import java.io.PrintWriter; import java.util.Scanner; public class B { public static void main(String[] args) throws Exception { String path = "D:\\B-small-attempt0"; Scanner sc = new Scanner(new File(path + ".in")); PrintWriter pw = new PrintWriter(path + ".out"); int testCases = sc.nextInt(); for (int testCase = 1; testCase <= testCases; testCase++) { int E = sc.nextInt(); int R = sc.nextInt(); int n = sc.nextInt(); int[] v = new int[n]; for (int i = 0; i < n; i++) { v[i] = sc.nextInt(); } int res = 0; int[] a = new int[n + 1]; while (a[n] == 0) { int cur = 0; int energy = E; for (int i = 0; i < n; i++) { energy -= a[i]; if (energy < 0) { cur = 0; break; } cur += a[i] * v[i]; energy = Math.min(energy + R, E); } res = Math.max(res, cur); ++a[0]; for (int i = 0; i < n; i++) { if (a[i] > E) { a[i] = 0; ++a[i + 1]; } } } pw.println("Case #" + testCase + ": " + res); pw.flush(); } pw.close(); } }
true
b3f612aa7568af52044926ada1c42399ffc323f0
Java
ammachado/exchange-core
/src/main/java/org/openpredict/exchange/beans/L2MarketData.java
UTF-8
3,045
2.65625
3
[ "Apache-2.0" ]
permissive
package org.openpredict.exchange.beans; import com.google.common.base.Strings; import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.Arrays; @ToString @EqualsAndHashCode public class L2MarketData { public int askSize; public int bidSize; public long totalVolumeAsk; public long totalVolumeBid; public int askPrices[]; public long askVolumes[]; public int bidPrices[]; public long bidVolumes[]; public L2MarketData(int[] askPrices, long[] askVolumes, int[] bidPrices, long[] bidVolumes) { this.askPrices = askPrices; this.askVolumes = askVolumes; this.bidPrices = bidPrices; this.bidVolumes = bidVolumes; this.askSize = askPrices.length; this.bidSize = bidPrices.length; } public L2MarketData(int preAllocatedSize) { this.askPrices = new int[preAllocatedSize]; this.bidPrices = new int[preAllocatedSize]; this.askVolumes = new long[preAllocatedSize]; this.bidVolumes = new long[preAllocatedSize]; } public String dumpOrderBook() { L2MarketData l2MarketData = this; int priceWith = maxWidth(2, l2MarketData.askPrices, l2MarketData.bidPrices); int volWith = maxWidth(2, l2MarketData.askVolumes, l2MarketData.bidVolumes); StringBuilder s = new StringBuilder("Order book:\n"); s.append(".").append(Strings.repeat("-", priceWith - 2)).append("ASKS").append(Strings.repeat("-", volWith - 1)).append(".\n"); for (int i = l2MarketData.askPrices.length - 1; i >= 0; i--) { String price = Strings.padStart(String.valueOf(l2MarketData.askPrices[i]), priceWith, ' '); String volume = Strings.padStart(String.valueOf(l2MarketData.askVolumes[i]), volWith, ' '); s.append(String.format("|%s|%s|\n", price, volume)); } s.append("|").append(Strings.repeat("-", priceWith)).append("+").append(Strings.repeat("-", volWith)).append("|\n"); for (int i = 0; i < l2MarketData.bidPrices.length; i++) { String price = Strings.padStart(String.valueOf(l2MarketData.bidPrices[i]), priceWith, ' '); String volume = Strings.padStart(String.valueOf(l2MarketData.bidVolumes[i]), volWith, ' '); s.append(String.format("|%s|%s|\n", price, volume)); } s.append("'").append(Strings.repeat("-", priceWith - 2)).append("BIDS").append(Strings.repeat("-", volWith - 1)).append("'\n"); return s.toString(); } private static int maxWidth(int minWidth, long[]... arrays) { return Arrays.stream(arrays) .flatMapToLong(Arrays::stream) .mapToInt(p -> String.valueOf(p).length()) .max() .orElse(minWidth); } private static int maxWidth(int minWidth, int[]... arrays) { return Arrays.stream(arrays) .flatMapToInt(Arrays::stream) .map(p -> String.valueOf(p).length()) .max() .orElse(minWidth); } }
true
fd65f6c4b889ee33903279751b644ed4d2c61802
Java
depromeet/7th-finalProject-3team-server
/src/main/java/com/depromeet/watni/domain/attendance/service/AttendanceServiceFactory.java
UTF-8
734
2.53125
3
[]
no_license
package com.depromeet.watni.domain.attendance.service; import com.depromeet.watni.domain.attendance.constant.AttendanceType; import org.springframework.stereotype.Component; @Component public class AttendanceServiceFactory { private final PhotoAttendanceService photoAttendanceService; public AttendanceServiceFactory(PhotoAttendanceService photoAttendanceService) { this.photoAttendanceService = photoAttendanceService; } public AttendanceService createAttendanceService(AttendanceType attendanceType) { switch (attendanceType) { case PHOTO: return this.photoAttendanceService; } throw new IllegalArgumentException("not support attendanceType"); } }
true
75c8e77dc3bee8cbb741b83669f90402d8439083
Java
deepc-6/ClientManagement
/src/main/java/fr/dc/clients/datamodel/Client.java
UTF-8
8,021
2.9375
3
[]
no_license
package fr.dc.clients.datamodel; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; /** * This is the datamodel class for the entity Client * */ @Entity @Table(name = "Client") public class Client { /** * This is the default constructor for the class Client with no parameters */ public Client() { } /** * This is the id for each client in the database. It is auto generated when * a new client is created. */ @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; /** * This is the business name of the client in the database. */ private String businessName; /** * This is the interlocuter name of the client in the database. */ private String interlocuter; /** * This is the address of the client in the database. */ private String address; /** * This is the postal code of the client in the database. */ private String zipcode; /** * This is the city name of the client in the database. */ private String city; /** * This is the phone number of the client in the database. */ private String phone; /** * This is the email of the client in the database. */ private String email; /** * This is the comment about the client in the database. */ private String comment; /** * This is a constructor for the class Client with parameters businessName, * interlocuter, address, zipcode, city, phone, email, comment * * @param id * The id of the identity. Data type: <b>int</b> * @param businessName * The business name of the identity. Data type: <b>String</b> * @param interlocuter * The interlocuter name of the identity. Data type: * <b>String</b> * @param address * The address of the identity. Data type: <b>String</b> * @param zipcode * The postal code of the identity. Data type: <b>String</b> * @param city * The city name of the identity. Data type: <b>String</b> * @param phone * The phone number of the identity. Data type: <b>String</b> * @param email * The email of the identity. Data type: <b>String</b> * @param comment * The comment about the identity. Data type: <b>String</b> */ public Client(int id, String businessName, String interlocuter, String address, String zipcode, String city, String phone, String email, String comment) { this.id = id; this.businessName = businessName; this.interlocuter = interlocuter; this.address = address; this.zipcode = zipcode; this.city = city; this.phone = phone; this.email = email; this.comment = comment; } /** * This method returns the output to the console in the following format: * <p> * [ID [Business Name, Interlocuter, Address, Zipcode, City, Phone, E-mail * address, Comment] * <p> * This method overrides the {@link java.lang.Object#toString()} method. * <p> * * @return <b>id</b> The id of the client. Data type: <b>int</b> * <p> * <b>businessName</b> The business name of the client. Data type: * <b>String</b> * <p> * <b>interlocuter</b> The interlocuter name of the client. Data * type: <b>String</b> * <p> * <b>address</b> The address of the client. Data type: * <b>String</b> * <p> * <b>zipcode</b> The postal code of the client. Data type: * <b>String</b> * <p> * <b>city</b> The city name of the client. Data type: <b>String</b> * <p> * <b>phone</b> The phone number of the client. Data type: * <b>String</b> * <p> * <b>email</b> The e-mail of the client. Data type: <b>String</b> * <p> * <b>comment</b> The comment about the client. Data type: * <b>String</b> * * @see java.lang.Object#toString() */ @Override public String toString() { return "\n" + "ID=" + id + " Business Name=" + businessName + ", Interlocuter=" + interlocuter + ", Address=" + address + ", Zipcode=" + zipcode + ", City=" + city + ", Telephone=" + phone + ", E-mail address=" + email + ", Comment=" + comment; } /** * This method returns the business name of the client * * @return <b>businessName</b> The business name of the identity */ public final String getBusinessName() { return businessName; } /** * This method sets the business name of the client * * @param businessName * The business name of the client. Data type: <b>String</b> */ public final void setBusinessName(String businessName) { this.businessName = businessName; } /** * This method returns the interlocuter name of the client * * @return <b>interlocuter</b> The interlocuter name of the client */ public final String getInterlocuter() { return interlocuter; } /** * This method sets the interlocuter name of the client * * @param interlocuter * The interlocuter name of the client. Data type: <b>String</b> */ public final void setInterlocuter(String interlocuter) { this.interlocuter = interlocuter; } /** * This method returns the address of the client * * @return <b>address</b> The address of the client */ public final String getAddress() { return address; } /** * This method sets the address of the client * * @param address * The address of the client. Data type: <b>String</b> */ public final void setAddress(String address) { this.address = address; } /** * This method returns the postal code of the client * * @return <b>zipcode</b> The postal code of the client */ public final String getZipCode() { return zipcode; } /** * This method sets the postal code of the client * * @param zipcode * The postal code of the client. Data type: <b>String</b> */ public final void setZipCode(String zipcode) { this.zipcode = zipcode; } /** * This method returns the city name of the client * * @return <b>city</b> The city name of the client */ public final String getCity() { return city; } /** * This method sets the city name of the client * * @param city * The city name of the client. Data type: <b>String</b> */ public final void setCity(String city) { this.city = city; } /** * This method returns the phone number of the client * * @return <b>phone</b> The phone number of the client */ public final String getPhone() { return phone; } /** * This method sets the phone number of the client * * @param phone * The phone number of the client. Data type: <b>String</b> */ public final void setPhone(String phone) { this.phone = phone; } /** * This method returns the email address of the client * * @return <b>email</b> The email address of the client */ public final String getEmail() { return email; } /** * This method sets the email address of the client * * @param email * The email address of the client. Data type: <b>String</b> */ public final void setEmail(String email) { this.email = email; } /** * This method returns the comment about the client * * @return <b>comment</b> The comment about the client */ public String getComment() { return comment; } /** * This method sets the comment about the client * * @param comment * The comment about the client. Data type: <b>String</b> */ public void setComment(String comment) { this.comment = comment; } /** * This method returns the id of the client * * @return <b>id</b> The id of the client */ public int getId() { return id; } /** * This method sets the id of the client * * @param id * The id of the client. Data type: <b>String</b> */ public void setId(int id) { this.id = id; } }
true
dfa86035880f1c5d79a26d41b7a3a5e43a8285c5
Java
dash-/apache-openaz
/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/ValidatorFactory.java
UTF-8
3,012
1.875
2
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
/* * 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.openaz.xacml.admin.view.validators; import org.apache.openaz.xacml.admin.jpa.Datatype; import org.apache.openaz.xacml.api.XACML3; import com.vaadin.data.Validator; public class ValidatorFactory { public static Validator newInstance(Datatype datatype) { if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_ANYURI)) { return new AnyURIValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_BASE64BINARY)) { return new Base64BinaryValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_BOOLEAN)) { return new BooleanValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DATE)) { return new DateValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DATETIME)) { return new DateTimeValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DAYTIMEDURATION)) { return new DayTimeDurationValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DNSNAME)) { return new DNSNameValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DOUBLE)) { return new DoubleValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_HEXBINARY)) { return new HexBinaryValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_INTEGER)) { return new IntegerValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_IPADDRESS)) { return new IpAddressValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_RFC822NAME)) { return new RFC822NameValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_STRING)) { return new StringValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_TIME)) { return new TimeValidator(); } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_X500NAME)) { return new X500NameValidator(); /* } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_XPATHEXPRESSION)) { */ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_YEARMONTHDURATION)) { return new YearMonthDurationValidator(); } return null; } }
true
d46275e91bcf81fc0465f1fe14124a7bc3baed96
Java
LeeBeomho/practicecode
/java/plzrun/Boj/src/dp/Boj11057.java
UTF-8
721
2.828125
3
[]
no_license
package dp; import java.util.*; public class Boj11057 { static int number; static int[][]dp; static int sum; public static int solve() { for(int i=0; i<=9; i++) { dp[1][i]=1; } if(number>1) for(int j=2; j<=number; j++) { for(int i=0; i<=9; i++) { for(int w=i; w<=9; w++) { dp[j][i]+=dp[j-1][w]; dp[j][i]%=10007; } dp[j][i]%=10007; } } sum=0; for(int i=0; i<10; i++) sum+=dp[number][i]; sum%=10007; return sum; } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); number=scanner.nextInt(); dp=new int[number+1][10]; System.out.println(solve()); scanner.close(); return; } }
true
f8c4398f3561cafe3eafc7c79f34e7557f3a33b5
Java
rekharokkam/ConcurrencyClass
/src/com/learning/basicjava/atomicC/RaceConditionAtomicC.java
UTF-8
567
3.09375
3
[]
no_license
package com.learning.basicjava.atomicC; public class RaceConditionAtomicC { public static void main(String[] args) { Miser miser = new Miser (1000); SpendThrift spendThrift = new SpendThrift (1000); miser.start(); spendThrift.start(); try { miser.join(); //main thread waits until miser thread completes spendThrift.join();//main thread waits until spendThrift completes. }catch (InterruptedException exception) { exception.printStackTrace(System.err); } System.out.println("account balance : " + AccountAtomicC.balance.get()); } }
true
b848fa94684cb92e4c0c73ed5c8d6cadf055ac11
Java
aqnote0/aqnote.android
/app/wifi/src/test/java/com/aqnote/app/wifi/wifi/scanner/CacheTest.java
UTF-8
5,168
2.171875
2
[ "Apache-2.0" ]
permissive
/* * WiFi Analyzer * Copyright (C) 2016 VREM Software Development <VREMSoftwareDevelopment@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package com.aqnote.app.wifi.wifi.scanner; import android.net.wifi.ScanResult; import com.aqnote.app.wifi.MainContextHelper; import com.aqnote.app.wifi.settings.Settings; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class CacheTest { @Mock private ScanResult scanResult1; @Mock private ScanResult scanResult2; @Mock private ScanResult scanResult3; @Mock private ScanResult scanResult4; @Mock private ScanResult scanResult5; @Mock private ScanResult scanResult6; private Settings settings; private Cache fixture; @Before public void setUp() { fixture = new Cache(); settings = MainContextHelper.INSTANCE.getSettings(); } @After public void tearDown() { MainContextHelper.INSTANCE.restore(); } @Test public void testAddWithNulls() throws Exception { // setup when(settings.getScanInterval()).thenReturn(5); // execute fixture.add(null); // validate assertTrue(fixture.getCache().isEmpty()); } @Test public void testAdd() throws Exception { // setup when(settings.getScanInterval()).thenReturn(5); List<ScanResult> scanResults = new ArrayList<>(); // execute fixture.add(scanResults); // validate assertEquals(scanResults, fixture.getCache().getFirst()); } @Test public void testAddCompliesToMaxCacheSize() throws Exception { // setup int scanInterval = 5; int cacheSize = 2; when(settings.getScanInterval()).thenReturn(scanInterval); List<List<ScanResult>> expected = new ArrayList<>(); // execute for (int i = 0; i < cacheSize; i++) { List<ScanResult> scanResults = new ArrayList<>(); expected.add(scanResults); fixture.add(scanResults); } // validate assertEquals(cacheSize, expected.size()); assertEquals(cacheSize, fixture.getCache().size()); assertEquals(expected.get(cacheSize - 1), fixture.getCache().getFirst()); assertEquals(expected.get(cacheSize - 2), fixture.getCache().getLast()); } @Test public void testGetWiFiData() throws Exception { // setup withScanResults(); // execute List<CacheResult> actuals = fixture.getScanResults(); // validate assertEquals(3, actuals.size()); validate(scanResult3, 20, actuals.get(0)); validate(scanResult4, 50, actuals.get(1)); validate(scanResult6, 10, actuals.get(2)); } private void validate(ScanResult expectedScanResult, int expectedLevel, CacheResult actual) { assertEquals(expectedScanResult, actual.getScanResult()); assertEquals(expectedLevel, actual.getLevelAverage()); } private void withScanResults() { scanResult1.BSSID = scanResult2.BSSID = scanResult3.BSSID = "BBSID1"; scanResult1.level = 10; scanResult2.level = 20; scanResult3.level = 30; scanResult4.BSSID = scanResult5.BSSID = "BBSID2"; scanResult4.level = 60; scanResult5.level = 40; scanResult6.BSSID = "BBSID3"; scanResult6.level = 10; fixture.add(Arrays.asList(scanResult1, scanResult4)); fixture.add(Arrays.asList(scanResult2, scanResult5)); fixture.add(Arrays.asList(scanResult3, scanResult6)); } @Test public void testGetCacheSize() throws Exception { int values[] = new int[]{ 1, 4, 4, 4, 5, 3, 9, 3, 10, 2, 19, 2, 20, 1 }; for (int i = 0; i < values.length; i += 2) { when(settings.getScanInterval()).thenReturn(values[i]); assertEquals("Scan Interval:" + values[i], values[i + 1], fixture.getCacheSize()); } verify(settings, times(values.length / 2)).getScanInterval(); } }
true
12430d38e299dc8fed32686e8b82b93545e9b9ed
Java
azuma0717/AndroidStudio
/Fragment-master/app/src/main/java/com/example/toki/fragment/MainActivity.java
UTF-8
1,204
2.4375
2
[]
no_license
package com.example.toki.fragment; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { private SectionStatePagerAdapter sectionStatePagerAdapter; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sectionStatePagerAdapter=new SectionStatePagerAdapter(getSupportFragmentManager()); viewPager=findViewById(R.id.container); setupViewPager(viewPager); } private void setupViewPager(ViewPager viewPager) { sectionStatePagerAdapter=new SectionStatePagerAdapter(getSupportFragmentManager()); sectionStatePagerAdapter.addFragment(new Fragment1(),"Fragment1"); sectionStatePagerAdapter.addFragment(new Fragment2(),"Fragment2"); sectionStatePagerAdapter.addFragment(new Fragment3(),"Fragment3"); viewPager.setAdapter(sectionStatePagerAdapter); } public void setViewPager(int fragmentNumber){ viewPager.setCurrentItem(fragmentNumber); } }
true
614c89a13b5139a8cded75f664d0f3a74b8dc5bd
Java
mengxi-chen/PHAULR
/src/storage/datastructure/InVal.java
UTF-8
599
2.453125
2
[]
no_license
package storage.datastructure; import java.util.HashSet; import java.util.Set; import messaging.message.UpdateMessage; import messaging.message.MessageGid; /** * {@link UpdateMessage}s that participated in computing val * @date 2014-10-13 */ public class InVal { private Set<MessageGid> umid_set = new HashSet<>(); public InVal() { } public void addUmid(UpdateMessage update_msg) { this.addUmid(update_msg.getMsgGid()); } public void addUmid(MessageGid umid) { this.umid_set.add(umid); } public boolean contains(MessageGid umid) { return this.umid_set.contains(umid); } }
true
93d2617492cbd525760b5324e0b009d8542fdb16
Java
curiousTauseef/training-spring
/exercises/app-jms/src/main/java/com/example/dictionary/AsyncApp.java
UTF-8
1,929
2.234375
2
[]
no_license
package com.example.dictionary; import org.apache.activemq.spring.ActiveMQConnectionFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.GenericApplicationContext; import org.springframework.jms.annotation.EnableJms; import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import javax.jms.ConnectionFactory; public class AsyncApp { public static void main(String[] args) { GenericApplicationContext context = new AnnotationConfigApplicationContext( MessagingListnerConfiguration.class); Consumer bean = context.getBean(Consumer.class); bean.consumeMessage(); } @Configuration @EnableJms public static class MessagingListnerConfiguration { private static final String DEFAULT_BROKER_URL = "tcp://localhost:61616"; // @Bean // public MessageReceiver receiver() { // return new MessageReceiver(); // } @Bean public Consumer consumer(ConnectionFactory cf) { return new Consumer(cf); } @Bean public ActiveMQConnectionFactory connectionFactory(){ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL(DEFAULT_BROKER_URL); connectionFactory.setTrustAllPackages(true); return connectionFactory; } @Bean public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory cf) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setConnectionFactory(cf); factory.setConcurrency("1-1"); return factory; } } }
true
f2dd8129b037063a0814d90fe5a449c578be0c53
Java
mrslnv/invia
/src/main/java/invia/list/DList.java
UTF-8
743
3.046875
3
[]
no_license
package invia.list; import java.util.List; /** * Created by mirek on 7/31/2015. */ public class DList<T> { public ListNode<T> first; public ListNode<T> last; public DList() { } public void addLast(T item){ ListNode<T> newN = new ListNode<T>(last,null,item); if (last == null){ first = newN; } last = newN; } public void addAll(List<T> all){ for (T t : all) { addLast(t); } } public void addBefore(ListNode<T> node, T item){ ListNode<T> newE = new ListNode<T>(node.prev, node, item); if (node.prev != null) node.prev.next = newE; else first = newE; node.prev = newE; } }
true
5a018ddba4735fe7fc695482b07ac8c3fe9be61c
Java
dechapie/m1gil
/archi_log/tp6/FormLanguage.java
UTF-8
78
1.632813
2
[]
no_license
package tp6; public abstract class FormLanguage implements FormGenerator { }
true
a2f2a8fbc796ed35e53b118fb2c8d8188d30d092
Java
FalsoMoralista/MI-Concorrencia-e-conectividade
/Boggle/src/br/ecomp/uefs/view/Registration.java
UTF-8
5,093
2.359375
2
[]
no_license
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.ecomp.uefs.view; import br.ecomp.uefs.controller.Controller; import java.io.IOException; import java.io.Serializable; import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.ButtonType; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import javafx.scene.image.Image; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; import shared.exception.InvalidDataException; import shared.exception.InvalidTypeOfRequestException; import shared.exception.UserAlreadyRegisteredException; import br.ecomp.uefs.model.User; /** * * @author luciano */ public class Registration extends Application implements Serializable { private TextField loginField; private PasswordField passwordField; private Label passwordLabel; private Label nameLabel; private Button submit; private Button cancel; private Controller controller; protected User user; private final Text infoError = new Text(); public static void main(String[] args) { launch(args); } public Registration() { } public Registration(Controller controller) { this.controller = controller; } public User getInfo() throws InvalidDataException, IOException { if (passwordField.getText().isEmpty() && loginField.getText().isEmpty()) { throw new InvalidDataException(); } return user = new User(loginField.getText(), passwordField.getText()); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Registration"); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); Scene scene = new Scene(grid, 500, 400); grid.setPadding(new Insets(25, 25, 25, 25)); Label header = new Label("Registration"); header.setFont(Font.font("Arial", FontWeight.BOLD, 24)); grid.add(header, 1, 0, 2, 1); nameLabel = new Label("User name:"); grid.add(nameLabel, 0, 1); loginField = new TextField(); grid.add(loginField,1,1); passwordLabel = new Label("Password:"); grid.add(passwordLabel, 0, 3); passwordField = new PasswordField(); grid.add(passwordField, 1, 3); grid.add(infoError, 1, 5); submit = new Button("Submit"); submit.setOnAction((ActionEvent event) -> { try { Alert error = new Alert(Alert.AlertType.ERROR); getInfo(); try { controller.register(user); Alert ok = new Alert(Alert.AlertType.INFORMATION); ok.setTitle("Registration sucessfull"); ok.setHeaderText("You were sucessfully registered"); Optional<ButtonType> result = ok.showAndWait(); if (result.get() == ButtonType.OK) { primaryStage.close(); } else { primaryStage.close(); } } catch (ClassNotFoundException | IOException | InvalidTypeOfRequestException ex) { Logger.getLogger(Registration.class.getName()).log(Level.SEVERE, null, ex); } catch (UserAlreadyRegisteredException ex) { error.setTitle("Error"); error.setHeaderText("User name already in use"); error.show(); } } catch (InvalidDataException ide) { infoError.setFill(Color.FIREBRICK); infoError.setText("Missing information"); } catch (IOException ex) { Logger.getLogger(Registration.class.getName()).log(Level.SEVERE, null, ex); } }); HBox hbSubmit = new HBox(10); hbSubmit.setAlignment(Pos.CENTER_RIGHT); hbSubmit.getChildren().add(submit); grid.add(hbSubmit, 3, 6); cancel = new Button("Cancel"); cancel.setOnAction((ActionEvent event) -> { primaryStage.close(); }); HBox hbCancel = new HBox(10); hbCancel.setAlignment(Pos.CENTER); hbCancel.getChildren().add(cancel); grid.add(hbCancel, 0, 6); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); } }
true
63816eee21d752a330ee8dee32dfe8e2b6f9469b
Java
goroFaruk/NWT
/NWTProjekatJukebox/NotificationModule/src/main/java/NotificationService/Models/OcjenaEntity.java
UTF-8
1,927
2.453125
2
[]
no_license
package NotificationService.Models; import javax.persistence.*; /** * Created by Enver on 19.3.2017. */ @Entity @Table(name = "ocjena", schema = "nwtjukebox", catalog = "") public class OcjenaEntity { private int id; private int listaId; private Integer ocjena; private Integer korisnikId; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false) public int getId() { return id; } public void setId(int id) { this.id = id; } @Basic @Column(name = "lista_id") public int getListaId() { return listaId; } public void setListaId(int listaId) { this.listaId = listaId; } @Basic @Column(name = "ocjena") public Integer getOcjena() { return ocjena; } public void setOcjena(Integer ocjena) { this.ocjena = ocjena; } @Basic @Column(name = "korisnik_id") public Integer getKorisnikId() { return korisnikId; } public void setKorisnikId(Integer korisnikId) { this.korisnikId = korisnikId; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OcjenaEntity that = (OcjenaEntity) o; if (id != that.id) return false; if (listaId != that.listaId) return false; if (ocjena != null ? !ocjena.equals(that.ocjena) : that.ocjena != null) return false; if (korisnikId != null ? !korisnikId.equals(that.korisnikId) : that.korisnikId != null) return false; return true; } @Override public int hashCode() { int result = id; result = 31 * result + listaId; result = 31 * result + (ocjena != null ? ocjena.hashCode() : 0); result = 31 * result + (korisnikId != null ? korisnikId.hashCode() : 0); return result; } }
true
e16fbe01aec831f5db87c72ac14116f545af7544
Java
vespa-engine/vespa
/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java
UTF-8
2,964
2.359375
2
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.configserver; import com.yahoo.config.provision.zone.RoutingMethod; import java.util.List; import java.util.Objects; import java.util.OptionalInt; /** * This represents a list of one or more names for a container cluster. * * @author mpolden */ public class ContainerEndpoint { private final String clusterId; private final String scope; private final List<String> names; private final OptionalInt weight; private final RoutingMethod routingMethod; public ContainerEndpoint(String clusterId, String scope, List<String> names, OptionalInt weight, RoutingMethod routingMethod) { this.clusterId = nonEmpty(clusterId, "clusterId must be non-empty"); this.scope = Objects.requireNonNull(scope, "scope must be non-null"); this.names = List.copyOf(Objects.requireNonNull(names, "names must be non-null")); this.weight = Objects.requireNonNull(weight, "weight must be non-null"); this.routingMethod = Objects.requireNonNull(routingMethod, "routingMethod must be non-null"); } /** ID of the cluster to which this points */ public String clusterId() { return clusterId; } /** The scope of this endpoint */ public String scope() { return scope; } /** * All valid DNS names for this endpoint. This can contain both proper DNS names and synthetic identifiers used for * routing, such as a Host header value that is not necessarily a proper DNS name. */ public List<String> names() { return names; } /** The relative weight of this endpoint */ public OptionalInt weight() { return weight; } /** The routing method used by this endpoint */ public RoutingMethod routingMethod() { return routingMethod; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ContainerEndpoint that = (ContainerEndpoint) o; return clusterId.equals(that.clusterId) && scope.equals(that.scope) && names.equals(that.names) && weight.equals(that.weight) && routingMethod == that.routingMethod; } @Override public int hashCode() { return Objects.hash(clusterId, scope, names, weight, routingMethod); } @Override public String toString() { return "container endpoint for cluster " + clusterId + ": " + String.join(", ", names) + " [method=" + routingMethod + ",scope=" + scope + ",weight=" + weight.stream().boxed().map(Object::toString).findFirst().orElse("<none>") + "]"; } private static String nonEmpty(String s, String message) { if (s == null || s.isBlank()) throw new IllegalArgumentException(message); return s; } }
true
c77da1c49e33c1c335efa68a418c7984d031f3ac
Java
deepakjainlnct/PrannmyaSagar
/app/src/main/java/com/prannmya/sagar/fragment/GuruJIFragment.java
UTF-8
525
1.601563
2
[]
no_license
package com.prannmya.sagar.fragment; import android.content.Context; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import com.prannmya.sagar.activity.MainActivity; import com.prannmya.sagar.utils.Constant; /** * Created by Deepak on 16-02-2017. */ public class GuruJIFragment extends Fragment { public static Constant constant; public transient static MainActivity eventActivity; public static FragmentManager fragmentManager; public static Context context; }
true
1da1b85d498137e85581359e91fc210018e00f50
Java
peterl1084/aba
/ui/src/main/java/ch/abacus/application/ui/data/DataTableMoneyConverter.java
UTF-8
625
2.421875
2
[ "Apache-2.0" ]
permissive
package ch.abacus.application.ui.data; import java.util.Currency; import java.util.Locale; import org.springframework.format.number.CurrencyStyleFormatter; import com.vaadin.spring.annotation.SpringComponent; import ch.abacus.application.common.data.Money; @SpringComponent public class DataTableMoneyConverter implements DataTableConverter<Money> { @Override public String convertToString(Locale locale, Money value) { CurrencyStyleFormatter formatter = new CurrencyStyleFormatter(); formatter.setCurrency(Currency.getInstance(value.getCurrencyCode())); return formatter.print(value.getAmount(), locale); } }
true
8fa38a5920d918fb205060f85686e761c4d31f0d
Java
yeycfri/leetcode-java
/src/Greedy/_0968_Binary_Tree_Cameras/Solution.java
UTF-8
772
3.171875
3
[]
no_license
package Greedy._0968_Binary_Tree_Cameras; import common.bst.TreeNode; public class Solution { private static final int UNCOVERED = 0; private static final int HAS_CAMERA = 1; private static final int COVERED = 2; int result; public int minCameraCover(TreeNode root) { result = 0; if (traversal(root) == UNCOVERED) result++; return result; } private int traversal(TreeNode root) { if (root == null) return COVERED; int left = traversal(root.left); int right = traversal(root.right); if (left == UNCOVERED || right == UNCOVERED) { result++; return HAS_CAMERA; } return left == HAS_CAMERA || right == HAS_CAMERA ? COVERED : UNCOVERED; } }
true
852a6852e92884128c075fcc2453ce6008507bed
Java
SkyManMD/HoolubHACKATHONGame
/Hoolub/Hoolub/src/com/evision/hoolub/AnimatorHuman.java
UTF-8
1,676
2.875
3
[]
no_license
package com.evision.hoolub; import java.awt.Rectangle; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; public class AnimatorHuman extends Actor { private static final int FRAME_COLS = 4; private static final int FRAME_ROWS = 2; private Animation walkAnimation; private Texture walkSheet; private TextureRegion[] walkFrames; private SpriteBatch spriteBatch; private TextureRegion currentFrame; private float stateTime; static final int WIDTH = 42, HEIGHT = 66; public AnimatorHuman(Texture texture) { setSize(WIDTH, HEIGHT); setPosition(Gdx.graphics.getWidth(), 30); walkSheet = texture;//new Texture(Gdx.files.internal("data/image/Human.png")); walkFrames = new TextureRegion[16]; int index = 0; for (int i = 0; i < 8; i++) { walkFrames[index++] = new TextureRegion(walkSheet,i*42,0,42,66); walkFrames[15-i] = walkFrames[i]; } walkAnimation = new Animation(0.1f, walkFrames); spriteBatch = new SpriteBatch(); stateTime = 0f; } public void draw() { stateTime += Gdx.graphics.getDeltaTime(); currentFrame = walkAnimation.getKeyFrame(stateTime, true); spriteBatch.begin(); spriteBatch.draw(currentFrame, getX(), getY()); spriteBatch.end(); } public Rectangle getRectangle() { return new Rectangle((int) this.getX(), (int) this.getY(), (int)this.getWidth(), (int)this.getHeight()); } public void move(int coef) { this.setX(this.getX() - coef); } }
true
e9d165682cf2eb7a9cf40e87908f9d33cf646538
Java
zixiaolu/final_test
/src/main/java/action/Loginaction.java
UTF-8
885
2.234375
2
[]
no_license
package action; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.ServletActionContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; public class Loginaction extends ActionSupport { private HttpServletRequest request; public String execute() throws Exception { request= ServletActionContext.getRequest(); HttpSession session = request.getSession(); if(!request.getParameter("username").equals("zxl")||!request.getParameter("password").equals("123")){ if(session.getAttribute("times")==null){ session.setAttribute("times",9); } else{ int now=(int)session.getAttribute("times"); session.setAttribute("times",now-1); } return "failed"; } return "success"; } }
true
3ed384cf73e5acb0f219eb68aa053c9c1fbb7518
Java
cdToucher/codebase
/exercise/src/main/java/ClassLoadOrder.java
UTF-8
294
2.046875
2
[]
no_license
public class ClassLoadOrder { private int a = 10; private static int b = new Integer(10); private static int c = 10; static { } ClassLoadOrder() { } public static void main(String[] args) { ClassLoadOrder order = new ClassLoadOrder(); } }
true
8e678d14f3805029f876e43e0712e75e1503e268
Java
Devnug/ClassifiedsForOlas
/app/src/main/java/devnug/classifiedsforolas/PostingAdapter.java
UTF-8
5,662
2.546875
3
[]
no_license
package devnug.classifiedsforolas; import android.content.Context; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater.Filter; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; import java.util.ArrayList; import java.util.List; /** * PostingAdapter<T> * * Used to create a custom listview to show data for each job available * */ public class PostingAdapter<T> extends ArrayAdapter<T> implements Filter { public static final String TAG = "PostingAdapter"; public List<T> object; public List<T> allObjects; public Filter myFilter; public PostingFilter postingFilter; public PostingAdapter(Context context, int resource, List<T> objects) { super(context, resource, objects); object = objects; allObjects = objects; } @Override public int getCount() { return object.size(); } @Override public T getItem(int position) { return object.get(position); } //@Override //public Posting getItemId(int position) { // return object.get(position).getId(); //} @Override public android.widget.Filter getFilter() { if (postingFilter == null) postingFilter = new PostingFilter(); return (android.widget.Filter) postingFilter; } /* * we are overriding the getView method here - this is what defines how each * list item will look. */ public View getView(int position, View convertView, ViewGroup parent){ // assign the view we are converting to a local variable View v = convertView; // first check to see if the view is null. if so, we have to inflate it. // to inflate it basically means to render, or show, the view. if (v == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.item_list, null); } /* * Recall that the variable position is sent in as an argument to this method. * The variable simply refers to the position of the current object in the list. (The ArrayAdapter * iterates through the list we sent it) * * Therefore, i refers to the current Item object. */ Posting i = (Posting) object.get(position); if(i != null) { // This is how you obtain a reference to the TextViews. // These TextViews are created in the XML files we defined. TextView tt = (TextView) v.findViewById(R.id.toptext); TextView ttd = (TextView) v.findViewById(R.id.toptextdata); TextView mt = (TextView) v.findViewById(R.id.middletext); TextView mtd = (TextView) v.findViewById(R.id.middletextdata); TextView bt = (TextView) v.findViewById(R.id.longdesc); TextView btd = (TextView) v.findViewById(R.id.longdesctext); // check to see if each individual textview is null. // if not, assign some text! if (tt != null){ } if (ttd != null){ ttd.setText(i.getSchool()); } if (mt != null){ } if (mtd != null){ mtd.setText(i.getQuickDesc()); } if (bt != null && bt.getVisibility() == View.VISIBLE){ bt.setText("Desc: "); //bt.setVisibility(View.GONE); } else { bt.setVisibility(View.GONE); } if (btd != null && bt.getVisibility() == View.VISIBLE){ btd.setText(i.getDesc()); //btd.setVisibility(View.GONE); } else { btd.setVisibility(View.GONE); } } return v; } @Override public boolean onLoadClass(Class clazz) { // TODO Auto-generated method stub return false; } public void changeState(View v, int position) { Log.d(TAG, "Click for " + ((Posting) object.get(position)).getSchool()); TextView bt = (TextView) v.findViewById(R.id.longdesc); TextView btd = (TextView) v.findViewById(R.id.longdesctext); if (bt.getVisibility() != View.VISIBLE){ bt.setText("Full Desc: "); bt.setVisibility(View.VISIBLE); Log.d(TAG, "Set Visible"); } else { bt.setText("Full Desc: "); bt.setVisibility(View.GONE); Log.d(TAG, "Set invisible"); } if (btd.getVisibility() != View.VISIBLE){ //btd.setText(((Posting) object.get(position)).getDesc()); btd.setVisibility(View.VISIBLE); Log.d(TAG, "Set Visible"); } else { //btd.setText(((Posting) object.get(position)).getDesc()); btd.setVisibility(View.GONE); Log.d(TAG, "Set invisible"); } notifyDataSetChanged(); } private class PostingFilter extends android.widget.Filter{ //ArrayList<Posting> pList; @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results = new FilterResults(); // We implement here the filter logic if (constraint == null || constraint.length() == 0) { // No filter implemented we return all the list results.values = allObjects; results.count = allObjects.size(); } else { // We perform filtering operation List<Posting> nPlanetList = new ArrayList<Posting>(); for (T p : object) { if (((Posting) p).getDesc().toUpperCase().contains(constraint.toString().toUpperCase())) nPlanetList.add((Posting) p); } results.values = nPlanetList; results.count = nPlanetList.size(); } return results; } @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { // Now we have to inform the adapter about the new list filtered if (results.count == 0) notifyDataSetInvalidated(); else { object = (List<T>) results.values; notifyDataSetChanged(); } } } }
true
096fa52910995e93cdbefdb249016443963fdd53
Java
elile/project_gemer
/EyeWhereUploadLib/src/upload/controller/QualityGetSet.java
UTF-8
714
2.296875
2
[]
no_license
package upload.controller; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.preference.PreferenceManager; public class QualityGetSet { public static void setQuality(Context c, int q) { if (q > 100) { q=100; } if (q <= 0) { q=1; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c.getApplicationContext()); Editor editor = prefs.edit(); editor.putInt("quality", q); editor.commit(); } public static int getQuality(Context c) { SharedPreferences prefs =PreferenceManager.getDefaultSharedPreferences(c.getApplicationContext()); return prefs.getInt("quality", -1); } }
true
c8545a906cae594896a1f5f130bc41583fa3c55a
Java
xieqi520/NaiDeAnProject
/NaideanDoorLock20200512/app/src/main/java/com/saiyi/naideanlock/bean/MdlWeekCheck.java
UTF-8
270
1.945313
2
[]
no_license
package com.saiyi.naideanlock.bean; public class MdlWeekCheck { public String name; public boolean isCheck; public MdlWeekCheck() { } public MdlWeekCheck(String name) { this.name = name; this.isCheck = false; } }
true
24a4b30e3ea3a6ddf69f5f68c9bae9d8093bce59
Java
bigyam/BattleShip
/src/ca/bcit/comp2613/battleship/model/SetupBoard.java
UTF-8
54,909
2.484375
2
[]
no_license
package ca.bcit.comp2613.battleship.model; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JComponent; import javax.swing.JTextField; public class SetupBoard extends JPanel { /** * */ private static final long serialVersionUID = 1L; private JPanel gridPane; private JPanel shipPane; private JButton[][] setupGrid; private static boolean [][] filled; public static final int WIDTH = 11; public static final int LENGTH = 11; private Coordinates theShipCoord; private Coordinates destroyerShipCoordOne; private Coordinates destroyerShipCoordTwo; private Coordinates submarineShipCoordOne; private Coordinates submarineShipCoordTwo; private Coordinates battleshipShipCoordOne; private Coordinates battleshipShipCoordTwo; private Coordinates carrierShipCoordOne; private Coordinates carrierShipCoordTwo; private int shipTypeTab; private static Destroyer playerDestroyer; private static Submarine playerSubmarine; private static Battleship playerBattleship; private static Carrier playerCarrier; private JTextField textDestroyerCoordXOne; private JTextField textDestroyerCoordYOne; private JTextField textDestroyerCoordXTwo; private JTextField textDestroyerCoordYTwo; private JTextField textSubmarineCoordXOne; private JTextField textSubmarineCoordYOne; private JTextField textSubmarineCoordXTwo; private JTextField textSubmarineCoordYTwo; private JTextField textBattleshipCoordXOne; private JTextField textBattleshipCoordYOne; private JTextField textBattleshipCoordXTwo; private JTextField textBattleshipCoordYTwo; private JTextField textCarrierCoordXOne; private JTextField textCarrierCoordYOne; private JTextField textCarrierCoordXTwo; private JTextField textCarrierCoordYTwo; private static JFrame f; public SetupBoard() { //setSize(850, 1000); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); gridPane = new JPanel(); shipPane = new JPanel(); gridPane.setLayout(new GridLayout(WIDTH, LENGTH)); //gridPane.setSize(850, 150); createSetupButtons(); shipPane.setLayout(new GridLayout(1, 1)); //shipPane.setSize(850, 850); createTabbedPanel(); add(gridPane); add(shipPane); playerDestroyer = new Destroyer(null, null, null, null, 2); //playerDestroyer.zeroCoordinates(); playerSubmarine = new Submarine(null, null, null, null, null, null, 3); //playerSubmarine.zeroCoordinates(); playerBattleship = new Battleship(null, null, null, null, null, null, null, null, 4); //playerBattleship.zeroCoordinates(); playerCarrier = new Carrier(null, null, null, null, null, null, null, null, null, null, 5); //playerCarrier.zeroCoordinates(); f = new JFrame("BattleShip"); } /** * Create tabbed panel on the bottom of setup grid. * Each panel has textfields to show coordinates and an edit button to edit the textfields. */ public void createTabbedPanel() { JTabbedPane tabbedPane = new JTabbedPane(); //Creates the destroyer tab panel JPanel destroyerPanel = new JPanel(false); JLabel destroyerLabel = new JLabel("Destroyer"); destroyerLabel.setHorizontalAlignment(JLabel.CENTER); destroyerPanel.setLayout(new BoxLayout(destroyerPanel, BoxLayout.Y_AXIS)); JPanel destroyerOnePanel = new JPanel(new FlowLayout()); JLabel destroyerPositionOne = new JLabel("Position 1"); textDestroyerCoordXOne = new JTextField("X Coordinates"); textDestroyerCoordXOne.setColumns(10); textDestroyerCoordYOne = new JTextField("Y Coordinates"); textDestroyerCoordYOne.setColumns(10); destroyerOnePanel.add(destroyerPositionOne); destroyerOnePanel.add(textDestroyerCoordXOne); destroyerOnePanel.add(textDestroyerCoordYOne); JPanel destroyerTwoPanel = new JPanel(new FlowLayout()); JLabel destroyerPositionTwo = new JLabel("Position 2"); textDestroyerCoordXTwo = new JTextField("X Coordinates"); textDestroyerCoordXTwo.setColumns(10); textDestroyerCoordYTwo = new JTextField("Y Coordinates"); textDestroyerCoordYTwo.setColumns(10); destroyerTwoPanel.add(destroyerPositionTwo); destroyerTwoPanel.add(textDestroyerCoordXTwo); destroyerTwoPanel.add(textDestroyerCoordYTwo); destroyerPanel.add(destroyerOnePanel); destroyerPanel.add(destroyerTwoPanel); destroyerPanel.add(createShipEdit("Destroyer")); //Submarine Tab Panel //JComponent submarine = makeShipPanel("Submarine"); JPanel submarinePanel = new JPanel(false); JLabel submarineLabel = new JLabel("Submarine"); submarineLabel.setHorizontalAlignment(JLabel.CENTER); submarinePanel.setLayout(new BoxLayout(submarinePanel, BoxLayout.Y_AXIS)); JPanel submarineOnePanel = new JPanel(new FlowLayout()); JLabel submarinePositionOne = new JLabel("Position 1"); textSubmarineCoordXOne = new JTextField("X Coordinates"); textSubmarineCoordXOne.setColumns(10); textSubmarineCoordYOne = new JTextField("Y Coordinates"); textSubmarineCoordYOne.setColumns(10); submarineOnePanel.add(submarinePositionOne); submarineOnePanel.add(textSubmarineCoordXOne); submarineOnePanel.add(textSubmarineCoordYOne); JPanel submarineTwoPanel = new JPanel(new FlowLayout()); JLabel submarinePositionTwo = new JLabel("Position 2"); textSubmarineCoordXTwo = new JTextField("X Coordinates"); textSubmarineCoordXTwo.setColumns(10); textSubmarineCoordYTwo = new JTextField("Y Coordinates"); textSubmarineCoordYTwo.setColumns(10); submarineTwoPanel.add(submarinePositionTwo); submarineTwoPanel.add(textSubmarineCoordXTwo); submarineTwoPanel.add(textSubmarineCoordYTwo); submarinePanel.add(submarineOnePanel); submarinePanel.add(submarineTwoPanel); submarinePanel.add(createShipEdit("Submarine")); //Battleship tab panel JPanel battleshipPanel = new JPanel(false); JLabel battleshipLabel = new JLabel("Battleship"); battleshipLabel.setHorizontalAlignment(JLabel.CENTER); battleshipPanel.setLayout(new BoxLayout(battleshipPanel, BoxLayout.Y_AXIS)); JPanel battleshipOnePanel = new JPanel(new FlowLayout()); JLabel battleshipPositionOne = new JLabel("Position 1"); textBattleshipCoordXOne = new JTextField("X Coordinates"); textBattleshipCoordXOne.setColumns(10); textBattleshipCoordYOne = new JTextField("Y Coordinates"); textBattleshipCoordYOne.setColumns(10); battleshipOnePanel.add(battleshipPositionOne); battleshipOnePanel.add(textBattleshipCoordXOne); battleshipOnePanel.add(textBattleshipCoordYOne); JPanel battleshipTwoPanel = new JPanel(new FlowLayout()); JLabel battleshipPositionTwo = new JLabel("Position 2"); textBattleshipCoordXTwo = new JTextField("X Coordinates"); textBattleshipCoordXTwo.setColumns(10); textBattleshipCoordYTwo = new JTextField("Y Coordinates"); textBattleshipCoordYTwo.setColumns(10); battleshipTwoPanel.add(battleshipPositionTwo); battleshipTwoPanel.add(textBattleshipCoordXTwo); battleshipTwoPanel.add(textBattleshipCoordYTwo); battleshipPanel.add(battleshipOnePanel); battleshipPanel.add(battleshipTwoPanel); battleshipPanel.add(createShipEdit("Battleship")); //JComponent battleship = makeShipPanel("Battleship"); //Carrier tab Panel JPanel carrierPanel = new JPanel(false); JLabel carrierLabel = new JLabel("Carrier"); carrierLabel.setHorizontalAlignment(JLabel.CENTER); carrierPanel.setLayout(new BoxLayout(carrierPanel, BoxLayout.Y_AXIS)); JPanel carrierOnePanel = new JPanel(new FlowLayout()); JLabel carrierPositionOne = new JLabel("Position 1"); textCarrierCoordXOne = new JTextField("X Coordinates"); textCarrierCoordXOne.setColumns(10); textCarrierCoordYOne = new JTextField("Y Coordinates"); textCarrierCoordYOne.setColumns(10); carrierOnePanel.add(carrierPositionOne); carrierOnePanel.add(textCarrierCoordXOne); carrierOnePanel.add(textCarrierCoordYOne); JPanel carrierTwoPanel = new JPanel(new FlowLayout()); JLabel carrierPositionTwo = new JLabel("Position 2"); textCarrierCoordXTwo = new JTextField("X Coordinates"); textCarrierCoordXTwo.setColumns(10); textCarrierCoordYTwo = new JTextField("Y Coordinates"); textCarrierCoordYTwo.setColumns(10); carrierTwoPanel.add(carrierPositionTwo); carrierTwoPanel.add(textCarrierCoordXTwo); carrierTwoPanel.add(textCarrierCoordYTwo); carrierPanel.add(carrierOnePanel); carrierPanel.add(carrierTwoPanel); carrierPanel.add(createShipEdit("Carrier")); //JComponent carrier = makeShipPanel("Carrier"); tabbedPane.addTab("Destroyer", destroyerPanel); tabbedPane.addTab("Submarine", submarinePanel); tabbedPane.addTab("Battleship", battleshipPanel); tabbedPane.addTab("Carrier", carrierPanel); shipPane.add(tabbedPane); } // protected JComponent makeShipPanel(String textString) { // String typeOfShip = textString; // JPanel panel = new JPanel(false); // JLabel label = new JLabel(textString); // label.setHorizontalAlignment(JLabel.CENTER); // panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // // JPanel onePanel = new JPanel(new FlowLayout()); // // JLabel positionOne = new JLabel("Position 1"); // JTextField coordXOne = new JTextField("X Coordinates"); // JTextField coordYOne = new JTextField("Y Coordinates"); // // onePanel.add(positionOne); // onePanel.add(coordXOne); // onePanel.add(coordYOne); // // JPanel twoPanel = new JPanel(new FlowLayout()); // // JLabel positionTwo = new JLabel("Position 2"); // JTextField coordXTwo = new JTextField("X Coordinates"); // JTextField coordYTwo = new JTextField("Y Coordinates"); // // twoPanel.add(positionTwo); // twoPanel.add(coordXTwo); // twoPanel.add(coordYTwo); // // // panel.add(onePanel); // panel.add(twoPanel); // panel.add(createShipEdit(textString)); // return panel; // } /** * Creates edit button for each panel when called. * Creates a start button on the main destroyer panel. * @param shipType * @return */ public JPanel createShipEdit(String shipType) { JPanel threePanel = new JPanel(); if(shipType.equals("Destroyer")){ final JPanel destroyerPanel = new JPanel(new FlowLayout()); final JButton edit = new JButton("Edit"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //shipTypeTab selects which ship to edit. shipTypeTab = 1; //zeroes the coordinates if they wanna re-edit the coordinates. playerDestroyer.zeroCoordinates(); //changes text on buttons back to nothing and filled to false. if(destroyerShipCoordOne != null) { setupGrid[destroyerShipCoordOne.getxCoord()][destroyerShipCoordOne.getyCoord()].setText(""); setupGrid[destroyerShipCoordTwo.getxCoord()][destroyerShipCoordTwo.getyCoord()].setText(""); filled[destroyerShipCoordOne.getxCoord()][destroyerShipCoordOne.getyCoord()] = false; filled[destroyerShipCoordTwo.getxCoord()][destroyerShipCoordTwo.getyCoord()] = false; } //sets textfields back to original. textDestroyerCoordXOne.setText("X Coordinates"); textDestroyerCoordYOne.setText("Y Coordinates"); textDestroyerCoordXTwo.setText("X Coordinates"); textDestroyerCoordYTwo.setText("Y Coordinates"); } }); destroyerPanel.add(edit); //start button to start game. Removes the start button once pressed. final JButton startGame = new JButton("Start"); startGame.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if( (playerDestroyer.getPositionX1() == null) || (playerSubmarine.getPositionX1() == null) || (playerBattleship.getPositionX1() == null) || (playerCarrier.getPositionX1() == null)) { System.out.println("Please place all ships"); } else { startGame(); destroyerPanel.remove(startGame); } } }); destroyerPanel.add(startGame); threePanel = destroyerPanel; } //same things as above, except for submarine panel. if(shipType.equals("Submarine")){ JPanel submarinePanel = new JPanel(new FlowLayout()); JButton edit = new JButton("Edit"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shipTypeTab = 2; playerSubmarine.zeroCoordinates(); if(submarineShipCoordOne != null) { setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord()].setText(""); setupGrid[submarineShipCoordTwo.getxCoord()][submarineShipCoordTwo.getyCoord()].setText(""); if ( (submarineShipCoordOne.getxCoord() == submarineShipCoordTwo.getxCoord()) && ( (submarineShipCoordOne.getyCoord() - submarineShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() + 1].setText(""); filled[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() + 1] = false; } if ( (submarineShipCoordOne.getxCoord() == submarineShipCoordTwo.getxCoord()) && ( (submarineShipCoordOne.getyCoord() - submarineShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() - 1].setText(""); filled[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() - 1] = false; } if ( ((submarineShipCoordOne.getxCoord() - submarineShipCoordTwo.getxCoord()) < 0) && ( submarineShipCoordOne.getyCoord() == submarineShipCoordTwo.getyCoord()) ) { setupGrid[submarineShipCoordOne.getxCoord() + 1][submarineShipCoordOne.getyCoord()].setText(""); filled[submarineShipCoordOne.getxCoord() + 1][submarineShipCoordOne.getyCoord()] = false; } if ( ((submarineShipCoordOne.getxCoord() - submarineShipCoordTwo.getxCoord()) > 0) && ( (submarineShipCoordOne.getyCoord() == submarineShipCoordTwo.getyCoord()) ) ) { setupGrid[submarineShipCoordOne.getxCoord() - 1][submarineShipCoordOne.getyCoord()].setText(""); filled[submarineShipCoordOne.getxCoord() - 1][submarineShipCoordOne.getyCoord()] = false; } } textSubmarineCoordXOne.setText("X Coordinates"); textSubmarineCoordYOne.setText("Y Coordinates"); textSubmarineCoordXTwo.setText("X Coordinates"); textSubmarineCoordYTwo.setText("Y Coordinates"); } }); submarinePanel.add(edit); threePanel = submarinePanel; } //same things as above, except for battlehip panel. if(shipType.equals("Battleship")){ JPanel battleshipPanel = new JPanel(new FlowLayout()); JButton edit = new JButton("Edit"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shipTypeTab = 3; playerBattleship.zeroCoordinates(); if (battleshipShipCoordOne != null) { setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord()].setText(""); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord()] = false; setupGrid[battleshipShipCoordTwo.getxCoord()][battleshipShipCoordTwo.getyCoord()].setText(""); filled[battleshipShipCoordTwo.getxCoord()][battleshipShipCoordTwo.getyCoord()] = false; if ( (battleshipShipCoordOne.getxCoord() == battleshipShipCoordTwo.getxCoord()) && ( (battleshipShipCoordOne.getyCoord() - battleshipShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 1].setText(""); setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 2].setText(""); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 1] = false; filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 2] = false; } if ( (battleshipShipCoordOne.getxCoord() == battleshipShipCoordTwo.getxCoord()) && ( (battleshipShipCoordOne.getyCoord() - battleshipShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 1].setText(""); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 1] = false; setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 2].setText(""); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 2] = false; } if ( ((battleshipShipCoordOne.getxCoord() - battleshipShipCoordTwo.getxCoord()) < 0) && ( battleshipShipCoordOne.getyCoord() == battleshipShipCoordTwo.getyCoord()) ) { setupGrid[battleshipShipCoordOne.getxCoord() + 1][battleshipShipCoordOne.getyCoord()].setText(""); filled[battleshipShipCoordOne.getxCoord() + 1][battleshipShipCoordOne.getyCoord()] = false; setupGrid[battleshipShipCoordOne.getxCoord() + 2][battleshipShipCoordOne.getyCoord()].setText(""); filled[battleshipShipCoordOne.getxCoord() + 2][battleshipShipCoordOne.getyCoord()] = false; } if ( ((battleshipShipCoordOne.getxCoord() - battleshipShipCoordTwo.getxCoord()) > 0) && ( (battleshipShipCoordOne.getyCoord() == battleshipShipCoordTwo.getyCoord()) ) ) { setupGrid[battleshipShipCoordOne.getxCoord() - 1][battleshipShipCoordOne.getyCoord()].setText(""); filled[battleshipShipCoordOne.getxCoord() - 1][battleshipShipCoordOne.getyCoord()] = false; setupGrid[battleshipShipCoordOne.getxCoord() - 2][battleshipShipCoordOne.getyCoord()].setText(""); filled[battleshipShipCoordOne.getxCoord() - 2][battleshipShipCoordOne.getyCoord()] = false; } } textBattleshipCoordXOne.setText("X Coordinates"); textBattleshipCoordYOne.setText("Y Coordinates"); textBattleshipCoordXTwo.setText("X Coordinates"); textBattleshipCoordYTwo.setText("Y Coordinates"); } }); battleshipPanel.add(edit); threePanel = battleshipPanel; } //same things as above, except for carrier panel. if(shipType.equals("Carrier")){ JPanel carrierPanel = new JPanel(new FlowLayout()); JButton edit = new JButton("Edit"); edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { shipTypeTab = 4; playerCarrier.zeroCoordinates(); if (carrierShipCoordOne != null){ setupGrid[carrierShipCoordTwo.getxCoord()][carrierShipCoordTwo.getyCoord()].setText(""); filled[carrierShipCoordTwo.getxCoord()][carrierShipCoordTwo.getyCoord()] = false; setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord()] = false; if ( (carrierShipCoordOne.getxCoord() == carrierShipCoordTwo.getxCoord()) && ( (carrierShipCoordOne.getyCoord() - carrierShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 1].setText(""); setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 2].setText(""); setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 3].setText(""); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 1] = false; filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 2] = false; filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 3] = false; } if ( (carrierShipCoordOne.getxCoord() == carrierShipCoordTwo.getxCoord()) && ( (carrierShipCoordOne.getyCoord() - carrierShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 1].setText(""); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 1] = false; setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 2].setText(""); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 2] = false; setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 3].setText(""); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 3] = false; } if ( ((carrierShipCoordOne.getxCoord() - carrierShipCoordTwo.getxCoord()) < 0) && ( carrierShipCoordOne.getyCoord() == carrierShipCoordTwo.getyCoord()) ) { setupGrid[carrierShipCoordOne.getxCoord() + 1][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() + 1][carrierShipCoordOne.getyCoord()] = false; setupGrid[carrierShipCoordOne.getxCoord() + 2][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() + 2][carrierShipCoordOne.getyCoord()] = false; setupGrid[carrierShipCoordOne.getxCoord() + 3][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() + 3][carrierShipCoordOne.getyCoord()] = false; } if ( ((carrierShipCoordOne.getxCoord() - carrierShipCoordTwo.getxCoord()) > 0) && ( (carrierShipCoordOne.getyCoord() == carrierShipCoordTwo.getyCoord()) ) ) { setupGrid[carrierShipCoordOne.getxCoord() - 1][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() - 1][carrierShipCoordOne.getyCoord()] = false; setupGrid[carrierShipCoordOne.getxCoord() - 2][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() - 2][carrierShipCoordOne.getyCoord()] = false; setupGrid[carrierShipCoordOne.getxCoord() - 3][carrierShipCoordOne.getyCoord()].setText(""); filled[carrierShipCoordOne.getxCoord() - 3][carrierShipCoordOne.getyCoord()] = false; } } textCarrierCoordXOne.setText("X Coordinates"); textCarrierCoordYOne.setText("Y Coordinates"); textCarrierCoordXTwo.setText("X Coordinates"); textCarrierCoordYTwo.setText("Y Coordinates"); } }); carrierPanel.add(edit); threePanel = carrierPanel; } return threePanel; } /** * Starts game. */ public void startGame() { //checks to see if all ships have been placed. // if( (playerDestroyer.getPositionX1() == null) || (playerSubmarine.getPositionX1() == null) || (playerBattleship.getPositionX1() == null) || (playerCarrier.getPositionX1() == null)) { // System.out.println("Please place all ships"); // } else { Board board = new Board(); JPanel holder = new JPanel(); holder.setLayout(new BoxLayout(holder, BoxLayout.Y_AXIS)); JPanel ctrlPanel = new JPanel(); //Allows toggle to view your own ships. JButton viewSetup = new JButton("View Ships"); viewSetup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(Menu.getFrameVisibility() == false){ Menu.setupFrameVisibility(true); } else { Menu.setupFrameVisibility(false); } } }); ctrlPanel.setSize(600, 100); ctrlPanel.add(viewSetup); holder.add(board); holder.add(ctrlPanel); f.setSize(600, 700); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); f.add(holder); // f.add(ctrlPanel); Menu.setupFrameVisibility(false); } /** * Sets the ship coordinates for the player's ships. * Changes button text to "ship" when placed. Creates ship objects once placed. * Auto fills the space between two coordinates pressed with "ship". * Example: submarine takes 3 grids. Press two different grids 1 distance apart. Each button pressed will change text to "ship", the button in between will autofill. * Makes sure you can't press a space that's already taken. */ public void setShipCoordinates() { //checks to see if space is taken. if(filled[theShipCoord.getxCoord()][theShipCoord.getyCoord()] == false){ if (shipTypeTab == 1) { //checks if coordinates are null if(playerDestroyer.getPositionX1() == null){ destroyerShipCoordOne = theShipCoord; playerDestroyer.setPositionX1(destroyerShipCoordOne.getxCoord()); textDestroyerCoordXOne.setText(Integer.toString(destroyerShipCoordOne.getxCoord())); playerDestroyer.setPositionY1(destroyerShipCoordOne.getyCoord()); textDestroyerCoordYOne.setText(Integer.toString(destroyerShipCoordOne.getyCoord())); setupGrid[destroyerShipCoordOne.getxCoord()][destroyerShipCoordOne.getyCoord()].setText("Ship"); filled[destroyerShipCoordOne.getxCoord()][destroyerShipCoordOne.getyCoord()] = true; } else if (playerDestroyer.getPositionX2() == null) { //makes sure destroyer is placed on two grids side by side. if( ( ((playerDestroyer.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerDestroyer.getPositionY1() - theShipCoord.getyCoord()) == 1) ) || ( ((playerDestroyer.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerDestroyer.getPositionY1() - theShipCoord.getyCoord()) == -1) ) || ( ((playerDestroyer.getPositionX1() - theShipCoord.getxCoord() ) == 1 ) && ((playerDestroyer.getPositionY1() - theShipCoord.getyCoord()) == 0) ) || ( ((playerDestroyer.getPositionX1() - theShipCoord.getxCoord() ) == -1 ) && ((playerDestroyer.getPositionY1() - theShipCoord.getyCoord()) == 0) ) ) { destroyerShipCoordTwo = theShipCoord; playerDestroyer.setPositionX2(destroyerShipCoordTwo.getxCoord()); textDestroyerCoordXTwo.setText(Integer.toString(destroyerShipCoordTwo.getxCoord())); playerDestroyer.setPositionY2(destroyerShipCoordTwo.getyCoord()); textDestroyerCoordYTwo.setText(Integer.toString(destroyerShipCoordTwo.getyCoord())); setupGrid[destroyerShipCoordTwo.getxCoord()][destroyerShipCoordTwo.getyCoord()].setText("Ship"); filled[destroyerShipCoordTwo.getxCoord()][destroyerShipCoordTwo.getyCoord()] = true; // System.out.println(playerDestroyer.getPositionY1()); // System.out.println(playerDestroyer.getPositionX1()); // System.out.println(playerDestroyer.getPositionY2()); // System.out.println(playerDestroyer.getPositionX2()); } else { System.out.println("Invalid entry. Destroyers take up 2 grid."); textDestroyerCoordXTwo.setText("X Coordinates"); textDestroyerCoordYTwo.setText("Y Coordinates"); } } //use theShipCoordinates to set ship coord } if (shipTypeTab == 2) { if(playerSubmarine.getPositionX1() == null){ submarineShipCoordOne = theShipCoord; playerSubmarine.setPositionX1(submarineShipCoordOne.getxCoord()); textSubmarineCoordXOne.setText(Integer.toString(submarineShipCoordOne.getxCoord())); playerSubmarine.setPositionY1(submarineShipCoordOne.getyCoord()); textSubmarineCoordYOne.setText(Integer.toString(submarineShipCoordOne.getyCoord())); setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord()].setText("Ship"); } else if (playerSubmarine.getPositionX2() == null){ //checks to make sure submarine takes up 3 grids in a row. if( ( ((playerSubmarine.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerSubmarine.getPositionY1() - theShipCoord.getyCoord()) == 2) ) || ( ((playerSubmarine.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerSubmarine.getPositionY1() - theShipCoord.getyCoord()) == -2) ) || ( ((playerSubmarine.getPositionX1() - theShipCoord.getxCoord() ) == 2 ) && ((playerSubmarine.getPositionY1() - theShipCoord.getyCoord()) == 0) ) || ( ((playerSubmarine.getPositionX1() - theShipCoord.getxCoord() ) == -2 ) && ((playerSubmarine.getPositionY1() - theShipCoord.getyCoord()) == 0) ) ) { submarineShipCoordTwo = theShipCoord; playerSubmarine.setPositionX3(submarineShipCoordTwo.getxCoord()); textSubmarineCoordXTwo.setText(Integer.toString(submarineShipCoordTwo.getxCoord())); playerSubmarine.setPositionY3(submarineShipCoordTwo.getyCoord()); textSubmarineCoordYTwo.setText(Integer.toString(submarineShipCoordTwo.getyCoord())); setupGrid[submarineShipCoordTwo.getxCoord()][submarineShipCoordTwo.getyCoord()].setText("Ship"); //auto fill section if ( (submarineShipCoordOne.getxCoord() == submarineShipCoordTwo.getxCoord()) && ( (submarineShipCoordOne.getyCoord() - submarineShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() + 1].setText("Ship"); filled[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() + 1] = true; playerSubmarine.setPositionX2(submarineShipCoordOne.getxCoord()); playerSubmarine.setPositionY2(submarineShipCoordOne.getyCoord()+1); } if ( (submarineShipCoordOne.getxCoord() == submarineShipCoordTwo.getxCoord()) && ( (submarineShipCoordOne.getyCoord() - submarineShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() - 1].setText("Ship"); filled[submarineShipCoordOne.getxCoord()][submarineShipCoordOne.getyCoord() - 1] = true; playerSubmarine.setPositionX2(submarineShipCoordOne.getxCoord()); playerSubmarine.setPositionY2(submarineShipCoordOne.getyCoord()-1); } if ( ((submarineShipCoordOne.getxCoord() - submarineShipCoordTwo.getxCoord()) < 0) && ( submarineShipCoordOne.getyCoord() == submarineShipCoordTwo.getyCoord()) ) { setupGrid[submarineShipCoordOne.getxCoord() + 1][submarineShipCoordOne.getyCoord()].setText("Ship"); filled[submarineShipCoordOne.getxCoord() + 1][submarineShipCoordOne.getyCoord()] = true; playerSubmarine.setPositionX2(submarineShipCoordOne.getxCoord()+1); playerSubmarine.setPositionY2(submarineShipCoordOne.getyCoord()); } if ( ((submarineShipCoordOne.getxCoord() - submarineShipCoordTwo.getxCoord()) > 0) && ( (submarineShipCoordOne.getyCoord() == submarineShipCoordTwo.getyCoord()) ) ) { setupGrid[submarineShipCoordOne.getxCoord() - 1][submarineShipCoordOne.getyCoord()].setText("Ship"); filled[submarineShipCoordOne.getxCoord() - 1][submarineShipCoordOne.getyCoord()] = true; playerSubmarine.setPositionX2(submarineShipCoordOne.getxCoord()-1); playerSubmarine.setPositionY2(submarineShipCoordOne.getyCoord()); } } else { System.out.println("Invalid entry. Submarines take up 3 grid"); textSubmarineCoordXTwo.setText("X Coordinates"); textSubmarineCoordYTwo.setText("Y Coordinates"); } } //reminder set ship coordinates } if (shipTypeTab == 3) { if(playerBattleship.getPositionX1() == null){ battleshipShipCoordOne = theShipCoord; playerBattleship.setPositionX1(battleshipShipCoordOne.getxCoord()); textBattleshipCoordXOne.setText(Integer.toString(battleshipShipCoordOne.getxCoord())); playerBattleship.setPositionY1(battleshipShipCoordOne.getyCoord()); textBattleshipCoordYOne.setText(Integer.toString(battleshipShipCoordOne.getyCoord())); setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord()].setText("Ship"); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord()] = true; } else if (playerBattleship.getPositionX2() == null) { if( ( ((playerBattleship.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerBattleship.getPositionY1() - theShipCoord.getyCoord()) == 3) ) || ( ((playerBattleship.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerBattleship.getPositionY1() - theShipCoord.getyCoord()) == -3) ) || ( ((playerBattleship.getPositionX1() - theShipCoord.getxCoord() ) == 3 ) && ((playerBattleship.getPositionY1() - theShipCoord.getyCoord()) == 0) ) || ( ((playerBattleship.getPositionX1() - theShipCoord.getxCoord() ) == -3 ) && ((playerBattleship.getPositionY1() - theShipCoord.getyCoord()) == 0) ) ) { battleshipShipCoordTwo = theShipCoord; playerBattleship.setPositionX4(battleshipShipCoordTwo.getxCoord()); textBattleshipCoordXTwo.setText(Integer.toString(battleshipShipCoordTwo.getxCoord())); playerBattleship.setPositionY4(battleshipShipCoordTwo.getyCoord()); textBattleshipCoordYTwo.setText(Integer.toString(battleshipShipCoordTwo.getyCoord())); setupGrid[battleshipShipCoordTwo.getxCoord()][battleshipShipCoordTwo.getyCoord()].setText("Ship"); filled[battleshipShipCoordTwo.getxCoord()][battleshipShipCoordTwo.getyCoord()] = true; if ( (battleshipShipCoordOne.getxCoord() == battleshipShipCoordTwo.getxCoord()) && ( (battleshipShipCoordOne.getyCoord() - battleshipShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 1].setText("Ship"); setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 2].setText("Ship"); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 1] = true; filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() + 2] = true; playerBattleship.setPositionX2(battleshipShipCoordOne.getxCoord()); playerBattleship.setPositionY2(battleshipShipCoordOne.getyCoord()+1); playerBattleship.setPositionX3(battleshipShipCoordOne.getxCoord()); playerBattleship.setPositionY3(battleshipShipCoordOne.getyCoord()+2); } if ( (battleshipShipCoordOne.getxCoord() == battleshipShipCoordTwo.getxCoord()) && ( (battleshipShipCoordOne.getyCoord() - battleshipShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 1].setText("Ship"); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 1] = true; setupGrid[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 2].setText("Ship"); filled[battleshipShipCoordOne.getxCoord()][battleshipShipCoordOne.getyCoord() - 2] = true; playerBattleship.setPositionX2(battleshipShipCoordOne.getxCoord()); playerBattleship.setPositionY2(battleshipShipCoordOne.getyCoord()-1); playerBattleship.setPositionX3(battleshipShipCoordOne.getxCoord()); playerBattleship.setPositionY3(battleshipShipCoordOne.getyCoord()-2); } if ( ((battleshipShipCoordOne.getxCoord() - battleshipShipCoordTwo.getxCoord()) < 0) && ( battleshipShipCoordOne.getyCoord() == battleshipShipCoordTwo.getyCoord()) ) { setupGrid[battleshipShipCoordOne.getxCoord() + 1][battleshipShipCoordOne.getyCoord()].setText("Ship"); filled[battleshipShipCoordOne.getxCoord() + 1][battleshipShipCoordOne.getyCoord()] = true; setupGrid[battleshipShipCoordOne.getxCoord() + 2][battleshipShipCoordOne.getyCoord()].setText("Ship"); filled[battleshipShipCoordOne.getxCoord() + 2][battleshipShipCoordOne.getyCoord()] = true; playerBattleship.setPositionX2(battleshipShipCoordOne.getxCoord()+1); playerBattleship.setPositionY2(battleshipShipCoordOne.getyCoord()); playerBattleship.setPositionX3(battleshipShipCoordOne.getxCoord()+2); playerBattleship.setPositionY3(battleshipShipCoordOne.getyCoord()); } if ( ((battleshipShipCoordOne.getxCoord() - battleshipShipCoordTwo.getxCoord()) > 0) && ( (battleshipShipCoordOne.getyCoord() == battleshipShipCoordTwo.getyCoord()) ) ) { setupGrid[battleshipShipCoordOne.getxCoord() - 1][battleshipShipCoordOne.getyCoord()].setText("Ship"); filled[battleshipShipCoordOne.getxCoord() - 1][battleshipShipCoordOne.getyCoord()] = true; setupGrid[battleshipShipCoordOne.getxCoord() - 2][battleshipShipCoordOne.getyCoord()].setText("Ship"); filled[battleshipShipCoordOne.getxCoord() - 2][battleshipShipCoordOne.getyCoord()] = true; playerBattleship.setPositionX2(battleshipShipCoordOne.getxCoord()-1); playerBattleship.setPositionY2(battleshipShipCoordOne.getyCoord()); playerBattleship.setPositionX3(battleshipShipCoordOne.getxCoord()-2); playerBattleship.setPositionY3(battleshipShipCoordOne.getyCoord()); } } else { System.out.println("Invalid entry. Battleships take up 4 grid"); textBattleshipCoordXTwo.setText("X Coordinates"); textBattleshipCoordYTwo.setText("Y Coordinates"); } } //reminder: use theShipCoordinates to set ship coord } if (shipTypeTab == 4) { if(playerCarrier.getPositionX1() == null){ carrierShipCoordOne = theShipCoord; playerCarrier.setPositionX1(carrierShipCoordOne.getxCoord()); textCarrierCoordXOne.setText(Integer.toString(carrierShipCoordOne.getxCoord())); playerCarrier.setPositionY1(carrierShipCoordOne.getyCoord()); textCarrierCoordYOne.setText(Integer.toString(carrierShipCoordOne.getyCoord())); setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord()] = true; } else if (playerCarrier.getPositionX2() == null){ if( ( ((playerCarrier.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerCarrier.getPositionY1() - theShipCoord.getyCoord()) == 4) ) || ( ((playerCarrier.getPositionX1() - theShipCoord.getxCoord() ) == 0 ) && ((playerCarrier.getPositionY1() - theShipCoord.getyCoord()) == -4) ) || ( ((playerCarrier.getPositionX1() - theShipCoord.getxCoord() ) == 4 ) && ((playerCarrier.getPositionY1() - theShipCoord.getyCoord()) == 0) ) || ( ((playerCarrier.getPositionX1() - theShipCoord.getxCoord() ) == -4 ) && ((playerCarrier.getPositionY1() - theShipCoord.getyCoord()) == 0) ) ) { carrierShipCoordTwo = theShipCoord; playerCarrier.setPositionX5(carrierShipCoordTwo.getxCoord()); textCarrierCoordXTwo.setText(Integer.toString(carrierShipCoordTwo.getxCoord())); playerCarrier.setPositionY5(carrierShipCoordTwo.getyCoord()); textCarrierCoordYTwo.setText(Integer.toString(carrierShipCoordTwo.getyCoord())); setupGrid[carrierShipCoordTwo.getxCoord()][carrierShipCoordTwo.getyCoord()].setText("Ship"); filled[carrierShipCoordTwo.getxCoord()][carrierShipCoordTwo.getyCoord()] = true; if ( (carrierShipCoordOne.getxCoord() == carrierShipCoordTwo.getxCoord()) && ( (carrierShipCoordOne.getyCoord() - carrierShipCoordTwo.getyCoord()) < 0 ) ) { setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 1].setText("Ship"); setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 2].setText("Ship"); setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 3].setText("Ship"); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 1] = true; filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 2] = true; filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() + 3] = true; playerCarrier.setPositionX2(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY2(carrierShipCoordOne.getyCoord()+1); playerCarrier.setPositionX3(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY3(carrierShipCoordOne.getyCoord()+2); playerCarrier.setPositionX4(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY4(carrierShipCoordOne.getyCoord()+3); } if ( (carrierShipCoordOne.getxCoord() == carrierShipCoordTwo.getxCoord()) && ( (carrierShipCoordOne.getyCoord() - carrierShipCoordTwo.getyCoord()) > 0 ) ) { setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 1].setText("Ship"); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 1] = true; setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 2].setText("Ship"); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 2] = true; setupGrid[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 3].setText("Ship"); filled[carrierShipCoordOne.getxCoord()][carrierShipCoordOne.getyCoord() - 3] = true; playerCarrier.setPositionX2(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY2(carrierShipCoordOne.getyCoord()-1); playerCarrier.setPositionX3(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY3(carrierShipCoordOne.getyCoord()-2); playerCarrier.setPositionX4(carrierShipCoordOne.getxCoord()); playerCarrier.setPositionY4(carrierShipCoordOne.getyCoord()-3); } if ( ((carrierShipCoordOne.getxCoord() - carrierShipCoordTwo.getxCoord()) < 0) && ( carrierShipCoordOne.getyCoord() == carrierShipCoordTwo.getyCoord()) ) { setupGrid[carrierShipCoordOne.getxCoord() + 1][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() + 1][carrierShipCoordOne.getyCoord()] = true; setupGrid[carrierShipCoordOne.getxCoord() + 2][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() + 2][carrierShipCoordOne.getyCoord()] = true; setupGrid[carrierShipCoordOne.getxCoord() + 3][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() + 3][carrierShipCoordOne.getyCoord()] = true; playerCarrier.setPositionX2(carrierShipCoordOne.getxCoord()+1); playerCarrier.setPositionY2(carrierShipCoordOne.getyCoord()); playerCarrier.setPositionX3(carrierShipCoordOne.getxCoord()+2); playerCarrier.setPositionY3(carrierShipCoordOne.getyCoord()); playerCarrier.setPositionX4(carrierShipCoordOne.getxCoord()+3); playerCarrier.setPositionY4(carrierShipCoordOne.getyCoord()); } if ( ((carrierShipCoordOne.getxCoord() - carrierShipCoordTwo.getxCoord()) > 0) && ( (carrierShipCoordOne.getyCoord() == carrierShipCoordTwo.getyCoord()) ) ) { setupGrid[carrierShipCoordOne.getxCoord() - 1][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() - 1][carrierShipCoordOne.getyCoord()] = true; setupGrid[carrierShipCoordOne.getxCoord() - 2][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() - 2][carrierShipCoordOne.getyCoord()] = true; setupGrid[carrierShipCoordOne.getxCoord() - 3][carrierShipCoordOne.getyCoord()].setText("Ship"); filled[carrierShipCoordOne.getxCoord() - 3][carrierShipCoordOne.getyCoord()] = true; playerCarrier.setPositionX2(carrierShipCoordOne.getxCoord()-1); playerCarrier.setPositionY2(carrierShipCoordOne.getyCoord()); playerCarrier.setPositionX3(carrierShipCoordOne.getxCoord()-2); playerCarrier.setPositionY3(carrierShipCoordOne.getyCoord()); playerCarrier.setPositionX4(carrierShipCoordOne.getxCoord()-3); playerCarrier.setPositionY4(carrierShipCoordOne.getyCoord()); } } else { System.out.println("Invalid entry. Carriers take up 5 grid"); textCarrierCoordXTwo.setText("X Coordinates"); textCarrierCoordYTwo.setText("Y Coordinates"); } } } } else { System.out.println("Space is occupied"); } } /** * Create grid and buttons for setup. * Add action listeners */ public void createSetupButtons() { setupGrid = new JButton[WIDTH][LENGTH]; filled = new boolean[WIDTH][LENGTH]; for(int i = 0; i < LENGTH; i++){ for(int j = 0; j < WIDTH; j++){ if( i == 0 || j == 0) { setupGrid[j][i] = new JButton("(" + j + "," + i + ")"); filled[j][i] = false; gridPane.add(setupGrid[j][i]); } else { filled[j][i] = false; setupGrid[j][i] = new JButton(""); gridPane.add(setupGrid[j][i]); final int tempI = i; final int tempJ = j; setupGrid[j][i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Coordinates shipCoord = new Coordinates(tempJ, tempI); theShipCoord = shipCoord; setShipCoordinates(); } }); } } } } public static boolean[][] getFilled() { return filled; } public void setFilled(boolean[][] filled) { this.filled = filled; } public static Destroyer getPlayerDestroyer() { return playerDestroyer; } public void setPlayerDestroyer(Destroyer playerDestroyer) { this.playerDestroyer = playerDestroyer; } public static Submarine getPlayerSubmarine() { return playerSubmarine; } public void setPlayerSubmarine(Submarine playerSubmarine) { this.playerSubmarine = playerSubmarine; } public static Battleship getPlayerBattleship() { return playerBattleship; } public void setPlayerBattleship(Battleship playerBattleship) { this.playerBattleship = playerBattleship; } public static Carrier getPlayerCarrier() { return playerCarrier; } public void setPlayerCarrier(Carrier playerCarrier) { this.playerCarrier = playerCarrier; } public static void dispose() { f.dispose(); } }
true
84326450b405eac9d308da1835dd165f3c00cbee
Java
brzaskun/NetBeansProjects
/taxmanfk/src/main/java/pdf/PdfPIT5.java
UTF-8
9,151
2.359375
2
[]
no_license
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pdf; import static beansPdf.PdfFont.ustawfrazeAlign; import com.itextpdf.text.Chunk; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; import com.itextpdf.text.Font; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Phrase; import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import dao.PodatnikDAO; import data.Data; import entity.Pitpoz; import entity.Podatnik; import entity.Uz; import java.io.FileNotFoundException; import java.io.IOException; import java.text.DateFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import msg.Msg;import plik.Plik; import view.WpisView; /** * * @author Osito */ public class PdfPIT5 { public static void drukuj(Pitpoz selected, WpisView wpisView, PodatnikDAO podatnikDAO) throws DocumentException, FileNotFoundException, IOException { Document document = new Document(); PdfWriter.getInstance(document, Plik.plikR("pit5" + wpisView.getPodatnikWpisu() + ".pdf")).setInitialLeading(16); document.addTitle("PIT5"); document.addAuthor("Biuro Rachunkowe Taxman Grzegorz Grzelczyk"); document.addSubject("Wydruk PIT5"); document.addKeywords("PIT5, PDF"); document.addCreator("Grzegorz Grzelczyk"); document.open(); //Rectangle rect = new Rectangle(0, 832, 136, 800); //rect.setBackgroundColor(BaseColor.RED); //document.add(rect); document.add(new Chunk("Biuro Rachunkowe Taxman")); document.add(Chunk.NEWLINE); BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED); Font font = new Font(helvetica,12); Font fontM = new Font(helvetica,10); Font fontS = new Font(helvetica,6); document.add(Chunk.NEWLINE); Date date = Calendar.getInstance().getTime(); DateFormat formatt = new SimpleDateFormat("dd/MM/yyyy"); String today = formatt.format(date); Paragraph miziu = new Paragraph(new Phrase("Szczecin, dnia "+Data.ostatniDzien(wpisView.getRokWpisuSt(), wpisView.getMiesiacWpisu()),font)); miziu.setAlignment(Element.ALIGN_RIGHT); miziu.setLeading(50); document.add(miziu); document.add(Chunk.NEWLINE); Paragraph miziu1 = new Paragraph(new Phrase("Zestawienie PIT-5",font)); miziu1.setAlignment(Element.ALIGN_CENTER); document.add(miziu1); document.add(Chunk.NEWLINE); miziu1 = new Paragraph(new Phrase("okres rozliczeniowy "+selected.getPkpirM()+"/"+selected.getPkpirR(),fontM)); document.add(miziu1); document.add(Chunk.NEWLINE); miziu1 = new Paragraph(new Phrase("Firma: "+wpisView.getPrintNazwa(),fontM)); document.add(miziu1); Podatnik pod = wpisView.getPodatnikObiekt(); miziu1 = new Paragraph(new Phrase("adres: "+pod.getMiejscowosc()+" "+pod.getUlica()+" "+pod.getNrdomu(),fontM)); document.add(miziu1); miziu1 = new Paragraph(new Phrase("NIP: "+pod.getNip(),fontM)); document.add(miziu1); PdfPTable table0 = new PdfPTable(2); PdfPTable table = new PdfPTable(2); PdfPTable table1 = new PdfPTable(2); PdfPTable table2 = new PdfPTable(2); table0.setWidths(new int[]{5, 5,}); table.setWidths(new int[]{5, 5,}); table1.setWidths(new int[]{5, 5,}); table2.setWidths(new int[]{5, 5,}); NumberFormat formatter = NumberFormat.getCurrencyInstance(); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); formatter.setGroupingUsed(true); table0.addCell(ustawfrazeAlign("imię i nazwisko podatnika","center",10)); table0.addCell(ustawfrazeAlign(selected.getUdzialowiec(),"right",10)); table.addCell(ustawfrazeAlign("przychody narastająco","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getPrzychody())),"right",10)); table.addCell(ustawfrazeAlign("koszty narastająco","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getKoszty())),"right",10)); if (selected.getRemanent()!=null) { table.addCell(ustawfrazeAlign("różnica remanentów","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getRemanent())),"right",10)); } table.addCell(ustawfrazeAlign("udział","center",10)); table.addCell(ustawfrazeAlign(selected.getUdzial()+"%","right",10)); table.addCell(ustawfrazeAlign("","center",10)); table.addCell(ustawfrazeAlign("","center",10)); table.addCell(ustawfrazeAlign("przychody narast./udział","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getPrzychodyudzial())),"right",10)); table.addCell(ustawfrazeAlign("koszty narast./udział","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getKosztyudzial())),"right",10)); table.addCell(ustawfrazeAlign("wynik od początku roku","center",10)); table.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getWynik())),"right",10)); table.addCell(ustawfrazeAlign("","center",10)); table.addCell(ustawfrazeAlign("","center",10)); table1.addCell(ustawfrazeAlign("ZUS 51","center",10)); if (selected.getZus51() != null) { table1.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getZus51())),"right",10)); } else { table1.addCell(ustawfrazeAlign(String.valueOf(formatter.format(0)),"right",10)); } table1.addCell(ustawfrazeAlign("strata z lat ub.","center",10)); table1.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getStrata())),"right",10)); table1.addCell(ustawfrazeAlign("podstawa op.","center",10)); table1.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getPodstawa())),"right",10)); table1.addCell(ustawfrazeAlign("podatek brutto od pocz.roku","center",10)); table1.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getPodatek())),"right",10)); table2.addCell(ustawfrazeAlign("ZUS 52","center",10)); if (selected.getZus52() != null) { table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getZus52())),"right",10)); } else { table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(0)),"right",10)); } table2.addCell(ustawfrazeAlign("strata z lat ub.","center",10)); table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getStrata())),"right",10)); table2.addCell(ustawfrazeAlign("podatek należny od pocz.roku","center",10)); table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getPododpoczrok())),"right",10)); table2.addCell(ustawfrazeAlign("zaliczki za pop.mce","center",10)); table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getNalzalodpoczrok())),"right",10)); table2.addCell(ustawfrazeAlign("do zapłaty","center",10)); table2.addCell(ustawfrazeAlign(String.valueOf(formatter.format(selected.getDozaplaty())),"right",10)); table2.addCell(ustawfrazeAlign("termin płatności","center",10)); table2.addCell(ustawfrazeAlign(selected.getTerminwplaty(),"center",10)); document.add(Chunk.NEWLINE); document.add(table0); document.add(Chunk.NEWLINE); document.add(table); document.add(Chunk.NEWLINE); document.add(table1); document.add(Chunk.NEWLINE); document.add(table2); document.add(Chunk.NEWLINE); Uz uz = wpisView.getUzer(); document.add(new Paragraph(String.valueOf(uz.getImie()+" "+uz.getNazw()),fontM)); document.add(new Paragraph("___________________________",fontM)); document.add(new Paragraph("sporządził",fontM)); document.close(); Msg.msg("i", "Wydrukowano PIT5", "form:messages"); } }
true