blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
5f61a672661a40b81a80d619d489d4fd568d57a3
13672b0f12ca2dc658c3d95d543b6af37518ca92
/src/bootcamp/demo/SwitchDemo.java
9bdfedbe599f93cce199f950029ff944bbe125b9
[]
no_license
rohatgiDivanshu/BootCampDemo
69f93c4521f6864f91d84e4d0e69b5d9161f7600
481380c68043e239ab29af8eff74d9bc8a8983e0
refs/heads/master
2020-03-29T21:42:29.829316
2018-10-04T05:14:49
2018-10-04T05:14:49
150,382,416
0
0
null
null
null
null
UTF-8
Java
false
false
539
java
package bootcamp.demo; import java.util.Scanner; public class SwitchDemo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numberOfDay = sc.nextInt(); switch (numberOfDay) { case 1: case 2: case 3: case 4: System.out.println("Monday - Thrusday"); break; case 5: case 6: case 7: System.out.println("Friday - Sunday"); } } }
[ "divanshu.rohatgi@tothenew.com" ]
divanshu.rohatgi@tothenew.com
79fd63cc8193dbd85c90017773f07d7707f9e9d5
230f46ef91aeb28c544ee6df446f9ff6b402bc15
/src/main/java/com/xero/Business/InvoiceSummary.java
7175a5843c45fe343164092fc13063d406f02700
[ "MIT" ]
permissive
kensantoso/Xero-Java
336156c0fc8f5e5fa01066798e91923af7047a06
c772a9ab7a8d471ebd3618532ae99c9838f4a342
refs/heads/master
2022-02-26T16:55:25.065693
2019-05-22T00:10:37
2019-05-22T00:10:37
null
0
0
null
null
null
null
UTF-8
Java
false
false
912
java
package com.xero.Business; import com.xero.models.accounting.Invoice; import com.xero.models.accounting.Invoices; import org.threeten.bp.LocalDate; import java.util.TreeMap; public class InvoiceSummary { private TreeMap<LocalDate, Double> summary; /** * * @param invoices Xero Invoices Model */ public InvoiceSummary(Invoices invoices) { summary = new TreeMap<LocalDate, Double>(); for (Invoice i : invoices.getInvoices()) { if (getSummary().containsKey(i.getDate())) { getSummary().put(i.getDate(), getSummary().get(i.getDate()) + i.getTotal()); } else { getSummary().put(i.getDate(), i.getTotal()); } } } /** * * @return Ordered Treemap by LocalDate and Double of total */ public TreeMap<LocalDate, Double> getSummary() { return summary; } }
[ "ken.santoso@xero.com" ]
ken.santoso@xero.com
4dcaa7689a611f44e57c247ab5b852a029f7fd5c
2be33a533b4e260738fe1b1f98ede29a789ea88e
/src/main/java/com/wp/Services/CustomerService.java
5bd534bad9544587e638c58f4cce7a8e344a8a36
[]
no_license
sadiyakhan0308/Transport-Deal-Portal
f1071392459223c06752a2e25bdd6db4fa5c3414
0a88ddc62ae8410044b75e2f8c6ffdd5f49ed770
refs/heads/master
2022-12-21T00:49:52.220533
2019-10-09T04:23:13
2019-10-09T04:23:13
213,820,491
0
0
null
2022-12-16T13:43:20
2019-10-09T04:25:16
Java
UTF-8
Java
false
false
426
java
package com.wp.Services; import java.util.List; import com.wp.Models.Customer; public interface CustomerService { public void customerEntry(Customer customer); public void deleteCustomer(String email); public Customer searchCustomer(String email); public void updateCustomer(Customer customer); public void changeCustomerDetails(Customer customer); public List<Customer> viewAllCustomers(); }
[ "jai hind@jaihind-PC" ]
jai hind@jaihind-PC
18ce5353e428b1ed94d61274e02501b7995de8e4
f2981adad612c33411fa36d049b24f5ec4e694b7
/Numbers-28.java
3fe7b0558d6feecfc8e8ca4ee3e485506057d56c
[]
no_license
Kata1213/w3resource
0557215461bbdd69e22b1a9c404da7f74e78a513
284c8304240118f9d034cde9e21a841e90982c82
refs/heads/master
2020-03-22T00:24:13.493449
2018-06-30T11:20:39
2018-06-30T11:20:39
139,242,210
0
0
null
null
null
null
UTF-8
Java
false
false
595
java
import java.util.stream.Stream; class Numbers_28 { private static boolean isHamming(int num) { if (num == 1) return true; if (num % 2 == 0) return isHamming(num / 2); if (num % 3 == 0) return isHamming(num / 3); if (num % 5 == 0) return isHamming(num / 5); return false; } public static void main(String[] args) { System.out.print("First Twenty Hamming numbers:"); Stream.iterate(1, n -> n + 1) .filter(item->isHamming(item)).limit(20) .forEach(item -> System.out.print(item + " ")); } }
[ "2726456039@qq.com" ]
2726456039@qq.com
c6eb3330a7adcc3e87c401c2088ca999f46f8bd3
83c94549bfec5c87255e768c72b5802d99d761cf
/src/main/java/org/certificatic/tarjetaDigital/service/TarjetaService.java
fa073fa5532ec2321409ac2bc9bbc5731a4ba638
[]
no_license
jessmtzhtdz/TarjetaDigital
92876b308565434bff410be4370aec9373c8ab9a
aa4f9515eabf63bbe1f2099c81fc0a3115631d13
refs/heads/master
2022-12-21T21:59:44.124620
2020-03-01T19:50:32
2020-03-01T19:50:32
244,208,262
0
0
null
2022-12-10T03:28:30
2020-03-01T19:13:07
Java
ISO-8859-2
Java
false
false
444
java
package org.certificatic.tarjetaDigital.service; import java.util.List; import javax.jws.WebService; import org.certificatic.tarjetaDigital.model.Tarjeta; @WebService public interface TarjetaService { /** * Método para crear una tarjeta nueva * @param tarjeta * @return tarjeta creada */ Tarjeta crearTarjeta(Tarjeta tarjeta); /** * Método para obtener todas las tarjetas * @return */ List<Tarjeta> obtenerTodas(); }
[ "enriquejm2504@gmail.com" ]
enriquejm2504@gmail.com
30666eb49864b966e30e84c8155bb2d458ed23b9
b13c34525a31785fd86e3bedfb82123975b2fbf9
/src/main/java/com/sunyard/emp/codegen/entity/TableEntity.java
15fc3eb6c052ea64c332f81ab6ce25b7aa9ee0ce
[]
no_license
wu305813704/DS_EMP
49b469320a02374e07d606ae2331652d1d8d0c94
c49ff57f40b13e7bfe83da7bd81a01b30d3ffb63
refs/heads/master
2023-02-26T12:48:35.658665
2021-02-04T12:34:26
2021-02-04T12:34:26
331,548,504
0
0
null
null
null
null
UTF-8
Java
false
false
537
java
package com.sunyard.emp.codegen.entity; import lombok.Data; import java.util.List; /** * @date 2018/07/29 * 表属性: https://blog.csdn.net/lkforce/article/details/79557482 */ @Data public class TableEntity { /** * 名称 */ private String tableName; /** * 备注 */ private String comments; /** * 主键 */ private ColumnEntity pk; /** * 列名 */ private List<ColumnEntity> columns; /** * 驼峰类型 */ private String caseClassName; /** * 普通类型 */ private String lowerClassName; }
[ "kangq.wu@sunyard.com" ]
kangq.wu@sunyard.com
c3d6079f121add4d3288125053a65d3559b66cb7
40a9b43877073566825b733ceb1e0c0ad7c1db93
/Regex/Introduction/Match Specific String.java
827b848a029ff0ba84f07fe9b204eb473313d657
[]
no_license
juancstlm/HackerRank
e7321b84effec9b5e77f1b88b01d8af72780f756
fb0a6b237fb5e1e0e164e6604d0223a0331ddc02
refs/heads/master
2021-04-15T09:07:54.370890
2019-01-06T06:56:22
2019-01-06T06:56:22
126,526,614
0
0
null
null
null
null
UTF-8
Java
false
false
803
java
// You have a test string . Your task is to match the string hackerrank. This is case sensitive. import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Regex_Test tester = new Regex_Test(); tester.checker("hackerrank"); } } class Regex_Test { public void checker(String Regex_Pattern){ Scanner Input = new Scanner(System.in); String Test_String = Input.nextLine(); Pattern p = Pattern.compile(Regex_Pattern); Matcher m = p.matcher(Test_String); int Count = 0; while(m.find()){ Count += 1; } System.out.format("Number of matches : %d",Count); } }
[ "juan.a.castillo@sjsu.edu" ]
juan.a.castillo@sjsu.edu
b8a6dcd21c4afbc1506a97a1b96ababeb2d9ad8a
8e79a26ee058ded3646c61ccf6657df4c1f796e2
/src/src_Solution/enclos/Cage_.java
48755d183d457049e8308ce2c298914369278d1a
[]
no_license
MaafiHanene/Design-Pattern-Project
2a9ae4a36522a8fa1ff9878f6876ec381f1865d8
dfc5e4d8e22780872c8861070942781371ecf409
refs/heads/master
2020-04-05T09:43:47.229020
2018-11-09T16:49:39
2018-11-09T16:49:39
156,771,303
1
0
null
2018-11-08T21:28:51
2018-11-08T21:28:51
null
UTF-8
Java
false
false
1,022
java
package src_Solution.enclos; import Enum.*; import src_Solution.*; import src_Solution.espece.*; import java.awt.*; import java.util.Iterator; public class Cage_ extends Enclos_ { private TypeSol typeSol; public Cage_(int id, double lng, double lrg, int max, TypeSol typesol) { super(id, lng, lrg, max); this.typeSol = typesol; // TODO Auto-generated constructor stub } public boolean marche(Animal_ a) { boolean resultat = false; if (a.getEspece() instanceof Vertebre_) { resultat = true; } Iterator<Animal_> it = animaux.iterator(); while (it.hasNext()) { if (!a.marche(it.next())) resultat = false; } return resultat; } @Override public void colorier() { PlanZoo.cases.get(this.getAdr()).setBackground(new Color(139, 69, 19)); } public String toString() { // TODO Auto-generated method stub return "Cage" + String.valueOf(identifiant); } }
[ "fh_maafi@esi.dz" ]
fh_maafi@esi.dz
68eb96afa1a837b3df5687c8b1c3871b1b2b504e
a874b11e796148aa8b84e59ba67c846e15e171d3
/src/main/java/by/gsu/epamlab/model/connection/ConnectionManager.java
c865738ff58a9e3e8b5c734589db323b1aae94b6
[]
no_license
northeim/EpamWebPrj
a6789c9b91d970c7a23acfed2cca129eade5d0c8
fa621f0b3a6ae580e372ae9132b0b790a46234f0
refs/heads/master
2021-01-22T02:57:59.824862
2017-09-08T14:16:28
2017-09-08T14:16:28
102,257,873
0
0
null
null
null
null
UTF-8
Java
false
false
1,695
java
package by.gsu.epamlab.model.connection; import by.gsu.epamlab.exeptions.DataBaseException; import java.sql.*; public class ConnectionManager { private static final String DB_DRIVER = "com.mysql.jdbc.Driver"; private static final String DB_URL = "jdbc:mysql://localhost/epamlabweb"; private static final String DB_LOGIN = "root"; private static final String DB_PASSWORD = "root"; public static Connection getConnection() { Connection connection = null; try { Class.forName(DB_DRIVER); connection = DriverManager.getConnection(DB_URL, DB_LOGIN, DB_PASSWORD); } catch (ClassNotFoundException e) { throw new DataBaseException(e.getMessage()); } catch (SQLException e) { throw new DataBaseException(e.getMessage()); } return connection; } public static void close(Connection connection) throws SQLException { if (connection != null) { connection.close(); } } public static void close(PreparedStatement... preparedStatements) throws SQLException { for (PreparedStatement prstm: preparedStatements){ if (prstm != null){ prstm.close(); } } } public static void close(Statement... statements) throws SQLException { for (Statement stm: statements) { if (stm != null) { stm.close(); } } } public static void close(ResultSet... resultSets) throws SQLException { for (ResultSet rs: resultSets) { if (rs != null) { rs.close(); } } } }
[ "fedorov_p88@mail.ru" ]
fedorov_p88@mail.ru
141ec95c4657bce35fdf14390f6dda286fce3a6b
c0dae480fb6a4430d90d53e76982feae81369842
/mebitech-web/src/main/java/com/mebitech/web/controller/user/RoleController.java
7cbbf73f726befaaf29e9383e03880396b75c97f
[]
no_license
MustafaGungor/t1core
99309df64c92115551bf0d2a08754206e067c282
93b547eaba5bbfd565d2065a4cd6de0d55c30599
refs/heads/master
2021-01-21T19:57:52.781259
2017-05-23T13:42:50
2017-05-23T13:42:50
92,178,282
0
0
null
null
null
null
UTF-8
Java
false
false
3,163
java
package com.mebitech.web.controller.user; import com.mebitech.core.api.rest.IResponseFactory; import com.mebitech.core.api.rest.enums.RestResponseStatus; import com.mebitech.core.api.rest.processors.IRoleRequestProcessor; import com.mebitech.core.api.rest.responses.IRestResponse; import com.mebitech.persistence.entities.RoleImpl; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.Date; /** * Created by tayipdemircan on 26.10.2016. */ @Controller @RequestMapping("/resources/role") public class RoleController { @Autowired private IResponseFactory responseFactory; @Autowired private IRoleRequestProcessor roleRequestProcessor; ObjectMapper objectMapper = new ObjectMapper(); @RequestMapping(value = "/add" , method = RequestMethod.PUT) @ResponseBody public IRestResponse addNewRole(@RequestBody String json){ try { RoleImpl role = objectMapper.readValue(json,RoleImpl.class); role.setCreateDate(new Date()); return roleRequestProcessor.add(role); } catch (Exception e) { e.printStackTrace(); return responseFactory.createResponse(RestResponseStatus.ERROR,"Hata : " + e.getMessage()); } } @RequestMapping(value = "/update" , method = RequestMethod.POST) @ResponseBody public IRestResponse updateRole(@RequestBody String json){ try { RoleImpl role = objectMapper.readValue(json,RoleImpl.class); return roleRequestProcessor.update(role); } catch (Exception e) { e.printStackTrace(); return responseFactory.createResponse(RestResponseStatus.ERROR,"Hata : " + e.getMessage()); } } @RequestMapping(value = "/all" , method = RequestMethod.GET) @ResponseBody public IRestResponse getAllRoles(){ try { return roleRequestProcessor.findAll(); } catch (Exception e) { e.printStackTrace(); return responseFactory.createResponse(RestResponseStatus.ERROR,"Hata : " + e.getMessage()); } } @RequestMapping(value = "/delete" , method = RequestMethod.DELETE) @ResponseBody public IRestResponse deleteRole(@RequestBody(required = false) String json, @RequestParam(value = "id", required = false) Long id){ try { if(json != null && !json.equals("")) { RoleImpl role = objectMapper.readValue(json, RoleImpl.class); return roleRequestProcessor.delete(role); }else if(id != null && id.longValue() > 0L){ return roleRequestProcessor.deleteById(id); } else { return responseFactory.createResponse(RestResponseStatus.ERROR, "Hata : Kayıt bulunamadı!!!"); } } catch (Exception e) { e.printStackTrace(); return responseFactory.createResponse(RestResponseStatus.ERROR,"Hata : " + e.getMessage()); } } }
[ "mustafa.gungor@mebitech.com" ]
mustafa.gungor@mebitech.com
94e0ae05e328022de073301c98304c94b406d83b
82b54908a3d2cc146c4404d08354ae60c4df02d5
/MVVM/src/main/java/org/jzl/android/mvvm/ViewHelper.java
e0b265a33d039f689e69c03e518414427b214c72
[]
no_license
j1046697411/UniversalAdapter
6d49d921c610b409d38bfb259614e5b42662d349
de8439a6b193b0e1ff7c9019867e0cc0653d94c0
refs/heads/master
2023-06-21T16:00:40.299002
2021-08-06T03:34:51
2021-08-06T06:52:23
388,641,702
1
0
null
null
null
null
UTF-8
Java
false
false
5,939
java
package org.jzl.android.mvvm; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.databinding.DataBindingUtil; import androidx.databinding.ViewDataBinding; import androidx.databinding.ViewStubProxy; import java.util.Objects; /** * * MVVM 核心代码,用于控制整个MVVM框架viewModel的创建,绑定、初始化,以及释放 * 以及 view层的绑定和初始化 以及释放等功能 * * @param <V> 核心的View类型 * @param <VM> 核心的ViewModel 类型 * @param <VDB> 对应页面的ViewDataBinding */ public class ViewHelper<V extends IView, VM extends IViewModel<V>, VDB extends ViewDataBinding> implements IVariableBinder, IViewModelStoreOwner { private IViewBindingHelper<V, VM> viewBindingHelper; private IExtendView<V, VM, VDB> extendView; private VDB dataBinding; private VM viewModel; /** * activity 的入口方法 * * @param activity 实现了 IExtendView 接口的activity对象 * @param savedInstanceState 保存状态对象 * @param <A> activity 的类型 */ public <A extends Activity & IExtendView<V, VM, VDB>> void setContentView(@NonNull A activity, @Nullable Bundle savedInstanceState) { perBind(activity); bind(activity, viewBindingHelper, DataBindingUtil.setContentView(activity, viewBindingHelper.getLayoutResId())); } /** * 布局绑定的入口方法,适用于需要 inflate 布局的方式实现MVVM框架 * * @param extendView 实现了 IExtendView 接口的容器对象View对象 * @param layoutInflater 布局 layoutInflater * @param parent 父节点 View * @return inflate 的 View */ public View inflate(@NonNull IExtendView<V, VM, VDB> extendView, @NonNull LayoutInflater layoutInflater, @Nullable ViewGroup parent) { perBind(extendView); VDB dataBinding = DataBindingUtil.inflate(layoutInflater, viewBindingHelper.getLayoutResId(), parent, false); bind(extendView, viewBindingHelper, dataBinding); return dataBinding.getRoot(); } /** * ViewStubProxy 对象的绑定入口方法 * * @param extendView 实现了 IExtendView 接口的容器对象View对象 * @param viewStubProxy ViewStub 代理对象 */ public void inflate(@NonNull IExtendView<V, VM, VDB> extendView, @NonNull ViewStubProxy viewStubProxy) { perBind(extendView); ViewStub viewStub = viewStubProxy.getViewStub(); Objects.requireNonNull(viewStub, "viewStub is null"); if (!viewStubProxy.isInflated()) { viewStub.setLayoutResource(viewBindingHelper.getLayoutResId()); } VDB dataBinding = DataBindingUtil.bind(viewStub.inflate()); Objects.requireNonNull(dataBinding, "dataBinding is null"); bind(extendView, viewBindingHelper, dataBinding); } /** * 绑定已经是view的MVVM框架的入口方法 * * @param extendView 实现了 IExtendView 接口的容器对象View对象 * @param view 容器的view对象 */ public void bind(@NonNull IExtendView<V, VM, VDB> extendView, @NonNull View view) { perBind(extendView); bind(extendView, viewBindingHelper, Objects.requireNonNull(DataBindingUtil.bind(view), "dataBinding is null")); } private void bind(@NonNull IExtendView<V, VM, VDB> extendView, @NonNull IViewBindingHelper<V, VM> viewBindingHelper, @NonNull VDB dataBinding) { dataBinding.setLifecycleOwner(extendView); this.dataBinding = dataBinding; this.extendView = extendView; if (extendView instanceof IPreBindingView) { ((IPreBindingView) extendView).onPreBinding(); } ViewModelProvider<V, VM> viewModelProvider = viewBindingHelper.getViewModelProvider(); this.viewModel = viewModelProvider.bindViewModel(this, extendView, dataBinding); } protected void perBind(@NonNull IExtendView<V, VM, VDB> extendView) { viewBindingHelper = extendView.createViewBindingHelper(new ViewBindingHelperFactory()); } @Override public void bindVariable(int variableId, @Nullable Object value) { if (value instanceof IBindVariableOwner) { this.dataBinding.setVariable(variableId, ((IBindVariableOwner) value).getBindVariableValue()); } else { this.dataBinding.setVariable(variableId, value); } } @NonNull public IViewBindingHelper<V, VM> getViewBindingHelper() { return viewBindingHelper; } @NonNull public V getView() { return viewBindingHelper.getView(); } @NonNull public VDB getViewDataBinding() { return dataBinding; } @NonNull public VM getViewModel() { return viewModel; } @NonNull public IViewModelFactory getViewModelFactory() { return viewBindingHelper.getViewModelFactory(); } @Override public IViewModelStore getSelfViewModelStore() { return viewBindingHelper.getRealViewModelStore(extendView); } /** * * @return */ @NonNull public IViewModelProvider getViewModelProvider() { return viewBindingHelper.getViewModelProvider(); } /** * 创建 viewModel 时,只传入了 viewModelType 时生成key的方法 * * @param viewModel ViewModel 类型 * @return 生成的key */ public String generateViewModelKey(Class<?> viewModel) { return viewModel.getSimpleName(); } /** * view 容器释放时调用的方法 */ public void unbind() { viewBindingHelper.unbind(); dataBinding.unbind(); extendView.unbind(); } }
[ "1046697411@qq.com" ]
1046697411@qq.com
483be09fe9d6074649126f7944eaa37998739d66
afdbe830791bf07b618bdbe518c428a2f270a175
/Furniture/client/controllers/ProfitController.java
8f438d89b75540dc11a91975f2646759342064da
[]
no_license
BorovikAlex/JavaFX
2e45aef2c642617b81f461d0c7f16af543fcd7bf
5b6d1f98fac5cff8ebbba020bd8cb2e591206a7d
refs/heads/master
2020-12-22T23:30:20.254480
2020-03-27T14:10:20
2020-03-27T14:10:20
236,963,566
0
0
null
null
null
null
UTF-8
Java
false
false
5,321
java
package client.controllers; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.ResourceBundle; import client.entityClass.Profit; import client.sample.AlertWindow; import client.sample.Client; import client.sample.ClientInstance; import client.sceneLoaders.SceneLoaderInstance; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; import javafx.stage.FileChooser; import javafx.stage.Stage; public class ProfitController { @FXML private Button backButton; @FXML private TableView<Profit> profitTable; @FXML private TableColumn<Profit, Integer> idColumn; @FXML private TableColumn<Profit, String> firmColumn; @FXML private TableColumn<Profit, String> furnitureColumn; @FXML private TableColumn<Profit, String> materialColumn; @FXML private TableColumn<Profit, Double> costsColumn; @FXML private TableColumn<Profit, Double> priceColumn; @FXML private TableColumn<Profit, Double> profitColumn; @FXML private Button addB; @FXML private Button setB; @FXML private TextField search; public void initialize() { Client client = ClientInstance.INSTANCE.getInstance(); client.connect(); fillTableView(); search.textProperty().addListener(( observable, oldValue, newValue)-> filterList(oldValue, newValue)); } public void fillTableView() { ClientInstance.INSTANCE.getInstance().send("getProfit"); ArrayList<String> list = ClientInstance.INSTANCE.getInstance().receiveResultList(); ObservableList<Profit> information = FXCollections.observableArrayList(); String[] infoString; for (int i = 0; i < list.size(); i++) { infoString = list.get(i).split(" ", 8); Profit profit = new Profit(); profit.setId_profit(Integer.valueOf(infoString[0])); profit.setFirm(infoString[1]); profit.setFurniture(infoString[2]); profit.setMaterial(infoString[3]); profit.setCosts(Double.valueOf(infoString[4])); profit.setPrice(Double.valueOf(infoString[5])); profit.setProfit(Double.valueOf(infoString[6])); information.add(profit); } idColumn.setCellValueFactory(new PropertyValueFactory<>("id_profit")); firmColumn.setCellValueFactory(new PropertyValueFactory<>("firm")); furnitureColumn.setCellValueFactory(new PropertyValueFactory<>("furniture")); materialColumn.setCellValueFactory(new PropertyValueFactory<>("material")); costsColumn.setCellValueFactory(new PropertyValueFactory<>("costs")); priceColumn.setCellValueFactory(new PropertyValueFactory<>("price")); profitColumn.setCellValueFactory(new PropertyValueFactory<>("profit")); profitTable.setItems(information); } public void filterList(String oldValue, String newValue) { ObservableList<Profit> filteredList = FXCollections.observableArrayList(); if (search == null || (newValue.length() < oldValue.length() || newValue == null)) { fillTableView(); } else { newValue = newValue.toUpperCase(); for (Profit profit : profitTable.getItems()) { String filter = profit.getFurniture(); if (filter.toUpperCase().contains(newValue) || filter.toUpperCase().contains(newValue)) { filteredList.add(profit); } } profitTable.setItems(filteredList); } } public void saveToFile() { Stage stage = new Stage(); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Сохранить в файл"); File file = fileChooser.showSaveDialog(stage); if (file != null) { try { BufferedWriter outWriter = new BufferedWriter(new FileWriter(file)); for (Profit profit : profitTable.getItems()) { outWriter.write(profit.toString()); outWriter.newLine(); } outWriter.close(); } catch (IOException e) { AlertWindow.display("Ошибка записи в файл!"); } } } @FXML void add() { addB.getScene().getWindow().hide(); SceneLoaderInstance.INSTANCE.getInstance().loadScene("addProfit", ""); } @FXML void set() { setB.getScene().getWindow().hide(); SceneLoaderInstance.INSTANCE.getInstance().loadScene("setProfit", ""); } @FXML void back() { backButton.getScene().getWindow().hide(); SceneLoaderInstance.INSTANCE.getInstance().loadScene("adminMenu", ""); } }
[ "noreply@github.com" ]
noreply@github.com
478d392004b3a0d438d5f3410120325c03d37a27
447520f40e82a060368a0802a391697bc00be96f
/apks/comparison_androart/at_spardat_bcrmobile/source/com/google/android/gms/common/internal/zzaf.java
937ea7a4cc5815e131910fffa19fdc3d291bde8d
[ "Apache-2.0" ]
permissive
iantal/AndroidPermissions
7f3343a9c29d82dbcd4ecd98b3a50ddf8d179465
d623b732734243590b5f004d167e542e2e2ae249
refs/heads/master
2023-07-19T01:29:26.689186
2019-09-30T19:01:42
2019-09-30T19:01:42
107,239,248
0
0
Apache-2.0
2023-07-16T07:41:38
2017-10-17T08:22:57
null
UTF-8
Java
false
false
1,433
java
package com.google.android.gms.common.internal; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable.Creator; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.internal.safeparcel.zza; public class zzaf extends zza { public static final Parcelable.Creator<zzaf> CREATOR = new f(); final int a; IBinder b; private ConnectionResult c; private boolean d; private boolean e; zzaf(int paramInt, IBinder paramIBinder, ConnectionResult paramConnectionResult, boolean paramBoolean1, boolean paramBoolean2) { this.a = paramInt; this.b = paramIBinder; this.c = paramConnectionResult; this.d = paramBoolean1; this.e = paramBoolean2; } public final ai a() { return aj.a(this.b); } public final ConnectionResult b() { return this.c; } public final boolean c() { return this.d; } public final boolean d() { return this.e; } public boolean equals(Object paramObject) { if (this == paramObject) {} do { return true; if (!(paramObject instanceof zzaf)) { return false; } paramObject = (zzaf)paramObject; } while ((this.c.equals(paramObject.c)) && (aj.a(this.b).equals(aj.a(paramObject.b)))); return false; } public void writeToParcel(Parcel paramParcel, int paramInt) { f.a(this, paramParcel, paramInt); } }
[ "antal.micky@yahoo.com" ]
antal.micky@yahoo.com
e4f739f4f973ea3c4969573900a7a70c7ce7fd35
fb94bf2f79e8ad93b3c1880a826d7bf4d82b180b
/ch12_Ex/a_test2.java
0f97f2a18123bceea93f0321e2da457decf0f9df
[]
no_license
kim-kiwon/Java_Jeongseok
eeda0b3c6233129cbce9f46b5c8afcf3f3eebcb9
d925092fe84818be5d89095cdbf8c847601bc8cc
refs/heads/master
2023-02-25T01:40:34.162814
2021-02-03T13:46:15
2021-02-03T13:46:15
334,135,896
0
0
null
null
null
null
UTF-8
Java
false
false
885
java
import java.util.*; class Book {} class Note extends Book {} public class a_test2 { public static void main(String[] args) { ArrayList<Book> list = new ArrayList<Book>(); //참조변수 타입과. 생성자 타입은 기본적으로 같다. 다형성도 안됨. 일치해야함. //지네릭 클래스간 다형성은 성립 //List<Book> list = new ArrayList<Book>(); list.add(new Note()); //list.add(new Audio()); //매개변수의 다형성은 성립. //지네릭스가 Book인 ArrayList list에. 그 자손인 Note 객체 add 가능. //즉 클래스와 매개변수 다형성은 지네릭스 써도 성립 //타입 변수를 Object를 하면 모든 객체를 담을 수 있는 이유 Book t = list.get(0); //원래 반환형 Object. //지네릭스 덕에 반환형이 타입변수에 넣어준 Book이됨. //형변환 필요없다. } }
[ "76721493+kim-kiwon@users.noreply.github.com" ]
76721493+kim-kiwon@users.noreply.github.com
7e4f72d116583e80d90ff6f48944e5be800ac78c
4cb77b58bc6dfdf8e69240b9e4289b05c2d62144
/src/main/java/org/solteam/stellar/xdr/ChangeTrustResultCode.java
58a1f9d7dada09e4f3d4568e8da7aa16dd090ae8
[ "MIT" ]
permissive
lman/stellar-sdk
df380bcd2022e6830013473724efedaa04458fee
32cdac0a923263c0c1f84e58a116a4be56e81bbf
refs/heads/master
2021-04-12T11:35:04.025507
2018-09-24T14:05:19
2018-09-24T14:05:19
126,353,409
0
0
MIT
2018-09-27T08:28:46
2018-03-22T15:09:22
Java
UTF-8
Java
false
false
1,979
java
// Automatically generated by xdrgen // DO NOT EDIT or your changes may be overwritten package org.solteam.stellar.xdr; import java.io.IOException; // === xdr source ============================================================ // enum ChangeTrustResultCode // { // // codes considered as "success" for the operation // CHANGE_TRUST_SUCCESS = 0, // // codes considered as "failure" for the operation // CHANGE_TRUST_MALFORMED = -1, // bad input // CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer // CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance // // cannot create with a limit of 0 // CHANGE_TRUST_LOW_RESERVE = -4, // not enough funds to create a new trust line, // CHANGE_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed // }; // =========================================================================== public enum ChangeTrustResultCode { CHANGE_TRUST_SUCCESS(0), CHANGE_TRUST_MALFORMED(-1), CHANGE_TRUST_NO_ISSUER(-2), CHANGE_TRUST_INVALID_LIMIT(-3), CHANGE_TRUST_LOW_RESERVE(-4), CHANGE_TRUST_SELF_NOT_ALLOWED(-5), ; private int mValue; ChangeTrustResultCode(int value) { mValue = value; } public int getValue() { return mValue; } static ChangeTrustResultCode decode(XdrDataInputStream stream) throws IOException { int value = stream.readInt(); switch (value) { case 0: return CHANGE_TRUST_SUCCESS; case -1: return CHANGE_TRUST_MALFORMED; case -2: return CHANGE_TRUST_NO_ISSUER; case -3: return CHANGE_TRUST_INVALID_LIMIT; case -4: return CHANGE_TRUST_LOW_RESERVE; case -5: return CHANGE_TRUST_SELF_NOT_ALLOWED; default: throw new RuntimeException("Unknown enum value: " + value); } } static void encode(XdrDataOutputStream stream, ChangeTrustResultCode value) throws IOException { stream.writeInt(value.getValue()); } }
[ "vadim.lman@gmail.com" ]
vadim.lman@gmail.com
e12d1ea8c9fa61d52740d5ec901e2bb8376ac4c9
bf2966abae57885c29e70852243a22abc8ba8eb0
/aws-java-sdk-workmail/src/main/java/com/amazonaws/services/workmail/model/ListMailboxPermissionsRequest.java
0a50747638491c330fe3f5d81adb467c37fed1bb
[ "Apache-2.0" ]
permissive
kmbotts/aws-sdk-java
ae20b3244131d52b9687eb026b9c620da8b49935
388f6427e00fb1c2f211abda5bad3a75d29eef62
refs/heads/master
2021-12-23T14:39:26.369661
2021-07-26T20:09:07
2021-07-26T20:09:07
246,296,939
0
0
Apache-2.0
2020-03-10T12:37:34
2020-03-10T12:37:33
null
UTF-8
Java
false
false
9,243
java
/* * Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.workmail.model; import java.io.Serializable; import javax.annotation.Generated; import com.amazonaws.AmazonWebServiceRequest; /** * * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/workmail-2017-10-01/ListMailboxPermissions" target="_top">AWS * API Documentation</a> */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class ListMailboxPermissionsRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable { /** * <p> * The identifier of the organization under which the user, group, or resource exists. * </p> */ private String organizationId; /** * <p> * The identifier of the user, group, or resource for which to list mailbox permissions. * </p> */ private String entityId; /** * <p> * The token to use to retrieve the next page of results. The first call does not contain any tokens. * </p> */ private String nextToken; /** * <p> * The maximum number of results to return in a single call. * </p> */ private Integer maxResults; /** * <p> * The identifier of the organization under which the user, group, or resource exists. * </p> * * @param organizationId * The identifier of the organization under which the user, group, or resource exists. */ public void setOrganizationId(String organizationId) { this.organizationId = organizationId; } /** * <p> * The identifier of the organization under which the user, group, or resource exists. * </p> * * @return The identifier of the organization under which the user, group, or resource exists. */ public String getOrganizationId() { return this.organizationId; } /** * <p> * The identifier of the organization under which the user, group, or resource exists. * </p> * * @param organizationId * The identifier of the organization under which the user, group, or resource exists. * @return Returns a reference to this object so that method calls can be chained together. */ public ListMailboxPermissionsRequest withOrganizationId(String organizationId) { setOrganizationId(organizationId); return this; } /** * <p> * The identifier of the user, group, or resource for which to list mailbox permissions. * </p> * * @param entityId * The identifier of the user, group, or resource for which to list mailbox permissions. */ public void setEntityId(String entityId) { this.entityId = entityId; } /** * <p> * The identifier of the user, group, or resource for which to list mailbox permissions. * </p> * * @return The identifier of the user, group, or resource for which to list mailbox permissions. */ public String getEntityId() { return this.entityId; } /** * <p> * The identifier of the user, group, or resource for which to list mailbox permissions. * </p> * * @param entityId * The identifier of the user, group, or resource for which to list mailbox permissions. * @return Returns a reference to this object so that method calls can be chained together. */ public ListMailboxPermissionsRequest withEntityId(String entityId) { setEntityId(entityId); return this; } /** * <p> * The token to use to retrieve the next page of results. The first call does not contain any tokens. * </p> * * @param nextToken * The token to use to retrieve the next page of results. The first call does not contain any tokens. */ public void setNextToken(String nextToken) { this.nextToken = nextToken; } /** * <p> * The token to use to retrieve the next page of results. The first call does not contain any tokens. * </p> * * @return The token to use to retrieve the next page of results. The first call does not contain any tokens. */ public String getNextToken() { return this.nextToken; } /** * <p> * The token to use to retrieve the next page of results. The first call does not contain any tokens. * </p> * * @param nextToken * The token to use to retrieve the next page of results. The first call does not contain any tokens. * @return Returns a reference to this object so that method calls can be chained together. */ public ListMailboxPermissionsRequest withNextToken(String nextToken) { setNextToken(nextToken); return this; } /** * <p> * The maximum number of results to return in a single call. * </p> * * @param maxResults * The maximum number of results to return in a single call. */ public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; } /** * <p> * The maximum number of results to return in a single call. * </p> * * @return The maximum number of results to return in a single call. */ public Integer getMaxResults() { return this.maxResults; } /** * <p> * The maximum number of results to return in a single call. * </p> * * @param maxResults * The maximum number of results to return in a single call. * @return Returns a reference to this object so that method calls can be chained together. */ public ListMailboxPermissionsRequest withMaxResults(Integer maxResults) { setMaxResults(maxResults); return this; } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getOrganizationId() != null) sb.append("OrganizationId: ").append(getOrganizationId()).append(","); if (getEntityId() != null) sb.append("EntityId: ").append(getEntityId()).append(","); if (getNextToken() != null) sb.append("NextToken: ").append(getNextToken()).append(","); if (getMaxResults() != null) sb.append("MaxResults: ").append(getMaxResults()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListMailboxPermissionsRequest == false) return false; ListMailboxPermissionsRequest other = (ListMailboxPermissionsRequest) obj; if (other.getOrganizationId() == null ^ this.getOrganizationId() == null) return false; if (other.getOrganizationId() != null && other.getOrganizationId().equals(this.getOrganizationId()) == false) return false; if (other.getEntityId() == null ^ this.getEntityId() == null) return false; if (other.getEntityId() != null && other.getEntityId().equals(this.getEntityId()) == false) return false; if (other.getNextToken() == null ^ this.getNextToken() == null) return false; if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false) return false; if (other.getMaxResults() == null ^ this.getMaxResults() == null) return false; if (other.getMaxResults() != null && other.getMaxResults().equals(this.getMaxResults()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getOrganizationId() == null) ? 0 : getOrganizationId().hashCode()); hashCode = prime * hashCode + ((getEntityId() == null) ? 0 : getEntityId().hashCode()); hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode()); hashCode = prime * hashCode + ((getMaxResults() == null) ? 0 : getMaxResults().hashCode()); return hashCode; } @Override public ListMailboxPermissionsRequest clone() { return (ListMailboxPermissionsRequest) super.clone(); } }
[ "" ]
2e17f677c36bcf894ee15a55be18bbd930cf0d30
17c711e58b29ce91cc1068d7ff459de2fef3df3b
/src/com/jhlabs/image/WeaveFilter.java
d525d76d3669585f755d53e0de1876b284f7d677
[]
no_license
mdu314/DrawLine
f6650ebaf892ecb79d71eca8bd6304f2c9a30e6d
cb8ebf057cbdebdceb7850659d5665e42af3e7fc
refs/heads/master
2021-07-03T19:08:58.924812
2020-09-18T14:39:59
2020-09-18T14:39:59
20,884,439
1
0
null
null
null
null
UTF-8
Java
false
false
4,366
java
/* Copyright 2006 Jerry Huxtable 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.jhlabs.image; public class WeaveFilter extends PointFilter { private final int cols = 4; public int[][] matrix = { { 0, 1, 0, 1 }, { 1, 0, 1, 0 }, { 0, 1, 0, 1 }, { 1, 0, 1, 0 }, }; private final int rgbX = 0xffff8080; private final int rgbY = 0xff8080ff; private boolean roundThreads = false; private final int rows = 4; private boolean shadeCrossings = true; private boolean useImageColors = true; private float xGap = 6; private float xWidth = 16; private float yGap = 6; private float yWidth = 16; public WeaveFilter() { } @Override public int filterRGB(int x, int y, int rgb) { x += xWidth + xGap / 2; y += yWidth + yGap / 2; final float nx = ImageMath.mod(x, xWidth + xGap); final float ny = ImageMath.mod(y, yWidth + yGap); final int ix = (int) (x / (xWidth + xGap)); final int iy = (int) (y / (yWidth + yGap)); final boolean inX = nx < xWidth; final boolean inY = ny < yWidth; float dX, dY; float cX, cY; int lrgbX, lrgbY; if (roundThreads) { dX = Math.abs(xWidth / 2 - nx) / xWidth / 2; dY = Math.abs(yWidth / 2 - ny) / yWidth / 2; } else dX = dY = 0; if (shadeCrossings) { cX = ImageMath.smoothStep(xWidth / 2, xWidth / 2 + xGap, Math.abs(xWidth / 2 - nx)); cY = ImageMath.smoothStep(yWidth / 2, yWidth / 2 + yGap, Math.abs(yWidth / 2 - ny)); } else cX = cY = 0; if (useImageColors) lrgbX = lrgbY = rgb; else { lrgbX = rgbX; lrgbY = rgbY; } int v; final int ixc = ix % cols; final int iyr = iy % rows; final int m = matrix[iyr][ixc]; if (inX) { if (inY) { v = m == 1 ? lrgbX : lrgbY; v = ImageMath.mixColors(2 * (m == 1 ? dX : dY), v, 0xff000000); } else { if (shadeCrossings) if (m != matrix[(iy + 1) % rows][ixc]) { if (m == 0) cY = 1 - cY; cY *= 0.5f; lrgbX = ImageMath.mixColors(cY, lrgbX, 0xff000000); } else if (m == 0) lrgbX = ImageMath.mixColors(0.5f, lrgbX, 0xff000000); v = ImageMath.mixColors(2 * dX, lrgbX, 0xff000000); } } else if (inY) { if (shadeCrossings) if (m != matrix[iyr][(ix + 1) % cols]) { if (m == 1) cX = 1 - cX; cX *= 0.5f; lrgbY = ImageMath.mixColors(cX, lrgbY, 0xff000000); } else if (m == 1) lrgbY = ImageMath.mixColors(0.5f, lrgbY, 0xff000000); v = ImageMath.mixColors(2 * dY, lrgbY, 0xff000000); } else v = 0x00000000; return v; } public int[][] getCrossings() { return matrix; } public boolean getRoundThreads() { return roundThreads; } public boolean getShadeCrossings() { return shadeCrossings; } public boolean getUseImageColors() { return useImageColors; } public float getXGap() { return xGap; } public float getXWidth() { return xWidth; } public float getYGap() { return yGap; } public float getYWidth() { return yWidth; } public void setCrossings(int[][] matrix) { this.matrix = matrix; } public void setRoundThreads(boolean roundThreads) { this.roundThreads = roundThreads; } public void setShadeCrossings(boolean shadeCrossings) { this.shadeCrossings = shadeCrossings; } public void setUseImageColors(boolean useImageColors) { this.useImageColors = useImageColors; } public void setXGap(float xGap) { this.xGap = xGap; } public void setXWidth(float xWidth) { this.xWidth = xWidth; } public void setYGap(float yGap) { this.yGap = yGap; } public void setYWidth(float yWidth) { this.yWidth = yWidth; } @Override public String toString() { return "Texture/Weave..."; } }
[ "mdurocher@free.fr" ]
mdurocher@free.fr
1df01959c0559c06b74d44ffc0bcad76968dd4b6
8f2e9b91b6bfe9c70135673a8ddf69519813d835
/dubbo-consumer/src/main/java/tech/liuxiaogang/dubbo/consumer/HelloController.java
8dc4d4a73b36aef2c5b65cbf18a202d1c80d88c1
[ "Apache-2.0" ]
permissive
summerHearts/spring_boot_dubbo_example
c2298fd349b11434f0b505ad2d9f5ca7933b38f8
5bbc464550b16e087813ccb28771debe4a5a6eeb
refs/heads/master
2021-05-11T03:49:56.265585
2016-11-25T01:51:56
2016-11-25T01:51:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
626
java
package tech.liuxiaogang.dubbo.consumer; import tech.liuxiaogang.dubbo.api.service.HelloService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** * Created by liuxiaogang on 2016/7/10. */ @RestController public class HelloController { @Autowired private HelloService helloService; @RequestMapping("/index") @ResponseBody public String run() { return helloService.sayHello("dubbo"); } }
[ "15986754905@126.com" ]
15986754905@126.com
573a19e090325233614136163e74f0970bd22823
5c05c0af04ee5625ba98d864fef05e3d46c85b7a
/common/src/main/java/com/sinjinsong/icourse/common/util/MapUtil.java
ab42370e6d6a1131f19ec06221c8bd3fc05947fe
[]
no_license
songxinjianqwe/iCourse
43e556d54349eb356c22952fd6369541d3f51b21
d6e585b41b7d38eb5998ea830fdd0f09ee2f0811
refs/heads/master
2020-03-08T08:18:54.247518
2018-07-09T12:37:49
2018-07-09T12:37:49
128,019,594
0
0
null
null
null
null
UTF-8
Java
false
false
497
java
package com.sinjinsong.icourse.common.util; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Created by SinjinSong on 2017/3/19. */ public final class MapUtil { private MapUtil(){} public static <K,V> void putMultiValue(Map<K,List<V>> map, K k, V v){ if(map.get(k) == null){ List<V> values = new ArrayList<V>(); values.add(v); map.put(k,values); }else{ map.get(k).add(v); } } }
[ "songxinjianzx@163.com" ]
songxinjianzx@163.com
1abfd977b7598682bbc1e67ccfb050ac1ce78e0c
027b42368e671d4ccb244a4a816ad26b455919f2
/app/src/main/java/com/yadong/pattern/behavioral/chain_of_responsibility/Course.java
82c6edb2e2cdf5c448bc0a96fae8682ab620324d
[]
no_license
ydstar/DesignPattern
de38fc9260ea2a6b2c950e8fda72e8fc4da46e50
42f77a4807b058ed5e5f4365e736809d88061cc3
refs/heads/master
2022-04-19T12:30:09.050210
2020-04-16T02:15:26
2020-04-16T02:15:26
138,538,416
19
9
null
null
null
null
UTF-8
Java
false
false
833
java
package com.yadong.pattern.behavioral.chain_of_responsibility; /** *课程 */ public class Course { private String name; private String article; private String video; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getArticle() { return article; } public void setArticle(String article) { this.article = article; } public String getVideo() { return video; } public void setVideo(String video) { this.video = video; } @Override public String toString() { return "Course{" + "name='" + name + '\'' + ", article='" + article + '\'' + ", video='" + video + '\'' + '}'; } }
[ "hydznsqk@163.com" ]
hydznsqk@163.com
d69e09d2a06c56cd8c7b5a0dbda0cb105cd8c12e
a20cc53efe1b7323cc262f7c94e53aceb11401a4
/bean/QuestionBankFillBean.java
91a344c0ba2959825010d2d19810a601339338ac
[]
no_license
WayneLizhi/onlineEaxmSystem
47bbc50b74dad7705367ed880c38e1eab68ada31
043fce0a03fb3e16f875dfec5d10a0bb8ca50dcb
refs/heads/master
2020-04-14T23:34:02.161883
2019-01-05T12:04:07
2019-01-05T12:04:07
164,207,052
0
0
null
2019-01-05T11:14:11
2019-01-05T11:04:02
null
UTF-8
Java
false
false
841
java
package com.online_examination_system.bean; public class QuestionBankFillBean { private int id; private String question; private String answer; private String teachername; private int courseid; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getQuestion() { return question; } public void setQuestion(String question) { this.question = question; } public String getAnswer() { return answer; } public void setAnswer(String answer) { this.answer = answer; } public String getTeachername() { return teachername; } public void setTeachername(String teachername) { this.teachername = teachername; } public int getCourseid() { return courseid; } public void setCourseid(int courseid) { this.courseid = courseid; } }
[ "noreply@github.com" ]
noreply@github.com
e93df63c8070caacabdfdfee1235170cb1bd37ed
d9e08dee5ce6a44c5ea509f75751e89094849458
/boot-activemq-topic-consumer/src/main/java/com/yyong/activemq/consumer/test/QueueConsumer.java
2f0bc816cfff092170572b6b5f62f07794ce40e1
[]
no_license
yongyong849876282/wangyong
90b80723201b2a73b91ff46aaf8a7f001d6699fe
47ae50f2f497f0ed23b8a127baa574b80fc97eb4
refs/heads/master
2022-07-08T11:40:31.507249
2019-11-28T10:19:02
2019-11-28T10:19:02
224,119,622
0
0
null
2022-07-06T20:44:20
2019-11-26T06:34:01
Java
UTF-8
Java
false
false
432
java
package com.yyong.activemq.consumer.test; import org.springframework.jms.annotation.JmsListener; import org.springframework.stereotype.Component; import javax.jms.TextMessage; @Component public class QueueConsumer { @JmsListener(destination = "${mytopic}") public void receive(TextMessage textMessage)throws Exception{ System.out.println("****消费者收到订阅的主题:"+ textMessage.getText()); } }
[ "wy849876282" ]
wy849876282
8736b21089be184a3e711dea47ae3b351f4d5cc1
8ecfbd90cc2c4a15b7f2301119f486cc1cfd9740
/DemoSlk/src/com/slk/task13/Synchronization/SynchronizedBlockMain.java
2b96504df81656f672c8092f7597cf3df20b0602
[]
no_license
tarunpatel2982/DemoSlk
1f06e48e2a3f582d5ef0bacfcdb496b52c427c04
f7959ee3028a017eed847a0da5f0a898a0b052b8
refs/heads/master
2020-12-05T15:51:53.626047
2020-03-04T10:14:00
2020-03-04T10:14:00
232,162,100
0
0
null
null
null
null
UTF-8
Java
false
false
419
java
package com.slk.task13.Synchronization; public class SynchronizedBlockMain { public static void main(String[] args) { // TODO Auto-generated method stub final Table2 table2 =new Table2(); SynchronizedBlock1 synchronizedBlock1 = new SynchronizedBlock1(table2); SynchronizedBlock2 synchronizedBlock2 =new SynchronizedBlock2(table2); synchronizedBlock1.start(); synchronizedBlock2.start(); } }
[ "tarun.patel@C069" ]
tarun.patel@C069
4985b2fc2ce0eb8f8f38b0d7df90adbf6d24ed50
5c7f0767ee6663b6d03b014535399d54b1e816c5
/src/org/turnerha/environment/RealEnvironment.java
053aead76c39dfd25550d545f9071b86bfb5e9a5
[]
no_license
hamiltont/Empower
6c099c6f1150ce9a98aeec00a3b75166515c4daa
9e7b62c4e1924f3dc0fdba0351b93504cbad2710
refs/heads/master
2021-01-15T11:49:21.744758
2011-04-13T19:28:34
2011-04-13T19:28:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package org.turnerha.environment; // For now this is just a placeholder public interface RealEnvironment extends Environment { }
[ "hamiltont@gmail.com" ]
hamiltont@gmail.com
b52656e4018b1b91504e78b7ee65e7aa7a92e4ce
aa047f0494e73d022077248f807217258e1d1d0d
/tzhehe/5-22/demo_sqlite/src/com/tz/sqlite/dao/StudentService.java
5bb20e256959595aaf5fa062b531a60ac570872f
[]
no_license
AbnerChenyi/April_PublicWork
1412bd482113e3bb8729132e14964e0572297f14
5a75c3a8314becf5fe53485f7690c2fad75ab004
refs/heads/master
2021-01-22T13:13:55.540762
2015-07-08T10:11:48
2015-07-08T10:11:48
null
0
0
null
null
null
null
GB18030
Java
false
false
1,009
java
package com.tz.sqlite.dao; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.tz.sqlite.entity.Student; public class StudentService extends BaseDao<Student> { public StudentService(SQLiteDatabase db) { super(db,"Student"); } public void createTable(){ String sb="create table Student ( _id int ,_name varchar(20))"; db.execSQL(sb); } //查询所有学生 public List<Student> qureyAll(){ List<Student> students = new ArrayList<Student>(); Cursor cursor = db.rawQuery("select * from student", null); Student student; while(cursor.moveToNext()){ //每查到一个学生 student = new Student(); String name = cursor.getString(cursor.getColumnIndex("_name")); student.set_name(name); int _id = cursor.getInt(cursor.getColumnIndex("_id")); student.set_id(_id); students.add(student); } return students; } }
[ "158905138@qq.com" ]
158905138@qq.com
ba6229186a052c0ac206f8bdd71bfb15a6395d2c
69aec546718d2fea09420b777ec720ac1632e25d
/src/main/java/com/teccsoluction/hermeticum/controle/PdvController.java
854233b67e8c7c576896b1e5d03bbc93b322ed62
[]
no_license
windsonleo/hermeticum
3338a39377d05e25a0f4189733957e73b9f79127
c0a55f25273b154abaafab4718a02a25c81b63eb
refs/heads/master
2020-03-11T15:24:37.978683
2018-04-23T14:47:20
2018-04-23T14:47:20
130,083,386
0
0
null
null
null
null
UTF-8
Java
false
false
26,683
java
package com.teccsoluction.hermeticum.controle; import java.io.IOException; import java.math.BigDecimal; import java.net.URL; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.ResourceBundle; import org.controlsfx.control.textfield.TextFields; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Controller; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXTextField; import com.teccsoluction.hermeticum.conf.StageManager; import com.teccsoluction.hermeticum.entidade.Cliente; import com.teccsoluction.hermeticum.entidade.Empresa; import com.teccsoluction.hermeticum.entidade.Estoque; import com.teccsoluction.hermeticum.entidade.Item; import com.teccsoluction.hermeticum.entidade.PedidoVenda; import com.teccsoluction.hermeticum.entidade.Produto; import com.teccsoluction.hermeticum.entidade.Usuario; import com.teccsoluction.hermeticum.servico.ClienteServicoImpl; import com.teccsoluction.hermeticum.servico.EmpresaServicoImpl; import com.teccsoluction.hermeticum.servico.EstoqueServicoImpl; import com.teccsoluction.hermeticum.servico.ItemServicoImpl; import com.teccsoluction.hermeticum.servico.PedidoVendaServicoImpl; import com.teccsoluction.hermeticum.servico.ProdutoServicoImpl; import com.teccsoluction.hermeticum.servico.UsuarioServicoImpl; import com.teccsoluction.hermeticum.util.SituacaoItem; import com.teccsoluction.hermeticum.util.StatusPedido; import com.teccsoluction.hermeticum.view.FxmlView; import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; 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.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.Dialog; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.PasswordField; import javafx.scene.control.SelectionMode; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.effect.DropShadow; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; import javafx.scene.paint.Color; import javafx.scene.paint.ImagePattern; import javafx.scene.shape.Circle; import javafx.stage.Modality; import javafx.stage.Popup; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Pair; import lombok.Getter; import lombok.Setter; @Getter @Setter @Controller public class PdvController implements Initializable{ @Autowired private EmpresaServicoImpl empresaService; @Autowired private UsuarioServicoImpl usuarioService; @Autowired private ItemServicoImpl itemService; @Autowired private EstoqueServicoImpl estoqueService; // @Autowired // private CaixaServicoImpl caixaService; @Autowired private ProdutoServicoImpl ProdutoService; @Autowired private PedidoVendaServicoImpl PedidoVendaService; @Autowired private ClienteServicoImpl ClienteService; @Lazy @Autowired private StageManager stageManager; @FXML private JFXButton btempresa; @FXML private JFXButton btfuncionario; @FXML private JFXButton btcliente; @FXML private JFXButton btfornecedor; @FXML private JFXButton btcategoria; @FXML private JFXButton btproduto; @FXML private JFXButton btconfiguracao; @FXML private JFXButton btcompras; @FXML private JFXButton btvendas; @FXML private JFXButton btestoque; @FXML private JFXButton btpdv; @FXML private JFXButton btusuario; @FXML private JFXButton btfinanceiro; @FXML private JFXButton bttrocarusuario; @FXML private JFXButton bteditarusuario; @FXML private JFXButton btexit; @FXML private Label txthora; @FXML private Label txtcontext; @FXML private JFXButton btaddcliente; @FXML private JFXButton btabrecupom; @FXML private JFXButton btcancelacupom; @FXML private JFXButton btcancelaitem; @FXML private JFXButton btencerracaixa; @FXML private JFXButton btpesquisaproduto; @FXML private JFXButton btalteraquantidade; @FXML private JFXButton btreimprimir; @FXML private JFXButton btfinalizavenda; @FXML private JFXButton bttrocaroperador; private Usuario usuarioUp; private Empresa empresaUp; @FXML private Label empresanome; // @FXML // private Label empresadata; @FXML private Image imgsempresa; @FXML private ImageView imgviewempresa; // @FXML // private Label nomeusuario; @FXML private Image imgsusuario; @FXML private ImageView imgviewusuario; @FXML private MenuItem sair; @FXML private Circle circulo; @FXML private Circle circuloemp; @FXML private JFXButton additem; @FXML private TextField codigobarra; @FXML private TextField qtd; @FXML private JFXTextField descricao; @FXML private JFXTextField valorunitario; @FXML private JFXTextField valortotal; @FXML private JFXTextField totalitems ; @FXML private JFXTextField totalvenda; private PedidoVenda pv ; // private ObservableList<Map.Entry<Item, String>> itemList; private ObservableList<Item> itemList; @FXML private TableView<Item> cupomtabela ; // // @FXML // private TableColumn<Item, Long> colItemId; @FXML private TableColumn<Item, String> colItemCode; @FXML private TableColumn<Item, String> colItemDescricao; @FXML private TableColumn<Item, String> colItemQtd; @FXML private TableColumn<Item, String> colItemValorUnitario; @FXML private TableColumn<Item, String> colItemValorTotal; @FXML private Label retorno; private Cliente clientecupom; @FXML private Label cupomnome; @FXML private Label cupomend; @FXML private Label cupomdata; @FXML private Label pdv; @FXML private Label cupomoperador; private FinalizaVendaController control; private AddClienteController controlcliente; private TrocarOperadorController controloperador; @FXML private Label txtusuarionome; private Cliente cliente; private Usuario operador; private Estoque estoque; // @FXML // private Label lbdata; // @FXML // private Label lbhora; private Produto produto; public PdvController() { // TODO Auto-generated constructor stub } @FXML private void exit(ActionEvent event) { Platform.exit(); } @FXML private void logout(ActionEvent event) throws IOException { Platform.exit(); } @FXML private void trocarusuario(ActionEvent event) throws IOException { stageManager.switchScene(FxmlView.LOGIN); } @FXML private void editarusuario(ActionEvent event) throws IOException { stageManager.switchScene(FxmlView.MOVIMENTACAOUSUARIO); } @FXML private void movimentacaoempresa(){ stageManager.switchScene(FxmlView.MOVIMENTACAOEMPRESA); } @FXML private void movimentacaofornecedor(){ stageManager.switchScene(FxmlView.MOVIMENTACAOFORNECEDOR); } @FXML private void movimentacaofuncionario(){ stageManager.switchScene(FxmlView.MOVIMENTACAOFUNCIONARIO); } @FXML private void movimentacaocliente(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCLIENTE); } @FXML private void movimentacaocategoria(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCATEGORIA); } @FXML private void movimentacaoproduto(){ stageManager.switchScene(FxmlView.MOVIMENTACAOPRODUTO); } @FXML private void movimentacaoformapagamento(){ stageManager.switchScene(FxmlView.MOVIMENTACAOFORMAPAGAMENTO); } @FXML private void movimentacaoconfiguracao(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCONFIGURACAO); } @FXML private void movimentacaocaixa(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCAIXA); } @FXML private void movimentacaousuario(){ stageManager.switchScene(FxmlView.MOVIMENTACAOUSUARIO); } @FXML private void movimentacaopagamento(){ stageManager.switchScene(FxmlView.MOVIMENTACAOPAGAMENTO); } @FXML private void movimentacaoestoque(){ stageManager.switchScene(FxmlView.MOVIMENTACAOESTOQUE); } @FXML private void movimentacaocontasreceber(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCONTASRECEBER); } @FXML private void movimentacaocontaspagar(){ stageManager.switchScene(FxmlView.MOVIMENTACAOCONTASPAGAR); } @FXML private void movimentacaorecebimento(){ stageManager.switchScene(FxmlView.MOVIMENTACAORECEBIMENTO); } @FXML private void movimentacaopedidocompra(){ stageManager.switchScene(FxmlView.MOVIMENTACAOPEDIDOCOMPRA); } @FXML private void movimentacaopedidovenda(){ stageManager.switchScene(FxmlView.MOVIMENTACAOPEDIDOVENDA); } @FXML private void movimentacaofinanceiro(){ stageManager.switchScene(FxmlView.MOVIMENTACAOFINANCEIRO); } @FXML public void movimentacaopdv() { // TODO Auto-generated method stub stageManager.switchScene(FxmlView.PDV); } @FXML private void abrecupom(){ // stageManager.switchScene(FxmlView.MOVIMENTACAOPEDIDOVENDA); if(pv != null){ retorno.setText("Cupom Aberto..."); }else{ retorno.setText("Abrindo Cupom..."); pv = new PedidoVenda(); itemList.clear(); cupomtabela.setItems(itemList); } } @FXML private void addcliente(){ retorno.setText("Adicionando Cliente ..."); DialogoEscolhaCliente(); retorno.setText("Cliente Adicionado ..." + pv.getCliente()); } @FXML private void trocaroperador(){ retorno.setText("Trocando Operador ..."); DialogoTrocaOperador(); retorno.setText("Operador Trocado ..." + operador); } @FXML private void finalizavenda(){ FinalizaVenda(pv); retorno.setText("venda finalizada" + pv.getId()); } @FXML private void cancelaitem(){ retorno.setText("Cacnelando Item ..."); } @FXML private void cancelacupom(){ pv = new PedidoVenda(); clearFields(); totalitems.clear(); totalvenda.clear(); itemList.clear(); cupomtabela.setItems(itemList); retorno.setText(" Cupom CANCELADO ..."); } @FXML private void reimprimir(){ retorno.setText("Reimprimindo Cupom ..."); } @FXML private void alteraquantidade(){ retorno.setText("Alterando a Quantidade ..."); } @FXML private void pesquisaproduto(){ retorno.setText("Pesquisando Produto..."); } @FXML private void encerracaixa(){ retorno.setText("Encerrando Caixa ..."); } public void saveAlert(PedidoVenda user){ Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Entity saved successfully."); alert.setHeaderText(null); alert.setContentText("The entity "+user.getId()+" has been created and \n"+" id is "+user.getId()+"."); alert.showAndWait(); } public void updateAlert(PedidoVenda user){ Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Entity updated successfully."); alert.setHeaderText(null); alert.setContentText("The entity "+user.getId()+" has been created and \n"+" id is "+user.getId()+"."); alert.showAndWait(); } public void DialogoEscolhaCliente(){ List<Cliente> clientes = ClienteService.findAll(); try{ FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/addcliente.fxml")); Parent root =loader.load(); controlcliente = (AddClienteController)loader.getController(); controlcliente.SetTxtFields(clientes); controlcliente.getTxtcliente().focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (! isNowFocused) { controlcliente.initialize(); } }); controlcliente.getBtconfirma().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { cliente = controlcliente.getClienteEscolhido(); cliente = ClienteService.getClientePorNome(cliente.getNome()); pv.setCliente(cliente); System.out.println(" cliente escolhido PDV" + controlcliente.getClienteEscolhido()); retorno.setText("cliente escolhido" + controlcliente.getTxtclienteescolhido().getText()); cupomnome.setText(controlcliente.getTxtclienteescolhido().getText()); Stage stage = (Stage) controlcliente.getBtconfirma().getScene().getWindow(); //Obtendo a janela atual stage.close(); } }); controlcliente.getBtcancela().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Stage stage = (Stage) controlcliente.getBtcancela().getScene().getWindow(); //Obtendo a janela atual stage.close(); } }); javafx.stage.Window win = new Popup() ; Stage s1 = new Stage(); s1.initOwner(win); s1.initModality(Modality.APPLICATION_MODAL); s1.initStyle(StageStyle.UNDECORATED); Scene scene = new Scene(root); s1.setScene(scene); s1.show(); }catch (Exception e) { System.out.println("erro PDV cliente CONTROL:"+ e); } } public void DialogoTrocaOperador(){ try{ FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/trocaroperador.fxml")); Parent root =loader.load(); controloperador = (TrocarOperadorController)loader.getController(); // controloperador.initialize(); controloperador.getBtcancela().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // System.out.println("cancelando trocar operador PDV"); Stage stage = (Stage) controloperador.getBtcancela().getScene().getWindow(); //Obtendo a janela atual stage.close(); } }); controloperador.getBttrocar().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // operador = controloperador.GetCampos(); // operador.setUsername(controloperador.getTxtusuario().getText()); // operador.setUsername(controloperador.getTxtsenha().getText()); System.out.println("trocando operador PDV" + controloperador.getTxtusuario().getText()); //controloperador boolean isvalido = usuarioService.authenticate(controloperador.getTxtusuario().getText(), controloperador.getTxtsenha().getText()); if(isvalido){ operador = usuarioService.findByUsername((controloperador.getTxtusuario().getText())); System.out.println("operador valido" + controloperador.getTxtusuario().getText()); retorno.setText("operador trocado e valido" + controloperador.getTxtusuario().getText()); cupomoperador.setText(controloperador.getTxtusuario().getText()); } //Obtendo a janela atual Stage stage = (Stage) controloperador.getBttrocar().getScene().getWindow(); stage.close(); } }); javafx.stage.Window win = new Popup() ; Stage s1 = new Stage(); s1.initOwner(win); s1.initModality(Modality.APPLICATION_MODAL); s1.initStyle(StageStyle.UNDECORATED); Scene scene = new Scene(root); s1.setScene(scene); s1.show(); }catch (Exception e) { System.out.println("erro TROCA OPERADOR PDV :"+ e); } // PreencheCupom(pv); } public void FinalizaVenda(PedidoVenda ped) { List<Estoque> estoques = estoqueService.findAll(); estoque = estoques.get(0); try{ FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/finalizavenda.fxml")); Parent root =loader.load(); control = (FinalizaVendaController)loader.getController(); control.setPedidovenda(pv); // control.getPedidovenda(); control.SetFormasEmVenda(pv); control.PreencherTabela(); control.PreencherCampos(pv); control.loadFormaDetails(pv); // // control.setBtcancela(btcancela); // control.setBtconfirma(btconfirma); control.getBtcancela().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // pv = control.pedidovenda; pv.setFormas(control.getPedidovenda().getFormas()); pv.getFormas().clear(); System.out.println("cancelando Forma PDV" + pv.getFormas()); control.SetFormasEmVenda(pv); control.PreencherTabela(); control.PreencherCampos(pv); control.loadFormaDetails(pv); Stage stage = (Stage) control.getBtcancela().getScene().getWindow(); //Obtendo a janela atual stage.close(); } }); control.getBtconfirma().setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // pv = control.getPedidovenda(); pv.setFormas(control.getPedidovenda().getFormas()); pv.setAtivo(true); pv.setData(new Date()); pv.setIspago(true); pv.setStatus(StatusPedido.FINALIZADO); pv.setTotal(pv.CalcularTotal(pv.getItems())); for(Item item : pv.getItems()){ itemService.save(item); } estoque.OperacaoEstoqueVenda(pv); estoqueService.edit(estoque); // List<Caixa> caixas = caixaService.findAll(); // // Caixa caixa = caixas.get(0); // caixa.setSaldo(caixa.getSaldo().add(pv.getTotalVenda())); // caixaService.edit(caixa); System.out.println("confirmando Forma PDV" + pv.getFormas()); PedidoVendaService.save(pv); System.out.println("Pedido Venda Salvo com Formas PDV!" + pv); retorno.setText("venda salva" + pv); Stage stage = (Stage) control.getBtconfirma().getScene().getWindow(); //Obtendo a janela atual stage.close(); // clearFields(); updateAlert(pv); itemList.clear(); pv = new PedidoVenda(); totalitems.clear(); totalvenda.clear(); } }); javafx.stage.Window win = new Popup() ; Stage s1 = new Stage(); s1.initOwner(win); s1.initModality(Modality.APPLICATION_MODAL); s1.initStyle(StageStyle.UNDECORATED); Scene scene = new Scene(root); s1.setScene(scene); s1.show(); }catch (Exception e) { System.out.println("erro PDV CONTROL:"+ e); } } private void CarregarHeader(){ circulo.setStroke(Color.DARKGRAY); circulo.setFill(new ImagePattern(imgsusuario)); circulo.setEffect(new DropShadow(+25d, 0d, +2d, Color.AZURE)); circuloemp.setStroke(Color.DARKGRAY); circuloemp.setFill(new ImagePattern(imgsempresa)); circuloemp.setEffect(new DropShadow(+25d, 0d, +2d, Color.AZURE)); imgviewempresa.setVisible(false); imgviewusuario.setVisible(false); txthora.setText(getHora()); txtcontext.setText("Pdv"); empresanome.setText("Empresa Tal"); } public void loadItemDetails(){ itemList.clear(); itemList.addAll(pv.getItems()); cupomtabela.setItems(itemList); // setColumnProperties(); } private void setColumnProperties() { // TODO Auto-generated method stub // colItemId.setCellValueFactory(new PropertyValueFactory<>("id")); colItemCode.setCellValueFactory(new PropertyValueFactory<>("codigo")); colItemDescricao.setCellValueFactory(new PropertyValueFactory<>("descricao")); colItemQtd.setCellValueFactory(new PropertyValueFactory<>("qtd")); colItemValorTotal.setCellValueFactory(new PropertyValueFactory<>("totalItem")); // colIE.setCellValueFactory(new PropertyValueFactory<>("inscricaoestadual")); // colEmail.setCellValueFactory(new PropertyValueFactory<>("email")); // colTelefone.setCellValueFactory(new PropertyValueFactory<>("telefone")); colItemValorUnitario.setCellValueFactory(new PropertyValueFactory<>("precoUnitario")); // // colEdit.setCellFactory(cellFactory); // colDel.setCellFactory(cellFactorydel); // super.setColumnProperties(); } private void clearFields() { codigobarra.clear(); qtd.clear(); valorunitario.clear(); valortotal.clear(); descricao.clear(); } @Override public void initialize(URL arg0, ResourceBundle arg1) { CarregarHeader(); if(pv == null){ pv = new PedidoVenda(); // cupomtabela = new TableView<>(itemList); } itemList = FXCollections.observableArrayList(pv.getItems()); cupomtabela.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); List<Produto> prods = ProdutoService.findAll(); // List<Cliente> clientes = ClienteService.findAll(); TextFields.bindAutoCompletion(codigobarra,prods); // TextFields.bindAutoCompletion(txtcliente,clientes); codigobarra.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (! isNowFocused) { produto = ProdutoService.getProdutoPorCode(codigobarra.getText()); codigobarra.setText(produto.getCodebar()); descricao.setText(produto.getDescricao()); valorunitario.setText(produto.getPrecovenda().toString()); } }); qtd.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (! isNowFocused) { produto = ProdutoService.getProdutoPorCode(codigobarra.getText()); java.math.BigDecimal qtdaux = new java.math.BigDecimal(qtd.getText()); java.math.BigDecimal tot = produto.getPrecovenda().multiply(qtdaux); codigobarra.setText(produto.getCodebar()); descricao.setText(produto.getDescricao()); valorunitario.setText(produto.getPrecovenda().toString()); valortotal.setText(tot.toString()); } }); int totit = pv.getItems().size(); String toit = String.valueOf(totit); BigDecimal tvenda = pv.getTotalVenda(); totalitems.setText(toit); totalvenda.setText(tvenda.toString()); // cupomoperador.setText(operador.getUsername()); // cupomnome.setText(pv.getCliente().getNome()); // cupomend.setText(pv.getCliente().getNome()); additem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Item it = new Item(); it.setDescricao(produto.getDescricao()); it.setNome(produto.getNome()); it.setCodigo(produto.getCodebar()); it.setPrecoUnitario(produto.getPrecovenda()); it.setSituacao(SituacaoItem.AGUARDANDO); it.setPrecoCusto(produto.getPrecocusto()); it.setUn_medida(produto.getUn_medida()); java.math.BigDecimal qtdaux = new java.math.BigDecimal(qtd.getText()); it.setTotalItem(it.getPrecoUnitario().multiply(qtdaux)); it.setQtd(qtdaux); pv.addItem(it); cupomdata.setText(new Date().toLocaleString()); int totit = pv.getItems().size(); String toit = String.valueOf(totit); BigDecimal tvenda = pv.getTotalVenda(); totalitems.setText(toit); totalvenda.setText(tvenda.toString()); // itemList.addAll(pv.getItems().entrySet()); // itemList = FXCollections.observableArrayList(pv.getItems().entrySet()); cupomtabela.setItems(itemList); // cupomtabela.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // PedidoVendaService.edit(pv); retorno.setText("item Add" + it.getDescricao()); loadItemDetails(); clearFields(); } }); setColumnProperties(); loadItemDetails(); SetarUsuarioPdv(); } public void SetarUsuarioPdv() { usuarioUp = stageManager.GetaUsuarioStage(); txtusuarionome.setText(usuarioUp.getUsername()); cupomoperador.setText(usuarioUp.getUsername()); } public String getHora() { // cria um StringBuilder StringBuilder sb = new StringBuilder(); // cria um GregorianCalendar que vai conter a hora atual GregorianCalendar d = new GregorianCalendar(); // anexa do StringBuilder os dados da hora sb.append( d.get( GregorianCalendar.HOUR_OF_DAY ) ); sb.append( ":" ); sb.append( d.get( GregorianCalendar.MINUTE ) ); sb.append( ":" ); sb.append( d.get( GregorianCalendar.SECOND ) ); // retorna a String do StringBuilder return sb.toString(); } // // public void PreencheCupom(PedidoVenda pedidovenda) { // // cupomnome.setText(pedidovenda.getCliente().getNome()); // cupomend.setText(pedidovenda.getCliente().getNome()); // cupomoperador.setText(operador.getUsername()); // cupomdata.setText(new Date().toLocaleString()); // // // } // }
[ "windsor_melo@hotmail.com" ]
windsor_melo@hotmail.com
a434b518406fe78a4533a04d435cc4c38b3cfbea
8633142abd5ad1583d2bbc4f104578bafd1597db
/src/main/java/it/uniroma3/dia/alfred/mpi/runner/SlaveMPI.java
1a37e921d3e03f658e9138eae9e066bc54b757f2
[ "MIT" ]
permissive
disheng/alfred-mpi
bd5f540fa3ec56a8b159bb56d1a3d9e2982d7724
c95bcbee58497afc97e10d5a4ea03ff5e3393794
refs/heads/master
2021-01-19T15:29:02.670108
2013-10-31T13:05:34
2013-10-31T13:05:34
12,872,427
0
1
null
null
null
null
UTF-8
Java
false
false
6,805
java
package it.uniroma3.dia.alfred.mpi.runner; import it.uniroma3.dia.alfred.mpi.model.ConfigHolder; import it.uniroma3.dia.alfred.mpi.model.constants.ConfigHolderKeys; import it.uniroma3.dia.alfred.mpi.model.serializer.ConfigHolderSerializable; import it.uniroma3.dia.alfred.mpi.runner.MPIConstants.AbortReason; import it.uniroma3.dia.alfred.mpi.runner.MPIConstants.TagValue; import it.uniroma3.dia.alfred.mpi.runner.data.ResultHolder; import java.io.File; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.log4j.Logger; import mpi.MPI; import mpi.MPIException; import com.google.common.collect.Lists; class SlaveMPI { private static int MIN_THREADS = 1; private static int MAX_THREADS = 8; private static Logger currentLogger = Logger.getLogger(SlaveMPI.class); private SlaveMPI() {} public static void run() throws MPIException { List<ConfigHolder> confPerWorker; int howMuchWork; // howMuchWork = recvWorkQty(); currentLogger.debug("Process[" + MPI.COMM_WORLD.Rank() + "]:recv: " + howMuchWork); // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]:recv: " + howMuchWork); ackWorkQty(howMuchWork); currentLogger.debug("Process[" + MPI.COMM_WORLD.Rank() + "]:end"); // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]:end"); // Recv confs confPerWorker = recvConfigs(howMuchWork); currentLogger.info("Process[" + MPI.COMM_WORLD.Rank() + "]: Conf("+confPerWorker.size()+") receive done"); // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]: Conf("+confPerWorker.size()+") receive done"); // RunAlfred.dumpConf(MPI.COMM_WORLD.Rank(), confPerWorker); if (confPerWorker.size() != howMuchWork) { RunAlfred.abort(AbortReason.WORK_SIZE_MISMATCH); } List<ResultHolder> execResults = runThreads(MPI.COMM_WORLD.Rank(), confPerWorker); currentLogger.info("Process[" + MPI.COMM_WORLD.Rank() + "]: ConfResults: " + execResults); // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]: ConfResults: " + execResults); // Synchro after thread execution MPI.COMM_WORLD.Barrier(); // Send to master to know how it went sendResults(execResults); } private static int recvWorkQty() { int[] messageSend = new int[1]; int[] messageRecv = new int[1]; messageSend[0] = 0; messageRecv[0] = 0; try { MPI.COMM_WORLD.Recv(messageRecv, 0, 1, MPI.INT, MPIConstants.MASTER, TagValue.TAG_SIZE_CONF.getValue()); } catch (MPIException e) { currentLogger.error("recvWorkQty()", e); // e.printStackTrace(); RunAlfred.abort(AbortReason.WORK_SEND); } return messageRecv[0]; } private static void ackWorkQty(int howMuchWork) { int[] messageSend = new int[1]; int[] messageRecv = new int[1]; messageSend[0] = howMuchWork; messageRecv[0] = 0; try { MPI.COMM_WORLD.Reduce(messageSend, 0, messageRecv, 0, 1, MPI.INT, MPI.SUM, MPIConstants.MASTER); } catch (MPIException e) { currentLogger.error("ackWorkQty()", e); RunAlfred.abort(AbortReason.WORK_SEND_ACK); } } private static List<ConfigHolder> recvConfigs(int howMuchWork) { List<ConfigHolder> confPerWorker = Lists.newArrayList(); char[] stringRecvBuffer; int[] messageRecv = new int[1]; messageRecv[0] = 0; // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]: Want to receive " + howMuchWork); for(int i = 0; i < howMuchWork; ++i) { try { MPI.COMM_WORLD.Recv(messageRecv, 0, 1, MPI.INT, MPIConstants.MASTER, TagValue.TAG_CONF_LEN.getValue()); stringRecvBuffer = new char[messageRecv[0]]; // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]: Receiving conf len " + messageRecv[0]); MPI.COMM_WORLD.Recv(stringRecvBuffer, 0, messageRecv[0], MPI.CHAR, MPIConstants.MASTER, TagValue.TAG_CONF_DATA.getValue()); confPerWorker.add( ConfigHolderSerializable.fromJson(String.valueOf(stringRecvBuffer)) ); // System.out.println("Process[" + MPI.COMM_WORLD.Rank() + "]: Receiving conf " + confPerWorker.get(confPerWorker.size() - 1).getUid() ); } catch (MPIException e) { currentLogger.error("recvConfigs()", e); // e.printStackTrace(); RunAlfred.abort(AbortReason.WORK_RECV_DATA); } } return confPerWorker; } private static void sendResults(List<ResultHolder> execResults) throws MPIException { int[] messageSend = new int[1]; messageSend[0] = execResults.size(); byte[] bDataSend = new byte[execResults.size()]; for(int i = 0; i < bDataSend.length; ++i) { bDataSend[i] = (byte) (execResults.get(i).getBooleanResult() ? 1 : 0); } MPI.COMM_WORLD.Send(messageSend, 0, 1, MPI.INT, MPIConstants.MASTER, TagValue.TAG_CONF_RESULTS_SIZE.getValue()); MPI.COMM_WORLD.Send(bDataSend, 0, bDataSend.length, MPI.BYTE, MPIConstants.MASTER, TagValue.TAG_CONF_RESULTS.getValue()); } private static List<ResultHolder> runThreads(int rank, List<ConfigHolder> confPerWorker) { // Execute configurations in parallel if necessary ExecutorService executor = Executors.newFixedThreadPool(Math.max(Math.min(MAX_THREADS, Runtime.getRuntime().availableProcessors() - 1), MIN_THREADS)); List<Future<ResultHolder>> threadResults = Lists.newArrayList(); List<String> attributeList; for (ConfigHolder cfgCurr: confPerWorker) { attributeList = cfgCurr.getAssociatedDomain().getXPathNames(); createOutputDirForConf(cfgCurr); for(String attrCurrent: attributeList) { threadResults.add(executor.submit(new SlaveMPIThread_Attribute(cfgCurr, attrCurrent, rank))); } } executor.shutdown(); while (!executor.isTerminated()) {} List<ResultHolder> bResult = Lists.newArrayList(); for(Future<ResultHolder> bCurr: threadResults) { try { bResult.add(bCurr.get()); } catch (InterruptedException e) { currentLogger.error("runThreads()", e); // e.printStackTrace(); } catch (ExecutionException e) { currentLogger.error("runThreads()", e); // e.printStackTrace(); } } return bResult; } private static void createOutputDirForConf(ConfigHolder cfg) { String configDir = cfg.getConfigurationValue(ConfigHolderKeys.OUTPUT_FOLDER_KEY); try { new File(configDir + "/").mkdirs(); } catch(Exception e) { // System.out.println("Directory " + configDir + " might already exist."); currentLogger.error("Directory " + configDir + " might already exist.", e); } } }
[ "francesco@furio.me" ]
francesco@furio.me
8e6f2260880c7173d64aa343541495579331c36f
0c656b19d3ea0497b8ea5127f8a3b036de109f86
/android/POS/app/src/androidTest/java/com/dinerico/pos/ApplicationTest.java
835c030f1a3e76264be9451604ffb5689c3302c5
[]
no_license
datil/dinerico
868ec8249b399a34d395efd45ac4dd70cc24ff0d
6684fc08c322059c50dbde215dc889ac7641cd00
refs/heads/master
2021-01-18T11:38:51.087543
2014-11-02T05:59:36
2014-11-02T05:59:36
24,167,937
0
0
null
null
null
null
UTF-8
Java
false
false
347
java
package com.dinerico.pos; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
[ "joseph_jiy@hotmail.com" ]
joseph_jiy@hotmail.com
530925a503541e9932d9bbabe7d3a338a72e092b
753aa7d815fca5b360a15c8ceb118f11fbd9d842
/project/Airbnb/src/java/controller/RoomProfileController.java
5986b6764022b36e36da960df6c2c01ac82f53db
[ "Apache-2.0" ]
permissive
kougianos/Homie
9d8597ab59d55b49716c189e32cce7b86d786904
b10940ddc7ed7a678450df341af411662eac820c
refs/heads/master
2021-06-17T01:56:48.414385
2021-02-08T14:07:52
2021-02-08T14:07:52
152,896,733
1
0
null
null
null
null
UTF-8
Java
false
false
4,814
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package controller; import dao.RoomDAO; import dao.RoomDAOImpl; import dao.UserRentsRoomDAO; import dao.UserRentsRoomDAOImpl; import dao.UserVisitsRoomDAO; import dao.UserVisitsRoomDAOImpl; import entities.Bed; import entities.Facilities; import entities.Room; import entities.Roomtype; import entities.Rules; import entities.Space; import entities.UserRentsRoom; import java.io.Serializable; import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.faces.context.FacesContext; /** * * @author valia */ @ManagedBean(name = "roomProfileController") @ViewScoped public class RoomProfileController implements Serializable { private int idroom; private String id; private Room room; private Facilities facility = null; private Rules rule = null; private Space space = null; private List<Bed> bedList = null; private Roomtype roomtype = null; private double rating = 0; private int rates_number = 0; private List<UserRentsRoom> rentalList = null; @PostConstruct public void init() { FacesContext fc = FacesContext.getCurrentInstance(); Map<String, String> m = fc.getExternalContext().getRequestParameterMap(); id = m.get("idroom"); idroom = Integer.parseInt(id); RoomDAO dao = new RoomDAOImpl(); room = dao.find(idroom); facility = room.getFacilitiesList().get(0); rule = room.getRulesList().get(0); space = room.getSpaceList().get(0); bedList = room.getBedList(); UserRentsRoomDAO urrdao = new UserRentsRoomDAOImpl(); rentalList = urrdao.findallbyidroom(room); for (UserRentsRoom rent : rentalList) { if (rent.getRate() == null) { continue; } rating += rent.getRate(); } rates_number = rentalList.size(); if (rates_number > 0) { rating = rating / rates_number; } else { rating = 0; } try { String ownerusername = room.getUserList().get(0).getUsername(); Map<String, Object> m2 = fc.getExternalContext().getSessionMap(); SessionController sc = (SessionController) m2.get("sessionController"); String username = sc.getLoggedInUser().getUsername(); if (!username.equals(ownerusername)) { UserVisitsRoomDAO dao1800 = new UserVisitsRoomDAOImpl(); dao1800.visit(username, idroom); } } catch (Exception ex) { ex.printStackTrace(); } } public int getIdroom() { return idroom; } public void setIdroom(int idroom) { this.idroom = idroom; } public int getRates_number() { return rates_number; } public void setRates_number(int rates_number) { this.rates_number = rates_number; } public List<UserRentsRoom> getRentalList() { return rentalList; } public void setRentalList(List<UserRentsRoom> rentalList) { this.rentalList = rentalList; } public Room getRoom() { return room; } public void setRoom(Room room) { this.room = room; } public Facilities getFacility() { return facility; } public void setFacility(Facilities facility) { this.facility = facility; } public Rules getRule() { return rule; } public void setRule(Rules rule) { this.rule = rule; } public Space getSpace() { return space; } public void setSpace(Space space) { this.space = space; } public List<Bed> getBedList() { return bedList; } public void setBedList(List<Bed> bedList) { this.bedList = bedList; } public String getId() { return id; } public void setId(String id) { this.id = id; } public Roomtype getRoomtype() { return roomtype; } public void setRoomtype(Roomtype roomtype) { this.roomtype = roomtype; } public double getRating() { return rating; } public void setRating(double rating) { this.rating = rating; } public String save() { RoomDAO dao = new RoomDAOImpl(); dao.update(this.room); FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(null, new FacesMessage("Changes saved successfully")); return null; } }
[ "kougi_jr@hotmail.com" ]
kougi_jr@hotmail.com
e98ad266c53cf27829e25ca16cd7259b0f9d5d3a
83837bf11e3f5826f59cb9588894403ef7a95def
/app/src/main/java/com/debd/kgp/dsmusic/model/UserCredential.java
0fa9ad00c1c0f24d9ea82ecc3d29cccbce574da8
[]
no_license
debd1995/DSMusic
67153c48916441e6b79da24c2475117f9e3c0959
6833647e194542a3c5f3a777689d9df15b790b61
refs/heads/master
2021-04-15T04:55:24.505859
2018-03-24T12:08:19
2018-03-24T12:08:19
126,594,122
2
1
null
null
null
null
UTF-8
Java
false
false
1,184
java
package com.debd.kgp.dsmusic.model; import java.io.Serializable; public class UserCredential implements Serializable { private String username, password; private boolean rememberStatus, loginStatus; public UserCredential(){} public UserCredential(String username, String password, boolean rememberStatus, boolean loginStatus) { this.username = username; this.password = password; this.rememberStatus = rememberStatus; this.loginStatus = loginStatus; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public boolean getRememberStatus() { return rememberStatus; } public void setRememberStatus(boolean rememberStatus) { this.rememberStatus = rememberStatus; } public boolean getLoginStatus() { return loginStatus; } public void setLoginStatus(boolean loginStatus) { this.loginStatus = loginStatus; } }
[ "root@localhost.localdomain" ]
root@localhost.localdomain
84761aa6ec8ffe0f2fdc7c0d717731405f35577f
1cd92220828054328cf20804dce0b8f16a42b86c
/src/main/java/com/hust/smarthotel/components/user/domain_model/Manager.java
a504e30fd43e33f6114c067a3976854391e1d29a
[]
no_license
vking34/smart-hotel
62ac5a5299924977d9a72677b7167c47c29dd5e7
db2836a962cbbf0a42d51887bc8b53500d244783
refs/heads/master
2020-04-24T19:51:47.839399
2019-10-01T15:06:59
2019-10-01T15:06:59
172,225,822
0
0
null
2019-10-01T15:07:01
2019-02-23T14:49:09
Java
UTF-8
Java
false
false
1,530
java
package com.hust.smarthotel.components.user.domain_model; import com.hust.smarthotel.generic.util.EncryptedPasswordUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; import java.time.LocalDateTime; import static com.hust.smarthotel.generic.constant.ManagerState.*; @Data @NoArgsConstructor @AllArgsConstructor @Document(collection = "VerifyingManager") public class Manager extends BasicManager { @Id private String id; @Field("created_time") private LocalDateTime createdTime; @Field("status") private String status; @Field("reason") private String reason; public Manager(BasicManager basicManager){ this.setUsername(basicManager.getUsername()); this.setPassword(EncryptedPasswordUtils.encryptPassword(basicManager.getPassword())); this.setName(basicManager.getName()); this.setFullName(basicManager.getFullName()); this.setEmail(basicManager.getEmail()); this.setPhone(basicManager.getPhone()); this.createdTime = LocalDateTime.now(); this.status = VERIFYING; } public void reject(){ this.status = REJECTED; } public void reject(String reason){ this.status = REJECTED; this.reason = reason; } public void verify(){ this.status = VERIFIED; } }
[ "root@localhost.localdomain" ]
root@localhost.localdomain
8ce9472d0d6cd2d280d2022c116eb6fe0f24b4bd
25e99a0af5751865bce1702ee85cc5c080b0715c
/design_pattern/src/DPModel/src/dp/com/company/memento/section9/Client.java
620fb5b0ccd6dce7cec893bceb96f70c48954fd7
[]
no_license
jasonblog/note
215837f6a08d07abe3e3d2be2e1f183e14aa4a30
4471f95736c60969a718d854cab929f06726280a
refs/heads/master
2023-05-31T13:02:27.451743
2022-04-04T11:28:06
2022-04-04T11:28:06
35,311,001
130
67
null
2023-02-10T21:26:36
2015-05-09T02:04:40
C
UTF-8
Java
false
false
500
java
package com.company.memento.section9; /** * @author cbf4Life cbf4life@126.com * I'm glad to share my knowledge with you all. */ public class Client { public static void main(String[] args) { //定义出发起人 Originator originator = new Originator(); //定义出备忘录管理员 Caretaker caretaker = new Caretaker(); //创建一个备忘录 caretaker.setMemento(originator.createMemento()); //恢复一个备忘录 originator.restoreMemento(caretaker.getMemento()); } }
[ "jason_yao" ]
jason_yao
700c48c96dc790e789786e6150ec58fad4d95ac3
932ed0800389d12bf1b77346f7c97e32795f1b44
/src/main/java/com/yadu/restaurant/menu/MenuItem.java
ce84416533801c7ec04b1f053b495b3f5995fad7
[]
no_license
nothinggreat2011/gordon_ramsey
975d2ddffa66df27339fc1ae9daf14cef08c0632
de9bde779a2f1ef76d84655f85f99793e645396c
refs/heads/master
2021-06-14T18:20:17.361225
2016-11-22T09:29:46
2016-11-22T09:29:46
74,108,857
0
0
null
null
null
null
UTF-8
Java
false
false
592
java
package com.yadu.restaurant.menu; /** * Created by ybhushan on 18/11/16. */ public class MenuItem { private String name; private int satisfaction; private int timeTakenToEat; public MenuItem(String name, int satisfaction, int timeTakenToEat) { this.name = name; this.satisfaction = satisfaction; this.timeTakenToEat = timeTakenToEat; } public String getName() { return name; } public int getSatisfaction() { return satisfaction; } public int getTimeTakenToEat() { return timeTakenToEat; } }
[ "yadubhushan2011@gmail.com" ]
yadubhushan2011@gmail.com
7217fa40cdcefdb35afba6a2febc6b58e2e07db2
d7dd88823655437b3ffbf3eb8b3a789cd87bc503
/src/main/java/org/reactome/web/diagram/search/results/cells/SearchResultCell.java
cc0e768a3312e35e0d94bab4e23a5e2e6d5df0c3
[]
no_license
reactome-pwp/diagram
fcfc9cbae6d6ace27e52d5714e0fc75e40570cad
55419a20d5bb4d5f7dbcbd0e253b20cb086a2895
refs/heads/master
2023-06-23T11:34:38.438713
2023-06-13T16:34:45
2023-06-13T16:34:45
39,070,905
5
6
null
2021-06-01T18:38:10
2015-07-14T11:27:19
Java
UTF-8
Java
false
false
5,435
java
package org.reactome.web.diagram.search.results.cells; import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.core.client.GWT; import com.google.gwt.safehtml.client.SafeHtmlTemplates; import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlUtils; import com.google.gwt.user.client.ui.Image; import org.reactome.web.diagram.search.SearchLauncher; import org.reactome.web.diagram.search.SearchResultObject; /** * The Cell used to render a {@link SearchResultObject}. * * @author Kostas Sidiropoulos <ksidiro@ebi.ac.uk> */ public class SearchResultCell extends AbstractCell<SearchResultObject> { private static SafeHtml urHereIcon; interface Templates extends SafeHtmlTemplates { @SafeHtmlTemplates.Template("" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; height:44px; border-bottom:#efefef solid 1px \">" + "<div title=\"{1}\" style=\"float:left; margin:15px 0 0 5px;\">{0}</div>" + "<div style=\"float:left; margin-left:10px; width:290px;\">" + "<div title=\"{3}\" style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:small;\">" + "{2}" + "</div>" + "<div style=\"float:left; width:270px;\">" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin-top:-2px; font-size:x-small; color:#89c053;\">" + "{4}" + "</div>" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin-top:-2px; font-size:x-small; color:#f5b945;\">" + "{5}" + "</div>" + "</div>" + "<div style=\"float:left; margin-left: 1px;\">{6}</div>" + "</div>" + "</div>") SafeHtml cell(SafeHtml image, String imgTooltip, SafeHtml primary, String primaryTooltip, SafeHtml secondary, SafeHtml tertiary, SafeHtml uRHereImage); @SafeHtmlTemplates.Template("" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; height:44px; border-bottom:#efefef solid 1px \">" + "<div title=\"{1}\" style=\"float:left; margin:15px 0 0 5px;\">{0}</div>" + "<div style=\"float:left; margin-left:10px; width:290px;\">" + "<div title=\"{3}\" style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:small;\">" + "{2}" + "</div>" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin-top:-2px; font-size:x-small; color:#89c053;\">" + "{4}" + "</div>" + "<div style=\"overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin-top:-2px; font-size:x-small; color:#f5b945;\">" + "{5}" + "</div>" + "</div>" + "</div>") SafeHtml minCell(SafeHtml image, String imgTooltip, SafeHtml primary, String primaryTooltip, SafeHtml secondary, SafeHtml tertiary); } private static Templates templates = GWT.create(Templates.class); public SearchResultCell() { super(); Image urHere = new Image(SearchLauncher.RESOURCES.youAreHere()); urHere.setStyleName(SearchLauncher.RESOURCES.getCSS().youAreHereIcon()); urHere.setTitle("You are here. This is the displayed pathway."); SearchResultCell.urHereIcon = SafeHtmlUtils.fromTrustedString(urHere.toString()); } @Override public void render(Context context, SearchResultObject value, SafeHtmlBuilder sb) { /* * Always do a null check on the value. Cell widgets can pass null to * cells if the underlying data contains a null, or if the data arrives * out of order. */ if (value == null) { return; } // Next two lines DO NOT work for Chrome // final ImagePrototypeElement imageElement = AbstractImagePrototype.create(value.getImageResource()).createElement(); // final SafeHtml safeImage = new OnlyToBeUsedInGeneratedCodeStringBlessedAsSafeHtml(imageElement.getString()); Image img = new Image(value.getImageResource()); SafeHtml image = SafeHtmlUtils.fromTrustedString(img.toString()); String imgTooltip = value.getSchemaClass().name; SafeHtml primary = SafeHtmlUtils.fromTrustedString(value.getPrimarySearchDisplay()); String primaryTooltip = value.getPrimaryTooltip(); SafeHtml secondary = SafeHtmlUtils.fromTrustedString(value.getSecondarySearchDisplay()); SafeHtml tertiary = SafeHtmlUtils.fromTrustedString(value.getTertiarySearchDisplay()); if(value.isDisplayed()) { sb.append(templates.cell(image, imgTooltip, primary, primaryTooltip, secondary, tertiary, SearchResultCell.urHereIcon)); } else { sb.append(templates.minCell(image, imgTooltip, primary, primaryTooltip, secondary, tertiary)); } } }
[ "ksidiro@ebi.ac.uk" ]
ksidiro@ebi.ac.uk
cada42e896852cefbdb582e1d01292ce82be499c
e6b03b3eadbd229dd3f0c04651adb43744b959c8
/imkf/src/main/java/com/moor/imkf/netty/channel/socket/nio/AbstractNioSelector.java
d2370e9418016c14fb103c5a68cd4d0888e227c4
[]
no_license
longwei243/kefusdk_new
55e1e9f41ed3e79eb4dc380d67a3d2b9d7ab861d
092ee0b050e083c935894849bd2580ad848c0087
refs/heads/master
2021-01-20T19:09:12.479918
2016-12-05T06:32:25
2016-12-05T06:32:25
64,110,541
0
0
null
null
null
null
UTF-8
Java
false
false
11,599
java
/* * Copyright 2012 The Netty Project * * The Netty Project 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 com.moor.imkf.netty.channel.socket.nio; import java.io.IOException; import java.nio.channels.CancelledKeyException; import java.nio.channels.DatagramChannel; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.ConcurrentModificationException; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import com.moor.imkf.netty.channel.Channel; import com.moor.imkf.netty.channel.ChannelException; import com.moor.imkf.netty.channel.ChannelFuture; import com.moor.imkf.netty.util.ThreadNameDeterminer; import com.moor.imkf.netty.util.ThreadRenamingRunnable; import com.moor.imkf.netty.util.internal.DeadLockProofWorker; abstract class AbstractNioSelector implements NioSelector { private static final AtomicInteger nextId = new AtomicInteger(); private final int id = nextId.incrementAndGet(); private static final int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, // but won't need // customization. /** * Executor used to execute {@link Runnable}s such as channel registration * task. */ private final Executor executor; /** * If this worker has been started thread will be a reference to the thread * used when starting. i.e. the current thread when the run method is * executed. */ protected volatile Thread thread; /** * The NIO {@link Selector}. */ protected volatile Selector selector; /** * Boolean that controls determines if a blocked Selector.select should * break out of its selection process. In our case we use a timeone for the * select method and the select method will block for that time unless waken * up. */ protected final AtomicBoolean wakenUp = new AtomicBoolean(); private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<Runnable>(); private volatile int cancelledKeys; // should use AtomicInteger but we just // need approximation private final CountDownLatch shutdownLatch = new CountDownLatch(1); private volatile boolean shutdown; AbstractNioSelector(Executor executor) { this(executor, null); } AbstractNioSelector(Executor executor, ThreadNameDeterminer determiner) { this.executor = executor; openSelector(determiner); } public void register(Channel channel, ChannelFuture future) { Runnable task = createRegisterTask(channel, future); registerTask(task); } protected final void registerTask(Runnable task) { taskQueue.add(task); Selector selector = this.selector; if (selector != null) { if (wakenUp.compareAndSet(false, true)) { selector.wakeup(); } } else { if (taskQueue.remove(task)) { // the selector was null this means the Worker has already been // shutdown. throw new RejectedExecutionException("Worker has already been shutdown"); } } } protected final boolean isIoThread() { return Thread.currentThread() == thread; } public void rebuildSelector() { if (!isIoThread()) { taskQueue.add(new Runnable() { public void run() { rebuildSelector(); } }); return; } final Selector oldSelector = selector; final Selector newSelector; if (oldSelector == null) { return; } try { newSelector = Selector.open(); } catch (Exception e) { e.printStackTrace(); return; } // Register all channels to the new Selector. for (;;) { try { for (SelectionKey key : oldSelector.keys()) { try { if (key.channel().keyFor(newSelector) != null) { continue; } int interestOps = key.interestOps(); key.cancel(); key.channel().register(newSelector, interestOps, key.attachment()); } catch (Exception e) { close(key); } } } catch (ConcurrentModificationException e) { // Probably due to concurrent modification of the key set. continue; } break; } selector = newSelector; try { // time to close the old selector as everything else is registered // to the new one oldSelector.close(); } catch (Throwable t) { t.printStackTrace(); } // logger.info("Migrated " + nChannels + // " channel(s) to the new Selector,"); } public void run() { thread = Thread.currentThread(); int selectReturnsImmediately = 0; Selector selector = this.selector; if (selector == null) { return; } // use 80% of the timeout for measure final long minSelectTimeout = SelectorUtil.SELECT_TIMEOUT_NANOS * 80 / 100; boolean wakenupFromLoop = false; for (;;) { wakenUp.set(false); try { long beforeSelect = System.nanoTime(); int selected = select(selector); if (SelectorUtil.EPOLL_BUG_WORKAROUND && selected == 0 && !wakenupFromLoop && !wakenUp.get()) { long timeBlocked = System.nanoTime() - beforeSelect; if (timeBlocked < minSelectTimeout) { boolean notConnected = false; // loop over all keys as the selector may was unblocked // because of a closed channel for (SelectionKey key : selector.keys()) { SelectableChannel ch = key.channel(); try { if (ch instanceof DatagramChannel && !((DatagramChannel) ch).isConnected() || ch instanceof SocketChannel && !((SocketChannel) ch).isConnected()) { notConnected = true; // cancel the key just to be on the safe // side key.cancel(); } } catch (CancelledKeyException e) { // ignore } } if (notConnected) { selectReturnsImmediately = 0; } else { // returned before the minSelectTimeout elapsed with // nothing select. // this may be the cause of the jdk epoll(..) bug, // so increment the counter // which we use later to see if its really the jdk // bug. selectReturnsImmediately++; } } else { selectReturnsImmediately = 0; } if (selectReturnsImmediately == 1024) { // The selector returned immediately for 10 times in a // row, // so recreate one selector as it seems like we hit the // famous epoll(..) jdk bug. rebuildSelector(); selector = this.selector; selectReturnsImmediately = 0; wakenupFromLoop = false; // try to select again continue; } } else { // reset counter selectReturnsImmediately = 0; } // 'wakenUp.compareAndSet(false, true)' is always evaluated // before calling 'selector.wakeup()' to reduce the wake-up // overhead. (Selector.wakeup() is an expensive operation.) // // However, there is a race condition in this approach. // The race condition is triggered when 'wakenUp' is set to // true too early. // // 'wakenUp' is set to true too early if: // 1) Selector is waken up between 'wakenUp.set(false)' and // 'selector.select(...)'. (BAD) // 2) Selector is waken up between 'selector.select(...)' and // 'if (wakenUp.get()) { ... }'. (OK) // // In the first case, 'wakenUp' is set to true and the // following 'selector.select(...)' will wake up immediately. // Until 'wakenUp' is set to false again in the next round, // 'wakenUp.compareAndSet(false, true)' will fail, and therefore // any attempt to wake up the Selector will fail, too, causing // the following 'selector.select(...)' call to block // unnecessarily. // // To fix this problem, we wake up the selector again if wakenUp // is true immediately after selector.select(...). // It is inefficient in that it wakes up the selector for both // the first case (BAD - wake-up required) and the second case // (OK - no wake-up required). if (wakenUp.get()) { wakenupFromLoop = true; selector.wakeup(); } else { wakenupFromLoop = false; } cancelledKeys = 0; processTaskQueue(); selector = this.selector; // processTaskQueue() can call // rebuildSelector() if (shutdown) { this.selector = null; // process one time again processTaskQueue(); for (SelectionKey k : selector.keys()) { close(k); } try { selector.close(); } catch (IOException e) { e.printStackTrace(); } shutdownLatch.countDown(); break; } else { process(selector); } } catch (Throwable t) { t.printStackTrace(); try { Thread.sleep(1000); } catch (InterruptedException e) { // Ignore. } } } } /** * Start the {@link AbstractNioWorker} and return the {@link Selector} that * will be used for the {@link AbstractNioChannel}'s when they get * registered */ private void openSelector(ThreadNameDeterminer determiner) { try { selector = Selector.open(); } catch (Throwable t) { throw new ChannelException("Failed to create a selector.", t); } // Start the worker thread with the new Selector. boolean success = false; try { DeadLockProofWorker.start(executor, newThreadRenamingRunnable(id, determiner)); success = true; } finally { if (!success) { // Release the Selector if the execution fails. try { selector.close(); } catch (Throwable e) { e.printStackTrace(); } selector = null; // The method will return to the caller at this point. } } assert selector != null && selector.isOpen(); } private void processTaskQueue() { for (;;) { final Runnable task = taskQueue.poll(); if (task == null) { break; } task.run(); try { cleanUpCancelledKeys(); } catch (IOException e) { // Ignore } } } protected final void increaseCancelledKeys() { cancelledKeys++; } protected final boolean cleanUpCancelledKeys() throws IOException { if (cancelledKeys >= CLEANUP_INTERVAL) { cancelledKeys = 0; selector.selectNow(); return true; } return false; } public void shutdown() { if (isIoThread()) { throw new IllegalStateException("Must not be called from a I/O-Thread to prevent deadlocks!"); } Selector selector = this.selector; shutdown = true; if (selector != null) { selector.wakeup(); } try { shutdownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); } } protected abstract void process(Selector selector) throws IOException; protected int select(Selector selector) throws IOException { return SelectorUtil.select(selector); } protected abstract void close(SelectionKey k); protected abstract ThreadRenamingRunnable newThreadRenamingRunnable(int id, ThreadNameDeterminer determiner); protected abstract Runnable createRegisterTask(Channel channel, ChannelFuture future); }
[ "liulongwei243@yeah.net" ]
liulongwei243@yeah.net
027dce33a6f082372af16c3be00d9fc4a3e34298
cb1cc3ede9427576d4dce47062e565ffb183e672
/Plugins/Aspose.Slides Java (Maven) for NetBeans/src/com/aspose/slides/maven/AsposeMavenProjectWizardIterator.java
405b4d49c2955a883468b89c9c3addac8d2b3f35
[ "MIT" ]
permissive
aspose-slides/Aspose.Slides-for-Java
fe11ee8c7d9fd21ae39a96328fae1cfead0a0997
51a62aea850deeed57780bba1939919236a2de35
refs/heads/master
2023-08-31T23:13:40.957116
2023-08-23T14:30:30
2023-08-23T14:30:30
2,849,951
31
45
MIT
2023-03-23T17:08:07
2011-11-25T13:57:36
Java
UTF-8
Java
false
false
13,073
java
package com.aspose.slides.maven; import com.aspose.slides.maven.artifacts.Metadata; import com.aspose.slides.maven.utils.AsposeConstants; import com.aspose.slides.maven.utils.AsposeJavaAPI; import com.aspose.slides.maven.utils.AsposeMavenProjectManager; import static com.aspose.slides.maven.utils.AsposeMavenProjectManager.getAsposeProjectMavenDependencies; import com.aspose.slides.maven.utils.AsposeSlidesJavaAPI; import com.aspose.slides.maven.utils.TasksExecutor; import java.awt.Component; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.LinkedHashSet; import java.util.List; import java.util.NoSuchElementException; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.swing.JComponent; import javax.swing.event.ChangeListener; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.templates.TemplateRegistration; import org.netbeans.spi.project.ui.support.ProjectChooser; import org.netbeans.spi.project.ui.templates.support.Templates; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.openide.xml.XMLUtil; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * @author Adeel Ilyas */ @TemplateRegistration( folder = "Project/Maven2", displayName = "#Aspose_displayName", description = "AsposeSlidesMavenDescription.html", iconBase = "com/aspose/slides/maven/Aspose.png", position = 1, content = "AsposeMavenProject.zip") @Messages("Aspose_displayName=Aspose.Slides Maven Project") public class AsposeMavenProjectWizardIterator implements WizardDescriptor.ProgressInstantiatingIterator<WizardDescriptor> { private int index; private WizardDescriptor.Panel[] panels; private WizardDescriptor wiz; List<String> list = new ArrayList<>(); /** * */ public AsposeMavenProjectWizardIterator() { } /** * * @return */ public static AsposeMavenProjectWizardIterator createIterator() { return new AsposeMavenProjectWizardIterator(); } private WizardDescriptor.Panel[] createPanels() { return new WizardDescriptor.Panel[]{ new AsposeMavenBasicWizardPanel() }; } /** * * @return */ private String[] createSteps() { return new String[]{ NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "LBL_CreateProjectStep"), }; } /** * * @return * @throws IOException */ @Override public Set<?> instantiate() throws IOException { throw new AssertionError("instantiate(ProgressHandle) " //NOI18N + "should have been called"); //NOI18N } /** * * @param ph * @return * @throws IOException */ @Override public Set instantiate(ProgressHandle ph) throws IOException { ph.start(); ph.switchToIndeterminate(); ph.progress("Processing..."); final AsposeMavenProjectManager asposeMavenProjectManager = AsposeMavenProjectManager.initialize(wiz); final AsposeJavaAPI asposeSlidesJavaAPI = AsposeSlidesJavaAPI.initialize(asposeMavenProjectManager); boolean isDownloadExamplesSelected = (boolean) wiz.getProperty("downloadExamples"); // Downloading Aspose.Slides Java (mvn based) examples... if (isDownloadExamplesSelected) { TasksExecutor tasksExecutionDownloadExamples = new TasksExecutor(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressExamplesTitle")); // Downloading Aspose API mvn based examples tasksExecutionDownloadExamples.addNewTask(asposeMavenProjectManager.createDownloadExamplesTask(asposeSlidesJavaAPI)); // Execute the tasks tasksExecutionDownloadExamples.processTasks(); } TasksExecutor tasksExecutionRetrieve = new TasksExecutor(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.progressTitle")); // Retrieving Aspose.Slides Java Maven artifact... tasksExecutionRetrieve.addNewTask(asposeMavenProjectManager.retrieveAsposeAPIMavenTask(asposeSlidesJavaAPI)); // Execute the tasks tasksExecutionRetrieve.processTasks(); // Creating Maven project ph.progress(NbBundle.getMessage(AsposeMavenProjectWizardIterator.class, "AsposeManager.projectMessage")); Set<FileObject> resultSet = new LinkedHashSet<>(); File projectDir = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); projectDir.mkdirs(); FileObject template = Templates.getTemplate(wiz); FileObject projectRoot = FileUtil.toFileObject(projectDir); createAsposeMavenProject(template.getInputStream(), projectRoot); createStartupPackage(projectRoot); resultSet.add(projectRoot); // Look for nested projects to open as well: Enumeration<? extends FileObject> e = projectRoot.getFolders(true); while (e.hasMoreElements()) { FileObject subfolder = e.nextElement(); if (ProjectManager.getDefault().isProject(subfolder)) { resultSet.add(subfolder); } } File parent = projectDir.getParentFile(); if (parent != null && parent.exists()) { ProjectChooser.setProjectsFolder(parent); } ph.finish(); return resultSet; } /** * * @param wiz */ @Override public void initialize(WizardDescriptor wiz) { this.wiz = wiz; index = 0; panels = createPanels(); // Make sure list of steps is accurate. String[] steps = createSteps(); for (int i = 0; i < panels.length; i++) { Component c = panels[i].getComponent(); if (steps[i] == null) { // Default step name to component name of panel. // Mainly useful for getting the name of the target // chooser to appear in the list of steps. steps[i] = c.getName(); } if (c instanceof JComponent) { // assume Swing components JComponent jc = (JComponent) c; // Step #. // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*: jc.putClientProperty("WizardPanel_contentSelectedIndex", i); // Step name (actually the whole list for reference). jc.putClientProperty("WizardPanel_contentData", steps); } } } /** * * @param wiz */ @Override public void uninitialize(WizardDescriptor wiz) { this.wiz.putProperty("projdir", null); this.wiz.putProperty("name", null); this.wiz = null; panels = null; } /** * * @return */ @Override public String name() { return MessageFormat.format("{0} of {1}", new Object[]{ index + 1, panels.length }); } /** * * @return */ @Override public boolean hasNext() { return index < panels.length - 1; } /** * * @return */ @Override public boolean hasPrevious() { return index > 0; } /** * */ @Override public void nextPanel() { if (!hasNext()) { throw new NoSuchElementException(); } index++; } /** * */ @Override public void previousPanel() { if (!hasPrevious()) { throw new NoSuchElementException(); } index--; } /** * * @return */ @Override public WizardDescriptor.Panel current() { return panels[index]; } /** * * @param l */ @Override public final void addChangeListener(ChangeListener l) { } /** * * @param l */ @Override public final void removeChangeListener(ChangeListener l) { } private void createAsposeMavenProject(InputStream source, FileObject projectRoot) throws IOException { try { ZipInputStream str = new ZipInputStream(source); ZipEntry entry; while ((entry = str.getNextEntry()) != null) { if (entry.isDirectory()) { FileUtil.createFolder(projectRoot, entry.getName()); } else { FileObject fo = FileUtil.createData(projectRoot, entry.getName()); if (AsposeConstants.MAVEN_POM_XML.equals(entry.getName())) { /* Special handling for maven pom.xml: 1. Defining / creating project artifacts 2. Adding latest Aspose.Slides Maven Dependency reference into pom.xml */ configureProjectMavenPOM(fo, str); } else { writeFile(str, fo); } } } } finally { source.close(); } } private void createStartupPackage(FileObject projectRoot) throws IOException { String startupPackage = wiz.getProperty("package").toString().replace(".", File.separator); FileUtil.createFolder(projectRoot, "src" + File.separator + "main" + File.separator + "java" + File.separator + startupPackage); } private static void writeFile(ZipInputStream str, FileObject fo) throws IOException { try (OutputStream out = fo.getOutputStream()) { FileUtil.copy(str, out); } } private void configureProjectMavenPOM(FileObject fo, ZipInputStream str) throws IOException { String groupId = (String) wiz.getProperty("groupId"); String artifactId = (String) wiz.getProperty("artifactId"); String version = (String) wiz.getProperty("version"); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); FileUtil.copy(str, baos); Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null); Element root = doc.getDocumentElement(); Node node = root.getElementsByTagName("groupId").item(0); node.setTextContent(groupId); node = root.getElementsByTagName("artifactId").item(0); node.setTextContent(artifactId); node = root.getElementsByTagName("version").item(0); node.setTextContent(version); updateProjectPom(doc); try (OutputStream out = fo.getOutputStream()) { XMLUtil.write(doc, out, "UTF-8"); } } catch (IOException | SAXException | DOMException ex) { Exceptions.printStackTrace(ex); writeFile(str, fo); } } private void updateProjectPom(Document pomDocument) { // Get the root element Node projectNode = pomDocument.getFirstChild(); // Adding Dependencies here Element dependenciesTag = pomDocument.createElement("dependencies"); projectNode.appendChild(dependenciesTag); for (Metadata dependency : getAsposeProjectMavenDependencies()) { addAsposeMavenDependency(pomDocument, dependenciesTag, dependency); } } private void addAsposeMavenDependency(Document doc, Element dependenciesTag, Metadata dependency) { Element dependencyTag = doc.createElement("dependency"); dependenciesTag.appendChild(dependencyTag); Element groupIdTag = doc.createElement("groupId"); groupIdTag.appendChild(doc.createTextNode(dependency.getGroupId())); dependencyTag.appendChild(groupIdTag); Element artifactId = doc.createElement("artifactId"); artifactId.appendChild(doc.createTextNode(dependency.getArtifactId())); dependencyTag.appendChild(artifactId); Element version = doc.createElement("version"); version.appendChild(doc.createTextNode(dependency.getVersioning().getLatest())); dependencyTag.appendChild(version); if (dependency.getClassifier() != null) { Element classifer = doc.createElement("classifier"); classifer.appendChild(doc.createTextNode(dependency.getClassifier())); dependencyTag.appendChild(classifer); } } }
[ "DAWOOD RIAZ" ]
DAWOOD RIAZ
7d539773375ad09f0ac8259ed749a9a277cead93
627dafa165ee4420680b4144c849e141596ae0b0
/wecardio/project/src/main/java/com/hiteam/common/repository/dao/pub/impl/CountryDaoImpl.java
6b8a38ec692c0bd3fb44d51d812a93de1f95b77b
[]
no_license
tan-tian/wecardio
97339383a00ecd090dd952ea3c4c3f32dac8a6f2
5e291d19bce2d4cebd43040e4195a26d18d947c3
refs/heads/master
2020-04-03T01:01:57.429064
2018-10-25T15:26:50
2018-10-25T15:26:50
154,917,227
0
0
null
null
null
null
UTF-8
Java
false
false
1,624
java
package com.hiteam.common.repository.dao.pub.impl; import com.hiteam.common.base.repository.dao.impl.BaseDaoImpl; import com.hiteam.common.repository.dao.pub.CountryDao; import com.hiteam.common.repository.entity.pub.Country; import com.hiteam.common.util.pojo.EnumBean; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Repository; import javax.persistence.FlushModeType; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.util.List; /** * 国家 - Dao */ @Repository("countryDaoImpl") public class CountryDaoImpl extends BaseDaoImpl<Country, Long> implements CountryDao { @Override public List<EnumBean> countrySel(String name) { CriteriaBuilder criteriaBuilder = this.entityManager.getCriteriaBuilder(); CriteriaQuery<EnumBean> criteriaQuery = criteriaBuilder.createQuery(EnumBean.class); Root<Country> root = criteriaQuery.from(Country.class); Predicate restrictions = criteriaBuilder.conjunction(); criteriaQuery.select(criteriaBuilder.construct(EnumBean.class, root.get("id"), root.get("name"))); if (!StringUtils.isEmpty(name)) { restrictions = criteriaBuilder.like(root.<String> get("name"), "%" + name + "%"); } criteriaQuery.where(restrictions); TypedQuery<EnumBean> query = entityManager.createQuery(criteriaQuery).setFlushMode(FlushModeType.COMMIT); return query.getResultList(); } }
[ "tantiant@126.com" ]
tantiant@126.com
3a20baf72b6689db568639bd535884783a8e1c69
1da4748a085c6fa95bcec038a41fd0773ad862cd
/codigo/PLeiList/src/pleilist/app/facade/handlers/CriarPlaylistAutomaticoHandler.java
778ce5e355bafc8ae86f6f4f862adfc1098adf12
[]
no_license
guigateixeira/PLEI_LIST
d99f9603177d7159b2304d48bdb6af33175d2de5
d14429a7bd00b2881c60d8a6e1d5b50d0e066ca2
refs/heads/main
2023-07-05T21:35:32.674856
2020-12-12T19:39:30
2020-12-12T19:39:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,701
java
package pleilist.app.facade.handlers; import java.time.Duration; import java.util.List; import pleilist.app.facade.Sessao; import pleilist.app.facade.dto.Curador; import pleilist.app.facade.dto.Item; import pleilist.app.facade.dto.Playlist; import pleilist.app.facade.dto.biblioteca.BibliotecaPrivada; import pleilist.app.facade.dto.biblioteca.BibliotecaPublica; import pleilist.app.facade.dto.catalogos.CatalogoHashTags; import pleilist.app.facade.dto.catalogos.CatalogoPlaylist; import pleilist.app.facade.dto.video.CodigoVideo; import pleilist.app.facade.dto.video.Stream; import pleilist.app.facade.dto.video.Video; import strategy.ICreatePlaylistStrategy; import strategy.RandomVideosStrategy; import utils.Configuration; public class CriarPlaylistAutomaticoHandler { private Sessao s; private BibliotecaPublica bPublica; private Curador curador; private CatalogoPlaylist catPlaylist; private CatalogoHashTags catHashTag; private BibliotecaPrivada bPrivada; private Playlist corrente; private ICreatePlaylistStrategy defaultObject = new RandomVideosStrategy(); private final static Duration DURACAO_DEFAULT_STREAM = Duration.ofSeconds(300); /* * Construtor */ public CriarPlaylistAutomaticoHandler(Sessao s, BibliotecaPublica bPub, CatalogoHashTags catHash, CatalogoPlaylist catPlay) { this.s = s; this.curador = (Curador) s.getUtilizador(); this.bPrivada = this.curador.getBibliotPrivada(); this.bPublica = bPub; this.catHashTag = catHash; this.catPlaylist = catPlay; } /** * Metodo que cria a nova playlist e devolve uma lista das estrategias configuradas para criar uma playlist automatica * @param nomePlaylist = nome da playlist a criar * @return Uma lista de strategy ja configuradas */ public List<ICreatePlaylistStrategy> obterListaCriterios (String nomePlaylist){ int cod = CodigoVideo.getInstance().getCodNum(); this.corrente = new Playlist(nomePlaylist, cod); catPlaylist.addPlaylist(corrente); Configuration c = Configuration.getInstance(); return c.getInstances("strategyCreatePlaylist", defaultObject); } /** * Metodo que adiciona q videos de acordo com a strategy a playlist * @return codigo da playlist */ public String indicaStrategy(ICreatePlaylistStrategy strategy, int q) { List<Video> ls = strategy.escolherVideos(q, curador, bPublica); for(Video v : ls) { Item i = v.criarItem(corrente); if(v instanceof Stream) { i.setDuracao(DURACAO_DEFAULT_STREAM); } corrente.adicionarEmPlaylist(i); } return corrente.getCodigo(); } public CatalogoPlaylist getCatPlay() { return catPlaylist; } }
[ "noreply@github.com" ]
noreply@github.com
8946b621ddf7d44625f2aae0a454d80dc29fd4bb
f7be2aad450fc96adf5e1f79ffc723b3fefd0874
/CTS_Seminar13/src/ro/ase/cts/tests/TestGrupaWithFake.java
cdb01047f5f15856d729ad7d130f86e9adca6ef0
[]
no_license
anampetrescu/CTS2021
7253a8298100e0052bbaa4fb60ebafe7087cd6d2
a17add2bcd3d1b40772990235129279824982289
refs/heads/master
2023-05-13T15:19:13.597125
2021-06-03T14:05:04
2021-06-03T14:05:04
342,260,049
0
0
null
null
null
null
UTF-8
Java
false
false
794
java
package ro.ase.cts.tests; import static org.junit.Assert.*; import org.junit.Test; import org.junit.experimental.categories.Category; import ro.ase.cts.categorii.TesteGetPromovabilitateCategory; import ro.ase.cts.clase.Grupa; import ro.ase.cts.clase.dubluri.StudentFake; public class TestGrupaWithFake { @Test @Category(TesteGetPromovabilitateCategory.class) public void testPromovabilitateRight() { Grupa grupa=new Grupa(1083); for(int i=0;i<8;i++) { StudentFake student= new StudentFake(); student.setValoareAreRestante(false); grupa.adaugaStudent(student); } for(int i=0;i<2;i++) { StudentFake student= new StudentFake(); student.setValoareAreRestante(true); grupa.adaugaStudent(student); } assertEquals(0.8, grupa.getPromovabilitate(),0.01); } }
[ "anamaria.petrescu03@gmail.com" ]
anamaria.petrescu03@gmail.com
9ceba2a661a483157029f90defa366080aaa90c2
3001ba2aa9b0012756dc7082a34ae98908d9f13d
/app/src/main/java/com/marverenic/music/player/MusicPlayer.java
cb76b37f9989904905b8c46000fb3491ce468fad
[ "Apache-2.0" ]
permissive
naijarace/Jockey
ec9d43229032623fc128a874460c68e40db17ac1
5fba5351932d7c4a0b55feb150eccfa56091fb3f
refs/heads/master
2020-12-30T15:43:02.017990
2017-05-11T19:43:00
2017-05-11T19:43:00
91,171,661
1
0
null
2017-05-13T12:08:59
2017-05-13T12:08:59
null
UTF-8
Java
false
false
51,768
java
package com.marverenic.music.player; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Handler; import android.os.PowerManager; import android.support.annotation.NonNull; import android.support.v4.media.MediaMetadataCompat; import android.support.v4.media.session.MediaButtonReceiver; import android.support.v4.media.session.MediaSessionCompat; import android.support.v4.media.session.PlaybackStateCompat; import android.view.KeyEvent; import com.marverenic.music.JockeyApplication; import com.marverenic.music.R; import com.marverenic.music.activity.MainActivity; import com.marverenic.music.data.store.MediaStoreUtil; import com.marverenic.music.data.store.PlayCountStore; import com.marverenic.music.data.store.PreferenceStore; import com.marverenic.music.data.store.ReadOnlyPreferenceStore; import com.marverenic.music.data.store.RemotePreferenceStore; import com.marverenic.music.data.store.SharedPreferenceStore; import com.marverenic.music.model.Song; import com.marverenic.music.utils.Internal; import com.marverenic.music.utils.Util; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; import javax.inject.Inject; import timber.log.Timber; import static android.content.Intent.ACTION_HEADSET_PLUG; import static android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY; /** * High level implementation for a MediaPlayer. MusicPlayer is backed by a {@link QueuedMediaPlayer} * and provides high-level behavior definitions (for actions like {@link #skip()}, * {@link #skipPrevious()} and {@link #togglePlay()}) as well as system integration. * * MediaPlayer provides shuffle and repeat with {@link #setShuffle(boolean)} and * {@link #setRepeat(int)}, respectively. * * MusicPlayer also provides play count logging and state reloading. * See {@link #logPlayCount(Song, boolean)}, {@link #loadState()} and {@link #saveState()} * * System integration is implemented by handling Audio Focus through {@link AudioManager}, attaching * a {@link MediaSessionCompat}, and with a {@link HeadsetListener} -- an implementation of * {@link BroadcastReceiver} that pauses playback when headphones are disconnected. */ public class MusicPlayer implements AudioManager.OnAudioFocusChangeListener, QueuedMediaPlayer.PlaybackEventListener { private static final String TAG = "MusicPlayer"; /** * The filename of the queue state used to load and save previous configurations. * This file will be stored in the directory defined by * {@link Context#getExternalFilesDir(String)} */ private static final String QUEUE_FILE = ".queue"; /** * An {@link Intent} action broadcasted when a MusicPlayer has changed its state automatically */ public static final String UPDATE_BROADCAST = "marverenic.jockey.player.REFRESH"; /** * An {@link Intent} extra sent with {@link #UPDATE_BROADCAST} intents which maps to a boolean * representing whether or not the update is a minor update (i.e. an update that was triggered * by the user). */ public static final String UPDATE_EXTRA_MINOR = "marverenic.jockey.player.REFRESH:minor"; /** * An {@link Intent} action broadcasted when a MusicPlayer has information that should be * presented to the user * @see #INFO_EXTRA_MESSAGE */ public static final String INFO_BROADCAST = "marverenic.jockey.player.INFO"; /** * An {@link Intent} extra sent with {@link #INFO_BROADCAST} intents which maps to a * user-friendly information message */ public static final String INFO_EXTRA_MESSAGE = "marverenic.jockey.player.INFO:MSG"; /** * An {@link Intent} action broadcasted when a MusicPlayer has encountered an error when * setting the current playback source * @see #ERROR_EXTRA_MSG */ public static final String ERROR_BROADCAST = "marverenic.jockey.player.ERROR"; /** * An {@link Intent} extra sent with {@link #ERROR_BROADCAST} intents which maps to a * user-friendly error message */ public static final String ERROR_EXTRA_MSG = "marverenic.jockey.player.ERROR:MSG"; /** * Repeat value that corresponds to repeat none. Playback will continue as normal until and will * end after the last song finishes * @see #setRepeat(int) */ public static final int REPEAT_NONE = 0; /** * Repeat value that corresponds to repeat all. Playback will continue as normal, but the queue * will restart from the beginning once the last song finishes * @see #setRepeat(int) */ public static final int REPEAT_ALL = -1; /** * Repeat value that corresponds to repeat one. When the current song is finished, it will be * repeated. The MusicPlayer will never progress to the next track until the user manually * changes the song. * @see #setRepeat(int) */ public static final int REPEAT_ONE = -2; /** * Defines the threshold for skip previous behavior. If the current seek position in the song is * greater than this value, {@link #skipPrevious()} will seek to the beginning of the song. * If the current seek position is less than this threshold, then the queue index will be * decremented and the previous song in the queue will be played. * This value is measured in milliseconds and is currently set to 5 seconds * @see #skipPrevious() */ private static final int SKIP_PREVIOUS_THRESHOLD = 5000; /** * Defines the minimum duration that must be passed for a song to be considered "played" when * logging play counts * This value is measured in milliseconds and is currently set to 24 seconds */ private static final int PLAY_COUNT_THRESHOLD = 24000; /** * Defines the maximum duration that a song can reach to be considered "skipped" when logging * play counts * This value is measured in milliseconds and is currently set to 20 seconds */ private static final int SKIP_COUNT_THRESHOLD = 20000; /** * The volume scalar to set when {@link AudioManager} causes a MusicPlayer instance to duck */ private static final float DUCK_VOLUME = 0.5f; private QueuedMediaPlayer mMediaPlayer; private Context mContext; private Handler mHandler; private MediaSessionCompat mMediaSession; private HeadsetListener mHeadphoneListener; private OnPlaybackChangeListener mCallback; private List<Song> mQueue; private List<Song> mQueueShuffled; private boolean mShuffle; private int mRepeat; private int mMultiRepeat; /** * Whether this MusicPlayer has focus from {@link AudioManager} to play audio * @see #getFocus() */ private boolean mFocused = false; /** * Whether playback should continue once {@link AudioManager} returns focus to this MusicPlayer * @see #onAudioFocusChange(int) */ private boolean mResumeOnFocusGain = false; private boolean mResumeOnHeadphonesConnect; /** * The album artwork of the current song */ private Bitmap mArtwork; @Inject PlayCountStore mPlayCountStore; private RemotePreferenceStore mRemotePreferenceStore; private final Runnable mSleepTimerRunnable = this::onSleepTimerEnd; /** * Creates a new MusicPlayer with an empty queue. The backing {@link android.media.MediaPlayer} * will create a wakelock (specified by {@link PowerManager#PARTIAL_WAKE_LOCK}), and all * system integration will be initialized * @param context A Context used to interact with other components of the OS and used to * load songs. This Context will be kept for the lifetime of this Object. */ public MusicPlayer(Context context) { mContext = context; mHandler = new Handler(); JockeyApplication.getComponent(mContext).inject(this); mRemotePreferenceStore = new RemotePreferenceStore(mContext); // Initialize play count store mPlayCountStore.refresh() .subscribe(complete -> { Timber.i("init: Initialized play count store values"); }, throwable -> { Timber.e(throwable, "init: Failed to read play count store values"); }); // Initialize the media player mMediaPlayer = new QueuedExoPlayer(context); mMediaPlayer.setPlaybackEventListener(this); mQueue = new ArrayList<>(); mQueueShuffled = new ArrayList<>(); // Attach a HeadsetListener to respond to headphone events mHeadphoneListener = new HeadsetListener(this); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_HEADSET_PLUG); filter.addAction(ACTION_AUDIO_BECOMING_NOISY); context.registerReceiver(mHeadphoneListener, filter); loadPrefs(); initMediaSession(); } /** * Reloads shuffle and repeat preferences from {@link SharedPreferences} */ private void loadPrefs() { Timber.i("Loading SharedPreferences..."); // SharedPreferenceStore is backed by an instance of SharedPreferences. Because // SharedPreferences isn't safe to use across processes, the only time we can get valid // data is right after we open the SharedPreferences for the first time in this process. // // We're going to take advantage of that here so that we can load the latest preferences // as soon as the MusicPlayer is started (which should be the same time that this process // is started). To update these preferences, see updatePreferences(preferenceStore) PreferenceStore preferenceStore = new SharedPreferenceStore(mContext); mShuffle = preferenceStore.isShuffled(); setRepeat(preferenceStore.getRepeatMode()); setMultiRepeat(mRemotePreferenceStore.getMultiRepeatCount()); initEqualizer(preferenceStore); startSleepTimer(mRemotePreferenceStore.getSleepTimerEndTime()); mResumeOnHeadphonesConnect = preferenceStore.resumeOnHeadphonesConnect(); } /** * Updates shuffle and repeat preferences from a Preference Store * @param preferencesStore The preference store to read values from */ public void updatePreferences(ReadOnlyPreferenceStore preferencesStore) { Timber.i("Updating preferences..."); if (preferencesStore.isShuffled() != mShuffle) { setShuffle(preferencesStore.isShuffled()); } mResumeOnHeadphonesConnect = preferencesStore.resumeOnHeadphonesConnect(); setRepeat(preferencesStore.getRepeatMode()); initEqualizer(preferencesStore); } /** * Initiate a MediaSession to allow the Android system to interact with the player */ private void initMediaSession() { Timber.i("Initializing MediaSession"); MediaSessionCompat session = new MediaSessionCompat(mContext, TAG, null, null); session.setCallback(new MediaSessionCallback(this)); session.setSessionActivity( PendingIntent.getActivity( mContext, 0, MainActivity.newNowPlayingIntent(mContext) .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_CANCEL_CURRENT)); session.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); PlaybackStateCompat.Builder state = new PlaybackStateCompat.Builder() .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SEEK_TO | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS | PlaybackStateCompat.ACTION_STOP) .setState(PlaybackStateCompat.STATE_NONE, 0, 0f); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setClass(mContext, MediaButtonReceiver.class); PendingIntent mbrIntent = PendingIntent.getBroadcast(mContext, 0, mediaButtonIntent, 0); session.setMediaButtonReceiver(mbrIntent); session.setPlaybackState(state.build()); session.setActive(true); mMediaSession = session; } /** * Reload all equalizer settings from SharedPreferences */ private void initEqualizer(ReadOnlyPreferenceStore preferencesStore) { Timber.i("Initializing equalizer"); mMediaPlayer.setEqualizer(preferencesStore.getEqualizerEnabled(), preferencesStore.getEqualizerSettings()); } /** * Saves the player's current state to a file with the name {@link #QUEUE_FILE} in * the app's external files directory specified by {@link Context#getExternalFilesDir(String)} * @throws IOException * @see #loadState() */ public void saveState() throws IOException { Timber.i("Saving player state"); // Anticipate the outcome of a command so that if we're killed right after it executes, // we can restore to the proper state int reloadSeekPosition = mMediaPlayer.getCurrentPosition(); int reloadQueuePosition = mMediaPlayer.getQueueIndex(); final String currentPosition = Integer.toString(reloadSeekPosition); final String queuePosition = Integer.toString(reloadQueuePosition); final String queueLength = Integer.toString(mQueue.size()); StringBuilder queue = new StringBuilder(); for (Song s : mQueue) { queue.append(' ').append(s.getSongId()); } StringBuilder queueShuffled = new StringBuilder(); for (Song s : mQueueShuffled) { queueShuffled.append(' ').append(s.getSongId()); } String output = currentPosition + " " + queuePosition + " " + queueLength + queue + queueShuffled; File save = new File(mContext.getExternalFilesDir(null), QUEUE_FILE); FileOutputStream stream = null; try { stream = new FileOutputStream(save); stream.write(output.getBytes()); } finally { if (stream != null) { stream.close(); } } } /** * Reloads a saved state * @see #saveState() */ public void loadState() { Timber.i("Loading state..."); Scanner scanner = null; try { File save = new File(mContext.getExternalFilesDir(null), QUEUE_FILE); scanner = new Scanner(save); int currentPosition = scanner.nextInt(); int queuePosition = scanner.nextInt(); int queueLength = scanner.nextInt(); long[] queueIDs = new long[queueLength]; for (int i = 0; i < queueLength; i++) { queueIDs[i] = scanner.nextInt(); } mQueue = MediaStoreUtil.buildSongListFromIds(queueIDs, mContext); long[] shuffleQueueIDs; if (scanner.hasNextInt()) { shuffleQueueIDs = new long[queueLength]; for (int i = 0; i < queueLength; i++) { shuffleQueueIDs[i] = scanner.nextInt(); } mQueueShuffled = MediaStoreUtil.buildSongListFromIds(shuffleQueueIDs, mContext); } else if (mShuffle) { shuffleQueue(queuePosition); } setBackingQueue(queuePosition); mMediaPlayer.seekTo(currentPosition); mArtwork = Util.fetchFullArt(mContext, getNowPlaying()); } catch(FileNotFoundException ignored) { Timber.i("State does not exist. Using empty state"); // If there's no queue file, just restore to an empty state } catch (IllegalArgumentException|NoSuchElementException e) { Timber.i(e, "Failed to parse previous state. Resetting..."); mQueue.clear(); mQueueShuffled.clear(); mMediaPlayer.reset(); } finally { if (scanner != null) { scanner.close(); } } } /** * Sets a callback for when the current song changes (no matter the source of the change) * @param listener The callback to be registered. {@code null} may be passed in to remove a * previously registered listener. Only one callback may be registered at * a time. */ public void setPlaybackChangeListener(OnPlaybackChangeListener listener) { mCallback = listener; } /** * Updates the metadata in the attached {@link MediaSessionCompat} */ private void updateMediaSession() { Timber.i("Updating MediaSession"); if (getNowPlaying() != null) { Song nowPlaying = getNowPlaying(); MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, nowPlaying.getSongName()) .putString(MediaMetadataCompat.METADATA_KEY_TITLE, nowPlaying.getSongName()) .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, nowPlaying.getAlbumName()) .putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, nowPlaying.getAlbumName()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, nowPlaying.getArtistName()) .putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, nowPlaying.getArtistName()) .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, getDuration()) .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, mArtwork); mMediaSession.setMetadata(metadataBuilder.build()); PlaybackStateCompat.Builder state = new PlaybackStateCompat.Builder().setActions( PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SEEK_TO | PlaybackStateCompat.ACTION_STOP | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS); if (mMediaPlayer.isPlaying()) { state.setState(PlaybackStateCompat.STATE_PLAYING, getCurrentPosition(), 1f); } else if (mMediaPlayer.isPaused()) { state.setState(PlaybackStateCompat.STATE_PAUSED, getCurrentPosition(), 1f); } else if (mMediaPlayer.isStopped()) { state.setState(PlaybackStateCompat.STATE_STOPPED, getCurrentPosition(), 1f); } else { state.setState(PlaybackStateCompat.STATE_NONE, getCurrentPosition(), 1f); } mMediaSession.setPlaybackState(state.build()); } Timber.i("Sending minor broadcast to update UI process"); Intent broadcast = new Intent(UPDATE_BROADCAST) .putExtra(UPDATE_EXTRA_MINOR, true); mContext.sendBroadcast(broadcast, null); } @Override public void onAudioFocusChange(int focusChange) { Timber.i("AudioFocus changed (%d)", focusChange); switch (focusChange) { case AudioManager.AUDIOFOCUS_LOSS: Timber.i("Focus lost. Pausing music."); mFocused = false; mResumeOnFocusGain = false; pause(); break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: Timber.i("Focus lost transiently. Pausing music."); boolean resume = isPlaying() || mResumeOnFocusGain; mFocused = false; pause(); mResumeOnFocusGain = resume; break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: Timber.i("Focus lost transiently. Ducking."); mMediaPlayer.setVolume(DUCK_VOLUME); break; case AudioManager.AUDIOFOCUS_GAIN: Timber.i("Regained AudioFocus"); mMediaPlayer.setVolume(1f); if (mResumeOnFocusGain) play(); mResumeOnFocusGain = false; break; default: Timber.i("Ignoring AudioFocus state change"); break; } updateNowPlaying(); updateUi(); } @Internal boolean shouldResumeOnHeadphonesConnect() { AudioManager manager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); return mResumeOnHeadphonesConnect && (mFocused || !manager.isMusicActive()); } /** * Notifies the attached {@link MusicPlayer.OnPlaybackChangeListener} that a playback change * has occurred, and updates the attached {@link MediaSessionCompat} */ private void updateNowPlaying() { Timber.i("updateNowPlaying() called"); updateMediaSession(); if (mCallback != null) { mCallback.onPlaybackChange(); } } /** * Called to notify the UI thread to refresh any player data when the player changes states * on its own (Like when a song finishes) */ protected void updateUi() { Timber.i("Sending broadcast to update UI process"); Intent broadcast = new Intent(UPDATE_BROADCAST) .putExtra(UPDATE_EXTRA_MINOR, false); mContext.sendBroadcast(broadcast, null); } /** * Called to notify the UI thread that an error has occurred. The typical listener will show the * message passed in to the user. * @param message A user-friendly message associated with this error that may be shown in the UI */ protected void postError(String message) { Timber.i("Posting error to UI process: %s", message); mContext.sendBroadcast( new Intent(ERROR_BROADCAST).putExtra(ERROR_EXTRA_MSG, message), null); } /** * Called to notify the UI thread of a non-critical event. The typical listener will show the * message passed in to the user * @param message A user-friendly message associated with this event that may be shown in the UI */ protected void postInfo(String message) { Timber.i("Posting info to UI process: %s", message); mContext.sendBroadcast( new Intent(INFO_BROADCAST).putExtra(INFO_EXTRA_MESSAGE, message), null); } /** * Gain Audio focus from the system if we don't already have it * @return whether we have gained focus (or already had it) */ private boolean getFocus() { if (!mFocused) { Timber.i("Requesting AudioFocus..."); AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int response = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); mFocused = response == AudioManager.AUDIOFOCUS_REQUEST_GRANTED; } return mFocused; } /** * Generates a new random permutation of the queue, and sets it as the backing * {@link QueuedMediaPlayer}'s queue * @param currentIndex The index of the current song which will be moved to the top of the * shuffled queue */ private void shuffleQueue(int currentIndex) { Timber.i("Shuffling queue..."); ArrayList<Song> shuffled = new ArrayList<>(mQueue); if (!shuffled.isEmpty()) { Song first = shuffled.remove(currentIndex); Collections.shuffle(shuffled); shuffled.add(0, first); } mQueueShuffled = Collections.unmodifiableList(shuffled); } /** * Called when disabling shuffle to ensure that any modifications made to the shuffled queue * are applied to the unshuffled queue. Currently, the only such modification is song deletions * since they are implemented on the client side. */ private void unshuffleQueue() { List<Song> unshuffled = new ArrayList<>(mQueue); List<Song> songs = new ArrayList<>(mQueueShuffled); Iterator<Song> unshuffledIterator = unshuffled.iterator(); while (unshuffledIterator.hasNext()) { Song song = unshuffledIterator.next(); if (!songs.remove(song)) { unshuffledIterator.remove(); } } mQueue = Collections.unmodifiableList(unshuffled); } /** * Toggles playback between playing and paused states * @see #play() * @see #pause() */ public void togglePlay() { Timber.i("Toggling playback"); if (isPlaying()) { pause(); } else if (mMediaPlayer.isComplete()) { mMediaPlayer.setQueueIndex(0); play(); } else { play(); } } /** * Pauses music playback */ public void pause() { Timber.i("Pausing playback"); if (isPlaying()) { mMediaPlayer.pause(); updateNowPlaying(); } mResumeOnFocusGain = false; } /** * Starts or resumes music playback */ public void play() { Timber.i("Resuming playback"); if (!isPlaying() && getFocus()) { mMediaPlayer.play(); updateNowPlaying(); } } /** * Skips to the next song in the queue and logs a play count or skip count * If repeat all is enabled, the queue will loop from the beginning when it it is finished. * Otherwise, calling this method when the last item in the queue is being played will stop * playback * @see #setRepeat(int) to set the current repeat mode */ public void skip() { Timber.i("Skipping song"); if (!mMediaPlayer.isComplete() && !mMediaPlayer.hasError()) { logPlay(); } setMultiRepeat(0); if (mMediaPlayer.getQueueIndex() < mQueue.size() - 1 || mRepeat == REPEAT_ALL) { // If we're in the middle of the queue, or repeat all is on, start the next song mMediaPlayer.skip(); } else { mMediaPlayer.setQueueIndex(0); mMediaPlayer.pause(); } } /** * Records a play or skip for the current song based on the current time of the backing * {@link MediaPlayer} as returned by {@link #getCurrentPosition()} */ private void logPlay() { Timber.i("Logging play count..."); if (getNowPlaying() != null) { if (getCurrentPosition() > PLAY_COUNT_THRESHOLD || getCurrentPosition() > getDuration() / 2) { // Log a play if we're passed a certain threshold or more than 50% in a song // (whichever is smaller) Timber.i("Marking song as played"); logPlayCount(getNowPlaying(), false); } else if (getCurrentPosition() < SKIP_COUNT_THRESHOLD) { // If we're not very far into this song, log a skip Timber.i("Marking song as skipped"); logPlayCount(getNowPlaying(), true); } else { Timber.i("Not writing play count. Song was neither played nor skipped."); } } } /** * Record a play or skip for a certain song * @param song the song to change the play count of * @param skip Whether the song was skipped (true if skipped, false if played) */ private void logPlayCount(Song song, boolean skip) { Timber.i("Logging %s count to PlayCountStore for %s...", (skip) ? "skip" : "play", song.toString()); if (skip) { mPlayCountStore.incrementSkipCount(song); } else { mPlayCountStore.incrementPlayCount(song); mPlayCountStore.setPlayDateToNow(song); } Timber.i("Writing PlayCountStore to disk..."); mPlayCountStore.save(); } /** * Skips to the previous song in the queue * If the song's current position is more than 5 seconds or 50% of the song (whichever is * smaller), then the song will be restarted from the beginning instead. * If this is called when the first item in the queue is being played, it will loop to the last * song if repeat all is enabled, otherwise the current song will always be restarted * @see #setRepeat(int) to set the current repeat mode */ public void skipPrevious() { Timber.i("skipPrevious() called"); if ((getQueuePosition() == 0 && mRepeat != REPEAT_ALL) || getCurrentPosition() > SKIP_PREVIOUS_THRESHOLD || getCurrentPosition() > getDuration() / 2) { Timber.i("Restarting current song..."); mMediaPlayer.seekTo(0); mMediaPlayer.play(); updateNowPlaying(); } else { Timber.i("Starting previous song..."); mMediaPlayer.skipPrevious(); } } /** * Stops music playback */ public void stop() { Timber.i("stop() called"); pause(); seekTo(0); } /** * Seek to a specified position in the current song * @param mSec The time (in milliseconds) to seek to * @see MediaPlayer#seekTo(int) */ public void seekTo(int mSec) { Timber.i("Seeking to %d", mSec); mMediaPlayer.seekTo(mSec); } /** * @return The {@link Song} that is currently being played */ public Song getNowPlaying() { return mMediaPlayer.getNowPlaying(); } /** * @return Whether music is being played or not * @see MediaPlayer#isPlaying() */ public boolean isPlaying() { return mMediaPlayer.isPlaying(); } /** * @return The current queue. If shuffle is enabled, then the shuffled queue will be returned, * otherwise the regular queue will be returned */ public List<Song> getQueue() { // If you're using this method on the UI thread, consider replacing this method with // return new ArrayList<>(mMediaPlayer.getQueue()); // to prevent components from accidentally changing the backing queue return mMediaPlayer.getQueue(); } /** * @return The current index in the queue that is being played */ public int getQueuePosition() { return mMediaPlayer.getQueueIndex(); } /** * @return The number of items in the current queue */ public int getQueueSize() { return mMediaPlayer.getQueueSize(); } /** * @return The current seek position of the song that is playing * @see MediaPlayer#getCurrentPosition() */ public int getCurrentPosition() { return mMediaPlayer.getCurrentPosition(); } /** * @return The length of the current song in milliseconds * @see MediaPlayer#getDuration() */ public int getDuration() { return mMediaPlayer.getDuration(); } /** * Changes the current index of the queue and starts playback from this new position * @param position The index in the queue to skip to * @throws IllegalArgumentException if {@code position} is not between 0 and the queue length */ public void changeSong(int position) { Timber.i("changeSong called (position = %d)", position); mMediaPlayer.setQueueIndex(position); play(); } /** * Changes the current queue and starts playback from the current index * @param queue The replacement queue * @see #setQueue(List, int) to change the current index simultaneously * @throws IllegalArgumentException if the current index cannot be applied to the updated queue */ public void setQueue(@NonNull List<Song> queue) { Timber.i("setQueue called (%d songs)", queue.size()); setQueue(queue, mMediaPlayer.getQueueIndex()); } /** * Changes the current queue and starts playback from the specified index * @param queue The replacement queue * @param index The index to start playback from * @throws IllegalArgumentException if {@code index} is not between 0 and the queue length */ public void setQueue(@NonNull List<Song> queue, int index) { Timber.i("setQueue called (%d songs)", queue.size()); // If you're using this method on the UI thread, consider replacing the first line in this // method with "mQueue = new ArrayList<>(queue);" // to prevent components from accidentally changing the backing queue mQueue = Collections.unmodifiableList(queue); if (mShuffle) { Timber.i("Shuffling new queue and starting from beginning"); shuffleQueue(index); setBackingQueue(0); } else { Timber.i("Setting new backing queue (starting at index %d)", index); setBackingQueue(index); } seekTo(0); } /** * Changes the order of the current queue without interrupting playback * @param queue The modified queue. This List should contain all of the songs currently in the * queue, but in a different order to prevent discrepancies between the shuffle * and non-shuffled queue. * @param index The index of the song that is currently playing in the modified queue */ public void editQueue(@NonNull List<Song> queue, int index) { Timber.i("editQueue called (index = %d)", index); if (mShuffle) { mQueueShuffled = Collections.unmodifiableList(queue); } else { mQueue = Collections.unmodifiableList(queue); } setBackingQueue(index); } /** * Helper method to push changes in the queue to the backing {@link QueuedMediaPlayer} * @see #setBackingQueue(int) */ private void setBackingQueue() { Timber.i("setBackingQueue() called"); setBackingQueue(mMediaPlayer.getQueueIndex()); } /** * Helper method to push changes in the queue to the backing {@link QueuedMediaPlayer}. This * method will set the queue to the appropriate shuffled or ordered list and apply the * specified index as the replacement queue position * @param index The new queue index to send to the backing {@link QueuedMediaPlayer}. */ private void setBackingQueue(int index) { Timber.i("setBackingQueue() called (index = %d)", index); if (mShuffle) { mMediaPlayer.setQueue(mQueueShuffled, index); } else { mMediaPlayer.setQueue(mQueue, index); } } /** * Sets the repeat option to control what happens when a track finishes. * @param repeat An integer representation of the repeat option. May be one of either * {@link #REPEAT_NONE}, {@link #REPEAT_ALL}, {@link #REPEAT_ONE}. */ public void setRepeat(int repeat) { Timber.i("Changing repeat setting to %d", repeat); mRepeat = repeat; switch (repeat) { case REPEAT_ALL: mMediaPlayer.enableRepeatAll(); break; case REPEAT_ONE: mMediaPlayer.enableRepeatOne(); break; case REPEAT_NONE: default: mMediaPlayer.enableRepeatNone(); } } /** * Sets the Multi-Repeat counter to repeat a song {@code count} times before proceeding to the * next song * @param count The number of times to repeat the song. When multi-repeat is enabled, the * current song will be played back-to-back for the specified number of loops. * Once this counter decrements to 0, playback will resume as it was before and the * previous repeat option will be restored unless it was previously Repeat All. If * Repeat All was enabled before Multi-Repeat, the repeat setting will be reset to * Repeat none. */ public void setMultiRepeat(int count) { Timber.i("Changing Multi-Repeat counter to %d", count); mMultiRepeat = count; mRemotePreferenceStore.setMultiRepeatCount(count); if (count > 1) { mMediaPlayer.enableRepeatOne(); } else { setRepeat(mRepeat); } } /** * Gets the current Multi-Repeat status * @return The number of times that the current song will be played back-to-back. This is * decremented when the song finishes. If Multi-Repeat is disabled, this method * will return {@code 0}. */ public int getMultiRepeatCount() { return mMultiRepeat; } /** * Enables or updates the sleep timer to pause music at a specified timestamp * @param endTimestampInMillis The timestamp to pause music. This is in milliseconds since the * Unix epoch as returned by {@link System#currentTimeMillis()}. */ public void setSleepTimer(long endTimestampInMillis) { Timber.i("Changing sleep timer end time to %d", endTimestampInMillis); startSleepTimer(endTimestampInMillis); mRemotePreferenceStore.setSleepTimerEndTime(endTimestampInMillis); } /** * Internal method for setting up the system timer to pause music. * @param endTimestampInMillis The timestamp to pause music in milliseconds since the Unix epoch * @see #setSleepTimer(long) */ private void startSleepTimer(long endTimestampInMillis) { if (endTimestampInMillis <= System.currentTimeMillis()) { Timber.i("Sleep timer end time (%1$d) is in the past (currently %2$d). Stopping timer", endTimestampInMillis, System.currentTimeMillis()); mHandler.removeCallbacks(mSleepTimerRunnable); } else { long delay = endTimestampInMillis - System.currentTimeMillis(); Timber.i("Setting sleep timer for %d ms", delay); mHandler.postDelayed(mSleepTimerRunnable, delay); } } /** * Internal method called once the sleep timer is triggered. * @see #setSleepTimer(long) to set the sleep timer * @see #startSleepTimer(long) for the sleep timer setup */ private void onSleepTimerEnd() { Timber.i("Sleep timer ended."); pause(); updateUi(); postInfo(mContext.getString(R.string.confirm_sleep_timer_end)); } /** * Gets the current end time of the sleep timer. * @return The current end time of the sleep timer in milliseconds since the Unix epoch. This * method returns {@code 0} if the sleep timer is disabled. */ public long getSleepTimerEndTime() { return mRemotePreferenceStore.getSleepTimerEndTime(); } /** * Sets the shuffle option and immediately applies it to the queue * @param shuffle The new shuffle option. {@code true} will switch the current playback to a * copy of the current queue in a randomized order. {@code false} will restore * the queue to its original order. */ public void setShuffle(boolean shuffle) { if (shuffle) { Timber.i("Enabling shuffle..."); shuffleQueue(getQueuePosition()); mMediaPlayer.setQueue(mQueueShuffled, 0); } else { Timber.i("Disabling shuffle..."); unshuffleQueue(); int position = mQueue.indexOf(getNowPlaying()); mMediaPlayer.setQueue(mQueue, position); } mShuffle = shuffle; updateNowPlaying(); } /** * Adds a {@link Song} to the queue to be played after the current song * @param song the song to enqueue */ public void queueNext(Song song) { Timber.i("queueNext(Song) called"); int index = mQueue.isEmpty() ? 0 : mMediaPlayer.getQueueIndex() + 1; List<Song> shuffledQueue = new ArrayList<>(mQueueShuffled); List<Song> queue = new ArrayList<>(mQueue); if (mShuffle) { shuffledQueue.add(index, song); queue.add(song); } else { queue.add(index, song); } mQueueShuffled = Collections.unmodifiableList(shuffledQueue); mQueue = Collections.unmodifiableList(queue); setBackingQueue(); } /** * Adds a {@link List} of {@link Song}s to the queue to be played after the current song * @param songs The songs to enqueue */ public void queueNext(List<Song> songs) { Timber.i("queueNext(List<Song>) called"); int index = mQueue.isEmpty() ? 0 : mMediaPlayer.getQueueIndex() + 1; List<Song> shuffledQueue = new ArrayList<>(mQueueShuffled); List<Song> queue = new ArrayList<>(mQueue); if (mShuffle) { shuffledQueue.addAll(index, songs); queue.addAll(songs); } else { queue.addAll(index, songs); } mQueueShuffled = Collections.unmodifiableList(shuffledQueue); mQueue = Collections.unmodifiableList(queue); setBackingQueue(); } /** * Adds a {@link Song} to the end of the queue * @param song The song to enqueue */ public void queueLast(Song song) { Timber.i("queueLast(Song) called"); List<Song> shuffledQueue = new ArrayList<>(mQueueShuffled); List<Song> queue = new ArrayList<>(mQueue); if (mShuffle) { shuffledQueue.add(song); queue.add(song); } else { queue.add(song); } mQueueShuffled = Collections.unmodifiableList(shuffledQueue); mQueue = Collections.unmodifiableList(queue); setBackingQueue(); } /** * Adds a {@link List} of {@link Song}s to the end of the queue * @param songs The songs to enqueue */ public void queueLast(List<Song> songs) { Timber.i("queueLast(List<Song>)"); List<Song> shuffledQueue = new ArrayList<>(mQueueShuffled); List<Song> queue = new ArrayList<>(mQueue); if (mShuffle) { shuffledQueue.addAll(songs); queue.addAll(songs); } else { queue.addAll(songs); } mQueueShuffled = Collections.unmodifiableList(shuffledQueue); mQueue = Collections.unmodifiableList(queue); setBackingQueue(); } /** * Releases all resources and bindings associated with this MusicPlayer. * Once this is called, this MusicPlayer can no longer be used. */ public void release() { Timber.i("release() called"); ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE)).abandonAudioFocus(this); mContext.unregisterReceiver(mHeadphoneListener); // Make sure to disable the sleep timer to purge any delayed runnables in the message queue startSleepTimer(0); mFocused = false; mCallback = null; mMediaPlayer.stop(); mMediaPlayer.release(); mMediaSession.release(); mMediaPlayer = null; mContext = null; } protected MediaSessionCompat getMediaSession() { return mMediaSession; } @Override public void onCompletion(Song completed) { Timber.i("onCompletion called"); logPlayCount(completed, false); if (mMultiRepeat > 1) { Timber.i("Multi-Repeat (%d) is enabled. Restarting current song and decrementing.", mMultiRepeat); setMultiRepeat(mMultiRepeat - 1); updateNowPlaying(); updateUi(); } else if (mMediaPlayer.isComplete()) { updateNowPlaying(); updateUi(); } } @Override public void onSongStart() { Timber.i("Started new song"); mArtwork = Util.fetchFullArt(mContext, getNowPlaying()); updateNowPlaying(); updateUi(); } @Override public boolean onError(Throwable error) { Timber.i(error, "Sending error message to UI..."); postError(mContext.getString( R.string.message_play_error_io_exception, getNowPlaying().getSongName())); if (mQueue.size() > 1) { skip(); } else { stop(); } return true; } /** * Creates a snapshot of the current player state including the state of the queue, * seek position, playing status, etc. This is useful for undoing modifications to the state. * @return A {@link PlayerState} object with the current status of this MusicPlayer instance. * @see #restorePlayerState(PlayerState) To restore this state */ public PlayerState getState() { return new PlayerState.Builder() .setPlaying(isPlaying()) .setQueuePosition(getQueuePosition()) .setQueue(mQueue) .setShuffledQueue(mQueueShuffled) .setSeekPosition(getCurrentPosition()) .build(); } /** * Restores a player state created from {@link #getState()}. * @param state The state to be restored. All properties including seek position and playing * status will immediately be applied. */ public void restorePlayerState(PlayerState state) { mQueue = Collections.unmodifiableList(state.getQueue()); mQueueShuffled = Collections.unmodifiableList(state.getShuffledQueue()); setBackingQueue(state.getQueuePosition()); seekTo(state.getSeekPosition()); if (state.isPlaying()) { play(); } else { pause(); } updateNowPlaying(); updateUi(); } /** * A callback for receiving information about song changes -- useful for integrating * {@link MusicPlayer} with other components */ public interface OnPlaybackChangeListener { /** * Called when a MusicPlayer changes songs. This method will always be called, even if the * event was caused by an external source. Implement and attach this callback to provide * more integration with external sources which requires up-to-date song information * (i.e. to post a notification) * * This method will only be called after the current song changes -- not when the * {@link MediaPlayer} changes states. */ void onPlaybackChange(); } private static class MediaSessionCallback extends MediaSessionCompat.Callback { /** * A period of time added after a remote button press to delay handling the event. This * delay allows the user to press the remote button multiple times to execute different * actions */ private static final int REMOTE_CLICK_SLEEP_TIME_MS = 300; private int mClickCount; private MusicPlayer mMusicPlayer; private Handler mHandler; MediaSessionCallback(MusicPlayer musicPlayer) { mHandler = new Handler(); mMusicPlayer = musicPlayer; } private final Runnable mButtonHandler = () -> { if (mClickCount == 1) { mMusicPlayer.togglePlay(); mMusicPlayer.updateUi(); } else if (mClickCount == 2) { onSkipToNext(); } else { onSkipToPrevious(); } mClickCount = 0; }; @Override public boolean onMediaButtonEvent(Intent mediaButtonEvent) { KeyEvent keyEvent = mediaButtonEvent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK) { if (keyEvent.getAction() == KeyEvent.ACTION_UP && !keyEvent.isLongPress()) { onRemoteClick(); } return true; } else { return super.onMediaButtonEvent(mediaButtonEvent); } } private void onRemoteClick() { mClickCount++; mHandler.removeCallbacks(mButtonHandler); mHandler.postDelayed(mButtonHandler, REMOTE_CLICK_SLEEP_TIME_MS); } @Override public void onPlay() { mMusicPlayer.play(); mMusicPlayer.updateUi(); } @Override public void onSkipToQueueItem(long id) { mMusicPlayer.changeSong((int) id); mMusicPlayer.updateUi(); } @Override public void onPause() { mMusicPlayer.pause(); mMusicPlayer.updateUi(); } @Override public void onSkipToNext() { mMusicPlayer.skip(); mMusicPlayer.updateUi(); } @Override public void onSkipToPrevious() { mMusicPlayer.skipPrevious(); mMusicPlayer.updateUi(); } @Override public void onStop() { mMusicPlayer.stop(); // Don't update the UI if this object has been released if (mMusicPlayer.mContext != null) { mMusicPlayer.updateUi(); } } @Override public void onSeekTo(long pos) { mMusicPlayer.seekTo((int) pos); mMusicPlayer.updateUi(); } } /** * Receives headphone connect and disconnect intents so that music may be paused when headphones * are disconnected */ public static class HeadsetListener extends BroadcastReceiver { private MusicPlayer mInstance; public HeadsetListener(MusicPlayer instance) { mInstance = instance; } @Override public void onReceive(Context context, Intent intent) { if (isInitialStickyBroadcast()) { return; } Timber.i("onReceive: %s", intent); boolean plugged, unplugged; if (ACTION_HEADSET_PLUG.equals(intent.getAction())) { unplugged = intent.getIntExtra("state", -1) == 0; plugged = intent.getIntExtra("state", -1) == 1; } else { unplugged = plugged = false; } boolean becomingNoisy = ACTION_AUDIO_BECOMING_NOISY.equals(intent.getAction()); if (unplugged || becomingNoisy) { mInstance.pause(); mInstance.updateUi(); } else if (plugged && mInstance.shouldResumeOnHeadphonesConnect()) { mInstance.play(); mInstance.updateUi(); } } } }
[ "marverenic@gmail.com" ]
marverenic@gmail.com
5a57077f4e4df7b35b374f2f6e32ff284bc28df1
c30eaa08440d489990c8dbed0d714130a52220a1
/src/com/luv2code/springdemo/HappyFortuneService.java
350b33438716c6c7dcc70ba27b5447460aa5acc6
[]
no_license
SudalaiM/Spring_Boot
7516f7c2c8df84117366b96cbc06456968b120e8
832df91e25b40107bd48117fc530f5da8623247c
refs/heads/master
2020-11-25T18:26:30.675537
2019-12-18T08:49:53
2019-12-18T08:49:53
228,792,649
0
0
null
null
null
null
UTF-8
Java
false
false
180
java
package com.luv2code.springdemo; public class HappyFortuneService implements FortuneService { @Override public String getFortune() { return "Today Is Your Lucky Day!"; } }
[ "sudalai@admin-PC.cognitivemobile.local" ]
sudalai@admin-PC.cognitivemobile.local
7bbd3057cc134da690b317a7c1383c7ac84991a1
84d67cfe9c6c1ddb2739d3e83b3af72c72313931
/Dir/src/ru/sapteh/Main.java
72c0802b65c5562f1362433b7fad104898befd63
[]
no_license
catBoris453alexmol/Dir
c67a2ac59690142bedde59c10d0e2da1cd6c5b6d
351cf39515e27347ac5a5e6ad19cfed546d65cdc
refs/heads/main
2023-02-17T18:20:24.872021
2021-01-18T13:27:09
2021-01-18T13:27:09
330,674,174
0
0
null
null
null
null
UTF-8
Java
false
false
1,619
java
package ru.sapteh; import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Input name: "); String path = reader.readLine(); Path sourcePath = Paths.get(path ); //Проход по дереву файлов MyVisitClass myVisitClass = new MyVisitClass(); Files.walkFileTree(sourcePath, myVisitClass); //Создание архива FileOutputStream zipArchive = new FileOutputStream(sourcePath.toString() + ".zip"); ZipOutputStream zip = new ZipOutputStream(zipArchive); ZipEntry ze; for(File filePath : myVisitClass.getFileList()) { if(filePath.isDirectory()){ ze = new ZipEntry(filePath + "/"); zip.putNextEntry(ze); zip.closeEntry(); } else if(filePath.isFile()){ ze = new ZipEntry(filePath.toString()); zip.putNextEntry(ze); Files.copy(filePath.toPath(),zip); zip.closeEntry(); System.out.printf("%-35s %-5d (%-4d) %.0f%%\n", filePath, ze.getSize(), ze.getCompressedSize(), (100 - ((double)ze.getCompressedSize()/ ze.getSize()*100))); } } zip.close(); } }
[ "noreply@github.com" ]
noreply@github.com
478477e2084a0686eb90b63f2ba2b168731c1364
41188a82ce093f69ffea5684bc2cefc866487652
/server-api/src/main/java/org/jboss/capedwarf/server/api/persistence/ProxyingInterceptor.java
8427a16ee69c2d958ab68bbc0c4229faf263b3ab
[]
no_license
alesj/capedwarf-green
787b4cfa1e576bb14c45fca210bfecf9e34ea59f
a1e7a2a9708d3d6a20a8d101b9b8304b136c2cf7
refs/heads/master
2021-01-16T17:41:50.604010
2011-10-21T19:42:42
2011-10-21T19:42:42
1,859,620
0
0
null
null
null
null
UTF-8
Java
false
false
2,283
java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.capedwarf.server.api.persistence; import javax.interceptor.AroundInvoke; import javax.interceptor.Interceptor; import javax.interceptor.InvocationContext; import java.io.Serializable; import java.lang.reflect.Method; import org.jboss.capedwarf.jpa.ProxyingEnum; /** * Proxying interceptor. * * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> */ @Proxying(ProxyingEnum.ENABLE) @Interceptor public class ProxyingInterceptor implements Serializable { private static final long serialVersionUID = 1L; @AroundInvoke public Object aroundInvoke(final InvocationContext invocation) throws Exception { Method method = invocation.getMethod(); Proxying proxying = method.getAnnotation(Proxying.class); if (proxying == null) { Class<?> clazz = invocation.getTarget().getClass(); proxying = clazz.getAnnotation(Proxying.class); } if (proxying != null) { ProxyingEnum pe = proxying.value(); pe.begin(); try { return invocation.proceed(); } finally { pe.end(); } } else { return invocation.proceed(); } } }
[ "ales.justin@gmail.com" ]
ales.justin@gmail.com
82f563b419bab530cf1764612e0578404344b55f
be5c86e8fe3f5836b7d2097dd5272c72b5b28f15
/math/Java/0268-missing-number/src/Solution.java
5decc2ff41b060cdb61ca63dc42b9e7a98e1f322
[ "Apache-2.0" ]
permissive
lemonnader/LeetCode-Solution-Well-Formed
d24674898ceb5441c036016dc30afc58e4a1247a
baabdb1990fd49ab82a712e121f49c4f68b29459
refs/heads/master
2021-04-23T18:49:40.337569
2020-03-24T04:50:27
2020-03-24T04:50:27
249,972,064
1
0
Apache-2.0
2020-03-25T12:26:25
2020-03-25T12:26:24
null
UTF-8
Java
false
false
247
java
public class Solution { public int missingNumber(int[] nums) { int n = nums.length; int sum = (n + 1) * n / 2; for (int i = 0; i < n; i++) { sum -= nums[i]; } return sum; } }
[ "liweiwei1419@gmail.com" ]
liweiwei1419@gmail.com
d617d39a2fc959df40932efe48430cc7d003b4a5
1671d87c2e414de8186570983c65c220888f20b1
/第一阶段/JDBCTest/src/com/atguigu/java2/JdbcConnection.java
a481d618561772e8f4931fec8ab2abd42635b447
[]
no_license
qisirendexudoudou/BigData_0722
4f25b508b4c20088d4155abb2d52e1d39c8b0e81
e474e6ebcbbfedd12f859f0198238f58b73e5bec
refs/heads/master
2022-07-21T17:41:47.611707
2019-11-16T05:59:11
2019-11-16T05:59:11
221,875,869
0
0
null
2022-06-21T02:14:43
2019-11-15T08:10:07
Java
UTF-8
Java
false
false
5,092
java
package com.atguigu.java2; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import org.junit.Test; public class JdbcConnection { /* * 对数据库的操作(查询) */ @Test public void testResultSet() { Connection connection = null; Statement statement = null; ResultSet resultSet = null; try { //1.获取数据库连接 connection = getConnection(); //2.调用Connection对象的CreateaStream()方法获取Statement对象 statement = connection.createStatement(); //3.需要执行的SQL语句 String sql = "select id,name from Student;"; //4.执行sql语句,调用statement对象的executeQuery(sql)方法,得到ResultSet对象 resultSet = statement.executeQuery(sql); //5.处理结果集 //5.1 调用ResultSet的next()方法:查看结果集的下一条记录是否有效,如果有效则指针下移 while (resultSet.next()) { //5.2 getXXX()方法获取列的具体的值 int id = resultSet.getInt(1); String name = resultSet.getString(2); System.out.println("id = " + id + " " + "name = " + name); System.out.println(); } } catch (Exception e) { e.printStackTrace(); } finally { //6. 关闭数据库资源 releaseDB(resultSet, statement, connection); } } /* * 对数据库的操作(增删改) */ @Test public void testStatement() { Connection connection = null; Statement statement = null; try { //1.获取数据库连接 connection = getConnection(); //2.调用Connection对象的CreateaStream()方法获取Statement对象 statement = connection.createStatement(); //3.需要执行的SQL语句 String sql = "insert into Student values(3,'test3')"; // String sql = "update Student set name ='test2' where id = 2;"; // String sql = "delete from Student where id = 1;"; //4.执行sql语句,调用statement对象的executeUpdate()方法 statement.executeUpdate(sql); } catch (Exception e) { e.printStackTrace(); } finally { //5.关闭数据库资源 releaseDB(null, statement, connection); } } //关闭数据库资源的方法 public void releaseDB(ResultSet resultSet, Statement statement, Connection connection) { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { e.printStackTrace(); } } if (statement != null) { try { statement.close(); } catch (Exception e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (Exception e) { e.printStackTrace(); } } } /* * 获取数据库的连接2 */ @Test public void getConnection2() throws Exception { Connection connection = getConnection(); // System.out.println(connection); } //获取数据库连接的方法 private Connection getConnection() throws IOException, ClassNotFoundException, SQLException { Properties properties = new Properties(); InputStream in = JdbcConnection.class.getClassLoader().getSystemResourceAsStream("jdbc.properties"); properties.load(in); //1.从配置文件中读取 连接数据库所需要的四个参数 String user = properties.getProperty("user"); String password = properties.getProperty("password"); String jdbcUrl = properties.getProperty("jdbcUrl"); String driverClass = properties.getProperty("driver"); //2.加载数据库驱动 Class.forName(driverClass); //3.调用DriverManager.getConnection()方法 Connection connection = DriverManager.getConnection(jdbcUrl, user, password); return connection; } /* * 获取数据库连接 */ @Test public void getConnection1() throws Exception { //1.获取连接数据库所需要的四个字符串 String user = "root"; String password = "root"; String jdbcUrl = "jdbc:mysql://127.0.0.1/test"; String driverClass = "com.mysql.jdbc.Driver"; //2.加载数据库驱动 Class.forName(driverClass); //3.调用DriverManager.getConnection()方法 Connection connection = DriverManager.getConnection(jdbcUrl, user, password); System.out.println(connection); } }
[ "546223079@qq.com" ]
546223079@qq.com
ca9e8067033c05c227fe3e22b491c0dacda8761e
455ac8d18441054564df3fe92cf317cad4c5eae5
/evm/src/main/java/tech/pegasys/poc/witnesscodeanalysis/vm/operations/TimestampOperation.java
5b6182f9aa3b198d078d4e1a296599cde8cfe9be
[ "Apache-2.0" ]
permissive
hmijail/codewitness
0c78593d4eda44327946af0659ed63e0adc4b367
eb39ae656648929f71566861d0f7a43c8ffafffd
refs/heads/master
2022-11-07T00:49:44.524305
2020-06-26T22:46:24
2020-06-26T22:46:24
276,542,766
0
0
Apache-2.0
2020-07-02T03:50:33
2020-07-02T03:50:32
null
UTF-8
Java
false
false
1,315
java
/* * Copyright ConsenSys AG. * * 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. * * SPDX-License-Identifier: Apache-2.0 */ package tech.pegasys.poc.witnesscodeanalysis.vm.operations; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.poc.witnesscodeanalysis.vm.AbstractOperation; import tech.pegasys.poc.witnesscodeanalysis.vm.MessageFrame; import org.apache.tuweni.units.bigints.UInt256; public class TimestampOperation extends AbstractOperation { public static final int OPCODE = 0x42; public static Bytes32 MARKER_AND_OPCODE = UInt256.valueOf(DYNAMIC_MARKER + OPCODE).toBytes(); public TimestampOperation() { super(OPCODE, "TIMESTAMP", 0, 1, 1); } @Override public UInt256 execute(final MessageFrame frame) { frame.pushStackItem(MARKER_AND_OPCODE); return UInt256.ZERO; } }
[ "drinkcoffee@eml.cc" ]
drinkcoffee@eml.cc
f38500792c2684f49252ad714957154a6acb095e
064d2e3f54965c5b3f8d7baced48be0c53bb2eae
/testProject/src/designpatterns/decorator/WorkFather.java
a2f074202c54b250164c850652bcff7aebcb5fdd
[]
no_license
ankailiu/testprj
658c735ff0e4f2e37251880f6e05f0df0ba9f198
d4631595547c7f1beda503b37eb7a9c109827674
refs/heads/master
2021-01-01T15:29:59.162912
2015-03-20T06:16:03
2015-03-20T06:16:03
32,307,360
0
1
null
2015-03-18T10:10:45
2015-03-16T07:06:33
Java
UTF-8
Java
false
false
341
java
package designpatterns.decorator; public class WorkFather extends WorkDecorator { public WorkFather(Work work) { super(work); } @Override public void paint() { super.paint(); this.makeFrameForPaint(); } public void makeFrameForPaint(){ System.out.println("Father make a frame for son's paint!"); } }
[ "ankai.liu@lombardrisk.com" ]
ankai.liu@lombardrisk.com
23e1e73a809ce77cd48b73192b1e7275ce700f48
008830a9de75a3aa2e9c8d1059df580b9983aac5
/examples/gdx-autumn-tests/core/src/com/github/czyzby/context/initiate/Initiator.java
a642b40c7f5ee4e835fc4420a11840cd4de9ac5f
[ "Apache-2.0" ]
permissive
JarvisAPI/gdx-lml
0a8ab4f2d7e757509f91b6ae17d4321629fd2373
d3810454bc3cce59319c6c354438ede98646f95e
refs/heads/master
2022-06-06T18:32:06.917031
2019-12-04T16:51:02
2019-12-04T16:51:02
260,815,073
0
0
Apache-2.0
2020-05-03T02:37:46
2020-05-03T02:37:45
null
UTF-8
Java
false
false
1,548
java
package com.github.czyzby.context.initiate; import com.github.czyzby.autumn.annotation.Component; import com.github.czyzby.autumn.annotation.Destroy; import com.github.czyzby.autumn.annotation.Initiate; import com.github.czyzby.kiwi.log.Logger; import com.github.czyzby.kiwi.log.LoggerService; /** {@link Initiate} and {@link Destroy} are annotations that allow you to control the flow of application's creation * and destruction. Both feature a priority setting, which is honored not only in class scope, but in the whole * application scope - if two classes contain method annotated with {@link Initiate}, you can be 100% sure that the * method with higher priority will be invoked first. Both {@link Initiate}- and {@link Destroy}-annotated methods can * consume any parameters that will be injected upon invocation. This class demonstrates use of these annotations. * * @author MJ */ @Component public class Initiator { /** Kiwi logger for this class. */ private static final Logger LOGGER = LoggerService.forClass(Initiator.class); @Initiate(priority = 42) void first() { LOGGER.info("I should be initiated first. I'm {0}.", this); } @Initiate(priority = -42) void last() { LOGGER.info("I should be initiated last."); } @Destroy(priority = 10) void destroy(final Destructor destructor) { LOGGER.info("I should be destroyed after {0}.", destructor); } @Override public String toString() { return "(Initiator[hashCode=" + hashCode() + "])"; } }
[ "john.hervicc@gmail.com" ]
john.hervicc@gmail.com
9beeff78e1c6c30cb890bfe6aac4d54a41b2d2d0
a0f678e4540137f3a3ca31a94b963ac7e2087dc3
/src/hw7Q4Abstraction02/RockefellerUniversity.java
4fd281c73f2bc2154447c363e12b2a8567b5577b
[]
no_license
Imran6th/Enthroll.IT-HW
dbe11ed31c1113d27c69c8a3c3cf8dde23f49d58
3e27230f94b09da1dd22c667c44ec78335b25e0c
refs/heads/main
2023-08-15T05:39:33.412088
2021-09-27T01:34:21
2021-09-27T01:34:21
400,934,012
0
0
null
null
null
null
UTF-8
Java
false
false
128
java
package hw7Q4Abstraction02; public class RockefellerUniversity extends NYUniversity implements College,Hospital,University { }
[ "imran6th@hotmail.com" ]
imran6th@hotmail.com
fa25604cc0a18064b45bbcf90d2d4601c05e4295
02d31dd1cbde6bd98f3fcb94dd842d19776469bc
/src/main/java/artof/designitems/DesignFrame.java
d3d3bf698505558b45c447b831f4d933e29c1828
[]
no_license
delirian/rsf
5e719dd782140421dff786109c9620c0d92f6f83
ad4e147fa3e0b070d1de4ac3ed96de573c40c2d1
refs/heads/master
2021-06-16T01:18:10.679344
2017-02-01T12:16:17
2017-02-01T12:16:17
80,531,589
0
0
null
null
null
null
UTF-8
Java
false
false
10,716
java
package artof.designitems; import artof.database.*; import artof.utils.*; import artof.designer.Designer; import artof.designitems.dialogs.DesignDialogFrames; import artof.materials.*; import java.awt.*; import java.util.*; import java.io.*; import javax.swing.JPanel; import java.awt.image.BufferedImage; /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */ public class DesignFrame extends DesignItem2 implements Cloneable, Externalizable { static final long serialVersionUID = 536631154699809243L; protected static CodeMapper frameMapper = null; public DesignFrame() { //refreshItem(); defColor = UserSettings.DEF_FRAME_COLOR; //createFrameMapper(); } public DesignFrame(double limitWidth, double limitHeight) { super(limitWidth, limitHeight); refreshItem(); defColor = UserSettings.DEF_FRAME_COLOR; createFrameMapper(); } public static void createFrameMapper() { if (frameMapper == null) frameMapper = new CodeMapper(MaterialDets.MAT_FRAME); } public static void rebuildFrameMapper() { frameMapper = new CodeMapper(MaterialDets.MAT_FRAME); } public CodeMapper getCodeMapper() { return frameMapper; } public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); try { out.writeObject(defaultSupplier); } catch (java.io.OptionalDataException e) { } } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); try { defaultSupplier = (String) in.readObject(); } catch (java.io.OptionalDataException e) { } } public Object clone() { return (DesignFrame)super.clone(); } public void refreshItem() { try { MaterialDets dets = ArtofDB.getCurrentDB().getMaterial(itemCode); setColor(dets.getColor()); thickness = dets.getDefaultValues(this.getDefaultSupplier()).getThickness(); leftGap = rightGap = topGap = bottomGap = dets.getDefaultValues(this.getDefaultSupplier()).getWidth(); } catch (NullPointerException e) { // doen niks } } public boolean showPropertyDialog(int titleType, int type) { String title; if (titleType == Designer.TITLE_ADD) title = "Add Frame"; else if (titleType == Designer.TITLE_INSERT) title = "Insert Frame"; else title = "Edit Frame"; DesignDialogFrames dialog = new DesignDialogFrames(title, type, this); if (!dialog.canceled()) setMaterialDets(ArtofDB.getCurrentDB().getMaterial(itemCode)); return dialog.canceled(); } public String getType() { return "Frame"; } public void printSimbool(Graphics2D big, double centerX, double centerY, double scaleFactor) { double baseX = centerX - getOuterWidth() * scaleFactor / 2; double baseY = centerY - getOuterHeight() * scaleFactor / 2; double inBaseX = centerX - getInnerWidth() * scaleFactor / 2; double inBaseY = centerY - getInnerHeight() * scaleFactor / 2; super.printSimbool(big, centerX, centerY, scaleFactor); big.setColor(color.black); //big.setStroke(new BasicStroke(0.5f)); double shifter = 0.0; big.drawLine((int)(baseX + shifter), (int)(baseY + shifter), (int)(inBaseX - shifter), (int)(inBaseY - shifter)); big.drawLine((int)(baseX + getOuterWidth() * scaleFactor - shifter), (int)(baseY + shifter), (int)(inBaseX + getInnerWidth() * scaleFactor + shifter), (int)(inBaseY - shifter)); big.drawLine((int)(baseX + getOuterWidth() * scaleFactor - shifter), (int)(baseY + getOuterHeight() * scaleFactor - shifter), (int)(inBaseX + getInnerWidth() * scaleFactor + shifter), (int)(inBaseY + getInnerHeight() * scaleFactor + shifter)); big.drawLine((int)(baseX + shifter), (int)(baseY + getOuterHeight() * scaleFactor - shifter), (int)(inBaseX - shifter), (int)(inBaseY + getInnerHeight() * scaleFactor + shifter)); } public void drawSimbool(Graphics2D big, double centerX, double centerY, double scaleFactor) { double baseX = centerX - getOuterWidth() * scaleFactor / 2; double baseY = centerY - getOuterHeight() * scaleFactor / 2; double inBaseX = centerX - getInnerWidth() * scaleFactor / 2; double inBaseY = centerY - getInnerHeight() * scaleFactor / 2; if (UserSettings.DES_DRAW_BORDER && !(UserSettings2.DES_USE_IMAGES && materialDets != null && materialDets.isImageAvailable())) { super.drawSimbool(big, centerX, centerY, scaleFactor); big.setColor(UserSettings.DEF_COLOR); double shifter = 2.0; big.drawLine((int)(baseX + shifter), (int)(baseY + shifter), (int)(inBaseX - shifter), (int)(inBaseY - shifter)); big.drawLine((int)(baseX + getOuterWidth() * scaleFactor - shifter), (int)(baseY + shifter), (int)(inBaseX + getInnerWidth() * scaleFactor + shifter), (int)(inBaseY - shifter)); big.drawLine((int)(baseX + getOuterWidth() * scaleFactor - shifter), (int)(baseY + getOuterHeight() * scaleFactor - shifter), (int)(inBaseX + getInnerWidth() * scaleFactor + shifter), (int)(inBaseY + getInnerHeight() * scaleFactor + shifter)); big.drawLine((int)(baseX + shifter), (int)(baseY + getOuterHeight() * scaleFactor - shifter), (int)(inBaseX - shifter), (int)(inBaseY + getInnerHeight() * scaleFactor + shifter)); } if (UserSettings2.DES_USE_IMAGES && materialDets != null && materialDets.isImageAvailable()) { //if (UserSettings2.DES_USE_IMAGES) { // linker deel int[] xPoints = { (int)baseX, (int)(baseX + getLeftGap() * scaleFactor), (int)(baseX + getLeftGap() * scaleFactor), (int)baseX }; int[] yPoints = { (int)baseY, (int)(baseY + getTopGap() * scaleFactor), (int)(baseY + (getOuterHeight() - getBottomGap()) * scaleFactor), (int)(baseY + getOuterHeight() * scaleFactor) }; Polygon profile = new Polygon(xPoints, yPoints, 4); BufferedImage sampleImage = materialDets.getLeftImage(scaleFactor); double offset = baseX % sampleImage.getWidth(); TexturePaint p = new TexturePaint(sampleImage, new Rectangle((int)offset, 0, sampleImage.getWidth(), sampleImage.getHeight())); big.setPaint(p); big.fill(profile); // regter deel xPoints[0] = (int)(baseX + getOuterWidth() * scaleFactor); xPoints[1] = (int)(baseX + getOuterWidth() * scaleFactor); xPoints[2] = (int)(baseX + (getOuterWidth() - getRightGap()) * scaleFactor); xPoints[3] = (int)(baseX + (getOuterWidth() - getRightGap()) * scaleFactor); yPoints[0] = (int)baseY; yPoints[1] = (int)(baseY + getOuterHeight() * scaleFactor); yPoints[2] = (int)(baseY + (getOuterHeight() - getBottomGap()) * scaleFactor); yPoints[3] = (int)(baseY + getTopGap() * scaleFactor); profile = new Polygon(xPoints, yPoints, 4); sampleImage = materialDets.getRightImage(scaleFactor); offset = (baseX + (getOuterWidth() - getRightGap()) * scaleFactor) % sampleImage.getWidth(); p = new TexturePaint(sampleImage, new Rectangle((int)offset, 0, sampleImage.getWidth(), sampleImage.getHeight())); big.setPaint(p); big.fill(profile); // boonste deel xPoints[0] = (int)baseX; xPoints[1] = (int)(baseX + getOuterWidth() * scaleFactor); xPoints[2] = (int)(baseX + (getOuterWidth() - getRightGap()) * scaleFactor); xPoints[3] = (int)(baseX + getRightGap() * scaleFactor); yPoints[0] = (int)baseY; yPoints[1] = (int)baseY; yPoints[2] = (int)(baseY + getTopGap() * scaleFactor); yPoints[3] = (int)(baseY + getTopGap() * scaleFactor); profile = new Polygon(xPoints, yPoints, 4); sampleImage = materialDets.getTopImage(scaleFactor); offset = baseY % sampleImage.getHeight(); p = new TexturePaint(sampleImage, new Rectangle(0, (int)offset, sampleImage.getWidth(), sampleImage.getHeight())); big.setPaint(p); big.fill(profile); // onderste deel xPoints[0] = (int)(baseX + getLeftGap() * scaleFactor); xPoints[1] = (int)(baseX + (getOuterWidth() - getRightGap()) * scaleFactor); xPoints[2] = (int)(baseX + getOuterWidth() * scaleFactor); xPoints[3] = (int)baseX; yPoints[0] = (int)(baseY + (getOuterHeight() - getBottomGap()) * scaleFactor); yPoints[1] = (int)(baseY + (getOuterHeight() - getBottomGap()) * scaleFactor); yPoints[2] = (int)(baseY + getOuterHeight() * scaleFactor); yPoints[3] = (int)(baseY + getOuterHeight() * scaleFactor); profile = new Polygon(xPoints, yPoints, 4); sampleImage = materialDets.getBottomImage(scaleFactor); offset = (baseY + (getOuterHeight() - getBottomGap()) * scaleFactor) % sampleImage.getHeight(); p = new TexturePaint(sampleImage, new Rectangle(0, (int)offset, sampleImage.getWidth(), sampleImage.getHeight())); big.setPaint(p); big.fill(profile); //super.drawSimbool(big, centerX, centerY, scaleFactor); //} } super.drawSimbool(big, centerX, centerY, scaleFactor); } public int getDesignType() { return Designer.ITEM_FRAME; } public void calcItemSize(JPanel parent, LinkedList itemList, int nextIndex, MethodPrefDets methodPrefs) { double width = getMaterialDets().getDefaultValues(this.getDefaultSupplier()).getWidth(); setDesignTopGap(width); setDesignBottomGap(width); setDesignLeftGap(width); setDesignRightGap(width); setDesignWidth(getInnerWidth() + 2 * width); setDesignHeight(getInnerHeight() + 2 * width); } public void checkItemSize(LinkedList itemList, int nextIndex, MethodPrefDets methodPrefs) { } public void calcItemPrice(MethodPrefDets methodPrefs, BusPrefDets busPrefs, boolean stretching, boolean pasting) { double totalLength = 2 * (getDesignWidth() + getDesignHeight()) / 1000; MaterialValues mats = getMaterialDets().getDefaultValues(this.getDefaultSupplier()); double price = busPrefs.getMarkupFrames() * mats.getCost() * mats.getCompFactor() * mats.getExqFactor(); setDesignPrice(price * totalLength); } public boolean isOversized() { return false; } }
[ "christiedavel@gmail.com" ]
christiedavel@gmail.com
13cfeb57a601b9c908558972492a7cf4b41da108
e2b6a07d1f5145ce89f4998ce998b9d03d44f931
/src/main/java/tech/jiangtao/backstage/controller/addition/AccountTigController.java
d3f98081b43cbd4824692eb1a16f1e71415a2c17
[ "Apache-2.0" ]
permissive
BosCattle/JMessage-Api
3f851652833aeab3c740e4c71633e246c87d2cc9
554c9f042a74a415c1bd1f2a0432371a5807ddeb
refs/heads/master
2021-06-16T00:38:04.301705
2017-05-08T19:42:30
2017-05-08T19:42:30
82,381,164
0
0
null
null
null
null
UTF-8
Java
false
false
3,465
java
package tech.jiangtao.backstage.controller.addition; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import tech.jiangtao.backstage.model.json.Account; import tech.jiangtao.backstage.service.TigAccountService; import tech.jiangtao.backstage.utils.Authorization; /** * @class: CommonController </br> * @description: 一些公共的接口</br> * @creator: kevin </br> * @email: jiangtao103cp@gmail.com </br> * @date: 10/04/2017 3:21 PM</br> * @version: 0.0.1 </br> **/ @Api(value = "账户", description = "与账户相关的接口", tags = "账户") @RestController @RequestMapping("/account") public class AccountTigController { @Autowired private TigAccountService tigAccountService; /** * 注册账户 */ @RequestMapping(value = "/create", method = RequestMethod.POST) @ApiOperation(value = "用户注册", httpMethod = "POST", response = Account.class, notes = "用户注册") public @ResponseBody Account createAccount( @ApiParam(required = true, name = "userJid", value = "用户userId") @RequestParam("userJid") String userJid, @ApiParam(required = true, name = "nickName", value = "用户昵称") @RequestParam("nickName") String nickName, @ApiParam(required = true, name = "password", value = "密码") @RequestParam("password") String password, @ApiParam(name = "avatar", value = "用户头像") String avatar, @ApiParam(name = "sex", value = "性别") boolean sex, @ApiParam(name = "signature", value = "个性签名") String signature, HttpServletResponse response) throws Exception { System.out.println(userJid); Account account = tigAccountService.insertAccount(userJid, nickName, avatar, sex, signature, password); response.setHeader(Authorization.AUTHORIZATION, account.getNid() + "-" + account.getToken()); return account; } /** * 更新用户信息 */ @RequestMapping(value = "/update", method = RequestMethod.POST) @ApiOperation(value = "用户资料更新", httpMethod = "POST", response = Account.class, notes = "用户资料更新") public @ResponseBody Account updateAccount( @ApiParam(required = true, name = "uid", value = "用户唯一标识uid") @RequestParam("uid") long uid, @ApiParam(name = "userJid", value = "用户userId") @RequestParam("userJid") String userJid, @ApiParam(name = "nickName", value = "用户昵称") String nickName, @ApiParam(name = "avatar", value = "用户头像") String avatar, @ApiParam(name = "sex", value = "性别,0:男,1:女") boolean sex, @ApiParam(name = "signature", value = "个性签名") String signature) throws Exception { try { return tigAccountService.updateAccount(uid, userJid, nickName, avatar, sex, signature); } catch (Exception e) { e.printStackTrace(); } return null; } }
[ "jiangtao103cp@163.com" ]
jiangtao103cp@163.com
41b33dca40f8c29a34758d3387bcd5ad855b4e1b
f9c4d2dff72da66936dddeaf461a40d8c5f758ec
/Project and Final/project/Step3/keyDeriveFunction.java
0ddb27de30b3a1d0275675c774137a10c965a848
[]
no_license
xiaochenai/Information-Security-Labs
bb6a19289ec34b7a5c3a62f2f00105b8bbc6d637
5c9254885bf272e195397ebf38d697c222a95356
refs/heads/master
2021-01-01T17:47:29.759042
2014-10-10T20:02:43
2014-10-10T20:02:43
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,531
java
import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import biz.source_code.base64Coder.Base64Coder; public class keyDeriveFunction { private byte[] Psw; private byte[] Salt; private int C; private int kLen; private int hLen = 512; private byte[][] T; private byte[] MK; public keyDeriveFunction(byte[] Psw, byte[] Salt, int C, int kLen){ this.Psw = Psw; this.Salt = Salt; this.C = C; this.kLen = kLen; } public void DeriveMK() throws NoSuchAlgorithmException, InvalidKeyException{ // len is in bit int len = 0; if(kLen % hLen == 0) len = kLen/hLen; else len = kLen/hLen + 1; System.out.println("LEN " + len); SecretKey secretekey = new SecretKeySpec(Psw,"HmacSHA512"); Mac mac = Mac.getInstance(secretekey.getAlgorithm()); mac.init(secretekey); // r is in bit int r = (kLen - (len - 1) * hLen); System.out.println("IIII : " + r); T = new byte[len][64]; byte[] U0 = new byte[Salt.length + 4]; byte[][] U = new byte[C][64]; byte[] current = new byte[64]; for(int i = 0; i < len; i++){ System.arraycopy(Salt, 0, U0, 0, Salt.length); byte[] byteArray = IntToByte(i); System.arraycopy(byteArray, 0, U0, Salt.length, 4); for(int j = 0; j < C; j++){ if(j == 0){ System.arraycopy(mac.doFinal(U0), 0, U[j], 0, U[j].length); // System.out.println("MAC " + Base64Coder.encodeLines(mac.doFinal(U0))); } else{ System.arraycopy(mac.doFinal(U[j-1]), 0, U[j], 0, U[j].length); // System.out.println("MAC " + Base64Coder.encodeLines(mac.doFinal((U[j-1])))); } byte a; byte b; for(int p = 0; p < current.length;p++){ a =T[i][p]; b =U[j][p]; current[p] = (byte) (a ^ b); } System.arraycopy(current, 0, T[i], 0, current.length); } } MK = new byte[64*(len-1) + r/8]; System.out.println("MK LENGTH : " + MK.length); for(int i = 0;i<(len-1);i++){ System.arraycopy(T[i], 0, MK, 64*i, 64); } System.arraycopy(T[len-1], 0, MK, 64*(len-1), r/8); } private byte[] IntToByte(int i){ byte[] byteArray = new byte[4]; byteArray[0] = (byte)((i >> 0) & 0xff); byteArray[1] = (byte)((i >> 8) & 0xff); byteArray[2] = (byte)((i >> 16) & 0xff); byteArray[3] = (byte)((i >> 24) & 0xff); return byteArray; } public byte[] GetMK(){ return MK; } }
[ "xzl0036@auburn.edu" ]
xzl0036@auburn.edu
35c0de562c2e913414338cbec5a2b92e3b7029fd
228149574190f1432301982b4d3088b33be6901a
/MultipleInterface.java
abac386fce7f6c21d53664288ea88af04ce3c738
[]
no_license
mahiambekar/java
859760c9e0e2f09277a7abcebdab8f5d2277218f
6192221b35a92b7d92569002875dfa8385a0048b
refs/heads/master
2022-12-06T14:15:53.357923
2020-09-03T11:21:21
2020-09-03T11:21:21
269,244,225
0
0
null
null
null
null
UTF-8
Java
false
false
764
java
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *******************************************************************************/ interface A{ void add(int x,int y); } interface B{ void sub(int x,int y); } class Test implements A,B{ @Override public void add(int x,int y){ System.out.println(x+y); } @Override public void sub(int x,int y){ System.out.println(x-y); } } public class Main { public static void main(String[] args) { A r; r=new Test(); r.add(100,200); r.sub(90,10); } }
[ "noreply@github.com" ]
noreply@github.com
cc42c4fdfa0faa49c2e77798bccfb4575c6900fb
b0282328962ebec281ffda24600657d6bd35e796
/starter-microservice-web/src/main/java/com/ibm/liberty/starter/service/web/api/v1/ProviderEndpoint.java
47d06b62b79da3a9ad16b82ddec3946b7165a11a
[ "Apache-2.0" ]
permissive
leochr/tool.accelerate.core
af80fb73f366520d83effdc6cb4a4d84d00211af
6b7efaf8a809d3bad677455f3bf3aa529d58e142
refs/heads/master
2021-01-22T05:19:51.513023
2016-07-26T14:05:40
2016-07-26T14:05:40
64,339,710
0
0
null
2016-07-27T20:30:17
2016-07-27T20:30:17
null
UTF-8
Java
false
false
4,752
java
/******************************************************************************* * Copyright (c) 2016 IBM Corp. * * 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.ibm.liberty.starter.service.web.api.v1; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import com.ibm.liberty.starter.api.v1.model.provider.Dependency; import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope; import com.ibm.liberty.starter.api.v1.model.provider.Location; import com.ibm.liberty.starter.api.v1.model.provider.Provider; import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig; import com.ibm.liberty.starter.api.v1.model.provider.Tag; @Path("v1/provider") public class ProviderEndpoint { private static final String DEPENDENCY_URL = "http://localhost:9082/web/artifacts/net/wasdev/wlp/starters/web"; @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Provider details(@Context UriInfo info) { Provider details = new Provider(); String description = getStringResource("/description.html"); details.setDescription(description); Location repoLocation = new Location(); String url = info.getBaseUri().resolve("../artifacts").toString(); repoLocation.setUrl(url); details.setRepoUrl(repoLocation); Dependency providedDependency = new Dependency(); providedDependency.setGroupId("net.wasdev.wlp.starters.web"); providedDependency.setArtifactId("provided-pom"); providedDependency.setScope(Scope.PROVIDED); providedDependency.setVersion("0.0.2"); Dependency runtimeDependency = new Dependency(); runtimeDependency.setScope(Scope.RUNTIME); runtimeDependency.setGroupId("net.wasdev.wlp.starters.web"); runtimeDependency.setArtifactId("runtime-pom"); runtimeDependency.setVersion("0.0.2"); Dependency[] dependencies = {providedDependency, runtimeDependency}; details.setDependencies(dependencies); return details; } //read the description contained in the index.html file private String getStringResource(String path) { InputStream in = getClass().getResourceAsStream(path); StringBuilder index = new StringBuilder(); char[] buffer = new char[1024]; int read = 0; try (InputStreamReader reader = new InputStreamReader(in)) { while ((read = reader.read(buffer)) != -1) { index.append(buffer, 0, read); } } catch (IOException e) { //just return what we've got return index.toString(); } return index.toString(); } @GET @Path("samples") @Produces(MediaType.APPLICATION_JSON) public Response constructSample(@Context UriInfo info) { StringBuilder json = new StringBuilder("{\n"); String base = info.getBaseUri().resolve("../sample").toString(); json.append("\"base\" : \"" + base + "\",\n"); json.append(getStringResource("/locations.json")); json.append("}\n"); return Response.ok(json.toString()).build(); } @GET @Path("config") @Produces(MediaType.APPLICATION_JSON) public ServerConfig getServerConfig() throws Exception { ServerConfig config = new ServerConfig(); Tag[] tags = new Tag[] { new Tag("featureManager") }; tags[0].setTags(new Tag[] { new Tag("feature", "servlet-3.1") }); config.setTags(tags); return config; } @GET @Path("dependencies") @Produces(MediaType.APPLICATION_JSON) public ServerConfig getDependencies() throws Exception { ServerConfig config = new ServerConfig(); Tag[] tags = new Tag[] { new Tag("featureManager") }; tags[0].setTags(new Tag[] { new Tag("feature", "servlet-3.1") }); config.setTags(tags); return config; } }
[ "katheris@uk.ibm.com" ]
katheris@uk.ibm.com
99a2a22a742caf3b483c2e95c752873893be5396
c5096090f769aee575df9c10c1505e5855ecf38a
/usaco/nocows_java/nocows.java
e37579d7f918b8ef6f1705a781d7140107caf3b8
[]
no_license
fanofxiaofeng/cpp
51d50455ef3431eb1dfbec88790c066e19b46340
a7f32b0d508fac156fd313b602d03a96a4569f6b
refs/heads/master
2020-04-05T22:53:32.421275
2015-01-03T01:40:22
2015-01-03T01:40:22
26,848,676
0
0
null
null
null
null
UTF-8
Java
false
false
3,183
java
/* ID: jyjz2001 LANG: JAVA TASK: nocows */ import java.io.*; import java.util.*; class nocows { public static void main (String [] args) throws IOException { // Use BufferedReader rather than RandomAccessFile; it's much faster BufferedReader f = new BufferedReader(new FileReader("nocows.in")); // input file name goes above PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("nocows.out"))); // Use StringTokenizer vs. readLine/split -- lots faster StringTokenizer st = new StringTokenizer(f.readLine()); // Get line, break into tokens int n = Integer.parseInt(st.nextToken()); // first integer int k = Integer.parseInt(st.nextToken()); // System.out.println(n + " " + k); out.println(f(n, k - 1, 9901)); // System.out.println("n: " + n); // System.out.println("h: " + heightLowerLimit(n)); out.close(); // close the output file System.exit(0); // don't omit this! } private static int heightLowerLimit(int n){ int curHeight = 0; int nodesUpperLimit = 1; while(nodesUpperLimit < n){ nodesUpperLimit = nodesUpperLimit * 2 + 1; curHeight++; } return curHeight; } private static int specialPlus(int a, int b, int m){ int s = a + b; return (s < m)?s:(s % m); } private static int f(int n, int k, int m){ int[][] with = new int[n + 1][k + 1]; int[][] le = new int[n + 1][k + 1]; with[1][0] = 1; le[1][0] = 1; // System.out.println("row: " + 1 + ". " + Arrays.toString(with[1])); for(int h = 1;h <= k;h++) le[1][h] = le[1][h - 1]; for(int row = 2;row <= n;row++){ for(int h = heightLowerLimit(row);h <= Math.min(row - 1, k);h++){ int sum = row - 1; // left child is empty // with[row][h] = specialPlus(with[row][h], with[row - 1][h - 1], m); // right child is empty // with[row][h] = specialPlus(with[row][h], with[row - 1][h - 1], m); for(int left = 1;left < sum;left++){ int right = sum - left; with[row][h] = specialPlus(with[row][h], with[left][h - 1] * le[right][h - 1], m); with[row][h] = specialPlus(with[row][h], ((h >= 2)?(le[left][h - 2]):0) * with[right][h - 1], m); } le[row][h] = specialPlus(le[row][h - 1], with[row][h], m); } for(int h = Math.min(row - 1, k) + 1;h <= k;h++) le[row][h] = le[row][h - 1]; // System.out.println("row: " + row + ". " + Arrays.toString(with[row])); } // System.out.println(); // System.out.println(); // System.out.println(); /* for(int row = 1;row <= n;row++) System.out.println("row: " + row + ". " + Arrays.toString(le[row])); */ return with[n][k]; } }
[ "jyjz2008@sjtu.edu.cn" ]
jyjz2008@sjtu.edu.cn
6b2397f7fb77cad902735ec985cd75e7a341e597
545ed9f0e5878f6b98ce937294c65e40c3aff39e
/src/main/java/com/satyam/oca/chap2/IntegerComparisionDemo.java
83869710f18ca2e90b3ad6c0749c1c30fd3435a2
[]
no_license
neo182/oca-traps
d49d748025d495cb3a2e67c32e5a8ba92cfef9c8
6053836e183715db53e536b1cc56d73345f995a8
refs/heads/master
2021-01-20T05:33:42.756072
2018-08-21T22:11:52
2018-08-21T22:11:52
89,790,591
0
0
null
null
null
null
UTF-8
Java
false
false
871
java
package com.satyam.oca.chap2; /** * * @author satyam */ public class IntegerComparisionDemo { public static void main(String[] args) { Integer a = new Integer(1); Integer b = new Integer(1); System.out.println("Integer ref equals " + (a == b)); a = 1; b = 1; System.out.println("Integer ref equals (after value) " + (a == b)); Integer c = new Integer(1); int d = 1; // This results true as the comparision would be made in value stored not in reference level System.out.println("Integer equals with value and ref type : " + (c == d)); //But, the following line results false as both c and a are reference type and comparision has been made in ref. level System.out.println("Integer equals with value and ref type : " + (c == a)); } }
[ "meet_neo1@gmail.com" ]
meet_neo1@gmail.com
aceb8b30061fd82c0b16198cb10c412aa0b6b068
cd303d35fa037e8eecd4aa03381765342b2cff6a
/src/main/java/org/springframework/data/orientdb3/repository/support/CollectOrientdbIdParserPostProcessor.java
8ca223651d4b1de56cfca95363bed51b7f25c265
[]
no_license
xxcxy/spring-data-orientdb
965cb6d607048a214a6f8a79d07b683f88e495b7
fe70fc9faf1b971d850657c29101784fbc86ade4
refs/heads/master
2023-06-07T20:01:29.187918
2019-11-13T12:38:11
2019-11-13T12:38:11
214,389,590
2
1
null
2023-05-26T22:14:52
2019-10-11T08:54:39
Java
UTF-8
Java
false
false
1,095
java
package org.springframework.data.orientdb3.repository.support; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; /** * Sets up all {@link OrientdbIdParser}. * * @author xxcxy */ public class CollectOrientdbIdParserPostProcessor implements BeanFactoryPostProcessor { /** * Finds all {@link OrientdbIdParser} in spring context and adds to {@link OrientdbIdParserHolder}. * * @param configurableListableBeanFactory * @throws BeansException */ @Override public void postProcessBeanFactory(final ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException { OrientdbIdParserHolder holder = configurableListableBeanFactory.getBean(OrientdbIdParserHolder.class); for (OrientdbIdParser parser : configurableListableBeanFactory. getBeansOfType(OrientdbIdParser.class).values()) { holder.addParser(parser); } } }
[ "bert7914@gmail.com" ]
bert7914@gmail.com
953fcacebb555d29594e6cebe4f1c03bd3d74170
f9a9885970edee88d925c4789b88c9a61885e742
/src/dms/SearchProjectForm.java
48d132876ba37d6f83a8f03e1d07a00534f25ae4
[]
no_license
UzairAhmedBhatti/Donation-Management-System
a1b2567ec4532b704e80d5ea52f9728edd2a8a78
0a92472c74e6c393f3ef3a9bbf37f85b7add009c
refs/heads/main
2023-05-28T21:45:48.455285
2021-06-05T17:35:33
2021-06-05T17:35:33
330,770,604
0
1
null
null
null
null
UTF-8
Java
false
false
13,565
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package dms; /** * * @author Uzair */ import java.util.*; import javax.swing.table.DefaultTableModel; public class SearchProjectForm extends javax.swing.JFrame { /** * Creates new form SearchProjectForm */ public SearchProjectForm() { 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); SearchByTextField = new javax.swing.JTextField(); Search = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); ProjectsTable = new javax.swing.JTable(); SearchBy1 = new javax.swing.JComboBox<>(); Continue = new javax.swing.JButton(); Clear = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); Output = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setBackground(new java.awt.Color(0, 0, 0)); Search.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N Search.setText("Search"); Search.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SearchActionPerformed(evt); } }); ProjectsTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "projectID", "projectName", "projectDescription", "requiredBudget", "projectManager", "teamID" } )); jScrollPane2.setViewportView(ProjectsTable); SearchBy1.setForeground(new java.awt.Color(255, 255, 255)); SearchBy1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Project Name", "Project Manager" })); Continue.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N Continue.setText("Continue"); Continue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ContinueActionPerformed(evt); } }); Clear.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N Clear.setText("Clear"); Clear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearActionPerformed(evt); } }); Output.setColumns(20); Output.setRows(5); jScrollPane1.setViewportView(Output); jLabel1.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 255, 255)); jLabel1.setText("Search Project"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(SearchBy1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(350, 350, 350)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Search) .addComponent(SearchByTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(57, 57, 57)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(174, 174, 174))))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Continue) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 591, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Clear)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(55, 55, 55) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(SearchByTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(SearchBy1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(60, 60, 60) .addComponent(Search)) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(Clear) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 132, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Continue)) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void SearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchActionPerformed // TODO add your handling code here: Output.setText(""); String value= (String)SearchBy1.getSelectedItem(); if(value.equalsIgnoreCase("Project Name")) { String name=SearchByTextField.getText(); Projectlist plist=new Projectlist(); plist.getdata(); Project p =new Project(); p=plist.Searchbyname(name); if(p!=null) { Object[] row = new Object[6]; DefaultTableModel model= (DefaultTableModel)ProjectsTable.getModel(); row[0]=p.getProjectID(); row[1]=p.getProjectName(); row[2]=p.getProjectDescription(); row[3]=p.getRequiredBudget(); row[4]=p.getProjectManager(); row[5]=p.getTeamID(); model.addRow(row); } else{ Output.setText("Project Not Found"); } } else if(value.equalsIgnoreCase("Project Manager")){ String name=SearchByTextField.getText(); Projectlist plist=new Projectlist(); plist.getdata(); Project p =new Project(); p=plist.Searchbymanager(name); if(p!= null) { Object[] row = new Object[6]; DefaultTableModel model= (DefaultTableModel)ProjectsTable.getModel(); row[0]=p.getProjectID(); row[1]=p.getProjectName(); row[2]=p.getProjectDescription(); row[3]=p.getRequiredBudget(); row[4]=p.getProjectManager(); row[5]=p.getTeamID(); model.addRow(row); } else{ Output.setText("Project Not Found"); } } SearchByTextField.setText(""); }//GEN-LAST:event_SearchActionPerformed private void ClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearActionPerformed // TODO add your handling code here: ProjectsTable.setModel(new DefaultTableModel(null,new String[]{"projectID","projectName","projectDescription","requiredBudget","projectManager","teamID"})); }//GEN-LAST:event_ClearActionPerformed private void ContinueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ContinueActionPerformed // TODO add your handling code here: this.setVisible(false); new HomePage().setVisible(true); }//GEN-LAST:event_ContinueActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(SearchProjectForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(SearchProjectForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(SearchProjectForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(SearchProjectForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SearchProjectForm().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton Clear; private javax.swing.JButton Continue; private javax.swing.JTextArea Output; private javax.swing.JTable ProjectsTable; private javax.swing.JButton Search; private javax.swing.JComboBox<String> SearchBy1; private javax.swing.JTextField SearchByTextField; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; // End of variables declaration//GEN-END:variables }
[ "noreply@github.com" ]
noreply@github.com
3fae59dbd2e9a560cbb1f33a19729c406699f0aa
3e3f7eb5e7a1714d6e3c8845368db9d17861a8cb
/Java/SpaceCup/src/br/com/spacecup/dao/EquipeDAO.java
db07fc1d88b4541741f30f4b3f1964c07d0fa77f
[]
no_license
danielkiesshau/FIAP_Project_2SI
bc7c3ce7515d825deec0916a9ca6bd4740c4905b
4d36c89f98f46fb4a7f3a68d5e44017786d085ea
refs/heads/master
2021-05-04T13:59:29.786242
2018-02-05T16:10:13
2018-02-05T16:10:13
120,327,381
0
0
null
null
null
null
UTF-8
Java
false
false
1,324
java
package br.com.spacecup.dao; import br.com.spacecup.conexao.Conexao; import br.com.spacecup.modelo.Aluno; import br.com.spacecup.modelo.Equipe; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.swing.JOptionPane; public class EquipeDAO { private Connection conexao; private String sql; private PreparedStatement p; private ResultSet rs; public EquipeDAO() { this.conexao = Conexao.getConnection(); } public List<Aluno> retornarComponentes(Equipe equipe){ sql = "select * from spacecup_alunos where nome_equipe = ?"; List<Aluno> lista = new ArrayList<Aluno>(); try { p = conexao.prepareStatement(sql); p.setString(1, equipe.getNome()); rs = p.executeQuery(); while (rs.next()) { String nome = rs.getString("nome_aluno"); int rm = rs.getInt("rm"); Aluno aluno = new Aluno(rm, nome, equipe); lista.add(aluno); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro na tentativa de listagem no banco\n" + ex); } return lista; } }
[ "danielkiesshau@outlook.com" ]
danielkiesshau@outlook.com
d6750adccd6e14bec33485fe6fdff1280cb19237
bc7494ecc2a877e9d6f5e449d7940b5fb3ade57f
/src/main/java/com/xiaoyu/lingdian/tool/wx/WxPayUtil.java
1f47aaf415baecc5d982768799512e7eadeaa6c0
[]
no_license
zhangxiaoyu185/runing
8632c5564f8b8f9e01b4eb9e49062964a4357a0f
f3fe06008e954d545788f955b4772655514dc28b
refs/heads/master
2022-12-22T00:48:16.364055
2019-06-02T05:39:26
2019-06-02T05:39:26
128,635,363
3
4
null
2022-12-16T04:33:31
2018-04-08T11:45:40
JavaScript
UTF-8
Java
false
false
12,300
java
package com.xiaoyu.lingdian.tool.wx; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.StringReader; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.params.ClientPNames; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.jdom.Document; import org.jdom.Element; import org.jdom.input.SAXBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.InputSource; import com.xiaoyu.lingdian.entity.weixin.Constant; import com.xiaoyu.lingdian.entity.weixin.PayOrder; import com.xiaoyu.lingdian.entity.weixin.PayPackage; import com.xiaoyu.lingdian.entity.weixin.PayResult; import com.xiaoyu.lingdian.tool.StringUtil; import com.xiaoyu.lingdian.tool.SystemUtil; import com.xiaoyu.lingdian.tool.encrypt.MD5Util; /** * 微信支付API */ public class WxPayUtil { private static Logger logger = LoggerFactory.getLogger("BASE_LOGGER"); private static String CREATE_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder"; /** * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名 * * @param packageParams * @param partner_key * @param charset * @return */ @SuppressWarnings("rawtypes") public String createSign(SortedMap<String, String> packageParams, String partner_key, String charset) { StringBuffer sb = new StringBuffer(); Set es = packageParams.entrySet(); Iterator it = es.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String k = (String) entry.getKey(); String v = (String) entry.getValue(); if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) { sb.append(k + "=" + v + "&"); } } sb.append("key=" + partner_key); String sign = MD5Util.encode(sb.toString(), charset).toUpperCase(); return sign; } /** * 获取请求预支付id报文 * * @param payOrder * return PayPackage */ public PayPackage getPackage(PayOrder payOrder) { String spbill_create_ip = SystemUtil.getIPInfo(); //订单生成的机器 IP // 总金额以分为单位,不带小数点 String totalFee = StringUtil.getMoney(payOrder.getFee().toString()); // 随机字符串 String nonce_str = StringUtil.getNonceStr(); SortedMap<String, String> packageParams = new TreeMap<String, String>(); packageParams.put("appid", payOrder.getAppid()); packageParams.put("mch_id", payOrder.getMch_id()); packageParams.put("nonce_str", nonce_str); packageParams.put("body", payOrder.getBody()); packageParams.put("attach", payOrder.getAttach()); packageParams.put("out_trade_no", payOrder.getOut_trade_no()); packageParams.put("total_fee", totalFee); packageParams.put("spbill_create_ip", spbill_create_ip); packageParams.put("notify_url", payOrder.getNotify_url()); packageParams.put("trade_type", Constant.TRADE_TYPE); packageParams.put("openid", payOrder.getOpenId()); if (StringUtil.isEmpty(payOrder.getCharset())) { payOrder.setCharset(Constant.DEFAULT_CHARSET); } String sign = createSign(packageParams, payOrder.getPartnerkey(), payOrder.getCharset()); String xml = "<xml>" + "<appid>" + payOrder.getAppid() + "</appid>" + "<mch_id>" + payOrder.getMch_id() + "</mch_id>" + "<nonce_str>" + nonce_str + "</nonce_str>" + "<sign>" + sign + "</sign>" + "<body><![CDATA[" + payOrder.getBody() + "]]></body>" + "<out_trade_no>" + payOrder.getOut_trade_no() + "</out_trade_no>" + "<attach>" + payOrder.getAttach() + "</attach>" + "<total_fee>" + totalFee + "</total_fee>" + "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>" + "<notify_url>" + payOrder.getNotify_url() + "</notify_url>" + "<trade_type>" + Constant.TRADE_TYPE + "</trade_type>" + "<openid>" + payOrder.getOpenId() + "</openid>" + "</xml>"; String prepay_id = getPayNo(CREATE_ORDER_URL, xml); logger.info("获取到的预支付ID:" + prepay_id); // 获取prepay_id后,拼接最后请求支付所需要的package SortedMap<String, String> finalpackage = new TreeMap<String, String>(); String timestamp = StringUtil.create_timestamp(); String packages = "prepay_id=" + prepay_id; finalpackage.put("appId", payOrder.getAppid()); finalpackage.put("timeStamp", timestamp); finalpackage.put("nonceStr", nonce_str); finalpackage.put("package", packages); finalpackage.put("signType", "MD5"); // 要签名 String finalsign = createSign(finalpackage, payOrder.getPartnerkey(), payOrder.getCharset()); PayPackage payPackage = new PayPackage(); payPackage.setAppId(payOrder.getAppid()); payPackage.setNonceStr(nonce_str); payPackage.setPackages(packages); payPackage.setPaySign(finalsign); payPackage.setSignType("MD5"); payPackage.setTimeStamp(timestamp); logger.info("V3 jsApi package:" + "\"appId\":\"" + payOrder.getAppid() + "\",\"timeStamp\":\"" + timestamp + "\",\"nonceStr\":\"" + nonce_str + "\",\"package\":\"" + packages + "\",\"signType\" : \"MD5" + "\",\"paySign\":\"" + finalsign + "\""); return payPackage; } /** * description:获取预支付id * * @param url * @param xmlParam * @return */ @SuppressWarnings("rawtypes") public static String getPayNo(String url, String xmlParam) { DefaultHttpClient client = new DefaultHttpClient(); client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); HttpPost httpost = getPostMethod(url); String prepay_id = ""; try { httpost.setEntity(new StringEntity(xmlParam, "UTF-8")); HttpResponse response = getSSLInstance().execute(httpost); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); if (jsonStr.indexOf("FAIL") != -1) { logger.info("FAIL:" + jsonStr); return prepay_id; } Map map = doXMLParse(jsonStr); prepay_id = (String) map.get("prepay_id"); } catch (Exception e) { e.printStackTrace(); } return prepay_id; } /** * description:获取扫码支付连接 * * @param url * @param xmlParam * @return */ @SuppressWarnings("rawtypes") public static String getCodeUrl(String url, String xmlParam) { DefaultHttpClient client = new DefaultHttpClient(); client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); HttpPost httpost = getPostMethod(url); String code_url = ""; try { httpost.setEntity(new StringEntity(xmlParam, "UTF-8")); HttpResponse response = getSSLInstance().execute(httpost); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); if (jsonStr.indexOf("FAIL") != -1) { logger.info(jsonStr); return code_url; } Map map = doXMLParse(jsonStr); code_url = (String) map.get("code_url"); } catch (Exception e) { e.printStackTrace(); } return code_url; } /** * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。 * * @param strxml * @return * @throws Exception */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static Map doXMLParse(String strxml) throws Exception { if (null == strxml || "".equals(strxml)) { return null; } Map m = new HashMap(); InputStream in = new ByteArrayInputStream(strxml.getBytes()); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(in); Element root = doc.getRootElement(); List list = root.getChildren(); Iterator it = list.iterator(); while (it.hasNext()) { Element e = (Element) it.next(); String k = e.getName(); String v = ""; List children = e.getChildren(); if (children.isEmpty()) { v = e.getTextNormalize(); } else { v = getChildrenText(children); } m.put(k, v); } // 关闭流 in.close(); return m; } /** * 获取子结点的xml * * @param children * @return String */ @SuppressWarnings("rawtypes") public static String getChildrenText(List children) { StringBuffer sb = new StringBuffer(); if (!children.isEmpty()) { Iterator it = children.iterator(); while (it.hasNext()) { Element e = (Element) it.next(); String name = e.getName(); String value = e.getTextNormalize(); List list = e.getChildren(); sb.append("<" + name + ">"); if (!list.isEmpty()) { sb.append(getChildrenText(list)); } sb.append(value); sb.append("</" + name + ">"); } } return sb.toString(); } /** * 解析微信回调通知xml * * @param xml */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static PayResult parseXmlToList(String xml) { PayResult wpr = new PayResult(); try { Map m = new HashMap(); StringReader read = new StringReader(xml); // 创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML InputSource source = new InputSource(read); // 创建一个新的SAXBuilder SAXBuilder sb = new SAXBuilder(); // 通过输入源构造一个Document Document doc = (Document) sb.build(source); Element root = doc.getRootElement();// 指向根节点 List<Element> es = root.getChildren(); if (es != null && es.size() != 0) { for (Element element : es) { m.put(element.getName(), element.getValue()); } } wpr.setAppid(m.get("appid").toString()); String attach = m.get("attach")==null?"":m.get("attach").toString(); wpr.setAttach(attach); wpr.setBankType(m.get("bank_type").toString()); wpr.setCashFee(m.get("cash_fee").toString()); wpr.setFeeType(m.get("fee_type").toString()); wpr.setIsSubscribe(m.get("is_subscribe").toString()); wpr.setMchId(m.get("mch_id").toString()); wpr.setNonceStr(m.get("nonce_str").toString()); wpr.setOpenid(m.get("openid").toString()); wpr.setOutTradeNo(m.get("out_trade_no").toString()); wpr.setResultCode(m.get("result_code").toString()); wpr.setSign(m.get("sign").toString()); wpr.setTimeEnd(m.get("time_end").toString()); wpr.setTotalFee(m.get("total_fee").toString()); wpr.setTradeType(m.get("trade_type").toString()); wpr.setTransactionId(m.get("transaction_id").toString()); } catch (Exception e) { e.printStackTrace(); } return wpr; } /** * 获取SSL验证的HttpClient * * @param httpClient * @return */ @SuppressWarnings("deprecation") public static HttpClient getSSLInstance(){ HttpClient httpClient = new DefaultHttpClient(); ClientConnectionManager ccm = httpClient.getConnectionManager(); SchemeRegistry sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", MySSLSocketFactory.getInstance(), 443)); httpClient = new DefaultHttpClient(ccm, httpClient.getParams()); return httpClient; } /** * 模拟浏览器post提交 * * @param url * @return */ public static HttpPost getPostMethod(String url) { HttpPost pmethod = new HttpPost(url); // 设置响应头信息 pmethod.addHeader("Connection", "keep-alive"); pmethod.addHeader("Accept", "*/*"); pmethod.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); pmethod.addHeader("Host", "api.mch.weixin.qq.com"); pmethod.addHeader("X-Requested-With", "XMLHttpRequest"); pmethod.addHeader("Cache-Control", "max-age=0"); pmethod.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); return pmethod; } /** * 模拟浏览器GET提交 * * @param url * @return */ public static HttpGet getGetMethod(String url) { HttpGet pmethod = new HttpGet(url); // 设置响应头信息 pmethod.addHeader("Connection", "keep-alive"); pmethod.addHeader("Cache-Control", "max-age=0"); pmethod.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); pmethod.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8"); return pmethod; } }
[ "zy135185@163.com" ]
zy135185@163.com
6a10c709ca7dfce9686dac9c03535b419c5c9698
1a9ceff7e463ff03098bcef67744c53f2d9788bb
/speed-core/speed-core-domain/src/main/java/org/phoenix/speed/domain/config/MapperScanConfig.java
968f43d7e67c5ec596aa4660755c2c9820a7fdbf
[ "Apache-2.0" ]
permissive
aaa448579123/Speed
ffd2cf6a5a1b83db3e69fe53709e1336d412f270
eca663ac65879d9c699ee799f2d3f9992b0ed08b
refs/heads/master
2022-11-08T19:43:50.880654
2020-03-18T06:34:57
2020-03-18T06:34:57
243,929,163
4
0
Apache-2.0
2022-10-12T20:37:40
2020-02-29T08:06:30
Java
UTF-8
Java
false
false
230
java
package org.phoenix.speed.domain.config; import org.mybatis.spring.annotation.MapperScan; import org.springframework.stereotype.Component; @MapperScan("org.phoenix.speed.domain.dao") @Component public class MapperScanConfig { }
[ "851952906@qq.com" ]
851952906@qq.com
88af95839f3659a317072008f5078c42d5de6344
7dd9b324e603eee358885027f7e745868053f790
/src/Orders/UntilEngaged.java
98a5605dbbef1d12d16dfa3dbeeac8e0904bf6cc
[]
no_license
arlo181/BattleSim
71ce19fdec2e7b276a201cad5d05ed48370c87f6
006ada82b53061741eedc2dbd777700ce866da94
refs/heads/master
2021-09-10T08:03:29.855450
2018-03-22T14:21:17
2018-03-22T14:21:17
105,155,108
0
0
null
null
null
null
UTF-8
Java
false
false
434
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Orders; /** * * @author Arlo */ public class UntilEngaged extends Countdown{ double percentage; public UntilEngaged(int timeoutTicks, double percentage) { super(timeoutTicks); this.percentage = percentage; } public double getPercentage() { return percentage; } }
[ "32363957+arlo181@users.noreply.github.com" ]
32363957+arlo181@users.noreply.github.com
91e4fa961543b7561a8b9abde4175e8c6d57e97e
9fc849970c854b4d5283b7f4d9fc1bd7f0a1bba0
/javaStudySSM/src/main/java/ch11/no3/jvmTest/BitSetTest.java
5933f621973835c816ce6df5ed47ff8e4b911fe7
[]
no_license
namhokim/studyJava
b5f59c6429f04af7498d3fa563ed1328c690849b
4a308a1d8a72802f68975ac6c6bef0f5734eaca1
refs/heads/master
2022-09-27T12:04:23.561686
2022-09-13T15:57:57
2022-09-13T15:57:57
25,922,576
0
0
null
null
null
null
UTF-8
Java
false
false
348
java
package ch11.no3.jvmTest; import java.util.BitSet; public class BitSetTest { static final int FIVE_HUNDRED_MILLIION = 500000000; // 5억 public static void main(String[] args) { BitSet bs = new BitSet(FIVE_HUNDRED_MILLIION); System.out.println("BitSet[0]" + bs.get(0)); bs.set(0); System.out.println("BitSet[0]" + bs.get(0)); } }
[ "namhokim@sindoh.com" ]
namhokim@sindoh.com
031b2e4bebec9c2f5e3a13f468b53343dfeba523
00ed68367f4c2f4001a9b7d06ece47e1235a14e1
/app/src/main/java/br/com/digitalhouse/workshopmarvel/view/DetailActivity.java
bb73930d8b6b152b9b69a7c14405668b48419206
[]
no_license
DigitalHouseBrasil/WorkshopMobileAndroid-11-03-2019
ff0dbde73a3b21d0d740959d5ee46659ec373a18
3fd4d378937a629bed7ca2fe9b7c478364143b40
refs/heads/master
2020-04-27T22:40:25.939138
2019-03-09T21:58:36
2019-03-09T21:58:36
174,744,863
0
1
null
null
null
null
UTF-8
Java
false
false
5,614
java
package br.com.digitalhouse.workshopmarvel.view; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.AppBarLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.Html; import android.transition.Explode; import android.view.View; import android.view.Window; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import br.com.digitalhouse.workshopmarvel.R; import br.com.digitalhouse.workshopmarvel.model.Result; import static br.com.digitalhouse.workshopmarvel.utils.AppUtils.setAnimation; public class DetailActivity extends AppCompatActivity { private ImageView imageHero; private ImageView imageBackground; private ImageView imageBack; private Toolbar toolbar; private AppBarLayout appBarLayout; private Result result; private TextView textTitle; private TextView textViewDescription; private TextView textViewPublished; private TextView textViewPrice; private TextView textViewPages; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setAnimation(this); setContentView(R.layout.activity_detail); // Inicializa as views que serão utilizadas na activity initViews(); // Adicionamos a status bar setSupportActionBar(toolbar); // Pegamos o quadrinho que que foi clicado na lista anterior result = getIntent().getParcelableExtra("comic"); // Pegamos o nome da transição para fazer a animação String transitionName = getIntent().getStringExtra("transitionName"); imageHero.setTransitionName(transitionName); // Configuramos nas view os valores do quadrinho que pegamos textTitle.setText(result.getTitle()); textViewPrice.setText("$" + result.getPrices().get(0).getPrice()); textViewPages.setText(""+result.getPageCount()); if (result.getDescription() != null) { textViewDescription.setText(Html.fromHtml(result.getDescription())); } Picasso.get().load(result.getThumbnail().getPath() + "/portrait_incredible." + result.getThumbnail().getExtension()) .placeholder(R.drawable.marvel_logo) .error(R.drawable.marvel_logo) .into(imageHero); if (!result.getImages().isEmpty()) { Picasso.get().load(result.getImages().get(0).getPath() + "/landscape_incredible." + result.getImages().get(0).getExtension()) .placeholder(R.drawable.marvel_logo) .error(R.drawable.marvel_logo) .into(imageBackground); } // Mudadamos a forma de mostrar a data DE '2007-10-31 00:00:00' para 'qua, 31 out 2007' try { SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()); SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy", Locale.getDefault()); Date date = formatDate.parse(result.getDates().get(0).getDate()); String dateString = format.format(date); textViewPublished.setText(dateString); } catch (ParseException e) { e.printStackTrace(); } // Adicionamos o evendo se click na imagem para irmos para tela // que mostra a imagem inteira imageHero.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(DetailActivity.this, ImagePopupActivity.class); intent.putExtra("image", result.getThumbnail().getPath() + "/detail." + result.getThumbnail().getExtension()); startActivity(intent); } }); // Adicionamos o evento de click para finalizarmos a activity imageBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { supportFinishAfterTransition(); } }); // Adicionamos o evento de scroll, para mostrar ou não a imagem pequena do quadrinho appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (verticalOffset == 0) { imageHero.setVisibility(View.VISIBLE); } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) { imageHero.setVisibility(View.GONE); toolbar.setTitle(result.getTitle()); } else { imageHero.setVisibility(View.VISIBLE); } } }); } private void initViews() { toolbar = findViewById(R.id.toolbar); imageBack = findViewById(R.id.imageBack); imageHero = findViewById(R.id.imageComic); appBarLayout = findViewById(R.id.app_bar); textTitle = findViewById(R.id.textTitle); textViewDescription = findViewById(R.id.textViewDesciption); textViewPublished = findViewById(R.id.textViewPublished); textViewPrice = findViewById(R.id.textViewPrice); textViewPages = findViewById(R.id.textViewPages); imageBackground = findViewById(R.id.imageBackground); } }
[ "tairoroberto@hotmail.com" ]
tairoroberto@hotmail.com
01033ae58c6282ee659396c3205e52221ca2b05b
c285a5572e0e7233a5bd6aaf79348e7cd207fbbc
/practice2/src/main/java/com/oops/DiamondProblem.java
13cbd9e71fa16427659995f325dcf39654f2ad3f
[]
no_license
ShashankSVN/svnbyshashank
c58bdd6ecb8f4d659640e3af0bfd2495a16e7167
be5d0b7e1db3099c79e78811682c1ccea07a6fc3
refs/heads/master
2021-06-30T08:04:07.796353
2020-03-29T14:00:37
2020-03-29T14:00:37
32,139,067
0
0
null
2020-10-13T20:44:22
2015-03-13T07:30:28
Java
UTF-8
Java
false
false
569
java
package com.oops; class A { void method() { System.out.println("A"); } } class B { void method() { System.out.println("B"); } } class C extends A { } // Diamond problem will becoming when we do multiple inheritance with classes // assume C extends A and B and we don't have defination in A than on calling C c // =new C() how jvm decide to call which class method- Ambiguity public class DiamondProblem { public static void main(String[] args) { A a = new A(); a.method(); A ac = new C(); ac.method(); C c = new C(); c.method(); } }
[ "shashankbiet@gmail.com" ]
shashankbiet@gmail.com
d3a08838e4de98bcd8abf87bc665e1e11fbdb9f1
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/4/4_edb6325d2357f1bd7f6815da746a5f56c7706299/TexturedGeometryClipmapTerrainExample/4_edb6325d2357f1bd7f6815da746a5f56c7706299_TexturedGeometryClipmapTerrainExample_t.java
67c80340b45e97d1087fb2ec0f91004f1bda4613
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
18,431
java
/** * Copyright (c) 2008-2009 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ package com.ardor3d.example.effect; import com.ardor3d.example.ExampleBase; import com.ardor3d.extension.terrain.HeightmapPyramid; import com.ardor3d.extension.terrain.TexturedGeometryClipmapTerrain; import com.ardor3d.extension.terrain.basic.BasicHeightmap; import com.ardor3d.extension.terrain.basic.BasicHeightmapPyramid; import com.ardor3d.extension.terrain.util.BresenhamYUpGridTracer; import com.ardor3d.extension.terrain.util.HeightmapPyramidPicker; import com.ardor3d.extension.texturing.CachedFileTextureStreamer; import com.ardor3d.extension.texturing.TextureClipmap; import com.ardor3d.framework.Canvas; import com.ardor3d.framework.FrameHandler; import com.ardor3d.image.Image; import com.ardor3d.image.Texture; import com.ardor3d.image.util.GeneratedImageFactory; import com.ardor3d.input.Key; import com.ardor3d.input.logical.InputTrigger; import com.ardor3d.input.logical.KeyPressedCondition; import com.ardor3d.input.logical.LogicalLayer; import com.ardor3d.input.logical.TriggerAction; import com.ardor3d.input.logical.TwoInputStates; import com.ardor3d.light.DirectionalLight; import com.ardor3d.math.ColorRGBA; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Ray3; import com.ardor3d.math.Vector3; import com.ardor3d.math.function.FbmFunction3D; import com.ardor3d.math.function.Function3D; import com.ardor3d.math.function.Functions; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.renderer.Camera; import com.ardor3d.renderer.queue.RenderBucketType; import com.ardor3d.renderer.state.CullState; import com.ardor3d.renderer.state.FogState; import com.ardor3d.renderer.state.FogState.DensityFunction; import com.ardor3d.scenegraph.Node; import com.ardor3d.scenegraph.extension.Skybox; import com.ardor3d.scenegraph.hint.CullHint; import com.ardor3d.scenegraph.hint.LightCombineMode; import com.ardor3d.scenegraph.shape.Sphere; import com.ardor3d.ui.text.BasicText; import com.ardor3d.util.ReadOnlyTimer; import com.ardor3d.util.TextureManager; import com.google.inject.Inject; /** * Example showing the a textured version of geometry clipmapped terrain */ public class TexturedGeometryClipmapTerrainExample extends ExampleBase { final int SIZE = 2048; private boolean updateTerrain = true; private final float farPlane = 3500.0f; private final float heightOffset = 3.0f; // Clipmap parameters and a list of clipmaps that are used. private final int clipLevelCount = 7; private final int clipSideSize = 127; private final float heightScale = 400; private TexturedGeometryClipmapTerrain geometryClipmapTerrain; private HeightmapPyramid heightmapPyramid; private boolean groundCamera = true; private Camera terrainCamera; private final Vector3 lightDirection = new Vector3(); private Skybox skybox; private final Sphere sphere = new Sphere("sp", 16, 16, 1); private HeightmapPyramidPicker picker; Ray3 pickRay = new Ray3(); /** Text fields used to present info about the example. */ private final BasicText _exampleInfo[] = new BasicText[8]; public static void main(final String[] args) { start(TexturedGeometryClipmapTerrainExample.class); } @Inject public TexturedGeometryClipmapTerrainExample(final LogicalLayer layer, final FrameHandler frameWork) { super(layer, frameWork); } private double counter = 0; private int frames = 0; @Override protected void updateExample(final ReadOnlyTimer timer) { final Camera camera = _canvas.getCanvasRenderer().getCamera(); final double height = getHeight(camera.getLocation().getX(), camera.getLocation().getZ()); if (groundCamera || camera.getLocation().getY() < height + heightOffset) { camera.setLocation(new Vector3(camera.getLocation().getX(), height + heightOffset, camera.getLocation() .getZ())); } if (updateTerrain) { terrainCamera.set(camera); } geometryClipmapTerrain.setLightDirection(lightDirection); skybox.setTranslation(camera.getLocation()); counter += timer.getTimePerFrame(); frames++; if (counter > 1) { final double fps = (frames / counter); counter = 0; frames = 0; System.out.printf("%7.1f FPS\n", fps); } // if we're picking... if (sphere.getSceneHints().getCullHint() == CullHint.Dynamic) { // Set up our pick ray pickRay.setOrigin(camera.getLocation()); pickRay.setDirection(camera.getDirection()); // do pick and move the sphere final Vector3 loc = picker.getTerrainIntersection(pickRay, null); if (loc != null && Vector3.isValid(loc)) { sphere.setTranslation(loc); // XXX: maybe change the color of the ball for valid vs. invalid? } } } /** * Initialize pssm pass and scene. */ @Override protected void initExample() { // Setup main camera. _canvas.setTitle("Geometry Clipmap Terrain - Example"); _canvas.getCanvasRenderer().getCamera().setLocation(new Vector3(0, 100, 0)); _canvas.getCanvasRenderer().getCamera().lookAt(new Vector3(0, 100, 1), Vector3.UNIT_Y); _canvas.getCanvasRenderer().getCamera().setFrustumPerspective( 65.0, (float) _canvas.getCanvasRenderer().getCamera().getWidth() / _canvas.getCanvasRenderer().getCamera().getHeight(), 1.0f, farPlane); _controlHandle.setMoveSpeed(5); lightDirection.set(0.0, 1.0, 2.0).normalizeLocal(); _lightState.detachAll(); final DirectionalLight dLight = new DirectionalLight(); dLight.setEnabled(true); dLight.setDiffuse(new ColorRGBA(1, 1, 1, 1)); dLight.setDirection(new Vector3(-1, -1, -1).normalizeLocal()); _lightState.attach(dLight); _lightState.setEnabled(true); final CullState cs = new CullState(); cs.setEnabled(true); cs.setCullFace(CullState.Face.Back); _root.setRenderState(cs); final FogState fs = new FogState(); fs.setStart(farPlane / 2.0f); fs.setEnd(farPlane); fs.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); fs.setDensityFunction(DensityFunction.Linear); _root.setRenderState(fs); // add our sphere, but have it off for now. sphere.getSceneHints().setCullHint(CullHint.Always); _root.attachChild(sphere); try { final int sourceSize = 2048; final int textureSliceSize = 256; final double scale = 1.0 / 5000.0; Function3D function = new FbmFunction3D(Functions.simplexNoise(), 5, 0.5, 0.5, 3.14); function = Functions.clamp(function, -1.2, 1.2); function = Functions.scaleInput(function, scale, scale, 1); final ReadOnlyColorRGBA[] terrainColors = new ReadOnlyColorRGBA[256]; terrainColors[0] = new ColorRGBA(0, 0, .5f, 1); terrainColors[95] = new ColorRGBA(0, 0, 1, 1); terrainColors[127] = new ColorRGBA(0, .5f, 1, 1); terrainColors[137] = new ColorRGBA(240 / 255f, 240 / 255f, 64 / 255f, 1); terrainColors[143] = new ColorRGBA(32 / 255f, 160 / 255f, 0, 1); terrainColors[175] = new ColorRGBA(224 / 255f, 224 / 255f, 0, 1); terrainColors[223] = new ColorRGBA(128 / 255f, 128 / 255f, 128 / 255f, 1); terrainColors[255] = ColorRGBA.WHITE; GeneratedImageFactory.fillInColorTable(terrainColors); // Add a touch of noise as a "detail texture" final Function3D texFunction = Functions.lerp(function, Functions.simplexNoise(), 0.02); final float[] heightMap = new float[SIZE * SIZE]; for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { heightMap[x * SIZE + y] = (float) function.eval(x, y, 0); } } CachedFileTextureStreamer .createTexture("texture", texFunction, terrainColors, sourceSize, textureSliceSize); final CachedFileTextureStreamer streamer = new CachedFileTextureStreamer("texture", sourceSize, textureSliceSize); final int validLevels = streamer.getValidLevels(); final TextureClipmap textureClipmap = new TextureClipmap(streamer, textureSliceSize, validLevels, 64f * SIZE / sourceSize); // Create a heightmap pyramid for the clipmap terrain to use heightmapPyramid = new BasicHeightmapPyramid(new BasicHeightmap(heightMap, SIZE), clipLevelCount); ((BasicHeightmapPyramid) heightmapPyramid).setDoWrap(false); // Keep a separate camera to be able to freeze terrain update final Camera camera = _canvas.getCanvasRenderer().getCamera(); terrainCamera = new Camera(camera); // Create the monster terrain engine geometryClipmapTerrain = new TexturedGeometryClipmapTerrain(textureClipmap, terrainCamera, heightmapPyramid, clipSideSize, heightScale); geometryClipmapTerrain.setHeightRange(-1.2f, 1.2f); // geometryClipmapTerrain.setRenderState(ts); _root.attachChild(geometryClipmapTerrain); // Create a picker picker = new HeightmapPyramidPicker(heightmapPyramid, heightScale, new BresenhamYUpGridTracer(), farPlane); } catch (final Exception ex1) { ex1.printStackTrace(); } skybox = buildSkyBox(); _root.attachChild(skybox); // Setup labels for presenting example info. final Node textNodes = new Node("Text"); _root.attachChild(textNodes); textNodes.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); textNodes.getSceneHints().setLightCombineMode(LightCombineMode.Off); final double infoStartY = _canvas.getCanvasRenderer().getCamera().getHeight() / 2; for (int i = 0; i < _exampleInfo.length; i++) { _exampleInfo[i] = BasicText.createDefaultTextLabel("Text", "", 16); _exampleInfo[i].setTranslation(new Vector3(10, infoStartY - i * 20, 0)); textNodes.attachChild(_exampleInfo[i]); } textNodes.updateGeometricState(0.0); updateText(); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { updateTerrain = !updateTerrain; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(5); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(50); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { _controlHandle.setMoveSpeed(400); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { groundCamera = !groundCamera; updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (geometryClipmapTerrain.getVisibleLevels() < clipLevelCount - 1) { geometryClipmapTerrain.setVisibleLevels(geometryClipmapTerrain.getVisibleLevels() + 1); updateText(); } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (geometryClipmapTerrain.getVisibleLevels() > 0) { geometryClipmapTerrain.setVisibleLevels(geometryClipmapTerrain.getVisibleLevels() - 1); updateText(); } } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.P), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { sphere.getSceneHints().setCullHint( sphere.getSceneHints().getCullHint() == CullHint.Always ? CullHint.Dynamic : CullHint.Always); updateText(); } })); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { if (heightmapPyramid instanceof BasicHeightmapPyramid) { final BasicHeightmapPyramid pyramid = (BasicHeightmapPyramid) heightmapPyramid; pyramid.setDoWrap(!pyramid.isDoWrap()); geometryClipmapTerrain.regenerate(); updateText(); } } })); } /** * Builds the sky box. */ private Skybox buildSkyBox() { final Skybox skybox = new Skybox("skybox", 10, 10, 10); final String dir = "images/skybox/"; final Texture north = TextureManager.load(dir + "1.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); final Texture south = TextureManager.load(dir + "3.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); final Texture east = TextureManager.load(dir + "2.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); final Texture west = TextureManager.load(dir + "4.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); final Texture up = TextureManager.load(dir + "6.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); final Texture down = TextureManager.load(dir + "5.jpg", Texture.MinificationFilter.BilinearNearestMipMap, Image.Format.GuessNoCompression, true); skybox.setTexture(Skybox.Face.North, north); skybox.setTexture(Skybox.Face.West, west); skybox.setTexture(Skybox.Face.South, south); skybox.setTexture(Skybox.Face.East, east); skybox.setTexture(Skybox.Face.Up, up); skybox.setTexture(Skybox.Face.Down, down); return skybox; } /** * Update text information. */ private void updateText() { _exampleInfo[0].setText("Heightmap size: " + SIZE + "x" + SIZE); _exampleInfo[1].setText("Spec: One meter per heightmap value"); _exampleInfo[2].setText("[1/2/3] Moving speed: " + _controlHandle.getMoveSpeed() + " m/s"); _exampleInfo[3].setText("[I/K] Max visible level: " + geometryClipmapTerrain.getVisibleLevels()); _exampleInfo[4].setText("[U] Update terrain: " + updateTerrain); _exampleInfo[5].setText("[SPACE] Toggle fly/walk: " + (groundCamera ? "walk" : "fly")); _exampleInfo[6].setText("[P] Toggle showing a sphere that follows the ground using picking: " + (sphere.getSceneHints().getCullHint() != CullHint.Always)); if (heightmapPyramid instanceof BasicHeightmapPyramid) { final BasicHeightmapPyramid pyramid = (BasicHeightmapPyramid) heightmapPyramid; _exampleInfo[7].setText("[J] Toggle heightmap wrapping: " + pyramid.isDoWrap()); } } private double getHeight(double x, double z) { x = x % SIZE; x += x < 0 ? SIZE : 0; z = z % SIZE; z += z < 0 ? SIZE : 0; final double col = Math.floor(x); final double row = Math.floor(z); final double intOnX = x - col, intOnZ = z - row; double col1 = (col + 1) % SIZE; col1 += col1 < 0 ? SIZE : 0; double row1 = (row + 1) % SIZE; row1 += row1 < 0 ? SIZE : 0; // find the heightmap point closest to this position (but will always // be to the left ( < x) and above (< z) of the spot. final double topLeft = heightmapPyramid.getHeight(0, (int) col, (int) row); // now find the next point to the right of topLeft's position... final double topRight = heightmapPyramid.getHeight(0, (int) col1, (int) row); // now find the next point below topLeft's position... final double bottomLeft = heightmapPyramid.getHeight(0, (int) col, (int) row1); // now find the next point below and to the right of topLeft's // position... final double bottomRight = heightmapPyramid.getHeight(0, (int) col1, (int) row1); // Use linear interpolation to find the height. return MathUtils.lerp(intOnZ, MathUtils.lerp(intOnX, topLeft, topRight), MathUtils.lerp(intOnX, bottomLeft, bottomRight)) * heightScale; } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
53c2d6570053dc9bb8ebd7ccc6118052ff5b577b
13dfd110df6cccc7ed5ce992ba5e7eadc56a42af
/sm-core/src/test/java/com/salesmanager/test/shipping/ShippingMethodDecisionTest.java
8d9b14e3a7c63b2f23b037a6254aae5c27aa4a16
[]
no_license
ajaytiwari000/Habbit
24ca9455f0200e648640079945a04b01918dac7b
1ccff760c0a17515748cdc7c9d133fae71b8d937
refs/heads/master
2023-03-21T11:32:26.708784
2021-03-12T07:38:02
2021-03-12T07:38:02
265,888,454
1
0
null
null
null
null
UTF-8
Java
false
false
2,897
java
package com.salesmanager.test.shipping; import com.salesmanager.core.business.modules.integration.shipping.impl.ShippingDecisionPreProcessorImpl; import com.salesmanager.core.model.common.Delivery; import com.salesmanager.core.model.reference.country.Country; import com.salesmanager.core.model.reference.zone.Zone; import com.salesmanager.core.model.shipping.PackageDetails; import com.salesmanager.core.model.shipping.ShippingQuote; import com.salesmanager.core.model.system.IntegrationModule; import java.util.ArrayList; import java.util.List; import java.util.Locale; import javax.inject.Inject; import org.junit.Ignore; import org.junit.Test; @Ignore public class ShippingMethodDecisionTest extends com.salesmanager.test.common.AbstractSalesManagerCoreTestCase { @Inject ShippingDecisionPreProcessorImpl shippingMethodDecisionProcess; @Test @Ignore public void validateShippingMethod() throws Exception { ShippingQuote quote = new ShippingQuote(); PackageDetails pDetail = new PackageDetails(); pDetail.setShippingHeight(20); pDetail.setShippingLength(10); pDetail.setShippingWeight(70); pDetail.setShippingWidth(78); List<PackageDetails> details = new ArrayList<PackageDetails>(); details.add(pDetail); Delivery delivery = new Delivery(); delivery.setAddress("358 Du Languedoc"); delivery.setCity("Boucherville"); delivery.setPostalCode("J4B 8J9"); Country country = new Country(); country.setIsoCode("CA"); country.setName("Canada"); // country.setIsoCode("US"); // country.setName("United States"); delivery.setCountry(country); Zone zone = new Zone(); zone.setCode("QC"); zone.setName("Quebec"); // zone.setCode("NY"); // zone.setName("New York"); delivery.setZone(zone); IntegrationModule currentModule = new IntegrationModule(); currentModule.setCode("canadapost"); quote.setCurrentShippingModule(currentModule); quote.setShippingModuleCode(currentModule.getCode()); IntegrationModule canadapost = new IntegrationModule(); canadapost.setCode("canadapost"); IntegrationModule ups = new IntegrationModule(); ups.setCode("ups"); IntegrationModule inhouse = new IntegrationModule(); inhouse.setCode("customQuotesRules"); List<IntegrationModule> allModules = new ArrayList<IntegrationModule>(); allModules.add(canadapost); allModules.add(ups); allModules.add(inhouse); shippingMethodDecisionProcess.prePostProcessShippingQuotes( quote, details, null, delivery, null, null, null, currentModule, null, allModules, Locale.CANADA); System.out.println( "Done : " + quote.getCurrentShippingModule() != null ? quote.getCurrentShippingModule().getCode() : currentModule.getCode()); } }
[ "ajaytiwari000@gmail.com" ]
ajaytiwari000@gmail.com
2525c2ed11d5f50cbab2d4ac1730e3e5bbb914d5
7a8262797d4428ff119a24b255e582c171f539b4
/noah/Client.java
96c79a6e5d6d1efa61d5a06fc4a3d5d1d5263da1
[]
no_license
NazerkeBS/Distributed-Systems
93afbbdd124bc01b166ff4dcb5443f25bb40a241
d7e445eaf2129e9a4f0175fe1dbefa59ac308a6c
refs/heads/master
2020-04-22T23:37:50.422248
2019-05-28T21:12:32
2019-05-28T21:12:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
940
java
import java.util.*; import java.io.*; import java.net.*; import java.rmi.registry.*; public class Client{ public static void main(String[] args) throws Exception{ Socket socket = new Socket("localhost", 12345); String animal; List<String> result = new ArrayList<>(); while(true){ try{ ObjectInputStream input = new ObjectInputStream(socket.getInputStream()); animal = (String) input.readObject(); System.out.println(animal); result.add(animal); }catch(Exception e){ break; } } //connect to RMI Ark Socket socket1 = new Socket("localhost", 12343); Registry registry = LocateRegistry.getRegistry("localhost", 12343); ArkInterface arkAdd = (ArkInterface) registry.lookup("addAnimal"); for(String r : result){ arkAdd.addAnimal(r); } ArkInterface arkList = (ArkInterface) registry.lookup("listAnimals"); System.out.println("******* RMI: *******" + arkList.listAnimals()); } }
[ "seinaz1997@gmail.com" ]
seinaz1997@gmail.com
94e38fd6d35deb8e902f8ed55f1f92783635a0c6
83be2eee23f1e7caee053637627b3513e27a99bf
/src/main/java/com/example/TheaterCircle/WebApplicationConfig.java
ddc13aa3568635a9f09e783e479d09419b1e711d
[]
no_license
jaydedm/TheaterCircle
225956810e80f5aa918c396d80ff634f5316059b
917dc062d99a4dbc1821678112e6d1e2a3e0069b
refs/heads/master
2020-03-25T13:22:29.024096
2018-08-07T05:09:17
2018-08-07T05:09:17
143,105,508
0
0
null
null
null
null
UTF-8
Java
false
false
666
java
package com.example.TheaterCircle; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebApplicationConfig implements WebMvcConfigurer{ @Bean public AuthenticationInterceptor authenticationInterceptor() { return new AuthenticationInterceptor(); } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor( authenticationInterceptor() ); } }
[ "jdmitchell@alumni.berklee.edu" ]
jdmitchell@alumni.berklee.edu
b62e2d7587d0e17fe6f181fcfbb5a6356bbf24f2
72714ed75716e928ce3ced4f987cbeb979441aca
/src/main/java/com/sunway/ws/module/common/DataStatus.java
ed9cb15a597c7ffa0767f536e6960131e0469eb9
[]
no_license
ld000/ppms-interface
cb5a265f5e5500c566756d48be6848de66cff6f4
19eeec414d7ea4996d7416f51e0a91deb1fcf184
refs/heads/master
2021-06-01T01:23:17.821920
2016-04-04T17:13:48
2016-04-04T17:13:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,082
java
package com.sunway.ws.module.common; /** * 数据发送状态 */ public enum DataStatus { /** * 成功 */ SUCCESS(0, "成功"), /** * 失败(会重发) */ FAILED(1, "失败(会重发)"), /** * 失败(失败次数过多,不重发) */ FAILED_TOO_MANY_TIMES(2, "失败(失败次数过多,不重发)"), /** * 接口未开启或在 i_config 表中无记录 */ WARN_NO_CLIENT(3, "接口未开启或在 i_config 表中无记录"), /** * 手动重发 */ RETRY_MANUAL(4, "手动重发"), /** * 未注册数据监听 */ WARN_UNREGISTER_LISTENER(5, "未注册数据监听"), /** * message 为 null */ WARN_MESSAGE_IS_NULL(6, "message 为 null"); private Integer status; private String cnName; private DataStatus(Integer status, String cnName) { this.status = status; this.cnName = cnName; } public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } public String getCnName() { return cnName; } public void setCnName(String cnName) { this.cnName = cnName; } }
[ "lidong9144@163.com" ]
lidong9144@163.com
e095c70d9f7246d058d2416c57f3ae07d93f2fbe
b591dc9a8ea98a560a0371a4470362b16061cfb8
/src/main/java/org/jenkinsci/plugins/database/steps/DatabaseConnectionStep.java
93d6f652f49a1cef70b5bd84bc4f2870a9ccf7f3
[]
no_license
timja/database-plugin
b7a8c235af14f5efe52ecc6ad72fd6f76483f338
69db582bf6fa9753f9370e61a3810453be2572d0
refs/heads/master
2023-07-07T00:48:06.282974
2017-07-16T02:43:44
2017-07-16T02:44:03
287,902,210
0
0
null
2020-08-16T08:15:37
2020-08-16T08:15:36
null
UTF-8
Java
false
false
5,882
java
package org.jenkinsci.plugins.database.steps; import hudson.Extension; import hudson.Util; import hudson.model.Run; import hudson.model.TaskListener; import hudson.model.TopLevelItem; import hudson.util.ListBoxModel; import org.jenkinsci.plugins.database.GlobalDatabaseConfiguration; import org.jenkinsci.plugins.database.PerItemDatabaseConfiguration; import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl; import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl; import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl; import org.jenkinsci.plugins.workflow.steps.BodyExecution; import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.jenkinsci.plugins.workflow.steps.StepContextParameter; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.inject.Inject; import java.sql.Connection; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; public class DatabaseConnectionStep extends AbstractStepImpl { @Extension public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl (); private static final Logger LOG = Logger.getLogger ( DatabaseConnectionStep.class.getName () ); private DatabaseType type; private String id; @DataBoundConstructor public DatabaseConnectionStep () { } public DatabaseType getType () { return type; } @DataBoundSetter public void setType ( DatabaseType type ) { this.type = type; } public String getId () { return id; } @DataBoundSetter public void setId ( @CheckForNull String id ) { this.id = Util.fixEmptyAndTrim ( id ); } @Override public StepDescriptor getDescriptor () { return DESCRIPTOR; } public static class Execution extends AbstractStepExecutionImpl { @StepContextParameter private transient Run<?, ?> build; @StepContextParameter private transient TaskListener taskListener; @Inject private transient DatabaseConnectionStep step; @Inject private transient GlobalDatabaseConfiguration globalDatabaseConfiguration; @Inject private transient PerItemDatabaseConfiguration perItemDatabaseConfiguration; private transient Connection connection; private transient BodyExecution execution; @Override public void onResume () { throw new RuntimeException ( "Database operations can't be resumed" ); } @Override public boolean start () throws Exception { fetchDatabase (); try { DatabaseContext dbContext = new DatabaseContext ( getContext ().get ( DatabaseContext.class ), connection, step.id ); execution = getContext () .newBodyInvoker () .withContext ( dbContext ) .withCallback ( new BodyExecutionCallback.TailCall () { @Override protected void finished ( StepContext context ) throws Exception { closeConnection (); } } ) .start (); return false; } catch ( Exception e ) { closeConnection (); getContext ().onFailure ( e ); return true; } } private void fetchDatabase () throws FailedToGetDatabaseException { try { LOG.log ( Level.FINE, "Fetching database connection of type {0}", step.type ); switch ( step.type ) { default: case GLOBAL: connection = globalDatabaseConfiguration.getDatabase ().getDataSource ().getConnection (); break; case PERITEM: if ( build.getParent () instanceof TopLevelItem ) { connection = perItemDatabaseConfiguration.getDatabase ().getDataSource ( (TopLevelItem) build.getParent () ) .getConnection (); } else { throw new FailedToGetDatabaseException ( "Failed to get per item database build.getParent is not instance of TopLevelItem? " + build.getParent ().getClass () ); } break; } LOG.log ( Level.FINE, "Got database connection" ); } catch ( SQLException e ) { throw new FailedToGetDatabaseException ( "Failed to get database connection", e ); } } private void closeConnection () { if ( connection != null ) { try { LOG.log ( Level.FINE, "Closing database connection" ); connection.close (); connection = null; } catch ( SQLException e ) { taskListener.error ( "Failed to close connection %s", e ); } } } @Override public void stop ( @Nonnull Throwable cause ) throws Exception { LOG.log ( Level.FINE, "Recived stop request", cause ); try { if ( execution != null ) { execution.cancel ( cause ); execution = null; } } finally { closeConnection (); } } } public static class DescriptorImpl extends AbstractStepDescriptorImpl { public DescriptorImpl () { super ( Execution.class ); } @Override public String getFunctionName () { return "getDatabaseConnection"; } @Nonnull @Override public String getDisplayName () { return "Get Database Connection"; } @Override public boolean takesImplicitBlockArgument () { return true; } public ListBoxModel doFillTypeItems () { ListBoxModel items = new ListBoxModel (); for ( DatabaseType dataType : DatabaseType.values () ) { items.add ( dataType.getDisplayName (), dataType.name () ); } return items; } } }
[ "david@vanlaatum.id.au" ]
david@vanlaatum.id.au
dc311bdf0d9154638c717be9835e169911c4457a
133454e2906482c1791acb682f29396da1b5d2e6
/Chess-Game/src/chess/pieces/Queen.java
f7cc33df5bfdf7c09586dff3c7865daee7721c9c
[]
no_license
FelipeZucchiNeves/JogoDeXadrez
0482bbef94ea215400815a82a821786ce8318c53
6220d2750cf73f5f8efbb65eabfb9dbe4501f4e0
refs/heads/master
2020-07-25T11:22:07.088338
2019-11-11T20:08:45
2019-11-11T20:08:45
208,271,792
0
0
null
null
null
null
UTF-8
Java
false
false
3,393
java
package chess.pieces; import boardgame.Board; import boardgame.Position; import chess.ChessPiece; import chess.Color; public class Queen extends ChessPiece { public Queen(Board board, Color color) { super(board, color); } @Override public String toString() { return "Q"; } @Override public boolean[][] possibleMove() { boolean[][] matriz = new boolean[getBoard().getRows()][getBoard().getColumns()]; Position p = new Position(0, 0); // above, para cima. p.setValues(position.getRow() - 1, position.getColumn()); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setRow(p.getRow() - 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Left, esquerda p.setValues(position.getRow(), position.getColumn() - 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setColumn(p.getColumn() - 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Right, Direita p.setValues(position.getRow(), position.getColumn() + 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setColumn(p.getColumn() + 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Below, para baixo p.setValues(position.getRow() + 1, position.getColumn()); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setRow(p.getRow() + 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Noroeste. p.setValues(position.getRow() - 1, position.getColumn() - 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setValues(p.getRow() - 1, p.getColumn() - 1); ; } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Nordeste p.setValues(position.getRow() - 1, position.getColumn() + 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setValues(p.getRow() - 1, p.getColumn() + 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Sudeste p.setValues(position.getRow() + 1, position.getColumn() + 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setValues(p.getRow() + 1, p.getColumn() + 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } // Sudoeste p.setValues(position.getRow() + 1, position.getColumn() - 1); while (getBoard().positionExists(p) && (!getBoard().thereIsPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; p.setValues(p.getRow() + 1, p.getColumn() - 1); } if ((getBoard().positionExists(p)) && (isThereOpponentPiece(p))) { matriz[p.getRow()][p.getColumn()] = true; } return matriz; } }
[ "felipe_neves_2@hotmail.com" ]
felipe_neves_2@hotmail.com
4e501333665c9bf37417e537c2fcdee282b8ae66
b78f4e4fb8689c0c3b71a1562a7ee4228a116cda
/JFramework/crypto/src/main/java/org/bouncycastle/asn1/x9/X9IntegerConverter.java
26865d3726a28e2fa20bbeee668b6ff0fccf1663
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
richkmeli/JFramework
94c6888a6bb9af8cbff924e8a1525e6ec4765902
54250a32b196bb9408fb5715e1c677a26255bc29
refs/heads/master
2023-07-24T23:59:19.077417
2023-05-05T22:52:14
2023-05-05T22:52:14
176,379,860
5
6
Apache-2.0
2023-07-13T22:58:27
2019-03-18T22:32:12
Java
UTF-8
Java
false
false
1,715
java
package org.bouncycastle.asn1.x9; import org.bouncycastle.math.ec.ECCurve; import org.bouncycastle.math.ec.ECFieldElement; import java.math.BigInteger; /** * A class which converts integers to byte arrays, allowing padding and calculations * to be done according the the filed size of the curve or field element involved. */ public class X9IntegerConverter { /** * Return the curve's field size in bytes. * * @param c the curve of interest. * @return the field size in bytes (rounded up). */ public int getByteLength( ECCurve c) { return (c.getFieldSize() + 7) / 8; } /** * Return the field element's field size in bytes. * * @param fe the field element of interest. * @return the field size in bytes (rounded up). */ public int getByteLength( ECFieldElement fe) { return (fe.getFieldSize() + 7) / 8; } /** * Convert an integer to a byte array, ensuring it is exactly qLength long. * * @param s the integer to be converted. * @param qLength the length * @return the resulting byte array. */ public byte[] integerToBytes( BigInteger s, int qLength) { byte[] bytes = s.toByteArray(); if (qLength < bytes.length) { byte[] tmp = new byte[qLength]; System.arraycopy(bytes, bytes.length - tmp.length, tmp, 0, tmp.length); return tmp; } else if (qLength > bytes.length) { byte[] tmp = new byte[qLength]; System.arraycopy(bytes, 0, tmp, tmp.length - bytes.length, bytes.length); return tmp; } return bytes; } }
[ "richkmeli@gmail.com" ]
richkmeli@gmail.com
f2ca35b179ddf69ed5c5957ca593eb93aa4588cc
d0f716063ffd74f9416bce6fe79aed2591654f42
/app/src/main/java/com/pma/mastercart/asyncTasks/NotificationTask.java
c541ddc50577336ab6b3af83b359bc5cf3f263dc
[]
no_license
tanjaindjic/MasterCart
51e2484b6c079da40fafbb850acb071f93237966
aeda5033bdc20687bb6119e0b8c8a5c3a7e48ef0
refs/heads/master
2020-05-05T10:15:40.586756
2019-07-02T19:32:34
2019-07-02T19:32:34
179,937,013
1
1
null
null
null
null
UTF-8
Java
false
false
2,217
java
package com.pma.mastercart.asyncTasks; import android.app.NotificationManager; import android.content.Context; import android.content.SharedPreferences; import android.os.AsyncTask; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.pma.mastercart.MainActivity; import com.pma.mastercart.R; import com.pma.mastercart.model.Product; import com.pma.mastercart.model.User; import com.pma.mastercart.service.NotificationService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import java.util.concurrent.ExecutionException; public class NotificationTask extends AsyncTask<User, Void, Product[]> { @Override protected Product[] doInBackground(User... users) { String requested_method = "LoadBU"; String bu_status = "1"; Log.i("SERVICE", "USAO"); if(users[0]!=null) { SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory(); simpleClientHttpRequestFactory.setConnectTimeout(3000); RestTemplate restTemplate = new RestTemplate(simpleClientHttpRequestFactory); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); ResponseEntity<Product[]> response = null; Product[] products = new Product[0]; try { response = restTemplate.getForEntity(MainActivity.URL + "notification/" + users[0].getId(), Product[].class); Log.i("SERVICE", "DOBIO"); if (response.getStatusCode() == HttpStatus.OK) { products = response.getBody(); } } catch (RestClientException e) { } return products; } else return null; } }
[ "mali.patuljko@gmail.com" ]
mali.patuljko@gmail.com
f21cca1c910acc9a712b17ed027b78c70387a08a
cddb85c171d04311b990fff4438f640dc6071bc2
/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java
5d9de18cd9811fe74d98b8591ec5bf0f5641a6cb
[ "Apache-2.0" ]
permissive
harshitgupta1337/bookkeeper
c599db614b5922c6a4935d0a80628cd6db7dbe2a
751990111f2839d13b481908d8930d23f38af5ca
refs/heads/master
2023-02-08T20:15:07.443797
2020-12-31T21:26:42
2020-12-31T21:26:42
325,875,508
0
0
null
null
null
null
UTF-8
Java
false
false
28,333
java
/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.bookkeeper.bookie; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import org.apache.bookkeeper.client.ClientUtil; import org.apache.bookkeeper.client.LedgerHandle; import org.apache.bookkeeper.conf.ServerConfiguration; import org.apache.bookkeeper.conf.TestBKConfiguration; import org.apache.bookkeeper.util.IOUtils; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Test the bookie journal. */ public class BookieJournalTest { private static final Logger LOG = LoggerFactory.getLogger(BookieJournalTest.class); final Random r = new Random(System.currentTimeMillis()); final List<File> tempDirs = new ArrayList<File>(); File createTempDir(String prefix, String suffix) throws IOException { File dir = IOUtils.createTempDir(prefix, suffix); tempDirs.add(dir); return dir; } @After public void tearDown() throws Exception { for (File dir : tempDirs) { FileUtils.deleteDirectory(dir); } tempDirs.clear(); } private void writeIndexFileForLedger(File indexDir, long ledgerId, byte[] masterKey) throws Exception { File fn = new File(indexDir, IndexPersistenceMgr.getLedgerName(ledgerId)); fn.getParentFile().mkdirs(); FileInfo fi = new FileInfo(fn, masterKey); // force creation of index file fi.write(new ByteBuffer[]{ ByteBuffer.allocate(0) }, 0); fi.close(true); } private void writePartialIndexFileForLedger(File indexDir, long ledgerId, byte[] masterKey, boolean truncateToMasterKey) throws Exception { File fn = new File(indexDir, IndexPersistenceMgr.getLedgerName(ledgerId)); fn.getParentFile().mkdirs(); FileInfo fi = new FileInfo(fn, masterKey); // force creation of index file fi.write(new ByteBuffer[]{ ByteBuffer.allocate(0) }, 0); fi.close(true); // file info header int headerLen = 8 + 4 + masterKey.length; // truncate the index file int leftSize; if (truncateToMasterKey) { leftSize = r.nextInt(headerLen); } else { leftSize = headerLen + r.nextInt(1024 - headerLen); } FileChannel fc = new RandomAccessFile(fn, "rw").getChannel(); fc.truncate(leftSize); fc.close(); } /** * Generate fence entry. */ private ByteBuf generateFenceEntry(long ledgerId) { ByteBuf bb = Unpooled.buffer(); bb.writeLong(ledgerId); bb.writeLong(Bookie.METAENTRY_ID_FENCE_KEY); return bb; } /** * Generate meta entry with given master key. */ private ByteBuf generateMetaEntry(long ledgerId, byte[] masterKey) { ByteBuf bb = Unpooled.buffer(); bb.writeLong(ledgerId); bb.writeLong(Bookie.METAENTRY_ID_LEDGER_KEY); bb.writeInt(masterKey.length); bb.writeBytes(masterKey); return bb; } private void writeJunkJournal(File journalDir) throws Exception { long logId = System.currentTimeMillis(); File fn = new File(journalDir, Long.toHexString(logId) + ".txn"); FileChannel fc = new RandomAccessFile(fn, "rw").getChannel(); ByteBuffer zeros = ByteBuffer.allocate(512); fc.write(zeros, 4 * 1024 * 1024); fc.position(0); for (int i = 1; i <= 10; i++) { fc.write(ByteBuffer.wrap("JunkJunkJunk".getBytes())); } } private void writePreV2Journal(File journalDir, int numEntries) throws Exception { long logId = System.currentTimeMillis(); File fn = new File(journalDir, Long.toHexString(logId) + ".txn"); FileChannel fc = new RandomAccessFile(fn, "rw").getChannel(); ByteBuffer zeros = ByteBuffer.allocate(512); fc.write(zeros, 4 * 1024 * 1024); fc.position(0); byte[] data = "JournalTestData".getBytes(); long lastConfirmed = LedgerHandle.INVALID_ENTRY_ID; for (int i = 1; i <= numEntries; i++) { ByteBuf packet = ClientUtil.generatePacket(1, i, lastConfirmed, i * data.length, data); lastConfirmed = i; ByteBuffer lenBuff = ByteBuffer.allocate(4); lenBuff.putInt(packet.readableBytes()); lenBuff.flip(); fc.write(lenBuff); fc.write(packet.nioBuffer()); packet.release(); } } private static void moveToPosition(JournalChannel jc, long pos) throws IOException { jc.fc.position(pos); jc.bc.position.set(pos); jc.bc.writeBufferStartPosition.set(pos); } private static void updateJournalVersion(JournalChannel jc, int journalVersion) throws IOException { long prevPos = jc.fc.position(); try { ByteBuffer versionBuffer = ByteBuffer.allocate(4); versionBuffer.putInt(journalVersion); versionBuffer.flip(); jc.fc.position(4); IOUtils.writeFully(jc.fc, versionBuffer); jc.fc.force(true); } finally { jc.fc.position(prevPos); } } private JournalChannel writeV2Journal(File journalDir, int numEntries) throws Exception { long logId = System.currentTimeMillis(); JournalChannel jc = new JournalChannel(journalDir, logId); moveToPosition(jc, JournalChannel.VERSION_HEADER_SIZE); BufferedChannel bc = jc.getBufferedChannel(); byte[] data = new byte[1024]; Arrays.fill(data, (byte) 'X'); long lastConfirmed = LedgerHandle.INVALID_ENTRY_ID; for (int i = 1; i <= numEntries; i++) { ByteBuf packet = ClientUtil.generatePacket(1, i, lastConfirmed, i * data.length, data); lastConfirmed = i; ByteBuffer lenBuff = ByteBuffer.allocate(4); lenBuff.putInt(packet.readableBytes()); lenBuff.flip(); bc.write(Unpooled.wrappedBuffer(lenBuff)); bc.write(packet); packet.release(); } bc.flushAndForceWrite(false); updateJournalVersion(jc, JournalChannel.V2); return jc; } private JournalChannel writeV3Journal(File journalDir, int numEntries, byte[] masterKey) throws Exception { long logId = System.currentTimeMillis(); JournalChannel jc = new JournalChannel(journalDir, logId); moveToPosition(jc, JournalChannel.VERSION_HEADER_SIZE); BufferedChannel bc = jc.getBufferedChannel(); byte[] data = new byte[1024]; Arrays.fill(data, (byte) 'X'); long lastConfirmed = LedgerHandle.INVALID_ENTRY_ID; for (int i = 0; i <= numEntries; i++) { ByteBuf packet; if (i == 0) { packet = generateMetaEntry(1, masterKey); } else { packet = ClientUtil.generatePacket(1, i, lastConfirmed, i * data.length, data); } lastConfirmed = i; ByteBuffer lenBuff = ByteBuffer.allocate(4); lenBuff.putInt(packet.readableBytes()); lenBuff.flip(); bc.write(Unpooled.wrappedBuffer(lenBuff)); bc.write(packet); packet.release(); } bc.flushAndForceWrite(false); updateJournalVersion(jc, JournalChannel.V3); return jc; } private JournalChannel writeV4Journal(File journalDir, int numEntries, byte[] masterKey) throws Exception { long logId = System.currentTimeMillis(); JournalChannel jc = new JournalChannel(journalDir, logId); moveToPosition(jc, JournalChannel.VERSION_HEADER_SIZE); BufferedChannel bc = jc.getBufferedChannel(); byte[] data = new byte[1024]; Arrays.fill(data, (byte) 'X'); long lastConfirmed = LedgerHandle.INVALID_ENTRY_ID; for (int i = 0; i <= numEntries; i++) { ByteBuf packet; if (i == 0) { packet = generateMetaEntry(1, masterKey); } else { packet = ClientUtil.generatePacket(1, i, lastConfirmed, i * data.length, data); } lastConfirmed = i; ByteBuffer lenBuff = ByteBuffer.allocate(4); lenBuff.putInt(packet.readableBytes()); lenBuff.flip(); bc.write(Unpooled.wrappedBuffer(lenBuff)); bc.write(packet); packet.release(); } // write fence key ByteBuf packet = generateFenceEntry(1); ByteBuf lenBuf = Unpooled.buffer(); lenBuf.writeInt(packet.readableBytes()); bc.write(lenBuf); bc.write(packet); bc.flushAndForceWrite(false); updateJournalVersion(jc, JournalChannel.V4); return jc; } private JournalChannel writeV5Journal(File journalDir, int numEntries, byte[] masterKey) throws Exception { long logId = System.currentTimeMillis(); JournalChannel jc = new JournalChannel(journalDir, logId); BufferedChannel bc = jc.getBufferedChannel(); ByteBuf paddingBuff = Unpooled.buffer(); paddingBuff.writeZero(2 * JournalChannel.SECTOR_SIZE); byte[] data = new byte[4 * 1024 * 1024]; Arrays.fill(data, (byte) 'X'); long lastConfirmed = LedgerHandle.INVALID_ENTRY_ID; long length = 0; for (int i = 0; i <= numEntries; i++) { ByteBuf packet; if (i == 0) { packet = generateMetaEntry(1, masterKey); } else { packet = ClientUtil.generatePacket(1, i, lastConfirmed, length, data, 0, i); } lastConfirmed = i; length += i; ByteBuf lenBuff = Unpooled.buffer(); lenBuff.writeInt(packet.readableBytes()); bc.write(lenBuff); bc.write(packet); packet.release(); Journal.writePaddingBytes(jc, paddingBuff, JournalChannel.SECTOR_SIZE); } // write fence key ByteBuf packet = generateFenceEntry(1); ByteBuf lenBuf = Unpooled.buffer(); lenBuf.writeInt(packet.readableBytes()); bc.write(lenBuf); bc.write(packet); Journal.writePaddingBytes(jc, paddingBuff, JournalChannel.SECTOR_SIZE); bc.flushAndForceWrite(false); updateJournalVersion(jc, JournalChannel.V5); return jc; } /** * test that we can open a journal written without the magic * word at the start. This is for versions of bookkeeper before * the magic word was introduced */ @Test public void testPreV2Journal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writePreV2Journal(Bookie.getCurrentDirectory(journalDir), 100); writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 100); try { b.readEntry(1, 101); fail("Shouldn't have found entry 101"); } catch (Bookie.NoEntryException e) { // correct behaviour } b.shutdown(); } @Test public void testV4Journal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writeV4Journal(Bookie.getCurrentDirectory(journalDir), 100, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 100); try { b.readEntry(1, 101); fail("Shouldn't have found entry 101"); } catch (Bookie.NoEntryException e) { // correct behaviour } assertTrue(b.handles.getHandle(1, "testPasswd".getBytes()).isFenced()); b.shutdown(); } @Test public void testV5Journal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writeV5Journal(Bookie.getCurrentDirectory(journalDir), 2 * JournalChannel.SECTOR_SIZE, "testV5Journal".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); for (int i = 1; i <= 2 * JournalChannel.SECTOR_SIZE; i++) { b.readEntry(1, i); } try { b.readEntry(1, 2 * JournalChannel.SECTOR_SIZE + 1); fail("Shouldn't have found entry " + (2 * JournalChannel.SECTOR_SIZE + 1)); } catch (Bookie.NoEntryException e) { // correct behavior } assertTrue(b.handles.getHandle(1, "testV5Journal".getBytes()).isFenced()); b.shutdown(); } /** * Test that if the journal is all journal, we can not * start the bookie. An admin should look to see what has * happened in this case */ @Test public void testAllJunkJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writeJunkJournal(Bookie.getCurrentDirectory(journalDir)); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = null; try { b = new Bookie(conf); fail("Shouldn't have been able to start without admin"); } catch (Throwable t) { // correct behaviour } finally { if (b != null) { b.shutdown(); } } } /** * Test that we can start with an empty journal. * This can happen if the bookie crashes between creating the * journal and writing the magic word. It could also happen before * the magic word existed, if the bookie started but nothing was * ever written. */ @Test public void testEmptyJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writePreV2Journal(Bookie.getCurrentDirectory(journalDir), 0); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); } /** * Test that a journal can load if only the magic word and * version are there. */ @Test public void testHeaderOnlyJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writeV2Journal(Bookie.getCurrentDirectory(journalDir), 0); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); } /** * Test that if a journal has junk at the end, it does not load. * If the journal is corrupt like this, admin intervention is needed */ @Test public void testJunkEndedJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); JournalChannel jc = writeV2Journal(Bookie.getCurrentDirectory(journalDir), 0); jc.getBufferedChannel().write(Unpooled.wrappedBuffer("JunkJunkJunk".getBytes())); jc.getBufferedChannel().flushAndForceWrite(false); writeIndexFileForLedger(ledgerDir, 1, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = null; try { b = new Bookie(conf); } catch (Throwable t) { // correct behaviour } } /** * Test that if the bookie crashes while writing the length * of an entry, that we can recover. * * <p>This is currently not the case, which is bad as recovery * should be fine here. The bookie has crashed while writing * but so the client has not be notified of success. */ @Test public void testTruncatedInLenJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); JournalChannel jc = writeV2Journal( Bookie.getCurrentDirectory(journalDir), 100); ByteBuffer zeros = ByteBuffer.allocate(2048); jc.fc.position(jc.getBufferedChannel().position() - 0x429); jc.fc.write(zeros); jc.fc.force(false); writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 99); try { b.readEntry(1, 100); fail("Shouldn't have found entry 100"); } catch (Bookie.NoEntryException e) { // correct behaviour } } /** * Test that if the bookie crashes in the middle of writing * the actual entry it can recover. * In this case the entry will be available, but it will corrupt. * This is ok, as the client will disregard the entry after looking * at its checksum. */ @Test public void testTruncatedInEntryJournal() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); JournalChannel jc = writeV2Journal( Bookie.getCurrentDirectory(journalDir), 100); ByteBuffer zeros = ByteBuffer.allocate(2048); jc.fc.position(jc.getBufferedChannel().position() - 0x300); jc.fc.write(zeros); jc.fc.force(false); writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 99); // still able to read last entry, but it's junk ByteBuf buf = b.readEntry(1, 100); assertEquals("Ledger Id is wrong", buf.readLong(), 1); assertEquals("Entry Id is wrong", buf.readLong(), 100); assertEquals("Last confirmed is wrong", buf.readLong(), 99); assertEquals("Length is wrong", buf.readLong(), 100 * 1024); buf.readLong(); // skip checksum boolean allX = true; for (int i = 0; i < 1024; i++) { byte x = buf.readByte(); allX = allX && x == (byte) 'X'; } assertFalse("Some of buffer should have been zeroed", allX); try { b.readEntry(1, 101); fail("Shouldn't have found entry 101"); } catch (Bookie.NoEntryException e) { // correct behaviour } } /** * Test journal replay with SortedLedgerStorage and a very small max * arena size. */ @Test public void testSortedLedgerStorageReplayWithSmallMaxArenaSize() throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); JournalChannel jc = writeV2Journal( Bookie.getCurrentDirectory(journalDir), 100); jc.fc.force(false); writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes()); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setLedgerStorageClass("org.apache.bookkeeper.bookie.SortedLedgerStorage"); conf.setSkipListArenaMaxAllocSize(0); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }); Bookie b = new Bookie(conf); b.readJournal(); b.ledgerStorage.flush(); b.readEntry(1, 80); b.readEntry(1, 99); } /** * Test partial index (truncate master key) with pre-v3 journals. */ @Test public void testPartialFileInfoPreV3Journal1() throws Exception { testPartialFileInfoPreV3Journal(true); } /** * Test partial index with pre-v3 journals. */ @Test public void testPartialFileInfoPreV3Journal2() throws Exception { testPartialFileInfoPreV3Journal(false); } /** * Test partial index file with pre-v3 journals. */ private void testPartialFileInfoPreV3Journal(boolean truncateMasterKey) throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); writePreV2Journal(Bookie.getCurrentDirectory(journalDir), 100); writePartialIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes(), truncateMasterKey); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); if (truncateMasterKey) { try { Bookie b = new Bookie(conf); b.readJournal(); fail("Should not reach here!"); } catch (IOException ie) { } } else { Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 100); try { b.readEntry(1, 101); fail("Shouldn't have found entry 101"); } catch (Bookie.NoEntryException e) { // correct behaviour } } } /** * Test partial index (truncate master key) with post-v3 journals. */ @Test public void testPartialFileInfoPostV3Journal1() throws Exception { testPartialFileInfoPostV3Journal(true); } /** * Test partial index with post-v3 journals. */ @Test public void testPartialFileInfoPostV3Journal2() throws Exception { testPartialFileInfoPostV3Journal(false); } /** * Test partial index file with post-v3 journals. */ private void testPartialFileInfoPostV3Journal(boolean truncateMasterKey) throws Exception { File journalDir = createTempDir("bookie", "journal"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(journalDir)); File ledgerDir = createTempDir("bookie", "ledger"); Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir)); byte[] masterKey = "testPasswd".getBytes(); writeV3Journal(Bookie.getCurrentDirectory(journalDir), 100, masterKey); writePartialIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, masterKey, truncateMasterKey); ServerConfiguration conf = TestBKConfiguration.newServerConfiguration(); conf.setJournalDirName(journalDir.getPath()) .setLedgerDirNames(new String[] { ledgerDir.getPath() }) .setMetadataServiceUri(null); Bookie b = new Bookie(conf); b.readJournal(); b.readEntry(1, 100); try { b.readEntry(1, 101); fail("Shouldn't have found entry 101"); } catch (Bookie.NoEntryException e) { // correct behaviour } } }
[ "harshitg@gatech.edu" ]
harshitg@gatech.edu
8828df8fb6e726a1258341eee508fb770276fbd4
ac5d08387f8c51289fdad003b7c9f5ad8c77e876
/corona_android/app/src/main/java/com/example/corona/PatientDetailActivity.java
550e0d9e687eadb3484ff1b4af762c766350f3ec
[]
no_license
CJW23/Corona_Android_Project
cdaecc3f792619d97b9f6c507ef2cc0ac2a34aef
146d9d986121a5f0b53056e57d0b78a400f5ee27
refs/heads/master
2021-03-03T11:26:27.668413
2020-03-22T13:12:40
2020-03-22T13:12:40
245,957,420
0
0
null
null
null
null
UTF-8
Java
false
false
618
java
package com.example.corona; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; public class PatientDetailActivity extends AppCompatActivity { private TextView text; private Intent intent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_patient_detail); intent = getIntent(); text = (TextView)findViewById(R.id.detail_text); text.setText(intent.getExtras().getString("detail")); } }
[ "cjw7242@gmail.com" ]
cjw7242@gmail.com
3933efb3a2966274096c6d8378a303930478d763
8ec951ba315ed12565e753c3ba4426110e7e0457
/src/main/java/com/app/controller/UserController.java
c166c4b26c1a74f9d4b10b25f45f248330a49ffa
[]
no_license
Uniquebuddies110/SpringBoot-AngularJs-SPA-App
9ae376a9ac0810c213d95de51c30615e7fdeb51a
7450d6c302d0aeeee9933bdb6a1c7c3c8b091351
refs/heads/master
2022-12-18T03:09:55.238285
2020-09-13T16:26:57
2020-09-13T16:26:57
295,190,631
0
0
null
null
null
null
UTF-8
Java
false
false
1,322
java
package com.app.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.app.dto.User; import com.app.service.UserService; @Controller public class UserController { @Autowired private UserService userService; @RequestMapping("/home") public String homePage() { return "Home"; } @RequestMapping("/userReg") public String userRegPage() { return "userReg"; } @RequestMapping(value="/register",method=RequestMethod.POST) @ResponseBody public ResponseEntity<String> userRegisterPage(@RequestBody User user) { System.out.println("Application.userRegPage()"); System.out.println("user: "+user); return userService.saveUser(user); } @RequestMapping("/displayUsers") public String displayUsersPage() { return "displayUsers"; } @RequestMapping("/deleteUser") public String deleteUserPage() { return "deleteUser"; } }
[ "ajay@Ajay" ]
ajay@Ajay
bbb0fbbb65e4b8419c1988ab562345d9536337bf
94bb04dd64316854c4029958d6bedd5d4d76b99e
/ConvertMe/src/main/java/Convert.java
88f400f283bbc9dc7945f4ce2bc491a77b79e602
[]
no_license
Ipshita-Das22/converting-documents-using-Java-application
40f260b78ffd345642de14b7b51dfbbfb599741e
67e2773746779b76daebd820c359ebff2c2ad308
refs/heads/main
2023-07-28T15:58:32.706241
2021-09-07T07:01:39
2021-09-07T07:01:39
403,873,854
1
0
null
null
null
null
UTF-8
Java
false
false
9,390
java
import com.aspose.words.*; import com.spire.pdf.FileFormat; import com.spire.pdf.PdfDocument; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Convert extends JFrame { final private JLabel choose; final private JTextField paths; final private JComboBox type; final private JButton open,save,clear,close,update; final private JFileChooser opn,sav; final private FileNameExtensionFilter ex = new FileNameExtensionFilter("only word file (.doc)", ("doc")); final private FileNameExtensionFilter ex1 = new FileNameExtensionFilter("only word file (.docx)", ("docx")); final private FileNameExtensionFilter ex2 = new FileNameExtensionFilter("only pdf file (.pdf)", ("pdf")); final private FileNameExtensionFilter ex3 = new FileNameExtensionFilter("only xps file (.xps)", ("xps")); final private FileNameExtensionFilter ex4 = new FileNameExtensionFilter("only html file (.html)", ("html")); private String from,to; public Convert(){ setVisible(true); setSize(700,500); setLocationRelativeTo(null); setResizable(false); setTitle("Convert Files"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = this.getContentPane(); c.setBackground(new Color(204,255,153)); c.setLayout(null); choose = new JLabel("Choose file"); choose.setBounds(15,15,100,30); choose.setFont(new Font("arial",Font.BOLD,15)); paths = new JTextField(); paths.setBounds(120,15,400,30); paths.setBackground(Color.WHITE); paths.setEditable(false); String arr[] ={"SELECT THE FORMAT TO CONVERT -:","DOC to PDF","DOCX to PDF","XPS to PDF","PDF to DOCX","HTML to PDF"}; type = new JComboBox(arr); type.setBackground(Color.WHITE); type.setEditable(false); type.setToolTipText("select your option"); type.setBounds(120,60,400,30); open = new JButton("Open"); open.setBounds(530,15,100,30); open.setFont(new Font("arial",Font.BOLD,15)); open.setCursor(new Cursor(Cursor.HAND_CURSOR)); update = new JButton("Update"); update.setBounds(530,60,100,30); update.setFont(new Font("arial",Font.BOLD,15)); update.setCursor(new Cursor(Cursor.HAND_CURSOR)); clear = new JButton("Clear"); clear.setBounds(270,400,100,30); clear.setFont(new Font("arial",Font.BOLD,15)); clear.setCursor(new Cursor(Cursor.HAND_CURSOR)); save = new JButton("Save"); save.setBounds(380,400,100,30); save.setFont(new Font("arial",Font.BOLD,15)); save.setCursor(new Cursor(Cursor.HAND_CURSOR)); save.setEnabled(false); close = new JButton("Close"); close.setBounds(490,400,100,30); close.setFont(new Font("arial",Font.BOLD,15)); close.setCursor(new Cursor(Cursor.HAND_CURSOR)); c.add(choose); c.add(paths); c.add(type); c.add(open); c.add(clear); c.add(close); c.add(save); c.add(update); //adding actions to clear button clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { paths.setText(""); save.setEnabled(false); } }); //adding actions to update button open.setEnabled(false); update.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { paths.setText(""); if(type.getSelectedIndex()==0){ open.setEnabled(false); } else if (type.getSelectedIndex() == 1) { open.setEnabled(true); opn.resetChoosableFileFilters(); opn.addChoosableFileFilter(ex); } else if (type.getSelectedIndex() == 2) { open.setEnabled(true); opn.resetChoosableFileFilters(); opn.addChoosableFileFilter(ex1); } else if (type.getSelectedIndex() == 3) { open.setEnabled(true); opn.resetChoosableFileFilters(); opn.addChoosableFileFilter(ex3); } else if (type.getSelectedIndex() == 4) { open.setEnabled(true); opn.resetChoosableFileFilters(); opn.addChoosableFileFilter(ex2); } else if (type.getSelectedIndex() == 5) { open.setEnabled(true); opn.resetChoosableFileFilters(); opn.addChoosableFileFilter(ex4); } else { open.setEnabled(false); } } }); //adding actions to close button close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); //adding actions to open button opn = new JFileChooser("D:/"); opn.setAcceptAllFileFilterUsed(false); open.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int a = opn.showOpenDialog(null); if (a == JFileChooser.APPROVE_OPTION) { from = opn.getSelectedFile().getAbsolutePath(); paths.setText(from); save.setEnabled(true); } } }); //adding actions to save button sav = new JFileChooser("d:/"); PdfSaveOptions ps = new PdfSaveOptions(); ps.setCompliance(PdfCompliance.PDF_15) ; save.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int a = sav.showSaveDialog(null); if (a == JFileChooser.APPROVE_OPTION) { to = sav.getSelectedFile().getAbsolutePath(); try { switch(type.getSelectedIndex()){ case 1: Document d = new Document(from); d.save(to,ps); break; case 2: Document d1 = new Document(from); d1.save(to,ps); break; case 3: Document d2 = new Document(from); d2.save(to,ps); break; case 4: PdfDocument doc4 = new PdfDocument(); //load a sample PDF file doc4.loadFromFile(from); //save as .doc file doc4.saveToFile(to, FileFormat.DOCX); doc4.close(); break; case 5: Document d5 = new Document(from); d5.save(to,ps); break; default: JOptionPane.showMessageDialog(null, "CANT PERFORM THE OPERATION", "Error", JOptionPane.ERROR_MESSAGE); break; } JOptionPane.showMessageDialog(null, "Document Created", "Message", JOptionPane.INFORMATION_MESSAGE); paths.setText(""); to=""; from=""; save.setEnabled(false); }catch (Exception e1){ e1.printStackTrace(); JOptionPane.showMessageDialog(null, "CANT PERFORM THE OPERATION", "Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "CANCELLED OPERATION", "Message", JOptionPane.INFORMATION_MESSAGE); sav.setEnabled(false); } } }); } public static void main(String...args) throws Exception{ new Convert(); } }
[ "noreply@github.com" ]
noreply@github.com
ca7b7b4c33ce98d1ea9161985f54b81d7d3e7072
cb7b6e948ddea1ab8dc5fd0565059cd5b5de9a23
/src/main/java/com/vgmsistemas/vgmweb/service/ContactoService.java
c2e2aaa0535890747ec4ba65f4a9bf63bac14a6d
[]
no_license
mdgarcia4/VGMWeb
631ae57e564165f967a4fa555415e668fa57ef50
d901f61cb94cbf8d58e8baa9a8433dc4b0e7fb94
refs/heads/master
2023-03-08T01:02:28.337294
2021-02-17T19:41:38
2021-02-17T19:41:38
263,759,735
1
0
null
null
null
null
UTF-8
Java
false
false
2,302
java
package com.vgmsistemas.vgmweb.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.MailAuthenticationException; import org.springframework.mail.MailException; import org.springframework.mail.MailParseException; import org.springframework.mail.MailSendException; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import com.vgmsistemas.vgmweb.dto.ContactoConsulta; @Service public class ContactoService { @Autowired EnvioMail mail; @Autowired PropertiesService propertyService; static Logger logger = LoggerFactory.getLogger(ContactoService.class); public String mandarConsulta(ContactoConsulta consulta) { String respuesta,msjMail = ""; try { msjMail = "Consulta de " + consulta.getName() + ";\n"; msjMail += "Correo electrónico: " + consulta.getEmail() + ".\n"; msjMail += "Título de la consulta: " + consulta.getSub() + ".\n"; msjMail += "Comentario: " + consulta.getMessage() + ".\n"; mail.sendEmail(propertyService.getEmailDeConsulta(), propertyService.getAsuntoContulta(), msjMail); respuesta = "OK"; } catch (MailParseException mpe) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. El mensaje en el email no puede ser parseado."); throw mpe; } catch (MailAuthenticationException mae) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. No es posible autenticarse con el email."); throw mae; } catch (MailSendException mse) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. Problemas en el envío del email."); throw mse; } catch (MailException me) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. Problemas general en el envío del email."); throw me; } catch (UsernameNotFoundException ex) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. El email configurado no es correcto o la clave no es valida."); throw ex; } catch (Exception e) { logger.error("Error inesperado en clase ContactoService-Met: mandarConsulta. Exception general"); throw e; } return respuesta; } }
[ "gustavorbravo@gmail.com" ]
gustavorbravo@gmail.com
2b04f3198cce575f41eca5f308abcb6c015538b9
ca0ff73a182fb8daf1478dba04683a5d0c205680
/Spring/Spring_Recipes_3/Ch5/Recipe_5_1_v/src/main/java/com/apress/springrecipes/court/web/RestMemberController.java
a2cb0464d5391cc971638598fe727e540f1348d8
[]
no_license
DawningTiger/Studio
3db6c8f3e56600201947ffd0f652c76f663f328b
0472979ea13ddb5d3a836bc9fc7dbd5d8f710c24
refs/heads/master
2023-04-27T18:28:05.502124
2019-11-07T05:53:11
2019-11-07T05:53:11
91,751,549
3
0
null
2023-04-21T20:39:53
2017-05-19T01:10:45
HTML
UTF-8
Java
false
false
1,475
java
package com.apress.springrecipes.court.web; import com.apress.springrecipes.court.domain.Member; import com.apress.springrecipes.court.domain.Members; import com.apress.springrecipes.court.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; /** * Created by marten on 16-06-14. */ @Controller public class RestMemberController { private final MemberService memberService; @Autowired public RestMemberController(MemberService memberService) { super(); this.memberService=memberService; } @RequestMapping("/members") @ResponseBody public Members getRestMembers() { Members members = new Members(); members.addMembers(memberService.findAll()); return members; } @RequestMapping("/member/{memberid}") @ResponseBody public ResponseEntity<Member> getMember(@PathVariable("memberid") long memberID) { Member member = memberService.find(memberID); if (member != null) { return new ResponseEntity<Member>(member, HttpStatus.OK); } return new ResponseEntity(HttpStatus.NOT_FOUND); } }
[ "410758267@qq.com" ]
410758267@qq.com
59ed8c26010227b900df60300cbbd3f1e1f0f1c8
ae5eb1a38b4d22c82dfd67c86db73592094edc4b
/project475/src/test/java/org/gradle/test/performance/largejavamultiproject/project475/p2378/Test47564.java
e9e9e401a64618e2961d6023f4bb75f8ecbc7f8b
[]
no_license
big-guy/largeJavaMultiProject
405cc7f55301e1fd87cee5878a165ec5d4a071aa
1cd6a3f9c59e9b13dffa35ad27d911114f253c33
refs/heads/main
2023-03-17T10:59:53.226128
2021-03-04T01:01:39
2021-03-04T01:01:39
344,307,977
0
0
null
null
null
null
UTF-8
Java
false
false
2,182
java
package org.gradle.test.performance.largejavamultiproject.project475.p2378; import org.junit.Test; import static org.junit.Assert.*; public class Test47564 { Production47564 objectUnderTest = new Production47564(); @Test public void testProperty0() { Production47561 value = new Production47561(); objectUnderTest.setProperty0(value); assertEquals(value, objectUnderTest.getProperty0()); } @Test public void testProperty1() { Production47562 value = new Production47562(); objectUnderTest.setProperty1(value); assertEquals(value, objectUnderTest.getProperty1()); } @Test public void testProperty2() { Production47563 value = new Production47563(); objectUnderTest.setProperty2(value); assertEquals(value, objectUnderTest.getProperty2()); } @Test public void testProperty3() { String value = "value"; objectUnderTest.setProperty3(value); assertEquals(value, objectUnderTest.getProperty3()); } @Test public void testProperty4() { String value = "value"; objectUnderTest.setProperty4(value); assertEquals(value, objectUnderTest.getProperty4()); } @Test public void testProperty5() { String value = "value"; objectUnderTest.setProperty5(value); assertEquals(value, objectUnderTest.getProperty5()); } @Test public void testProperty6() { String value = "value"; objectUnderTest.setProperty6(value); assertEquals(value, objectUnderTest.getProperty6()); } @Test public void testProperty7() { String value = "value"; objectUnderTest.setProperty7(value); assertEquals(value, objectUnderTest.getProperty7()); } @Test public void testProperty8() { String value = "value"; objectUnderTest.setProperty8(value); assertEquals(value, objectUnderTest.getProperty8()); } @Test public void testProperty9() { String value = "value"; objectUnderTest.setProperty9(value); assertEquals(value, objectUnderTest.getProperty9()); } }
[ "sterling.greene@gmail.com" ]
sterling.greene@gmail.com
48296ef1f4084aaa11abc7ba96c165890a9f07f5
d23386db14dca6ade2604bd1de959d2dab7b8d09
/Robot2/app/src/main/java/com/example/administrator/robot/FtpUtil.java
285a93a63a7149cb27a4ad403e5f9eb0461a4909
[]
no_license
dybangel/gubaomojing
3f30b74f9a845b56bd00267e33992050025e0a50
59d3d0779d2016555844f75d34ff5348f7eb17cf
refs/heads/master
2020-04-12T04:45:39.501331
2019-10-14T17:00:18
2019-10-14T17:00:18
162,304,891
0
0
null
null
null
null
UTF-8
Java
false
false
4,177
java
package com.example.administrator.robot; import android.util.Log; import java.io.FileInputStream; import java.io.FileOutputStream; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; class FtpUtil { private FTPClient ftpClient; private String serverIp; private int port; private String userName; private String passWord; public FtpUtil(String serverIp, int port, String userName, String passWord) { super(); this.serverIp = serverIp; this.port = port; this.userName = userName; this.passWord = passWord; } /** * 连接ftp服务器 * @return */ public boolean open(){ if(ftpClient != null && ftpClient.isConnected()) return true; //连接服务器 try{ ftpClient = new FTPClient(); ftpClient.connect(serverIp, port); //连接服务器 ftpClient.login(userName, passWord); //登录 ftpClient.setBufferSize(1024); //设置文件类型,二进制 ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode(); int reply = ftpClient.getReplyCode(); if(!FTPReply.isPositiveCompletion(reply)){ //判断ftp服务器是否连通 this.closeFtp(); System.out.println("FtpServer连接失败!"); return false; }else{ System.out.println("FtpServer连接成功!!!!!!"); } return true; }catch(Exception e){ this.closeFtp(); e.printStackTrace(); return false; } } /** * 关闭ftp服务器,主要是对disconnect函数的调用 */ public void closeFtp() { try { if (ftpClient != null && ftpClient.isConnected()) ftpClient.disconnect(); } catch (Exception e) { e.printStackTrace(); } System.out.println("Close Server Success :"+this.serverIp+";port:"+this.port); } /** * 从ftp服务器下载文件 * @param ftpDirectoryAndFileName 包含ftp部分的文件路径和名字,这里是从ftp设置的根目录开始 * @param localDirectoryAndFieName 本文的文件路径和文件名字,相当于是绝对路径 * @return */ public boolean donwLoad(String ftpDirectoryAndFileName,String localDirectoryAndFieName){ if(!ftpClient.isConnected()){ return false; } FileOutputStream fos =null; try { fos = new FileOutputStream(localDirectoryAndFieName); //下面的函数实现文件的下载功能,参数的设置解决了ftp服务中的中文问题。这里要记得更改eclipse的编码格式为utf-8 ftpClient.retrieveFile(new String(ftpDirectoryAndFileName.getBytes(), "iso-8859-1"), fos); fos.close(); return true; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return false; }finally{ this.closeFtp(); } } /** *从本地上传文件到ftp服务器 * @param ftpDirectoryAndFileName * @param localDirectoryAndFieName * @return */ public boolean upLoading(String ftpDirectoryAndFileName,String localDirectoryAndFieName){ if(!ftpClient.isConnected()){ return false; } FileInputStream fis = null; try { Log.d("ftputil:","开始上传ftp....."); fis = new FileInputStream(localDirectoryAndFieName); //和文件的下载基本一致,但是要注意流的写法 ftpClient.storeFile(new String(ftpDirectoryAndFileName.getBytes(), "utf-8"), fis);//iso-8859-1 fis.close(); return true; } catch (Exception e) { // TODO: handle exception Log.d("catch++++++++++++",e.toString()); e.printStackTrace(); return false; }finally{ this.closeFtp(); } } }
[ "176682769@qq.com" ]
176682769@qq.com
e92555eba6cef426eecb62c9e04f1bd4e8f44055
c7da370b30f14e7cd8a5810143cc691c283a81a3
/9.ssm小微博/ssm-wb/src/com/lzr/controller/AdminuserController.java
c88442b8793485e8dd541a30b9efd6613c1cdfe9
[]
no_license
xu-juan/project
86d5484be0c3044e5715b993ce0ed3f4b1403248
ff43774353d8ac2130926b1b3aa8a18c7f91c486
refs/heads/master
2021-09-27T19:54:50.552210
2018-11-11T05:52:41
2018-11-11T05:52:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,366
java
package com.lzr.controller; import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import org.springframework.http.HttpRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.lzr.pojo.Adminuser; import com.lzr.pojo.Page; import com.lzr.pojo.QueryVo; import com.lzr.service.AdminuserService; @Controller("adminuserController") public class AdminuserController { @Resource(name = "adminuserService") private AdminuserService adminuserService; /* * 用户注册 */ @RequestMapping("/register.action") public String register(Model model, HttpSession session, Adminuser user, String productCheck) { String checkcode_session = (String) session.getAttribute("checkcode_session"); System.out.println(user); if (user.getUsernichen() == null || user.getUserpassword() == null || user.getUsernichen() == "" || user.getUserpassword() == "") { model.addAttribute("checkuser", "昵称或密码不能为空"); return "forward:toregister.action"; } if (!productCheck.equals(checkcode_session)) { model.addAttribute("check", "验证码有误"); return "forward:toregister.action"; } Integer findUser = adminuserService.findUser(user.getUsernichen()); if (findUser == null) { model.addAttribute("checkuser", "昵称或密码有误"); return "forward:toregister.action"; } if (productCheck.equals(checkcode_session) && findUser != null) { user.setUsercreatetime(new Date()); user.setState("0"); Integer register = adminuserService.register(user); if (register == 1) { return "redirect:tologin.action"; } } return "redirect:toregister.action"; } /* * 用户登录 */ @RequestMapping("/login.action") public String login(Model model, HttpSession session, Adminuser user) { Adminuser login = adminuserService.login(user); if (login != null) { session.setAttribute("username", login.getUsernichen()); session.setAttribute("userid", login.getUserid()); return "redirect:touser.action"; } model.addAttribute("message", "用户名或密码有误"); return "forward:tologin.action"; } /* * 用户退出 */ @RequestMapping("/logout.action") public String loginout(Model model, HttpSession session) { session.invalidate(); return "redirect:tologin.action"; } /* * ajax检验用户昵称是否已经注册 */ @RequestMapping("/checkUserNiChen.action") public @ResponseBody String checkUserNiChen(@RequestBody String usernichen) { // 切割json数据获取值 String[] split = usernichen.split(":"); String check = split[1].substring(0, split[1].length() - 1); Integer findUser = adminuserService.findUser(check); if (findUser == null) { return "{\"name\":\"yes\"}"; } return "{\"name\":\"no\"}"; } /* * ajax检验验证码---json解析 */ @RequestMapping("/productCheck.action") public @ResponseBody String productCheck(HttpSession session, @RequestBody String productCheck) { String checkcode_session = (String) session.getAttribute("checkcode_session"); String[] split = productCheck.split(":"); String check = split[1].substring(0, split[1].length() - 1); if (checkcode_session.equals(check)) { return "{\"name\":\"yes\"}"; } return "{\"name\":\"no\"}"; } /* * 分页查询所有用户 */ @RequestMapping("/touser.action") public String fans(Model model, HttpSession session, @RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "") String pname) { String username = (String) session.getAttribute("username"); QueryVo vo = new QueryVo(); vo.setPage(page); Page<Adminuser> findAllUser = null; vo.setName(username); vo.setFind(pname.trim()); findAllUser = adminuserService.findAllUser(vo); // 获取用户的数集合 List<Adminuser> rows = findAllUser.getRows(); model.addAttribute("lists", rows); model.addAttribute("page", findAllUser); return "login/index"; } }
[ "188@139.com" ]
188@139.com
f722f283e21d393ae877cf7075fe3706a59fa672
715f53b208df06ad80bf89245141773932599fc6
/M1L5/M1_L5_FranksHolly/src/m1_l5_franksholly/M1_L5_FranksHolly.java
320537daa2d82eb762f5da1ad01e0a921fa9cf57
[]
no_license
Franksh8359/FTCC_JavaAssignments
0de31a0b7420d62e4f6e980bf5f4b9a7d29a7462
349212afe7f070293bcbc4c8cae55e0a1c2eca39
refs/heads/master
2020-12-27T02:15:49.773670
2020-02-02T06:37:33
2020-02-02T06:37:33
237,730,751
0
0
null
null
null
null
UTF-8
Java
false
false
1,419
java
/** * Here is lab 5 from module 1 (Personal Information Class) using NetBeans! * 8-28-2017 * CSC 251 Lab 5 - Personal Information Class * @author Holly Franks */ package m1_l5_franksholly; public class M1_L5_FranksHolly { public static void main(String[] args) { Person me = new Person(); Person friend1 = new Person(); Person friend2 = new Person(); me.setName("Holly Franks"); me.setAddress("2256 Second Street, Fayetteville NC 28306"); me.setAge(21); me.setPhone("910-689-5793"); friend1.setName("Paulette Boehler"); friend1.setAddress("213 Walnut Street, Savanna IL 61074"); friend1.setAge(73); friend1.setPhone("710-273-1125"); friend2.setName("John Doe"); friend2.setAddress("103 Hazel Lane, Somewhere NC 01010"); friend2.setAge(28); friend2.setPhone("919-123-4567"); displayRecord(me); displayRecord(friend1); displayRecord(friend2); } public static void displayRecord(Person person) { System.out.println("Name: " + person.getName()); System.out.println("Address: " + person.getAddress()); System.out.println("Age: " + person.getAge()); System.out.println("Phone: " + person.getPhone()); System.out.print("\n"); } }
[ "franksh8359@student.faytechcc.edu" ]
franksh8359@student.faytechcc.edu
6d6a65fe5533886da34ff33c31856adb5c2d006e
3fc119016ed3cf417bc1854c5fd312e993921911
/src/main/java/br/com/fwtj/MavenJSfPrimefaces/jpa/MultiTenantProvider.java
bd22b6ccaf4c9fea1091eec6bc77fa476a1c557e
[]
no_license
fredwilliamtjr/JsfDeltaspikeMultiTenantSession
ffee2129f8729923cbf67d3da489b58a034715c5
48bda75a5366f632480fe85cb1c5eea350f45943
refs/heads/master
2022-12-07T13:02:26.214149
2020-01-18T14:53:10
2020-01-18T14:53:10
175,270,316
2
1
null
2022-11-24T08:54:04
2019-03-12T18:07:05
Java
UTF-8
Java
false
false
6,432
java
package br.com.fwtj.MavenJSfPrimefaces.jpa; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.c3p0.internal.C3P0ConnectionProvider; import org.hibernate.cfg.Environment; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.ServiceRegistryAwareService; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.Stoppable; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import java.sql.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class MultiTenantProvider implements MultiTenantConnectionProvider, Stoppable, ServiceRegistryAwareService { private static final long serialVersionUID = 1L; private ConnectionProvider connectionProvider = null; @Override public boolean isUnwrappableAs(Class unwrapType) { return false; } @Override public <T> T unwrap(Class<T> unwrapType) { return null; } @Override public void injectServices(ServiceRegistryImplementor serviceRegistry) { Map lSettings = serviceRegistry.getService(ConfigurationService.class).getSettings(); connectionProvider = new C3P0ConnectionProvider(); Class<?> providerClass = connectionProvider.getClass(); if (!Configurable.class.isAssignableFrom(providerClass) || !Stoppable.class.isAssignableFrom(providerClass) || !ServiceRegistryAwareService.class.isAssignableFrom(providerClass)) { throw new RuntimeException("The provider '" + providerClass + "' needs to implment the intrefaces: Configurable, Stoppable, ServiceRegistryAwareService"); } ((ServiceRegistryAwareService) connectionProvider).injectServices(serviceRegistry); ((Configurable) connectionProvider).configure(lSettings); } @Override public Connection getAnyConnection() throws SQLException { return connectionProvider.getConnection(); } @Override public void releaseAnyConnection(Connection connection) throws SQLException { try { connection.createStatement().execute("SET SCHEMA 'public'"); } catch (Exception e) { throw new HibernateException("Could not alter JDBC connection to specified schema [public]", e); } connectionProvider.closeConnection(connection); } @Override public Connection getConnection(String tenantIdentifier) throws SQLException { final Connection connection = getAnyConnection(); List<Tenant> tenantList = new ArrayList<>(); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("select schema_name from information_schema.schemata"); while (resultSet.next()) { String resultSetString = resultSet.getString(1); Tenant tenant = new Tenant(resultSetString); tenantList.add(tenant); } statement.close(); boolean contains = tenantList.contains(new Tenant(tenantIdentifier)); System.out.println("contains : " + contains); if (!contains) { criarSchema(tenantIdentifier); criarTabelas(tenantIdentifier); } try { boolean execute = connection.createStatement().execute("SET SCHEMA '" + tenantIdentifier + "'"); } catch (Exception e) { throw new HibernateException("Could not alter JDBC connection to specified schema [" + tenantIdentifier + "]", e); } return connection; } @Override public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException { releaseAnyConnection(connection); } @Override public boolean supportsAggressiveRelease() { return false; } @Override public void stop() { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>> STOP <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); ((Stoppable) connectionProvider).stop(); } private void criarSchema(String schemaName) { Connection connection = null; Statement statement = null; try { String IP_BANCO_DADOS = "localhost"; String PORTA_BANCO_DADOS = "5433"; String NOME_BANCO_DADOS_CLIENTE = "sistema"; String USUARIO_SISTEMA_BANCO_DADOS = "user"; String SENHA_SISTEMA_BANCO_DADOS = "123456"; connection = DriverManager.getConnection("jdbc:postgresql://" + IP_BANCO_DADOS + ":" + PORTA_BANCO_DADOS + "/" + NOME_BANCO_DADOS_CLIENTE, USUARIO_SISTEMA_BANCO_DADOS, SENHA_SISTEMA_BANCO_DADOS); statement = connection.createStatement(); int executeUpdate0 = statement.executeUpdate("CREATE SCHEMA \"" + schemaName + "\" AUTHORIZATION \"" + USUARIO_SISTEMA_BANCO_DADOS + "\";"); int executeUpdate1 = statement.executeUpdate("GRANT ALL ON SCHEMA \"" + schemaName + "\" TO \"" + USUARIO_SISTEMA_BANCO_DADOS + "\";"); statement.close(); connection.close(); } catch (Exception e) { try { statement.close(); connection.close(); } catch (Exception ignored) { } } } private void criarTabelas(String schemaName) { Map<String, String> properties = new HashMap<>(); properties.put(Environment.URL, "jdbc:postgresql://localhost:5433/sistema?ApplicationName=SistemaCriarTabelas"); properties.put(Environment.C3P0_MIN_SIZE, "1"); properties.put(Environment.C3P0_MAX_SIZE, "1"); properties.put("hibernate.default_schema", schemaName); EntityManagerFactory factory = Persistence.createEntityManagerFactory("SISTEMA", properties); SessionFactory sessionFactory = factory.unwrap(SessionFactory.class); Session session = sessionFactory.openSession(); session.close(); sessionFactory.close(); factory.close(); properties = null; factory = null; sessionFactory = null; session = null; } }
[ "fredwilliam@gmail.com" ]
fredwilliam@gmail.com
989126c5f603542b5caa46d0dcd26ecc3c37ff56
d3ff05c9620d61c25392da1030f1f64e27ffb8df
/msinm-user/src/main/java/dk/dma/msinm/user/UserService.java
25570afb44d98711c11eff751c7dad1106ff9cf1
[]
no_license
dma-dk/MsiNm
549c5c1efdfa0cab0715302047346e0973c99226
b0a86895c34b67d28120918e68ea780d42a520a9
refs/heads/master
2022-11-25T02:08:56.833824
2019-09-04T11:50:55
2019-09-04T11:50:55
19,449,439
6
1
null
2022-11-16T03:41:51
2014-05-05T08:35:15
Java
UTF-8
Java
false
false
13,695
java
/* Copyright (c) 2011 Danish Maritime Authority * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ package dk.dma.msinm.user; import dk.dma.msinm.common.mail.MailService; import dk.dma.msinm.common.service.BaseService; import dk.dma.msinm.common.templates.TemplateContext; import dk.dma.msinm.common.templates.TemplateService; import dk.dma.msinm.common.templates.TemplateType; import dk.dma.msinm.user.security.JbossJaasCacheFlusher; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import javax.annotation.Resource; import javax.ejb.SessionContext; import javax.ejb.Stateless; import javax.inject.Inject; import java.security.Principal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.regex.Pattern; import java.util.stream.Collectors; /** * Business interface for managing User entities */ @Stateless public class UserService extends BaseService { /** Require 6-20 characters, at least 1 digit and 1 character */ private static final Pattern PASSWORD_PATTERN = Pattern.compile("((?=.*\\d)(?=.*[a-zA-ZæøåÆØÅ]).{6,20})"); @Inject private Logger log; @Resource SessionContext ctx; @Inject private MailService mailService; @Inject private TemplateService templateService; @Inject private JbossJaasCacheFlusher jbossJaasCacheFlusher; /** * Looks up the {@code User} with the given id and preloads the roles * * @param id the id * @return the user or null */ public User findById(Integer id) { try { User user = em.createNamedQuery("User.findById", User.class) .setParameter("id", id) .getSingleResult(); user.preload(); return user; } catch (Exception e) { return null; } } /** * Looks up the {@code User} with the given email address and pre-loads the roles * * @param email the email * @return the user or null */ public User findByEmail(String email) { try { User user = em.createNamedQuery("User.findByEmail", User.class) .setParameter("email", email) .getSingleResult(); user.preload(); return user; } catch (Exception e) { return null; } } /** * Looks up the {@code User} based on the given principal * * @param principal the principal * @return the user or null */ public User findByPrincipal(Principal principal) { // Throughout MSI-NM, the email is used as the Principal name return findByEmail(principal.getName()); } /** * Searches for users matching the given term * @param term the search term * @param limit the maximum number of results * @return the search result */ public List<UserVo> searchUsers(String term, int limit) { List<UserVo> result = new ArrayList<>(); if (StringUtils.isNotBlank(term)) { List<User> users = em .createNamedQuery("User.searchUsers", User.class) .setParameter("term", "%" + term + "%") .setParameter("sort", term) .setMaxResults(limit) .getResultList(); users.forEach(user -> result.add(new UserVo(user))); } return result; } /** * Returns the current caller or null if none is defined * @return the current caller or null if none is defined */ public User getCurrentUser() { if (ctx != null && ctx.getCallerPrincipal() != null) { return findByPrincipal(ctx.getCallerPrincipal()); } return null; } /** * Updates the current user. * * @param user the template user entity * @return the updated user */ public User updateCurrentUser(User user) throws Exception { User existingUser = getCurrentUser(); if (existingUser == null || !existingUser.getEmail().equalsIgnoreCase(user.getEmail())) { throw new IllegalArgumentException("Invalid user " + user.getEmail()); } // Update the existing user existingUser.setFirstName(user.getFirstName()); existingUser.setLastName(user.getLastName()); existingUser.setLanguage(user.getLanguage()); existingUser.setVesselName(user.getVesselName()); existingUser.setMmsi(user.getMmsi()); // And save the user existingUser = saveEntity(existingUser); return existingUser; } /** * Finds the role with the given name * * @param name the name of the role * @return the role or null if not found */ public Role findRoleByName(String name) { try { return em.createNamedQuery("Role.findByName", Role.class) .setParameter("name", name) .getSingleResult(); } catch (Exception e) { return null; } } /** * When creating a new user, check the roles assigned to the user. * <p> * A new user can always get the "user" role, e.g.via self-registration * on the website. * <p> * When an editor or administrator updates a user, they can only assign * roles they hold themselves. * * @param roles the roles to check */ private void validateRoleAssignment(String... roles) { // The "user" role can always be assigned if (roles.length == 1 && roles[0].equals("user")) { return; } // All other role assignments require a calling user with compatible roles User caller = findByPrincipal(ctx.getCallerPrincipal()); if (caller == null) { throw new SecurityException("Invalid caller " + ctx.getCallerPrincipal()); } Set<String> callerRoles = caller.getRoles().stream() .map(Role::getName) .collect(Collectors.toSet()); for (String role : roles) { if (!callerRoles.contains(role)) { throw new SecurityException("Calling user " + ctx.getCallerPrincipal() + " cannot assign role " + role); } } } /** * Validates the strength of the password * @param password the password to validate * @return if the password is valid or not */ public boolean validatePasswordStrength(String password) { return password != null && PASSWORD_PATTERN.matcher(password).matches(); } /** * Called when a person registers a new user via the website. * The user will automatically get the "user" role. * * @param user the template user entity * @return the updated user */ public User registerUser(User user) throws Exception { return registerUserWithRoles(user, true, "user"); } /** * Called when a user has logged in via OAuth and did not exist in advance. * No activation email is sent. * * @param user the template user entity * @return the updated user */ public User registerOAuthOnlyUser(User user) throws Exception { return registerUserWithRoles(user, false, "user"); } /** * Registers a new user with the given roles. * Sends an activation email to the user. * * @param user the template user entity * @param sendEmail whether to send activation email or not * @param roles the list of roles to assign the user * @return the updated user */ private User registerUserWithRoles(User user, boolean sendEmail, String... roles) throws Exception { // Validate that the email address is not already registered if (findByEmail(user.getEmail()) != null) { throw new Exception("Email " + user.getEmail() + " is already registered"); } // Validate the role assignment validateRoleAssignment(roles); // Associate the user with the roles user.getRoles().clear(); for (String role : roles) { user.getRoles().add(findRoleByName(role)); } // Set a reset-password token if (sendEmail) { user.setResetPasswordToken(UUID.randomUUID().toString()); } // Persist the user user = saveEntity(user); // Send registration email if (sendEmail) { Map<String, Object> data = new HashMap<>(); data.put("token", user.getResetPasswordToken()); data.put("name", user.getName()); data.put("email", user.getEmail()); sendEmail(data, "user-activation.ftl", "user.registration.subject", user); } return user; } /** * Called when an administrator creates or edits a user. * * @param user the template user entity * @param roles the list of roles to assign the user * @param activationEmail whether to send an activation email for new users or not * @return the updated user */ public User createOrUpdateUser(User user, String[] roles, boolean activationEmail) throws Exception { // Check if the user is already registered User existnigUser = findByEmail(user.getEmail()); if (existnigUser == null) { // Create a new user existnigUser = registerUserWithRoles(user, activationEmail, roles); } else { // Validate the role assignment validateRoleAssignment(roles); // Update the existing user existnigUser.setFirstName(user.getFirstName()); existnigUser.setLastName(user.getLastName()); existnigUser.setLanguage(user.getLanguage()); existnigUser.getRoles().clear(); for (String role : roles) { existnigUser.getRoles().add(findRoleByName(role)); } existnigUser = saveEntity(existnigUser); } return existnigUser; } /** * First step of setting a new password. * A reset-password token is generated and an email sent to the user * with a link to reset the password. * @param email the email address */ public void resetPassword(String email) throws Exception { User user = findByEmail(email); if (user == null) { throw new Exception("Invalid email " + email); } user.setResetPasswordToken(UUID.randomUUID().toString()); saveEntity(user); // Send reset-password email Map<String, Object> data = new HashMap<>(); data.put("token", user.getResetPasswordToken()); data.put("name", user.getName()); data.put("email", user.getEmail()); sendEmail(data, "reset-password.ftl", "reset.password.subject", user); } /** * Sends an email based on the parameters * @param data the email data * @param template the Freemarker template * @param subjectKey the subject key * @param user the recipient user */ private void sendEmail(Map<String, Object> data, String template, String subjectKey, User user) throws Exception { TemplateContext ctx = templateService.getTemplateContext( TemplateType.MAIL, template, data, user.getLanguage(), "Mails"); String subject = ctx.getBundle().getString(subjectKey); String content = templateService.process(ctx); String baseUri = (String)ctx.getData().get("baseUri"); mailService.sendMail(content, subject, baseUri, user.getEmail()); } /** * Second step of setting a new password. * The used submits the token generated by calling {@code resetPassword()} * along with the new password. * * @param email the email address * */ public void updatePassword(String email, String password, String token) throws Exception { User user = findByEmail(email); if (user == null) { throw new Exception("Invalid email " + email); } if (!token.equals(user.getResetPasswordToken())) { throw new Exception("Invalid token " + token); } // Validate the password strength if (!validatePasswordStrength(password)) { throw new Exception("Invalid password. Must be at least 6 characters long and contain letters and digits"); } if (user.getPassword() == null) { user.setPassword(new SaltedPasswordHash()); } // E-mail used as salt for now user.getPassword().setPassword(password, email); // Reset the password token, so the same mail cannot be used again... user.setResetPasswordToken(null); // Persist the user entity saveEntity(user); // Flush the jboss JAAS cache jbossJaasCacheFlusher.flushJaasCache(email); } }
[ "peder@carolus.dk" ]
peder@carolus.dk
4ec0c00f4255ab3d1cb339d23da84d90b949d046
04b59ceb44be47630397e35802490f65704c4116
/src/main/java/br/com/leonardojgs/scalog/taglib/components/PaginableTable.java
296291a7af40063cc20253becbbd7dc4c756e64f
[ "Apache-2.0" ]
permissive
leosilvadev/scalog
34be2ddc01b0748bf0e4628f9a1cb59a0f37c004
23273911e51cf783a785a5d4d9c86e17684ec3ad
refs/heads/master
2021-01-19T10:58:22.042577
2014-12-16T11:04:48
2014-12-16T11:04:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
430
java
package br.com.leonardojgs.scalog.taglib.components; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; public class PaginableTable extends TagSupport { private static final long serialVersionUID = 9177797199966629593L; @Override public int doStartTag() throws JspException { JspWriter out = pageContext.getOut(); return super.doStartTag(); } }
[ "leosilvadev@gmail.com" ]
leosilvadev@gmail.com
740821589f2109cb53c64b3d37291209a1dfcc3e
2281d40da613b717541b3a0619970259c4a7ef11
/src/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/UpdateByPrimaryKeySelectiveElementGenerator.java
b7869224b41988dce57d152060ded08dda26f0d2
[]
no_license
nihaoyes/hello-git
7745d55ac2c5ad69c97195b6e8854f66bb8cf892
b1d1f17d509f32f6a8ee0f6c1d0283f9d9ef7d95
refs/heads/master
2021-01-19T03:45:41.596024
2016-09-19T05:35:18
2016-09-19T05:35:18
60,438,736
0
0
null
2016-06-05T04:59:35
2016-06-05T02:01:25
null
UTF-8
Java
false
false
5,017
java
/* */ package org.mybatis.generator.codegen.mybatis3.xmlmapper.elements; /* */ /* */ import java.util.Iterator; /* */ import java.util.List; /* */ import org.mybatis.generator.api.CommentGenerator; /* */ import org.mybatis.generator.api.IntrospectedColumn; /* */ import org.mybatis.generator.api.IntrospectedTable; /* */ import org.mybatis.generator.api.Plugin; /* */ import org.mybatis.generator.api.dom.xml.Attribute; /* */ import org.mybatis.generator.api.dom.xml.TextElement; /* */ import org.mybatis.generator.api.dom.xml.XmlElement; /* */ import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; /* */ import org.mybatis.generator.config.Context; /* */ import org.mybatis.generator.internal.rules.Rules; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class UpdateByPrimaryKeySelectiveElementGenerator /* */ extends AbstractXmlElementGenerator /* */ { /* */ public void addElements(XmlElement parentElement) /* */ { /* 38 */ XmlElement answer = new XmlElement("update"); /* */ /* 40 */ answer /* 41 */ .addAttribute(new Attribute( /* 42 */ "id", this.introspectedTable.getUpdateByPrimaryKeySelectiveStatementId())); /* */ /* */ String parameterType; /* */ //String parameterType; /* 46 */ if (this.introspectedTable.getRules().generateRecordWithBLOBsClass()) { /* 47 */ parameterType = this.introspectedTable.getRecordWithBLOBsType(); /* */ } else { /* 49 */ parameterType = this.introspectedTable.getBaseRecordType(); /* */ } /* */ /* 52 */ answer.addAttribute(new Attribute("parameterType", /* 53 */ parameterType)); /* */ /* 55 */ this.context.getCommentGenerator().addComment(answer); /* */ /* 57 */ StringBuilder sb = new StringBuilder(); /* */ /* 59 */ sb.append("update "); /* 60 */ sb.append(this.introspectedTable.getFullyQualifiedTableNameAtRuntime()); /* 61 */ answer.addElement(new TextElement(sb.toString())); /* */ /* 63 */ XmlElement dynamicElement = new XmlElement("set"); /* 64 */ answer.addElement(dynamicElement); /* */ /* */ /* 67 */ Iterator localIterator = this.introspectedTable.getNonPrimaryKeyColumns().iterator(); /* 66 */ while (localIterator.hasNext()) { /* 67 */ IntrospectedColumn introspectedColumn = (IntrospectedColumn)localIterator.next(); /* 68 */ XmlElement isNotNullElement = new XmlElement("if"); /* 69 */ sb.setLength(0); /* 70 */ sb.append(introspectedColumn.getJavaProperty()); /* 71 */ sb.append(" != null"); /* 72 */ isNotNullElement.addAttribute(new Attribute("test", sb.toString())); /* 73 */ dynamicElement.addElement(isNotNullElement); /* */ /* 75 */ sb.setLength(0); /* 76 */ sb.append( /* 77 */ MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn)); /* 78 */ sb.append(" = "); /* 79 */ sb.append( /* 80 */ MyBatis3FormattingUtilities.getParameterClause(introspectedColumn)); /* 81 */ sb.append(','); /* */ /* 83 */ isNotNullElement.addElement(new TextElement(sb.toString())); /* */ } /* */ /* 86 */ boolean and = false; /* */ /* 88 */ Iterator<IntrospectedColumn> isNotNullElement = this.introspectedTable.getPrimaryKeyColumns().iterator(); /* 87 */ while (isNotNullElement.hasNext()) { /* 88 */ IntrospectedColumn introspectedColumn = (IntrospectedColumn)isNotNullElement.next(); /* 89 */ sb.setLength(0); /* 90 */ if (and) { /* 91 */ sb.append(" and "); /* */ } else { /* 93 */ sb.append("where "); /* 94 */ and = true; /* */ } /* */ /* 97 */ sb.append( /* 98 */ MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn)); /* 99 */ sb.append(" = "); /* 100 */ sb.append( /* 101 */ MyBatis3FormattingUtilities.getParameterClause(introspectedColumn)); /* 102 */ answer.addElement(new TextElement(sb.toString())); /* */ } /* */ /* */ /* 106 */ if (this.context.getPlugins().sqlMapUpdateByPrimaryKeySelectiveElementGenerated(answer, /* 107 */ this.introspectedTable)) { /* 108 */ parentElement.addElement(answer); /* */ } /* */ } /* */ } /* Location: C:\Users\lenovo\Desktop\ibator_3.0.6.full.jar!\org\mybatis\generator\codegen\mybatis3\xmlmapper\elements\UpdateByPrimaryKeySelectiveElementGenerator.class * Java compiler version: 5 (49.0) * JD-Core Version: 0.7.1 */
[ "nihaoyes@163.com" ]
nihaoyes@163.com
78d8e93a118166c99fc4708155f8af1e9f46066b
d3d1c339b4350f597b8e82b962d3dabeb5dd9302
/main/ip/src/boofcv/alg/transform/fft/GeneralPurposeFFT_F32_1D.java
20da1e1cdf2014d0990bbd37868205e957c14936
[ "Apache-2.0" ]
permissive
luxigo/BoofCV
8c20e624081db443c8cc99f6fab9a6ea7a9b1597
f8ffdca5a5aa777a53a39c343c6f7ed85fb3fa10
refs/heads/master
2020-05-29T09:52:56.380031
2013-11-13T04:56:48
2013-11-13T04:56:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
155,461
java
/* * Copyright (c) 2011-2013, Peter Abeles. All Rights Reserved. * * This file is part of BoofCV (http://boofcv.org). * * 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 boofcv.alg.transform.fft; /** * Computes 1D Discrete Fourier Transform (DFT) of complex and real, float * precision data. The size of the data can be an arbitrary number. The code originally comes from * General Purpose FFT Package written by Takuya Ooura * (http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html). See below for the full history. * <p></p> * This code has a bit of a history. Originally from General Purpose FFT. Which was then ported into * JFFTPack written by Baoshe Zhang (http://jfftpack.sourceforge.net/), and then into JTransforms by Piotr Wendykier. * The major modification from JTransforms is that the SMP code has been stripped out. It might be added back in * once an SMP strategy has been finalized in BoofCV. * <p></p> * Code License: The original license of General Purpose FFT Package is shown below. This file will fall * under the same license: * <pre> * Copyright Takuya OOURA, 1996-2001 * * You may use, copy, modify and distribute this code for any purpose (include commercial use) and without fee. * Please refer to this package when you modify this code. * </pre> * * @author Piotr Wendykier (piotr.wendykier@gmail.com) * @author Peter Abeles * */ public class GeneralPurposeFFT_F32_1D { private static enum Plans { SPLIT_RADIX, MIXED_RADIX, BLUESTEIN } private int n; private int nBluestein; private int[] ip; private float[] w; private int nw; private int nc; private float[] wtable; private float[] wtable_r; private float[] bk1; private float[] bk2; private Plans plan; private static final int[] factors = { 4, 2, 3, 5 }; private static final float PI = 3.14159265358979311599796346854418516f; private static final float TWO_PI = 6.28318530717958623199592693708837032f; // local storage which is predeclared private float[] ak; private float[] ch; private float[] ch2; private int[] nac = new int[1]; /** * Creates new instance of DoubleFFT_1D. * * @param n * size of data */ public GeneralPurposeFFT_F32_1D(int n) { if (n < 1) { throw new IllegalArgumentException("n must be greater than 0"); } this.n = n; if (!DiscreteFourierTransformOps.isPowerOf2(n)) { if (getReminder(n, factors) >= 211) { plan = Plans.BLUESTEIN; nBluestein = DiscreteFourierTransformOps.nextPow2(n * 2 - 1); bk1 = new float[2 * nBluestein]; bk2 = new float[2 * nBluestein]; this.ip = new int[2 + (int) Math.ceil(2 + (1 << (int) (Math.log(nBluestein + 0.5) / Math.log(2)) / 2))]; this.w = new float[nBluestein]; int twon = 2 * nBluestein; nw = ip[0]; if (twon > (nw << 2)) { nw = twon >> 2; makewt(nw); } nc = ip[1]; if (nBluestein > (nc << 2)) { nc = nBluestein >> 2; makect(nc, w, nw); } bluesteini(); ak = new float[2 * nBluestein]; } else { plan = Plans.MIXED_RADIX; wtable = new float[4 * n + 15]; wtable_r = new float[2 * n + 15]; cffti(); rffti(); } } else { plan = Plans.SPLIT_RADIX; this.ip = new int[2 + (int) Math.ceil(2 + (1 << (int) (Math.log(n + 0.5) / Math.log(2)) / 2))]; this.w = new float[n]; int twon = 2 * n; nw = ip[0]; if (twon > (nw << 2)) { nw = twon >> 2; makewt(nw); } nc = ip[1]; if (n > (nc << 2)) { nc = n >> 2; makect(nc, w, nw); } } ch = new float[n]; ch2 = new float[n*2]; } /** * Computes 1D forward DFT of complex data leaving the result in * <code>a</code>. Complex number is stored as two float values in * sequence: the real and imaginary part, i.e. the size of the input array * must be greater or equal 2*n. The physical layout of the input data has * to be as follows:<br> * * <pre> * a[2*k] = Re[k], * a[2*k+1] = Im[k], 0&lt;=k&lt;n * </pre> * * @param a * data to transform */ public void complexForward(float[] a) { complexForward(a, 0); } /** * Computes 1D forward DFT of complex data leaving the result in * <code>a</code>. Complex number is stored as two float values in * sequence: the real and imaginary part, i.e. the size of the input array * must be greater or equal 2*n. The physical layout of the input data has * to be as follows:<br> * * <pre> * a[offa+2*k] = Re[k], * a[offa+2*k+1] = Im[k], 0&lt;=k&lt;n * </pre> * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> */ public void complexForward(float[] a, int offa) { if (n == 1) return; switch (plan) { case SPLIT_RADIX: cftbsub(2 * n, a, offa, ip, nw, w); break; case MIXED_RADIX: cfftf(a, offa, -1); break; case BLUESTEIN: bluestein_complex(a, offa, -1); break; } } /** * Computes 1D inverse DFT of complex data leaving the result in * <code>a</code>. Complex number is stored as two float values in * sequence: the real and imaginary part, i.e. the size of the input array * must be greater or equal 2*n. The physical layout of the input data has * to be as follows:<br> * * <pre> * a[2*k] = Re[k], * a[2*k+1] = Im[k], 0&lt;=k&lt;n * </pre> * * @param a * data to transform * @param scale * if true then scaling is performed */ public void complexInverse(float[] a, boolean scale) { complexInverse(a, 0, scale); } /** * Computes 1D inverse DFT of complex data leaving the result in * <code>a</code>. Complex number is stored as two float values in * sequence: the real and imaginary part, i.e. the size of the input array * must be greater or equal 2*n. The physical layout of the input data has * to be as follows:<br> * * <pre> * a[offa+2*k] = Re[k], * a[offa+2*k+1] = Im[k], 0&lt;=k&lt;n * </pre> * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> * @param scale * if true then scaling is performed */ public void complexInverse(float[] a, int offa, boolean scale) { if (n == 1) return; switch (plan) { case SPLIT_RADIX: cftfsub(2 * n, a, offa, ip, nw, w); break; case MIXED_RADIX: cfftf(a, offa, +1); break; case BLUESTEIN: bluestein_complex(a, offa, 1); break; } if (scale) { scale(n, a, offa, true); } } /** * Computes 1D forward DFT of real data leaving the result in <code>a</code> * . The physical layout of the output data is as follows:<br> * * if n is even then * * <pre> * a[2*k] = Re[k], 0&lt;=k&lt;n/2 * a[2*k+1] = Im[k], 0&lt;k&lt;n/2 * a[1] = Re[n/2] * </pre> * * if n is odd then * * <pre> * a[2*k] = Re[k], 0&lt;=k&lt;(n+1)/2 * a[2*k+1] = Im[k], 0&lt;k&lt;(n-1)/2 * a[1] = Im[(n-1)/2] * </pre> * * This method computes only half of the elements of the real transform. The * other half satisfies the symmetry condition. If you want the full real * forward transform, use <code>realForwardFull</code>. To get back the * original data, use <code>realInverse</code> on the output of this method. * * @param a * data to transform */ public void realForward(float[] a) { realForward(a, 0); } /** * Computes 1D forward DFT of real data leaving the result in <code>a</code> * . The physical layout of the output data is as follows:<br> * * if n is even then * * <pre> * a[offa+2*k] = Re[k], 0&lt;=k&lt;n/2 * a[offa+2*k+1] = Im[k], 0&lt;k&lt;n/2 * a[offa+1] = Re[n/2] * </pre> * * if n is odd then * * <pre> * a[offa+2*k] = Re[k], 0&lt;=k&lt;(n+1)/2 * a[offa+2*k+1] = Im[k], 0&lt;k&lt;(n-1)/2 * a[offa+1] = Im[(n-1)/2] * </pre> * * This method computes only half of the elements of the real transform. The * other half satisfies the symmetry condition. If you want the full real * forward transform, use <code>realForwardFull</code>. To get back the * original data, use <code>realInverse</code> on the output of this method. * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> */ public void realForward(float[] a, int offa) { if (n == 1) return; switch (plan) { case SPLIT_RADIX: float xi; if (n > 4) { cftfsub(n, a, offa, ip, nw, w); rftfsub(n, a, offa, nc, w, nw); } else if (n == 4) { cftx020(a, offa); } xi = a[offa] - a[offa + 1]; a[offa] += a[offa + 1]; a[offa + 1] = xi; break; case MIXED_RADIX: rfftf(a, offa); for (int k = n - 1; k >= 2; k--) { int idx = offa + k; float tmp = a[idx]; a[idx] = a[idx - 1]; a[idx - 1] = tmp; } ch = new float[n]; break; case BLUESTEIN: bluestein_real_forward(a, offa); break; } } /** * Computes 1D forward DFT of real data leaving the result in <code>a</code> * . This method computes the full real forward transform, i.e. you will get * the same result as from <code>complexForward</code> called with all * imaginary parts equal 0. Because the result is stored in <code>a</code>, * the size of the input array must greater or equal 2*n, with only the * first n elements filled with real data. To get back the original data, * use <code>complexInverse</code> on the output of this method. * * @param a * data to transform */ public void realForwardFull(float[] a) { realForwardFull(a, 0); } /** * Computes 1D forward DFT of real data leaving the result in <code>a</code> * . This method computes the full real forward transform, i.e. you will get * the same result as from <code>complexForward</code> called with all * imaginary part equal 0. Because the result is stored in <code>a</code>, * the size of the input array must greater or equal 2*n, with only the * first n elements filled with real data. To get back the original data, * use <code>complexInverse</code> on the output of this method. * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> */ public void realForwardFull(final float[] a, final int offa) { final int twon = 2 * n; switch (plan) { case SPLIT_RADIX:{ realForward(a, offa); int idx1, idx2; for (int k = 0; k < n / 2; k++) { idx1 = 2 * k; idx2 = offa + ((twon - idx1) % twon); a[idx2] = a[offa + idx1]; a[idx2 + 1] = -a[offa + idx1 + 1]; } a[offa + n] = -a[offa + 1]; a[offa + 1] = 0; }break; case MIXED_RADIX:{ rfftf(a, offa); int m; if (n % 2 == 0) { m = n / 2; } else { m = (n + 1) / 2; } for (int k = 1; k < m; k++) { int idx1 = offa + twon - 2 * k; int idx2 = offa + 2 * k; a[idx1 + 1] = -a[idx2]; a[idx1] = a[idx2 - 1]; } for (int k = 1; k < n; k++) { int idx = offa + n - k; float tmp = a[idx + 1]; a[idx + 1] = a[idx]; a[idx] = tmp; } a[offa + 1] = 0; }break; case BLUESTEIN: bluestein_real_full(a, offa, -1); break; } } /** * Computes 1D inverse DFT of real data leaving the result in <code>a</code> * . The physical layout of the input data has to be as follows:<br> * * if n is even then * * <pre> * a[2*k] = Re[k], 0&lt;=k&lt;n/2 * a[2*k+1] = Im[k], 0&lt;k&lt;n/2 * a[1] = Re[n/2] * </pre> * * if n is odd then * * <pre> * a[2*k] = Re[k], 0&lt;=k&lt;(n+1)/2 * a[2*k+1] = Im[k], 0&lt;k&lt;(n-1)/2 * a[1] = Im[(n-1)/2] * </pre> * * This method computes only half of the elements of the real transform. The * other half satisfies the symmetry condition. If you want the full real * inverse transform, use <code>realInverseFull</code>. * * @param a * data to transform * * @param scale * if true then scaling is performed * */ public void realInverse(float[] a, boolean scale) { realInverse(a, 0, scale); } /** * Computes 1D inverse DFT of real data leaving the result in <code>a</code> * . The physical layout of the input data has to be as follows:<br> * * if n is even then * * <pre> * a[offa+2*k] = Re[k], 0&lt;=k&lt;n/2 * a[offa+2*k+1] = Im[k], 0&lt;k&lt;n/2 * a[offa+1] = Re[n/2] * </pre> * * if n is odd then * * <pre> * a[offa+2*k] = Re[k], 0&lt;=k&lt;(n+1)/2 * a[offa+2*k+1] = Im[k], 0&lt;k&lt;(n-1)/2 * a[offa+1] = Im[(n-1)/2] * </pre> * * This method computes only half of the elements of the real transform. The * other half satisfies the symmetry condition. If you want the full real * inverse transform, use <code>realInverseFull</code>. * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> * @param scale * if true then scaling is performed * */ public void realInverse(float[] a, int offa, boolean scale) { if (n == 1) return; switch (plan) { case SPLIT_RADIX: a[offa + 1] = 0.5f * (a[offa] - a[offa + 1]); a[offa] -= a[offa + 1]; if (n > 4) { rftfsub(n, a, offa, nc, w, nw); cftbsub(n, a, offa, ip, nw, w); } else if (n == 4) { cftxc020(a, offa); } if (scale) { scale(n / 2, a, offa, false); } break; case MIXED_RADIX: for (int k = 2; k < n; k++) { int idx = offa + k; float tmp = a[idx - 1]; a[idx - 1] = a[idx]; a[idx] = tmp; } rfftb(a, offa); if (scale) { scale(n, a, offa, false); } break; case BLUESTEIN: bluestein_real_inverse(a, offa); if (scale) { scale(n, a, offa, false); } break; } } /** * Computes 1D inverse DFT of real data leaving the result in <code>a</code> * . This method computes the full real inverse transform, i.e. you will get * the same result as from <code>complexInverse</code> called with all * imaginary part equal 0. Because the result is stored in <code>a</code>, * the size of the input array must greater or equal 2*n, with only the * first n elements filled with real data. * * @param a * data to transform * @param scale * if true then scaling is performed */ public void realInverseFull(float[] a, boolean scale) { realInverseFull(a, 0, scale); } /** * Computes 1D inverse DFT of real data leaving the result in <code>a</code> * . This method computes the full real inverse transform, i.e. you will get * the same result as from <code>complexInverse</code> called with all * imaginary part equal 0. Because the result is stored in <code>a</code>, * the size of the input array must greater or equal 2*n, with only the * first n elements filled with real data. * * @param a * data to transform * @param offa * index of the first element in array <code>a</code> * @param scale * if true then scaling is performed */ public void realInverseFull(final float[] a, final int offa, boolean scale) { final int twon = 2 * n; switch (plan) { case SPLIT_RADIX:{ realInverse2(a, offa, scale); int idx1, idx2; for (int k = 0; k < n / 2; k++) { idx1 = 2 * k; idx2 = offa + ((twon - idx1) % twon); a[idx2] = a[offa + idx1]; a[idx2 + 1] = -a[offa + idx1 + 1]; } a[offa + n] = -a[offa + 1]; a[offa + 1] = 0; }break; case MIXED_RADIX: rfftf(a, offa); if (scale) { scale(n, a, offa, false); } int m; if (n % 2 == 0) { m = n / 2; } else { m = (n + 1) / 2; } for (int k = 1; k < m; k++) { int idx1 = offa + 2 * k; int idx2 = offa + twon - 2 * k; a[idx1] = -a[idx1]; a[idx2 + 1] = -a[idx1]; a[idx2] = a[idx1 - 1]; } for (int k = 1; k < n; k++) { int idx = offa + n - k; float tmp = a[idx + 1]; a[idx + 1] = a[idx]; a[idx] = tmp; } a[offa + 1] = 0; break; case BLUESTEIN: bluestein_real_full(a, offa, 1); if (scale) { scale(n, a, offa, true); } break; } } protected void realInverse2(float[] a, int offa, boolean scale) { if (n == 1) return; switch (plan) { case SPLIT_RADIX: float xi; if (n > 4) { cftfsub(n, a, offa, ip, nw, w); rftbsub(n, a, offa, nc, w, nw); } else if (n == 4) { cftbsub(n, a, offa, ip, nw, w); } xi = a[offa] - a[offa + 1]; a[offa] += a[offa + 1]; a[offa + 1] = xi; if (scale) { scale(n, a, offa, false); } break; case MIXED_RADIX: rfftf(a, offa); for (int k = n - 1; k >= 2; k--) { int idx = offa + k; float tmp = a[idx]; a[idx] = a[idx - 1]; a[idx - 1] = tmp; } if (scale) { scale(n, a, offa, false); } int m; if (n % 2 == 0) { m = n / 2; for (int i = 1; i < m; i++) { int idx = offa + 2 * i + 1; a[idx] = -a[idx]; } } else { m = (n - 1) / 2; for (int i = 0; i < m; i++) { int idx = offa + 2 * i + 1; a[idx] = -a[idx]; } } break; case BLUESTEIN: bluestein_real_inverse2(a, offa); if (scale) { scale(n, a, offa, false); } break; } } private static int getReminder(int n, int factors[]) { int reminder = n; if (n <= 0) { throw new IllegalArgumentException("n must be positive integer"); } for (int i = 0; i < factors.length && reminder != 1; i++) { int factor = factors[i]; while ((reminder % factor) == 0) { reminder /= factor; } } return reminder; } /* -------- initializing routines -------- */ void cffti() { if (n == 1) return; final int twon = 2 * n; final int fourn = 4 * n; float argh; int idot, ntry = 0, i, j; float argld; int i1, k1, l1, l2, ib; float fi; int ld, ii, nf, ip, nl, nq, nr; float arg; int ido, ipm; nl = n; nf = 0; j = 0; factorize_loop: while (true) { j++; if (j <= 4) ntry = factors[j - 1]; else ntry += 2; do { nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) continue factorize_loop; nf++; wtable[nf + 1 + fourn] = ntry; nl = nq; if (ntry == 2 && nf != 1) { for (i = 2; i <= nf; i++) { ib = nf - i + 2; int idx = ib + fourn; wtable[idx + 1] = wtable[idx]; } wtable[2 + fourn] = 2; } } while (nl != 1); break factorize_loop; } wtable[fourn] = n; wtable[1 + fourn] = nf; argh = TWO_PI / (float) n; i = 1; l1 = 1; for (k1 = 1; k1 <= nf; k1++) { ip = (int) wtable[k1 + 1 + fourn]; ld = 0; l2 = l1 * ip; ido = n / l2; idot = ido + ido + 2; ipm = ip - 1; for (j = 1; j <= ipm; j++) { i1 = i; wtable[i - 1 + twon] = 1; wtable[i + twon] = 0; ld += l1; fi = 0; argld = ld * argh; for (ii = 4; ii <= idot; ii += 2) { i += 2; fi += 1; arg = fi * argld; int idx = i + twon; wtable[idx - 1] = (float)Math.cos(arg); wtable[idx] = (float)Math.sin(arg); } if (ip > 5) { int idx1 = i1 + twon; int idx2 = i + twon; wtable[idx1 - 1] = wtable[idx2 - 1]; wtable[idx1] = wtable[idx2]; } } l1 = l2; } } void rffti() { if (n == 1) return; final int twon = 2 * n; float argh; int ntry = 0, i, j; float argld; int k1, l1, l2, ib; float fi; int ld, ii, nf, ip, nl, is, nq, nr; float arg; int ido, ipm; int nfm1; nl = n; nf = 0; j = 0; factorize_loop: while (true) { ++j; if (j <= 4) ntry = factors[j - 1]; else ntry += 2; do { nq = nl / ntry; nr = nl - ntry * nq; if (nr != 0) continue factorize_loop; ++nf; wtable_r[nf + 1 + twon] = ntry; nl = nq; if (ntry == 2 && nf != 1) { for (i = 2; i <= nf; i++) { ib = nf - i + 2; int idx = ib + twon; wtable_r[idx + 1] = wtable_r[idx]; } wtable_r[2 + twon] = 2; } } while (nl != 1); break factorize_loop; } wtable_r[twon] = n; wtable_r[1 + twon] = nf; argh = TWO_PI / (float) (n); is = 0; nfm1 = nf - 1; l1 = 1; if (nfm1 == 0) return; for (k1 = 1; k1 <= nfm1; k1++) { ip = (int) wtable_r[k1 + 1 + twon]; ld = 0; l2 = l1 * ip; ido = n / l2; ipm = ip - 1; for (j = 1; j <= ipm; ++j) { ld += l1; i = is; argld = (float) ld * argh; fi = 0; for (ii = 3; ii <= ido; ii += 2) { i += 2; fi += 1; arg = fi * argld; int idx = i + n; wtable_r[idx - 2] = (float)Math.cos(arg); wtable_r[idx - 1] = (float)Math.sin(arg); } is += ido; } l1 = l2; } } private void bluesteini() { int k = 0; float arg; float pi_n = PI / n; bk1[0] = 1; bk1[1] = 0; for (int i = 1; i < n; i++) { k += 2 * i - 1; if (k >= 2 * n) k -= 2 * n; arg = pi_n * k; bk1[2 * i] = (float)Math.cos(arg); bk1[2 * i + 1] = (float)Math.sin(arg); } float scale = 1.0f / nBluestein; bk2[0] = bk1[0] * scale; bk2[1] = bk1[1] * scale; for (int i = 2; i < 2 * n; i += 2) { bk2[i] = bk1[i] * scale; bk2[i + 1] = bk1[i + 1] * scale; bk2[2 * nBluestein - i] = bk2[i]; bk2[2 * nBluestein - i + 1] = bk2[i + 1]; } cftbsub(2 * nBluestein, bk2, 0, ip, nw, w); } private void makewt(int nw) { int j, nwh, nw0, nw1; float delta, wn4r, wk1r, wk1i, wk3r, wk3i; float delta2, deltaj, deltaj3; ip[0] = nw; ip[1] = 1; if (nw > 2) { nwh = nw >> 1; delta = 0.785398163397448278999490867136046290f / nwh; delta2 = delta * 2; wn4r = (float)Math.cos(delta * nwh); w[0] = 1; w[1] = wn4r; if (nwh == 4) { w[2] = (float)Math.cos(delta2); w[3] = (float)Math.sin(delta2); } else if (nwh > 4) { makeipt(nw); w[2] = 0.5f / (float)Math.cos(delta2); w[3] = 0.5f / (float)Math.cos(delta * 6); for (j = 4; j < nwh; j += 4) { deltaj = delta * j; deltaj3 = 3 * deltaj; w[j] = (float)Math.cos(deltaj); w[j + 1] = (float)Math.sin(deltaj); w[j + 2] = (float)Math.cos(deltaj3); w[j + 3] = -(float)Math.sin(deltaj3); } } nw0 = 0; while (nwh > 2) { nw1 = nw0 + nwh; nwh >>= 1; w[nw1] = 1; w[nw1 + 1] = wn4r; if (nwh == 4) { wk1r = w[nw0 + 4]; wk1i = w[nw0 + 5]; w[nw1 + 2] = wk1r; w[nw1 + 3] = wk1i; } else if (nwh > 4) { wk1r = w[nw0 + 4]; wk3r = w[nw0 + 6]; w[nw1 + 2] = 0.5f / wk1r; w[nw1 + 3] = 0.5f / wk3r; for (j = 4; j < nwh; j += 4) { int idx1 = nw0 + 2 * j; int idx2 = nw1 + j; wk1r = w[idx1]; wk1i = w[idx1 + 1]; wk3r = w[idx1 + 2]; wk3i = w[idx1 + 3]; w[idx2] = wk1r; w[idx2 + 1] = wk1i; w[idx2 + 2] = wk3r; w[idx2 + 3] = wk3i; } } nw0 = nw1; } } } private void makeipt(int nw) { int j, l, m, m2, p, q; ip[2] = 0; ip[3] = 16; m = 2; for (l = nw; l > 32; l >>= 2) { m2 = m << 1; q = m2 << 3; for (j = m; j < m2; j++) { p = ip[j] << 2; ip[m + j] = p; ip[m2 + j] = p + q; } m = m2; } } private void makect(int nc, float[] c, int startc) { int j, nch; float delta, deltaj; ip[1] = nc; if (nc > 1) { nch = nc >> 1; delta = 0.785398163397448278999490867136046290f / nch; c[startc] = (float)Math.cos(delta * nch); c[startc + nch] = 0.5f * c[startc]; for (j = 1; j < nch; j++) { deltaj = delta * j; c[startc + j] = 0.5f * (float)Math.cos(deltaj); c[startc + nc - j] = 0.5f * (float)Math.sin(deltaj); } } } private void bluestein_complex(final float[] a, final int offa, final int isign) { if (isign > 0) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; ak[idx1] = a[idx3] * bk1[idx1] - a[idx4] * bk1[idx2]; ak[idx2] = a[idx3] * bk1[idx2] + a[idx4] * bk1[idx1]; } } else { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; ak[idx1] = a[idx3] * bk1[idx1] + a[idx4] * bk1[idx2]; ak[idx2] = -a[idx3] * bk1[idx2] + a[idx4] * bk1[idx1]; } } cftbsub(2 * nBluestein, ak, 0, ip, nw, w); if (isign > 0) { for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = -ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] + ak[idx2] * bk2[idx2]; ak[idx2] = im; } } else { for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] - ak[idx2] * bk2[idx2]; ak[idx2] = im; } } cftfsub(2 * nBluestein, ak, 0, ip, nw, w); if (isign > 0) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; a[idx3] = bk1[idx1] * ak[idx1] - bk1[idx2] * ak[idx2]; a[idx4] = bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } else { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; a[idx3] = bk1[idx1] * ak[idx1] + bk1[idx2] * ak[idx2]; a[idx4] = -bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } } private void bluestein_real_full(final float[] a, final int offa, final int isign) { if (isign > 0) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + i; ak[idx1] = a[idx3] * bk1[idx1]; ak[idx2] = a[idx3] * bk1[idx2]; } } else { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + i; ak[idx1] = a[idx3] * bk1[idx1]; ak[idx2] = -a[idx3] * bk1[idx2]; } } cftbsub(2 * nBluestein, ak, 0, ip, nw, w); if (isign > 0) { for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = -ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] + ak[idx2] * bk2[idx2]; ak[idx2] = im; } } else { for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] - ak[idx2] * bk2[idx2]; ak[idx2] = im; } } cftfsub(2 * nBluestein, ak, 0, ip, nw, w); if (isign > 0) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] - bk1[idx2] * ak[idx2]; a[offa + idx2] = bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } else { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] + bk1[idx2] * ak[idx2]; a[offa + idx2] = -bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } } private void bluestein_real_forward(final float[] a, final int offa) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + i; ak[idx1] = a[idx3] * bk1[idx1]; ak[idx2] = -a[idx3] * bk1[idx2]; } cftbsub(2 * nBluestein, ak, 0, ip, nw, w); for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] - ak[idx2] * bk2[idx2]; ak[idx2] = im; } cftfsub(2 * nBluestein, ak, 0, ip, nw, w); if (n % 2 == 0) { a[offa] = bk1[0] * ak[0] + bk1[1] * ak[1]; a[offa + 1] = bk1[n] * ak[n] + bk1[n + 1] * ak[n + 1]; for (int i = 1; i < n / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] + bk1[idx2] * ak[idx2]; a[offa + idx2] = -bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } else { a[offa] = bk1[0] * ak[0] + bk1[1] * ak[1]; a[offa + 1] = -bk1[n] * ak[n - 1] + bk1[n - 1] * ak[n]; for (int i = 1; i < (n - 1) / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] + bk1[idx2] * ak[idx2]; a[offa + idx2] = -bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } a[offa + n - 1] = bk1[n - 1] * ak[n - 1] + bk1[n] * ak[n]; } } private void bluestein_real_inverse(final float[] a, final int offa) { if (n % 2 == 0) { ak[0] = a[offa] * bk1[0]; ak[1] = a[offa] * bk1[1]; for (int i = 1; i < n / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; ak[idx1] = a[idx3] * bk1[idx1] - a[idx4] * bk1[idx2]; ak[idx2] = a[idx3] * bk1[idx2] + a[idx4] * bk1[idx1]; } ak[n] = a[offa + 1] * bk1[n]; ak[n + 1] = a[offa + 1] * bk1[n + 1]; for (int i = n / 2 + 1; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + 2 * n - idx1; int idx4 = idx3 + 1; ak[idx1] = a[idx3] * bk1[idx1] + a[idx4] * bk1[idx2]; ak[idx2] = a[idx3] * bk1[idx2] - a[idx4] * bk1[idx1]; } } else { ak[0] = a[offa] * bk1[0]; ak[1] = a[offa] * bk1[1]; for (int i = 1; i < (n - 1) / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + idx1; int idx4 = offa + idx2; ak[idx1] = a[idx3] * bk1[idx1] - a[idx4] * bk1[idx2]; ak[idx2] = a[idx3] * bk1[idx2] + a[idx4] * bk1[idx1]; } ak[n - 1] = a[offa + n - 1] * bk1[n - 1] - a[offa + 1] * bk1[n]; ak[n] = a[offa + n - 1] * bk1[n] + a[offa + 1] * bk1[n - 1]; ak[n + 1] = a[offa + n - 1] * bk1[n + 1] + a[offa + 1] * bk1[n + 2]; ak[n + 2] = a[offa + n - 1] * bk1[n + 2] - a[offa + 1] * bk1[n + 1]; for (int i = (n - 1) / 2 + 2; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + 2 * n - idx1; int idx4 = idx3 + 1; ak[idx1] = a[idx3] * bk1[idx1] + a[idx4] * bk1[idx2]; ak[idx2] = a[idx3] * bk1[idx2] - a[idx4] * bk1[idx1]; } } cftbsub(2 * nBluestein, ak, 0, ip, nw, w); for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = -ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] + ak[idx2] * bk2[idx2]; ak[idx2] = im; } cftfsub(2 * nBluestein, ak, 0, ip, nw, w); for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + i] = bk1[idx1] * ak[idx1] - bk1[idx2] * ak[idx2]; } } private void bluestein_real_inverse2(final float[] a, final int offa) { for (int i = 0; i < n; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; int idx3 = offa + i; ak[idx1] = a[idx3] * bk1[idx1]; ak[idx2] = a[idx3] * bk1[idx2]; } cftbsub(2 * nBluestein, ak, 0, ip, nw, w); for (int i = 0; i < nBluestein; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; float im = -ak[idx1] * bk2[idx2] + ak[idx2] * bk2[idx1]; ak[idx1] = ak[idx1] * bk2[idx1] + ak[idx2] * bk2[idx2]; ak[idx2] = im; } cftfsub(2 * nBluestein, ak, 0, ip, nw, w); if (n % 2 == 0) { a[offa] = bk1[0] * ak[0] - bk1[1] * ak[1]; a[offa + 1] = bk1[n] * ak[n] - bk1[n + 1] * ak[n + 1]; for (int i = 1; i < n / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] - bk1[idx2] * ak[idx2]; a[offa + idx2] = bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } } else { a[offa] = bk1[0] * ak[0] - bk1[1] * ak[1]; a[offa + 1] = bk1[n] * ak[n - 1] + bk1[n - 1] * ak[n]; for (int i = 1; i < (n - 1) / 2; i++) { int idx1 = 2 * i; int idx2 = idx1 + 1; a[offa + idx1] = bk1[idx1] * ak[idx1] - bk1[idx2] * ak[idx2]; a[offa + idx2] = bk1[idx2] * ak[idx1] + bk1[idx1] * ak[idx2]; } a[offa + n - 1] = bk1[n - 1] * ak[n - 1] - bk1[n] * ak[n]; } } /** *--------------------------------------------------------- * rfftf1: further processing of Real forward FFT *--------------------------------------------------------- */ void rfftf(final float a[], final int offa) { if (n == 1) return; int l1, l2, na, kh, nf, ip, iw, ido, idl1; final int twon = 2 * n; nf = (int) wtable_r[1 + twon]; na = 1; l2 = n; iw = twon - 1; for (int k1 = 1; k1 <= nf; ++k1) { kh = nf - k1; ip = (int) wtable_r[kh + 2 + twon]; l1 = l2 / ip; ido = n / l2; idl1 = ido * l1; iw -= (ip - 1) * ido; na = 1 - na; switch (ip) { case 2: if (na == 0) { radf2(ido, l1, a, offa, ch, 0, iw); } else { radf2(ido, l1, ch, 0, a, offa, iw); } break; case 3: if (na == 0) { radf3(ido, l1, a, offa, ch, 0, iw); } else { radf3(ido, l1, ch, 0, a, offa, iw); } break; case 4: if (na == 0) { radf4(ido, l1, a, offa, ch, 0, iw); } else { radf4(ido, l1, ch, 0, a, offa, iw); } break; case 5: if (na == 0) { radf5(ido, l1, a, offa, ch, 0, iw); } else { radf5(ido, l1, ch, 0, a, offa, iw); } break; default: if (ido == 1) na = 1 - na; if (na == 0) { radfg(ido, ip, l1, idl1, a, offa, ch, 0, iw); na = 1; } else { radfg(ido, ip, l1, idl1, ch, 0, a, offa, iw); na = 0; } break; } l2 = l1; } if (na == 1) return; System.arraycopy(ch, 0, a, offa, n); } /*--------------------------------------------------------- rfftb1: further processing of Real backward FFT --------------------------------------------------------*/ void rfftb(final float a[], final int offa) { if (n == 1) return; int l1, l2, na, nf, ip, iw, ido, idl1; final int twon = 2 * n; nf = (int) wtable_r[1 + twon]; na = 0; l1 = 1; iw = n; for (int k1 = 1; k1 <= nf; k1++) { ip = (int) wtable_r[k1 + 1 + twon]; l2 = ip * l1; ido = n / l2; idl1 = ido * l1; switch (ip) { case 2: if (na == 0) { radb2(ido, l1, a, offa, ch, 0, iw); } else { radb2(ido, l1, ch, 0, a, offa, iw); } na = 1 - na; break; case 3: if (na == 0) { radb3(ido, l1, a, offa, ch, 0, iw); } else { radb3(ido, l1, ch, 0, a, offa, iw); } na = 1 - na; break; case 4: if (na == 0) { radb4(ido, l1, a, offa, ch, 0, iw); } else { radb4(ido, l1, ch, 0, a, offa, iw); } na = 1 - na; break; case 5: if (na == 0) { radb5(ido, l1, a, offa, ch, 0, iw); } else { radb5(ido, l1, ch, 0, a, offa, iw); } na = 1 - na; break; default: if (na == 0) { radbg(ido, ip, l1, idl1, a, offa, ch, 0, iw); } else { radbg(ido, ip, l1, idl1, ch, 0, a, offa, iw); } if (ido == 1) na = 1 - na; break; } l1 = l2; iw += (ip - 1) * ido; } if (na == 0) return; System.arraycopy(ch, 0, a, offa, n); } /*------------------------------------------------- radf2: Real FFT's forward processing of factor 2 -------------------------------------------------*/ void radf2(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { int i, ic, idx0, idx1, idx2, idx3, idx4; float t1i, t1r, w1r, w1i; int iw1; iw1 = offset; idx0 = l1 * ido; idx1 = 2 * ido; for (int k = 0; k < l1; k++) { int oidx1 = out_off + k * idx1; int oidx2 = oidx1 + idx1 - 1; int iidx1 = in_off + k * ido; int iidx2 = iidx1 + idx0; float i1r = in[iidx1]; float i2r = in[iidx2]; out[oidx1] = i1r + i2r; out[oidx2] = i1r - i2r; } if (ido < 2) return; if (ido != 2) { for (int k = 0; k < l1; k++) { idx1 = k * ido; idx2 = 2 * idx1; idx3 = idx2 + ido; idx4 = idx1 + idx0; for (i = 2; i < ido; i += 2) { ic = ido - i; int widx1 = i - 1 + iw1; int oidx1 = out_off + i + idx2; int oidx2 = out_off + ic + idx3; int iidx1 = in_off + i + idx1; int iidx2 = in_off + i + idx4; float a1i = in[iidx1 - 1]; float a1r = in[iidx1]; float a2i = in[iidx2 - 1]; float a2r = in[iidx2]; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; t1r = w1r * a2i + w1i * a2r; t1i = w1r * a2r - w1i * a2i; out[oidx1] = a1r + t1i; out[oidx1 - 1] = a1i + t1r; out[oidx2] = t1i - a1r; out[oidx2 - 1] = a1i - t1r; } } if (ido % 2 == 1) return; } idx2 = 2 * idx1; for (int k = 0; k < l1; k++) { idx1 = k * ido; int oidx1 = out_off + idx2 + ido; int iidx1 = in_off + ido - 1 + idx1; out[oidx1] = -in[iidx1 + idx0]; out[oidx1 - 1] = in[iidx1]; } } /*------------------------------------------------- radb2: Real FFT's backward processing of factor 2 -------------------------------------------------*/ void radb2(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { int i, ic; float t1i, t1r, w1r, w1i; int iw1 = offset; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 2 * idx1; int idx3 = idx2 + ido; int oidx1 = out_off + idx1; int iidx1 = in_off + idx2; int iidx2 = in_off + ido - 1 + idx3; float i1r = in[iidx1]; float i2r = in[iidx2]; out[oidx1] = i1r + i2r; out[oidx1 + idx0] = i1r - i2r; } if (ido < 2) return; if (ido != 2) { for (int k = 0; k < l1; ++k) { int idx1 = k * ido; int idx2 = 2 * idx1; int idx3 = idx2 + ido; int idx4 = idx1 + idx0; for (i = 2; i < ido; i += 2) { ic = ido - i; int idx5 = i - 1 + iw1; int idx6 = out_off + i; int idx7 = in_off + i; int idx8 = in_off + ic; w1r = wtable_r[idx5 - 1]; w1i = wtable_r[idx5]; int iidx1 = idx7 + idx2; int iidx2 = idx8 + idx3; int oidx1 = idx6 + idx1; int oidx2 = idx6 + idx4; t1r = in[iidx1 - 1] - in[iidx2 - 1]; t1i = in[iidx1] + in[iidx2]; float i1i = in[iidx1]; float i1r = in[iidx1 - 1]; float i2i = in[iidx2]; float i2r = in[iidx2 - 1]; out[oidx1 - 1] = i1r + i2r; out[oidx1] = i1i - i2i; out[oidx2 - 1] = w1r * t1r - w1i * t1i; out[oidx2] = w1r * t1i + w1i * t1r; } } if (ido % 2 == 1) return; } for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 2 * idx1; int oidx1 = out_off + ido - 1 + idx1; int iidx1 = in_off + idx2 + ido; out[oidx1] = 2 * in[iidx1 - 1]; out[oidx1 + idx0] = -2 * in[iidx1]; } } /*------------------------------------------------- radf3: Real FFT's forward processing of factor 3 -------------------------------------------------*/ void radf3(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float taur = -0.5f; final float taui = 0.866025403784438707610604524234076962f; int i, ic; float ci2, di2, di3, cr2, dr2, dr3, ti2, ti3, tr2, tr3, w1r, w2r, w1i, w2i; int iw1, iw2; iw1 = offset; iw2 = iw1 + ido; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx3 = 2 * idx0; int idx4 = (3 * k + 1) * ido; int iidx1 = in_off + idx1; int iidx2 = iidx1 + idx0; int iidx3 = iidx1 + idx3; float i1r = in[iidx1]; float i2r = in[iidx2]; float i3r = in[iidx3]; cr2 = i2r + i3r; out[out_off + 3 * idx1] = i1r + cr2; out[out_off + idx4 + ido] = taui * (i3r - i2r); out[out_off + ido - 1 + idx4] = i1r + taur * cr2; } if (ido == 1) return; for (int k = 0; k < l1; k++) { int idx3 = k * ido; int idx4 = 3 * idx3; int idx5 = idx3 + idx0; int idx6 = idx5 + idx0; int idx7 = idx4 + ido; int idx8 = idx7 + ido; for (i = 2; i < ido; i += 2) { ic = ido - i; int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; int idx9 = in_off + i; int idx10 = out_off + i; int idx11 = out_off + ic; int iidx1 = idx9 + idx3; int iidx2 = idx9 + idx5; int iidx3 = idx9 + idx6; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; dr2 = w1r * i2i + w1i * i2r; di2 = w1r * i2r - w1i * i2i; dr3 = w2r * i3i + w2i * i3r; di3 = w2r * i3r - w2i * i3i; cr2 = dr2 + dr3; ci2 = di2 + di3; tr2 = i1i + taur * cr2; ti2 = i1r + taur * ci2; tr3 = taui * (di2 - di3); ti3 = taui * (dr3 - dr2); int oidx1 = idx10 + idx4; int oidx2 = idx11 + idx7; int oidx3 = idx10 + idx8; out[oidx1 - 1] = i1i + cr2; out[oidx1] = i1r + ci2; out[oidx2 - 1] = tr2 - tr3; out[oidx2] = ti3 - ti2; out[oidx3 - 1] = tr2 + tr3; out[oidx3] = ti2 + ti3; } } } /*------------------------------------------------- radb3: Real FFT's backward processing of factor 3 -------------------------------------------------*/ void radb3(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float taur = -0.5f; final float taui = 0.866025403784438707610604524234076962f; int i, ic; float ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2, w1r, w2r, w1i, w2i; int iw1, iw2; iw1 = offset; iw2 = iw1 + ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int iidx1 = in_off + 3 * idx1; int iidx2 = iidx1 + 2 * ido; float i1i = in[iidx1]; tr2 = 2 * in[iidx2 - 1]; cr2 = i1i + taur * tr2; ci3 = 2 * taui * in[iidx2]; out[out_off + idx1] = i1i + tr2; out[out_off + (k + l1) * ido] = cr2 - ci3; out[out_off + (k + 2 * l1) * ido] = cr2 + ci3; } if (ido == 1) return; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 3 * idx1; int idx3 = idx2 + ido; int idx4 = idx3 + ido; int idx5 = idx1 + idx0; int idx6 = idx5 + idx0; for (i = 2; i < ido; i += 2) { ic = ido - i; int idx7 = in_off + i; int idx8 = in_off + ic; int idx9 = out_off + i; int iidx1 = idx7 + idx2; int iidx2 = idx7 + idx4; int iidx3 = idx8 + idx3; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; tr2 = i2i + i3i; cr2 = i1i + taur * tr2; ti2 = i2r - i3r; ci2 = i1r + taur * ti2; cr3 = taui * (i2i - i3i); ci3 = taui * (i2r + i3r); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; int oidx1 = idx9 + idx1; int oidx2 = idx9 + idx5; int oidx3 = idx9 + idx6; out[oidx1 - 1] = i1i + tr2; out[oidx1] = i1r + ti2; out[oidx2 - 1] = w1r * dr2 - w1i * di2; out[oidx2] = w1r * di2 + w1i * dr2; out[oidx3 - 1] = w2r * dr3 - w2i * di3; out[oidx3] = w2r * di3 + w2i * dr3; } } } /*------------------------------------------------- radf4: Real FFT's forward processing of factor 4 -------------------------------------------------*/ void radf4(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float hsqt2 = 0.707106781186547572737310929369414225f; int i, ic; float ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4, w1r, w1i, w2r, w2i, w3r, w3i; int iw1, iw2, iw3; iw1 = offset; iw2 = offset + ido; iw3 = iw2 + ido; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 4 * idx1; int idx3 = idx1 + idx0; int idx4 = idx3 + idx0; int idx5 = idx4 + idx0; int idx6 = idx2 + ido; float i1r = in[in_off + idx1]; float i2r = in[in_off + idx3]; float i3r = in[in_off + idx4]; float i4r = in[in_off + idx5]; tr1 = i2r + i4r; tr2 = i1r + i3r; int oidx1 = out_off + idx2; int oidx2 = out_off + idx6 + ido; out[oidx1] = tr1 + tr2; out[oidx2 - 1 + ido + ido] = tr2 - tr1; out[oidx2 - 1] = i1r - i3r; out[oidx2] = i4r - i2r; } if (ido < 2) return; if (ido != 2) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = idx1 + idx0; int idx3 = idx2 + idx0; int idx4 = idx3 + idx0; int idx5 = 4 * idx1; int idx6 = idx5 + ido; int idx7 = idx6 + ido; int idx8 = idx7 + ido; for (i = 2; i < ido; i += 2) { ic = ido - i; int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; int widx3 = i - 1 + iw3; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; w3r = wtable_r[widx3 - 1]; w3i = wtable_r[widx3]; int idx9 = in_off + i; int idx10 = out_off + i; int idx11 = out_off + ic; int iidx1 = idx9 + idx1; int iidx2 = idx9 + idx2; int iidx3 = idx9 + idx3; int iidx4 = idx9 + idx4; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; cr2 = w1r * i2i + w1i * i2r; ci2 = w1r * i2r - w1i * i2i; cr3 = w2r * i3i + w2i * i3r; ci3 = w2r * i3r - w2i * i3i; cr4 = w3r * i4i + w3i * i4r; ci4 = w3r * i4r - w3i * i4i; tr1 = cr2 + cr4; tr4 = cr4 - cr2; ti1 = ci2 + ci4; ti4 = ci2 - ci4; ti2 = i1r + ci3; ti3 = i1r - ci3; tr2 = i1i + cr3; tr3 = i1i - cr3; int oidx1 = idx10 + idx5; int oidx2 = idx11 + idx6; int oidx3 = idx10 + idx7; int oidx4 = idx11 + idx8; out[oidx1 - 1] = tr1 + tr2; out[oidx4 - 1] = tr2 - tr1; out[oidx1] = ti1 + ti2; out[oidx4] = ti1 - ti2; out[oidx3 - 1] = ti4 + tr3; out[oidx2 - 1] = tr3 - ti4; out[oidx3] = tr4 + ti3; out[oidx2] = tr4 - ti3; } } if (ido % 2 == 1) return; } for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 4 * idx1; int idx3 = idx1 + idx0; int idx4 = idx3 + idx0; int idx5 = idx4 + idx0; int idx6 = idx2 + ido; int idx7 = idx6 + ido; int idx8 = idx7 + ido; int idx9 = in_off + ido; int idx10 = out_off + ido; float i1i = in[idx9 - 1 + idx1]; float i2i = in[idx9 - 1 + idx3]; float i3i = in[idx9 - 1 + idx4]; float i4i = in[idx9 - 1 + idx5]; ti1 = -hsqt2 * (i2i + i4i); tr1 = hsqt2 * (i2i - i4i); out[idx10 - 1 + idx2] = tr1 + i1i; out[idx10 - 1 + idx7] = i1i - tr1; out[out_off + idx6] = ti1 - i3i; out[out_off + idx8] = ti1 + i3i; } } /*------------------------------------------------- radb4: Real FFT's backward processing of factor 4 -------------------------------------------------*/ void radb4(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float sqrt2 = 1.41421356237309514547462185873882845f; int i, ic; float ci2, ci3, ci4, cr2, cr3, cr4; float ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4, w1r, w1i, w2r, w2i, w3r, w3i; int iw1, iw2, iw3; iw1 = offset; iw2 = iw1 + ido; iw3 = iw2 + ido; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 4 * idx1; int idx3 = idx1 + idx0; int idx4 = idx3 + idx0; int idx5 = idx4 + idx0; int idx6 = idx2 + ido; int idx7 = idx6 + ido; int idx8 = idx7 + ido; float i1r = in[in_off + idx2]; float i2r = in[in_off + idx7]; float i3r = in[in_off + ido - 1 + idx8]; float i4r = in[in_off + ido - 1 + idx6]; tr1 = i1r - i3r; tr2 = i1r + i3r; tr3 = i4r + i4r; tr4 = i2r + i2r; out[out_off + idx1] = tr2 + tr3; out[out_off + idx3] = tr1 - tr4; out[out_off + idx4] = tr2 - tr3; out[out_off + idx5] = tr1 + tr4; } if (ido < 2) return; if (ido != 2) { for (int k = 0; k < l1; ++k) { int idx1 = k * ido; int idx2 = idx1 + idx0; int idx3 = idx2 + idx0; int idx4 = idx3 + idx0; int idx5 = 4 * idx1; int idx6 = idx5 + ido; int idx7 = idx6 + ido; int idx8 = idx7 + ido; for (i = 2; i < ido; i += 2) { ic = ido - i; int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; int widx3 = i - 1 + iw3; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; w3r = wtable_r[widx3 - 1]; w3i = wtable_r[widx3]; int idx12 = in_off + i; int idx13 = in_off + ic; int idx14 = out_off + i; int iidx1 = idx12 + idx5; int iidx2 = idx13 + idx6; int iidx3 = idx12 + idx7; int iidx4 = idx13 + idx8; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; ti1 = i1r + i4r; ti2 = i1r - i4r; ti3 = i3r - i2r; tr4 = i3r + i2r; tr1 = i1i - i4i; tr2 = i1i + i4i; ti4 = i3i - i2i; tr3 = i3i + i2i; cr3 = tr2 - tr3; ci3 = ti2 - ti3; cr2 = tr1 - tr4; cr4 = tr1 + tr4; ci2 = ti1 + ti4; ci4 = ti1 - ti4; int oidx1 = idx14 + idx1; int oidx2 = idx14 + idx2; int oidx3 = idx14 + idx3; int oidx4 = idx14 + idx4; out[oidx1 - 1] = tr2 + tr3; out[oidx1] = ti2 + ti3; out[oidx2 - 1] = w1r * cr2 - w1i * ci2; out[oidx2] = w1r * ci2 + w1i * cr2; out[oidx3 - 1] = w2r * cr3 - w2i * ci3; out[oidx3] = w2r * ci3 + w2i * cr3; out[oidx4 - 1] = w3r * cr4 - w3i * ci4; out[oidx4] = w3r * ci4 + w3i * cr4; } } if (ido % 2 == 1) return; } for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 4 * idx1; int idx3 = idx1 + idx0; int idx4 = idx3 + idx0; int idx5 = idx4 + idx0; int idx6 = idx2 + ido; int idx7 = idx6 + ido; int idx8 = idx7 + ido; int idx9 = in_off + ido; int idx10 = out_off + ido; float i1r = in[idx9 - 1 + idx2]; float i2r = in[idx9 - 1 + idx7]; float i3r = in[in_off + idx6]; float i4r = in[in_off + idx8]; ti1 = i3r + i4r; ti2 = i4r - i3r; tr1 = i1r - i2r; tr2 = i1r + i2r; out[idx10 - 1 + idx1] = tr2 + tr2; out[idx10 - 1 + idx3] = sqrt2 * (tr1 - ti1); out[idx10 - 1 + idx4] = ti2 + ti2; out[idx10 - 1 + idx5] = -sqrt2 * (tr1 + ti1); } } /*------------------------------------------------- radf5: Real FFT's forward processing of factor 5 -------------------------------------------------*/ void radf5(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float tr11 = 0.309016994374947451262869435595348477f; final float ti11 = 0.951056516295153531181938433292089030f; final float tr12 = -0.809016994374947340240566973079694435f; final float ti12 = 0.587785252292473248125759255344746634f; int i, ic; float ci2, di2, ci4, ci5, di3, di4, di5, ci3, cr2, cr3, dr2, dr3, dr4, dr5, cr5, cr4, ti2, ti3, ti5, ti4, tr2, tr3, tr4, tr5, w1r, w1i, w2r, w2i, w3r, w3i, w4r, w4i; int iw1, iw2, iw3, iw4; iw1 = offset; iw2 = iw1 + ido; iw3 = iw2 + ido; iw4 = iw3 + ido; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 5 * idx1; int idx3 = idx2 + ido; int idx4 = idx3 + ido; int idx5 = idx4 + ido; int idx6 = idx5 + ido; int idx7 = idx1 + idx0; int idx8 = idx7 + idx0; int idx9 = idx8 + idx0; int idx10 = idx9 + idx0; int idx11 = out_off + ido - 1; float i1r = in[in_off + idx1]; float i2r = in[in_off + idx7]; float i3r = in[in_off + idx8]; float i4r = in[in_off + idx9]; float i5r = in[in_off + idx10]; cr2 = i5r + i2r; ci5 = i5r - i2r; cr3 = i4r + i3r; ci4 = i4r - i3r; out[out_off + idx2] = i1r + cr2 + cr3; out[idx11 + idx3] = i1r + tr11 * cr2 + tr12 * cr3; out[out_off + idx4] = ti11 * ci5 + ti12 * ci4; out[idx11 + idx5] = i1r + tr12 * cr2 + tr11 * cr3; out[out_off + idx6] = ti12 * ci5 - ti11 * ci4; } if (ido == 1) return; for (int k = 0; k < l1; ++k) { int idx1 = k * ido; int idx2 = 5 * idx1; int idx3 = idx2 + ido; int idx4 = idx3 + ido; int idx5 = idx4 + ido; int idx6 = idx5 + ido; int idx7 = idx1 + idx0; int idx8 = idx7 + idx0; int idx9 = idx8 + idx0; int idx10 = idx9 + idx0; for (i = 2; i < ido; i += 2) { int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; int widx3 = i - 1 + iw3; int widx4 = i - 1 + iw4; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; w3r = wtable_r[widx3 - 1]; w3i = wtable_r[widx3]; w4r = wtable_r[widx4 - 1]; w4i = wtable_r[widx4]; ic = ido - i; int idx15 = in_off + i; int idx16 = out_off + i; int idx17 = out_off + ic; int iidx1 = idx15 + idx1; int iidx2 = idx15 + idx7; int iidx3 = idx15 + idx8; int iidx4 = idx15 + idx9; int iidx5 = idx15 + idx10; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; float i5i = in[iidx5 - 1]; float i5r = in[iidx5]; dr2 = w1r * i2i + w1i * i2r; di2 = w1r * i2r - w1i * i2i; dr3 = w2r * i3i + w2i * i3r; di3 = w2r * i3r - w2i * i3i; dr4 = w3r * i4i + w3i * i4r; di4 = w3r * i4r - w3i * i4i; dr5 = w4r * i5i + w4i * i5r; di5 = w4r * i5r - w4i * i5i; cr2 = dr2 + dr5; ci5 = dr5 - dr2; cr5 = di2 - di5; ci2 = di2 + di5; cr3 = dr3 + dr4; ci4 = dr4 - dr3; cr4 = di3 - di4; ci3 = di3 + di4; tr2 = i1i + tr11 * cr2 + tr12 * cr3; ti2 = i1r + tr11 * ci2 + tr12 * ci3; tr3 = i1i + tr12 * cr2 + tr11 * cr3; ti3 = i1r + tr12 * ci2 + tr11 * ci3; tr5 = ti11 * cr5 + ti12 * cr4; ti5 = ti11 * ci5 + ti12 * ci4; tr4 = ti12 * cr5 - ti11 * cr4; ti4 = ti12 * ci5 - ti11 * ci4; int oidx1 = idx16 + idx2; int oidx2 = idx17 + idx3; int oidx3 = idx16 + idx4; int oidx4 = idx17 + idx5; int oidx5 = idx16 + idx6; out[oidx1 - 1] = i1i + cr2 + cr3; out[oidx1] = i1r + ci2 + ci3; out[oidx3 - 1] = tr2 + tr5; out[oidx2 - 1] = tr2 - tr5; out[oidx3] = ti2 + ti5; out[oidx2] = ti5 - ti2; out[oidx5 - 1] = tr3 + tr4; out[oidx4 - 1] = tr3 - tr4; out[oidx5] = ti3 + ti4; out[oidx4] = ti4 - ti3; } } } /*------------------------------------------------- radb5: Real FFT's backward processing of factor 5 -------------------------------------------------*/ void radb5(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { final float tr11 = 0.309016994374947451262869435595348477f; final float ti11 = 0.951056516295153531181938433292089030f; final float tr12 = -0.809016994374947340240566973079694435f; final float ti12 = 0.587785252292473248125759255344746634f; int i, ic; float ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5, w1r, w1i, w2r, w2i, w3r, w3i, w4r, w4i; int iw1, iw2, iw3, iw4; iw1 = offset; iw2 = iw1 + ido; iw3 = iw2 + ido; iw4 = iw3 + ido; int idx0 = l1 * ido; for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = 5 * idx1; int idx3 = idx2 + ido; int idx4 = idx3 + ido; int idx5 = idx4 + ido; int idx6 = idx5 + ido; int idx7 = idx1 + idx0; int idx8 = idx7 + idx0; int idx9 = idx8 + idx0; int idx10 = idx9 + idx0; int idx11 = in_off + ido - 1; float i1r = in[in_off + idx2]; ti5 = 2 * in[in_off + idx4]; ti4 = 2 * in[in_off + idx6]; tr2 = 2 * in[idx11 + idx3]; tr3 = 2 * in[idx11 + idx5]; cr2 = i1r + tr11 * tr2 + tr12 * tr3; cr3 = i1r + tr12 * tr2 + tr11 * tr3; ci5 = ti11 * ti5 + ti12 * ti4; ci4 = ti12 * ti5 - ti11 * ti4; out[out_off + idx1] = i1r + tr2 + tr3; out[out_off + idx7] = cr2 - ci5; out[out_off + idx8] = cr3 - ci4; out[out_off + idx9] = cr3 + ci4; out[out_off + idx10] = cr2 + ci5; } if (ido == 1) return; for (int k = 0; k < l1; ++k) { int idx1 = k * ido; int idx2 = 5 * idx1; int idx3 = idx2 + ido; int idx4 = idx3 + ido; int idx5 = idx4 + ido; int idx6 = idx5 + ido; int idx7 = idx1 + idx0; int idx8 = idx7 + idx0; int idx9 = idx8 + idx0; int idx10 = idx9 + idx0; for (i = 2; i < ido; i += 2) { ic = ido - i; int widx1 = i - 1 + iw1; int widx2 = i - 1 + iw2; int widx3 = i - 1 + iw3; int widx4 = i - 1 + iw4; w1r = wtable_r[widx1 - 1]; w1i = wtable_r[widx1]; w2r = wtable_r[widx2 - 1]; w2i = wtable_r[widx2]; w3r = wtable_r[widx3 - 1]; w3i = wtable_r[widx3]; w4r = wtable_r[widx4 - 1]; w4i = wtable_r[widx4]; int idx15 = in_off + i; int idx16 = in_off + ic; int idx17 = out_off + i; int iidx1 = idx15 + idx2; int iidx2 = idx16 + idx3; int iidx3 = idx15 + idx4; int iidx4 = idx16 + idx5; int iidx5 = idx15 + idx6; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; float i5i = in[iidx5 - 1]; float i5r = in[iidx5]; ti5 = i3r + i2r; ti2 = i3r - i2r; ti4 = i5r + i4r; ti3 = i5r - i4r; tr5 = i3i - i2i; tr2 = i3i + i2i; tr4 = i5i - i4i; tr3 = i5i + i4i; cr2 = i1i + tr11 * tr2 + tr12 * tr3; ci2 = i1r + tr11 * ti2 + tr12 * ti3; cr3 = i1i + tr12 * tr2 + tr11 * tr3; ci3 = i1r + tr12 * ti2 + tr11 * ti3; cr5 = ti11 * tr5 + ti12 * tr4; ci5 = ti11 * ti5 + ti12 * ti4; cr4 = ti12 * tr5 - ti11 * tr4; ci4 = ti12 * ti5 - ti11 * ti4; dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; int oidx1 = idx17 + idx1; int oidx2 = idx17 + idx7; int oidx3 = idx17 + idx8; int oidx4 = idx17 + idx9; int oidx5 = idx17 + idx10; out[oidx1 - 1] = i1i + tr2 + tr3; out[oidx1] = i1r + ti2 + ti3; out[oidx2 - 1] = w1r * dr2 - w1i * di2; out[oidx2] = w1r * di2 + w1i * dr2; out[oidx3 - 1] = w2r * dr3 - w2i * di3; out[oidx3] = w2r * di3 + w2i * dr3; out[oidx4 - 1] = w3r * dr4 - w3i * di4; out[oidx4] = w3r * di4 + w3i * dr4; out[oidx5 - 1] = w4r * dr5 - w4i * di5; out[oidx5] = w4r * di5 + w4i * dr5; } } } /*--------------------------------------------------------- radfg: Real FFT's forward processing of general factor --------------------------------------------------------*/ void radfg(final int ido, final int ip, final int l1, final int idl1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { int idij, ipph, j2, ic, jc, lc, is, nbd; float dc2, ai1, ai2, ar1, ar2, ds2, dcp, arg, dsp, ar1h, ar2h, w1r, w1i; int iw1 = offset; arg = TWO_PI / (float) ip; dcp = (float)Math.cos(arg); dsp = (float)Math.sin(arg); ipph = (ip + 1) / 2; nbd = (ido - 1) / 2; if (ido != 1) { for (int ik = 0; ik < idl1; ik++) out[out_off + ik] = in[in_off + ik]; for (int j = 1; j < ip; j++) { int idx1 = j * l1 * ido; for (int k = 0; k < l1; k++) { int idx2 = k * ido + idx1; out[out_off + idx2] = in[in_off + idx2]; } } if (nbd <= l1) { is = -ido; for (int j = 1; j < ip; j++) { is += ido; idij = is - 1; int idx1 = j * l1 * ido; for (int i = 2; i < ido; i += 2) { idij += 2; int idx2 = idij + iw1; int idx4 = in_off + i; int idx5 = out_off + i; w1r = wtable_r[idx2 - 1]; w1i = wtable_r[idx2]; for (int k = 0; k < l1; k++) { int idx3 = k * ido + idx1; int oidx1 = idx5 + idx3; int iidx1 = idx4 + idx3; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; out[oidx1 - 1] = w1r * i1i + w1i * i1r; out[oidx1] = w1r * i1r - w1i * i1i; } } } } else { is = -ido; for (int j = 1; j < ip; j++) { is += ido; int idx1 = j * l1 * ido; for (int k = 0; k < l1; k++) { idij = is - 1; int idx3 = k * ido + idx1; for (int i = 2; i < ido; i += 2) { idij += 2; int idx2 = idij + iw1; w1r = wtable_r[idx2 - 1]; w1i = wtable_r[idx2]; int oidx1 = out_off + i + idx3; int iidx1 = in_off + i + idx3; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; out[oidx1 - 1] = w1r * i1i + w1i * i1r; out[oidx1] = w1r * i1r - w1i * i1i; } } } } if (nbd >= l1) { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int k = 0; k < l1; k++) { int idx3 = k * ido + idx1; int idx4 = k * ido + idx2; for (int i = 2; i < ido; i += 2) { int idx5 = in_off + i; int idx6 = out_off + i; int iidx1 = idx5 + idx3; int iidx2 = idx5 + idx4; int oidx1 = idx6 + idx3; int oidx2 = idx6 + idx4; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; float o2i = out[oidx2 - 1]; float o2r = out[oidx2]; in[iidx1 - 1] = o1i + o2i; in[iidx1] = o1r + o2r; in[iidx2 - 1] = o1r - o2r; in[iidx2] = o2i - o1i; } } } } else { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int i = 2; i < ido; i += 2) { int idx5 = in_off + i; int idx6 = out_off + i; for (int k = 0; k < l1; k++) { int idx3 = k * ido + idx1; int idx4 = k * ido + idx2; int iidx1 = idx5 + idx3; int iidx2 = idx5 + idx4; int oidx1 = idx6 + idx3; int oidx2 = idx6 + idx4; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; float o2i = out[oidx2 - 1]; float o2r = out[oidx2]; in[iidx1 - 1] = o1i + o2i; in[iidx1] = o1r + o2r; in[iidx2 - 1] = o1r - o2r; in[iidx2] = o2i - o1i; } } } } } else { System.arraycopy(out, out_off, in, in_off, idl1); } for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int k = 0; k < l1; k++) { int idx3 = k * ido + idx1; int idx4 = k * ido + idx2; int oidx1 = out_off + idx3; int oidx2 = out_off + idx4; float o1r = out[oidx1]; float o2r = out[oidx2]; in[in_off + idx3] = o1r + o2r; in[in_off + idx4] = o2r - o1r; } } ar1 = 1; ai1 = 0; int idx0 = (ip - 1) * idl1; for (int l = 1; l < ipph; l++) { lc = ip - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; int idx1 = l * idl1; int idx2 = lc * idl1; for (int ik = 0; ik < idl1; ik++) { int idx3 = out_off + ik; int idx4 = in_off + ik; out[idx3 + idx1] = in[idx4] + ar1 * in[idx4 + idl1]; out[idx3 + idx2] = ai1 * in[idx4 + idx0]; } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; for (int j = 2; j < ipph; j++) { jc = ip - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; int idx3 = j * idl1; int idx4 = jc * idl1; for (int ik = 0; ik < idl1; ik++) { int idx5 = out_off + ik; int idx6 = in_off + ik; out[idx5 + idx1] += ar2 * in[idx6 + idx3]; out[idx5 + idx2] += ai2 * in[idx6 + idx4]; } } } for (int j = 1; j < ipph; j++) { int idx1 = j * idl1; for (int ik = 0; ik < idl1; ik++) { out[out_off + ik] += in[in_off + ik + idx1]; } } if (ido >= l1) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = idx1 * ip; for (int i = 0; i < ido; i++) { in[in_off + i + idx2] = out[out_off + i + idx1]; } } } else { for (int i = 0; i < ido; i++) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; in[in_off + i + idx1 * ip] = out[out_off + i + idx1]; } } } int idx01 = ip * ido; for (int j = 1; j < ipph; j++) { jc = ip - j; j2 = 2 * j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = j2 * ido; for (int k = 0; k < l1; k++) { int idx4 = k * ido; int idx5 = idx4 + idx1; int idx6 = idx4 + idx2; int idx7 = k * idx01; in[in_off + ido - 1 + idx3 - ido + idx7] = out[out_off + idx5]; in[in_off + idx3 + idx7] = out[out_off + idx6]; } } if (ido == 1) return; if (nbd >= l1) { for (int j = 1; j < ipph; j++) { jc = ip - j; j2 = 2 * j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = j2 * ido; for (int k = 0; k < l1; k++) { int idx4 = k * idx01; int idx5 = k * ido; for (int i = 2; i < ido; i += 2) { ic = ido - i; int idx6 = in_off + i; int idx7 = in_off + ic; int idx8 = out_off + i; int iidx1 = idx6 + idx3 + idx4; int iidx2 = idx7 + idx3 - ido + idx4; int oidx1 = idx8 + idx5 + idx1; int oidx2 = idx8 + idx5 + idx2; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; float o2i = out[oidx2 - 1]; float o2r = out[oidx2]; in[iidx1 - 1] = o1i + o2i; in[iidx2 - 1] = o1i - o2i; in[iidx1] = o1r + o2r; in[iidx2] = o2r - o1r; } } } } else { for (int j = 1; j < ipph; j++) { jc = ip - j; j2 = 2 * j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = j2 * ido; for (int i = 2; i < ido; i += 2) { ic = ido - i; int idx6 = in_off + i; int idx7 = in_off + ic; int idx8 = out_off + i; for (int k = 0; k < l1; k++) { int idx4 = k * idx01; int idx5 = k * ido; int iidx1 = idx6 + idx3 + idx4; int iidx2 = idx7 + idx3 - ido + idx4; int oidx1 = idx8 + idx5 + idx1; int oidx2 = idx8 + idx5 + idx2; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; float o2i = out[oidx2 - 1]; float o2r = out[oidx2]; in[iidx1 - 1] = o1i + o2i; in[iidx2 - 1] = o1i - o2i; in[iidx1] = o1r + o2r; in[iidx2] = o2r - o1r; } } } } } /*--------------------------------------------------------- radbg: Real FFT's backward processing of general factor --------------------------------------------------------*/ void radbg(final int ido, final int ip, final int l1, final int idl1, final float in[], final int in_off, final float out[], final int out_off, final int offset) { int idij, ipph, j2, ic, jc, lc, is; float dc2, ai1, ai2, ar1, ar2, ds2, w1r, w1i; int nbd; float dcp, arg, dsp, ar1h, ar2h; int iw1 = offset; arg = TWO_PI / (float) ip; dcp = (float)Math.cos(arg); dsp = (float)Math.sin(arg); nbd = (ido - 1) / 2; ipph = (ip + 1) / 2; int idx0 = ip * ido; if (ido >= l1) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = k * idx0; for (int i = 0; i < ido; i++) { out[out_off + i + idx1] = in[in_off + i + idx2]; } } } else { for (int i = 0; i < ido; i++) { int idx1 = out_off + i; int idx2 = in_off + i; for (int k = 0; k < l1; k++) { out[idx1 + k * ido] = in[idx2 + k * idx0]; } } } int iidx0 = in_off + ido - 1; for (int j = 1; j < ipph; j++) { jc = ip - j; j2 = 2 * j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = j2 * ido; for (int k = 0; k < l1; k++) { int idx4 = k * ido; int idx5 = idx4 * ip; int iidx1 = iidx0 + idx3 + idx5 - ido; int iidx2 = in_off + idx3 + idx5; float i1r = in[iidx1]; float i2r = in[iidx2]; out[out_off + idx4 + idx1] = i1r + i1r; out[out_off + idx4 + idx2] = i2r + i2r; } } if (ido != 1) { if (nbd >= l1) { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = 2 * j * ido; for (int k = 0; k < l1; k++) { int idx4 = k * ido + idx1; int idx5 = k * ido + idx2; int idx6 = k * ip * ido + idx3; for (int i = 2; i < ido; i += 2) { ic = ido - i; int idx7 = out_off + i; int idx8 = in_off + ic; int idx9 = in_off + i; int oidx1 = idx7 + idx4; int oidx2 = idx7 + idx5; int iidx1 = idx9 + idx6; int iidx2 = idx8 + idx6 - ido; float a1i = in[iidx1 - 1]; float a1r = in[iidx1]; float a2i = in[iidx2 - 1]; float a2r = in[iidx2]; out[oidx1 - 1] = a1i + a2i; out[oidx2 - 1] = a1i - a2i; out[oidx1] = a1r - a2r; out[oidx2] = a1r + a2r; } } } } else { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; int idx3 = 2 * j * ido; for (int i = 2; i < ido; i += 2) { ic = ido - i; int idx7 = out_off + i; int idx8 = in_off + ic; int idx9 = in_off + i; for (int k = 0; k < l1; k++) { int idx4 = k * ido + idx1; int idx5 = k * ido + idx2; int idx6 = k * ip * ido + idx3; int oidx1 = idx7 + idx4; int oidx2 = idx7 + idx5; int iidx1 = idx9 + idx6; int iidx2 = idx8 + idx6 - ido; float a1i = in[iidx1 - 1]; float a1r = in[iidx1]; float a2i = in[iidx2 - 1]; float a2r = in[iidx2]; out[oidx1 - 1] = a1i + a2i; out[oidx2 - 1] = a1i - a2i; out[oidx1] = a1r - a2r; out[oidx2] = a1r + a2r; } } } } } ar1 = 1; ai1 = 0; int idx01 = (ip - 1) * idl1; for (int l = 1; l < ipph; l++) { lc = ip - l; ar1h = dcp * ar1 - dsp * ai1; ai1 = dcp * ai1 + dsp * ar1; ar1 = ar1h; int idx1 = l * idl1; int idx2 = lc * idl1; for (int ik = 0; ik < idl1; ik++) { int idx3 = in_off + ik; int idx4 = out_off + ik; in[idx3 + idx1] = out[idx4] + ar1 * out[idx4 + idl1]; in[idx3 + idx2] = ai1 * out[idx4 + idx01]; } dc2 = ar1; ds2 = ai1; ar2 = ar1; ai2 = ai1; for (int j = 2; j < ipph; j++) { jc = ip - j; ar2h = dc2 * ar2 - ds2 * ai2; ai2 = dc2 * ai2 + ds2 * ar2; ar2 = ar2h; int idx5 = j * idl1; int idx6 = jc * idl1; for (int ik = 0; ik < idl1; ik++) { int idx7 = in_off + ik; int idx8 = out_off + ik; in[idx7 + idx1] += ar2 * out[idx8 + idx5]; in[idx7 + idx2] += ai2 * out[idx8 + idx6]; } } } for (int j = 1; j < ipph; j++) { int idx1 = j * idl1; for (int ik = 0; ik < idl1; ik++) { int idx2 = out_off + ik; out[idx2] += out[idx2 + idx1]; } } for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int k = 0; k < l1; k++) { int idx3 = k * ido; int oidx1 = out_off + idx3; int iidx1 = in_off + idx3 + idx1; int iidx2 = in_off + idx3 + idx2; float i1r = in[iidx1]; float i2r = in[iidx2]; out[oidx1 + idx1] = i1r - i2r; out[oidx1 + idx2] = i1r + i2r; } } if (ido == 1) return; if (nbd >= l1) { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int k = 0; k < l1; k++) { int idx3 = k * ido; for (int i = 2; i < ido; i += 2) { int idx4 = out_off + i; int idx5 = in_off + i; int oidx1 = idx4 + idx3 + idx1; int oidx2 = idx4 + idx3 + idx2; int iidx1 = idx5 + idx3 + idx1; int iidx2 = idx5 + idx3 + idx2; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; out[oidx1 - 1] = i1i - i2r; out[oidx2 - 1] = i1i + i2r; out[oidx1] = i1r + i2i; out[oidx2] = i1r - i2i; } } } } else { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * l1 * ido; int idx2 = jc * l1 * ido; for (int i = 2; i < ido; i += 2) { int idx4 = out_off + i; int idx5 = in_off + i; for (int k = 0; k < l1; k++) { int idx3 = k * ido; int oidx1 = idx4 + idx3 + idx1; int oidx2 = idx4 + idx3 + idx2; int iidx1 = idx5 + idx3 + idx1; int iidx2 = idx5 + idx3 + idx2; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; out[oidx1 - 1] = i1i - i2r; out[oidx2 - 1] = i1i + i2r; out[oidx1] = i1r + i2i; out[oidx2] = i1r - i2i; } } } } System.arraycopy(out, out_off, in, in_off, idl1); for (int j = 1; j < ip; j++) { int idx1 = j * l1 * ido; for (int k = 0; k < l1; k++) { int idx2 = k * ido + idx1; in[in_off + idx2] = out[out_off + idx2]; } } if (nbd <= l1) { is = -ido; for (int j = 1; j < ip; j++) { is += ido; idij = is - 1; int idx1 = j * l1 * ido; for (int i = 2; i < ido; i += 2) { idij += 2; int idx2 = idij + iw1; w1r = wtable_r[idx2 - 1]; w1i = wtable_r[idx2]; int idx4 = in_off + i; int idx5 = out_off + i; for (int k = 0; k < l1; k++) { int idx3 = k * ido + idx1; int iidx1 = idx4 + idx3; int oidx1 = idx5 + idx3; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; in[iidx1 - 1] = w1r * o1i - w1i * o1r; in[iidx1] = w1r * o1r + w1i * o1i; } } } } else { is = -ido; for (int j = 1; j < ip; j++) { is += ido; int idx1 = j * l1 * ido; for (int k = 0; k < l1; k++) { idij = is - 1; int idx3 = k * ido + idx1; for (int i = 2; i < ido; i += 2) { idij += 2; int idx2 = idij + iw1; w1r = wtable_r[idx2 - 1]; w1i = wtable_r[idx2]; int idx4 = in_off + i; int idx5 = out_off + i; int iidx1 = idx4 + idx3; int oidx1 = idx5 + idx3; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; in[iidx1 - 1] = w1r * o1i - w1i * o1r; in[iidx1] = w1r * o1r + w1i * o1i; } } } } } /*--------------------------------------------------------- cfftf1: further processing of Complex forward FFT --------------------------------------------------------*/ void cfftf(float a[], int offa, int isign) { int idot; int l1, l2; int na, nf, ip, iw, ido, idl1; final int twon = 2 * n; int iw1, iw2; float[] ch = ch2; iw1 = twon; iw2 = 4 * n; nac[0] = 0; nf = (int) wtable[1 + iw2]; na = 0; l1 = 1; iw = iw1; for (int k1 = 2; k1 <= nf + 1; k1++) { ip = (int) wtable[k1 + iw2]; l2 = ip * l1; ido = n / l2; idot = ido + ido; idl1 = idot * l1; switch (ip) { case 4: if (na == 0) { passf4(idot, l1, a, offa, ch, 0, iw, isign); } else { passf4(idot, l1, ch, 0, a, offa, iw, isign); } na = 1 - na; break; case 2: if (na == 0) { passf2(idot, l1, a, offa, ch, 0, iw, isign); } else { passf2(idot, l1, ch, 0, a, offa, iw, isign); } na = 1 - na; break; case 3: if (na == 0) { passf3(idot, l1, a, offa, ch, 0, iw, isign); } else { passf3(idot, l1, ch, 0, a, offa, iw, isign); } na = 1 - na; break; case 5: if (na == 0) { passf5(idot, l1, a, offa, ch, 0, iw, isign); } else { passf5(idot, l1, ch, 0, a, offa, iw, isign); } na = 1 - na; break; default: if (na == 0) { passfg(nac, idot, ip, l1, idl1, a, offa, ch, 0, iw, isign); } else { passfg(nac, idot, ip, l1, idl1, ch, 0, a, offa, iw, isign); } if (nac[0] != 0) na = 1 - na; break; } l1 = l2; iw += (ip - 1) * idot; } if (na == 0) return; System.arraycopy(ch, 0, a, offa, twon); } /*---------------------------------------------------------------------- passf2: Complex FFT's forward/backward processing of factor 2; isign is +1 for backward and -1 for forward transforms ----------------------------------------------------------------------*/ void passf2(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset, final int isign) { float t1i, t1r; int iw1; iw1 = offset; int idx = ido * l1; if (ido <= 2) { for (int k = 0; k < l1; k++) { int idx0 = k * ido; int iidx1 = in_off + 2 * idx0; int iidx2 = iidx1 + ido; float a1r = in[iidx1]; float a1i = in[iidx1 + 1]; float a2r = in[iidx2]; float a2i = in[iidx2 + 1]; int oidx1 = out_off + idx0; int oidx2 = oidx1 + idx; out[oidx1] = a1r + a2r; out[oidx1 + 1] = a1i + a2i; out[oidx2] = a1r - a2r; out[oidx2 + 1] = a1i - a2i; } } else { for (int k = 0; k < l1; k++) { for (int i = 0; i < ido - 1; i += 2) { int idx0 = k * ido; int iidx1 = in_off + i + 2 * idx0; int iidx2 = iidx1 + ido; float i1r = in[iidx1]; float i1i = in[iidx1 + 1]; float i2r = in[iidx2]; float i2i = in[iidx2 + 1]; int widx1 = i + iw1; float w1r = wtable[widx1]; float w1i = isign * wtable[widx1 + 1]; t1r = i1r - i2r; t1i = i1i - i2i; int oidx1 = out_off + i + idx0; int oidx2 = oidx1 + idx; out[oidx1] = i1r + i2r; out[oidx1 + 1] = i1i + i2i; out[oidx2] = w1r * t1r - w1i * t1i; out[oidx2 + 1] = w1r * t1i + w1i * t1r; } } } } /*---------------------------------------------------------------------- passf3: Complex FFT's forward/backward processing of factor 3; isign is +1 for backward and -1 for forward transforms ----------------------------------------------------------------------*/ void passf3(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset, final int isign) { final float taur = -0.5f; final float taui = 0.866025403784438707610604524234076962f; float ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2; int iw1, iw2; iw1 = offset; iw2 = iw1 + ido; final int idxt = l1 * ido; if (ido == 2) { for (int k = 1; k <= l1; k++) { int iidx1 = in_off + (3 * k - 2) * ido; int iidx2 = iidx1 + ido; int iidx3 = iidx1 - ido; float i1r = in[iidx1]; float i1i = in[iidx1 + 1]; float i2r = in[iidx2]; float i2i = in[iidx2 + 1]; float i3r = in[iidx3]; float i3i = in[iidx3 + 1]; tr2 = i1r + i2r; cr2 = i3r + taur * tr2; ti2 = i1i + i2i; ci2 = i3i + taur * ti2; cr3 = isign * taui * (i1r - i2r); ci3 = isign * taui * (i1i - i2i); int oidx1 = out_off + (k - 1) * ido; int oidx2 = oidx1 + idxt; int oidx3 = oidx2 + idxt; out[oidx1] = in[iidx3] + tr2; out[oidx1 + 1] = i3i + ti2; out[oidx2] = cr2 - ci3; out[oidx2 + 1] = ci2 + cr3; out[oidx3] = cr2 + ci3; out[oidx3 + 1] = ci2 - cr3; } } else { for (int k = 1; k <= l1; k++) { int idx1 = in_off + (3 * k - 2) * ido; int idx2 = out_off + (k - 1) * ido; for (int i = 0; i < ido - 1; i += 2) { int iidx1 = i + idx1; int iidx2 = iidx1 + ido; int iidx3 = iidx1 - ido; float a1r = in[iidx1]; float a1i = in[iidx1 + 1]; float a2r = in[iidx2]; float a2i = in[iidx2 + 1]; float a3r = in[iidx3]; float a3i = in[iidx3 + 1]; tr2 = a1r + a2r; cr2 = a3r + taur * tr2; ti2 = a1i + a2i; ci2 = a3i + taur * ti2; cr3 = isign * taui * (a1r - a2r); ci3 = isign * taui * (a1i - a2i); dr2 = cr2 - ci3; dr3 = cr2 + ci3; di2 = ci2 + cr3; di3 = ci2 - cr3; int widx1 = i + iw1; int widx2 = i + iw2; float w1r = wtable[widx1]; float w1i = isign * wtable[widx1 + 1]; float w2r = wtable[widx2]; float w2i = isign * wtable[widx2 + 1]; int oidx1 = i + idx2; int oidx2 = oidx1 + idxt; int oidx3 = oidx2 + idxt; out[oidx1] = a3r + tr2; out[oidx1 + 1] = a3i + ti2; out[oidx2] = w1r * dr2 - w1i * di2; out[oidx2 + 1] = w1r * di2 + w1i * dr2; out[oidx3] = w2r * dr3 - w2i * di3; out[oidx3 + 1] = w2r * di3 + w2i * dr3; } } } } /*---------------------------------------------------------------------- passf4: Complex FFT's forward/backward processing of factor 4; isign is +1 for backward and -1 for forward transforms ----------------------------------------------------------------------*/ void passf4(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset, final int isign) { float ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; int iw1, iw2, iw3; iw1 = offset; iw2 = iw1 + ido; iw3 = iw2 + ido; int idx0 = l1 * ido; if (ido == 2) { for (int k = 0; k < l1; k++) { int idxt1 = k * ido; int iidx1 = in_off + 4 * idxt1 + 1; int iidx2 = iidx1 + ido; int iidx3 = iidx2 + ido; int iidx4 = iidx3 + ido; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; ti1 = i1r - i3r; ti2 = i1r + i3r; tr4 = i4r - i2r; ti3 = i2r + i4r; tr1 = i1i - i3i; tr2 = i1i + i3i; ti4 = i2i - i4i; tr3 = i2i + i4i; int oidx1 = out_off + idxt1; int oidx2 = oidx1 + idx0; int oidx3 = oidx2 + idx0; int oidx4 = oidx3 + idx0; out[oidx1] = tr2 + tr3; out[oidx1 + 1] = ti2 + ti3; out[oidx2] = tr1 + isign * tr4; out[oidx2 + 1] = ti1 + isign * ti4; out[oidx3] = tr2 - tr3; out[oidx3 + 1] = ti2 - ti3; out[oidx4] = tr1 - isign * tr4; out[oidx4 + 1] = ti1 - isign * ti4; } } else { for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = in_off + 1 + 4 * idx1; for (int i = 0; i < ido - 1; i += 2) { int iidx1 = i + idx2; int iidx2 = iidx1 + ido; int iidx3 = iidx2 + ido; int iidx4 = iidx3 + ido; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; ti1 = i1r - i3r; ti2 = i1r + i3r; ti3 = i2r + i4r; tr4 = i4r - i2r; tr1 = i1i - i3i; tr2 = i1i + i3i; ti4 = i2i - i4i; tr3 = i2i + i4i; cr3 = tr2 - tr3; ci3 = ti2 - ti3; cr2 = tr1 + isign * tr4; cr4 = tr1 - isign * tr4; ci2 = ti1 + isign * ti4; ci4 = ti1 - isign * ti4; int widx1 = i + iw1; int widx2 = i + iw2; int widx3 = i + iw3; float w1r = wtable[widx1]; float w1i = isign * wtable[widx1 + 1]; float w2r = wtable[widx2]; float w2i = isign * wtable[widx2 + 1]; float w3r = wtable[widx3]; float w3i = isign * wtable[widx3 + 1]; int oidx1 = out_off + i + idx1; int oidx2 = oidx1 + idx0; int oidx3 = oidx2 + idx0; int oidx4 = oidx3 + idx0; out[oidx1] = tr2 + tr3; out[oidx1 + 1] = ti2 + ti3; out[oidx2] = w1r * cr2 - w1i * ci2; out[oidx2 + 1] = w1r * ci2 + w1i * cr2; out[oidx3] = w2r * cr3 - w2i * ci3; out[oidx3 + 1] = w2r * ci3 + w2i * cr3; out[oidx4] = w3r * cr4 - w3i * ci4; out[oidx4 + 1] = w3r * ci4 + w3i * cr4; } } } } /*---------------------------------------------------------------------- passf5: Complex FFT's forward/backward processing of factor 5; isign is +1 for backward and -1 for forward transforms ----------------------------------------------------------------------*/ void passf5(final int ido, final int l1, final float in[], final int in_off, final float out[], final int out_off, final int offset, final int isign) /* isign==-1 for forward transform and+1 for backward transform */ { final float tr11 = 0.309016994374947451262869435595348477f; final float ti11 = 0.951056516295153531181938433292089030f; final float tr12 = -0.809016994374947340240566973079694435f; final float ti12 = 0.587785252292473248125759255344746634f; float ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4, ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5; int iw1, iw2, iw3, iw4; iw1 = offset; iw2 = iw1 + ido; iw3 = iw2 + ido; iw4 = iw3 + ido; int idx0 = l1 * ido; if (ido == 2) { for (int k = 1; k <= l1; ++k) { int iidx1 = in_off + (5 * k - 4) * ido + 1; int iidx2 = iidx1 + ido; int iidx3 = iidx1 - ido; int iidx4 = iidx2 + ido; int iidx5 = iidx4 + ido; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; float i5i = in[iidx5 - 1]; float i5r = in[iidx5]; ti5 = i1r - i5r; ti2 = i1r + i5r; ti4 = i2r - i4r; ti3 = i2r + i4r; tr5 = i1i - i5i; tr2 = i1i + i5i; tr4 = i2i - i4i; tr3 = i2i + i4i; cr2 = i3i + tr11 * tr2 + tr12 * tr3; ci2 = i3r + tr11 * ti2 + tr12 * ti3; cr3 = i3i + tr12 * tr2 + tr11 * tr3; ci3 = i3r + tr12 * ti2 + tr11 * ti3; cr5 = isign * (ti11 * tr5 + ti12 * tr4); ci5 = isign * (ti11 * ti5 + ti12 * ti4); cr4 = isign * (ti12 * tr5 - ti11 * tr4); ci4 = isign * (ti12 * ti5 - ti11 * ti4); int oidx1 = out_off + (k - 1) * ido; int oidx2 = oidx1 + idx0; int oidx3 = oidx2 + idx0; int oidx4 = oidx3 + idx0; int oidx5 = oidx4 + idx0; out[oidx1] = i3i + tr2 + tr3; out[oidx1 + 1] = i3r + ti2 + ti3; out[oidx2] = cr2 - ci5; out[oidx2 + 1] = ci2 + cr5; out[oidx3] = cr3 - ci4; out[oidx3 + 1] = ci3 + cr4; out[oidx4] = cr3 + ci4; out[oidx4 + 1] = ci3 - cr4; out[oidx5] = cr2 + ci5; out[oidx5 + 1] = ci2 - cr5; } } else { for (int k = 1; k <= l1; k++) { int idx1 = in_off + 1 + (k * 5 - 4) * ido; int idx2 = out_off + (k - 1) * ido; for (int i = 0; i < ido - 1; i += 2) { int iidx1 = i + idx1; int iidx2 = iidx1 + ido; int iidx3 = iidx1 - ido; int iidx4 = iidx2 + ido; int iidx5 = iidx4 + ido; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; float i3i = in[iidx3 - 1]; float i3r = in[iidx3]; float i4i = in[iidx4 - 1]; float i4r = in[iidx4]; float i5i = in[iidx5 - 1]; float i5r = in[iidx5]; ti5 = i1r - i5r; ti2 = i1r + i5r; ti4 = i2r - i4r; ti3 = i2r + i4r; tr5 = i1i - i5i; tr2 = i1i + i5i; tr4 = i2i - i4i; tr3 = i2i + i4i; cr2 = i3i + tr11 * tr2 + tr12 * tr3; ci2 = i3r + tr11 * ti2 + tr12 * ti3; cr3 = i3i + tr12 * tr2 + tr11 * tr3; ci3 = i3r + tr12 * ti2 + tr11 * ti3; cr5 = isign * (ti11 * tr5 + ti12 * tr4); ci5 = isign * (ti11 * ti5 + ti12 * ti4); cr4 = isign * (ti12 * tr5 - ti11 * tr4); ci4 = isign * (ti12 * ti5 - ti11 * ti4); dr3 = cr3 - ci4; dr4 = cr3 + ci4; di3 = ci3 + cr4; di4 = ci3 - cr4; dr5 = cr2 + ci5; dr2 = cr2 - ci5; di5 = ci2 - cr5; di2 = ci2 + cr5; int widx1 = i + iw1; int widx2 = i + iw2; int widx3 = i + iw3; int widx4 = i + iw4; float w1r = wtable[widx1]; float w1i = isign * wtable[widx1 + 1]; float w2r = wtable[widx2]; float w2i = isign * wtable[widx2 + 1]; float w3r = wtable[widx3]; float w3i = isign * wtable[widx3 + 1]; float w4r = wtable[widx4]; float w4i = isign * wtable[widx4 + 1]; int oidx1 = i + idx2; int oidx2 = oidx1 + idx0; int oidx3 = oidx2 + idx0; int oidx4 = oidx3 + idx0; int oidx5 = oidx4 + idx0; out[oidx1] = i3i + tr2 + tr3; out[oidx1 + 1] = i3r + ti2 + ti3; out[oidx2] = w1r * dr2 - w1i * di2; out[oidx2 + 1] = w1r * di2 + w1i * dr2; out[oidx3] = w2r * dr3 - w2i * di3; out[oidx3 + 1] = w2r * di3 + w2i * dr3; out[oidx4] = w3r * dr4 - w3i * di4; out[oidx4 + 1] = w3r * di4 + w3i * dr4; out[oidx5] = w4r * dr5 - w4i * di5; out[oidx5 + 1] = w4r * di5 + w4i * dr5; } } } } /*---------------------------------------------------------------------- passfg: Complex FFT's forward/backward processing of general factor; isign is +1 for backward and -1 for forward transforms ----------------------------------------------------------------------*/ void passfg(final int nac[], final int ido, final int ip, final int l1, final int idl1, final float in[], final int in_off, final float out[], final int out_off, final int offset, final int isign) { int idij, idlj, idot, ipph, l, jc, lc, idj, idl, inc, idp; float w1r, w1i, w2i, w2r; int iw1; iw1 = offset; idot = ido / 2; ipph = (ip + 1) / 2; idp = ip * ido; if (ido >= l1) { for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * ido; int idx2 = jc * ido; for (int k = 0; k < l1; k++) { int idx3 = k * ido; int idx4 = idx3 + idx1 * l1; int idx5 = idx3 + idx2 * l1; int idx6 = idx3 * ip; for (int i = 0; i < ido; i++) { int oidx1 = out_off + i; float i1r = in[in_off + i + idx1 + idx6]; float i2r = in[in_off + i + idx2 + idx6]; out[oidx1 + idx4] = i1r + i2r; out[oidx1 + idx5] = i1r - i2r; } } } for (int k = 0; k < l1; k++) { int idxt1 = k * ido; int idxt2 = idxt1 * ip; for (int i = 0; i < ido; i++) { out[out_off + i + idxt1] = in[in_off + i + idxt2]; } } } else { for (int j = 1; j < ipph; j++) { jc = ip - j; int idxt1 = j * l1 * ido; int idxt2 = jc * l1 * ido; int idxt3 = j * ido; int idxt4 = jc * ido; for (int i = 0; i < ido; i++) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; int idx2 = idx1 * ip; int idx3 = out_off + i; int idx4 = in_off + i; float i1r = in[idx4 + idxt3 + idx2]; float i2r = in[idx4 + idxt4 + idx2]; out[idx3 + idx1 + idxt1] = i1r + i2r; out[idx3 + idx1 + idxt2] = i1r - i2r; } } } for (int i = 0; i < ido; i++) { for (int k = 0; k < l1; k++) { int idx1 = k * ido; out[out_off + i + idx1] = in[in_off + i + idx1 * ip]; } } } idl = 2 - ido; inc = 0; int idxt0 = (ip - 1) * idl1; for (l = 1; l < ipph; l++) { lc = ip - l; idl += ido; int idxt1 = l * idl1; int idxt2 = lc * idl1; int idxt3 = idl + iw1; w1r = wtable[idxt3 - 2]; w1i = isign * wtable[idxt3 - 1]; for (int ik = 0; ik < idl1; ik++) { int idx1 = in_off + ik; int idx2 = out_off + ik; in[idx1 + idxt1] = out[idx2] + w1r * out[idx2 + idl1]; in[idx1 + idxt2] = w1i * out[idx2 + idxt0]; } idlj = idl; inc += ido; for (int j = 2; j < ipph; j++) { jc = ip - j; idlj += inc; if (idlj > idp) idlj -= idp; int idxt4 = idlj + iw1; w2r = wtable[idxt4 - 2]; w2i = isign * wtable[idxt4 - 1]; int idxt5 = j * idl1; int idxt6 = jc * idl1; for (int ik = 0; ik < idl1; ik++) { int idx1 = in_off + ik; int idx2 = out_off + ik; in[idx1 + idxt1] += w2r * out[idx2 + idxt5]; in[idx1 + idxt2] += w2i * out[idx2 + idxt6]; } } } for (int j = 1; j < ipph; j++) { int idxt1 = j * idl1; for (int ik = 0; ik < idl1; ik++) { int idx1 = out_off + ik; out[idx1] += out[idx1 + idxt1]; } } for (int j = 1; j < ipph; j++) { jc = ip - j; int idx1 = j * idl1; int idx2 = jc * idl1; for (int ik = 1; ik < idl1; ik += 2) { int idx3 = out_off + ik; int idx4 = in_off + ik; int iidx1 = idx4 + idx1; int iidx2 = idx4 + idx2; float i1i = in[iidx1 - 1]; float i1r = in[iidx1]; float i2i = in[iidx2 - 1]; float i2r = in[iidx2]; int oidx1 = idx3 + idx1; int oidx2 = idx3 + idx2; out[oidx1 - 1] = i1i - i2r; out[oidx2 - 1] = i1i + i2r; out[oidx1] = i1r + i2i; out[oidx2] = i1r - i2i; } } nac[0] = 1; if (ido == 2) return; nac[0] = 0; System.arraycopy(out, out_off, in, in_off, idl1); int idx0 = l1 * ido; for (int j = 1; j < ip; j++) { int idx1 = j * idx0; for (int k = 0; k < l1; k++) { int idx2 = k * ido; int oidx1 = out_off + idx2 + idx1; int iidx1 = in_off + idx2 + idx1; in[iidx1] = out[oidx1]; in[iidx1 + 1] = out[oidx1 + 1]; } } if (idot <= l1) { idij = 0; for (int j = 1; j < ip; j++) { idij += 2; int idx1 = j * l1 * ido; for (int i = 3; i < ido; i += 2) { idij += 2; int idx2 = idij + iw1 - 1; w1r = wtable[idx2 - 1]; w1i = isign * wtable[idx2]; int idx3 = in_off + i; int idx4 = out_off + i; for (int k = 0; k < l1; k++) { int idx5 = k * ido + idx1; int iidx1 = idx3 + idx5; int oidx1 = idx4 + idx5; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; in[iidx1 - 1] = w1r * o1i - w1i * o1r; in[iidx1] = w1r * o1r + w1i * o1i; } } } } else { idj = 2 - ido; for (int j = 1; j < ip; j++) { idj += ido; int idx1 = j * l1 * ido; for (int k = 0; k < l1; k++) { idij = idj; int idx3 = k * ido + idx1; for (int i = 3; i < ido; i += 2) { idij += 2; int idx2 = idij - 1 + iw1; w1r = wtable[idx2 - 1]; w1i = isign * wtable[idx2]; int iidx1 = in_off + i + idx3; int oidx1 = out_off + i + idx3; float o1i = out[oidx1 - 1]; float o1r = out[oidx1]; in[iidx1 - 1] = w1r * o1i - w1i * o1r; in[iidx1] = w1r * o1r + w1i * o1i; } } } } } private void cftfsub(int n, float[] a, int offa, int[] ip, int nw, float[] w) { if (n > 8) { if (n > 32) { cftf1st(n, a, offa, w, nw - (n >> 2)); if (n > 512) { cftrec4(n, a, offa, nw, w); } else if (n > 128) { cftleaf(n, 1, a, offa, nw, w); } else { cftfx41(n, a, offa, nw, w); } bitrv2(n, ip, a, offa); } else if (n == 32) { cftf161(a, offa, w, nw - 8); bitrv216(a, offa); } else { cftf081(a, offa, w, 0); bitrv208(a, offa); } } else if (n == 8) { cftf040(a, offa); } else if (n == 4) { cftxb020(a, offa); } } private void cftbsub(int n, float[] a, int offa, int[] ip, int nw, float[] w) { if (n > 8) { if (n > 32) { cftb1st(n, a, offa, w, nw - (n >> 2)); if (n > 512) { cftrec4(n, a, offa, nw, w); } else if (n > 128) { cftleaf(n, 1, a, offa, nw, w); } else { cftfx41(n, a, offa, nw, w); } bitrv2conj(n, ip, a, offa); } else if (n == 32) { cftf161(a, offa, w, nw - 8); bitrv216neg(a, offa); } else { cftf081(a, offa, w, 0); bitrv208neg(a, offa); } } else if (n == 8) { cftb040(a, offa); } else if (n == 4) { cftxb020(a, offa); } } private void bitrv2(int n, int[] ip, float[] a, int offa) { int j1, k1, l, m, nh, nm; float xr, xi, yr, yi; int idx0, idx1, idx2; m = 1; for (l = n >> 2; l > 8; l >>= 2) { m <<= 1; } nh = n >> 1; nm = 4 * m; if (l == 8) { for (int k = 0; k < m; k++) { idx0 = 4 * k; for (int j = 0; j < k; j++) { j1 = 4 * j + 2 * ip[m + k]; k1 = idx0 + 2 * ip[m + j]; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh; k1 += 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh; k1 -= 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } k1 = idx0 + 2 * ip[m + k]; j1 = k1 + 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= 2; k1 -= nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh + 2; k1 += nh + 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh - nm; k1 += 2 * nm - 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } } else { for (int k = 0; k < m; k++) { idx0 = 4 * k; for (int j = 0; j < k; j++) { j1 = 4 * j + ip[m + k]; k1 = idx0 + ip[m + j]; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh; k1 += 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh; k1 -= 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } k1 = idx0 + ip[m + k]; j1 = k1 + 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = a[idx1 + 1]; yr = a[idx2]; yi = a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } } } private void bitrv2conj(int n, int[] ip, float[] a, int offa) { int j1, k1, l, m, nh, nm; float xr, xi, yr, yi; int idx0, idx1, idx2; m = 1; for (l = n >> 2; l > 8; l >>= 2) { m <<= 1; } nh = n >> 1; nm = 4 * m; if (l == 8) { for (int k = 0; k < m; k++) { idx0 = 4 * k; for (int j = 0; j < k; j++) { j1 = 4 * j + 2 * ip[m + k]; k1 = idx0 + 2 * ip[m + j]; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh; k1 += 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh; k1 -= 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } k1 = idx0 + 2 * ip[m + k]; j1 = k1 + 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; a[idx1 - 1] = -a[idx1 - 1]; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; a[idx2 + 3] = -a[idx2 + 3]; j1 += nm; k1 += 2 * nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= 2; k1 -= nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh + 2; k1 += nh + 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh - nm; k1 += 2 * nm - 2; idx1 = offa + j1; idx2 = offa + k1; a[idx1 - 1] = -a[idx1 - 1]; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; a[idx2 + 3] = -a[idx2 + 3]; } } else { for (int k = 0; k < m; k++) { idx0 = 4 * k; for (int j = 0; j < k; j++) { j1 = 4 * j + ip[m + k]; k1 = idx0 + ip[m + j]; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nh; k1 += 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nh; k1 -= 2; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; j1 -= nm; k1 -= nm; idx1 = offa + j1; idx2 = offa + k1; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; } k1 = idx0 + ip[m + k]; j1 = k1 + 2; k1 += nh; idx1 = offa + j1; idx2 = offa + k1; a[idx1 - 1] = -a[idx1 - 1]; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; a[idx2 + 3] = -a[idx2 + 3]; j1 += nm; k1 += nm; idx1 = offa + j1; idx2 = offa + k1; a[idx1 - 1] = -a[idx1 - 1]; xr = a[idx1]; xi = -a[idx1 + 1]; yr = a[idx2]; yi = -a[idx2 + 1]; a[idx1] = yr; a[idx1 + 1] = yi; a[idx2] = xr; a[idx2 + 1] = xi; a[idx2 + 3] = -a[idx2 + 3]; } } } private void bitrv216(float[] a, int offa) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x7r, x7i, x8r, x8i, x10r, x10i, x11r, x11i, x12r, x12i, x13r, x13i, x14r, x14i; x1r = a[offa + 2]; x1i = a[offa + 3]; x2r = a[offa + 4]; x2i = a[offa + 5]; x3r = a[offa + 6]; x3i = a[offa + 7]; x4r = a[offa + 8]; x4i = a[offa + 9]; x5r = a[offa + 10]; x5i = a[offa + 11]; x7r = a[offa + 14]; x7i = a[offa + 15]; x8r = a[offa + 16]; x8i = a[offa + 17]; x10r = a[offa + 20]; x10i = a[offa + 21]; x11r = a[offa + 22]; x11i = a[offa + 23]; x12r = a[offa + 24]; x12i = a[offa + 25]; x13r = a[offa + 26]; x13i = a[offa + 27]; x14r = a[offa + 28]; x14i = a[offa + 29]; a[offa + 2] = x8r; a[offa + 3] = x8i; a[offa + 4] = x4r; a[offa + 5] = x4i; a[offa + 6] = x12r; a[offa + 7] = x12i; a[offa + 8] = x2r; a[offa + 9] = x2i; a[offa + 10] = x10r; a[offa + 11] = x10i; a[offa + 14] = x14r; a[offa + 15] = x14i; a[offa + 16] = x1r; a[offa + 17] = x1i; a[offa + 20] = x5r; a[offa + 21] = x5i; a[offa + 22] = x13r; a[offa + 23] = x13i; a[offa + 24] = x3r; a[offa + 25] = x3i; a[offa + 26] = x11r; a[offa + 27] = x11i; a[offa + 28] = x7r; a[offa + 29] = x7i; } private void bitrv216neg(float[] a, int offa) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i, x8r, x8i, x9r, x9i, x10r, x10i, x11r, x11i, x12r, x12i, x13r, x13i, x14r, x14i, x15r, x15i; x1r = a[offa + 2]; x1i = a[offa + 3]; x2r = a[offa + 4]; x2i = a[offa + 5]; x3r = a[offa + 6]; x3i = a[offa + 7]; x4r = a[offa + 8]; x4i = a[offa + 9]; x5r = a[offa + 10]; x5i = a[offa + 11]; x6r = a[offa + 12]; x6i = a[offa + 13]; x7r = a[offa + 14]; x7i = a[offa + 15]; x8r = a[offa + 16]; x8i = a[offa + 17]; x9r = a[offa + 18]; x9i = a[offa + 19]; x10r = a[offa + 20]; x10i = a[offa + 21]; x11r = a[offa + 22]; x11i = a[offa + 23]; x12r = a[offa + 24]; x12i = a[offa + 25]; x13r = a[offa + 26]; x13i = a[offa + 27]; x14r = a[offa + 28]; x14i = a[offa + 29]; x15r = a[offa + 30]; x15i = a[offa + 31]; a[offa + 2] = x15r; a[offa + 3] = x15i; a[offa + 4] = x7r; a[offa + 5] = x7i; a[offa + 6] = x11r; a[offa + 7] = x11i; a[offa + 8] = x3r; a[offa + 9] = x3i; a[offa + 10] = x13r; a[offa + 11] = x13i; a[offa + 12] = x5r; a[offa + 13] = x5i; a[offa + 14] = x9r; a[offa + 15] = x9i; a[offa + 16] = x1r; a[offa + 17] = x1i; a[offa + 18] = x14r; a[offa + 19] = x14i; a[offa + 20] = x6r; a[offa + 21] = x6i; a[offa + 22] = x10r; a[offa + 23] = x10i; a[offa + 24] = x2r; a[offa + 25] = x2i; a[offa + 26] = x12r; a[offa + 27] = x12i; a[offa + 28] = x4r; a[offa + 29] = x4i; a[offa + 30] = x8r; a[offa + 31] = x8i; } private void bitrv208(float[] a, int offa) { float x1r, x1i, x3r, x3i, x4r, x4i, x6r, x6i; x1r = a[offa + 2]; x1i = a[offa + 3]; x3r = a[offa + 6]; x3i = a[offa + 7]; x4r = a[offa + 8]; x4i = a[offa + 9]; x6r = a[offa + 12]; x6i = a[offa + 13]; a[offa + 2] = x4r; a[offa + 3] = x4i; a[offa + 6] = x6r; a[offa + 7] = x6i; a[offa + 8] = x1r; a[offa + 9] = x1i; a[offa + 12] = x3r; a[offa + 13] = x3i; } private void bitrv208neg(float[] a, int offa) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i; x1r = a[offa + 2]; x1i = a[offa + 3]; x2r = a[offa + 4]; x2i = a[offa + 5]; x3r = a[offa + 6]; x3i = a[offa + 7]; x4r = a[offa + 8]; x4i = a[offa + 9]; x5r = a[offa + 10]; x5i = a[offa + 11]; x6r = a[offa + 12]; x6i = a[offa + 13]; x7r = a[offa + 14]; x7i = a[offa + 15]; a[offa + 2] = x7r; a[offa + 3] = x7i; a[offa + 4] = x3r; a[offa + 5] = x3i; a[offa + 6] = x5r; a[offa + 7] = x5i; a[offa + 8] = x1r; a[offa + 9] = x1i; a[offa + 10] = x6r; a[offa + 11] = x6i; a[offa + 12] = x2r; a[offa + 13] = x2i; a[offa + 14] = x4r; a[offa + 15] = x4i; } private void cftf1st(int n, float[] a, int offa, float[] w, int startw) { int j0, j1, j2, j3, k, m, mh; float wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i; int idx0, idx1, idx2, idx3, idx4, idx5; mh = n >> 3; m = 2 * mh; j1 = m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[offa] + a[idx2]; x0i = a[offa + 1] + a[idx2 + 1]; x1r = a[offa] - a[idx2]; x1i = a[offa + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[offa] = x0r + x2r; a[offa + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; a[idx2] = x1r - x3i; a[idx2 + 1] = x1i + x3r; a[idx3] = x1r + x3i; a[idx3 + 1] = x1i - x3r; wn4r = w[startw + 1]; csc1 = w[startw + 2]; csc3 = w[startw + 3]; wd1r = 1; wd1i = 0; wd3r = 1; wd3i = 0; k = 0; for (int j = 2; j < mh - 2; j += 4) { k += 4; idx4 = startw + k; wk1r = csc1 * (wd1r + w[idx4]); wk1i = csc1 * (wd1i + w[idx4 + 1]); wk3r = csc3 * (wd3r + w[idx4 + 2]); wk3i = csc3 * (wd3i + w[idx4 + 3]); wd1r = w[idx4]; wd1i = w[idx4 + 1]; wd3r = w[idx4 + 2]; wd3i = w[idx4 + 3]; j1 = j + m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; idx5 = offa + j; x0r = a[idx5] + a[idx2]; x0i = a[idx5 + 1] + a[idx2 + 1]; x1r = a[idx5] - a[idx2]; x1i = a[idx5 + 1] - a[idx2 + 1]; y0r = a[idx5 + 2] + a[idx2 + 2]; y0i = a[idx5 + 3] + a[idx2 + 3]; y1r = a[idx5 + 2] - a[idx2 + 2]; y1i = a[idx5 + 3] - a[idx2 + 3]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; y2r = a[idx1 + 2] + a[idx3 + 2]; y2i = a[idx1 + 3] + a[idx3 + 3]; y3r = a[idx1 + 2] - a[idx3 + 2]; y3i = a[idx1 + 3] - a[idx3 + 3]; a[idx5] = x0r + x2r; a[idx5 + 1] = x0i + x2i; a[idx5 + 2] = y0r + y2r; a[idx5 + 3] = y0i + y2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; a[idx1 + 2] = y0r - y2r; a[idx1 + 3] = y0i - y2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wk1r * x0r - wk1i * x0i; a[idx2 + 1] = wk1r * x0i + wk1i * x0r; x0r = y1r - y3i; x0i = y1i + y3r; a[idx2 + 2] = wd1r * x0r - wd1i * x0i; a[idx2 + 3] = wd1r * x0i + wd1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = wk3r * x0r + wk3i * x0i; a[idx3 + 1] = wk3r * x0i - wk3i * x0r; x0r = y1r + y3i; x0i = y1i - y3r; a[idx3 + 2] = wd3r * x0r + wd3i * x0i; a[idx3 + 3] = wd3r * x0i - wd3i * x0r; j0 = m - j; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] + a[idx2]; x0i = a[idx0 + 1] + a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = a[idx0 + 1] - a[idx2 + 1]; y0r = a[idx0 - 2] + a[idx2 - 2]; y0i = a[idx0 - 1] + a[idx2 - 1]; y1r = a[idx0 - 2] - a[idx2 - 2]; y1i = a[idx0 - 1] - a[idx2 - 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; y2r = a[idx1 - 2] + a[idx3 - 2]; y2i = a[idx1 - 1] + a[idx3 - 1]; y3r = a[idx1 - 2] - a[idx3 - 2]; y3i = a[idx1 - 1] - a[idx3 - 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i + x2i; a[idx0 - 2] = y0r + y2r; a[idx0 - 1] = y0i + y2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; a[idx1 - 2] = y0r - y2r; a[idx1 - 1] = y0i - y2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wk1i * x0r - wk1r * x0i; a[idx2 + 1] = wk1i * x0i + wk1r * x0r; x0r = y1r - y3i; x0i = y1i + y3r; a[idx2 - 2] = wd1i * x0r - wd1r * x0i; a[idx2 - 1] = wd1i * x0i + wd1r * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = wk3i * x0r + wk3r * x0i; a[idx3 + 1] = wk3i * x0i - wk3r * x0r; x0r = y1r + y3i; x0i = y1i - y3r; a[offa + j3 - 2] = wd3i * x0r + wd3r * x0i; a[offa + j3 - 1] = wd3i * x0i - wd3r * x0r; } wk1r = csc1 * (wd1r + wn4r); wk1i = csc1 * (wd1i + wn4r); wk3r = csc3 * (wd3r - wn4r); wk3i = csc3 * (wd3i - wn4r); j0 = mh; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0 - 2] + a[idx2 - 2]; x0i = a[idx0 - 1] + a[idx2 - 1]; x1r = a[idx0 - 2] - a[idx2 - 2]; x1i = a[idx0 - 1] - a[idx2 - 1]; x2r = a[idx1 - 2] + a[idx3 - 2]; x2i = a[idx1 - 1] + a[idx3 - 1]; x3r = a[idx1 - 2] - a[idx3 - 2]; x3i = a[idx1 - 1] - a[idx3 - 1]; a[idx0 - 2] = x0r + x2r; a[idx0 - 1] = x0i + x2i; a[idx1 - 2] = x0r - x2r; a[idx1 - 1] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2 - 2] = wk1r * x0r - wk1i * x0i; a[idx2 - 1] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3 - 2] = wk3r * x0r + wk3i * x0i; a[idx3 - 1] = wk3r * x0i - wk3i * x0r; x0r = a[idx0] + a[idx2]; x0i = a[idx0 + 1] + a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = a[idx0 + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wn4r * (x0r - x0i); a[idx2 + 1] = wn4r * (x0i + x0r); x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = -wn4r * (x0r + x0i); a[idx3 + 1] = -wn4r * (x0i - x0r); x0r = a[idx0 + 2] + a[idx2 + 2]; x0i = a[idx0 + 3] + a[idx2 + 3]; x1r = a[idx0 + 2] - a[idx2 + 2]; x1i = a[idx0 + 3] - a[idx2 + 3]; x2r = a[idx1 + 2] + a[idx3 + 2]; x2i = a[idx1 + 3] + a[idx3 + 3]; x3r = a[idx1 + 2] - a[idx3 + 2]; x3i = a[idx1 + 3] - a[idx3 + 3]; a[idx0 + 2] = x0r + x2r; a[idx0 + 3] = x0i + x2i; a[idx1 + 2] = x0r - x2r; a[idx1 + 3] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2 + 2] = wk1i * x0r - wk1r * x0i; a[idx2 + 3] = wk1i * x0i + wk1r * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3 + 2] = wk3i * x0r + wk3r * x0i; a[idx3 + 3] = wk3i * x0i - wk3r * x0r; } private void cftb1st(int n, float[] a, int offa, float[] w, int startw) { int j0, j1, j2, j3, k, m, mh; float wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i; int idx0, idx1, idx2, idx3, idx4, idx5; mh = n >> 3; m = 2 * mh; j1 = m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[offa] + a[idx2]; x0i = -a[offa + 1] - a[idx2 + 1]; x1r = a[offa] - a[idx2]; x1i = -a[offa + 1] + a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[offa] = x0r + x2r; a[offa + 1] = x0i - x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i + x2i; a[idx2] = x1r + x3i; a[idx2 + 1] = x1i + x3r; a[idx3] = x1r - x3i; a[idx3 + 1] = x1i - x3r; wn4r = w[startw + 1]; csc1 = w[startw + 2]; csc3 = w[startw + 3]; wd1r = 1; wd1i = 0; wd3r = 1; wd3i = 0; k = 0; for (int j = 2; j < mh - 2; j += 4) { k += 4; idx4 = startw + k; wk1r = csc1 * (wd1r + w[idx4]); wk1i = csc1 * (wd1i + w[idx4 + 1]); wk3r = csc3 * (wd3r + w[idx4 + 2]); wk3i = csc3 * (wd3i + w[idx4 + 3]); wd1r = w[idx4]; wd1i = w[idx4 + 1]; wd3r = w[idx4 + 2]; wd3i = w[idx4 + 3]; j1 = j + m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; idx5 = offa + j; x0r = a[idx5] + a[idx2]; x0i = -a[idx5 + 1] - a[idx2 + 1]; x1r = a[idx5] - a[offa + j2]; x1i = -a[idx5 + 1] + a[idx2 + 1]; y0r = a[idx5 + 2] + a[idx2 + 2]; y0i = -a[idx5 + 3] - a[idx2 + 3]; y1r = a[idx5 + 2] - a[idx2 + 2]; y1i = -a[idx5 + 3] + a[idx2 + 3]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; y2r = a[idx1 + 2] + a[idx3 + 2]; y2i = a[idx1 + 3] + a[idx3 + 3]; y3r = a[idx1 + 2] - a[idx3 + 2]; y3i = a[idx1 + 3] - a[idx3 + 3]; a[idx5] = x0r + x2r; a[idx5 + 1] = x0i - x2i; a[idx5 + 2] = y0r + y2r; a[idx5 + 3] = y0i - y2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i + x2i; a[idx1 + 2] = y0r - y2r; a[idx1 + 3] = y0i + y2i; x0r = x1r + x3i; x0i = x1i + x3r; a[idx2] = wk1r * x0r - wk1i * x0i; a[idx2 + 1] = wk1r * x0i + wk1i * x0r; x0r = y1r + y3i; x0i = y1i + y3r; a[idx2 + 2] = wd1r * x0r - wd1i * x0i; a[idx2 + 3] = wd1r * x0i + wd1i * x0r; x0r = x1r - x3i; x0i = x1i - x3r; a[idx3] = wk3r * x0r + wk3i * x0i; a[idx3 + 1] = wk3r * x0i - wk3i * x0r; x0r = y1r - y3i; x0i = y1i - y3r; a[idx3 + 2] = wd3r * x0r + wd3i * x0i; a[idx3 + 3] = wd3r * x0i - wd3i * x0r; j0 = m - j; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] + a[idx2]; x0i = -a[idx0 + 1] - a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = -a[idx0 + 1] + a[idx2 + 1]; y0r = a[idx0 - 2] + a[idx2 - 2]; y0i = -a[idx0 - 1] - a[idx2 - 1]; y1r = a[idx0 - 2] - a[idx2 - 2]; y1i = -a[idx0 - 1] + a[idx2 - 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; y2r = a[idx1 - 2] + a[idx3 - 2]; y2i = a[idx1 - 1] + a[idx3 - 1]; y3r = a[idx1 - 2] - a[idx3 - 2]; y3i = a[idx1 - 1] - a[idx3 - 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i - x2i; a[idx0 - 2] = y0r + y2r; a[idx0 - 1] = y0i - y2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i + x2i; a[idx1 - 2] = y0r - y2r; a[idx1 - 1] = y0i + y2i; x0r = x1r + x3i; x0i = x1i + x3r; a[idx2] = wk1i * x0r - wk1r * x0i; a[idx2 + 1] = wk1i * x0i + wk1r * x0r; x0r = y1r + y3i; x0i = y1i + y3r; a[idx2 - 2] = wd1i * x0r - wd1r * x0i; a[idx2 - 1] = wd1i * x0i + wd1r * x0r; x0r = x1r - x3i; x0i = x1i - x3r; a[idx3] = wk3i * x0r + wk3r * x0i; a[idx3 + 1] = wk3i * x0i - wk3r * x0r; x0r = y1r - y3i; x0i = y1i - y3r; a[idx3 - 2] = wd3i * x0r + wd3r * x0i; a[idx3 - 1] = wd3i * x0i - wd3r * x0r; } wk1r = csc1 * (wd1r + wn4r); wk1i = csc1 * (wd1i + wn4r); wk3r = csc3 * (wd3r - wn4r); wk3i = csc3 * (wd3i - wn4r); j0 = mh; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0 - 2] + a[idx2 - 2]; x0i = -a[idx0 - 1] - a[idx2 - 1]; x1r = a[idx0 - 2] - a[idx2 - 2]; x1i = -a[idx0 - 1] + a[idx2 - 1]; x2r = a[idx1 - 2] + a[idx3 - 2]; x2i = a[idx1 - 1] + a[idx3 - 1]; x3r = a[idx1 - 2] - a[idx3 - 2]; x3i = a[idx1 - 1] - a[idx3 - 1]; a[idx0 - 2] = x0r + x2r; a[idx0 - 1] = x0i - x2i; a[idx1 - 2] = x0r - x2r; a[idx1 - 1] = x0i + x2i; x0r = x1r + x3i; x0i = x1i + x3r; a[idx2 - 2] = wk1r * x0r - wk1i * x0i; a[idx2 - 1] = wk1r * x0i + wk1i * x0r; x0r = x1r - x3i; x0i = x1i - x3r; a[idx3 - 2] = wk3r * x0r + wk3i * x0i; a[idx3 - 1] = wk3r * x0i - wk3i * x0r; x0r = a[idx0] + a[idx2]; x0i = -a[idx0 + 1] - a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = -a[idx0 + 1] + a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i - x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i + x2i; x0r = x1r + x3i; x0i = x1i + x3r; a[idx2] = wn4r * (x0r - x0i); a[idx2 + 1] = wn4r * (x0i + x0r); x0r = x1r - x3i; x0i = x1i - x3r; a[idx3] = -wn4r * (x0r + x0i); a[idx3 + 1] = -wn4r * (x0i - x0r); x0r = a[idx0 + 2] + a[idx2 + 2]; x0i = -a[idx0 + 3] - a[idx2 + 3]; x1r = a[idx0 + 2] - a[idx2 + 2]; x1i = -a[idx0 + 3] + a[idx2 + 3]; x2r = a[idx1 + 2] + a[idx3 + 2]; x2i = a[idx1 + 3] + a[idx3 + 3]; x3r = a[idx1 + 2] - a[idx3 + 2]; x3i = a[idx1 + 3] - a[idx3 + 3]; a[idx0 + 2] = x0r + x2r; a[idx0 + 3] = x0i - x2i; a[idx1 + 2] = x0r - x2r; a[idx1 + 3] = x0i + x2i; x0r = x1r + x3i; x0i = x1i + x3r; a[idx2 + 2] = wk1i * x0r - wk1r * x0i; a[idx2 + 3] = wk1i * x0i + wk1r * x0r; x0r = x1r - x3i; x0i = x1i - x3r; a[idx3 + 2] = wk3i * x0r + wk3r * x0i; a[idx3 + 3] = wk3i * x0i - wk3r * x0r; } private void cftrec4(int n, float[] a, int offa, int nw, float[] w) { int isplt, j, k, m; m = n; int idx1 = offa + n; while (m > 512) { m >>= 2; cftmdl1(m, a, idx1 - m, w, nw - (m >> 1)); } cftleaf(m, 1, a, idx1 - m, nw, w); k = 0; int idx2 = offa - m; for (j = n - m; j > 0; j -= m) { k++; isplt = cfttree(m, j, k, a, offa, nw, w); cftleaf(m, isplt, a, idx2 + j, nw, w); } } private int cfttree(int n, int j, int k, float[] a, int offa, int nw, float[] w) { int i, isplt, m; int idx1 = offa - n; if ((k & 3) != 0) { isplt = k & 1; if (isplt != 0) { cftmdl1(n, a, idx1 + j, w, nw - (n >> 1)); } else { cftmdl2(n, a, idx1 + j, w, nw - n); } } else { m = n; for (i = k; (i & 3) == 0; i >>= 2) { m <<= 2; } isplt = i & 1; int idx2 = offa + j; if (isplt != 0) { while (m > 128) { cftmdl1(m, a, idx2 - m, w, nw - (m >> 1)); m >>= 2; } } else { while (m > 128) { cftmdl2(m, a, idx2 - m, w, nw - m); m >>= 2; } } } return isplt; } private void cftleaf(int n, int isplt, float[] a, int offa, int nw, float[] w) { if (n == 512) { cftmdl1(128, a, offa, w, nw - 64); cftf161(a, offa, w, nw - 8); cftf162(a, offa + 32, w, nw - 32); cftf161(a, offa + 64, w, nw - 8); cftf161(a, offa + 96, w, nw - 8); cftmdl2(128, a, offa + 128, w, nw - 128); cftf161(a, offa + 128, w, nw - 8); cftf162(a, offa + 160, w, nw - 32); cftf161(a, offa + 192, w, nw - 8); cftf162(a, offa + 224, w, nw - 32); cftmdl1(128, a, offa + 256, w, nw - 64); cftf161(a, offa + 256, w, nw - 8); cftf162(a, offa + 288, w, nw - 32); cftf161(a, offa + 320, w, nw - 8); cftf161(a, offa + 352, w, nw - 8); if (isplt != 0) { cftmdl1(128, a, offa + 384, w, nw - 64); cftf161(a, offa + 480, w, nw - 8); } else { cftmdl2(128, a, offa + 384, w, nw - 128); cftf162(a, offa + 480, w, nw - 32); } cftf161(a, offa + 384, w, nw - 8); cftf162(a, offa + 416, w, nw - 32); cftf161(a, offa + 448, w, nw - 8); } else { cftmdl1(64, a, offa, w, nw - 32); cftf081(a, offa, w, nw - 8); cftf082(a, offa + 16, w, nw - 8); cftf081(a, offa + 32, w, nw - 8); cftf081(a, offa + 48, w, nw - 8); cftmdl2(64, a, offa + 64, w, nw - 64); cftf081(a, offa + 64, w, nw - 8); cftf082(a, offa + 80, w, nw - 8); cftf081(a, offa + 96, w, nw - 8); cftf082(a, offa + 112, w, nw - 8); cftmdl1(64, a, offa + 128, w, nw - 32); cftf081(a, offa + 128, w, nw - 8); cftf082(a, offa + 144, w, nw - 8); cftf081(a, offa + 160, w, nw - 8); cftf081(a, offa + 176, w, nw - 8); if (isplt != 0) { cftmdl1(64, a, offa + 192, w, nw - 32); cftf081(a, offa + 240, w, nw - 8); } else { cftmdl2(64, a, offa + 192, w, nw - 64); cftf082(a, offa + 240, w, nw - 8); } cftf081(a, offa + 192, w, nw - 8); cftf082(a, offa + 208, w, nw - 8); cftf081(a, offa + 224, w, nw - 8); } } private void cftmdl1(int n, float[] a, int offa, float[] w, int startw) { int j0, j1, j2, j3, k, m, mh; float wn4r, wk1r, wk1i, wk3r, wk3i; float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; int idx0, idx1, idx2, idx3, idx4, idx5; mh = n >> 3; m = 2 * mh; j1 = m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[offa] + a[idx2]; x0i = a[offa + 1] + a[idx2 + 1]; x1r = a[offa] - a[idx2]; x1i = a[offa + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[offa] = x0r + x2r; a[offa + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; a[idx2] = x1r - x3i; a[idx2 + 1] = x1i + x3r; a[idx3] = x1r + x3i; a[idx3 + 1] = x1i - x3r; wn4r = w[startw + 1]; k = 0; for (int j = 2; j < mh; j += 2) { k += 4; idx4 = startw + k; wk1r = w[idx4]; wk1i = w[idx4 + 1]; wk3r = w[idx4 + 2]; wk3i = w[idx4 + 3]; j1 = j + m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; idx5 = offa + j; x0r = a[idx5] + a[idx2]; x0i = a[idx5 + 1] + a[idx2 + 1]; x1r = a[idx5] - a[idx2]; x1i = a[idx5 + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[idx5] = x0r + x2r; a[idx5 + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wk1r * x0r - wk1i * x0i; a[idx2 + 1] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = wk3r * x0r + wk3i * x0i; a[idx3 + 1] = wk3r * x0i - wk3i * x0r; j0 = m - j; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] + a[idx2]; x0i = a[idx0 + 1] + a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = a[idx0 + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wk1i * x0r - wk1r * x0i; a[idx2 + 1] = wk1i * x0i + wk1r * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = wk3i * x0r + wk3r * x0i; a[idx3 + 1] = wk3i * x0i - wk3r * x0r; } j0 = mh; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] + a[idx2]; x0i = a[idx0 + 1] + a[idx2 + 1]; x1r = a[idx0] - a[idx2]; x1i = a[idx0 + 1] - a[idx2 + 1]; x2r = a[idx1] + a[idx3]; x2i = a[idx1 + 1] + a[idx3 + 1]; x3r = a[idx1] - a[idx3]; x3i = a[idx1 + 1] - a[idx3 + 1]; a[idx0] = x0r + x2r; a[idx0 + 1] = x0i + x2i; a[idx1] = x0r - x2r; a[idx1 + 1] = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; a[idx2] = wn4r * (x0r - x0i); a[idx2 + 1] = wn4r * (x0i + x0r); x0r = x1r + x3i; x0i = x1i - x3r; a[idx3] = -wn4r * (x0r + x0i); a[idx3 + 1] = -wn4r * (x0i - x0r); } private void cftmdl2(int n, float[] a, int offa, float[] w, int startw) { int j0, j1, j2, j3, k, kr, m, mh; float wn4r, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y2r, y2i; int idx0, idx1, idx2, idx3, idx4, idx5, idx6; mh = n >> 3; m = 2 * mh; wn4r = w[startw + 1]; j1 = m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[offa] - a[idx2 + 1]; x0i = a[offa + 1] + a[idx2]; x1r = a[offa] + a[idx2 + 1]; x1i = a[offa + 1] - a[idx2]; x2r = a[idx1] - a[idx3 + 1]; x2i = a[idx1 + 1] + a[idx3]; x3r = a[idx1] + a[idx3 + 1]; x3i = a[idx1 + 1] - a[idx3]; y0r = wn4r * (x2r - x2i); y0i = wn4r * (x2i + x2r); a[offa] = x0r + y0r; a[offa + 1] = x0i + y0i; a[idx1] = x0r - y0r; a[idx1 + 1] = x0i - y0i; y0r = wn4r * (x3r - x3i); y0i = wn4r * (x3i + x3r); a[idx2] = x1r - y0i; a[idx2 + 1] = x1i + y0r; a[idx3] = x1r + y0i; a[idx3 + 1] = x1i - y0r; k = 0; kr = 2 * m; for (int j = 2; j < mh; j += 2) { k += 4; idx4 = startw + k; wk1r = w[idx4]; wk1i = w[idx4 + 1]; wk3r = w[idx4 + 2]; wk3i = w[idx4 + 3]; kr -= 4; idx5 = startw + kr; wd1i = w[idx5]; wd1r = w[idx5 + 1]; wd3i = w[idx5 + 2]; wd3r = w[idx5 + 3]; j1 = j + m; j2 = j1 + m; j3 = j2 + m; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; idx6 = offa + j; x0r = a[idx6] - a[idx2 + 1]; x0i = a[idx6 + 1] + a[idx2]; x1r = a[idx6] + a[idx2 + 1]; x1i = a[idx6 + 1] - a[idx2]; x2r = a[idx1] - a[idx3 + 1]; x2i = a[idx1 + 1] + a[idx3]; x3r = a[idx1] + a[idx3 + 1]; x3i = a[idx1 + 1] - a[idx3]; y0r = wk1r * x0r - wk1i * x0i; y0i = wk1r * x0i + wk1i * x0r; y2r = wd1r * x2r - wd1i * x2i; y2i = wd1r * x2i + wd1i * x2r; a[idx6] = y0r + y2r; a[idx6 + 1] = y0i + y2i; a[idx1] = y0r - y2r; a[idx1 + 1] = y0i - y2i; y0r = wk3r * x1r + wk3i * x1i; y0i = wk3r * x1i - wk3i * x1r; y2r = wd3r * x3r + wd3i * x3i; y2i = wd3r * x3i - wd3i * x3r; a[idx2] = y0r + y2r; a[idx2 + 1] = y0i + y2i; a[idx3] = y0r - y2r; a[idx3 + 1] = y0i - y2i; j0 = m - j; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] - a[idx2 + 1]; x0i = a[idx0 + 1] + a[idx2]; x1r = a[idx0] + a[idx2 + 1]; x1i = a[idx0 + 1] - a[idx2]; x2r = a[idx1] - a[idx3 + 1]; x2i = a[idx1 + 1] + a[idx3]; x3r = a[idx1] + a[idx3 + 1]; x3i = a[idx1 + 1] - a[idx3]; y0r = wd1i * x0r - wd1r * x0i; y0i = wd1i * x0i + wd1r * x0r; y2r = wk1i * x2r - wk1r * x2i; y2i = wk1i * x2i + wk1r * x2r; a[idx0] = y0r + y2r; a[idx0 + 1] = y0i + y2i; a[idx1] = y0r - y2r; a[idx1 + 1] = y0i - y2i; y0r = wd3i * x1r + wd3r * x1i; y0i = wd3i * x1i - wd3r * x1r; y2r = wk3i * x3r + wk3r * x3i; y2i = wk3i * x3i - wk3r * x3r; a[idx2] = y0r + y2r; a[idx2 + 1] = y0i + y2i; a[idx3] = y0r - y2r; a[idx3 + 1] = y0i - y2i; } wk1r = w[startw + m]; wk1i = w[startw + m + 1]; j0 = mh; j1 = j0 + m; j2 = j1 + m; j3 = j2 + m; idx0 = offa + j0; idx1 = offa + j1; idx2 = offa + j2; idx3 = offa + j3; x0r = a[idx0] - a[idx2 + 1]; x0i = a[idx0 + 1] + a[idx2]; x1r = a[idx0] + a[idx2 + 1]; x1i = a[idx0 + 1] - a[idx2]; x2r = a[idx1] - a[idx3 + 1]; x2i = a[idx1 + 1] + a[idx3]; x3r = a[idx1] + a[idx3 + 1]; x3i = a[idx1 + 1] - a[idx3]; y0r = wk1r * x0r - wk1i * x0i; y0i = wk1r * x0i + wk1i * x0r; y2r = wk1i * x2r - wk1r * x2i; y2i = wk1i * x2i + wk1r * x2r; a[idx0] = y0r + y2r; a[idx0 + 1] = y0i + y2i; a[idx1] = y0r - y2r; a[idx1 + 1] = y0i - y2i; y0r = wk1i * x1r - wk1r * x1i; y0i = wk1i * x1i + wk1r * x1r; y2r = wk1r * x3r - wk1i * x3i; y2i = wk1r * x3i + wk1i * x3r; a[idx2] = y0r - y2r; a[idx2 + 1] = y0i - y2i; a[idx3] = y0r + y2r; a[idx3 + 1] = y0i + y2i; } private void cftfx41(int n, float[] a, int offa, int nw, float[] w) { if (n == 128) { cftf161(a, offa, w, nw - 8); cftf162(a, offa + 32, w, nw - 32); cftf161(a, offa + 64, w, nw - 8); cftf161(a, offa + 96, w, nw - 8); } else { cftf081(a, offa, w, nw - 8); cftf082(a, offa + 16, w, nw - 8); cftf081(a, offa + 32, w, nw - 8); cftf081(a, offa + 48, w, nw - 8); } } private void cftf161(float[] a, int offa, float[] w, int startw) { float wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i, y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i, y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i; wn4r = w[startw + 1]; wk1r = w[startw + 2]; wk1i = w[startw + 3]; x0r = a[offa] + a[offa + 16]; x0i = a[offa + 1] + a[offa + 17]; x1r = a[offa] - a[offa + 16]; x1i = a[offa + 1] - a[offa + 17]; x2r = a[offa + 8] + a[offa + 24]; x2i = a[offa + 9] + a[offa + 25]; x3r = a[offa + 8] - a[offa + 24]; x3i = a[offa + 9] - a[offa + 25]; y0r = x0r + x2r; y0i = x0i + x2i; y4r = x0r - x2r; y4i = x0i - x2i; y8r = x1r - x3i; y8i = x1i + x3r; y12r = x1r + x3i; y12i = x1i - x3r; x0r = a[offa + 2] + a[offa + 18]; x0i = a[offa + 3] + a[offa + 19]; x1r = a[offa + 2] - a[offa + 18]; x1i = a[offa + 3] - a[offa + 19]; x2r = a[offa + 10] + a[offa + 26]; x2i = a[offa + 11] + a[offa + 27]; x3r = a[offa + 10] - a[offa + 26]; x3i = a[offa + 11] - a[offa + 27]; y1r = x0r + x2r; y1i = x0i + x2i; y5r = x0r - x2r; y5i = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; y9r = wk1r * x0r - wk1i * x0i; y9i = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; y13r = wk1i * x0r - wk1r * x0i; y13i = wk1i * x0i + wk1r * x0r; x0r = a[offa + 4] + a[offa + 20]; x0i = a[offa + 5] + a[offa + 21]; x1r = a[offa + 4] - a[offa + 20]; x1i = a[offa + 5] - a[offa + 21]; x2r = a[offa + 12] + a[offa + 28]; x2i = a[offa + 13] + a[offa + 29]; x3r = a[offa + 12] - a[offa + 28]; x3i = a[offa + 13] - a[offa + 29]; y2r = x0r + x2r; y2i = x0i + x2i; y6r = x0r - x2r; y6i = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; y10r = wn4r * (x0r - x0i); y10i = wn4r * (x0i + x0r); x0r = x1r + x3i; x0i = x1i - x3r; y14r = wn4r * (x0r + x0i); y14i = wn4r * (x0i - x0r); x0r = a[offa + 6] + a[offa + 22]; x0i = a[offa + 7] + a[offa + 23]; x1r = a[offa + 6] - a[offa + 22]; x1i = a[offa + 7] - a[offa + 23]; x2r = a[offa + 14] + a[offa + 30]; x2i = a[offa + 15] + a[offa + 31]; x3r = a[offa + 14] - a[offa + 30]; x3i = a[offa + 15] - a[offa + 31]; y3r = x0r + x2r; y3i = x0i + x2i; y7r = x0r - x2r; y7i = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; y11r = wk1i * x0r - wk1r * x0i; y11i = wk1i * x0i + wk1r * x0r; x0r = x1r + x3i; x0i = x1i - x3r; y15r = wk1r * x0r - wk1i * x0i; y15i = wk1r * x0i + wk1i * x0r; x0r = y12r - y14r; x0i = y12i - y14i; x1r = y12r + y14r; x1i = y12i + y14i; x2r = y13r - y15r; x2i = y13i - y15i; x3r = y13r + y15r; x3i = y13i + y15i; a[offa + 24] = x0r + x2r; a[offa + 25] = x0i + x2i; a[offa + 26] = x0r - x2r; a[offa + 27] = x0i - x2i; a[offa + 28] = x1r - x3i; a[offa + 29] = x1i + x3r; a[offa + 30] = x1r + x3i; a[offa + 31] = x1i - x3r; x0r = y8r + y10r; x0i = y8i + y10i; x1r = y8r - y10r; x1i = y8i - y10i; x2r = y9r + y11r; x2i = y9i + y11i; x3r = y9r - y11r; x3i = y9i - y11i; a[offa + 16] = x0r + x2r; a[offa + 17] = x0i + x2i; a[offa + 18] = x0r - x2r; a[offa + 19] = x0i - x2i; a[offa + 20] = x1r - x3i; a[offa + 21] = x1i + x3r; a[offa + 22] = x1r + x3i; a[offa + 23] = x1i - x3r; x0r = y5r - y7i; x0i = y5i + y7r; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); x0r = y5r + y7i; x0i = y5i - y7r; x3r = wn4r * (x0r - x0i); x3i = wn4r * (x0i + x0r); x0r = y4r - y6i; x0i = y4i + y6r; x1r = y4r + y6i; x1i = y4i - y6r; a[offa + 8] = x0r + x2r; a[offa + 9] = x0i + x2i; a[offa + 10] = x0r - x2r; a[offa + 11] = x0i - x2i; a[offa + 12] = x1r - x3i; a[offa + 13] = x1i + x3r; a[offa + 14] = x1r + x3i; a[offa + 15] = x1i - x3r; x0r = y0r + y2r; x0i = y0i + y2i; x1r = y0r - y2r; x1i = y0i - y2i; x2r = y1r + y3r; x2i = y1i + y3i; x3r = y1r - y3r; x3i = y1i - y3i; a[offa] = x0r + x2r; a[offa + 1] = x0i + x2i; a[offa + 2] = x0r - x2r; a[offa + 3] = x0i - x2i; a[offa + 4] = x1r - x3i; a[offa + 5] = x1i + x3r; a[offa + 6] = x1r + x3i; a[offa + 7] = x1i - x3r; } private void cftf162(float[] a, int offa, float[] w, int startw) { float wn4r, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, x0r, x0i, x1r, x1i, x2r, x2i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i, y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i, y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i; wn4r = w[startw + 1]; wk1r = w[startw + 4]; wk1i = w[startw + 5]; wk3r = w[startw + 6]; wk3i = -w[startw + 7]; wk2r = w[startw + 8]; wk2i = w[startw + 9]; x1r = a[offa] - a[offa + 17]; x1i = a[offa + 1] + a[offa + 16]; x0r = a[offa + 8] - a[offa + 25]; x0i = a[offa + 9] + a[offa + 24]; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); y0r = x1r + x2r; y0i = x1i + x2i; y4r = x1r - x2r; y4i = x1i - x2i; x1r = a[offa] + a[offa + 17]; x1i = a[offa + 1] - a[offa + 16]; x0r = a[offa + 8] + a[offa + 25]; x0i = a[offa + 9] - a[offa + 24]; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); y8r = x1r - x2i; y8i = x1i + x2r; y12r = x1r + x2i; y12i = x1i - x2r; x0r = a[offa + 2] - a[offa + 19]; x0i = a[offa + 3] + a[offa + 18]; x1r = wk1r * x0r - wk1i * x0i; x1i = wk1r * x0i + wk1i * x0r; x0r = a[offa + 10] - a[offa + 27]; x0i = a[offa + 11] + a[offa + 26]; x2r = wk3i * x0r - wk3r * x0i; x2i = wk3i * x0i + wk3r * x0r; y1r = x1r + x2r; y1i = x1i + x2i; y5r = x1r - x2r; y5i = x1i - x2i; x0r = a[offa + 2] + a[offa + 19]; x0i = a[offa + 3] - a[offa + 18]; x1r = wk3r * x0r - wk3i * x0i; x1i = wk3r * x0i + wk3i * x0r; x0r = a[offa + 10] + a[offa + 27]; x0i = a[offa + 11] - a[offa + 26]; x2r = wk1r * x0r + wk1i * x0i; x2i = wk1r * x0i - wk1i * x0r; y9r = x1r - x2r; y9i = x1i - x2i; y13r = x1r + x2r; y13i = x1i + x2i; x0r = a[offa + 4] - a[offa + 21]; x0i = a[offa + 5] + a[offa + 20]; x1r = wk2r * x0r - wk2i * x0i; x1i = wk2r * x0i + wk2i * x0r; x0r = a[offa + 12] - a[offa + 29]; x0i = a[offa + 13] + a[offa + 28]; x2r = wk2i * x0r - wk2r * x0i; x2i = wk2i * x0i + wk2r * x0r; y2r = x1r + x2r; y2i = x1i + x2i; y6r = x1r - x2r; y6i = x1i - x2i; x0r = a[offa + 4] + a[offa + 21]; x0i = a[offa + 5] - a[offa + 20]; x1r = wk2i * x0r - wk2r * x0i; x1i = wk2i * x0i + wk2r * x0r; x0r = a[offa + 12] + a[offa + 29]; x0i = a[offa + 13] - a[offa + 28]; x2r = wk2r * x0r - wk2i * x0i; x2i = wk2r * x0i + wk2i * x0r; y10r = x1r - x2r; y10i = x1i - x2i; y14r = x1r + x2r; y14i = x1i + x2i; x0r = a[offa + 6] - a[offa + 23]; x0i = a[offa + 7] + a[offa + 22]; x1r = wk3r * x0r - wk3i * x0i; x1i = wk3r * x0i + wk3i * x0r; x0r = a[offa + 14] - a[offa + 31]; x0i = a[offa + 15] + a[offa + 30]; x2r = wk1i * x0r - wk1r * x0i; x2i = wk1i * x0i + wk1r * x0r; y3r = x1r + x2r; y3i = x1i + x2i; y7r = x1r - x2r; y7i = x1i - x2i; x0r = a[offa + 6] + a[offa + 23]; x0i = a[offa + 7] - a[offa + 22]; x1r = wk1i * x0r + wk1r * x0i; x1i = wk1i * x0i - wk1r * x0r; x0r = a[offa + 14] + a[offa + 31]; x0i = a[offa + 15] - a[offa + 30]; x2r = wk3i * x0r - wk3r * x0i; x2i = wk3i * x0i + wk3r * x0r; y11r = x1r + x2r; y11i = x1i + x2i; y15r = x1r - x2r; y15i = x1i - x2i; x1r = y0r + y2r; x1i = y0i + y2i; x2r = y1r + y3r; x2i = y1i + y3i; a[offa] = x1r + x2r; a[offa + 1] = x1i + x2i; a[offa + 2] = x1r - x2r; a[offa + 3] = x1i - x2i; x1r = y0r - y2r; x1i = y0i - y2i; x2r = y1r - y3r; x2i = y1i - y3i; a[offa + 4] = x1r - x2i; a[offa + 5] = x1i + x2r; a[offa + 6] = x1r + x2i; a[offa + 7] = x1i - x2r; x1r = y4r - y6i; x1i = y4i + y6r; x0r = y5r - y7i; x0i = y5i + y7r; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); a[offa + 8] = x1r + x2r; a[offa + 9] = x1i + x2i; a[offa + 10] = x1r - x2r; a[offa + 11] = x1i - x2i; x1r = y4r + y6i; x1i = y4i - y6r; x0r = y5r + y7i; x0i = y5i - y7r; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); a[offa + 12] = x1r - x2i; a[offa + 13] = x1i + x2r; a[offa + 14] = x1r + x2i; a[offa + 15] = x1i - x2r; x1r = y8r + y10r; x1i = y8i + y10i; x2r = y9r - y11r; x2i = y9i - y11i; a[offa + 16] = x1r + x2r; a[offa + 17] = x1i + x2i; a[offa + 18] = x1r - x2r; a[offa + 19] = x1i - x2i; x1r = y8r - y10r; x1i = y8i - y10i; x2r = y9r + y11r; x2i = y9i + y11i; a[offa + 20] = x1r - x2i; a[offa + 21] = x1i + x2r; a[offa + 22] = x1r + x2i; a[offa + 23] = x1i - x2r; x1r = y12r - y14i; x1i = y12i + y14r; x0r = y13r + y15i; x0i = y13i - y15r; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); a[offa + 24] = x1r + x2r; a[offa + 25] = x1i + x2i; a[offa + 26] = x1r - x2r; a[offa + 27] = x1i - x2i; x1r = y12r + y14i; x1i = y12i - y14r; x0r = y13r - y15i; x0i = y13i + y15r; x2r = wn4r * (x0r - x0i); x2i = wn4r * (x0i + x0r); a[offa + 28] = x1r - x2i; a[offa + 29] = x1i + x2r; a[offa + 30] = x1r + x2i; a[offa + 31] = x1i - x2r; } private void cftf081(float[] a, int offa, float[] w, int startw) { float wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i; wn4r = w[startw + 1]; x0r = a[offa] + a[offa + 8]; x0i = a[offa + 1] + a[offa + 9]; x1r = a[offa] - a[offa + 8]; x1i = a[offa + 1] - a[offa + 9]; x2r = a[offa + 4] + a[offa + 12]; x2i = a[offa + 5] + a[offa + 13]; x3r = a[offa + 4] - a[offa + 12]; x3i = a[offa + 5] - a[offa + 13]; y0r = x0r + x2r; y0i = x0i + x2i; y2r = x0r - x2r; y2i = x0i - x2i; y1r = x1r - x3i; y1i = x1i + x3r; y3r = x1r + x3i; y3i = x1i - x3r; x0r = a[offa + 2] + a[offa + 10]; x0i = a[offa + 3] + a[offa + 11]; x1r = a[offa + 2] - a[offa + 10]; x1i = a[offa + 3] - a[offa + 11]; x2r = a[offa + 6] + a[offa + 14]; x2i = a[offa + 7] + a[offa + 15]; x3r = a[offa + 6] - a[offa + 14]; x3i = a[offa + 7] - a[offa + 15]; y4r = x0r + x2r; y4i = x0i + x2i; y6r = x0r - x2r; y6i = x0i - x2i; x0r = x1r - x3i; x0i = x1i + x3r; x2r = x1r + x3i; x2i = x1i - x3r; y5r = wn4r * (x0r - x0i); y5i = wn4r * (x0r + x0i); y7r = wn4r * (x2r - x2i); y7i = wn4r * (x2r + x2i); a[offa + 8] = y1r + y5r; a[offa + 9] = y1i + y5i; a[offa + 10] = y1r - y5r; a[offa + 11] = y1i - y5i; a[offa + 12] = y3r - y7i; a[offa + 13] = y3i + y7r; a[offa + 14] = y3r + y7i; a[offa + 15] = y3i - y7r; a[offa] = y0r + y4r; a[offa + 1] = y0i + y4i; a[offa + 2] = y0r - y4r; a[offa + 3] = y0i - y4i; a[offa + 4] = y2r - y6i; a[offa + 5] = y2i + y6r; a[offa + 6] = y2r + y6i; a[offa + 7] = y2i - y6r; } private void cftf082(float[] a, int offa, float[] w, int startw) { float wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i; wn4r = w[startw + 1]; wk1r = w[startw + 2]; wk1i = w[startw + 3]; y0r = a[offa] - a[offa + 9]; y0i = a[offa + 1] + a[offa + 8]; y1r = a[offa] + a[offa + 9]; y1i = a[offa + 1] - a[offa + 8]; x0r = a[offa + 4] - a[offa + 13]; x0i = a[offa + 5] + a[offa + 12]; y2r = wn4r * (x0r - x0i); y2i = wn4r * (x0i + x0r); x0r = a[offa + 4] + a[offa + 13]; x0i = a[offa + 5] - a[offa + 12]; y3r = wn4r * (x0r - x0i); y3i = wn4r * (x0i + x0r); x0r = a[offa + 2] - a[offa + 11]; x0i = a[offa + 3] + a[offa + 10]; y4r = wk1r * x0r - wk1i * x0i; y4i = wk1r * x0i + wk1i * x0r; x0r = a[offa + 2] + a[offa + 11]; x0i = a[offa + 3] - a[offa + 10]; y5r = wk1i * x0r - wk1r * x0i; y5i = wk1i * x0i + wk1r * x0r; x0r = a[offa + 6] - a[offa + 15]; x0i = a[offa + 7] + a[offa + 14]; y6r = wk1i * x0r - wk1r * x0i; y6i = wk1i * x0i + wk1r * x0r; x0r = a[offa + 6] + a[offa + 15]; x0i = a[offa + 7] - a[offa + 14]; y7r = wk1r * x0r - wk1i * x0i; y7i = wk1r * x0i + wk1i * x0r; x0r = y0r + y2r; x0i = y0i + y2i; x1r = y4r + y6r; x1i = y4i + y6i; a[offa] = x0r + x1r; a[offa + 1] = x0i + x1i; a[offa + 2] = x0r - x1r; a[offa + 3] = x0i - x1i; x0r = y0r - y2r; x0i = y0i - y2i; x1r = y4r - y6r; x1i = y4i - y6i; a[offa + 4] = x0r - x1i; a[offa + 5] = x0i + x1r; a[offa + 6] = x0r + x1i; a[offa + 7] = x0i - x1r; x0r = y1r - y3i; x0i = y1i + y3r; x1r = y5r - y7r; x1i = y5i - y7i; a[offa + 8] = x0r + x1r; a[offa + 9] = x0i + x1i; a[offa + 10] = x0r - x1r; a[offa + 11] = x0i - x1i; x0r = y1r + y3i; x0i = y1i - y3r; x1r = y5r + y7r; x1i = y5i + y7i; a[offa + 12] = x0r - x1i; a[offa + 13] = x0i + x1r; a[offa + 14] = x0r + x1i; a[offa + 15] = x0i - x1r; } private void cftf040(float[] a, int offa) { float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; x0r = a[offa] + a[offa + 4]; x0i = a[offa + 1] + a[offa + 5]; x1r = a[offa] - a[offa + 4]; x1i = a[offa + 1] - a[offa + 5]; x2r = a[offa + 2] + a[offa + 6]; x2i = a[offa + 3] + a[offa + 7]; x3r = a[offa + 2] - a[offa + 6]; x3i = a[offa + 3] - a[offa + 7]; a[offa] = x0r + x2r; a[offa + 1] = x0i + x2i; a[offa + 2] = x1r - x3i; a[offa + 3] = x1i + x3r; a[offa + 4] = x0r - x2r; a[offa + 5] = x0i - x2i; a[offa + 6] = x1r + x3i; a[offa + 7] = x1i - x3r; } private void cftb040(float[] a, int offa) { float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; x0r = a[offa] + a[offa + 4]; x0i = a[offa + 1] + a[offa + 5]; x1r = a[offa] - a[offa + 4]; x1i = a[offa + 1] - a[offa + 5]; x2r = a[offa + 2] + a[offa + 6]; x2i = a[offa + 3] + a[offa + 7]; x3r = a[offa + 2] - a[offa + 6]; x3i = a[offa + 3] - a[offa + 7]; a[offa] = x0r + x2r; a[offa + 1] = x0i + x2i; a[offa + 2] = x1r + x3i; a[offa + 3] = x1i - x3r; a[offa + 4] = x0r - x2r; a[offa + 5] = x0i - x2i; a[offa + 6] = x1r - x3i; a[offa + 7] = x1i + x3r; } private void cftx020(float[] a, int offa) { float x0r, x0i; x0r = a[offa] - a[offa + 2]; x0i = -a[offa + 1] + a[offa + 3]; a[offa] += a[offa + 2]; a[offa + 1] += a[offa + 3]; a[offa + 2] = x0r; a[offa + 3] = x0i; } private void cftxb020(float[] a, int offa) { float x0r, x0i; x0r = a[offa] - a[offa + 2]; x0i = a[offa + 1] - a[offa + 3]; a[offa] += a[offa + 2]; a[offa + 1] += a[offa + 3]; a[offa + 2] = x0r; a[offa + 3] = x0i; } private void cftxc020(float[] a, int offa) { float x0r, x0i; x0r = a[offa] - a[offa + 2]; x0i = a[offa + 1] + a[offa + 3]; a[offa] += a[offa + 2]; a[offa + 1] -= a[offa + 3]; a[offa + 2] = x0r; a[offa + 3] = x0i; } private void rftfsub(int n, float[] a, int offa, int nc, float[] c, int startc) { int k, kk, ks, m; float wkr, wki, xr, xi, yr, yi; int idx1, idx2; m = n >> 1; ks = 2 * nc / m; kk = 0; for (int j = 2; j < m; j += 2) { k = n - j; kk += ks; wkr = 0.5f - c[startc + nc - kk]; wki = c[startc + kk]; idx1 = offa + j; idx2 = offa + k; xr = a[idx1] - a[idx2]; xi = a[idx1 + 1] + a[idx2 + 1]; yr = wkr * xr - wki * xi; yi = wkr * xi + wki * xr; a[idx1] -= yr; a[idx1 + 1] = yi - a[idx1 + 1]; a[idx2] += yr; a[idx2 + 1] = yi - a[idx2 + 1]; } a[offa + m + 1] = -a[offa + m + 1]; } private void rftbsub(int n, float[] a, int offa, int nc, float[] c, int startc) { int k, kk, ks, m; float wkr, wki, xr, xi, yr, yi; int idx1, idx2; m = n >> 1; ks = 2 * nc / m; kk = 0; for (int j = 2; j < m; j += 2) { k = n - j; kk += ks; wkr = 0.5f - c[startc + nc - kk]; wki = c[startc + kk]; idx1 = offa + j; idx2 = offa + k; xr = a[idx1] - a[idx2]; xi = a[idx1 + 1] + a[idx2 + 1]; yr = wkr * xr - wki * xi; yi = wkr * xi + wki * xr; a[idx1] -= yr; a[idx1 + 1] -= yi; a[idx2] += yr; a[idx2 + 1] -= yi; } } private void scale(final float m, final float[] a, int offa, boolean complex) { final float norm = (1.0f / m); int n2; if (complex) { n2 = 2 * n; } else { n2 = n; } for (int i = offa; i < offa + n2; i++) { a[i] *= norm; } } }
[ "peter.abeles@gmail.com" ]
peter.abeles@gmail.com
20123aefb9d35f149ac060eaa0aea77cce128f1f
bdff55a6242b7af145180eb3e0218b1fec8810bc
/TestApplication/app/src/androidTest/java/com/yanxuwen/testapplication/ExampleInstrumentedTest.java
0da8577d3135d8f951550f768650b541dd640e11
[]
no_license
yanxuwen/MyDrawer
36b6ce9782c00522893f9edc2bdaf83dcba8ba53
06e88a255c5179e9b90b4cd23ebc7e45bfdb3974
refs/heads/master
2021-05-14T09:31:01.156466
2021-03-08T08:10:13
2021-03-08T08:10:13
116,328,981
45
8
null
null
null
null
UTF-8
Java
false
false
760
java
package com.yanxuwen.testapplication; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumentation test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.yanxuwen.testapplication", appContext.getPackageName()); } }
[ "420255048@qq.com" ]
420255048@qq.com
74c6d88e60aa558dbb4770514c7a0e98fe031fb5
3489be05b9d4f5cc99027ee016fda0cc5886bbbf
/CodingPractice/CrackingTheCodingInterview/moderate/numberSwap.java
dc162e537ef59fe7e030087598eccccff54debfa
[]
no_license
praveenkuruvadi/CodingPracticeBackup
30ee2c3982903990da4967e6cb4358be6b546b76
2f04657a932f77b2b06490e0633c5595397ac0ed
refs/heads/master
2020-12-30T17:11:02.384121
2017-11-07T16:27:41
2017-11-07T16:27:41
91,061,499
0
0
null
null
null
null
UTF-8
Java
false
false
442
java
package moderate; public class numberSwap { public static void main(String[] args) { // TODO Auto-generated method stub int[] input = {28,34}; System.out.println(input[0]+" "+input[1]); swapNums(input); System.out.println("After Swap: "+input[0]+" "+input[1]); } private static void swapNums(int[] arr) { // TODO Auto-generated method stub arr[0] = arr[0]+arr[1]; arr[1] = arr[0]-arr[1]; arr[0] = arr[0]-arr[1]; } }
[ "praveen.kuruvadi@gmail.com" ]
praveen.kuruvadi@gmail.com
cd3a874b9bbec6e2ace031c5fbf700fcf71c195c
259c3453f6b3ed7c91d225103f43cbffef8db600
/src/main/java/com/crm/crm/model/ContactController.java
3e197b33846d86265f8b74a6dc7c4544636c87f4
[]
no_license
mpechkurov/spring-react-example
507b2bfa08a3f7e64cd0531f1200171937f2a44f
86e19fa458f943aa51ba02c50df04837bc6d6831
refs/heads/master
2022-12-25T23:25:12.121349
2020-10-07T18:04:00
2020-10-07T18:04:00
297,085,261
0
0
null
null
null
null
UTF-8
Java
false
false
1,220
java
package com.crm.crm.model; import java.net.URISyntaxException; import java.util.Collection; import javax.validation.Valid; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api") @CrossOrigin(origins = "http://localhost:3000") public class ContactController { private ContacRepository contacRepository; public ContactController(ContacRepository contacRepository){ this.contacRepository = contacRepository; } @GetMapping("/contacts") Collection<Contact> contacts(){ return (Collection<Contact>) contacRepository.findAll(); } @PostMapping("/contacts") ResponseEntity<Contact> createContact(@Valid @RequestBody Contact contact) throws URISyntaxException{ Contact result = contacRepository.save(contact); return ResponseEntity.ok().body(result); } }
[ "mykhailo.pechkurov@gmail.com" ]
mykhailo.pechkurov@gmail.com
6513a4a365c02062eb8c4aba8ee9d4314e8a661b
d84c3b0c717c5fb70109a79b9853d81cccadb058
/src/weixin/mp/util/json/WxMpMassVideoAdapter.java
bbc3b09d074a4bcdcb151906dbc9ced06fd7d43d
[]
no_license
bournecao24/SuperETUF
179bf2dd196dcab89fa6652a6fe97a1920a02fbb
c6b2292e3440cb50fdc9f7702ed3f632663d4a28
refs/heads/master
2021-09-03T10:14:03.918087
2018-01-08T09:41:51
2018-01-08T09:41:51
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,195
java
/* * KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved. * * This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended * only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction * arose from modification of the original source, or other redistribution of this source * is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD. */ package weixin.mp.util.json; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import weixin.mp.bean.WxMpMassVideo; import java.lang.reflect.Type; /** * @author Daniel Qian */ public class WxMpMassVideoAdapter implements JsonSerializer<WxMpMassVideo> { @Override public JsonElement serialize(WxMpMassVideo message, Type typeOfSrc, JsonSerializationContext context) { JsonObject messageJson = new JsonObject(); messageJson.addProperty("media_id", message.getMediaId()); messageJson.addProperty("description", message.getDescription()); messageJson.addProperty("title", message.getTitle()); return messageJson; } }
[ "zhenlongla0824@163.com" ]
zhenlongla0824@163.com
4f4775045c0f05cf7e51096436044a595e0cb702
e2ca9545bcae8e701381dcc2578eae9d87ddf456
/src/faspayapi/credit/entity/payment/FaspayPaymentCreditWrapperDev.java
880f6acdd9cbedb48aba0ec687b89e17f155d95e
[]
no_license
hilmanshini/FaspayApi
e3a4591aa6ff03f58d5fc3728772bc3ec92385d4
e5c65d0ea189152122710d918ad4cb76618cee71
refs/heads/master
2020-06-03T14:46:31.755486
2019-07-04T06:52:42
2019-07-04T06:52:42
191,611,602
4
0
null
null
null
null
UTF-8
Java
false
false
19,360
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package faspayapi.credit.entity.payment; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import faspayapi.credit.FaspayUserCredit; import faspayapi.credit.TetsUser; import faspayapi.credit.TetsUser2; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditBillData; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditCardData; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditConfigApp; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditDomicileData; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditItemData; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditShippingdata; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditShopperData; import faspayapi.credit.entity.payment.wrapper.FaspayPaymentCreditTransactionData; import java.io.FileOutputStream; import java.text.DecimalFormat; import java.util.Iterator; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import okhttp3.Call; import okhttp3.FormBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.json.JSONObject; /** * * @author hilmananwarsah */ public class FaspayPaymentCreditWrapperDev extends FaspayPaymentCreditDev { String pymt_ind = ""; String pymt_criteria = ""; String pymt_token = ""; public String getPymt_token() { return pymt_token; } public void setPymt_token(String pymt_token) { this.pymt_token = pymt_token; } public String getPymt_ind() { return pymt_ind; } public void setPymt_ind(String pymt_ind) { this.pymt_ind = pymt_ind; } public String getPymt_criteria() { return pymt_criteria; } public void setPymt_criteria(String pymt_criteria) { this.pymt_criteria = pymt_criteria; } FaspayPaymentCreditShopperData shopperData; /** * * * TODO PYMT_IND, PYMT_CRITERIA in PROD */ FaspayPaymentCreditConfigApp app; FaspayUserCredit user; FaspayPaymentCreditTransactionData transactionData; FaspayPaymentCreditBillData billData; FaspayPaymentCreditShippingdata shippingdata; FaspayPaymentCreditItemData itemData; FaspayPaymentCreditDomicileData domicileData; FaspayPaymentCreditCardData cardData; public FaspayPaymentCreditWrapperDev(FaspayUserCredit user, FaspayPaymentCreditTransactionData transactionData, FaspayPaymentCreditShopperData shopperData, FaspayPaymentCreditConfigApp app, FaspayPaymentCreditBillData billData, FaspayPaymentCreditShippingdata shippingdata, FaspayPaymentCreditItemData itemData, FaspayPaymentCreditDomicileData domicileData, FaspayPaymentCreditCardData cardData) { this.cardData = cardData; this.domicileData = domicileData; this.shippingdata = shippingdata; this.itemData = itemData; this.app = app; this.billData = billData; this.user = user; this.transactionData = transactionData; this.shopperData = shopperData; setMerchantid(user.getMerchantId()); setMerchant_tranid(transactionData.getMerchant_tranid()); //PYMT IND //PYMT CRIT setCurrencycode(transactionData.getCurrencycode()); DecimalFormat decimalFormat = new DecimalFormat("#.00"); setAmount(decimalFormat.format(transactionData.getAmount())); setSignature(transactionData.getSignature()); } public String getCard_issuer_bank() { return cardData.getCard_issuer_bank(); } public void setCard_issuer_bank(String card_issuer_bank) { cardData.setCard_issuer_bank(card_issuer_bank); } public String getCard_identity_ref_type() { return cardData.getCard_identity_ref_type(); } public void setCard_identity_ref_type(String card_identity_ref_type) { cardData.setCard_identity_ref_type(card_identity_ref_type); } public String getCard_identity_ref() { return cardData.getCard_identity_ref(); } public void setCard_identity_ref(String card_identity_ref) { cardData.setCard_identity_ref(card_identity_ref); } public String getCard_phone() { return cardData.getCard_phone(); } public void setCard_phone(String card_phone) { cardData.setCard_phone(card_phone); } public String getCard_bill_addr() { return cardData.getCard_bill_addr(); } public void setCard_bill_addr(String card_bill_addr) { cardData.setCard_bill_addr(card_bill_addr); } public String getCard_bill_addr_poscode() { return cardData.getCard_bill_addr_poscode(); } public void setCard_bill_addr_poscode(String card_bill_addr_poscode) { cardData.setCard_bill_addr_poscode(card_bill_addr_poscode); } public String getCard_bill_addr_city() { return cardData.getCard_bill_addr_city(); } public void setCard_bill_addr_city(String card_bill_addr_city) { cardData.setCard_bill_addr_city(card_bill_addr_city); } public String getCard_bill_addr_region() { return cardData.getCard_bill_addr_region(); } public void setCard_bill_addr_region(String card_bill_addr_region) { cardData.setCard_bill_addr_region(card_bill_addr_region); } public String getCard_bill_addr_state() { return cardData.getCard_bill_addr_state(); } public void setCard_bill_addr_state(String card_bill_addr_state) { cardData.setCard_bill_addr_state(card_bill_addr_state); } public String getCard_bill_addr_country_code() { return cardData.getCard_bill_addr_country_code(); } public void setCard_bill_addr_country_code(String card_bill_addr_country_code) { cardData.setCard_bill_addr_country_code(card_bill_addr_country_code); } public String getCard_email() { return cardData.getCard_email(); } public void setCard_email(String card_email) { cardData.setCard_email(card_email); } public String getHandshake_url() { return app.getHandshake_url(); } public void setHandshake_url(String handshake_url) { app.setHandshake_url(handshake_url); } public String getHandshake_param() { return app.getHandshake_param(); } public void setHandshake_param(String handshake_param) { app.setHandshake_param(handshake_param); } public String getDomicile_address() { return domicileData.getDomicile_address(); } public void setDomicile_address(String domicile_address) { domicileData.setDomicile_address(domicile_address); } public String getDomicile_address_city() { return domicileData.getDomicile_address_city(); } public void setDomicile_address_city(String domicile_address_city) { domicileData.setDomicile_address_city(domicile_address_city); } public String getDomicile_address_region() { return domicileData.getDomicile_address_region(); } public void setDomicile_address_region(String domicile_address_region) { domicileData.setDomicile_address_region(domicile_address_region); } public String getDomicile_address_state() { return domicileData.getDomicile_address_state(); } public void setDomicile_address_state(String domicile_address_state) { domicileData.setDomicile_address_state(domicile_address_state); } public String getDomicile_address_poscode() { return domicileData.getDomicile_address_poscode(); } public void setDomicile_address_poscode(String domicile_address_poscode) { domicileData.setDomicile_address_poscode(domicile_address_poscode); } public String getDomicile_address_country_code() { return domicileData.getDomicile_address_country_code(); } public void setDomicile_address_country_code(String domicile_address_country_code) { domicileData.setDomicile_address_country_code(domicile_address_country_code); } public String getDomicile_phone_no() { return domicileData.getDomicile_phone_no(); } public void setDomicile_phone_no(String domicile_phone_no) { domicileData.setDomicile_phone_no(domicile_phone_no); } public String getFrisk1() { return app.getFrisk1(); } public void setFrisk1(String frisk1) { app.setFrisk1(frisk1); } public String getFrisk2() { return app.getFrisk2(); } public void setFrisk2(String frisk2) { app.setFrisk2(frisk2); } public String getMparam1() { return app.getMparam1(); } public void setMparam1(String mparam1) { app.setMparam1(mparam1); } public String getMparam2() { return app.getMparam2(); } public void setMparam2(String mparam2) { app.setMparam2(mparam2); } public String getResponse_type() { return app.getResponse_type(); } public void setResponse_type(String response_type) { app.setResponse_type(response_type); } public String getReturn_url() { return app.getReturn_url(); } public void setReturn_url(String return_url) { app.setReturn_url(return_url); } public String getCustomer_ref() { return shopperData.getCustomer_ref(); } public void setCustomer_ref(String customer_ref) { shopperData.setCustomer_ref(customer_ref); } public String getCustname() { return shopperData.getCustname(); } public void setCustname(String custname) { shopperData.setCustname(custname); } public String getCustemail() { return shopperData.getCustemail(); } public void setCustemail(String custemail) { shopperData.setCustemail(custemail); } public String getShopper_ip() { return shopperData.getShopper_ip(); } public void setShopper_ip(String shopper_ip) { shopperData.setShopper_ip(shopper_ip); } public String getDescription() { return shopperData.getDescription(); } public void setDescription(String description) { shopperData.setDescription(description); } public String getCardno() { return shopperData.getCardno(); } public void setCardno(String cardno) { shopperData.setCardno(cardno); } public String getCardname() { return shopperData.getCardname(); } public void setCardname(String cardname) { shopperData.setCardname(cardname); } public String getCardtype() { return String.valueOf(shopperData.getCardtype()); } public void setCardtype(String cardtype) { } public String getExpirymonth() { return shopperData.getExpirymonth(); } public void setExpirymonth(String expirymonth) { shopperData.setExpirymonth(expirymonth); } public String getExpiryyear() { return shopperData.getExpiryyear(); } public void setExpiryyear(String expiryyear) { shopperData.setExpiryyear(expiryyear); } public String getCardcvc() { return shopperData.getCardcvc(); } public void setCardcvc(String cardcvc) { shopperData.setCardcvc(cardcvc); } public String getCard_issuer_bank_country_code() { return shopperData.getCard_issuer_bank_country_code(); } public void setCard_issuer_bank_country_code(String card_issuer_bank_country_code) { shopperData.setCard_issuer_bank_country_code(card_issuer_bank_country_code); } public String getPhone_no() { return shopperData.getPhone_no(); } public void setPhone_no(String phone_no) { shopperData.setPhone_no(phone_no); } public String getBilling_address() { return billData.getBilling_address(); } public void setBilling_address(String billing_address) { billData.setBilling_address(billing_address); } public String getBilling_address_city() { return billData.getBilling_address_city(); } public void setBilling_address_city(String billing_address_city) { billData.setBilling_address_city(billing_address_city); } public String getBilling_address_region() { return billData.getBilling_address_region(); } public void setBilling_address_region(String billing_address_region) { billData.setBilling_address_region(billing_address_region); } public String getBilling_address_state() { return billData.getBilling_address_state(); } public void setBilling_address_state(String billing_address_state) { billData.setBilling_address_state(billing_address_state); } public String getBilling_address_poscode() { return billData.getBilling_address_poscode(); } public void setBilling_address_poscode(String billing_address_poscode) { billData.setBilling_address_poscode(billing_address_poscode); } public String getBilling_address_country_code() { return billData.getBilling_address_country_code(); } public void setBilling_address_country_code(String billing_address_country_code) { billData.setBilling_address_country_code(billing_address_country_code); } public String getReceiver_name_for_shipping() { return shippingdata.getReceiver_name_for_shipping(); } public void setReceiver_name_for_shipping(String receiver_name_for_shipping) { shippingdata.setReceiver_name_for_shipping(receiver_name_for_shipping); } public String getShipping_address() { return shippingdata.getShipping_address(); } public void setShipping_address(String shipping_address) { shippingdata.setShipping_address(shipping_address); } public String getShipping_address_city() { return shippingdata.getShipping_address_city(); } public void setShipping_address_city(String shipping_address_city) { shippingdata.setShipping_address_city(shipping_address_city); } public String getShipping_address_region() { return shippingdata.getShipping_address_region(); } public void setShipping_address_region(String shipping_address_region) { shippingdata.setShipping_address_region(shipping_address_region); } public String getShipping_address_state() { return shippingdata.getShipping_address_state(); } public void setShipping_address_state(String shipping_address_state) { shippingdata.setShipping_address_state(shipping_address_state); } public String getShipping_address_poscode() { return shippingdata.getShipping_address_poscode(); } public void setShipping_address_poscode(String shipping_address_poscode) { shippingdata.setShipping_address_poscode(shipping_address_poscode); } public String getShipping_address_country_code() { return shippingdata.getShipping_address_country_code(); } public void setShipping_address_country_code(String shipping_address_country_code) { shippingdata.setShipping_address_country_code(shipping_address_country_code); } public String getShippingcost() { return shippingdata.getShippingcost(); } public void setShippingcost(String shippingcost) { shippingdata.setShippingcost(shippingcost); } public String getMref1() { return itemData.getMref1(); } public void setMref1(String mref1) { itemData.setMref1(mref1); } public String getMref2() { return itemData.getMref2(); } public void setMref2(String mref2) { itemData.setMref2(mref2); } public String getMref3() { return itemData.getMref3(); } public void setMref3(String mref3) { itemData.setMref3(mref3); } public String getMref4() { return itemData.getMref4(); } public void setMref4(String mref4) { itemData.setMref4(mref4); } public String getMref5() { return itemData.getMref5(); } public void setMref5(String mref5) { itemData.setMref5(mref5); } public String getMref6() { return itemData.getMref6(); } public void setMref6(String mref6) { itemData.setMref6(mref6); } public String getMref7() { return itemData.getMref7(); } public void setMref7(String mref7) { itemData.setMref7(mref7); } public String getMref8() { return itemData.getMref8(); } public void setMref8(String mref8) { itemData.setMref8(mref8); } public String getMref9() { return itemData.getMref9(); } public void setMref9(String mref9) { itemData.setMref9(mref9); } public String getMref10() { return itemData.getMref10(); } public void setMref10(String mref10) { itemData.setMref10(mref10); } public String getTxn_password() { return user.getPass(); } public void setTxn_password(String txn_password) { } public static void main(String[] args) { FaspayUserCredit usr = new TetsUser2(); FaspayPaymentCreditWrapperDev w = new FaspayPaymentCreditWrapperDev(usr, new FaspayPaymentCreditTransactionData(usr, UUID.randomUUID().toString().replaceAll("-", ""), "IDR", 100000), new FaspayPaymentCreditShopperData("ha", "ha@ha.com", "123123123123", "123123", "5123456789012346", "123123", CARD_TYPE_VISA, 10, "2020", "123123"), new FaspayPaymentCreditConfigApp(RESPONSE_TYPE_POST, "http://programmermiskin.chickenkiller.com/faspay/api/notify"), new FaspayPaymentCreditBillData("123", "123", "123", "123", "123", "ID"), new FaspayPaymentCreditShippingdata("5", "5", "5", "5", "5", "5", 0), new FaspayPaymentCreditItemData("Baju koko robet"), new FaspayPaymentCreditDomicileData(), new FaspayPaymentCreditCardData()); JSONObject o; try { o = new JSONObject(new ObjectMapper().writeValueAsString(w)); o.remove("cardno"); o.remove("CARDNO"); Iterator<String> e = o.keys(); OkHttpClient client = new OkHttpClient(new OkHttpClient.Builder()); FormBody.Builder g = new FormBody.Builder(); while (e.hasNext()) { String next = e.next(); String val; if (!o.isNull(next)) { val = o.getString(next); } else { val = ""; } g.addEncoded(next.toUpperCase(), val.replace(' ', '+')); } w.generateHtml("//Users/hilmananwarsah/test123.html"); } catch (Exception ex) { Logger.getLogger(FaspayPaymentCreditWrapperDev.class.getName()).log(Level.SEVERE, null, ex); } } }
[ "hilmansphinx@gmail.com" ]
hilmansphinx@gmail.com
bbdff1e177adf10f144603ff18c836e251c7a5e9
a1512b2d7e833a5559a4cfc5115d4ff259d48356
/addons/jobs/jobs-service/src/main/java/org/kie/kogito/jobs/service/repository/infinispan/marshaller/JobMarshaller.java
e57fc8556f08b7345b599648e8bd7fcd6e946c15
[ "Apache-2.0" ]
permissive
DuncanDoyle/kogito-runtimes
626ddb12381ee6703d24a6d25cd076cdbef58509
d1b38bfe640adf76b99f0652ccbe5055435e7ede
refs/heads/master
2020-09-17T03:36:22.395550
2019-11-22T20:27:58
2019-11-22T20:27:58
223,974,262
0
0
Apache-2.0
2019-11-25T14:57:42
2019-11-25T14:57:41
null
UTF-8
Java
false
false
2,820
java
/* * Copyright 2019 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.kie.kogito.jobs.service.repository.infinispan.marshaller; import java.io.IOException; import java.time.ZonedDateTime; import org.kie.kogito.jobs.api.Job; import org.kie.kogito.jobs.api.JobBuilder; public class JobMarshaller extends BaseMarshaller<Job> { @Override public String getTypeName() { return getPackage() + ".Job"; } @Override public Class<? extends Job> getJavaClass() { return Job.class; } @Override public void writeTo(ProtoStreamWriter writer, Job job) throws IOException { writer.writeString("id", job.getId()); writer.writeString("callbackEndpoint", job.getCallbackEndpoint()); writer.writeInstant("expirationTime", zonedDateTimeToInstant(job.getExpirationTime())); writer.writeInt("priority", job.getPriority()); writer.writeString("processId", job.getProcessId()); writer.writeString("processInstanceId", job.getProcessInstanceId()); writer.writeString("rootProcessId", job.getRootProcessId()); writer.writeString("rootProcessInstanceId", job.getRootProcessInstanceId()); } @Override public Job readFrom(ProtoStreamReader reader) throws IOException { String id = reader.readString("id"); String callbackEndpoint = reader.readString("callbackEndpoint"); ZonedDateTime expirationTime = instantToZonedDateTime(reader.readInstant("expirationTime")); Integer priority = reader.readInt("priority"); String processId = reader.readString("processId"); String processInstanceId = reader.readString("processInstanceId"); String rootProcessId = reader.readString("rootProcessId"); String rootProcessInstanceId = reader.readString("rootProcessInstanceId"); return JobBuilder.builder() .callbackEndpoint(callbackEndpoint) .id(id) .expirationTime(expirationTime) .priority(priority) .processId(processId) .processInstanceId(processInstanceId) .rootProcessId(rootProcessId) .rootProcessInstanceId(rootProcessInstanceId) .build(); } }
[ "swiderski.maciej@gmail.com" ]
swiderski.maciej@gmail.com
301515e793fcce6552057a51105737fb8c88614e
b967c6f64152a0df7b85b28acae2f36f7cb3e6fb
/sc-App/src/main/java/com/caicongyang/springcloudapp/wushuaiping/factory/PreConnection.java
be2a6b36607189c6b8f46ed6bc6629520d31f334
[]
no_license
dobiao/springcloud-practice
85be398808204a1b7e9641882d4be046856ccc04
31fef39893aa7a20e86bd680148704ed18abdb06
refs/heads/master
2021-04-06T10:47:21.976971
2018-03-15T13:19:09
2018-03-15T13:19:09
124,840,085
6
4
null
null
null
null
UTF-8
Java
false
false
365
java
package com.caicongyang.springcloudapp.wushuaiping.factory; /** * 连接预发环境数据库 * @author wushuaiping * @date 2018/3/11 下午2:39 */ public class PreConnection implements DatabaseConnection { public void connection() { // 连接预发环境数据库的逻辑代码 System.out.println("预发环境连接成功..."); } }
[ "wb-wsp312690@alibaba-inc.com" ]
wb-wsp312690@alibaba-inc.com
4b80a6f1a61555620e4e730c04d61d328918c5b7
2557011e0fb182a3f4b581b487ff76b558010e32
/E-Walletfinal/src/main/java/com/capgemini/ewallet/controller/TransactionController.java
d6344fba1252644bc1c3b5859d35fc6cea340367
[]
no_license
akshitabajpai/EwalletIntegrated
f9d4369676025ca56a8d08defadbfdf657bd287a
56c9d0bcabcd6e47953c105688a85fa1c9d78638
refs/heads/master
2022-09-17T01:05:09.832962
2020-05-24T14:50:19
2020-05-24T14:50:19
266,557,629
0
0
null
null
null
null
UTF-8
Java
false
false
1,676
java
package com.capgemini.ewallet.controller; import java.util.List; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.BindingResult; import org.springframework.validation.FieldError; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.capgemini.ewallet.entity.WalletTransaction; import com.capgemini.ewallet.exception.TransactionException; import com.capgemini.ewallet.service.TransactionServiceImpl; @CrossOrigin("http://localhost:4200") @RestController @RequestMapping("/transaction") public class TransactionController { @Autowired TransactionServiceImpl transactionService; @PostMapping(value = "/transfer", consumes = { "application/json" }) public boolean transferMoney(@RequestBody WalletTransaction transfer) { return transactionService.TransferAmount(transfer); } @GetMapping(value = "/history/{senderId}") public List<WalletTransaction> transactionHistory(@PathVariable int senderId) { // to find a account by id List<WalletTransaction> history = transactionService.transactionHistory(senderId); return history; } }
[ "DELL@DESKTOP-FRIMMDM" ]
DELL@DESKTOP-FRIMMDM
28b78e9217eea62f91268c54477ad881b49cb070
cf61582eaf20048fdae28dc61fa975f2f23a3fc4
/src/com/briup/jdk8/day2/Test03_Function.java
df2781c96200045e9ab99c93c6a058819f290509
[]
no_license
chlinlearn/jd1903_java
8d8eff7e204770c36985b830292f743b7b889a5a
bbdac2bfa5b9bb1db4cd1f4a6661c969adad3ddb
refs/heads/master
2020-06-05T18:28:00.348972
2019-07-05T07:32:19
2019-07-05T07:32:19
192,510,455
0
0
null
null
null
null
UTF-8
Java
false
false
1,161
java
package com.briup.jdk8.day2; /* * * @author: xuchunlin * @createTime: 2019/7/4/14:44 * @description: null */ import java.util.function.Function; public class Test03_Function { public static void main(String[] args) { Function<String,Integer> f = new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }; int n = f.apply("123"); System.out.println(n); Function<Integer,String> f2 = Integer::toBinaryString; //num->Integer.toBinaryString(num); String str = f2.apply(12); System.out.println(str); Function<Model,String> f3 = Model::getName; Function<String,Model> f4 = Model::new; Model model = f4.apply("lucy"); String name = f3.apply(model); System.out.println(name); //String "10" --> Integer -->Model System.out.println("------------"); Function<String,Integer> f5 = Integer::parseInt; Function<Integer,Model> f6 = age->new Model(age); //Function<Model,String> f7 = f5.andThen(f6); } }
[ "1573196748@qq.com" ]
1573196748@qq.com
a18be90cb0bef589c835512c77d72591c59c7e43
2b927681efb48c64d75451b4735aced06f38f066
/org.xtext.example.md3/src-gen/org/xtext/example/mydsl2/services/Md3GrammarAccess.java
9ff6720c3eb50cb62a2e3c84290e1d09b45ac108
[]
no_license
tfLabs/live3
fa0de647509189482b845b1fcd62aebfceb5445a
3e82511280dc3df97e2e2a1aefee33335a93e94e
refs/heads/master
2022-07-29T20:39:22.131396
2020-05-20T15:10:07
2020-05-20T15:10:07
265,601,402
0
0
null
null
null
null
UTF-8
Java
false
false
5,211
java
/* * generated by Xtext 2.20.0 */ package org.xtext.example.mydsl2.services; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; import org.eclipse.xtext.Assignment; import org.eclipse.xtext.Grammar; import org.eclipse.xtext.GrammarUtil; import org.eclipse.xtext.Group; import org.eclipse.xtext.Keyword; import org.eclipse.xtext.ParserRule; import org.eclipse.xtext.RuleCall; import org.eclipse.xtext.TerminalRule; import org.eclipse.xtext.common.services.TerminalsGrammarAccess; import org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder; import org.eclipse.xtext.service.GrammarProvider; @Singleton public class Md3GrammarAccess extends AbstractGrammarElementFinder { public class ModelElements extends AbstractParserRuleElementFinder { private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.xtext.example.mydsl2.Md3.Model"); private final Assignment cGreetingsAssignment = (Assignment)rule.eContents().get(1); private final RuleCall cGreetingsGreetingParserRuleCall_0 = (RuleCall)cGreetingsAssignment.eContents().get(0); //Model: // greetings+=Greeting*; @Override public ParserRule getRule() { return rule; } //greetings+=Greeting* public Assignment getGreetingsAssignment() { return cGreetingsAssignment; } //Greeting public RuleCall getGreetingsGreetingParserRuleCall_0() { return cGreetingsGreetingParserRuleCall_0; } } public class GreetingElements extends AbstractParserRuleElementFinder { private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.xtext.example.mydsl2.Md3.Greeting"); private final Group cGroup = (Group)rule.eContents().get(1); private final Keyword cHelloKeyword_0 = (Keyword)cGroup.eContents().get(0); private final Assignment cNameAssignment_1 = (Assignment)cGroup.eContents().get(1); private final RuleCall cNameIDTerminalRuleCall_1_0 = (RuleCall)cNameAssignment_1.eContents().get(0); private final Keyword cExclamationMarkKeyword_2 = (Keyword)cGroup.eContents().get(2); //Greeting: // 'Hello' name=ID '!'; @Override public ParserRule getRule() { return rule; } //'Hello' name=ID '!' public Group getGroup() { return cGroup; } //'Hello' public Keyword getHelloKeyword_0() { return cHelloKeyword_0; } //name=ID public Assignment getNameAssignment_1() { return cNameAssignment_1; } //ID public RuleCall getNameIDTerminalRuleCall_1_0() { return cNameIDTerminalRuleCall_1_0; } //'!' public Keyword getExclamationMarkKeyword_2() { return cExclamationMarkKeyword_2; } } private final ModelElements pModel; private final GreetingElements pGreeting; private final Grammar grammar; private final TerminalsGrammarAccess gaTerminals; @Inject public Md3GrammarAccess(GrammarProvider grammarProvider, TerminalsGrammarAccess gaTerminals) { this.grammar = internalFindGrammar(grammarProvider); this.gaTerminals = gaTerminals; this.pModel = new ModelElements(); this.pGreeting = new GreetingElements(); } protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { Grammar grammar = grammarProvider.getGrammar(this); while (grammar != null) { if ("org.xtext.example.mydsl2.Md3".equals(grammar.getName())) { return grammar; } List<Grammar> grammars = grammar.getUsedGrammars(); if (!grammars.isEmpty()) { grammar = grammars.iterator().next(); } else { return null; } } return grammar; } @Override public Grammar getGrammar() { return grammar; } public TerminalsGrammarAccess getTerminalsGrammarAccess() { return gaTerminals; } //Model: // greetings+=Greeting*; public ModelElements getModelAccess() { return pModel; } public ParserRule getModelRule() { return getModelAccess().getRule(); } //Greeting: // 'Hello' name=ID '!'; public GreetingElements getGreetingAccess() { return pGreeting; } public ParserRule getGreetingRule() { return getGreetingAccess().getRule(); } //terminal ID: // '^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; public TerminalRule getIDRule() { return gaTerminals.getIDRule(); } //terminal INT returns ecore::EInt: // '0'..'9'+; public TerminalRule getINTRule() { return gaTerminals.getINTRule(); } //terminal STRING: // '"' ('\\' . | !('\\' | '"'))* '"' | "'" ('\\' . | !('\\' | "'"))* "'"; public TerminalRule getSTRINGRule() { return gaTerminals.getSTRINGRule(); } //terminal ML_COMMENT: // '/*'->'*/'; public TerminalRule getML_COMMENTRule() { return gaTerminals.getML_COMMENTRule(); } //terminal SL_COMMENT: // '//' !('\n' | '\r')* ('\r'? '\n')?; public TerminalRule getSL_COMMENTRule() { return gaTerminals.getSL_COMMENTRule(); } //terminal WS: // ' ' | '\t' | '\r' | '\n'+; public TerminalRule getWSRule() { return gaTerminals.getWSRule(); } //terminal ANY_OTHER: // .; public TerminalRule getANY_OTHERRule() { return gaTerminals.getANY_OTHERRule(); } }
[ "hiro_n@cg7.so-net.ne.jp" ]
hiro_n@cg7.so-net.ne.jp
2ace80dc7adc843b4fcfdd93659ed47fec906287
dee88cf6855132795d2f1ac1125947defb6ecc3c
/src/gms/service/field/FieldNoticeServiceImpl.java
7a7c1548501a1bb13b980861cd97319e5b08d3c2
[]
no_license
ChuckLinsGit/GMS
8bc1760a21ae35fef10235ea82a06c6b0b686359
c0c5c2f7e916f95d4244da81b33428855bc2b863
refs/heads/master
2020-06-15T03:05:07.835606
2019-07-04T09:13:46
2019-07-04T09:13:46
195,188,978
0
0
null
null
null
null
UTF-8
Java
false
false
1,937
java
package gms.service.field; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import gms.DAO.field.FieldNoticeMapper; import gms.entry.field.FieldNotice; import gms.entry.field.NoticeWithFieldname; @Component("FieldNoticeServiceImpl") public class FieldNoticeServiceImpl implements FieldNoticeService { @Autowired private FieldNoticeMapper fieldNoticeDAO; @Transactional @Override public void addFNotice(FieldNotice fn) throws Exception { fieldNoticeDAO.insertNotice(fn); } @Transactional @Override public void delFNotice(Integer noticefid) throws Exception { fieldNoticeDAO.deleteNotice(noticefid); } @Transactional @Override public void changeFNotice(FieldNotice fn) throws Exception { fieldNoticeDAO.updateNotice(fn); } @Transactional @Override public FieldNotice getFNotice(Integer noticefid) throws Exception { return fieldNoticeDAO.selectNoticeById(noticefid); } @Transactional @Override public List<FieldNotice> getAll() throws Exception { return fieldNoticeDAO.selectAll(); } @Transactional @Override public List<FieldNotice> selectNoticeByNameDim(String noticename) throws Exception { return fieldNoticeDAO.selectNoticeByNameDim(noticename); } @Transactional @Override public List<FieldNotice> selectFive() throws Exception { return fieldNoticeDAO.selectFive(); } @Transactional @Override public List<NoticeWithFieldname> selectAllWfieldname() throws Exception { return fieldNoticeDAO.selectAllWfieldname(); } @Transactional @Override public List<NoticeWithFieldname> selectAllWfDeleted() throws Exception { return fieldNoticeDAO.selectAllWfDeleted(); } @Transactional @Override public void recycleNoticeDel(Integer noticefid) throws Exception { fieldNoticeDAO.recycleNotice(noticefid); } }
[ "Chuck_Lin_Mail@163.com" ]
Chuck_Lin_Mail@163.com