blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
439df09c4a757628d7f6be3b5cc0563750754507 | c3169a6548370be74053f900aea46d82b0ca5d5d | /Data Structures/AssociativeArray/RecursiveBST.java | b1438b77f31ecd4388df950ccca64fce64d5f109 | []
| no_license | WardBrian/CS1102 | 75858e59578dd0216766746507142e82151852ba | e6af39d0e8ebd55c30de5f3d76afb9df3a9830c6 | refs/heads/master | 2020-03-23T10:57:56.644451 | 2018-07-18T18:19:57 | 2018-07-18T18:19:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,019 | java | @SuppressWarnings({"rawtypes", "unchecked"})
public class RecursiveBST<Key extends Comparable, Val> implements IAssociativeArray<Key,Val>{
private Node root; // root of BST
private class Node {
private Key key; // sorted by key
private Val val; // associated data
private Node left, right; // left and right subtrees
private int size;
/**
* Dummy field so some of Meng's excercises below compile
**/
private int data;
public Node(Key key, Val val, int size) {
this.key = key;
this.val = val;
this.size = size;
if (key.getClass() == Integer.class){
data = (Integer)key;
}
}
public boolean isLeaf(){
return left == null && right == null;
}
}
public RecursiveBST(){
root = null;
}
public boolean isEmpty(){
return root == null;
}
public int size(){
return size(root);
}
public int size(Node n){
if(n == null) return 0;
return n.size;
}
public Val get(Key key){
return get(root, key);
}
public Val get(Node n, Key key){
if (n == null) return null;
int comp = key.compareTo(n.key);
if(comp < 0) return get(n.left, key);
else if (comp > 0) return get(n.right,key);
else return n.val;
}
public void put(Key key, Val val){
root = put(root, key, val);
}
public Node put(Node n, Key key, Val val){
if(n == null) return new Node(key, val, 1);
int comp = key.compareTo(n.key);
if (comp < 0) n.left = put(n.left, key, val);
else if (comp > 0) n.right = put(n.right, key, val);
else n.val = val;
n.size = size(n.left) + size(n.right) + 1;
return n;
}
public boolean contains(Key key){
return get(key) != null;
}
public Key min(){
return min(root).key;
}
private Node min(Node x){
if (x.left == null) return x;
return min(x.left);
}
private Node deleteMin(Node n){
if (n.left == null) return n.right;
n.left = deleteMin(n.left);
n.size = size(n.left) + size(n.right) + 1;
return n;
}
public void delete(Key key){
root = delete(root, key);
}
public Node delete(Node n, Key key){
if (n == null) return null;
int comp = key.compareTo(n.key);
if (comp < 0) n.left = delete(n.left, key);
else if (comp > 0) n.right = delete(n.right, key);
else {
if(n.right == null) return n.left;
if(n.left == null) return n.right;
Node t = n;
n = min(t.right);
n.right = deleteMin(t.right);
n.left = t.left;
}
n.size = size(n.left) + size(n.right) + 1;
return n;
}
/*
* Some fun with recursive functions
*/
public int countLeaves(){
return countLeaves(root);
}
private int countLeaves(Node n){
if(n == null) return 0;
if(n.isLeaf()) return 1;
return countLeaves(n.left) + countLeaves(n.right);
}
public int getHeight(){
return getHeight(root);
}
private int getHeight(Node n){
if(n == null) return 0;
return 1 + Math.max(getHeight(n.left), getHeight(n.right));
}
// the following only works with integer data, the dummy field "data" was added so this compiles
public int bound(int value){
return bound(value, root, -1);
}
private int bound(int value, Node p, int working){
if(p == null) return working;
if(p.data >= value) return bound(value, p.left, working); //we only care about smaller values, so check left
else /*if(p.data < value)*/{ // if statement ommited for compiler, but is logically equivalent
working = p.data; // this node holds a valid entry, so update our working bound
return bound(value,p.right,working); // only path to check is with bigger values AKA right
}
}
public boolean isBST(){
return isBST(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}
private boolean isBST(Node p, int min, int max){
if(p == null){
return true;
}
if(p.data < min || p.data > max){
return false;
}
return isBST(p.left, min, p.data - 1) && isBST(p.right, p.data + 1, max);
}
public boolean isBST2(){
return isBST2(root);
}
private boolean isBST2(Node p){
if(p == null){
return true;
}
if(p.left != null && p.data < maxValue(p.left)){
return false;
}
if(p.right != null && p.data > minValue(p.right)){
return false;
}
return isBST2(p.left) && isBST2(p.right);
}
private int maxValue(Node n){
if(n.right == null) return n.data;
return maxValue(n.right);
}
private int minValue(Node n){
if(n.left == null) return n.data;
return minValue(n.left);
}
public boolean hasPathSum(int n){
return hasPathSum(root, n);
}
private boolean hasPathSum(Node p, int n){
if(p == null) return false;
if(p.isLeaf()){
return (p.data == n);
}
return hasPathSum(p.left, n - p.data) || hasPathSum(p.right, n - p.data);
}
//pre: a < b
public int countKey(int a, int b){
return countKey(a, b, root);
}
private int countKey(int a, int b, Node n){
if(n == null) return 0;
else if(n.data >= a && n.data <= b) return 1 + countKey(a, b, n.left) + countKey(a,b,n.right);
else if(n.data < a) return countKey(a,b,n.right); //only care about larger nodes, right subtree
else /*if(n.data > b)*/ return countKey(a,b,n.left); //only care about smaller nodes, left subtree
}
}
| [
"[email protected]"
]
| |
10d85559beb99508c6ed2e674dc35067b1c85d52 | afe4788f76a915979c3f645e761a32002de80435 | /src/main/java/resources/ResponseResource.java | 19a5938da75fadf71578b1fb28668dd13b086c9e | []
| no_license | mikrut/tp_2015_02_java_DoDots | 59bbef5c4ba53a5b8ccb0e52bfd0cf0a2f8e8619 | 2698c61444b69090b14d9ee3cd84b760997f04fc | refs/heads/master | 2021-03-12T21:58:44.211005 | 2015-06-06T15:11:51 | 2015-06-06T15:11:51 | 31,475,067 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 526 | java | package resources;
/**
* Created by mihanik
* 07.04.15 8:58
* Package: resources
*/
@SuppressWarnings("UnusedDeclaration")
public class ResponseResource implements Resource {
private String status;
private String message;
private String ok;
private String error;
public String getMessage() {
return message;
}
public String getStatus() {
return status;
}
public String getOk() {
return ok;
}
public String getError() {
return error;
}
}
| [
"[email protected]"
]
| |
849482152851942ceb8853d15ff841820ca6906b | 5f0822f716aa251ea10662dc966cc8318468e27c | /src/main/java/com/alvin/wechat/authtool/WeChatController.java | c5d219e3f6b1c4b7df800aaba99a296e5d84d737 | []
| no_license | jieyoutech/wechat-auth | 98200ea74003e2056bd884456ce4d2d9dc0bd08e | 08b9a10b875ebfe36803155f6c803c4d955a8bdd | refs/heads/master | 2021-09-01T18:34:53.996198 | 2017-12-28T08:19:25 | 2017-12-28T08:19:25 | 115,601,142 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,770 | java | package com.alvin.wechat.authtool;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.alvin.wechat.authtool.util.JsonDB;
import com.alvin.wechat.authtool.util.XmlData;
import com.alvin.wechat.authtool.wechat.EncryptUtil;
import com.alvin.wechat.authtool.wechat.WeChatClient;
import com.qq.weixin.mp.aes.XMLParse;
import com.sun.jersey.api.view.Viewable;
@Path("/")
public class WeChatController {
private static final Logger logger = LogManager.getLogger(WeChatController.class);
private static WeChatClient client = new WeChatClient();
//Http Get
@GET
@Path("/")
public String hello() {
return "hello";
}
//JSP Get
@GET
@Path("/redirect_page")
public Viewable redirectPage(@Context HttpServletRequest request, @Context ServletContext servletContext) throws URISyntaxException, MalformedURLException {
String calbackURL = request.getScheme() + "://" + request.getServerName() + "oardc/wechat/auth_callback";
String code = client.getPreAuthCode();
String param = "?component_appid=" + JsonDB.get("component_app_id") + "&pre_auth_code=" + code
+ "&redirect_uri=" + calbackURL;
request.setAttribute("param", param);
return new Viewable("/jsp/redirect.jsp");
}
//Display auth result
@GET
@Path("auth_callback")
public String redirectPage(@QueryParam("auth_code") String authCode) throws URISyntaxException, MalformedURLException {
return client.getAuthAccessToken(authCode);
}
//Rest Post
@POST
@Path("/authorize/{componentAppId}/callback/trigger")
public String authorize(@PathParam("componentAppId") String componentAppId, String content) {
System.out.println("SYS: got auth request");
logger.info("Logger: got auth request");
try {
String[] extracted = XMLParse.extract(content);
String decryptedXml = EncryptUtil.decryptWeChatMessage(extracted[1]);
XmlData xml = XmlData.parseXML(decryptedXml);
String ticket = xml.getStringByTag("ComponentVerifyTicket");
String accessToken = client.refreshComponentAccessToken(JsonDB.get("component_app_id"),
JsonDB.get("component_app_secret"), ticket);
if (StringUtils.isNotBlank(accessToken)) {
JsonDB.put("component_access_token", accessToken);
} else {
return "failure";
}
} catch (Exception e) {
logger.error("authorize got exception, error = {}", e.getMessage());
return "failure";
}
return "success";
}
}
| [
"[email protected]"
]
| |
cb8ba95d76d85bde617fed98968a67c1acd9599a | 9e8d721737b3620ec09895102fe15644dd253853 | /chapter1/src/com/lss/phase2/ch8/Test.java | 8bd292985e77484087043cf80b8785a1083b5712 | []
| no_license | stephanie-lss/java-concurrency | c23c92297ebd5ea84cbb28f62fa255d2615a08db | 7b1a61fca46afe8fa72d5ce5e76485057676b766 | refs/heads/master | 2022-11-10T15:37:24.316659 | 2020-07-02T05:59:22 | 2020-07-02T05:59:22 | 250,286,084 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 677 | java | package com.lss.phase2.ch8;
/**
* @author LiSheng
* @date 2020/6/26 19:56
*/
public class Test {
public static void main(String[] args) throws InterruptedException {
FutureService futureService = new FutureService();
Future<String> future = futureService.submit(() -> {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "FINISH";
}, System.out::println);
System.out.println("==========");
System.out.println("do other thing.");
Thread.sleep(1000);
System.out.println("==========");
}
}
| [
"[email protected]"
]
| |
2afdd45d0cd08593d2be0d19766f1b15302268a7 | 4cf98017019f983040a00492217a87ed26cf8198 | /lollipop_CardViewEx/src/main/java/idv/david/cardviewex/MainActivity.java | 8ba95058601224623e20a4c96344a50923177608 | []
| no_license | EvanWn2015/Application_David_Demo | 8f0fa5c8168cf2e389539ecc6cf9270629b9a1cd | f3dc27e019982fbccfb2d3605f27ae69d31268cb | refs/heads/master | 2021-01-21T14:40:55.670331 | 2016-07-03T15:20:52 | 2016-07-03T15:20:52 | 58,410,039 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,984 | java | package idv.david.cardviewex;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends ActionBarActivity {
private RecyclerView myRecyclerview;
private RecyclerView.LayoutManager layoutManager;
private TeamAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
}
private void findViews() {
myRecyclerview = (RecyclerView)findViewById(R.id.myRecyclerview);
//設定每個List是否為固定尺寸
myRecyclerview.setHasFixedSize(true);
//產生一個LinearLayoutManger
layoutManager = new LinearLayoutManager(this);
//設定LayoutManger
myRecyclerview.setLayoutManager(layoutManager);
final List<Team> teamList = new ArrayList<>();
teamList.add(new Team(1, R.drawable.p1, "巴爾的摩金鶯"));
teamList.add(new Team(2, R.drawable.p2, "芝加哥白襪"));
teamList.add(new Team(3, R.drawable.p3, "洛杉磯天使"));
teamList.add(new Team(4, R.drawable.p4, "波士頓紅襪"));
teamList.add(new Team(5, R.drawable.p5, "克里夫蘭印地安人"));
teamList.add(new Team(6, R.drawable.p6, "奧克蘭運動家"));
teamList.add(new Team(7, R.drawable.p7, "紐約洋基"));
teamList.add(new Team(8, R.drawable.p8, "底特律老虎"));
teamList.add(new Team(9, R.drawable.p9, "西雅圖水手"));
teamList.add(new Team(10, R.drawable.p10, "坦帕灣光芒"));
adapter = new TeamAdapter(teamList);
myRecyclerview.setAdapter(adapter);
}
private class TeamAdapter extends RecyclerView.Adapter<TeamAdapter.ViewHolder> {
private List<Team> teamList;
public TeamAdapter(List<Team> teamList) {
this.teamList = teamList;
}
//建立ViewHolder,藉由ViewHolder做元件參照
class ViewHolder extends RecyclerView.ViewHolder {
private ImageView ivLogo;
private TextView tvName;
public ViewHolder(View view) {
super(view);
ivLogo = (ImageView)view.findViewById(R.id.ivLogo);
tvName = (TextView)view.findViewById(R.id.tvName);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(getAdapterPosition() == RecyclerView.NO_POSITION) {
Toast.makeText(MainActivity.this, getString(R.string.no_choose), Toast.LENGTH_SHORT).show();
return;
}
Team team = teamList.get(getAdapterPosition());
Toast.makeText(MainActivity.this, team.getName(), Toast.LENGTH_SHORT).show();
}
});
}
public ImageView getIvLogo() {
return ivLogo;
}
public TextView getTvName() {
return tvName;
}
}
@Override
public int getItemCount() {
return teamList.size();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
//將資料注入到View裡
Team team = teamList.get(position);
holder.getIvLogo().setImageResource(team.getLogo());
holder.getTvName().setText(team.getName());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
]
| |
5d76ec3532c211d86baee71dafef9cad1496e40e | c25d4e81ee5a1d1c1dbade6816b76ef0548937d6 | /src/java/Servlet/Detail.java | f21f7f0f676a617a78f7a65b055e7e250d20c020 | []
| no_license | mekzanarak5/AdisornJSP | 61dbda577c3c3bec1b6f68d333c665214a77ba57 | fa0cd99b87053cf38a91095b0aa77b31acfcf67d | refs/heads/master | 2020-05-19T20:56:35.031678 | 2014-09-13T18:33:07 | 2014-09-13T18:33:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,573 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Servlet;
import Model.Product;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Adisorn
*/
public class Detail extends HttpServlet {
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Product product = Product.findByProductNo(Integer.parseInt(request.getParameter("chooseProduct")));
request.setAttribute("PRODUCT", product);
getServletContext().getRequestDispatcher("/Detail.jsp").forward(request, response);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"Mekza@Adisorn"
]
| Mekza@Adisorn |
aea5789d5d013941f8d2f30df056c4a528049b48 | 6b08d599b576d5cabff6375fe7509079bc5a7b5c | /PotOGold/src/test/java/suite/tests/GamePauseTest.java | 927e06bf77c50f12620f4326fbece3f07a45457e | []
| no_license | Hunterszone/MyJavaGames | f18fb70f6641fbc265c72c41b1943cf6431b67be | 4734d22904b71fba40bf64f1e31e446a620b501b | refs/heads/master | 2023-07-21T06:56:36.520309 | 2023-06-18T13:35:53 | 2023-06-18T13:35:53 | 189,064,790 | 2 | 2 | null | 2022-11-05T10:29:54 | 2019-05-28T16:28:18 | Java | UTF-8 | Java | false | false | 367 | java | package suite.tests;
import static org.junit.Assert.*;
import org.junit.Test;
import org.newdawn.slick.Font;
import states.GamePause;
public class GamePauseTest {
private Font font;
private int x, y;
@Test
public void testGamePause() {
GamePause gamePause = new GamePause(x, y, font);
assertNotNull(gamePause.isGamePaused());
}
}
| [
"[email protected]"
]
| |
358ac5316ae038d11fe6db117bc738995856b7d6 | 77449ca1d6a946001521b54ab521466c9a0ebe09 | /src/main/java/org/bian/dto/BQFraudUpdateInputModelFraudInstanceRecord.java | b5c93b4387dfd4f22084f9648fa67860ce0ad8aa | [
"Apache-2.0"
]
| permissive | bianapis/sd-customer-event-history-v2.0 | 2abffcd7229d8daa378a51f9728d3c1a184ce1ca | 25135ff76374dc26cdef0573157e65d3bb6a6918 | refs/heads/master | 2020-07-11T08:45:47.631695 | 2019-09-09T05:06:14 | 2019-09-09T05:06:14 | 204,494,454 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,436 | java | package org.bian.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
/**
* BQFraudUpdateInputModelFraudInstanceRecord
*/
public class BQFraudUpdateInputModelFraudInstanceRecord {
private String customerFraudCaseEventType = null;
private String customerContactRecordReference = null;
private String accessedProductService = null;
private String employeeUnitReference = null;
private String fraudCaseReference = null;
private String dateTimeLocation = null;
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: The type of event (e.g. stolen card, disputed transaction)
* @return customerFraudCaseEventType
**/
public String getCustomerFraudCaseEventType() {
return customerFraudCaseEventType;
}
public void setCustomerFraudCaseEventType(String customerFraudCaseEventType) {
this.customerFraudCaseEventType = customerFraudCaseEventType;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to a contact event log
* @return customerContactRecordReference
**/
public String getCustomerContactRecordReference() {
return customerContactRecordReference;
}
public void setCustomerContactRecordReference(String customerContactRecordReference) {
this.customerContactRecordReference = customerContactRecordReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: Reference to the types or instances of products/services being serviced if provided
* @return accessedProductService
**/
public String getAccessedProductService() {
return accessedProductService;
}
public void setAccessedProductService(String accessedProductService) {
this.accessedProductService = accessedProductService;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Employees involved in recording the fraud case
* @return employeeUnitReference
**/
public String getEmployeeUnitReference() {
return employeeUnitReference;
}
public void setEmployeeUnitReference(String employeeUnitReference) {
this.employeeUnitReference = employeeUnitReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Reference to the fraud case processing the analysis and response
* @return fraudCaseReference
**/
public String getFraudCaseReference() {
return fraudCaseReference;
}
public void setFraudCaseReference(String fraudCaseReference) {
this.fraudCaseReference = fraudCaseReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: Date and time and the location the event was captured
* @return dateTimeLocation
**/
public String getDateTimeLocation() {
return dateTimeLocation;
}
public void setDateTimeLocation(String dateTimeLocation) {
this.dateTimeLocation = dateTimeLocation;
}
}
| [
"[email protected]"
]
| |
290a3a2ea3e43d5d718b54a6e487079f7df65b23 | b61cfd8d0eb8fc6d4423e980c682af78383993eb | /accounts-api/src/main/java/uk/gov/caz/accounts/dto/LoginRequestDto.java | b1d121024b512579b42c6eccdc57691d5e6fcea8 | [
"OGL-UK-3.0"
]
| permissive | DEFRA/clean-air-zones-api | 984e6ba7d16cc484e74dd57b1fab6150e230ce1c | e6437781ff5dc71b01ffce9fd6f8bec2226ee0a6 | refs/heads/master | 2023-07-24T13:59:03.152029 | 2021-05-06T16:24:20 | 2021-05-06T16:24:20 | 232,327,284 | 0 | 2 | NOASSERTION | 2023-07-13T17:02:58 | 2020-01-07T13:10:59 | Java | UTF-8 | Java | false | false | 1,741 | java | package uk.gov.caz.accounts.dto;
import static org.apache.logging.log4j.util.Strings.isNotBlank;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
import java.util.function.Function;
import lombok.Builder;
import lombok.Value;
import uk.gov.caz.accounts.controller.exception.InvalidRequestPayloadException;
import uk.gov.caz.accounts.util.MapPreservingOrderBuilder;
/**
* Class that represents incoming JSON payload for login.
*/
@Value
@Builder
public class LoginRequestDto {
/**
* Unique login credential.
*/
@ApiModelProperty(value = "${swagger.model.descriptions.login.email}")
String email;
/**
* User password used to login to the application.
*/
@ApiModelProperty(value = "${swagger.model.descriptions.account.password}")
String password;
private static final Map<Function<LoginRequestDto, Boolean>, String> validators =
MapPreservingOrderBuilder.<Function<LoginRequestDto, Boolean>, String>builder()
.put(loginRequestDto -> isNotBlank(loginRequestDto.email), "Email cannot be blank.")
.put(loginRequestDto -> isNotBlank(loginRequestDto.password), "Password cannot be blank.")
.put(loginRequestDto -> loginRequestDto.email.length() < 256, "Email is too long")
.put(loginRequestDto -> loginRequestDto.password.length() < 256, "Password is too long")
.build();
/**
* Public method that validates given object and throws exceptions if validation doesn't pass.
*/
public LoginRequestDto validate() {
validators.forEach((validator, message) -> {
boolean isValid = validator.apply(this);
if (!isValid) {
throw new InvalidRequestPayloadException(message);
}
});
return this;
}
} | [
"[email protected]"
]
| |
c47b51f4c1245f70cbb2ca7d73f39afd6c9e6611 | 00387fe46383162f99df40c94a854b9e5e04b651 | /src/dataprocessing/A0.java | f7431db2941dc4fbd37cf449c85f44b591ad9a58 | []
| no_license | navspeak/CP | 39b55da0222cb62c0f9194364969338931d07226 | 7938d75d0438cfb2ad212e2ba71ba1d9af33ca62 | refs/heads/master | 2020-04-08T17:03:55.375297 | 2019-05-14T03:01:41 | 2019-05-14T03:01:41 | 159,548,774 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,494 | java | package dataprocessing;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class A0 {
public static void main(String[] args) {
List<String> myList = Stream.of("a", "b")
.map(String::toUpperCase)
.collect(Collectors.toList());
System.out.println(myList);
List<List<String>> list = Arrays.asList(
Arrays.asList("a", "1", "one"),
Arrays.asList("b", "2", "two"));
System.out.println(list);
Stream<List<String>> streamOfList = list.stream();
Stream<String> streamOfString = streamOfList.flatMap(Collection::stream);
System.out.println(
streamOfString.collect(Collectors.toList())
);
System.out.println(
list.stream().flatMap(Collection::stream).collect(Collectors.toList())
);
String a = "abcdefg";
IntStream intStream = a.chars();
intStream.forEach(System.out::println);
try(Stream<String> streamOfLines = Files.lines(Paths.get("src/People.txt"));){
final List<List<String>> listOfLineEntry = streamOfLines.filter(A0::notACommentLine)
.map(A0::getLineContentAsList)
.collect(Collectors.toList());
System.out.println(listOfLineEntry);
List<Person> persons = new ArrayList<>();
listOfLineEntry.stream()
.map(t->{
String name = t.get(0);
Integer age = Integer.valueOf(t.get(1).trim());
String gender = t.get(2);
return new Person(name, age, gender);
})
.forEach(persons::add);
Comparator<Person> compareAgeAndThenName = Comparator.comparing(Person::getAge, Comparator.reverseOrder())
.thenComparing(Person::getName);
persons.sort(compareAgeAndThenName);
persons.forEach(System.out::println);
} catch (IOException e) {
e.printStackTrace();
}
/*
java.util.function: 4 categories:
Supplier: T get()
Consumer: void accept(T t)
BiConsumer: void accept(T t, U u)
Predicate: boolean test(T t)
BiPredicate(T t, U u)
Funtion<T, R>: R apply(T t)
BiFunction<T, U, R>: R apply(T t, U u, R r);
UnararyOperator<T> extends Function<T,T>
BiOperator<T> extends BiFunction<T, T, T>
*/
Supplier<Integer> supplier = () -> Integer.valueOf(10);
Consumer<Integer> consumer = System.out::println;
BiConsumer<String, Integer> biConsumer = System.out::printf;
List<String> strs = Arrays.asList("one", "two", "three", "four");
List<String> result = new ArrayList<>();
Consumer<String> c1 = System.out::println;
Consumer<String> c2 = result::add;
strs.forEach(c1.andThen(c2));
System.out.println("Size of result (should be 4) " + result.size());
Predicate<String> p2 = Predicate.isEqual("two");
Predicate<String> p3 = Predicate.isEqual("three");
Stream.of("one","two", "three").filter(p2.or(p2)).forEach(c1);
List<String> res = new ArrayList<>();
final Stream<String> peek = Stream.of("A", "AB", "C", "AD")
.peek(System.out::println)
.filter(x -> x.startsWith("A"))
.peek(result::add);// does nothing as peek is intermediary
peek.forEach(c1); // foreach is terminal (final)
// question what is the correct output:
// a) A \n A \n AB \n AB \n C \n AD \n AD
// b) A \n AB \n C \n AD \n A \n AB \AD
// ans - a. think why
List<Integer> list1 = Arrays.asList(1, 2, 3, 4);
List<Integer> list2= Arrays.asList(10, 20, 30);
List<Integer> list3 = Arrays.asList(100, 200, 300, 400, 500);
/*
<R> Stream<R> map(Function<T, R> mapper);
<R> Stream<R> flatMap(Function<T, Stream<R>>);
*/
List<List<Integer>> totList = Arrays.asList(list1,list2,list3);
Function<List<?>, Integer> sizeMap = List::size;
Function<List<Integer>, Stream<Integer>> flatMapper = l -> l.stream();
System.out.println("---");
totList.stream().map(sizeMap).forEach(System.out::println);
System.out.println("---");
totList.stream().map(flatMapper).forEach(System.out::println);
System.out.println("---");
totList.stream().flatMap(flatMapper).forEach(System.out::println);
List<String> strings = Arrays.asList("one", "two", "three", "four", "five");
//strings is unmodifable
Collection<String> col = new ArrayList<>(strings);
col.removeIf(s -> s.length() > 3);
System.out.println(col.stream().collect(Collectors.joining(", ")));
List<String> list_1 = new ArrayList<>(strings);
list_1.replaceAll(String::toUpperCase);
System.out.println(list_1.stream().collect(Collectors.joining(", ")));
}
static boolean notACommentLine(String line) { return !line.startsWith("#");}
static List<String> getLineContentAsList(String line) { return Arrays.asList(line.split(" "));}
}
| [
"[email protected]"
]
| |
505343705a99306542197b30489ee8130bb4337a | da93e68c64f3327e60278b5742c0e452414f0334 | /src/main/java/com/kdb/clients/ClientsApplication.java | 440cf6a95ac9e12460be271e0be6230706a2bb2e | []
| no_license | dudebowski/scaling-fortnight | 64a7b3cd1393babbcfd5ccd6f335ac218baf97a8 | 0b56a93dc97e5029f459665c49a6d151ef682d5b | refs/heads/main | 2023-05-08T04:55:59.483160 | 2021-05-27T19:45:02 | 2021-05-27T19:45:02 | 371,486,477 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 310 | java | package com.kdb.clients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ClientsApplication {
public static void main(String[] args) {
SpringApplication.run(ClientsApplication.class, args);
}
}
| [
"[email protected]"
]
| |
61dde9f2822d40b6335cc8c4eae3f7a94183ea5e | 241737d261b97e852bd90ff384cf4db7356205aa | /src/main/java/kr/ac/daegu/jspmvc/model/BoardDTO.java | 7d4224bb60a33bf05ed4ec171ce9d657d63da6b9 | []
| no_license | jangeunyoung00/jspmvc-1 | 618cb378a5d9e2950681ae3e19b91394853c611a | d05e110e9c8a614630e8d97e53124c6ea5536303 | refs/heads/master | 2023-07-15T10:29:25.027231 | 2021-08-25T01:49:40 | 2021-08-25T01:49:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,297 | java | package kr.ac.daegu.jspmvc.model;
import java.sql.Time;
import java.time.LocalDateTime;
import java.util.Date;
// db에서 Board테이블의 컬럼과 row를 정의.
public class BoardDTO {
private int id; // 글 id
private String author; // 작성자 이름
private String subject; // 글 제목
private String content; // 글 컨텐츠
private Date writeDate; // 작성 날짜
private Time writeTime; // 작성 시간
private int readCount; // 조회수
private int commentCount; // 댓글 갯수
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getWriteDate() {
return writeDate;
}
public void setWriteDate(Date writeDate) {
this.writeDate = writeDate;
}
public Time getWriteTime() {
return writeTime;
}
public void setWriteTime(Time writeTime) {
this.writeTime = writeTime;
}
public int getReadCount() {
return readCount;
}
public void setReadCount(int readCount) {
this.readCount = readCount;
}
public int getCommentCount() {
return commentCount;
}
public void setCommentCount(int commentCount) {
this.commentCount = commentCount;
}
@Override
public String toString() {
return "BoardDTO{" +
"id=" + id +
", author='" + author + '\'' +
", subject='" + subject + '\'' +
", content='" + content + '\'' +
", writeDate=" + writeDate +
", writeTime=" + writeTime +
", readCount=" + readCount +
", commentCount=" + commentCount +
'}';
}
}
| [
"[email protected]"
]
| |
3fd56431b9563494dbcb5a88228b038f408ed72d | 3f9229f161147a91d4cd8dab6912f1af5d528221 | /src/main/java/com/example/ProjetPriseMain/security/PasswordConfig.java | 6f6de71dd52286902f9782fe57be3a16d8b45039 | []
| no_license | Fadilou-coder/Gerer-visite | 5ec70078b7687fb43fd8cb5237d379e37541f42d | d515d4a89d131b14428b7295907ef37502a32e9c | refs/heads/master | 2023-07-07T17:23:30.388756 | 2021-08-30T08:48:58 | 2021-08-30T08:48:58 | 399,747,979 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 459 | java | package com.example.ProjetPriseMain.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
public class PasswordConfig {
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder(10);
}
}
| [
"[email protected]"
]
| |
d199dd6795c6188fd31ef2a5c53b2013eff31eda | 96fa4bafe1b67d16b1dcd93a3d8d9f3af4c28dbf | /Intro & Inter Java 1/Week 8/src/While (2019_01_09 03_21_30 UTC).java | ee0acf2265036363d08192526dfe2b6a8bec9822 | []
| no_license | AMSearer/JavaCourses | 8fad74c222d18590b3ec77a68b042c2b6cbdcaa3 | be79e62c6d458e43e3cf5ce9aa972bd578315818 | refs/heads/master | 2023-05-07T13:04:32.368885 | 2021-05-24T14:02:45 | 2021-05-24T14:02:45 | 229,746,394 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 499 | java | import java.util.Scanner;
public class While {
public static void main(String[] args) {
int sum = 0;
int newInt;
Scanner entry = new Scanner(System.in);
System.out.println("Please enter an integer: \n");
newInt = entry.nextInt();
while (newInt >= 0) {
sum += newInt;
newInt = entry.nextInt();
System.out.println("Please enter an integer: \n");
}
sum += newInt;
System.out.printf("The sum of your entries is: %d", sum);
}
}
| [
"[email protected]"
]
| |
79f9b815afc05097447f06852142cd2f562f6c57 | 40ef34f67c46c1197bb354a7a80f416c1208258e | /Lesson 32/Music Shop Demo/musicShop/Shop.java | 7a7a9929a523f588a8b061c8c0c7ffc5faa3bab9 | []
| no_license | noexile/Homework | ea2268c301c2b36caa1407e1536a9b803e3eec22 | bd833341a6c1471980d91f7d6706468a44f9e830 | refs/heads/master | 2021-01-10T05:46:43.146360 | 2016-03-19T13:13:31 | 2016-03-19T13:13:31 | 47,348,524 | 0 | 0 | null | 2015-12-08T19:32:32 | 2015-12-03T17:32:46 | Java | WINDOWS-1251 | Java | false | false | 21,909 | java | package musicShop;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
public class Shop {
enum Arrangement {ASCENDING, DESCENDING}
public static final int STARTING_MONEY_IN_CASH_REGISTER = 0;
private HashMap<String, ArrayList<Instrument>> availableInstruments;
private TreeMap<String, TreeMap<String, Integer>> catalogue;
private HashMap<String, ArrayList<Instrument>> soldItems;
private int moneyInCashRegister;
private int moneyFromSoldItems;
private InstrumentSupplier shano = new InstrumentSupplier();
public Shop () {
this.availableInstruments = new HashMap<String, ArrayList<Instrument>>();
this.catalogue = new TreeMap<String, TreeMap<String, Integer>>();
this.soldItems = new HashMap<String, ArrayList<Instrument>>();
this.moneyInCashRegister = STARTING_MONEY_IN_CASH_REGISTER;
this.setMoneyFromSoldItems(0);
this.availableInstruments.put("Stringed", new ArrayList<Instrument>());
this.soldItems.put("Stringed", new ArrayList<Instrument>());
this.availableInstruments.get("Stringed").add(new Instrument("Violin", 100, 3));
this.availableInstruments.get("Stringed").add(new Instrument("Viola", 80, 8));
this.availableInstruments.get("Stringed").add(new Instrument("Contrabass", 135, 2));
this.availableInstruments.get("Stringed").add(new Instrument("Harp", 50, 0));
this.availableInstruments.get("Stringed").add(new Instrument("Guitar", 60, 4));
this.availableInstruments.get("Stringed").add(new Instrument("Fiddle", 500, 1));
this.soldItems.get("Stringed").add(new Instrument("Violin", 100, 0));
this.soldItems.get("Stringed").add(new Instrument("Viola", 80, 0));
this.soldItems.get("Stringed").add(new Instrument("Contrabass", 135, 0));
this.soldItems.get("Stringed").add(new Instrument("Harp", 50, 0));
this.soldItems.get("Stringed").add(new Instrument("Guitar", 60, 0));
this.soldItems.get("Stringed").add(new Instrument("Fiddle", 500, 0));
this.availableInstruments.put("Percussion", new ArrayList<Instrument>());
this.soldItems.put("Percussion", new ArrayList<Instrument>());
this.availableInstruments.get("Percussion").add(new Instrument("Drums", 200, 2));
this.availableInstruments.get("Percussion").add(new Instrument("Tarambuka", 75, 5));
this.availableInstruments.get("Percussion").add(new Instrument("Tupan", 30, 12));
this.availableInstruments.get("Percussion").add(new Instrument("Tambourine", 200, 2));
this.soldItems.get("Percussion").add(new Instrument("Drums", 200, 0));
this.soldItems.get("Percussion").add(new Instrument("Tarambuka", 75, 0));
this.soldItems.get("Percussion").add(new Instrument("Tupan", 30, 0));
this.soldItems.get("Percussion").add(new Instrument("Tambourine", 200, 0));
this.availableInstruments.put("Wind", new ArrayList<Instrument>());
this.soldItems.put("Wind", new ArrayList<Instrument>());
this.availableInstruments.get("Wind").add(new Instrument("Trumpet", 310, 4));
this.availableInstruments.get("Wind").add(new Instrument("Trombone", 90, 11));
this.availableInstruments.get("Wind").add(new Instrument("Tuba", 85, 10));
this.availableInstruments.get("Wind").add(new Instrument("Flute", 160, 3));
this.availableInstruments.get("Wind").add(new Instrument("Clarinet", 115, 13));
this.soldItems.get("Wind").add(new Instrument("Trumpet", 310, 0));
this.soldItems.get("Wind").add(new Instrument("Trombone", 90, 0));
this.soldItems.get("Wind").add(new Instrument("Tuba", 85, 0));
this.soldItems.get("Wind").add(new Instrument("Flute", 160, 0));
this.soldItems.get("Wind").add(new Instrument("Clarinet", 115, 0));
this.availableInstruments.put("Keyboards", new ArrayList<Instrument>());
this.soldItems.put("Keyboards", new ArrayList<Instrument>());
this.availableInstruments.get("Keyboards").add(new Instrument("Organ", 800, 0));
this.availableInstruments.get("Keyboards").add(new Instrument("Piano", 350, 2));
this.availableInstruments.get("Keyboards").add(new Instrument("Accordion", 90, 8));
this.soldItems.get("Keyboards").add(new Instrument("Organ", 800, 0));
this.soldItems.get("Keyboards").add(new Instrument("Piano", 350, 0));
this.soldItems.get("Keyboards").add(new Instrument("Accordion", 90, 0));
this.availableInstruments.put("Electronic", new ArrayList<Instrument>());
this.soldItems.put("Electronic", new ArrayList<Instrument>());
this.availableInstruments.get("Electronic").add(new Instrument("Bass", 138, 12));
this.availableInstruments.get("Electronic").add(new Instrument("Synthesizer", 230, 6));
this.availableInstruments.get("Electronic").add(new Instrument("Electric Violin", 960, 1));
this.soldItems.get("Electronic").add(new Instrument("Bass", 138, 0));
this.soldItems.get("Electronic").add(new Instrument("Synthesizer", 230, 0));
this.soldItems.get("Electronic").add(new Instrument("Electric Violin", 960, 0));
createCatalogue(); // also creates list of products for the sold items to be added later
}
// methods
public void leastSoldInstrument() {
boolean zeroItemsSold = false;
int leastSoldQuantity = 0;
ArrayList<Instrument> instruments = new ArrayList<Instrument>();
for(Map.Entry<String, ArrayList<Instrument>> outerMap : this.soldItems.entrySet()) {
for (int i = 0; i < outerMap.getValue().size(); i++) {
if (outerMap.getValue().get(i).getAvailableQuantity() == 0) {
instruments.add(outerMap.getValue().get(i));
} else {
zeroItemsSold = true;
}
}
}
if (zeroItemsSold) { // prints the items as there are some with sold value 0 /the least number of sold item/
System.out.println("Least sold items:");
for (int i = 0; i < instruments.size(); i++) {
System.out.println("- " + instruments.get(i).getName() + " : " + instruments.get(i).getAvailableQuantity() + " items");
}
return;
}
instruments.clear(); // clears the values of the previous checking
boolean firstItemChecker = true;
for(Map.Entry<String, ArrayList<Instrument>> outerMapSecond : this.soldItems.entrySet()) {
for (int i = 0; i < outerMapSecond.getValue().size(); i++) {
if (firstItemChecker) {
instruments.add(outerMapSecond.getValue().get(i));
firstItemChecker = false;
leastSoldQuantity = outerMapSecond.getValue().get(i).getAvailableQuantity();
continue;
}
if (outerMapSecond.getValue().get(i).getAvailableQuantity() == leastSoldQuantity) {
instruments.add(outerMapSecond.getValue().get(i));
continue;
} else if (outerMapSecond.getValue().get(i).getAvailableQuantity() < leastSoldQuantity) {
instruments.clear();
instruments.add(outerMapSecond.getValue().get(i));
leastSoldQuantity = outerMapSecond.getValue().get(i).getAvailableQuantity();
continue;
}
}
}
}
public void mostSoldTypeOfInstruments() {
String mostSoldType = "";
int mostSoldItemsFromType = 0;
boolean zeroSoldItems = true;
for(Map.Entry<String, ArrayList<Instrument>> outerMap : soldItems.entrySet()) {
int tempCounter = 0;
for (int i = 0; i < outerMap.getValue().size(); i++) {
if (outerMap.getValue().get(i) == null) {
continue;
}
if (outerMap.getValue().get(i).getAvailableQuantity() > 0) {
tempCounter += outerMap.getValue().get(i).getAvailableQuantity();
}
}
if (mostSoldItemsFromType < tempCounter) {
mostSoldItemsFromType = tempCounter;
mostSoldType = outerMap.getKey();
zeroSoldItems = false;
}
}
if (zeroSoldItems) {
System.out.println("No instruments are sold yet!");
return;
}
System.out.println("Most sold Instrument type: " + mostSoldType + " - " + mostSoldItemsFromType + " pieces.");
}
public void mostProfitableInstrument() {
String mostProfitableItem = null;
int mostSoldItem = 0;
int totalPriceForSoldItem = 0;
int tempPrice = 0;
boolean zeroSoldItems = true;
for(Map.Entry<String, ArrayList<Instrument>> outerMap : soldItems.entrySet()) {
for (int i = 0; i < outerMap.getValue().size(); i++) {
tempPrice = 0;
if (outerMap.getValue().get(i) == null) {
continue;
}
tempPrice += (outerMap.getValue().get(i).getAvailableQuantity() * outerMap.getValue().get(i).getPrice());
if (tempPrice > totalPriceForSoldItem) {
totalPriceForSoldItem = tempPrice;
mostProfitableItem = outerMap.getValue().get(i).getName();
mostSoldItem = outerMap.getValue().get(i).getAvailableQuantity();
zeroSoldItems = false;
}
}
}
if (zeroSoldItems) {
System.out.println("No instruments are sold yet!");
return;
}
System.out.println("Most profitable Instrument: " + mostProfitableItem + " - " + mostSoldItem + " pieces sold for " + totalPriceForSoldItem + " lv.");
}
public void mostSoldItem() {
boolean firstEntry = true;
Instrument mostSoldInstrument = null;
for(Map.Entry<String, ArrayList<Instrument>> outerMap : this.soldItems.entrySet()) {
for (int i = 0; i < outerMap.getValue().size(); i++) {
if (outerMap.getValue().get(i) == null) {
continue;
}
if (outerMap.getValue().get(i).getAvailableQuantity() > 0) {
if (firstEntry) { // adds the 1st item to be the most sold product
mostSoldInstrument = outerMap.getValue().get(i);
firstEntry = false;
continue;
}
if (outerMap.getValue().get(i).getAvailableQuantity() > mostSoldInstrument.getAvailableQuantity()) {
mostSoldInstrument = outerMap.getValue().get(i);
}
}
}
}
if (firstEntry) {
System.out.println("No sold items yet!");
return;
}
System.out.println("Most sold item: " + mostSoldInstrument.getName() + " - " + mostSoldInstrument.getAvailableQuantity() + " items sold.");
}
private void addSoldItem(String name, int quantity) {
for (Map.Entry<String, ArrayList<Instrument>> soldItemsList : this.soldItems.entrySet()) {
for (int i = 0; i < soldItemsList.getValue().size(); i++) {
if (soldItemsList.getValue().get(i).getName().equalsIgnoreCase(name)) {
soldItemsList.getValue().get(i).setAvailableQuantity(soldItemsList.getValue().get(i).getAvailableQuantity() + quantity);
return;
}
}
}
}
public void printSoldItems() {
ArrayList<Instrument> tempListForSoldItems = new ArrayList<Instrument>();
for(Map.Entry<String, ArrayList<Instrument>> outerMap : this.soldItems.entrySet()) {
for (int i = 0; i < outerMap.getValue().size(); i++) {
if (outerMap.getValue().get(i).getAvailableQuantity() > 0) {
tempListForSoldItems.add(outerMap.getValue().get(i));
}
}
}
Collections.sort(tempListForSoldItems);
System.out.println("Sold Items: ");
for (int i = 0; i < tempListForSoldItems.size(); i++) {
System.out.println(tempListForSoldItems.get(i).getName() + " - " + tempListForSoldItems.get(i).getAvailableQuantity() + " items sold.");
}
}
private void createCatalogue() {
for(Entry<String, ArrayList<Instrument>> entry : this.availableInstruments.entrySet()) {
ArrayList<Instrument> tempInstruments = entry.getValue();
String instrumentType = entry.getKey();
for (int i = 0; i < tempInstruments.size(); i++) {
if (tempInstruments.get(i) == null) {
continue;
} else if (!this.catalogue.containsKey(instrumentType)) { // if does not have instrument type - add it to the catalogue
this.catalogue.put(instrumentType, new TreeMap<String, Integer>());
}
if (!this.catalogue.get(instrumentType).containsKey(tempInstruments.get(i).getName())) { // if does not contain instrument
this.catalogue.get(instrumentType).put(tempInstruments.get(i).getName(), tempInstruments.get(i).getPrice());
}
}
}
}
// ADDING INSTRUMENTS
// public void addInstrument(String name, int quantity) {
// for(Map.Entry<String, ArrayList<Instrument>> entry : this.availableInstruments.entrySet()) {
// ArrayList<Instrument> tempInstruments = entry.getValue();
// for (int i = 0; i < tempInstruments.size(); i++) {
// if (tempInstruments.get(i) == null) {
// continue;
// } else if(tempInstruments.get(i).getName().equalsIgnoreCase(name)) {
// tempInstruments.get(i).setAvailableQuantity(tempInstruments.get(i).getAvailableQuantity() + quantity);
// }
// }
// }
// }
public void sellInstrument(String name, int quantity) {
if(checkIfInstrumentIsAvailable(name, quantity)) { // checks if the item is in the shop
sell(name, quantity);
addSoldItem(name, quantity); // adding item in the sold list
} else { // if item is not available
for (Map.Entry<String, TreeMap<String, Integer>> shanoItems : this.shano.itemsForSale.entrySet()) {
for (Map.Entry<String, Integer> shanoItemList : shanoItems.getValue().entrySet()) {
if (shanoItemList.getKey().equalsIgnoreCase(name)) {
int waitDays = (shanoItemList.getValue() / 100);
if (waitDays < 1) {
waitDays = 1;
}
System.out.println("We are sorry but we does not have the Instrument in Stock. If ordered today it will arrive in: " + waitDays + " days.");
return;
}
}
}
System.out.println("We are sorry but we will not supply more of this item: " + name);
}
}
private void sell(String name, int quantity) {
for(Map.Entry<String, ArrayList<Instrument>> entry : this.availableInstruments.entrySet()) {
ArrayList<Instrument> tempInstruments = entry.getValue();
for (int i = 0; i < tempInstruments.size(); i++) {
if (tempInstruments.get(i).getName().equalsIgnoreCase(name)) {
if (tempInstruments.get(i).getAvailableQuantity() < quantity) {
System.out.println("Unfortunately the instrument: " + tempInstruments.get(i).getName() + " is out of stock.");
return;
}
System.out.print("Item sold: " + name + ". Quantity: " + quantity + " for " + tempInstruments.get(i).getPrice() + " lv");
if (quantity > 1) {
System.out.println(" each");
} else {
System.out.println();
}
this.moneyInCashRegister += (tempInstruments.get(i).getPrice() * quantity);
this.moneyFromSoldItems += (tempInstruments.get(i).getPrice() * quantity);
tempInstruments.get(i).setAvailableQuantity(tempInstruments.get(i).getAvailableQuantity() - quantity);
return;
}
}
}
}
private boolean checkIfInstrumentIsAvailable(String name, int quantity) {
for(Map.Entry<String, ArrayList<Instrument>> entry : this.availableInstruments.entrySet()) {
ArrayList<Instrument> tempInstruments = entry.getValue();
for (int i = 0; i < tempInstruments.size(); i++) {
if (tempInstruments.get(i) == null) {
continue;
} else if(tempInstruments.get(i).getName().equalsIgnoreCase(name)) {
if (tempInstruments.get(i).getAvailableQuantity() < quantity) {
return false;
}
return true;
}
}
}
return false;
}
public void printCatalogue() {
System.out.println("Catalogue:");
int numeration = 1;
for (Map.Entry<String, TreeMap<String, Integer>> outerMap : catalogue.entrySet()) {
System.out.println((numeration++) + " " + outerMap.getKey() + ": ");
TreeMap<String, Integer> innerMap = outerMap.getValue();
for (Map.Entry<String, Integer> inner : innerMap.entrySet()) {
System.out.println("- " + inner.getKey() + ", " + inner.getValue() + " lv.");
}
}
}
public void printCatalogueSortedByType() {
System.out.println("Catalogue:");
int numeration = 1;
for (Map.Entry<String, TreeMap<String, Integer>> outerMap : catalogue.entrySet()) {
System.out.println((numeration++) + " " + outerMap.getKey() + ": ");
TreeMap<String, Integer> innerMap = outerMap.getValue();
for (Map.Entry<String, Integer> inner : innerMap.entrySet()) {
System.out.println("- " + inner.getKey() + ", " + inner.getValue() + " lv.");
}
}
}
public void printCatalogueSortedByName() {
ArrayList<String> list = new ArrayList<String>();
for(Map.Entry<String, TreeMap<String, Integer>> outerMap : catalogue.entrySet()) {
TreeMap<String, Integer> innerMap = outerMap.getValue();
for (String key: innerMap.keySet()) {
list.add(key);
}
}
Collections.sort(list);
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
public void printCatalogueSortedByPrice(String arrangeBy) {
if (arrangeBy.equalsIgnoreCase(Arrangement.ASCENDING.toString().toLowerCase()) || arrangeBy.equalsIgnoreCase(Arrangement.DESCENDING.toString().toLowerCase())) {
Map<String, Integer> unsortMap = new TreeMap<String, Integer>();
for(Map.Entry<String, TreeMap<String, Integer>> outerMap : catalogue.entrySet()) {
unsortMap.putAll(outerMap.getValue());
}
if (arrangeBy.equalsIgnoreCase(Arrangement.ASCENDING.toString())) {
Map<String, Integer> sortedMapAsc = sortByComparator(unsortMap, true);
printMap(sortedMapAsc);
} else if (arrangeBy.equalsIgnoreCase(Arrangement.DESCENDING.toString())) {
Map<String, Integer> sortedMapDesc = sortByComparator(unsortMap, false);
printMap(sortedMapDesc);
}
} else {
System.out.println("You can arrange the price only in ascending or descending order!");
}
}
public void printItemsOnStock() {
System.out.println("Available Items in the shop:");
for(Map.Entry<String, ArrayList<Instrument>> outerMap : this.availableInstruments.entrySet()) {
ArrayList<Instrument> inner = outerMap.getValue();
for (int i = 0; i < inner.size(); i++) {
if (inner.get(i).getAvailableQuantity() == 0) {
continue;
}
System.out.println("- " + inner.get(i).getName() + ", " + inner.get(i).getAvailableQuantity() + " items");
}
}
}
public void printCurrentShopMoney() {
System.out.println(this.moneyInCashRegister + " lv."); // prints available money in cash register
}
private Map<String, Integer> sortByComparator(Map<String, Integer> unsortMap, boolean order) {
List<Entry<String, Integer>> list = new LinkedList<Entry<String, Integer>>(unsortMap.entrySet());
// Sorting the list based on values
Collections.sort(list, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
if (order) {
return o1.getValue().compareTo(o2.getValue());
} else {
return o2.getValue().compareTo(o1.getValue());
}
}
});
// Maintaining insertion order with the help of LinkedList
Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
for (Entry<String, Integer> entry : list) {
sortedMap.put(entry.getKey(), entry.getValue());
}
return sortedMap;
}
private void printMap(Map<String, Integer> map) {
System.out.println("Catalogue:");
for (Entry<String, Integer> entry : map.entrySet()) {
System.out.println("- " + entry.getKey() + ", " + entry.getValue() + " lv.");
}
}
// getters and setters
private int getMoneyInCashRegister() {
return moneyInCashRegister;
}
private HashMap<String,ArrayList<Instrument>> getAvailableInstruments() {
return availableInstruments;
}
private int getMoneyFromSoldItems() {
return moneyFromSoldItems;
}
private void setMoneyFromSoldItems(int moneyFromSoldItems) {
this.moneyFromSoldItems = moneyFromSoldItems;
}
// Instrument supplier
// Да се създаде обект „Доставчик на инструменти“, който предлага гама от
// инструменти, като за всеки инструмент има информация за времето на доставката до магазина.
// TODO
private class InstrumentSupplier {
private String name;
private TreeMap<String, TreeMap<String, Integer>> itemsForSale;
InstrumentSupplier() {
this.name ="Bat Sali";
this.itemsForSale = new TreeMap<String, TreeMap<String, Integer>>();
this.itemsForSale.put("Stringed", new TreeMap<String, Integer>());
this.itemsForSale.get("Stringed").put("Violin", 80);
this.itemsForSale.get("Stringed").put("Guitar", 50);
this.itemsForSale.get("Stringed").put("Contrabass", 90);
this.itemsForSale.put("Percussion", new TreeMap<String, Integer>());
this.itemsForSale.get("Percussion").put("Drums", 140);
this.itemsForSale.get("Percussion").put("Tarambuka", 55);
this.itemsForSale.get("Percussion").put("Tupan", 15);
this.itemsForSale.put("Wind", new TreeMap<String, Integer>());
this.itemsForSale.get("Wind").put("Trumpet", 220);
this.itemsForSale.get("Wind").put("Trombone", 60);
this.itemsForSale.get("Wind").put("Flute", 220);
this.itemsForSale.put("Keyboards", new TreeMap<String, Integer>());
this.itemsForSale.get("Keyboards").put("Organ", 550);
this.itemsForSale.get("Keyboards").put("Piano", 280);
this.itemsForSale.get("Keyboards").put("Accordion", 65);
}
// getters and setters
String getName() {
return name;
}
TreeMap<String, TreeMap<String, Integer>> getItemsForSale() {
return itemsForSale;
}
}
private class SortByType implements Comparator<LinkedHashMap<String, LinkedHashMap<String, Integer>>>{
private LinkedHashMap<String, LinkedHashMap<String, Integer>> map;
private SortByType(LinkedHashMap<String, LinkedHashMap<String, Integer>> map) {
this.map = map;
}
@Override
public int compare(LinkedHashMap<String, LinkedHashMap<String, Integer>> o1, LinkedHashMap<String, LinkedHashMap<String, Integer>> o2) {
Map.Entry<String, LinkedHashMap<String, Integer>> e1 = (Entry<String, LinkedHashMap<String, Integer>>) o1.entrySet();
Map.Entry<String, LinkedHashMap<String, Integer>> e2 = (Entry<String, LinkedHashMap<String, Integer>>) o2.entrySet();
return e1.getKey().compareTo(e2.getKey());
}
}
}
| [
"[email protected]"
]
| |
85124b3f745ecbe458250873e97873ec40b39e6b | 3814944e51daecb9fc08845a816054a242dd66b6 | /src/main/java/com/hbmr/common/Clock.java | 32cffbc9462df2ab7d8ee049c3aff3f5d5dbc155 | []
| no_license | vpatryshev/HBMR | 6767f8f3c52e97d89475e44174cd490dfc1fd0ff | 06eb944b89d9a31024f3e587d34baf30bcbc3a91 | refs/heads/master | 2021-01-01T05:47:24.527221 | 2011-12-12T01:14:54 | 2011-12-12T01:14:54 | 2,841,590 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 212 | java | package com.hbmr.common;
/**
* Abstract idea of clock, good for mocking/testing
*
* @author Vlad Patryshev
*/
public interface Clock {
long now();
void sleep(long howLong) throws InterruptedException;
}
| [
"[email protected]"
]
| |
c1695a60e034c3b2867f61ee534d4844be7dc429 | 31394300389f7c7c542ef891498e8cdbe24c5b8f | /dmn-signavio/src/test/java/com/gs/dmn/signavio/transformation/ExportedDecisionTableDMNToJavaTransformerTest.java | 28d97a39db95dbc6da635d8eca43d1c5178cf1f3 | [
"Apache-2.0"
]
| permissive | kaizer/jdmn | 82c30c577bae413e9117c7a7e0c692327f34ead1 | 929e9d11b839e328420b489a6412b501d1f39035 | refs/heads/master | 2021-05-01T04:02:22.030117 | 2020-03-04T11:22:06 | 2020-03-04T11:22:06 | 121,198,495 | 0 | 0 | null | 2018-02-12T04:08:22 | 2018-02-12T04:08:22 | null | UTF-8 | Java | false | false | 1,087 | java | /*
* Copyright 2016 Goldman Sachs.
*
* 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.gs.dmn.signavio.transformation;
import org.junit.Test;
public class ExportedDecisionTableDMNToJavaTransformerTest extends AbstractSignavioDMNToJavaTest {
@Test
public void testAll() throws Exception {
doTestFolder();
}
@Override
protected String getInputPath() {
return "dmn2java/exported/decision-table/input";
}
@Override
protected String getExpectedPath() {
return "dmn2java/exported/decision-table/expected/dmn";
}
}
| [
"[email protected]"
]
| |
36f2aa7d24ad7ec77f3eb1ad2854a1d39c39fae4 | 9236b9ae129e587d049dba4fd6040bf58a478ca4 | /src/test/java/com/example/GitSampleFukuApplicationTests.java | cd070b4538caf7f9856690173e31efc589f2671b | []
| no_license | happyislandR/git-sample-fuku | abef4d79ed8812879bebb56226cb9300b299fa53 | 170c8598ab10d96ddfde43d0345ca7d9dfd290b9 | refs/heads/main | 2023-07-02T01:22:14.266610 | 2021-07-29T03:07:25 | 2021-07-29T03:07:25 | 390,561,806 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 210 | java | package com.example;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class GitSampleFukuApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
]
| |
edcfb473937d3dafd913d1686ade65e633b6e86c | 40abbb61dd4fbc8e9cd70415de442b0847a6ac90 | /src/Year_2019_7_23/第五节课Constructor/Animal.java | d7db68a7cf17c434c55b8f3870a5b870851a08bc | []
| no_license | Micro-hard/JavaDB1905 | 5bbbf4948293f7d82a648646a6873ef9e6d18017 | ef370d9bd0fb1fa150c4fd1fe88e7204963f1a80 | refs/heads/master | 2022-11-16T07:47:45.880878 | 2020-07-05T16:35:15 | 2020-07-05T16:35:15 | 272,234,063 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 506 | java | package Year_2019_7_23.第五节课Constructor;
public class Animal {
private int legs;
public void setLegs(int legs) {
this.legs = legs;
}
public int getLegs() {
return legs;
}
//构造方法与类名相同 没有返回值
//一般写成public
public Animal(int i){
legs =i;
System.out.println("构造方法");
}
public static void main(String[] args) {
Animal animal=new Animal(4);
animal.setLegs(5);
}
}
| [
"[email protected]"
]
| |
57e196cf5da571b458f1bf90dd7c03c49cb99409 | a41a9b1e5faf63004a6239757ab3d9b6fdd9b3e3 | /nnbdc-service/src/main/java/beidanci/service/SessionListener.java | de38869db39d1bc67bb9a58b8f8153b643b289b2 | []
| no_license | chengtaowan/nnbdc-server | 8b314894b0586b5dfcfe5f7abeeb7a2239bb5b5b | 7744d72e69733e40413f56619a6afcc97b1bc6a7 | refs/heads/master | 2022-01-08T22:48:35.896060 | 2019-05-11T03:28:48 | 2019-05-11T03:28:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,587 | java | package beidanci.service;
import beidanci.api.model.UserVo;
import beidanci.service.po.User;
import beidanci.service.util.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@WebListener
public class SessionListener implements HttpSessionListener, HttpSessionAttributeListener {
private static Logger log = LoggerFactory.getLogger(SessionListener.class);
private static int OnlineUsercount = 0;
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
}
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
}
public void attributeAdded(HttpSessionBindingEvent event) {
if (event.getName().equals("sessionData")) {
OnlineUsercount++;
UserVo user = Util.getLoggedInUserVO();
log.info(String.format("用户【%s】登录成功,在线用户数【%d】", user.getUserName(), OnlineUsercount));
}
}
public void attributeRemoved(HttpSessionBindingEvent event) {
if (event.getName().equals("sessionData")) {
User user = Util.getLoggedInUser();
OnlineUsercount--;
log.info(String.format("用户【%s】登出,在线用户数【%d】", Util.getNickNameOfUser(user), OnlineUsercount));
}
}
public void attributeReplaced(HttpSessionBindingEvent event) {
}
}
| [
"[email protected]"
]
| |
2702a6df05e2ade1db72354b3dfd455075cd7f3d | 53c35321b476cb1eb80ff9d4e2b9faaabb54d432 | /src/JDBCconnecter.java | 10be5ed0ed77050d265fe0d302e55d0da49f0c9d | []
| no_license | Vintony/patternbased | cf6a0acf5e1b82b1c29b2b577dbccc7d5a6987db | 1279ac0cb208fbe83cb977c93a08efedb9325731 | refs/heads/master | 2020-05-02T08:37:32.595637 | 2019-04-30T12:07:04 | 2019-04-30T12:07:04 | 177,847,822 | 0 | 1 | null | 2019-04-27T00:15:25 | 2019-03-26T18:36:31 | Java | UTF-8 | Java | false | false | 1,121 | java | import java.sql.*;
public class JDBCconnecter {
private Connection conn = null;
private Statement statement = null;
public void Connect(String driver,String jdbcUrl,String userName,String userPass) {
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(jdbcUrl,userName,userPass);
statement = conn.createStatement();
}
catch (Exception e) {
e.printStackTrace();
}
}
public int executeUpdate(String sql) {
try {
return statement.executeUpdate(sql);
}
catch (SQLException e) {
e.printStackTrace();
return -1;
}
}
public ResultSet executeQuery(String sql) {
try {
return statement.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
public void Disconnect() {
try {
conn.close();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} | [
"[email protected]"
]
| |
80f72c1e8cbba8059ac06b52fb1b8dc93de6be9a | c30d71f8a49377ecd3aabad37548069768c53709 | /android/HCBLED/app/src/main/java/com/example/hcbled/MainActivity.java | c310d8791dbdf2771a5a263c19a9468175145b3c | []
| no_license | eugenioao/aquario | 5f4c9266a736ba0b4c4146163bf27e685cb40c30 | 4908cabe7be943d96c663dc0ee7576b97fd924b8 | refs/heads/master | 2022-12-21T08:48:29.168212 | 2020-09-27T22:38:16 | 2020-09-27T22:38:16 | 299,119,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,983 | java | package com.example.hcbled;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
static String MQTTHOST = "tcp://io.adafruit.com:1883";
static String USERNAME = "USERNAME";
static String PASSWORD = "aio_CODE";
// CANAIS
String feedsPWM = USERNAME + "/feeds/tempo-real.canais-pwm";
String tmpFeed = "";
MqttAndroidClient client;
MqttConnectOptions options;
TextView PercBranco;
TextView PercAzul;
TextView PercAzulRoyal;
TextView PercVioleta;
TextView PercTempLuminaria;
TextView PercTempAquario;
TextView valorPH;
ProgressBar progressBarBranco;
ProgressBar progressBarAzul;
ProgressBar progressBarAzulRoyal;
ProgressBar progressBarVioleta;
ProgressBar progressBarTempLuminaria;
ProgressBar progressBarTempAquario;
ImageButton btnConfig, btnTeste;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PercBranco = (TextView) findViewById(R.id.PercBranco);
PercAzul = (TextView) findViewById(R.id.PercAzul);
PercAzulRoyal = (TextView) findViewById(R.id.PercAzulRoyal);
PercVioleta = (TextView) findViewById(R.id.PercVioleta);
PercTempLuminaria = (TextView) findViewById(R.id.PercTemperaturaLumaria);
PercTempAquario = (TextView) findViewById(R.id.PercTemperaturaAquario);
progressBarBranco = (ProgressBar) findViewById(R.id.progressBarBranco);
progressBarAzul = (ProgressBar) findViewById(R.id.progressBarAzul);
progressBarAzulRoyal = (ProgressBar) findViewById(R.id.progressBarAzulRoyal);
progressBarVioleta = (ProgressBar) findViewById(R.id.progressBarVioleta);
progressBarTempLuminaria = (ProgressBar) findViewById(R.id.progressBarLuminaria);
progressBarTempAquario = (ProgressBar) findViewById(R.id.progressBarAquario);
valorPH = (TextView) findViewById(R.id.valorPH);
btnConfig = (ImageButton)findViewById(R.id.imageButtonConfig);
btnTeste = (ImageButton)findViewById(R.id.imageButtonTeste);
ImageButton imageButtonConfig = (ImageButton) findViewById(R.id.imageButtonConfig);
imageButtonConfig.setOnClickListener(this);
ImageButton imageButtonTeste = (ImageButton) findViewById(R.id.imageButtonTeste);
imageButtonTeste.setOnClickListener(this);
String clientId = MqttClient.generateClientId();
client = new MqttAndroidClient(this.getApplicationContext(), MQTTHOST, clientId);
options = new MqttConnectOptions();
options.setUserName(USERNAME);
options.setPassword(PASSWORD.toCharArray());
try {
IMqttToken token = client.connect(options);
token.setActionCallback(new IMqttActionListener() {
@Override
public void onSuccess(IMqttToken asyncActionToken) {
Toast.makeText(MainActivity.this, "Conectado ao MQTT", Toast.LENGTH_LONG).show();
setSubscription();
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
Toast.makeText(MainActivity.this, "Não conectado ao MQTT", Toast.LENGTH_LONG).show();
}
});
} catch (MqttException e) {
e.printStackTrace();
}
client.setCallback(new MqttCallback() {
@Override
public void connectionLost(Throwable cause) {
}
@SuppressLint("SetTextI18n")
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
Toast.makeText(MainActivity.this, "Chegou mensagem do MQTT", Toast.LENGTH_LONG).show();
tmpFeed = new String(message.getPayload());
String[] strFeed = tmpFeed.split(";");
PercBranco.setText("Branco: " + strFeed[0] + "%");
progressBarBranco.setProgress(Integer.parseInt(strFeed[0]));
PercAzul.setText("Azul: " + strFeed[1] + "%");
progressBarAzul.setProgress(Integer.parseInt(strFeed[1]));
PercAzulRoyal.setText("Azul Royal: " + strFeed[2] + "%");
progressBarAzulRoyal.setProgress(Integer.parseInt(strFeed[2]));
PercVioleta.setText("Violeta: " + strFeed[3] + "%");
progressBarVioleta.setProgress(Integer.parseInt(strFeed[3]));
PercTempLuminaria.setText("Luminária: " + strFeed[4] + "º");
progressBarTempLuminaria.setProgress(Integer.parseInt(strFeed[4]));
PercTempAquario.setText("Aquario: " + strFeed[5] + "º");
progressBarTempAquario.setProgress(Integer.parseInt(strFeed[5]));
valorPH.setText("PH: " + strFeed[6] + "ppm");
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.imageButtonConfig:
btnConfig.setImageResource(R.drawable.ic_baseline_settings_a48);
Intent itConfig = new Intent(this, MainActivityConfig.class);
startActivity(itConfig);
break;
case R.id.imageButtonTeste:
btnTeste.setImageResource(R.drawable.ic_baseline_luz_pink_48);
Intent itTestar = new Intent(this, MainActivityTestar.class);
startActivity(itTestar);
break;
default:
break;
}
}
private void setSubscription() {
try {
// OUTROS
client.subscribe(feedsPWM, 0);
} catch (MqttException e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
btnConfig.setImageResource(R.drawable.ic_baseline_settings_48);
btnTeste.setImageResource(R.drawable.ic_baseline_luz_azulroyal_48);
}
} | [
"[email protected]"
]
| |
78626dd1fda79066ae7f90a4ec6146a3b77f36c4 | e5813aa49016985d2378198cf129dcc4b88579a5 | /src/main/java/com/emc/rpsp/fal/commons/StorageAccessState.java | ef60a361846dd9821a03c5358c7b14759469e089 | [
"MIT"
]
| permissive | cunla/RPSP | d10fa3a756c8ea6ea7dc2334d7ebd7c4bf1b81ec | ed34b8c07a97ac99a984b3508c20fba50a0b31d7 | refs/heads/master | 2021-07-17T15:15:04.137384 | 2021-04-26T17:51:34 | 2021-04-26T17:51:34 | 35,469,747 | 4 | 1 | null | 2021-04-26T17:51:35 | 2015-05-12T05:58:51 | Java | UTF-8 | Java | false | false | 943 | java | package com.emc.rpsp.fal.commons;
import lombok.AllArgsConstructor;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@AllArgsConstructor
public enum StorageAccessState {
DIRECT_ACCESS("DirectAccess"),
LOGGED_ACCESS("LoggedAccess"),
VIRTUAL_ACCESS("VirtualAccess"),
ENABLING_LOGGED_ACCESS("EnablingLoggedAccess"),
ENABLING_VIRTUAL_ACCESS("EnablingVirtualAccess"),
VIRTUAL_ACCESS_ROLLING_IMAGE("VirtualAccessRollingImage"),
LOGGED_ACCESS_ROLL_COMPLETE("LoggedAccessRollComplete"),
NO_ACCESS("NoAccess"),
NO_ACCESS_UNDOING_WRITES("NoAccessUndoingWrites"),
NO_ACCESS_SPACE_FULL("NoAccessSpaceFull"),
NO_ACCESS_JOURNAL_PRESERVED("NoAccessJournalPreserved"),
NO_ACCESS_BFS_GROUP("NoAccessBFSGroup"),
VIRTUAL_ACCESS_CANNOT_ROLL_IMAGE("VirtualAccessCannotRollImage"),
UNKNOWN("Unknown");
private String name;
public String toString() {
return name;
}
}
| [
"[email protected]"
]
| |
a469b5e662a12b7b97711059218d59a7405bf8b6 | f1ea18203add1170b72795bc2ef26375de01dc20 | /src/main/java/biz/pdxtech/iaas/repository/JpaRunner.java | b873e8362b6aa25615e4b62925c18bd3a23c3597 | []
| no_license | PDXbaap/iaas | 7a0b21467d31e9c667dfb51d5e7ac7fcaed36825 | fe86785b457d45e1469e13debcf06abf54d686f4 | refs/heads/master | 2020-04-23T03:51:38.782980 | 2019-04-15T12:49:00 | 2019-04-15T12:49:00 | 170,889,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,759 | java | /*************************************************************************
* Copyright (C) 2016-2019 PDX Technologies, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*************************************************************************/
package biz.pdxtech.iaas.repository;
import biz.pdxtech.iaas.entity.Chain;
import biz.pdxtech.iaas.entity.DeployInfo;
import biz.pdxtech.iaas.entity.Deploy_Node;
import biz.pdxtech.iaas.entity.User;
import biz.pdxtech.iaas.util.EnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class JpaRunner implements CommandLineRunner {
@Autowired
private UserRepository userRepository;
@Override
public void run(String... args) throws Exception {
List<User> users = userRepository.findByLastName("测试");
if (users.isEmpty()){
User user = User.builder().lastName("测试").build();
userRepository.save(user);
}
}
}
| [
"[email protected]"
]
| |
e7589366559c259449f5c9b30f8eb850aa800c70 | e6aaf02f8270d16abf8d45212d113e030f88a54b | /Task_2/repository/src/main/java/com/epam/esm/repository/specification/FindAllOrdersByUserID.java | 867260e1a2b1b13d605ce73d6de63b6df677be96 | []
| no_license | alialiusefi/JavaMentoring | 15af4e84c529fa3beac47fd73814b8fe939cfdc3 | 9b7372eab43b0096053bcf0b87bd519caa288847 | refs/heads/master | 2022-12-20T17:12:37.613735 | 2020-04-15T16:27:50 | 2020-04-15T16:27:50 | 255,955,316 | 2 | 0 | null | 2020-10-13T21:13:08 | 2020-04-15T15:14:31 | Java | UTF-8 | Java | false | false | 1,053 | java | package com.epam.esm.repository.specification;
import com.epam.esm.entity.Order;
import com.epam.esm.entity.UserEntity;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.Root;
public class FindAllOrdersByUserID extends FindSpecification<Order> {
private Long userID;
public FindAllOrdersByUserID(Long userID) {
this.userID = userID;
}
@Override
public Query getQuery(EntityManager entityManager, CriteriaBuilder builder) {
CriteriaQuery<Order> criteriaQuery = builder.createQuery(Order.class);
Root<UserEntity> userRoot = criteriaQuery.from(UserEntity.class);
criteriaQuery.where(builder.equal(userRoot.get("id"), this.userID));
Join<UserEntity, Order> orders = userRoot.join("orders");
criteriaQuery.select(orders);
return entityManager.createQuery(criteriaQuery);
}
}
| [
"[email protected]"
]
| |
a1872bd3a5fa0c7d5d6e5710f360aac48f747279 | d58e269125ee0f58c6cf12019f9c7ee34383ff79 | /springannotation/src/main/java/com/sonic/bootstrap/ConfigurationBootstrap.java | b5d58971ec4518fc6d9435a34578de77959b5d9a | []
| no_license | AK47Sonic/drive-in-spring-boot | 7a011a878c21487d3e502f48b800721dba002752 | 403f67034b60c37082f0159e0ecc28cec5629e15 | refs/heads/master | 2022-12-25T20:29:32.694725 | 2020-06-21T01:22:42 | 2020-06-21T01:22:42 | 163,733,768 | 0 | 0 | null | 2022-12-16T03:39:56 | 2019-01-01T12:06:07 | Java | UTF-8 | Java | false | false | 2,730 | java | package com.sonic.bootstrap;
import com.sonic.bean.Person;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import java.util.Arrays;
/**
* @Configuration @Bean @ComponentScan使用
* @auther Sonic
* @since 2018/12/12
*/
@SpringBootApplication
//Filter[] excludeFilters
@ComponentScans(value = {
@ComponentScan(
basePackages = {"com.sonic.bean", "com.sonic.config", "com.sonic.service", "com.sonic.controller", "com.sonic.dao"},
// excludeFilters = {
// @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
// },
includeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
// ,
// @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {BookService.class}),
// @ComponentScan.Filter(type = FilterType.CUSTOM, classes = {MyTypeFilter.class})
},
useDefaultFilters = false //默认的过滤是什么都不过滤,必须设置为false,才能使得includeFilters生效
)
, // 第二个@ComponentScan是追加之前的效果
@ComponentScan(
basePackages = {"com.sonic.bean", "com.sonic.config", "com.sonic.service", "com.sonic.controller", "com.sonic.dao"},
excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})},
useDefaultFilters = true
)
})
public class ConfigurationBootstrap {
public static void main(String[] args) {
//AnnotationConfigApplicationContext
ConfigurableApplicationContext ac = new SpringApplicationBuilder(ConfigurationBootstrap.class)
.web(WebApplicationType.NONE)
.run(args);
// Person person = ac.getBean("person02", Person.class);
// System.out.println(person);
//
String[] beanNamesForType = ac.getBeanNamesForType(Person.class);
for (String beanName : beanNamesForType) {
System.out.println(beanName);
}
Arrays.stream(ac.getBeanDefinitionNames()).forEach(System.out::println);
ac.close();
}
}
| [
"[email protected]"
]
| |
6231e197e9f45fee5f49b290a3a7a14bea04c40a | 9208ba403c8902b1374444a895ef2438a029ed5c | /sources/com/androidquery/util/AQUtility.java | 06a0f30069fe0c7a866d81f4eca7a5b03dde2651 | []
| no_license | MewX/kantv-decompiled-v3.1.2 | 3e68b7046cebd8810e4f852601b1ee6a60d050a8 | d70dfaedf66cdde267d99ad22d0089505a355aa1 | refs/heads/main | 2023-02-27T05:32:32.517948 | 2021-02-02T13:38:05 | 2021-02-02T13:44:31 | 335,299,807 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,243 | java | package com.androidquery.util;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.animation.AlphaAnimation;
import com.androidquery.AQuery;
import com.kantv.flt_tencent_im.utils.TUIKitConstants.Group;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.Thread.UncaughtExceptionHandler;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class AQUtility {
private static final int IO_BUFFER_SIZE = 4096;
private static File cacheDir = null;
private static Context context = null;
/* renamed from: debug reason: collision with root package name */
private static boolean f3debug = false;
private static UncaughtExceptionHandler eh;
private static Handler handler;
private static File pcacheDir;
private static ScheduledExecutorService storeExe;
private static Map<String, Long> times = new HashMap();
private static Object wait;
public static void setDebug(boolean z) {
f3debug = z;
}
public static boolean isDebug() {
return f3debug;
}
public static void debugWait(long j) {
if (f3debug) {
if (wait == null) {
wait = new Object();
}
synchronized (wait) {
try {
wait.wait(j);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void debugNotify() {
if (f3debug) {
Object obj = wait;
if (obj != null) {
synchronized (obj) {
wait.notifyAll();
}
}
}
}
public static void debug(Object obj) {
if (f3debug) {
StringBuilder sb = new StringBuilder();
sb.append(obj);
sb.append("");
Log.w("AQuery", sb.toString());
}
}
public static void warn(Object obj, Object obj2) {
StringBuilder sb = new StringBuilder();
sb.append(obj);
sb.append(":");
sb.append(obj2);
Log.w("AQuery", sb.toString());
}
public static void debug(Object obj, Object obj2) {
if (f3debug) {
StringBuilder sb = new StringBuilder();
sb.append(obj);
sb.append(":");
sb.append(obj2);
Log.w("AQuery", sb.toString());
}
}
public static void debug(Throwable th) {
if (f3debug) {
Log.w("AQuery", Log.getStackTraceString(th));
}
}
public static void report(Throwable th) {
if (th != null) {
try {
warn("reporting", Log.getStackTraceString(th));
if (eh != null) {
eh.uncaughtException(Thread.currentThread(), th);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void setExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
eh = uncaughtExceptionHandler;
}
public static void time(String str) {
times.put(str, Long.valueOf(System.currentTimeMillis()));
}
public static long timeEnd(String str, long j) {
Long l = (Long) times.get(str);
if (l == null) {
return 0;
}
long currentTimeMillis = System.currentTimeMillis() - l.longValue();
if (j == 0 || currentTimeMillis > j) {
debug(str, Long.valueOf(currentTimeMillis));
}
return currentTimeMillis;
}
public static Object invokeHandler(Object obj, String str, boolean z, boolean z2, Class<?>[] clsArr, Object... objArr) {
return invokeHandler(obj, str, z, z2, clsArr, null, objArr);
}
public static Object invokeHandler(Object obj, String str, boolean z, boolean z2, Class<?>[] clsArr, Class<?>[] clsArr2, Object... objArr) {
try {
return invokeMethod(obj, str, z, clsArr, clsArr2, objArr);
} catch (Exception e) {
if (z2) {
report(e);
} else {
debug((Throwable) e);
}
return null;
}
}
private static Object invokeMethod(Object obj, String str, boolean z, Class<?>[] clsArr, Class<?>[] clsArr2, Object... objArr) throws Exception {
if (!(obj == null || str == null)) {
if (clsArr == null) {
try {
clsArr = new Class[0];
} catch (NoSuchMethodException unused) {
if (z) {
if (clsArr2 != null) {
return obj.getClass().getMethod(str, clsArr2).invoke(obj, objArr);
}
try {
return obj.getClass().getMethod(str, new Class[0]).invoke(obj, new Object[0]);
} catch (NoSuchMethodException unused2) {
}
}
}
}
return obj.getClass().getMethod(str, clsArr).invoke(obj, objArr);
}
return null;
}
public static void transparent(View view, boolean z) {
setAlpha(view, z ? 0.5f : 1.0f);
}
private static void setAlpha(View view, float f) {
if (f == 1.0f) {
view.clearAnimation();
return;
}
AlphaAnimation alphaAnimation = new AlphaAnimation(f, f);
alphaAnimation.setDuration(0);
alphaAnimation.setFillAfter(true);
view.startAnimation(alphaAnimation);
}
public static void ensureUIThread() {
if (!isUIThread()) {
report(new IllegalStateException("Not UI Thread"));
}
}
public static boolean isUIThread() {
return Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId();
}
public static Handler getHandler() {
if (handler == null) {
handler = new Handler(Looper.getMainLooper());
}
return handler;
}
public static void post(Runnable runnable) {
getHandler().post(runnable);
}
public static void post(Object obj, String str) {
post(obj, str, new Class[0], new Object[0]);
}
public static void post(final Object obj, final String str, final Class<?>[] clsArr, final Object... objArr) {
post(new Runnable() {
public void run() {
AQUtility.invokeHandler(obj, str, false, true, clsArr, objArr);
}
});
}
public static void postAsync(final Runnable runnable) {
new AsyncTask<Void, Void, String>() {
/* access modifiers changed from: protected */
public String doInBackground(Void... voidArr) {
try {
runnable.run();
} catch (Exception e) {
AQUtility.report(e);
}
return null;
}
}.execute(new Void[0]);
}
public static void postAsync(Object obj, String str) {
postAsync(obj, str, new Class[0], new Object[0]);
}
public static void postAsync(final Object obj, final String str, final Class<?>[] clsArr, final Object... objArr) {
postAsync(new Runnable() {
public void run() {
AQUtility.invokeHandler(obj, str, false, true, clsArr, objArr);
}
});
}
public static void removePost(Runnable runnable) {
getHandler().removeCallbacks(runnable);
}
public static void postDelayed(Runnable runnable, long j) {
getHandler().postDelayed(runnable, j);
}
public static void apply(Editor editor) {
if (AQuery.SDK_INT >= 9) {
Editor editor2 = editor;
invokeHandler(editor2, Group.MEMBER_APPLY, false, true, null, null);
return;
}
editor.commit();
}
private static String getMD5Hex(String str) {
return new BigInteger(getMD5(str.getBytes())).abs().toString(36);
}
private static byte[] getMD5(byte[] bArr) {
try {
MessageDigest instance = MessageDigest.getInstance("MD5");
instance.update(bArr);
return instance.digest();
} catch (NoSuchAlgorithmException e) {
report(e);
return null;
}
}
public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
copy(inputStream, outputStream, 0, null);
}
public static void copy(InputStream inputStream, OutputStream outputStream, int i, Progress progress) throws IOException {
if (progress != null) {
progress.reset();
progress.setBytes(i);
}
byte[] bArr = new byte[4096];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
outputStream.write(bArr, 0, read);
if (progress != null) {
progress.increment(read);
}
}
if (progress != null) {
progress.done();
}
}
public static byte[] toBytes(InputStream inputStream) {
byte[] bArr;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
copy(inputStream, byteArrayOutputStream);
bArr = byteArrayOutputStream.toByteArray();
} catch (IOException e) {
report(e);
bArr = null;
}
close(inputStream);
return bArr;
}
public static void write(File file, byte[] bArr) {
try {
if (!file.exists()) {
try {
file.createNewFile();
} catch (Exception e) {
debug("file create fail", file);
report(e);
}
}
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(bArr);
fileOutputStream.close();
} catch (Exception e2) {
report(e2);
}
}
public static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception unused) {
}
}
}
private static ScheduledExecutorService getFileStoreExecutor() {
if (storeExe == null) {
storeExe = Executors.newSingleThreadScheduledExecutor();
}
return storeExe;
}
public static void storeAsync(File file, byte[] bArr, long j) {
getFileStoreExecutor().schedule(new Common().method(1, file, bArr), j, TimeUnit.MILLISECONDS);
}
public static File getCacheDir(Context context2, int i) {
if (i != 1) {
return getCacheDir(context2);
}
File file = pcacheDir;
if (file != null) {
return file;
}
pcacheDir = new File(getCacheDir(context2), "persistent");
pcacheDir.mkdirs();
return pcacheDir;
}
public static File getCacheDir(Context context2) {
if (cacheDir == null) {
cacheDir = new File(context2.getCacheDir(), "aquery");
cacheDir.mkdirs();
}
return cacheDir;
}
public static void setCacheDir(File file) {
cacheDir = file;
File file2 = cacheDir;
if (file2 != null) {
file2.mkdirs();
}
}
private static File makeCacheFile(File file, String str) {
return new File(file, str);
}
private static String getCacheFileName(String str) {
return getMD5Hex(str);
}
public static File getCacheFile(File file, String str) {
if (str == null) {
return null;
}
if (str.startsWith(File.separator)) {
return new File(str);
}
return makeCacheFile(file, getCacheFileName(str));
}
public static File getExistedCacheByUrl(File file, String str) {
File cacheFile = getCacheFile(file, str);
if (cacheFile == null || !cacheFile.exists()) {
return null;
}
return cacheFile;
}
public static File getExistedCacheByUrlSetAccess(File file, String str) {
File existedCacheByUrl = getExistedCacheByUrl(file, str);
if (existedCacheByUrl != null) {
lastAccess(existedCacheByUrl);
}
return existedCacheByUrl;
}
private static void lastAccess(File file) {
file.setLastModified(System.currentTimeMillis());
}
public static void store(File file, byte[] bArr) {
if (file != null) {
try {
write(file, bArr);
} catch (Exception e) {
report(e);
}
}
}
public static void cleanCacheAsync(Context context2) {
cleanCacheAsync(context2, 3000000, 2000000);
}
public static void cleanCacheAsync(Context context2, long j, long j2) {
try {
File cacheDir2 = getCacheDir(context2);
getFileStoreExecutor().schedule(new Common().method(2, cacheDir2, Long.valueOf(j), Long.valueOf(j2)), 0, TimeUnit.MILLISECONDS);
} catch (Exception e) {
report(e);
}
}
public static void cleanCache(File file, long j, long j2) {
try {
File[] listFiles = file.listFiles();
if (listFiles != null) {
Arrays.sort(listFiles, new Common());
if (testCleanNeeded(listFiles, j)) {
cleanCache(listFiles, j2);
}
File tempDir = getTempDir();
if (tempDir != null && tempDir.exists()) {
cleanCache(tempDir.listFiles(), 0);
}
}
} catch (Exception e) {
report(e);
}
}
public static File getTempDir() {
File file = new File(Environment.getExternalStorageDirectory(), "aquery/temp");
file.mkdirs();
if (!file.exists() || !file.canWrite()) {
return null;
}
return file;
}
private static boolean testCleanNeeded(File[] fileArr, long j) {
long j2 = 0;
for (File length : fileArr) {
j2 += length.length();
if (j2 > j) {
return true;
}
}
return false;
}
private static void cleanCache(File[] fileArr, long j) {
long j2 = 0;
int i = 0;
for (File file : fileArr) {
if (file.isFile()) {
j2 += file.length();
if (j2 >= j) {
file.delete();
i++;
}
}
}
debug("deleted", Integer.valueOf(i));
}
public static int dip2pixel(Context context2, float f) {
return (int) TypedValue.applyDimension(1, f, context2.getResources().getDisplayMetrics());
}
public static float pixel2dip(Context context2, float f) {
return f / (((float) context2.getResources().getDisplayMetrics().densityDpi) / 160.0f);
}
public static void setContext(Application application) {
context = application.getApplicationContext();
}
public static Context getContext() {
if (context == null) {
warn("warn", "getContext with null");
debug((Throwable) new IllegalStateException());
}
return context;
}
}
| [
"[email protected]"
]
| |
8b3544c9ac9a1b8ea90671695c257b8fb83a6f80 | b86ade6ab28252a8e6d77dc41a4ca8522ba615ca | /src/app/datasim/Dao/BookDao.java | f43fc1f359b38a6aeda37a107b6b57122bd380cf | []
| no_license | kikemascote/FinalProgra | 6442a2333bf706b2cf50bc0a54c0d20211007f34 | fcca71b0fbd2b4fe0e9b14bcbd1194f969e6f8fe | refs/heads/master | 2021-05-17T06:36:18.184784 | 2020-03-28T08:35:07 | 2020-03-28T08:35:07 | 250,677,127 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,971 | java | package app.datasim.Dao;
import app.datasim.DBConnect;
import app.modelo.Book;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
public class BookDao extends DBConnect {
public ArrayList<Book> getAllBook() {
ArrayList<Book> booklist = new ArrayList<>();
IODao ioDao = new IODao();
try {
Connection conn = super.getConnection();
String sql = "SELECT * FROM Book";
PreparedStatement pst = null;
ResultSet rs = null;
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while (rs.next()) {
Book book = new Book();
book.setId(rs.getString("id"));
book.setName(rs.getString("bookname"));
book.setAuthor(rs.getString("author"));
book.setPublisher(rs.getString("publisher"));
book.setPrice(rs.getInt("price"));
book.setCategory(rs.getString("category"));
book.setStore(rs.getInt("store"));
book.setLend(ioDao.QueryBookNumById(book.getId()));
book.setRemain(book.getStore() - book.getLend());
book.setLocation(rs.getString("location"));
booklist.add(book);
}
return booklist;
} catch (Exception e) {
e.printStackTrace();
}
return booklist;
}
public void addtemp(Book book) {
try {
int i = 0;
Connection conn = super.getConnection();
PreparedStatement pst = null;
String sql = "insert into tempadd (id, bookname, author, publisher, price, category, store, bookdesc, location)values(?, ?, ?, ?, ?, ?, ?, ?, ?)";
pst = conn.prepareStatement(sql);
pst.setString(1, book.getId());
pst.setString(2, book.getName());
pst.setString(3, book.getAuthor());
pst.setString(4, book.getPublisher());
pst.setInt(5, book.getPrice());
pst.setString(6, book.getCategory());
pst.setInt(7, book.getStore());
pst.setString(8, book.getDesc());
pst.setString(9, book.getLocation());
i = pst.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
public ArrayList<Book> getadd() {
ArrayList<Book> booklist = new ArrayList<>();
try {
Connection conn = super.getConnection();
String sql = "SELECT * FROM tempadd";
PreparedStatement pst = null;
ResultSet rs = null;
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Book addbook = null;
while (rs.next()) {
addbook = new Book();
addbook.setPrice(rs.getInt("price"));
addbook.setCategory(rs.getString("category"));
addbook.setStore(rs.getInt("store"));
addbook.setLocation(rs.getString("location"));
addbook.setId(rs.getString("id"));
addbook.setName(rs.getString("bookname"));
addbook.setAuthor(rs.getString("author"));
addbook.setPublisher(rs.getString("publisher"));
booklist.add(addbook);
}
return booklist;
} catch (Exception e) {
e.printStackTrace();
}
return booklist;
}
public void confirm() {
try {
int i = 0;
Connection conn = super.getConnection();
PreparedStatement pst = null;
String sql = "INSERT INTO Book SELECT * FROM tempadd;";
pst = conn.prepareStatement(sql);
i = pst.executeUpdate();
sql = "truncate table tempadd;";
pst = conn.prepareStatement(sql);
i = pst.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
public void truncatetable() {
int i = 0;
Connection conn = null;
try {
conn = super.getConnection();
PreparedStatement pst = null;
String sql = "truncate table tempadd;";
pst = conn.prepareStatement(sql);
i = pst.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
public Book QueryBookById(String s) {
try {
IODao ioDao = new IODao();
Connection conn = super.getConnection();
String sql = "SELECT * FROM Book WHERE id=" + "'" + s + "'";
PreparedStatement pst = null;
ResultSet rs = null;
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Book book = new Book();
while (rs.next()) {
book.setId(rs.getString("id"));
book.setName(rs.getString("bookname"));
book.setAuthor(rs.getString("author"));
book.setPublisher(rs.getString("publisher"));
book.setPrice(rs.getInt("price"));
book.setCategory(rs.getString("category"));
book.setStore(rs.getInt("store"));
book.setLend(ioDao.QueryBookNumById(book.getId()));
book.setRemain(book.getStore() - book.getLend());
book.setDesc(rs.getString("bookdesc"));
book.setLocation(rs.getString("location"));
}
return book;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void DeleteById(String s) {
try {
int i = 0;
Connection conn = super.getConnection();
PreparedStatement pst = null;
String sql = "DELETE FROM Book WHERE id=" + "'" + s + "'";
pst = conn.prepareStatement(sql);
i = pst.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
public void EditDone(Book book) {
try {
int i = 0;
Connection conn = super.getConnection();
PreparedStatement pst = null;
String sql = "UPDATE Book SET bookname=?,author=?,publisher=?,price=?,category=?,store=?,bookdesc=?,location=? WHERE id=?";
pst = conn.prepareStatement(sql);
pst.setString(1, book.getName());
pst.setString(2, book.getAuthor());
pst.setString(3, book.getPublisher());
pst.setInt(4, book.getPrice());
pst.setString(5, book.getCategory());
pst.setInt(6, book.getStore());
pst.setString(7, book.getDesc());
pst.setString(8, book.getLocation());
pst.setString(9, book.getId());
i = pst.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
2a2e888e9439adf5ff01e5cd7f7d8c5cb1460a9f | 239f9d9a281a4969fe2acdf64eef369f01067d67 | /src/java/entity/thanhtich.java | f723bc86afc5561477506f922d37c5b9ed3e7842 | []
| no_license | hieunmps05633/hieuhh | 50286964d343500207f41d05877f789c8615fdd4 | e9f03aa8e30f27fbcc77bedd23a731f2805afe9f | refs/heads/master | 2020-03-14T21:38:08.232066 | 2018-05-02T05:16:57 | 2018-05-02T05:16:57 | 131,801,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 266 | 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 entity;
/**
*
* @author TrungQuoc
*/
public class thanhtich {
}
| [
"[email protected]"
]
| |
eb39bdd0a65e39557bbf02842b080f3a53c9c192 | 989db38f70797be4a841be1c4d45e76012d6d442 | /src/main/java/history/GalleryState.java | a0e9f1c80bd81e012d1479968a2679f3cf0b30a4 | []
| no_license | jchien14/technologic | 33761315ed668b4f5480e0bd354032df8bd03387 | 7a3e69f6e2c8a348641f6c61b46a476c5f957d7d | refs/heads/master | 2021-03-24T12:30:30.041412 | 2014-09-07T09:47:27 | 2014-09-07T09:47:27 | 23,693,804 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,680 | java | package history;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import java.util.*;
/**
* Created by jchien on 9/6/14.
*/
public final class GalleryState {
private int currentTime;
private final Set<String> employeesInside;
private final Set<String> guestsInside;
private final Map<String, PersonHistory> histories;
private GalleryState(int currentTime, TreeSet<String> employees, TreeSet<String> guests,
Map<String, PersonHistory> histories) {
this.currentTime = currentTime;
this.employeesInside = employees;
this.guestsInside = guests;
this.histories = histories;
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(Integer.toString(currentTime));
builder.append(HistoryUtils.DELIMITER);
builder.append(HistoryUtils.toListDelimitedString(employeesInside));
builder.append(HistoryUtils.DELIMITER);
builder.append(HistoryUtils.toListDelimitedString(guestsInside));
builder.append(HistoryUtils.DELIMITER);
builder.append(PersonHistory.toString(histories));
return builder.toString();
}
// TODO(jchien): Should this throw a specific checked exception when parsing fails?
public static GalleryState fromString(String decryptedContents) {
try {
final String[] parts = decryptedContents.split(HistoryUtils.DELIMITER);
assert parts.length % 3 == 0 && parts.length >= 3;
return new GalleryState(Integer.valueOf(parts[0]), HistoryUtils.toSortedStringSet(parts[1]),
HistoryUtils.toSortedStringSet(parts[2]),
PersonHistory.fromStringParts(Arrays.copyOfRange(parts, 3, parts.length)));
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
/**
* No defensive copying for performance reasons. DO NOT MUTATE the returned List.
*/
List<Integer> getRoomsVisited(String name) {
final PersonHistory history = histories.get(name);
if (history == null) {
return Collections.emptyList();
} else {
return history.getRoomsVisited();
}
}
Integer getTimeSpentInGallery(String name) {
final PersonHistory history = histories.get(name);
if (history == null) {
return null;
} else {
return history.getTimeSpentInGallery();
}
}
Set<String> getEmployeesInsideGallery() {
return employeesInside;
}
Set<String> getGuestsInsideGallery() {
return guestsInside;
}
Map<Integer, Set<String>> getRoomOccupancies() {
final Map<Integer, Set<String>> roomOccupancies = new TreeMap<Integer, Set<String>>();
for (PersonHistory history : histories.values()) {
if (history.isInsideRoom()) {
Integer room = Iterables.getLast(history.getRoomsVisited());
if (roomOccupancies.containsKey(room)) {
roomOccupancies.get(room).add(history.getName());
} else {
final Set<String> people = new TreeSet<String>();
people.add(history.getName());
roomOccupancies.put(room, people);
}
}
}
return roomOccupancies;
}
public void employeeGalleryArrival(int time, String name) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(!employeesInside.contains(name));
updateCurrentTime(time);
employeesInside.add(name);
}
public void guestGalleryArrival(int time, String name) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(!guestsInside.contains(name));
updateCurrentTime(time);
guestsInside.add(name);
}
public void personRoomEnter(int time, String name, Integer room) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(employeesInside.contains(name) || guestsInside.contains(name));
updateCurrentTime(time);
histories.get(name).enterRoom(room);
}
public void employeeGalleryDeparture(int time, String name) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(employeesInside.contains(name));
updateCurrentTime(time);
employeesInside.remove(name);
}
public void guestGalleryDeparture(int time, String name) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(guestsInside.contains(name));
updateCurrentTime(time);
guestsInside.remove(name);
}
public void personRoomLeave(int time, String name, Integer room) throws IllegalArgumentException {
Preconditions.checkArgument(time > currentTime);
Preconditions.checkArgument(employeesInside.contains(name) || guestsInside.contains(name));
updateCurrentTime(time);
histories.get(name).leaveRoom(room);
}
private void updateCurrentTime(int newTime) {
for (String person : employeesInside) {
histories.get(person).incrementTimeSpentInGallery(newTime - currentTime);
}
for (String person : guestsInside) {
histories.get(person).incrementTimeSpentInGallery(newTime - currentTime);
}
currentTime = newTime;
}
}
| [
"[email protected]"
]
| |
bc623ef2249d05dea61fa3d96a04fde0924c9f19 | ef0cb56afd7562895643986153836e8eb987ede8 | /CrmApp/src/com/myclass/connection/JDBCConnection.java | 0762bf4e021199a6aa6cea17d57665124a8f0666 | []
| no_license | truongduongkhang277/CRM_Project | b4f112dca66a652bbe5971467e3c8a6eb95b4df3 | 0c94e93a91fde4e3f5e9b10fd94dfbbc82f79556 | refs/heads/main | 2023-01-05T19:57:56.773089 | 2020-10-28T17:40:14 | 2020-10-28T17:40:14 | 308,093,315 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 621 | java | package com.myclass.connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCConnection {
public static Connection getConnection() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/crm", "root", "123456");
return conn;
} catch (ClassNotFoundException e) {
System.out.println("Không tìm thấy Driver!");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("Sai thông tin kết nối db!");
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
]
| |
ca7c832c2f37991ea52c3c165114e4afd7fe40b7 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/ReactiveX--RxJava/4017e26b22b4905c241d1f3b13e9387bab5ccbd8/after/ObservableDoOnEachTest.java | c583b891eef1f112643327b850fa65c1f3becdac | []
| no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,556 | java | /**
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/
package io.reactivex.internal.operators.observable;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.*;
import io.reactivex.*;
import io.reactivex.functions.*;
public class ObservableDoOnEachTest {
Observer<String> subscribedObserver;
Observer<String> sideEffectObserver;
@Before
public void before() {
subscribedObserver = TestHelper.mockObserver();
sideEffectObserver = TestHelper.mockObserver();
}
@Test
public void testDoOnEach() {
Observable<String> base = Observable.just("a", "b", "c");
Observable<String> doOnEach = base.doOnEach(sideEffectObserver);
doOnEach.subscribe(subscribedObserver);
// ensure the leaf Observer is still getting called
verify(subscribedObserver, never()).onError(any(Throwable.class));
verify(subscribedObserver, times(1)).onNext("a");
verify(subscribedObserver, times(1)).onNext("b");
verify(subscribedObserver, times(1)).onNext("c");
verify(subscribedObserver, times(1)).onComplete();
// ensure our injected Observer is getting called
verify(sideEffectObserver, never()).onError(any(Throwable.class));
verify(sideEffectObserver, times(1)).onNext("a");
verify(sideEffectObserver, times(1)).onNext("b");
verify(sideEffectObserver, times(1)).onNext("c");
verify(sideEffectObserver, times(1)).onComplete();
}
@Test
public void testDoOnEachWithError() {
Observable<String> base = Observable.just("one", "fail", "two", "three", "fail");
Observable<String> errs = base.map(new Function<String, String>() {
@Override
public String apply(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
return s;
}
});
Observable<String> doOnEach = errs.doOnEach(sideEffectObserver);
doOnEach.subscribe(subscribedObserver);
verify(subscribedObserver, times(1)).onNext("one");
verify(subscribedObserver, never()).onNext("two");
verify(subscribedObserver, never()).onNext("three");
verify(subscribedObserver, never()).onComplete();
verify(subscribedObserver, times(1)).onError(any(Throwable.class));
verify(sideEffectObserver, times(1)).onNext("one");
verify(sideEffectObserver, never()).onNext("two");
verify(sideEffectObserver, never()).onNext("three");
verify(sideEffectObserver, never()).onComplete();
verify(sideEffectObserver, times(1)).onError(any(Throwable.class));
}
@Test
public void testDoOnEachWithErrorInCallback() {
Observable<String> base = Observable.just("one", "two", "fail", "three");
Observable<String> doOnEach = base.doOnNext(new Consumer<String>() {
@Override
public void accept(String s) {
if ("fail".equals(s)) {
throw new RuntimeException("Forced Failure");
}
}
});
doOnEach.subscribe(subscribedObserver);
verify(subscribedObserver, times(1)).onNext("one");
verify(subscribedObserver, times(1)).onNext("two");
verify(subscribedObserver, never()).onNext("three");
verify(subscribedObserver, never()).onComplete();
verify(subscribedObserver, times(1)).onError(any(Throwable.class));
}
@Test
public void testIssue1451Case1() {
// https://github.com/Netflix/RxJava/issues/1451
final int expectedCount = 3;
final AtomicInteger count = new AtomicInteger();
for (int i = 0; i < expectedCount; i++) {
Observable
.just(Boolean.TRUE, Boolean.FALSE)
.takeWhile(new Predicate<Boolean>() {
@Override
public boolean test(Boolean value) {
return value;
}
})
.toList()
.doOnNext(new Consumer<List<Boolean>>() {
@Override
public void accept(List<Boolean> booleans) {
count.incrementAndGet();
}
})
.subscribe();
}
assertEquals(expectedCount, count.get());
}
@Test
public void testIssue1451Case2() {
// https://github.com/Netflix/RxJava/issues/1451
final int expectedCount = 3;
final AtomicInteger count = new AtomicInteger();
for (int i = 0; i < expectedCount; i++) {
Observable
.just(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE)
.takeWhile(new Predicate<Boolean>() {
@Override
public boolean test(Boolean value) {
return value;
}
})
.toList()
.doOnNext(new Consumer<List<Boolean>>() {
@Override
public void accept(List<Boolean> booleans) {
count.incrementAndGet();
}
})
.subscribe();
}
assertEquals(expectedCount, count.get());
}
// FIXME crashing ObservableSource can't propagate to an Observer
// @Test
// public void testFatalError() {
// try {
// Observable.just(1, 2, 3)
// .flatMap(new Function<Integer, Observable<?>>() {
// @Override
// public Observable<?> apply(Integer integer) {
// return Observable.create(new ObservableSource<Object>() {
// @Override
// public void accept(Observer<Object> o) {
// throw new NullPointerException("Test NPE");
// }
// });
// }
// })
// .doOnNext(new Consumer<Object>() {
// @Override
// public void accept(Object o) {
// System.out.println("Won't come here");
// }
// })
// .subscribe();
// fail("should have thrown an exception");
// } catch (OnErrorNotImplementedException e) {
// assertTrue(e.getCause() instanceof NullPointerException);
// assertEquals(e.getCause().getMessage(), "Test NPE");
// System.out.println("Received exception: " + e);
// }
// }
} | [
"[email protected]"
]
| |
646d0f915ddef7b93f0980fe2c365c14ed685cea | 05ec2d0f858974e9822adee80572d663a50841f7 | /AndroidGame31/src/main/java/com/ruanyf/androidgame31/FightLayer.java | 3885b39eadaf669f025e5743c097a255d8d13c28 | []
| no_license | asflex/AndroidGameExperiments | 60f01ec8479be56f5f8dfd228181a53c75b6689f | 50a83dfb142ecb43c335f3c6e02687dbf52207b7 | refs/heads/master | 2022-04-08T10:46:55.439208 | 2017-12-26T07:00:44 | 2017-12-26T07:00:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,348 | java | package com.ruanyf.androidgame31;
import android.view.MotionEvent;
import com.ruanyf.androidgame31.plants.*;
import org.cocos2d.actions.base.CCRepeatForever;
import org.cocos2d.actions.instant.CCCallFunc;
import org.cocos2d.actions.interval.CCAnimate;
import org.cocos2d.actions.interval.CCDelayTime;
import org.cocos2d.actions.interval.CCMoveBy;
import org.cocos2d.actions.interval.CCMoveTo;
import org.cocos2d.actions.interval.CCSequence;
import org.cocos2d.layers.CCLayer;
import org.cocos2d.layers.CCTMXObjectGroup;
import org.cocos2d.layers.CCTMXTiledMap;
import org.cocos2d.nodes.CCAnimation;
import org.cocos2d.nodes.CCDirector;
import org.cocos2d.nodes.CCLabel;
import org.cocos2d.nodes.CCSprite;
import org.cocos2d.nodes.CCSpriteFrame;
import org.cocos2d.types.CGPoint;
import org.cocos2d.types.CGRect;
import org.cocos2d.types.CGSize;
import org.cocos2d.types.ccColor3B;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
/**
* Created by Feng on 2017/11/16.
* Update on 2017/11/29.
*/
public class FightLayer extends CCLayer {
private CGSize winSize;
private CCSprite aSeedBankSprite;
private CCSprite aSeedChooserSprite;
private ArrayList<PlantCard> aPlantCards;
private ArrayList<PlantCard> aSelectPlantCards;
private CCTMXTiledMap mCctmxTiledMap;
private CCSprite aSeedChooser_Button_DisabledSprite;
private CCSprite aSeedChooser_ButtonSprite;
private CCSprite startReadySprite;
private boolean isStart;
private CCSprite selectCardSprite;
private Plant selectPlant;
public FightLayer() {
super();
loadMap();
}
private void loadMap() {
mCctmxTiledMap = CCTMXTiledMap.tiledMap("fight/map1.tmx");
addChild(mCctmxTiledMap);
CCTMXObjectGroup objectGroup_show = mCctmxTiledMap.objectGroupNamed("show");
ArrayList<HashMap<String, String>> objects = objectGroup_show.objects;
for (HashMap<String, String> hashMap : objects) {
int x = Integer.parseInt(hashMap.get("x"));
int y = Integer.parseInt(hashMap.get("y"));
CCSprite zombieCcSprite = CCSprite.sprite("zombies/zombies_1/shake/z_1_00.png");
zombieCcSprite.setPosition(x, y);
mCctmxTiledMap.addChild(zombieCcSprite);
ArrayList<CCSpriteFrame> mCcSpriteFrames = new ArrayList<CCSpriteFrame>();
for (int i = 0; i < 2; i++) {
CCSpriteFrame mCcSpriteFrame = CCSprite
.sprite(String.format(Locale.CHINA, "zombies/zombies_1/shake/z_1_%02d.png", i))
.displayedFrame();
mCcSpriteFrames.add(mCcSpriteFrame);
}
CCAnimation mCcAnimation = CCAnimation.animation("show", 0.2f, mCcSpriteFrames);
CCAnimate mCcAnimate = CCAnimate.action(mCcAnimation, true);
CCRepeatForever mCcRepeatForever = CCRepeatForever.action(mCcAnimate);
zombieCcSprite.runAction(mCcRepeatForever);
}
winSize = CCDirector.sharedDirector().getWinSize();
CCDelayTime mCcDelayTime = CCDelayTime.action(2);
CCMoveBy mCcMoveBy = CCMoveBy.action(2, ccp(winSize.width - mCctmxTiledMap.getContentSize().width, 0));
CCCallFunc mCcCallFunc = CCCallFunc.action(this, "loadChoose");
CCSequence mCcSequence = CCSequence.actions(mCcDelayTime, mCcMoveBy, mCcCallFunc);
mCctmxTiledMap.runAction(mCcSequence);
}
public void loadChoose() {
aSeedBankSprite = CCSprite.sprite("choose/SeedBank.png");
aSeedBankSprite.setAnchorPoint(0, 1);
aSeedBankSprite.setPosition(0, winSize.height);
addChild(aSeedBankSprite);
aSeedChooserSprite = CCSprite.sprite("choose/SeedChooser.png");
aSeedChooserSprite.setAnchorPoint(0, 0);
addChild(aSeedChooserSprite);
CCLabel mCcLabel = CCLabel.makeLabel("50", "", 16);
mCcLabel.setColor(ccColor3B.ccBLACK);
mCcLabel.setPosition(30, 420);
addChild(mCcLabel);
aSeedChooser_Button_DisabledSprite = CCSprite.sprite("choose/SeedChooser_Button_Disabled.png");
aSeedChooser_Button_DisabledSprite.setPosition(aSeedChooserSprite.getContentSize().width / 2, 50);
aSeedChooserSprite.addChild(aSeedChooser_Button_DisabledSprite);
aSeedChooser_ButtonSprite = CCSprite.sprite("choose/SeedChooser_Button.png");
aSeedChooser_ButtonSprite.setPosition(aSeedChooserSprite.getContentSize().width / 2, 50);
aSeedChooserSprite.addChild(aSeedChooser_ButtonSprite);
aSeedChooser_ButtonSprite.setVisible(false);
aPlantCards = new ArrayList<PlantCard>();
for (int i = 0; i < 8; i++) {
PlantCard aPlantCard = new PlantCard(i);
aPlantCards.add(aPlantCard);
aPlantCard.getLightCardSprite().setPosition(50 + 55 * (i % 6), 330 - 80 * (i / 6));
aSeedChooserSprite.addChild(aPlantCard.getLightCardSprite());
aPlantCard.getDarkCardSprite().setPosition(50 + 55 * (i % 6), 330 - 80 * (i / 6));
aSeedChooserSprite.addChild(aPlantCard.getDarkCardSprite());
}
aSelectPlantCards = new ArrayList<PlantCard>();
setIsTouchEnabled(true);
}
@Override
public boolean ccTouchesBegan(MotionEvent event) {
CGPoint aCgPoint = convertTouchToNodeSpace(event);
if (isStart) {
if (CGRect.containsPoint(aSeedBankSprite.getBoundingBox(), aCgPoint)) {
if (selectCardSprite != null) {
selectCardSprite.setOpacity(255);
selectCardSprite = null;
}
for (PlantCard aPlantCard : aSelectPlantCards) {
if (CGRect.containsPoint(aPlantCard.getLightCardSprite().getBoundingBox(), aCgPoint)) {
selectCardSprite = aPlantCard.getLightCardSprite();
selectCardSprite.setOpacity(100);
switch (aPlantCard.getId()) {
case 0:
selectPlant = new Peashooter();
break;
case 1:
selectPlant = new SunFlower();
break;
case 2:
selectPlant = new CherryBomb();
break;
case 3:
selectPlant = new WallNut();
break;
case 4:
selectPlant = new PotatoMine();
break;
case 5:
selectPlant = new SnowPea();
break;
case 6:
selectPlant = new Chomper();
break;
case 7:
selectPlant = new Repeater();
break;
default:
break;
}
}
}
} else if (selectPlant != null && selectCardSprite != null) {
selectPlant.setPosition(aCgPoint);
addChild(selectPlant);
selectPlant = null;
selectCardSprite.setOpacity(255);
selectCardSprite = null;
}
} else {
if (CGRect.containsPoint(aSeedChooserSprite.getBoundingBox(), aCgPoint)) {
if (aSelectPlantCards.size() < 5) {
for (PlantCard aPlantCard : aPlantCards) {
if (CGRect.containsPoint(aPlantCard.getLightCardSprite().getBoundingBox(), aCgPoint)) {
if (!aSelectPlantCards.contains(aPlantCard)) {
aSelectPlantCards.add(aPlantCard);
if (aSelectPlantCards.size() == 5) {
aSeedChooser_ButtonSprite.setVisible(true);
}
CCMoveTo mCcMoveTo = CCMoveTo.action(0.1f,
ccp(45 + 55 * aSelectPlantCards.size(), 450));
aPlantCard.getLightCardSprite().runAction(mCcMoveTo);
}
}
}
}
}
if (CGRect.containsPoint(aSeedBankSprite.getBoundingBox(), aCgPoint)) {
boolean isRemove = false;
for (int i = 0; i < aSelectPlantCards.size(); i++) {
PlantCard aPlantCard = aSelectPlantCards.get(i);
if (CGRect.containsPoint(aPlantCard.getLightCardSprite().getBoundingBox(), aCgPoint)) {
CCMoveTo mCcMoveTo = CCMoveTo.action(0.1f, aPlantCard.getDarkCardSprite().getPosition());
aPlantCard.getLightCardSprite().runAction(mCcMoveTo);
aSelectPlantCards.remove(aPlantCard);
aSeedChooser_ButtonSprite.setVisible(false);
isRemove = true;
break;
}
}
if (isRemove) {
for (int i = 0; i < aSelectPlantCards.size(); i++) {
PlantCard aPlantCard = aSelectPlantCards.get(i);
CCMoveTo mCcMoveTo = CCMoveTo.action(0.1f, ccp(100 + 55 * i, 450));
aPlantCard.getLightCardSprite().runAction(mCcMoveTo);
}
}
}
if (aSeedChooser_ButtonSprite.getVisible()) {
if (CGRect.containsPoint(aSeedChooser_ButtonSprite.getBoundingBox(), aCgPoint)) {
for (PlantCard aPlantCard : aSelectPlantCards) {
addChild(aPlantCard.getLightCardSprite());
}
aSeedChooserSprite.removeSelf();
CCMoveBy mCcMoveBy = CCMoveBy.action(2,
ccp(mCctmxTiledMap.getContentSize().width - winSize.width - 200, 0));
CCCallFunc mCcCallFunc = CCCallFunc.action(this, "startReady");
CCSequence mCcSequence = CCSequence.actions(mCcMoveBy, mCcCallFunc);
mCctmxTiledMap.runAction(mCcSequence);
}
}
}
return super.ccTouchesBegan(event);
}
public void startReady() {
setIsTouchEnabled(false);
startReadySprite = CCSprite.sprite("startready/startReady_00.png");
startReadySprite.setPosition(winSize.width / 2, winSize.height / 2);
addChild(startReadySprite);
ArrayList<CCSpriteFrame> mCcSpriteFrames = new ArrayList<CCSpriteFrame>();
for (int i = 0; i < 3; i++) {
CCSpriteFrame mCcSpriteFrame = CCSprite
.sprite(String.format(Locale.CHINA, "startready/startReady_%02d.png", i)).displayedFrame();
mCcSpriteFrames.add(mCcSpriteFrame);
}
CCAnimation mCcAnimation = CCAnimation.animation("startReady", 0.2f, mCcSpriteFrames);
CCAnimate mCcAnimate = CCAnimate.action(mCcAnimation, false);
CCCallFunc mCcCallFunc = CCCallFunc.action(this, "start");
CCSequence mCcSequence = CCSequence.actions(mCcAnimate, mCcCallFunc);
startReadySprite.runAction(mCcSequence);
}
public void start() {
startReadySprite.removeSelf();
isStart = true;
setIsTouchEnabled(true);
}
}
| [
"[email protected]"
]
| |
da0ff5d5b8434862e86ea0dc33a8ae0fdd7bdf3c | aa3522367eee4a30cb0c0944bd9d2d87a7cef412 | /TestaIdade.java | c40a0c13efb3c7e8ff3041cc33be37b9ee3cd34a | []
| no_license | KleciusPalma/EstudoJava | 578fc213bd854882ad5a512085b37d49bb3d863c | 6afb6e6a50b2337cdbc14797bc8056aabe5c1653 | refs/heads/master | 2020-03-27T03:44:01.319225 | 2018-08-23T17:35:57 | 2018-08-23T17:35:57 | 145,885,507 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 299 | java | class TestaIdade {
public static void main(String[] args) {
// imprime a idade
int idade = 20;
System.out.println(idade);
// gera uma idade no ano seguinte
int idadeNoAnoQueVem;
idadeNoAnoQueVem = idade + 1;
// imprime a idade
System.out.println(idadeNoAnoQueVem);
}
} | [
"[email protected]"
]
| |
0eb77c7d812f8850aa0ddd4973706c93bc7c8ca1 | b77fc8734b8f7ece129c8758649d8088ea1a887a | /LoginLogoutSample/src/com/simplilearn/servlet/LogoutServlet.java | c5ec292b432328053a9ab22dd333bc5ca6a6c9ab | []
| no_license | sonam-niit/Phase-2-Backend-JAVA | 8b0ddba5144e385f2c844f7c04c0652b55655cc4 | fb2cc24d5c9fd0ccc0fb37d4d75553f8c06ea490 | refs/heads/master | 2023-08-13T13:39:29.035509 | 2021-10-13T09:04:23 | 2021-10-13T09:04:23 | 411,664,388 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,457 | java | package com.simplilearn.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class LogoutServlet
*/
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LogoutServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session=request.getSession(false);
session.invalidate();
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("Loggedout Successfully<br>");
out.println("<a href='login.html'>Click Here to login again</a>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
]
| |
eac3d6c344f8ec00d60f1dc0b3e4809ab7e805f8 | cc1c512f0e7160466d3c0e733b82a6c40b11aad9 | /src/com/java/interviewprograms/RemoveDuplicateFromAnArray.java | 75eb8bd801f4cd23c78349695ffc4686d89c0a84 | []
| no_license | sailsn/Programs | ac5b4076e204524f0076d1c1565451ac5729d129 | 25617d1dd82010264a7e97cfa6e68435ec0f7fa6 | refs/heads/master | 2020-03-31T21:59:27.257087 | 2018-10-14T10:50:19 | 2018-10-14T10:50:19 | 152,600,940 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 730 | java | package com.java.interviewprograms;
public class RemoveDuplicateFromAnArray {
public static void main(String[] args) {
String[] str = { "AA", "BB", "CC", "AA", "BB" };
int indexlocation = 0;
String[] tempArray = new String[str.length];
int count;
boolean flag;
for (int i = 0; i < str.length; i++) {
count = 0;
flag = true;
for (int j = 0; j < str.length; j++) {
if (str[i].equals(str[j])) {
count++;
if (count > 1) {
flag = false;
break;
}
}
}
if (flag) {
tempArray[indexlocation] = str[i];
indexlocation++;
}
}
for(int i = 0; i < tempArray.length; i++)
{
System.out.println(tempArray[i]);
}
}
}
| [
"[email protected]"
]
| |
7fa51e6033343c98039d190d50fc928ec6ff2bd2 | b15c4ff40e206afb6a3df69fe92260e36f4a3fc3 | /src/main/java/mcjty/meecreeps/items/PortalGunItem.java | f5afc73c6b35fea21e36d40751664a63d9d3aa7f | [
"MIT"
]
| permissive | McJtyMods/MeeCreeps | 4eff1883ea61dc52596051b72884e481e23a332b | bdeb0ffdb6d0cd3e807865a7d7ddc494844182b6 | refs/heads/master | 2021-06-03T19:16:32.923397 | 2019-05-05T06:22:08 | 2019-05-05T06:22:08 | 108,944,939 | 12 | 8 | MIT | 2018-07-02T03:28:32 | 2017-10-31T04:23:27 | Java | UTF-8 | Java | false | false | 9,987 | java | package mcjty.meecreeps.items;
import mcjty.lib.network.PacketSendServerCommand;
import mcjty.lib.typed.TypedMap;
import mcjty.meecreeps.CommandHandler;
import mcjty.meecreeps.MeeCreeps;
import mcjty.meecreeps.actions.PacketShowBalloonToClient;
import mcjty.meecreeps.blocks.ModBlocks;
import mcjty.meecreeps.config.ConfigSetup;
import mcjty.meecreeps.entities.EntityProjectile;
import mcjty.meecreeps.gui.GuiWheel;
import mcjty.meecreeps.network.MeeCreepsMessages;
import mcjty.meecreeps.setup.GuiProxy;
import mcjty.meecreeps.teleport.TeleportDestination;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PortalGunItem extends Item {
public PortalGunItem() {
setRegistryName("portalgun");
setUnlocalizedName(MeeCreeps.MODID + ".portalgun");
setMaxStackSize(1);
setCreativeTab(MeeCreeps.setup.getTab());
}
public static ItemStack getGun(EntityPlayer player) {
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem.getItem() != ModItems.portalGunItem) {
heldItem = player.getHeldItem(EnumHand.OFF_HAND);
if (heldItem.getItem() != ModItems.portalGunItem) {
// Something went wrong
return ItemStack.EMPTY;
}
}
return heldItem;
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
Collections.addAll(tooltip, StringUtils.split(I18n.format("message.meecreeps.tooltip.portalgun", Integer.toString(getCharge(stack))), "\n"));
}
@SideOnly(Side.CLIENT)
public void initModel() {
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote) {
if (world.getBlockState(pos.offset(side)).getBlock() == ModBlocks.portalBlock) {
MeeCreepsMessages.INSTANCE.sendToServer(new PacketSendServerCommand(MeeCreeps.MODID, CommandHandler.CMD_CANCEL_PORTAL, TypedMap.builder().put(CommandHandler.PARAM_POS, pos.offset(side)).build()));
return EnumActionResult.SUCCESS;
}
if (side != EnumFacing.UP && side != EnumFacing.DOWN && world.getBlockState(pos.offset(side).down()).getBlock() == ModBlocks.portalBlock) {
MeeCreepsMessages.INSTANCE.sendToServer(new PacketSendServerCommand(MeeCreeps.MODID, CommandHandler.CMD_CANCEL_PORTAL, TypedMap.builder().put(CommandHandler.PARAM_POS, pos.offset(side).down()).build()));
return EnumActionResult.SUCCESS;
}
if (player.isSneaking()) {
GuiWheel.selectedBlock = pos;
GuiWheel.selectedSide = side;
player.openGui(MeeCreeps.instance, GuiProxy.GUI_WHEEL, world, pos.getX(), pos.getY(), pos.getZ());
}
return EnumActionResult.SUCCESS;
} else {
if (world.getBlockState(pos.offset(side)).getBlock() == ModBlocks.portalBlock) {
return EnumActionResult.SUCCESS;
}
if (side != EnumFacing.UP && side != EnumFacing.DOWN && world.getBlockState(pos.offset(side).down()).getBlock() == ModBlocks.portalBlock) {
return EnumActionResult.SUCCESS;
}
if (!player.isSneaking()) {
throwProjectile(player, hand, world);
}
}
return EnumActionResult.SUCCESS;
}
private void throwProjectile(EntityPlayer player, EnumHand hand, World world) {
ItemStack heldItem = player.getHeldItem(hand);
int charge = getCharge(heldItem);
if (charge <= 0) {
MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_charge"), (EntityPlayerMP) player);
return;
}
setCharge(heldItem, charge-1);
List<TeleportDestination> destinations = getDestinations(heldItem);
int current = getCurrentDestination(heldItem);
if (current == -1) {
MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_destination"), (EntityPlayerMP) player);
} else if (destinations.get(current) == null) {
MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_bad_destination"), (EntityPlayerMP) player);
} else {
EntityProjectile projectile = new EntityProjectile(world, player);
projectile.setDestination(destinations.get(current));
projectile.setPlayerId(player.getUniqueID());
projectile.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntity(projectile);
}
}
public static void addDestination(ItemStack stack, @Nullable TeleportDestination destination, int destinationIndex) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
List<TeleportDestination> destinations = getDestinations(stack);
destinations.set(destinationIndex, destination);
setDestinations(stack, destinations);
if (destination != null) {
setCurrentDestination(stack, destinationIndex);
}
}
private static void setDestinations(ItemStack stack, List<TeleportDestination> destinations) {
NBTTagList dests = new NBTTagList();
for (TeleportDestination destination : destinations) {
if (destination != null) {
dests.appendTag(destination.getCompound());
} else {
dests.appendTag(new NBTTagCompound());
}
}
stack.getTagCompound().setTag("dests", dests);
}
public static int getCurrentDestination(ItemStack stack) {
NBTTagCompound tag = stack.getTagCompound();
if (tag == null) {
return -1;
}
return tag.getInteger("destination");
}
public static void setCurrentDestination(ItemStack stack, int dest) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setInteger("destination", dest);
}
public static List<TeleportDestination> getDestinations(ItemStack stack) {
List<TeleportDestination> destinations = new ArrayList<>();
if (!stack.hasTagCompound()) {
for (int i = 0; i < 8; i++) {
destinations.add(null);
}
} else {
NBTTagCompound tag = stack.getTagCompound();
NBTTagList dests = tag.getTagList("dests", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < 8; i++) {
NBTTagCompound tc = i < dests.tagCount() ? dests.getCompoundTagAt(i) : null;
if (tc != null && tc.hasKey("dim")) {
destinations.add(new TeleportDestination(tc));
} else {
destinations.add(null);
}
}
}
return destinations;
}
public static void setCharge(ItemStack stack, int charge) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setInteger("charge", charge);
}
public static int getCharge(ItemStack stack) {
if (stack.getTagCompound() == null) {
return 0;
}
return stack.getTagCompound().getInteger("charge");
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
int max = ConfigSetup.maxCharge.get();
int stored = getCharge(stack);
return (max - stored) / (double) max;
}
@Override
public boolean hasContainerItem(ItemStack stack) {
return true;
}
@Override
public Item getContainerItem() {
return ModItems.emptyPortalGunItem;
}
@Override
public ItemStack getContainerItem(ItemStack itemStack) {
ItemStack stack = new ItemStack(ModItems.emptyPortalGunItem);
stack.setTagCompound(itemStack.getTagCompound());
return stack;
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return EnumActionResult.SUCCESS;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (!world.isRemote) {
if (!player.isSneaking()) {
throwProjectile(player, hand, world);
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
}
| [
"[email protected]"
]
| |
962033e548c7c71c594332c1734a7ce6461423fa | 176a82d11126a980f8a93b15d87d1290f0eb2fea | /src/by/epam/introduction_to_java/unit06/task01/controller/impl/GetMessagesCommand.java | a2c55297e3a12dcde58bcc8d65e73e3aa581590c | []
| no_license | IhorLevchuk/IntroductionToJavaOnline | 98964bb19af3ad951288a45891e86568b8002026 | c1af22dbb61de166acb537f38fbc8513ee5bf842 | refs/heads/master | 2023-06-08T08:36:57.383809 | 2021-06-17T20:49:26 | 2021-06-17T20:49:26 | 370,011,462 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,156 | java | package by.epam.introduction_to_java.unit06.task01.controller.impl;
import by.epam.introduction_to_java.unit06.task01.controller.Command;
import by.epam.introduction_to_java.unit06.task01.exception.ServiceException;
import by.epam.introduction_to_java.unit06.task01.presentation.ProfileActionViewI;
import by.epam.introduction_to_java.unit06.task01.presentation.impl.ViewProvider;
import by.epam.introduction_to_java.unit06.task01.service.ProfileServiceI;
import by.epam.introduction_to_java.unit06.task01.service.impl.ServiceProvider;
public class GetMessagesCommand implements Command {
@Override
public String execute(String[] params) {
ViewProvider viewProvider = ViewProvider.getProvider();
ProfileActionViewI profileActionView = viewProvider.getProfileActionView();
ServiceProvider serviceProvider = ServiceProvider.getProvider();
ProfileServiceI profileService = serviceProvider.getProfileService();
try {
return profileActionView.getMessagesView(profileService.getMessages());
} catch (ServiceException e) {
return profileActionView.errorView();
}
}
}
| [
"[email protected]"
]
| |
eca118543fd3db9966bb0f415686809557670313 | 0aa6d2243975707444fe587edf2bcad7f6336bc1 | /NetoTrades/src/Main.java | 39ac3be7718e03877acd164b9e04b4a3ae7640c0 | []
| no_license | SujChapa/NetoTrades_Strategy | 59df402169be0c79bc4976e2d733b96cc45e0ec5 | 1b3b1d9d7253d8740b7ad7ee4a40fefb7c8df135 | refs/heads/master | 2020-12-24T15:49:19.185259 | 2015-08-20T13:03:17 | 2015-08-20T13:03:17 | 41,086,033 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,228 | java | import java.util.ArrayList;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Calculator calculator = new Calculator();
RegressionAnalyser regressionAnalyser = new RegressionAnalyser(calculator);
BayesianLearner bayesianLearner = new BayesianLearner(calculator);
AdaptiveConcessionStrategy ConcessionStrategy = new AdaptiveConcessionStrategy(calculator);
double itemPriceGuess = 1600.00;
int numberOfRounds = 15;
Date currentTime= new Date();
//Set the private information values for this agent
Agent agent1 = new Agent(1650.00, new Date(currentTime.getTime()+36000000));
ArrayList<Offer> offerHistory = new ArrayList<Offer>();
//Initialize detection region for other agent
int numberOfRows = 10;
int numberOfColumns = 10;
DetectionRegion detReg = new DetectionRegion(itemPriceGuess/2, itemPriceGuess*2, currentTime, new Date(currentTime.getTime()+42000000));
Cell[][] cells = new Cell[numberOfRows][numberOfColumns];
Cell newCell;
double cellLowerPrice;
double cellUpperPrice;
Date cellLowerDate;
Date cellUpperDate;
double cellReservePrice;
Date cellDeadline;
double cellProbability;
for(int i = 0; i < numberOfRows; i++){
for(int j = 0; j < numberOfColumns; j++){
cellLowerPrice = detReg.getLowerReservePrice()+((detReg.getUpperReservePrice()-detReg.getLowerReservePrice())/numberOfRows)*j;
cellUpperPrice=detReg.getLowerReservePrice()+((detReg.getUpperReservePrice()-detReg.getLowerReservePrice())/numberOfRows)*(j+1);
cellLowerDate= new Date(detReg.getLowerDeadline().getTime()+ ((detReg.getUpperDeadline().getTime()-detReg.getLowerDeadline().getTime())/numberOfColumns)*i);
cellUpperDate= new Date(detReg.getLowerDeadline().getTime()+ ((detReg.getUpperDeadline().getTime()-detReg.getLowerDeadline().getTime())/numberOfColumns)*(i+1));
cellReservePrice=(cellUpperPrice + cellLowerPrice)/2;
cellDeadline = new Date((cellUpperDate.getTime() + cellLowerDate.getTime())/2);
cellProbability= 1/(numberOfRows*numberOfColumns);
newCell = new Cell(cellLowerPrice, cellUpperPrice, cellLowerDate, cellUpperDate, cellReservePrice, cellDeadline, cellProbability);
cells[i][j] = newCell;
}
}
detReg.setCells(cells);
detReg.setNumberOfCells(numberOfRows*numberOfColumns);
double currentPriceOffer = 1500.00;
int currentRound = 4;
Offer newOffer = new Offer(currentPriceOffer, currentTime, currentRound);
offerHistory.add(newOffer);
int round = 0;
long stepSize = (newOffer.getOfferTime().getTime() - offerHistory.get(0).getOfferTime().getTime()) / (newOffer.getRoundNumber() - 1);
while(round < numberOfRounds){
regressionAnalyser.Analyse(detReg, numberOfRows, numberOfColumns, offerHistory, numberOfRounds, newOffer);
bayesianLearner.Learn(numberOfRows, numberOfColumns, detReg);
ConcessionStrategy.FindConcessionPoint(numberOfRows, numberOfColumns, detReg, newOffer, agent1, stepSize, numberOfRounds, offerHistory);
ConcessionStrategy.GenerateNextOffer(detReg, agent1, numberOfRows, numberOfColumns, newOffer, stepSize);
round++;
}
}
}
| [
"[email protected]"
]
| |
80aca9a7e0871f0ae70f5194dee4719d4b6739a7 | f7a40de5e51ecb60a273e19f939a41d00ff7df45 | /android/app/src/main/java/com/inso/core/pressed/ICheckDevicePressed.java | 36fecc313c8d3b657aa785ed3db8439ca5dfe112 | []
| no_license | ftc300/inso | 50d35294990945916a9733a76a0847fc96fc183d | b08071da4de3068bec2289df11c34fe35d855447 | refs/heads/master | 2022-01-05T01:32:23.982350 | 2019-06-05T03:19:08 | 2019-06-05T03:19:08 | 164,582,442 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 156 | java | package com.inso.core.pressed;
/**
* Created by chendong on 2018/6/28.
*/
public interface ICheckDevicePressed {
void miWatchPressed(String mac);
}
| [
"[email protected]"
]
| |
c8028159f1c8e4ae8dd7ef2b27f6542a4750df71 | 3b9d9934a007364ed769a5afdeca2c879cce33ef | /src/SigningProcess.java | 3d0fbb38fdea42af4ebaa7c2921322a6fe9b4d64 | []
| no_license | MurthyAvanithsa/dsfo | b5cf6af20a0a8065df2751e2041fcebc0f792528 | 13a315c810853ec446b890ce9819102b0b001a5a | refs/heads/master | 2021-01-20T04:21:41.260827 | 2017-04-28T05:48:55 | 2017-04-28T05:48:55 | 89,676,258 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,201 | 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.
*/
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfSignatureAppearance;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.security.BouncyCastleDigest;
import com.itextpdf.text.pdf.security.CertificateUtil;
import com.itextpdf.text.pdf.security.CrlClient;
import com.itextpdf.text.pdf.security.CrlClientOnline;
import com.itextpdf.text.pdf.security.DigestAlgorithms;
import com.itextpdf.text.pdf.security.ExternalDigest;
import com.itextpdf.text.pdf.security.ExternalSignature;
import com.itextpdf.text.pdf.security.MakeSignature;
import com.itextpdf.text.pdf.security.OcspClient;
import com.itextpdf.text.pdf.security.OcspClientBouncyCastle;
import com.itextpdf.text.pdf.security.PrivateKeySignature;
import com.itextpdf.text.pdf.security.TSAClient;
import com.itextpdf.text.pdf.security.TSAClientBouncyCastle;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.KeyStoreSpi;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import sun.misc.BASE64Decoder;
import sun.security.mscapi.SunMSCAPI;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.Map;
import java.util.Map.Entry;
/**
*
* @author Administrator
*/
public class SigningProcess {
static KeyStore ks;
static SunMSCAPI providerMSCAPI;
static X509Certificate[] certificateChain = null;
static Key privateKey = null;
static String alias;
static HashMap returnCertificates;
public static HashMap returnCertificates(){
HashMap map = new HashMap();
try {
providerMSCAPI = new SunMSCAPI();
Security.addProvider(providerMSCAPI);
ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi");
spiField.setAccessible(true);
KeyStoreSpi spi = (KeyStoreSpi) spiField.get(ks);
Field entriesField = spi.getClass().getSuperclass().getDeclaredField("entries");
entriesField.setAccessible(true);
Collection entries = (Collection) entriesField.get(spi);
for (Object entry : entries) {
alias = (String) invokeGetter(entry, "getAlias");
// System.out.println("alias :" + alias);
privateKey = (Key) invokeGetter(entry, "getPrivateKey");
certificateChain = (X509Certificate[]) invokeGetter(entry, "getCertificateChain");
// System.out.println(alias + ": " + privateKey + "CERTIFICATES -----------"+Arrays.toString(certificateChain));
}
map.put("privateKey", privateKey);
map.put("certificateChain", certificateChain);
} catch (KeyStoreException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (IOException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (NoSuchAlgorithmException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (CertificateException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (NoSuchFieldException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (SecurityException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (IllegalArgumentException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (IllegalAccessException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (NoSuchMethodException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (InvocationTargetException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
}
return map;
}
private static Object invokeGetter(Object instance, String methodName)
throws NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
Method getAlias = instance.getClass().getDeclaredMethod(methodName);
getAlias.setAccessible(true);
return getAlias.invoke(instance);
}
public static String sign(String base64,HashMap map){
String base64string = null;
try {
System.out.println("map :"+map);
// Getting a set of the entries
Set set = map.entrySet();
System.out.println("set :"+set);
// Get an iterator
Iterator it = set.iterator();
// Display elements
while(it.hasNext()) {
Entry me = (Entry)it.next();
String key = (String) me.getKey();
if("privateKey".equalsIgnoreCase(key)){
privateKey = (PrivateKey)me.getValue();
}
if("certificateChain".equalsIgnoreCase(key)){
certificateChain = (X509Certificate[])me.getValue();
}
}
OcspClient ocspClient = new OcspClientBouncyCastle();
TSAClient tsaClient = null;
for (int i = 0; i < certificateChain.length; i++) {
X509Certificate cert = (X509Certificate) certificateChain[i];
String tsaUrl = CertificateUtil.getTSAURL(cert);
if (tsaUrl != null) {
tsaClient = new TSAClientBouncyCastle(tsaUrl);
break;
}
}
List<CrlClient> crlList = new ArrayList<CrlClient>();
crlList.add(new CrlClientOnline(certificateChain));
String property = System.getProperty("java.io.tmpdir");
BASE64Decoder decoder = new BASE64Decoder();
byte[] FileByte = decoder.decodeBuffer(base64);
writeByteArraysToFile(property+"_unsigned.pdf", FileByte);
// Creating the reader and the stamper
PdfReader reader = new PdfReader(property+"_unsigned.pdf");
FileOutputStream os = new FileOutputStream(property+"_signed.pdf");
PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
// Creating the appearance
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
// appearance.setReason(reason);
// appearance.setLocation(location);
appearance.setAcro6Layers(false);
appearance.setVisibleSignature(new Rectangle(36, 748, 144, 780), 1, "sig1");
// Creating the signature
ExternalSignature pks = new PrivateKeySignature((PrivateKey) privateKey, DigestAlgorithms.SHA256, providerMSCAPI.getName());
ExternalDigest digest = new BouncyCastleDigest();
MakeSignature.signDetached(appearance, digest, pks, certificateChain, crlList, ocspClient, tsaClient, 0, MakeSignature.CryptoStandard.CMS);
InputStream docStream = new FileInputStream(property+"_signed.pdf");
byte[] encodeBase64 = Base64.encodeBase64(IOUtils.toByteArray(docStream));
base64string = new String(encodeBase64);
} catch (IOException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (DocumentException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
} catch (GeneralSecurityException ex) {
System.out.println("Exception :"+ex.getLocalizedMessage());
}
return base64string;
}
public static void writeByteArraysToFile(String fileName, byte[] content) throws IOException {
File file = new File(fileName);
BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(file));
writer.write(content);
writer.flush();
writer.close();
}
public static void main(String[] args) {
returnCertificates = returnCertificates();
System.out.println("returnCertificates :" + returnCertificates.get("privateKey"));
String base64 = "JVBERi0xLjcNCiWhs8XXDQoxIDAgb2JqDQo8PC9QYWdlcyAyIDAgUiAvVHlwZS9DYXRhbG9nPj4N\n" +
"CmVuZG9iag0KMiAwIG9iag0KPDwvQ291bnQgMS9LaWRzWyA0IDAgUiBdL1R5cGUvUGFnZXM+Pg0K\n" +
"ZW5kb2JqDQozIDAgb2JqDQo8PC9DcmVhdGlvbkRhdGUoRDoyMDE3MDQyNzEzMTUzNykvQ3JlYXRv\n" +
"cihQREZpdW0pL1Byb2R1Y2VyKFBERml1bSk+Pg0KZW5kb2JqDQo0IDAgb2JqDQo8PC9Db250ZW50\n" +
"cyA1IDAgUiAvQ3JvcEJveFsgMCAwIDU5NSA4NDJdL01lZGlhQm94WyAwIDAgNTk1IDg0Ml0vUGFy\n" +
"ZW50IDIgMCBSIC9SZXNvdXJjZXMgNiAwIFIgL1JvdGF0ZSAwL1R5cGUvUGFnZT4+DQplbmRvYmoN\n" +
"CjUgMCBvYmoNCjw8L0ZpbHRlci9GbGF0ZURlY29kZS9MZW5ndGggMTUzMD4+c3RyZWFtDQpIibRX\n" +
"S2/jNhBGr/4Vc1uqiBW9H8d0tynQ02IroIduD7LEJCpk0RDppPlT/Y2dB2l7nS0KLFoEUPgacuab\n" +
"mW/GP3Sb267LIIXuYZMWcVJAgn8yytI8rqukgrqscZ7k0O03t+9tCYPlYwnYYXP70y8pPNrNNomT\n" +
"JKugGzY0qhroXja/qbsoTeJMjdG2jlNldhqibUpD3GjiWg3RNlNrtK3iCnd7Bx8/3MP9RAuNmrWN\n" +
"fu9+Jh0Lr2MmCmbQtHGbkXJZG+eZKMc6JK3XIaMR6zDiu3/BR7O6fjdr+GBQhyRu1XDc68XBfVTG\n" +
"ucJFWlv3uJmjgqjLZ4Xa8ObnCCZLqieqh+MyPevV9rMsPEwzWZXhyKx7FONV9xRGh5WMb5W2en32\n" +
"L+sow2+4cZ7ZzAS2aZyW0H1gCJPGG9K2mRhiHqIcYYGI79dRgaDxRNbN4uzN5TxK8LvymKyKC9Wz\n" +
"jHPTEm1b9MsjuadRN3ySRQc+IaKzOYq05S0RXkZ4lFWZH54mkbFRosDIvV5RL8GXvcpTYrLFm0XK\n" +
"WzEamR5JUdJUX4i6G5AXdbQtcc9r3dMs9waOorGIWQuIFWHafe+jogiRSSMCEwGE/nCYp6F3k1mg\n" +
"R8MOc+/IiXC0rEam9AjOwLBqCdEe3yqU0zC5OPgsi3PvspTC8BRxjJkEUCvYTh7HRWYjX1rypaWa\n" +
"xXMSQg8Somgc6NkfG/iYW80yDYQXQ5XhEsXwOFm3TrujmGJRPzAYpIPZawsUK1cBJqDUJ1BqUfyw\n" +
"GsyQvQUU3Jtl5hda8h1mmQK9sFqYtua4OM2BXRNGL5N7Ik0HVs9LDcCpYZ96MgBTC4M+V9PyGNFl\n" +
"gt/tvWcfAbJhJFkrUkh9F3V/UPpX/lBcVJj+eAYBlZ3GE4NwV0id0htWtSXfc7e8mkXfoJNfX540\n" +
"elOEPaugEV6YYUm9cJ0KKDCgx8xBI7BIT9G2wUAjr2aKDYzhbiYqyBPGSZmjxPiiCR4OIZ4HAqHA\n" +
"E+JA/DCm/YxihoJOhfmw+oUeccMkYLy2rCu5sQjGpj6006SpROFPmrXr+TtGkk40XjE7ChVzpH3S\n" +
"A69NxHuNOkxyZOHjTiIVk4gEZExRdL7E8wwNEQOPBk8N3yCn9nK5aOJkYsFiVMrK5AcYcBcqL4Rx\n" +
"pd5FmIJVEEMPyPKlnvClBhZ2+vKiIx+yXj0yYIu1jbjoq+nwhiNGs7zDYEXw4akX7iYoiQPgzB+e\n" +
"Gij1LDLHP1EGCZzTtqK0tVdJgPqU35gHxdfyQEJjG4ZkEhFSTYx7jVyotD6hsAUoLy4qzxeVclE/\n" +
"v/SvXByR+JEF4LBOSESDL6ZoiVpXzTNZc/PrVTXHRGov8i7JTvj7ggfMy1RbUUUmoca/MwkTUQXj\n" +
"xVE/iyPEP/U1vZDfi+K/xDb0GWndppfQpgRtjnQ3cTGqEdqe/xOZIgwvyIYp4fEaZdQKEHoogwSO\n" +
"1efLrWufUOvwluXkcS6NtfqzH97inF3hHDRvQ4dEFYNJh6OWbOi5QXF6pNIr7YtsEN5hex1n3yz5\n" +
"fobKLtYu7kOseXBkKwmtTL2jMBgKNPmZwr5MvSqkHvLt2gc3F/ysb3awNGdpiAes9Q7rlVAakfJl\n" +
"G0QlXQTZBmx/qFkJzQxnJ9WkSkmtXoyD2VgspkdNKRy6gbMtLIG2SNvmDbpq29LsnCo+jJ8xDZgQ\n" +
"M/Y2Zh3G9bRgWnCiZGp/QL5CNtxN8+SIiNX/yQzbs5oUvkHLDvnpQfyPSQR3g4xWbss/6X4MLdFK\n" +
"vbA/1zN+5BJ2CJVGgm40L8ts+pG7KoksrKG7U+ELr2D8ZESPQfTUxiCJ7i5Z+hwqeXMR9UQOFE90\n" +
"QYW6YdtEs7CqsSX9dyC/mV1zgbBoGt8+vTfsSYz4gb9OflOcOsEaSfFUOHNPvumpvabxKnksG2D3\n" +
"sjr7kyvLYSmRZSqCPKXKGIQm/0NGjlKnzaPBX3n9tL9p9D6Tm2QR3fdVF4SI4ah9pHAFjl9EXUYg\n" +
"hV0eY680/EukCF0CF2hl3QXtEelReBHnc6uh4Ff67sSBP3abvwcArRiH3QoNCmVuZHN0cmVhbQ0K\n" +
"ZW5kb2JqDQo2IDAgb2JqDQo8PC9Db2xvclNwYWNlPDwvQ3M1IDcgMCBSID4+L0V4dEdTdGF0ZTw8\n" +
"L0dTMSA4IDAgUiA+Pi9Gb250PDwvRjIgOSAwIFIgL1RUMiAxMiAwIFIgL1RUNCAxNCAwIFIgL1RU\n" +
"NiAxNiAwIFIgL1RUOCAxOCAwIFIgPj4vUHJvY1NldFsvUERGL1RleHRdPj4NCmVuZG9iag0KNyAw\n" +
"IG9iag0KWy9DYWxSR0I8PC9HYW1tYVsgMi4yMjIyMSAyLjIyMjIxIDIuMjIyMjFdL01hdHJpeFsg\n" +
"MC40MTI0IDAuMjEyNiAwLjAxOTMgMC4zNTc2IDAuNzE1MTkgMC4xMTkyIDAuMTgwNSAwLjA3MjIg\n" +
"MC45NTA1XS9XaGl0ZVBvaW50WyAwLjk1MDUgMSAxLjA4OV0+Pl0NCmVuZG9iag0KOCAwIG9iag0K\n" +
"PDwvU0EgZmFsc2UvU00gMC4wMi9UUi9JZGVudGl0eS9UeXBlL0V4dEdTdGF0ZT4+DQplbmRvYmoN\n" +
"CjkgMCBvYmoNCjw8L0Jhc2VGb250L1N5bWJvbC9FbmNvZGluZyAxMCAwIFIgL1N1YnR5cGUvVHlw\n" +
"ZTEvVG9Vbmljb2RlIDExIDAgUiAvVHlwZS9Gb250Pj4NCmVuZG9iag0KMTAgMCBvYmoNCjw8L0Rp\n" +
"ZmZlcmVuY2VzWyAxL2J1bGxldF0vVHlwZS9FbmNvZGluZz4+DQplbmRvYmoNCjExIDAgb2JqDQo8\n" +
"PC9GaWx0ZXIvRmxhdGVEZWNvZGUvTGVuZ3RoIDIwOD4+c3RyZWFtDQpIiVSQvQ7CMAyE9z6FRxBD\n" +
"2s5VF1g68CMK7GniVpGIE7np0LcnKQXEEEv25dOdLfbNoSETQFzYqRYD9IY04+gmVggdDoagKEEb\n" +
"FdZuqcpKDyLC7TwGtA31DqoqE9cojoFn2LSz7dxzl29BnFkjGxpgcyvujzhoJ++faJEC5FDXoLHP\n" +
"xP4o/UlajPKKLvNiNXQaRy8VsqQBocqL+l2Q9L/2Ibr+3f6+VmVelnUWiY+W4LTJ11tNzDHWsu6S\n" +
"KGUwhN+LeOeTZXrZS4ABAEPIaT8KDQplbmRzdHJlYW0NCmVuZG9iag0KMTIgMCBvYmoNCjw8L0Jh\n" +
"c2VGb250L0FyaWFsLUJvbGRNVC9FbmNvZGluZy9XaW5BbnNpRW5jb2RpbmcvRmlyc3RDaGFyIDMy\n" +
"L0ZvbnREZXNjcmlwdG9yIDEzIDAgUiAvTGFzdENoYXIgMTE2L1N1YnR5cGUvVHJ1ZVR5cGUvVHlw\n" +
"ZS9Gb250L1dpZHRoc1sgMjc4IDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAg\n" +
"MCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCA3MjIgMCAwIDcyMiAwIDYxMSAwIDAgMCAwIDAgMCAw\n" +
"IDAgMCA2NjcgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCA1NTYgNjExIDU1NiA2MTEg\n" +
"NTU2IDAgMCAwIDI3OCAwIDAgMjc4IDAgMCA2MTEgMCAwIDM4OSA1NTYgMzMzXT4+DQplbmRvYmoN\n" +
"CjEzIDAgb2JqDQo8PC9Bc2NlbnQgOTA1L0NhcEhlaWdodCAwL0Rlc2NlbnQgLTIxMS9GbGFncyAz\n" +
"Mi9Gb250QkJveFsgLTYyOCAtMzc2IDIwMzQgMTA0OF0vRm9udE5hbWUvQXJpYWwtQm9sZE1UL0l0\n" +
"YWxpY0FuZ2xlIDAvU3RlbVYgMTMzL1R5cGUvRm9udERlc2NyaXB0b3I+Pg0KZW5kb2JqDQoxNCAw\n" +
"IG9iag0KPDwvQmFzZUZvbnQvVGltZXNOZXdSb21hblBTTVQvRW5jb2RpbmcvV2luQW5zaUVuY29k\n" +
"aW5nL0ZpcnN0Q2hhciAzMi9Gb250RGVzY3JpcHRvciAxNSAwIFIgL0xhc3RDaGFyIDE3NC9TdWJ0\n" +
"eXBlL1RydWVUeXBlL1R5cGUvRm9udC9XaWR0aHNbIDI1MCAwIDAgMCAwIDAgMCAxODAgMzMzIDMz\n" +
"MyAwIDAgMjUwIDAgMjUwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDcyMiAw\n" +
"IDY2NyA3MjIgMCA1NTYgMCAwIDAgMCAwIDAgMCAwIDAgNTU2IDAgNjY3IDAgNjExIDAgMCA5NDQg\n" +
"MCAwIDAgMCAwIDAgMCAwIDAgNDQ0IDUwMCA0NDQgNTAwIDQ0NCAzMzMgNTAwIDUwMCAyNzggMCAw\n" +
"IDI3OCA3NzggNTAwIDUwMCA1MDAgMCAzMzMgMzg5IDI3OCA1MDAgNTAwIDcyMiAwIDUwMCAwIDAg\n" +
"MCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAw\n" +
"IDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDc2MF0+Pg0KZW5kb2Jq\n" +
"DQoxNSAwIG9iag0KPDwvQXNjZW50IDg5MS9DYXBIZWlnaHQgMC9EZXNjZW50IC0yMTYvRmxhZ3Mg\n" +
"MzQvRm9udEJCb3hbIC01NjggLTMwNyAyMDI4IDEwMDddL0ZvbnROYW1lL1RpbWVzTmV3Um9tYW5Q\n" +
"U01UL0l0YWxpY0FuZ2xlIDAvU3RlbVYgMC9UeXBlL0ZvbnREZXNjcmlwdG9yPj4NCmVuZG9iag0K\n" +
"MTYgMCBvYmoNCjw8L0Jhc2VGb250L0FyaWFsTVQvRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nL0Zp\n" +
"cnN0Q2hhciAzMi9Gb250RGVzY3JpcHRvciAxNyAwIFIgL0xhc3RDaGFyIDMyL1N1YnR5cGUvVHJ1\n" +
"ZVR5cGUvVHlwZS9Gb250L1dpZHRoc1sgMjc4XT4+DQplbmRvYmoNCjE3IDAgb2JqDQo8PC9Bc2Nl\n" +
"bnQgOTA1L0NhcEhlaWdodCAwL0Rlc2NlbnQgLTIxMS9GbGFncyAzMi9Gb250QkJveFsgLTY2NSAt\n" +
"MzI1IDIwMjggMTAzN10vRm9udE5hbWUvQXJpYWxNVC9JdGFsaWNBbmdsZSAwL1N0ZW1WIDAvVHlw\n" +
"ZS9Gb250RGVzY3JpcHRvcj4+DQplbmRvYmoNCjE4IDAgb2JqDQo8PC9CYXNlRm9udC9UaW1lc05l\n" +
"d1JvbWFuUFMtQm9sZEl0YWxpY01UL0VuY29kaW5nL1dpbkFuc2lFbmNvZGluZy9GaXJzdENoYXIg\n" +
"MzIvRm9udERlc2NyaXB0b3IgMTkgMCBSIC9MYXN0Q2hhciAxMjEvU3VidHlwZS9UcnVlVHlwZS9U\n" +
"eXBlL0ZvbnQvV2lkdGhzWyAyNTAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDI1MCAwIDAgMCAwIDAg\n" +
"MCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgNjY3IDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAw\n" +
"IDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgNTAwIDAgNDQ0IDAgNDQ0IDAg\n" +
"MCA1NTYgMjc4IDAgMCAyNzggMCA1NTYgNTAwIDUwMCAwIDM4OSAzODkgMjc4IDAgMCA2NjcgNTAw\n" +
"IDQ0NF0+Pg0KZW5kb2JqDQoxOSAwIG9iag0KPDwvQXNjZW50IDg5MS9DYXBIZWlnaHQgMC9EZXNj\n" +
"ZW50IC0yMTYvRmxhZ3MgOTgvRm9udEJCb3hbIC01NDcgLTMwNyAxMjA2IDEwMzJdL0ZvbnROYW1l\n" +
"L1RpbWVzTmV3Um9tYW5QUy1Cb2xkSXRhbGljTVQvSXRhbGljQW5nbGUgLTE1L1N0ZW1WIDEzMy9U\n" +
"eXBlL0ZvbnREZXNjcmlwdG9yPj4NCmVuZG9iag0KeHJlZg0KMCAyMA0KMDAwMDAwMDAwMCA2NTUz\n" +
"NSBmDQowMDAwMDAwMDE3IDAwMDAwIG4NCjAwMDAwMDAwNjYgMDAwMDAgbg0KMDAwMDAwMDEyMiAw\n" +
"MDAwMCBuDQowMDAwMDAwMjA5IDAwMDAwIG4NCjAwMDAwMDAzNDMgMDAwMDAgbg0KMDAwMDAwMTk0\n" +
"NiAwMDAwMCBuDQowMDAwMDAyMTA2IDAwMDAwIG4NCjAwMDAwMDIyNzEgMDAwMDAgbg0KMDAwMDAw\n" +
"MjMzOCAwMDAwMCBuDQowMDAwMDAyNDM2IDAwMDAwIG4NCjAwMDAwMDI0OTcgMDAwMDAgbg0KMDAw\n" +
"MDAwMjc3OCAwMDAwMCBuDQowMDAwMDAzMTM2IDAwMDAwIG4NCjAwMDAwMDMzMDIgMDAwMDAgbg0K\n" +
"MDAwMDAwMzgyMSAwMDAwMCBuDQowMDAwMDAzOTkwIDAwMDAwIG4NCjAwMDAwMDQxNDQgMDAwMDAg\n" +
"bg0KMDAwMDAwNDMwMyAwMDAwMCBuDQowMDAwMDA0NjkxIDAwMDAwIG4NCnRyYWlsZXINCjw8DQov\n" +
"Um9vdCAxIDAgUg0KL0luZm8gMyAwIFINCi9TaXplIDIwL0lEWzwxQzhFMDZCNEQ1OTRCQ0Q5NTYz\n" +
"RDczQkRDMEY0NzA2MD48MUM4RTA2QjRENTk0QkNEOTU2M0Q3M0JEQzBGNDcwNjA+XT4+DQpzdGFy\n" +
"dHhyZWYNCjQ4NzUNCiUlRU9GDQo=";
String sign = sign(base64, returnCertificates);
System.out.println("sign :" + sign);
}
}
| [
"Murthy AVSN"
]
| Murthy AVSN |
cba66db8e67a7192e9c7f7307e64e00ff14655d7 | 3cc5341f184ca252ff2cb4f91d5a7c720b3fe2f9 | /src/main/java/org/sfm/csv/impl/cellreader/CharCellValueReaderUnbox.java | 1ad549a99065952f6e9a765f71a790e3ab1c98ad | [
"MIT"
]
| permissive | a8t3r/SimpleFlatMapper | 966e5624759420ac49a3fbf581d5da17c6f0319b | a2f20edb6fd1749721b8e728b8ec5edf4f44191f | refs/heads/master | 2021-01-17T23:13:06.346141 | 2015-02-15T12:03:08 | 2015-02-15T12:03:08 | 30,813,419 | 0 | 0 | null | 2015-02-15T00:41:52 | 2015-02-15T00:41:52 | null | UTF-8 | Java | false | false | 739 | java | package org.sfm.csv.impl.cellreader;
import org.sfm.csv.CellValueReader;
import org.sfm.csv.impl.ParsingContext;
public class CharCellValueReaderUnbox implements CharCellValueReader {
private final CellValueReader<Character> reader;
public CharCellValueReaderUnbox(CellValueReader<Character> customReader) {
this.reader = customReader;
}
@Override
public char readChar(char[] chars, int offset, int length, ParsingContext parsingContext) {
return read(chars, offset, length, parsingContext).charValue();
}
@Override
public Character read(char[] chars, int offset, int length, ParsingContext parsingContext) {
return reader.read(chars, offset, length, parsingContext);
}
}
| [
"[email protected]"
]
| |
6eb1e271907d746ccf3d38cc0d2bc118ae8ece67 | e5653f4d33e77c0b5d80112def1b7bcbc2f734eb | /luajavaInAndroid/src/cn/iolove/luajava/LuaInvocationHandler.java | 54eddab789a7149243beee3595e86a5f211ad5c3 | []
| no_license | rokerdou/luajava | 6002e674af6d4625050c383c4c6b949d567c6172 | afb1c001de21f3411b8692d6c8eef22e57f8d81c | refs/heads/master | 2021-01-10T04:23:49.162126 | 2016-02-13T07:56:38 | 2016-02-13T07:56:38 | 49,375,170 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,522 | java | /*
* $Id: LuaInvocationHandler.java,v 1.4 2006/12/22 14:06:40 thiago Exp $
* Copyright (C) 2003-2007 Kepler Project.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package cn.iolove.luajava;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/**
* Class that implements the InvocationHandler interface.
* This class is used in the LuaJava's proxy system.
* When a proxy object is accessed, the method invoked is
* called from Lua
* @author Rizzato
* @author Thiago Ponte
*/
public class LuaInvocationHandler implements InvocationHandler
{
private LuaObject obj;
public LuaInvocationHandler(LuaObject obj)
{
this.obj = obj;
}
/**
* Function called when a proxy object function is invoked.
*/
public Object invoke(Object proxy, Method method, Object[] args) throws LuaException
{
synchronized(obj.L)
{
String methodName = method.getName();
LuaObject func = obj.getField(methodName);
if ( func.isNil() )
{
return null;
}
Class retType = method.getReturnType();
Object ret;
// Checks if returned type is void. if it is returns null.
if ( retType.equals( Void.class ) || retType.equals( void.class ) )
{
func.call( args , 0 );
ret = null;
}
else
{
ret = func.call(args, 1)[0];
if( ret != null && ret instanceof Double )
{
ret = LuaState.convertLuaNumber((Double) ret, retType);
}
}
return ret;
}
}
}
| [
"[email protected]"
]
| |
1c4dbb758257cc439bd0495435fda687517073b5 | 4c5d88d49cdd49663809941123ddf4222f72ccdb | /src/main/java/com/mb11/application/model/cricapidata/Series.java | afddf322a1dc2bdbb9598ce23b59a1cc1030966e | []
| no_license | dabhsams91/MB11 | 73bad675802c0b82a995b2015f85c338f4a5cf78 | 4c58d6af8c9bc68d446072c1f4d39b6bb7b4fcbd | refs/heads/master | 2020-04-14T23:37:35.792227 | 2019-03-05T18:32:24 | 2019-03-05T18:32:24 | 164,209,491 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,064 | java | package com.mb11.application.model.cricapidata;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
// TODO: Auto-generated Javadoc
/**
* The Class Series.
*/
@Entity
@Table(name = "Series")
public class Series {
/** The id. */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private long ID;
/** The series id. */
@NotNull
@Column(name = "seriesid", unique = true, length = 30)
private String seriesid;
/** The sname. */
@Column(nullable = false, length = 200)
private String sname;
@Column(nullable = false, length = 200)
private String short_name;
@Column(nullable = false, length = 30)
private String category;
/** The startdate. */
@Column(nullable = false)
private Date startdate;
/** The enddate. */
@Column(nullable = false)
private Date enddate;
/** The totalmatch. */
@Column(nullable = false)
private int totalmatch;
@Column(nullable = false)
private int totalteams;
@Column(nullable = false)
private Boolean status;
@ManyToMany(mappedBy = "series")
Set<MTeam> mTeams = new HashSet<>();
public Series() {
}
public Series(@NotNull String seriesid, String sname, String short_name, String category, Date startdate,
Date enddate, int totalmatch, int totalteams, Boolean status) {
super();
this.seriesid = seriesid;
this.sname = sname;
this.short_name = short_name;
this.category = category;
this.startdate = startdate;
this.enddate = enddate;
this.totalmatch = totalmatch;
this.totalteams = totalteams;
this.status = status;
}
public Series(@NotNull String seriesid, String sname, String short_name, String category, Date startdate,
Date enddate, int totalmatch, int totalteams, Boolean status, Set<MTeam> mTeams) {
super();
this.seriesid = seriesid;
this.sname = sname;
this.short_name = short_name;
this.category = category;
this.startdate = startdate;
this.enddate = enddate;
this.totalmatch = totalmatch;
this.totalteams = totalteams;
this.status = status;
this.mTeams = mTeams;
}
public long getID() {
return ID;
}
public void setID(long iD) {
ID = iD;
}
public String getSeriesid() {
return seriesid;
}
public void setSeriesid(String seriesid) {
this.seriesid = seriesid;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getShort_name() {
return short_name;
}
public void setShort_name(String short_name) {
this.short_name = short_name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public int getTotalmatch() {
return totalmatch;
}
public void setTotalmatch(int totalmatch) {
this.totalmatch = totalmatch;
}
public int getTotalteams() {
return totalteams;
}
public void setTotalteams(int totalteams) {
this.totalteams = totalteams;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
public Set<MTeam> getmTeams() {
return mTeams;
}
public void setmTeams(Set<MTeam> mTeams) {
this.mTeams = mTeams;
}
@Override
public String toString() {
return "Series [ID=" + ID + ", seriesid=" + seriesid + ", sname=" + sname + ", short_name=" + short_name
+ ", category=" + category + ", startdate=" + startdate + ", enddate=" + enddate + ", totalmatch="
+ totalmatch + ", totalteams=" + totalteams + ", status=" + status + ", mTeams=" + mTeams + "]";
}
}
| [
"yoges@DESKTOP-V61QEJH"
]
| yoges@DESKTOP-V61QEJH |
eff8d5cc03d6fb4d4734ecc0621c7b8396e3499e | 2a6638de93becc4fad6fea56f3f12632f0260c77 | /imooc-java-reflection/src/main/java/com/imooc/handler/thress/TwoFilter.java | c7ecd1b5b467c637960969dc0ca5a5eeddb587eb | []
| no_license | 917067089/lambda | b0df7de55203ccf0560c1ce2d49a90d111ddb87e | d652b6273f779f2d68e42fb49fd3f80e5c0f53b9 | refs/heads/master | 2022-07-05T12:55:32.682646 | 2020-02-08T14:41:57 | 2020-02-08T14:41:57 | 239,131,699 | 1 | 0 | null | 2022-06-21T02:45:45 | 2020-02-08T12:50:56 | Java | UTF-8 | Java | false | false | 727 | java | package com.imooc.handler.thress;
/**
* 去掉所有空格类
* 初数化StringBuffer sb使其为空,然后遍历原始字符串,当字符串不为空,则将该字符串添加到 sb 的尾部。从而得出最终结果
*/
public class TwoFilter implements Filter {
@Override
public void doFilter(Request request, Response response, FilterChain filterChain) {
String str = response.res;
StringBuffer sb = new StringBuffer();
for (int i=0;i<str.length();i++){
char ch = str.charAt(i);
if(ch != ' '){
sb.append(ch);
}
}
response.res = sb.toString();
filterChain.doFilter(request,response,filterChain);
}
}
| [
"[email protected]"
]
| |
534fa71e1bcf35639960850e5f6573f08da1877d | a685e5dcedc4e51e8be5a36200f535f7d36b7aff | /src/chao/android/tenyearsfromnow/CalendarFragment/YearlyCalendarFragment.java | 8b72c8f95b7377c85fa768f935e9860aec9221b6 | []
| no_license | chaowentan/10-Years-from-Now | 311a56257d70dab5039f9e4b03f84884a781e8c3 | 91405bf9da72acf55ed87b11c601a06c0e36516a | refs/heads/master | 2021-01-21T12:06:51.475177 | 2013-01-21T06:38:30 | 2013-01-21T06:38:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,387 | java | package chao.android.tenyearsfromnow.CalendarFragment;
import chao.android.tenyearsfromnow.R;
import chao.android.tenyearsfromnow.CalendarAdapter.YearlyCalendarAdapter;
import chao.android.tenyearsfromnow.R.layout;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class YearlyCalendarFragment extends ListFragment
{
YearlyCalendarAdapter mAdapter;
// ////////////////////////////////////////////////////////////////////////
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
mAdapter = new YearlyCalendarAdapter( getActivity() );
setListAdapter( mAdapter );
}
// ////////////////////////////////////////////////////////////////////////
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState )
{
return inflater.inflate( R.layout.yearly_calendar, container, false );
}
// ////////////////////////////////////////////////////////////////////////
@Override
public void onStart()
{
super.onStart();
getListView().setSelectionFromTop(
mAdapter.getPositionForCurrentTime(),
0 );
}
}
| [
"[email protected]"
]
| |
6f044deb1078aee184b4cdb0776039e718cbff67 | 3abd77888f87b9a874ee9964593e60e01a9e20fb | /sim/EJS/OSP_core/src/org/opensourcephysics/numerics/Root.java | 259b71efbfd861d1287633a92599f1a0c7e66414 | [
"MIT"
]
| permissive | joakimbits/Quflow-and-Perfeco-tools | 7149dec3226c939cff10e8dbb6603fd4e936add0 | 70af4320ead955d22183cd78616c129a730a9d9c | refs/heads/master | 2021-01-17T14:02:08.396445 | 2019-07-12T10:08:07 | 2019-07-12T10:08:07 | 1,663,824 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 15,793 | java | /*
* Open Source Physics software is free software as described near the bottom of this code file.
*
* For additional information and documentation on Open Source Physics please see:
* <http://www.opensourcephysics.org/>
*/
package org.opensourcephysics.numerics;
/**
* Class Root defines various root finding algorithms.
*
* This class cannot be subclassed or instantiated because all methods are static.
*
* @author Wolfgang Christian
*/
public class Root {
static final int MAX_ITERATIONS = 15;
private Root() {} // prohibit instantiation because all methods are static
/**
* Solves for the real roots of the quadratic equation
* ax<sup>2</sup>+bx+c=0.
*
* @param a double quadratic term coefficient
* @param b double linear term coefficient
* @param c double constant term
* @return double[] an array containing the two roots.
*/
public static double[] quadraticReal(final double a, final double b, final double c) {
final double roots[] = new double[2];
final double q = -0.5*(b+((b<0.0) ? -1.0 : 1.0)*Math.sqrt(b*b-4.0*a*c));
roots[0] = q/a;
roots[1] = c/q;
return roots;
}
/**
* Solves for the complex roots of the quadratic equation
* ax<sup>2</sup>+bx+c=0.
*
* @param a double quadratic term coefficient
* @param b double linear term coefficient
* @param c double constant term
* @return double[] an array containing the two roots.
*/
public static double[][] quadratic(final double a, final double b, final double c) {
final double roots[][] = new double[2][2];
double disc = b*b-4.0*a*c;
if(disc<0) { // roots are complex
roots[1][0] = roots[0][0] = -b/2/a;
roots[1][1] -= roots[0][1] = Math.sqrt(-disc)/2/a;
return roots;
}
final double q = -0.5*(b+((b<0.0) ? -1.0 : 1.0)*Math.sqrt(disc));
roots[0][0] = q/a;
roots[1][0] = c/q;
return roots;
}
/**
* Solves for the roots of the cubic equation
* ax<sup>3</sup>+bx<sup>2</sup>+cx+d=0.
*
* @param a double cubic term coefficient
* @param b double quadratic term coefficient
* @param c double linear term coefficient
* @param d double constant term
* @return double[] an array containing the two roots.
*/
public static double[][] cubic(final double a, final double b, final double c, final double d) {
final double roots[][] = new double[3][2];
// use standard form x<sup>3</sup>+Ax<sup>2</sup>+Bx+C=0.
double A = b/a, B = c/a, C = d/a;
double A2 = A*A;
double Q = (3*B-A2)/9;
double R = (9*A*B-27*C-2*A*A2)/54;
double D = Q*Q*Q+R*R;
if(D==0) { // all roots are real and at least two are equal
double S = (R<0) ? -Math.pow(-R, 1.0/3) : Math.pow(R, 1.0/3);
roots[0][0] = -A/3+2*S;
roots[2][0] = roots[1][0] = -A/3-S;
} else if(D>0) { // one root is real and two are complex
D = Math.sqrt(D);
double S = (R+D<0) ? -Math.pow(-R-D, 1.0/3) : Math.pow(R+D, 1.0/3);
double T = (R-D<0) ? -Math.pow(-R+D, 1.0/3) : Math.pow(R-D, 1.0/3);
roots[0][0] = -A/3+S+T;
roots[2][0] = roots[1][0] = -A/3-(S+T)/2;
//complex parts
roots[2][1] -= roots[1][1] = Math.sqrt(3)*(S-T)/2;
} else { // D<0; all roots are real and unequal
Q = -Q; // make Q positive
double theta = Math.acos(R/Math.sqrt(Q*Q*Q))/3;
Q = 2*Math.sqrt(Q);
A = A/3;
roots[0][0] = Q*Math.cos(theta)-A;
roots[1][0] = Q*Math.cos(theta+2*Math.PI/3)-A;
roots[2][0] = Q*Math.cos(theta+4*Math.PI/3)-A;
}
return roots;
}
/**
* Solves for the roots of the polynomial with the given coefficients c:
* c[0] + c[1] * x + c[2] * x^2 + ....
*
* The roots are the complex eigenvalues of the companion matrix.
*
* @param double[] c coefficients
* @return double[][] complex roots
*/
public static double[][] polynomial(double[] c) {
int n = c.length;
int highest = n-1;
for(int i = highest; i>0; i--) {
if(c[highest]!=0) {
break;
}
highest = i;
}
double ch = c[highest]; //highest nonzero power coefficient
double[][] companion = new double[highest][highest];
companion[0][highest-1] = -c[0]/ch;
for(int i = 0; i<highest-1; i++) {
companion[0][i] = -c[highest-i-1]/ch;
companion[i+1][i] = 1;
}
EigenvalueDecomposition eigen = new EigenvalueDecomposition(companion);
double[][] roots = new double[2][];
roots[0] = eigen.getRealEigenvalues();
roots[1] = eigen.getImagEigenvalues();
return roots;
}
/**
* Implements Newton's method for finding the root of a function.
* The derivative is calculated numerically using the central difference approximation.
*
* @param f Function the function
* @param x double guess the root
* @param tol double computation tolerance
* @return double the root or NaN if root not found.
*/
public static double newton(final Function f, double x, final double tol) {
int count = 0;
while(count<MAX_ITERATIONS) {
double xold = x; // save the old value to test for convergence
double df = 0;
try {
//df = Derivative.romberg(f, x, Math.max(0.001, 0.001*Math.abs(x)), tol/10);
df = fxprime(f, x, tol);
} catch(NumericMethodException ex) {
return Double.NaN; // did not converve
}
x -= f.evaluate(x)/df;
if(Util.relativePrecision(Math.abs(x-xold), x)<tol) {
return x;
}
count++;
}
NumericsLog.fine(count+" newton root trials made - no convergence achieved"); //$NON-NLS-1$
return Double.NaN; // did not converve in max iterations
}
/**
* Implements Newton's method for finding the root of a function.
*
* @param f Function the function
* @param df Function the derivative of the function
* @param x double guess the root
* @param tol double computation tolerance
* @return double the root or NaN if root not found.
*/
public static double newton(final Function f, final Function df, double x, final double tol) {
int count = 0;
while(count<MAX_ITERATIONS) {
double xold = x; // save the old value to test for convergence
// approximate the derivative using the given derivative function
x -= f.evaluate(x)/df.evaluate(x);
if(Util.relativePrecision(Math.abs(x-xold), x)<tol) {
return x;
}
count++;
}
NumericsLog.fine(count+" newton root trials made - no convergence achieved"); //$NON-NLS-1$
return Double.NaN; // did not converve in max iterations
}
/**
* Implements the bisection method for finding the root of a function.
* @param f Function the function
* @param x1 double lower
* @param x2 double upper
* @param tol double computation tolerance
* @return double the root or NaN if root not found
*/
public static double bisection(final Function f, double x1, double x2, final double tol) {
int count = 0;
int maxCount = (int) (Math.log(Math.abs(x2-x1)/tol)/Math.log(2));
maxCount = Math.max(MAX_ITERATIONS, maxCount)+2;
double y1 = f.evaluate(x1), y2 = f.evaluate(x2);
if(y1*y2>0) { // y1 and y2 must have opposite sign
NumericsLog.fine(count+" bisection root - interval endpoints must have opposite sign"); //$NON-NLS-1$
return Double.NaN; // interval does not contain a root
}
while(count<maxCount) {
double x = (x1+x2)/2;
double y = f.evaluate(x);
if(Util.relativePrecision(Math.abs(x1-x2), x)<tol) {
return x;
}
if(y*y1>0) { // replace end-point that has the same sign
x1 = x;
y1 = y;
} else {
x2 = x;
y2 = y;
}
count++;
}
NumericsLog.fine(count+" bisection root trials made - no convergence achieved"); //$NON-NLS-1$
return Double.NaN; // did not converge in max iterations
}
/**
* Implements Newton's method for finding the root but switches to the bisection method if the
* the estimate is not between xleft and xright.
*
* Method contributed by: J E Hasbun
*
* A Newton Raphson result is accepted if it is within the known bounds,
* else a bisection step is taken.
* Ref: Computational Physics by P. L. Devries (J. Wiley, 1993)
* input: [xleft,xright] is the interval wherein fx() has a root, icmax is the
* maximum iteration number, and tol is the tolerance level
* output: returns xbest as the value of the function
* Reasonable values of icmax and tol are 25, 5e-3.
*
* Returns the root or NaN if root not found.
*
* @param xleft double
* @param xright double
* @param tol double tolerance
* @param icmax int number of trials
* @return double the root
*/
public static double newtonBisection(Function f, double xleft, double xright, double tol, int icmax) {
double rtest = 10*tol;
double xbest, fleft, fright, fbest, derfbest, delta;
int icount = 0, iflag = 0; //loop counter
//variables
fleft = f.evaluate(xleft);
fright = f.evaluate(xright);
if(fleft*fright>=0) {
iflag = 1;
}
switch(iflag) {
case 1 :
System.out.println("No solution possible"); //$NON-NLS-1$
break;
}
if(Math.abs(fleft)<=Math.abs(fright)) {
xbest = xleft;
fbest = fleft;
} else {
xbest = xright;
fbest = fright;
}
derfbest = fxprime(f, xbest, tol);
while((icount<icmax)&&(rtest>tol)) {
icount++;
//decide Newton-Raphson or Bisection method to do:
if((derfbest*(xbest-xleft)-fbest)*(derfbest*(xbest-xright)-fbest)<=0) {
//Newton-Raphson step
delta = -fbest/derfbest;
xbest = xbest+delta;
//System.out.println("Newton: count="+icount+", fx="+fbest);
} else {
//bisection step
delta = (xright-xleft)/2;
xbest = (xleft+xright)/2;
//System.out.println("Bisection: count="+icount+", fx ="+fbest);
}
rtest = Math.abs(delta/xbest);
//Compare the relative error to the tolerance
if(rtest<=tol) {
//if the error is small, the root has been found
//System.out.println("root found="+xbest);
} else {
//the error is still large, so loop
fbest = f.evaluate(xbest);
derfbest = fxprime(f, xbest, tol);
//adjust brackets
if(fleft*fbest<=0) {
//root is in the xleft subinterval:
xright = xbest;
fright = fbest;
} else {
//root is in the xright subinterval:
xleft = xbest;
fleft = fbest;
}
}
}
//reach here if either the error is too large or icount reached icmax
if((icount>icmax)||(rtest>tol)) {
NumericsLog.fine(icmax+" Newton and bisection trials made - no convergence achieved"); //$NON-NLS-1$
return Double.NaN;
}
return xbest;
}
/*
* Inputs
* feqs - the function containing n equations with n unknowns and whose zeros we seek
* xx - the array containing the guess to the solutions
* max - the maximum iteration number
* tol - the tolerance level
* @return double the error
*/
public static double newtonMultivar(VectorFunction feqs, double xx[], int max, double tol) {
int Ndim = xx.length;
double[] xxn = new double[Ndim];
double[] F = new double[Ndim];
int Iterations = 0;
double err, relerr;
err = 9999.;
relerr = 9999.;
//Use the Newton-Raphson method for systems of equations - employs the Jacobian
//Needs a good guess - use one found by a grid method if one is not available
while((err>tol*1.e-6)&&(relerr>tol*1.e-6)&&(Iterations<max)) {
Iterations++;
LUPDecomposition lu = new LUPDecomposition(getJacobian(feqs, Ndim, xx, tol/100.));
//use the LUPDecomposition's solve method
F = feqs.evaluate(xx, F); //the functions
xxn = lu.solve(F); //the corrections
for(int i = 0; i<Ndim; i++) {
xxn[i] = xx[i]-xxn[i]; //new guesses
}
err = (xx[0]-xxn[0])*(xx[0]-xxn[0]);
relerr = xx[0]*xx[0];
xx[0] = xxn[0];
for(int i = 1; i<Ndim; i++) {
err = err+(xx[i]-xxn[i])*(xx[i]-xxn[i]);
relerr = relerr+xx[i]*xx[i];
xx[i] = xxn[i];
}
err = Math.sqrt(err);
relerr = err/(relerr+tol);
}
return err;
}
/**
* Computes the Jacobian using a finite difference approximation.
* Contributed to OSP by J E Hasbun 2007.
*
* @param feqs VectorFunction - the function containing n equations
* @param n int - number of equations
* @param xx double[] - the variable array at which the Jacobian is calculated
* @param tol double - the small change to find the derivatives
* @return double[][] J - the square matrix containing the Jacobian
*/
public static double[][] getJacobian(VectorFunction feqs, int n, double xx[], double tol) {
//builds the Jacobian
//xxp, xxm contain the varied parameter values to evaluate the equations on
//fp, fm comtain the transpose of the function evaluations needed in the Jacobian
//The Jacobian is calculated by the finite difference method
double[][] J = new double[n][n];
double[][] xxp = new double[n][n];
double[][] xxm = new double[n][n];
double[][] fp = new double[n][n];
double[][] fm = new double[n][n];
//build the coordinates for the derivatives
for(int i = 0; i<n; i++) {
for(int j = 0; j<n; j++) {
xxp[i][j] = xx[j];
xxm[i][j] = xx[j];
}
xxp[i][i] = xxp[i][i]+tol;
xxm[i][i] = xxm[i][i]-tol;
}
for(int i = 0; i<n; i++) { //f's here are built in transpose form
fp[i] = feqs.evaluate(xxp[i], fp[i]); //i=1: f's at x+tol; i=2 f's at y+tol, etc
fm[i] = feqs.evaluate(xxm[i], fm[i]); //i=1: f's at x-tol; i=2 f's at y-tol, etc
}
//Builds the Jacobian by the differences methods
//becasue the f's above are in transpose form, we swap i, j in the derivative
for(int i = 0; i<n; i++) {
for(int j = 0; j<n; j++) {
J[i][j] = (fp[j][i]-fm[j][i])/tol/2.; //the derivatives df_i/dx_j
}
}
return J;
}
/**
* Central difference approximation to the derivative for use in Newton's mehtod.
* @param f Function
* @param x double
* @param tol double
* @return double
*/
final static double fxprime(Function f, double x, double tol) {
//numerical derivative evaluation
double del = tol/10;
double der = (f.evaluate(x+del)-f.evaluate(x-del))/del/2.0;
return der;
}
}
/*
* Open Source Physics software is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License (GPL) as
* published by the Free Software Foundation; either version 2 of the License,
* or(at your option) any later version.
*
* Code that uses any portion of the code in the org.opensourcephysics package
* or any subpackage (subdirectory) of this package must must also be be released
* under the GNU GPL license.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA
* or view the license online at http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2007 The Open Source Physics project
* http://www.opensourcephysics.org
*/
| [
"[email protected]"
]
| |
b02a00747467c222a701f824fe4b89f867c669c8 | 18b731ab437622d5936e531ece88c3dd0b2bb2ea | /pbtd-central/src/main/java/com/pbtd/playclick/base/common/web/RequestUtil.java | 29800d12b6e91b6ef7b2f5429dccc4b6f39810b7 | []
| no_license | harry0102/bai_project | b6c130e7235d220f2f0d4294a3f87b58f77cd265 | 674c6ddff7cf5dae514c69d2639d4b0245c0761f | refs/heads/master | 2021-10-07T20:32:15.985439 | 2018-12-05T06:50:11 | 2018-12-05T06:50:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,931 | java | package com.pbtd.playclick.base.common.web;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.time.DateUtils;
public class RequestUtil {
public static String getString(HttpServletRequest request, String key) {
return getString(request, key, null);
}
public static String getString(HttpServletRequest request, String key, String defaultValue) {
String value = request.getParameter(key);
if (value == null) {
return defaultValue;
}
return value;
}
public static Integer getInteger(HttpServletRequest request, String key) {
return getInteger(request, key, null);
}
public static Integer getInteger(HttpServletRequest request, String key, Integer defaultValue) {
String value = request.getParameter(key);
if (value == null || value.trim().equals("")) {
return defaultValue;
} else {
return new Integer(value);
}
}
public static int getInt(HttpServletRequest request, String key) {
return getInt(request, key, Integer.MIN_VALUE);
}
public static int getInt(HttpServletRequest request, String key, int defaultValue) {
String value = request.getParameter(key);
if (value == null || value.trim().equals("")) {
return defaultValue;
} else {
return Integer.parseInt(value);
}
}
public static Double getDouble2(HttpServletRequest request, String key) {
return getDouble2(request, key, null);
}
public static Double getDouble2(HttpServletRequest request, String key, Double defaultValue) {
String value = request.getParameter(key);
if (value == null || value.trim().equals("")) {
return defaultValue;
} else {
return new Double(value);
}
}
public static double getDouble(HttpServletRequest request, String key) {
return getDouble(request, key, Double.MIN_VALUE);
}
public static double getDouble(HttpServletRequest request, String key, double defaultValue) {
String value = request.getParameter(key);
if (value == null || value.trim().equals("")) {
return defaultValue;
} else {
return Double.parseDouble(value);
}
}
private static Date parseDate(String input) {
Date date = null;
try {
date = DateUtils.parseDate(input, new String[]{"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM-dd"});
} catch (ParseException e) {
}
return date;
}
/**
* 把HttpServletRequest请求参数包装成Map
*
* @param request
* @param emptiable 可空?
* @return
*/
public static Map<String, Object> asMap(HttpServletRequest request, boolean emptiable) {
Map<String, Object> params = new HashMap<String, Object>();
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = ((String) names.nextElement()).trim();
if (name.equalsIgnoreCase("idField") || name.equalsIgnoreCase("nameField")) {
continue;
}
String[] values = request.getParameterValues(name);
String key = name.replaceAll("\\[([^\\]]*)\\]", "_$1");
if (values.length == 1) {
key = key.replaceAll("_$", "");
String val = values[0].trim();
if (val.length() > 0) {
Date date = parseDate(val);
params.put(key, (date == null ? val : date));
} else if (emptiable) {
params.put(key, "");
}
} else {
boolean isDate = parseDate(values[0].trim()) == null ? (parseDate(values[1].trim()) == null ? false : true) : true;
List<Object> vals = new ArrayList<Object>();
for (int i = 0; i < values.length; i++) {
String val = values[i].trim();
if (val.length() > 0) {
Date date = parseDate(val);
vals.add(date == null ? val : date);
} else if (emptiable || isDate) {
vals.add("");
}
}
if (vals.size() > 0) {
params.put(key, vals);
}
}
}
return params;
}
public static Map<String, Object> asMap(HttpServletRequest request) {
return asMap(request, false);
}
/**
* 把HttpServletRequest请求参数包装成Map
* @param flag 是否对日期格式进行处理
* @param request
* @param emptiable 可空?
* @return
*/
public static Map<String, Object> asMap(HttpServletRequest request,boolean flag,boolean emptiable ){
Map<String, Object> params = new HashMap<String, Object>();
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = ((String) names.nextElement()).trim();
if (name.equalsIgnoreCase("idField") || name.equalsIgnoreCase("nameField")) {
continue;
}
String[] values = request.getParameterValues(name);
String key = name.replaceAll("\\[([^\\]]*)\\]", "_$1");
if (values.length == 1) {
key = key.replaceAll("_$", "");
String val = values[0].trim();
if (val.length() > 0) {
if(flag){
Date date = parseDate(val);
params.put(key, (date == null ? val : date));
}else{
params.put(key, val);
}
} else if (emptiable) {
params.put(key, "");
}
} else {
boolean isDate = parseDate(values[0].trim()) == null ? (parseDate(values[1].trim()) == null ? false : true) : true;
List<Object> vals = new ArrayList<Object>();
for (int i = 0; i < values.length; i++) {
String val = values[i].trim();
if (val.length() > 0) {
if(flag){
Date date = parseDate(val);
vals.add(date == null ? val : date);
}else{
vals.add(val);
}
} else if (emptiable || isDate) {
vals.add("");
}
}
if (vals.size() > 0) {
params.put(key, vals);
}
}
}
return params;
}
public static <T> T applyUpdate(T newObj, T oldObj) throws ServletException {
try {
BeanInfo info = Introspector.getBeanInfo(newObj.getClass());
PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
for (PropertyDescriptor descriptor : descriptors) {
Method read = descriptor.getReadMethod();
if (read != null && read.invoke(newObj) == null) {
Method write = descriptor.getWriteMethod();
if (write != null) {
write.invoke(newObj, read.invoke(oldObj));
}
}
}
return newObj;
} catch (Exception e) {
throw new ServletException(e);
}
}
}
| [
"[email protected]"
]
| |
59ebe7108d721685d8f1e176849b52cd4fae03ce | fbbaeb7d16b410e3c9d83735f0ce47f4836240ea | /src/org/tamanegi/wallpaper/multipicture/MultiPictureSetting.java | 83841ef20a2190651cedccda62d95d9217b9fecd | []
| no_license | isimsoyad/MultiPictureLiveWallpaper | eaa69303f037feb6aa3c6186d4b562a40d5f345e | 3c8c61396a5c8248be7d71043dd7814c59cd3688 | refs/heads/master | 2021-01-23T14:14:23.320047 | 2016-01-06T05:57:11 | 2016-01-06T05:57:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 30,782 | java | package org.tamanegi.wallpaper.multipicture;
import java.lang.reflect.Method;
import java.util.IllegalFormatException;
import org.tamanegi.wallpaper.multipicture.picsource.AlbumSource;
import org.tamanegi.wallpaper.multipicture.picsource.FolderSource;
import org.tamanegi.wallpaper.multipicture.picsource.PictureUtils;
import org.tamanegi.wallpaper.multipicture.picsource.SingleSource;
import org.tamanegi.wallpaper.multipicture.plugin.PictureSourceContract;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
public class MultiPictureSetting extends PreferenceActivity
{
public static final String SCREEN_DEFAULT = "default";
public static final String SCREEN_KEYGUARD = "keyguard";
public static final String SCREEN_ENABLE_KEY = "screen.%s.enable";
public static final String SCREEN_PICSOURCE_KEY = "screen.%s.picsource";
public static final String SCREEN_PICSOURCE_DESC_KEY =
"screen.%s.picsource.desc";
public static final String SCREEN_PICSOURCE_SERVICE_KEY =
"screen.%s.picsource.service";
public static final String SCREEN_PICSOURCE_SERIAL_KEY =
"screen.picsource.serial";
public static final String SCREEN_BGCOLOR_KEY = "screen.%s.bgcolor";
public static final String SCREEN_BGCOLOR_CUSTOM_KEY =
"screen.%s.bgcolor.custom";
public static final String SCREEN_CLIP_KEY = "screen.%s.clipratio";
public static final String SCREEN_SATURATION_KEY = "screen.%s.saturation";
public static final String SCREEN_OPACITY_KEY = "screen.%s.opacity";
public static final String SCREEN_RECURSIVE_KEY = "screen.%s.recursive";
public static final String SCREEN_ORDER_KEY = "screen.%s.order";
public static final String SCREEN_RESCAN_KEY = "screen.%s.rescan";
public static final String SCREEN_MEDIAPROVIDER_KEY =
"screen.%s.mediaprovider";
public static final String SCREEN_TYPE_KEY = "screen.%s.type";
public static final String SCREEN_FILE_KEY = "screen.%s.file";
public static final String SCREEN_FOLDER_KEY = "screen.%s.folder";
public static final String SCREEN_BUCKET_KEY = "screen.%s.bucket";
private static final String DEFAULT_CLIP_KEY = "draw.clipratio";
private static final String DEFALUT_RECURSIVE_KEY = "folder.recursive";
private static final String DEFAULT_ORDER_KEY = "folder.order";
private static final int REQUEST_CODE_PICSOURCE = 1;
private static final int MIN_MEMORY_CLASS = 16;
private static final int MAX_MEMORY_CLASS = 24;
private static final int MAX_LARGE_MEMORY_CLASS = 48;
private static final String TAG = "MultiPictureSetting";
private SharedPreferences pref;
private PreferenceGroup pref_group;
private ContentResolver resolver;
private Handler handler;
private ScreenPickerPreference screen_picker;
private int pickable_screen = 0;
private int all_screen_mask = 0;
private PictureSourcePreference cur_item = null;
private ComponentName cur_comp = null;
private String cur_key = null;
private boolean cur_is_default = false;
public static String getIndexString(int idx)
{
return (idx >= 0 ? String.valueOf(idx) : SCREEN_DEFAULT);
}
public static String getKey(String base, int idx)
{
return getKey(base, getIndexString(idx));
}
public static String getKey(String base, String key)
{
if(SCREEN_DEFAULT.equals(key)) {
if(SCREEN_CLIP_KEY.equals(base)) {
return DEFAULT_CLIP_KEY;
}
if(SCREEN_RECURSIVE_KEY.equals(base)) {
return DEFALUT_RECURSIVE_KEY;
}
if(SCREEN_ORDER_KEY.equals(base)) {
return DEFAULT_ORDER_KEY;
}
}
return String.format(base, key);
}
public static int getAutoMemoryClass(Context context)
{
ActivityManager amgr = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
int mclass = amgr.getMemoryClass();
int large_mclass = getLargeMemoryClass(amgr);
if(large_mclass > 0) {
return Math.min(Math.max(large_mclass, MIN_MEMORY_CLASS),
MAX_LARGE_MEMORY_CLASS);
}
else {
return Math.min(Math.max(mclass, MIN_MEMORY_CLASS),
MAX_MEMORY_CLASS);
}
}
private static int getLargeMemoryClass(ActivityManager amgr)
{
try {
Method m = ActivityManager.class.getMethod(
"getLargeMemoryClass", (Class[])null);
return (Integer)m.invoke(amgr);
}
catch(Exception e) {
// ignore
return -1;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref);
pref = PreferenceManager.getDefaultSharedPreferences(this);
resolver = getContentResolver();
handler = new Handler();
if(! "org.tamanegi.wallpaper.multipicture".equals(getPackageName())) {
getPreferenceScreen().removePreference(
getPreferenceManager().findPreference("other.cat"));
}
else {
getPreferenceManager().findPreference("other.dnt")
.setOnPreferenceClickListener(new OnDntClickListener());
}
// setup screen-N setting item
pref_group = (PreferenceGroup)
getPreferenceManager().findPreference("screen.cat");
for(int i = 0; i < ScreenPickerPreference.SCREEN_COUNT; i++) {
addScreenPreferences(i, true);
all_screen_mask |= (1 << i);
}
screen_picker = (ScreenPickerPreference)
getPreferenceManager().findPreference("screen.picker");
screen_picker.setOnPreferenceClickListener(
new ScreenPickerClickListener());
screen_picker.setScreenPickedListener(new ScreenPickerListener());
if(pickable_screen == all_screen_mask) {
screen_picker.setEnabled(false);
}
// setup default type item
PictureSourcePreference def_picsource = (PictureSourcePreference)
getPreferenceManager().findPreference(
getKey(SCREEN_PICSOURCE_KEY, -1));
convertPictureSourcePreference(def_picsource, -1);
def_picsource.setOnPreferenceChangeListener(
new OnPictureSourceChangeListener(-1));
updatePictureSourceSummary(def_picsource, -1);
ListPreference def_color = (ListPreference)
getPreferenceManager().findPreference(
getKey(SCREEN_BGCOLOR_KEY, -1));
def_color.setOnPreferenceChangeListener(
new OnColorChangeListener(-1));
updateColorSummary(def_color, null);
// setup keyguard screen item
PictureSourcePreference keyguard_picsource = (PictureSourcePreference)
getPreferenceManager().findPreference(
getKey(SCREEN_PICSOURCE_KEY, SCREEN_KEYGUARD));
keyguard_picsource.setShowDefault(true);
keyguard_picsource.setOnPreferenceChangeListener(
new OnPictureSourceChangeListener(SCREEN_KEYGUARD, false));
updatePictureSourceSummary(keyguard_picsource, SCREEN_KEYGUARD, false);
ListPreference keyguard_color = (ListPreference)
getPreferenceManager().findPreference(
getKey(SCREEN_BGCOLOR_KEY, SCREEN_KEYGUARD));
keyguard_color.setOnPreferenceChangeListener(
new OnColorChangeListener(SCREEN_KEYGUARD));
updateColorSummary(keyguard_color, null);
// setup maximum memory usage item
getPreferenceManager().findPreference("memory.max").
setOnPreferenceChangeListener(new OnMaximumMemoryChangeListener());
// backward compatibility
String duration_min_str = pref.getString("folder.duration", null);
String duration_sec_str = pref.getString("folder.duration_sec", null);
if(duration_sec_str == null) {
int duration_sec = (duration_min_str == null ? 60 * 60 :
Integer.parseInt(duration_min_str) * 60);
ListPreference duration = (ListPreference)
getPreferenceManager().findPreference("folder.duration_sec");
duration.setValue(Integer.toString(duration_sec));
}
boolean workaround_sense_val =
pref.getBoolean("workaround.htcsense", true);
String workaround_launcher_str =
pref.getString("workaround.launcher", null);
if(workaround_launcher_str == null) {
ListPreference workaround_launcher = (ListPreference)
getPreferenceManager().findPreference("workaround.launcher");
workaround_launcher.setValue(
(pref.contains("workaround.htcsense") ?
(workaround_sense_val ? "htc_sense" : "none") :
getString(R.string.workaround_default)));
}
// for summary
setupValueSummary(getKey(SCREEN_CLIP_KEY, -1),
R.string.pref_screen_clipratio_summary);
setupValueSummary(getKey(SCREEN_SATURATION_KEY, -1),
R.string.pref_screen_saturation_summary);
setupValueSummary(getKey(SCREEN_OPACITY_KEY, -1),
R.string.pref_screen_opacity_summary);
setupValueSummary(getKey(SCREEN_CLIP_KEY, SCREEN_KEYGUARD),
R.string.pref_screen_clipratio_summary);
setupValueSummary(getKey(SCREEN_SATURATION_KEY, SCREEN_KEYGUARD),
R.string.pref_screen_saturation_summary);
setupValueSummary(getKey(SCREEN_OPACITY_KEY, SCREEN_KEYGUARD),
R.string.pref_screen_opacity_summary);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.setting_options, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId() == R.id.menu_share) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,
getString(R.string.share_text));
startActivity(Intent.createChooser(
intent, getString(R.string.menu_share)));
}
catch(Exception e) {
e.printStackTrace();
// ignore
}
return true;
}
else if(item.getItemId() == R.id.menu_qr) {
startActivity(
new Intent(getApplicationContext(), QRViewer.class));
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data)
{
if(cur_item == null || resultCode == RESULT_CANCELED || data == null) {
Log.d(TAG, "picture source: canceled: " + resultCode + ", " + data);
return;
}
String desc = data.getStringExtra(
PictureSourceContract.EXTRA_DESCRIPTION);
if(desc == null) {
desc = "";
}
Parcelable serv = data.getParcelableExtra(
PictureSourceContract.EXTRA_SERVICE_NAME);
if(serv == null || ! (serv instanceof ComponentName)) {
Log.d(TAG, "picture source: no serviceName: " + serv);
return;
}
String service_val = ((ComponentName)serv).flattenToString();
cur_item.setValue(cur_comp);
persistPictureSourceInfo(cur_key, desc, service_val);
updatePictureSourceSummary(cur_item, cur_key, cur_is_default);
cur_item = null;
cur_key = null;
Log.d(TAG, "picture source: apply: " + serv);
}
private void addScreenPreferences(int idx, boolean check_default)
{
String picsource_key = getKey(SCREEN_PICSOURCE_KEY, idx);
String type_key = getKey(SCREEN_TYPE_KEY, idx);
String fname_key = getKey(SCREEN_FILE_KEY, idx);
String bgcolor_key = getKey(SCREEN_BGCOLOR_KEY, idx);
String clip_key = getKey(SCREEN_CLIP_KEY, idx);
String satu_key = getKey(SCREEN_SATURATION_KEY, idx);
String opac_key = getKey(SCREEN_OPACITY_KEY, idx);
if(check_default) {
String picsource_str = pref.getString(picsource_key, null);
String type_str = pref.getString(type_key, null);
String fname = pref.getString(fname_key, null);
String bgcolor = pref.getString(bgcolor_key, "use_default");
String clip = pref.getString(clip_key, "use_default");
String satu = pref.getString(satu_key, "use_default");
String opac = pref.getString(opac_key, "use_default");
if(((picsource_str == null &&
((type_str == null && fname == null) ||
("use_default".equals(type_str)))) ||
"".equals(picsource_str)) &&
"use_default".equals(bgcolor) &&
"use_default".equals(clip) &&
"use_default".equals(satu) &&
"use_default".equals(opac)) {
return;
}
}
// group for each screen
PreferenceScreen sgroup =
getPreferenceManager().createPreferenceScreen(this);
sgroup.setTitle(
getString(R.string.pref_cat_picture_screen_title, idx + 1));
sgroup.setSummary(
getString((idx == 0 ?
R.string.pref_cat_picture_screen_left_summary :
R.string.pref_cat_picture_screen_summary), idx + 1));
sgroup.setOrder(idx + 1);
pref_group.addPreference(sgroup);
// screen type
PictureSourcePreference picsource = new PictureSourcePreference(this);
picsource.setKey(picsource_key);
picsource.setTitle(R.string.pref_screen_type_title);
picsource.setDialogTitle(R.string.pref_screen_type_title);
picsource.setSummary(R.string.pref_screen_type_base_summary);
picsource.setShowDefault(true);
picsource.setOnPreferenceChangeListener(
new OnPictureSourceChangeListener(idx));
sgroup.addPreference(picsource);
convertPictureSourcePreference(picsource, idx);
updatePictureSourceSummary(picsource, idx);
// background color
ListPreference color = new ListPreference(this);
color.setKey(bgcolor_key);
color.setTitle(R.string.pref_screen_bgcolor_title);
color.setDialogTitle(color.getTitle());
color.setSummary(R.string.pref_screen_bgcolor_summary);
color.setEntries(R.array.pref_screen_bgcolor_entries);
color.setEntryValues(R.array.pref_screen_bgcolor_entryvalues);
color.setDefaultValue("use_default");
color.setOnPreferenceChangeListener(
new OnColorChangeListener(idx));
sgroup.addPreference(color);
updateColorSummary(color, null);
// clip ratio
ListPreference clip = new ListPreference(this);
clip.setKey(clip_key);
clip.setTitle(R.string.pref_screen_clipratio_title);
clip.setDialogTitle(clip.getTitle());
clip.setSummary(R.string.pref_screen_clipratio_summary);
clip.setEntries(R.array.pref_screen_clipratio_entries);
clip.setEntryValues(R.array.pref_screen_clipratio_entryvalues);
clip.setDefaultValue("use_default");
sgroup.addPreference(clip);
setupValueSummary(clip_key, R.string.pref_screen_clipratio_summary);
// saturation
ListPreference satu = new ListPreference(this);
satu.setKey(satu_key);
satu.setTitle(R.string.pref_screen_saturation_title);
satu.setDialogTitle(satu.getTitle());
satu.setSummary(R.string.pref_screen_saturation_summary);
satu.setEntries(R.array.pref_screen_saturation_entries);
satu.setEntryValues(R.array.pref_screen_saturation_entryvalues);
satu.setDefaultValue("use_default");
sgroup.addPreference(satu);
setupValueSummary(satu_key,
R.string.pref_screen_saturation_summary);
// opacity
ListPreference opac = new ListPreference(this);
opac.setKey(opac_key);
opac.setTitle(R.string.pref_screen_opacity_title);
opac.setDialogTitle(opac.getTitle());
opac.setSummary(R.string.pref_screen_opacity_summary);
opac.setEntries(R.array.pref_screen_opacity_entries);
opac.setEntryValues(R.array.pref_screen_opacity_entryvalues);
opac.setDefaultValue("use_default");
sgroup.addPreference(opac);
setupValueSummary(opac_key, R.string.pref_screen_opacity_summary);
// manage pickable screen numbers
pickable_screen |= (1 << idx);
}
private void convertPictureSourcePreference(
PictureSourcePreference item, int idx)
{
String picsource_key = getKey(SCREEN_PICSOURCE_KEY, idx);
String picsource_val = pref.getString(picsource_key, null);
if(picsource_val != null) {
return;
}
String type_key = getKey(SCREEN_TYPE_KEY, idx);
String type_val = pref.getString(type_key, null);
String file_key = getKey(SCREEN_FILE_KEY, idx);
Class<?> cls = null;
String desc = null;
if("file".equals(type_val) ||
(type_val == null && pref.getString(file_key, null) != null)) {
String file_val = pref.getString(file_key, "");
cls = SingleSource.class;
desc = getString(R.string.pref_screen_type_file_desc,
PictureUtils.getUriFileName(resolver, file_val));
}
else if("folder".equals(type_val)) {
String folder_key = getKey(SCREEN_FOLDER_KEY, idx);
String folder_val = pref.getString(folder_key, "");
cls = FolderSource.class;
desc = getString(R.string.pref_screen_type_folder_desc,
folder_val);
}
else if("buckets".equals(type_val)) {
String bucket_key = getKey(SCREEN_BUCKET_KEY, idx);
String bucket_val = pref.getString(bucket_key, "");
cls = AlbumSource.class;
desc = getString(R.string.pref_screen_type_bucket_desc,
PictureUtils.getBucketNames(
resolver, bucket_val));
}
else if("use_default".equals(type_val) || idx >= 0) {
cls = null;
desc = getString(R.string.pref_use_default);
}
if(desc != null) {
persistPictureSourceInfo(idx, desc, null);
}
item.setValue(cls != null ? new ComponentName(this, cls) : null);
}
private void persistPictureSourceInfo(int idx, String desc, String service)
{
persistPictureSourceInfo(getIndexString(idx), desc, service);
}
private void persistPictureSourceInfo(String key,
String desc, String service)
{
String desc_key = getKey(SCREEN_PICSOURCE_DESC_KEY, key);
String service_key = getKey(SCREEN_PICSOURCE_SERVICE_KEY, key);
int serial = pref.getInt(SCREEN_PICSOURCE_SERIAL_KEY, 0);
SharedPreferences.Editor editor = pref.edit();
editor.putString(desc_key, desc);
if(service != null) {
editor.putString(service_key, service);
}
editor.putInt(SCREEN_PICSOURCE_SERIAL_KEY, serial + 1);
editor.commit();
}
private void updatePictureSourceSummary(
PictureSourcePreference item, int idx)
{
updatePictureSourceSummary(item, getIndexString(idx), (idx < 0));
}
private void updatePictureSourceSummary(
PictureSourcePreference item, String key, boolean is_default)
{
ComponentName picsource_val = item.getValue();
StringBuilder summary = new StringBuilder();
summary.append(getString(R.string.pref_screen_type_base_summary));
if(picsource_val != null) {
String desc_key = getKey(SCREEN_PICSOURCE_DESC_KEY, key);
String desc_val = pref.getString(desc_key, "");
if(desc_val.length() != 0) {
summary.append(
getString(R.string.pref_screen_val_summary,
desc_val));
}
}
else if(! is_default) {
summary.append(
getString(R.string.pref_screen_val_summary,
getString(R.string.pref_use_default)));
}
item.setSummary(summary);
}
private void updateColorSummary(ListPreference item, String val)
{
updateValueSummary(item, R.string.pref_screen_bgcolor_summary, val);
}
private void updateValueSummary(ListPreference item, int res_id, String val)
{
if(val == null) {
val = item.getValue();
}
String summary =
getString(res_id) +
getString(R.string.pref_screen_val_summary,
item.getEntries()[item.findIndexOfValue(val)]);
item.setSummary(summary);
try {
item.getSummary();
}
catch(IllegalFormatException e) {
// workaround for summary formatter...
item.setSummary(summary.replaceAll("%", "%%"));
}
}
private void setupValueSummary(String key, int res_id)
{
ListPreference item = (ListPreference)
getPreferenceManager().findPreference(key);
item.setOnPreferenceChangeListener(new OnValueChangeListener(res_id));
updateValueSummary(item, res_id, null);
}
private void startColorPickerDialog(final Preference item, final String key)
{
int color = pref.getInt(getKey(SCREEN_BGCOLOR_CUSTOM_KEY, key),
0xff000000);
View view = getLayoutInflater().inflate(R.layout.color_picker, null);
final ColorPickerView picker =
(ColorPickerView)view.findViewById(R.id.color_picker_picker);
final View expl = view.findViewById(R.id.color_picker_explain);
picker.setOnColorChangeListener(
new ColorPickerView.OnColorChangeListener() {
@Override public void onColorChange(int color) {
expl.setBackgroundColor(color);
}
});
picker.setColor(color);
new AlertDialog.Builder(this)
.setTitle(R.string.pref_screen_bgcolor_title)
.setView(view)
.setPositiveButton(
android.R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int button) {
applyCustomColor((ListPreference)item, key,
picker.getColor());
}
})
.setNegativeButton(android.R.string.no, null)
.show();
}
private void applyCustomColor(ListPreference item, String key, int color)
{
String val = "custom";
updateColorSummary(item, val);
item.setValue(val);
SharedPreferences.Editor editor = pref.edit();
editor.putInt(getKey(SCREEN_BGCOLOR_CUSTOM_KEY, key), color);
editor.commit();
}
private void startMaxMemoryConfirmDialog(final ListPreference item,
final String val)
{
new AlertDialog.Builder(this)
.setTitle(R.string.pref_memory_max_title)
.setMessage(R.string.pref_memory_max_confirm)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(
android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int button) {
item.setValue(val);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private class ScreenPickerClickListener
implements Preference.OnPreferenceClickListener
{
@Override
public boolean onPreferenceClick(Preference preference)
{
int num = 1;
for(int i = 0; i < ScreenPickerPreference.SCREEN_COUNT; i++) {
if((pickable_screen & (1 << i)) == 0) {
num = i + 1;
break;
}
}
screen_picker.setScreenNumber(num);
return false;
}
}
private class ScreenPickerListener
implements ScreenPickerPreference.ScreenPickerListener
{
@Override
public boolean onScreenNumberChanging(int screen_num)
{
return ((pickable_screen & (1 << (screen_num - 1))) == 0);
}
@Override
public void onScreenNumberPicked(int screen_num)
{
addScreenPreferences(screen_num - 1, false);
if(pickable_screen == all_screen_mask) {
screen_picker.setEnabled(false);
}
}
}
private class OnPictureSourceChangeListener
implements Preference.OnPreferenceChangeListener
{
private String key;
private boolean is_default;
private OnPictureSourceChangeListener(int idx)
{
this(getIndexString(idx), (idx < 0));
}
private OnPictureSourceChangeListener(String key, boolean is_default)
{
this.key = key;
this.is_default = is_default;
}
@Override
public boolean onPreferenceChange(Preference item, Object val)
{
final PictureSourcePreference picsource =
(PictureSourcePreference)item;
if(val != null) {
cur_comp = (ComponentName)val;
Intent intent = picsource.createIntent(cur_comp, key);
Log.d(TAG, "picture source: start: " + key + ", " + intent);
try {
startActivityForResult(intent, REQUEST_CODE_PICSOURCE);
cur_item = picsource;
cur_key = key;
}
catch(ActivityNotFoundException e) {
e.printStackTrace();
Toast.makeText(
MultiPictureSetting.this,
R.string.picsource_not_found, Toast.LENGTH_SHORT)
.show();
}
return false;
}
else {
handler.post(new Runnable() {
public void run() {
persistPictureSourceInfo(key, "", "");
updatePictureSourceSummary(
picsource, key, is_default);
}
});
return true;
}
}
}
private class OnColorChangeListener
implements Preference.OnPreferenceChangeListener
{
private String key;
private OnColorChangeListener(int idx)
{
this(getIndexString(idx));
}
private OnColorChangeListener(String key)
{
this.key = key;
}
@Override
public boolean onPreferenceChange(final Preference item, Object val)
{
if("custom".equals(val)) {
startColorPickerDialog(item, key);
return false;
}
else {
updateColorSummary((ListPreference)item, (String)val);
return true;
}
}
}
private class OnValueChangeListener
implements Preference.OnPreferenceChangeListener
{
private int res_id;
private OnValueChangeListener(int res_id)
{
this.res_id = res_id;
}
@Override
public boolean onPreferenceChange(Preference item, Object val)
{
updateValueSummary((ListPreference)item, res_id, (String)val);
return true;
}
}
private class OnMaximumMemoryChangeListener
implements Preference.OnPreferenceChangeListener
{
@Override
public boolean onPreferenceChange(Preference item, Object val)
{
int msize = 0;
try {
msize = Integer.valueOf(val.toString());
}
catch(Exception e) {
// ignore
}
int mclass = getAutoMemoryClass(MultiPictureSetting.this);
if(msize < 0 || msize > mclass) {
startMaxMemoryConfirmDialog(
(ListPreference)item, val.toString());
return false;
}
else {
return true;
}
}
}
private class OnDntClickListener
implements Preference.OnPreferenceClickListener
{
@Override
public boolean onPreferenceClick(Preference preference)
{
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse(getString(R.string.dnt_search_uri)));
try {
startActivity(intent);
}
catch(ActivityNotFoundException e) {
Toast.makeText(MultiPictureSetting.this,
R.string.market_not_found,
Toast.LENGTH_SHORT)
.show();
}
return false;
}
}
}
| [
"[email protected]"
]
| |
76eb82a6baaf6c642728613551154c32b5fe0498 | d9477e8e6e0d823cf2dec9823d7424732a7563c4 | /plugins/Highlight/tags/2006-05-01/src/gatchan/highlight/Highlighter.java | 127e20571db516f2166275cccc86068485988561 | []
| no_license | RobertHSchmidt/jedit | 48fd8e1e9527e6f680de334d1903a0113f9e8380 | 2fbb392d6b569aefead29975b9be12e257fbe4eb | refs/heads/master | 2023-08-30T02:52:55.676638 | 2018-07-11T13:28:01 | 2018-07-11T13:28:01 | 140,587,948 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,335 | java | package gatchan.highlight;
import org.gjt.sp.jedit.buffer.JEditBuffer;
import org.gjt.sp.jedit.search.SearchMatcher;
import org.gjt.sp.jedit.textarea.JEditTextArea;
import org.gjt.sp.jedit.textarea.TextAreaExtension;
import org.gjt.sp.jedit.textarea.TextAreaPainter;
import org.gjt.sp.util.CharIndexedSegment;
import javax.swing.text.Segment;
import java.awt.*;
/**
* The Highlighter is the TextAreaExtension that will look for some String to highlightList in the textarea and draw a
* rectangle in it's background.
*
* @author Matthieu Casanova
* @version $Id$
*/
final class Highlighter extends TextAreaExtension implements HighlightChangeListener {
private final JEditTextArea textArea;
private final Segment seg;
private final Point point;
private final FontMetrics fm;
private final HighlightManager highlightManager;
private final AlphaComposite blend = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
Highlighter(JEditTextArea textArea) {
highlightManager = HighlightManagerTableModel.getManager();
this.textArea = textArea;
TextAreaPainter painter = textArea.getPainter();
fm = painter.getFontMetrics();
seg = new Segment();
point = new Point();
}
public void paintValidLine(Graphics2D gfx,
int screenLine,
int physicalLine,
int start,
int end,
int y) {
if (highlightManager.isHighlightEnable() &&
highlightManager.countHighlights() != 0 ||
HighlightManagerTableModel.currentWordHighlight.isEnabled()) {
highlightList(gfx, physicalLine, start, end, y);
}
}
private void highlightList(Graphics2D gfx, int physicalLine, int lineStartOffset, int lineEndOffset, int y) {
String lineContent = textArea.getLineText(physicalLine);
JEditBuffer buffer = textArea.getBuffer();
for (int i = 0; i < highlightManager.countHighlights(); i++) {
Highlight highlight = highlightManager.getHighlight(i);
highlight(highlight, buffer, lineContent, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
}
highlight(HighlightManagerTableModel.currentWordHighlight, buffer, lineContent, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
}
private void highlight(Highlight highlight,
JEditBuffer buffer,
String lineContent,
int physicalLine,
int lineStartOffset,
int lineEndOffset,
Graphics2D gfx,
int y) {
if (highlight.isEnabled() && (highlight.getScope() != Highlight.BUFFER_SCOPE ||
highlight.getBuffer() == buffer)) {
highlight(highlight, lineContent, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
}
}
private void highlight(Highlight highlight,
String lineContent,
int physicalLine,
int lineStartOffset,
int lineEndOffset,
Graphics2D gfx,
int y) {
if (highlight.isRegexp()) {
SearchMatcher searchMatcher = highlight.getSearchMatcher();
Segment segment = new Segment(lineContent.toCharArray(), 0, lineContent.length());
SearchMatcher.Match match = null;
int i = 0;
while (true) {
match = searchMatcher.nextMatch(new CharIndexedSegment(segment, false),
physicalLine == 0,
physicalLine == textArea.getLineCount(),
match == null,
false);
if (match == null) {
break;
}
String s = lineContent.substring(match.start, match.end);
_highlight(highlight.getColor(), s, match.start + i, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
highlight.updateLastSeen();
if (match.end == lineContent.length()) {
break;
}
lineContent = lineContent.substring(match.end);
i += match.end;
segment = new Segment(lineContent.toCharArray(), 0, lineContent.length());
}
} else {
boolean found = highlightStringInLine(highlight.getColor(),
lineContent,
highlight.getStringToHighlight(),
highlight.isIgnoreCase(),
highlight.isHighlightSubsequence(),
physicalLine,
lineStartOffset,
lineEndOffset,
gfx,
y);
if (found) {
highlight.updateLastSeen();
}
}
}
private boolean highlightStringInLine(Color highlightColor,
String lineStringParam,
String stringToHighlightParam,
boolean ignoreCase,
boolean highlightSubsequence,
int physicalLine,
int lineStartOffset,
int lineEndOffset,
Graphics2D gfx,
int y) {
String stringToHighlight;
String lineString;
if (ignoreCase) {
lineString = lineStringParam.toLowerCase();
stringToHighlight = stringToHighlightParam.toLowerCase();
} else {
lineString = lineStringParam;
stringToHighlight = stringToHighlightParam;
}
int start = lineString.indexOf(stringToHighlight, textArea.getLineStartOffset(physicalLine) - lineStartOffset);
if (start == -1) return false;
_highlight(highlightColor, stringToHighlight, start, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
while (true) {
if (highlightSubsequence) {
start = lineString.indexOf(stringToHighlight, start + 1);
} else {
start = lineString.indexOf(stringToHighlight, start + stringToHighlight.length());
}
if (start == -1) return true;
_highlight(highlightColor, stringToHighlight, start, physicalLine, lineStartOffset, lineEndOffset, gfx, y);
}
}
private void _highlight(Color highlightColor,
String stringToHighlight,
int start,
int physicalLine,
int lineStartOffset,
int lineEndOffset,
Graphics2D gfx,
int y) {
int end = start + stringToHighlight.length();
int lineStart = textArea.getLineStartOffset(physicalLine);
if (start == 0 && end == 0) {
textArea.getLineText(physicalLine, seg);
for (int j = 0; j < seg.count; j++) {
if (Character.isWhitespace(seg.array[seg.offset + j])) {
start++;
} else {
break;
}
}
end = seg.count;
}
if (start + lineStart >= lineEndOffset || end + lineStart <= lineStartOffset) {
return;
}
int startX;
if (start + lineStart >= lineStartOffset) {
startX = textArea.offsetToXY(physicalLine, start, point).x;
} else {
startX = 0;
}
int endX;
if (end + lineStart >= lineEndOffset) {
endX = textArea.offsetToXY(physicalLine, lineEndOffset - lineStart - 1, point).x;
} else {
endX = textArea.offsetToXY(physicalLine, end, point).x;
}
Color oldColor = gfx.getColor();
Composite oldComposite = gfx.getComposite();
gfx.setColor(highlightColor);
gfx.setComposite(blend);
gfx.fillRect(startX, y, endX - startX, fm.getHeight());
gfx.setColor(oldColor);
gfx.setComposite(oldComposite);
}
public void highlightUpdated(boolean highlightEnable) {
int firstLine = textArea.getFirstPhysicalLine();
textArea.invalidateLineRange(firstLine, firstLine + textArea.getVisibleLines());
}
}
| [
"kpouer@6b1eeb88-9816-0410-afa2-b43733a0f04e"
]
| kpouer@6b1eeb88-9816-0410-afa2-b43733a0f04e |
c302e2c01928810699386304652cd19f22b8e8a8 | 47984d3b623e74e8029f3b8b7422893f1bfdfefa | /src/panel/SkillTooltipPanel.java | ce78b9c345af046a888bf92bd4a19d5256a2ae94 | []
| no_license | SetosanMs/MapleStory2 | 71467682165a85f6b31ee16aecce009847ee27d9 | 311bd8fa3f832f2a34dee41d43e7daf9766044a3 | refs/heads/master | 2022-12-10T00:44:55.389534 | 2020-08-26T15:22:17 | 2020-08-26T15:22:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,147 | java | package panel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JPanel;
import map.Point;
import skill.Skill;
public class SkillTooltipPanel extends JPanel {
private static final long serialVersionUID = 1L;
public static final int TOOLTIP_WIDTH = 200;
public static final int TOOLTIP_HEIGHT = 300;
private Skill skill;
private Point point;
public SkillTooltipPanel() {
setLayout(null);
setBackground(new Color(0, 0, 0, 0));
}
public Point getPoint() {
return this.point;
}
public void setPoint(Point point) {
this.point = point;
}
public Skill getSkill() {
return this.skill;
}
public void setSkill(Skill skill) {
this.skill = skill;
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
screenDraw((Graphics2D) g);
}
public void screenDraw(Graphics2D g) {
rendering(g);
if (this.skill != null) {
this.skill.drawInfor(g, this.point);
}
repaint();
}
private void rendering(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
} | [
"[email protected]"
]
| |
2ab8de730141c13c08c40abc2e4c2a223ad2afa2 | 0e748782bc9bd2a3a19025e1223474124baae3b1 | /src/main/java/br/com/rouparia/entities/Funcionario.java | 358e534a29740935d19ba9fd95399b600620d41a | []
| no_license | edvalson/roupariaweb | d7fd0d71f4c3cc25edaefce7c0bbe3ba9bb07721 | 241fdc74a8b5ecd1de866c7a1c6a8293b5ff0259 | refs/heads/master | 2020-04-28T14:51:03.411682 | 2019-03-13T05:54:46 | 2019-03-13T05:54:46 | 175,348,048 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,431 | java | package br.com.rouparia.entities;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@SequenceGenerator(name="funcionario_id", sequenceName="funcionario_seq", allocationSize=1)
public class Funcionario extends AbstractEntity {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="funcionario_id")
private Long id;
private String nome;
private String matricula;
private String funcao;
@Embedded
private Endereco endereco;
public Funcionario(Long id) {
this.id = id;
}
public Funcionario(){
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getFuncao() {
return funcao;
}
public void setFuncao(String funcao) {
this.funcao = funcao;
}
public Endereco getEndereco() {
return endereco;
}
public void setEndereco(Endereco endereco) {
this.endereco = endereco;
}
}
| [
"[email protected]"
]
| |
f6cdf6f41ced2f0f07b186aff6765704f290dd82 | 97f60c04f636ecbcc9c41e556c83d1f75952de02 | /jitstatic/src/main/java/io/jitstatic/api/StreamingDeserializer.java | 12330bb7be4c37887f1a9a3df84a90334f660d3f | [
"Apache-2.0"
]
| permissive | evabrannstrom/jitstatic | e864ba5f5c07a453335f85c2c8b7381653583d7b | 47e2e0ca2b4d48a9df835df7be42f315292424c9 | refs/heads/master | 2020-08-16T15:09:09.745447 | 2019-10-04T05:58:13 | 2019-10-04T05:58:13 | 215,515,180 | 0 | 0 | null | 2019-10-16T09:58:07 | 2019-10-16T09:58:07 | null | UTF-8 | Java | false | false | 5,615 | java | package io.jitstatic.api;
import java.io.BufferedOutputStream;
/*-
* #%L
* jitstatic
* %%
* Copyright (C) 2017 - 2018 H.Hegardt
* %%
* 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.
* #L%
*/
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.io.input.ProxyInputStream;
import org.apache.commons.io.output.DeferredFileOutputStream;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import io.jitstatic.source.ObjectStreamProvider;
import io.jitstatic.utils.FilesUtils;
public class StreamingDeserializer extends JsonDeserializer<ObjectStreamProvider> {
private static final Logger LOG = LoggerFactory.getLogger(StreamingDeserializer.class);
private static final int DEFAULT_MAX_BYTE_SIZE = 10_000_000;
private static final int MAX_FILE_SIZE = Integer.MAX_VALUE - 1;
private static final File TMP_DIR = Paths.get(System.getProperty("java.io.tmpdir"), "jitstatic").toFile();
static {
FilesUtils.checkOrCreateFolder(TMP_DIR);
}
private final int threshold;
private final File workingDirectory;
public StreamingDeserializer() {
this(DEFAULT_MAX_BYTE_SIZE, TMP_DIR);
}
public StreamingDeserializer(final int threshold) {
this(threshold, TMP_DIR);
}
public StreamingDeserializer(final File workingDirectory) {
this(DEFAULT_MAX_BYTE_SIZE, workingDirectory);
}
public StreamingDeserializer(final int threshold, final File workingDirectory) {
if (threshold >= MAX_FILE_SIZE) {
throw new IllegalArgumentException("Threshold too large " + threshold);
}
this.threshold = threshold < 0 ? DEFAULT_MAX_BYTE_SIZE : threshold;
FilesUtils.checkOrCreateFolder(workingDirectory);
this.workingDirectory = workingDirectory;
}
DeferredFileOutputStream getOutPutStream() {
return new DeferredFileOutputStream(threshold, "defer", "dat", workingDirectory) {
@Override
protected void checkThreshold(int count) throws IOException {
if (getByteCount() >= MAX_FILE_SIZE) {
throw new FileTooLargeException();
}
super.checkThreshold(count);
}
};
}
@Override
public ObjectStreamProvider deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
final DeferredFileOutputStream dfos = getOutPutStream();
try (BufferedOutputStream bos = new BufferedOutputStream(dfos)) {
p.readBinaryValue(bos);
} catch (FileTooLargeException ftle) {
ctxt.reportInputMismatch(ObjectStreamProvider.class, "Input is too large > " + MAX_FILE_SIZE);
} finally {
dfos.close();
}
return new ObjectStreamProvider() {
@Override
public long getSize() {
return dfos.getByteCount();
}
@Override
public byte[] asByteArray() throws IOException {
byte[] data = dfos.getData();
if (data != null) {
return data;
}
try (InputStream is = Files.newInputStream(dfos.getFile().toPath(), StandardOpenOption.READ)) {
return is.readAllBytes();
}
}
@Override
public InputStream getInputStream() throws IOException {
if (dfos.isInMemory()) {
return new ByteArrayInputStream(dfos.getData());
}
final Path tmpPath = dfos.getFile().toPath();
return new ProxyInputStream(Files.newInputStream(tmpPath, StandardOpenOption.READ)) {
@Override
public void close() throws IOException {
try {
super.close();
} finally {
CompletableFuture.runAsync(() -> {
try {
if (!Files.deleteIfExists(tmpPath)) {
Files.delete(tmpPath);
}
} catch (IOException e) {
LOG.warn("Error deleting temporary file", e);
}
});
}
}
};
}
};
}
static class FileTooLargeException extends IOException {
private static final long serialVersionUID = 1L;
}
}
| [
"[email protected]"
]
| |
7c2e8c666163f8ff7faa26d2770862d571f5f214 | 27f5457d47aaf3491f0d64032247adc08efba867 | /vertx-pin/zero-psi/src/main/java/cn/vertxup/psi/domain/tables/interfaces/IPBuyItem.java | 202814a4f7906923ddfe698c6dcd5f87f64686bf | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
]
| permissive | silentbalanceyh/vertx-zero | e73d22f4213263933683e4ebe87982ba68803878 | 1ede4c3596f491d5251eefaaaedc56947ef784cd | refs/heads/master | 2023-06-11T23:10:29.241769 | 2023-06-08T16:15:33 | 2023-06-08T16:15:33 | 108,104,586 | 348 | 71 | Apache-2.0 | 2020-04-10T02:15:18 | 2017-10-24T09:21:56 | HTML | UTF-8 | Java | false | true | 17,318 | java | /*
* This file is generated by jOOQ.
*/
package cn.vertxup.psi.domain.tables.interfaces;
import io.github.jklingsporn.vertx.jooq.shared.internal.VertxPojo;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static io.github.jklingsporn.vertx.jooq.shared.internal.VertxPojo.setOrThrow;
/**
* This class is generated by jOOQ.
*/
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public interface IPBuyItem extends VertxPojo, Serializable {
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.KEY</code>. 「key」- 采购明细主键
*/
public IPBuyItem setKey(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.KEY</code>. 「key」- 采购明细主键
*/
public String getKey();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.SERIAL</code>. 「serial」-
* 采购单号(系统可用,直接计算)
*/
public IPBuyItem setSerial(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.SERIAL</code>. 「serial」-
* 采购单号(系统可用,直接计算)
*/
public String getSerial();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.STATUS</code>. 「status」- 明细状态
*/
public IPBuyItem setStatus(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.STATUS</code>. 「status」- 明细状态
*/
public String getStatus();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_ID</code>.
* 「commodityId」- 商品ID
*/
public IPBuyItem setCommodityId(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_ID</code>.
* 「commodityId」- 商品ID
*/
public String getCommodityId();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_CODE</code>.
* 「commodityCode」- 商品编码
*/
public IPBuyItem setCommodityCode(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_CODE</code>.
* 「commodityCode」- 商品编码
*/
public String getCommodityCode();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_NAME</code>.
* 「commodityName」- 商品名称
*/
public IPBuyItem setCommodityName(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.COMMODITY_NAME</code>.
* 「commodityName」- 商品名称
*/
public String getCommodityName();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.CUSTOMER_ID</code>. 「customerId」-
* 建议供应商
*/
public IPBuyItem setCustomerId(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.CUSTOMER_ID</code>. 「customerId」-
* 建议供应商
*/
public String getCustomerId();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.TICKET_ID</code>. 「ticketId」-
* 采购申请ID
*/
public IPBuyItem setTicketId(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.TICKET_ID</code>. 「ticketId」-
* 采购申请ID
*/
public String getTicketId();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.ORDER_ID</code>. 「orderId」- 采购订单ID
*/
public IPBuyItem setOrderId(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.ORDER_ID</code>. 「orderId」- 采购订单ID
*/
public String getOrderId();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.NUM_REQUEST</code>. 「numRequest」-
* 申请数量
*/
public IPBuyItem setNumRequest(Integer value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.NUM_REQUEST</code>. 「numRequest」-
* 申请数量
*/
public Integer getNumRequest();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.NUM_APPROVED</code>.
* 「numApproved」- 审批数量
*/
public IPBuyItem setNumApproved(Integer value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.NUM_APPROVED</code>.
* 「numApproved」- 审批数量
*/
public Integer getNumApproved();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.NUM</code>. 「num」- 实际采购数量(订单中)
*/
public IPBuyItem setNum(Integer value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.NUM</code>. 「num」- 实际采购数量(订单中)
*/
public Integer getNum();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_RATE</code>. 「taxRate」- 税率
*/
public IPBuyItem setTaxRate(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_RATE</code>. 「taxRate」- 税率
*/
public BigDecimal getTaxRate();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_AMOUNT</code>. 「taxAmount」- 税额
*/
public IPBuyItem setTaxAmount(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_AMOUNT</code>. 「taxAmount」- 税额
*/
public BigDecimal getTaxAmount();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_PRICE</code>. 「taxPrice」- 含税单价
*/
public IPBuyItem setTaxPrice(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.TAX_PRICE</code>. 「taxPrice」- 含税单价
*/
public BigDecimal getTaxPrice();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT_TOTAL</code>.
* 「amountTotal」- 税价合计
*/
public IPBuyItem setAmountTotal(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT_TOTAL</code>.
* 「amountTotal」- 税价合计
*/
public BigDecimal getAmountTotal();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT_SPLIT</code>.
* 「amountSplit」- 采购分摊费用
*/
public IPBuyItem setAmountSplit(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT_SPLIT</code>.
* 「amountSplit」- 采购分摊费用
*/
public BigDecimal getAmountSplit();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT</code>. 「amount」-
* 采购总价(订单总价)
*/
public IPBuyItem setAmount(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.AMOUNT</code>. 「amount」-
* 采购总价(订单总价)
*/
public BigDecimal getAmount();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.PRICE</code>. 「price」- 采购单价(采购价)
*/
public IPBuyItem setPrice(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.PRICE</code>. 「price」- 采购单价(采购价)
*/
public BigDecimal getPrice();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.DISCOUNT_AMOUNT</code>.
* 「discountAmount」- 折扣金额
*/
public IPBuyItem setDiscountAmount(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.DISCOUNT_AMOUNT</code>.
* 「discountAmount」- 折扣金额
*/
public BigDecimal getDiscountAmount();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.DISCOUNT_RATE</code>.
* 「discountRate」- 折扣率
*/
public IPBuyItem setDiscountRate(BigDecimal value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.DISCOUNT_RATE</code>.
* 「discountRate」- 折扣率
*/
public BigDecimal getDiscountRate();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.COMMENT</code>. 「comment」- 商品行备注
*/
public IPBuyItem setComment(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.COMMENT</code>. 「comment」- 商品行备注
*/
public String getComment();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.ARRIVE_AT</code>. 「arriveAt」-
* 预计到货时间
*/
public IPBuyItem setArriveAt(LocalDateTime value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.ARRIVE_AT</code>. 「arriveAt」-
* 预计到货时间
*/
public LocalDateTime getArriveAt();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.ACTIVE</code>. 「active」- 是否启用
*/
public IPBuyItem setActive(Boolean value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.ACTIVE</code>. 「active」- 是否启用
*/
public Boolean getActive();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.SIGMA</code>. 「sigma」- 统一标识
*/
public IPBuyItem setSigma(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.SIGMA</code>. 「sigma」- 统一标识
*/
public String getSigma();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.METADATA</code>. 「metadata」- 附加配置
*/
public IPBuyItem setMetadata(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.METADATA</code>. 「metadata」- 附加配置
*/
public String getMetadata();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.LANGUAGE</code>. 「language」- 使用的语言
*/
public IPBuyItem setLanguage(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.LANGUAGE</code>. 「language」- 使用的语言
*/
public String getLanguage();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.CREATED_AT</code>. 「createdAt」-
* 创建时间
*/
public IPBuyItem setCreatedAt(LocalDateTime value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.CREATED_AT</code>. 「createdAt」-
* 创建时间
*/
public LocalDateTime getCreatedAt();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.CREATED_BY</code>. 「createdBy」-
* 创建人
*/
public IPBuyItem setCreatedBy(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.CREATED_BY</code>. 「createdBy」-
* 创建人
*/
public String getCreatedBy();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.UPDATED_AT</code>. 「updatedAt」-
* 更新时间
*/
public IPBuyItem setUpdatedAt(LocalDateTime value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.UPDATED_AT</code>. 「updatedAt」-
* 更新时间
*/
public LocalDateTime getUpdatedAt();
/**
* Setter for <code>DB_ETERNAL.P_BUY_ITEM.UPDATED_BY</code>. 「updatedBy」-
* 更新人
*/
public IPBuyItem setUpdatedBy(String value);
/**
* Getter for <code>DB_ETERNAL.P_BUY_ITEM.UPDATED_BY</code>. 「updatedBy」-
* 更新人
*/
public String getUpdatedBy();
// -------------------------------------------------------------------------
// FROM and INTO
// -------------------------------------------------------------------------
/**
* Load data from another generated Record/POJO implementing the common
* interface IPBuyItem
*/
public void from(IPBuyItem from);
/**
* Copy data into another generated Record/POJO implementing the common
* interface IPBuyItem
*/
public <E extends IPBuyItem> E into(E into);
@Override
public default IPBuyItem fromJson(io.vertx.core.json.JsonObject json) {
setOrThrow(this::setKey,json::getString,"KEY","java.lang.String");
setOrThrow(this::setSerial,json::getString,"SERIAL","java.lang.String");
setOrThrow(this::setStatus,json::getString,"STATUS","java.lang.String");
setOrThrow(this::setCommodityId,json::getString,"COMMODITY_ID","java.lang.String");
setOrThrow(this::setCommodityCode,json::getString,"COMMODITY_CODE","java.lang.String");
setOrThrow(this::setCommodityName,json::getString,"COMMODITY_NAME","java.lang.String");
setOrThrow(this::setCustomerId,json::getString,"CUSTOMER_ID","java.lang.String");
setOrThrow(this::setTicketId,json::getString,"TICKET_ID","java.lang.String");
setOrThrow(this::setOrderId,json::getString,"ORDER_ID","java.lang.String");
setOrThrow(this::setNumRequest,json::getInteger,"NUM_REQUEST","java.lang.Integer");
setOrThrow(this::setNumApproved,json::getInteger,"NUM_APPROVED","java.lang.Integer");
setOrThrow(this::setNum,json::getInteger,"NUM","java.lang.Integer");
setOrThrow(this::setTaxRate,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"TAX_RATE","java.math.BigDecimal");
setOrThrow(this::setTaxAmount,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"TAX_AMOUNT","java.math.BigDecimal");
setOrThrow(this::setTaxPrice,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"TAX_PRICE","java.math.BigDecimal");
setOrThrow(this::setAmountTotal,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"AMOUNT_TOTAL","java.math.BigDecimal");
setOrThrow(this::setAmountSplit,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"AMOUNT_SPLIT","java.math.BigDecimal");
setOrThrow(this::setAmount,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"AMOUNT","java.math.BigDecimal");
setOrThrow(this::setPrice,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"PRICE","java.math.BigDecimal");
setOrThrow(this::setDiscountAmount,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"DISCOUNT_AMOUNT","java.math.BigDecimal");
setOrThrow(this::setDiscountRate,key -> {String s = json.getString(key); return s==null?null:new java.math.BigDecimal(s);},"DISCOUNT_RATE","java.math.BigDecimal");
setOrThrow(this::setComment,json::getString,"COMMENT","java.lang.String");
setOrThrow(this::setArriveAt,key -> {String s = json.getString(key); return s==null?null:java.time.LocalDateTime.parse(s);},"ARRIVE_AT","java.time.LocalDateTime");
setOrThrow(this::setActive,json::getBoolean,"ACTIVE","java.lang.Boolean");
setOrThrow(this::setSigma,json::getString,"SIGMA","java.lang.String");
setOrThrow(this::setMetadata,json::getString,"METADATA","java.lang.String");
setOrThrow(this::setLanguage,json::getString,"LANGUAGE","java.lang.String");
setOrThrow(this::setCreatedAt,key -> {String s = json.getString(key); return s==null?null:java.time.LocalDateTime.parse(s);},"CREATED_AT","java.time.LocalDateTime");
setOrThrow(this::setCreatedBy,json::getString,"CREATED_BY","java.lang.String");
setOrThrow(this::setUpdatedAt,key -> {String s = json.getString(key); return s==null?null:java.time.LocalDateTime.parse(s);},"UPDATED_AT","java.time.LocalDateTime");
setOrThrow(this::setUpdatedBy,json::getString,"UPDATED_BY","java.lang.String");
return this;
}
@Override
public default io.vertx.core.json.JsonObject toJson() {
io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject();
json.put("KEY",getKey());
json.put("SERIAL",getSerial());
json.put("STATUS",getStatus());
json.put("COMMODITY_ID",getCommodityId());
json.put("COMMODITY_CODE",getCommodityCode());
json.put("COMMODITY_NAME",getCommodityName());
json.put("CUSTOMER_ID",getCustomerId());
json.put("TICKET_ID",getTicketId());
json.put("ORDER_ID",getOrderId());
json.put("NUM_REQUEST",getNumRequest());
json.put("NUM_APPROVED",getNumApproved());
json.put("NUM",getNum());
json.put("TAX_RATE",getTaxRate()==null?null:getTaxRate().toString());
json.put("TAX_AMOUNT",getTaxAmount()==null?null:getTaxAmount().toString());
json.put("TAX_PRICE",getTaxPrice()==null?null:getTaxPrice().toString());
json.put("AMOUNT_TOTAL",getAmountTotal()==null?null:getAmountTotal().toString());
json.put("AMOUNT_SPLIT",getAmountSplit()==null?null:getAmountSplit().toString());
json.put("AMOUNT",getAmount()==null?null:getAmount().toString());
json.put("PRICE",getPrice()==null?null:getPrice().toString());
json.put("DISCOUNT_AMOUNT",getDiscountAmount()==null?null:getDiscountAmount().toString());
json.put("DISCOUNT_RATE",getDiscountRate()==null?null:getDiscountRate().toString());
json.put("COMMENT",getComment());
json.put("ARRIVE_AT",getArriveAt()==null?null:getArriveAt().toString());
json.put("ACTIVE",getActive());
json.put("SIGMA",getSigma());
json.put("METADATA",getMetadata());
json.put("LANGUAGE",getLanguage());
json.put("CREATED_AT",getCreatedAt()==null?null:getCreatedAt().toString());
json.put("CREATED_BY",getCreatedBy());
json.put("UPDATED_AT",getUpdatedAt()==null?null:getUpdatedAt().toString());
json.put("UPDATED_BY",getUpdatedBy());
return json;
}
}
| [
"[email protected]"
]
| |
293864ad10074b401ec0d2b4285284b17b33dc93 | 829126367560dc4964f6ec5860a97261916fc8ac | /app/src/main/java/com/example/chillapp/App.java | 1e2927f04dd8f0049dcef3b1cf35e1097fcdaa04 | [
"MIT"
]
| permissive | CodeBellum/hakvelonchillapp-mobile | 45b87da2198cb5734f95576a95180372f8f200d6 | d8ab1114a453a1700f2fa7609ec076dc5ce2b296 | refs/heads/master | 2020-04-07T22:37:03.382217 | 2018-11-24T07:01:35 | 2018-11-24T07:01:35 | 158,777,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 183 | java | package com.example.chillapp;
import android.app.Application;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
}
}
| [
"[email protected]"
]
| |
ca43755e34a52f9b9f6a65d6a9e3e4a970802139 | 763b969678370050c9b26603bf6cd1617570056f | /DS_2.java | 1bb74995bb55aa7635a9e14a074afb85bf1e8eea | []
| no_license | zoeyxiaoli/Design_GasPumpSystem | b64bed25f6309d3362ca3eaff6ffb55cd8b20c1e | 3f467525072a13f14740deeac97b6e5567d08f76 | refs/heads/master | 2020-03-18T10:33:25.139466 | 2018-05-23T20:36:58 | 2018-05-23T20:36:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,397 | java | //Data for the gas pump 2
public class DS_2 extends DS{
private int aa;
private int bb;
private int cc;
private int aa_temp;
private int bb_temp;
private int cc_temp;
private int cash;
private int cash_temp;
private float price;
private int num;
private float total;
public void setaa(int a){
this.aa = a;
}
public void setbb(int b){
this.bb = b;
}
public void setcc(int c){
this.cc = c;
}
public void setaa_temp(int a){
this.aa_temp = a;
}
public void setbb_temp(int b){
this.bb_temp = b;
}
public void setcc_temp(int c){
this.cc_temp = c;
}
public int getaa(){
return aa;
}
public int getbb(){
return bb;
}
public int getcc(){
return cc;
}
public int getaa_temp(){
return aa_temp;
}
public int getbb_temp(){
return bb_temp;
}
public int getcc_temp(){
return cc_temp;
}
public void setcash(int c){
this.cash = c;
}
public void setcash_temp(int c){
this.cash_temp = c;
}
public int getcash(){
return cash;
}
public int getcash_temp(){
return cash_temp;
}
//total
public void setprice(float price){
this.price = price;
}
public float getPrice(){
return price;
}
public void setnum(int num){
this.num = num;
}
public int getnum(){
return num;
}
public void settotal(float total){
this.total = total;
}
public float gettotal(){
return total;
}
}
| [
"[email protected]"
]
| |
85aea7968c1a27a9b676ed709f69d7a8f896ed0c | f1bca26c5ae63e6210d403c0f4d2b02d12f8a33a | /src/com/baidu/push/motu/Tag_3_None_en.java | 9394464b971857e6eefcfa101d68a673b3b3d3e5 | []
| no_license | wuxianjin/Push | 3e2ed8bc98d848b791b3e3e0b16a32320d008590 | 6f6b2157e8d36247d3c73b164e28cbf5d76148b1 | refs/heads/master | 2020-05-18T11:42:19.814811 | 2015-08-18T08:02:45 | 2015-08-18T08:02:45 | 38,697,362 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,054 | java | package com.baidu.push.motu;
import java.io.File;
import java.io.IOException;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class Tag_3_None_en extends UiAutomatorTestCase{
public void testTag_2_None() throws UiObjectNotFoundException,InterruptedException,IOException {
getUiDevice().pressHome();
sleep(1000);
getUiDevice().openNotification();
sleep(1000);
try{
UiObject pushmsg= new UiObject(new UiSelector().text("百度魔图"));
pushmsg.clickAndWaitForNewWindow();
sleep(5000);
//验证
//to to_page":3 进入手机相册界面 能打开即可,每个手机的相册展示都不一样
}catch(Exception e){
e.printStackTrace();
}finally{
File storeFile=new File("/data/local/tmp/push/motu/"+"motu.png");
getUiDevice().takeScreenshot(storeFile);
getUiDevice().pressBack();
}
}
}
| [
"[email protected]"
]
| |
b52dbdb2727d9ee17d121cd12ebd7e9438ee07a0 | 63e23a109d0cff367c4aa13bf9131380dda850a9 | /app/src/main/java/com/example/jordy/geo/inicioFragment.java | ef2bc45bc22dd79844aa879c83edc895a8ef6e04 | []
| no_license | jomora24/GeoCLient | 50791c6b98b392b721ad2762f02b0f65d77cd3e1 | 8324a8daec7bc12cf292c62c834dedbe6e2c3c17 | refs/heads/master | 2020-03-27T22:30:09.037199 | 2018-09-03T17:48:23 | 2018-09-03T17:48:23 | 145,958,676 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,631 | java | package com.example.jordy.geo;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link inicioFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link inicioFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class inicioFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public inicioFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment inicioFragment.
*/
// TODO: Rename and change types and number of parameters
public static inicioFragment newInstance(String param1, String param2) {
inicioFragment fragment = new inicioFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_inicio, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
| [
"[email protected]"
]
| |
f177f44e94eb4b6448f9702672a6ea09f8ea1aaf | cc340e70d612aa41e01201a44f0d4b382f0cc4af | /src/main/java/pad/ijvm/Short.java | d9115ca41ff3cb2777f1da05a47808325167d010 | []
| no_license | sabenoist/IJVM-Emulator | 16ec24c63531ca13549dd224966bec64793664c9 | 109dc3122d9324c55333affde13d7f784cc728fc | refs/heads/master | 2023-05-12T07:34:13.983510 | 2021-06-01T01:08:58 | 2021-06-01T01:08:58 | 50,048,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 613 | java | package pad.ijvm;
public class Short {
private byte[] bytes;
public Short(byte[] input) {
bytes = input;
}
public int toInteger() {
return ((bytes[0] & 0xFF) << 8) | (bytes[1] & 0xFF);
}
public int getByte(int pos) {
return bytes[pos];
}
public String toString() {
StringBuffer buffer = new StringBuffer();
for(int i=0; i < bytes.length; i++) {
buffer.append(Character.forDigit((bytes[i] >> 4) & 0xFF, 16));
buffer.append(Character.forDigit((bytes[i] & 0xFF), 16));
}
return buffer.toString();
}
}
| [
"[email protected]"
]
| |
a3e708d9e3107ede7f0f96a70b890b21c5f2fe43 | b6c5d2bdbe6740111c2375a3d38a78875eaa49dc | /Ch07_ReusingClasses/src/ex10/Component1.java | 9883f5271be6d147a9145cb23657971a35375765 | []
| no_license | rediska8118/ThinkingInJava | 7b6ac2fb4153bf858776f60de8a8d3a7f8f8cdb8 | b9b854ce1daf7e0fdc4f0ea84eeac37f9a695993 | refs/heads/master | 2021-01-19T03:14:35.321440 | 2016-06-09T10:05:40 | 2016-06-09T10:05:40 | 48,924,396 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 131 | java | package ex10;
public class Component1 {
public Component1(int i) {
System.out.println("Component1 non-def constructor");
}
}
| [
"[email protected]"
]
| |
9be5d28dc17e354e0fe37e821f656a4735eac792 | b8d61803676be1e6e81e5391492aa43fc84d89bc | /src/main/java/org/springframework/cloud/cluster/test/SimpleCandidate.java | 862a6ffa43b26104c7cca3a49c32921f0a3da970 | []
| no_license | kuguobing/spring-cloud-cluster | 9a55915b18e25f8f81343057f41e9151f948a130 | 5080d40d87ac7b7adba2a563547d01927f2fd4db | refs/heads/master | 2021-01-21T17:03:24.470801 | 2014-11-17T10:29:14 | 2014-11-17T10:29:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,926 | java | /*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.cluster.test;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.cluster.leader.Candidate;
import org.springframework.cloud.cluster.leader.Context;
/**
* Simple {@link org.springframework.cloud.cluster.leader.Candidate} for leadership.
* This implementation simply logs when it is elected and when its leadership is revoked.
*/
public class SimpleCandidate implements Candidate {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private static final String ROLE = "leader";
private final String id = UUID.randomUUID().toString();
private volatile Context leaderContext;
@Override
public String getRole() {
return ROLE;
}
@Override
public String getId() {
return id;
}
@Override
public void onGranted(Context ctx) {
logger.info("{} has been granted leadership; context: {}", this, ctx);
leaderContext = ctx;
}
@Override
public void onRevoked(Context ctx) {
logger.info("{} leadership has been revoked", this, ctx);
}
/**
* Voluntarily yield leadership if held.
*/
public void yieldLeadership() {
leaderContext.yield();
}
@Override
public String toString() {
return String.format("SimpleCandidate{role=%s, id=%s}", getRole(), getId());
}
}
| [
"[email protected]"
]
| |
de8f787c48ae03fb8fc86512b7939cd6a4daa988 | 56319e53f4155b0f0ae4ab249b1d3249fc8ddd98 | /apache-tomcat-8.0.39/converted/org/apache/tomcat/util/descriptor/web/MainForTestWebXmlOrdering_testOrderWebFragmentsRelative7.java | 0931989abd54ac2c88e40a1b60828cf53332777b | []
| no_license | SnowOnion/J2mConvertedTestcases | 2f904e2f2754f859f6125f248d3672eb1a70abd1 | e74b0e4c08f12e5effeeb8581670156ace42640a | refs/heads/master | 2021-01-11T19:01:42.207334 | 2017-01-19T12:22:22 | 2017-01-19T12:22:22 | 79,295,183 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | package org.apache.tomcat.util.descriptor.web;
import org.apache.tomcat.util.descriptor.web.TestWebXmlOrdering;
public class MainForTestWebXmlOrdering_testOrderWebFragmentsRelative7 {
public static void main(String[] args) {
try {
TestWebXmlOrdering objTestWebXmlOrdering = new TestWebXmlOrdering();
objTestWebXmlOrdering.setUp();
objTestWebXmlOrdering.testOrderWebFragmentsRelative7();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
b40e409d1dd5df16f542ab4e3ffd79341a3631dd | 0a2680f26a9868aec40ed5f315c29d9c167a6df9 | /src/main/java/com/hongqiang/shop/modules/user/web/shop/LogoutController.java | 94bf1f4d919ad393788d671b96a160cb1c178242 | []
| no_license | hongqiang/shop_format | 6c599decd6871efa1ba52ad97c64c5b46abe85ed | 007b16447ff22e6170057ee1fe454cff63a9124d | refs/heads/master | 2020-06-01T03:54:23.770336 | 2014-04-24T12:39:28 | 2014-04-24T12:39:28 | 14,840,544 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 967 | java | package com.hongqiang.shop.modules.user.web.shop;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.hongqiang.shop.common.utils.CookieUtils;
import com.hongqiang.shop.common.web.BaseController;
import com.hongqiang.shop.modules.entity.Member;
@Controller("shopLogoutController")
@RequestMapping({ "${frontPath}" })
public class LogoutController extends BaseController
{
@RequestMapping(value={"/logout"}, method=RequestMethod.GET)
public String execute(HttpServletRequest request, HttpServletResponse response, HttpSession session)
{
session.removeAttribute(Member.PRINCIPAL_ATTRIBUTE_NAME);
CookieUtils.removeCookie(request, response, "username");
return "redirect:/";
}
} | [
"[email protected]"
]
| |
aa2fe80341315bf451ce500a88560a58deda3224 | 62773640657b6f4530c264213ef72021e30f4670 | /microserviceA/src/main/java/com/happypanda/feignclient/microserviceA/web/HelloMicroserviceA.java | 773039d038430ab937fc21a9b632a2bb98ebcd3c | []
| no_license | FlorinAlexandru/DemoMicroservices | cd6c30dbb87b4a996945c6df137dc1f2b6fb462c | 7ec1f84f25d241309368ef92ec3b9fe302b11495 | refs/heads/master | 2021-04-04T13:45:47.490830 | 2020-03-20T10:28:34 | 2020-03-20T10:28:34 | 248,462,579 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 612 | java | package com.happypanda.feignclient.microserviceA.web;
import com.happypanda.feignclient.microserviceA.model.HelloMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(method = RequestMethod.GET, path = "/api")
public class HelloMicroserviceA {
@GetMapping(path = "hello")
public HelloMessage hello() {
return new HelloMessage("Hello microservice A");
}
}
| [
"[email protected]"
]
| |
1fc0ea791783e6d21153cbfe833a117389047337 | 3526132361e6a57d7991e1844cb8742e67e985bf | /app/src/main/java/org/twinone/locker/ui/AddressUpdate.java | 3df13617c2f7bd0cbab532372a0cdaec894803c7 | [
"Apache-2.0"
]
| permissive | miworking/xfactor_demo | df8fa2e0b1865af320da4c855160d1d2d64bc907 | d8b1b6c0f7806f018b268871f8d789c5bcf70758 | refs/heads/master | 2020-05-31T18:50:47.794410 | 2015-09-16T03:00:49 | 2015-09-16T03:00:49 | 41,344,894 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 21,044 | java | package org.twinone.locker.ui;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Geocoder;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import org.twinone.locker.lock.FetchAddressIntentService;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import static com.google.android.gms.location.LocationServices.API;
import static com.google.android.gms.location.LocationServices.FusedLocationApi;
/**
* Created by Jhalak on 26-Jul-15.
*/
public class AddressUpdate implements
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener {
protected static final String TAG = "location-updates-sample";
/**
* The desired interval for location updates. Inexact. Updates may be more or less frequent.
*/
public static final long UPDATE_INTERVAL_IN_MILLISECONDS = 30000;
/**
* The fastest rate for active location updates. Exact. Updates will never be more frequent
* than this value.
*/
public static final long FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS =
UPDATE_INTERVAL_IN_MILLISECONDS / 2;
// Keys for storing activity state in the Bundle.
// protected final static String REQUESTING_LOCATION_UPDATES_KEY = "requesting-location-updates-key";
// protected final static String LOCATION_KEY = "location-key";
// protected final static String LAST_UPDATED_TIME_STRING_KEY = "last-updated-time-string-key";
/**
* Stores parameters for requests to the FusedLocationProviderApi.
*/
protected LocationRequest mLocationRequest;
/**
* Represents a geographical location.
*/
protected Location mCurrentLocation;
// UI Widgets.
//
protected TextView mLastUpdateTimeTextView;
protected TextView mLatitudeTextView;
protected TextView mLongitudeTextView;
//
/**
* Tracks the status of the location updates request. Value changes when the user presses the
* Start Updates and Stop Updates buttons.
*/
protected Boolean mRequestingLocationUpdates;
/**
* Time when the location was updated represented as a String.
*/
protected String mLastUpdateTime;
// protected static final String ADDRESS_REQUESTED_KEY = "address-request-pending";
// protected static final String LOCATION_ADDRESS_KEY = "location-address";
/**
* Provides the entry point to Google Play services.
*/
protected GoogleApiClient mGoogleApiClient;
/**
* Represents a geographical location.
*/
// protected Location mLastLocation;
/**
* Tracks whether the user has requested an address. Becomes true when the user requests an
* address and false when the address (or an error message) is delivered.
* The user requests an address by pressing the Fetch Address button. This may happen
* before GoogleApiClient connects. This activity uses this boolean to keep track of the
* user's intent. If the value is true, the activity tries to fetch the address as soon as
* GoogleApiClient connects.
*/
protected boolean mAddressRequested;
/**
* Receiver registered with this activity to get the response from FetchAddressIntentService.
*/
private AddressResultReceiver mResultReceiver;
private Context c;
public AddressUpdate(Context c){
Log.i(TAG,"Inside the address update constructor");
this.c=c;
Log.i("Context", String.valueOf(c));
mRequestingLocationUpdates = false;
mLastUpdateTime = "";
mAddressRequested = true;
// this.mLatitudeTextView = mLatitudeTextView;
// this.mLongitudeTextView = mLongitudeTextView;
// this.mLastUpdateTimeTextView=mLastUpdateTimeTextView;
// Kick off the process of building a GoogleApiClient and requesting the LocationServices
// API.
Log.i(TAG,"calling buildgoogleapiclient method");
buildGoogleApiClient();
Log.i(TAG, "creating the addressresultreceiver object");
mResultReceiver = new AddressResultReceiver(new Handler());
}
// AddressUpdate addressUpdate = new AddressUpdate(c);
/**
* Builds a GoogleApiClient. Uses the {@code #addApi} method to request the
* LocationServices API.
*/
protected synchronized void buildGoogleApiClient() {
Log.i(TAG, "Building GoogleApiClient");
mGoogleApiClient = new GoogleApiClient.Builder(c)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(API)
.build();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
}
Log.i(TAG,"calling the create location request method");
createLocationRequest();
}
/**
* Sets up the location request. Android has two location request settings:
* {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
* the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
* the AndroidManifest.xml.
* <p/>
* When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
* interval (5 seconds), the Fused Location Provider API returns location updates that are
* accurate to within a few feet.
* <p/>
* These settings are appropriate for mapping applications that show real-time location
* updates.
*/
protected void createLocationRequest() {
Log.i(TAG, "creating location request");
mLocationRequest = new LocationRequest();
// Sets the desired interval for active location updates. This interval is
// inexact. You may not receive updates at all if no location sources are available, or
// you may receive them slower than requested. You may also receive updates faster than
// requested if other applications are requesting location at a faster interval.
mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
// Sets the fastest rate for active location updates. This interval is exact, and your
// application will never receive updates faster than this value.
mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onConnected(Bundle connectionHint) {
Log.i(TAG, "Connected to GoogleApiClient");
// If the initial location was never previously requested, we use
// FusedLocationApi.getLastLocation() to get it. If it was previously requested, we store
// its value in the Bundle and check for it in onCreate(). We
// do not request it again unless the user specifically requests location updates by pressing
// the Start Updates button.
//
// Because we cache the value of the initial location in the Bundle, it means that if the
// user launches the activity,
// moves to a new location, and then changes the device orientation, the original location
// is displayed as the activity is re-created.
if (mCurrentLocation == null) {
Log.i(TAG, "got current loocation null");
mCurrentLocation = FusedLocationApi.getLastLocation(mGoogleApiClient);
mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
Log.i(TAG, "got current loocation NOW");
if ( mCurrentLocation != null) {
// Determine whether a Geocoder is available.
if (!Geocoder.isPresent()) {
//Toast.makeText(c, "no geocoder available", Toast.LENGTH_LONG).show();
return;
}
// It is possible that the user presses the button to get the address before the
// GoogleApiClient object successfully connects. In such a case, mAddressRequested
// is set to true, but no attempt is made to fetch the address (see
// fetchAddressButtonHandler()) . Instead, we start the intent service here if the
// user has requested an address, since we now have a connection to GoogleApiClient.
Log.i(TAG, "Calling method to fetch address");
startIntentService();
}
}
// If the user presses the Start Updates button before GoogleApiClient connects, we set
// mRequestingLocationUpdates to true (see startUpdatesButtonHandler()). Here, we check
// the value of mRequestingLocationUpdates and if it is true, we start location updates.
Log.i(TAG, "starting the location updates");
startLocationUpdates();
}
protected void startIntentService() {
Log.i(TAG, "startIntentservice method called!!");
// Create an intent for passing to the intent service responsible for fetching the address.
Log.i(TAG, "creating an intent to fetch the address");
Intent intent = new Intent(c, FetchAddressIntentService.class);
// Pass the result receiver as an extra to the service.
intent.putExtra(Constants.RECEIVER, mResultReceiver);
// Pass the location data as an extra to the service.
intent.putExtra(Constants.LOCATION_DATA_EXTRA, mCurrentLocation);
//Toast.makeText(c,"-----"+mCurrentLocation.getLatitude(),Toast.LENGTH_SHORT).show();
Log.i("inside strtintenservice", "" + mCurrentLocation.getLatitude());
Log.i("inside strtintenservice",""+mCurrentLocation.getLongitude());
// Start the service. If the service isn't already running, it is instantiated and started
// (creating a process for it if needed); if it is running then it remains running. The
// service kills itself automatically once all intents are processed.
Log.i(TAG, "Starting the service to fetch address");
c.startService(intent);
}
//protected void showToast(String text) {
// Toast.makeText(c, text, Toast.LENGTH_SHORT).show();
//}
@Override
public void onConnectionSuspended(int cause) {
// The connection to Google Play services was lost for some reason. We call connect() to
// attempt to re-establish the connection.
Log.i(TAG, "Connection suspended");
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
// Refer to the javadoc for ConnectionResult to see what error codes might be returned in
// onConnectionFailed.
Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + result.getErrorCode());
}
/**
* Callback that fires when the location changes.
*/
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onLocationChanged(Location location) {
Log.i(TAG, "inside On location changed method");
mCurrentLocation = location;
mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
mAddressRequested = true;
Log.i(TAG, "Location Updated");
Log.i("Latitude", String.valueOf(mCurrentLocation.getLatitude()));
Log.i("Longitude", String.valueOf(mCurrentLocation.getLongitude()));
if (mCurrentLocation != null) {
// Determine whether a Geocoder is available.
if (!Geocoder.isPresent()) {
//Toast.makeText(c, "no geocoder available", Toast.LENGTH_LONG).show();
return;
}
startIntentService();
}
Log.i(TAG,"Calling the startIntentService method");
startIntentService();
Log.i(TAG, "Calling the addressstore method");
mResultReceiver.addressStore(c);
updateUI();
}
private void updateUI() {
}
/**
* Requests location updates from the FusedLocationApi.
*/
protected void startLocationUpdates() {
// The final argument to {@code requestLocationUpdates()} is a LocationListener
// (http://developer.android.com/reference/com/google/android/gms/location/LocationListener.html).
Log.i(TAG,"Calling the startLocationUpdates method");
FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
// @Override
// protected void onStart() {
// super.onStart();
//
// mGoogleApiClient.connect();
//
// }
// @Override
// public void onResume() {
// super.onResume();
// // Within {@code onPause()}, we pause location updates, but leave the
// // connection to GoogleApiClient intact. Here, we resume receiving
// // location updates if the user has requested them.
//
// if (mGoogleApiClient.isConnected() && mRequestingLocationUpdates) {
// startLocationUpdates();
// }
}
// @Override
// protected void onPause() {
// super.onPause();
// // Stop location updates to save battery, but don't disconnect the GoogleApiClient object.
// if (mGoogleApiClient.isConnected()) {
//
// }
// }
//
// @Override
// protected void onStop() {
// mGoogleApiClient.disconnect();
//
// super.onStop();
// }
/**
* Receiver for data sent from FetchAddressIntentService.
*/
class AddressResultReceiver extends ResultReceiver {
protected TextView mLocationAddressTextView;
public String mAddressOutput= "";
//time variables
long t1=0;
HashMap<String,Integer> home= new HashMap<>();
HashMap<String,Integer> work= new HashMap<>();
LRU homeCache= new LRU(3,0.1f);
LRU workCache= new LRU(3,0.1f);
String homeAddress="";
String workAddress="";
public AddressResultReceiver(Handler handler) {
super(handler);
// this.mLocationAddressTextView = mLocationAddressTextView;
}
/**
* Receives data sent from FetchAddressIntentService and updates the UI in MainActivity.
*/
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
Log.i("Result address received", String.valueOf(resultCode));
// Display the address string or an error message sent from the intent service.
mAddressOutput = resultData.getString(Constants.RESULT_DATA_KEY);
LocationData data= LocationData.getInstance();
Log.v("LOC home",homeAddress);
Log.v("LOC work", workAddress);
Log.v("LOC curr",mAddressOutput);
if(!mAddressOutput.equals("") && homeCache.containsKey(mAddressOutput)){
//Zero is home
//One in work
//2 ins NA
// Toast.makeText(c, "here 2", Toast.LENGTH_SHORT).show();
Log.v("CHECK","1");
data.setStatus(0);
}else if(!mAddressOutput.equals("") && workCache.containsKey(mAddressOutput)){
data.setStatus(1);
Log.v("CHECK", "2");
}else {
data.setStatus(2);
Log.v("CHECK", "3");
}
Log.i("Mad Output YAYAYA",mAddressOutput);
// displayAddressOutput();
// Show a toast message if an address was found.
if (resultCode == Constants.SUCCESS_RESULT) {
Log.i("Address Found HURRAY", mAddressOutput);
}
// Reset. Enable the Fetch Address button and stop showing the progress bar.
//mAddressRequested = false;
}
// protected void displayAddressOutput() {
// mLocationAddressTextView.setText(mAddressOutput);
// }
private void openAlert(final String address, final String name, Context c) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(c);
// set title
alertDialogBuilder.setTitle("GPS Address");
// set dialog message
alertDialogBuilder
.setMessage("Is "+address+" your "+name+" location?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
if (name.equals("home")) {
homeAddress = address;
homeCache.put(address, 10);
} else {
workAddress = address;
workCache.put(address, 8);
}
dialog.dismiss();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// show it
alertDialog.show();
}
public void addressStore(Context c){
Log.i("New Vrsn ADDRESS 1",mAddressOutput);
//Added by: Abhishek Shukla (25 JULY)
//code for capturing every hour address
//it can enter this loop only thrice in every hour
//convert current time into date and extract 24 hours
if(System.currentTimeMillis()-t1>1200000){
Date date = new Date(t1);
DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
String dateFormatted = formatter.format(date);
int hour = date.getHours();
//Logoc to find home and work location
//home is defined as place where device live at 0,1,2,3,4,5 hours of day
// so we take sample of three days , and place with minimum 12 out of 18 is taken as home
// similarly for office we do it, for 11,12,13,14,15,16
if(hour<=5 && hour>=0)
{
int homesize=0;
for(int i:home.values()){
homesize+=i;
}
if(homesize>36)
home.clear();
if(home.containsKey(mAddressOutput)){
int temp= home.get(mAddressOutput);
home.put(mAddressOutput,temp+1);
}else{
home.put(mAddressOutput,1);
}
//Toast.makeText(c,homeAddress,Toast.LENGTH_LONG).show();
Log.i("HOME LEARNED", homeAddress);
Log.i("home map size",Integer.toString(homesize));
for(String s:home.keySet()){
Log.i("Current S",s);
int freq=home.get(s);
if(freq>15){
//set home addresss as S
//update home address only when it is different from previous location
if(!homeAddress.equals(s))
openAlert(s,"home",c);
// homeAddress=s;
// homeCache.put(s,10);
}
}
}
//office location learning
if(hour>=16 && hour<=11)
{
int worksize=0;
for(int i:work.values()){
worksize+=i;
}
if(worksize>36)
work.clear();
if(work.containsKey(mAddressOutput)){
int temp= work.get(mAddressOutput);
work.put(mAddressOutput,temp+1);
}else{
work.put(mAddressOutput,1);
}
// Toast.makeText(c,workAddress,Toast.LENGTH_LONG).show();
Log.i("WORK LEARNED", workAddress);
Log.i("Work map size",Integer.toString(worksize));
for(String s:work.keySet()){
int freq=work.get(s);
if(freq>15){
//set home addresss as S
if(!workAddress.equals(s))
openAlert(s,"work",c);
// workAddress=s;
// workCache.put(s,8);
}
}
}
//update t1 with current time
t1 = System.currentTimeMillis();
}//if ends here
}
}
| [
"[email protected]"
]
| |
527cadcbf4ab0bf6ff42c616b4b90753bb2da017 | f64c6f03810211fab709bc5d9771de1f4ff6e4da | /app/src/main/java/com/example/kb/lab5_2/ui/AddNewActivity.java | a07302896ddc631604f3a928dae856977cd34c1c | []
| no_license | Splenish/ToDoListAndroid | ca8c3bfd7b1d76388d6f20c30153e35d9f9cb9a3 | a230be3682a2b73133aafbd6cce7e5b64508b030 | refs/heads/master | 2020-04-26T03:30:23.935707 | 2019-03-01T08:58:06 | 2019-03-01T08:58:06 | 173,268,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,947 | java | package com.example.kb.lab5_2.ui;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.DatePicker;
import android.widget.EditText;
import com.example.kb.lab5_2.R;
import com.example.kb.lab5_2.model.ToDoItem;
import com.example.kb.lab5_2.model.ToDoModel;
import java.util.Calendar;
public class AddNewActivity extends AppCompatActivity {
ToDoModel model = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_new);
model = new ToDoModel(getApplicationContext());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.add_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.save_list_item) {
EditText nameInput = findViewById(R.id.name_input);
EditText descInput = findViewById(R.id.description_input);
DatePicker dueDate = findViewById(R.id.dueDate);
String title = nameInput.getText().toString();
String description = descInput.getText().toString();
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, dueDate.getDayOfMonth());
cal.set(Calendar.MONTH, dueDate.getMonth());
cal.set(Calendar.YEAR, dueDate.getYear());
long date = cal.getTimeInMillis();
Log.d("DATE", date + "");
ToDoItem itemToAdd = new ToDoItem(title, description, date);
model.addItemToDb(itemToAdd);
finish();
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
]
| |
6284cdd4a6eaa22971e92e4e90d29b16a1efdfc4 | 520dd9a2baa355faac003c2ac84d28fb4a0340c9 | /src/com/cetp/view/FavoriteView.java | 88441d03c31988211a334aa1870b718472305f11 | []
| no_license | gubojun/cetpv2.0.0 | 99c6c1e82ef8aab994e116dd8f7ea946b57e2c99 | bd2e5b38beed70e401342a0abb2e6b5361fbf136 | refs/heads/master | 2021-01-13T01:46:00.353524 | 2015-04-17T15:06:38 | 2015-04-17T15:06:38 | 30,029,049 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,782 | java | package com.cetp.view;
import com.cetp.R;
import com.cetp.action.SkinSettingManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class FavoriteView {
//
private RelativeLayout rltListening;
private RelativeLayout rltClozing;
private RelativeLayout rltReading;
Context context;
Activity activity;
public FavoriteView(Context c) {
context = c;
activity = (Activity) c;
}
public void setView(View v) {
findView(v);
rltListening.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.putExtra("VIEW", 0);
intent.putExtra("KindOfView", 2);
intent.setClass(context, CommonTab.class);
context.startActivity(intent);
}
});
rltClozing.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.putExtra("VIEW", 1);
intent.putExtra("KindOfView", 2);
intent.setClass(context, CommonTab.class);
context.startActivity(intent);
}
});
rltReading.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.putExtra("VIEW", 2);
intent.putExtra("KindOfView", 2);
intent.setClass(context, CommonTab.class);
context.startActivity(intent);
}
});
}
private void findView(View v) {
rltListening=(RelativeLayout)v.findViewById(R.id.fav_rlt_listening);
rltClozing=(RelativeLayout)v.findViewById(R.id.fav_rlt_clozing);
rltReading=(RelativeLayout)v.findViewById(R.id.fav_rlt_reading);
}
}
| [
"[email protected]"
]
| |
272730d47a45220ea79e2fca58143762ed52d204 | 5d22064497af6d81623b8fd42e2125e9cfa4cf24 | /app/src/main/java/com/example/boon_android_app/SearchActivity.java | 0a7a0264392c99e40809a3ac7a61b330cd040974 | []
| no_license | Anuragsingh691/BoonAndroidApp | 95657b156e7d583fe4236806dad098cbe79da986 | 326264b91677c2986b282c97b689c236eea2189b | refs/heads/master | 2023-01-24T08:23:08.111898 | 2020-12-02T03:49:41 | 2020-12-02T03:49:41 | 294,193,218 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,601 | java | package com.example.boon_android_app;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.example.boon_android_app.Prevalent.Prevalent;
import com.example.boon_android_app.Search.BestRatingFragment;
import com.example.boon_android_app.Search.MaxExpFragment;
import com.example.boon_android_app.Search.TrendingSearchFragment;
import com.example.boon_android_app.homeFragments.TrendingFrag;
import com.example.boon_android_app.model.TutorVH;
import com.example.boon_android_app.model.tutors;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
public class SearchActivity extends AppCompatActivity {
BottomNavigationView bottomNavigationView;
private ImageView searchImg,back;
private EditText searchEdt;
FrameLayout frameLayout;
private RecyclerView searchRv;
private RecyclerView.LayoutManager layoutManager;
private String searchInput;
private FloatingActionButton chatFab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
bottomNavigationView = findViewById(R.id.bottom_nav);
frameLayout = findViewById(R.id.frameLayout2);
chatFab=findViewById(R.id.chat_fab_search);
chatFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SearchActivity.this,ChatBotAct.class));
}
});
getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout2,new BestRatingFragment()).commit();
bottomNavigationView.setOnNavigationItemSelectedListener(bottomMethod2);
}
private BottomNavigationView.OnNavigationItemSelectedListener bottomMethod2 =
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment fragment = null;
switch (item.getItemId())
{
case R.id.bottom_best_rating:
fragment=new BestRatingFragment();
break;
case R.id.bottom_nav_trending_search:
fragment=new TrendingSearchFragment();
break;
case R.id.bottom_nav_max_search:
fragment=new MaxExpFragment();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout2,fragment).commit();
return true;
}
};
} | [
"[email protected]"
]
| |
e1360b8ca112950ae4d2eeef04c27d972b318aba | 2ae25775d0056a550c40f54fe1f8120a39694a26 | /src/main/java/org/orlounge/bean/InstrumentPrefListBean.java | 32a48889367f935039b71295f19180c3d4c3faa1 | []
| no_license | PoojaShimpi/orlounge | b5c79cd87a13ea255556ca6a5d23e54317671ee6 | 2d1ca847426e736b0ca93d367c750519b8620349 | refs/heads/master | 2023-03-17T20:28:18.260983 | 2021-03-06T06:03:24 | 2021-03-06T06:03:24 | 337,763,205 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,877 | java | package org.orlounge.bean;
import javax.persistence.*;
/**
* Created by Satyam Soni on 1/1/2016.
*/
@Entity
@Table(name = "instrument_pref_list")
public class InstrumentPrefListBean {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "pref_id")
private Integer prefId;
@ManyToOne
@JoinColumn(name = "pref_id", insertable = false, updatable = false)
private PrefListBean preference;
@Column
private String name;
@Column
private String quantity;
@Column(name = "photo")
private String photoImagePath;
@Column
private String bin;
@Column
private String catalog;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getPhotoImagePath() {
return photoImagePath;
}
public void setPhotoImagePath(String photoImagePath) {
this.photoImagePath = photoImagePath;
}
public String getBin() {
return bin;
}
public void setBin(String bin) {
this.bin = bin;
}
public String getCatalog() {
return catalog;
}
public void setCatalog(String catalog) {
this.catalog = catalog;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPrefId() {
return prefId;
}
public void setPrefId(Integer prefId) {
this.prefId = prefId;
}
public PrefListBean getPreference() {
return preference;
}
public void setPreference(PrefListBean preference) {
this.preference = preference;
}
}
| [
"[email protected]"
]
| |
853037e948a7d4480ca96eeeb44a81181ead4178 | b35e42618890b01f01f5408c05741dc895db50a2 | /opentsp-dongfeng-modules/opentsp-dongfeng-system/dongfeng-system-core/src/main/java/com/navinfo/opentsp/dongfeng/system/service/IRoleService.java | d9bac90429dfaca02e4f850c0a6c9d54ca19ce91 | []
| no_license | shanghaif/dongfeng-huanyou-platform | 28eb5572a1f15452427456ceb3c7f3b3cf72dc84 | 67bcc02baab4ec883648b167717f356df9dded8d | refs/heads/master | 2023-05-13T01:51:37.463721 | 2018-03-07T14:24:03 | 2018-03-07T14:26:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,146 | java | package com.navinfo.opentsp.dongfeng.system.service;
import com.navinfo.opentsp.dongfeng.common.result.CommonResult;
import com.navinfo.opentsp.dongfeng.common.result.HttpCommandResultWithData;
import com.navinfo.opentsp.dongfeng.system.commands.role.*;
/**
* Created by yaocy on 2017/03/13.
* 角色Service接口
*/
@SuppressWarnings("rawtypes")
public interface IRoleService {
/**
* 查询
* @param command
* @return
*/
public HttpCommandResultWithData queryRoleList(RoleListCommand command);
public HttpCommandResultWithData getRole(GetRoleCommand command);
/**
* 添加
* @param command
* @return
*/
public CommonResult addRole(AddRoleCommand command);
/**
* 修改
* @param command
* @return
*/
public CommonResult editRole(EditRoleCommand command);
/**
* 删除
* @param command
* @return
*/
public CommonResult delRole(DelRoleCommand command);
public HttpCommandResultWithData queryRoleByType(RoleByTypeCommand command);
public HttpCommandResultWithData queryRolePermission(RolePermissionCommand command);
}
| [
"[email protected]"
]
| |
c68adf26657534158ead2d2a51f1bf674835d273 | cbc61ffb33570a1bc55bb1e754510192b0366de2 | /ole-app/olefs/src/main/java/org/kuali/ole/fp/document/validation/impl/DisbursementVoucherPayeeStateCodeValidation.java | 844a8205be98db38113bf99147df4366f6f581ce | [
"ECL-2.0"
]
| permissive | VU-libtech/OLE-INST | 42b3656d145a50deeb22f496f6f430f1d55283cb | 9f5efae4dfaf810fa671c6ac6670a6051303b43d | refs/heads/master | 2021-07-08T11:01:19.692655 | 2015-05-15T14:40:50 | 2015-05-15T14:40:50 | 24,459,494 | 1 | 0 | ECL-2.0 | 2021-04-26T17:01:11 | 2014-09-25T13:40:33 | Java | UTF-8 | Java | false | false | 4,970 | java | /*
* Copyright 2009 The Kuali Foundation
*
* Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
*
* 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.kuali.ole.fp.document.validation.impl;
import org.apache.commons.lang.StringUtils;
import org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail;
import org.kuali.ole.fp.document.DisbursementVoucherDocument;
import org.kuali.ole.sys.OLEKeyConstants;
import org.kuali.ole.sys.OLEPropertyConstants;
import org.kuali.ole.sys.context.SpringContext;
import org.kuali.ole.sys.document.AccountingDocument;
import org.kuali.ole.sys.document.validation.GenericValidation;
import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
import org.kuali.rice.kns.service.DataDictionaryService;
import org.kuali.rice.krad.util.GlobalVariables;
import org.kuali.rice.krad.util.MessageMap;
import org.kuali.rice.location.api.state.State;
import org.kuali.rice.location.api.state.StateService;
public class DisbursementVoucherPayeeStateCodeValidation extends GenericValidation {
private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherPayeeStateCodeValidation.class);
private AccountingDocument accountingDocumentForValidation;
/**
* @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
*/
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
DisbursementVoucherDocument document = (DisbursementVoucherDocument) accountingDocumentForValidation;
DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(OLEPropertyConstants.DOCUMENT);
DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
StateService stateService = SpringContext.getBean(StateService.class);
String countryCode = payeeDetail.getDisbVchrPayeeCountryCode();
String stateCode = payeeDetail.getDisbVchrPayeeStateCode();
if (StringUtils.isNotBlank(stateCode) && StringUtils.isNotBlank(countryCode)) {
State state = stateService.getState(countryCode, stateCode);
if (state == null) {
String label = dataDictionaryService.getAttributeLabel(DisbursementVoucherPayeeDetail.class, OLEPropertyConstants.DISB_VCHR_PAYEE_STATE_CODE);
String propertyPath = OLEPropertyConstants.DV_PAYEE_DETAIL + "." + OLEPropertyConstants.DISB_VCHR_PAYEE_STATE_CODE;
errors.putError(propertyPath, OLEKeyConstants.ERROR_EXISTENCE, label);
isValid = false;
}
}
countryCode = payeeDetail.getDisbVchrSpecialHandlingCountryCode();
stateCode = payeeDetail.getDisbVchrSpecialHandlingStateCode();
if (document.isDisbVchrSpecialHandlingCode() && StringUtils.isNotBlank(stateCode) && StringUtils.isNotBlank(countryCode)) {
State state = stateService.getState(countryCode, stateCode);
if (state == null) {
String label = dataDictionaryService.getAttributeLabel(DisbursementVoucherPayeeDetail.class, OLEPropertyConstants.DISB_VCHR_SPECIAL_HANDLING_STATE_CODE);
String propertyPath = OLEPropertyConstants.DV_PAYEE_DETAIL + "." + OLEPropertyConstants.DISB_VCHR_SPECIAL_HANDLING_STATE_CODE;
errors.putError(propertyPath, OLEKeyConstants.ERROR_EXISTENCE, label);
isValid = false;
}
}
errors.removeFromErrorPath(OLEPropertyConstants.DOCUMENT);
return isValid;
}
/**
* Gets the accountingDocumentForValidation attribute.
*
* @return Returns the accountingDocumentForValidation.
*/
public AccountingDocument getAccountingDocumentForValidation() {
return accountingDocumentForValidation;
}
/**
* Sets the accountingDocumentForValidation attribute value.
*
* @param accountingDocumentForValidation The accountingDocumentForValidation to set.
*/
public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
this.accountingDocumentForValidation = accountingDocumentForValidation;
}
}
| [
"[email protected]"
]
| |
f72acc8fa0f1b92c7c182782df0c4bd3d99a28e5 | 77d9a4cca1b93b9f68520cc1d9a1c948acc50710 | /peachJob-core/src/main/java/com/ld/peach/job/core/constant/TaskConstant.java | 554164db10b6b3da524635ee1b465e0b57cc911e | [
"Apache-2.0"
]
| permissive | superHeroLD/peachJob | 4190aebd9e685f9a086385c31ea185b6aba97f50 | eedbf776208d053bf9911abcf0d4c281cc342ed1 | refs/heads/master | 2023-01-09T23:23:23.718994 | 2020-11-18T11:48:06 | 2020-11-18T11:48:06 | 290,934,985 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,080 | java | package com.ld.peach.job.core.constant;
/**
* @InterfaceName JobConstant
* @Description 常量
* @Author lidong
* @Date 2020/9/8
* @Version 1.0
*/
public interface TaskConstant {
/**
* 成功
*/
int CODE_SUCCESS = 1;
/**
* 失败
*/
int CODE_FAILED = -1;
/**
* 心跳时长
*/
int BEAT_TIMEOUT = 30;
/**
* 最大重试次数
*/
int MAX_RETRY_NUM = 10;
/**
* 清理时长,需比心跳稍大
*/
int CLEAN_TIMEOUT = 50000;
/**
* owner标志常量,用于标志是否做过tryLock()操作
*/
String OPERATION_TRY_LOCK = "OPERATION_TRY_LOCK";
/**
* 锁唯一标示
*/
String DEFAULT_LOCK_KEY = "PEACH_JOB_LOCK";
/**
* 异常任务锁
*/
String ABNORMAL_TASK_LOCK_KEY = "ABNORMAL_TASK_LOCK";
/**
* 逗号分隔符
*/
String COMMA = ",";
/**
* API URI
*/
String ADMIN_SERVICE_API = "/adminService-api";
/**
* 三分钟毫秒
*/
int THREE_MINS_MILLIS = 3 * 60 * 1000;
}
| [
"[email protected]"
]
| |
cd08ff20461403e850eefc6464746a456a89c726 | e8063490a4f62b197d121e532f9b353fb224dc6e | /src/main/java/itacademy/model/Engine.java | 0ebef9135e727a94f776907cf004f01ffe82d41d | []
| no_license | AlexeyYanul/SpringRentCar | 5a4636b42004cd42c63430ddcc1534667aae667e | d1063638eeddf3c6a101752c8bffe9e21f087e63 | refs/heads/master | 2022-12-29T11:11:05.183904 | 2020-02-06T12:50:49 | 2020-02-06T12:50:49 | 218,053,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,398 | java | package itacademy.model;
import javax.persistence.*;
@Entity
public class Engine {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private Double volume;
@Column(nullable = false)
private String fuel;
@Column(name = "fuel_economy", nullable = false)
private String fuelEconomy;
public Engine() {
}
public Engine(Double volume, String fuel, String fuelEconomy) {
this.volume = volume;
this.fuel = fuel;
this.fuelEconomy = fuelEconomy;
}
@Override
public String toString() {
return "Engine{" +
"id=" + id +
", volume=" + volume +
", fuel='" + fuel + '\'' +
", fuelEconomy='" + fuelEconomy + '\'' +
'}';
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Double getVolume() {
return volume;
}
public void setVolume(Double volume) {
this.volume = volume;
}
public String getFuel() {
return fuel;
}
public void setFuel(String fuel) {
this.fuel = fuel;
}
public String getFuelEconomy() {
return fuelEconomy;
}
public void setFuelEconomy(String fuelEconomy) {
this.fuelEconomy = fuelEconomy;
}
}
| [
"[email protected]"
]
| |
e95ec04ee4d6d33329e43c5d5b084d4d3b350835 | d38819cc340feb41fdea2f2f57b6914ba8786ca6 | /ChefsFrontEnd/src/main/java/sample/User.java | c3abbb7913e894476b0eeff219a3a84e3447b074 | [
"MIT"
]
| permissive | Kobrestad/ChefsApprentice | c85f01db13ab272a3774057ee316f6ac23b59bb9 | e9e78f096d4d560c56d396f1c0eca9aa708a09dd | refs/heads/master | 2022-06-22T04:59:53.364592 | 2020-10-15T15:13:07 | 2020-10-15T15:13:07 | 180,764,968 | 2 | 1 | MIT | 2022-06-21T01:03:26 | 2019-04-11T10:01:05 | Java | UTF-8 | Java | false | false | 1,252 | java | package sample;
import java.io.Serializable;
/**
* Denne klassen brukes for aa holde styr paa brukerprivilegier.
*/
public class User implements Serializable {
/**
* Brukernavnet til brukeren.
*/
private final String username;
/**
* Hvilken grad av systemprivilegier brukeren har.
*/
private final String role;
/**
* Lager et bruker-objekt.
* @param username Brukernavnet til brukeren.
* @param role Graden av systemprivilegier som brukeren har.
*/
public User(String username, String role) {
this.username = username;
this.role = role;
}
/**
* Standard getter for brukernavn.
* @return returnerer brukernavnet til brukeren.
*/
public String getUsername() {
return this.username;
}
/**
* Standard getter for rolle.
* @return returnerer brukerprivilegiene til brukeren.
*/
public String getRole() {
return this.role;
}
/**
* Denne metoden er en slags toString(). Printer oppskriftsklassen paa et fint format.
*/
public void printUser() {
System.out.println("\nUsername: " + this.getUsername());
System.out.println("Role: " + this.getRole());
}
}
| [
"[email protected]"
]
| |
0df862593ad7ae018428e4065896e6034983dafe | 536790f9860e8d809a5faf2c3ae72d8893182b51 | /UDPEchoServer.java | fa5420b0c68f363f6ae0bcf22f12093215309def | []
| no_license | HamzaMasharqa/UDPServer-clientComunication | 3f2f4ed896079bfefc10acf1f85bb7c4a61e0328 | 63b7d1f2ae46538ddd286f2116a08f371cae0ecb | refs/heads/master | 2023-06-26T02:26:18.864546 | 2021-07-05T17:07:30 | 2021-07-05T17:07:30 | 383,212,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,041 | java | package clientserver;
import java.net.*;
import java.io.*;
public class UDPEchoServer {
public static void main(String args[]) {
int port = 8000;
DatagramSocket serverDatagramSocket = null;
try {
serverDatagramSocket = new DatagramSocket(port);
System.out.println("Created UDP Echo Server on port number : " + port);
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
try {
byte buffer[] = new byte[1024];
DatagramPacket dp = new
DatagramPacket(buffer, buffer.length);
String input;
while (true) {
serverDatagramSocket.receive(dp);
input = new String(dp.getData(), 0,
dp.getLength());
System.out.println("the receved input server: " + input);
serverDatagramSocket.send(dp);
}
} catch (IOException e) {
System.out.println(e);
}
}
} | [
"[email protected]"
]
| |
cddad49f76eb4646b3256b4b6e953d335c9f7b1d | 8a65dd04f516ed1488b6dbd5bb14c73fd3874e02 | /org.eclipse.buckminster.cspecxml/src/org/eclipse/buckminster/cspecxml/IDocumentRoot.java | 5ed65e5d810664b567056f9c1ddff240dc73fd70 | []
| no_license | PalladioSimulator/buckminster | ffb173c7734d24ac7fa542b6c27171d53c80a4a8 | ecd4575c37c76888fc9bf4714fd6438b10621a30 | refs/heads/master | 2021-04-18T22:10:25.856251 | 2018-03-26T12:21:04 | 2018-03-26T12:21:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,885 | java | /**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.eclipse.buckminster.cspecxml;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.FeatureMap;
/**
* <!-- begin-user-doc --> A representation of the model object '
* <em><b>Document Root</b></em>'. <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getMixed <em>Mixed
* </em>}</li>
* <li>{@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getXMLNSPrefixMap
* <em>XMLNS Prefix Map</em>}</li>
* <li>
* {@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getXSISchemaLocation
* <em>XSI Schema Location</em>}</li>
* <li>{@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getCspec <em>Cspec
* </em>}</li>
* <li>{@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getCspecExtension
* <em>Cspec Extension</em>}</li>
* </ul>
* </p>
*
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot()
* @model extendedMetaData="name='' kind='mixed'"
* @generated
*/
public interface IDocumentRoot extends EObject {
/**
* Returns the value of the '<em><b>Cspec</b></em>' containment reference.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Cspec</em>' containment reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Cspec</em>' containment reference.
* @see #setCspec(IComponentSpec)
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot_Cspec()
* @model containment="true" upper="-2" transient="true" volatile="true"
* derived="true" extendedMetaData=
* "kind='element' name='cspec' namespace='##targetNamespace'"
* @generated
*/
IComponentSpec getCspec();
/**
* Returns the value of the '<em><b>Cspec Extension</b></em>' containment
* reference. <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Cspec Extension</em>' containment reference
* isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Cspec Extension</em>' containment
* reference.
* @see #setCspecExtension(ICSpecExtension)
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot_CspecExtension()
* @model containment="true" upper="-2" transient="true" volatile="true"
* derived="true" extendedMetaData=
* "kind='element' name='cspecExtension' namespace='##targetNamespace'"
* @generated
*/
ICSpecExtension getCspecExtension();
/**
* Returns the value of the '<em><b>Mixed</b></em>' attribute list. The list
* contents are of type {@link org.eclipse.emf.ecore.util.FeatureMap.Entry}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Mixed</em>' attribute list isn't clear, there
* really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Mixed</em>' attribute list.
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot_Mixed()
* @model unique="false" dataType="org.eclipse.emf.ecore.EFeatureMapEntry"
* many="true"
* extendedMetaData="kind='elementWildcard' name=':mixed'"
* @generated
*/
FeatureMap getMixed();
/**
* Returns the value of the '<em><b>XMLNS Prefix Map</b></em>' map. The key
* is of type {@link java.lang.String}, and the value is of type
* {@link java.lang.String}, <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>XMLNS Prefix Map</em>' map isn't clear, there
* really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>XMLNS Prefix Map</em>' map.
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot_XMLNSPrefixMap()
* @model mapType="org.eclipse.emf.ecore.EStringToStringMapEntry<org.eclipse.emf.ecore.EString, org.eclipse.emf.ecore.EString>"
* transient="true"
* extendedMetaData="kind='attribute' name='xmlns:prefix'"
* @generated
*/
EMap<String, String> getXMLNSPrefixMap();
/**
* Returns the value of the '<em><b>XSI Schema Location</b></em>' map. The
* key is of type {@link java.lang.String}, and the value is of type
* {@link java.lang.String}, <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>XSI Schema Location</em>' map isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>XSI Schema Location</em>' map.
* @see org.eclipse.buckminster.cspecxml.ICSpecXMLPackage#getDocumentRoot_XSISchemaLocation()
* @model mapType="org.eclipse.emf.ecore.EStringToStringMapEntry<org.eclipse.emf.ecore.EString, org.eclipse.emf.ecore.EString>"
* transient="true"
* extendedMetaData="kind='attribute' name='xsi:schemaLocation'"
* @generated
*/
EMap<String, String> getXSISchemaLocation();
/**
* Sets the value of the '
* {@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getCspec
* <em>Cspec</em>}' containment reference. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @param value
* the new value of the '<em>Cspec</em>' containment reference.
* @see #getCspec()
* @generated
*/
void setCspec(IComponentSpec value);
/**
* Sets the value of the '
* {@link org.eclipse.buckminster.cspecxml.IDocumentRoot#getCspecExtension
* <em>Cspec Extension</em>}' containment reference. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value
* the new value of the '<em>Cspec Extension</em>' containment
* reference.
* @see #getCspecExtension()
* @generated
*/
void setCspecExtension(ICSpecExtension value);
} // IDocumentRoot
| [
"thallgren@ee007c2a-0a25-0410-9ab9-bf268980928c"
]
| thallgren@ee007c2a-0a25-0410-9ab9-bf268980928c |
799b9491c678ef8694ebd356c6f23d785911c0f6 | 7caaf0ea93b2e2af944e4e0949c3b8ad5337c94d | /src/main/java/module/Contract.java | 64dc142dca4d1dc39ba7ff26024c084b86f191c8 | []
| no_license | tianwei99/poipdf | 4fda3133fdb345231469f1716f1b5c2d5ccb877f | ce413f7cb603550d329d7c5432d43ede9f7ede0d | refs/heads/master | 2021-06-25T12:30:22.935631 | 2017-08-26T07:45:45 | 2017-08-26T07:45:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,610 | java | package module;
/**
* Created by Administrator on 2017/8/25.
*/
public class Contract {
private String name;
private String phone;
private String idcard;
private String address;
private String money = "17600.00";
private String moneyText = "壹万柒仟陆百元整";
private String month = "6";
private String payback = "0.29";
private String paybackMonth = "7个月";
private String paybackPermonth = "1215.28";
private String totalMonth = "24个月";
private String now;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getIdcard() {
return idcard;
}
public void setIdcard(String idcard) {
this.idcard = idcard;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public String getMoneyText() {
return moneyText;
}
public void setMoneyText(String moneyText) {
this.moneyText = moneyText;
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public String getPayback() {
return payback;
}
public void setPayback(String payback) {
this.payback = payback;
}
public String getPaybackMonth() {
return paybackMonth;
}
public void setPaybackMonth(String paybackMonth) {
this.paybackMonth = paybackMonth;
}
public String getPaybackPermonth() {
return paybackPermonth;
}
public void setPaybackPermonth(String paybackPermonth) {
this.paybackPermonth = paybackPermonth;
}
public String getTotalMonth() {
return totalMonth;
}
public void setTotalMonth(String totalMonth) {
this.totalMonth = totalMonth;
}
public String getNow() {
return now;
}
public void setNow(String now) {
this.now = now;
}
public Contract() {
}
public Contract(String name, String phone, String idcard, String address, String now) {
this.name = name;
this.phone = phone;
this.idcard = idcard;
this.address = address;
this.now = now;
}
}
| [
"[email protected]"
]
| |
e58b486dadceb3ba333e6a3ed55d09b54a41451f | 051b879fb621c5d5d392b1d284d325683d93e58f | /Final-android-storage-permissions-master/android-storage-permissions-master/app/src/main/java/com/google/samples/dataprivacy/storage/LocalImagesRepository.java | a944b94330f188f6150f7d225c97f2b1baac810b | [
"Apache-2.0"
]
| permissive | SimoneCastellitto/Data-Privacy-Facial-Detection-Android-App | d9e193423fafc0a434cbefec8b8358d2e8fc534b | 5d894b83264992afd3e5bfc71f5db6bbdb7194c7 | refs/heads/master | 2021-07-10T03:51:25.883957 | 2021-05-18T06:33:19 | 2021-05-18T06:33:19 | 244,688,919 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,787 | java | /*
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.samples.dataprivacy.storage;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;
//to use Android Api:
//import android.media.*;
import android.util.SparseArray;
import com.google.android.gms.vision.Frame;
import com.google.android.gms.vision.face.Face;
//to use google vision
import com.google.android.gms.vision.face.FaceDetector;
import com.google.samples.dataprivacy.model.Image;
import com.google.samples.dataprivacy.util.MyContext;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Repository of images that stores data on the device. The initial implementation is using
* the external storage directory (see {@link Environment#getExternalStorageDirectory()}.
*/
public class LocalImagesRepository implements ImagesRepository {
private static final String TAG = "LocalImagesRepository";
private static final String PATH = "secureimages/";
private File mStorage;
public LocalImagesRepository(Context context) {
File internalStorage = context.getFilesDir();
mStorage = new File(internalStorage, PATH);
if (!mStorage.exists()) {
if (!mStorage.mkdirs()) {
Log.e(TAG, "Could not create storage directory: " + mStorage.getAbsolutePath());
}
}
}
/**
* Generates a file name for the png image and stores it in local storage.
*
* @param image The bitmap to store.
* @return The name of the image file.
*/
@Override
public String saveImage(Bitmap image) {
//code to get the number of faces before to save it (Android API)
/*Bitmap bmp = image.copy(Bitmap.Config.RGB_565, true);
int maxFaces = 3;
FaceDetector faceDetector = new FaceDetector(image.getWidth(),image.getHeight(),maxFaces);
FaceDetector.Face[] faces = new FaceDetector.Face[maxFaces];
int numberFaces = faceDetector.findFaces(bmp,faces);*/
//Code to get the number of faces (max 3) using google vision
Frame.Builder myFrameBuilder = new Frame.Builder().setBitmap(image);
Frame myFrame = myFrameBuilder.build();
FaceDetector faceDetector = new FaceDetector.Builder(MyContext.getContext()).build();
SparseArray<Face> arrayOfFaces= faceDetector.detect(myFrame);
int numberFaces = arrayOfFaces.size();
if (numberFaces > 3) numberFaces = 3;
//code to save the fileName with the first letter the number of faces
final String fileName = numberFaces + UUID.randomUUID().toString() + ".png";
File file = new File(mStorage, fileName);
try (FileOutputStream fos = new FileOutputStream(file)) {
image.compress(Bitmap.CompressFormat.PNG, 85, fos);
} catch (IOException e) {
Log.e(TAG, "Error during saving of image: " + e.getMessage());
return null;
}
return fileName;
}
/**
* Deletes the given image.
*
* @param fileName Filename of the image to delete.
*/
@Override
public void deleteImage(String fileName) {
File file = new File(fileName);
if (!file.delete()) {
Log.e(TAG, "File could not be deleted: " + fileName);
}
}
/**
* Returns a list of all images stored in this repository.
* An {@link Image} contains a {@link Bitmap} and a string with its filename.
*
* @return
*/
@Override
public List<Image> getImages() {
File[] files = mStorage.listFiles();
if (files == null) {
Log.e(TAG, "Could not list files.");
return null;
}
ArrayList<Image> list = new ArrayList<>(files.length);
for (File f : files) {
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
list.add(new Image(f.getAbsolutePath(), bitmap));
}
return list;
}
//Returns a list of the images saved in the repository with the number of faces I want.
public List<Image> getSomeImages(int numberFaces){
File[] files = mStorage.listFiles();
if (files == null) {
Log.e(TAG, "Could not list files.");
return null;
}
String prefixToCompare = String.valueOf(numberFaces);
ArrayList<Image> list = new ArrayList<>(files.length);
for (File f : files) {
if(f.getName().startsWith(prefixToCompare)) {
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
list.add(new Image(f.getAbsolutePath(), bitmap));
}
}
return list;
}
/**
* Loads the given file as a bitmap.
*/
@Override
public Bitmap getImage(String path) {
File file = new File(path);
if (!file.exists()) {
Log.e(TAG, "File could not opened. It does not exist: " + path);
return null;
}
return BitmapFactory.decodeFile(file.getAbsolutePath());
}
}
| [
"[email protected]"
]
| |
c49c284f393517570ac9b8d29585062761bd85bf | bf390e6589e240c6ccc325355cfd0c21fbe9d884 | /3.JavaMultithreading/src/com/javarush/task/task27/task2710/MailServer.java | 186dbed991825c23d6d946768150714183c15958 | []
| no_license | vladmeh/jrt | 84878788fbb1f10aa55d320d205f886d1df9e417 | 0272ded03ac8eced7bf901bdfcc503a4eb6da12a | refs/heads/master | 2020-04-05T11:20:15.441176 | 2019-05-22T22:24:56 | 2019-05-22T22:24:56 | 81,300,849 | 4 | 5 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package com.javarush.task.task27.task2710;
public class MailServer implements Runnable {
private Mail mail;
public MailServer(Mail mail) {
this.mail = mail;
}
@Override
public void run() {
long beforeTime = System.currentTimeMillis();
//сделайте что-то тут - do something here
synchronized (mail){
try {
mail.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
String name = Thread.currentThread().getName();
long afterTime = System.currentTimeMillis();
System.out.format("%s MailServer has got: [%s] in %d ms after start", name, mail.getText(), (afterTime - beforeTime));
}
}
}
| [
"[email protected]"
]
| |
c3dcca175f2f05103acdaeb7d2dc9e1e58b80e69 | b52ae144b4ff51c6176488808032100faf47bf1d | /app/src/test/java/com/arkinnov/happybirthday/ExampleUnitTest.java | c92ed7967f81410c8a88b8e05adacf0d039fedb6 | []
| no_license | pjithinshaji/HappyBirthday | b5a134dfb0a365399c0ff7766697e5367c3849a4 | 280fa7d7e7c661d146732a1d892bf07927d90134 | refs/heads/master | 2021-09-03T14:11:29.759308 | 2018-01-09T17:47:32 | 2018-01-09T17:47:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 404 | java | package com.arkinnov.happybirthday;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
5a9b46b3df445d1198468be1b8abab6926fa15f2 | baea0bc30c0cfabd99edc056213370c9133aaa46 | /company-frontend/Model/src/br/com/tqi/company/domain/package-info.java | 7130fb937a540f5f09e075c49e10b520397be0bf | []
| no_license | alexandrefvb/company-poc | 030bc09f87d028893afa969c5b71c01b84b4da31 | ac4a41ebbb33d9340690974f4f3e81a4752aa81f | refs/heads/master | 2020-05-19T22:32:15.809396 | 2011-08-26T16:51:50 | 2011-08-26T16:51:50 | 2,265,936 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36 | java | package br.com.tqi.company.domain;
| [
"[email protected]"
]
| |
60bd233b1893fe665d4bc8462b965ab55add1a48 | 0c3939076076bef23d31fc2e02da9a5948a14b0e | /src/main/java/com/zenika/zencontact/persistence/objectify/UserDaoObjectify.java | 8ce7920f9a900d895a36119efabd7d63e16fd53b | []
| no_license | MaximeAnsquer/TP_App_Engine | edebfdcbe8ff3a2120aae03c84de9e2e866bc3e4 | 2e7e56cc43b547844ac95860321525a012f48d64 | refs/heads/master | 2020-06-12T20:27:16.941480 | 2016-12-07T15:20:04 | 2016-12-07T15:20:04 | 75,753,697 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,080 | java | package com.zenika.zencontact.persistence.objectify;
import com.google.appengine.api.blobstore.BlobKey;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.ObjectifyService;
import com.zenika.zencontact.domain.User;
import com.zenika.zencontact.persistence.UserDao;
import java.util.List;
public class UserDaoObjectify implements UserDao {
private static UserDaoObjectify INSTANCE = new UserDaoObjectify();
public static UserDaoObjectify getInstance() {
ObjectifyService.factory().register(User.class);
return INSTANCE;
}
public long save(User contact) {
return ObjectifyService.ofy().save().entity(contact).now().getId();
}
public void delete(Long id) {
ObjectifyService.ofy().delete().key(Key.create(User.class, id)).now();
}
public User get(Long id) {
return ObjectifyService.ofy().load().key(Key.create(User.class, id)).now();
}
public List<User> getAll() {
return ObjectifyService.ofy().load().type(User.class).list();
}
public BlobKey fetchOldBlob(Long id) {
return this.get(id).photoKey;
}
} | [
"[email protected]"
]
| |
0203abc78b97b78c74b580d3a00e078265532394 | ba4b4d2d8b12e5c22a878d02ef409caadcd4febb | /kie-dmn/kie-dmn-openapi/src/main/java/org/kie/dmn/openapi/impl/FEELBuiltinTypeSchemas.java | 84a40b45964d44eeb26578d110f1bf1ec73a6351 | [
"Apache-2.0"
]
| permissive | 7vqinqiwei/drools | 2758e63a2dc0df3caee6026c87717d3c6220f128 | 2210d82035f7d5c4eb46fa3e16ddf6dfcd18bdd2 | refs/heads/master | 2021-06-16T09:13:42.144910 | 2021-03-01T08:49:11 | 2021-03-01T08:49:11 | 168,125,013 | 0 | 0 | Apache-2.0 | 2021-03-01T08:49:13 | 2019-01-29T09:12:29 | Java | UTF-8 | Java | false | false | 3,766 | java | /*
* Copyright 2020 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.dmn.openapi.impl;
import org.eclipse.microprofile.openapi.OASFactory;
import org.eclipse.microprofile.openapi.models.media.Schema;
import org.eclipse.microprofile.openapi.models.media.Schema.SchemaType;
import org.kie.dmn.api.core.DMNType;
import org.kie.dmn.feel.lang.SimpleType;
import org.kie.dmn.feel.lang.types.BuiltInType;
import org.kie.dmn.typesafe.DMNTypeUtils;
public class FEELBuiltinTypeSchemas {
public static Schema from(DMNType t) {
BuiltInType builtin = DMNTypeUtils.getFEELBuiltInType(t);
if (builtin == BuiltInType.DURATION) {
return convertDurationToSchema(t);
} else {
return convertBuiltInToJavaClass(builtin);
}
}
private static Schema convertDurationToSchema(DMNType t) {
switch (t.getName()) {
case SimpleType.YEARS_AND_MONTHS_DURATION:
case "yearMonthDuration":
return OASFactory.createObject(Schema.class).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:years and months duration").type(SchemaType.STRING).format("years and months duration").example("P1Y2M");
case SimpleType.DAYS_AND_TIME_DURATION:
case "dayTimeDuration":
return OASFactory.createObject(Schema.class).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:days and time duration").type(SchemaType.STRING).format("days and time duration").example("P1D");
default:
throw new IllegalArgumentException();
}
}
private static Schema convertBuiltInToJavaClass(BuiltInType builtin) {
switch (builtin) {
case UNKNOWN:
return OASFactory.createObject(Schema.class).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:Any"); // intentional, do NOT add .type(SchemaType.OBJECT), the JSONSchema to represent FEEL:Any is {}
case DATE:
return OASFactory.createObject(Schema.class).type(SchemaType.STRING).format("date").addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:date");
case TIME:
return OASFactory.createObject(Schema.class).type(SchemaType.STRING).format("time").addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:time");
case DATE_TIME:
return OASFactory.createObject(Schema.class).type(SchemaType.STRING).format("date-time").addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:date and time");
case BOOLEAN:
return OASFactory.createObject(Schema.class).type(SchemaType.BOOLEAN).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:boolean");
case NUMBER:
return OASFactory.createObject(Schema.class).type(SchemaType.NUMBER).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:number");
case STRING:
return OASFactory.createObject(Schema.class).type(SchemaType.STRING).addExtension(DMNOASConstants.X_DMN_TYPE, "FEEL:string");
case DURATION:
default:
throw new IllegalArgumentException();
}
}
private FEELBuiltinTypeSchemas() {
// deliberate intention not to allow instantiation of this class.
}
}
| [
"[email protected]"
]
| |
ee88c6ddce125d770866ffa0808ad48044a4c368 | a81e72ee504a382c496e491aedff955b541d3dc4 | /day01-08/src/com/itstar/demo01/ForDemo.java | e2826548f19216fb04760e47ca0e7bd9dc2aee44 | []
| no_license | hengyufxh1/javase | d5f0dc9f1a1663e798a15018cc9f54a02925d105 | 2d5ea79c39bcb23c7c0d4817efa74d81a31c910a | refs/heads/master | 2020-04-18T08:19:18.197699 | 2019-01-24T16:31:05 | 2019-01-24T16:31:05 | 167,392,351 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 337 | java | package com.itstar.demo01;
/**
* 99乘法表
* @author dxw
* @version 1.0
*/
public class ForDemo{
public static void main(String [] args){
for(int i = 1; i < 10;i++){
for(int j = 1;j <= i;j++){
// 计算 \t 制表符
System.out.print(j +"*"+ i +"="+ (i*j) +"\t" );
}
//换行
System.out.println();
}
}
}
| [
"[email protected]"
]
| |
bc3b2946fa857448d111c1343d467c81d1f0e30b | ac1ba9fc04a04fc54c0372830228e4f2a5a4689c | /src/main/java/day5/classroom/PocoPhone.java | 3871dd272279e110637c63236fbd773b381ff1bb | []
| no_license | Dhanalakshmi1602/selenium-java | 6155b2ead276a92a851d92d0b76f5c500f158fea | ddfb5315f9aae204f41a81a7b6a2ce578ab093b9 | refs/heads/master | 2023-05-27T13:23:51.969943 | 2020-01-15T13:19:41 | 2020-01-15T13:19:41 | 223,636,281 | 0 | 0 | null | 2023-05-09T18:37:37 | 2019-11-23T18:40:21 | HTML | UTF-8 | Java | false | false | 459 | java | package day5.classroom;
public class PocoPhone extends Redmi
{
@Override
public void takeAIPhoto()
{
System.out.println("Taking Special AI photo for poco");
}
public void takePocoPhoto()
{
System.out.println("Taking Special Poco photo for poco");
}
public String getModelName() {
// TODO Auto-generated method stub
return null;
}
public String getIntroDate() {
return "2019";
}
}
| [
"[email protected]"
]
| |
c38347aa2520aeec24ff230c87a9bdd9b57425f0 | 3b9402ecdd3fa0ed49ca7795511269a83a078177 | /src/test/java/com/atguigu/easyexcel/QRcode/service/qrcode.java | ef4ac6234a96cc7974579966012b0e8ea99b34e5 | []
| no_license | fjy-lwj/easyexcel | 894ff01eb7df763dadc72faee1aef0e10dcc843d | 0c31daf3e6ffde836ba685dc04599acaa584cf5a | refs/heads/master | 2023-08-16T00:45:17.790791 | 2021-10-22T10:11:22 | 2021-10-22T10:11:22 | 341,763,634 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 919 | java | package com.atguigu.easyexcel.QRcode.service;
/**
* @author fjy
* @date 2020/12/29 9:53
*/
public class qrcode {
// @Override
// public String qrcode(String orderNo) {
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
//
// String address = ip + ":" + request.getLocalPort();
// String payUrl = "http://" + address + "/pay?orderNo=" + orderNo;
// try {
// QRCodeGenerator.generateQRCodeImage(payUrl, 350, 350, Constant.FILE_UPLOAD_PATH + orderNo + ".png");
// } catch (WriterException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// String pngAddress = "http://" + address + "/images-dev/" + orderNo + ".png";
// return pngAddress;
// }
}
| [
"[email protected]"
]
| |
8ab5ab817d6dfc3152949b6ceaecddbc77ad4754 | 018e8d5f9e6482b80c0dfd6f501dd1fe11b9073c | /src/com/safay/api/demo01/Person.java | df712ee9d9d165177d7e622eef880a67005ef0d1 | []
| no_license | wqf-c/javapractice | 5b0bf6ff32fb733004dbc1593afc68c31aa6e640 | b177513e9ebc8f9bb1dda4c1bc078b82a3b3859a | refs/heads/master | 2022-10-13T14:38:31.864306 | 2020-06-02T12:24:22 | 2020-06-02T12:24:22 | 268,793,556 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,023 | java | package com.safay.api.demo01;
import java.util.Objects;
/**
* Author: wqf
* Date: 2019/10/27
* Time: 11:13
*/
public class Person {
String name;
int age;
Person(String name, int age){
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
// @Override
// public boolean equals(Object obj){
// if(obj == this){
// return true;
// }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Person)) return false;
Person person = (Person) o;
return age == person.age &&
Objects.equals(name, person.name);
}
@Override
public int hashCode() {
return Objects.hash(name, age);
}
// if(obj == null || obj instanceof Person ){
// return false;
// }else{
// Person p = (Person)obj;
// if(p.name.equals(this.name) && p.age == this.age){
// return true;
// }
// }
// }
}
| [
"[email protected]"
]
| |
1fc8988eae1e62aa281540049f86f72ec1cfcc2d | db289fdb2532d4c0c0e5e6ef251c5e38c692c017 | /Pertemuan 5/Teori/Array_List.java | b0a313ad34f3eecd094ddf742ebce8902c920f57 | []
| no_license | sandikap/PBO4417 | 56478bfe8bfc7b729d9f822b964cf4bc47150ddb | 98f90ade1d77fb87c8c47a24508161b0705f93da | refs/heads/main | 2023-05-28T06:10:00.168550 | 2021-06-15T14:07:14 | 2021-06-15T14:07:14 | 345,915,754 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,151 | java | import java.util.ArrayList;
class L1{
ArrayList<String> Array = new ArrayList<String>();
public void TambahArray(String i){
Array.add(i);
}
public void HapusArray(String n){
Array.remove(n);
}
}
class L2 extends L1{
public void GantiArray(int x, String y){
Array.set(x, y);
}
public void Cetak(){
System.out.println(Array);
}
}
public class Array_List{
public static void main(String[] args) {
L2 data = new L2();
System.out.println("----- Isi Array -----");
data.Cetak();
System.out.println("----- Menambah Array ----");
data.TambahArray("Soekarno");
data.TambahArray("Supriyadi");
data.TambahArray("Panjaitan");
data.TambahArray("WR Supratman");
data.TambahArray("Adi Sucipto");
data.Cetak();
data.HapusArray("Panjaitan");
data.HapusArray("Adi Sucipto");
System.out.println("----- Setelah Dihapus -----");
data.Cetak();
data.GantiArray(1, "Ahmad Yani");
System.out.println("----- Setelah Diganti -----");
data.Cetak();
}
}
| [
"[email protected]"
]
| |
4eb8e34a560838a04f2edf9b3ed7546022a09e53 | eb9f655206c43c12b497c667ba56a0d358b6bc3a | /plugins/lombok/testData/before/logger/LoggerLog4j2.java | 9f7b79b808c6c73dca3a6505dacbfdf602567abe | [
"Apache-2.0"
]
| permissive | JetBrains/intellij-community | 2ed226e200ecc17c037dcddd4a006de56cd43941 | 05dbd4575d01a213f3f4d69aa4968473f2536142 | refs/heads/master | 2023-09-03T17:06:37.560889 | 2023-09-03T11:51:00 | 2023-09-03T12:12:27 | 2,489,216 | 16,288 | 6,635 | Apache-2.0 | 2023-09-12T07:41:58 | 2011-09-30T13:33:05 | null | UTF-8 | Java | false | false | 180 | java | import lombok.extern.log4j.Log4j2;
@Log4j2
class LoggerLog4j2 {
}
@Log4j2
class LoggerLog4j2WithImport {
}
@Log4j2(topic="DifferentName")
class LoggerLog4j2WithDifferentName {
} | [
"[email protected]"
]
| |
bffdb0640255265c22cc7ebb30fe010e7d55d37c | ef5bea450f69e1d16dee0cd15e9076da2a427e8f | /app/src/main/java/cn/longmaster/hospital/doctor/core/entity/consult/record/BaseDiagnosisInfo.java | 28438a8a8664de737a62d9c027521e5f589d944e | []
| no_license | chengsoft618/Internet_Hospital_Doctor | c9e37e8ce80bf3c303f799406644f1adf4cb10df | b6486de17b2246113bcee26d0ec3f2586828d5f7 | refs/heads/master | 2021-02-07T20:55:11.939929 | 2020-01-16T09:10:08 | 2020-01-16T09:10:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,762 | java | package cn.longmaster.hospital.doctor.core.entity.consult.record;
import java.io.Serializable;
import cn.longmaster.doctorlibrary.util.json.JsonField;
/**
* 医嘱基类
* Created by yangyong on 16/8/24.
*/
public class BaseDiagnosisInfo implements Serializable {
@JsonField("appointment_id")
private int appointmentId;//预约ID
@JsonField("recure_num")
private int recureNum;//复诊次数
@JsonField("insert_dt")
private String insertDt;//插入时间
private boolean isMedia;//是否多媒体医嘱,当为文本时为false
private boolean isLocalData;//是否本地数据,默认为false
public int getAppointmentId() {
return appointmentId;
}
public void setAppointmentId(int appointmentId) {
this.appointmentId = appointmentId;
}
public int getRecureNum() {
return recureNum;
}
public void setRecureNum(int recureNum) {
this.recureNum = recureNum;
}
public String getInsertDt() {
return insertDt;
}
public void setInsertDt(String insertDt) {
this.insertDt = insertDt;
}
public boolean isMedia() {
return isMedia;
}
public void setMedia(boolean media) {
isMedia = media;
}
public boolean isLocalData() {
return isLocalData;
}
public void setLocalData(boolean localData) {
isLocalData = localData;
}
@Override
public String toString() {
return "BaseDiagnosisInfo{" +
"appointmentId=" + appointmentId +
", recureNum=" + recureNum +
", insertDt='" + insertDt + '\'' +
", isMedia=" + isMedia +
", isLocalData=" + isLocalData +
'}';
}
}
| [
"[email protected]"
]
| |
3592a73d34a285a31786a42ace1f6c97ccd7825b | 731b43348e9f1082c5106d08f72cc6064944b941 | /HW5/DiningThread.java | bce5fe2be251849fd14d081d33a7021c08b65383 | []
| no_license | dhhines/OS-concepts | c5bd4a24b3ad560eaad80f8c7d8fafb407df3dbb | 830e517cea13db40550414d66074c02dbfff7586 | refs/heads/master | 2023-04-16T18:58:26.833959 | 2021-04-29T12:00:10 | 2021-04-29T12:00:10 | 348,361,632 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 478 | java | public class DiningThread extends Thread{
private Barrier barrier;
private String task; //e.g. "Task A"
private int id;
public DiningThread (Barrier b, String work, int threadid) {
barrier = b;
task = work;
id = threadid;
}
public void run ( ) {
}
public static void main (String [] args)throws InterruptedException {
Barrier b = new Barrier (4); //4 threads must be synchronized
// create DiningThread objects
// start them
// join them
}
}
| [
"[email protected]"
]
| |
78c4b25f38a1de8e9a43a10d6cc3b50b86780866 | c81340901371a2026dc26aed82bfbd2d0a7e8485 | /src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java | fc390299c03dd1d805868d47af3eda7775650de4 | [
"Apache-2.0"
]
| permissive | Re4yz/ArcturusEmulator | f9cbe520809eb36fc370a1d285182e083dfbb4ef | a039967aa27e5340ac2997822142f4eaa9caafe4 | refs/heads/master | 2023-04-19T03:49:05.138800 | 2021-05-05T20:35:20 | 2021-05-05T20:35:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,295 | java | package com.eu.habbo.threading.runnables;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
import com.eu.habbo.habbohotel.pets.GnomePet;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
public class PetEatAction implements Runnable
{
private final Pet pet;
private final InteractionPetFood food;
public PetEatAction(Pet pet, InteractionPetFood food)
{
this.pet = pet;
this.food = food;
}
@Override
public void run()
{
if(this.pet.getRoomUnit() != null && this.pet.getRoom() != null)
{
if (this.pet.levelHunger >= 20 && this.food != null && Integer.valueOf(this.food.getExtradata()) < this.food.getBaseItem().getStateCount())
{
this.pet.addHunger(-20);
this.pet.setTask(PetTasks.EAT);
this.pet.getRoomUnit().setCanWalk(false);
this.food.setExtradata(Integer.valueOf(this.food.getExtradata()) + 1 + "");
this.pet.getRoom().updateItem(this.food);
if (this.pet instanceof GnomePet)
{
if (this.pet.getPetData().getType() == 26)
{
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GnomeFeedingFeeding"), 20);
}
else
{
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("LeprechaunFeedingFeeding"), 20);
}
}
else
{
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetFeeding"), 20);
}
Emulator.getThreading().run(this, 1000);
} else
{
if (this.food != null && Integer.valueOf(this.food.getExtradata()) == this.food.getBaseItem().getStateCount())
{
Emulator.getThreading().run(new QueryDeleteHabboItem(this.food), 500);
if (this.pet.getRoom() != null)
{
this.pet.getRoom().removeHabboItem(this.food);
this.pet.getRoom().sendComposer(new RemoveFloorItemComposer(this.food, true).compose());
}
}
this.pet.setTask(PetTasks.FREE);
this.pet.getRoomUnit().getStatus().remove("eat");
this.pet.getRoomUnit().setCanWalk(true);
this.pet.getRoom().sendComposer(new RoomUserStatusComposer(this.pet.getRoomUnit()).compose());
}
}
}
}
| [
"[email protected]"
]
| |
d99c32556ac25b10e75a3b7b6a808ac4d8d56f0c | ddb2a0485c91737da9430e7897bf5b79afe8f0fd | /HiringProcess/src/main/java/utilities/PageObjects.java | 7764aa4b94ec875babcc22e6af1e04001edc1b34 | []
| no_license | aniketarora19/Hiring-Module | 31464a4eb268310076e7c88d78e6b82cf0492c55 | abb655eff5b1e87591f97c51629e1f6fbea40f44 | refs/heads/master | 2020-07-28T20:21:37.056945 | 2019-09-19T12:38:18 | 2019-09-19T12:38:18 | 209,525,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package utilities;
import org.openqa.selenium.By;
public class PageObjects {
By txt_username = By.id("userid");
By txt_password = By.id("pwd");
By btn_login = By.name("Submit");
By txt_query_search = By.name("QRYSELECT_WRK_QRYSEARCHTEXT254");
By btn_query_search = By.name("QRYSELECT_WRK_QRYSEARCHBTN");
By btn_query_edit = By.name("QRYSELECT_WRK_QRYEDITFIELD$0");
}
| [
"[email protected]"
]
| |
ae898e9abab2ec034a7edf1db011eb82258fd653 | aa700b45e181e37f07742a860e28fa6c89ebc125 | /Backend/src/main/java/capstone/p2plend/repo/RequestRepository.java | 3a13aa12bc793f98b343ed24ca9a57f238a7cb72 | []
| no_license | avatarprvip/peer-to-peer-lending-system | 62d56e342e374f4e32dbb9443a69b58b6985f816 | 52daacba937178c24f2dad5591003a499223f976 | refs/heads/master | 2020-06-27T02:15:40.645191 | 2019-07-31T08:11:40 | 2019-07-31T08:11:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,928 | java | package capstone.p2plend.repo;
import capstone.p2plend.entity.Request;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface RequestRepository extends JpaRepository<Request, Integer> {
@Query(value = "SELECT * FROM request WHERE borrower_id <> :id AND lender_id is null", nativeQuery = true)
Page<Request> findAllOtherUserRequest(Pageable pageable, @Param("id") Integer id);
@Query(value = "SELECT * FROM request WHERE borrower_id = :id AND status = :status", nativeQuery = true)
Page<Request> findAllUserRequestByStatus(Pageable pageable, @Param("id") Integer id,
@Param("status") String status);
@Query(value = "SELECT * FROM request WHERE borrower_id = :id AND status <> :status", nativeQuery = true)
List<Request> findListAllUserRequestByExceptStatus(@Param("id") Integer id, @Param("status") String status);
@Query(value = "SELECT * FROM request WHERE status = :status AND (borrower_id = :borrowerId OR lender_id = :lenderId)", nativeQuery = true)
Page<Request> findAllRequestByStatusWithLenderOrBorrower(Pageable pageable, @Param("status") String status,
@Param("borrowerId") Integer borrowerId, @Param("lenderId") Integer lenderId);
@Query(value = "SELECT * FROM request WHERE status = :status AND lender_id = :lenderId", nativeQuery = true)
Page<Request> findAllRequestByStatusWithLender(Pageable pageable, @Param("status") String status,
@Param("lenderId") Integer lenderId);
@Query(value = "SELECT * FROM request WHERE status = :status AND borrower_id = :borrowerId", nativeQuery = true)
Page<Request> findAllRequestByStatusWithBorrower(Pageable pageable, @Param("status") String status,
@Param("borrowerId") Integer borrowerId);
}
| [
"[email protected]"
]
| |
436c611ee4b16a2e6432984627ca85112f24977c | ebdcaff90c72bf9bb7871574b25602ec22e45c35 | /modules/adwords_appengine/src/main/java/com/google/api/ads/adwords/jaxws/v201809/cm/AdGroupExtensionSettingServiceInterfacegetResponse.java | 1e7782fca251ec38d1a3a56cf86db119b0b3d93d | [
"Apache-2.0"
]
| permissive | ColleenKeegan/googleads-java-lib | 3c25ea93740b3abceb52bb0534aff66388d8abd1 | 3d38daadf66e5d9c3db220559f099fd5c5b19e70 | refs/heads/master | 2023-04-06T16:16:51.690975 | 2018-11-15T20:50:26 | 2018-11-15T20:50:26 | 158,986,306 | 1 | 0 | Apache-2.0 | 2023-04-04T01:42:56 | 2018-11-25T00:56:39 | Java | UTF-8 | Java | false | false | 2,233 | java | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.ads.adwords.jaxws.v201809.cm;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getResponse element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <element name="getResponse">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="rval" type="{https://adwords.google.com/api/adwords/cm/v201809}AdGroupExtensionSettingPage" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"rval"
})
@XmlRootElement(name = "getResponse")
public class AdGroupExtensionSettingServiceInterfacegetResponse {
protected AdGroupExtensionSettingPage rval;
/**
* Gets the value of the rval property.
*
* @return
* possible object is
* {@link AdGroupExtensionSettingPage }
*
*/
public AdGroupExtensionSettingPage getRval() {
return rval;
}
/**
* Sets the value of the rval property.
*
* @param value
* allowed object is
* {@link AdGroupExtensionSettingPage }
*
*/
public void setRval(AdGroupExtensionSettingPage value) {
this.rval = value;
}
}
| [
"[email protected]"
]
| |
967aa22c155650e526194345b3aff6edf1753831 | ee1b40e5f1d7ced4e2303a56b81834e9b45693a5 | /src/main/java/com/athena/test/App.java | 376c678010bb37cad6f581c8b1a9fb78b509d4f4 | []
| no_license | maharsuresh/sonarqube1 | b5dafe80770d50f737f212fc3c4cafad7042284f | f3f77c759cdb2c6d1cbfd13ddc5cdd3515ddcbcb | refs/heads/master | 2020-11-25T00:27:16.924380 | 2020-01-21T15:22:27 | 2020-01-21T15:24:59 | 228,408,010 | 0 | 0 | null | 2020-10-13T18:59:35 | 2019-12-16T14:42:19 | Java | UTF-8 | Java | false | false | 178 | java | package com.athena.test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| [
"[email protected]"
]
| |
32c3ad724fc8ceb5317cc0e668424c74d25e7e4b | 99b91e3e1a6bb7e9f20a1f2195d606f298db46ea | /JavaTest/src/generics/coffee/Coffee.java | 4e9d736fb8e12137e71b8cfe5a9a0f0f47fe8425 | []
| no_license | xinyuesy/ThinkingInJava | 93be8f48f8090586b95833ff0b141bf784bc5e36 | eff150c9707f143451cf651ae3cd1851f2a0ce0e | refs/heads/master | 2020-05-29T14:39:27.437007 | 2016-08-26T04:17:41 | 2016-08-26T04:17:41 | 59,836,879 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package generics.coffee;
public class Coffee
{
private static long counter = 0;
private final long id = counter++;
public String toString()
{
return getClass().getSimpleName() + " " + id;
}
}
| [
"[email protected]"
]
| |
b6d7bd8a9211907a6681b0a954d1d3cffaeceb81 | a6296ad3ab1aadc4405065edd4b4543751d13289 | /src/main/java/de/javastream/netbeans/ansible/nodes/ProjectFilesNodeFactory.java | 9709822d02370035ad7ad883e861c09a67b3a906 | [
"Apache-2.0"
]
| permissive | 6PATyCb/netbeans-ansible | ade5ee853b94e06b63d4ca3144cb43245aa0079d | 62c611080f1abb3f0e297c3f1740a66d2e2dbc7b | refs/heads/master | 2021-07-14T07:19:08.643694 | 2020-10-08T13:11:17 | 2020-10-08T13:11:17 | 206,423,402 | 0 | 0 | Apache-2.0 | 2019-09-04T22:06:09 | 2019-09-04T22:06:09 | null | UTF-8 | Java | false | false | 6,471 | java | package de.javastream.netbeans.ansible.nodes;
import de.javastream.netbeans.ansible.AnsibleProject;
import static de.javastream.netbeans.ansible.nodes.SourcePackagesNodeFactory.SOURCE_PACKAGES_ICON;
import java.awt.Image;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.swing.event.ChangeListener;
import org.netbeans.api.annotations.common.StaticResource;
import org.netbeans.api.project.Project;
import org.netbeans.spi.project.ui.support.NodeFactory;
import org.netbeans.spi.project.ui.support.NodeList;
import org.openide.filesystems.FileChangeAdapter;
import org.openide.filesystems.FileEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileRenameEvent;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.nodes.NodeAdapter;
import org.openide.nodes.NodeEvent;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
/**
*
* @author 6PATyCb
*/
@NodeFactory.Registration(projectType = "de-javastream-ansible", position = 20)
public class ProjectFilesNodeFactory implements NodeFactory {
private static final String PROJECT_FILES_NAME = "Project Files";
public static final String HOSTS_NAME = "hosts";
public static final String ANSIBLE_CFG_NAME = "ansible.cfg";
public static final String ANSIBLE_INI_TYPE_ATTR_NAME = "ansible-ini-file";
@StaticResource()
public static final String PROJECT_FILES_BADGE_ICON = "de/javastream/netbeans/ansible/projectfiles-badge.png";
@Override
public NodeList<?> createNodes(Project project) {
AnsibleProject ansibleProject = project.getLookup().lookup(AnsibleProject.class);
assert ansibleProject != null;
return new ProjectFilesNodeList(ansibleProject);
}
private class ProjectFilesNodeList implements NodeList<Node> {
private final AnsibleProject project;
public ProjectFilesNodeList(AnsibleProject project) {
this.project = project;
}
@Override
public List<Node> keys() {
return Collections.singletonList(new ProjectFilesNode(Children.create(new ChildFactory<Node>() {
@Override
protected boolean createKeys(List<Node> toPopulate) {
FileObject rootProjectDir = project.getProjectDirectory();
rootProjectDir.addFileChangeListener(new FileChangeAdapter() {
@Override
public void fileRenamed(FileRenameEvent fe) {
super.fileRenamed(fe);
refresh(true);
}
@Override
public void fileDataCreated(FileEvent fe) {
super.fileDataCreated(fe);
refresh(true);
}
@Override
public void fileDeleted(FileEvent fe) {
super.fileDeleted(fe);
refresh(true);
}
@Override
public void fileChanged(FileEvent fe) {
super.fileChanged(fe);
refresh(true);
}
@Override
public void fileFolderCreated(FileEvent fe) {
super.fileFolderCreated(fe);
refresh(true);
}
});
for (FileObject file : rootProjectDir.getChildren()) {
String fileName = file.getNameExt().toLowerCase();
if (fileName.equals(HOSTS_NAME) || fileName.equals(ANSIBLE_CFG_NAME)) {
try {
file.setAttribute(ANSIBLE_INI_TYPE_ATTR_NAME, true);
DataObject dataObject = DataObject.find(file);
Node node = dataObject.getNodeDelegate();
node.addNodeListener(new NodeAdapter() {
@Override
public void nodeDestroyed(NodeEvent ev) {
super.nodeDestroyed(ev);
refresh(true);
}
});
toPopulate.add(node.cloneNode());
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return true;
}
@Override
protected Node createNodeForKey(Node key) {
return key;
}
}, true)));
}
@Override
public Node node(Node node) {
return new FilterNode(node);
}
@Override
public void addNotify() {
}
@Override
public void removeNotify() {
}
@Override
public void addChangeListener(ChangeListener cl) {
}
@Override
public void removeChangeListener(ChangeListener cl) {
}
}
private class ProjectFilesNode extends AbstractNode {
public ProjectFilesNode(Children children) {
super(children);
setDisplayName(PROJECT_FILES_NAME);
}
@Override
public final void setDisplayName(String s) {
super.setDisplayName(s);
}
@Override
public Image getIcon(int type) {
Image icon = ImageUtilities.loadImage(SOURCE_PACKAGES_ICON);
Image badge = ImageUtilities.loadImage(PROJECT_FILES_BADGE_ICON);
return ImageUtilities.mergeImages(icon, badge, 7, 7);
}
@Override
public Image getOpenedIcon(int type) {
return getIcon(type);
}
}
}
| [
""
]
| |
002d9a13ffa3de5405195707acd7186b2d792be4 | 139d8ec99bc59cf33637e3062cb21fcd0f86648d | /src/main/java/com/github/mars05/crud/intellij/plugin/ui/CrudList.java | 5338ed3cbd54d69de326f497634fb4fc994ca2e7 | [
"Apache-2.0"
]
| permissive | mars05/crud-intellij-plugin | b4cef1a030776b9645719c8e9ae1f6e8eb7e7458 | 011dd2aa8328d5fe5ffd6a77dbdf47d7a9b03b29 | refs/heads/master | 2022-10-30T14:26:07.644085 | 2022-09-13T03:20:19 | 2022-09-13T03:20:19 | 184,971,390 | 323 | 87 | null | null | null | null | UTF-8 | Java | false | false | 1,686 | java | package com.github.mars05.crud.intellij.plugin.ui;
import com.intellij.ui.ListSpeedSearch;
import com.intellij.ui.SpeedSearchComparator;
import com.intellij.ui.components.JBList;
import javax.swing.*;
import java.awt.*;
import java.util.List;
/**
* @author xiaoyu
*/
public class CrudList extends JBList<ListElement> {
private final DefaultListModel<ListElement> model = new DefaultListModel<>();
public CrudList() {
setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel jbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
ListElement ele = (ListElement) value;
jbl.setIcon(ele.getIcon());
jbl.setText(ele.getName());
return jbl;
}
});
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setModel(model);
new ListSpeedSearch<ListElement>(this) {
@Override
protected String getElementText(Object element) {
return ((ListElement) element).getName();
}
}.setComparator(new SpeedSearchComparator(false));
}
public ListElement getSelectedElement() {
return getSelectedValue();
}
public List<ListElement> getSelectedElementList() {
return getSelectedValuesList();
}
public void addElement(ListElement element) {
model.add(model.getSize(), element);
}
public void clearElement() {
model.clear();
}
}
| [
"[email protected]"
]
| |
d32431f9827e98276c8e798757a42a0df357d9c6 | 00eda6f9492ff482223356f65353a8b036f1ee90 | /Agenda/src/com/ambimetrics/agenda/ModificarPerfilActivity.java | e9bcf2934978b5a1fa167ca1cd98f1108398a99e | []
| no_license | Kahosk/penta-amb | 0430bf2292165c8a6830e333644959ecb803d2b4 | f1a250284f93f13bbced7c9197626c03b10d8afb | refs/heads/master | 2021-01-10T21:40:21.692554 | 2013-04-09T07:12:35 | 2013-04-09T07:12:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 571 | java | package com.ambimetrics.agenda;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class ModificarPerfilActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modificar_perfil);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.modificar_perfil, menu);
return true;
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.