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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4298413fc4c67e85045d425e91c96963b17e4e5b
|
192dba54304ba100648fc6e3f6419b3b55963181
|
/src/dm-tool/org/ancora/DMTool/Simulation/SimulationData.java
|
667ffd29e1153e3ddce2e07e120ca14f3072d119
|
[] |
no_license
|
joaobispo/jb-phd
|
ec120cb573bf2567631e96508de88c271ae8434b
|
43bb1fe6ae25c8fd9e9f8c3658d876cd8ba0a377
|
refs/heads/master
| 2021-01-13T02:16:16.475411 | 2011-01-03T15:43:05 | 2011-01-03T15:43:05 | 39,536,637 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,689 |
java
|
/*
* Copyright 2010 Ancora Research Group.
*
* 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.
* under the License.
*/
package org.ancora.DMTool.Simulation;
import java.util.List;
import org.ancora.FuMatrix.Architecture.Fu;
import org.ancora.FuMatrix.Stats.MapperData;
import org.ancora.InstructionBlock.InstructionBlock;
/**
*
* @author Joao Bispo
*/
public class SimulationData {
public SimulationData() {
totalSeenInstructions = 0l;
processorExecutedInstructions = 0l;
hardwareExecutedCycles = 0l;
failedMappings = 0;
communicationsCost = 0l;
totalMappings = 0l;
totalMappedLines = 0l;
totalMappedOps = 0l;
totalMappedMoves = 0l;
// maxLineSize = 0;
// maxLineOps = 0;
}
public long getCommunicationsCost() {
return communicationsCost;
}
public long getTotalSeenInstructions() {
return totalSeenInstructions;
}
public long getHardwareExecutedCycles() {
return hardwareExecutedCycles;
}
public int getFailedMappings() {
return failedMappings;
}
public int getMaxMappedLineSize() {
return maxMappedLineSize;
}
/*
public int getMaxLineOps() {
return maxLineOps;
}
*/
/*
public int getMaxLineSize() {
return maxLineSize;
}
*
*/
public long getProcessorExecutedInstructions() {
return processorExecutedInstructions;
}
public long getTotalMappedLines() {
return totalMappedLines;
}
public long getTotalMappedMoves() {
return totalMappedMoves;
}
public long getTotalMappedOps() {
return totalMappedOps;
}
public long getTotalMappings() {
return totalMappings;
}
void updateProcessorPath(InstructionBlock block) {
processorExecutedInstructions += block.getTotalInstructions();
totalSeenInstructions += block.getTotalInstructions();
}
void signalMappingFailure() {
failedMappings++;
}
void updateHwPath(MapperData mapperData, InstructionBlock block) {
long commCost = mapperData.getLiveIns() + mapperData.getLiveOuts();
// Get cycles
hardwareExecutedCycles += mapperData.getLines() * block.getRepetitions();
hardwareExecutedCycles += commCost;
totalMappings++;
totalMappedLines += mapperData.getLines();
totalMappedOps += mapperData.getOps();
totalMappedMoves += mapperData.getMoves();
maxMappedLineSize = Math.max(maxMappedLineSize, mapperData.getLineSizeMax());
}
/**
* INSTANCE VARIABLES
*/
private long totalSeenInstructions;
private long processorExecutedInstructions;
private long hardwareExecutedCycles;
private int failedMappings;
private long communicationsCost;
private long totalMappings;
private long totalMappedLines;
private long totalMappedOps;
private long totalMappedMoves;
private int maxMappedLineSize;
//private int maxLineSize;
//private int maxLineOps;
//private int maxLineMoves;
}
|
[
"joaobispo@localhost"
] |
joaobispo@localhost
|
ad314f4dabae197e7b7bc21bbbd0221010c65b99
|
26b7f30c6640b8017a06786e4a2414ad8a4d71dd
|
/src/number_of_direct_superinterfaces/i39991.java
|
de44db5e2bf95e0d7bfe8a7145a0689610944938
|
[] |
no_license
|
vincentclee/jvm-limits
|
b72a2f2dcc18caa458f1e77924221d585f23316b
|
2fd1c26d1f7984ea8163bc103ad14b6d72282281
|
refs/heads/master
| 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 69 |
java
|
package number_of_direct_superinterfaces;
public interface i39991 {}
|
[
"[email protected]"
] | |
622b9b75796cb592eac430da903d196448acad39
|
b57e762b3855300e814b1f96f92f4cc194f9c56b
|
/cloudp/src/main/java/com/cloudp/config/AlipayConfig.java
|
b3fc84985d7b0d06486dd2fe8bc54c8c56bbc51a
|
[
"Apache-2.0"
] |
permissive
|
abbhay/YunGe_Bookstore
|
2be631d21fb5d027b333255ec35d51258699398e
|
41535f026d55226e0d8d5fb339eee8c746aa6fac
|
refs/heads/master
| 2020-05-03T07:37:16.177510 | 2019-05-10T07:17:35 | 2019-05-10T07:17:35 | 178,503,040 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 4,734 |
java
|
package com.cloudp.config;
import java.io.FileWriter;
import java.io.IOException;
/* *
*类名:AlipayConfig
*功能:基础配置类
*详细:设置帐户有关信息及返回路径
*修改日期:2017-04-05
*说明:
*以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
*/
public class AlipayConfig {
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
// 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
public static String app_id = "2016093000633562";
// 商户私钥,您的PKCS8格式RSA2私钥
public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCgZeH9AolnHDGy2PNQTSIdBkoBJtcw9kO8MoWafRnhwkkVMCDP56Keux75knftpDmf6p+59c40rLCouPins+dLdhiMCHk1O6Q0VX48Kyc4Un7ax0KP/amQjK/7TgCqNiwLDn8/j3/RAUxwO5RpSaE98D7d9KdyWimpQ7BT4G4t/GTv06Ti+14U776cUI61y2NlHCjLvvFV/3/DUtoiMDmI0d3NuBmA/6g/Y1+xmfYQQzRObXtuvmwTArGwZmQIrtUPyHyWREXynQprg6+bCnfTTr/OVo/SoXUL+KzHNV3gI8dbDnDTyCd7rtSDdJFD6jU+Efx3v6lyzaUcrJ6JEgHBAgMBAAECggEACl6r3pykX3suJ17pVB64fuHiNPLa5Lp3JJqrkpJV8weJjAohhO93zwVP+lii0kVUyGb1zqL6ouMrRK04vjbeVD2dVqhRlcR2WD/SuncbwQNsWh6Zyg9fQA4obnnbhyWbcVeNmIFhhRStaXAgpzHwb72xgs4HaVg061GJ+9I9rVFSNLVAvt0YvbOPfKp+CezyukFJPvVsC6XWAwkz1xUwTXtJ+8ZkTi4zb8r2KBgodkdAavN7PvnF+NV9+xlYr2RUv7fCN0GJRYf8juBdbnY36HgijYIx1xxVKrlBt6U6GMTjfysYD7H30baXm4lEVP6jh69W4sKk4iWQcvK8Ztf7tQKBgQD6xsK8AbrQ4/LnudiUTES9HL5+Kxhas3ZZFWrcM7o7AIzQXZDpJXWdkMROavyo4AJNI0fZdfE9FmNyvdSsz+siYqWgOTD5N90beNBAeBjDSxDkfqbdI6OaTf5C1WXoQcLw+lB681sQoB6Oy0IhF0fzcVBKsMisJ0rm+Ve9eZojnwKBgQCjvTA9hXvJgLlWuEvzIvTBhRZXLC5Krr9tzTDdtdh0rGz2SxfG49D/gTjHf9+rauDad9OChps4IkvRIORDOx6uoA4FFfnUuyg2jd1JYmgLvL59YSm5u/iztRIh3oosVE3ZdLSU2s4nQDLX7a0ozWnadj4vkNtWqz/h0LnhY07enwKBgQD0+60La4ksPjNy6txIa4WPVYBG0yTUnpMUDdc5zRK2RyBJAc7p5J1U0zLjBKNU+plk7/1l1FFaAwAd/JLCS9AB5Gq27ogIPumyx8Bx6qEOT8vt3Eh4qjNOL7kfY0dNsMiXD4IFyq0Avdt8VdaBazPv/5eXj8JKY4xJvfZX9G5/MwKBgFEC5KA7r9A1kP1395PXIrOwjioZINowdWP1Fo1LUEoBmXOOGbh8tMYFgDssaFSeb5uHl61Hvfpa9ZoFpQoicP7DD8yyX8ZBxxaev/Jz7riH7NOJxCQx/U2kc9EwErr2BwJk/Id9bmv7FmzBGmBKqWm+AOx1xh+uYM/v/lemU7pPAoGBANiYZrkpb/gUbhjlh2H4l3lS52hzg4efdhQsAyD1mAjJKA2QPn79d4rmQCR2drduBNVgvrMJil4Kr3cuFbGM2s93BZpSrgk+FIPqM2w/ZPh2M1RmW+FzCGKuZG5Et5rHfWt8cmNXRpfu6B0E0rKRJz164pWW7lzTaBRIdk4UQC49";
// 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgA7EtTGwG4LUDf2xJbK9JXsDUSyOHKk/snLZpD3fyYckdTYLFPF1Eq17nV9RYro1W97knKufdkG/LVeRPhYZGzqhZ0wdcYSCDHumvXKDC09kDmgm1J95NPjI9AwSWLiF6M9jneYSVXE1E8OdTMy8BbvbBAzSpOErLa0uW8CNbNdbVdKIY2mLhOp54mazz9qN7Llqs1rV1+pvp7zCJtpSkb7O+zaWeMhik7PhFKrx2d7xoz4OUFHQTRpxKIhOzdw6LJSHNO8GkZtUR/JMmf9UQensG/EFlQbCYc6oqNYRyhomc3p8scXcrEHIHfSHh0JavBkLAYr+2/86kXdevuSB0wIDAQAB";
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public static String notify_url = "http://zhangjiahao.imwork.net/returnAlipay.do";
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public static String return_url = "http://localhost:8080/returnAlipay.do";
// 签名方式
public static String sign_type = "RSA2";
// 字符编码格式
public static String charset = "utf-8";
// 支付宝网关
public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
// 支付宝网关
public static String log_path = "C:\\";
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
/**
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
* @param sWord 要写入日志里的文本内容
*/
public static void logResult(String sWord) {
FileWriter writer = null;
try {
writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
writer.write(sWord);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
|
[
"[email protected]"
] | |
97f50de08b586dbe2ce2cc1492ea36fd680ea0f5
|
c5c15039f3c215f5e54a2ba6a827acc3606db95c
|
/src/main/java/com/test/model/Team.java
|
452b8db9db09bc982662a43e11a2f6bac5cd7dcc
|
[] |
no_license
|
arvdhatwalia/RestSoapApi
|
12f229f0498104c34ea638d9bc8d1094be1201b1
|
11e60d0edf46c93d6b5912f44244d311e62c9519
|
refs/heads/master
| 2021-01-18T04:10:00.406782 | 2017-03-21T23:04:44 | 2017-03-21T23:04:44 | 85,761,204 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 627 |
java
|
package com.test.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="teams")
public class Team {
@Id
@GeneratedValue
private Integer id;
private String name;
private Integer rating;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getRating() {
return rating;
}
public void setRating(Integer rating) {
this.rating = rating;
}
}
|
[
"[email protected]"
] | |
8a1fb0263c42cdd4365b2f938be96bc85a9518f9
|
e4904f554b25edbdcc9d65f32d71609894ba5225
|
/android/src/fq/router/feedback/DownloadFailedIntent.java
|
01260c50c50fa54d4b81e435d106ec26e0a8bb26
|
[] |
no_license
|
keremkusmezer/fqrouter
|
619a4bb5b903f7b31abc0f8034949edccd4011dd
|
3ebf471fc17aa261a93258bfe53b7ccb6b881976
|
refs/heads/master
| 2021-01-16T21:25:19.200331 | 2013-06-25T16:24:24 | 2013-06-25T16:24:24 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,050 |
java
|
package fq.router.feedback;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import fq.router.utils.LoggedBroadcastReceiver;
public class DownloadFailedIntent extends Intent {
private final static String ACTION_DOWNLOAD_FAILED = "DownloadFailed";
public DownloadFailedIntent(String url, String downloadTo) {
setAction(ACTION_DOWNLOAD_FAILED);
putExtra("url", url);
putExtra("downloadTo", downloadTo);
}
public static void register(final Handler handler) {
handler.getBaseContext().registerReceiver(new LoggedBroadcastReceiver() {
@Override
protected void handle(Context context, Intent intent) {
handler.onDownloadFailed(intent.getStringExtra("url"), intent.getStringExtra("downloadTo"));
}
}, new IntentFilter(ACTION_DOWNLOAD_FAILED));
}
public static interface Handler {
void onDownloadFailed(String url, String downloadTo);
Context getBaseContext();
}
}
|
[
"[email protected]"
] | |
1bdcce58e98b6edf4832285d65919bd41764429a
|
01a27303d12e622d038f8ba826705554d75698ad
|
/app/src/test/java/jyq/testokhttp/ExampleUnitTest.java
|
6eef9117bd96a7ade46cd0a5bba0b95dc02e29fe
|
[] |
no_license
|
echojiangyq/TestOkhttp
|
f9997367417590023e552b4a79bce7de1cde61bb
|
815bf6e9ce84d518e44d059836c67b869114be71
|
refs/heads/master
| 2020-12-25T13:45:17.758739 | 2016-07-16T07:31:23 | 2016-07-16T07:31:23 | 63,471,277 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 702 |
java
|
package jyq.testokhttp;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
@Test
public void testOkHttpUtilGet(){
try {
final String asString = OkhttpUtil.getAsString("http://oacisqzry.bkt.clouddn.com/readme.txt");
System.out.println(asString);
assertEquals(asString, "echo, you are the best!");
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
[
"[email protected]"
] | |
6b8daacda264040482943524316b917d8af9dc8d
|
e30d3cc50c441c153cb271a27a86a906606ffc95
|
/Data Structures/Module6/myListADT.java
|
bd8e26daf730ed5b666b3e4d9ba3787993aa242c
|
[] |
no_license
|
kresshnakumar/DataStructures
|
29877312c13fcfa468a834fe5f4c6f3deea146d8
|
593017d5c36c9db260d6f10165944523e03d0fc6
|
refs/heads/master
| 2021-01-10T08:34:23.400209 | 2015-11-27T18:06:29 | 2015-11-27T18:06:29 | 46,993,439 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 372 |
java
|
interface myListADT<E> {
public void addElement(E element);
public void removeElement(E element);
public void removeElementAtIndex(int index);
public void modifyByIndex(int index, E element);
public void modifyByElement(E oldElement, E newElement);
public void read(int index);
public void reallocateSize();
public void removeSize();
public void printMyArray();
}
|
[
"[email protected]"
] | |
7abbae4c43677e9346f7762f60b94fb7ad691fa0
|
0cddb34eea481448f462f219807c869b0d5d9f47
|
/app-sample/src/main/java/io/noties/markwon/app/samples/table/TableLinkifySample.java
|
b692af2122f2916e01fd280cac0bfeb7ac657deb
|
[
"Apache-2.0"
] |
permissive
|
sophimp/x-editor
|
a2e67e9061efd49ad1c03cb4e4391d8f51a6fab3
|
b0b6cea5bf50b8d641f66272fe77e91c1fde799d
|
refs/heads/master
| 2023-07-13T05:49:55.852239 | 2021-08-23T01:44:14 | 2021-08-23T01:44:14 | 398,147,815 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,900 |
java
|
package io.noties.markwon.app.samples.table;
import io.noties.markwon.Markwon;
import io.noties.markwon.app.sample.ui.MarkwonTextViewSample;
import io.noties.markwon.ext.tables.TableAwareMovementMethod;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
import io.noties.markwon.sample.annotations.MarkwonArtifact;
import io.noties.markwon.sample.annotations.MarkwonSampleInfo;
import io.noties.markwon.sample.annotations.Tag;
@MarkwonSampleInfo(
id = "20200702135739",
title = "Linkify table",
description = "Automatically linkify markdown content " +
"including content inside tables, handle clicks inside tables",
artifacts = {MarkwonArtifact.EXT_TABLES, MarkwonArtifact.LINKIFY},
tags = {Tag.links}
)
public class TableLinkifySample extends MarkwonTextViewSample {
@Override
public void render() {
final String md = "" +
"| HEADER | HEADER | HEADER |\n" +
"|:----:|:----:|:----:|\n" +
"| 测试 | 测试 | 测试 |\n" +
"| 测试 | 测试 | 测测测12345试测试测试 |\n" +
"| 测试 | 测试 | 123445 |\n" +
"| 测试 | 测试 | (650) 555-1212 |\n" +
"| 测试 | 测试 | [email protected] |\n" +
"| 测试 | 测试 | some text that goes here is very very very very important [link](https://noties.io/Markwon) |\n" +
"\n" +
"测试\n" +
"\n" +
"[link link](https://link.link)";
final Markwon markwon = Markwon.builder(context)
.usePlugin(LinkifyPlugin.create())
.usePlugin(TablePlugin.create(context))
// use TableAwareLinkMovementMethod to handle clicks inside tables
.usePlugin(MovementMethodPlugin.create(TableAwareMovementMethod.create()))
.build();
markwon.setMarkdown(textView, md);
}
}
|
[
"[email protected]"
] | |
b96527c1231eb76c002cfeba16e3d45a4db32205
|
1d3e99c9304066556cdbac105103e723873d0036
|
/src/main/Application.java
|
7168520862078c00b6d595eb797f6fc13890f259
|
[] |
no_license
|
abakkaba/unique-characters
|
4e5c3fa180dd5609f247038a03a847b9c93509c7
|
a64a2c3b16ec8519ea2cd4aa2f815088a85a5905
|
refs/heads/master
| 2020-04-17T18:11:50.796846 | 2019-01-21T13:09:19 | 2019-01-21T13:09:19 | 166,815,994 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 568 |
java
|
package main;
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter string to calculate characters: ");
String input = scanner.nextLine();
while (!input.isEmpty()) {
System.out.println(CharactersCalculator.doCalculations(input));
System.out.print("Let's do it again: ");
input = scanner.nextLine();
}
System.out.println("Exiting...");
scanner.close();
}
}
|
[
"[email protected]"
] | |
b8c27d31beb52a097f59c3f1a8d9be7e43ba141f
|
8031542fb099fa63eac09113a712e167d5cc166b
|
/src/main/java/com/iycharge/server/domain/service/OperatorService.java
|
7e9e2e82e83b83986266f63cad8c2fd8f5afab36
|
[] |
no_license
|
gdgly/charge-1
|
d4aaab68804e5f51216b930a6604952d3bc018aa
|
e58f20e6c934f4e69583ffe33baea5a083eb5af6
|
refs/heads/master
| 2021-06-27T13:08:26.238949 | 2017-09-01T09:19:39 | 2017-09-01T09:19:39 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 643 |
java
|
package com.iycharge.server.domain.service;
import com.iycharge.server.domain.entity.operator.Operator;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface OperatorService {
public Page<Operator> findAll(Pageable pageable);
public Operator findById(long id);
public Operator save(Operator operator);
public void del(Long operatorId);
Page<Operator> findSearch(String name, Pageable pageable);
List<Operator> findListAll();
List<Operator> findByCode(String code);
List<Operator> findByName(String name);
}
|
[
"[email protected]"
] | |
46571b853d64e782dea78299879c73b1ca50a901
|
7a8e18ad7ad1cdc6b3a91ca4ff5d402d0d20be17
|
/CFT/elasticsearch/57a88859643477db5ae62a3a64d936a8ef5679b7/NestedAggregator.java/res_NestedAggregator.java
|
cbaabd28fc8f83513508623441886b726482c721
|
[] |
no_license
|
mandelbrotset/Test
|
ec5d5ad5b29d28240f6d21073b41ca60070404b1
|
2a119c9a6077dce184d2edb872489f3f2c5d872e
|
refs/heads/master
| 2021-01-21T04:46:42.441186 | 2016-06-30T15:10:39 | 2016-06-30T15:10:39 | 50,836,379 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 9,253 |
java
|
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.search.aggregations.bucket.nested;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.QueryCachingPolicy;
import org.apache.lucene.search.join.BitDocIdSetFilter;
import org.apache.lucene.util.BitDocIdSet;
import org.apache.lucene.util.BitSet;
import org.elasticsearch.common.lucene.docset.DocIdSets;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.object.ObjectMapper;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.AggregatorFactory;
import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.LeafBucketCollector;
import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;
import org.elasticsearch.search.aggregations.NonCollectingAggregator;
import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator;
import org.elasticsearch.search.aggregations.reducers.Reducer;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
*
*/
public class NestedAggregator extends SingleBucketAggregator {
private BitDocIdSetFilter parentFilter;
private final Filter childFilter;
private DocIdSetIterator childDocs;
private BitSet parentDocs;
public NestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parentAggregator, List<Reducer> reducers, Map<String, Object> metaData, QueryCachingPolicy filterCachingPolicy) throws IOException {
super(name, factories, aggregationContext, parentAggregator, reducers, metaData);
childFilter = aggregationContext.searchContext().filterCache().cache(objectMapper.nestedTypeFilter(), null, filterCachingPolicy);
}
@Override
public LeafBucketCollector getLeafCollector(final LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException {
// Reset parentFilter, so we resolve the parentDocs for each new segment being searched
this.parentFilter = null;
// In ES if parent is deleted, then also the children are deleted. Therefore acceptedDocs can also null here.
DocIdSet childDocIdSet = childFilter.getDocIdSet(ctx, null);
if (DocIdSets.isEmpty(childDocIdSet)) {
childDocs = null;
} else {
childDocs = childDocIdSet.iterator();
}
return new LeafBucketCollectorBase(sub, null) {
@Override
public void collect(int parentDoc, long bucket) throws IOException {
// here we translate the parent doc to a list of its nested docs, and then call super.collect for evey one of them so they'll be collected
// if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent doc), so we can skip:
if (parentDoc == 0 || childDocs == null) {
return;
}
if (parentFilter == null) {
// The aggs are instantiated in reverse, first the most inner nested aggs and lastly the top level aggs
// So at the time a nested 'nested' aggs is parsed its closest parent nested aggs hasn't been constructed.
// So the trick is to set at the last moment just before needed and we can use its child filter as the
// parent filter.
// Additional NOTE: Before this logic was performed in the setNextReader(...) method, but the the assumption
// that aggs instances are constructed in reverse doesn't hold when buckets are constructed lazily during
// aggs execution
Filter parentFilterNotCached = findClosestNestedPath(parent());
if (parentFilterNotCached == null) {
parentFilterNotCached = Queries.newNonNestedFilter();
}
parentFilter = context.searchContext().bitsetFilterCache().getBitDocIdSetFilter(parentFilterNotCached);
BitDocIdSet parentSet = parentFilter.getDocIdSet(ctx);
if (DocIdSets.isEmpty(parentSet)) {
// There are no parentDocs in the segment, so return and set childDocs to null, so we exit early for future invocations.
childDocs = null;
return;
} else {
parentDocs = parentSet.bits();
}
}
final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
int childDocId = childDocs.docID();
if (childDocId <= prevParentDoc) {
childDocId = childDocs.advance(prevParentDoc + 1);
}
for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
collectBucket(sub, childDocId, bucket);
}
}
};
}
@Override
public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException {
return new InternalNested(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(),
metaData());
}
@Override
public InternalAggregation buildEmptyAggregation() {
return new InternalNested(name, 0, buildEmptySubAggregations(), reducers(), metaData());
}
private static Filter findClosestNestedPath(Aggregator parent) {
for (; parent != null; parent = parent.parent()) {
if (parent instanceof NestedAggregator) {
return ((NestedAggregator) parent).childFilter;
} else if (parent instanceof ReverseNestedAggregator) {
return ((ReverseNestedAggregator) parent).getParentFilter();
}
}
return null;
}
public static class Factory extends AggregatorFactory {
private final String path;
private final QueryCachingPolicy queryCachingPolicy;
public Factory(String name, String path, QueryCachingPolicy queryCachingPolicy) {
super(name, InternalNested.TYPE.name());
this.path = path;
this.queryCachingPolicy = queryCachingPolicy;
}
@Override
public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket,
List<Reducer> reducers, Map<String, Object> metaData) throws IOException {
if (collectsFromSingleBucket == false) {
return asMultiBucketAggregator(this, context, parent);
}
MapperService.SmartNameObjectMapper mapper = context.searchContext().smartNameObjectMapper(path);
if (mapper == null) {
return new Unmapped(name, context, parent, reducers, metaData);
}
ObjectMapper objectMapper = mapper.mapper();
if (objectMapper == null) {
return new Unmapped(name, context, parent, reducers, metaData);
}
if (!objectMapper.nested().isNested()) {
throw new AggregationExecutionException("[nested] nested path [" + path + "] is not nested");
}
return new NestedAggregator(name, factories, objectMapper, context, parent, reducers, metaData, queryCachingPolicy);
}
private final static class Unmapped extends NonCollectingAggregator {
public Unmapped(String name, AggregationContext context, Aggregator parent, List<Reducer> reducers, Map<String, Object> metaData)
throws IOException {
super(name, context, parent, reducers, metaData);
}
@Override
public InternalAggregation buildEmptyAggregation() {
return new InternalNested(name, 0, buildEmptySubAggregations(), reducers(), metaData());
}
}
}
}
|
[
"[email protected]"
] | |
9f33c7abc2e0a89ff5ed80988f9d254ae56e1e5e
|
51aef8e206201568d04fb919bf54a3009c039dcf
|
/trunk/src/com/jme/scene/state/lwjgl/records/ShaderObjectsStateRecord.java
|
7ca89c0e0af1179d838ff712ad907193185b23e3
|
[] |
no_license
|
lihak/fairytale-soulfire-svn-to-git
|
0b8bdbfcaf774f13fc3d32cc3d3a6fae64f29c81
|
a85eb3fc6f4edf30fef9201902fcdc108da248e4
|
refs/heads/master
| 2021-02-11T15:25:47.199953 | 2015-12-28T14:48:14 | 2015-12-28T14:48:14 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,377 |
java
|
/*
* Copyright (c) 2003-2008 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme.scene.state.lwjgl.records;
import com.jme.scene.state.StateRecord;
import com.jme.scene.state.lwjgl.LWJGLShaderObjectsState;
public class ShaderObjectsStateRecord extends StateRecord{
//XXX NOTE: This is non-standard. Due to the fact that shader implementations
//XXX will be changed this record simply makes use of the old reference
//XXX checking system.
LWJGLShaderObjectsState reference = null;
public LWJGLShaderObjectsState getReference() {
return reference;
}
public void setReference(LWJGLShaderObjectsState reference) {
this.reference = reference;
}
@Override
public void invalidate() {
super.invalidate();
reference = null;
}
}
|
[
"[email protected]"
] | |
517bcb976d60a89d57d466f7fb12296e0980a1b1
|
ef1b72abf5554c94661c495a0bf0a6aded89e37c
|
/src/net/minecraft/src/ccy.java
|
35ebdfda301737504bc11e34f061823eed6b30e7
|
[] |
no_license
|
JimmyZJX/MC1.8_source
|
ad459b12d0d01db28942b9af87c86393011fd626
|
25f56c7884a320cbf183b23010cccecb5689d707
|
refs/heads/master
| 2016-09-10T04:26:40.951576 | 2014-11-29T06:22:02 | 2014-11-29T06:22:02 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,528 |
java
|
package net.minecraft.src;
/* 1: */ public class ccy
/* 2: */ extends ccv
/* 3: */ {
/* 4: */ private float i;
/* 5: */
/* 6: */ public ccy()
/* 7: */ {
/* 8:12 */ super(12, 0.0F);
/* 9: */
/* 10:14 */ this.a = new cdy(this, 0, 0);
/* 11:15 */ this.a.a(-3.0F, -4.0F, -6.0F, 6, 6, 8, 0.0F);
/* 12:16 */ this.a.a(0.0F, 6.0F, -8.0F);
/* 13: */
/* 14:18 */ this.b = new cdy(this, 28, 8);
/* 15:19 */ this.b.a(-4.0F, -10.0F, -7.0F, 8, 16, 6, 0.0F);
/* 16:20 */ this.b.a(0.0F, 5.0F, 2.0F);
/* 17: */ }
/* 18: */
/* 19: */ public void a(EntityLiving paramxm, float paramFloat1, float paramFloat2, float paramFloat3)
/* 20: */ {
/* 21:25 */ super.a(paramxm, paramFloat1, paramFloat2, paramFloat3);
/* 22: */
/* 23:27 */ this.a.d = (6.0F + ((EntitySheep)paramxm).o(paramFloat3) * 9.0F);
/* 24:28 */ this.i = ((EntitySheep)paramxm).p(paramFloat3);
/* 25: */ }
/* 26: */
/* 27: */ public void a(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6, Entity paramwv)
/* 28: */ {
/* 29:33 */ super.a(paramFloat1, paramFloat2, paramFloat3, paramFloat4, paramFloat5, paramFloat6, paramwv);
/* 30: */
/* 31:35 */ this.a.f = this.i;
/* 32: */ }
/* 33: */ }
/* Location: C:\Minecraft1.7.5\.minecraft\versions\1.8\1.8.jar
* Qualified Name: ccy
* JD-Core Version: 0.7.0.1
*/
|
[
"[email protected]"
] | |
35de4a1dca529c33817dcd809bd606ea4d10e805
|
743f1bc645707b95409f1d4b2e3ae0998fae3dc3
|
/设计模式/shell/src/main/java/com/dc/springboot/Main.java
|
24e12dd6c3b264e1ca0aa40bab0583ffb94d3367
|
[] |
no_license
|
sayaoailun/hello-world
|
6551a7eabd0f159fd436853b65de345306022da8
|
2e630262a3d773d8a76ec32665b1ab896de33d12
|
refs/heads/master
| 2021-05-04T11:32:21.715532 | 2017-07-18T07:32:35 | 2017-07-18T07:32:35 | 50,559,906 | 1 | 0 | null | 2016-01-28T06:31:07 | 2016-01-28T06:02:20 | null |
UTF-8
|
Java
| false | false | 674 |
java
|
package com.dc.springboot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = "com.dc")
public class Main extends SpringBootServletInitializer {
private static Logger log = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) throws Exception {
log.info("spring boot starting");
SpringApplication.run(Main.class, args);
}
}
|
[
"[email protected]"
] | |
8f31b273f13583f86308db5d2592b8549c42ec41
|
24dfe9c1b2b7c4b3855de3362bb52581e794a453
|
/app/src/main/java/com/example/ashutosh/supertourism/TourType.java
|
06d3980735053625479006ef342663ec91b54e29
|
[] |
no_license
|
ashu9326/SuperTourism
|
036dcde712cf14fffa02eab5cd9752e27d49669a
|
6de6526c37bd0b59591e1128b12203df6010f99d
|
refs/heads/master
| 2021-01-12T15:02:22.536227 | 2016-10-02T09:23:12 | 2016-10-02T09:23:12 | 69,788,904 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,381 |
java
|
package com.example.ashutosh.supertourism;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import java.util.ArrayList;
public class TourType extends AppCompatActivity {
private ListView listViewTourType;
Toolbar toolbar;
//Data Source
private String[] typeOfTour = new String[]{"Adventure", "Ecotourism", "Historical", "Industrial Tourism", "Religious Tourism"};
private ArrayAdapter<String> arrayAdapterTypeOfTour;
ArrayList<String> arrayListTypeOfTour = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tour_type);
listViewTourType = (ListView) findViewById(R.id.listview_tour_type);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Build array list
arrayListTypeOfTour.add(typeOfTour[0]);
arrayListTypeOfTour.add(typeOfTour[1]);
arrayListTypeOfTour.add(typeOfTour[2]);
arrayListTypeOfTour.add(typeOfTour[3]);
arrayListTypeOfTour.add(typeOfTour[4]);
//Initialliziing adapter and attaching data source
arrayAdapterTypeOfTour = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayListTypeOfTour);
//Attaching the adapter to the listview (destination)
listViewTourType.setAdapter(arrayAdapterTypeOfTour);
listViewTourType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(TourType.this, TourismPlace.class);
intent.putExtra("typeOfTour", typeOfTour[position]);
intent.putExtra("position", position);
startActivity(intent);
}
});
}
}
|
[
"Ashutosh Gupta"
] |
Ashutosh Gupta
|
08152841d7309629deea8ca89244717c793c34c4
|
6c79bd9a1d5fe0803e764670cc3ff6a63e20f62a
|
/src/main/java/myProj/HelloBlocksWorld.java
|
90ec2d6fa7907a8ab98c29e803a7158314636f62
|
[] |
no_license
|
Dtrycode/BlocksWorld
|
0aa11aba9847af3902702207504f7c6f39ce2925
|
cf23f4cae19c0bbbb0cac813d053cfb1f050fd23
|
refs/heads/master
| 2020-05-29T16:43:19.986951 | 2019-05-29T18:49:20 | 2019-05-29T18:49:20 | 189,256,333 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 14,078 |
java
|
package myProj;
import burlap.domain.singleagent.blocksworld.BlocksWorld;
import burlap.domain.singleagent.blocksworld.BlocksWorldBlock;
import burlap.domain.singleagent.blocksworld.BlocksWorldState;
import burlap.domain.singleagent.blocksworld.BlocksWorldVisualizer;
import burlap.domain.singleagent.blocksworld.BWModel;
import burlap.domain.singleagent.blocksworld.BlocksWorldTerminalFunction;
import burlap.domain.singleagent.blocksworld.BlocksWorldRewardFunction;
import burlap.domain.singleagent.blocksworld.BlocksWorldTower;
import burlap.mdp.auxiliary.DomainGenerator;
import burlap.mdp.auxiliary.common.NullTermination;
import burlap.mdp.core.TerminalFunction;
import burlap.mdp.core.oo.OODomain;
import burlap.mdp.core.oo.ObjectParameterizedAction;
import burlap.mdp.core.oo.propositional.GroundedProp;
import burlap.mdp.core.oo.propositional.PropositionalFunction;
import burlap.mdp.core.oo.state.OOState;
import burlap.mdp.core.oo.state.ObjectInstance;
import burlap.mdp.core.state.State;
import burlap.mdp.singleagent.model.RewardFunction;
import burlap.mdp.singleagent.model.SampleModel;
import burlap.mdp.singleagent.SADomain;
import burlap.mdp.singleagent.common.NullRewardFunction;
import burlap.shell.visual.VisualExplorer;
import burlap.mdp.singleagent.model.FactoredModel;
import burlap.mdp.singleagent.oo.OOSADomain;
import burlap.mdp.core.action.Action;
import burlap.mdp.singleagent.oo.ObjectParameterizedActionType;
import burlap.shell.EnvironmentShell;
import burlap.statehashing.simple.SimpleHashableStateFactory;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.LinkedList;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class HelloBlocksWorld {
/**
* initialize blocks and colors
*/
public static State getNewState(int nBlocks, Color[] colors) {
BlocksWorldState s = new BlocksWorldState();
for (int i = 0; i < nBlocks; i++) {
BlocksWorldBlock b = new BlocksWorldBlock("block" + i);
b.color = colors[i];
s.addObject(b);
}
return s;
}
/**
* print out current state
*/
public static void printCurrentState(SADomain domain, State s){
if(!(domain instanceof OODomain) || !(s instanceof OOState)){
return ;
}
StringBuilder buf = new StringBuilder();
List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
for(PropositionalFunction pf : props){
List<GroundedProp> gps = pf.allGroundings((OOState)s);
for(GroundedProp gp : gps){
if(gp.isTrue((OOState)s)){
buf.append(gp.toString()).append("\n");
}
}
}
System.out.println("Current state is:");
System.out.println(buf.toString());
}
/**
* print out current available actions
*/
public static void printAvailableActions(BlocksWorld bw, State s) {
ObjectParameterizedActionType actiontype = bw.new StackActionType("stack");
StringBuilder buf = new StringBuilder();
// all applicable stack actions
List<Action> actions = actiontype.allApplicableActions(s);
for (Action act : actions) {
buf.append(((ObjectParameterizedActionType.SAObjectParameterizedAction) act).toString()).append("\n");
}
// all applicable unstack actions
List<ObjectInstance> blocks = ((BlocksWorldState) s).objects();
for (ObjectInstance b : blocks) {
BlocksWorldBlock bwb = (BlocksWorldBlock) b;
if (bwb.clear && !(bwb.on.equals(BlocksWorld.TABLE_VAL))) {
buf.append("unstack " + bwb.name() + "\n");
}
}
System.out.println("Current available actions are:");
System.out.println(buf.toString());
}
/**
* Test 1
* Basic version of blocks world
*/
public static void test1(String [] args) {
BlocksWorld bw = new BlocksWorld();
// set terminal state
BlocksWorldTerminalFunction tf = new BlocksWorldTerminalFunction("clear", "block1");
BlocksWorldRewardFunction rf = new BlocksWorldRewardFunction(tf, 10., -1.);
bw.setTf(tf);
bw.setRf(rf);
SADomain domain = bw.generateDomain();
SampleModel model = domain.getModel();
// initial state
State s0 = getNewState(4, new Color[]{Color.red, Color.green, Color.blue, Color.yellow});
int expMode = 1;
if (args.length > 0) {
if (args[0].equals("v")) {
expMode = 1;
} else if(args[0].equals("t")) {
expMode = 0;
}
}
if (expMode == 0) {
EnvironmentShell shell = new EnvironmentShell(domain, s0);
shell.start();
} else if (expMode == 1) {
VisualExplorer exp = new VisualExplorer(domain, BlocksWorldVisualizer.getVisualizer(24), s0);
exp.initGUI();
printCurrentState(domain, s0);
// stack
ObjectParameterizedActionType mystack = bw.new StackActionType("stack");
// unstack
ObjectParameterizedActionType myunstack = bw.new StackActionType("unstack");
printAvailableActions(bw, s0);
System.out.println(model.terminal(s0));
// stack block0 onto block1
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a0 = mystack.associatedAction("block0 block1");
State s1 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s0, a0);
exp.updateState(s1);
printCurrentState(domain, s1);
printAvailableActions(bw, s1);
System.out.println(model.terminal(s1));
System.out.println(rf.reward(s0, a0, s1));
// stack block2 onto block0
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a1 = mystack.associatedAction("block2 block0");
State s2 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s1, a1);
exp.updateState(s2);
printCurrentState(domain, s2);
printAvailableActions(bw, s2);
System.out.println(model.terminal(s2));
System.out.println(rf.reward(s1, a1, s2));
// stack block3 onto block2
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a2 = mystack.associatedAction("block3 block2");
State s3 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s2, a2);
exp.updateState(s3);
printCurrentState(domain, s3);
printAvailableActions(bw, s3);
System.out.println(model.terminal(s3));
System.out.println(rf.reward(s2, a2, s3));
// unstack block3
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a3 = myunstack.associatedAction("block3");
State s4 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s3, a3);
exp.updateState(s4);
printCurrentState(domain, s4);
printAvailableActions(bw, s4);
System.out.println(model.terminal(s4));
System.out.println(rf.reward(s3, a3, s4));
// unstack block2
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a4 = myunstack.associatedAction("block2");
State s5 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s4, a4);
exp.updateState(s5);
printCurrentState(domain, s5);
printAvailableActions(bw, s5);
System.out.println(model.terminal(s5));
System.out.println(rf.reward(s4, a4, s5));
// unstack block0
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
Action a5 = myunstack.associatedAction("block0");
State s6 = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s5, a5);
exp.updateState(s6);
printCurrentState(domain, s6);
printAvailableActions(bw, s6);
System.out.println(model.terminal(s6));
System.out.println(rf.reward(s5, a5, s6));
}
}
/**
* Print out the blocks in each tower
*/
public static void printBlocks(State s) {
System.out.println("Blocks in each tower:");
for (int i = 0; i < 3; i++) {
BlocksWorldTower tower = ((BlocksWorldState) s).getTower(i);
System.out.println("-" + tower.name());
List<BlocksWorldBlock> blocks = (List<BlocksWorldBlock>) tower.get(BlocksWorld.VAR_TOP);
System.out.print("--");
for (BlocksWorldBlock b : blocks) {
System.out.print(b.name() + ",");
}
System.out.println();
}
System.out.println();
}
/**
* Move one block from one tower to another tower with state updated
*/
public static State moveFromTowerToTower(BlocksWorld bw, SADomain domain, State s, BlocksWorldTower curTower,
BlocksWorldTower targetTower) {
ObjectParameterizedActionType mystack = bw.new StackActionType("stack");
BlocksWorldBlock curBlock = curTower.getTopBlock();
BlocksWorldBlock targetBlock = targetTower.getTopBlock();
curTower.removeBlockTop();
targetTower.removeBlockTop();
Action a = mystack.associatedAction(curBlock.name() + " " + targetBlock.name());
State sprime = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s, a);
curBlock = (BlocksWorldBlock) ((BlocksWorldState) sprime).object(curBlock.name());
targetBlock = (BlocksWorldBlock) ((BlocksWorldState) sprime).object(targetBlock.name());
targetTower.addBlockTop(targetBlock);
targetTower.addBlockTop(curBlock);
return sprime;
}
/**
* return one of the heighest towers
*/
public static BlocksWorldTower maxTower(List<BlocksWorldTower> towers) {
int high = -1;
List<Integer> indices = null;
for (int i = 0; i < towers.size(); i++) {
BlocksWorldTower tower = towers.get(i);
if (indices == null || high < tower.getHeight()) {
high = tower.getHeight();
indices = new ArrayList<Integer>();
indices.add(i);
} else if (high == tower.getHeight()) {
indices.add(i);
}
}
// randomly select one heighest tower as the target tower
Random rand = new Random();
int ind = rand.nextInt(indices.size());
return towers.get((int) indices.get(ind));
}
/**
* Test 2:
* Blocks world with towers and random initialization
*/
public static void test2(String [] args) {
BlocksWorld bw = new BlocksWorld();
// set terminal state
BlocksWorldTerminalFunction tf = new BlocksWorldTerminalFunction("stack");
BlocksWorldRewardFunction rf = new BlocksWorldRewardFunction(tf, 10., -1.);
bw.setTf(tf);
bw.setRf(rf);
SADomain domain = bw.generateDomain();
SampleModel model = domain.getModel();
// initial state
State s0 = BlocksWorld.getRandomNewState(5, 3);
int expMode = 1;
if (args.length > 0) {
if (args[0].equals("v")) {
expMode = 1;
} else if(args[0].equals("t")) {
expMode = 0;
}
}
if (expMode == 0) {
EnvironmentShell shell = new EnvironmentShell(domain, s0);
shell.start();
} else if (expMode == 1) {
VisualExplorer exp = new VisualExplorer(domain, BlocksWorldVisualizer.getVisualizer(24), s0);
exp.initGUI();
// print out the blocks in each tower
printBlocks(s0);
// test the BlocksWorldTower class by implementing the optimal strategy
List<BlocksWorldTower> towers = new LinkedList<BlocksWorldTower>(((BlocksWorldState) s0).getTowers());
Random rand = new Random();
// --------Testing Tower---------
// randomly select one heighest tower as the target tower
// BlocksWorldTower targetTower = maxTower(towers);
// towers.remove(tower);
// loop until no tower left:
// randomly select one tower and move all blocks one by one in that tower to the target tower
// State s = s0;
// while (!towers.isEmpty()) {
// int cur = rand.nextInt(towers.size());
// BlocksWorldTower curTower = towers.remove(cur);
// while (curTower.getHeight() > 0) {
// s = moveFromTowerToTower(bw, domain, s, curTower, targetTower);
// try {
// TimeUnit.SECONDS.sleep(2);
// } catch (Exception ex) {
// }
// exp.updateState(s);
// // print out the blocks in each tower
// printBlocks(s);
// System.out.println(model.terminal(s));
// System.out.println();
// }
// }
// -------Optimal vs. Not optimal--------
// decide optimality on step basis
State s = s0;
int numSteps = 0;
int maxSteps = 10;
// probability to choose random action
double epsilon = 0.7;
while (!model.terminal(s) && (numSteps < maxSteps)) {
double p = rand.nextDouble();
if (p < epsilon) {
// random action
System.out.println("--random action--");
ObjectParameterizedActionType actiontype = bw.new StackActionType("stack");
List<Action> actions = actiontype.allApplicableActions(s);
// randomly select an action
int ind = rand.nextInt(actions.size());
Action action = actions.get(ind);
String [] params = ((ObjectParameterizedAction) action).getObjectParameters();
BlocksWorldBlock aBlock = (BlocksWorldBlock) ((BlocksWorldState) s).object(params[0]);
BlocksWorldBlock bBlock = (BlocksWorldBlock) ((BlocksWorldState) s).object(params[1]);
BlocksWorldTower aTower = aBlock.tower;
BlocksWorldTower bTower = bBlock.tower;
aTower.removeBlockTop();
bTower.removeBlockTop();
s = ((BWModel) ((FactoredModel) domain.getModel()).getStateModel()).sample(s, action);
aBlock = (BlocksWorldBlock) ((BlocksWorldState) s).object(params[0]);
bBlock = (BlocksWorldBlock) ((BlocksWorldState) s).object(params[1]);
bTower.addBlockTop(bBlock);
bTower.addBlockTop(aBlock);
} else {
// optimal action
System.out.println("--optimal action--");
BlocksWorldTower targetTower = maxTower(towers);
BlocksWorldTower curTower = targetTower;
while ((curTower == targetTower) || (curTower.getHeight() == 0)) {
int ind = rand.nextInt(towers.size());
curTower = towers.get(ind);
}
s = moveFromTowerToTower(bw, domain, s, curTower, targetTower);
}
try {
TimeUnit.SECONDS.sleep(2);
} catch (Exception ex) {
}
exp.updateState(s);
// print out the blocks in each tower
printBlocks(s);
}
System.out.println("--agent finishes--");
}
}
/**
* Main method for exploring the domain. The initial state will have 3 red blocks starting on the table. By default this method will launch the visual explorer.
* Pass a "t" argument to use the terminal explorer.
* @param args process arguments
*/
public static void main(String [] args) {
test2(args);
}
}
|
[
"[email protected]"
] | |
cde7dba54d02411abd623ebd96e79d032177bc83
|
a071fc9bd75c86c0b548c8a8c09f96993b772227
|
/src/main/java/com/vlasovartem/wotalyzer/entity/wot/api/global_map/SeasonAccountInfo.java
|
a0b5b230a28b787fb348e408b2b11f74fa519957
|
[] |
no_license
|
VlasovArtem/wotalyzer
|
e6d402d1f1cb1c3575b07af099729698fa7ce7ad
|
09f874b3086ed6d87cdcb766052c6d1582df4dc6
|
refs/heads/master
| 2021-01-11T01:17:10.055542 | 2018-11-18T06:14:17 | 2018-11-18T06:14:17 | 70,731,698 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,707 |
java
|
package com.vlasovartem.wotalyzer.entity.wot.api.global_map;
import java.time.LocalDateTime;
import java.util.List;
/**
* Created by artemvlasov on 15/10/2016.
* https://developers.wargaming.net/reference/all/wot/globalmap/seasonaccountinfo/
*/
public class SeasonAccountInfo {
/* seasons - Account information by seasons and vehicle Tiers */
private List<Season> seasons;
private class Season {
/* Account ID */
private int accountId;
/* Award level */
private String awardLevel;
/* Battles fought for current clan */
private int battles;
/* Battles to fight in a current clan to get clan award for the season */
private int battlesToAward;
/* Clan ID */
private int clanId;
/* Clan rating */
private int clanRank;
/* Season ID */
private String seasonId;
/* Date when account data were updated */
private LocalDateTime updatedAt;
/* Vehicle Tier */
private int vehicleLevel;
public int getAccountId() {
return accountId;
}
public void setAccountId(int accountId) {
this.accountId = accountId;
}
public String getAwardLevel() {
return awardLevel;
}
public void setAwardLevel(String awardLevel) {
this.awardLevel = awardLevel;
}
public int getBattles() {
return battles;
}
public void setBattles(int battles) {
this.battles = battles;
}
public int getBattlesToAward() {
return battlesToAward;
}
public void setBattlesToAward(int battlesToAward) {
this.battlesToAward = battlesToAward;
}
public int getClanId() {
return clanId;
}
public void setClanId(int clanId) {
this.clanId = clanId;
}
public int getClanRank() {
return clanRank;
}
public void setClanRank(int clanRank) {
this.clanRank = clanRank;
}
public String getSeasonId() {
return seasonId;
}
public void setSeasonId(String seasonId) {
this.seasonId = seasonId;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
public int getVehicleLevel() {
return vehicleLevel;
}
public void setVehicleLevel(int vehicleLevel) {
this.vehicleLevel = vehicleLevel;
}
}
}
|
[
"[email protected]"
] | |
c0eafddd7d858bb790f53f2300df6026c93ba6c7
|
88286bd665c559827ca52940e5a814172610a757
|
/app/src/androidTest/java/com/example/nlowe/calculator/ExampleInstrumentedTest.java
|
ccfe0b71d4a9d294ed7ede172e99404174d05e04
|
[] |
no_license
|
nrlowe/calculator
|
e84ec0a10f132a4938127204f3cddc068c79022a
|
9e3c24f02361d7f5fbb72fbb8f6a3e38bbfa0135
|
refs/heads/master
| 2020-03-21T04:07:46.203606 | 2018-07-23T20:31:47 | 2018-07-23T20:31:47 | 138,092,240 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 740 |
java
|
package com.example.nlowe.calculator;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.nlowe.calculator", appContext.getPackageName());
}
}
|
[
"[email protected]"
] | |
d5bc0f741e888defc1d76710701739bd78d1dfa1
|
ffedc8558881fa60a7b348895e01c9a08875f83f
|
/src/test/java/com/anfelisa/card/movecard/scenarios/MoveCardsNoAccessToCardScenario.java
|
46d87d73b39efb28d9a390114e3ef0f05b9d216d
|
[
"ISC"
] |
permissive
|
annettedorothea/com.anfelisa.server
|
f1573abf238438e6915a22f63e9f5e9613f5e960
|
3d647ba7914c9e0e35bf855b48a1636e69149f84
|
refs/heads/master
| 2023-03-19T06:51:21.087628 | 2023-03-12T16:40:17 | 2023-03-12T16:40:17 | 72,461,607 | 0 | 1 |
ISC
| 2023-01-06T13:43:54 | 2016-10-31T17:38:27 |
Java
|
UTF-8
|
Java
| false | false | 977 |
java
|
/*
* Copyright (c) 2019, Annette Pohl, Koblenz, Germany
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package com.anfelisa.card.movecard.scenarios;
public class MoveCardsNoAccessToCardScenario extends AbstractMoveCardsNoAccessToCardScenario {
}
/******* S.D.G. *******/
|
[
"[email protected]"
] | |
38d0d5190280966e417f8aa3e229c7fb353ea2ff
|
8c334c3365428b4c5ea88a3b084a67302f484103
|
/core/src/main/java/org/streameps/engine/ICompositeEnginePair.java
|
a04cdfaf47973fced0d84295492f57206125b1c0
|
[
"BSD-3-Clause"
] |
permissive
|
fanhubgt/StreamEPS
|
9d2835b54dee43253a78e8faa6bdeed149d4c856
|
ea8f9cd03755315e34301a50fdbfe9a30b59077f
|
refs/heads/master
| 2023-04-27T11:02:26.538584 | 2020-11-17T14:08:20 | 2020-11-17T14:08:20 | 1,288,135 | 0 | 0 |
NOASSERTION
| 2023-04-14T17:08:44 | 2011-01-24T15:54:57 |
Java
|
UTF-8
|
Java
| false | false | 2,071 |
java
|
/*
* ====================================================================
* StreamEPS Platform
*
* (C) Copyright 2011.
*
* Distributed under the Modified BSD License.
* Copyright notice: The copyright for this software and a full listing
* of individual contributors are as shown in the packaged copyright.txt
* file.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the ORGANIZATION nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* =============================================================================
*/
package org.streameps.engine;
/**
*
* @author Frank Appiah
*/
public interface ICompositeEnginePair {
}
|
[
"[email protected]"
] | |
57beb5ed1608441e5b78b063bf15bbca90c4fb5b
|
dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9
|
/data_defect4j/preprossed_method_corpus/Math/65/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer_setMaxEvaluations_57.java
|
a93d5ba0fe6cc00bf37266821bcf3d06c3af11f6
|
[] |
no_license
|
hvdthong/NetML
|
dca6cf4d34c5799b400d718e0a6cd2e0b167297d
|
9bb103da21327912e5a29cbf9be9ff4d058731a5
|
refs/heads/master
| 2021-06-30T15:03:52.618255 | 2020-10-07T01:58:48 | 2020-10-07T01:58:48 | 150,383,588 | 1 | 1 | null | 2018-09-26T07:08:45 | 2018-09-26T07:08:44 | null |
UTF-8
|
Java
| false | false | 792 |
java
|
org apach common math optim
optim algorithm find input point set link goal type goaltyp
maxim minim object function
intend enforc intern coher
common math user api advis base code
link multivari real optim multivariaterealoptim
link differenti multivari real optim differentiablemultivariaterealoptim
param type object function optim
multivari real optim multivariaterealoptim
differenti multivari real optim differentiablemultivariaterealoptim
version revis date
base multivari real optim basemultivariaterealoptim multivari real function multivariaterealfunct
set maxim number function evalu
param max evalu maxevalu maxim number function evalu
set max evalu setmaxevalu max evalu maxevalu
|
[
"[email protected]"
] | |
33aed4f53d1f6521a0787a0f025380e1ffdda6a3
|
6d01d0b0ed45a318ca3f4eb1baa215cbe458139e
|
/programprocessor/experiment-dataset/TrainingData/51CTO-java1200221/MR/555/src/com/cdd/derive/LocalTableModel.java
|
36c6b912441d4f88d4225d11c23df1203cfdc820
|
[] |
no_license
|
yangyixiaof/gitcrawler
|
83444de5de1e0e0eb1cb2f1e2f39309f10b52eb5
|
f07f0525bcb33c054820cf27e9ff73aa591ed3e0
|
refs/heads/master
| 2022-09-16T20:07:56.380308 | 2020-04-12T17:03:02 | 2020-04-12T17:03:02 | 46,218,938 | 0 | 1 | null | 2022-09-01T22:36:18 | 2015-11-15T13:36:48 |
Java
|
GB18030
|
Java
| false | false | 687 |
java
|
package com.cdd.derive;
public class LocalTableModel extends javax.swing.table.DefaultTableModel {
Class[] types = new Class[] { java.lang.Object.class,
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class,java.lang.String.class};
boolean[] canEdit = new boolean[] { false, false, false,false,false,false };
public LocalTableModel() {
super(new Object[][] {}, new String[] { "编号", "姓名", "部门","职位","入司时间","工资" });
}
public Class getColumnClass(int columnIndex) {
return types[columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
}
|
[
"yyx@ubuntu"
] |
yyx@ubuntu
|
9ea93175ae04819d109fedf13f15f1580371758b
|
79668e1c6cce4ac6524c0515c6adcbecaf88f3b2
|
/app/src/main/java/com/seol/sos/ShakingSensor.java
|
1dce70dcea4ef479b795621c5ca4f8fbce4c399d
|
[] |
no_license
|
Seolinho/SOS
|
169b4ad694f881d8d24805996672e3d01958d852
|
ae97d14dfc7ecca473b960fe5ee0c1f001ed98f8
|
refs/heads/master
| 2021-05-06T02:17:15.377977 | 2018-01-25T12:51:53 | 2018-01-25T12:51:53 | 114,513,473 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 4,806 |
java
|
package com.seol.sos;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
import java.util.Timer;
import java.util.TimerTask;
/**
* Created by Seol on 2017-12-17.
*/
public class ShakingSensor extends Service implements SensorEventListener {
private long lastTime;
private float speed;
private float lastX;
private float lastY;
private float lastZ;
private float x, y, z;
private static final int SHAKE_THRESHOLD = 20000;
private static final int DATA_X = SensorManager.DATA_X;
private static final int DATA_Y = SensorManager.DATA_Y;
private static final int DATA_Z = SensorManager.DATA_Z;
private int cnt = 0;
public static String markerTitle="";
private SensorManager sensorManager;
private Sensor accelerormeterSensor;
private Timer timer;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Log.i("MyServiceIntent", "Service is Create");
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
accelerormeterSensor = sensorManager
.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
SharedPreferences pref = getSharedPreferences("pref",MODE_PRIVATE);
String shakingOption = pref.getString("shakingUse","N");
if (accelerormeterSensor != null&&shakingOption.equals("Y"))
sensorManager.registerListener(this, accelerormeterSensor,
SensorManager.SENSOR_DELAY_GAME);
boolean loctionOn =pref.getBoolean("locationOn",false);
if (loctionOn){
Log.d("timer",loctionOn+"");
long interval =pref.getLong("Interval",1800000);
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
SendTextMessageService sms = new SendTextMessageService(getApplicationContext());
sms.sendSMS(2);
}
};
if (timer==null){
timer = new Timer();
timer.schedule(timerTask,0,interval);
}
} else {
if (timer!=null){
timer.cancel();
}
}
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Log.i("MyServiceIntent", "Service is destroy");
cnt = 0;
if (sensorManager != null)
sensorManager.unregisterListener(this);
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
long currentTime = System.currentTimeMillis();
long gabOfTime = (currentTime - lastTime);
if (gabOfTime > 100) {
lastTime = currentTime;
x = event.values[SensorManager.DATA_X];
y = event.values[SensorManager.DATA_Y];
z = event.values[SensorManager.DATA_Z];
speed = Math.abs(x + y + z - lastX - lastY - lastZ) / gabOfTime
* 10000;
if (speed > SHAKE_THRESHOLD) {
SendTextMessageService send = new SendTextMessageService(getApplicationContext());
if (cnt == 0) { //한 번 문자 보내고 그만 보냄
send.sendSMS(1);
cnt++;
Toast.makeText(getApplicationContext(), "SOS문자가 전송되었습니다.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "이미 SOS문자가 전송되었습니다.", Toast.LENGTH_SHORT).show();
}
}
if (speed == 0) {
cnt = 0;
}// 멈췄다가 다시 하면 문자 전송 가능하도록
lastX = event.values[DATA_X];
lastY = event.values[DATA_Y];
lastZ = event.values[DATA_Z];
}
}
}
}
|
[
"[email protected]"
] | |
fc7855588b6b89c98c9dd9b107c6ff082764a4ef
|
d148e77bf2c417044253dcd19c44326bc7198362
|
/build/classes/data/AddToCourse.java
|
c946c93f7da3a74905efb359c38d3403a60b01b0
|
[
"MIT"
] |
permissive
|
JohnGrigoriou/IndividualProjectPartA
|
eeeede4da909e1710233ddbda782cf3d55460dfd
|
fdb639558156c89c25f3d6f982ab2417705cf999
|
refs/heads/main
| 2023-08-05T07:12:27.237907 | 2021-09-24T07:14:10 | 2021-09-24T07:14:10 | 409,869,200 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 5,267 |
java
|
package data;
import utils.Date;
import utils.Lists;
import models.Student;
import models.Course;
import models.Assignment;
import models.Trainer;
import java.util.ArrayList;
import java.util.Scanner;
import utils.Color;
public class AddToCourse {
Scanner sc = new Scanner(System.in);
Lists lists = Lists.getInstance();
Date date = new Date();
public void addStudents(Student student) {
System.out.println("DO YOU WANT TO ADD THE STUDENT TO A COURSE?");
System.out.println("TYPE \"YES\" OR \"NO\"");
String str = sc.nextLine().trim().toLowerCase();
if (str.equals("yes")) {
if (!(lists.getCourses().isEmpty())) {
int i = 1;
System.out.println("THE AVAILABLE COURSES ARE");
for (Course c : lists.getCourses()) {
System.out.println(i + " - " + c);
i++;
}
int j = 1;
for (Course c : lists.getCourses()) {
System.out.println("IF YOU WANNA ADD THE STUDENT TO COURSE " + j + " TYPE \"YES\", ELSE TYPE ANYTHING");
if (sc.nextLine().trim().toLowerCase().equals("yes")) {
lists.getCourses().get(j - 1).getcStudents().add(student);
Color.print(Color.GREEN,student + " ADDED TO COURSE " + j);
}
j++;
}
} else {
System.out.println("THERE ARE NO AVAILABLE COURSES AT THE MOMENT");
}
} else if (str.equals("no")) {
System.out.println("STUDENT NOT ADDED");
} else {
Color.print(Color.RED,"WRONG INPUT!!!");
addStudents(student);
}
}
public void addTrainers(Trainer trainer) {
System.out.println("DO YOU WANT TO ADD THE TRAINER TO A COURSE?");
System.out.println("TYPE \"YES\" OR \"NO\"");
String str = sc.nextLine().trim().toLowerCase();
if (str.equals("yes")) {
if (!(lists.getCourses().isEmpty())) {
int i = 1;
System.out.println("THE AVAILABLE COURSES ARE");
for (Course c : lists.getCourses()) {
System.out.println(i + " - " + c);
i++;
}
int j = 1;
for (Course c : lists.getCourses()) {
System.out.println("IF YOU WANNA ADD THE TRAINER TO COURSE " + j + " TYPE \"YES\", ELSE TYPE ANYTHING");
if (sc.nextLine().trim().toLowerCase().equals("yes")) {
lists.getCourses().get(j - 1).getcTrainers().add(trainer);
Color.print(Color.GREEN,trainer + " ADDED TO COURSE " + j);
}
j++;
}
} else {
System.out.println("THERE ARE NO AVAILABLE COURSES AT THE MOMENT");
}
} else if (str.equals("no")) {
System.out.println("TRAINER NOT ADDED");
} else {
Color.print(Color.RED,"WRONG INPUT!!!");
addTrainers(trainer);
}
}
public void addAssignments(Assignment assignment) {
System.out.println("DO YOU WANT TO ADD THE ASSIGNMENT TO A COURSE?");
Color.print(Color.RED,"BE CAREFUL! THE ASSIGNMENTS SUB-DATE MUST BE BETWEEN START AND END DATE OF THE COURSE");
System.out.println("TYPE \"YES\" OR \"NO\"");
String str = sc.nextLine().trim().toLowerCase();
if (str.equals("yes")) {
if (!(lists.getCourses().isEmpty())) {
int i = 1;
System.out.println("CHECKING FOR AVAILABLE COURSES...");
ArrayList<Course> availableC = new ArrayList<>();
for (Course c : lists.getCourses()) {
if (date.localDate(assignment.getSubDateTime()).isAfter(date.localDate(c.getStartDate()))) {
if (date.localDate(assignment.getSubDateTime()).isBefore(date.localDate(c.getEndDate()))) {
availableC.add(c);
System.out.println(i + " - " + c);
i++;
}
}
}
if (availableC.isEmpty()){
Color.print(Color.RED,"NO AVAILABLE COURSES FOUND");
}
int j = 1;
for (Course c : availableC) {
System.out.println("IF YOU WANNA ADD THE ASSIGNMENT TO COURSE " + j + " TYPE \"YES\", ELSE TYPE ANYTHING");
if (sc.nextLine().trim().toLowerCase().equals("yes")) {
availableC.get(j - 1).getcAssignments().add(assignment);
Color.print(Color.GREEN,assignment + " ADDED TO COURSE " + j);
}
j++;
}
} else {
System.out.println("THERE ARE NO AVAILABLE COURSES AT THE MOMENT");
}
} else if (str.equals("no")) {
System.out.println("ASSIGNMENT NOT ADDED");
} else {
Color.print(Color.RED,"WRONG INPUT!!!");
addAssignments(assignment);
}
}
}
|
[
"[email protected]"
] | |
c888a88ed93ec8479a1248d6c08f848239af012a
|
4e175b9fe3f9902701ccc0f81e33bdda810727fa
|
/datastructures/hashset/prog1.java
|
becfa589f248ca7ce508c6d44d5e382f46e1bb86
|
[] |
no_license
|
Annoymous-coder/DS
|
53eca19068efe0a59e87cd98c612b7eda8317679
|
a38d274c274005cc95e9f9d95eeb63e1ee444a6c
|
refs/heads/master
| 2023-03-17T12:51:18.064838 | 2020-04-28T18:10:56 | 2020-04-28T18:10:56 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 321 |
java
|
import java.util.HashMap;
import java.util.HashSet;
public class prog1
{
public static void main(String[] args) {
HashSet<Integer> h1=new HashSet<>();
h1.add(1);
h1.add(7);
h1.add(9);
h1.add(3);
h1.add(15);
for(int i:h1)
{
if()
}
}
}
|
[
"[email protected]"
] | |
75d790cf4ec3c85dc59c6681fd4f9cbbe49cf2ca
|
d14571bf37ec5532497fad46a3449ca8866efaf1
|
/plugins-for-tests/test-valid-subclass-plugin/src/com/tw/qa/plugin/sample/SubClassOne.java
|
63bb9642fe7fa8e4e6226df39b1a3c3794153bf8
|
[
"Apache-2.0"
] |
permissive
|
arvindsv/go-plugins
|
1901a272e5a7d264a261a0be3c9bd3886fcda438
|
c25bf3014a30e38eab3ebf1be43a92777f48cfd1
|
refs/heads/master
| 2020-03-29T20:38:20.216048 | 2018-09-11T12:33:18 | 2018-09-11T12:33:18 | 150,322,663 | 0 | 0 | null | 2018-09-25T20:05:48 | 2018-09-25T20:05:48 | null |
UTF-8
|
Java
| false | false | 1,059 |
java
|
/*************************GO-LICENSE-START*********************************
* Copyright 2014 ThoughtWorks, 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.
*************************GO-LICENSE-END***********************************/
package com.tw.qa.plugin.sample;
import com.thoughtworks.go.plugin.api.annotation.Extension;
import com.thoughtworks.go.plugin.api.logging.Logger;
@Extension
public class SubClassOne extends ValidSubClassPlugin {
static {
Logger.getLoggerFor(SubClassOne.class).info("Inside Sub Class");
}
}
|
[
"pshivana@praveends.(none)"
] |
pshivana@praveends.(none)
|
eac68c3f6e3c25af0e0131c4e404ab8c78be1c55
|
c294aae7b003dc9d6ea6141f67a7eab021e55375
|
/ichiyazuke_web/src/bean/Question.java
|
11320818ee2ce75e02e18c115e106e4670349da3
|
[] |
no_license
|
gishhub/ichiyazuke
|
fc6b448d72868ed4ae76e3234a703997ac1ce060
|
1811e282ef984facd85786fdc9655749aa55e6d6
|
refs/heads/master
| 2020-04-02T01:04:16.659427 | 2013-01-26T05:07:12 | 2013-01-26T05:07:12 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,244 |
java
|
package bean;
import java.util.Date;
public class Question {
private int id;
private int grade;
private int category;
private int level;
private String title;
private String contents;
private String choice1;
private String choice2;
private String choice3;
private String choice4;
private String answer;
private String explanation;
private int count;
private Date regDate;
public Question() {
}
public Question(int id, String title, String contents, Date regDate) {
this.id = id;
this.title = title;
this.contents = contents;
this.regDate = regDate;
}
public Question(int id, String title, String contents, String choice1, String choice2,String choice3, String choice4, String answer, String explanation,Date regDate) {
this.id = id;
this.title = title;
this.contents = contents;
this.choice1 = choice1;
this.choice2 = choice2;
this.choice3 = choice3;
this.choice4 = choice4;
this.answer = answer;
this.explanation = explanation;
this.regDate = regDate;
}
public Question(int id, int grade, int category, int level,
String title, String contents, String choice1, String choice2,
String choice3, String choice4, String answer, String explanation,
int count, Date regDate) {
this.id = id;
this.grade = grade;
this.category = category;
this.level = level;
this.title = title;
this.contents = contents;
this.choice1 = choice1;
this.choice2 = choice2;
this.choice3 = choice3;
this.choice4 = choice4;
this.answer = answer;
this.explanation = explanation;
this.count = count;
this.regDate = regDate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public int getCategory() {
return category;
}
public void setCategory(int category) {
this.category = category;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
public String getChoice1() {
return choice1;
}
public void setChoice1(String choice1) {
this.choice1 = choice1;
}
public String getChoice2() {
return choice2;
}
public void setChoice2(String choice2) {
this.choice2 = choice2;
}
public String getChoice3() {
return choice3;
}
public void setChoice3(String choice3) {
this.choice3 = choice3;
}
public String getChoice4() {
return choice4;
}
public void setChoice4(String choice4) {
this.choice4 = choice4;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public String getExplanation() {
return explanation;
}
public void setExplanation(String explanation) {
this.explanation = explanation;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public Date getRegDate() {
return regDate;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
}
|
[
"[email protected]"
] | |
4b9ba0b0a39ff88ecd97039184f62e95ffd90688
|
4f5206a53996357320b5fa10ec8111b2fea02bad
|
/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDouble.java
|
17f1458b1424e6e8c8909fe9740d5a483bd60a43
|
[] |
no_license
|
misqu23/errai
|
a59a73d5559065b82d561ac67db2247d484be61f
|
1da0d7011e37b63b324e368f14e5df3fdfa3b269
|
refs/heads/master
| 2021-01-16T18:44:07.114659 | 2010-09-30T09:33:43 | 2010-09-30T09:33:43 | 948,364 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 967 |
java
|
/*
* Copyright 2010 JBoss, a divison Red Hat, 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 org.jboss.errai.common.client.types.handlers.numbers;
import org.jboss.errai.common.client.types.DecodingContext;
import org.jboss.errai.common.client.types.TypeHandler;
public class NumberToDouble implements TypeHandler<Number, Double> {
public Double getConverted(Number in, DecodingContext ctx) {
return in.doubleValue();
}
}
|
[
"[email protected]"
] | |
a509b8b56a65c817c7407ab4d98b55b41eae1b75
|
19809d0be46f6582a7802a773afc792868304942
|
/java7SrcStudy/src/main/java/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
|
0616d3999ee36a81efa58b0315442dfee2c43b51
|
[] |
no_license
|
jxxiangwen/JavaStudy
|
fa5194630a0c46d498d1a49acba8449fa4d447e9
|
fbf2accf3e9ec24b633ef26d2f3328e6b021d054
|
refs/heads/master
| 2022-12-21T20:46:04.447682 | 2019-09-02T09:35:27 | 2019-09-02T09:35:27 | 48,320,572 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,676 |
java
|
package org.omg.CosNaming.NamingContextPackage;
/**
* org/omg/CosNaming/NamingContextPackage/NotFoundReason.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from ../../../../src/share/classes/org/omg/CosNaming/nameservice.idl
* Friday, July 25, 2014 9:00:00 AM PDT
*/
/**
* Indicates the reason for not able to resolve.
*/
public class NotFoundReason implements org.omg.CORBA.portable.IDLEntity
{
private int __value;
private static int __size = 3;
private static org.omg.CosNaming.NamingContextPackage.NotFoundReason[] __array = new org.omg.CosNaming.NamingContextPackage.NotFoundReason [__size];
public static final int _missing_node = 0;
public static final org.omg.CosNaming.NamingContextPackage.NotFoundReason missing_node = new org.omg.CosNaming.NamingContextPackage.NotFoundReason(_missing_node);
public static final int _not_context = 1;
public static final org.omg.CosNaming.NamingContextPackage.NotFoundReason not_context = new org.omg.CosNaming.NamingContextPackage.NotFoundReason(_not_context);
public static final int _not_object = 2;
public static final org.omg.CosNaming.NamingContextPackage.NotFoundReason not_object = new org.omg.CosNaming.NamingContextPackage.NotFoundReason(_not_object);
public int value ()
{
return __value;
}
public static org.omg.CosNaming.NamingContextPackage.NotFoundReason from_int (int value)
{
if (value >= 0 && value < __size)
return __array[value];
else
throw new org.omg.CORBA.BAD_PARAM ();
}
protected NotFoundReason (int value)
{
__value = value;
__array[__value] = this;
}
} // class NotFoundReason
|
[
"[email protected]"
] | |
674062fa498f286604b444de22f9d18c4f2a4237
|
791532db8be70e7d2aee1346e30cec3d3ae511af
|
/src/main/java/com/microsoft/bingads/v12/bulk/entities/BulkCallAdExtension.java
|
ab21ca23c18e46621d123dc0dfcd4798afef7188
|
[
"MIT"
] |
permissive
|
charan1595/BingAds-Java-SDK
|
d5d894484391057141b146a7e0893e4c29220ee9
|
d981912a71fa2f5aa61a337b33ca4caca8fbc66f
|
refs/heads/master
| 2020-03-28T03:50:44.751557 | 2018-09-12T10:19:53 | 2018-09-12T10:19:53 | 147,675,402 | 0 | 0 | null | 2018-09-06T13:09:45 | 2018-09-06T13:09:45 | null |
UTF-8
|
Java
| false | false | 7,054 |
java
|
package com.microsoft.bingads.v12.bulk.entities;
import com.microsoft.bingads.v12.bulk.BulkFileReader;
import com.microsoft.bingads.v12.bulk.BulkFileWriter;
import com.microsoft.bingads.v12.bulk.BulkServiceManager;
import com.microsoft.bingads.v12.campaignmanagement.CallAdExtension;
import com.microsoft.bingads.v12.bulk.BulkOperation;
import com.microsoft.bingads.v12.internal.bulk.StringExtensions;
import com.microsoft.bingads.v12.internal.bulk.StringTable;
import com.microsoft.bingads.v12.internal.bulk.BulkMapping;
import com.microsoft.bingads.v12.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v12.internal.bulk.RowValues;
import com.microsoft.bingads.v12.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Represents a call ad extension. This class exposes {@link #setCallAdExtension} and {@link #getCallAdExtension}
* that can be used to read and write fields of the Call Ad Extension record in a bulk file.
*
* For more information, see Call Ad Extension at
* <a href="https://go.microsoft.com/fwlink/?linkid=846127">https://go.microsoft.com/fwlink/?linkid=846127</a>
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public class BulkCallAdExtension extends BulkAdExtension<CallAdExtension> {
/**
* Gets the call ad extension.
*/
public CallAdExtension getCallAdExtension() {
return this.getAdExtension();
}
/**
* Sets the call ad extension.
*/
public void setCallAdExtension(CallAdExtension value) {
this.setAdExtension(value);
}
private static List<BulkMapping<BulkCallAdExtension>> MAPPINGS;
static {
List<BulkMapping<BulkCallAdExtension>> m = new ArrayList<BulkMapping<BulkCallAdExtension>>();
m.add(new SimpleBulkMapping<BulkCallAdExtension, String>(StringTable.PhoneNumber,
new Function<BulkCallAdExtension, String>() {
@Override
public String apply(BulkCallAdExtension c) {
return c.getCallAdExtension().getPhoneNumber();
}
},
new BiConsumer<String, BulkCallAdExtension>() {
@Override
public void accept(String v, BulkCallAdExtension c) {
c.getCallAdExtension().setPhoneNumber(v);
}
}
));
m.add(new SimpleBulkMapping<BulkCallAdExtension, String>(StringTable.CountryCode,
new Function<BulkCallAdExtension, String>() {
@Override
public String apply(BulkCallAdExtension c) {
return c.getCallAdExtension().getCountryCode();
}
},
new BiConsumer<String, BulkCallAdExtension>() {
@Override
public void accept(String v, BulkCallAdExtension c) {
c.getCallAdExtension().setCountryCode(v);
}
}
));
m.add(new SimpleBulkMapping<BulkCallAdExtension, String>(StringTable.IsCallOnly,
new Function<BulkCallAdExtension, String>() {
@Override
public String apply(BulkCallAdExtension c) {
return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getIsCallOnly());
}
},
new BiConsumer<String, BulkCallAdExtension>() {
@Override
public void accept(String v, BulkCallAdExtension c) {
c.getCallAdExtension().setIsCallOnly(StringExtensions.<Boolean>parseOptional(v, new Function<String, Boolean>() {
@Override
public Boolean apply(String value) {
return Boolean.parseBoolean(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping<BulkCallAdExtension, String>(StringTable.IsCallTrackingEnabled,
new Function<BulkCallAdExtension, String>() {
@Override
public String apply(BulkCallAdExtension c) {
return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getIsCallTrackingEnabled());
}
},
new BiConsumer<String, BulkCallAdExtension>() {
@Override
public void accept(String v, BulkCallAdExtension c) {
c.getCallAdExtension().setIsCallTrackingEnabled(StringExtensions.<Boolean>parseOptional(v, new Function<String, Boolean>() {
@Override
public Boolean apply(String value) {
return Boolean.parseBoolean(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping<BulkCallAdExtension, String>(StringTable.RequireTollFreeTrackingNumber,
new Function<BulkCallAdExtension, String>() {
@Override
public String apply(BulkCallAdExtension c) {
return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getRequireTollFreeTrackingNumber());
}
},
new BiConsumer<String, BulkCallAdExtension>() {
@Override
public void accept(String v, BulkCallAdExtension c) {
c.getCallAdExtension().setRequireTollFreeTrackingNumber(StringExtensions.<Boolean>parseOptional(v, new Function<String, Boolean>() {
@Override
public Boolean apply(String value) {
return Boolean.parseBoolean(value);
}
}));
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
@Override
public void processMappingsFromRowValues(RowValues values) {
CallAdExtension extension = new CallAdExtension();
extension.setType("CallAdExtension");
this.setAdExtension(extension);
super.processMappingsFromRowValues(values);
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
this.validatePropertyNotNull(this.getCallAdExtension(), "CallAdExtension");
super.processMappingsToRowValues(values, excludeReadonlyData);
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
}
|
[
"[email protected]"
] | |
4a675cd1c6feaeda396127889f0f629eda65d55d
|
be759110e0aeea1b31e4f3df9375dfc170fe2fc0
|
/src/main/java/com/googlecode/jtiger/modules/hr/employee/model/Employee.java
|
fd8b597ce4e5175d45d3482d8aeb360e58e2ba20
|
[] |
no_license
|
adian98/bdjjkq
|
b8a8b7abde3f69be83d7db60862d2584b59fa448
|
c614eac8f9b3ac03a174f52b4b7dd0fbea3be233
|
refs/heads/master
| 2021-05-28T16:48:41.222576 | 2011-11-08T03:28:30 | 2011-11-08T03:28:30 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 8,487 |
java
|
package com.googlecode.jtiger.modules.hr.employee.model;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.googlecode.jtiger.core.model.BaseIdModel;
import com.googlecode.jtiger.modules.hr.HrConstants;
import com.googlecode.jtiger.modules.hr.dept.model.Dept;
import com.googlecode.jtiger.modules.security.user.model.User;
/**
* 员工表 The persistent class for the employees database table.
*
*/
@SuppressWarnings("serial")
@Entity
@Table(name = "assess_employees")
public class Employee extends BaseIdModel implements Serializable {
/**
* 地址
*/
private String address;
/**
* 出身日期
*/
private Date birthday;
/**
* 证件号码
*/
private String credentialNo;
/**
* 警号
*/
private String policeNo;
/**
* 学历
*/
private String degree;
/**
* 传真
*/
private String fax = "xdd";
/**
* 民族
*/
private String folk;
/**
* 毕业时间
*/
private Date graduateDate;
/**
* 宅电
*/
private String hTel;
/**
* 参加工作时间
*/
private Date jobDate;
/**
* 婚姻状况
*/
private String married = HrConstants.MARRIED_N;
/**
* 手机
*/
private String mobil;
/**
* msn
*/
private String msn;
/**
* 姓名或昵称
*/
private String name;
/**
* 照片
*/
private String photo;
/**
* 职位
*/
private String place;
/**
* 政治面貌
*/
private String political;
/**
* qq
*/
private String qq;
/**
* 户口所在地
*/
private String registeredPos;
/**
* 毕业学校
*/
private String school;
/**
* 性别
*/
private String sex = HrConstants.GENT;
/**
* 专业
*/
private String speciality;
/**
* 邮编
*/
private String zip;
/**
* 对应的User
*/
private User user = new User();
/**
* 对应的Dept
*/
private Dept dept;
/**
* 排序依据
*/
private Integer orderNo;
/**
* 对应的部门下的主管
*/
private Set<Dept> leaders = new HashSet<Dept>(0);
/**
* 对应的部门下的上级主管
*/
private Set<Dept> superior = new HashSet<Dept>(0);
/**
* 对应的部门下的上级分管领导
*/
private Set<Dept> subSuperior = new HashSet<Dept>(0);
/**
* 缺省构造
*/
public Employee() {
}
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "leader")
public Set<Dept> getLeaders() {
return leaders;
}
public void setLeaders(Set<Dept> leaders) {
this.leaders = leaders;
}
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "superior")
public Set<Dept> getSuperior() {
return superior;
}
public void setSuperior(Set<Dept> superior) {
this.superior = superior;
}
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "subSuperior")
public Set<Dept> getSubSuperior() {
return subSuperior;
}
public void setSubSuperior(Set<Dept> subSuperior) {
this.subSuperior = subSuperior;
}
@Column(name = "address")
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
@Column(name = "birthday")
public Date getBirthday() {
return this.birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
@Column(name = "credential_no")
public String getCredentialNo() {
return this.credentialNo;
}
public void setCredentialNo(String credentialNo) {
this.credentialNo = credentialNo;
}
@Column(name = "degrees")
public String getDegree() {
return this.degree;
}
public void setDegree(String degree) {
this.degree = degree;
}
@Column(name = "fax")
public String getFax() {
return this.fax;
}
public void setFax(String fax) {
this.fax = fax;
}
@Column(name = "folk")
public String getFolk() {
return this.folk;
}
public void setFolk(String folk) {
this.folk = folk;
}
@Column(name = "graduate_date")
public Date getGraduateDate() {
return this.graduateDate;
}
public void setGraduateDate(Date graduateDate) {
this.graduateDate = graduateDate;
}
@Column(name = "H_tel")
public String getHTel() {
return this.hTel;
}
public void setHTel(String hTel) {
this.hTel = hTel;
}
@Column(name = "job_date")
public Date getJobDate() {
return this.jobDate;
}
public void setJobDate(Date jobDate) {
this.jobDate = jobDate;
}
@Column(name = "married")
public String getMarried() {
return this.married;
}
public void setMarried(String married) {
this.married = married;
}
@Column(name = "mobil")
public String getMobil() {
return this.mobil;
}
public void setMobil(String mobil) {
this.mobil = mobil;
}
@Column(name = "msn")
public String getMsn() {
return this.msn;
}
public void setMsn(String msn) {
this.msn = msn;
}
@Column(name = "name")
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "photo")
public String getPhoto() {
return this.photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
@Column(name = "place")
public String getPlace() {
return this.place;
}
public void setPlace(String place) {
this.place = place;
}
@Column(name = "political")
public String getPolitical() {
return this.political;
}
public void setPolitical(String political) {
this.political = political;
}
@Column(name = "qq")
public String getQq() {
return this.qq;
}
public void setQq(String qq) {
this.qq = qq;
}
@Column(name = "registered_pos")
public String getRegisteredPos() {
return this.registeredPos;
}
public void setRegisteredPos(String registeredPos) {
this.registeredPos = registeredPos;
}
@Column(name = "school")
public String getSchool() {
return this.school;
}
public void setSchool(String school) {
this.school = school;
}
@Column(name = "sex")
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Column(name = "speciality")
public String getSpeciality() {
return this.speciality;
}
public void setSpeciality(String speciality) {
this.speciality = speciality;
}
@Column(name = "zip")
public String getZip() {
return this.zip;
}
public void setZip(String zip) {
this.zip = zip;
}
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
// @OneToOne(cascade = CascadeType.ALL)
// @JoinColumn(name="user_id")
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "dept_id")
public Dept getDept() {
return this.dept;
}
public void setDept(Dept dept) {
this.dept = dept;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Employee)) {
return false;
}
Employee castOther = (Employee) other;
return new EqualsBuilder().append(this.getId(), castOther.getId())
.isEquals();
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return new HashCodeBuilder().append(getId()).toHashCode();
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return new ToStringBuilder(this).append("id", getId()).toString();
}
public String getPoliceNo() {
return policeNo;
}
public void setPoliceNo(String policeNo) {
this.policeNo = policeNo;
}
@Column(name = "order_no")
public Integer getOrderNo() {
return orderNo;
}
public void setOrderNo(Integer orderNo) {
this.orderNo = orderNo;
}
}
|
[
"thinker.lonely@433d85af-394b-5fbc-b905-bae6433641f6"
] |
thinker.lonely@433d85af-394b-5fbc-b905-bae6433641f6
|
67020d8a45b17ca6791e8dad90316c211facc969
|
2178bf21c06fc8324b53095343f4dd9571dd87ea
|
/src/test/java/com/example/messagingservice/JpaRepositoryTests.java
|
896072d4802805ab55fe556a34ec21ae96020f03
|
[] |
no_license
|
dandgelb/messaging-service
|
3a38dcad315b27adf1d194a020e953afba8e8adb
|
f70e60b8379bd02b7376238e3e8ad0f36aec2c25
|
refs/heads/master
| 2020-03-19T02:34:25.266285 | 2018-06-08T16:36:20 | 2018-06-08T16:36:20 | 135,640,475 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 6,186 |
java
|
package com.example.messagingservice;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.junit4.SpringRunner;
import javax.persistence.EntityExistsException;
import javax.persistence.PersistenceException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.stream.LongStream;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@RunWith(SpringRunner.class)
@DataJpaTest
public class JpaRepositoryTests {
@Autowired
private TestEntityManager entityManager;
@Autowired
private UserRepository userRepository;
@Autowired
private ConnectionRepository connectionRepository;
public List<User> userEntitySeeder(){
List<User> userList = new ArrayList<>();
LongStream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.forEach(userId -> userList.add(new User(Long.valueOf(userId))));
return userList;
}
@Test
public void testUserCreateAndReadOperations() {
//given - no users
//when - tried to findAll
Integer total = userRepository.findAll().size();
//then - size = 0
assertThat(total).isEqualTo(0);
//given - one user created
entityManager.persist(userEntitySeeder().get(0));
entityManager.flush();
//when - findOne
User found = userRepository.findById(new Long(1)).get();
//then - it is the same user
assertThat(found.getId()).isEqualTo(1);
}
@Test(expected = NoSuchElementException.class)
public void testUserDeleteOperation() {
//given - two users created
List<User> users = userEntitySeeder();
entityManager.persist(users.get(0));
entityManager.persist(users.get(1));
//when - one user deleted
userRepository.delete(users.get(1));
User u2Found = userRepository.findById(Long.valueOf(2)).get();
}
@Test(expected = PersistenceException.class)
public void testConnectionCreationWithoutUserCreated() {
List<User> users = userEntitySeeder();
Connection connection = new Connection(new ConnectionId(users.get(0), users.get(1)));
entityManager.persist(connection);
entityManager.flush();
}
@Test
public void testConnectionCreateAndRead() {
List<User> users = userEntitySeeder();
//given - no connections
//when - tried to findAll
Integer total = connectionRepository.findAll().size();
//then - size = 0
assertThat(total).isEqualTo(0);
//given - at least two users created - connection could be created
entityManager.persist(users.get(0));
entityManager.persist(users.get(1));
entityManager.persist(users.get(2));
ConnectionId ci12 = new ConnectionId(users.get(0), users.get(1));
ConnectionId ci13 = new ConnectionId(users.get(0), users.get(2));
Connection c1 = new Connection(ci12);
Connection c2 = new Connection(ci13);
entityManager.persist(c1);
entityManager.persist(c2);
entityManager.flush();
//when - findOne
List<User> found = connectionRepository.findConnectionsByUserId(Long.valueOf(1));
//then - it is the same user
assertThat(found.size()).isEqualTo(2);
assertThat(found.get(0).getId()). isEqualTo(users.get(1).getId());
assertThat(found.get(1).getId()). isEqualTo(users.get(2).getId());
}
@Test(expected = EntityExistsException.class)
public void testDuplicateConnectionCreation() {
List<User> users = userEntitySeeder();
//given - at two users created - connection could be created
entityManager.persist(users.get(0));
entityManager.persist(users.get(1));
Connection c1 = new Connection(new ConnectionId(users.get(0), users.get(1)));
Connection c2 = new Connection(new ConnectionId(users.get(0), users.get(1)));
entityManager.persist(c1);
entityManager.flush();
entityManager.persist(c2);
entityManager.flush();
}
@Test
public void testMultipleConnectionForUser() {
//given - at two users created - connection could be created
List<User> users = userEntitySeeder();
entityManager.persist(users.get(0));
entityManager.persist(users.get(1));
entityManager.persist(users.get(2));
Connection c1 = new Connection(new ConnectionId(users.get(0), users.get(1)));
Connection c2 = new Connection(new ConnectionId(users.get(0), users.get(2)));
entityManager.persist(c1);
entityManager.flush();
entityManager.persist(c2);
entityManager.flush();
List<Connection> connections = connectionRepository.findAll();
assertThat(connections.size()).isEqualTo(2);
//TODO: No accessors in Connection
}
@Test
public void testConnectionDelete() {
//given - at two users created - connection could be created
List<User> users = userEntitySeeder();
entityManager.persist(users.get(0));
entityManager.persist(users.get(1));
entityManager.persist(users.get(2));
ConnectionId ci12 = new ConnectionId(users.get(0), users.get(1));
ConnectionId ci13 = new ConnectionId(users.get(0), users.get(2));
Connection c1 = new Connection(ci12);
Connection c2 = new Connection(ci13);
entityManager.persist(c1);
entityManager.persist(c2);
entityManager.flush();
//when - deleted and attempted to findOne
connectionRepository.delete(c1);
List<User> found = connectionRepository.findConnectionsByUserId(Long.valueOf(1));
//then - it is the same user
assertThat(found.size()).isEqualTo(1);
assertThat(found.get(0).getId()). isEqualTo(users.get(2).getId());
//TODO: Think better way of unit testing this
}
}
|
[
"[email protected]"
] | |
524b1d2fc7953fb363498aa19fd21ff9f1695e95
|
43c804162280aab11d713f820584cf05295ac91a
|
/src/main/java/org/gopivotal/app/web/controllers/FunctionAccessController.java
|
8311931418bd724e78a052e2885ad1dddd384f60
|
[] |
no_license
|
jxblum/gemfire-rest-api
|
b788f103259f19efffcdd693906e9b1b7b0dc717
|
aa72e2a590f2c589927f5a3dd061e7532bf79ff6
|
refs/heads/master
| 2021-01-20T04:03:03.057623 | 2016-07-30T00:10:22 | 2016-07-30T00:10:22 | 64,517,414 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 4,711 |
java
|
package org.gopivotal.app.web.controllers;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.gemstone.gemfire.cache.execute.Execution;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.FunctionService;
import com.gemstone.gemfire.cache.execute.ResultCollector;
import org.gopivotal.app.util.ArrayUtils;
import org.springframework.hateoas.Link;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
* The FunctionsController class...
* <p/>
* @author John Blum
* @see org.springframework.stereotype.Controller
* @since 7.5
*/
@Controller("functionController")
@RequestMapping(FunctionAccessController.REST_API_VERSION + "/functions")
@SuppressWarnings("unused")
public class FunctionAccessController extends AbstractBaseController {
// Constant String value indicating the version of the REST API.
protected static final String REST_API_VERSION = "/v2";
/**
* Gets the version of the REST API implemented by this @Controller.
* <p/>
* @return a String indicating the REST API version.
*/
@Override
protected String getRestApiVersion() {
return REST_API_VERSION;
}
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public Link[] list() {
logger.info("Listing all registered Functions in GemFire...");
final Map<String, Function> registeredFunctions = FunctionService.getRegisteredFunctions();
final List<Link> functionLinks = new ArrayList<Link>(registeredFunctions.size());
for (String functionId : registeredFunctions.keySet()) {
functionLinks.add(linkTo(getClass()).slash(functionId).withRel(functionId));
}
return functionLinks.toArray(new Link[functionLinks.size()]);
}
// TODO arguments are primitive, scalar values, probably Strings
// TODO I did not add support here for extracting an (JSON) array of complex arguments types (like Objects)
// TODO the return type is a Function dependent... may need to define some sort of convention restricting return types (like an Object[] of Objects convertible to JSON/XML)
@RequestMapping(method = RequestMethod.POST, value = "/{functionId}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public Object[] execute(@PathVariable("functionId") final String functionId,
@RequestParam("args") final Object[] arguments,
@RequestParam("onRegion") final String region,
@RequestParam("onMembers") final String[] members,
@RequestParam("onGroups") final String[] groups)
{
Execution function = null;
if (StringUtils.hasText(region)) {
logger.info(String.format("Executing Function (%1$s) with arguments (%2$s) on Region (%3$s)...", functionId,
ArrayUtils.toString(arguments), region));
function = FunctionService.onRegion(getRegion(region));
}
else if (ArrayUtils.isNotEmpty(members)) {
logger.info(String.format("Executing Function (%1$s) with arguments (%2$s) on Member (%3$s)...", functionId,
ArrayUtils.toString(arguments), ArrayUtils.toString(members)));
function = FunctionService.onMembers(getMembers(members));
}
else if (ArrayUtils.isNotEmpty(groups)) {
logger.info(String.format("Executing Function (%1$s) with arguments (%2$s) on Groups (%3$s)...", functionId,
ArrayUtils.toString(arguments), ArrayUtils.toString(groups)));
function = FunctionService.onMembers(groups);
}
else {
logger.info(String.format("Executing Function (%1$s) with arguments (%2$s) on all Members...", functionId,
ArrayUtils.toString(arguments)));
function = FunctionService.onMembers(getCache().getMembers());
}
final ResultCollector<?, ?> results = function.withArgs(arguments).execute(functionId);
final List<?> resultList = (List<?>) results.getResult();
return resultList.toArray();
}
}
|
[
"[email protected]"
] | |
4677d418d492ec612c4b073bd581cf98ef9e3d69
|
2c4b1622e6bd8e386d5725867038c0834ec46fd4
|
/src/com/concentriclivers/launcher/LauncherModel.java
|
2f5a3da5115176e596ebf03d64dcf7894a37741a
|
[
"Apache-2.0"
] |
permissive
|
Timmmm/Launcher2
|
833a96d5c62093ab3d679d5033306ba841e996e1
|
3b6e91609359c1f86dc5a6da79512f48e1dbbec8
|
refs/heads/master
| 2016-09-05T14:16:35.524414 | 2013-06-11T18:13:02 | 2013-06-11T18:13:02 | 10,627,580 | 2 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 94,504 |
java
|
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.concentriclivers.launcher;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import com.concentriclivers.launcher.R;
import com.concentriclivers.launcher.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
/**
* Maintains in-memory state of the Launcher. It is expected that there should be only one
* LauncherModel object held in a static. Also provide APIs for updating the database state
* for the Launcher.
*/
public class LauncherModel extends BroadcastReceiver {
static final boolean DEBUG_LOADERS = false;
static final String TAG = "Launcher.Model";
private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons
private final boolean mAppsCanBeOnExternalStorage;
private int mBatchSize; // 0 is all apps at once
private int mAllAppsLoadDelay; // milliseconds between batches
private final LauncherApplication mApp;
private final Object mLock = new Object();
private DeferredHandler mHandler = new DeferredHandler();
private LoaderTask mLoaderTask;
private static final HandlerThread sWorkerThread = new HandlerThread("launcher-loader");
static {
sWorkerThread.start();
}
private static final Handler sWorker = new Handler(sWorkerThread.getLooper());
// We start off with everything not loaded. After that, we assume that
// our monitoring of the package manager provides all updates and we never
// need to do a requery. These are only ever touched from the loader thread.
private boolean mWorkspaceLoaded;
private boolean mAllAppsLoaded;
private WeakReference<Callbacks> mCallbacks;
// < only access in worker thread >
private AllAppsList mAllAppsList;
// sItemsIdMap maps *all* the ItemInfos (shortcuts, folders, and widgets) created by
// LauncherModel to their ids
static final HashMap<Long, ItemInfo> sItemsIdMap = new HashMap<Long, ItemInfo>();
// sItems is passed to bindItems, which expects a list of all folders and shortcuts created by
// LauncherModel that are directly on the home screen (however, no widgets or shortcuts
// within folders).
static final ArrayList<ItemInfo> sWorkspaceItems = new ArrayList<ItemInfo>();
// sAppWidgets is all LauncherAppWidgetInfo created by LauncherModel. Passed to bindAppWidget()
static final ArrayList<LauncherAppWidgetInfo> sAppWidgets =
new ArrayList<LauncherAppWidgetInfo>();
// sFolders is all FolderInfos created by LauncherModel. Passed to bindFolders()
static final HashMap<Long, FolderInfo> sFolders = new HashMap<Long, FolderInfo>();
// sDbIconCache is the set of ItemInfos that need to have their icons updated in the database
static final HashMap<Object, byte[]> sDbIconCache = new HashMap<Object, byte[]>();
// </ only access in worker thread >
private IconCache mIconCache;
private Bitmap mDefaultIcon;
private static int mCellCountX;
private static int mCellCountY;
protected int mPreviousConfigMcc;
public interface Callbacks {
public boolean setLoadOnResume();
public int getCurrentWorkspaceScreen();
public void startBinding();
public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end);
public void bindFolders(HashMap<Long,FolderInfo> folders);
public void finishBindingItems();
public void bindAppWidget(LauncherAppWidgetInfo info);
public void bindAllApplications(ArrayList<ApplicationInfo> apps);
public void bindAppsAdded(ArrayList<ApplicationInfo> apps);
public void bindAppsUpdated(ArrayList<ApplicationInfo> apps);
public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
public boolean isAllAppsButtonRank(int rank);
public void bindSearchablesChanged();
}
LauncherModel(LauncherApplication app, IconCache iconCache) {
mAppsCanBeOnExternalStorage = !Environment.isExternalStorageEmulated();
mApp = app;
mAllAppsList = new AllAppsList(iconCache);
mIconCache = iconCache;
mDefaultIcon = Utilities.createIconBitmap(
mIconCache.getFullResDefaultActivityIcon(), app);
final Resources res = app.getResources();
mAllAppsLoadDelay = res.getInteger(R.integer.config_allAppsBatchLoadDelay);
mBatchSize = res.getInteger(R.integer.config_allAppsBatchSize);
Configuration config = res.getConfiguration();
mPreviousConfigMcc = config.mcc;
}
public Bitmap getFallbackIcon() {
return Bitmap.createBitmap(mDefaultIcon);
}
public void unbindWorkspaceItems() {
sWorker.post(new Runnable() {
@Override
public void run() {
unbindWorkspaceItemsOnMainThread();
}
});
}
/** Unbinds all the sWorkspaceItems on the main thread, and return a copy of sWorkspaceItems
* that is save to reference from the main thread. */
private ArrayList<ItemInfo> unbindWorkspaceItemsOnMainThread() {
// Ensure that we don't use the same workspace items data structure on the main thread
// by making a copy of workspace items first.
final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>(sWorkspaceItems);
final ArrayList<ItemInfo> appWidgets = new ArrayList<ItemInfo>(sAppWidgets);
mHandler.post(new Runnable() {
@Override
public void run() {
for (ItemInfo item : workspaceItems) {
item.unbind();
}
for (ItemInfo item : appWidgets) {
item.unbind();
}
}
});
return workspaceItems;
}
/**
* Adds an item to the DB if it was not created previously, or move it to a new
* <container, screen, cellX, cellY>
*/
static void addOrMoveItemInDatabase(Context context, ItemInfo item, long container,
int screen, int cellX, int cellY) {
if (item.container == ItemInfo.NO_ID) {
// From all apps
addItemToDatabase(context, item, container, screen, cellX, cellY, false);
} else {
// From somewhere else
moveItemInDatabase(context, item, container, screen, cellX, cellY);
}
}
static void updateItemInDatabaseHelper(Context context, final ContentValues values,
final ItemInfo item, final String callingFunction) {
final long itemId = item.id;
final Uri uri = LauncherSettings.Favorites.getContentUri(itemId, false);
final ContentResolver cr = context.getContentResolver();
Runnable r = new Runnable() {
public void run() {
cr.update(uri, values, null, null);
ItemInfo modelItem = sItemsIdMap.get(itemId);
if (item != modelItem) {
// the modelItem needs to match up perfectly with item if our model is to be
// consistent with the database-- for now, just require modelItem == item
String msg = "item: " + ((item != null) ? item.toString() : "null") +
"modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
"Error: ItemInfo passed to " + callingFunction + " doesn't match original";
throw new RuntimeException(msg);
}
// Items are added/removed from the corresponding FolderInfo elsewhere, such
// as in Workspace.onDrop. Here, we just add/remove them from the list of items
// that are on the desktop, as appropriate
if (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP ||
modelItem.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
if (!sWorkspaceItems.contains(modelItem)) {
sWorkspaceItems.add(modelItem);
}
} else {
sWorkspaceItems.remove(modelItem);
}
}
};
if (sWorkerThread.getThreadId() == Process.myTid()) {
r.run();
} else {
sWorker.post(r);
}
}
/**
* Move an item in the DB to a new <container, screen, cellX, cellY>
*/
static void moveItemInDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY) {
item.container = container;
item.cellX = cellX;
item.cellY = cellY;
// We store hotseat items in canonical form which is this orientation invariant position
// in the hotseat
if (context instanceof Launcher && screen < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
item.screen = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
} else {
item.screen = screen;
}
final ContentValues values = new ContentValues();
values.put(LauncherSettings.Favorites.CONTAINER, item.container);
values.put(LauncherSettings.Favorites.CELLX, item.cellX);
values.put(LauncherSettings.Favorites.CELLY, item.cellY);
values.put(LauncherSettings.Favorites.SCREEN, item.screen);
updateItemInDatabaseHelper(context, values, item, "moveItemInDatabase");
}
/**
* Move and/or resize item in the DB to a new <container, screen, cellX, cellY, spanX, spanY>
*/
static void modifyItemInDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY, final int spanX, final int spanY) {
item.container = container;
item.cellX = cellX;
item.cellY = cellY;
item.spanX = spanX;
item.spanY = spanY;
// We store hotseat items in canonical form which is this orientation invariant position
// in the hotseat
if (context instanceof Launcher && screen < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
item.screen = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
} else {
item.screen = screen;
}
final ContentValues values = new ContentValues();
values.put(LauncherSettings.Favorites.CONTAINER, item.container);
values.put(LauncherSettings.Favorites.CELLX, item.cellX);
values.put(LauncherSettings.Favorites.CELLY, item.cellY);
values.put(LauncherSettings.Favorites.SPANX, item.spanX);
values.put(LauncherSettings.Favorites.SPANY, item.spanY);
values.put(LauncherSettings.Favorites.SCREEN, item.screen);
updateItemInDatabaseHelper(context, values, item, "moveItemInDatabase");
}
/**
* Update an item to the database in a specified container.
*/
static void updateItemInDatabase(Context context, final ItemInfo item) {
final ContentValues values = new ContentValues();
item.onAddToDatabase(values);
item.updateValuesWithCoordinates(values, item.cellX, item.cellY);
updateItemInDatabaseHelper(context, values, item, "updateItemInDatabase");
}
/**
* Returns true if the shortcuts already exists in the database.
* we identify a shortcut by its title and intent.
*/
static boolean shortcutExists(Context context, String title, Intent intent) {
final ContentResolver cr = context.getContentResolver();
Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,
new String[] { "title", "intent" }, "title=? and intent=?",
new String[] { title, intent.toUri(0) }, null);
boolean result = false;
try {
result = c.moveToFirst();
} finally {
c.close();
}
return result;
}
/**
* Returns an ItemInfo array containing all the items in the LauncherModel.
* The ItemInfo.id is not set through this function.
*/
static ArrayList<ItemInfo> getItemsInLocalCoordinates(Context context) {
ArrayList<ItemInfo> items = new ArrayList<ItemInfo>();
final ContentResolver cr = context.getContentResolver();
Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, new String[] {
LauncherSettings.Favorites.ITEM_TYPE, LauncherSettings.Favorites.CONTAINER,
LauncherSettings.Favorites.SCREEN, LauncherSettings.Favorites.CELLX, LauncherSettings.Favorites.CELLY,
LauncherSettings.Favorites.SPANX, LauncherSettings.Favorites.SPANY }, null, null, null);
final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
final int spanXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANX);
final int spanYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANY);
try {
while (c.moveToNext()) {
ItemInfo item = new ItemInfo();
item.cellX = c.getInt(cellXIndex);
item.cellY = c.getInt(cellYIndex);
item.spanX = c.getInt(spanXIndex);
item.spanY = c.getInt(spanYIndex);
item.container = c.getInt(containerIndex);
item.itemType = c.getInt(itemTypeIndex);
item.screen = c.getInt(screenIndex);
items.add(item);
}
} catch (Exception e) {
items.clear();
} finally {
c.close();
}
return items;
}
/**
* Find a folder in the db, creating the FolderInfo if necessary, and adding it to folderList.
*/
FolderInfo getFolderById(Context context, HashMap<Long,FolderInfo> folderList, long id) {
final ContentResolver cr = context.getContentResolver();
Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, null,
"_id=? and (itemType=? or itemType=?)",
new String[] { String.valueOf(id),
String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)}, null);
try {
if (c.moveToFirst()) {
final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);
final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);
final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);
final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
FolderInfo folderInfo = null;
switch (c.getInt(itemTypeIndex)) {
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
folderInfo = findOrMakeFolder(folderList, id);
break;
}
folderInfo.title = c.getString(titleIndex);
folderInfo.id = id;
folderInfo.container = c.getInt(containerIndex);
folderInfo.screen = c.getInt(screenIndex);
folderInfo.cellX = c.getInt(cellXIndex);
folderInfo.cellY = c.getInt(cellYIndex);
return folderInfo;
}
} finally {
c.close();
}
return null;
}
/**
* Add an item to the database in a specified container. Sets the container, screen, cellX and
* cellY fields of the item. Also assigns an ID to the item.
*/
static void addItemToDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY, final boolean notify) {
item.container = container;
item.cellX = cellX;
item.cellY = cellY;
// We store hotseat items in canonical form which is this orientation invariant position
// in the hotseat
if (context instanceof Launcher && screen < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
item.screen = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
} else {
item.screen = screen;
}
final ContentValues values = new ContentValues();
final ContentResolver cr = context.getContentResolver();
item.onAddToDatabase(values);
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
item.id = app.getLauncherProvider().generateNewId();
values.put(LauncherSettings.Favorites._ID, item.id);
item.updateValuesWithCoordinates(values, item.cellX, item.cellY);
Runnable r = new Runnable() {
public void run() {
cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);
if (sItemsIdMap.containsKey(item.id)) {
// we should not be adding new items in the db with the same id
throw new RuntimeException("Error: ItemInfo id (" + item.id + ") passed to " +
"addItemToDatabase already exists." + item.toString());
}
sItemsIdMap.put(item.id, item);
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
sFolders.put(item.id, (FolderInfo) item);
// Fall through
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP ||
item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
sWorkspaceItems.add(item);
}
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
sAppWidgets.add((LauncherAppWidgetInfo) item);
break;
}
}
};
if (sWorkerThread.getThreadId() == Process.myTid()) {
r.run();
} else {
sWorker.post(r);
}
}
/**
* Creates a new unique child id, for a given cell span across all layouts.
*/
static int getCellLayoutChildId(
long container, int screen, int localCellX, int localCellY, int spanX, int spanY) {
return (((int) container & 0xFF) << 24)
| (screen & 0xFF) << 16 | (localCellX & 0xFF) << 8 | (localCellY & 0xFF);
}
static int getCellCountX() {
return mCellCountX;
}
static int getCellCountY() {
return mCellCountY;
}
/**
* Updates the model orientation helper to take into account the current layout dimensions
* when performing local/canonical coordinate transformations.
*/
static void updateWorkspaceLayoutCells(int shortAxisCellCount, int longAxisCellCount) {
mCellCountX = shortAxisCellCount;
mCellCountY = longAxisCellCount;
}
/**
* Removes the specified item from the database
* @param context
* @param item
*/
static void deleteItemFromDatabase(Context context, final ItemInfo item) {
final ContentResolver cr = context.getContentResolver();
final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false);
Runnable r = new Runnable() {
public void run() {
cr.delete(uriToDelete, null, null);
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
sFolders.remove(item.id);
sWorkspaceItems.remove(item);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
sWorkspaceItems.remove(item);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
sAppWidgets.remove((LauncherAppWidgetInfo) item);
break;
}
sItemsIdMap.remove(item.id);
sDbIconCache.remove(item);
}
};
if (sWorkerThread.getThreadId() == Process.myTid()) {
r.run();
} else {
sWorker.post(r);
}
}
/**
* Remove the contents of the specified folder from the database
*/
static void deleteFolderContentsFromDatabase(Context context, final FolderInfo info) {
final ContentResolver cr = context.getContentResolver();
Runnable r = new Runnable() {
public void run() {
cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null);
sItemsIdMap.remove(info.id);
sFolders.remove(info.id);
sDbIconCache.remove(info);
sWorkspaceItems.remove(info);
cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION,
LauncherSettings.Favorites.CONTAINER + "=" + info.id, null);
for (ItemInfo childInfo : info.contents) {
sItemsIdMap.remove(childInfo.id);
sDbIconCache.remove(childInfo);
}
}
};
if (sWorkerThread.getThreadId() == Process.myTid()) {
r.run();
} else {
sWorker.post(r);
}
}
/**
* Set this as the current Launcher activity object for the loader.
*/
public void initialize(Callbacks callbacks) {
synchronized (mLock) {
mCallbacks = new WeakReference<Callbacks>(callbacks);
}
}
// TDH: For below.
public final static String SearchManager_INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED
= "android.search.action.GLOBAL_SEARCH_ACTIVITY_CHANGED";
/**
* Call from the handler for ACTION_PACKAGE_ADDED, ACTION_PACKAGE_REMOVED and
* ACTION_PACKAGE_CHANGED.
*/
@Override
public void onReceive(Context context, Intent intent) {
if (DEBUG_LOADERS) Log.d(TAG, "onReceive intent=" + intent);
final String action = intent.getAction();
if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
|| Intent.ACTION_PACKAGE_REMOVED.equals(action)
|| Intent.ACTION_PACKAGE_ADDED.equals(action)) {
final String packageName = intent.getData().getSchemeSpecificPart();
final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
int op = PackageUpdatedTask.OP_NONE;
if (packageName == null || packageName.length() == 0) {
// they sent us a bad intent
return;
}
if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
op = PackageUpdatedTask.OP_UPDATE;
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
if (!replacing) {
op = PackageUpdatedTask.OP_REMOVE;
}
// else, we are replacing the package, so a PACKAGE_ADDED will be sent
// later, we will update the package at this time
} else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
if (!replacing) {
op = PackageUpdatedTask.OP_ADD;
} else {
op = PackageUpdatedTask.OP_UPDATE;
}
}
if (op != PackageUpdatedTask.OP_NONE) {
enqueuePackageUpdated(new PackageUpdatedTask(op, new String[] { packageName }));
}
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {
// First, schedule to add these apps back in.
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));
// Then, rebind everything.
startLoaderFromBackground();
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
enqueuePackageUpdated(new PackageUpdatedTask(
PackageUpdatedTask.OP_UNAVAILABLE, packages));
} else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
// If we have changed locale we need to clear out the labels in all apps/workspace.
forceReload();
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
// Check if configuration change was an mcc/mnc change which would affect app resources
// and we would need to clear out the labels in all apps/workspace. Same handling as
// above for ACTION_LOCALE_CHANGED
Configuration currentConfig = context.getResources().getConfiguration();
if (mPreviousConfigMcc != currentConfig.mcc) {
Log.d(TAG, "Reload apps on config change. curr_mcc:"
+ currentConfig.mcc + " prevmcc:" + mPreviousConfigMcc);
forceReload();
}
// Update previousConfig
mPreviousConfigMcc = currentConfig.mcc;
// TDH: . -> _
} else if (SearchManager_INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||
SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {
if (mCallbacks != null) {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
callbacks.bindSearchablesChanged();
}
}
}
}
private void forceReload() {
resetLoadedState(true, true);
// Do this here because if the launcher activity is running it will be restarted.
// If it's not running startLoaderFromBackground will merely tell it that it needs
// to reload.
startLoaderFromBackground();
}
public void resetLoadedState(boolean resetAllAppsLoaded, boolean resetWorkspaceLoaded) {
synchronized (mLock) {
// Stop any existing loaders first, so they don't set mAllAppsLoaded or
// mWorkspaceLoaded to true later
stopLoaderLocked();
if (resetAllAppsLoaded) mAllAppsLoaded = false;
if (resetWorkspaceLoaded) mWorkspaceLoaded = false;
}
}
/**
* When the launcher is in the background, it's possible for it to miss paired
* configuration changes. So whenever we trigger the loader from the background
* tell the launcher that it needs to re-run the loader when it comes back instead
* of doing it now.
*/
public void startLoaderFromBackground() {
boolean runLoader = false;
if (mCallbacks != null) {
Callbacks callbacks = mCallbacks.get();
if (callbacks != null) {
// Only actually run the loader if they're not paused.
if (!callbacks.setLoadOnResume()) {
runLoader = true;
}
}
}
if (runLoader) {
startLoader(false);
}
}
// If there is already a loader task running, tell it to stop.
// returns true if isLaunching() was true on the old task
private boolean stopLoaderLocked() {
boolean isLaunching = false;
LoaderTask oldTask = mLoaderTask;
if (oldTask != null) {
if (oldTask.isLaunching()) {
isLaunching = true;
}
oldTask.stopLocked();
}
return isLaunching;
}
public void startLoader(boolean isLaunching) {
synchronized (mLock) {
if (DEBUG_LOADERS) {
Log.d(TAG, "startLoader isLaunching=" + isLaunching);
}
// Don't bother to start the thread if we know it's not going to do anything
if (mCallbacks != null && mCallbacks.get() != null) {
// If there is already one running, tell it to stop.
// also, don't downgrade isLaunching if we're already running
isLaunching = isLaunching || stopLoaderLocked();
mLoaderTask = new LoaderTask(mApp, isLaunching);
sWorkerThread.setPriority(Thread.NORM_PRIORITY);
sWorker.post(mLoaderTask);
}
}
}
public void stopLoader() {
synchronized (mLock) {
if (mLoaderTask != null) {
mLoaderTask.stopLocked();
}
}
}
public boolean isAllAppsLoaded() {
return mAllAppsLoaded;
}
boolean isLoadingWorkspace() {
synchronized (mLock) {
if (mLoaderTask != null) {
return mLoaderTask.isLoadingWorkspace();
}
}
return false;
}
/**
* Runnable for the thread that loads the contents of the launcher:
* - workspace icons
* - widgets
* - all apps icons
*/
private class LoaderTask implements Runnable {
private Context mContext;
private Thread mWaitThread;
private boolean mIsLaunching;
private boolean mIsLoadingAndBindingWorkspace;
private boolean mStopped;
private boolean mLoadAndBindStepFinished;
private HashMap<Object, CharSequence> mLabelCache;
LoaderTask(Context context, boolean isLaunching) {
mContext = context;
mIsLaunching = isLaunching;
mLabelCache = new HashMap<Object, CharSequence>();
}
boolean isLaunching() {
return mIsLaunching;
}
boolean isLoadingWorkspace() {
return mIsLoadingAndBindingWorkspace;
}
private void loadAndBindWorkspace() {
mIsLoadingAndBindingWorkspace = true;
// Load the workspace
if (DEBUG_LOADERS) {
Log.d(TAG, "loadAndBindWorkspace mWorkspaceLoaded=" + mWorkspaceLoaded);
}
if (!mWorkspaceLoaded) {
loadWorkspace();
synchronized (LoaderTask.this) {
if (mStopped) {
return;
}
mWorkspaceLoaded = true;
}
}
// Bind the workspace
bindWorkspace();
}
private void waitForIdle() {
// Wait until the either we're stopped or the other threads are done.
// This way we don't start loading all apps until the workspace has settled
// down.
synchronized (LoaderTask.this) {
final long workspaceWaitTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
mHandler.postIdle(new Runnable() {
public void run() {
synchronized (LoaderTask.this) {
mLoadAndBindStepFinished = true;
if (DEBUG_LOADERS) {
Log.d(TAG, "done with previous binding step");
}
LoaderTask.this.notify();
}
}
});
while (!mStopped && !mLoadAndBindStepFinished) {
try {
this.wait();
} catch (InterruptedException ex) {
// Ignore
}
}
if (DEBUG_LOADERS) {
Log.d(TAG, "waited "
+ (SystemClock.uptimeMillis()-workspaceWaitTime)
+ "ms for previous step to finish binding");
}
}
}
public void run() {
// Optimize for end-user experience: if the Launcher is up and // running with the
// All Apps interface in the foreground, load All Apps first. Otherwise, load the
// workspace first (default).
final Callbacks cbk = mCallbacks.get();
final boolean loadWorkspaceFirst = cbk != null ? (!cbk.isAllAppsVisible()) : true;
keep_running: {
// Elevate priority when Home launches for the first time to avoid
// starving at boot time. Staring at a blank home is not cool.
synchronized (mLock) {
if (DEBUG_LOADERS) Log.d(TAG, "Setting thread priority to " +
(mIsLaunching ? "DEFAULT" : "BACKGROUND"));
android.os.Process.setThreadPriority(mIsLaunching
? Process.THREAD_PRIORITY_DEFAULT : Process.THREAD_PRIORITY_BACKGROUND);
}
if (loadWorkspaceFirst) {
if (DEBUG_LOADERS) Log.d(TAG, "step 1: loading workspace");
loadAndBindWorkspace();
} else {
if (DEBUG_LOADERS) Log.d(TAG, "step 1: special: loading all apps");
loadAndBindAllApps();
}
if (mStopped) {
break keep_running;
}
// Whew! Hard work done. Slow us down, and wait until the UI thread has
// settled down.
synchronized (mLock) {
if (mIsLaunching) {
if (DEBUG_LOADERS) Log.d(TAG, "Setting thread priority to BACKGROUND");
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
}
waitForIdle();
// second step
if (loadWorkspaceFirst) {
if (DEBUG_LOADERS) Log.d(TAG, "step 2: loading all apps");
loadAndBindAllApps();
} else {
if (DEBUG_LOADERS) Log.d(TAG, "step 2: special: loading workspace");
loadAndBindWorkspace();
}
// Restore the default thread priority after we are done loading items
synchronized (mLock) {
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
}
}
// Update the saved icons if necessary
if (DEBUG_LOADERS) Log.d(TAG, "Comparing loaded icons to database icons");
for (Object key : sDbIconCache.keySet()) {
updateSavedIcon(mContext, (ShortcutInfo) key, sDbIconCache.get(key));
}
sDbIconCache.clear();
// Clear out this reference, otherwise we end up holding it until all of the
// callback runnables are done.
mContext = null;
synchronized (mLock) {
// If we are still the last one to be scheduled, remove ourselves.
if (mLoaderTask == this) {
mLoaderTask = null;
}
}
}
public void stopLocked() {
synchronized (LoaderTask.this) {
mStopped = true;
this.notify();
}
}
/**
* Gets the callbacks object. If we've been stopped, or if the launcher object
* has somehow been garbage collected, return null instead. Pass in the Callbacks
* object that was around when the deferred message was scheduled, and if there's
* a new Callbacks object around then also return null. This will save us from
* calling onto it with data that will be ignored.
*/
Callbacks tryGetCallbacks(Callbacks oldCallbacks) {
synchronized (mLock) {
if (mStopped) {
return null;
}
if (mCallbacks == null) {
return null;
}
final Callbacks callbacks = mCallbacks.get();
if (callbacks != oldCallbacks) {
return null;
}
if (callbacks == null) {
Log.w(TAG, "no mCallbacks");
return null;
}
return callbacks;
}
}
// check & update map of what's occupied; used to discard overlapping/invalid items
private boolean checkItemPlacement(ItemInfo occupied[][][], ItemInfo item) {
int containerIndex = item.screen;
if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
// Return early if we detect that an item is under the hotseat button
if (mCallbacks == null || mCallbacks.get().isAllAppsButtonRank(item.screen)) {
return false;
}
// We use the last index to refer to the hotseat and the screen as the rank, so
// test and update the occupied state accordingly
if (occupied[Launcher.SCREEN_COUNT][item.screen][0] != null) {
Log.e(TAG, "Error loading shortcut into hotseat " + item
+ " into position (" + item.screen + ":" + item.cellX + "," + item.cellY
+ ") occupied by " + occupied[Launcher.SCREEN_COUNT][item.screen][0]);
return false;
} else {
occupied[Launcher.SCREEN_COUNT][item.screen][0] = item;
return true;
}
} else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
// Skip further checking if it is not the hotseat or workspace container
return true;
}
// Check if any workspace icons overlap with each other
for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {
for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {
if (occupied[containerIndex][x][y] != null) {
Log.e(TAG, "Error loading shortcut " + item
+ " into cell (" + containerIndex + "-" + item.screen + ":"
+ x + "," + y
+ ") occupied by "
+ occupied[containerIndex][x][y]);
return false;
}
}
}
for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {
for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {
occupied[containerIndex][x][y] = item;
}
}
return true;
}
private void loadWorkspace() {
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final Context context = mContext;
final ContentResolver contentResolver = context.getContentResolver();
final PackageManager manager = context.getPackageManager();
final AppWidgetManager widgets = AppWidgetManager.getInstance(context);
final boolean isSafeMode = manager.isSafeMode();
// Make sure the default workspace is loaded, if needed
mApp.getLauncherProvider().loadDefaultFavoritesIfNecessary();
sWorkspaceItems.clear();
sAppWidgets.clear();
sFolders.clear();
sItemsIdMap.clear();
sDbIconCache.clear();
final ArrayList<Long> itemsToRemove = new ArrayList<Long>();
final Cursor c = contentResolver.query(
LauncherSettings.Favorites.CONTENT_URI, null, null, null, null);
// +1 for the hotseat (it can be larger than the workspace)
// Load workspace in reverse order to ensure that latest items are loaded first (and
// before any earlier duplicates)
final ItemInfo occupied[][][] =
new ItemInfo[Launcher.SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1];
try {
final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
final int intentIndex = c.getColumnIndexOrThrow
(LauncherSettings.Favorites.INTENT);
final int titleIndex = c.getColumnIndexOrThrow
(LauncherSettings.Favorites.TITLE);
final int iconTypeIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.ICON_TYPE);
final int iconIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);
final int iconPackageIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.ICON_PACKAGE);
final int iconResourceIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.ICON_RESOURCE);
final int containerIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.CONTAINER);
final int itemTypeIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.ITEM_TYPE);
final int appWidgetIdIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.APPWIDGET_ID);
final int screenIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.SCREEN);
final int cellXIndex = c.getColumnIndexOrThrow
(LauncherSettings.Favorites.CELLX);
final int cellYIndex = c.getColumnIndexOrThrow
(LauncherSettings.Favorites.CELLY);
final int spanXIndex = c.getColumnIndexOrThrow
(LauncherSettings.Favorites.SPANX);
final int spanYIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.SPANY);
//final int uriIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.URI);
//final int displayModeIndex = c.getColumnIndexOrThrow(
// LauncherSettings.Favorites.DISPLAY_MODE);
ShortcutInfo info;
String intentDescription;
LauncherAppWidgetInfo appWidgetInfo;
int container;
long id;
Intent intent;
while (!mStopped && c.moveToNext()) {
try {
int itemType = c.getInt(itemTypeIndex);
switch (itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
intentDescription = c.getString(intentIndex);
try {
intent = Intent.parseUri(intentDescription, 0);
} catch (URISyntaxException e) {
continue;
}
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
info = getShortcutInfo(manager, intent, context, c, iconIndex,
titleIndex, mLabelCache);
} else {
info = getShortcutInfo(c, context, iconTypeIndex,
iconPackageIndex, iconResourceIndex, iconIndex,
titleIndex);
// App shortcuts that used to be automatically added to Launcher
// didn't always have the correct intent flags set, so do that here
if (intent.getAction() != null &&
intent.getCategories() != null &&
intent.getAction().equals(Intent.ACTION_MAIN) &&
intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
}
if (info != null) {
info.intent = intent;
info.id = c.getLong(idIndex);
container = c.getInt(containerIndex);
info.container = container;
info.screen = c.getInt(screenIndex);
info.cellX = c.getInt(cellXIndex);
info.cellY = c.getInt(cellYIndex);
// check & update map of what's occupied
if (!checkItemPlacement(occupied, info)) {
break;
}
switch (container) {
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
case LauncherSettings.Favorites.CONTAINER_HOTSEAT:
sWorkspaceItems.add(info);
break;
default:
// Item is in a user folder
FolderInfo folderInfo =
findOrMakeFolder(sFolders, container);
folderInfo.add(info);
break;
}
sItemsIdMap.put(info.id, info);
// now that we've loaded everthing re-save it with the
// icon in case it disappears somehow.
queueIconToBeChecked(sDbIconCache, info, c, iconIndex);
} else {
// Failed to load the shortcut, probably because the
// activity manager couldn't resolve it (maybe the app
// was uninstalled), or the db row was somehow screwed up.
// Delete it.
id = c.getLong(idIndex);
Log.e(TAG, "Error loading shortcut " + id + ", removing it");
contentResolver.delete(LauncherSettings.Favorites.getContentUri(
id, false), null, null);
}
break;
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
id = c.getLong(idIndex);
FolderInfo folderInfo = findOrMakeFolder(sFolders, id);
folderInfo.title = c.getString(titleIndex);
folderInfo.id = id;
container = c.getInt(containerIndex);
folderInfo.container = container;
folderInfo.screen = c.getInt(screenIndex);
folderInfo.cellX = c.getInt(cellXIndex);
folderInfo.cellY = c.getInt(cellYIndex);
// check & update map of what's occupied
if (!checkItemPlacement(occupied, folderInfo)) {
break;
}
switch (container) {
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
case LauncherSettings.Favorites.CONTAINER_HOTSEAT:
sWorkspaceItems.add(folderInfo);
break;
}
sItemsIdMap.put(folderInfo.id, folderInfo);
sFolders.put(folderInfo.id, folderInfo);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
// Read all Launcher-specific widget details
int appWidgetId = c.getInt(appWidgetIdIndex);
id = c.getLong(idIndex);
final AppWidgetProviderInfo provider =
widgets.getAppWidgetInfo(appWidgetId);
if (!isSafeMode && (provider == null || provider.provider == null ||
provider.provider.getPackageName() == null)) {
String log = "Deleting widget that isn't installed anymore: id="
+ id + " appWidgetId=" + appWidgetId;
Log.e(TAG, log);
Launcher.sDumpLogs.add(log);
itemsToRemove.add(id);
} else {
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
provider.provider);
appWidgetInfo.id = id;
appWidgetInfo.screen = c.getInt(screenIndex);
appWidgetInfo.cellX = c.getInt(cellXIndex);
appWidgetInfo.cellY = c.getInt(cellYIndex);
appWidgetInfo.spanX = c.getInt(spanXIndex);
appWidgetInfo.spanY = c.getInt(spanYIndex);
int[] minSpan = Launcher.getMinSpanForWidget(context, provider);
appWidgetInfo.minSpanX = minSpan[0];
appWidgetInfo.minSpanY = minSpan[1];
container = c.getInt(containerIndex);
if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP &&
container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
Log.e(TAG, "Widget found where container "
+ "!= CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!");
continue;
}
appWidgetInfo.container = c.getInt(containerIndex);
// check & update map of what's occupied
if (!checkItemPlacement(occupied, appWidgetInfo)) {
break;
}
sItemsIdMap.put(appWidgetInfo.id, appWidgetInfo);
sAppWidgets.add(appWidgetInfo);
}
break;
}
} catch (Exception e) {
Log.w(TAG, "Desktop items loading interrupted:", e);
}
}
} finally {
c.close();
}
if (itemsToRemove.size() > 0) {
ContentProviderClient client = contentResolver.acquireContentProviderClient(
LauncherSettings.Favorites.CONTENT_URI);
// Remove dead items
for (long id : itemsToRemove) {
if (DEBUG_LOADERS) {
Log.d(TAG, "Removed id = " + id);
}
// Don't notify content observers
try {
client.delete(LauncherSettings.Favorites.getContentUri(id, false),
null, null);
} catch (RemoteException e) {
Log.w(TAG, "Could not remove id = " + id);
}
}
}
if (DEBUG_LOADERS) {
Log.d(TAG, "loaded workspace in " + (SystemClock.uptimeMillis()-t) + "ms");
Log.d(TAG, "workspace layout: ");
for (int y = 0; y < mCellCountY; y++) {
String line = "";
for (int s = 0; s < Launcher.SCREEN_COUNT; s++) {
if (s > 0) {
line += " | ";
}
for (int x = 0; x < mCellCountX; x++) {
line += ((occupied[s][x][y] != null) ? "#" : ".");
}
}
Log.d(TAG, "[ " + line + " ]");
}
}
}
/**
* Read everything out of our database.
*/
private void bindWorkspace() {
final long t = SystemClock.uptimeMillis();
// Don't use these two variables in any of the callback runnables.
// Otherwise we hold a reference to them.
final Callbacks oldCallbacks = mCallbacks.get();
if (oldCallbacks == null) {
// This launcher has exited and nobody bothered to tell us. Just bail.
Log.w(TAG, "LoaderTask running with no launcher");
return;
}
// Get the list of workspace items to load and unbind the existing ShortcutInfos
// before we call startBinding() below.
final int currentScreen = oldCallbacks.getCurrentWorkspaceScreen();
final ArrayList<ItemInfo> tmpWorkspaceItems = unbindWorkspaceItemsOnMainThread();
// Order the items for loading as follows: current workspace, hotseat, everything else
Collections.sort(tmpWorkspaceItems, new Comparator<ItemInfo>() {
@Override
public int compare(ItemInfo lhs, ItemInfo rhs) {
int cellCountX = LauncherModel.getCellCountX();
int cellCountY = LauncherModel.getCellCountY();
int screenOffset = cellCountX * cellCountY;
int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); // +1 hotseat
long lr = (lhs.container * containerOffset + lhs.screen * screenOffset +
lhs.cellY * cellCountX + lhs.cellX);
long rr = (rhs.container * containerOffset + rhs.screen * screenOffset +
rhs.cellY * cellCountX + rhs.cellX);
return (int) (lr - rr);
}
});
// Precondition: the items are ordered by page, screen
final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();
for (ItemInfo ii : tmpWorkspaceItems) {
// Prepend the current items, hotseat items, append everything else
if (ii.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
ii.screen == currentScreen) {
workspaceItems.add(0, ii);
} else if (ii.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
workspaceItems.add(0, ii);
} else {
workspaceItems.add(ii);
}
}
// Tell the workspace that we're about to start firing items at it
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.startBinding();
}
}
});
// Add the items to the workspace.
int N = workspaceItems.size();
for (int i=0; i<N; i+=ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindItems(workspaceItems, start, start+chunkSize);
}
}
});
}
// Ensure that we don't use the same folders data structure on the main thread
final HashMap<Long, FolderInfo> folders = new HashMap<Long, FolderInfo>(sFolders);
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindFolders(folders);
}
}
});
// Wait until the queue goes empty.
mHandler.post(new Runnable() {
public void run() {
if (DEBUG_LOADERS) {
Log.d(TAG, "Going to start binding widgets soon.");
}
}
});
// Bind the widgets, one at a time.
// WARNING: this is calling into the workspace from the background thread,
// but since getCurrentScreen() just returns the int, we should be okay. This
// is just a hint for the order, and if it's wrong, we'll be okay.
// TODO: instead, we should have that push the current screen into here.
N = sAppWidgets.size();
// once for the current screen
for (int i=0; i<N; i++) {
final LauncherAppWidgetInfo widget = sAppWidgets.get(i);
if (widget.screen == currentScreen) {
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindAppWidget(widget);
}
}
});
}
}
// once for the other screens
for (int i=0; i<N; i++) {
final LauncherAppWidgetInfo widget = sAppWidgets.get(i);
if (widget.screen != currentScreen) {
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindAppWidget(widget);
}
}
});
}
}
// Tell the workspace that we're done.
mHandler.post(new Runnable() {
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.finishBindingItems();
}
}
});
// Cleanup
mHandler.post(new Runnable() {
public void run() {
// If we're profiling, ensure this is the last thing in the queue.
if (DEBUG_LOADERS) {
Log.d(TAG, "bound workspace in "
+ (SystemClock.uptimeMillis()-t) + "ms");
}
mIsLoadingAndBindingWorkspace = false;
}
});
}
private void loadAndBindAllApps() {
if (DEBUG_LOADERS) {
Log.d(TAG, "loadAndBindAllApps mAllAppsLoaded=" + mAllAppsLoaded);
}
if (!mAllAppsLoaded) {
loadAllAppsByBatch();
synchronized (LoaderTask.this) {
if (mStopped) {
return;
}
mAllAppsLoaded = true;
}
} else {
onlyBindAllApps();
}
}
private void onlyBindAllApps() {
final Callbacks oldCallbacks = mCallbacks.get();
if (oldCallbacks == null) {
// This launcher has exited and nobody bothered to tell us. Just bail.
Log.w(TAG, "LoaderTask running with no launcher (onlyBindAllApps)");
return;
}
// shallow copy
@SuppressWarnings("unchecked")
final ArrayList<ApplicationInfo> list
= (ArrayList<ApplicationInfo>) mAllAppsList.data.clone();
mHandler.post(new Runnable() {
public void run() {
final long t = SystemClock.uptimeMillis();
final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
callbacks.bindAllApplications(list);
}
if (DEBUG_LOADERS) {
Log.d(TAG, "bound all " + list.size() + " apps from cache in "
+ (SystemClock.uptimeMillis()-t) + "ms");
}
}
});
}
private void loadAllAppsByBatch() {
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
// Don't use these two variables in any of the callback runnables.
// Otherwise we hold a reference to them.
final Callbacks oldCallbacks = mCallbacks.get();
if (oldCallbacks == null) {
// This launcher has exited and nobody bothered to tell us. Just bail.
Log.w(TAG, "LoaderTask running with no launcher (loadAllAppsByBatch)");
return;
}
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final PackageManager packageManager = mContext.getPackageManager();
List<ResolveInfo> apps = null;
int N = Integer.MAX_VALUE;
int startIndex;
int i=0;
int batchSize = -1;
while (i < N && !mStopped) {
if (i == 0) {
mAllAppsList.clear();
final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
apps = packageManager.queryIntentActivities(mainIntent, 0);
if (DEBUG_LOADERS) {
Log.d(TAG, "queryIntentActivities took "
+ (SystemClock.uptimeMillis()-qiaTime) + "ms");
}
if (apps == null) {
return;
}
N = apps.size();
if (DEBUG_LOADERS) {
Log.d(TAG, "queryIntentActivities got " + N + " apps");
}
if (N == 0) {
// There are no apps?!?
return;
}
if (mBatchSize == 0) {
batchSize = N;
} else {
batchSize = mBatchSize;
}
final long sortTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
Collections.sort(apps,
new LauncherModel.ShortcutNameComparator(packageManager, mLabelCache));
if (DEBUG_LOADERS) {
Log.d(TAG, "sort took "
+ (SystemClock.uptimeMillis()-sortTime) + "ms");
}
}
final long t2 = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
startIndex = i;
for (int j=0; i<N && j<batchSize; j++) {
// This builds the icon bitmaps.
mAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i),
mIconCache, mLabelCache));
i++;
}
final boolean first = i <= batchSize;
final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
final ArrayList<ApplicationInfo> added = mAllAppsList.added;
mAllAppsList.added = new ArrayList<ApplicationInfo>();
mHandler.post(new Runnable() {
public void run() {
final long t = SystemClock.uptimeMillis();
if (callbacks != null) {
if (first) {
callbacks.bindAllApplications(added);
} else {
callbacks.bindAppsAdded(added);
}
if (DEBUG_LOADERS) {
Log.d(TAG, "bound " + added.size() + " apps in "
+ (SystemClock.uptimeMillis() - t) + "ms");
}
} else {
Log.i(TAG, "not binding apps: no Launcher activity");
}
}
});
if (DEBUG_LOADERS) {
Log.d(TAG, "batch of " + (i-startIndex) + " icons processed in "
+ (SystemClock.uptimeMillis()-t2) + "ms");
}
if (mAllAppsLoadDelay > 0 && i < N) {
try {
if (DEBUG_LOADERS) {
Log.d(TAG, "sleeping for " + mAllAppsLoadDelay + "ms");
}
Thread.sleep(mAllAppsLoadDelay);
} catch (InterruptedException exc) { }
}
}
if (DEBUG_LOADERS) {
Log.d(TAG, "cached all " + N + " apps in "
+ (SystemClock.uptimeMillis()-t) + "ms"
+ (mAllAppsLoadDelay > 0 ? " (including delay)" : ""));
}
}
public void dumpState() {
Log.d(TAG, "mLoaderTask.mContext=" + mContext);
Log.d(TAG, "mLoaderTask.mWaitThread=" + mWaitThread);
Log.d(TAG, "mLoaderTask.mIsLaunching=" + mIsLaunching);
Log.d(TAG, "mLoaderTask.mStopped=" + mStopped);
Log.d(TAG, "mLoaderTask.mLoadAndBindStepFinished=" + mLoadAndBindStepFinished);
Log.d(TAG, "mItems size=" + sWorkspaceItems.size());
}
}
void enqueuePackageUpdated(PackageUpdatedTask task) {
sWorker.post(task);
}
private class PackageUpdatedTask implements Runnable {
int mOp;
String[] mPackages;
public static final int OP_NONE = 0;
public static final int OP_ADD = 1;
public static final int OP_UPDATE = 2;
public static final int OP_REMOVE = 3; // uninstlled
public static final int OP_UNAVAILABLE = 4; // external media unmounted
public PackageUpdatedTask(int op, String[] packages) {
mOp = op;
mPackages = packages;
}
public void run() {
final Context context = mApp;
final String[] packages = mPackages;
final int N = packages.length;
switch (mOp) {
case OP_ADD:
for (int i=0; i<N; i++) {
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);
mAllAppsList.addPackage(context, packages[i]);
}
break;
case OP_UPDATE:
for (int i=0; i<N; i++) {
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.updatePackage " + packages[i]);
mAllAppsList.updatePackage(context, packages[i]);
}
break;
case OP_REMOVE:
case OP_UNAVAILABLE:
for (int i=0; i<N; i++) {
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.removePackage " + packages[i]);
mAllAppsList.removePackage(packages[i]);
}
break;
}
ArrayList<ApplicationInfo> added = null;
ArrayList<ApplicationInfo> removed = null;
ArrayList<ApplicationInfo> modified = null;
if (mAllAppsList.added.size() > 0) {
added = mAllAppsList.added;
mAllAppsList.added = new ArrayList<ApplicationInfo>();
}
if (mAllAppsList.removed.size() > 0) {
removed = mAllAppsList.removed;
mAllAppsList.removed = new ArrayList<ApplicationInfo>();
for (ApplicationInfo info: removed) {
mIconCache.remove(info.intent.getComponent());
}
}
if (mAllAppsList.modified.size() > 0) {
modified = mAllAppsList.modified;
mAllAppsList.modified = new ArrayList<ApplicationInfo>();
}
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == null) {
Log.w(TAG, "Nobody to tell about the new app. Launcher is probably loading.");
return;
}
if (added != null) {
final ArrayList<ApplicationInfo> addedFinal = added;
mHandler.post(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
callbacks.bindAppsAdded(addedFinal);
}
}
});
}
if (modified != null) {
final ArrayList<ApplicationInfo> modifiedFinal = modified;
mHandler.post(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
callbacks.bindAppsUpdated(modifiedFinal);
}
}
});
}
if (removed != null) {
final boolean permanent = mOp != OP_UNAVAILABLE;
final ArrayList<ApplicationInfo> removedFinal = removed;
mHandler.post(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
callbacks.bindAppsRemoved(removedFinal, permanent);
}
}
});
}
mHandler.post(new Runnable() {
@Override
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
callbacks.bindPackagesUpdated();
}
}
});
}
}
/**
* Returns all the Workspace ShortcutInfos associated with a particular package.
* @param intent
* @return
*/
ArrayList<ShortcutInfo> getShortcutInfosForPackage(String packageName) {
ArrayList<ShortcutInfo> infos = new ArrayList<ShortcutInfo>();
for (ItemInfo i : sWorkspaceItems) {
if (i instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) i;
if (packageName.equals(info.getPackageName())) {
infos.add(info);
}
}
}
return infos;
}
/**
* This is called from the code that adds shortcuts from the intent receiver. This
* doesn't have a Cursor, but
*/
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context) {
return getShortcutInfo(manager, intent, context, null, -1, -1, null);
}
/**
* Make an ShortcutInfo object for a shortcut that is an application.
*
* If c is not null, then it will be used to fill in missing data like the title and icon.
*/
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context,
Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) {
Bitmap icon = null;
final ShortcutInfo info = new ShortcutInfo();
ComponentName componentName = intent.getComponent();
if (componentName == null) {
return null;
}
try {
PackageInfo pi = manager.getPackageInfo(componentName.getPackageName(), 0);
if (!pi.applicationInfo.enabled) {
// If we return null here, the corresponding item will be removed from the launcher
// db and will not appear in the workspace.
return null;
}
} catch (NameNotFoundException e) {
Log.d(TAG, "getPackInfo failed for package " + componentName.getPackageName());
}
// TODO: See if the PackageManager knows about this case. If it doesn't
// then return null & delete this.
// the resource -- This may implicitly give us back the fallback icon,
// but don't worry about that. All we're doing with usingFallbackIcon is
// to avoid saving lots of copies of that in the database, and most apps
// have icons anyway.
// Attempt to use queryIntentActivities to get the ResolveInfo (with IntentFilter info) and
// if that fails, or is ambiguious, fallback to the standard way of getting the resolve info
// via resolveActivity().
ResolveInfo resolveInfo = null;
ComponentName oldComponent = intent.getComponent();
Intent newIntent = new Intent(intent.getAction(), null);
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
newIntent.setPackage(oldComponent.getPackageName());
List<ResolveInfo> infos = manager.queryIntentActivities(newIntent, 0);
for (ResolveInfo i : infos) {
ComponentName cn = new ComponentName(i.activityInfo.packageName,
i.activityInfo.name);
if (cn.equals(oldComponent)) {
resolveInfo = i;
}
}
if (resolveInfo == null) {
resolveInfo = manager.resolveActivity(intent, 0);
}
if (resolveInfo != null) {
icon = mIconCache.getIcon(componentName, resolveInfo, labelCache);
}
// the db
if (icon == null) {
if (c != null) {
icon = getIconFromCursor(c, iconIndex, context);
}
}
// the fallback icon
if (icon == null) {
icon = getFallbackIcon();
info.usingFallbackIcon = true;
}
info.setIcon(icon);
// from the resource
if (resolveInfo != null) {
ComponentName key = LauncherModel.getComponentNameFromResolveInfo(resolveInfo);
if (labelCache != null && labelCache.containsKey(key)) {
info.title = labelCache.get(key);
} else {
info.title = resolveInfo.activityInfo.loadLabel(manager);
if (labelCache != null) {
labelCache.put(key, info.title);
}
}
}
// from the db
if (info.title == null) {
if (c != null) {
info.title = c.getString(titleIndex);
}
}
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
}
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
return info;
}
/**
* Make an ShortcutInfo object for a shortcut that isn't an application.
*/
private ShortcutInfo getShortcutInfo(Cursor c, Context context,
int iconTypeIndex, int iconPackageIndex, int iconResourceIndex, int iconIndex,
int titleIndex) {
Bitmap icon = null;
final ShortcutInfo info = new ShortcutInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
// TODO: If there's an explicit component and we can't install that, delete it.
info.title = c.getString(titleIndex);
int iconType = c.getInt(iconTypeIndex);
switch (iconType) {
case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:
String packageName = c.getString(iconPackageIndex);
String resourceName = c.getString(iconResourceIndex);
PackageManager packageManager = context.getPackageManager();
info.customIcon = false;
// the resource
try {
Resources resources = packageManager.getResourcesForApplication(packageName);
if (resources != null) {
final int id = resources.getIdentifier(resourceName, null, null);
icon = Utilities.createIconBitmap(
mIconCache.getFullResIcon(resources, id), context);
}
} catch (Exception e) {
// drop this. we have other places to look for icons
}
// the db
if (icon == null) {
icon = getIconFromCursor(c, iconIndex, context);
}
// the fallback icon
if (icon == null) {
icon = getFallbackIcon();
info.usingFallbackIcon = true;
}
break;
case LauncherSettings.Favorites.ICON_TYPE_BITMAP:
icon = getIconFromCursor(c, iconIndex, context);
if (icon == null) {
icon = getFallbackIcon();
info.customIcon = false;
info.usingFallbackIcon = true;
} else {
info.customIcon = true;
}
break;
default:
icon = getFallbackIcon();
info.usingFallbackIcon = true;
info.customIcon = false;
break;
}
info.setIcon(icon);
return info;
}
Bitmap getIconFromCursor(Cursor c, int iconIndex, Context context) {
@SuppressWarnings("all") // suppress dead code warning
final boolean debug = false;
if (debug) {
Log.d(TAG, "getIconFromCursor app="
+ c.getString(c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE)));
}
byte[] data = c.getBlob(iconIndex);
try {
return Utilities.createIconBitmap(
BitmapFactory.decodeByteArray(data, 0, data.length), context);
} catch (Exception e) {
return null;
}
}
ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,
int cellX, int cellY, boolean notify) {
final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
if (info == null) {
return null;
}
addItemToDatabase(context, info, container, screen, cellX, cellY, notify);
return info;
}
/**
* Attempts to find an AppWidgetProviderInfo that matches the given component.
*/
AppWidgetProviderInfo findAppWidgetProviderInfoWithComponent(Context context,
ComponentName component) {
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(context).getInstalledProviders();
for (AppWidgetProviderInfo info : widgets) {
if (info.provider.equals(component)) {
return info;
}
}
return null;
}
/**
* Returns a list of all the widgets that can handle configuration with a particular mimeType.
*/
List<WidgetMimeTypeHandlerData> resolveWidgetsForMimeType(Context context, String mimeType) {
final PackageManager packageManager = context.getPackageManager();
final List<WidgetMimeTypeHandlerData> supportedConfigurationActivities =
new ArrayList<WidgetMimeTypeHandlerData>();
final Intent supportsIntent =
new Intent(InstallWidgetReceiver.ACTION_SUPPORTS_CLIPDATA_MIMETYPE);
supportsIntent.setType(mimeType);
// Create a set of widget configuration components that we can test against
final List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(context).getInstalledProviders();
final HashMap<ComponentName, AppWidgetProviderInfo> configurationComponentToWidget =
new HashMap<ComponentName, AppWidgetProviderInfo>();
for (AppWidgetProviderInfo info : widgets) {
configurationComponentToWidget.put(info.configure, info);
}
// Run through each of the intents that can handle this type of clip data, and cross
// reference them with the components that are actual configuration components
final List<ResolveInfo> activities = packageManager.queryIntentActivities(supportsIntent,
PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo info : activities) {
final ActivityInfo activityInfo = info.activityInfo;
final ComponentName infoComponent = new ComponentName(activityInfo.packageName,
activityInfo.name);
if (configurationComponentToWidget.containsKey(infoComponent)) {
supportedConfigurationActivities.add(
new InstallWidgetReceiver.WidgetMimeTypeHandlerData(info,
configurationComponentToWidget.get(infoComponent)));
}
}
return supportedConfigurationActivities;
}
ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
if (intent == null) {
// If the intent is null, we can't construct a valid ShortcutInfo, so we return null
Log.e(TAG, "Can't construct ShorcutInfo with null intent");
return null;
}
Bitmap icon = null;
boolean customIcon = false;
ShortcutIconResource iconResource = null;
if (bitmap != null && bitmap instanceof Bitmap) {
icon = Utilities.createIconBitmap(new FastBitmapDrawable((Bitmap)bitmap), context);
customIcon = true;
} else {
Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (extra != null && extra instanceof ShortcutIconResource) {
try {
iconResource = (ShortcutIconResource) extra;
final PackageManager packageManager = context.getPackageManager();
Resources resources = packageManager.getResourcesForApplication(
iconResource.packageName);
final int id = resources.getIdentifier(iconResource.resourceName, null, null);
icon = Utilities.createIconBitmap(
mIconCache.getFullResIcon(resources, id), context);
} catch (Exception e) {
Log.w(TAG, "Could not load shortcut icon: " + extra);
}
}
}
final ShortcutInfo info = new ShortcutInfo();
if (icon == null) {
if (fallbackIcon != null) {
icon = fallbackIcon;
} else {
icon = getFallbackIcon();
info.usingFallbackIcon = true;
}
}
info.setIcon(icon);
info.title = name;
info.intent = intent;
info.customIcon = customIcon;
info.iconResource = iconResource;
return info;
}
boolean queueIconToBeChecked(HashMap<Object, byte[]> cache, ShortcutInfo info, Cursor c,
int iconIndex) {
// If apps can't be on SD, don't even bother.
if (!mAppsCanBeOnExternalStorage) {
return false;
}
// If this icon doesn't have a custom icon, check to see
// what's stored in the DB, and if it doesn't match what
// we're going to show, store what we are going to show back
// into the DB. We do this so when we're loading, if the
// package manager can't find an icon (for example because
// the app is on SD) then we can use that instead.
if (!info.customIcon && !info.usingFallbackIcon) {
cache.put(info, c.getBlob(iconIndex));
return true;
}
return false;
}
void updateSavedIcon(Context context, ShortcutInfo info, byte[] data) {
boolean needSave = false;
try {
if (data != null) {
Bitmap saved = BitmapFactory.decodeByteArray(data, 0, data.length);
Bitmap loaded = info.getIcon(mIconCache);
needSave = !saved.sameAs(loaded);
} else {
needSave = true;
}
} catch (Exception e) {
needSave = true;
}
if (needSave) {
Log.d(TAG, "going to save icon bitmap for info=" + info);
// This is slower than is ideal, but this only happens once
// or when the app is updated with a new icon.
updateItemInDatabase(context, info);
}
}
/**
* Return an existing FolderInfo object if we have encountered this ID previously,
* or make a new one.
*/
private static FolderInfo findOrMakeFolder(HashMap<Long, FolderInfo> folders, long id) {
// See if a placeholder was created for us already
FolderInfo folderInfo = folders.get(id);
if (folderInfo == null) {
// No placeholder -- create a new instance
folderInfo = new FolderInfo();
folders.put(id, folderInfo);
}
return folderInfo;
}
private static final Collator sCollator = Collator.getInstance();
public static final Comparator<ApplicationInfo> APP_NAME_COMPARATOR
= new Comparator<ApplicationInfo>() {
public final int compare(ApplicationInfo a, ApplicationInfo b) {
int result = sCollator.compare(a.title.toString(), b.title.toString());
if (result == 0) {
result = a.componentName.compareTo(b.componentName);
}
return result;
}
};
public static final Comparator<ApplicationInfo> APP_INSTALL_TIME_COMPARATOR
= new Comparator<ApplicationInfo>() {
public final int compare(ApplicationInfo a, ApplicationInfo b) {
if (a.firstInstallTime < b.firstInstallTime) return 1;
if (a.firstInstallTime > b.firstInstallTime) return -1;
return 0;
}
};
public static final Comparator<AppWidgetProviderInfo> WIDGET_NAME_COMPARATOR
= new Comparator<AppWidgetProviderInfo>() {
public final int compare(AppWidgetProviderInfo a, AppWidgetProviderInfo b) {
return sCollator.compare(a.label.toString(), b.label.toString());
}
};
static ComponentName getComponentNameFromResolveInfo(ResolveInfo info) {
if (info.activityInfo != null) {
return new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
} else {
return new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name);
}
}
public static class ShortcutNameComparator implements Comparator<ResolveInfo> {
private PackageManager mPackageManager;
private HashMap<Object, CharSequence> mLabelCache;
ShortcutNameComparator(PackageManager pm) {
mPackageManager = pm;
mLabelCache = new HashMap<Object, CharSequence>();
}
ShortcutNameComparator(PackageManager pm, HashMap<Object, CharSequence> labelCache) {
mPackageManager = pm;
mLabelCache = labelCache;
}
public final int compare(ResolveInfo a, ResolveInfo b) {
CharSequence labelA, labelB;
ComponentName keyA = LauncherModel.getComponentNameFromResolveInfo(a);
ComponentName keyB = LauncherModel.getComponentNameFromResolveInfo(b);
if (mLabelCache.containsKey(keyA)) {
labelA = mLabelCache.get(keyA);
} else {
labelA = a.loadLabel(mPackageManager).toString();
mLabelCache.put(keyA, labelA);
}
if (mLabelCache.containsKey(keyB)) {
labelB = mLabelCache.get(keyB);
} else {
labelB = b.loadLabel(mPackageManager).toString();
mLabelCache.put(keyB, labelB);
}
return sCollator.compare(labelA, labelB);
}
};
public static class WidgetAndShortcutNameComparator implements Comparator<Object> {
private PackageManager mPackageManager;
private HashMap<Object, String> mLabelCache;
WidgetAndShortcutNameComparator(PackageManager pm) {
mPackageManager = pm;
mLabelCache = new HashMap<Object, String>();
}
public final int compare(Object a, Object b) {
String labelA, labelB;
if (mLabelCache.containsKey(a)) {
labelA = mLabelCache.get(a);
} else {
labelA = (a instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) a).label :
((ResolveInfo) a).loadLabel(mPackageManager).toString();
mLabelCache.put(a, labelA);
}
if (mLabelCache.containsKey(b)) {
labelB = mLabelCache.get(b);
} else {
labelB = (b instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) b).label :
((ResolveInfo) b).loadLabel(mPackageManager).toString();
mLabelCache.put(b, labelB);
}
return sCollator.compare(labelA, labelB);
}
};
public void dumpState() {
Log.d(TAG, "mCallbacks=" + mCallbacks);
ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList.data", mAllAppsList.data);
ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList.added", mAllAppsList.added);
ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList.removed", mAllAppsList.removed);
ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList.modified", mAllAppsList.modified);
if (mLoaderTask != null) {
mLoaderTask.dumpState();
} else {
Log.d(TAG, "mLoaderTask=null");
}
}
}
|
[
"[email protected]"
] | |
3e5fa2e900f2a90effb77c928672d1541ab236bb
|
d105e39161ffabc46d529abf7184a5e383cddbfb
|
/outbox/order-service/src/main/java/io/debezium/examples/outbox/order/model/EntityNotFoundException.java
|
ad9b2ce0e6d373292834ced111602544b5633ea9
|
[
"Apache-2.0"
] |
permissive
|
debezium/debezium-examples
|
d4758b0bcaa95a6415a10b8901634a726792c69e
|
c84eb5a852ab48e695a2fad4a3b8ad932ea70dc1
|
refs/heads/main
| 2023-09-03T15:12:45.198421 | 2023-08-10T14:01:23 | 2023-08-10T14:01:23 | 98,498,455 | 1,316 | 859 |
Apache-2.0
| 2023-09-14T13:15:07 | 2017-07-27T05:48:19 |
JavaScript
|
UTF-8
|
Java
| false | false | 480 |
java
|
/*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.examples.outbox.order.model;
/**
* An exception that indicates an entity could not be found.
*/
public class EntityNotFoundException extends RuntimeException {
private static final long serialVersionUID = -1L;
public EntityNotFoundException(String message) {
super(message);
}
}
|
[
"[email protected]"
] | |
95051a7fd09eb5cb282637ec64f10030ef24fef1
|
e26ebaea4fb6dca55f9c778ccb892c1ac46fa20f
|
/biz/src/test/java/service/RemoteServiceTest.java
|
f112325859332cdca7aef48036c02e3733abc357
|
[] |
no_license
|
jinchengyang/ding-isv-channel
|
c022a2bc6ba925b42681fc0a21de787695183e01
|
aef40ae677420b7540603ac2b1486f9535946720
|
refs/heads/master
| 2020-06-13T16:20:35.666731 | 2016-10-30T11:20:38 | 2016-10-30T11:20:38 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,398 |
java
|
package service;
import base.BaseTestCase;
import com.alibaba.fastjson.JSON;
import com.caucho.hessian.client.HessianProxyFactory;
import com.dingtalk.isv.access.api.model.corp.CorpJSAPITicketVO;
import com.dingtalk.isv.access.api.model.corp.CorpTokenVO;
import com.dingtalk.isv.access.api.model.suite.CorpSuiteAuthVO;
import com.dingtalk.isv.access.api.service.corp.CorpManageService;
import com.dingtalk.isv.access.api.service.suite.CorpSuiteAuthService;
import com.dingtalk.isv.common.model.ServiceResult;
import org.junit.Test;
import javax.annotation.Resource;
import java.net.MalformedURLException;
/**
* Created by mint on 16-1-22.
*/
public class RemoteServiceTest extends BaseTestCase {
@Resource
private CorpManageService corpManageService;
@Resource
private CorpSuiteAuthService corpSuiteAuthService;
@Test
public void test_getCorpToken() {
String corpId="ding4ed6d279061db5e7";
String suiteKey="suite4rkgtvvhr1neumx2";
ServiceResult<CorpTokenVO> sr = corpManageService.getCorpToken(suiteKey,corpId);
System.err.println(JSON.toJSONString(sr));
}
@Test
public void test_getCorpSuiteAuth() {
String corpId="ding4ed6d279061db5e7";
String suiteKey="suiteytzpzchcpug3xpsm";
ServiceResult<CorpSuiteAuthVO> sr = corpSuiteAuthService.getCorpSuiteAuth(corpId,suiteKey);
}
}
|
[
"[email protected]"
] | |
914a48203ad6d1fdd4bab8fe97346ed16e12b1d3
|
b5d39f5eff1065bf2939449313632cd1e511914a
|
/simulator/package-info.java
|
c8eb1b2eb0694736596bea2951f3bbaad12eba18
|
[] |
no_license
|
ni3ol/ProcessScheduling
|
850fc22ff2542a7c8eee6512c1ddf14e46bbf7a1
|
ad00940bd57b9cd2bc2c4d56ada73fb2c65fa13a
|
refs/heads/master
| 2021-01-17T08:13:18.162464 | 2016-06-09T10:21:17 | 2016-06-09T10:21:17 | 60,766,047 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 97 |
java
|
/**
* This package contains data types for creating scheduling simulations.
*/
package simulator;
|
[
"[email protected]"
] | |
fa179c9b605e34524de86f30d5a1a3b5b9692160
|
3634eded90370ff24ee8f47ccfa19e388d3784ad
|
/src/main/java/com/igexin/push/core/a/q.java
|
549dcd77c21da0c53919bf60cf2457a97d06bc02
|
[] |
no_license
|
xiaofans/ResStudyPro
|
8bc3c929ef7199c269c6250b390d80739aaf50b9
|
ac3204b27a65e006ebeb5b522762848ea82d960b
|
refs/heads/master
| 2021-01-25T05:09:52.461974 | 2017-06-06T12:12:41 | 2017-06-06T12:12:41 | 93,514,258 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,055 |
java
|
package com.igexin.push.core.a;
import com.igexin.a.a.c.a;
import com.igexin.push.config.k;
import com.igexin.push.core.c.f;
import com.igexin.push.core.g;
import org.json.JSONObject;
public class q extends b {
private static final String a = k.a;
public boolean a(Object obj, JSONObject jSONObject) {
try {
if (jSONObject.has("action") && jSONObject.getString("action").equals("response_deviceid")) {
String string = jSONObject.getString("deviceid");
a.b(a + " get devid resp, devid : " + string + ", save 2db and file");
f.a().b(string);
if (g.av != null) {
a.b(a + " deviceid arrived cancel addPhoneInfoTimerTask...");
g.av.t();
g.av = null;
}
if (g.z != null) {
com.igexin.push.core.f.a().i().i();
}
a.b("deviceidRsp|" + g.z);
}
} catch (Exception e) {
}
return true;
}
}
|
[
"[email protected]"
] | |
3a6fae89da6ccf47ec2cf3a518201a63ffab58c6
|
02cbc33bb33663ac450460e5522c50b60d51515e
|
/src/main/java/iot/jdbc/JDBCMeasurements.java
|
6d13587ee9325c4bab935632a58fb505605bdbeb
|
[] |
no_license
|
kwlee0220/sensorthings
|
e8e9a9c9f7982a926f2d677095459daf7ee63c26
|
6b4841184929cc7d59a1f1822b35f25ad6a7d248
|
refs/heads/master
| 2021-01-17T22:21:12.590043 | 2019-07-29T14:03:17 | 2019-07-29T14:03:17 | 84,194,772 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,333 |
java
|
package iot.jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;
/**
*
* @author Kang-Woo Lee (ETRI)
*/
public class JDBCMeasurements {
private static final String SQL_PREFIX = "SELECT id, urn, unit FROM MEASUREMENTS ";
private final IoTPlatformImpl m_platform;
private final Connection m_conn;
private final PreparedStatement m_pstmtGet;
private final PreparedStatement m_pstmtGetAll;
public JDBCMeasurements(IoTPlatformImpl platform, Connection conn) throws SQLException {
m_platform = platform;
m_conn = conn;
// prepare all necessary SQL statements
m_pstmtGet = conn.prepareStatement(SQL_PREFIX + "WHERE id=?");
m_pstmtGetAll = conn.prepareStatement(SQL_PREFIX);
}
MeasurementImpl get(long id) throws SQLException {
m_pstmtGet.setLong(1, id);
return ResultSetStream.getFirst(m_pstmtGet, m_mapper);
}
Stream<MeasurementImpl> stream() throws SQLException {
return ResultSetStream.create(m_pstmtGetAll, m_mapper);
}
long create(String urn, String unit) throws SQLException {
PreparedStatement pstmt =null;
try {
pstmt = m_conn.prepareStatement("INSERT INTO MEASUREMENTS VALUES (default, ?, ?)");
pstmt.setString(1, urn);
pstmt.setString(2, unit);
pstmt.executeUpdate();
return JdbcUtils.getGeneratedKey(pstmt);
}
finally {
JdbcUtils.closeQuietly(pstmt);
}
}
void delete(long id) throws SQLException {
Statement stmt = null;
try {
stmt = m_conn.createStatement();
stmt.executeUpdate("DELETE FROM MEASUREMENTS WHERE id=" + id);
}
finally {
JdbcUtils.closeQuietly(stmt);
}
}
void update(long id, Map<String, Object> udata) throws SQLException {
JdbcUtils.updateTable(m_conn, "MEASUREMENTS", id, udata);
}
private Function<ResultSet,MeasurementImpl> m_mapper = new Function<ResultSet,MeasurementImpl>() {
@Override
public MeasurementImpl apply(ResultSet rs) {
try {
return new MeasurementImpl(m_platform, rs.getLong(1), rs.getString(2),
rs.getString(3));
}
catch ( SQLException e ) {
return null;
}
}
};
}
|
[
"[email protected]"
] | |
5af25af302990e5d37d9ea8bae0bca8e5ce633a7
|
eeb9a8f1e57e43bea2cec30a449b273921e705d8
|
/src/SDET_PROBLEMS/searchForElementInArray.java
|
6446f3a9b6286ecbd1ccb8c26b35658d0ac0e7e3
|
[] |
no_license
|
hakimliver/practice
|
6457a09d3d409464648605056e394b04432dd3d0
|
53fddb15a6d1d3f640fb72393bc8b659f32add12
|
refs/heads/main
| 2023-04-17T09:09:10.108385 | 2021-04-29T21:51:47 | 2021-04-29T21:51:47 | 362,954,629 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 562 |
java
|
package SDET_PROBLEMS;
public class searchForElementInArray {
public static void main(String[] args) {
// search for an element in array
int a[] = {10, 4, 5, 76};
int num = 3;
boolean status = false;
for (int i = 0; i < a.length; i++) {
if (num == a[i]) {
System.out.println("the element is present at index " + i);
status = true;
}
}
if (status == false) {
System.out.println("the element is not present");
}
}
}
|
[
"[email protected]"
] | |
144ed251cbd06d8ef639f38a482ed4a3d1434064
|
b6a2a799929f9d6436f3abcee4830e6eed5a0234
|
/Assignment/Java OO Concepts Lesson 02_Drills Set 1/Conditionals JUnit/Conditionals JUnit Tests/ConditionalsJUnitTests/src/test/java/com/sg/conditionalsjunittests/HasTeenTest.java
|
dd3a44d24072f1b3e15f43434743f60afb12872d
|
[] |
no_license
|
KratosOmega/software_guild_akron
|
6e03406a80948b526a403a5fc580e4e8aaab3c65
|
cc5943fd0885ebbd972bc134d8c8d5bf44e8399f
|
refs/heads/master
| 2020-07-08T10:31:54.192733 | 2016-08-19T22:14:58 | 2016-08-19T22:14:58 | 66,115,326 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,572 |
java
|
package com.sg.conditionalsjunittests;
/*
* 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 org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Kratos
*/
public class HasTeenTest {
int a, b, c;
boolean expected, actual;
@Test
public void hasTeenTest_1(){
// Arrange
a = 13;
b = 20;
c = 10;
expected = true;
// Act
ConditionalsJUnitDrills hasTeenTest = new ConditionalsJUnitDrills();
actual = hasTeenTest.hasTeen(a, b, c);
// Assert
org.junit.Assert.assertEquals(expected, actual);
}
@Test
public void hasTeenTest_2(){
// Arrange
a = 20;
b = 19;
c = 10;
expected = true;
// Act
ConditionalsJUnitDrills hasTeenTest = new ConditionalsJUnitDrills();
actual = hasTeenTest.hasTeen(a, b, c);
// Assert
org.junit.Assert.assertEquals(expected, actual);
}
@Test
public void hasTeenTest_3(){
// Arrange
a = 20;
b = 10;
c = 12;
expected = false;
// Act
ConditionalsJUnitDrills hasTeenTest = new ConditionalsJUnitDrills();
actual = hasTeenTest.hasTeen(a, b, c);
// Assert
org.junit.Assert.assertEquals(expected, actual);
}
}
|
[
"[email protected]"
] | |
84eae81110a332316f7abd24c3fba41ee22fd581
|
545dc590a4e610c516fa6b41b0dbb43a0d16a695
|
/src/main/java/no/bekk/bekkopen/mail/model/Kommunenummer.java
|
e5f79dd11c75261babd49a202e9943a5dc785331
|
[
"MIT"
] |
permissive
|
storbukas/NoCommons
|
73bbc3621d23520927584da687e925a29502f1b5
|
44c4bbac44817ce5894efb87cd4578cd19cc6ff7
|
refs/heads/master
| 2021-06-20T06:36:34.909917 | 2021-02-15T22:54:41 | 2021-02-15T22:54:41 | 179,371,023 | 0 | 0 |
MIT
| 2021-02-04T07:13:57 | 2019-04-03T21:11:06 |
Java
|
UTF-8
|
Java
| false | false | 357 |
java
|
package no.bekk.bekkopen.mail.model;
import no.bekk.bekkopen.common.StringNumber;
/**
* This class represent a Norwegian Municipalioty code - a Kommunenummer.
* A Kommunenummer consists of 4 digits.
*/
public class Kommunenummer extends StringNumber {
public Kommunenummer(String kommunenummer) {
super(kommunenummer);
}
}
|
[
"[email protected]"
] | |
fbf926563dd03806e63324a60a550e4155010bd8
|
4a0f50317a8433fcaabc58ec2811744331f9f1f8
|
/diaghealth-entities/src/main/java/com/diagonline/converter/Neo4jConverterConfiguration.java
|
244253d9171e5917842cda9261fbf18af15173c5
|
[] |
no_license
|
diaghealth/diaghealth
|
8c2b19f9ecc18bf429734f45f899f33bb0a5525b
|
cace2296ac3999d684383a2321e183559ed51c47
|
refs/heads/master
| 2021-01-10T12:02:36.268063 | 2015-06-02T15:31:45 | 2015-06-02T15:31:45 | 36,742,547 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,215 |
java
|
package com.diagonline.converter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableNeo4jRepositories("com.diagonline.converter")
@EnableTransactionManagement
public class Neo4jConverterConfiguration extends Neo4jConfiguration {
@Autowired
private StringToUserTypeConverter stringToUserTypeConverter;
@Autowired
private UserTypeToStringConverter userTypeToStringConverter;
@Override
protected ConversionService neo4jConversionService() throws Exception {
ConverterRegistry converterRegistry = (ConverterRegistry) super.neo4jConversionService();
converterRegistry.addConverter(stringToUserTypeConverter);
converterRegistry.addConverter(userTypeToStringConverter);
return (ConversionService) converterRegistry;
}
}
|
[
"[email protected]"
] | |
5dbb0be2d272022bbd31245588c47265e4d1d567
|
ed5159d056e98d6715357d0d14a9b3f20b764f89
|
/test/irvine/oeis/a188/A188510Test.java
|
ddac836fec05a8fd7808c16619ec3b958bd217db
|
[] |
no_license
|
flywind2/joeis
|
c5753169cf562939b04dd246f8a2958e97f74558
|
e5efd6971a0062ac99f4fae21a7c78c9f9e74fea
|
refs/heads/master
| 2020-09-13T18:34:35.080552 | 2019-11-19T05:40:55 | 2019-11-19T05:40:55 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 195 |
java
|
package irvine.oeis.a188;
import irvine.oeis.AbstractSequenceTest;
/**
* Tests the corresponding class.
* @author Sean A. Irvine
*/
public class A188510Test extends AbstractSequenceTest {
}
|
[
"[email protected]"
] | |
d7520ba808e68a1d9e5656c35b3db1ca72cb43dd
|
be28eb39046c22c79bba0ace07812ec8c729b5f8
|
/Strings/StringTokens.java
|
84cc9a2c8ff506a7a44d9d82c1cdeb8098a7979a
|
[
"MIT"
] |
permissive
|
AD9000/Hackerrank---Java
|
41eb6425dcc4ff1145bfc491849fce967f00c89d
|
fad11b37b879fc04f19a0c19b3577ecefc36df83
|
refs/heads/master
| 2020-04-20T23:37:09.625876 | 2019-04-01T02:50:12 | 2019-04-01T02:50:12 | 160,310,682 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,026 |
java
|
// Author: Atharv Damle
// Split a String into tokens and print it to the screen.
// Full Question: https://www.hackerrank.com/challenges/java-string-tokens/problem
import java.io.*;
import java.util.*;
public class StringTokens {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// Accept the string. Remove any leading and trailing spaces (using trim() function)
String s = scan.nextLine().trim();
// Check bounds.
if (s.length() == 0 || s.length() > 400000)
{
System.out.println(0);
return;
}
// Split String s into different tokens. Split at a ' ', '!', ',' and any other character in the String: "[ !,?._'@]+"
String split[] = s.split("[ !,?._'@]+");
// Print to the screen
System.out.println(split.length);
for (int i = 0; i < split.length; i++)
{
System.out.println(split[i]);
}
}
}
|
[
"[email protected]"
] | |
ab68d19f4a790a7699c95ce224edc8f1da468e10
|
92e7a62c54bcf24de97b5d4c1bb15b99f775bed2
|
/OpenConcerto/src/org/openconcerto/sql/ui/IPolyCombo.java
|
cbb988c58e6d76e6d6d033e3ce333c3a314cf7b5
|
[] |
no_license
|
trespe/openconcerto
|
4a9c294006187987f64dbf936f167d666e6c5d52
|
6ccd5a7b56cd75350877842998c94434083fb62f
|
refs/heads/master
| 2021-01-13T02:06:29.609413 | 2015-04-10T08:35:31 | 2015-04-10T08:35:31 | 33,717,537 | 3 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 8,119 |
java
|
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.sql.ui;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.PolymorphFK;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.request.SQLRowItemView;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
import org.openconcerto.sql.sqlobject.itemview.RowItemViewComponent;
import org.openconcerto.utils.checks.MutableValueObject;
import org.openconcerto.utils.model.ListComboBoxModel;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.MutableComboBoxModel;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
/**
* A class to edit a PolymorphFK.
*
* @author Sylvain CUAZ
*/
public class IPolyCombo extends JPanel implements MutableValueObject<SQLRow>, RowItemViewComponent {
/**
* Creates a new instance from a list of tablenames using the default Configuration to find the
* SQLElement.
*
* @param root the context from which <code>tables</code> are found.
* @param tables a list of tablenames, comma separated with no spaces, eg "RECEPTEUR,SOURCE".
* @return the corresponding IPolyCombo.
*/
public static final IPolyCombo create(DBRoot root, String tables) {
final List<String> tablesL = SQLRow.toList(tables);
final List<SQLElement> elements = new ArrayList<SQLElement>(tablesL.size());
for (final String tableName : tablesL) {
elements.add(Configuration.getInstance().getDirectory().getElement(root.getTableDesc(tableName)));
}
return new IPolyCombo(elements);
}
private PolymorphFK field;
private final PropertyChangeSupport supp;
private final JComboBox tableCombo;
// <SQLElement, TableRowCombo>
private final Map<SQLElement, ElementComboBox> idCombos;
// <String, SQLElement>
// necessary when reading the table name from DB to find the corresponding element
private final Map<String, SQLElement> name2elem;
/**
* Creates a IPolyCombo to edit the passed list of SQLElement. No 2 elements can share the same
* SQLTable.
*
* @param elements a list of SQLElement.
*/
public IPolyCombo(final List<SQLElement> elements) {
this.supp = new PropertyChangeSupport(this);
this.idCombos = new HashMap<SQLElement, ElementComboBox>();
this.name2elem = new HashMap<String, SQLElement>();
for (final SQLElement element : elements) {
final ElementComboBox c = new ElementComboBox();
c.addValueListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
fireValueChange();
}
});
this.idCombos.put(element, c);
this.name2elem.put(element.getTable().getName(), element);
}
if (this.name2elem.size() != this.idCombos.size())
throw new IllegalArgumentException("size mismatch: " + this.idCombos.keySet() + " / " + this.name2elem.keySet());
this.tableCombo = new JComboBox(new ListComboBoxModel(elements));
// put the empty element at the top
((MutableComboBoxModel) this.tableCombo.getModel()).insertElementAt(null, 0);
this.tableCombo.setRenderer(new BasicComboBoxRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
final SQLElement element = (SQLElement) value;
c.setText(element == null ? SQLRequestComboBox.UNDEFINED_STRING : element.getSingularName());
return c;
}
});
// each time we change the table combo, we must change the second combo.
this.tableCombo.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateIdCombo();
}
});
}
protected final void fireValueChange() {
this.supp.firePropertyChange("value", null, this.getValue());
}
protected void updateIdCombo() {
if (this.getComponentCount() > 1)
this.remove(1);
if (this.getIdCombo() != null)
this.add(this.getIdCombo());
this.revalidate();
this.fireValueChange();
}
/**
* The currently selected SQLElement, eg a RecepteurElement.
*
* @return the selected SQLElement or <code>null</code>.
*/
private final SQLElement getSelectedElement() {
return (SQLElement) this.tableCombo.getSelectedItem();
}
/**
* The combo needed to edit the selected element.
*
* @return a TableRowCombo containing rows of the selected element or <code>null</code>.
*/
private final ElementComboBox getIdCombo() {
return this.idCombos.get(this.getSelectedElement());
}
public void init(SQLRowItemView v) {
final SQLField f = v.getField();
this.field = new PolymorphFK(f.getTable(), PolymorphFK.tableField2propName(f));
this.setLayout(new GridLayout(1, 2));
this.add(this.tableCombo);
// no need to add idCombo it's done by updateIdCombo()
for (final SQLElement element : this.idCombos.keySet()) {
final ElementComboBox c = this.idCombos.get(element);
c.init(element);
}
this.resetValue();
}
public final void resetValue() {
this.setValue(null);
}
public void setValue(SQLRow foreignRow) {
final String tableName = foreignRow == null ? null : foreignRow.getTable().getName();
this.tableCombo.setSelectedItem(this.name2elem.get(tableName));
if (this.getIdCombo() != null)
this.getIdCombo().setValue(foreignRow.getID());
}
public SQLRow getValue() {
if (this.getIdCombo() == null)
return null;
else
return this.getIdCombo().getSelectedRow();
}
public void addValueListener(PropertyChangeListener l) {
this.supp.addPropertyChangeListener(l);
}
public void rmValueListener(PropertyChangeListener l) {
this.supp.removePropertyChangeListener(l);
}
public final PolymorphFK getPolymorphFK() {
return this.field;
}
public void setEnabled(boolean b) {
this.tableCombo.setEnabled(b);
for (final JComponent idCombo : this.idCombos.values())
idCombo.setEnabled(b);
}
@Override
public String toString() {
return this.getClass().getSimpleName() + " for " + this.field;
}
}
|
[
"[email protected]@658cf4a1-8b1b-4573-6053-fb3ec553790b"
] |
[email protected]@658cf4a1-8b1b-4573-6053-fb3ec553790b
|
59c37b9ce38a7b8f733113a998f902a3f71d8467
|
8022e46baeab00ac792a6f243d5852a71c5b76da
|
/evyn-design-pattern-all/evyn-design-pattern-proxy/src/main/java/com/evyn/desig/pattern/proxy/dbroute/DBrouteTest.java
|
521d398bf0e086daa8619cc05ccb4a04b367637f
|
[] |
no_license
|
Evynxyw/design-pattern
|
16b9b3b55334ae980b0291d978d96f1e5b2e4615
|
a8c0b386b053533bf5c1fdc56cc4816fd851528d
|
refs/heads/master
| 2020-04-27T21:02:40.828381 | 2019-03-19T13:31:40 | 2019-03-19T13:31:40 | 174,681,791 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 887 |
java
|
package com.evyn.desig.pattern.proxy.dbroute;
import com.evyn.desig.pattern.proxy.dbroute.proxy.OrderServiceDynamicProxy;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @ClassName DBrouteTest
* @Description:
* @Author xyw
* @Date 2019/3/15 22:16
* @Version 1.0
*/
public class DBrouteTest {
public static void main(String[] args) {
try {
Order order = new Order();
// order.setCreateTime(new Date().getTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Date date = sdf.parse("2017/02/01");
order.setCreateTime(date.getTime());
IOrderService orderService = (IOrderService)new OrderServiceDynamicProxy().getInstance(new OrderService());
orderService.createOrder(order);
}catch (Exception e){
e.printStackTrace();
}
}
}
|
[
"[email protected]"
] | |
270f8c3cd1d79cc92f1cac1fa5a8a4ce6e22e818
|
2597369eeea50276d776d1de531c2cdbad1713ee
|
/src/com/vincesu/framework/util/SystemUtil.java
|
3500ef6c6890266616162519fcb15bfbb70ff329
|
[] |
no_license
|
vincesu/zhgyms
|
47710a96dd6dcb692e5894d5ae9325803070930d
|
34d1acc3fbbbff5cab1c3a274c2fc1b1fa25834d
|
refs/heads/master
| 2020-05-31T05:56:43.675917 | 2014-12-08T08:00:04 | 2014-12-08T08:00:04 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 872 |
java
|
/* 1: */package com.vincesu.framework.util;
/* 2: */
/* 3: */import java.security.ProtectionDomain;
/* 4: */
/* 5: */public class SystemUtil
/* 6: */{
/* 7: */ public static String getLocation()
/* 8: */ {
/* 9: 9 */ java.io.File file = new java.io.File(SystemUtil.class.getProtectionDomain().getCodeSource().getLocation().getFile());
/* 10:10 */ for (int i = 0; i < 7; i++)
/* 11:11 */ file = file.getParentFile();
/* 12:12 */ String result = file.getAbsolutePath();
/* 13:13 */ if (result.endsWith("/"))
/* 14:14 */ result.substring(0, result.length() - 1);
/* 15:15 */ return file.getAbsolutePath();
/* 16: */ }
/* 17: */}
/* Location: C:\Users\Administrator\Desktop\code\WEB-INF\classes\
* Qualified Name: com.vincesu.framework.util.SystemUtil
* JD-Core Version: 0.7.0-SNAPSHOT-20130630
*/
|
[
"[email protected]"
] | |
c7c894ec47fe367cd430a1c57f367ae0a4636204
|
97e9dbed947a139add8521b971f4a3cc59f07762
|
/app/src/test/java/com/anderssonlegitapp/joakim/bluetoothmadness/ExampleUnitTest.java
|
be05a4aae52c42014116720647477802d388f0bf
|
[] |
no_license
|
HerrAndersson95/BlueToothMadness
|
529539bc79b4a35d006c40053982b7bdb517af58
|
65a420ffef7993cf0ad1e0c4c163a42605d6de12
|
refs/heads/master
| 2021-05-07T08:05:37.902440 | 2017-11-02T11:04:17 | 2017-11-02T11:04:17 | 109,253,806 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 423 |
java
|
package com.anderssonlegitapp.joakim.bluetoothmadness;
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]"
] | |
156198bee54160aa81478499ee40bc72462682e1
|
0c2817433299178441d7a31ee9e1c8c17ff4dcad
|
/src/main/java/br/com/zupacademy/gabriel/ecommerce/compra/CompraRepository.java
|
7dc0071ce9f33f6c070f37727726277ccc031ff2
|
[
"Apache-2.0"
] |
permissive
|
guesserzup/orange-talents-08-template-ecommerce
|
bb30be3730d2296aec1044cba26e0c0faac9fd9c
|
f39b9a1e7690fa652581de64c30ec40fea714f8c
|
refs/heads/master
| 2023-07-27T06:28:07.261160 | 2021-09-08T12:18:23 | 2021-09-08T12:18:23 | 401,777,369 | 0 | 0 |
Apache-2.0
| 2021-08-31T16:49:35 | 2021-08-31T16:49:35 | null |
UTF-8
|
Java
| false | false | 190 |
java
|
package br.com.zupacademy.gabriel.ecommerce.compra;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CompraRepository extends JpaRepository<Compra, Long> {
}
|
[
"[email protected]"
] | |
cfa7964a47c36c2eca02f91cfe5bb4fd978b9864
|
51fa3cc281eee60058563920c3c9059e8a142e66
|
/Java/src/testcases/CWE400_Resource_Exhaustion/s02/CWE400_Resource_Exhaustion__listen_tcp_write_81_goodB2G.java
|
d075cdbef7f2d6ecf635d2452babbcc8a6d22ae9
|
[] |
no_license
|
CU-0xff/CWE-Juliet-TestSuite-Java
|
0b4846d6b283d91214fed2ab96dd78e0b68c945c
|
f616822e8cb65e4e5a321529aa28b79451702d30
|
refs/heads/master
| 2020-09-14T10:41:33.545462 | 2019-11-21T07:34:54 | 2019-11-21T07:34:54 | 223,105,798 | 1 | 4 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,004 |
java
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE400_Resource_Exhaustion__listen_tcp_write_81_goodB2G.java
Label Definition File: CWE400_Resource_Exhaustion.label.xml
Template File: sources-sinks-81_goodB2G.tmpl.java
*/
/*
* @description
* CWE: 400 Resource Exhaustion
* BadSource: listen_tcp Read count using a listening tcp connection
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks: write
* GoodSink: Write to a file count number of times, but first validate count
* BadSink : Write to a file count number of times
* Flow Variant: 81 Data flow: data passed in a parameter to an abstract method
*
* */
package testcases.CWE400_Resource_Exhaustion.s02;
import testcasesupport.*;
import javax.servlet.http.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.logging.Level;
public class CWE400_Resource_Exhaustion__listen_tcp_write_81_goodB2G extends CWE400_Resource_Exhaustion__listen_tcp_write_81_base
{
public void action(int count ) throws Throwable
{
/* FIX: Validate count before using it as the for loop variant to write to a file */
if (count > 0 && count <= 20)
{
File file = new File("goodSink.txt");
FileOutputStream streamFileOutput = new FileOutputStream(file);
OutputStreamWriter writerOutputStream = new OutputStreamWriter(streamFileOutput, "UTF-8");
BufferedWriter writerBuffered = new BufferedWriter(writerOutputStream);
int i;
for (i = 0; i < count; i++)
{
try
{
writerBuffered.write("Hello");
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error with stream writing", exceptIO);
}
}
/* Close stream reading objects */
try
{
if (writerBuffered != null)
{
writerBuffered.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing BufferedWriter", exceptIO);
}
try
{
if (writerOutputStream != null)
{
writerOutputStream.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing OutputStreamWriter", exceptIO);
}
try
{
if (streamFileOutput != null)
{
streamFileOutput.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing FileOutputStream", exceptIO);
}
}
}
}
|
[
"[email protected]"
] | |
9f70c22156e0d5993681fd250a407483df0e8510
|
a0fc286ead8d6d62884b69e78c54b680794fb550
|
/Flashcards/Problems/The maximum pairwise product/src/Main.java
|
d46e3356518c5882d38f32e5d777d7f97e70b747
|
[] |
no_license
|
szilex/Course_JetBrains_Academy_Java_Developer
|
4a6bddb6cc7a0e8e447d7805ef723963b56374eb
|
4d8b36ab83526536385107659a8d910227dd38e8
|
refs/heads/master
| 2022-10-20T11:35:27.737743 | 2020-06-13T09:35:00 | 2020-06-13T09:35:00 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 513 |
java
|
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int size = scanner.nextInt();
int max = 0, oldValue = scanner.nextInt(), value;
for(int i = 0; i < size - 1; i++ ){
value = scanner.nextInt();
int product = oldValue * value;
if(product > max){
max = product;
}
oldValue = value;
}
System.out.println(max);
}
}
|
[
"[email protected]"
] | |
8c11df3b3bd12eb460059500d4d9bef1fea8a66d
|
863acb02a064a0fc66811688a67ce3511f1b81af
|
/sources/com/flurry/sdk/C7508dc.java
|
3e1a675af098b8cbe61ea9ed88825a3f0b797bfe
|
[
"MIT"
] |
permissive
|
Game-Designing/Custom-Football-Game
|
98d33eb0c04ca2c48620aa4a763b91bc9c1b7915
|
47283462b2066ad5c53b3c901182e7ae62a34fc8
|
refs/heads/master
| 2020-08-04T00:02:04.876780 | 2019-10-06T06:55:08 | 2019-10-06T06:55:08 | 211,914,568 | 1 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,169 |
java
|
package com.flurry.sdk;
/* renamed from: com.flurry.sdk.dc */
public final class C7508dc {
/* renamed from: a */
public static final String f14798a = C7508dc.class.getSimpleName();
/* renamed from: b */
private static C7508dc f14799b = null;
/* renamed from: c */
public boolean f14800c = false;
private C7508dc() {
}
/* renamed from: a */
public static synchronized C7508dc m16634a() {
C7508dc dcVar;
synchronized (C7508dc.class) {
if (f14799b == null) {
f14799b = new C7508dc();
}
dcVar = f14799b;
}
return dcVar;
}
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0014, code lost:
return p019d.p020e.p021a.C7294e.m15872d() != null ? p019d.p020e.p021a.C7294e.m15872d() : com.flurry.sdk.C7412Lb.m16398a().mo23854c();
*/
/* renamed from: b */
/* Code decompiled incorrectly, please refer to instructions dump. */
public final synchronized java.lang.String mo23946b() {
/*
r1 = this;
monitor-enter(r1)
boolean r0 = r1.f14800c // Catch:{ all -> 0x001e }
if (r0 != 0) goto L_0x0009
r0 = 0
monitor-exit(r1)
return r0
L_0x0009:
java.lang.String r0 = p019d.p020e.p021a.C7294e.m15872d() // Catch:{ all -> 0x001e }
if (r0 == 0) goto L_0x0015
java.lang.String r0 = p019d.p020e.p021a.C7294e.m15872d() // Catch:{ all -> 0x001e }
L_0x0013:
monitor-exit(r1)
return r0
L_0x0015:
com.flurry.sdk.Lb r0 = com.flurry.sdk.C7412Lb.m16398a() // Catch:{ all -> 0x001e }
java.lang.String r0 = r0.mo23854c() // Catch:{ all -> 0x001e }
goto L_0x0013
L_0x001e:
r0 = move-exception
monitor-exit(r1)
goto L_0x0022
L_0x0021:
throw r0
L_0x0022:
goto L_0x0021
*/
throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.C7508dc.mo23946b():java.lang.String");
}
}
|
[
"[email protected]"
] | |
e4493cff390e023e5d9c711a30c9feaf4ff6255f
|
06e22f38fbc8e88ba6ff4eec3a3efa446a27f8c4
|
/app/src/test/java/com/example/cs449_project/ScaleCreationAlgorithmTest.java
|
041dbdbfe4bc6abe9a8749fef349c4ec1ce5ec23
|
[] |
no_license
|
BrettGB/CS449-Project1
|
5907b862b00033818ee436d0c553ead5efa09cf8
|
64be51d463e699c0002bb8510947ed33f5acec84
|
refs/heads/master
| 2022-06-18T01:31:35.886665 | 2020-05-08T17:08:20 | 2020-05-08T17:08:20 | 255,174,209 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,414 |
java
|
package com.example.cs449_project;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class ScaleCreationAlgorithmTest {
private ScaleCreationAlgorithm theCreation;
@Before
public void setUp() throws Exception {
theCreation = new ScaleCreationAlgorithm();
}
@After
public void tearDown() throws Exception {
}
@Test
public void testMajorScaleCreator() {
String[] actual = theCreation.scaleCreator("Major", "C");
String[] expected = {"C", "D", "E", "F", "G", "A", "B"};
assertArrayEquals(expected, actual);
}
@Test
public void testMinorScaleCreator() {
String[] actual = theCreation.scaleCreator("Minor", "D");
String[] expected = {"D", "E", "F", "G", "A", "A#", "C"};
assertArrayEquals(expected, actual);
}
@Test
public void testHarmonicMinorScaleCreator() {
String[] actual = theCreation.scaleCreator("Harmonic Minor", "E");
String[] expected = {"E", "F#", "G", "A", "B", "C", "D#"};
assertArrayEquals(expected, actual);
}
@Test
public void testMelodicMinorScaleCreator() {
String[] actual = theCreation.scaleCreator("Melodic Minor", "F");
String[] expected = {"F", "G", "G#", "A#", "C", "D", "E"};
assertArrayEquals(expected, actual);
}
}
|
[
"[email protected]"
] | |
7773aeba6e4f5bf4d84f0228b50661cce12c499d
|
d1e3c96573cdcad2fa36e9c57569e5c57ad108cf
|
/src/main/java/manon/user/registration/RegistrationForm.java
|
9ea27e72fa4b5efd6ef9e23b6f38acf4b309d202
|
[
"MIT"
] |
permissive
|
jbravo/manon
|
a721eec854938e57e4b24974d0acd124c14806b4
|
bb926c475eb492942f8993b5a8a8bc8a722ada79
|
refs/heads/master
| 2020-06-01T11:12:56.947245 | 2017-09-08T16:29:12 | 2017-09-08T16:29:35 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 264 |
java
|
package manon.user.registration;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RegistrationForm {
private String username;
private String password;
}
|
[
"[email protected]"
] | |
3df8f990d1bd74f3b7088468679a14655f988b65
|
0b595e7c8f74928fc81e464019da331412e4eac0
|
/services/hrdb/src/com/auto_wopjoasedt/hrdb/service/UserService.java
|
e893e8ec3372fdf2cef2f94dabc4a744de0382dd
|
[] |
no_license
|
wavemakerapps/Auto_WoPjoaSEdt
|
8ac5038120d19e2ef9a4832d112a9a8109b5f033
|
4c543e733c5687fee86d875aeab3772a54762de6
|
refs/heads/master
| 2021-01-24T16:29:52.443291 | 2018-02-27T23:20:22 | 2018-02-27T23:20:22 | 123,199,962 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 5,788 |
java
|
/*Copyright (c) 2015-2016 wavemaker.com All Rights Reserved.
This software is the confidential and proprietary information of wavemaker.com You shall not disclose such Confidential Information and shall use it only in accordance
with the terms of the source code license agreement you entered into with wavemaker.com*/
package com.auto_wopjoasedt.hrdb.service;
/*This is a Studio Managed File. DO NOT EDIT THIS FILE. Your changes may be reverted by Studio.*/
import java.util.Map;
import javax.validation.Valid;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.wavemaker.runtime.data.exception.EntityNotFoundException;
import com.wavemaker.runtime.data.export.ExportType;
import com.wavemaker.runtime.data.expression.QueryFilter;
import com.wavemaker.runtime.data.model.AggregationInfo;
import com.wavemaker.runtime.file.model.Downloadable;
import com.auto_wopjoasedt.hrdb.User;
/**
* Service object for domain model class {@link User}.
*/
public interface UserService {
/**
* Creates a new User. It does cascade insert for all the children in a single transaction.
*
* This method overrides the input field values using Server side or database managed properties defined on User if any.
*
* @param user Details of the User to be created; value cannot be null.
* @return The newly created User.
*/
User create(@Valid User user);
/**
* Returns User by given id if exists.
*
* @param userIdInstance The id of the User to get; value cannot be null.
* @return User associated with the given userIdInstance.
* @throws EntityNotFoundException If no User is found.
*/
User getById(Integer userIdInstance) throws EntityNotFoundException;
/**
* Find and return the User by given id if exists, returns null otherwise.
*
* @param userIdInstance The id of the User to get; value cannot be null.
* @return User associated with the given userIdInstance.
*/
User findById(Integer userIdInstance);
/**
* Updates the details of an existing User. It replaces all fields of the existing User with the given user.
*
* This method overrides the input field values using Server side or database managed properties defined on User if any.
*
* @param user The details of the User to be updated; value cannot be null.
* @return The updated User.
* @throws EntityNotFoundException if no User is found with given input.
*/
User update(@Valid User user) throws EntityNotFoundException;
/**
* Deletes an existing User with the given id.
*
* @param userIdInstance The id of the User to be deleted; value cannot be null.
* @return The deleted User.
* @throws EntityNotFoundException if no User found with the given id.
*/
User delete(Integer userIdInstance) throws EntityNotFoundException;
/**
* Deletes an existing User with the given object.
*
* @param user The instance of the User to be deleted; value cannot be null.
*/
void delete(User user);
/**
* Find all Users matching the given QueryFilter(s).
* All the QueryFilter(s) are ANDed to filter the results.
* This method returns Paginated results.
*
* @deprecated Use {@link #findAll(String, Pageable)} instead.
*
* @param queryFilters Array of queryFilters to filter the results; No filters applied if the input is null/empty.
* @param pageable Details of the pagination information along with the sorting options. If null returns all matching records.
* @return Paginated list of matching Users.
*
* @see QueryFilter
* @see Pageable
* @see Page
*/
@Deprecated
Page<User> findAll(QueryFilter[] queryFilters, Pageable pageable);
/**
* Find all Users matching the given input query. This method returns Paginated results.
* Note: Go through the documentation for <u>query</u> syntax.
*
* @param query The query to filter the results; No filters applied if the input is null/empty.
* @param pageable Details of the pagination information along with the sorting options. If null returns all matching records.
* @return Paginated list of matching Users.
*
* @see Pageable
* @see Page
*/
Page<User> findAll(String query, Pageable pageable);
/**
* Exports all Users matching the given input query to the given exportType format.
* Note: Go through the documentation for <u>query</u> syntax.
*
* @param exportType The format in which to export the data; value cannot be null.
* @param query The query to filter the results; No filters applied if the input is null/empty.
* @param pageable Details of the pagination information along with the sorting options. If null exports all matching records.
* @return The Downloadable file in given export type.
*
* @see Pageable
* @see ExportType
* @see Downloadable
*/
Downloadable export(ExportType exportType, String query, Pageable pageable);
/**
* Retrieve the count of the Users in the repository with matching query.
* Note: Go through the documentation for <u>query</u> syntax.
*
* @param query query to filter results. No filters applied if the input is null/empty.
* @return The count of the User.
*/
long count(String query);
/**
* Retrieve aggregated values with matching aggregation info.
*
* @param aggregationInfo info related to aggregations.
* @param pageable Details of the pagination information along with the sorting options. If null exports all matching records.
* @return Paginated data with included fields.
* @see AggregationInfo
* @see Pageable
* @see Page
*/
Page<Map<String, Object>> getAggregatedValues(AggregationInfo aggregationInfo, Pageable pageable);
}
|
[
"[email protected]"
] | |
471951d0e12da190ce624a26a6e9076770ba3e05
|
f234000f117f3d6a87dbb4134c59e26c87c175e2
|
/src/main/java/com/manong/community/service/CommentService.java
|
3328dcd2d338026a74585cae40116d34850638b7
|
[] |
no_license
|
hua2580027487/community
|
d4559bc37f6bc82e07bc71f1fe9267fc2dc85ec8
|
ec0688e64ebc1057c241a09d13a0bb7d45577d8b
|
refs/heads/master
| 2022-07-03T06:07:14.611603 | 2020-03-30T14:57:00 | 2020-03-30T14:57:00 | 197,539,338 | 0 | 0 | null | 2022-06-21T01:56:12 | 2019-07-18T07:52:55 |
JavaScript
|
UTF-8
|
Java
| false | false | 5,587 |
java
|
package com.manong.community.service;
import com.manong.community.dto.CommentDTO;
import com.manong.community.enums.CommentTypeEnums;
import com.manong.community.enums.NotificationStatusEnum;
import com.manong.community.enums.NotificationTypeEnum;
import com.manong.community.exception.CustomizeErrorCode;
import com.manong.community.exception.CustomizeException;
import com.manong.community.mapper.*;
import com.manong.community.model.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class CommentService {
@Autowired
private QuestionMapper questionMapper;
@Autowired
private CommentMapper commentMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private QuestionExtMapper questionExtMapper;
@Autowired
private CommentExtMapper commentExtMapper;
@Autowired
private NotificationMapper notificationMapper;
@Transactional
public void insert(Comment comment, User commentor) {
if (comment.getParentId() == null || comment.getParentId() == 0) {
throw new CustomizeException(CustomizeErrorCode.TAEGET_PAEAM_NOT_FOUND);
}
if (comment.getType() == null || !CommentTypeEnums.isExist(comment.getType())) {
throw new CustomizeException(CustomizeErrorCode.TYPE_PAEAM_ERROR);
}
if (comment.getType() == CommentTypeEnums.COMMENT.getType()) {
//回复评论
Comment dbComment = commentMapper.selectByPrimaryKey(comment.getParentId());
if (dbComment == null) {
throw new CustomizeException(CustomizeErrorCode.COMMENT_NOT_FOUND);
}
//回复问题
Question question = questionMapper.selectByPrimaryKey(dbComment.getParentId());
if (question == null) {
throw new CustomizeException(CustomizeErrorCode.QUESTION_NOT_FOUND);
}
commentMapper.insert(comment);
//增加评论数
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());
parentComment.setCommentCount(1);
commentExtMapper.incCommentView(parentComment);
//评论通知
createNotify(comment, dbComment.getCommentator(), commentor.getName(), question.getTitle(), NotificationTypeEnum.REPLY_COMMENT, question.getId());
} else {
//回复问题
Question question = questionMapper.selectByPrimaryKey(comment.getParentId());
if (question == null) {
throw new CustomizeException(CustomizeErrorCode.QUESTION_NOT_FOUND);
}
commentMapper.insert(comment);
question.setCommentCount(1);
questionExtMapper.incCommentView(question);
//问题通知
createNotify(comment, question.getCreator(), commentor.getName(), question.getTitle(), NotificationTypeEnum.REPLY_QUESTION, question.getId());
}
}
private void createNotify(Comment comment, Long receiver, String notifierName, String outerTitle, NotificationTypeEnum notificationType, Long outerId) {
if(receiver == comment.getCommentator()){
return;
}
Notification notification = new Notification();
notification.setGmtCreate(System.currentTimeMillis());
notification.setType(notificationType.getType());
notification.setOuterid(outerId);
notification.setNotifier(comment.getCommentator());
notification.setStatus(NotificationStatusEnum.UNREAD.getStatus());
notification.setReceiver(receiver);
notification.setNotifierName(notifierName);
notification.setOuterTitle(outerTitle);
notificationMapper.insert(notification);
}
public List<CommentDTO> listByTargetId(Long id, CommentTypeEnums type) {
CommentExample commentExample = new CommentExample();
commentExample.createCriteria()
.andParentIdEqualTo(id)
.andTypeEqualTo(type.getType());
commentExample.setOrderByClause("gmt_create desc");
//拿到所有的comments
List<Comment> comments = commentMapper.selectByExample(commentExample);
if (comments.size() == 0) {
return new ArrayList<>();
}
//获取去重的评论人
Set<Long> commentators = comments.stream().map(comment -> comment.getCommentator()).collect(Collectors.toSet());
List<Long> userIds = new ArrayList<>();
userIds.addAll(commentators);
//获取评论人并转化为map
UserExample userExample = new UserExample();
userExample.createCriteria()
.andIdIn(userIds);
List<User> users = userMapper.selectByExample(userExample);
Map<Long, User> userMap = users.stream().collect(Collectors.toMap(user -> user.getId(), user -> user));
//转化comment为commentDTO
List<CommentDTO> commentDTOS = comments.stream().map(comment -> {
CommentDTO commentDTO = new CommentDTO();
BeanUtils.copyProperties(comment, commentDTO);
commentDTO.setUser(userMap.get(comment.getCommentator()));
return commentDTO;
}).collect(Collectors.toList());
return commentDTOS;
}
}
|
[
"[email protected]"
] | |
9efca09660837388d576a81fa44fbbf6770e3a0c
|
13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3
|
/crash-reproduction-new-fitness/results/LANG-54b-1-29-Single_Objective_GGA-IntegrationSingleObjective-BasicBlockCoverage/org/apache/commons/lang/LocaleUtils_ESTest_scaffolding.java
|
2165a96cc5f5a185f6d868e45db37b3775ff356e
|
[
"MIT",
"CC-BY-4.0"
] |
permissive
|
STAMP-project/Botsing-basic-block-coverage-application
|
6c1095c6be945adc0be2b63bbec44f0014972793
|
80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da
|
refs/heads/master
| 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,917 |
java
|
/**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Mon May 18 01:58:00 UTC 2020
*/
package org.apache.commons.lang;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class LocaleUtils_ESTest_scaffolding {
@org.junit.Rule
public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
@BeforeClass
public static void initEvoSuiteFramework() {
org.evosuite.runtime.RuntimeSettings.className = "org.apache.commons.lang.LocaleUtils";
org.evosuite.runtime.GuiSupport.initialize();
org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
}
@Before
public void initTestCase(){
threadStopper.storeCurrentThreads();
threadStopper.startRecordingTime();
org.evosuite.runtime.GuiSupport.setHeadless();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
org.evosuite.runtime.agent.InstrumentingAgent.activate();
}
@After
public void doneWithTestCase(){
threadStopper.killAndJoinClientThreads();
org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
}
private static void initializeClasses() {
org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(LocaleUtils_ESTest_scaffolding.class.getClassLoader() ,
"org.apache.commons.lang.LocaleUtils"
);
}
}
|
[
"[email protected]"
] | |
f46e8bc0aba69ea4ecc78d61e34134410445a958
|
dd76d0b680549acb07278b2ecd387cb05ec84d64
|
/divestory-CFR/androidx/transition/CanvasUtils.java
|
cbaa705b9b9ed7fb2fafc67b7b87e8cf001e99f9
|
[] |
no_license
|
ryangardner/excursion-decompiling
|
43c99a799ce75a417e636da85bddd5d1d9a9109c
|
4b6d11d6f118cdab31328c877c268f3d56b95c58
|
refs/heads/master
| 2023-07-02T13:32:30.872241 | 2021-08-09T19:33:37 | 2021-08-09T19:33:37 | 299,657,052 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,498 |
java
|
/*
* Decompiled with CFR <Could not determine version>.
*
* Could not load the following classes:
* android.graphics.Canvas
* android.os.Build
* android.os.Build$VERSION
*/
package androidx.transition;
import android.graphics.Canvas;
import android.os.Build;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
class CanvasUtils {
private static Method sInorderBarrierMethod;
private static boolean sOrderMethodsFetched;
private static Method sReorderBarrierMethod;
private CanvasUtils() {
}
/*
* Unable to fully structure code
* Enabled unnecessary exception pruning
*/
static void enableZ(Canvas var0, boolean var1_3) {
if (Build.VERSION.SDK_INT < 21) {
return;
}
if (Build.VERSION.SDK_INT >= 29) {
if (var1_3) {
var0.enableZ();
return;
}
var0.disableZ();
return;
}
if (Build.VERSION.SDK_INT == 28) throw new IllegalStateException("This method doesn't work on Pie!");
if (CanvasUtils.sOrderMethodsFetched) ** GOTO lbl-1000
try {
CanvasUtils.sReorderBarrierMethod = var2_4 = Canvas.class.getDeclaredMethod("insertReorderBarrier", new Class[0]);
var2_4.setAccessible(true);
CanvasUtils.sInorderBarrierMethod = var2_4 = Canvas.class.getDeclaredMethod("insertInorderBarrier", new Class[0]);
var2_4.setAccessible(true);
lbl16: // 2 sources:
do {
CanvasUtils.sOrderMethodsFetched = true;
break;
} while (true);
}
catch (NoSuchMethodException var2_5) {
** continue;
}
lbl-1000: // 2 sources:
{
if (!var1_3) ** GOTO lbl25
try {
if (CanvasUtils.sReorderBarrierMethod != null) {
CanvasUtils.sReorderBarrierMethod.invoke((Object)var0, new Object[0]);
}
lbl25: // 4 sources:
if (var1_3 != false) return;
if (CanvasUtils.sInorderBarrierMethod == null) return;
CanvasUtils.sInorderBarrierMethod.invoke((Object)var0, new Object[0]);
return;
}
catch (InvocationTargetException var0_1) {
throw new RuntimeException(var0_1.getCause());
}
}
catch (IllegalAccessException var0_2) {
return;
}
}
}
|
[
"[email protected]"
] | |
42922d25facb1f2985b1951160981ccb245bc848
|
2a47cd6b2ae0d9f8d6b0470eaef55791c620e4a4
|
/src/main/java/com/avs/coxinventory/services/ApiServiceKeyImpl.java
|
f112b56ddf9139a87ee91455a7af200bcfd6d94c
|
[] |
no_license
|
allen244/CoxInventory
|
ef7659ee12b1dc1c3ab2983439e5dcedb94b2294
|
5f7dcb5a5a09b66f47a24fa54dc74999560df79c
|
refs/heads/master
| 2021-05-02T00:30:34.229484 | 2018-02-09T19:23:20 | 2018-02-09T19:23:20 | 120,946,022 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 75 |
java
|
package com.avs.coxinventory.services;
public class ApiServiceKeyImpl {
}
|
[
"[email protected]"
] | |
ff704f9f86ef51d82c01492850c26ce4e621ec37
|
55b93ddeb025281f1e5bdfa165cb5074ec622544
|
/graphsdk/src/main/java/com/microsoft/graph/generated/BaseReportRootGetOneDriveUsageStorageRequestBuilder.java
|
9909649aa7bbf972ee764274137ad30a3e9cb26a
|
[
"MIT"
] |
permissive
|
Glennmen/msgraph-sdk-android
|
7c13e8367fb6cb7bb9a655860a4c14036601296b
|
cb774abbaa1abde0c63229a70256b3d97f212a3e
|
refs/heads/master
| 2020-03-30T15:56:29.622277 | 2018-10-03T09:07:00 | 2018-10-03T09:07:00 | 151,386,422 | 1 | 0 |
NOASSERTION
| 2018-10-03T09:03:00 | 2018-10-03T09:02:59 | null |
UTF-8
|
Java
| false | false | 2,519 |
java
|
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
package com.microsoft.graph.generated;
import com.microsoft.graph.concurrency.*;
import com.microsoft.graph.core.*;
import com.microsoft.graph.extensions.*;
import com.microsoft.graph.http.*;
import com.microsoft.graph.generated.*;
import com.microsoft.graph.options.*;
import com.microsoft.graph.serializer.*;
import java.util.Arrays;
import java.util.EnumSet;
// **NOTE** This file was generated by a tool and any changes will be overwritten.
/**
* The class for the Base Report Root Get One Drive Usage Storage Request Builder.
*/
public class BaseReportRootGetOneDriveUsageStorageRequestBuilder extends BaseFunctionRequestBuilder {
/**
* The request builder for this ReportRootGetOneDriveUsageStorage
*
* @param requestUrl The request url
* @param client The service client
* @param requestOptions The options for this request
*/
public BaseReportRootGetOneDriveUsageStorageRequestBuilder(final String requestUrl, final IBaseClient client, final java.util.List<Option> requestOptions, final String period) {
super(requestUrl, client, requestOptions);
mFunctionOptions.add(new FunctionOption("period", period));
}
/**
* Creates the IReportRootGetOneDriveUsageStorageRequest
*
* @return The IReportRootGetOneDriveUsageStorageRequest instance
*/
public IReportRootGetOneDriveUsageStorageRequest buildRequest() {
return buildRequest(getOptions());
}
/**
* Creates the IReportRootGetOneDriveUsageStorageRequest with specific requestOptions instead of the existing requestOptions
*
* @param requestOptions the options for the request
* @return The IReportRootGetOneDriveUsageStorageRequest instance
*/
public IReportRootGetOneDriveUsageStorageRequest buildRequest(final java.util.List<Option> requestOptions) {
ReportRootGetOneDriveUsageStorageRequest request = new ReportRootGetOneDriveUsageStorageRequest(
getRequestUrl(),
getClient(),
requestOptions
);
for (FunctionOption option : mFunctionOptions) {
request.addFunctionOption(option);
}
return request;
}
}
|
[
"[email protected]"
] | |
1c1b896975951803b9caec282dbc3589e6cb4f58
|
9b33f64bfc56c249ff779fa72fb3d1b1f847f0e5
|
/app/src/main/java/es/tfandroid/roombarlauncher/FileUtils.java
|
d036426e5943e1c93b1cb48de48ebb3b22b5f812
|
[] |
no_license
|
fraggel/roombarlauncher
|
6efe1889d57e0ba22f28dad8818e8b161988a006
|
67b2a9bf8ff7fb16128d8543049453644564bf62
|
refs/heads/master
| 2021-01-25T09:08:45.584671 | 2018-11-14T19:13:55 | 2018-11-14T19:13:55 | 93,781,977 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 594 |
java
|
package es.tfandroid.roombarlauncher;
import java.io.File;
/**
* Static method for helping user to validates servers configurations
*/
public class FileUtils {
/**
* Check if required file exist
*
* @return boolean
*/
public static boolean checkIfExecutableExists() {
return new File(Constants.LIGHTTPD_SBIN_LOCATION).exists() &&
new File(Constants.PHP_SBIN_LOCATION).exists() &&
new File(Constants.MYSQL_DAEMON_SBIN_LOCATION).exists() &&
new File(Constants.MYSQL_MONITOR_SBIN_LOCATION).exists();
}
}
|
[
"[email protected]"
] | |
a03b0a37af02ed4b7be121092664a1b7e618bbab
|
1d3e7afa102d1ef79046229367f4931961f2d386
|
/src/main/java/com/linbit/linstor/api/model/ResourceDefinition.java
|
e792c8fb71098e551ff831f6dcdb8136fe849b92
|
[] |
no_license
|
LINBIT/linstor-api-java
|
99e115b36229c97b37d38ae0a31dcb4923c0b341
|
1cf072c4c7d79c2aa74761f7e0ed33df857ee7c7
|
refs/heads/master
| 2023-07-18T12:55:39.701778 | 2021-08-31T11:12:51 | 2021-08-31T11:12:51 | 356,216,454 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 7,418 |
java
|
/*
* Linstor REST API
*
*
* OpenAPI spec version: 1.10.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.linbit.linstor.api.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.linbit.linstor.api.model.Properties;
import com.linbit.linstor.api.model.ResourceDefinitionLayer;
import com.linbit.linstor.api.model.VolumeDefinition;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.List;
/**
* ResourceDefinition
*/
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2021-08-31T11:02:45.596Z[GMT]")
public class ResourceDefinition {
@JsonProperty("name")
private String name = "";
@JsonProperty("external_name")
private String externalName = null;
@JsonProperty("props")
private Properties props = null;
@JsonProperty("flags")
private List<String> flags = null;
@JsonProperty("layer_data")
private List<ResourceDefinitionLayer> layerData = null;
@JsonProperty("uuid")
private String uuid = null;
@JsonProperty("resource_group_name")
private String resourceGroupName = null;
@JsonProperty("volume_definitions")
private List<VolumeDefinition> volumeDefinitions = null;
public ResourceDefinition name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
**/
@Schema(example = "rsc1", description = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ResourceDefinition externalName(String externalName) {
this.externalName = externalName;
return this;
}
/**
* Get externalName
* @return externalName
**/
@Schema(description = "")
public String getExternalName() {
return externalName;
}
public void setExternalName(String externalName) {
this.externalName = externalName;
}
public ResourceDefinition props(Properties props) {
this.props = props;
return this;
}
/**
* Get props
* @return props
**/
@Schema(description = "")
public Properties getProps() {
return props;
}
public void setProps(Properties props) {
this.props = props;
}
public ResourceDefinition flags(List<String> flags) {
this.flags = flags;
return this;
}
public ResourceDefinition addFlagsItem(String flagsItem) {
if (this.flags == null) {
this.flags = new ArrayList<>();
}
this.flags.add(flagsItem);
return this;
}
/**
* Get flags
* @return flags
**/
@Schema(description = "")
public List<String> getFlags() {
return flags;
}
public void setFlags(List<String> flags) {
this.flags = flags;
}
public ResourceDefinition layerData(List<ResourceDefinitionLayer> layerData) {
this.layerData = layerData;
return this;
}
public ResourceDefinition addLayerDataItem(ResourceDefinitionLayer layerDataItem) {
if (this.layerData == null) {
this.layerData = new ArrayList<>();
}
this.layerData.add(layerDataItem);
return this;
}
/**
* Get layerData
* @return layerData
**/
@Schema(description = "")
public List<ResourceDefinitionLayer> getLayerData() {
return layerData;
}
public void setLayerData(List<ResourceDefinitionLayer> layerData) {
this.layerData = layerData;
}
public ResourceDefinition uuid(String uuid) {
this.uuid = uuid;
return this;
}
/**
* unique object id
* @return uuid
**/
@Schema(example = "e8ef8d6b-17bc-42f0-9367-4aae40c78ecb", description = "unique object id")
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public ResourceDefinition resourceGroupName(String resourceGroupName) {
this.resourceGroupName = resourceGroupName;
return this;
}
/**
* name of the linked resource group, if there is a link
* @return resourceGroupName
**/
@Schema(description = "name of the linked resource group, if there is a link")
public String getResourceGroupName() {
return resourceGroupName;
}
public void setResourceGroupName(String resourceGroupName) {
this.resourceGroupName = resourceGroupName;
}
public ResourceDefinition volumeDefinitions(List<VolumeDefinition> volumeDefinitions) {
this.volumeDefinitions = volumeDefinitions;
return this;
}
public ResourceDefinition addVolumeDefinitionsItem(VolumeDefinition volumeDefinitionsItem) {
if (this.volumeDefinitions == null) {
this.volumeDefinitions = new ArrayList<>();
}
this.volumeDefinitions.add(volumeDefinitionsItem);
return this;
}
/**
* Get volumeDefinitions
* @return volumeDefinitions
**/
@Schema(description = "")
public List<VolumeDefinition> getVolumeDefinitions() {
return volumeDefinitions;
}
public void setVolumeDefinitions(List<VolumeDefinition> volumeDefinitions) {
this.volumeDefinitions = volumeDefinitions;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ResourceDefinition resourceDefinition = (ResourceDefinition) o;
return Objects.equals(this.name, resourceDefinition.name) &&
Objects.equals(this.externalName, resourceDefinition.externalName) &&
Objects.equals(this.props, resourceDefinition.props) &&
Objects.equals(this.flags, resourceDefinition.flags) &&
Objects.equals(this.layerData, resourceDefinition.layerData) &&
Objects.equals(this.uuid, resourceDefinition.uuid) &&
Objects.equals(this.resourceGroupName, resourceDefinition.resourceGroupName) &&
Objects.equals(this.volumeDefinitions, resourceDefinition.volumeDefinitions);
}
@Override
public int hashCode() {
return Objects.hash(name, externalName, props, flags, layerData, uuid, resourceGroupName, volumeDefinitions);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ResourceDefinition {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" externalName: ").append(toIndentedString(externalName)).append("\n");
sb.append(" props: ").append(toIndentedString(props)).append("\n");
sb.append(" flags: ").append(toIndentedString(flags)).append("\n");
sb.append(" layerData: ").append(toIndentedString(layerData)).append("\n");
sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n");
sb.append(" resourceGroupName: ").append(toIndentedString(resourceGroupName)).append("\n");
sb.append(" volumeDefinitions: ").append(toIndentedString(volumeDefinitions)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
|
[
"[email protected]"
] | |
19f70635e1f6babaec075e099af869aec8cc42f1
|
e7c3690505f8ea4a907454ed945cc01d7c052eef
|
/src/Bai3/Triangle.java
|
7fea2d6e7af3b05e561e795cad9331976919c8ce
|
[] |
no_license
|
ThanhNuong/ThanhNuong_59131817_BTCreationalPattern
|
43635b418e41ee4243f86418e66523d1cbf562cd
|
dce8a95d855c41d56e056b66bede3173e2aea6be
|
refs/heads/master
| 2022-07-03T10:05:20.105318 | 2020-05-13T02:13:11 | 2020-05-13T02:13:11 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 627 |
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 Bai3;
/**
*
* @author Admin
*/
public class Triangle extends Shape{
public Triangle() {
System.out.println("\nChào các bạn! Đây là hình Triangle");
}
@Override
public String draw() {
brush ="Chuẩn bị vẽ bằng bút chì màu xanh";
paper ="\nchuẩn bị giấy vẽ màu hồng";
frame ="\nChuẩn bị khung vẽ A0";
return brush + paper + frame;
}
}
|
[
"[email protected]"
] | |
ddc0d4621d53ca63501efca056f01712b683b54b
|
5199e14992bca024a45e2b5e0cc0a1733cdc7cb9
|
/src/com/algo/Tentamen/TEN1_150317/uppgift4/BinarySearchTree.java
|
942930c63e42160ad4b45494b6f8b8b05d31170d
|
[] |
no_license
|
TimothyHolmsten/Algoritmer_Datastrukturer
|
f714718929aa4c605075442c6bb9040e01765ff9
|
1041e565c44c13f2945c08855e7b08da3f3a5105
|
refs/heads/master
| 2020-05-28T05:25:32.976012 | 2017-04-16T12:20:20 | 2017-04-16T12:20:20 | 82,582,478 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,837 |
java
|
package com.algo.Tentamen.TEN1_150317.uppgift4;
public class BinarySearchTree<E extends Comparable<E>> {
private Node<E> root;
public BinarySearchTree() {
root = null;
}
private boolean add(E data, Node<E> node) {
if (data.compareTo(node.data) == 0)
return false;
else if (data.compareTo(node.data) < 0)
if (node.left == null) {
node.left = new Node<E>(data);
return true;
} else
return add(data, node.left);
else if (node.right == null) {
node.right = new Node<E>(data);
return true;
} else
return add(data, node.right);
}
public boolean add(E data) {
if (root == null) {
root = new Node<E>(data);
return true;
} else {
return add(data, root);
}
}
public E find(E target) {
return find(target, root);
}
private E find(E target, Node<E> node) {
while (node != null) {
if (target.compareTo(node.data) < 0)
node = node.left;
else if (target.compareTo(node.data) > 0)
node = node.right;
else
return node.data;
}
return null;
}
public void printTree() {
StringBuilder sb = new StringBuilder();
printTree(root, sb);
System.out.println(sb.toString());
}
private void printTree(Node<E> node, StringBuilder sb) {
}
private static class Node<E> {
private E data;
private Node<E> left, right;
private Node(E d) {
data = d;
left = right = null;
}
@Override
public String toString() {
return data.toString();
}
}
}
|
[
"[email protected]"
] | |
9b12ee4509a6c3fec86ae85328e0d1120aeeebc3
|
395db7bc1c7c166ecfdfa092434634f907001c87
|
/ma-gpro-gpao/ma-gpro-gpao-persistance/src/main/java/com/gpro/consulting/tiers/gpao/persitance/fichecolisage/entity/FicheColisageEntity.java
|
899169cf035fd7eb26486c78b0e5bc3575ce162a
|
[] |
no_license
|
anouarbensaad/habillement
|
2c4aea85511bae5cef00b5b0fc200b8c1973219f
|
4d6c395300c3eff0a81b38d68d0e0873c130f7b6
|
refs/heads/master
| 2022-02-19T10:14:15.442154 | 2019-09-26T19:09:02 | 2019-09-26T19:09:02 | 204,194,945 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 6,869 |
java
|
package com.gpro.consulting.tiers.gpao.persitance.fichecolisage.entity;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import com.gpro.consulting.tiers.gpao.coordination.IConstante;
@Entity
@Table(name=IConstante.TABLE_GP_FICHECOLISAGE)
public class FicheColisageEntity implements Serializable{
private static final long serialVersionUID = -3004815224021179635L;
@Id
@SequenceGenerator(name="FICHECOLISAGE_ID_GENERATOR", sequenceName=IConstante.SEQUENCE_GP_FICHECOLISAGE, allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="FICHECOLISAGE_ID_GENERATOR")
private Long id;
@Column(name = "DATE_LANCEMENT")
private Calendar dateLancement;
@Column(name = "OBSERVATIONS")
private String observations;
@Column(name = "GP_OF_ID")
private Long ordreFabricationId;
@Column(name = "NOMBRE_COLIS")
private Long nombreColis;
@Column(name = "QUANTITE_COLIS")
private Long quantiteColis;
@OneToMany(mappedBy = "ficheColisage", cascade = CascadeType.ALL, orphanRemoval=true)
private Set<ColisEntity> listColis;
@OneToMany(mappedBy = "ficheColisage", cascade = CascadeType.ALL, orphanRemoval=true)
private Set<DetailsColisageEntity> listDetails;
@Column(name = "BL_SUPPRESSION")
private Boolean blSuppression;
@Column(name = "DATE_SUPPRESSION")
private Calendar dateSuppression;
@Column(name = "DATE_CREATION")
private Calendar dateCreation;
@Column(name = "DATE_MODIFICATION")
private Calendar dateModification;
@Column(name = "VERSION")
private String version;
@Column(name = "NUMERO_OF")
private String numeroOf ;
@Column(name = "SEMAINE")
private String semaine;
// @Column(name = "REFERENCE")
// private String reference ;
//
// @Column(name = "DESIGNATON")
// private String designation ;
//
@Column(name = "QUANTITE_TOTALE")
private Long quantiteTotale ;
@Column(name = "PRODUIT_ID")
private Long produitId;
@Column(name = "PRODUIT_REFERENCE")
private String produitReference;
@Column(name = "PRODUIT_DESIGNATION")
private String produitDesignation;
@Column(name = "CLIENT_ID")
private Long clientId;
@Column(name = "CLIENT_ABREVIATION")
private String clientAbreviation;
@Column(name = "CLIENT_REFERENCE")
private String clientReference;
@Column(name = "COULEUR")
private String couleur ;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Calendar getDateLancement() {
return dateLancement;
}
public void setDateLancement(Calendar dateLancement) {
this.dateLancement = dateLancement;
}
public String getObservations() {
return observations;
}
public void setObservations(String observations) {
this.observations = observations;
}
public Long getOrdreFabricationId() {
return ordreFabricationId;
}
public void setOrdreFabricationId(Long ordreFabricationId) {
this.ordreFabricationId = ordreFabricationId;
}
public Boolean getBlSuppression() {
return blSuppression;
}
public void setBlSuppression(Boolean blSuppression) {
this.blSuppression = blSuppression;
}
public Calendar getDateSuppression() {
return dateSuppression;
}
public void setDateSuppression(Calendar dateSuppression) {
this.dateSuppression = dateSuppression;
}
public Calendar getDateCreation() {
return dateCreation;
}
public void setDateCreation(Calendar dateCreation) {
this.dateCreation = dateCreation;
}
public Calendar getDateModification() {
return dateModification;
}
public void setDateModification(Calendar dateModification) {
this.dateModification = dateModification;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Long getNombreColis() {
return nombreColis;
}
public void setNombreColis(Long nombreColis) {
this.nombreColis = nombreColis;
}
public Long getQuantiteColis() {
return quantiteColis;
}
public void setQuantiteColis(Long quantiteColis) {
this.quantiteColis = quantiteColis;
}
public Set<ColisEntity> getListColis() {
return listColis;
}
public void setListColis(Set<ColisEntity> listColis) {
this.listColis = listColis;
}
public Set<DetailsColisageEntity> getListDetails() {
return listDetails;
}
public void setListDetails(Set<DetailsColisageEntity> listDetails) {
this.listDetails = listDetails;
}
public String getNumeroOf() {
return numeroOf;
}
public void setNumeroOf(String numeroOf) {
this.numeroOf = numeroOf;
}
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public String getDesignation() {
// return designation;
// }
//
// public void setDesignation(String designation) {
// this.designation = designation;
// }
public Long getQuantiteTotale() {
return quantiteTotale;
}
public void setQuantiteTotale(Long quantiteTotale) {
this.quantiteTotale = quantiteTotale;
}
public Long getProduitId() {
return produitId;
}
public void setProduitId(Long produitId) {
this.produitId = produitId;
}
public String getProduitReference() {
return produitReference;
}
public void setProduitReference(String produitReference) {
this.produitReference = produitReference;
}
public String getProduitDesignation() {
return produitDesignation;
}
public void setProduitDesignation(String produitDesignation) {
this.produitDesignation = produitDesignation;
}
public Long getClientId() {
return clientId;
}
public void setClientId(Long clientId) {
this.clientId = clientId;
}
public String getClientAbreviation() {
return clientAbreviation;
}
public void setClientAbreviation(String clientAbreviation) {
this.clientAbreviation = clientAbreviation;
}
public String getClientReference() {
return clientReference;
}
public void setClientReference(String clientReference) {
this.clientReference = clientReference;
}
public String getCouleur() {
return couleur;
}
public void setCouleur(String couleur) {
this.couleur = couleur;
}
public String getSemaine() {
return semaine;
}
public void setSemaine(String semaine) {
this.semaine = semaine;
}
}
|
[
"[email protected]"
] | |
87d511a92e380a7d3e36facd56cd6037f513a811
|
b7f369b7c920802ee1d0f629314634941492099f
|
/BeeeOn/app/src/main/java/com/rehivetech/beeeon/gui/view/CircleTransformation.java
|
02301047e9b7be2e65e3f2d1df20482ae23126bc
|
[
"BSD-3-Clause"
] |
permissive
|
BeeeOn/android
|
d974b81a5e358f0e39be90bc7fd407821caef40d
|
a7189089594f1b79c97919fc18032f82698c47b2
|
refs/heads/master
| 2021-01-17T14:13:10.842428 | 2017-03-26T16:26:52 | 2017-03-26T16:26:52 | 47,215,894 | 10 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,832 |
java
|
package com.rehivetech.beeeon.gui.view;
/*
* Copyright 2014 Julian Shen
*
* 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.
*/
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import com.squareup.picasso.Transformation;
public class CircleTransformation implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if(squaredBitmap != source) {
source.recycle();
}
// GIF files generate null configs, assume ARGB_8888
Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = Bitmap.createBitmap(size, size, config);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
squaredBitmap.recycle();
return bitmap;
}
@Override
public String key() {
return "circle";
}
}
|
[
"[email protected]"
] | |
e6cb688895987e4afbec55e7bf69ccd1af885c62
|
e836986a441d8618d6d5b981bcf09272a4d41c10
|
/app/src/main/java/com/codepath/instagram/activities/HomeActivity.java
|
1fb5c8a35ba175483e6731087899270c25f59f09
|
[
"Apache-2.0"
] |
permissive
|
marcojmar/HW-1
|
43342deea0cd34836ccca18e2ddc0caffa80da70
|
5af6002d60c753be265a5950186cccd472934aad
|
refs/heads/master
| 2021-01-10T07:54:12.602430 | 2015-10-28T01:36:50 | 2015-10-28T01:36:50 | 45,078,037 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,065 |
java
|
package com.codepath.instagram.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import com.codepath.instagram.R;
import com.codepath.instagram.helpers.Utils;
import com.codepath.instagram.models.InstagramComment;
import com.codepath.instagram.models.InstagramImage;
import com.codepath.instagram.models.InstagramPost;
import com.codepath.instagram.models.InstagramUser;
import com.facebook.drawee.backends.pipeline.Fresco;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
public class HomeActivity extends AppCompatActivity {
private static final String TAG = "HomeActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_posts);
List<InstagramPost> instagramPosts = fetchPost();
RecyclerView rvPosts = (RecyclerView) findViewById(R.id.rvPosts);
PostsAdapter adapter = new PostsAdapter(instagramPosts, this);
// create adapter
rvPosts.setAdapter(adapter);
// set adapter
rvPosts.setLayoutManager(new LinearLayoutManager(this));
}
@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_home, 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);
}
public List<InstagramPost> fetchPost() {
List<InstagramPost> allPosts = null;
try {
JSONObject jsonObject = (JSONObject) Utils.loadJsonFromAsset(this, "popular.json");
allPosts = Utils.decodePostsFromJsonResponse(jsonObject);
}
catch (Exception e) {
e.getStackTrace();
}
return allPosts;
}
private void readPost(InstagramPost post) {
String imageUrl = post.image.imageUrl;
String fullName = post.user.fullName;
int likesCount = post.likesCount;
long createTime = post.createdTime;
String[] captions;
String comment = null;
String hashtag = null;
if (post.caption != null) {
captions = post.caption.split(" #");
comment = captions[0];
hashtag = "#" + captions[1];
}
int i =1;
}
}
|
[
"[email protected]"
] | |
fe3d9ede582741120f687af787900905a7140463
|
0b90c8d863f81cac34e9ec84037e8c441cae94aa
|
/spring-boot-shiro-dynamic-permission-sample/src/main/java/com/example/springboot/shiro/mapper/UserMapper.java
|
33d1e9955d9d42f3619e21e1c00b7097cb3728a7
|
[
"Apache-2.0"
] |
permissive
|
yiminyangguang520/shiro-sample
|
754a4ab15fab06533be6cce4640cfddb8571a6d7
|
2309424461d213764c84a39454d1397cf1e97015
|
refs/heads/master
| 2022-12-28T00:58:36.645575 | 2020-04-17T00:59:17 | 2020-04-17T00:59:52 | 140,244,097 | 1 | 1 |
Apache-2.0
| 2022-11-24T10:17:58 | 2018-07-09T06:58:54 |
Java
|
UTF-8
|
Java
| false | false | 360 |
java
|
package com.example.springboot.shiro.mapper;
import com.example.springboot.shiro.entity.User;
import java.util.List;
import org.springframework.stereotype.Repository;
/**
* @author min
*/
@Repository
public interface UserMapper {
User findUserByUserName(String username);
List<User> findAllUsers();
List<User> findUsersByRoleId(Integer roleId);
}
|
[
"[email protected]"
] | |
3152202607524d7de72eea178740026b6dec4cf5
|
ff3a61c2979ef01b8dad763fc6eabed555ae7fe9
|
/src/cn/edu/bnu/land/model/AHP.java
|
81f6502721e52d3345b298cc0e484c11a53be15f
|
[] |
no_license
|
bnu-land/tdlz
|
8b277e8f41ef9edea5a84c95202e90faa712eb9e
|
474a1da97a5b7296c52c08daa4b594908c73f127
|
refs/heads/master
| 2021-01-10T14:15:27.853720 | 2015-10-21T10:51:02 | 2015-10-21T10:51:02 | 44,668,212 | 2 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,764 |
java
|
package cn.edu.bnu.land.model;
import java.util.HashMap;
public class AHP {
static int n;// 鐭╅樀鐨勯樁鏁�
double cal[][];// 灞傛姣旇緝鐭╅樀,褰掍竴鍖栧悗鐨�
double cal1[][];// 灞傛姣旇緝鐭╅樀
static HashMap hm = null;// 灏�2闃剁殑鎴愬姣旇緝鐭╅樀鐨勫钩鍧囬殢鏈轰竴鑷存�鎸囨爣鍊间繚瀛樺湪鍝堝笇鏄犲皠琛ㄩ噷
// 璁剧疆骞冲潎闅忔満涓�嚧鎬ф寚鏍囧�
public static void setHm() {
hm = new HashMap();
hm.put(1, 0);
hm.put(2, 0);
hm.put(3, 0.58);
hm.put(4, 0.89);
hm.put(5, 1.12);
hm.put(6, 1.24);
hm.put(7, 1.32);
hm.put(8, 1.41);
hm.put(9, 1.45);
hm.put(10, 1.49);
hm.put(11, 1.52);
hm.put(12, 1.54);
}
public int getN() {
return n;
}
public void setN(int n) {
this.n = n;
}
// 鍘熷鎴愬姣旇緝鐭╅樀鍒楀悜閲忕殑褰掍竴鍖�
public void colvectortoone(double arr[])// 鍒楀悜閲忕殑褰掍竴鍖�
{
arr = new double[n];
// System.out.println("姣忓垪姹傚姞鍜屽紑濮�);
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
arr[j] += cal[i][j];// 姣忓垪姹傚姞鍜�
}
}
// System.out.println("姣忓垪姹傚姞鍜屽畬姣�);
// System.out.println("鎵撳嵃琛屽�鍜岃繘琛岄獙璇佸紑濮�);
for (int i = 0; i < n; i++) {
System.out.println(arr[i]);// 鎵撳嵃琛屽�鍜岃繘琛岄獙璇�
}
// System.out.println("鎵撳嵃琛屽�鍜岃繘琛岄獙璇佸畬姣�);
System.out.println("鍒楀悜閲忓綊涓�寲寮�");
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
cal[i][j] = cal[i][j] / arr[j];// 鍒楀悜閲忓綊涓�寲
}
}
System.out.println("鍒楀悜閲忓綊涓�寲瀹屾瘯");
// System.out.println("鎵撳嵃褰掍竴鍖栧悗鐨勬暟缁勫紑濮�);
for (int j = 0; j < n; j++)// 鎵撳嵃褰掍竴鍖栧悗鐨勬暟缁�
{
for (int i = 0; i < n; i++) {
System.out.print(cal[j][i] + "\t");// 鍒楀悜閲忓綊涓�寲
}
System.out.println();
}
// System.out.println("鎵撳嵃褰掍竴鍖栧悗鐨勬暟缁勭粨鏉�);
}
// 寰楀埌褰掍竴鍖栫煩闃靛悇琛岀殑琛屽拰
public double[] rowsum(double arr1[])// 鎸夎姹傚拰,骞惰繑鍥炴眰寰楃殑鏁扮粍
{
arr1 = new double[n];
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
arr1[j] += cal[j][i];// 姣忚姹傚姞鍜�
}
}
System.out.println("琛屽拰鎵撳嵃楠岃瘉寮�");
for (int j = 0; j < n; j++) {
System.out.println(arr1[j]);
}
System.out.println("琛屽拰鎵撳嵃楠岃瘉缁撴潫");
// 浠ヤ笅瀵筧rr1[]杩涜褰掍竴鍖�
double sum = 0;
for (int i = 0; i < n; i++) {
sum += arr1[i];
}
// System.out.println("鍚戦噺褰掍竴鍖栬绠楀紑濮�);
for (int i = 0; i < n; i++)// 寰楀埌鏉冮噸
{
arr1[i] = arr1[i] / sum;
}
// System.out.println("鍚戦噺褰掍竴鍖栬绠楃粨鏉�);
System.out.println("鎵撳嵃鏉冮噸寮�");
for (int j = 0; j < n; j++) {
System.out.println(arr1[j]);
}
System.out.println("鎵撳嵃鏉冮噸缁撴潫");
return arr1;
}
// 姹傛渶澶х壒寰佸�
public double getnamda(double arr1[], double arr2[]) {
arr2 = new double[n];
for (int j = 0; j < n; j++) {
for (int i = 0; i < n; i++) {
arr2[j] += cal1[j][i] * arr1[i];// 寰楀埌A*w
}
}
System.out.println("鎵撳嵃A*w寮�");
for (int i = 0; i < n; i++) {
System.out.println(arr2[i]);// 鎵撳嵃鏉冮噸鍚戦噺
}
System.out.println("鎵撳嵃A*w缁撴潫");
double L = 0;// 5*namda
for (int i = 0; i < n; i++) {
L += arr2[i] / arr1[i];
}
double namda = L / n;
return namda;
}
}
|
[
"[email protected]"
] | |
7e163e3a23342e1f9741412bb799c9c3dc1e315b
|
71afaacbc40bea2eec3e29dfd2fffadc11cd71fc
|
/game/GameLev.java
|
b73f129d39a6d18c6a45d13802092a5e6621811d
|
[] |
no_license
|
Hamz-06/java_game
|
37080d7d4cb2b6b5bf5838f9bcff6a2e31a50791
|
0935f4d35d0263136280dfb910952527d771fd67
|
refs/heads/main
| 2023-09-03T00:36:03.267789 | 2021-10-20T18:17:18 | 2021-10-20T18:17:18 | 416,861,426 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,053 |
java
|
package game;
import city.cs.engine.World;
import objects.chest;
import org.jbox2d.common.Vec2;
import player.EnemyPlayer;
import player.myPlayer;
import update.PlayerCollision;
import java.io.IOException;
public abstract class GameLev extends World {
private myPlayer player;
private PlayerCollision diamondPickup;
private myGame game;
public GameLev(myGame game){
this.game = game;
player = new myPlayer(this , game); //Create player
diamondPickup = new PlayerCollision(player , game , this); //creates collision listener
player.addCollisionListener(diamondPickup); //adds lisnter to player
}
public myPlayer getPlayer() {
return player;
} // return player
public abstract boolean isComplete();
public abstract chest[] getChest();
public abstract EnemyPlayer[] getEnemy();
public abstract String getLevel();
public abstract int getEnemyCount();
}
//collision diamondPickup = new collision(myplayer);
//
|
[
"[email protected]"
] | |
bf96e77a0d91d8ef4b46e5dbe0e4cc5d785e3d96
|
ee70f137f4ae15cdcf9345db48f3ddb9dd244037
|
/ServletJSP/7.MusicBox/src/main/java/ru/napadovskiu/servlets/EditUserServlets.java
|
ecbe33872aa8ba8000349761fbc88a4f0182840a
|
[
"Apache-2.0"
] |
permissive
|
BohdanNapadovskiy/jvm-byte-code
|
1289478aa89d7d3c60bcdad19db324932ecc8e93
|
aa77c5fdede7d74c84cd4bf00e46f6d927fa9b3e
|
refs/heads/master
| 2023-01-22T03:57:48.684484 | 2020-12-07T18:01:38 | 2020-12-07T18:01:38 | 319,394,258 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,918 |
java
|
package ru.napadovskiu.servlets;
import ru.napadovskiu.entities.Address;
import ru.napadovskiu.entities.MusicType;
import ru.napadovskiu.entities.Role;
import ru.napadovskiu.entities.User;
import ru.napadovskiu.store.AddressStore;
import ru.napadovskiu.store.MusicStore;
import ru.napadovskiu.store.RoleStore;
import ru.napadovskiu.store.UserStore;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
*
*/
public class EditUserServlets extends HttpServlet {
/**
*
*/
private final UserStore usersStore = UserStore.INSTANCE;
private final AddressStore addressStore = AddressStore.INSTANCE;
private final RoleStore roleStore = RoleStore.INSTANCE;
private final MusicStore musicStore = MusicStore.INSTANCE;
private List<MusicType> takeListMusicType(String[] arrayTypeMusic) {
List<MusicType> musicTypeList = new CopyOnWriteArrayList<>();
if (arrayTypeMusic !=null && arrayTypeMusic.length !=0) {
for (String typeMusic: arrayTypeMusic) {
MusicType musicType = musicStore.getByName(typeMusic);
musicTypeList.add(musicType);
}
}
return musicTypeList;
}
private void addMusicTypeListToUser(User user, List<MusicType> list) {
for (MusicType musicType: list) {
if (!usersStore.isUserHaveMusicType(user, musicType)) {
musicStore.addMusicToUser(user, musicType);
}
}
}
/**
*
* @param req
* @param resp
* @throws ServletException
* @throws IOException
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html");
int userId = Integer.parseInt(req.getParameter("userId"));
int roleId = Integer.parseInt(req.getParameter("roleId"));
User editUser = usersStore.getById(userId);
Role role = roleStore.getById(roleId);
req.setAttribute("editUser", editUser);
req.setAttribute("role", role.getUser_role());
RequestDispatcher rd = req.getRequestDispatcher("/WEB-INF/views/edit.jsp");
rd.forward(req, resp);
}
/**
*
* @param req
* @param resp
* @throws IOException
*/
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
resp.setContentType("text/html");
int userId = Integer.parseInt(req.getParameter("userId"));
User editUser = usersStore.getById(userId);
editUser.setName(req.getParameter("name"));
editUser.setPassword(req.getParameter("password"));
editUser.setLogin(req.getParameter("login"));
Role role = roleStore.getByName(req.getParameter("role"));
editUser.setRole(role);
usersStore.updateRoleInUser(editUser, role);
Address editAddress = addressStore.getByName(req.getParameter("address"));
if (editAddress == null) {
editAddress = new Address(req.getParameter("address"));
if (addressStore.create(editAddress)) {
editAddress = addressStore.getByName(editAddress.getAddress_name());
}
}
usersStore.updateAddressInUser(editUser,editAddress);
editUser.setAddress(editAddress);
List<MusicType> musicTypes = takeListMusicType(req.getParameterValues("music"));
if (musicTypes.size() != 0 ) {
addMusicTypeListToUser(editUser,musicTypes);
}
req.getRequestDispatcher("/WEB-INF/views/usersView.jsp").forward(req, resp);
}
}
|
[
"[email protected]"
] | |
be52d158323d50619b6af9b805a3bbc34c4ba7fb
|
7beb3def8ee38125132b01c0b74830a10ff1480c
|
/src/main/test/com/sk/test/Test.java
|
f6aeafb20a4f9ba4531d5caf0896cb6cbc0f45b9
|
[] |
no_license
|
sandeep-temp/socket-server
|
651e4a38c7ee8b50cff2c663e6ba2f6ce3f84a1f
|
ecb09efd4ee6a3c95d02122622096d67157f80ed
|
refs/heads/master
| 2021-01-23T13:31:59.876948 | 2015-04-17T04:57:43 | 2015-04-17T04:57:43 | 34,097,409 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 666 |
java
|
package com.sk.test;
import java.io.IOException;
public class Test {
public static void main(String[] args) {
long startTime = System.nanoTime();
try {
long count = 0;
while (true) {
String command = "curl -X GET http://localhost:8123/api/request?timeout=1&connId="
+ count;
Runtime.getRuntime().exec(command);
count++;
long currentRunningTime = System.nanoTime() - startTime;
System.out.println((double)(count*100000000) / (double)currentRunningTime);
Thread.sleep(0, 10000);
}
} catch (IOException e) {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
|
[
"[email protected]"
] | |
00d1b66d1df34166ed37e829b8322174e6141d48
|
b90cdb4c1d3e66355342a05fb497f3d185a7bdb1
|
/Assignment 5/RandomInts.java
|
75ba2892bdc657b6c69917f5873e3c5f6909d50c
|
[] |
no_license
|
mosest/11th-CP1-pt2
|
47d526f5d9252939c3aee4f7dc921294061b9ae2
|
f46fca2a8c0166845845dc9c1237f046d99149c2
|
refs/heads/master
| 2021-01-18T14:06:29.859895 | 2015-09-14T22:14:27 | 2015-09-14T22:14:27 | 42,431,473 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 625 |
java
|
//Tara Moses
//Assignment 5.4: Random Integers
//July 19, 2013
public class RandomInts
{
public static void main(String[] args)
{
System.out.println("-----5.4: RANDOM INTEGERS-----\n");
int sum=0;
int min=43;
int max=0;
int[] nums=new int[100];
for (int i=0;i<100;i++)
{
int newInt=(int)(Math.random()*33+10);
nums[i]=newInt;
System.out.println(newInt);
sum+=newInt;
min=Math.min(min,newInt);
max=Math.max(max,newInt);
}
double average=sum*1.0/100;
System.out.println("\nAverage: "+average);
System.out.println("Max: "+max);
System.out.println("Min: "+min+"\n");
}
}
|
[
"[email protected]"
] | |
794bdb5b09bce73c83ee36e385ff2e727220434d
|
228ed08f0c496a9c4f522eda16de147582124dde
|
/runWithWind-protal/src/main/java/com/runwithwind/project/demo/domain/GoodsModel.java
|
76a36e4e63a5f4d6b40370b59ebc195ad1ee3f54
|
[] |
no_license
|
tangminnan/suifengbenpao
|
b2e6d676a8f5b31dc557874ed5f80ce98e04090b
|
0ba6b38ba2eead027c11642a1f0f583cc805ef14
|
refs/heads/master
| 2023-04-16T03:32:17.724145 | 2021-04-25T10:59:41 | 2021-04-25T10:59:41 | 361,402,249 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,638 |
java
|
package com.runwithwind.project.demo.domain;
import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 商品测试信息
*
* @author runwithwind
*/
public class GoodsModel
{
/**
* 商品名称
*/
private String name;
/**
* 商品重量
*/
private Integer weight;
/**
* 商品价格
*/
private Double price;
/**
* 商品日期
*/
private Date date;
/**
* 商品种类
*/
private String type;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Integer getWeight()
{
return weight;
}
public void setWeight(Integer weight)
{
this.weight = weight;
}
public Double getPrice()
{
return price;
}
public void setPrice(Double price)
{
this.price = price;
}
public Date getDate()
{
return date;
}
public void setDate(Date date)
{
this.date = date;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("weight", getWeight())
.append("price", getPrice())
.append("date", getDate())
.append("type", getType())
.toString();
}
}
|
[
"[email protected]"
] | |
6cb7aa90ad87a7180fc437c9ba161ac4911f1e51
|
83ce1f74d83aeb0261a5772365c81ce7ba26e6d6
|
/src/main/java/com/Jaysun/Jaysun/Entity/Cellule.java
|
0e2a8c5ae28bf4e5cad4a34c20ef44f11f4bedfc
|
[] |
no_license
|
saliou-tech/jaysun-api
|
a674d1952a77643c3a488d9cafa054959ac433a2
|
a7100393c97b8722a7e55b8869954d2e8d5434ca
|
refs/heads/main
| 2023-05-04T03:18:57.251152 | 2021-05-18T16:14:34 | 2021-05-18T16:14:34 | 368,593,720 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,718 |
java
|
package com.Jaysun.Jaysun.Entity;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import javax.persistence.*;
import java.util.Collection;
@Entity
public class Cellule {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String nomcellule;
private Long effectif;
private Long nombredeSection;
private String Jeuwrin;
private String Adjoint;
private String Trésorier;
private String PdtCOM;
private String PdtOrganisation;
private String PdtCulturel;
private String PdtSaytou;
private String PdtSocial;
private String PdtCommite;
private String PdtFeminine;
private String coordonateurPrincipal;
private String coordonateurDeSection;
@OneToMany(mappedBy = "cellule")
@JsonManagedReference
private Collection<Membre> membres;
public Collection<Membre> getMembres() {
return membres;
}
public void setMembres(Collection<Membre> membres) {
this.membres = membres;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNomcellule() {
return nomcellule;
}
public void setNomcellule(String nomcellule) {
this.nomcellule = nomcellule;
}
public Long getEffectif() {
return effectif;
}
public void setEffectif(Long effectif) {
this.effectif = effectif;
}
public Long getNombredeSection() {
return nombredeSection;
}
public void setNombredeSection(Long nombredeSection) {
this.nombredeSection = nombredeSection;
}
public String getJeuwrin() {
return Jeuwrin;
}
public void setJeuwrin(String jeuwrin) {
Jeuwrin = jeuwrin;
}
public String getAdjoint() {
return Adjoint;
}
public void setAdjoint(String adjoint) {
Adjoint = adjoint;
}
public String getTrésorier() {
return Trésorier;
}
public void setTrésorier(String trésorier) {
Trésorier = trésorier;
}
public String getPdtCOM() {
return PdtCOM;
}
public void setPdtCOM(String pdtCOM) {
PdtCOM = pdtCOM;
}
public String getPdtOrganisation() {
return PdtOrganisation;
}
public void setPdtOrganisation(String pdtOrganisation) {
PdtOrganisation = pdtOrganisation;
}
public String getPdtCulturel() {
return PdtCulturel;
}
public void setPdtCulturel(String pdtCulturel) {
PdtCulturel = pdtCulturel;
}
public String getPdtSaytou() {
return PdtSaytou;
}
public void setPdtSaytou(String pdtSaytou) {
PdtSaytou = pdtSaytou;
}
public String getPdtSocial() {
return PdtSocial;
}
public void setPdtSocial(String pdtSocial) {
PdtSocial = pdtSocial;
}
public String getPdtCommité() {
return PdtCommite;
}
public void setPdtCommité(String pdtCommité) {
PdtCommite = pdtCommité;
}
public String getPdtFeminine() {
return PdtFeminine;
}
public void setPdtFeminine(String pdtFeminine) {
PdtFeminine = pdtFeminine;
}
public String getCoordonateurPrincipal() {
return coordonateurPrincipal;
}
public void setCoordonateurPrincipal(String coordonateurPrincipal) {
this.coordonateurPrincipal = coordonateurPrincipal;
}
public String getCoordonateurDeSection() {
return coordonateurDeSection;
}
public void setCoordonateurDeSection(String coordonateurDeSection) {
this.coordonateurDeSection = coordonateurDeSection;
}
}
|
[
"[email protected]"
] | |
ff61542673b856f446ae3bd3d26fade284d44d28
|
98e8ec6214edbf59bf042a65f754d68611805e15
|
/src/model/design/singleton/Test02.java
|
90fde484243ddcad08aa8cf6abbf505437567bad
|
[] |
no_license
|
guliangliang/zJavaDemo
|
61f9d048d12aedf770e8fb25f0cf85fed1105fcb
|
eaac549a5c5a77c2e854976c3f2d2655ba9835c3
|
refs/heads/master
| 2021-01-10T11:00:51.361470 | 2020-12-31T03:02:15 | 2020-12-31T03:02:15 | 47,619,298 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,050 |
java
|
package model.design.singleton;
/**
* 懒汉式
* @author liang.gu
* @date 2020/12/30
*/
public class Test02 {
public static void main(String[] args) {
Singleton.getInstance();
}
}
//饿汉式
class Singleton1{
//1 构造器私有化
private Singleton1(){
}
private static Singleton1 instance;
public static Singleton1 getInstance(){
if(instance == null) {
instance = new Singleton1();
}
return instance;
}
//线程安全,但是效率太低
// public synchronized static Singleton1 getInstance(){
// if(instance == null) {
// instance = new Singleton1();
// }
// return instance;
// }
//线程不安全,没有意义;只要进入if判断中,就会执行创建,没有意义
// public static Singleton1 getInstance(){
// if(instance == null) {
// synchronized(Singleton1.class) {
// instance = new Singleton1();
// }
// }
// return instance;
// }
}
|
[
"[email protected]"
] | |
b761e9df49122bf918ad51391ee6398dc6d5ff7a
|
3476915d393a562e547a7b0efd7536daa25e1103
|
/src/main/java/com/wangrollin/leetcode/n0_normal/p1600/p1650/problem1652/Solution1.java
|
d064e804566292b708051423ddfa79bfee4e835a
|
[
"Apache-2.0"
] |
permissive
|
wangrollin/leetcode-java
|
3c4987fb67685571c5332e4b5e23172eec54e4c0
|
82b8e029ebad195db082fa4453f1852d88b76062
|
refs/heads/master
| 2023-04-16T14:23:53.605531 | 2021-04-29T16:17:55 | 2021-04-29T16:17:55 | 218,214,448 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,863 |
java
|
package com.wangrollin.leetcode.n0_normal.p1600.p1650.problem1652;
import java.util.Arrays;
/**
* 拆炸弹
*
* 你有一个炸弹需要拆除,时间紧迫!你的情报员会给你一个长度为n的循环数组code以及一个密钥k。
* 为了获得正确的密码,你需要替换掉每一个数字。所有数字会同时被替换。
* 如果k > 0,将第i个数字用 接下来k个数字之和替换。
* 如果k < 0,将第i个数字用 之前k个数字之和替换。
* 如果k == 0,将第i个数字用0替换。
* 由于code是循环的,code[n-1]下一个元素是code[0],且code[0]前一个元素是code[n-1]。
* 给你 循环数组code和整数密钥k,请你返回解密后的结果来拆除炸弹!
*
* 示例 1:
* 输入:code = [5,7,1,4], k = 3
* 输出:[12,10,16,13]
* 解释:每个数字都被接下来 3 个数字之和替换。解密后的密码为 [7+1+4, 1+4+5, 4+5+7, 5+7+1]。注意到数组是循环连接的。
*
* 示例 2:
* 输入:code = [1,2,3,4], k = 0
* 输出:[0,0,0,0]
* 解释:当 k 为 0 时,所有数字都被 0 替换。
*
* 示例 3:
* 输入:code = [2,4,9,3], k = -2
* 输出:[12,5,6,13]
* 解释:解密后的密码为 [3+9, 2+3, 4+2, 9+4] 。注意到数组是循环连接的。如果 k 是负数,那么和为 之前 的数字。
*
* 提示:
* n == code.length
* 1 <= n<= 100
* 1 <= code[i] <= 100
* -(n - 1) <= k <= n - 1
*
* 来源:力扣(LeetCode)
* 链接:https://leetcode-cn.com/problems/defuse-the-bomb
*
* Solution1
* 模拟计算
*/
public class Solution1 {
public int[] decrypt(int[] code, int k) {
int[] result = new int[code.length];
if (k == 0) {
Arrays.fill(result, 0);
return result;
}
int start, end;
if (k > 0) {
start = getNextIndex(code, 0);
end = k % code.length;
} else {
start = (code.length - Math.abs(k)) % code.length;
end = (code.length - 1) % code.length;
}
int sum = 0;
if (start == end) {
sum = code[start];
} else if (start < end) {
for (int i = start; i <= end; i++) {
sum += code[i];
}
} else {
for (int i = start; i < code.length; i++) {
sum += code[i];
}
for (int i = 0; i <= end; i++) {
sum += code[i];
}
}
for (int i = 0; i < code.length; i++) {
result[i] = sum;
sum -= code[start];
start = getNextIndex(code, start);
end = getNextIndex(code, end);
sum += code[end];
}
return result;
}
private int getNextIndex(int[] code, int curIndex) {
return (curIndex + 1) % code.length;
}
}
|
[
"[email protected]"
] | |
45f432c0bd4b29dcd20f3a30d997c9e7b3b0833d
|
8e5fde0772c6925a1c78406dce3a6f4d2668330d
|
/app/src/main/java/edu/tesis/healthyfood/EditaReceta.java
|
6bc7c620e614ed108e3bbed36eaf4384fb356860
|
[
"Apache-2.0"
] |
permissive
|
lfmexi/HealtyFood
|
ee7399e0b5bcf8dc3888abfd0ed03fc147cc45e8
|
48fa95f562c9c5215435421efe965347e520e877
|
refs/heads/master
| 2020-05-17T00:42:27.218357 | 2015-10-01T19:55:02 | 2015-10-01T19:55:02 | 24,485,862 | 1 | 0 | null | null | null | null |
ISO-8859-1
|
Java
| false | false | 11,188 |
java
|
package edu.tesis.healthyfood;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;
import edu.tesis.healthyfood.sobj.ContenedorIngredientes;
import edu.tesis.healthyfood.sobj.Ingrediente_Receta;
@SuppressWarnings("deprecation")
public class EditaReceta extends Fragment {
String user="";
Activity act;
static ContenedorIngredientes contenedor = new ContenedorIngredientes();
public EditaReceta(String u, Activity a){
user=u;
act=a;
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.activity_publica_receta, container, false);
contenedor = new ContenedorIngredientes();
selector_categoria = (Spinner)view.findViewById(R.id.receta_spinner_cat);
campo_nombre = (EditText)view.findViewById(R.id.receta_nombre);
campo_instrucciones = (EditText)view.findViewById(R.id.receta_instrucciones);
imagen = (ImageView)view.findViewById(R.id.receta_imagen);
boton_registrar = (Button)view.findViewById(R.id.receta_publicar);
boton_ingredientes = (Button)view.findViewById(R.id.receta_boton_agrega);
boton_ver = (Button)view.findViewById(R.id.recetas_ver_ingredientes);
boton_foto = (Button)view.findViewById(R.id.receta_photo);
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(act,
R.array.categories_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Intent i=act.getIntent();
user = i.getExtras().getString("infoUser");
selector_categoria.setAdapter(adapter);
boton_registrar.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
registrarOnClick();
}
});
boton_ingredientes.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
agregarOnClick();
}
});
boton_ver.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
verOnClick();
}
});
boton_foto.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
onClickCamara();
}
});
return view;
}
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.publica_receta, menu);
// return true;
// }
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==REQUEST_CAMERA && resultCode==Activity.RESULT_OK){
if(photoPath==null){
Uri selectImageUri=data.getData();
path_imagen = getPath(selectImageUri);
}else{
path_imagen = photoPath;
}
bitmap=BitmapFactory.decodeFile(path_imagen);
imagen.setImageBitmap(bitmap);
}
}
private void verOnClick(){
String ingredientes = "";
for(Ingrediente_Receta ir :contenedor.lista.values()){
ingredientes+=ir.getNombre_ingrediente();
if(ir.getGramos()!=0){
ingredientes = ingredientes + " -> " +ir.getGramos() + "g";
}
if(ir.getUnidades()!=0){
ingredientes = ingredientes + " -> " +ir.getUnidades() + " unidades";
}
if(ir.getLitros()!=0){
ingredientes = ingredientes + " -> " +ir.getLitros() + " litros";
}
ingredientes+="\n";
}
AlertDialog.Builder b = new AlertDialog.Builder(act);
b.setTitle("Ingredientes en la receta");
b.setMessage(ingredientes);
b.show();
}
private void agregarOnClick(){
Intent i = new Intent(act,Ingredientes.class);
act.startActivity(i);
}
private String constructIngredientes(){
String json="[";
for(Ingrediente_Receta ir:contenedor.lista.values()){
String ingrediente = "{\"nombre_ingrediente\":\""+ir.getNombre_ingrediente()+"\",\"unidades\":"+ir.getUnidades()+",\"gramos\":"+ir.getGramos()+",\"litros\":"+ir.getLitros()+"}";
if(json.equals("[")){
json+=ingrediente;
}else{
json+=","+ingrediente;
}
}
json+="]";
return json;
}
private void registrarOnClick(){
if(campo_nombre.getText()!=null && campo_instrucciones.getText()!=null && selector_categoria.getSelectedItem()!=null){
if(!campo_nombre.getText().toString().equals("")&& !campo_instrucciones.getText().toString().equals("") && !contenedor.lista.isEmpty()){
AlertDialog.Builder b= new AlertDialog.Builder(act);
b.setTitle("Carga en progreso");
b.setMessage("Espere mientras se cargan los datos al servidor");
AlertDialog a = b.show();
UploaderTask ut = new UploaderTask(this,a);
String ingredientes = constructIngredientes();
ut.execute(path_imagen,user,campo_nombre.getText().toString(),campo_instrucciones.getText().toString(),selector_categoria.getSelectedItem().toString(),ingredientes);
}else {
AlertDialog.Builder b= new AlertDialog.Builder(act);
b.setTitle("Error en la carga");
b.setMessage("Todos los campos son obligatorios");
b.show();
}
}else {
AlertDialog.Builder b= new AlertDialog.Builder(act);
b.setTitle("Error en la carga");
b.setMessage("Todos los campos son obligatorios");
b.show();
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = act.managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
//METODO ONCREATE FOTO
public void onClickCamara()
{
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))
{
long captureTime = System.currentTimeMillis();
photoPath = Environment.getExternalStorageDirectory() + "/DCIM/Camera/Photo" + captureTime + ".jpg";
try
{
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File photo = new File(photoPath);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photo));
startActivityForResult(Intent.createChooser(intent, "Capture Image"), REQUEST_CAMERA);
}
catch (Exception e)
{
Toast.makeText(getActivity(), "Error", Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e);
}
}
}
private static final int REQUEST_CAMERA = 1;
private static final int REQUEST_SELECT_PHOTO = 0;
protected Uri imageUri;
private String photoPath;
private Spinner selector_categoria;
private EditText campo_nombre;
private EditText campo_instrucciones;
private ImageView imagen;
private Bitmap bitmap;
private String path_imagen="";
private Button boton_ingredientes;
private Button boton_registrar;
private Button boton_ver;
private Button boton_foto;
private class UploaderTask extends AsyncTask<String,Void,String>{
private EditaReceta padre;
private AlertDialog alerta;
public UploaderTask(EditaReceta p,AlertDialog a){
padre = p;
alerta=a;
}
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
try {
postFile(arg0[0],arg0[1],arg0[2],arg0[3],arg0[4],arg0[5]);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
return "ok";
}
private void postFile(String filename,String username, String nombre, String instruct,String cat,String ingr) throws ClientProtocolException, IOException{
String url=Login.url+"/recipes.php";
HttpClient cliente = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
MultipartEntityBuilder me = MultipartEntityBuilder.create();
me.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(!filename.equals("")) me.addPart("file", new FileBody(new File(filename)));
me.addPart("user", new StringBody(username));
me.addPart("name", new StringBody(nombre));
me.addPart("ins", new StringBody(instruct));
me.addPart("categoria", new StringBody(cat));
me.addPart("ingredientes", new StringBody(ingr));
post.setEntity(me.build());
HttpResponse response=cliente.execute(post);
HttpEntity entidad = response.getEntity();
entidad.consumeContent();
cliente.getConnectionManager().shutdown();
}
protected void onPostExecute(String result){
alerta.dismiss();
if(result!=null){
AlertDialog.Builder b= new AlertDialog.Builder(act);
b.setTitle("Carga exitosa");
b.setMessage("La receta ha sido publicada con éxito");
b.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
getActivity().getSupportFragmentManager().popBackStack();
}
});
b.show();
}else{
AlertDialog.Builder b= new AlertDialog.Builder(act);
b.setTitle("Error");
b.setMessage("La receta no ha sido publicada con éxito");
b.show();
}
}
}
}
|
[
"[email protected]"
] | |
22fd79afd785f8ec70429f786fee939955e195c2
|
647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4
|
/com.tencent.mobileqqi/classes.jar/cwh.java
|
191c01c69e223240f90bbabb8317a54ef6597497
|
[] |
no_license
|
tsuzcx/qq_apk
|
0d5e792c3c7351ab781957bac465c55c505caf61
|
afe46ef5640d0ba6850cdefd3c11badbd725a3f6
|
refs/heads/main
| 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 |
Java
|
UTF-8
|
Java
| false | false | 1,307 |
java
|
import android.widget.TextView;
import com.tencent.mobileqq.activity.ModifyFriendInfoActivity;
import com.tencent.mobileqq.app.FriendListObserver;
import com.tencent.mobileqq.app.QQAppInterface;
import com.tencent.mobileqq.model.FriendManager;
public class cwh
extends FriendListObserver
{
public cwh(ModifyFriendInfoActivity paramModifyFriendInfoActivity) {}
protected void a(String paramString, byte paramByte1, byte paramByte2)
{
if ((paramString != null) && (paramString.equals(this.a.jdField_a_of_type_JavaLangString)))
{
this.a.jdField_a_of_type_Int = paramByte1;
return;
}
this.a.c();
}
protected void a(boolean paramBoolean, String paramString1, String paramString2, byte paramByte)
{
if (paramBoolean)
{
this.a.c = paramString2;
paramString1 = (FriendManager)this.a.jdField_b_of_type_ComTencentMobileqqAppQQAppInterface.getManager(8);
this.a.jdField_b_of_type_JavaLangString = paramString1.a(this.a.jdField_a_of_type_JavaLangString);
return;
}
this.a.jdField_b_of_type_AndroidWidgetTextView.setText(this.a.c);
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mobileqqi\classes2.jar
* Qualified Name: cwh
* JD-Core Version: 0.7.0.1
*/
|
[
"[email protected]"
] | |
2b261ddb2e3bbdadd0133e93c1853906b0c6d5c3
|
bc266f399ca5046efa2a8f8246b81a6301e71be1
|
/src/test/java/com/muditasoft/artofwritingunittest/sample03/AssertTest.java
|
51ec3a8928e0364d869518ed47bf6ed464d6e4c0
|
[] |
no_license
|
tutkuince/art-of-writing-unit-test
|
52b60d4b07e86d611d8ec1dc12d0e79f98760b4f
|
45c667877b1359218a9319b54ff0a845647acfca
|
refs/heads/master
| 2022-12-15T22:37:19.603291 | 2020-09-09T19:52:10 | 2020-09-09T19:52:10 | 293,084,688 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 795 |
java
|
package com.muditasoft.artofwritingunittest.sample03;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class AssertTest {
@Test
void test_assertions() {
Dummy d1 = new Dummy(5);
Dummy d2 = new Dummy(5);
Dummy d3 = d2;
Dummy d4 = null;
assertEquals(d1, d2);
assertSame(d2, d3);
assertNull(d4);
assertTrue(d2 == d3);
assertFalse(d1 == d4);
}
private static class Dummy {
private int id;
public Dummy(int id) {
this.id = id;
}
public int getId() {
return id;
}
@Override
public boolean equals(Object obj) {
return this.id == ((Dummy) obj).getId();
}
}
}
|
[
"[email protected]"
] | |
f03f47ab609b80e44f27eacb64a827efb6578060
|
99b095ef2e52f6e22a42f93724256064cb9b78fa
|
/app/src/main/java/de/psawicki/payleven/ui/BasketListAdapter.java
|
c56e4f0d48e62fd46da1b71863b3f68ce895653c
|
[] |
no_license
|
pawsaw/payleven
|
2efaa8170bea0640ca8c18aa1dbc026101b28a5a
|
da44611b7e3f6881928bc8ab7c82dca747dd7733
|
refs/heads/master
| 2021-01-22T18:23:09.665775 | 2014-12-14T12:20:16 | 2014-12-14T12:20:16 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,057 |
java
|
package de.psawicki.payleven.ui;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;
import de.psawicki.payleven.R;
import de.psawicki.payleven.app.BasketSession;
import de.psawicki.payleven.model.Basket;
import de.psawicki.payleven.model.Catalog;
import de.psawicki.payleven.model.Product;
/**
* Created by Pawel Sawicki on 13.12.14.
*/
public class BasketListAdapter extends BaseAdapter implements BasketSession.IOnBasketChangedListener {
static private class ProductViewHolder {
TextView productNameTextView;
TextView inBasketTextView;
TextView pricePerUnitTextView;
TextView totalPriceTextView;
}
private LayoutInflater layoutInflater;
private Basket basket;
public BasketListAdapter(LayoutInflater layoutInflater, Basket basket) {
this.layoutInflater = layoutInflater;
this.basket = basket;
}
@Override
public int getCount() {
return basket.productsInBasketSorted.size();
}
@Override
public Object getItem(int position) {
return basket.productsInBasketSorted.get(position);
}
@Override
public long getItemId(int position) {
return basket.productsInBasketSorted.get(position).hashCode();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ProductViewHolder productViewHolder = null;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.item_product, null);
productViewHolder = new ProductViewHolder();
productViewHolder.productNameTextView = (TextView) convertView.findViewById(R.id.textView_productName);
productViewHolder.inBasketTextView = (TextView) convertView.findViewById(R.id.textView_quantityValue);
productViewHolder.pricePerUnitTextView = (TextView) convertView.findViewById(R.id.textView_pricePerUnitValue);
productViewHolder.totalPriceTextView = (TextView) convertView.findViewById(R.id.textView_totalPriceValue);
convertView.setTag(productViewHolder);
}
Product product = basket.productsInBasketSorted.get(position).product;
Basket.ProductInBasket productInBasket = basket.productsInBasket.get(product);
productViewHolder = (ProductViewHolder) convertView.getTag();
productViewHolder.productNameTextView.setText(product.name);
productViewHolder.inBasketTextView.setText("" + (productInBasket != null ? productInBasket.quantity : 0));
productViewHolder.pricePerUnitTextView.setText(String.format("%.2f", product.price));
productViewHolder.totalPriceTextView.setText(String.format("%.2f", (productInBasket != null ? productInBasket.getTotalPrice() : 0.0)));
return convertView;
}
@Override
public void basketChanged(Basket basket) {
this.basket = basket;
notifyDataSetChanged();
}
}
|
[
"[email protected]"
] | |
34ff12c5bd43bb6718bd5857b1efb44e802566a0
|
6e166bc4e5d8e01560a97a8e62a808f9caf3901c
|
/app/src/main/java/com/example/shoesworld/ui/busqueda/BuscarFragment.java
|
2209fab20bc760805aca8791ad609ff67838bdbd
|
[] |
no_license
|
alucero-gs/ShoesWorld
|
349f9168f1f0c407dc992c1f2e3aaa3bc456d540
|
ccabc9ba12513613106361c78f298ace476a574d
|
refs/heads/master
| 2023-06-04T09:46:46.636543 | 2021-06-21T08:50:11 | 2021-06-21T08:50:11 | 374,744,497 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 7,026 |
java
|
package com.example.shoesworld.ui.busqueda;
import androidx.lifecycle.ViewModelProvider;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
import com.example.shoesworld.MainActivity;
import com.example.shoesworld.Producto;
import com.example.shoesworld.R;
import com.example.shoesworld.ui.agregar.AgregarFragment;
import com.google.firebase.FirebaseApp;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class BuscarFragment extends Fragment implements View.OnClickListener {
private BuscarViewModel mViewModel;
private Button btnLimpiar, btnBuscar;
private EditText etId, etModelo, etPrecio, etCantidad, etStock, etMarca, etTalla, etColor, etStatus, etCategoria;
ListView lproducto;
private List<Producto> ListaProducto = new ArrayList<Producto>(100);
ArrayAdapter<Producto> arrayAdapterProducto;
Producto productoSelected;
FirebaseDatabase firebaseDatabase;
DatabaseReference databaseReference;
public static BuscarFragment newInstance() {
return new BuscarFragment();
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_buscar, container, false);
Componentes(root);
lproducto.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
productoSelected = (Producto) parent.getItemAtPosition(position);
etId.setText(productoSelected.getUid());
etModelo.setText(productoSelected.getModelo());
etMarca.setText(productoSelected.getMarca());
etColor.setText(productoSelected.getColor());
etCategoria.setText(productoSelected.getCategoria());
etTalla.setText(productoSelected.getTalla());
etPrecio.setText(productoSelected.getPrecio());
etCantidad.setText(productoSelected.getCantidad());
etStock.setText(productoSelected.getStock());
etStatus.setText(productoSelected.getStatus());
}
});
return root;
}
private void Componentes(View root){
EditTextComponent(root);
Botones(root);
lproducto = root.findViewById(R.id.lvElementos);
iniciarFirebase();
listarDatos();
}
public void iniciarFirebase(){
FirebaseApp.initializeApp(getContext());
firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference();
}
public void listarDatos(){
databaseReference.child("Producto").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
ListaProducto.clear();
for(DataSnapshot objSnapsot: snapshot.getChildren()){
Producto prod =objSnapsot.getValue(Producto.class);
ListaProducto.add(prod);
arrayAdapterProducto= new ArrayAdapter<Producto>(getContext(), android.R.layout.simple_list_item_1, ListaProducto);
lproducto.setAdapter(arrayAdapterProducto);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
private void EditTextComponent(View root){
etId = root.findViewById(R.id.fb_id);
etId.setEnabled(false);
etMarca = root.findViewById(R.id.fb_marca);
etMarca.setEnabled(false);
etModelo = root.findViewById(R.id.fb_modelo);
etCategoria = root.findViewById(R.id.fb_categoria);
etMarca.setEnabled(false);
etTalla = root.findViewById(R.id.fb_talla);
etTalla.setEnabled(false);
etPrecio = root.findViewById(R.id.fb_precio);
etCantidad = root.findViewById(R.id.fb_cantidad);
etStock = root.findViewById(R.id.fb_stock);
etStatus = root.findViewById(R.id.fb_status);
etStatus.setEnabled(false);
etColor = root.findViewById(R.id.fb_color);
}
private void Botones(View root){
btnLimpiar = root.findViewById(R.id.fb_btnClear);
btnBuscar = root.findViewById(R.id.fb_btnBuscar);
btnBuscar.setOnClickListener((View.OnClickListener) this);
btnLimpiar.setOnClickListener((View.OnClickListener) this);
}
private void clearFields(){
etId.setText("");
etModelo.setText("");
etPrecio.setText("");
etCantidad.setText("");
etStock.setText("");
etColor.setText("");
etTalla.setText("");
etMarca.setText("");
etStatus.setText("");
etCategoria.setText("");
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewModel = new ViewModelProvider(this).get(BuscarViewModel.class);
// TODO: Use the ViewModel
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.fb_btnClear:
clearFields();
break;
case R.id.fb_btnBuscar:
Producto p = new Producto();
p.setUid(productoSelected.getUid());
p.setMarca(etMarca.getText().toString().trim());
p.setModelo(etModelo.getText().toString().trim());
p.setCategoria(etCategoria.getText().toString().trim());
p.setTalla(etTalla.getText().toString().trim());
p.setColor(etColor.getText().toString().trim());
p.setPrecio(etPrecio.getText().toString().trim());
p.setCantidad(etCantidad.getText().toString().trim());
p.setStock(etStock.getText().toString().trim());
p.setStatus(etStatus.getText().toString().trim());
databaseReference.child("Producto").child(p.getUid()).setValue(p);
Toast.makeText(getContext(), "Actualizado correctamente", Toast.LENGTH_SHORT).show();
clearFields();
break;
}
}
}
|
[
"[email protected]"
] | |
eb89fcf4f3dbd5e19d62fdb97544d925b63037c4
|
c87f811f69bfb566682a99a88a6a810fd2b41afe
|
/src/main/java/at/matthew/dbexample/DB.java
|
6ea930f146489844cdceb7f0f0ebb0b485c87dbb
|
[] |
no_license
|
atmatthewat/dbexample
|
54041a91acf73d3d7c9b34a4eb6d42778a204f12
|
94c3548a4a5ffb0a49d8afbfbe951c6c8571440a
|
refs/heads/master
| 2021-01-06T03:05:09.463478 | 2020-02-18T18:00:41 | 2020-02-18T18:00:41 | 241,206,899 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,747 |
java
|
package at.matthew.dbexample;
import java.util.ArrayDeque;
class DB {
private final DBStorage storage;
private final ArrayDeque<DBTransaction> transactions;
public DB() {
transactions = new ArrayDeque<>();
storage = new DBStorage();
}
public String get(String key) {
for (DBTransaction transaction : transactions) {
if (transaction.knowsStateOf(key))
return transaction.get(key);
}
return storage.get(key);
}
public void set(String key, String value) {
if (transactions.isEmpty())
storage.set(key, value);
else
transactions.peek().set(key, value);
}
public void unset(String key) {
if (transactions.isEmpty())
storage.unset(key);
else
transactions.peek().unset(key);
}
public boolean exists(String key) {
for (DBTransaction transaction : transactions) {
if (transaction.knowsStateOf(key))
return transaction.exists(key);
}
return storage.exists(key);
}
public void begin() {
DBTransaction transaction = new DBTransaction();
transactions.push(transaction);
}
public boolean rollback() {
if (transactions.isEmpty())
return false;
transactions.pop();
return true;
}
public boolean commit() {
if (transactions.isEmpty())
return false;
DBTransaction thisTransaction = transactions.pop();
if (transactions.isEmpty())
thisTransaction.applyMutationsTo(storage);
else
thisTransaction.applyMutationsTo(transactions.peek());
return true;
}
}
|
[
"[email protected]"
] | |
331be1c3acdddcd837cbf6b3a493b4d12b04d360
|
610ae0a8be6b9e0a8371dcbbc20f76896b53d3e3
|
/src/main/java/com/tencent/ads/model/OrderByStruct.java
|
4693d009cc458afdcaf66adbcb3de6f961365ee3
|
[
"Apache-2.0"
] |
permissive
|
TencentAd/marketing-api-java-sdk
|
d106c6e4cd6e47857a0c63f23fd95e97a34666f3
|
f9c7e5d06202e05f8f7317e5bf69b61080829de9
|
refs/heads/master
| 2023-07-23T10:01:28.748383 | 2023-07-13T03:07:34 | 2023-07-13T03:07:34 | 266,974,939 | 31 | 14 |
Apache-2.0
| 2022-05-20T21:54:42 | 2020-05-26T07:32:11 |
Java
|
UTF-8
|
Java
| false | false | 2,221 |
java
|
/*
* Marketing API
* Marketing API
*
* OpenAPI spec version: 1.3
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.tencent.ads.model;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;
/** 排序字段结构 */
@ApiModel(description = "排序字段结构")
public class OrderByStruct {
@SerializedName("sort_field")
private String sortField = null;
@SerializedName("sort_type")
private Sortord sortType = null;
public OrderByStruct sortField(String sortField) {
this.sortField = sortField;
return this;
}
/**
* Get sortField
*
* @return sortField
*/
@ApiModelProperty(value = "")
public String getSortField() {
return sortField;
}
public void setSortField(String sortField) {
this.sortField = sortField;
}
public OrderByStruct sortType(Sortord sortType) {
this.sortType = sortType;
return this;
}
/**
* Get sortType
*
* @return sortType
*/
@ApiModelProperty(value = "")
public Sortord getSortType() {
return sortType;
}
public void setSortType(Sortord sortType) {
this.sortType = sortType;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
OrderByStruct orderByStruct = (OrderByStruct) o;
return Objects.equals(this.sortField, orderByStruct.sortField)
&& Objects.equals(this.sortType, orderByStruct.sortType);
}
@Override
public int hashCode() {
return Objects.hash(sortField, sortType);
}
@Override
public String toString() {
Gson gson = new Gson();
return gson.toJson(this);
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
|
[
"[email protected]"
] | |
4d5a237add240e10c5150cace2687a5ea046627a
|
b3de8ecd6b7e5ed1e1baebdef44d7b26e7a7e3d8
|
/helloworld/SSHM/ssm/src/main/java/cn/ben/dao/AccountDao.java
|
e3f4f69f06d6d7de2e78243382308e4b36ddda5d
|
[] |
no_license
|
lee-quinnf/quinnfResp
|
f9a57af8957ebe74be9676d70a1a32871a2a2226
|
0eeb9e2e69079f15e8b45994d48114d318bd3602
|
refs/heads/master
| 2022-12-21T09:59:37.661630 | 2020-05-03T01:01:39 | 2020-05-03T01:01:39 | 251,167,938 | 5 | 0 | null | 2022-12-15T23:47:28 | 2020-03-30T01:01:21 |
Java
|
UTF-8
|
Java
| false | false | 561 |
java
|
package cn.ben.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import cn.ben.domain.Account;
import java.util.List;
/**
* 帐户dao接口
*/
@Repository
public interface AccountDao {
// 查询所有账户
@Select("select * from account")
public List<Account> findAll();
// 保存帐户信息
@Insert("insert into account (name,money) values (#{name},#{money})")
public void saveAccount(Account account);
}
|
[
"[email protected]"
] | |
66f6f392c5f7b626173f57c195ff9c9dc755897c
|
27be6e4824ba82b5af2b33c38b1482be80cc20c1
|
/src/main/java/Andromeda/Collision/ContactPoint.java
|
186a450ee38385e0b91293c9060b73de9c007490
|
[
"MIT"
] |
permissive
|
eJatte/Simple-2D-physics-engine
|
17a16277095e7237506f4425ab97c1a5959758d4
|
008c4e812eec89e6b7d1358e95e1a86e5c37561d
|
refs/heads/master
| 2022-10-29T06:56:41.608339 | 2022-10-15T15:25:22 | 2022-10-15T15:25:22 | 172,190,551 | 3 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 709 |
java
|
package Andromeda.Collision;
import Andromeda.Utils.Vector2;
/**
* Classname: ContactPoint
* Author: Elias Jätte
* Date: 18/08/06
*
* Information container regarding a contact point.
*/
public class ContactPoint {
private Vector2 point;
private double depth;
public ContactPoint(Vector2 point, double depth) {
this.point = point;
this.depth = depth;
}
public Vector2 getPoint() {
return point;
}
public double getDepth() {
return depth;
}
public Vector2 getAdjusted(Vector2 n){
return point.add(n.multiply(depth));
}
public String toString(){
return "point: "+point.toString()+" depth: "+depth;
}
}
|
[
"[email protected]"
] | |
f172cc429cb7816cb22d0290e18fef0e68725103
|
5dbc04981baee365800632a97715148094d64c65
|
/src/main/java/ru/cpositive/t3/logic/Player.java
|
112f0d1f2e6f8d144d21ac4d13a3ac91e27d4487
|
[] |
no_license
|
posonsky/t3
|
5025834251de7ec5a10f605c7cced7ba884f52f6
|
61acdfec0c614ddbd3023932810ce0ba1537f2ad
|
refs/heads/master
| 2021-01-18T23:06:04.096948 | 2016-11-04T20:10:51 | 2016-11-04T20:10:51 | 72,613,169 | 0 | 0 | null | 2017-02-14T04:35:01 | 2016-11-02T07:03:46 |
Java
|
UTF-8
|
Java
| false | false | 310 |
java
|
package ru.cpositive.t3.logic;
public abstract class Player {
protected Dots dot;
protected GameField gameField;
public Player(GameField gameField) {
this.gameField = gameField;
}
abstract protected void realTurn();
public boolean turn() {
realTurn();
return gameField.isFinalState(dot);
}
}
|
[
"[email protected]"
] | |
f03ddc1e29e4ae8a9df1f970434fe4bfc5f629f6
|
e3a856e023ef723e37911ed65748d61336a06bdc
|
/app/src/main/java/uk/ac/tees/v8218996/p2_engage/LoginFragment.java
|
f03d4b40ba62976db711f4e36cc5b059dc6663ba
|
[] |
no_license
|
mal33k-eden/p2-engage
|
0822997893ca16970ae75c6c7609c3a925b6a6c3
|
84f84f33933478f6ad2cabb1f6bfc801093e22cc
|
refs/heads/master
| 2023-02-09T05:51:26.511164 | 2021-01-03T00:06:37 | 2021-01-03T00:06:37 | 316,518,005 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 8,420 |
java
|
package uk.ac.tees.v8218996.p2_engage;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.text.Editable;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.google.android.material.textview.MaterialTextView;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.concurrent.Executor;
import uk.ac.tees.v8218996.p2_engage.data.DatabaseHandler;
import uk.ac.tees.v8218996.p2_engage.model.User;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link LoginFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link LoginFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class LoginFragment 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";
private FirebaseAuth mAuth;
private FirebaseDatabase firebaseDB = FirebaseDatabase.getInstance();
DatabaseReference myDBRef = firebaseDB.getReference();
private static final String TAG = "AnonymousAuth";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public LoginFragment() {
// 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 LoginFragment.
*/
// TODO: Rename and change types and number of parameters
public static LoginFragment newInstance(String param1, String param2) {
LoginFragment fragment = new LoginFragment();
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
View view = inflater.inflate(R.layout.fragment_login, container, false);
mAuth = FirebaseAuth.getInstance();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
MaterialButton loginButton = view.findViewById(R.id.login_button);
TextInputLayout textInputLayout = view.findViewById(R.id.nicknameText);
final Editable userName = textInputLayout.getEditText().getText();
loginButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Log.d("nicename", String.valueOf(userName));
signInAnonymously(String.valueOf(userName));
}
});
// Clear the error once more than 8 characters are typed.
return view;
}
private boolean isPasswordValid(@Nullable Editable text) {
return text != null && text.length() >= 8;
}
// 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);
}
private void signOut() {
mAuth.signOut();
updateUI(null);
}
private void signInAnonymously(final String nickName) {
// [START signin_anonymously]
try {
mAuth.signInAnonymously().addOnCompleteListener( new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInAnonymously:success");
FirebaseUser user = mAuth.getCurrentUser();
//store user
saveUserInDb(user,nickName);
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInAnonymously:failure", task.getException());
// Toast.makeText(AnonymousAuthActivity.this, "Authentication failed.",
// Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
// [END signin_anonymously]
}catch (Exception ex){
Log.e("trycatcherror", ex.getLocalizedMessage().toString());
}
}
private void saveUserInDb(FirebaseUser user,String nickName) {
DatabaseHandler db = new DatabaseHandler(getContext());
User newUser = new User();
newUser.setNickName(nickName);
newUser.setUid(user.getUid());
db.addUser(newUser);
//FIREBASE WRITE
myDBRef.child("users").child(user.getUid()).setValue(newUser);
}
private void updateUI(FirebaseUser currentUser ) {
boolean isSignedIn = (currentUser != null);
if(isSignedIn){
//user is signed in
Log.d(TAG, currentUser.getUid());
Intent intent = new Intent();
intent.setClass(getActivity(), HomeActivity.class);
getActivity().startActivity(intent);
getActivity().finish();
}else{
//user is not signed in
Log.w(TAG, "signInAnonymously:failure -> not logged in");
}
}
@Override
public void onStart() {
super.onStart();
}
}
|
[
"[email protected]"
] | |
9e6770a47f831bf2ad10f6524036c80bd691a238
|
514414459119502f223a01bb7d7cb7732591b089
|
/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidApplicationResourceInfoApi.java
|
7a0441d2a380818aed704dc86177bc5b43ceef7e
|
[
"Apache-2.0"
] |
permissive
|
mgp/bazel
|
abdd2dd88050be3bca10f68abbb2c58606a5f6ab
|
d3ff5734d14a4afcfd4cd7fac48b183f77722ea0
|
refs/heads/master
| 2022-07-02T10:10:01.984572 | 2020-05-08T22:03:40 | 2020-05-08T22:04:43 | 262,443,498 | 1 | 0 |
Apache-2.0
| 2020-05-08T22:44:13 | 2020-05-08T22:44:12 | null |
UTF-8
|
Java
| false | false | 5,316 |
java
|
// Copyright 2019 The Bazel Authors. 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.devtools.build.lib.skylarkbuildapi.android;
import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkConstructor;
import com.google.devtools.build.lib.skylarkinterface.StarlarkBuiltin;
import com.google.devtools.build.lib.syntax.EvalException;
/** Supplies a resource apk file (".ap_") and related info. */
@StarlarkBuiltin(
name = "AndroidApplicationResourceInfo",
doc =
"Do not use this module. It is intended for migration purposes only. If you depend on it, "
+ "you will be broken when it is removed.",
documented = false)
public interface AndroidApplicationResourceInfoApi<FileT extends FileApi> extends StructApi {
/** Name of this info object. */
String NAME = "AndroidApplicationResourceInfo";
/** Returns the ap_ artifact to be merged into the final apk. */
@SkylarkCallable(
name = "resource_apk",
doc = "The resource apk file ('.ap_')",
documented = false,
allowReturnNones = true,
structField = true)
FileT getResourceApk();
/** The jar containing the R java source files. */
@SkylarkCallable(
name = "resource_java_src_jar",
doc = "The jar containing the R java source files.",
documented = false,
allowReturnNones = true,
structField = true)
FileT getResourceJavaSrcJar();
/** The jar containing the R java class files. */
@SkylarkCallable(
name = "resource_java_class_jar",
doc = "The jar containing the R java class files.",
documented = false,
allowReturnNones = true,
structField = true)
FileT getResourceJavaClassJar();
/** The final proessed manifest. */
@SkylarkCallable(
name = "manifest",
doc = "The final processed manifest.",
documented = false,
structField = true)
FileT getManifest();
/** The proguard config for Android resources. */
@SkylarkCallable(
name = "resource_proguard_config",
doc = "The resource proguard config file.",
documented = false,
allowReturnNones = true,
structField = true)
FileT getResourceProguardConfig();
/** The main dex proguard config file. */
@SkylarkCallable(
name = "main_dex_proguard_config",
doc = "The main dex proguard config file.",
documented = false,
allowReturnNones = true,
structField = true)
FileT getMainDexProguardConfig();
/** Provider for {@link AndroidApplicationResourceInfoApi}. */
@StarlarkBuiltin(
name = "Provider",
doc =
"Do not use this module. It is intended for migration purposes only. If you depend on "
+ "it, you will be broken when it is removed.",
documented = false)
interface AndroidApplicationResourceInfoApiProvider<FileT extends FileApi> extends ProviderApi {
@SkylarkCallable(
name = NAME,
doc = "The <code>AndroidApplicationResourceInfo</code> constructor.",
documented = false,
parameters = {
@Param(
name = "resource_apk",
type = FileApi.class,
noneable = true,
named = true,
doc = ""),
@Param(
name = "resource_java_src_jar",
type = FileApi.class,
noneable = true,
named = true,
doc = ""),
@Param(
name = "resource_java_class_jar",
type = FileApi.class,
noneable = true,
named = true,
doc = ""),
@Param(name = "manifest", type = FileApi.class, named = true, doc = ""),
@Param(
name = "resource_proguard_config",
type = FileApi.class,
noneable = true,
named = true,
doc = ""),
@Param(
name = "main_dex_proguard_config",
type = FileApi.class,
noneable = true,
named = true,
doc = ""),
},
selfCall = true)
@SkylarkConstructor(objectType = AndroidApplicationResourceInfoApi.class)
AndroidApplicationResourceInfoApi<FileT> createInfo(
Object resourceApk,
Object resourceJavaSrcJar,
Object resourceJavaClassJar,
FileT manifest,
Object resourceProguardConfig,
Object mainDexProguardConfig)
throws EvalException;
}
}
|
[
"[email protected]"
] | |
76ed04c348cf0104a364f646bc854be3a0003d45
|
e7ef4db3f2edbc9edbab92aa759b6050290a5bd1
|
/mall-manager/src/main/java/com/dd/manager/web/config/sys/SysProperties.java
|
3092c3aeb7581b1be60c1451c8280405dd4854d8
|
[] |
no_license
|
Ivan252525/dd-mall
|
e66fc8769867efb1b7dc908ec6473b7be062d6a7
|
8d167e8ade42f1c996bf0ea186303f90ec84426a
|
refs/heads/master
| 2022-06-23T07:31:48.282002 | 2019-08-27T09:22:12 | 2019-08-27T09:22:12 | 201,833,243 | 0 | 0 | null | 2022-06-17T02:21:40 | 2019-08-12T01:01:36 |
Java
|
UTF-8
|
Java
| false | false | 680 |
java
|
package com.dd.manager.web.config.sys;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "sys.config")
@Component
public class SysProperties {
private String host;
private int qrWidth;
private int qrHeight;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getQrWidth() {
return qrWidth;
}
public void setQrWidth(int qrWidth) {
this.qrWidth = qrWidth;
}
public int getQrHeight() {
return qrHeight;
}
public void setQrHeight(int qrHeight) {
this.qrHeight = qrHeight;
}
}
|
[
"[email protected]"
] | |
1117feac72647f7e9e76532905ceb3321d10b073
|
332f03d44ed3f9cc8f0d512e5a1406e5e4ad503e
|
/commons/src/main/java/ca/esystem/bridges/service/impl/ContentServiceImpl.java
|
8da51a636242109816985c4e0dc369d548bd0732
|
[] |
no_license
|
ubcweicai/3qnow
|
26d25f7d5c5d5317dede39f2f18d7e3704321e39
|
82e79c83d903e560797ad0bca7a754f25d781442
|
refs/heads/master
| 2021-06-24T18:02:42.165099 | 2017-09-10T05:35:46 | 2017-09-10T05:35:46 | 103,006,457 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,467 |
java
|
package ca.esystem.bridges.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import ca.esystem.bridges.dao.ContentDao;
import ca.esystem.bridges.service.ContentService;
import ca.esystem.framework.service.AbstractService;
/**
* ServiceImpl for Content
*
* @author Larry
*
*/
@Service("ContentService")
public class ContentServiceImpl extends AbstractService implements ContentService {
@Resource
private ContentDao contentDao;
public List queryList(Object condition) {
// TODO Auto-generated method stub
return contentDao.queryListByCondition(condition);
}
public int queryCount(Object condition) {
// TODO Auto-generated method stub
return contentDao.queryCountRowsByCondition(condition);
}
public Object queryOne(Object condition) {
// TODO Auto-generated method stub
return contentDao.queryObjectByCondition(condition);
}
public Object add(Object obj) {
// TODO Auto-generated method stub
return contentDao.insert(obj);
}
public int update(Object obj) {
// TODO Auto-generated method stub
return contentDao.update(obj);
}
public int archive(Object obj) {
// TODO Auto-generated method stub
return 0;
}
public int delete(Object obj) {
// TODO Auto-generated method stub
return contentDao.delete(obj);
}
}
|
[
"[email protected]"
] | |
0812c2ff5e287592eb81f881bd4e7531650dd7ff
|
88ca36fd1078c299e62b1b994f41e1850314a502
|
/src/main/java/msifeed/misca/mixins/wizardry/EntityMagicConstructMixin.java
|
237d2cdca7dfb433aea53f45ce0f6c5896396db8
|
[
"MIT"
] |
permissive
|
msifd/misca
|
580ab7f9f95ddfa18e009d7169c2ce6ad7629860
|
f34c9ddf8a86a770084ee28540bcf8621978540f
|
refs/heads/1.12.2
| 2023-01-21T16:34:39.454021 | 2023-01-13T22:56:21 | 2023-01-13T22:57:16 | 96,866,006 | 8 | 4 |
MIT
| 2021-04-05T19:34:10 | 2017-07-11T07:47:24 |
Java
|
UTF-8
|
Java
| false | false | 1,610 |
java
|
package msifeed.misca.mixins.wizardry;
import electroblob.wizardry.entity.construct.EntityMagicConstruct;
import msifeed.misca.combat.battle.Battle;
import msifeed.misca.combat.battle.BattleManager;
import msifeed.misca.combat.battle.BattleStateClient;
import msifeed.misca.combat.cap.CombatantProvider;
import msifeed.misca.combat.cap.ICombatant;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = EntityMagicConstruct.class, remap = false)
public abstract class EntityMagicConstructMixin {
@Shadow
public abstract EntityLivingBase getCaster();
@Shadow
public int lifetime;
@Inject(method = "onUpdate", at = @At(value = "HEAD"))
public void onUpdate(CallbackInfo ci) {
final EntityLivingBase entity = getCaster();
if (entity == null || lifetime == -1) return;
final ICombatant com = CombatantProvider.getOptional(entity);
if (com == null || !com.isInBattle()) return;
final Battle battle = entity.world.isRemote
? BattleStateClient.STATE
: BattleManager.getBattle(com.getBattleId());
if (battle == null) return;
if (!battle.shouldUpdatePotions(entity)) {
// Despawn happens when ticksExisted > lifetime
// so lets extend its lifetime when its others turn!
lifetime += 1;
}
}
}
|
[
"[email protected]"
] | |
691e826b9027082adf8cb4170b0c121a6e9f54ee
|
953fd537e07b37b71415896b615ab84531d7ed6f
|
/src/minecraft_server/net/minecraft/src/biomesoplenty/biomes/BiomeGenWoodland.java
|
5a57ed4fedd9959373d1848cf01c2b32a4e25e35
|
[] |
no_license
|
Pfilson/BiomesOPlentyBTWLight
|
29af766f9106e2e5104ee5c2d241ed7cee628c2d
|
1d77a9cd50e88b63e7a8531275a72f7a371e425a
|
refs/heads/master
| 2021-01-15T16:15:55.787143 | 2013-09-03T10:13:23 | 2013-09-03T10:13:23 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,518 |
java
|
package net.minecraft.src.biomesoplenty.biomes;
import java.util.Random;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
import net.minecraft.src.World;
import net.minecraft.src.WorldGenerator;
import net.minecraft.src.biomesoplenty.worldgen.WorldGenLog;
public class BiomeGenWoodland extends BiomeGenBase
{
private BiomeDecoratorBOP customBiomeDecorator;
public BiomeGenWoodland(int par1)
{
super(par1);
theBiomeDecorator = new BiomeDecoratorBOP(this);
customBiomeDecorator = (BiomeDecoratorBOP)theBiomeDecorator;
customBiomeDecorator.treesPerChunk = 9;
customBiomeDecorator.grassPerChunk = 7;
//customBiomeDecorator.toadstoolsPerChunk = 3;
}
@Override
public void decorate(World par1World, Random par2Random, int par3, int par4)
{
super.decorate(par1World, par2Random, par3, par4);
int var5 = 3 + par2Random.nextInt(6);
for (int var6 = 0; var6 < var5; ++var6)
{
int var7 = par3 + par2Random.nextInt(16);
int var8 = par2Random.nextInt(28) + 4;
int var9 = par4 + par2Random.nextInt(16);
int var10 = par1World.getBlockId(var7, var8, var9);
if (var10 == Block.stone.blockID)
{
par1World.setBlock(var7, var8, var9, Block.oreEmerald.blockID, 0, 2);
}
}
}
/**
* Gets a WorldGen appropriate for this biome.
*/
@Override
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
{
return par1Random.nextInt(5) == 0 ? new WorldGenLog() : (par1Random.nextInt(10) == 0 ? worldGeneratorBigTree : worldGeneratorTrees);
}
}
|
[
"[email protected]"
] | |
d980e5eddffda343b7b10e37704eaca116843dd4
|
24902eb4b6d30c017aba3066ff9965248b250d3b
|
/src/leetcode_81_TO_100/Program_85.java
|
4fa293e873d1a5a16f9779da944d1cb0de096be3
|
[] |
no_license
|
gaoshoutuo/leetcode_java
|
c725ee64fbb32b88c518f4566af92d3ff073eeab
|
af5d270c8a27929a2630f071172c4f15796f699a
|
refs/heads/master
| 2021-06-22T10:32:20.803786 | 2021-01-27T09:08:58 | 2021-01-27T09:08:58 | 188,839,370 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 480 |
java
|
package leetcode_81_TO_100;
public class Program_85 {
/*85. Maximal Rectangle hard 最大矩形 1X1
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing
only 1's and return its area.
Input:
[
["1","0","1","0","0"],
["1","0","1","1","1"],
["1","1","1","1","1"],
["1","0","0","1","0"]
]
Output: 6
*/
class Solution {
public int maximalRectangle(char[][] matrix) {
return 0;
}
}
}
|
[
"[email protected]"
] | |
1cc208d5f5ea24e6e19d62d51dc89d5e0ef2ce08
|
5219510be29db7844728c9adf419267a08311e4a
|
/src/tema11/calculadorainterfaz/main/Run.java
|
71a9639d655a8be10a2446c5c89162c26f6cee56
|
[] |
no_license
|
sergiomalagon/ProyectoProgramacion
|
cb95b52959731cb19db74b53a302b8ffee0342b1
|
187805ffb9ed7aa965add4d4882a967509d4905a
|
refs/heads/master
| 2021-02-26T10:29:28.834422 | 2020-05-05T14:57:31 | 2020-05-05T14:57:31 | 245,519,905 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 734 |
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 tema11.calculadorainterfaz.main;
import tema11.calculadorainterfaz.controlador.CCalculadora;
import tema11.calculadorainterfaz.modelo.MCalculadora;
import tema11.calculadorainterfaz.vista.VCalculadora;
/**
*
* @author Sergio
*/
public class Run {
public static void main(String[] args) {
MCalculadora modelo = new MCalculadora();
VCalculadora vista = new VCalculadora();
CCalculadora controlador = new CCalculadora(vista, modelo);
vista.setControlador(controlador);
vista.mostrar();
}
}
|
[
"[email protected]"
] | |
c66d5540f44b355aeda7c4f492a19e55d083280d
|
9eed3b1acddc8a73cc44cb230b15819c8bb4301a
|
/src/cn/qzl/www/Core_2/JDBC/Java/JDBC_5_select.java
|
c1a8fce98e21da3fa8c2a47b0d1ffcc9420aff1a
|
[] |
no_license
|
userqzl/Personal-learning-Java
|
59389c8437bc3f053bc256da3dd065c29fa3d874
|
189072fba7b11515027dc0109edaf1d1843237b8
|
refs/heads/master
| 2022-11-21T12:04:22.926845 | 2020-07-19T03:30:37 | 2020-07-19T03:30:37 | 279,033,114 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,481 |
java
|
package cn.qzl.www.Core_2.JDBC.Java;
import java.sql.*;
/**
* @description: select语句将查询的多个结果打印
* +--------+--------+-----+------+------+---------+
* | stu_id | name | age | addr | math | english |
* +--------+--------+-----+------+------+---------+
* | 1001 | 马云 | 25 | 杭州 | 51 | 85 |
* | 1002 | 马化腾 | 22 | 深圳 | 86 | 92 |
* | 1004 | 老六 | 23 | 武汉 | 71 | 79 |
* | 1005 | 丁磊 | 22 | 南京 | 74 | 89 |
* | 1006 | 刘能 | 25 | 沈阳 | 74 | 59 |
* | 1007 | 张一鸣 | 23 | 上海 | 88 | 85 |
* +--------+--------+-----+------+------+---------+
* @author: qzl
* @created: 2020/07/11 21:34
*/
public class JDBC_5_select {
public static void main(String[] args) {
Connection con = null;
Statement state = null;
try {
//注册驱动
Class.forName("com.mysql.cj.jdbc.Driver");
//获取数据库连接对象
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_3?serverTimezone=GMT%2B8","root","0502xsga230114");
//获取sql执行对象
state = con.createStatement();
//定义sql语句
String sql = "select * from student";
//接收结果集
ResultSet resultSet = state.executeQuery(sql);
while(resultSet.next()){
System.out.println(
resultSet.getInt("stu_id")+" "
+ resultSet.getString("name")+" "
+ resultSet.getInt("age")+" "
+ resultSet.getString("addr")+" "
+ resultSet.getInt("math")+" "
+ resultSet.getInt("english")
);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}finally {
//释放资源
if(state != null){
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(con != null){
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
|
[
"[email protected]"
] | |
1fadf014d83d1797143eafa032fcddb165efd871
|
74bac57dbe07b468651aa89f70e90dd560dadf33
|
/Practice3/src/Main.java
|
0e16422ea65c7ed43f8bd55137376a7803f5074b
|
[] |
no_license
|
kato2901/JAVA
|
5839d9f3b94229429ec6ddcfc0414793c00b3e58
|
dcbf1827623b7534fc08a4a4c4c21324f00dc62b
|
refs/heads/master
| 2022-08-21T20:23:36.560708 | 2020-05-23T12:33:22 | 2020-05-23T12:33:22 | 262,717,905 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 551 |
java
|
public class Main {
public static void main(String[] args) {
Person person1 = new Person("sotou", "tarou", 25, 1.7, 55.0, "医者");
person1.printData();
Person person2 = new Person("yamamoto", "d", "tarou", 30, 1.85, 75.0, "教師");
person2.printData();
System.out.println("----------------------------");
person1.setJob("獣医");
System.out.println("person1の仕事を" + person1.getJob() + "に変更しました");
person1.printData();
Person.printCount();
}
}
|
[
"[email protected]"
] | |
9d27309ef62ea1f7296e67a7b1f09a91017d3011
|
7175acfe15de173ac68a675bb560114cc3bb5bf8
|
/src/main/java/org/bdgp/util/ReverseComparator.java
|
6485f808583546b948289f9aae0914d4460ecc82
|
[] |
no_license
|
ylzheng/BatchAmpTargetSeqSearch
|
5762fef6cc4c86330e20d5325f3ec32f4acb507c
|
a68caea55130b0a97b8ec5b641a742a026c879d5
|
refs/heads/master
| 2021-01-10T01:10:02.392330 | 2016-02-05T06:09:26 | 2016-02-05T06:09:26 | 50,147,790 | 0 | 1 | null | 2016-02-05T06:09:26 | 2016-01-22T01:00:43 |
Java
|
UTF-8
|
Java
| false | false | 633 |
java
|
package org.bdgp.util;
/**
* A ReverseComparator wraps another Comparator and returns the reverse
* ordering of the wrapped comparator.
*/
public class ReverseComparator implements Comparator {
private Comparator original;
public ReverseComparator(Comparator in) {
original = in;
}
public int compare(Object a, Object b) {
int comp = original.compare(a, b);
if (comp == ComparisonConstants.GREATER_THAN)
return ComparisonConstants.LESS_THAN;
else if (comp == ComparisonConstants.LESS_THAN)
return ComparisonConstants.GREATER_THAN;
else
return ComparisonConstants.EQUAL_TO;
}
}
|
[
"[email protected]"
] | |
ce84083a6f8976d93582a8fac3048e61f588eac3
|
96ded4b80a459483d3359c9e2f68f1e4c80453a2
|
/leetcode/507_Perfect_Number.java
|
9b241c2a06494a85072bcc855d9a9d29b73c618c
|
[] |
no_license
|
hanrick2000/Leetcode-for-Fun
|
bd37f8a9ab92ac564e24e38edfa04f1fbaab9fbd
|
cce863008199c0beb0fc8839f9efbd4487240e2c
|
refs/heads/master
| 2020-12-19T05:33:48.957554 | 2019-04-15T19:52:01 | 2019-04-15T19:52:01 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 830 |
java
|
class Solution {
public boolean checkPerfectNumber(int num) {
if (num <= 0) return false;
int sum = 0;
for (int i = 1; i*i <= num; i++) {
if (num % i == 0) {
sum += i;
if (i*i != num)
sum += num / i;
}
}
return sum - num == num;
}
}
// Euclid proved that 2p−1(2p−1)2p−1(2p−1) is an even perfect number whenever 2p−12p−1 is prime, where pp is prime.
public class Solution {
public int pn(int p) {
return (1 << (p - 1)) * ((1 << p) - 1);
}
public boolean checkPerfectNumber(int num) {
int[] primes=new int[]{2,3,5,7,13,17,19,31};
for (int prime: primes) {
if (pn(prime) == num)
return true;
}
return false;
}
}
|
[
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.