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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
92db5ffa11b04c4cb908b5dce8c61febb171885a
|
88ab83270d3f8fe9d21142c8dd592b1cb6b9701c
|
/2.JavaCore/src/com/javarush/task/task17/task1710/Solution.java
|
fe101c8f6dc101c918acfa871ccf583f4f962391
|
[] |
no_license
|
AZorenkoV/JavaRushTasks
|
bd8463d46874f98c017347190df641be247235be
|
b788091cb4af2f348ec7e428c49ef3cc7f9b5a64
|
refs/heads/master
| 2021-07-12T09:20:00.604535 | 2021-04-09T08:25:01 | 2021-04-09T08:25:01 | 100,695,523 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,293 |
java
|
package com.javarush.task.task17.task1710;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/*
CRUD
*/
public class Solution {
public static List<Person> allPeople = new ArrayList<Person>();
static {
allPeople.add(Person.createMale("Иванов Иван", new Date())); //сегодня родился id=0
allPeople.add(Person.createMale("Петров Петр", new Date())); //сегодня родился id=1
}
public static void main(String[] args) {
//start here - начни тут
switch (args[0]) {
case "-c":
create(args);
break;
case "-u":
update(args);
break;
case "-d":
delete(args);
break;
case "-i":
info(args);
}
}
public static void create(String[] args) {
try {
Date bd = (new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH)).parse(args[3]);
if(args[2].equals("м")) allPeople.add(Person.createMale(args[1], bd));
else allPeople.add(Person.createFemale(args[1], bd));
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(allPeople.size()-1);
}
public static void update(String[] args) {
Person person = allPeople.get(Integer.parseInt(args[1]));
person.setName(args[2]);
person.setSex(args[3].equals("м") ? Sex.MALE : Sex.FEMALE);
try {
person.setBirthDay((new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH)).parse(args[4]));
} catch (ParseException e) {
e.printStackTrace();
}
}
public static void delete(String[] args) {
Person person = allPeople.get(Integer.parseInt(args[1]));
person.setName(null);
person.setSex(null);
person.setBirthDay(null);
}
public static void info(String[] args) {
Person person = allPeople.get(Integer.parseInt(args[1]));
System.out.println(person.getName() + " " + (person.getSex().equals(Sex.MALE) ? "м" : "ж") + " " + (new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH)).format(person.getBirthDay()));
}
}
|
[
"[email protected]"
] | |
49b211fbc921f10152998656c8765add8cbaa472
|
07bf9e1ef3559811804eb146032a61f6f5215c5e
|
/src/shy/teamcook/appffix/user/entity/PrivateUserEntity.java
|
845faaa755d72cb36f290fad7f61d1300e115384
|
[] |
no_license
|
bje0716/vod
|
8271d6d6bf1a5daff8af8652307b7797ef2fd934
|
57ce95e03334592a6654f4e4250d217e8acfbba8
|
refs/heads/master
| 2023-08-17T16:42:28.314541 | 2021-10-08T09:10:14 | 2021-10-08T09:10:14 | 414,695,140 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,377 |
java
|
package shy.teamcook.appffix.user.entity;
public class PrivateUserEntity extends UserEntity {
private String personalNumber; // (주민번호 / 912333-*******)
private String favoriteDirector; // (선호하는 감독 / 봉준호)
private String favoriteGenre; // (선호하는 장르 / 액션)
PrivateUserEntity() {}
PrivateUserEntity(String personalNumber) {
this.personalNumber = personalNumber;
this.favoriteDirector = "";
this.favoriteGenre = "";
}
public PrivateUserEntity(String personalNumber, String favoriteDirector, String favoriteGenre) {
this.personalNumber = personalNumber;
this.favoriteDirector = favoriteDirector;
this.favoriteGenre = favoriteGenre;
}
public String getPersonalNumber() {
return personalNumber;
}
public void setPersonalNumber(String personalNumber) {
this.personalNumber = personalNumber;
}
public String getFavoriteDirector() {
return favoriteDirector;
}
public void setFavoriteDirector(String favoriteDirector) {
this.favoriteDirector = favoriteDirector;
}
public String getFavoriteGenre() {
return favoriteGenre;
}
public void setFavoriteGenre(String favoriteGenre) {
this.favoriteGenre = favoriteGenre;
}
}
|
[
"[email protected]"
] | |
49441393d0ddbd4ad076a9caa09a0b539e3c9760
|
e0c8b073bb0deef25ec5cf3e845626c13a01d39a
|
/app/src/main/java/com/codepath/apps/restclienttemplate/TwitterClient.java
|
e4cb25ba3e9c8ab4bf8eccc36c3d18a3e1323627
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
shravya-95/SimpleTweetShravya
|
42919ef8eef8d641393d2189879316f324c0e0c4
|
11ff2528221b3195f927b77b5b3a07cbc57904e9
|
refs/heads/master
| 2023-01-02T23:33:11.626066 | 2020-10-17T23:05:31 | 2020-10-17T23:05:31 | 304,839,185 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,579 |
java
|
package com.codepath.apps.restclienttemplate;
import android.content.Context;
import com.codepath.oauth.OAuthBaseClient;
import com.github.scribejava.apis.FlickrApi;
import com.github.scribejava.apis.TwitterApi;
import com.github.scribejava.core.builder.api.BaseApi;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
/*
*
* This is the object responsible for communicating with a REST API.
* Specify the constants below to change the API being communicated with.
* See a full list of supported API classes:
* https://github.com/scribejava/scribejava/tree/master/scribejava-apis/src/main/java/com/github/scribejava/apis
* Key and Secret are provided by the developer site for the given API i.e dev.twitter.com
* Add methods for each relevant endpoint in the API.
*
* NOTE: You may want to rename this object based on the service i.e TwitterClient or FlickrClient
*
*/
public class TwitterClient extends OAuthBaseClient {
public static final BaseApi REST_API_INSTANCE = TwitterApi.instance();
public static final String REST_URL = "https://api.twitter.com/1.1/";
public static final String REST_CONSUMER_KEY = BuildConfig.TwitterRestConsumerApiKey;
public static final String REST_CONSUMER_SECRET = BuildConfig.TwitterRestConsumerSecret;
// Landing page to indicate the OAuth flow worked in case Chrome for Android 25+ blocks navigation back to the app.
public static final String FALLBACK_URL = "https://codepath.github.io/android-rest-client-template/success.html";
// See https://developer.chrome.com/multidevice/android/intents
public static final String REST_CALLBACK_URL_TEMPLATE = "intent://%s#Intent;action=android.intent.action.VIEW;scheme=%s;package=%s;S.browser_fallback_url=%s;end";
public TwitterClient(Context context) {
super(context, REST_API_INSTANCE,
REST_URL,
REST_CONSUMER_KEY,
REST_CONSUMER_SECRET,
String.format(REST_CALLBACK_URL_TEMPLATE, context.getString(R.string.intent_host),
context.getString(R.string.intent_scheme), context.getPackageName(), FALLBACK_URL));
}
// CHANGE THIS
// DEFINE METHODS for different API endpoints here
public void getHomeTimeline(AsyncHttpResponseHandler handler) {
String apiUrl = getApiUrl("statuses/home_timeline.json");
// Can specify query string params directly or through RequestParams.
RequestParams params = new RequestParams();
params.put("count", 5);
params.put("since_id", 1);
client.get(apiUrl, params, handler);
}
public void composeTweet(String tweetContent, AsyncHttpResponseHandler handler) {
String apiUrl = getApiUrl("statuses/update.json");
// Can specify query string params directly or through RequestParams.
RequestParams params = new RequestParams();
params.put("status", tweetContent);
client.post(apiUrl, params, handler);
}
public void getNextPageOfTweets(AsyncHttpResponseHandler handler, long maxId) {
String apiUrl = getApiUrl("statuses/home_timeline.json");
RequestParams params = new RequestParams();
params.put("count", 5);
params.put("max_id", maxId);
client.get(apiUrl, params, handler);
}
/* 1. Define the endpoint URL with getApiUrl and pass a relative path to the endpoint
* i.e getApiUrl("statuses/home_timeline.json");
* 2. Define the parameters to pass to the request (query or body)
* i.e RequestParams params = new RequestParams("foo", "bar");
* 3. Define the request method and make a call to the client
* i.e client.get(apiUrl, params, handler);
* i.e client.post(apiUrl, params, handler);
*/
}
|
[
"[email protected]"
] | |
fb43ec1fc530b9536f30374153ba7fc2b3e5253f
|
696d71e17fd1201312473771d22cdda3df81b077
|
/dynamic/src/main/java/com/mika/dynamic/log/Logger.java
|
07fc2db40b3929a5216ec8c978d9917906d8ec25
|
[] |
no_license
|
troy-sxj/PluginProject
|
ebb683d578ae9ef059c6d26dce5db73bfee36813
|
305a4382cf5499a5401da93e213f39c5e6ffa0a5
|
refs/heads/master
| 2020-04-06T22:30:45.489273 | 2019-01-02T06:54:17 | 2019-01-02T06:54:17 | 157,838,247 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,147 |
java
|
package com.mika.dynamic.log;
/**
* Logger.
*
* @author 12075179
* @date 2017/1/5
*/
public interface Logger {
/**
* @return is debug or not.
*/
boolean isDebug();
/**
* @param msg
*/
void v(String msg);
/**
* @param tag
* @param msg
*/
void v(String tag, String msg);
/**
* @param msg
*/
void d(String msg);
/**
* @param tag
* @param msg
*/
void d(String tag, String msg);
/**
* @param msg
*/
void i(String msg);
/**
* @param tag
* @param msg
*/
void i(String tag, String msg);
/**
* @param msg
*/
void w(String msg);
/**
* @param tag
* @param msg
*/
void w(String tag, String msg);
/**
* @param tag
* @param error
*/
void w(String tag, String msg, Throwable error);
/**
* @param msg
*/
void e(String msg);
/**
* @param tag
* @param msg
*/
void e(String tag, String msg);
/**
* @param tag
* @param error
*/
void e(String tag, String msg, Throwable error);
}
|
[
"[email protected]"
] | |
ff04282b65f701c19de1b8e1a0ad580364bd557b
|
7826588e64bb04dfb79c8262bad01235eb409b3d
|
/src/test/java/com/microsoft/bingads/v13/api/test/entities/ad_extension/disclaimer/write/BulkDisclaimerAdExtensionWriteToValuesPopupTextTest.java
|
be750134baba528d4163b3bfba091bb684888b74
|
[
"MIT"
] |
permissive
|
BingAds/BingAds-Java-SDK
|
dcd43e5a1beeab0b59c1679da1151d7dd1658d50
|
a3d904bbf93a0a93d9c117bfff40f6911ad71d2f
|
refs/heads/main
| 2023-08-28T13:48:34.535773 | 2023-08-18T06:41:51 | 2023-08-18T06:41:51 | 29,510,248 | 33 | 44 |
NOASSERTION
| 2023-08-23T01:29:18 | 2015-01-20T03:40:03 |
Java
|
UTF-8
|
Java
| false | false | 1,259 |
java
|
package com.microsoft.bingads.v13.api.test.entities.ad_extension.disclaimer.write;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.v13.api.test.entities.ad_extension.disclaimer.BulkDisclaimerAdExtensionTest;
import com.microsoft.bingads.v13.bulk.entities.BulkDisclaimerAdExtension;
public class BulkDisclaimerAdExtensionWriteToValuesPopupTextTest extends BulkDisclaimerAdExtensionTest {
@Parameter(value = 1)
public String expectedResult;
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{"Popup text", "Popup text"},
{null, null}
});
}
@Test
public void testWrite() {
this.<String>testWriteProperty("Disclaimer Popup Text", this.datum, this.expectedResult, new BiConsumer<BulkDisclaimerAdExtension, String>() {
@Override
public void accept(BulkDisclaimerAdExtension c, String v) {
c.getDisclaimerAdExtension().setPopupText(v);
}
});
}
}
|
[
"[email protected]"
] | |
f05409282a7a184d50ff5c1f12ac756f7d8ff857
|
7fca4e645f24880ab75f644f03d227aa5688749d
|
/p3/patterns/memento/src/memento/Originator.java
|
88604c9203b5e26f3dc8af0d4b99b713a2b02081
|
[] |
no_license
|
jcarlosadm/classes
|
95e687f8ec6e4c1f405442de86c0dffc588f0f2e
|
9658b1b0805647f64d02c4b760d81d26943ec6da
|
refs/heads/master
| 2021-05-15T02:18:30.318844 | 2018-07-24T15:29:20 | 2018-07-24T15:29:20 | 24,521,175 | 2 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 570 |
java
|
package memento;
public class Originator {
private String state;
public void setState(String state) {
System.out.println("Originator: Setting state to: "+state);
this.state = state;
}
public Memento saveToMemento(){
System.out.println("Originator: Saving to Memento.");
return new Memento(this.state);
}
public void restoreFromMemento(Memento memento){
this.state = memento.getSavedState();
System.out.println("Originator: State after restoring from Memento: "+this.state);
}
}
|
[
"[email protected]"
] | |
c845aa0f6b93f7443f31a7d5608d798e6c7396b1
|
69011b4a6233db48e56db40bc8a140f0dd721d62
|
/src/com/jshx/aqscsgyhpc/web/AqscsgyhpcAction.java
|
d3d71e80ca609f63351171eb8e172a702f994248
|
[] |
no_license
|
gechenrun/scysuper
|
bc5397e5220ee42dae5012a0efd23397c8c5cda0
|
e706d287700ff11d289c16f118ce7e47f7f9b154
|
refs/heads/master
| 2020-03-23T19:06:43.185061 | 2018-06-10T07:51:18 | 2018-06-10T07:51:18 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 9,822 |
java
|
package com.jshx.aqscsgyhpc.web;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.struts2.ServletActionContext;
import org.hibernate.LobHelper;
import org.hibernate.SessionFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;
import com.jshx.core.base.action.BaseAction;
import com.jshx.core.base.vo.Pagination;
import com.jshx.core.utils.Struts2Util;
import com.jshx.module.admin.entity.Department;
import com.jshx.module.admin.entity.User;
import com.jshx.module.form.service.AttachfileService;
import com.jshx.core.json.CodeJsonValueProcessor;
import com.jshx.core.json.DateJsonValueProcessor;
import com.jshx.gwhy.entity.GwhyBean;
import com.jshx.aqscsgyhpc.entity.Aqscsgyhpc;
import com.jshx.aqscsgyhpc.entity.AqscsgyhpcBean;
import com.jshx.aqscsgyhpc.service.AqscsgyhpcService;
public class AqscsgyhpcAction extends BaseAction
{
/**
* 主键ID列表,用于接收页面提交的多条主键ID信息
*/
private String ids;
/**
* 实体类
*/
private Aqscsgyhpc aqscsgyhpc = new Aqscsgyhpc();
/**
* 业务类
*/
@Autowired
private AqscsgyhpcService aqscsgyhpcService;
/**
* 修改新增标记,add为新增、mod为修改
*/
private String flag;
/**
* 分页信息
*/
private Pagination pagination;
private Date queryYearTimeStart;
private Date queryYearTimeEnd;
List<AqscsgyhpcBean> aqsclist=new ArrayList<AqscsgyhpcBean>();
@Autowired()
@Qualifier("sessionFactory")
private SessionFactory sessionFactory;
/**
* 执行查询的方法,返回json数据
*/
public void list() throws Exception{
Map<String, Object> paraMap = new HashMap<String, Object>();
if(pagination==null)
pagination = new Pagination(this.getRequest());
if(null != aqscsgyhpc){
//设置查询条件,开发人员可以在此增加过滤条件
if (null != queryYearTimeStart){
paraMap.put("startYearTime", queryYearTimeStart);
}
if (null != queryYearTimeEnd){
paraMap.put("endYearTime", queryYearTimeEnd);
}
if ((null != aqscsgyhpc.getAreaName()) && (0 < aqscsgyhpc.getAreaName().trim().length())){
paraMap.put("areaName", "%" + aqscsgyhpc.getAreaName().trim() + "%");
}
}
JsonConfig config = new JsonConfig();
config.registerJsonValueProcessor(java.util.Date.class,new DateJsonValueProcessor());
Map<String, String> codeMap = new HashMap<String, String>();
//此处添加需要转换的一维代码,key是一维代码在数据对象中的属性名,value是一维代码的codeId
config.registerJsonValueProcessor(String.class,new CodeJsonValueProcessor(codeMap));
final String filter = "id|yearTime|areaName|";
if (filter != null && filter.length() > 1) {
config.setJsonPropertyFilter(new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if (filter.indexOf(name + "|") != -1)
return false;
else
return true;
}
});
}
pagination = aqscsgyhpcService.findByPage(pagination, paraMap);
convObjectToJson(pagination, config);
}
/**
* 查看详细信息
*/
public String view() throws Exception{
if((null != aqscsgyhpc)&&(null != aqscsgyhpc.getId()))
aqscsgyhpc = aqscsgyhpcService.getById(aqscsgyhpc.getId());
return VIEW;
}
/**
* 初始化修改信息
*/
public String initEdit() throws Exception{
view();
return EDIT;
}
/**
* 保存信息(包括新增和修改)
*/
public String save() throws Exception{
FileInputStream in = null;
try
{
//设置Blob字段
setBlobField(in);
}
finally
{
if (null != in)
{
try
{
in.close();
}
catch (Exception ex)
{
}
}
}
if(aqscsgyhpc.getAreaName().equals("中新合作区")){
aqscsgyhpc.setAreaId("1");
}if(aqscsgyhpc.getAreaName().equals("娄葑街道")){
aqscsgyhpc.setAreaId("2");
}if(aqscsgyhpc.getAreaName().equals("斜塘街道")){
aqscsgyhpc.setAreaId("3");
}if(aqscsgyhpc.getAreaName().equals("唯亭街道")){
aqscsgyhpc.setAreaId("4");
}if(aqscsgyhpc.getAreaName().equals("胜浦街道")){
aqscsgyhpc.setAreaId("5");
}if(aqscsgyhpc.getAreaName().equals("其他部门")){
aqscsgyhpc.setAreaId("6");
}
if ("add".equalsIgnoreCase(this.flag)){
aqscsgyhpc.setDeptId(this.getLoginUserDepartmentId());
aqscsgyhpc.setDelFlag(0);
aqscsgyhpcService.save(aqscsgyhpc);
}else{
aqscsgyhpcService.update(aqscsgyhpc);
}
return RELOAD;
}
/**
* 将File对象转换为Blob对象,并设置到实体类中
* 如果没有File对象,可删除此方法,并一并删除save方法中调用此方法的代码
*/
private void setBlobField(FileInputStream in)
{
if (null != aqscsgyhpc)
{
try
{
//此处将File对象转换成blob对象,并设置到aqscsgyhpc中去
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
/**
* 删除信息
*/
public String delete() throws Exception{
try{
aqscsgyhpcService.deleteWithFlag(ids);
this.getResponse().getWriter().println("{\"result\":true}");
}catch(Exception e){
this.getResponse().getWriter().println("{\"result\":false}");
}
return null;
}
public void export()
{
try {
Map<String, Object> paraMap = new HashMap<String, Object>();
if(flag == null || "".equals(flag))
{
queryYearTimeStart = (Date) getSessionAttribute("queryYearTimeStart");
}
if (null != queryYearTimeStart && !"".equals(queryYearTimeStart)){
paraMap.put("startYearTime", queryYearTimeStart);
setSessionAttribute("queryYearTimeStart", queryYearTimeStart);
}
try {
aqsclist = aqscsgyhpcService.getAqscsgyhpcListByMap(paraMap);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
AqscsgyhpcBean aqsc = aqscsgyhpcService.getTotalAqscsgyhpcListByMap(paraMap);
aqsc.setData1("合计");
aqsclist.add(aqsc);
getResponse().setContentType("octets/stream");
getResponse().addHeader("Content-Disposition", "attachment;filename=aqscsg.xls");
String root = this.getRequest().getRealPath("/");
root = root.replaceAll("\\\\", "/");
InputStream is= new FileInputStream(root + "aqscsg.xls");
HSSFWorkbook wb = new HSSFWorkbook(is);
HSSFSheet sheet = wb.getSheetAt(0);
int num = 2;
int j=1;
for(int i=0;i<aqsclist.size();i++)
{
AqscsgyhpcBean aqscbean = aqsclist.get(i);
HSSFRow row0 = sheet.createRow(num);
HSSFCellStyle css = wb.createCellStyle();
css.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
css.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
css.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
css.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
HSSFCell cel0 = row0.createCell(0);
cel0.setCellValue(j);
cel0.setCellStyle(css);
HSSFCell cel1 = row0.createCell(1);
cel1.setCellValue(aqscbean.getData1());
cel1.setCellStyle(css);
HSSFCell cel2 = row0.createCell(2);
cel2.setCellValue(aqscbean.getData2());
cel2.setCellStyle(css);
HSSFCell cel3 = row0.createCell(3);
cel3.setCellValue(aqscbean.getData3());
cel3.setCellStyle(css);
HSSFCell cel4 = row0.createCell(4);
cel4.setCellValue(aqscbean.getData4());
cel4.setCellStyle(css);
HSSFCell cel5 = row0.createCell(5);
cel5.setCellValue(aqscbean.getData5());
cel5.setCellStyle(css);
HSSFCell cel6 = row0.createCell(6);
cel6.setCellValue(aqscbean.getData6());
cel6.setCellStyle(css);
HSSFCell cel7 = row0.createCell(7);
cel7.setCellValue(aqscbean.getData7());
cel7.setCellStyle(css);
num ++;
j++;
}
wb.write(getResponse().getOutputStream());
System.out.println("excel导出成功!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getIds(){
return ids;
}
public void setIds(String ids){
this.ids = ids;
}
public Pagination getPagination(){
return pagination;
}
public void setPagination(Pagination pagination){
this.pagination = pagination;
}
public Aqscsgyhpc getAqscsgyhpc(){
return this.aqscsgyhpc;
}
public void setAqscsgyhpc(Aqscsgyhpc aqscsgyhpc){
this.aqscsgyhpc = aqscsgyhpc;
}
public String getFlag(){
return flag;
}
public void setFlag(String flag){
this.flag = flag;
}
public Date getQueryYearTimeStart(){
return this.queryYearTimeStart;
}
public void setQueryYearTimeStart(Date queryYearTimeStart){
this.queryYearTimeStart = queryYearTimeStart;
}
public Date getQueryYearTimeEnd(){
return this.queryYearTimeEnd;
}
public void setQueryYearTimeEnd(Date queryYearTimeEnd){
this.queryYearTimeEnd = queryYearTimeEnd;
}
public List<AqscsgyhpcBean> getAqsclist() {
return aqsclist;
}
public void setAqsclist(List<AqscsgyhpcBean> aqsclist) {
this.aqsclist = aqsclist;
}
}
|
[
"[email protected]"
] | |
f3d07ae17c82525b33ad9b6dc381832948818a85
|
79050113b98c5479bc49499a22da1a25909d937b
|
/sk/src/main/java/sk/game/mock/PlayerCharacter.java
|
6a6903b5adc863a9cb1416e15c35cbe67a0609cb
|
[] |
no_license
|
HamptonJ/Learning_Java
|
5f0c9412176a7b2178e8ffc13be1f437de036a2c
|
f946500cd322542e9fb94c087913da6392b09899
|
refs/heads/master
| 2021-01-02T08:48:01.542793 | 2017-08-02T04:09:44 | 2017-08-02T04:09:44 | 99,062,834 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 405 |
java
|
/**
* $BATTELLE_CONTRACT_DISCLAIMER$
*/
package sk.game.mock;
import sk.game.character.GameCharacter;
/**
* @author Jhampton
*
*/
public class PlayerCharacter implements GameCharacter {
/* (non-Javadoc)
* @see sk.game.character.GameCharacter#move(java.lang.String)
*/
@Override
public void move(String direction) {
// TODO Auto-generated method stub
}
}
|
[
"[email protected]"
] | |
9c04869a862189dd8ebb82d49caa91b845755984
|
bbc0b2e507fd81afd11aa26b2d180912ed2f1927
|
/app/src/main/java/com/kapici/kapici/Adapters/SearchRecyclerAdapter.java
|
6439debeffa481e554f4aa53499fd4b04a57299e
|
[] |
no_license
|
doukurt/tasarim
|
84b8cb5eaa429dabdcb870c074128f1506859e25
|
01792bb9aa85bb93170fd2adafab64105fd9b55f
|
refs/heads/master
| 2023-05-29T02:45:49.621148 | 2021-06-10T10:06:59 | 2021-06-10T10:06:59 | 329,975,492 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 7,727 |
java
|
package com.kapici.kapici.Adapters;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.kapici.kapici.Models.Users;
import com.kapici.kapici.R;
import com.squareup.picasso.Picasso;
public class SearchRecyclerAdapter extends RecyclerView.Adapter<SearchRecyclerAdapter.SearchViewHolder> {
ArrayList<String> shoppingCart =new ArrayList<>();
ArrayList<String> cartQuantities =new ArrayList<>();
private long totalPrice;
private ArrayList<String> productNameList;
private ArrayList<String> productPriceList;
private ArrayList<String> productImageList;
private ArrayList<String> productIdList;
private ArrayList<String> productDetailList;
private ArrayList<String> productCategoryList;
private ArrayList<String> productImageNameList;
FirebaseFirestore firebaseFirestore= FirebaseFirestore.getInstance();
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = firebaseAuth.getCurrentUser();
public SearchRecyclerAdapter(ArrayList<String> productNameList, ArrayList<String> productPriceList, ArrayList<String> productImageList, ArrayList<String> productIdList, ArrayList<String> productDetailList, ArrayList<String> productCategoryList, ArrayList<String> productImageNameList) {
this.productNameList = productNameList;
this.productPriceList = productPriceList;
this.productImageList = productImageList;
this.productIdList = productIdList;
this.productDetailList = productDetailList;
this.productCategoryList = productCategoryList;
this.productImageNameList = productImageNameList;
}
@NonNull
@Override
public SearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.single_category_product,parent,false);
return new SearchViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull SearchViewHolder holder, int position) {
holder.productName.setText(productNameList.get(position));
Picasso.get().load(productImageList.get(position)).into(holder.productImage);
holder.productPrice.setText(String.format("%s₺", productPriceList.get(position)));
holder.increase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i= Integer.parseInt(holder.productCount.getText().toString());
i++;
holder.productCount.setText(String.valueOf(i));
}
});
holder.decrease.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i= Integer.parseInt(holder.productCount.getText().toString());
if (i>1){
i--;
holder.productCount.setText(String.valueOf(i));
}
}
});
holder.addCart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id=currentUser.getUid();
firebaseFirestore.collection("UserDetails").document(id).get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
Users user = documentSnapshot.toObject(Users.class);
assert user != null;
shoppingCart= (ArrayList<String>) user.getShoppingCart();
cartQuantities= (ArrayList<String>) user.getCartQuantities();
totalPrice = user.getCartTotal();
if (!shoppingCart.contains(productIdList.get(position))){
totalPrice+= Long.parseLong(String.valueOf(holder.productCount.getText()))*Long.parseLong(productPriceList.get(position));
cartQuantities.add(holder.productCount.getText().toString());
shoppingCart.add(productIdList.get(position));
firebaseFirestore.collection("UserDetails").document(id).update("shoppingCart",shoppingCart,"cartQuantities",cartQuantities,"cartTotal",totalPrice)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(holder.itemView.getContext(),"Sepete Başarıyla Eklendi",Toast.LENGTH_LONG).show();
}
});
}else if (shoppingCart.contains(productIdList.get(position))){
int index = shoppingCart.indexOf(productIdList.get(position));
int cartQuantitForUpdate= Integer.parseInt(cartQuantities.get(index));
int productCountForUpdate = Integer.parseInt(holder.productCount.getText().toString());
int newQuantity = cartQuantitForUpdate+productCountForUpdate;
cartQuantities.set(index, String.valueOf(newQuantity));
totalPrice+= Long.parseLong(holder.productCount.getText().toString())*Long.parseLong(productPriceList.get(position));
firebaseFirestore.collection("UserDetails").document(id).update("cartQuantities",cartQuantities,"cartTotal",totalPrice).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(holder.itemView.getContext(),"Sepete Başarıyla Eklendi",Toast.LENGTH_LONG).show();
}
});
}
}
});
}
});
}
@Override
public int getItemCount() {
return productNameList.size();
}
class SearchViewHolder extends RecyclerView.ViewHolder{
ImageView productImage;
TextView productName,productPrice;
EditText productCount;
CardView cardView;
Button increase,decrease,addCart;
public SearchViewHolder(@NonNull View itemView) {
super(itemView);
productImage=itemView.findViewById(R.id.listProductImage);
productName=itemView.findViewById(R.id.listProductName);
productCount=itemView.findViewById(R.id.productCount);
increase=itemView.findViewById(R.id.increase);
decrease=itemView.findViewById(R.id.decrease);
addCart=itemView.findViewById(R.id.addCart);
productPrice=itemView.findViewById(R.id.listProductPrice);
cardView=itemView.findViewById(R.id.single_category_product_id);
}
}
}
|
[
"[email protected]"
] | |
eb2c20aa32904d0f8f47fe4afb671addcd506fb4
|
75f99df486fd3794af193cfaabb7ab8c2d2e2d00
|
/fatec-museu/MASProject/jfreechart-1.0.19/source/org/jfree/chart/plot/dial/ArcDialFrame.java
|
d80b7a4176d41c9f0eafb1fd6cffa4c4cbfda297
|
[
"LGPL-3.0-only",
"GPL-3.0-only",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"MIT"
] |
permissive
|
Koynonia/fatec-campeonato
|
1f7c1199154361ea96ffc07a3b205915f9b3f653
|
f5506319ffb76eda4f67e0cf905653039d082bf7
|
refs/heads/master
| 2022-12-20T04:48:11.338940 | 2020-06-22T00:29:45 | 2020-06-22T00:29:45 | 273,974,445 | 0 | 0 |
MIT
| 2020-10-13T22:58:35 | 2020-06-21T19:57:12 |
Java
|
UTF-8
|
Java
| false | false | 16,061 |
java
|
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------
* ArcDialFrame.java
* -----------------
* (C) Copyright 2006-2013, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 03-Nov-2006 : Version 1 (DG);
* 08-Mar-2007 : Fix in hashCode() (DG);
* 17-Oct-2007 : Updated equals() (DG);
* 24-Oct-2007 : Added argument checks and API docs, and renamed
* StandardDialFrame --> ArcDialFrame (DG);
*
*/
package org.jfree.chart.plot.dial;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Arc2D;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.jfree.chart.HashUtilities;
import org.jfree.chart.util.ParamChecks;
import org.jfree.io.SerialUtilities;
import org.jfree.util.PaintUtilities;
import org.jfree.util.PublicCloneable;
/**
* A standard frame for the {@link DialPlot} class.
*
* @since 1.0.7
*/
public class ArcDialFrame extends AbstractDialLayer implements DialFrame,
Cloneable, PublicCloneable, Serializable {
/** For serialization. */
static final long serialVersionUID = -4089176959553523499L;
/**
* The color used for the front of the panel. This field is transient
* because it requires special handling for serialization.
*/
private transient Paint backgroundPaint;
/**
* The color used for the border around the window. This field is transient
* because it requires special handling for serialization.
*/
private transient Paint foregroundPaint;
/**
* The stroke for drawing the frame outline. This field is transient
* because it requires special handling for serialization.
*/
private transient Stroke stroke;
/**
* The start angle.
*/
private double startAngle;
/**
* The end angle.
*/
private double extent;
/** The inner radius, relative to the framing rectangle. */
private double innerRadius;
/** The outer radius, relative to the framing rectangle. */
private double outerRadius;
/**
* Creates a new instance of <code>ArcDialFrame</code> that spans
* 180 degrees.
*/
public ArcDialFrame() {
this(0, 180);
}
/**
* Creates a new instance of <code>ArcDialFrame</code> that spans
* the arc specified.
*
* @param startAngle the startAngle (in degrees).
* @param extent the extent of the arc (in degrees, counter-clockwise).
*/
public ArcDialFrame(double startAngle, double extent) {
this.backgroundPaint = Color.gray;
this.foregroundPaint = new Color(100, 100, 150);
this.stroke = new BasicStroke(2.0f);
this.innerRadius = 0.25;
this.outerRadius = 0.75;
this.startAngle = startAngle;
this.extent = extent;
}
/**
* Returns the background paint (never <code>null</code>).
*
* @return The background paint.
*
* @see #setBackgroundPaint(Paint)
*/
public Paint getBackgroundPaint() {
return this.backgroundPaint;
}
/**
* Sets the background paint and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param paint the paint (<code>null</code> not permitted).
*
* @see #getBackgroundPaint()
*/
public void setBackgroundPaint(Paint paint) {
ParamChecks.nullNotPermitted(paint, "paint");
this.backgroundPaint = paint;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the foreground paint.
*
* @return The foreground paint (never <code>null</code>).
*
* @see #setForegroundPaint(Paint)
*/
public Paint getForegroundPaint() {
return this.foregroundPaint;
}
/**
* Sets the foreground paint and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param paint the paint (<code>null</code> not permitted).
*
* @see #getForegroundPaint()
*/
public void setForegroundPaint(Paint paint) {
ParamChecks.nullNotPermitted(paint, "paint");
this.foregroundPaint = paint;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the stroke.
*
* @return The stroke (never <code>null</code>).
*
* @see #setStroke(Stroke)
*/
public Stroke getStroke() {
return this.stroke;
}
/**
* Sets the stroke and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param stroke the stroke (<code>null</code> not permitted).
*
* @see #getStroke()
*/
public void setStroke(Stroke stroke) {
ParamChecks.nullNotPermitted(stroke, "stroke");
this.stroke = stroke;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the inner radius, relative to the framing rectangle.
*
* @return The inner radius.
*
* @see #setInnerRadius(double)
*/
public double getInnerRadius() {
return this.innerRadius;
}
/**
* Sets the inner radius and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param radius the inner radius.
*
* @see #getInnerRadius()
*/
public void setInnerRadius(double radius) {
if (radius < 0.0) {
throw new IllegalArgumentException("Negative 'radius' argument.");
}
this.innerRadius = radius;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the outer radius, relative to the framing rectangle.
*
* @return The outer radius.
*
* @see #setOuterRadius(double)
*/
public double getOuterRadius() {
return this.outerRadius;
}
/**
* Sets the outer radius and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param radius the outer radius.
*
* @see #getOuterRadius()
*/
public void setOuterRadius(double radius) {
if (radius < 0.0) {
throw new IllegalArgumentException("Negative 'radius' argument.");
}
this.outerRadius = radius;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the start angle.
*
* @return The start angle.
*
* @see #setStartAngle(double)
*/
public double getStartAngle() {
return this.startAngle;
}
/**
* Sets the start angle and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param angle the angle.
*
* @see #getStartAngle()
*/
public void setStartAngle(double angle) {
this.startAngle = angle;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the extent.
*
* @return The extent.
*
* @see #setExtent(double)
*/
public double getExtent() {
return this.extent;
}
/**
* Sets the extent and sends a {@link DialLayerChangeEvent} to
* all registered listeners.
*
* @param extent the extent.
*
* @see #getExtent()
*/
public void setExtent(double extent) {
this.extent = extent;
notifyListeners(new DialLayerChangeEvent(this));
}
/**
* Returns the shape for the window for this dial. Some dial layers will
* request that their drawing be clipped within this window.
*
* @param frame the reference frame (<code>null</code> not permitted).
*
* @return The shape of the dial's window.
*/
@Override
public Shape getWindow(Rectangle2D frame) {
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius, this.innerRadius);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius, this.outerRadius);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
this.extent, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ this.extent, -this.extent, Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
/**
* Returns the outer window.
*
* @param frame the frame.
*
* @return The outer window.
*/
protected Shape getOuterWindow(Rectangle2D frame) {
double radiusMargin = 0.02;
double angleMargin = 1.5;
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius - radiusMargin, this.innerRadius
- radiusMargin);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius + radiusMargin, this.outerRadius
+ radiusMargin);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle
- angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ angleMargin + this.extent, -this.extent - 2 * angleMargin,
Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
/**
* Draws the frame.
*
* @param g2 the graphics target.
* @param plot the plot.
* @param frame the dial's reference frame.
* @param view the dial's view rectangle.
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
Shape window = getWindow(frame);
Shape outerWindow = getOuterWindow(frame);
Area area1 = new Area(outerWindow);
Area area2 = new Area(window);
area1.subtract(area2);
g2.setPaint(Color.lightGray);
g2.fill(area1);
g2.setStroke(this.stroke);
g2.setPaint(this.foregroundPaint);
g2.draw(window);
g2.draw(outerWindow);
}
/**
* Returns <code>false</code> to indicate that this dial layer is not
* clipped to the dial window.
*
* @return <code>false</code>.
*/
@Override
public boolean isClippedToWindow() {
return false;
}
/**
* Tests this instance for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ArcDialFrame)) {
return false;
}
ArcDialFrame that = (ArcDialFrame) obj;
if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) {
return false;
}
if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) {
return false;
}
if (this.startAngle != that.startAngle) {
return false;
}
if (this.extent != that.extent) {
return false;
}
if (this.innerRadius != that.innerRadius) {
return false;
}
if (this.outerRadius != that.outerRadius) {
return false;
}
if (!this.stroke.equals(that.stroke)) {
return false;
}
return super.equals(obj);
}
/**
* Returns a hash code for this instance.
*
* @return The hash code.
*/
@Override
public int hashCode() {
int result = 193;
long temp = Double.doubleToLongBits(this.startAngle);
result = 37 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.extent);
result = 37 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.innerRadius);
result = 37 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.outerRadius);
result = 37 * result + (int) (temp ^ (temp >>> 32));
result = 37 * result + HashUtilities.hashCodeForPaint(
this.backgroundPaint);
result = 37 * result + HashUtilities.hashCodeForPaint(
this.foregroundPaint);
result = 37 * result + this.stroke.hashCode();
return result;
}
/**
* Returns a clone of this instance.
*
* @return A clone.
*
* @throws CloneNotSupportedException if any attribute of this instance
* cannot be cloned.
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* Provides serialization support.
*
* @param stream the output stream.
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
SerialUtilities.writePaint(this.backgroundPaint, stream);
SerialUtilities.writePaint(this.foregroundPaint, stream);
SerialUtilities.writeStroke(this.stroke, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.backgroundPaint = SerialUtilities.readPaint(stream);
this.foregroundPaint = SerialUtilities.readPaint(stream);
this.stroke = SerialUtilities.readStroke(stream);
}
}
|
[
"[email protected]"
] | |
3724a72219d9664755106f19d638082e5bc918f5
|
c34ac07ccd06a2e88e5282fd26ac94c144a533e1
|
/src/main/java/cat/udl/cig/structures/builder/GroupElementBuilder.java
|
b4adab533a5a340d06122fbd85fc9209145097f7
|
[
"MIT"
] |
permissive
|
Oriolac/cig-lib
|
b9d03695acf67c2f079808fbfbdf8ddd131b009e
|
1bf29a9e749e85400f2349767fa312f7e6c0980e
|
refs/heads/master
| 2021-11-19T22:04:53.153010 | 2021-09-30T14:19:52 | 2021-09-30T14:19:52 | 222,956,242 | 1 | 0 |
MIT
| 2021-09-06T07:20:16 | 2019-11-20T14:29:40 |
Java
|
UTF-8
|
Java
| false | false | 203 |
java
|
package cat.udl.cig.structures.builder;
import cat.udl.cig.structures.GroupElement;
import java.util.Optional;
public interface GroupElementBuilder {
Optional<? extends GroupElement> build();
}
|
[
"[email protected]"
] | |
bd0f7831e914afeac96d7ca06face95cfc35029c
|
1157ddeba3a715637d131a03820236ba072c48b3
|
/api/src/main/java/org/openmrs/module/drugshistory/DrugsHistory.java
|
a4b7bc8955bfec186e23b38b058f1c6ebe00023c
|
[] |
no_license
|
Guerschon/drugshistory
|
0baf8f46e900d62cbeb66153969d6e25d13ef8de
|
e0e88d97d27dcc2a0a7eea3209223d41d037909f
|
refs/heads/master
| 2020-07-07T01:53:16.153019 | 2016-09-16T16:13:07 | 2016-09-16T16:13:07 | 67,516,071 | 0 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,085 |
java
|
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.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://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.drugshistory;
import java.io.Serializable;
import org.openmrs.BaseOpenmrsObject;
import org.openmrs.BaseOpenmrsMetadata;
/**
* It is a model class. It should extend either {@link BaseOpenmrsObject} or {@link BaseOpenmrsMetadata}.
*/
public class DrugsHistory extends BaseOpenmrsObject implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
}
|
[
"[email protected]"
] | |
e8c212e90051bedce084c148acbf0b059c11c58c
|
ef0952749946e230110b4e5b9055094398c0a01e
|
/JAVA/WebExample/ArrayZ.java
|
e9fb3e8c083ac4159cc8f9bda228d84a936f0e04
|
[] |
no_license
|
lees86209/Tatung_High_School-Coding
|
f3f6c31fa3ef25a7a3757d4a42cd219261d36d5f
|
f6601bd915d084ddbe8c341e50b71903108e2c1e
|
refs/heads/master
| 2022-03-27T09:27:09.106731 | 2019-12-12T08:41:11 | 2019-12-12T08:41:11 | null | 0 | 0 | null | null | null | null |
BIG5
|
Java
| false | false | 1,464 |
java
|
public class ArrayZ implements ArrayInterface {// implements ArrayInterface
public int[][] CreateRandomArray(int rowSize, int columSize) {// 產生亂數row*colum矩陣
int[][] randomArray = new int[rowSize][columSize];// 產生一個陣列空間size依照引數
for (int i = 0; i < rowSize; i++) {// 依序將亂數填入矩陣
for (int j = 0; j < columSize; j++) {
int r = (int) (30 * java.lang.Math.random());// 亂數產生,因為是double型態要強制轉換至int
randomArray[i][j] = r;
}
}
return randomArray;// 回傳矩陣
}
public int sum(int[][] arrayZ) {// 將矩陣丟入回傳總和
int sum = 0;
for (int i = 0; i < arrayZ.length; i++) {// 依序將array的值丟入sum
for (int j = 0; j < arrayZ[i].length; j++) {
sum += arrayZ[i][j];
}
}
return sum;
}
public void display(int[][] arrayb) { // 印出矩陣每一個元素
for (int k = 0; k < arrayb.length; k++) {
for (int l = 0; l < arrayb[k].length; l++) {
int t = arrayb[k][l];
System.out.print(t + " ");
}
System.out.println();
}
}
public int[][] combine(int[][] arrayX, int[][] arrayY) {// 相加兩個矩陣
int sum = 0;
int[][] arrayZ = new int[3][3];
for (int i = 0; i < arrayZ.length; i++) {
for (int j = 0; j < arrayZ[i].length; j++) {
arrayZ[i][j] = arrayX[i][j] + arrayY[i][j];
sum += arrayZ[i][j];
}
}
return arrayZ;// 回傳矩陣
}
}
|
[
"[email protected]"
] | |
0427a9010c89653665d40d8ab9b1eb0cf929e61c
|
77f3f5e1d9c8d6560bb4697b57c28c14404b55aa
|
/erpwell/erpwell/trunk/SourceCode/Client/com.graly.erp.inv/src/com/graly/erp/inv/material/online/QueryDialog.java
|
4d7e5ad599ca9e341457801950a2d6058ce9cea7
|
[
"Apache-2.0"
] |
permissive
|
liulong02/ERPL
|
b1871a1836c8e25af6a18d184b2f68f1b1bfdc5e
|
c8db598a3f762b357ae986050066098ce62bed44
|
refs/heads/master
| 2020-03-21T22:26:06.459293 | 2018-06-30T14:55:48 | 2018-06-30T14:55:48 | 139,126,269 | 0 | 0 | null | 2018-06-29T13:59:15 | 2018-06-29T08:57:20 | null |
GB18030
|
Java
| false | false | 9,593 |
java
|
package com.graly.erp.inv.material.online;
import java.util.HashMap;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.graly.erp.base.model.Material;
import com.graly.framework.activeentity.client.ADManager;
import com.graly.framework.activeentity.model.ADField;
import com.graly.framework.activeentity.model.ADTable;
import com.graly.framework.base.entitymanager.IRefresh;
import com.graly.framework.base.entitymanager.dialog.ExtendDialog;
import com.graly.framework.base.entitymanager.editor.EntityEditor;
import com.graly.framework.base.entitymanager.editor.EntityTableManager;
import com.graly.framework.base.entitymanager.editor.SectionEntryPage;
import com.graly.framework.base.entitymanager.forms.MasterSection;
import com.graly.framework.base.entitymanager.query.EntityQueryDialog;
import com.graly.framework.base.entitymanager.query.QueryForm;
import com.graly.framework.base.ui.forms.field.ComboField;
import com.graly.framework.base.ui.forms.field.IField;
import com.graly.framework.base.ui.forms.field.SearchField;
import com.graly.framework.base.ui.forms.field.TextField;
import com.graly.framework.base.ui.util.Env;
import com.graly.framework.base.ui.util.I18nUtil;
import com.graly.framework.base.ui.util.Message;
import com.graly.framework.base.ui.util.SWTResourceCache;
import com.graly.framework.base.ui.util.UI;
import com.graly.framework.runtime.Framework;
import com.graly.framework.runtime.exceptionhandler.ExceptionHandlerManager;
public class QueryDialog extends ExtendDialog {
private static String ID_MATERIALID = "materialRrn";
private static String ID_MATERIALNAME = "name";
private static String ID_IS_PURCHASE = "isPurchase";
private OnlineQueryDialog queryDialog;
private EntityTableManager tableManager;
protected boolean isCreateQuery;
public QueryDialog() {
super();
queryDialog = new OnlineQueryDialog(UI.getActiveShell());
}
public QueryDialog(boolean isCreateQuery) {
this.isCreateQuery = isCreateQuery;
}
@Override
public int open() {
int id = queryDialog.open();
setQueryDialogToSection();
return id;
}
// 调用该方法必须保证tableId不为空
protected EntityTableManager getEntityTableManager() {
ADManager manager;
try {
manager = Framework.getService(ADManager.class);
tableManager = new EntityTableManager(manager.getADTable(Long.valueOf(getTableId())));
} catch (Exception e) {
ExceptionHandlerManager.asyncHandleException(e);
}
return tableManager;
}
protected void setQueryDialogToSection() {
if(getParent() instanceof EntityEditor){
EntityEditor editor = (EntityEditor) getParent();
if(editor.getActivePageInstance() instanceof SectionEntryPage){
SectionEntryPage page = (SectionEntryPage) editor.getActivePageInstance();
MasterSection section = page.getMasterSection();
queryDialog.setIRefresh(section);
section.setQueryDialog(queryDialog);
((OnlineSection)section).setExtendDialog(this);
}
}
}
public OnlineQueryDialog getEntityQueryDialog() {
return this.queryDialog;
}
public void setEntityQueryDialog(EntityQueryDialog queryDialog) {
this.queryDialog = (OnlineQueryDialog)queryDialog;
}
class OnlineQueryDialog extends EntityQueryDialog {
String ModelName = "Material";
ADTable adTable;
public OnlineQueryDialog(Shell parent) {
super(parent);
}
public OnlineQueryDialog(Shell parent,
EntityTableManager tableManager, IRefresh refresh) {
super(parent, tableManager, refresh);
}
public OnlineQueryDialog(Shell parent,
ADTable adTable, IRefresh refresh) {
super(parent, null, refresh);
this.adTable = adTable;
}
@Override
protected Control createDialogArea(Composite parent) {
setTitleImage(SWTResourceCache.getImage("search-dialog"));
setTitle(Message.getString("common.search_Title"));
setMessage(Message.getString("common.keys"));
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setFont(parent.getFont());
// Build the separator line
Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL
| SWT.SEPARATOR);
titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if(tableManager == null) {
setTableManager(getEntityTableManager());
}
queryForm = new OnlineQueryForm(composite, SWT.NONE, getADTable(), this);
queryForm.setLayoutData(new GridData(GridData.FILL_BOTH));
return composite;
}
@Override
protected void createAdvanceButtonBar(Composite parent) {}
@Override
protected void okPressed() {
this.setErrorMessage(null);
if(queryForm.validate()) {
QueryDialog.this.okPressed();
// 设置materialRrn到实现IVdmAssess接口
fillQueryData();
setReturnCode(OK);
this.setVisible(false);
iRefresh.refresh();
}
}
protected void fillQueryData() {
Long materialRrn = null;
String mId = null;
List<Material> list = null;
boolean isQueryAll = false;
HashMap<String, IField> fields = queryForm.getFields();
StringBuffer sb = new StringBuffer(" 1 = 1");
if(fields.get(ID_MATERIALID) instanceof SearchField && fields.get(ID_MATERIALNAME) instanceof TextField && fields.get(ID_IS_PURCHASE) instanceof ComboField) {
SearchField sf = (SearchField)fields.get(ID_MATERIALID);
TextField tf = (TextField) fields.get(ID_MATERIALNAME);
ComboField cf = (ComboField) fields.get(ID_IS_PURCHASE);
String materialId = sf.getText();
String materialName = tf.getText();
String isPurchase = (String) cf.getValue();
// 如果是模糊查询则查出相关物料,否则直接找到确定的物料
if(materialId != null || (materialName != null && materialName.trim().length() != 0) || (isPurchase != null && isPurchase.trim().length()!=0)) {
if(materialId != null){
sb.append(" AND " + ModelName + "." + sf.getRefTable().getValueField() + " LIKE '" + materialId + "' ");
}
if(materialName != null && materialName.trim().length() != 0){
sb.append(" AND " + ModelName + "." + tf.getId() + " LIKE '" + materialName + "' ");
}
if(isPurchase != null && isPurchase.trim().length()!=0){
sb.append(" AND isPurchase ="+isPurchase);
}
try {
ADManager manager = Framework.getService(ADManager.class);
list = manager.getEntityList(Env.getOrgRrn(),
Material.class, Env.getMaxResult(), sb.toString(), "");
} catch(Exception e) {
ExceptionHandlerManager.asyncHandleException(e);
}
}
else {
Object obj = sf.getValue();
try {
materialRrn = Long.parseLong(obj.toString());
mId = ((Material)sf.getData()).getMaterialId();
} catch(Exception e) {
isQueryAll = true;
}
}
}
if(iRefresh instanceof OnlineSection) {
OnlineSection onlineSection = (OnlineSection)iRefresh;
onlineSection.setMaterialRrn(materialRrn);
onlineSection.setMaterialId(mId);
onlineSection.setQueryAll(isQueryAll);
onlineSection.setMaterials(list);
}
}
public EntityTableManager getTableManager(){
return super.tableManager;
}
public void setTableManager(EntityTableManager tableManager){
super.tableManager = tableManager;
}
public ADTable getADTable() {
if(tableManager != null)
return tableManager.getADTable();
return adTable;
}
}
class OnlineQueryForm extends QueryForm {
protected EntityQueryDialog dialog;
public OnlineQueryForm(Composite parent, int style, ADTable table, EntityQueryDialog dialog) {
super(parent, style, table);
this.dialog = dialog;
}
// 重载该方法, 使其提示强制性输入和并可以对其验证
@Override
public void addFields() {
if (allADfields != null && allADfields.size() > 0){
for (ADField adField : allADfields) {
if (adField.getIsQuery()) {
adField.setIsReadonly(false);
IField field = getField(adField);
if (field == null) {
continue;
}
adFields.put(adField.getName(), adField);
if (field != null) {
field.setADField(adField);
}
}
}
registeValueChangeListener();
}
}
// 重载该方法, 使错误提示信息放Dialog的头部
@Override
public boolean validate() {
boolean validFlag = true;
for (IField f : fields.values()){
// 验证强制性输入
ADField adField = adFields.get(f.getId());
if(adField != null) {
if (adField.getIsMandatory()){
Object value = f.getValue();
boolean isMandatory = false;
if (value == null){
isMandatory = true;
} else {
if (value instanceof String){
if ("".equalsIgnoreCase(value.toString().trim())){
isMandatory = true;
}
}
}
if (isMandatory){
validFlag = false;
if(dialog != null) {
dialog.setErrorMessage(
String.format(Message.getString("common.ismandatory"), I18nUtil.getI18nMessage(adField, "label")));
}
return false;
}
}
}
}
return validFlag;
}
}
}
|
[
"[email protected]"
] | |
3794801319a65d5d6da49033fbddbb356bce7911
|
9e2b5b96aefa05233dfd74397a8497744674176e
|
/rehlatMobileApp_Automation/src/test/java/com/automation/rehlat/tests/testCases/VerifyUserIsAbleToSeeTheUpComingAndCompletedTripsSuccessfully.java
|
24c9a6c742b98352033be5c579a2b6534c8453a2
|
[] |
no_license
|
BijjamSuresh/RehlatAutomation
|
77f3d8e66eba7a2f35a51b7fc71b2d1703a60d13
|
09952fc923c04f2894f291d875e534528b15686c
|
refs/heads/master
| 2020-03-25T23:45:13.188682 | 2018-09-05T14:59:50 | 2018-09-05T14:59:50 | 144,290,943 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,561 |
java
|
package com.automation.rehlat.tests.testCases;
import com.automation.rehlat.Labels;
import com.automation.rehlat.libCommon.Logger;
import com.automation.rehlat.tests.BaseTest;
import org.junit.Test;
public class VerifyUserIsAbleToSeeTheUpComingAndCompletedTripsSuccessfully extends BaseTest {
@Test
public void testRLTC_26() throws Exception{
Logger.beginTest("Verify user is able to see the upcoming and completed trips successfully");
FlightsScreen.checkFlightsTabIsDisplayed();
FlightsScreen.tapOnMenuButton();
if (!MenuScreen.isUserSignedIn()){
MenuScreen.tapOnSignUpOrSignInButton();
SignInScreen.checkSignInScreenIsDisplayed();
SignInScreen.enterLoginCredentials();
SignInScreen.tapOnLoginButton();
FlightsScreen.checkFlightsTabIsDisplayed();
FlightsScreen.tapOnMenuButton();
MenuScreen.checkMenuScreenIsDisplayed();
MenuScreen.checkUserIsSignedUpSignedInWithCorrectParsingCredentials(Labels.EMAIL_ID_SIGN_IN);
}
MenuScreen.tapOnMyTripsSubMenuButton();
MyTripsScreen.checkMyTripsScreenIsDisplayed();
MyTripsScreen.tapOnFlightsButton();
MyTripsScreen.tapOnUpcomingButton();
MyTripsScreen.checkUpcomingFlightsTravelInformationIsDisplayed();
MyTripsScreen.tapOnCompletedButton();
MyTripsScreen.checkCompletedFlightsTravelInformationIsDisplayed();
Logger.endTest("Verify user is able to see the upcoming and completed trips successfully");
}
}
|
[
"[email protected]"
] | |
d7d59b4f4888d55b764b2c5aa3f40b063f384439
|
0e7eaf3aea4e73c3ac0dbf56962b755dc1ef6d58
|
/src/main/java/prosia/basarnas/model/TrapeziumArea.java
|
17b6a980256b438b94fd24b6cc7f346f8ad2646b
|
[] |
no_license
|
taufikbudianto/upload2
|
c3b8fa6196d843d2bb77c77ac37dbc8c1298c7b8
|
c0651f2bb01d4d7c49804079e97e138268a28784
|
refs/heads/master
| 2020-03-30T14:49:03.911083 | 2018-10-02T16:34:18 | 2018-10-02T16:34:18 | 151,337,272 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,571 |
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 prosia.basarnas.model;
import java.io.Serializable;
import java.util.Date;
import java.util.TimeZone;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import lombok.Data;
import prosia.app.model.AbstractAuditingEntity;
/**
*
* @author Aris
*/
@Entity
@Table(name="dfc_trapeziumarea")
@Data
public class TrapeziumArea extends AbstractAuditingEntity implements Serializable {
@Id
@Column(name="trapeziumareaid")
private String trapeziumAreaID;
@Column(name="worksheetname")
private String worksheetName;
@Column(name="deskripsi")
private String deskripsi;
@Column(name = "waktuoperasi")
@Temporal(TemporalType.TIMESTAMP)
private Date waktuoperasi;
@Column(name="waktuoperasitimezone")
private TimeZone waktuOperasiTimezone;
@Column(name="latlkp")
private Double latLkp;
@Column(name="longlkp")
private Double longLkp;
@Column(name="latdest")
private Double latDest;
@Column(name="longdest")
private Double longDest;
@Column(name="safetyfactor")
private Double safetyFactor;
@Column(name="distresserror")
private Double distressError;
@Column(name="searcherror")
private Double searchError;
@Column(name="luasarea")
private Double luasArea;
@Column(name="taskarealastpoint")
private String taskAreaLastPoint;
@Column(name="totaltaskarealength")
private Double totalTaskAreaLength;
@Column(name="waypoint")
private Double waypoint;
@Column(name="parentid")
private String parentID;
@ManyToOne
@JoinColumn(name="incidentid")
private Incident incident;
@Column(name = "datecreated")
@Temporal(TemporalType.TIMESTAMP)
private Date dateCreated;
@Column(name = "createdby", length = 50)
private String createdBy;
@Column(name = "lastmodified")
@Temporal(TemporalType.TIMESTAMP)
private Date lastModified;
@Column(name = "modifiedby", length = 50)
private String modifiedBy;
@Column(name = "isdeleted")
private boolean deleted;
@Column(name = "usersiteid")
private String userSiteID;
@Column(name="unit")
private Double unit;
}
|
[
"[email protected]"
] | |
9631b008646686e3acd5dff0af667e5763911ea9
|
e24f64cb65c22ce6463f1077faf18d61b6579638
|
/Sample/src/leetcode/AllOoneDataStructure_432.java
|
2719b8099b7ca0b3bf4cb85e2b667f0df81aaf86
|
[] |
no_license
|
Anvesh-Patlolla/CompetitiveProgramming
|
1b7587758caec953a455d2852b7f7d0ff0b8dc06
|
0f9d21ea4db8407b1bb4e8bf8e0afc737078c378
|
refs/heads/master
| 2021-01-17T07:09:50.467600 | 2019-10-08T04:23:11 | 2019-10-08T04:23:11 | 49,544,638 | 0 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,888 |
java
|
package leetcode;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class AllOoneDataStructure_432 {
HashMap<String, Integer> dataMap = null;
TreeMap<Integer, Set<String>> ascendingValueMap = null;
/** Initialize your data structure here. */
public AllOoneDataStructure_432() {
dataMap = new HashMap<>();
ascendingValueMap = new TreeMap<>();
}
/**
* Inserts a new key <Key> with value 1. Or increments an existing key by 1.
*/
public void inc(String key) {
Integer value = dataMap.get(key);
if (dataMap.containsKey(key)) {
value = dataMap.get(key);
} else {
value = 1;
}
int postInstruction = value + 1;
instruct(key, value, postInstruction);
}
private void instruct(String key, int value, int postInstruction) {
dataMap.put(key, postInstruction);
Set<String> set = ascendingValueMap.get(value);
if (set != null) {
set.remove(key);
}
if (ascendingValueMap.containsKey(postInstruction)) {
Set<String> set2 = ascendingValueMap.get(postInstruction);
set2.add(key);
} else {
HashSet<String> set2 = new HashSet<>();
set2.add(key);
ascendingValueMap.put(postInstruction, set2);
}
}
/**
* Decrements an existing key by 1. If Key's value is 1, remove it from the
* data structure.
*/
public void dec(String key) {
Integer value = dataMap.get(key);
if (dataMap.containsKey(key)) {
value = dataMap.get(key);
} else {
return;
}
int postInstruction = value - 1;
instruct(key, value, postInstruction);
}
/** Returns one of the keys with maximal value. */
public String getMaxKey() {
return null;
}
/** Returns one of the keys with Minimal value. */
public String getMinKey() {
Iterator<Entry<Integer, Set<String>>> iterator = ascendingValueMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<Integer, Set<String>> entry = iterator.next();
if (entry.getValue().size() == 0) {
iterator.remove();
} else {
Set<String> value = entry.getValue();
Iterator<String> iterator2 = value.iterator();
String retVal = iterator2.next();
return retVal;
}
}
return null;
}
public static void main(String[] args) {
AllOoneDataStructure_432 obj = new AllOoneDataStructure_432();
obj.inc("test");
obj.inc("test");
obj.inc("test");
obj.inc("test");
obj.inc("test");
obj.inc("test1");
obj.inc("test4");
obj.inc("test1");
obj.inc("test2");
obj.inc("test2");
obj.inc("test2");
obj.inc("test2");
System.out.println(obj.getMinKey());
obj.dec("test4");
obj.dec("test1");
System.out.println(obj.getMinKey());
}
}
/**
* Your AllOne object will be instantiated and called as such: AllOne obj = new
* AllOne(); obj.inc(key); obj.dec(key); String param_3 = obj.getMaxKey();
* String param_4 = obj.getMinKey();
*/
|
[
"[email protected]"
] | |
afc516c08a5ea6abc7a193d33d24bd08a57662a7
|
4f5d41b2de7121fed2406910fe4f23caf067836a
|
/app/src/main/java/edu/utdallas/lsj150230/theia/CustomNestedScrollView.java
|
3516165a85a880cdde0510d9c263f9747c24f4a9
|
[] |
no_license
|
ags160230/Theia
|
806ef53ba65d2271ee26e58e6bbd56eb9259b88f
|
5cd59d0959df3d75283bb0c1f6aa1d0949e27986
|
refs/heads/master
| 2020-06-06T19:10:37.653720 | 2019-06-20T02:02:19 | 2019-06-20T02:02:19 | 192,830,941 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,638 |
java
|
package edu.utdallas.lsj150230.theia;
import android.content.Context;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* A NestedScrollView with our custom nested scrolling behavior.
*/
public class CustomNestedScrollView extends NestedScrollView {
// The NestedScrollView should steal the scroll/fling events away from
// the RecyclerView if: (1) the user is dragging their finger down and
// the RecyclerView is scrolled to the top of its content, or (2) the
// user is dragging their finger up and the NestedScrollView is not
// scrolled to the bottom of its content.
public CustomNestedScrollView(Context context){ super(context); }
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
final RecyclerView rv = (RecyclerView) target;
if ((dy < 0 && isRvScrolledToTop(rv)) || (dy > 0 && !isNsvScrolledToBottom(this))) {
// Scroll the NestedScrollView's content and record the number of pixels consumed
// (so that the RecyclerView will know not to perform the scroll as well).
scrollBy(0, dy);
consumed[1] = dy;
return;
}
super.onNestedPreScroll(target, dx, dy, consumed);
}
@Override
public boolean onNestedPreFling(View target, float velX, float velY) {
final RecyclerView rv = (RecyclerView) target;
if ((velY < 0 && isRvScrolledToTop(rv)) || (velY > 0 && !isNsvScrolledToBottom(this))) {
// Fling the NestedScrollView's content and return true (so that the RecyclerView
// will know not to perform the fling as well).
fling((int) velY);
return true;
}
return super.onNestedPreFling(target, velX, velY);
}
/**
* Returns true iff the NestedScrollView is scrolled to the bottom of its
* content (i.e. if the card's inner RecyclerView is completely visible).
*/
private static boolean isNsvScrolledToBottom(NestedScrollView nsv) {
return !nsv.canScrollVertically(1);
}
/**
* Returns true iff the RecyclerView is scrollezzd to the top of its
* content (i.e. if the RecyclerView's first item is completely visible).
*/
private static boolean isRvScrolledToTop(RecyclerView rv) {
final LinearLayoutManager lm = (LinearLayoutManager) rv.getLayoutManager();
return lm.findFirstVisibleItemPosition() == 0
&& lm.findViewByPosition(0).getTop() == 0;
}
}
|
[
"[email protected]"
] | |
9ea777f8fc8d297a6c0ff9782cfcd5fb017d0147
|
83b51a424be5dbae89a000b5c95b23b687ff76b2
|
/app/src/main/java/com/luobo/gallery/PhotoListAdapter.java
|
c5d44979d81d091d28ca738ae36b6c44be3b7811
|
[] |
no_license
|
ALuoBo/Gallery-Java
|
cbca2994c0488ebb4f508ab3f6c71d4b27ee57ac
|
ad346ad5b99a81487aebb1965927f599c81bce4a
|
refs/heads/master
| 2022-12-08T15:29:13.814623 | 2020-09-15T09:15:42 | 2020-09-15T09:15:42 | 292,530,248 | 3 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,678 |
java
|
package com.luobo.gallery;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.airbnb.lottie.LottieAnimationView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.luobo.gallery.repository.Photo;
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
class PhotoListAdapter extends ListAdapter<Photo.HitsBean, PhotoListAdapter.HitViewHolder> {
private static final int NORMAL_VIEW_TYPE = 0;
private static final int FOOTER_VIEW_TYPE = 1;
private Context context;
private OnItemClickListener onItemClickListener;
protected PhotoListAdapter(Context context, @NonNull DiffUtil.ItemCallback<Photo.HitsBean> diffCallback) {
super(diffCallback);
this.context = context;
mInflater = LayoutInflater.from(context);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.onItemClickListener = listener;
}
class HitViewHolder extends RecyclerView.ViewHolder {
public HitViewHolder(@NonNull View itemView) {
super(itemView);
}
}
private final LayoutInflater mInflater;
@NonNull
@Override
public HitViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView;
if (viewType == FOOTER_VIEW_TYPE) {
itemView = mInflater.inflate(R.layout.footer_layout, parent, false);
((StaggeredGridLayoutManager.LayoutParams) itemView.getLayoutParams()).setFullSpan(true);
} else {
itemView = mInflater.inflate(R.layout.recyclerview_item, parent, false);
}
return new HitViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull HitViewHolder holder, int position) {
if (position != getItemCount() - 1) {
ImageView imageView = holder.itemView.findViewById(R.id.itemImageView);
Glide.with(context)
.load(getItem(position).getWebformatURL())
.centerCrop()
.transition(withCrossFade())
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
if (onItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = holder.getLayoutPosition();
onItemClickListener.onItemListener(holder.itemView, position);
}
});
}
} else {
LottieAnimationView lottieAnimationView = holder.itemView.findViewById(R.id.lottieAnimationView);
lottieAnimationView.playAnimation();
}
}
interface OnItemClickListener {
void onItemListener(View view, int position);
}
@Override
public int getItemCount() {
//添加一个底部,所以条目总数加1
return super.getItemCount() + 1;
}
@Override
public int getItemViewType(int position) {
//getItemCount()-1代表最后一个条目
if (position == getItemCount() - 1) {
return FOOTER_VIEW_TYPE;
} else return NORMAL_VIEW_TYPE;
}
}
|
[
"[email protected]"
] | |
090c56b5aee8dd3049712db557ebc8720440984c
|
ca7e64d552ee310ec50c30659c3e9d035878b839
|
/RegistrationService/src/main/java/com/crotontech/RegistrationService/controllers/IndexController.java
|
4f15636405e3e9fb877418f8eb61dc1cc9c1a3f7
|
[] |
no_license
|
maina/microservices
|
a38ad244cfaed5fafaf4d40c092bbbdbadef0eba
|
e6e09bcd3f920d8f1c83f385185c1f968b0e1002
|
refs/heads/master
| 2021-06-11T22:59:54.795776 | 2021-06-04T04:39:43 | 2021-06-04T04:39:43 | 177,458,521 | 0 | 0 | null | 2021-06-04T04:39:43 | 2019-03-24T19:19:56 |
Java
|
UTF-8
|
Java
| false | false | 961 |
java
|
package com.crotontech.RegistrationService.controllers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RestController;
@RestController
@RequestMapping(value="/")
public class IndexController {
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
@RequestMapping(method = RequestMethod.GET)
public String getCompany( ) {
return "welcome. This is registration service";
}
// @RequestMapping(value="/{organizationId}",method = RequestMethod.DELETE)
// @ResponseStatus(HttpStatus.NO_CONTENT)
// public void deleteOrganization( @PathVariable("orgId") String orgId, @RequestBody Organization org) {
// orgService.deleteOrg( org );
// }
}
|
[
"[email protected]"
] | |
79469ec5841479295419699be52b8bc4b9f438bc
|
9c7d4d579c79631c894412c5d5e9c0e7eebf7827
|
/src/two/Vjezba2.java
|
5b1e0335d9a3c1715d5438cafeb6d0bda870e186
|
[] |
no_license
|
harunBucalovicITA2020/JavaCoreProgramming
|
0cb8e25c9d24c91a131fc54b05bb143638ad8ee4
|
9074b5ea7ca456b3ecc845691699c6db685dbc43
|
refs/heads/master
| 2023-02-03T17:21:53.557726 | 2020-12-21T09:54:54 | 2020-12-21T09:54:54 | 323,289,077 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 371 |
java
|
package two;
public class Vjezba2 {
public static void main(String[] args) {
int a = 2, b = 3;
// add (a,b++); public private void add
System.out.println();
boolean isBeter = !!!!!true;
System.out.println(isBeter);
System.out.println(a++);
//System.out.println(a++);
System.out.println(++a);
}
}
|
[
"[email protected]"
] | |
842d175db02cef26e8b67084d4a682f805acad02
|
63084827a13bebf6bd97d392ac5c0ca05cd37a91
|
/yycg-main-ee37/yycg-dao-ee37/src/main/java/cn/itcast/yycg/system/dao/impl/SysConfDaoImpl.java
|
c5b4ba73f541df126693ef6f103d39f159ea650b
|
[] |
no_license
|
57ggfk/ssh-yycg
|
3fbefbbef737413a1641cc5ed9416ba5eb4b7344
|
83da123c77e8dd04ba31d19be7c57aef8b30adf3
|
refs/heads/master
| 2020-12-24T20:24:24.514786 | 2017-03-26T16:32:14 | 2017-03-26T16:32:14 | 86,246,371 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,251 |
java
|
package cn.itcast.yycg.system.dao.impl;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.springframework.stereotype.Repository;
import cn.itcast.yycg.base.dao.impl.BaseDaoImpl;
import cn.itcast.yycg.domain.po.SysConf;
import cn.itcast.yycg.system.dao.SysConfDao;
@Repository
public class SysConfDaoImpl extends BaseDaoImpl<SysConf> implements SysConfDao {
private DetachedCriteria getCondition(SysConf sysConf){
DetachedCriteria dc = DetachedCriteria.forClass(SysConf.class);
return dc;
}
@Override
//获取信息总条数
public Integer findCount(SysConf sysConf) {
DetachedCriteria condition = this.getCondition(sysConf);
condition.setProjection(Projections.rowCount());
List<Long> list = (List<Long>) this.getHibernateTemplate().findByCriteria(condition);
if(list.size()>0){
return list.get(0).intValue();
}
return null;
}
//分页获取系统信息的详细信息
@Override
public List<SysConf> findAll(SysConf sysConf, Integer firstResult, Integer maxResults) {
DetachedCriteria condition = this.getCondition(sysConf);
return (List<SysConf>) this.getHibernateTemplate().findByCriteria(condition, firstResult, maxResults);
}
}
|
[
"[email protected]"
] | |
4f7bda14147a3b8ba8680ae467a4b2cf42c70dfc
|
f405015899c77fc7ffcc1fac262fbf0b6d396842
|
/sec2-keyserver/sec2-frontend/src/test/java/org/sec2/frontend/exceptions/FrontendExceptionsTestSuite.java
|
e1bfa433aec15e44e1dddc2625ac5fd3b1fc36ab
|
[] |
no_license
|
OniXinO/Sec2
|
a10ac99dd3fbd563288b8d21806afd949aea4f76
|
d0a4ed1ac97673239a8615a7ddac1d0fc0a1e988
|
refs/heads/master
| 2022-05-01T18:43:42.532093 | 2016-01-18T19:28:20 | 2016-01-18T19:28:20 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,449 |
java
|
/*
* Copyright 2012 Ruhr-University Bochum, Chair for Network and Data Security
*
* This source code is part of the "Sec2" project and as this remains property
* of the project partners. Content and concepts have to be treated as
* CONFIDENTIAL. Publication or partly disclosure without explicit
* written permission is prohibited.
* For details on "Sec2" and its contributors visit
*
* http://nds.rub.de/research/projects/sec2/
*/
package org.sec2.frontend.exceptions;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Test suite for namespace org.sec2.frontend.exceptions.
*
* @author Dennis Felsch - [email protected]
* @version 0.1
*
* November 29, 2012
*/
public class FrontendExceptionsTestSuite extends TestCase {
/**
* Create the test suite.
*
* @param testName name of the test case
*/
public FrontendExceptionsTestSuite(final String testName) {
super(testName);
}
/**
* @return the suite of tests being tested
*/
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(BackendProcessExceptionTests.class);
suite.addTestSuite(ErrorResponseExceptionTests.class);
suite.addTestSuite(KeyserverSecurityExceptionTests.class);
suite.addTestSuite(XMLProcessExceptionTests.class);
return new SuppressLogTestSetup(suite);
}
}
|
[
"developer@developer-VirtualBox"
] |
developer@developer-VirtualBox
|
a5df8229b803da738165e98ed6378f4d255581e2
|
52374e2b3da33b9ad1eaad2515f6b8812d03fa64
|
/ServiceDX_Base/servicedx-beans/src/main/java/org/servicedx/bean/model/CommonModeBean.java
|
539c9f9319f779557daade25bb643de1b238c142
|
[] |
no_license
|
tagananth/sdx_base
|
ce9820d5fa2962e0fdf4a2838216d63f2212c179
|
2ef37bc3c3334ba1d173d90072fbde90be60e3f2
|
refs/heads/master
| 2020-05-30T11:52:16.554090 | 2019-06-01T09:54:29 | 2019-06-01T09:54:29 | 189,716,235 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 720 |
java
|
package org.servicedx.bean.model;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public abstract class CommonModeBean extends CommonBeanFields implements ICommonModeBean
{
private static final long serialVersionUID = -9011290790620223523L;
protected boolean active;
protected String comments;
@Column(name = "comments")
public String getComments()
{
return comments;
}
@Override
@Column(name = "active")
public boolean isActive()
{
return active;
}
@Override
public void setActive(boolean active)
{
this.active = active;
}
public void setComments(String comments)
{
this.comments = comments;
}
}
|
[
"[email protected]"
] | |
b0ffb82c495445d31244e977ec1fd8204a6150c3
|
b003b1eaf3a8e6d38503f6c480e31d6592acd724
|
/framework/com/boidea/framework/core/orm/xibatis/sqlmap/engine/type/SqlTimeTypeHandler.java
|
f6e33d8ac5c53590ed36c3beceadbfff416cac77
|
[] |
no_license
|
havies/web3d
|
61e29faef943c12b10db6d6619ff66ff32679f28
|
ec774e9924728e4bfda207b3af7f1987520f7e2e
|
refs/heads/master
| 2021-01-01T04:29:16.534884 | 2016-05-04T15:45:10 | 2016-05-04T15:45:10 | 58,063,019 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,240 |
java
|
package com.boidea.framework.core.orm.xibatis.sqlmap.engine.type;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* SQL time implementation of TypeHandler
*/
public class SqlTimeTypeHandler extends BaseTypeHandler implements TypeHandler {
private static final String DATE_FORMAT = "hh:mm:ss";
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
ps.setTime(i, (java.sql.Time) parameter);
}
public Object getResult(ResultSet rs, String columnName) throws SQLException {
Object sqlTime = rs.getTime(columnName);
if (rs.wasNull()) {
return null;
} else {
return sqlTime;
}
}
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
Object sqlTime = rs.getTime(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return sqlTime;
}
}
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
Object sqlTime = cs.getTime(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return sqlTime;
}
}
public Object valueOf(String s) {
return SimpleDateFormatter.format(DATE_FORMAT, s);
}
}
|
[
"[email protected]"
] | |
3bc36ab5b70aef287bf64fe22e7a41492357a015
|
6c94ec66e87a810714c679aed5c5c39156d80d0b
|
/src/com/ding/ui/AdminAddUI.java
|
18fdc1d82841c30fa8fd8347bdc6237b25099204
|
[] |
no_license
|
rplalala/StudentManagerSystem_JavaBase
|
e253860c45a106710ee7d7e248181feeafe26db3
|
19c2836922e90a4d6aca29f7f205c95603da0ea7
|
refs/heads/master
| 2023-05-11T20:07:22.763274 | 2021-06-05T06:28:56 | 2021-06-05T06:28:56 | 370,895,028 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 6,142 |
java
|
package com.ding.ui;
import java.awt.Font;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import com.ding.dao.impl.AdminDaoImpl;
import com.ding.entity.AdminEntity;
import com.ding.utils.RegExpHelp;
public class AdminAddUI extends JFrame {
/**
* 串行版本标识
*/
private static final long serialVersionUID = -240441957949593746L;
private JPanel contentPane;
private JTextField userNameText;
private JTextField userPasswordText;
private AdminDaoImpl adminDaoImpl = new AdminDaoImpl();
private RegExpHelp regExpHelp = new RegExpHelp();
public AdminAddUI() {
//frame
setTitle("新增界面");
setIconImage(Toolkit.getDefaultToolkit().getImage("images/icon.jpg"));
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);//关闭新增窗口时,只是隐藏该窗口,并不结束程序
setSize(450, 300);
setLocationRelativeTo(null);
setVisible(true);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel userNameLabel = new JLabel("用户名:");
userNameLabel.setFont(new Font("宋体", Font.BOLD, 25));
userNameLabel.setBounds(40, 35, 106, 52);
contentPane.add(userNameLabel);
JLabel userPasswordLabel = new JLabel("密 码:");
userPasswordLabel.setFont(new Font("宋体", Font.BOLD, 25));
userPasswordLabel.setBounds(40, 95, 106, 52);
contentPane.add(userPasswordLabel);
userNameText = new JTextField();
userNameText.setFont(new Font("宋体", Font.PLAIN, 20));
userNameText.setBounds(139, 42, 225, 36);
contentPane.add(userNameText);
userNameText.setColumns(10);
userPasswordText = new JTextField();
userPasswordText.setFont(new Font("宋体", Font.PLAIN, 20));
userPasswordText.setColumns(10);
userPasswordText.setBounds(139, 102, 225, 36);
contentPane.add(userPasswordText);
//button
JButton addButton = new JButton("新 增");
addButton.setFont(new Font("宋体", Font.BOLD, 20));
addButton.setBounds(69, 168, 106, 36);
contentPane.add(addButton);
JButton resetButton = new JButton("重 置");
resetButton.setFont(new Font("宋体", Font.BOLD, 20));
resetButton.setBounds(250, 168, 106, 36);
contentPane.add(resetButton);
//重置按钮监听
resetButton.addActionListener(e -> {
if (e.getSource() == resetButton) {
userNameText.setText("");
userPasswordText.setText("");
}
});
//新增按钮监听
addButton.addActionListener(e -> {
if (e.getSource() == addButton) {
boolean inputJudge = true;
boolean regexpUserName = true; //正则表达式检验用户名
boolean regexpUserPassword = true; //正则表达式检验密码
AdminEntity addAdminEntity = new AdminEntity();//对该学生进行新增的信息
String userName = userNameText.getText();
String userPassword = userPasswordText.getText();
if ("".equals(userName) || userName == null) {
inputJudge = false;//若没有输入信息 ,则不执行新增操作
} else {
regexpUserName = regExpHelp.checkUserNameAndUserPassword(userName);
if (regexpUserName) {
addAdminEntity.setUserName(userName);//若有输入新增信息,且满足正则,则把输入的新增信息传入
}
}
if ("".equals(userPassword) || userPassword == null) {
inputJudge = false;//若没有输入信息 ,则不执行新增操作
} else {
regexpUserPassword = regExpHelp.checkUserNameAndUserPassword(userPassword);
if (regexpUserPassword) {
addAdminEntity.setUserPassword(userPassword);//若有输入新增信息,且满足正则,则把输入的新增信息传入
}
}
if (inputJudge && regexpUserName && regexpUserPassword) {
int n = JOptionPane.showConfirmDialog(null, "您确定要新增吗?", "确认新增",
JOptionPane.YES_NO_OPTION);
if (n == 0) {
boolean judge = adminDaoImpl.addAdmin(addAdminEntity);
if (judge) {
JOptionPane.showMessageDialog(null, "新增成功!");
setVisible(false);//关闭(隐藏)修改页面;
} else {
JOptionPane.showMessageDialog(null, "新增失败!", "失败",
JOptionPane.ERROR_MESSAGE);
}
}
} else if (!inputJudge) {
JOptionPane.showMessageDialog(null, "您还有未输入的管理员信息!", "错误",
JOptionPane.ERROR_MESSAGE);
} else if (!regexpUserName) {
JOptionPane.showMessageDialog(null, "用户名格式错误,请输入以字母开头,允许字母数字下划线的5-16个字节!", "错误",
JOptionPane.ERROR_MESSAGE);
userNameText.setText("");
} else {
JOptionPane.showMessageDialog(null, "密码格式错误,请输入以字母开头,允许字母数字下划线的5-16个字节!", "错误",
JOptionPane.ERROR_MESSAGE);
userPasswordText.setText("");
}
}
});
}
}
|
[
"[email protected]"
] | |
223eafc1654083d4563dadc8b68837db199f3166
|
26b7f30c6640b8017a06786e4a2414ad8a4d71dd
|
/src/number_of_direct_superinterfaces/i42243.java
|
878c3dda4aa01548f2222798b19fca592749ffe6
|
[] |
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 i42243 {}
|
[
"[email protected]"
] | |
92d562041eb722598d03717854be017ab32c3d5a
|
00ccc55950782514335fb66d1b04328ea2f9688e
|
/Leet/331_VerifyPreorderSerializationOfABinaryTree.java
|
8f42b1c00516fe75a7ff46596fd7750e464eb9ae
|
[] |
no_license
|
manishsat/geeks
|
4676e887a89ca63f1a031f5ba2473913634e17b7
|
5f01f5cc2b59bd3dd71823e73358919f49d0260b
|
refs/heads/master
| 2022-11-05T09:16:01.628668 | 2020-06-13T04:15:41 | 2020-06-13T04:15:41 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,094 |
java
|
/*
In/Out degree approach: consider null as leaves, then
1. each non-null node provides 2 outdegree and 1 indegree (2 children and 1 parent), except root (pure outdegree)
2. each null node provides 0 outdegree and 1 indegree (0 child and 1 parent).
3. record diff = outdegree - indegree
valid check: diff >= 0 during traverse, and diff == 0 when finish
ref: https://www.hrwhisper.me/leetcode-verify-preorder-serialization-of-a-binary-tree/
*/
class Solution {
public boolean isValidSerialization(String preorder) {
// record diff of degree: indegree -1, outdegree +1
// init as 1, since root node does NOT bring indegree
int deg = 1;
String[] nodes = preorder.split(",");
for (String node : nodes) {
// each node always bring 1 indegree
--deg;
// check if still valid
if (deg < 0) {
return false;
}
if (!node.equals("#")) {
// non-null node => add outdegrees
deg += 2;
}
}
return deg == 0;
}
}
|
[
"[email protected]"
] | |
54a87f0540c580d8d7c852bb34f4856620f5f1b9
|
cb1d0d6e246668603cf815c32183b88af849643f
|
/cse241/sac320chebruch/sac320/store_order.java
|
5014b87f496ed1810bc6a5501420b14c87af8de9
|
[] |
no_license
|
schebruch/Enterprise_Database_Project
|
2a22dc56b90058ed748cc4c9efbef6551a53a7e1
|
77bb6354a32335c1ecb5f88b0f9df81cce7cc035
|
refs/heads/master
| 2020-03-21T08:08:46.995507 | 2018-08-22T22:39:57 | 2018-08-22T22:39:57 | 138,323,634 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 5,666 |
java
|
/*
Sam Chebruch
Spring 2018
CSE 241
Final Project
*/
import java.sql.*;
import java.util.Scanner;
import java.util.ArrayList;
/**A class that represents a store order, whether it is a restock or triggered by a customer order*/
public class store_order
{
private int Loc_id;
private int order_num;
private String date;
private String purpose;
private ArrayList<Product> products;
private ArrayList<Integer> qty;
//default constructor assumes the order is online
public store_order(Connection con, Statement s, int order_num, String date, String purpose)
{
this.order_num = order_num;
this.date = date;
this.purpose = purpose;
Loc_id = 151;
order_num = assignID(con,s,"store_order");
}
public store_order(Connection con, Statement s, int Loc_id, int order_num, String date, String purpose)
{
this(con, s, order_num, date, purpose);
this.Loc_id = Loc_id;
}
public String getDate()
{
return date;
}
private int assignID(Connection con, Statement s, String tableName)
{
try
{
String q = "select MAX(order_num) from "+tableName;
ResultSet result = s.executeQuery(q);
result.next();
int r = result.getInt("MAX(order_num)");
result.close();
return r + 1;
}catch(Exception e)
{
System.out.println("Something went wrong in the servers. Please relaunch the program");
}
return -1;
}
//for the special case that a warehouse runs out of something, assume the minimum is 100
public void restock(Connection con, Statement s, int prod_id, int cat_id, int deficit )
{
int qtyToOrder = deficit + 100;
int wareOrdId = assignID(con, s, "store_orders");
String storeOrders = "insert into store_orders(order_num, Loc_id, date_ordered) values(" + wareOrdId +", " + Loc_id + ", '"+date + "')";
String storeOrder = "insert into store_order(order_num, purpose) values(" + assignID(con, s, "store_order") +", '"+purpose+"')";
String vendor = findCheapVendor(con, s, prod_id, cat_id);
double price = getStoreBuysPrice(con, s, vendor, prod_id, cat_id);
String updateOrdFrom = "insert into store_order_from(order_num, name) values(" + wareOrdId + ", '" + vendor + "')";
String updateStoreBuys = "insert into store_buys(order_num, cat_id, prod_id, qty, price, buy_date) values(" + wareOrdId + ", " + cat_id + ", " + prod_id + ", " + qtyToOrder + ", " + price + ", '" + date +"')";
String updateStoredIn = "update stored_in set qty = " + (qtyToOrder) + " where prod_id = " + prod_id + " and cat_id = " + cat_id + " and Loc_id = " + Loc_id;
try
{
int i = s.executeUpdate(storeOrder);
i = s.executeUpdate(storeOrders);
i = s.executeUpdate(updateOrdFrom);
i = s.executeUpdate(updateStoreBuys);
i = s.executeUpdate(updateStoredIn);
}catch(Exception e)
{
System.out.println("updates failed");
System.exit(0);
}
}
public void restockGeneral(Connection con, Statement s, int prod_id, int cat_id, int qtyToOrder, int minQty)
{
int wareOrdId = assignID(con, s, "store_orders");
String storeOrders = "insert into store_orders(order_num, Loc_id, date_ordered) values(" + wareOrdId +", " + Loc_id + ", '"+date + "')";
String storeOrder = "insert into store_order(order_num, purpose) values(" + assignID(con, s, "store_order") +", '"+purpose+"')";
String vendor = findCheapVendor(con, s, prod_id, cat_id);
double price = getStoreBuysPrice(con, s, vendor, prod_id, cat_id);
String updateOrdFrom = "insert into store_order_from(order_num, name) values(" + wareOrdId + ", '" + vendor + "')";
String updateStoreBuys = "insert into store_buys(order_num, cat_id, prod_id, qty, price, buy_date) values(" + wareOrdId + ", " + cat_id + ", " + prod_id + ", " + qtyToOrder + ", " + price + ", '" + getDate() + "')";
String updateStoredIn = "update stored_in set qty = " + minQty + " where prod_id = " + prod_id + " and cat_id = " + cat_id + " and Loc_id = " + Loc_id;
try
{
int i = s.executeUpdate(storeOrder);
i = s.executeUpdate(storeOrders);
i = s.executeUpdate(updateOrdFrom);
i = s.executeUpdate(updateStoreBuys);
i = s.executeUpdate(updateStoredIn);
}catch(Exception e)
{
System.out.println("updates failed");
System.exit(0);
}
}
public double getStoreBuysPrice(Connection con, Statement s, String name, int prod_id, int cat_id)
{
String q = "select price from offers where name = '" + name + "' and prod_id = " + prod_id + " and cat_id = " + cat_id;
try
{
ResultSet r = s.executeQuery(q);
r.next();
return r.getDouble("price");
}catch(Exception e)
{
System.out.println("Store buys price query failed. Please try again later");
System.exit(0);
}
return -1;
}
private String findCheapVendor(Connection con, Statement s, int prod_id, int cat_id)
{
String q = "select name from offers where prod_id = " + prod_id + " and cat_id = " + cat_id + " order by price";
try
{
ResultSet r = s.executeQuery(q);
r.next();
return r.getString("name");
}
catch(Exception e)
{
System.out.println("couldn't find vendor. Transaction terminated");
System.exit(0);
}
return null;
}
}
|
[
"[email protected]"
] | |
d6bb290cdb01e782b16e870bb56c77bb84e8ec55
|
a21d95f02ffb86eb48f0032fd31c1b3b03764732
|
/src/main/sevenstar_new/webframework/org/sevenstar/web/cfg/model/GlobalResultsModel.java
|
b8a3d9aff4cbfd06f3965094f334aeb457dc3662
|
[] |
no_license
|
maojimin/code-libray
|
af409954b402637bf3c7d86b13ac79b018d7b7bb
|
db8d8b33280feeb94e01fd74e65066b5b3f59d7d
|
refs/heads/master
| 2021-01-10T22:07:17.544448 | 2014-08-01T15:37:55 | 2014-08-01T15:37:55 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 546 |
java
|
package org.sevenstar.web.cfg.model;
import java.util.ArrayList;
import java.util.List;
public class GlobalResultsModel
{
private List resultModelList;
public void addResultModel(GlobalResultModel resultModel) {
if (this.resultModelList == null) {
this.resultModelList = new ArrayList();
}
getResultModelList().add(resultModel);
}
public List getResultModelList() {
return this.resultModelList;
}
public void setResultModelList(List resultModelList) {
this.resultModelList = resultModelList;
}
}
|
[
"[email protected]"
] | |
8305958c2dce78545c002b7f44e56e635504f758
|
fe1ee556fb8fff262336eaaecc5c6cb30c805e67
|
/src/main/java/com/eva/model/person/applicant/application/ResumeTextFileGenerator.java
|
ff05b7414a8b79ea3b1b673b30cead36d3bfce19
|
[
"MIT"
] |
permissive
|
AY2021S1-CS2103T-W13-1/tp
|
9cec3340988934345edad74053ef2e10164a7b1d
|
75c53893a54b059b9f271f39146b02617354f7c5
|
refs/heads/master
| 2023-01-18T23:29:19.203796 | 2020-11-13T15:09:31 | 2020-11-13T15:09:31 | 293,289,659 | 2 | 5 |
NOASSERTION
| 2020-11-13T02:23:05 | 2020-09-06T14:07:54 |
Java
|
UTF-8
|
Java
| false | false | 1,523 |
java
|
package com.eva.model.person.applicant.application;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
/**
* A class used to generate a sample resume text file for reference.
*/
public class ResumeTextFileGenerator {
/**
* Generates a sample resume text file in the same directory.
*/
public void generateResumeTextFile() {
try {
File myObj = new File("data/resume.txt");
if (myObj.createNewFile()) {
FileWriter myWriter = new FileWriter("data/"
+ "resume.txt");
myWriter.write("Name: Royce\n");
myWriter.write("\n");
myWriter.write("Education:\n");
myWriter.write("1.\nSchool: NUS\nStart: 01/01/2019\nEnd: 01/01/2023\n");
myWriter.write("2.\nSchool: SJI\nStart: 01/01/2011\nEnd: 01/01/2015\n");
myWriter.write("\n");
myWriter.write("Experience:\n");
myWriter.write("1.\nCompany: DSO\nPosition: Intern\nDescription: I did some coding."
+ "\nStart: 01/01/2020\nEnd: 01/02/2020");
myWriter.close();
System.out.println("File created in same directory: " + myObj.getName());
} else {
System.out.println("Sample resume.txt already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
|
[
"[email protected]"
] | |
70ee817a6547ee6301b5154775f21212fcd8e2cc
|
14f4f0722a00129ec04581a823d09fe8c4475588
|
/mp03/UF5/Pt2/src/apartado4/EscribeStreamObjecte.java
|
6cf796e3d8671526bab0becf3e80daa6b227478d
|
[] |
no_license
|
mirokshi/ProjectsJava
|
1eecd25eec15538138b6f431ec3d3a2045110af5
|
d40497696f82b4436cc2ab015eafd97d2f41060c
|
refs/heads/master
| 2020-03-31T18:26:44.086388 | 2019-06-01T07:58:48 | 2019-06-01T07:58:48 | 152,459,032 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,877 |
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 apartado4;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Scanner;
/**
*
* @author mirokshi
*/
public class EscribeStreamObjecte {
public static int count=1;
public static void main(String[] args) throws IOException {
Scanner ent = new Scanner(System.in);
Ordenadores o = new Ordenadores();
//peticion para introducir
System.out.println("INTRODUCCION DE NUEVO ORDENADOR");
System.out.print("Sistema Operativo : ");
o.setSO(ent.next());
System.out.print("Procesador : ");
o.setProcesador(ent.next());
System.out.print("Almacenamiento : ");
o.setAlmacenamiento(ent.nextInt());
System.out.print("RAM : ");
o.setRam(ent.nextInt());
File dataFile = new File("object");
ObjectOutputStream out = null;
try {
if (dataFile.exists()) {
out = new AppendingObjectOutputStream(new FileOutputStream(dataFile, true));
} else {
out = new ObjectOutputStream(new FileOutputStream(dataFile, true));
}
out.writeObject(o);
} finally {
if (out != null) {
out.close();
}
}
}
}
class AppendingObjectOutputStream extends ObjectOutputStream {
public AppendingObjectOutputStream(OutputStream out) throws IOException {
super(out);
}
@Override
protected void writeStreamHeader() throws IOException {
reset();
}
}
|
[
"[email protected]"
] | |
03ecfd94b5fcb169acb37b69040974ab48e8e624
|
d63238380662f4742cb74606d26992250003ae12
|
/app/src/main/java/com/example/vikas/loginsqlitedata/Search_Item/SearchinProductFragment.java
|
1b9fdcb54468c79d19a45602fc0583bde75c5f4b
|
[] |
no_license
|
VikasNVCchauhan/E-commerce-Android-App-Project
|
9c54faa54dcc2d2ba68c0d7d0f665a1e1989fe32
|
84ee3968417a9eefd7e6b797e5269671d7a25403
|
refs/heads/master
| 2020-09-04T00:05:59.292715 | 2019-11-05T10:19:46 | 2019-11-05T10:19:46 | 219,612,210 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 5,861 |
java
|
package com.example.vikas.loginsqlitedata.Search_Item;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.example.vikas.loginsqlitedata.MerchantAddProductToApp.UserMerchantUploadProductImage;
import com.example.vikas.loginsqlitedata.R;
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.Query;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class SearchinProductFragment extends Fragment {
private RelativeLayout relativeLayout;
private FrameLayout frameLayout;
private String searchText, phoneKey;
private AppCompatActivity appCompatActivity;
private DatabaseReference databaseReference;
private List<UserMerchantUploadProductImage> userMerchantUploadProductImageList;
private SearchRecyclerViewAdapter searchRecyclerViewAdapter;
private RecyclerView recyclerView;
private ProgressBar progressBar;
public SearchinProductFragment() {
// Required empty public constructor
}
@SuppressLint("ValidFragment")
public SearchinProductFragment(String searchText, String phoneKey) {
this.searchText = searchText;
this.phoneKey = phoneKey;
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_searchin_product, container, false);
appCompatActivity = (AppCompatActivity) view.getContext();
getIdForAllVariables(view);
progressBar.setVisibility(View.VISIBLE);
userMerchantUploadProductImageList = new ArrayList<>();
databaseReference = FirebaseDatabase.getInstance().getReference("MerchantAccout").child("MerchantProducts");
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2, GridLayoutManager.VERTICAL, false));
searchRecyclerViewAdapter=new SearchRecyclerViewAdapter(getContext(),userMerchantUploadProductImageList);
recyclerView.setAdapter(searchRecyclerViewAdapter);
SerarchData(searchText);
return view;
}
private void getIdForAllVariables(View view) {
recyclerView = view.findViewById(R.id.recycler_view_search_product_fragment);
progressBar = view.findViewById(R.id.progressBarInmenProducts);
frameLayout = view.findViewById(R.id.fragment_search);
relativeLayout = view.findViewById(R.id.relative_layout_search_fragment);
}
private void SerarchData(String searchText) {
//
// FirebaseRecyclerAdapter<UserMerchantUploadProductImage,SearchRecyclerViewAdapter.SearchProductViewHolderClass> firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<UserMerchantUploadProductImage, SearchRecyclerViewAdapter.SearchProductViewHolderClass>(
// UserMerchantUploadProductImage.class,
// R.layout.product_view_for_all_fraggments_layout,
// SearchRecyclerViewAdapter.SearchProductViewHolderClass.class,
// databaseReference
// ) {
// @Override
// protected void populateViewHolder(SearchRecyclerViewAdapter.SearchProductViewHolderClass viewHolder, UserMerchantUploadProductImage model, int position) {
// viewHolder.setDetail(appCompatActivity,model.getImage(),model.getStringBrandname(),
// model.getStringProductPrice(),model.getStringProductName());
// }
// };
// firebaseRecyclerAdapter.notifyDataSetChanged();
// recyclerView.setAdapter(firebaseRecyclerAdapter);
Query firebaseQuery = databaseReference.orderByChild("stringBrandname").startAt(searchText).endAt(searchText + "\uf8ff");
firebaseQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
userMerchantUploadProductImageList.clear();
for (DataSnapshot ds : dataSnapshot.getChildren()) {
UserMerchantUploadProductImage userMerchantUploadProductImage = ds.getValue(UserMerchantUploadProductImage.class);
userMerchantUploadProductImageList.add(userMerchantUploadProductImage);
}
if (userMerchantUploadProductImageList.size() != 0) {
progressBar.setVisibility(View.INVISIBLE);
searchRecyclerViewAdapter.notifyDataSetChanged();
} else {
Toast.makeText(getContext(), "No data Found...", Toast.LENGTH_SHORT).show();
appCompatActivity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SearchProductMainFragment(phoneKey)).addToBackStack(null).commit();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
progressBar.setVisibility(View.INVISIBLE);
Snackbar.make(frameLayout, "Some Error found during data loading", Snackbar.LENGTH_LONG).show();
}
});
}
}
|
[
"[email protected]"
] | |
17b32a501e875823717096dfecb24e772a47d19f
|
cc70f0eac152553f0744954a1c4da8af67faa5ab
|
/PPA/src/examples/AllCodeSnippets/class_49.java
|
6ba7fba45ee7530753995c4928f16884cf05aa2a
|
[] |
no_license
|
islamazhar/Detecting-Insecure-Implementation-code-snippets
|
b49b418e637a2098027e6ce70c0ddf93bc31643b
|
af62bef28783c922a8627c62c700ef54028b3253
|
refs/heads/master
| 2023-02-01T10:48:31.815921 | 2020-12-11T00:21:40 | 2020-12-11T00:21:40 | 307,543,127 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,132 |
java
|
package examples.AllCodeSnippets;
public class class_49 extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
sslContext.init(null, new TrustManager[] { tm }, null);
}
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
}
@Override
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
public static HttpClient getNewHttpClient() {
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", sf, 443));
ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
return new DefaultHttpClient(ccm, params);
} catch (Exception e) {
return new DefaultHttpClient();
}
}
}
|
[
"[email protected]"
] | |
3a84271197d9380fd786f06663d6f528d34c8e2b
|
a8477115d2f70a54b8b07b704fcea2c0cc85326c
|
/08Days_HandlerMapping_SimplerURLHandlerMapping/src/main/java/com/controller/OneController.java
|
5523758f6b10632d85e7af0700c95b7be4266cdf
|
[] |
no_license
|
peteryoon11/spring_training
|
23dac64cfb1ddd3247a8e6ee284212966fa38a7c
|
723e24104ab9a9fafd2129d07a4ca18e028a3795
|
refs/heads/master
| 2021-01-19T14:18:36.429217 | 2017-05-09T02:36:54 | 2017-05-09T02:36:54 | 88,142,199 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 551 |
java
|
package com.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class OneController {
@RequestMapping("/one/list")
public String bbbb() {
System.out.println("oneController");
// return 값은 view 이름
return "Hello";
}
@RequestMapping("/one/list2")
public String aaaa() {
System.out.println("oneController+ aaa");
// return 값은 view 이름
return "Hello";
}
}
|
[
"[email protected]"
] | |
afd4973b17621ee030bbe058afa6d06bceef6f5f
|
7fad1c85fc725b0b593ffc919d5bf1960e22f859
|
/src/com/example/helloworld/ArrayExperiment.java
|
03547ca91720e843bf3dfc0a8c075f7bacc52e5b
|
[] |
no_license
|
ahorseisananimal/Playground
|
5bd8eb01acd5cae4cfe97a40d833073fd52c9d07
|
3275f2d30b8f2fa7e28630cec1a341c1c14f76eb
|
refs/heads/master
| 2021-01-22T10:01:49.462597 | 2017-10-10T18:46:38 | 2017-10-10T18:46:38 | 68,647,215 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,103 |
java
|
package com.example.helloworld;
public class ArrayExperiment {
public static final int EXPEREMENTS_COUNT = 1000;
public static final int MAX_ELEMENTS = 100;
public static void main(String[] args) {
int[] massive = new int[5];
int i = 0;
int globalCount = 0;
int unsortedArrayCount = 0;
while (globalCount < EXPEREMENTS_COUNT) {
while (i < 5) {
massive[i] = (int) (Math.random() * MAX_ELEMENTS);
// System.out.println(massive[i]);
i = i + 1;
}
i = 0;
while (i < 4) {
if (massive[i] < massive[i + 1]) {
i++;
} else {
unsortedArrayCount++;
i = 0;
break;
}
}
globalCount++;
}
System.out.println("result: " + (100-unsortedArrayCount/1000000.0d) + "% sorted");
System.out.println("result: " + ((EXPEREMENTS_COUNT-unsortedArrayCount)/(EXPEREMENTS_COUNT/100.d)) + "% sorted");
}
}
|
[
"[email protected]"
] | |
7cb395b50f57fe17cc00f546bc1d9fddebfe5ca9
|
a2c03b5483a8db9a8350de992460a1efb7b76ce8
|
/duola-framework/src/main/java/com/xul/duola/framework/shiro/web/filter/online/OnlineSessionFilter.java
|
e563d2c8a1b977d7fc7ced4f26b8e2fcf4c5daf0
|
[] |
no_license
|
GodKerwin/duola
|
f40fa460658cab8e79641fab623e91755b2756ab
|
fd9699398cd6ca574f3796f4ae8b6ed081f31fbe
|
refs/heads/master
| 2020-05-31T13:39:43.351612 | 2019-06-05T02:17:56 | 2019-06-05T02:17:56 | 190,310,839 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,406 |
java
|
package com.xul.duola.framework.shiro.web.filter.online;
import com.xul.duola.common.constant.ShiroConstants;
import com.xul.duola.common.enums.OnlineStatus;
import com.xul.duola.framework.shiro.session.OnlineSession;
import com.xul.duola.framework.shiro.session.OnlineSessionDAO;
import com.xul.duola.framework.util.ShiroUtils;
import com.xul.duola.system.domain.SysUser;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.AccessControlFilter;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
/**
* 自定义访问控制
*
* Created by lxu on 2019/06/03.
*/
public class OnlineSessionFilter extends AccessControlFilter
{
/**
* 强制退出后重定向的地址
*/
@Value("${shiro.user.loginUrl}")
private String loginUrl;
@Autowired
private OnlineSessionDAO onlineSessionDAO;
/**
* 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false;
*/
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
throws Exception
{
Subject subject = getSubject(request, response);
if (subject == null || subject.getSession() == null)
{
return true;
}
Session session = onlineSessionDAO.readSession(subject.getSession().getId());
if (session != null && session instanceof OnlineSession)
{
OnlineSession onlineSession = (OnlineSession) session;
request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession);
// 把user对象设置进去
boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L;
if (isGuest == true)
{
SysUser user = ShiroUtils.getSysUser();
if (user != null)
{
onlineSession.setUserId(user.getUserId());
onlineSession.setLoginName(user.getLoginName());
onlineSession.setDeptName(user.getDept().getDeptName());
onlineSession.markAttributeChanged();
}
}
if (onlineSession.getStatus() == OnlineStatus.off_line)
{
return false;
}
}
return true;
}
/**
* 表示当访问拒绝时是否已经处理了;如果返回true表示需要继续处理;如果返回false表示该拦截器实例已经处理了,将直接返回即可。
*/
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception
{
Subject subject = getSubject(request, response);
if (subject != null)
{
subject.logout();
}
saveRequestAndRedirectToLogin(request, response);
return false;
}
// 跳转到登录页
@Override
protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException
{
WebUtils.issueRedirect(request, response, loginUrl);
}
}
|
[
"[email protected]"
] | |
e43443fe9de33a60f4c1b8179adc1162daa37707
|
0191ea20fd576a59ab07e4bf3322d4117e87f8bb
|
/src/gfg/PancakeSorting.java
|
e672b4ae299646e6ccdd905b8edbabd4cfc3d5d9
|
[] |
no_license
|
hitesh-kumar-mahour/CodingProblems
|
b22b1312b2a4168a37aabbdbe36d155d860793f6
|
5db7199b9bd43d54e6a586e6bca990d8c490ec10
|
refs/heads/master
| 2023-07-23T12:11:48.987419 | 2023-07-14T16:38:11 | 2023-07-14T16:38:11 | 321,714,931 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 678 |
java
|
package gfg;
import java.util.Arrays;
public class PancakeSorting {
// https://www.youtube.com/watch?v=AFtXLUn_TZg&ab_channel=KnowledgeCenter
private static void reverse(int [] a, int k){
if(k>=a.length)
return;
for(int i=0;i<=k/2;i++) {
int c = a[i];
a[i]=a[k-i];
a[k-i]=c;
}
}
private static void pancakeSort(int []a, int n) {
if(n==0)
return;
int max_i=0;
for(int i=0;i<=n;i++) {
if(a[i]>a[max_i])
max_i=i;
}
reverse(a, max_i);
reverse(a, n);
pancakeSort(a, n-1);
}
public static void main(String[] args) {
int [] a = {6,5,4,3,2,1};
pancakeSort(a, a.length-1);
System.out.println(Arrays.toString(a));
}
}
|
[
"[email protected]"
] | |
598303a142985147161e35f23443f82dc91b5513
|
801775fafc28ca91a0d3831863da05cf45a9dde4
|
/hrms/src/main/java/kodlamaio/hrms/core/utilites/results/ErrorDataResult.java
|
e0f67900b862dedbac59fbc9ccdafed839dfbda8
|
[] |
no_license
|
MuhammetSaitAkgunes/HRMS_new
|
486bcc70581d491e5834e90f3cf32a7994410811
|
6aa021bae15de074efd60192913f297bed7741d9
|
refs/heads/main
| 2023-06-01T21:22:44.958489 | 2021-06-13T15:37:52 | 2021-06-13T15:37:52 | 371,183,536 | 2 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 375 |
java
|
package kodlamaio.hrms.core.utilites.results;
public class ErrorDataResult<T> extends DataResult<T> {
public ErrorDataResult(T data,String message) {
super(data,false,message);
}
public ErrorDataResult(T data) {
super(data,false);
}
public ErrorDataResult(String message) {
super(null,false,message);
}
public ErrorDataResult() {
super(null,false);
}
}
|
[
"[email protected]"
] | |
beb73ecdac434344f061075e1c79a6032cfa1573
|
bcda8e393039636a6cd21f78361815f79f2c4f75
|
/src/main/java/com/game/sdk/dolls/request/payorder/PayOrderReq.java
|
ac6da27c6c141e884d861c1ebb97b2e6307b6117
|
[
"Apache-2.0"
] |
permissive
|
lqwluckyer/dolls
|
289ab4931cc251fcc735ff623501888fa2c8852d
|
7488f64959c1979989450f8700af2b7e87201ba0
|
refs/heads/master
| 2020-05-16T23:52:58.315847 | 2019-04-28T07:39:39 | 2019-04-28T07:39:39 | 183,380,817 | 4 | 2 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,224 |
java
|
package com.game.sdk.dolls.request.payorder;
public class PayOrderReq {
// 系统用户ID
private Long userId;
//当前商品ID
private String productId;
private String productName;
private String productDesc;
//支付总金额,单位 分
private Integer money;
// 物品单价,单位 分
private Integer price;
// 购买数据
private Integer buyNumbers;
//玩家在游戏服中的角色ID
private String roleId;
//玩家在游戏服中的角色名称
private String roleName;
//玩家等级
private String roleLevel;
//玩家所在的服务器ID
private String serverId;
//玩家所在的服务器名称
private String serverName;
//支付回调通知的游戏服地址
private String extension;
//通知CP发货地址
private String notifyUrl;
//MD5 签名
private String sign;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductDesc() {
return productDesc;
}
public void setProductDesc(String productDesc) {
this.productDesc = productDesc;
}
public Integer getMoney() {
return money;
}
public void setMoney(Integer money) {
this.money = money;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Integer getBuyNumbers() {
return buyNumbers;
}
public void setBuyNumbers(Integer buyNumbers) {
this.buyNumbers = buyNumbers;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleLevel() {
return roleLevel;
}
public void setRoleLevel(String roleLevel) {
this.roleLevel = roleLevel;
}
public String getServerId() {
return serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
}
public String getServerName() {
return serverName;
}
public void setServerName(String serverName) {
this.serverName = serverName;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}
|
[
"[email protected]"
] | |
9fa7125557da5a70f60360b9d8671c8fc965b194
|
b2dc53e01d7056b1de94c38127a1afd7c4febf36
|
/src/com/weavernorth/util/SelectUtil.java
|
77d53bedfbdd1a1f106b6cc788acaf7e67fc27e2
|
[] |
no_license
|
QingShuiSuYi/Dylan
|
63318e7e74e4e771861ec6a2572fb8c7f6e0196f
|
b028ca5ecfea7025ae0e8cca66a27c9c88bb673e
|
refs/heads/master
| 2021-05-14T14:39:40.467510 | 2018-02-11T08:11:12 | 2018-02-11T08:11:15 | 115,975,809 | 2 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 173 |
java
|
package com.weavernorth.util;
import weaver.conn.RecordSet;
import weaver.general.Util;
public class SelectUtil {
public static void main(String[] args) {
}
}
|
[
"[email protected]"
] | |
4a704e9250ac4502fda5dc6c0a9039e80b043116
|
1c25675d9533ef7834ed490a144a76f67e82603c
|
/unit9/src/TestDialogFrame/ButtonPanel.java
|
e26f05e99914f8eee1fe0c10e9f39a9b8b716528
|
[] |
no_license
|
Cowin1997/JAVA
|
bb2d200f76aeca269d9a69b8e5ccc63e15c64dae
|
0c17ce9090f80e83a7de9ded58e2224bb95b4c46
|
refs/heads/master
| 2021-04-18T22:48:14.135278 | 2018-03-24T04:18:00 | 2018-03-24T04:18:00 | 126,503,921 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 659 |
java
|
package TestDialogFrame;
import javax.swing.*;
public class ButtonPanel extends JPanel{
private ButtonGroup group;
public ButtonPanel(String title,String[]options) {
this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),title));
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));//面板里的组件 垂直排列
this.group=new ButtonGroup();
for(String option:options) {
JRadioButton b=new JRadioButton(option);
b.setActionCommand(option);
add(b);
this.group.add(b);
b.setSelected(option==options[0]);
}
}
public String getSelection() {
return group.getSelection().getActionCommand();
}
}
|
[
"[email protected]"
] | |
b5860392f42d59103bbf6a78005667ca4ca8566a
|
deb9e5d21dacb07498d180a924a84d94f8c6b782
|
/19.7.9/SSMDemoFinal/src/main/java/com/ming/po/ItemsCustom.java
|
32b79015456f7ef4829a59a7b68b9662d520d2af
|
[] |
no_license
|
LeBronJJJ/mydocument
|
c4043c394c0af707ef9bd559a5612dd4cb0ff9ec
|
69a8f83720b34f13deef203901db58db207db9cb
|
refs/heads/master
| 2022-12-22T23:24:25.548766 | 2019-09-14T16:02:23 | 2019-09-14T16:02:23 | 152,721,976 | 0 | 0 | null | 2022-12-16T04:50:13 | 2018-10-12T08:52:18 |
Java
|
UTF-8
|
Java
| false | false | 87 |
java
|
package com.ming.po;
/**
* 扩展类
*/
public class ItemsCustom extends Items
{
}
|
[
"[email protected]"
] | |
5b75b4c4a365903dc56d85a708fb1f6ee9fc36d5
|
d8f33e3f86feba283790046dca3aac7fd205233d
|
/app/src/main/java/com/perawat/yacob/perawat/PengkajianAwalActivity3.java
|
02935f34f3099ab3ae364f3cd9aa12999901d663
|
[] |
no_license
|
yacob21/Perawat
|
cdc0ec2751133b9e359eb0b9e1881302f7762e0c
|
85a418e1dd405fc5223bbc16015f797f60464c1b
|
refs/heads/master
| 2020-03-25T04:54:19.813767 | 2018-08-03T11:30:39 | 2018-08-03T11:30:39 | 143,419,434 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 62,274 |
java
|
package com.perawat.yacob.perawat;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PengkajianAwalActivity3 extends AppCompatActivity {
Button btnLanjut;
EditText etLokasiSakitKepala,etFrekuensiSakitKepala,etLokasiNeurosensori
,etStroke,etTipeKejang,etAuraKejang,etFrekuensiKejang,
etCaraMengontrolKejang,etStatusPostikalKejang,etPemeriksaanMata,
etPemeriksaanTelinga,etAfek,etUkuran,etReflekCahaya,etLokasiParalisis,
etLokasiNyeri,etIntensitasNyeri,etFrekuensiNyeri,etKualitasNyeri,
etPenjalaranNyeri,etDurasiNyeri,etFaktorNyeri,etCaraNyeri,etResponsEmosional,
etJumlahMerokok,etLamaMerokok,etFrekuensiNapas,etKarakteristikSputum;
CheckBox cbKesemutan,cbKebas,cbKelemahan,cbKehilanganPenghilatan,cbGlaukoma,
cbKatarak,cbKehilanganPendengaran,cbPerubahanPenciuman,cbPerubahanPengecap,
cbEpistasis,cbTerorientasi,cbDisorientasi,cbOrang,cbWaktu,cbTempat,
cbKooperatif,cbMenyerang,cbDelusi,cbHalusinasi,cbMengantuk,cbLetargi
,cbStupor,cbKoma,cbKacamata,cbLensaKontak,cbAlatBantuDengar,cbMengkerutkanMuka
,cbMenjagaArea,cbPenyempitanFokus,cbDispnea,cbBatuk,cbBronkhitis,cbAsma,cbTuberkolosis
,cbPneumonia,cbEmfisema,cbPenggunaanOtot,cbNapasCuping,cbSputum,cbVersikuler,cbRonkhi,cbWheezing;
int kesemutan=0,kebas=0,kelemahan=0,penglihatan=0,glaukoma=0,katarak=0,pendengaran=0,penciuman=0,pengecap=0,
epistasis=0,terorientasi=0,disorientasi=0,orang=0,waktu=0,tempat=0,kooperatif=0,menyerang=0,delusi=0,halusinasi=0,
mengantuk=0,letargi=0,stupor=0,koma=0,kacamata=0,lensakontak=0,alatbantu=0,mengkerutkan=0,menjaga=0,penyempitan=0,
dispnea=0,batuk=0,bronkhitis=0,asma=0,tuberkolosis=0,pneumonia=0,emfisema=0,otot=0,cuping=0,sputum=0,versikuler=0,
ronkhi=0,wheezing=0;
RadioButton rbCederaOtakYa,rbCederaOtakTidak,rbSaatIniBaik,rbSaatIniTerganggu,
rbLampauBaik,rbLampauTerganggu,rbFacialDropYa,rbFacialDropTidak,
rbRefleksTendonNormal,rbRefleksTendonTerganggu,rbParalisisYa,rbParalisisTidak,
rbTerpajanYa,rbTerpajanTidak,rbSimetris,rbTidakSimetris,rbKedalamanNormal,rbKedalamanDangkal,
rbKedalamanDalam,rbFremitusNormal,rbFremitusMenurun,rbFremitusMeningkat;
int otak=0,saatini=0,lampau=0,facial=0,tendon=0,paralisis=0,terpajan=0,simetris=0;
String kedalaman="",fremitus="";
RequestQueue queue;
SessionIdPasien sessionIdPasien;
Context context;
String INSERT_PENGKAJIAN_AWAL_3_URL = "http://rumahsakit.gearhostpreview.com/Rumah_Sakit/insertPengkajianAwal3.php";
AlertDialog dialog;
AlertDialog.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pengkajian_awal3);
context = this;
getSupportActionBar().setTitle(Html.fromHtml("<'font color='#ffffff'>Pengkajian Awal</font>"));
sessionIdPasien = new SessionIdPasien(getApplicationContext());
queue = Volley.newRequestQueue(this);
btnLanjut = findViewById(R.id.btnLanjut);
builder = new AlertDialog.Builder(this);
etLokasiSakitKepala = findViewById(R.id.etLokasiSakitKepala);
etFrekuensiSakitKepala = findViewById(R.id.etFrekuensiSakitKepala);
etLokasiNeurosensori = findViewById(R.id.etLokasiNeurosensori);
etStroke = findViewById(R.id.etStroke);
etTipeKejang = findViewById(R.id.etTipeKejang);
etAuraKejang = findViewById(R.id.etAuraKejang);
etFrekuensiKejang = findViewById(R.id.etFrekuensiKejang);
etCaraMengontrolKejang = findViewById(R.id.etCaraMengontrolKejang);
etStatusPostikalKejang = findViewById(R.id.etStatusPostikalKejang);
etPemeriksaanMata = findViewById(R.id.etPemeriksaanMata);
etPemeriksaanTelinga = findViewById(R.id.etPemeriksaanTelinga);
etAfek = findViewById(R.id.etAfek);
etUkuran = findViewById(R.id.etUkuran);
etReflekCahaya = findViewById(R.id.etReflekCahaya);
etLokasiParalisis = findViewById(R.id.etLokasiParalisis);
etLokasiNyeri = findViewById(R.id.etLokasiNyeri);
etIntensitasNyeri = findViewById(R.id.etIntensitasNyeri);
etFrekuensiNyeri = findViewById(R.id.etFrekuensiNyeri);
etKualitasNyeri = findViewById(R.id.etKualitasNyeri);
etPenjalaranNyeri = findViewById(R.id.etPenjalaranNyeri);
etDurasiNyeri = findViewById(R.id.etDurasiNyeri);
etFaktorNyeri = findViewById(R.id.etFaktorNyeri);
etCaraNyeri = findViewById(R.id.etCaraNyeri);
etResponsEmosional = findViewById(R.id.etResponsEmosional);
etJumlahMerokok = findViewById(R.id.etJumlahMerokok);
etLamaMerokok = findViewById(R.id.etLamaMerokok);
etFrekuensiNapas = findViewById(R.id.etFrekuensiNapas);
etKarakteristikSputum = findViewById(R.id.etKarakteristikSputum);
cbKesemutan = findViewById(R.id.cbKesemutan);
cbKebas = findViewById(R.id.cbKebas);
cbKelemahan = findViewById(R.id.cbKelemahan);
cbKehilanganPenghilatan = findViewById(R.id.cbKehilanganPenglihatan);
cbGlaukoma = findViewById(R.id.cbGlaukoma);
cbKatarak = findViewById(R.id.cbKatarak);
cbKehilanganPendengaran = findViewById(R.id.cbKehilanganPendengaran);
cbPerubahanPenciuman = findViewById(R.id.cbPerubahanPenciuman);
cbPerubahanPengecap = findViewById(R.id.cbPerubahanPengecap);
cbEpistasis = findViewById(R.id.cbEpistasis);
cbTerorientasi = findViewById(R.id.cbTerorientasi);
cbDisorientasi = findViewById(R.id.cbDisorientasi);
cbOrang = findViewById(R.id.cbOrang);
cbWaktu = findViewById(R.id.cbWaktu);
cbTempat = findViewById(R.id.cbTempat);
cbKooperatif = findViewById(R.id.cbKooperatif);
cbMenyerang = findViewById(R.id.cbMenyerang);
cbDelusi = findViewById(R.id.cbDelusi);
cbHalusinasi = findViewById(R.id.cbHalusinasi);
cbMengantuk = findViewById(R.id.cbMengantuk);
cbLetargi = findViewById(R.id.cbLetargi);
cbStupor = findViewById(R.id.cbStupor);
cbKoma = findViewById(R.id.cbKoma);
cbKacamata = findViewById(R.id.cbKacamata);
cbLensaKontak = findViewById(R.id.cbLensaKontak);
cbAlatBantuDengar = findViewById(R.id.cbAlatBantuDengar);
cbMengkerutkanMuka = findViewById(R.id.cbMengkerutkanMuka);
cbMenjagaArea = findViewById(R.id.cbMenjagaArea);
cbPenyempitanFokus = findViewById(R.id.cbPenyempitanFokus);
cbDispnea = findViewById(R.id.cbDispnea);
cbBatuk = findViewById(R.id.cbBatuk);
cbBronkhitis = findViewById(R.id.cbBronkhitis);
cbAsma = findViewById(R.id.cbAsma);
cbTuberkolosis = findViewById(R.id.cbTuberkulosis);
cbPneumonia = findViewById(R.id.cbPneumonia);
cbEmfisema = findViewById(R.id.cbEmfisema);
cbPenggunaanOtot = findViewById(R.id.cbPenggunaanOtot);
cbNapasCuping = findViewById(R.id.cbNapasCuping);
cbSputum = findViewById(R.id.cbSputum);
cbVersikuler = findViewById(R.id.cbVersikuler);
cbRonkhi = findViewById(R.id.cbRonkhi);
cbWheezing = findViewById(R.id.cbWheezing);
cbKesemutan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kesemutan=1;
}
else{
kesemutan=0;
}
}
});
cbKebas.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kebas=1;
}
else{
kebas=0;
}
}
});
cbKelemahan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kelemahan=1;
}
else{
kelemahan=0;
}
}
});
cbKehilanganPenghilatan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
penglihatan=1;
}
else{
penglihatan=0;
}
}
});
cbGlaukoma.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
glaukoma=1;
}
else{
glaukoma=0;
}
}
});
cbKatarak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
katarak=1;
}
else{
katarak=0;
}
}
});
cbKehilanganPendengaran.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
pendengaran=1;
}
else{
pendengaran=0;
}
}
});
cbPerubahanPenciuman.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
penciuman=1;
}
else{
penciuman=0;
}
}
});
cbPerubahanPengecap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
pengecap=1;
}
else{
pengecap=0;
}
}
});
cbEpistasis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
epistasis=1;
}
else{
epistasis=0;
}
}
});
cbTerorientasi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
terorientasi=1;
}
else{
terorientasi=0;
}
}
});
cbDisorientasi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
disorientasi=1;
}
else{
disorientasi=0;
}
}
});
cbOrang.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
orang=1;
}
else{
orang=0;
}
}
});
cbWaktu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
waktu=1;
}
else{
waktu=0;
}
}
});
cbTempat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
tempat=1;
}
else{
tempat=0;
}
}
});
cbKooperatif.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kooperatif=1;
}
else{
kooperatif=0;
}
}
});
cbMenyerang.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
menyerang=1;
}
else{
menyerang=0;
}
}
});
cbDelusi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
delusi=1;
}
else{
delusi=0;
}
}
});
cbHalusinasi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
halusinasi=1;
}
else{
halusinasi=0;
}
}
});
cbMengantuk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
mengantuk=1;
}
else{
mengantuk=0;
}
}
});
cbLetargi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
letargi=1;
}
else{
letargi=0;
}
}
});
cbStupor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
stupor=1;
}
else{
stupor=0;
}
}
});
cbKoma.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
koma=1;
}
else{
koma=0;
}
}
});
cbKacamata.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kacamata=1;
}
else{
kacamata=0;
}
}
});
cbLensaKontak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
lensakontak=1;
}
else{
lensakontak=0;
}
}
});
cbAlatBantuDengar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
alatbantu=1;
}
else{
alatbantu=0;
}
}
});
cbMengkerutkanMuka.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
mengkerutkan=1;
}
else{
mengkerutkan=0;
}
}
});
cbMenjagaArea.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
menjaga=1;
}
else{
menjaga=0;
}
}
});
cbPenyempitanFokus.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
penyempitan=1;
}
else{
penyempitan=0;
}
}
});
cbDispnea.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
dispnea=1;
}
else{
dispnea=0;
}
}
});
cbBatuk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
batuk=1;
}
else{
batuk=0;
}
}
});
cbBronkhitis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
bronkhitis=1;
}
else{
bronkhitis=0;
}
}
});
cbAsma.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
asma=1;
}
else{
asma=0;
}
}
});
cbTuberkolosis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
tuberkolosis=1;
}
else{
tuberkolosis=0;
}
}
});
cbPneumonia.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
pneumonia=1;
}
else{
pneumonia=0;
}
}
});
cbEmfisema.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
emfisema=1;
}
else{
emfisema=0;
}
}
});
cbPenggunaanOtot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
otot=1;
}
else{
otot=0;
}
}
});
cbNapasCuping.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
cuping=1;
}
else{
cuping=0;
}
}
});
cbSputum.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
sputum=1;
}
else{
sputum=0;
}
}
});
cbVersikuler.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
versikuler=1;
}
else{
versikuler=0;
}
}
});
cbRonkhi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
ronkhi=1;
}
else{
ronkhi=0;
}
}
});
cbWheezing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
wheezing=1;
}
else{
wheezing=0;
}
}
});
rbCederaOtakYa = findViewById(R.id.rbCederaOtakYa);
rbCederaOtakTidak = findViewById(R.id.rbCederaOtakTidak);
rbSaatIniBaik = findViewById(R.id.rbSaatIniBaik);
rbSaatIniTerganggu = findViewById(R.id.rbSaatIniTerganggu);
rbLampauBaik = findViewById(R.id.rbLampauBaik);
rbLampauTerganggu = findViewById(R.id.rbLampauTerganggu);
rbFacialDropYa = findViewById(R.id.rbFacialDropYa);
rbFacialDropTidak = findViewById(R.id.rbFacialDropTidak);
rbRefleksTendonNormal = findViewById(R.id.rbRefleksTendonNormal);
rbRefleksTendonTerganggu = findViewById(R.id.rbRefleksTendonTerganggu);
rbParalisisYa = findViewById(R.id.rbParalisisYa);
rbParalisisTidak = findViewById(R.id.rbParalisisTidak);
rbTerpajanYa = findViewById(R.id.rbTerpajanYa);
rbTerpajanTidak = findViewById(R.id.rbTerpajanTidak);
rbSimetris = findViewById(R.id.rbSimetris);
rbTidakSimetris = findViewById(R.id.rbTidakSimetris);
rbKedalamanNormal = findViewById(R.id.rbKedalamanNormal);
rbKedalamanDangkal = findViewById(R.id.rbKedalamanDalam);
rbKedalamanDalam = findViewById(R.id.rbKedalamanDalam);
rbFremitusNormal = findViewById(R.id.rbFremitusNormal);
rbFremitusMenurun = findViewById(R.id.rbFremitusMenurun);
rbFremitusMeningkat = findViewById(R.id.rbFremitusMenigkat);
rbCederaOtakYa.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
otak=1;
}
}
});
rbCederaOtakTidak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
otak=0;
}
}
});
rbSaatIniBaik.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
saatini=1;
}
}
});
rbSaatIniTerganggu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
saatini=0;
}
}
});
rbLampauBaik.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
lampau=1;
}
}
});
rbLampauTerganggu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
lampau=0;
}
}
});
rbFacialDropYa.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
facial=1;
}
}
});
rbFacialDropTidak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
facial=0;
}
}
});
rbRefleksTendonNormal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
tendon=1;
}
}
});
rbRefleksTendonTerganggu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
tendon=0;
}
}
});
rbParalisisYa.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
paralisis=1;
}
}
});
rbParalisisTidak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
paralisis=0;
}
}
});
rbTerpajanYa.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
terpajan=1;
}
}
});
rbTerpajanTidak.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
terpajan=0;
}
}
});
rbSimetris.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
simetris=1;
}
}
});
rbTidakSimetris.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
simetris=0;
}
}
});
rbKedalamanNormal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kedalaman="Normal";
}
}
});
rbKedalamanDalam.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kedalaman="Dalam";
}
}
});
rbKedalamanDangkal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
kedalaman="Dangkal";
}
}
});
rbFremitusNormal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
fremitus="Normal";
}
}
});
rbFremitusMeningkat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
fremitus="Meningkat";
}
}
});
rbFremitusMenurun.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
fremitus="Menurun";
}
}
});
final Intent x = getIntent();
if(x.getStringExtra("panduan").equals("view")){
getPengkajianAwal(sessionIdPasien.getIdPasienDetails().get(SessionIdPasien.KEY_ID_PASIEN));
}
btnLanjut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (x.getStringExtra("panduan").equals("view")) {
Intent i = new Intent(PengkajianAwalActivity3.this,PengkajianAwalActivity4.class);
i.putExtra("panduan","view");
startActivity(i);
} else {
insertPengkajianAwal(otak, etLokasiSakitKepala.getText().toString(), etFrekuensiSakitKepala.getText().toString(), kesemutan, kebas, kelemahan,
etLokasiNeurosensori.getText().toString(), etStroke.getText().toString(), etTipeKejang.getText().toString(), etAuraKejang.getText().toString(),
etFrekuensiKejang.getText().toString(), etCaraMengontrolKejang.getText().toString(), etStatusPostikalKejang.getText().toString(), penglihatan, glaukoma,
katarak, etPemeriksaanMata.getText().toString(), pendengaran, etPemeriksaanTelinga.getText().toString(), penciuman, pengecap, epistasis, terorientasi, disorientasi,
orang, waktu, tempat, kooperatif, delusi, menyerang, halusinasi, etAfek.getText().toString(), mengantuk, stupor, letargi, koma, saatini, lampau, kacamata, lensakontak, alatbantu,
etUkuran.getText().toString(), etReflekCahaya.getText().toString(), facial, tendon, paralisis, etLokasiParalisis.getText().toString(), etLokasiNyeri.getText().toString(),
etIntensitasNyeri.getText().toString(), etFrekuensiNyeri.getText().toString(), etKualitasNyeri.getText().toString(), etPenjalaranNyeri.getText().toString(), etDurasiNyeri.getText().toString(),
etFaktorNyeri.getText().toString(), etCaraNyeri.getText().toString(), mengkerutkan, menjaga, penyempitan, etResponsEmosional.getText().toString(), dispnea, batuk, bronkhitis, asma, tuberkolosis,
pneumonia, emfisema, terpajan, etJumlahMerokok.getText().toString().replace(",", "."), etLamaMerokok.getText().toString().replace(",", "."), etFrekuensiNapas.getText().toString(), kedalaman, simetris, otot, cuping, fremitus,
versikuler, ronkhi, wheezing, sputum, etKarakteristikSputum.getText().toString(), Integer.parseInt(sessionIdPasien.getIdPasienDetails().get(SessionIdPasien.KEY_ID_PASIEN)));
}
}
});
}
public void getPengkajianAwal(String id){
cbKesemutan.setClickable(false);cbKebas.setClickable(false);cbKelemahan.setClickable(false);cbKehilanganPenghilatan.setClickable(false);cbGlaukoma.setClickable(false);
cbKatarak.setClickable(false);cbKehilanganPendengaran.setClickable(false);cbPerubahanPenciuman.setClickable(false);cbPerubahanPengecap.setClickable(false);
cbEpistasis.setClickable(false);cbTerorientasi.setClickable(false);cbDisorientasi.setClickable(false);cbOrang.setClickable(false);cbWaktu.setClickable(false);
cbTempat.setClickable(false);cbKooperatif.setClickable(false);cbMenyerang.setClickable(false);cbDelusi.setClickable(false);
cbHalusinasi.setClickable(false);cbMengantuk.setClickable(false);cbLetargi.setClickable(false);
cbStupor.setClickable(false);cbKoma.setClickable(false);cbKacamata.setClickable(false);cbLensaKontak.setClickable(false);
cbAlatBantuDengar.setClickable(false);cbMengkerutkanMuka.setClickable(false);cbMenjagaArea.setClickable(false);
cbPenyempitanFokus.setClickable(false);cbDispnea.setClickable(false);cbBatuk.setClickable(false);
cbBronkhitis.setClickable(false);cbAsma.setClickable(false);cbTuberkolosis.setClickable(false);
cbPneumonia.setClickable(false);cbEmfisema.setClickable(false);cbPenggunaanOtot.setClickable(false);cbNapasCuping.setClickable(false);cbSputum.setClickable(false);cbVersikuler.setClickable(false);cbRonkhi.setClickable(false);cbWheezing.setClickable(false);
rbCederaOtakYa.setClickable(false);rbCederaOtakTidak.setClickable(false);rbSaatIniBaik.setClickable(false);rbSaatIniTerganggu.setClickable(false);
rbLampauBaik.setClickable(false);rbLampauTerganggu.setClickable(false);rbFacialDropYa.setClickable(false);rbFacialDropTidak.setClickable(false);
rbRefleksTendonNormal.setClickable(false);rbRefleksTendonTerganggu.setClickable(false);rbParalisisYa.setClickable(false);rbParalisisTidak.setClickable(false);
rbTerpajanYa.setClickable(false);rbTerpajanTidak.setClickable(false);rbSimetris.setClickable(false);rbTidakSimetris.setClickable(false);
rbKedalamanNormal.setClickable(false);rbKedalamanDangkal.setClickable(false);rbKedalamanDalam.setClickable(false);rbFremitusNormal.setClickable(false);
rbFremitusMenurun.setClickable(false);rbFremitusMeningkat.setClickable(false);
etLokasiSakitKepala.setKeyListener(null);etFrekuensiSakitKepala.setKeyListener(null);etLokasiNeurosensori.setKeyListener(null);
etStroke.setKeyListener(null);etTipeKejang.setKeyListener(null);etAuraKejang.setKeyListener(null);etFrekuensiKejang.setKeyListener(null);etCaraMengontrolKejang.setKeyListener(null);etStatusPostikalKejang.setKeyListener(null);etPemeriksaanMata.setKeyListener(null);etPemeriksaanTelinga.setKeyListener(null);etAfek.setKeyListener(null);etUkuran.setKeyListener(null);etReflekCahaya.setKeyListener(null);etLokasiParalisis.setKeyListener(null);
etLokasiNyeri.setKeyListener(null);etIntensitasNyeri.setKeyListener(null);etFrekuensiNyeri.setKeyListener(null);etKualitasNyeri.setKeyListener(null);
etPenjalaranNyeri.setKeyListener(null);etDurasiNyeri.setKeyListener(null);etFaktorNyeri.setKeyListener(null);etCaraNyeri.setKeyListener(null);
etResponsEmosional.setKeyListener(null);etJumlahMerokok.setKeyListener(null);etLamaMerokok.setKeyListener(null);etFrekuensiNapas.setKeyListener(null);
etKarakteristikSputum.setKeyListener(null);
String url = "http://rumahsakit.gearhostpreview.com/Rumah_Sakit/selectPengkajianAwal3.php?id_pasien="+id;
JsonObjectRequest req = new JsonObjectRequest(url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
JSONArray users = null;
try {
users = response.getJSONArray("result");
} catch (JSONException e) {
e.printStackTrace();
}
for (int i = 0; i < users.length(); i++) {
try {
JSONObject obj = users.getJSONObject(i);
if(obj.getInt("Riwayat_Cedera_Otak") == 1){
rbCederaOtakYa.setChecked(true);
}
if(obj.getInt("Riwayat_Cedera_Otak")== 0){
rbCederaOtakTidak.setChecked(true);
}
if(obj.getInt("Memori_Saat_Ini") == 1){
rbSaatIniBaik.setChecked(true);
}
if(obj.getInt("Memori_Saat_Ini")== 0){
rbSaatIniTerganggu.setChecked(true);
}
if(obj.getInt("Memori_Masa_Lalu") == 1){
rbLampauBaik.setChecked(true);
}
if(obj.getInt("Memori_Masa_Lalu")== 0){
rbLampauTerganggu.setChecked(true);
}
if(obj.getInt("Facial_Drop") == 1){
rbFacialDropYa.setChecked(true);
}
if(obj.getInt("Facial_Drop")== 0){
rbFacialDropTidak.setChecked(true);
}
if(obj.getInt("Refleks_Tendon_Dalam") == 1){
rbRefleksTendonNormal.setChecked(true);
}
if(obj.getInt("Refleks_Tendon_Dalam")== 0){
rbRefleksTendonTerganggu.setChecked(true);
}
if(obj.getInt("Paralisis_Parastesia") == 1){
rbParalisisYa.setChecked(true);
}
if(obj.getInt("Paralisis_Parastesia")== 0){
rbParalisisTidak.setChecked(true);
}
if(obj.getInt("Terpajan_Udara_berbahaya") == 1){
rbTerpajanYa.setChecked(true);
}
if(obj.getInt("Terpajan_Udara_berbahaya")== 0){
rbTerpajanTidak.setChecked(true);
}
if(obj.getString("Kedalaman_Napas").equals("Normal")){
rbKedalamanNormal.setChecked(true);
}
if(obj.getString("Kedalaman_Napas").equals("Dalam")){
rbKedalamanDalam.setChecked(true);
}
if(obj.getString("Kedalaman_Napas").equals("Dangkal")){
rbKedalamanDangkal.setChecked(true);
}
if(obj.getInt("Simetrisitas") == 1){
rbSimetris.setChecked(true);
}
if(obj.getInt("Simetrisitas") == 0){
rbTidakSimetris.setChecked(true);
}
if(obj.getString("Fremitus").equals("Normal")){
rbFremitusNormal.setChecked(true);
}
if(obj.getString("Fremitus").equals("Meningkat")){
rbFremitusMeningkat.setChecked(true);
}
if(obj.getString("Fremitus").equals("Menurun")){
rbFremitusMenurun.setChecked(true);
}
etLokasiSakitKepala.setText(obj.getString("Lokasi_Sakit_Kepala"));
etFrekuensiSakitKepala.setText(obj.getString("Frek_Sakit_Kepala"));
etLokasiNeurosensori.setText(obj.getString("Lokasi_Keluhan_Neurosensori"));
etStroke.setText(obj.getString("Stroke_Gejala_Sisa"));
etTipeKejang.setText(obj.getString("Tipe_Kejang"));
etAuraKejang.setText(obj.getString("Aura_Kejang"));
etFrekuensiKejang.setText(obj.getString("Frek_Kejang"));
etCaraMengontrolKejang.setText(obj.getString("Cara_Kontrol_Kejang"));
etStatusPostikalKejang.setText(obj.getString("Status_Postikal"));
etPemeriksaanMata.setText(obj.getString("Pemeriksaan_Mata_Terakhir"));
etPemeriksaanTelinga.setText(obj.getString("Pemeriksaan_Telinga_Terakhir"));
etAfek.setText(obj.getString("Afek_Mental"));
etUkuran.setText(obj.getString("Ukuran_Pupil"));
etReflekCahaya.setText(obj.getString("Reflek_Cahaya"));
etLokasiParalisis.setText(obj.getString("Lokasi_Paralisis"));
etLokasiNyeri.setText(obj.getString("Lokasi_Nyeri"));
etIntensitasNyeri.setText(obj.getString("Intensitas_Nyeri"));
etFrekuensiNyeri.setText(obj.getString("Frek_Nyeri"));
etKualitasNyeri.setText(obj.getString("Kualitas_Nyeri"));
etPenjalaranNyeri.setText(obj.getString("Penjalaran_Nyeri"));
etDurasiNyeri.setText(obj.getString("Durasi_Nyeri"));
etFaktorNyeri.setText(obj.getString("Faktor_Pencetus_Nyeri"));
etCaraNyeri.setText(obj.getString("Cara_Memghilangkan_Nyeri"));
etResponsEmosional.setText(obj.getString("Respons_Emosional"));
etJumlahMerokok.setText(obj.getString("Jumlah_Rokok_Harian"));
etLamaMerokok.setText(obj.getString("Lama_Merokok"));
etFrekuensiNapas.setText(obj.getString("Frek_Napas"));
etKarakteristikSputum.setText(obj.getString("Karakteristik_Sputum"));
if(obj.getInt("Kesemutan") == 1){
cbKesemutan.setChecked(true);
}
if(obj.getInt("Kebas") == 1){
cbKebas.setChecked(true);
}
if(obj.getInt("Kelemahan") == 1){
cbKelemahan.setChecked(true);
}
if(obj.getInt("Kehilangan_Penglihatan") == 1){
cbKehilanganPenghilatan.setChecked(true);
}
if(obj.getInt("Glaukoma") == 1){
cbGlaukoma.setChecked(true);
}
if(obj.getInt("Katarak") == 1){
cbKatarak.setChecked(true);
}
if(obj.getInt("Kehilangan_Pendengaran") == 1){
cbKehilanganPendengaran.setChecked(true);
}
if(obj.getInt("Perubahan_Penciuman") == 1){
cbPerubahanPenciuman.setChecked(true);
}
if(obj.getInt("Perubahan_Pengecap") == 1){
cbPerubahanPengecap.setChecked(true);
}
if(obj.getInt("Epistasis") == 1){
cbEpistasis.setChecked(true);
}
if(obj.getInt("Mental_Terorientasi") == 1){
cbTerorientasi.setChecked(true);
}
if(obj.getInt("Mental_Disorentasi") == 1){
cbDisorientasi.setChecked(true);
}
if(obj.getInt("Disorientasi_Orang") == 1){
cbOrang.setChecked(true);
}
if(obj.getInt("Disorientasi_Waktu") == 1){
cbWaktu.setChecked(true);
}
if(obj.getInt("Disorientasi_Tempat") == 1){
cbTempat.setChecked(true);
}
if(obj.getInt("Mental_Kooperatif") == 1){
cbKooperatif.setChecked(true);
}
if(obj.getInt("Mental_Delusi") == 1){
cbDelusi.setChecked(true);
}
if(obj.getInt("Mental_Menyerang") == 1){
cbMenyerang.setChecked(true);
}
if(obj.getInt("Mental_Halusinasi") == 1){
cbHalusinasi.setChecked(true);
}
if(obj.getInt("Mengatuk") == 1){
cbMengantuk.setChecked(true);
}
if(obj.getInt("Letargi") == 1){
cbLetargi.setChecked(true);
}
if(obj.getInt("Stupor") == 1){
cbStupor.setChecked(true);
}
if(obj.getInt("Koma") == 1){
cbKoma.setChecked(true);
}
if(obj.getInt("Kacamata") == 1){
cbKacamata.setChecked(true);
}
if(obj.getInt("Lensa_Kontak") == 1){
cbLensaKontak.setChecked(true);
}
if(obj.getInt("Alat_Bantu_Dengar") == 1){
cbAlatBantuDengar.setChecked(true);
}
if(obj.getInt("Mengkerutkan_Muka") == 1){
cbMengkerutkanMuka.setChecked(true);
}
if(obj.getInt("Menjaga_Area_Sakit") == 1){
cbMenjagaArea.setChecked(true);
}
if(obj.getInt("Penyempitan_Fokus") == 1){
cbPenyempitanFokus.setChecked(true);
}
if(obj.getInt("Dispnea") == 1){
cbDispnea.setChecked(true);
}
if(obj.getInt("Batuk") == 1){
cbBatuk.setChecked(true);
}
if(obj.getInt("Bronkhitis") == 1){
cbBronkhitis.setChecked(true);
}
if(obj.getInt("Asma") == 1){
cbAsma.setChecked(true);
}
if(obj.getInt("Tuberkulosis") == 1){
cbTuberkolosis.setChecked(true);
}
if(obj.getInt("Pneumonia") == 1){
cbPneumonia.setChecked(true);
}
if(obj.getInt("Emfisema") == 1){
cbEmfisema.setChecked(true);
}
if(obj.getInt("Penggunaan_Otot_Asesorius") == 1){
cbPenggunaanOtot.setChecked(true);
}
if(obj.getInt("Napas_Cuping_Hidung") == 1){
cbNapasCuping.setChecked(true);
}
if(obj.getInt("Versikuler") == 1){
cbVersikuler.setChecked(true);
}
if(obj.getInt("Ronkhi") == 1){
cbRonkhi.setChecked(true);
}
if(obj.getInt("Wheezing") == 1){
cbWheezing.setChecked(true);
}
if(obj.getInt("Sputum") == 1){
cbSputum.setChecked(true);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
queue.add(req);
}
public void insertPengkajianAwal(int Riwayat_Cedera_Otak,String Lokasi_Sakit_Kepala,String Frek_Sakit_Kepala,
int Kesemutan,int Kebas,int Kelemahan,String Lokasi_Keluhan_Neurosensori,
String Stroke_Gejala_Sisa,String Tipe_Kejang,String Aura_Kejang,
String Frek_Kejang, String Cara_Kontrol_Kejang,String Status_Postikal,int Kehilangan_Penglihatan,
int Glaukoma,int Katarak,String Pemeriksaan_Mata_Terakhir,int Kehilangan_Pendengaran,String Pemeriksaan_Telinga_Terakhir,
int Perubahan_Penciuman,int Perubahan_Pengecap,int Epistasis,int Mental_Terorientasi,int Mental_Disorentasi,int Disorientasi_Orang,
int Disorientasi_Waktu,int Disorientasi_Tempat,int Mental_Kooperatif,int Mental_Delusi,int Mental_Menyerang,int Mental_Halusinasi,
String Afek_Mental,int Mengatuk,int Stupor,int Letargi,int Koma,int Memori_Saat_Ini,int Memori_Masa_Lalu,int Kacamata,int Lensa_Kontak,
int Alat_Bantu_Dengar,String Ukuran_Pupil,String Reflek_Cahaya,int Facial_Drop,int Refleks_Tendon_Dalam,int Paralisis_Parastesia,String Lokasi_Paralisis,
String Lokasi_Nyeri,String Intensitas_Nyeri,String Frek_Nyeri,String Kualitas_Nyeri,String Penjalaran_Nyeri,String Durasi_Nyeri,String Faktor_Pencetus_Nyeri,
String Cara_Memghilangkan_Nyeri,int Mengkerutkan_Muka,int Menjaga_Area_Sakit,int Penyempitan_Fokus,String Respons_Emosional,int Dispnea,int Batuk,int Bronkhitis,
int Asma,int Tuberkulosis,int Pneumonia,int Emfisema,int Terpajan_Udara_berbahaya,String Jumlah_Rokok_Harian,String Lama_Merokok,String Frek_Napas,String Kedalaman_Napas,
int Simetrisitas,int Penggunaan_Otot_Asesorius,int Napas_Cuping_Hidung,String Fremitus,int Versikuler,int Ronkhi,int Wheezing,int Sputum,String Karakteristik_Sputum,int id_pasien){
JSONObject objAdd = new JSONObject();
try {
JSONArray arrData = new JSONArray();
JSONObject objDetail = new JSONObject();
objDetail.put("Riwayat_Cedera_Otak",Riwayat_Cedera_Otak);
objDetail.put("Lokasi_Sakit_Kepala",Lokasi_Sakit_Kepala);
objDetail.put("Frek_Sakit_Kepala",Frek_Sakit_Kepala);
objDetail.put("Kesemutan",Kesemutan);
objDetail.put("Kebas",Kebas);
objDetail.put("Kelemahan",Kelemahan);
objDetail.put("Lokasi_Keluhan_Neurosensori",Lokasi_Keluhan_Neurosensori);
objDetail.put("Stroke_Gejala_Sisa",Stroke_Gejala_Sisa);
objDetail.put("Tipe_Kejang",Tipe_Kejang);
objDetail.put("Aura_Kejang",Aura_Kejang);
objDetail.put("Frek_Kejang",Frek_Kejang);
objDetail.put("Cara_Kontrol_Kejang",Cara_Kontrol_Kejang);
objDetail.put("Status_Postikal",Status_Postikal);
objDetail.put("Kehilangan_Penglihatan",Kehilangan_Penglihatan);
objDetail.put("Glaukoma",Glaukoma);
objDetail.put("Katarak",Katarak);
objDetail.put("Pemeriksaan_Mata_Terakhir",Pemeriksaan_Mata_Terakhir);
objDetail.put("Kehilangan_Pendengaran",Kehilangan_Pendengaran);
objDetail.put("Pemeriksaan_Telinga_Terakhir",Pemeriksaan_Telinga_Terakhir);
objDetail.put("Perubahan_Penciuman",Perubahan_Penciuman);
objDetail.put("Perubahan_Pengecap",Perubahan_Pengecap);
objDetail.put("Epistasis",Epistasis);
objDetail.put("Mental_Terorientasi",Mental_Terorientasi);
objDetail.put("Mental_Disorentasi",Mental_Disorentasi);
objDetail.put("Disorientasi_Orang",Disorientasi_Orang);
objDetail.put("Disorientasi_Waktu",Disorientasi_Waktu);
objDetail.put("Disorientasi_Tempat",Disorientasi_Tempat);
objDetail.put("Mental_Kooperatif",Mental_Kooperatif);
objDetail.put("Mental_Delusi",Mental_Delusi);
objDetail.put("Mental_Menyerang",Mental_Menyerang);
objDetail.put("Mental_Halusinasi",Mental_Halusinasi);
objDetail.put("Afek_Mental",Afek_Mental);
objDetail.put("Mengatuk",Mengatuk);
objDetail.put("Stupor",Stupor);
objDetail.put("Letargi",Letargi);
objDetail.put("Koma",Koma);
objDetail.put("Memori_Saat_Ini",Memori_Saat_Ini);
objDetail.put("Memori_Masa_Lalu",Memori_Masa_Lalu);
objDetail.put("Kacamata",Kacamata);
objDetail.put("Lensa_Kontak",Lensa_Kontak);
objDetail.put("Alat_Bantu_Dengar",Alat_Bantu_Dengar);
objDetail.put("Ukuran_Pupil",Ukuran_Pupil);
objDetail.put("Reflek_Cahaya",Reflek_Cahaya);
objDetail.put("Facial_Drop",Facial_Drop);
objDetail.put("Refleks_Tendon_Dalam",Refleks_Tendon_Dalam);
objDetail.put("Paralisis_Parastesia",Paralisis_Parastesia);
objDetail.put("Lokasi_Paralisis",Lokasi_Paralisis);
objDetail.put("Lokasi_Nyeri",Lokasi_Nyeri);
objDetail.put("Intensitas_Nyeri",Intensitas_Nyeri);
objDetail.put("Frek_Nyeri",Frek_Nyeri);
objDetail.put("Kualitas_Nyeri",Kualitas_Nyeri);
objDetail.put("Penjalaran_Nyeri",Penjalaran_Nyeri);
objDetail.put("Durasi_Nyeri",Durasi_Nyeri);
objDetail.put("Faktor_Pencetus_Nyeri",Faktor_Pencetus_Nyeri);
objDetail.put("Cara_Memghilangkan_Nyeri",Cara_Memghilangkan_Nyeri);
objDetail.put("Mengkerutkan_Muka",Mengkerutkan_Muka);
objDetail.put("Menjaga_Area_Sakit",Menjaga_Area_Sakit);
objDetail.put("Penyempitan_Fokus",Penyempitan_Fokus);
objDetail.put("Respons_Emosional",Respons_Emosional);
objDetail.put("Dispnea",Dispnea);
objDetail.put("Batuk",Batuk);
objDetail.put("Bronkhitis",Bronkhitis);
objDetail.put("Asma",Asma);
objDetail.put("Tuberkulosis",Tuberkulosis);
objDetail.put("Pneumonia",Pneumonia);
objDetail.put("Emfisema",Emfisema);
objDetail.put("Terpajan_Udara_berbahaya",Terpajan_Udara_berbahaya);
objDetail.put("Jumlah_Rokok_Harian",Jumlah_Rokok_Harian);
objDetail.put("Lama_Merokok",Lama_Merokok);
objDetail.put("Frek_Napas",Frek_Napas);
objDetail.put("Kedalaman_Napas",Kedalaman_Napas);
objDetail.put("Simetrisitas",Simetrisitas);
objDetail.put("Penggunaan_Otot_Asesorius",Penggunaan_Otot_Asesorius);
objDetail.put("Napas_Cuping_Hidung",Napas_Cuping_Hidung);
objDetail.put("Fremitus",Fremitus);
objDetail.put("Versikuler",Versikuler);
objDetail.put("Ronkhi",Ronkhi);
objDetail.put("Wheezing",Wheezing);
objDetail.put("Sputum",Sputum);
objDetail.put("Karakteristik_Sputum",Karakteristik_Sputum);
objDetail.put("id_pasien",id_pasien);
arrData.put(objDetail);
objAdd.put("data",arrData);
} catch (JSONException e1) {
e1.printStackTrace();
}
JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.POST, INSERT_PENGKAJIAN_AWAL_3_URL, objAdd,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
if(response.getString("status").equals("OK")) {
Intent i = new Intent(PengkajianAwalActivity3.this,PengkajianAwalActivity4.class);
i.putExtra("panduan","insert");
startActivity(i);
}
else{
Toast.makeText(PengkajianAwalActivity3.this, "Gagal", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e1) {
e1.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show();
}
}) ;
RequestQueue requestQueue = Volley.newRequestQueue(PengkajianAwalActivity3.this);
requestQueue.add(stringRequest);
}
@Override
public void onBackPressed() {
Intent x = getIntent();
if (x.getStringExtra("panduan").equals("view")) {
finish();
} else {
builder.setMessage("Harap selesaikan pengisian kajian awal");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
dialog = builder.show();
}
}
}
|
[
"[email protected]"
] | |
99d56f3d8262ac2df071252a03f68952d409dc0a
|
e977c424543422f49a25695665eb85bfc0700784
|
/benchmark/icse15/1539360/buggy-version/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
|
a30248491e5e9cf2239a9bed2639575700c2ad54
|
[] |
no_license
|
amir9979/pattern-detector-experiment
|
17fcb8934cef379fb96002450d11fac62e002dd3
|
db67691e536e1550245e76d7d1c8dced181df496
|
refs/heads/master
| 2022-02-18T10:24:32.235975 | 2019-09-13T15:42:55 | 2019-09-13T15:42:55 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 40,287 |
java
|
Merged /lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfig.java:r1539343
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.handler.admin;
import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Future;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.IOUtils;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.SyncStrategy;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.DocRouter;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.CloseHook;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrXMLCoresLocator;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.MergeIndexesCommand;
import org.apache.solr.update.SplitIndexCommand;
import org.apache.solr.update.UpdateLog;
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
import org.apache.solr.util.NumberUtils;
import org.apache.solr.util.RefCounted;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
/**
*
* @since solr 1.3
*/
public class CoreAdminHandler extends RequestHandlerBase {
protected static Logger log = LoggerFactory.getLogger(CoreAdminHandler.class);
protected final CoreContainer coreContainer;
public CoreAdminHandler() {
super();
// Unlike most request handlers, CoreContainer initialization
// should happen in the constructor...
this.coreContainer = null;
}
/**
* Overloaded ctor to inject CoreContainer into the handler.
*
* @param coreContainer Core Container of the solr webapp installed.
*/
public CoreAdminHandler(final CoreContainer coreContainer) {
this.coreContainer = coreContainer;
}
@Override
final public void init(NamedList args) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"CoreAdminHandler should not be configured in solrconf.xml\n" +
"it is a special Handler configured directly by the RequestDispatcher");
}
/**
* The instance of CoreContainer this handler handles. This should be the CoreContainer instance that created this
* handler.
*
* @return a CoreContainer instance
*/
public CoreContainer getCoreContainer() {
return this.coreContainer;
}
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
// Make sure the cores is enabled
CoreContainer cores = getCoreContainer();
if (cores == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Core container instance missing");
}
//boolean doPersist = false;
// Pick the action
SolrParams params = req.getParams();
CoreAdminAction action = CoreAdminAction.STATUS;
String a = params.get(CoreAdminParams.ACTION);
if (a != null) {
action = CoreAdminAction.get(a);
if (action == null) {
this.handleCustomAction(req, rsp);
}
}
if (action != null) {
switch (action) {
case CREATE: {
this.handleCreateAction(req, rsp);
break;
}
case RENAME: {
this.handleRenameAction(req, rsp);
break;
}
case UNLOAD: {
this.handleUnloadAction(req, rsp);
break;
}
case STATUS: {
this.handleStatusAction(req, rsp);
break;
}
case PERSIST: {
this.handlePersistAction(req, rsp);
break;
}
case RELOAD: {
this.handleReloadAction(req, rsp);
break;
}
case SWAP: {
this.handleSwapAction(req, rsp);
break;
}
case MERGEINDEXES: {
this.handleMergeAction(req, rsp);
break;
}
case SPLIT: {
this.handleSplitAction(req, rsp);
break;
}
case PREPRECOVERY: {
this.handleWaitForStateAction(req, rsp);
break;
}
case REQUESTRECOVERY: {
this.handleRequestRecoveryAction(req, rsp);
break;
}
case REQUESTSYNCSHARD: {
this.handleRequestSyncAction(req, rsp);
break;
}
// todo : Can this be done by the regular RecoveryStrategy route?
case REQUESTAPPLYUPDATES: {
this.handleRequestApplyUpdatesAction(req, rsp);
break;
}
default: {
this.handleCustomAction(req, rsp);
break;
}
case LOAD:
break;
}
}
rsp.setHttpCaching(false);
}
/**
* Handle the core admin SPLIT action.
*/
protected void handleSplitAction(SolrQueryRequest adminReq, SolrQueryResponse rsp) throws IOException {
SolrParams params = adminReq.getParams();
List<DocRouter.Range> ranges = null;
String[] pathsArr = params.getParams("path");
String rangesStr = params.get(CoreAdminParams.RANGES); // ranges=a-b,c-d,e-f
if (rangesStr != null) {
String[] rangesArr = rangesStr.split(",");
if (rangesArr.length == 0) {
throw new SolrException(ErrorCode.BAD_REQUEST, "There must be at least one range specified to split an index");
} else {
ranges = new ArrayList<DocRouter.Range>(rangesArr.length);
for (String r : rangesArr) {
try {
ranges.add(DocRouter.DEFAULT.fromString(r));
} catch (Exception e) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Exception parsing hexadecimal hash range: " + r, e);
}
}
}
}
String splitKey = params.get("split.key");
String[] newCoreNames = params.getParams("targetCore");
String cname = params.get(CoreAdminParams.CORE, "");
if ((pathsArr == null || pathsArr.length == 0) && (newCoreNames == null || newCoreNames.length == 0)) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Either path or targetCore param must be specified");
}
log.info("Invoked split action for core: " + cname);
SolrCore core = coreContainer.getCore(cname);
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
List<SolrCore> newCores = null;
try {
// TODO: allow use of rangesStr in the future
List<String> paths = null;
int partitions = pathsArr != null ? pathsArr.length : newCoreNames.length;
DocRouter router = null;
String routeFieldName = null;
if (coreContainer.isZooKeeperAware()) {
ClusterState clusterState = coreContainer.getZkController().getClusterState();
String collectionName = req.getCore().getCoreDescriptor().getCloudDescriptor().getCollectionName();
DocCollection collection = clusterState.getCollection(collectionName);
String sliceName = req.getCore().getCoreDescriptor().getCloudDescriptor().getShardId();
Slice slice = clusterState.getSlice(collectionName, sliceName);
router = collection.getRouter() != null ? collection.getRouter() : DocRouter.DEFAULT;
if (ranges == null) {
DocRouter.Range currentRange = slice.getRange();
ranges = currentRange != null ? router.partitionRange(partitions, currentRange) : null;
}
Map m = (Map) collection.get(DOC_ROUTER);
if (m != null) {
routeFieldName = (String) m.get("field");
}
}
if (pathsArr == null) {
newCores = new ArrayList<SolrCore>(partitions);
for (String newCoreName : newCoreNames) {
SolrCore newcore = coreContainer.getCore(newCoreName);
if (newcore != null) {
newCores.add(newcore);
} else {
throw new SolrException(ErrorCode.BAD_REQUEST, "Core with core name " + newCoreName + " expected but doesn't exist.");
}
}
} else {
paths = Arrays.asList(pathsArr);
}
SplitIndexCommand cmd = new SplitIndexCommand(req, paths, newCores, ranges, router, routeFieldName, splitKey);
core.getUpdateHandler().split(cmd);
// After the split has completed, someone (here?) should start the process of replaying the buffered updates.
} catch (Exception e) {
log.error("ERROR executing split:", e);
throw new RuntimeException(e);
} finally {
if (req != null) req.close();
if (core != null) core.close();
if (newCores != null) {
for (SolrCore newCore : newCores) {
newCore.close();
}
}
}
}
protected void handleMergeAction(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
SolrParams params = req.getParams();
String cname = params.required().get(CoreAdminParams.CORE);
SolrCore core = coreContainer.getCore(cname);
SolrQueryRequest wrappedReq = null;
List<SolrCore> sourceCores = Lists.newArrayList();
List<RefCounted<SolrIndexSearcher>> searchers = Lists.newArrayList();
// stores readers created from indexDir param values
List<DirectoryReader> readersToBeClosed = Lists.newArrayList();
List<Directory> dirsToBeReleased = Lists.newArrayList();
if (core != null) {
try {
String[] dirNames = params.getParams(CoreAdminParams.INDEX_DIR);
if (dirNames == null || dirNames.length == 0) {
String[] sources = params.getParams("srcCore");
if (sources == null || sources.length == 0)
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"At least one indexDir or srcCore must be specified");
for (int i = 0; i < sources.length; i++) {
String source = sources[i];
SolrCore srcCore = coreContainer.getCore(source);
if (srcCore == null)
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Core: " + source + " does not exist");
sourceCores.add(srcCore);
}
} else {
DirectoryFactory dirFactory = core.getDirectoryFactory();
for (int i = 0; i < dirNames.length; i++) {
Directory dir = dirFactory.get(dirNames[i], DirContext.DEFAULT, core.getSolrConfig().indexConfig.lockType);
dirsToBeReleased.add(dir);
// TODO: why doesn't this use the IR factory? what is going on here?
readersToBeClosed.add(DirectoryReader.open(dir));
}
}
List<DirectoryReader> readers = null;
if (readersToBeClosed.size() > 0) {
readers = readersToBeClosed;
} else {
readers = Lists.newArrayList();
for (SolrCore solrCore: sourceCores) {
// record the searchers so that we can decref
RefCounted<SolrIndexSearcher> searcher = solrCore.getSearcher();
searchers.add(searcher);
readers.add(searcher.get().getIndexReader());
}
}
UpdateRequestProcessorChain processorChain =
core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN));
wrappedReq = new LocalSolrQueryRequest(core, req.getParams());
UpdateRequestProcessor processor =
processorChain.createProcessor(wrappedReq, rsp);
processor.processMergeIndexes(new MergeIndexesCommand(readers, req));
} catch (Exception e) {
// log and rethrow so that if the finally fails we don't lose the original problem
log.error("ERROR executing merge:", e);
throw e;
} finally {
for (RefCounted<SolrIndexSearcher> searcher : searchers) {
if (searcher != null) searcher.decref();
}
for (SolrCore solrCore : sourceCores) {
if (solrCore != null) solrCore.close();
}
IOUtils.closeWhileHandlingException(readersToBeClosed);
for (Directory dir : dirsToBeReleased) {
DirectoryFactory dirFactory = core.getDirectoryFactory();
dirFactory.release(dir);
}
if (wrappedReq != null) wrappedReq.close();
core.close();
}
}
}
/**
* Handle Custom Action.
* <p/>
* This method could be overridden by derived classes to handle custom actions. <br> By default - this method throws a
* solr exception. Derived classes are free to write their derivation if necessary.
*/
protected void handleCustomAction(SolrQueryRequest req, SolrQueryResponse rsp) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unsupported operation: " +
req.getParams().get(CoreAdminParams.ACTION));
}
public static ImmutableMap<String, String> paramToProp = ImmutableMap.<String, String>builder()
.put(CoreAdminParams.CONFIG, CoreDescriptor.CORE_CONFIG)
.put(CoreAdminParams.SCHEMA, CoreDescriptor.CORE_SCHEMA)
.put(CoreAdminParams.DATA_DIR, CoreDescriptor.CORE_DATADIR)
.put(CoreAdminParams.ULOG_DIR, CoreDescriptor.CORE_ULOGDIR)
.put(CoreAdminParams.LOAD_ON_STARTUP, CoreDescriptor.CORE_LOADONSTARTUP)
.put(CoreAdminParams.TRANSIENT, CoreDescriptor.CORE_TRANSIENT)
.put(CoreAdminParams.SHARD, CoreDescriptor.CORE_SHARD)
.put(CoreAdminParams.COLLECTION, CoreDescriptor.CORE_COLLECTION)
.put(CoreAdminParams.ROLES, CoreDescriptor.CORE_ROLES)
.put(CoreAdminParams.CORE_NODE_NAME, CoreDescriptor.CORE_NODE_NAME)
.put(CoreAdminParams.SHARD_STATE, CloudDescriptor.SHARD_STATE)
.put(CoreAdminParams.SHARD_RANGE, CloudDescriptor.SHARD_RANGE)
.put(CoreAdminParams.SHARD_PARENT, CloudDescriptor.SHARD_PARENT)
.put(ZkStateReader.NUM_SHARDS_PROP, CloudDescriptor.NUM_SHARDS)
.build();
public static ImmutableMap<String, String> cloudParamToProp;
protected static CoreDescriptor buildCoreDescriptor(SolrParams params, CoreContainer container) {
String name = checkNotEmpty(params.get(CoreAdminParams.NAME),
"Missing parameter [" + CoreAdminParams.NAME + "]");
String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
if (StringUtils.isEmpty(instancedir)) {
instancedir = name; // will be resolved later against solr.home
//instancedir = container.getSolrHome() + "/" + name;
}
Properties coreProps = new Properties();
for (String param : paramToProp.keySet()) {
String value = params.get(param, null);
if (StringUtils.isNotEmpty(value)) {
coreProps.setProperty(paramToProp.get(param), value);
}
}
Iterator<String> paramsIt = params.getParameterNamesIterator();
while (paramsIt.hasNext()) {
String param = paramsIt.next();
if (!param.startsWith(CoreAdminParams.PROPERTY_PREFIX))
continue;
String propName = param.substring(CoreAdminParams.PROPERTY_PREFIX.length());
String propValue = params.get(param);
coreProps.setProperty(propName, propValue);
}
return new CoreDescriptor(container, name, instancedir, coreProps, params);
}
private static String checkNotEmpty(String value, String message) {
if (StringUtils.isEmpty(value))
throw new SolrException(ErrorCode.BAD_REQUEST, message);
return value;
}
/**
* Handle 'CREATE' action.
*
* @throws SolrException in case of a configuration error.
*/
protected void handleCreateAction(SolrQueryRequest req, SolrQueryResponse rsp) throws SolrException {
SolrParams params = req.getParams();
CoreDescriptor dcore = buildCoreDescriptor(params, coreContainer);
if (coreContainer.getAllCoreNames().contains(dcore.getName())) {
log.warn("Creating a core with existing name is not allowed");
throw new SolrException(ErrorCode.SERVER_ERROR,
"Core with name '" + dcore.getName() + "' already exists.");
}
// TODO this should be moved into CoreContainer, really...
try {
if (coreContainer.getZkController() != null) {
coreContainer.preRegisterInZk(dcore);
}
// make sure we can write out the descriptor first
coreContainer.getCoresLocator().create(coreContainer, dcore);
SolrCore core = coreContainer.create(dcore);
coreContainer.register(dcore.getName(), core, false);
if (coreContainer.getCoresLocator() instanceof SolrXMLCoresLocator) {
// hack - in this case we persist once more because a core create race might
// have dropped entries.
coreContainer.getCoresLocator().create(coreContainer);
}
rsp.add("core", core.getName());
}
catch (Exception ex) {
if (coreContainer.isZooKeeperAware() && dcore != null) {
try {
coreContainer.getZkController().unregister(dcore.getName(), dcore);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
SolrException.log(log, null, e);
} catch (KeeperException e) {
SolrException.log(log, null, e);
}
}
Throwable tc = ex;
Throwable c = null;
do {
tc = tc.getCause();
if (tc != null) {
c = tc;
}
} while (tc != null);
String rootMsg = "";
if (c != null) {
rootMsg = " Caused by: " + c.getMessage();
}
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Error CREATEing SolrCore '" + dcore.getName() + "': " +
ex.getMessage() + rootMsg, ex);
}
}
/**
* Handle "RENAME" Action
*/
protected void handleRenameAction(SolrQueryRequest req, SolrQueryResponse rsp) throws SolrException {
SolrParams params = req.getParams();
String name = params.get(CoreAdminParams.OTHER);
String cname = params.get(CoreAdminParams.CORE);
if (cname.equals(name)) return;
coreContainer.rename(cname, name);
}
/**
* Handle "ALIAS" action
*/
@Deprecated
protected void handleAliasAction(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String name = params.get(CoreAdminParams.OTHER);
String cname = params.get(CoreAdminParams.CORE);
boolean doPersist = false;
if (cname.equals(name)) return;
SolrCore core = coreContainer.getCore(cname);
if (core != null) {
doPersist = coreContainer.isPersistent();
coreContainer.register(name, core, false);
// no core.close() since each entry in the cores map should increase the ref
}
return;
}
/**
* Handle "UNLOAD" Action
*/
protected void handleUnloadAction(SolrQueryRequest req,
SolrQueryResponse rsp) throws SolrException {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
SolrCore core = coreContainer.remove(cname);
try {
if (core == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"No such core exists '" + cname + "'");
} else {
if (coreContainer.getZkController() != null) {
log.info("Unregistering core " + core.getName() + " from cloudstate.");
try {
coreContainer.getZkController().unregister(cname,
core.getCoreDescriptor());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Could not unregister core " + cname + " from cloudstate: "
+ e.getMessage(), e);
} catch (KeeperException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Could not unregister core " + cname + " from cloudstate: "
+ e.getMessage(), e);
}
}
if (params.getBool(CoreAdminParams.DELETE_INDEX, false)) {
try {
core.getDirectoryFactory().remove(core.getIndexDir());
} catch (Exception e) {
SolrException.log(log, "Failed to flag index dir for removal for core:"
+ core.getName() + " dir:" + core.getIndexDir());
}
}
}
if (params.getBool(CoreAdminParams.DELETE_DATA_DIR, false)) {
try {
core.getDirectoryFactory().remove(core.getDataDir(), true);
} catch (Exception e) {
SolrException.log(log, "Failed to flag data dir for removal for core:"
+ core.getName() + " dir:" + core.getDataDir());
}
}
if (params.getBool(CoreAdminParams.DELETE_INSTANCE_DIR, false)) {
core.addCloseHook(new CloseHook() {
@Override
public void preClose(SolrCore core) {}
@Override
public void postClose(SolrCore core) {
CoreDescriptor cd = core.getCoreDescriptor();
if (cd != null) {
File instanceDir = new File(cd.getInstanceDir());
try {
FileUtils.deleteDirectory(instanceDir);
} catch (IOException e) {
SolrException.log(log, "Failed to delete instance dir for core:"
+ core.getName() + " dir:" + instanceDir.getAbsolutePath());
}
}
}
});
}
} finally {
// it's important that we try and cancel recovery
// before we close here - else we might close the
// core *in* recovery and end up locked in recovery
// waiting to for recovery to be cancelled
if (core != null) {
if (coreContainer.getZkController() != null) {
core.getSolrCoreState().cancelRecovery();
}
core.close();
}
}
}
/**
* Handle "STATUS" action
*/
protected void handleStatusAction(SolrQueryRequest req, SolrQueryResponse rsp)
throws SolrException {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
String indexInfo = params.get(CoreAdminParams.INDEX_INFO);
boolean isIndexInfoNeeded = Boolean.parseBoolean(null == indexInfo ? "true" : indexInfo);
boolean doPersist = false;
NamedList<Object> status = new SimpleOrderedMap<Object>();
Map<String,Exception> allFailures = coreContainer.getCoreInitFailures();
try {
if (cname == null) {
rsp.add("defaultCoreName", coreContainer.getDefaultCoreName());
for (String name : coreContainer.getAllCoreNames()) {
status.add(name, getCoreStatus(coreContainer, name, isIndexInfoNeeded));
}
rsp.add("initFailures", allFailures);
} else {
Map failures = allFailures.containsKey(cname)
? Collections.singletonMap(cname, allFailures.get(cname))
: Collections.emptyMap();
rsp.add("initFailures", failures);
status.add(cname, getCoreStatus(coreContainer, cname, isIndexInfoNeeded));
}
rsp.add("status", status);
} catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Error handling 'status' action ", ex);
}
}
/**
* Handler "PERSIST" action
*/
protected void handlePersistAction(SolrQueryRequest req, SolrQueryResponse rsp)
throws SolrException {
rsp.add("message", "The PERSIST action has been deprecated");
}
/**
* Handler "RELOAD" action
*/
protected void handleReloadAction(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
try {
coreContainer.reload(cname);
} catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error handling 'reload' action", ex);
}
}
/**
* Handle "SWAP" action
*/
protected void handleSwapAction(SolrQueryRequest req, SolrQueryResponse rsp) {
final SolrParams params = req.getParams();
final SolrParams required = params.required();
final String cname = params.get(CoreAdminParams.CORE);
String other = required.get(CoreAdminParams.OTHER);
coreContainer.swap(cname, other);
}
protected void handleRequestRecoveryAction(SolrQueryRequest req,
SolrQueryResponse rsp) throws IOException {
final SolrParams params = req.getParams();
log.info("It has been requested that we recover");
Thread thread = new Thread() {
@Override
public void run() {
String cname = params.get(CoreAdminParams.CORE);
if (cname == null) {
cname = "";
}
SolrCore core = null;
try {
core = coreContainer.getCore(cname);
if (core != null) {
// try to publish as recovering right away
try {
coreContainer.getZkController().publish(core.getCoreDescriptor(), ZkStateReader.RECOVERING);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
SolrException.log(log, "", e);
} catch (Throwable t) {
SolrException.log(log, "", t);
}
core.getUpdateHandler().getSolrCoreState().doRecovery(coreContainer, core.getCoreDescriptor());
} else {
SolrException.log(log, "Cound not find core to call recovery:" + cname);
}
} finally {
// no recoveryStrat close for now
if (core != null) {
core.close();
}
}
}
};
thread.start();
}
protected void handleRequestSyncAction(SolrQueryRequest req,
SolrQueryResponse rsp) throws IOException {
final SolrParams params = req.getParams();
log.info("I have been requested to sync up my shard");
ZkController zkController = coreContainer.getZkController();
if (zkController == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Only valid for SolrCloud");
}
String cname = params.get(CoreAdminParams.CORE);
if (cname == null) {
throw new IllegalArgumentException(CoreAdminParams.CORE + " is required");
}
SolrCore core = null;
SyncStrategy syncStrategy = null;
try {
core = coreContainer.getCore(cname);
if (core != null) {
syncStrategy = new SyncStrategy();
Map<String,Object> props = new HashMap<String,Object>();
props.put(ZkStateReader.BASE_URL_PROP, zkController.getBaseUrl());
props.put(ZkStateReader.CORE_NAME_PROP, cname);
props.put(ZkStateReader.NODE_NAME_PROP, zkController.getNodeName());
boolean success = syncStrategy.sync(zkController, core, new ZkNodeProps(props));
// solrcloud_debug
if (log.isDebugEnabled()) {
try {
RefCounted<SolrIndexSearcher> searchHolder = core
.getNewestSearcher(false);
SolrIndexSearcher searcher = searchHolder.get();
try {
log.debug(core.getCoreDescriptor().getCoreContainer()
.getZkController().getNodeName()
+ " synched "
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits);
} finally {
searchHolder.decref();
}
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
if (!success) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Sync Failed");
}
} else {
SolrException.log(log, "Cound not find core to call sync:" + cname);
}
} finally {
// no recoveryStrat close for now
if (core != null) {
core.close();
}
if (syncStrategy != null) {
syncStrategy.close();
}
}
}
protected void handleWaitForStateAction(SolrQueryRequest req,
SolrQueryResponse rsp) throws IOException, InterruptedException, KeeperException {
final SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
if (cname == null) {
cname = "";
}
String nodeName = params.get("nodeName");
String coreNodeName = params.get("coreNodeName");
String waitForState = params.get("state");
Boolean checkLive = params.getBool("checkLive");
Boolean onlyIfLeader = params.getBool("onlyIfLeader");
log.info("Going to wait for coreNodeName: " + coreNodeName + ", state: " + waitForState
+ ", checkLive: " + checkLive + ", onlyIfLeader: " + onlyIfLeader);
String state = null;
boolean live = false;
int retry = 0;
while (true) {
SolrCore core = null;
try {
core = coreContainer.getCore(cname);
if (core == null && retry == 30) {
throw new SolrException(ErrorCode.BAD_REQUEST, "core not found:"
+ cname);
}
if (core != null) {
if (onlyIfLeader != null && onlyIfLeader) {
if (!core.getCoreDescriptor().getCloudDescriptor().isLeader()) {
throw new SolrException(ErrorCode.BAD_REQUEST, "We are not the leader");
}
}
// wait until we are sure the recovering node is ready
// to accept updates
CloudDescriptor cloudDescriptor = core.getCoreDescriptor()
.getCloudDescriptor();
if (retry == 15 || retry == 60) {
// force a cluster state update
coreContainer.getZkController().getZkStateReader().updateClusterState(true);
}
ClusterState clusterState = coreContainer.getZkController()
.getClusterState();
String collection = cloudDescriptor.getCollectionName();
Slice slice = clusterState.getSlice(collection,
cloudDescriptor.getShardId());
if (slice != null) {
ZkNodeProps nodeProps = slice.getReplicasMap().get(coreNodeName);
if (nodeProps != null) {
state = nodeProps.getStr(ZkStateReader.STATE_PROP);
live = clusterState.liveNodesContain(nodeName);
if (nodeProps != null && state.equals(waitForState)) {
if (checkLive == null) {
break;
} else if (checkLive && live) {
break;
} else if (!checkLive && !live) {
break;
}
}
}
}
}
if (retry++ == 120) {
throw new SolrException(ErrorCode.BAD_REQUEST,
"I was asked to wait on state " + waitForState + " for "
+ nodeName
+ " but I still do not see the requested state. I see state: "
+ state + " live:" + live);
}
if (coreContainer.isShutDown()) {
throw new SolrException(ErrorCode.BAD_REQUEST,
"Solr is shutting down");
}
// solrcloud_debug
if (log.isDebugEnabled()) {
try {
;
LocalSolrQueryRequest r = new LocalSolrQueryRequest(core,
new ModifiableSolrParams());
CommitUpdateCommand commitCmd = new CommitUpdateCommand(r, false);
commitCmd.softCommit = true;
core.getUpdateHandler().commit(commitCmd);
RefCounted<SolrIndexSearcher> searchHolder = core
.getNewestSearcher(false);
SolrIndexSearcher searcher = searchHolder.get();
try {
log.debug(core.getCoreDescriptor().getCoreContainer()
.getZkController().getNodeName()
+ " to replicate "
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits
+ " gen:"
+ core.getDeletionPolicy().getLatestCommit().getGeneration()
+ " data:" + core.getDataDir());
} finally {
searchHolder.decref();
}
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
} finally {
if (core != null) {
core.close();
}
}
Thread.sleep(1000);
}
log.info("Waited coreNodeName: " + coreNodeName + ", state: " + waitForState
+ ", checkLive: " + checkLive + ", onlyIfLeader: " + onlyIfLeader + " for: " + retry + " seconds.");
}
private void handleRequestApplyUpdatesAction(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.NAME, "");
SolrCore core = coreContainer.getCore(cname);
try {
UpdateLog updateLog = core.getUpdateHandler().getUpdateLog();
if (updateLog.getState() != UpdateLog.State.BUFFERING) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Core " + cname + " not in buffering state");
}
Future<UpdateLog.RecoveryInfo> future = updateLog.applyBufferedUpdates();
if (future == null) {
log.info("No buffered updates available. core=" + cname);
rsp.add("core", cname);
rsp.add("status", "EMPTY_BUFFER");
return;
}
UpdateLog.RecoveryInfo report = future.get();
if (report.failed) {
SolrException.log(log, "Replay failed");
throw new SolrException(ErrorCode.SERVER_ERROR, "Replay failed");
}
coreContainer.getZkController().publish(core.getCoreDescriptor(), ZkStateReader.ACTIVE);
rsp.add("core", cname);
rsp.add("status", "BUFFER_APPLIED");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.warn("Recovery was interrupted", e);
} catch (Throwable e) {
if (e instanceof SolrException)
throw (SolrException)e;
else
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not apply buffered updates", e);
} finally {
if (req != null) req.close();
if (core != null)
core.close();
}
}
/**
* Returns the core status for a particular core.
* @param cores - the enclosing core container
* @param cname - the core to return
* @param isIndexInfoNeeded - add what may be expensive index information. NOT returned if the core is not loaded
* @return - a named list of key/value pairs from the core.
* @throws IOException - LukeRequestHandler can throw an I/O exception
*/
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname, boolean isIndexInfoNeeded) throws IOException {
NamedList<Object> info = new SimpleOrderedMap<Object>();
if (!cores.isLoaded(cname)) { // Lazily-loaded core, fill in what we can.
// It would be a real mistake to load the cores just to get the status
CoreDescriptor desc = cores.getUnloadedCoreDescriptor(cname);
if (desc != null) {
info.add("name", desc.getName());
info.add("isDefaultCore", desc.getName().equals(cores.getDefaultCoreName()));
info.add("instanceDir", desc.getInstanceDir());
// None of the following are guaranteed to be present in a not-yet-loaded core.
String tmp = desc.getDataDir();
if (StringUtils.isNotBlank(tmp)) info.add("dataDir", tmp);
tmp = desc.getConfigName();
if (StringUtils.isNotBlank(tmp)) info.add("config", tmp);
tmp = desc.getSchemaName();
if (StringUtils.isNotBlank(tmp)) info.add("schema", tmp);
info.add("isLoaded", "false");
}
} else {
SolrCore core = cores.getCore(cname);
if (core != null) {
try {
info.add("name", core.getName());
info.add("isDefaultCore", core.getName().equals(cores.getDefaultCoreName()));
info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
info.add("dataDir", normalizePath(core.getDataDir()));
info.add("config", core.getConfigResource());
info.add("schema", core.getSchemaResource());
info.add("startTime", new Date(core.getStartTime()));
info.add("uptime", System.currentTimeMillis() - core.getStartTime());
if (isIndexInfoNeeded) {
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
SimpleOrderedMap<Object> indexInfo = LukeRequestHandler.getIndexInfo(searcher.get().getIndexReader());
long size = getIndexSize(core);
indexInfo.add("sizeInBytes", size);
indexInfo.add("size", NumberUtils.readableSize(size));
info.add("index", indexInfo);
} finally {
searcher.decref();
}
}
} finally {
core.close();
}
}
}
return info;
}
private long getIndexSize(SolrCore core) {
Directory dir;
long size = 0;
try {
dir = core.getDirectoryFactory().get(core.getIndexDir(), DirContext.DEFAULT, core.getSolrConfig().indexConfig.lockType);
try {
size = DirectoryFactory.sizeOfDirectory(dir);
} finally {
core.getDirectoryFactory().release(dir);
}
} catch (IOException e) {
SolrException.log(log, "IO error while trying to get the size of the Directory", e);
}
return size;
}
protected static String normalizePath(String path) {
if (path == null)
return null;
path = path.replace('/', File.separatorChar);
path = path.replace('\\', File.separatorChar);
return path;
}
public static ModifiableSolrParams params(String... params) {
ModifiableSolrParams msp = new ModifiableSolrParams();
for (int i=0; i<params.length; i+=2) {
msp.add(params[i], params[i+1]);
}
return msp;
}
//////////////////////// SolrInfoMBeans methods //////////////////////
@Override
public String getDescription() {
return "Manage Multiple Solr Cores";
}
@Override
public String getSource() {
return "$URL$";
}
}
|
[
"[email protected]"
] | |
85a2b5aec351df61ebd4e6a66d4df8b5be70b4fd
|
874a4b7f45a1a8ca6b25e06a35a67eb2bc8c8a75
|
/src/main/java/com/li/experience/common/aop/WebLogAspect.java
|
f1c5aa66ff3d7635af48a32b74d8cf41ea5fb052
|
[] |
no_license
|
liw66/Experience
|
71474c7b202b34ebad08481f1931108ef1680bed
|
afe7eeed3c4e723d2d891cb10c8739f13ff9bbe8
|
refs/heads/master
| 2022-10-24T14:26:27.339902 | 2020-02-06T09:20:30 | 2020-02-06T09:20:30 | 215,746,846 | 0 | 0 | null | 2022-09-01T23:14:18 | 2019-10-17T08:54:25 |
Java
|
UTF-8
|
Java
| false | false | 2,292 |
java
|
package com.li.experience.common.aop;
import com.alibaba.druid.support.json.JSONUtils;
import com.li.experience.common.utils.HttpUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
/**
* @program: experience
* @description: WEB日志打印
* @author: Liwei
* @create: 2019-08-13 09:58
**/
@Aspect
@Component
public class WebLogAspect {
private final static Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
@Pointcut("execution( * com.li.experience..controller.*.*(..))")
public void logPointCut() {
}
@Before("logPointCut()")
public void doBefore(JoinPoint point) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
MethodSignature signature = (MethodSignature) point.getSignature();
logger.info("请求地址:" + request.getRequestURL().toString());
logger.info("HTTP METHOD:" + request.getMethod());
logger.info("CLASS METHOD:" + signature.getDeclaringTypeName() + "." + signature.getName());
logger.info("参数:" + JSONUtils.toJSONString(HttpUtils.getAllRequestParam(request)));
}
@Around("logPointCut()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object obj = joinPoint.proceed();
long time = System.currentTimeMillis() - startTime;
logger.info("耗时:" + time);
return obj;
}
@AfterReturning(returning = "obj",pointcut = "logPointCut()")
public void doAfterReturning(Object obj) {
logger.info("返回值:" + obj);
}
}
|
[
"[email protected]"
] | |
ce2c5a898812e0fd4ec71d9aa24fb574d1d2fca7
|
bb4563af60c9fb77dfc591e9f989acdc98a8a364
|
/test/model/PersonTest.java
|
7840af83cffd13d12d7722ec1acbd3b108b4b0f8
|
[] |
no_license
|
PhilippFuraev/FamilyTree
|
59e6a491f9b5363ec84b9d144d014e404d634158
|
fc91c405d477fbbd9b0bb22ee2381a71074e3f5d
|
refs/heads/master
| 2020-03-14T23:07:59.970519 | 2018-05-02T10:52:49 | 2018-05-02T10:52:49 | 131,837,683 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 4,107 |
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 model;
import java.util.LinkedList;
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 furae_000
*/
public class PersonTest {
Person p;
public PersonTest() {
LinkedList<String> parents = new LinkedList();
parents.add("Father");
parents.add("Mother");
LinkedList<String> children = new LinkedList();
children.add("Vasya");
String spouse = "Yulya";
p = new Person("Vitya", 33, children, parents, spouse, 2);
}
/**
* Test of getLevel method, of class Person.
*/
@Test
public void testGetLevel() {
System.out.println("getLevel");
Person instance = this.p;
int expResult = 2;
int result = instance.getLevel();
assertEquals(expResult, result);
}
/**
* Test of getName method, of class Person.
*/
@Test
public void testGetName() {
System.out.println("getName");
Person instance = p;
String expResult = "Vitya";
String result = instance.getName();
assertEquals(expResult, result);
}
/**
* Test of getSpouse method, of class Person.
*/
@Test
public void testGetSpouse() {
System.out.println("getSpouse");
Person instance = p;
String expResult = "Yulya";
String result = instance.getSpouse();
assertEquals(expResult, result);
}
/**
* Test of setSpouse method, of class Person.
*/
@Test
public void testSetSpouse() {
System.out.println("setSpouse");
String testSpouse = "Petya";
Person instance = p;
instance.setSpouse(testSpouse);
String result = testSpouse;
assertEquals(testSpouse, instance.getSpouse());
}
/**
* Test of addChild method, of class Person.
*/
@Test
public void testAddChild() {
System.out.println("addChild");
String child = "Lesha";
Person instance = p;
instance.addChild(child);
assertEquals(child, instance.getChildren().get(1));
}
/**
* Test of removeChild method, of class Person.
*/
@Test
public void testRemoveChild() {
System.out.println("removeChild");
String child = "Vasya";
Person instance = p;
String result = null;
instance.removeChild(child);
if (instance.getChildren().size() == 0) {
assertNull(result);
} else {
fail("Remove Child test Failed");
}
}
@Test
public void testRemoveParent() {
System.out.println("removeParent");
String parent = "Mother";
Person instance = p;
String result = null;
instance.removeParent(parent);
if (instance.getChildren().size() == 1) {
assertNull(result);
} else {
fail("Remove Child test Failed");
}
}
/**
* Test of getChildren method, of class Person.
*/
@Test
public void testGetChildren() {
System.out.println("getChildren");
LinkedList<String> expResult = new LinkedList();
expResult.add("Vasya");
Person instance = p;
LinkedList result = instance.getChildren();
assertEquals(expResult, result);
}
/**
* Test of getParents method, of class Person.
*/
@Test
public void testGetParents() {
System.out.println("getParents");
LinkedList<String> expResult = new LinkedList();
expResult.add("Father");
expResult.add("Mother");
Person instance = p;
LinkedList result = instance.getParents();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
}
}
|
[
"[email protected]"
] | |
96639d2efa898798e207210eaa961c522896ec6e
|
c2e669e0aa092562ef240f28e9411f34a7690f92
|
/backend/src/main/java/com/wz/GubeeTecnologia/resources/ProductResource.java
|
2e3fe870a59ed299202527bedf9c0c1f67d8f93d
|
[] |
no_license
|
WelingtonZanon/GubeeTecnologia
|
705060752cc9250011d53be174e4056174a32951
|
cb924721d424cdc3631906a85b6a807bca2d9efd
|
refs/heads/main
| 2023-08-11T09:34:09.210335 | 2021-10-06T07:37:35 | 2021-10-06T07:37:35 | 412,488,328 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,406 |
java
|
package com.wz.GubeeTecnologia.resources;
import java.net.URI;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import com.wz.GubeeTecnologia.dto.ProductDTO;
import com.wz.GubeeTecnologia.services.ProductService;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/products")
public class ProductResource {
private final ProductService service;
@GetMapping
public ResponseEntity<Page<ProductDTO>> findAll(Pageable pageable,
@RequestParam(value = "stackId", defaultValue = "0") Long stackId,
@RequestParam(value = "targetMarketId", defaultValue = "0") Long targetMarketId,
@RequestParam(value = "name", defaultValue = "") String name
) {
Page<ProductDTO> page = service.findAll(pageable, stackId,targetMarketId, name.trim());
return ResponseEntity.ok().body(page);
}
@GetMapping(value = "/{id}")
public ResponseEntity<ProductDTO> findById(@PathVariable Long id) {
ProductDTO dto = service.findByID(id);
return ResponseEntity.ok().body(dto);
}
@PostMapping
public ResponseEntity<ProductDTO> insert(@RequestBody ProductDTO dto) {
dto = service.insert(dto);
URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(dto.getId()).toUri();
return ResponseEntity.created(uri).body(dto);
}
@PutMapping(value = "/{id}")
public ResponseEntity<ProductDTO> update(@PathVariable Long id, @RequestBody ProductDTO dto) {
dto = service.update(id, dto);
return ResponseEntity.ok().body(dto);
}
@DeleteMapping(value = "/{id}")
public ResponseEntity<ProductDTO> delete(@PathVariable Long id) {
service.delete(id);
return ResponseEntity.noContent().build();
}
}
|
[
"[email protected]"
] | |
4763303241cba17549107a205d3919f891467fb7
|
227c895b7cb0bf7e9f2e4bdc190460b191e8daef
|
/src/com/sourceit/homework/andrey01/tasc11/Encryption.java
|
9b70a3daf238e3be34887255edbb402c254958b0
|
[] |
no_license
|
Andrey3007/homeTask
|
2d191935886d9efd55c77b53f9e100221e2ec1b4
|
f248dc62a60f804c56408d3a2de14b73de193d60
|
refs/heads/master
| 2020-06-09T05:31:39.119349 | 2015-03-28T08:13:48 | 2015-03-28T08:13:48 | 30,258,200 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,427 |
java
|
package com.sourceit.homework.andrey01.tasc11;
import static java.lang.Integer.toUnsignedString;
/**
* Created by Андрей on 11.02.2015.
* • Создать класс, который будет хранить в одной целочисленной переменной несколько значений меньшей длины.
* Например, возраст, вес, рост и год рождения. Добавить методы получения и добавления параметров отдельно.
*/
public class Encryption {
long storeg;
public void setAge(int i){
setParam(i, 48);
}
public int getAge(){
return getParam(48);
}
public void setParam(int newParam, int shift){
long mask= 0xffffL<<shift;
mask= ~mask;
storeg=storeg&mask;
long l=((long)newParam)<<shift;
storeg= storeg|l;
}
public int getParam(int shift){
long i= (storeg>>>shift);
int d= (int)(i & 0xFFFF);
return d;
}
public void setWeigh(int i){
setParam(i, 32);
}
public int getWeight(){
return getParam(32);
}
public void setHigh(int i){
setParam(i, 16);
}
public int getHigh(){
return getParam(16);
}
public void setYear(int i){
setParam(i, 0);
}
public int getYear(){
return getParam(0);
}
}
|
[
"[email protected]"
] | |
a6bba4ae3494ec469cc758cccb31a8c6ca24a69b
|
bb544736bc4267412bf7e774dd1601371fb0b91d
|
/kie-server-parent/kie-server-api/src/main/java/org/kie/server/api/model/Severity.java
|
365e71cf0f39c7997cfc10b516b7ae3818d928db
|
[
"Apache-2.0"
] |
permissive
|
domhanak/droolsjbpm-integration
|
b807ded5c600e0a335bbd340ede855ca5911ff33
|
62ca32b448401fc3b287bd28b99531540a85782f
|
refs/heads/master
| 2022-04-30T08:11:52.809050 | 2019-04-03T11:54:50 | 2019-04-03T11:54:50 | 88,586,866 | 1 | 0 |
Apache-2.0
| 2021-05-05T11:43:34 | 2017-04-18T05:50:01 |
Java
|
UTF-8
|
Java
| false | false | 662 |
java
|
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kie.server.api.model;
public enum Severity {
INFO, WARN, ERROR
}
|
[
"[email protected]"
] | |
80f8a66b72019a13bbe24c0c52a2110f8cf836b4
|
815107352520ed77e7d5da88e1c8c37fe20c7a00
|
/src/com/intuitive/yummy/models/OrderItem.java
|
342be088b101f9cf6b4085d56531f70a81dd1d6e
|
[] |
no_license
|
Intuitive/YummyAndroid
|
a2d58a30939290610b4d914cb6ee76213ac95255
|
1f4d6eb42f972e9ebe7790c9f29dc7749033ce4e
|
refs/heads/master
| 2021-03-12T22:55:03.332387 | 2013-06-02T14:43:40 | 2013-06-02T14:43:40 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 4,406 |
java
|
package com.intuitive.yummy.models;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
//includes menu item information, includes their ingredients' information
public class OrderItem implements Model {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final String modelName = "OrderItem";
private Integer id;
private Integer menuItemId;
private String name;
private Double price;
private String specialInstructions;
private Integer quantity;
@Override
public Integer getId() {
return id;
}
public Integer getMenuItemId() {
return menuItemId;
}
public String getName() {
return name;
}
public Double getPrice() {
return price;
}
public String getSpecialInstructions() {
return specialInstructions;
}
public Integer getQuantity() {
return quantity;
}
public void setId(Integer id) {
this.id = id;
}
public void setMenuItemId(Integer menuItemId) {
this.menuItemId = menuItemId;
}
public void setName(String name) {
this.name = name;
}
public void setPrice(Double price) {
this.price = price;
}
public void setSpecialInstructions(String specialInstructions) {
this.specialInstructions = specialInstructions;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public OrderItem() {};
public OrderItem(Integer id, Integer menuItemId, String name,
Double price, String specialInstructions, Integer quantity) {
this.id = id;
this.menuItemId = menuItemId;
this.name = name;
this.price = price;
this.specialInstructions = specialInstructions;
this.quantity = quantity;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
if (id == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeInt(id);
}
if (menuItemId == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeInt(menuItemId);
}
if(name == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeString(name);
}
if(price == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeDouble(price);
}
if(specialInstructions == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeString(specialInstructions);
}
if (quantity == null)
out.writeInt(0);
else
{
out.writeInt(1);
out.writeInt(quantity);
}
}
@Override
public Model createFromParcel(Parcel parcel) {
return new OrderItem(parcel);
}
public OrderItem(Parcel parcel) {
if(parcel.readInt() == 1)
id = parcel.readInt();
if(parcel.readInt() == 1)
menuItemId = parcel.readInt();
if(parcel.readInt() == 1)
name = parcel.readString();
if(parcel.readInt() == 1)
price = parcel.readDouble();
if(parcel.readInt() == 1)
specialInstructions = parcel.readString();
if(parcel.readInt() == 1)
quantity = parcel.readInt();
}
public static final Parcelable.Creator<OrderItem> CREATOR = new Creator<OrderItem> () {
public OrderItem createFromParcel(Parcel source) {
return new OrderItem(source);
}
public OrderItem[] newArray(int size) {
return new OrderItem[size];
}
};
@Override
public Model[] newArray(int size) {
return null;
}
@Override
public void parseJson(JSONObject json) {
try {
id = json.getInt("id");
menuItemId = json.getInt("menu_item_id");
name = json.getString("name");
price = json.getDouble("price");
specialInstructions = json.getString("special_instructions");
quantity = json.getInt("quantity");
} catch (JSONException e) {
Log.e("Yummy", "JSON object did not map to OrderItem object.");
e.printStackTrace();
}
}
@Override
public String getModelName() {
return modelName;
}
@Override
public HashMap<String, String> getPostData() {
HashMap<String, String> postData = new HashMap<String, String>();
if(id != null) postData.put("id", String.valueOf(id));
if(menuItemId != null) postData.put("menu_item_id", String.valueOf(menuItemId));
if(name != null) postData.put("name", name);
if(price != null) postData.put("price", String.valueOf(price));
if(specialInstructions!= null) postData.put("special_instructions", specialInstructions);
if(quantity != null) postData.put("quantity", String.valueOf(quantity));
return postData;
}
}
|
[
"[email protected]"
] | |
e027fa4abe574509b6bf93177035a5c275bf303f
|
2a36ec5de99236c5604b5ebe98862d3764647deb
|
/SeguroDeVida.java
|
50c63f1c385aa6737a5111fa231460f419990eb9
|
[] |
no_license
|
erikkaueusp/Alura-java
|
a24a628d4ee579c43e915560edbc77fe395c26c9
|
b8164947aa02d00e6dc76e87a4296d17a7068fba
|
refs/heads/main
| 2023-03-24T06:37:14.999270 | 2021-03-19T19:42:07 | 2021-03-19T19:42:07 | 349,188,701 | 0 | 0 | null | 2021-03-18T19:50:32 | 2021-03-18T19:06:33 | null |
UTF-8
|
Java
| false | false | 151 |
java
|
package com.company;
public class SeguroDeVida implements Tributavel{
@Override
public double getValorImposto() {
return 42;
}
}
|
[
"[email protected]"
] | |
ba81ab2a50e2fb0db5bc538d2836720f0307c9eb
|
36211cbfdceca0cf40f1774037556d032bc759a2
|
/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/codesystems/SystemVersionProcessingModeEnumFactory.java
|
c519aa07b16a9a75c2c14a271bd799f57d0daad9
|
[
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] |
permissive
|
VincentZhangy/hapi-fhir
|
284e1e16873f7f3e55f004d156f0329d9ac8f9cf
|
2fa7aedf63e0e071e1ecbc39455d8dc1a2789dc0
|
refs/heads/master
| 2021-01-22T05:46:52.270334 | 2017-05-25T23:47:09 | 2017-05-25T23:47:09 | 92,494,591 | 1 | 0 | null | 2017-05-26T09:24:58 | 2017-05-26T09:24:58 | null |
UTF-8
|
Java
| false | false | 2,835 |
java
|
package org.hl7.fhir.dstu3.model.codesystems;
/*
Copyright (c) 2011+, HL7, Inc.
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 HL7 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.
*/
// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
import org.hl7.fhir.dstu3.model.EnumFactory;
public class SystemVersionProcessingModeEnumFactory implements EnumFactory<SystemVersionProcessingMode> {
public SystemVersionProcessingMode fromCode(String codeString) throws IllegalArgumentException {
if (codeString == null || "".equals(codeString))
return null;
if ("default".equals(codeString))
return SystemVersionProcessingMode.DEFAULT;
if ("check".equals(codeString))
return SystemVersionProcessingMode.CHECK;
if ("override".equals(codeString))
return SystemVersionProcessingMode.OVERRIDE;
throw new IllegalArgumentException("Unknown SystemVersionProcessingMode code '"+codeString+"'");
}
public String toCode(SystemVersionProcessingMode code) {
if (code == SystemVersionProcessingMode.DEFAULT)
return "default";
if (code == SystemVersionProcessingMode.CHECK)
return "check";
if (code == SystemVersionProcessingMode.OVERRIDE)
return "override";
return "?";
}
public String toSystem(SystemVersionProcessingMode code) {
return code.getSystem();
}
}
|
[
"[email protected]"
] | |
7bcd7f5bc7d46575073e199e2b11591179311231
|
f136e7ecff66580c6bb361733f6aa63dd9a83998
|
/eml-api/src/main/jaxb/au/org/ecoinformatics/eml/jaxb/eml/LengthUnits.java
|
aaa01b4eb56051d57081aeffb9cd53aaddb728ff
|
[] |
no_license
|
francis-vaughan/ecoinf-dataone
|
cc59cfbe2e4a27661ed4929d9b9803ea191d94af
|
0648bf163f2deae56a7037cdb2c2f1fff9d10fc3
|
refs/heads/master
| 2021-01-12T22:22:55.568720 | 2015-11-27T01:25:59 | 2015-11-27T01:25:59 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,644 |
java
|
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.02.19 at 11:10:18 AM CST
//
package au.org.ecoinformatics.eml.jaxb.eml;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for lengthUnits.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="lengthUnits">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="meter"/>
* <enumeration value="nanometer"/>
* <enumeration value="micrometer"/>
* <enumeration value="micron"/>
* <enumeration value="millimeter"/>
* <enumeration value="centimeter"/>
* <enumeration value="decimeter"/>
* <enumeration value="dekameter"/>
* <enumeration value="hectometer"/>
* <enumeration value="kilometer"/>
* <enumeration value="megameter"/>
* <enumeration value="angstrom"/>
* <enumeration value="inch"/>
* <enumeration value="Foot_US"/>
* <enumeration value="foot"/>
* <enumeration value="Foot_Gold_Coast"/>
* <enumeration value="fathom"/>
* <enumeration value="nauticalMile"/>
* <enumeration value="yard"/>
* <enumeration value="Yard_Indian"/>
* <enumeration value="Link_Clarke"/>
* <enumeration value="Yard_Sears"/>
* <enumeration value="mile"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "lengthUnits", namespace = "eml://ecoinformatics.org/spatialReference-2.1.1")
@XmlEnum
public enum LengthUnits {
@XmlEnumValue("meter")
METER("meter"),
@XmlEnumValue("nanometer")
NANOMETER("nanometer"),
@XmlEnumValue("micrometer")
MICROMETER("micrometer"),
@XmlEnumValue("micron")
MICRON("micron"),
@XmlEnumValue("millimeter")
MILLIMETER("millimeter"),
@XmlEnumValue("centimeter")
CENTIMETER("centimeter"),
@XmlEnumValue("decimeter")
DECIMETER("decimeter"),
@XmlEnumValue("dekameter")
DEKAMETER("dekameter"),
@XmlEnumValue("hectometer")
HECTOMETER("hectometer"),
@XmlEnumValue("kilometer")
KILOMETER("kilometer"),
@XmlEnumValue("megameter")
MEGAMETER("megameter"),
@XmlEnumValue("angstrom")
ANGSTROM("angstrom"),
@XmlEnumValue("inch")
INCH("inch"),
@XmlEnumValue("Foot_US")
FOOT_US("Foot_US"),
@XmlEnumValue("foot")
FOOT("foot"),
@XmlEnumValue("Foot_Gold_Coast")
FOOT_GOLD_COAST("Foot_Gold_Coast"),
@XmlEnumValue("fathom")
FATHOM("fathom"),
@XmlEnumValue("nauticalMile")
NAUTICAL_MILE("nauticalMile"),
@XmlEnumValue("yard")
YARD("yard"),
@XmlEnumValue("Yard_Indian")
YARD_INDIAN("Yard_Indian"),
@XmlEnumValue("Link_Clarke")
LINK_CLARKE("Link_Clarke"),
@XmlEnumValue("Yard_Sears")
YARD_SEARS("Yard_Sears"),
@XmlEnumValue("mile")
MILE("mile");
private final String value;
LengthUnits(String v) {
value = v;
}
public String value() {
return value;
}
public static LengthUnits fromValue(String v) {
for (LengthUnits c: LengthUnits.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
|
[
"[email protected]"
] | |
a05cc48bbcb215a63b50ea1cb4f51010f7b6f813
|
5841ebcb90abaad976c31e1929f72de86a30397b
|
/likp_ai/trunk/pc/src/main/java/com/lkp/service/SYSUPloadService.java
|
e890106982db89d75a2a986af1b3a923a8e13a10
|
[] |
no_license
|
JustForMyDream/lkp_ai
|
4e95a375f07449221ef0111e5cfa787d93800bfc
|
96f8b24abe9fc6f67814a7eab2a139677df952e0
|
refs/heads/master
| 2021-07-09T12:24:47.790259 | 2017-10-08T08:57:29 | 2017-10-08T08:57:29 | 106,161,465 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 279 |
java
|
package com.lkp.service;
import org.springframework.stereotype.Service;
import java.io.Serializable;
/**
*
* 摄影师上传业务
*/
public interface SYSUPloadService {
Serializable uploadYingji(String orderid, String title, String des, String music, String[] pic);
}
|
[
"[email protected]"
] | |
8acd2316845e830bfd2c719a1c3a3822f4b446d1
|
9354accc36606e2191e12ca926becb498bbfd257
|
/src/main/java/eu/hansolo/steelseries/gauges/DisplayRectangular.java
|
a67f5960378f1507ef31f760bf558cdb6ada46ba
|
[
"BSD-3-Clause"
] |
permissive
|
wolfgangreder/SteelSeries-Swing
|
cfcc4240803efdff1741ad15427ee35c1c01700b
|
388ad1cf0173d220324d3a79218c6565c5342756
|
refs/heads/master
| 2020-09-16T09:34:00.880128 | 2019-11-24T21:37:43 | 2019-11-24T21:37:43 | 223,728,646 | 0 | 0 |
BSD-3-Clause
| 2019-11-24T10:47:24 | 2019-11-24T10:47:23 | null |
UTF-8
|
Java
| false | false | 10,616 |
java
|
/*
* Copyright (c) 2012, Gerrit Grunwald
* 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.
* The names of its contributors may not 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 eu.hansolo.steelseries.gauges;
import eu.hansolo.steelseries.tools.LcdColor;
import eu.hansolo.steelseries.tools.Util;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
/**
*
* @author hansolo
*/
public final class DisplayRectangular extends AbstractLinear {
// <editor-fold defaultstate="collapsed" desc="Variable declarations">
private BufferedImage frameImage;
private BufferedImage backgroundImage;
private BufferedImage titleImage;
private BufferedImage lcdImage;
private BufferedImage foregroundImage;
private BufferedImage disabledImage;
private final FontRenderContext RENDER_CONTEXT = new FontRenderContext(null, true, true);
private TextLayout unitLayout;
private final Rectangle2D UNIT_BOUNDARY = new Rectangle2D.Double();
private TextLayout valueLayout;
private final Rectangle2D VALUE_BOUNDARY = new Rectangle2D.Double();
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Constructor">
public DisplayRectangular() {
super();
init(getInnerBounds().width, getInnerBounds().height);
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Initialization">
@Override
public final AbstractGauge init(final int WIDTH, final int HEIGHT) {
if (WIDTH <= 1 || HEIGHT <= 1) {
return this;
}
int offset = 0;
if (isFrameVisible()) {
offset = 18;
}
if (isDigitalFont()) {
setLcdValueFont(LCD_DIGITAL_FONT.deriveFont(0.7f * (getHeight() - (2 * offset))));
} else {
setLcdValueFont(LCD_STANDARD_FONT.deriveFont(0.625f * (getHeight() - (2 * offset))));
}
if (isCustomLcdUnitFontEnabled()) {
setLcdUnitFont(getCustomLcdUnitFont().deriveFont(0.25f * (getHeight() - (2 * offset))));
} else {
setLcdUnitFont(LCD_STANDARD_FONT.deriveFont(0.25f * (getHeight() - (2 * offset))));
}
if (frameImage != null) {
frameImage.flush();
}
frameImage = create_FRAME_Image(WIDTH, HEIGHT);
if (backgroundImage != null) {
backgroundImage.flush();
}
backgroundImage = create_BACKGROUND_Image(WIDTH, HEIGHT);
if (lcdImage != null) {
lcdImage.flush();
}
if (isFrameVisible()) {
lcdImage = create_LCD_Image(WIDTH - (2 * offset), HEIGHT - (2 * offset), getLcdColor(), getCustomLcdBackground());
} else {
lcdImage = create_LCD_Image(getWidth(), getHeight(), getLcdColor(), getCustomLcdBackground());
}
if (foregroundImage != null) {
foregroundImage.flush();
}
foregroundImage = create_FOREGROUND_Image(WIDTH, HEIGHT);
if (disabledImage != null) {
disabledImage.flush();
}
disabledImage = create_DISABLED_Image(getWidth(), getHeight());
if (backgroundImage != null) {
backgroundImage.flush();
}
backgroundImage = create_BACKGROUND_Image(WIDTH, HEIGHT);
if (foregroundImage != null) {
foregroundImage.flush();
}
foregroundImage = create_FOREGROUND_Image(WIDTH, HEIGHT);
if (disabledImage != null) {
disabledImage.flush();
}
disabledImage = create_DISABLED_Image(WIDTH, HEIGHT);
return this;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Visualization">
@Override
protected void paintComponent(Graphics g) {
if (!isInitialized()) {
return;
}
final Graphics2D G2 = (Graphics2D) g.create();
G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
//G2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
//G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
//G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
//G2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
G2.translate(getInnerBounds().x, getInnerBounds().y);
// Draw the frame
if (isFrameVisible()) {
G2.drawImage(frameImage, 0, 0, null);
}
// Draw the background
if (isBackgroundVisible()) {
G2.drawImage(backgroundImage, 0, 0, null);
}
// Draw LCD display
if (isLcdVisible()) {
int offset = 0;
if (isFrameVisible()) {
offset = 18;
}
G2.drawImage(lcdImage, offset, offset, null);
if (getLcdColor() == LcdColor.CUSTOM) {
G2.setColor(getCustomLcdForeground());
} else {
G2.setColor(getLcdColor().TEXT_COLOR);
}
G2.setFont(getLcdUnitFont());
final double UNIT_STRING_WIDTH;
if (isLcdUnitStringVisible()) {
unitLayout = new TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
G2.drawString(getLcdUnitString(), (int) ((lcdImage.getWidth() - UNIT_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.03f) + offset, (int) (lcdImage.getHeight() * 0.76f) + offset);
UNIT_STRING_WIDTH = UNIT_BOUNDARY.getWidth();
} else {
UNIT_STRING_WIDTH = 0;
}
G2.setFont(getLcdValueFont());
valueLayout = new TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
G2.drawString(formatLcdValue(getLcdValue()), (int) ((lcdImage.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.09) + offset, (int) (lcdImage.getHeight() * 0.76f) + offset);
}
// Draw the foreground
if (isForegroundVisible()) {
G2.drawImage(foregroundImage, 0, 0, null);
}
if (!isEnabled()) {
G2.drawImage(disabledImage, 0, 0, null);
}
G2.translate(-getInnerBounds().x, -getInnerBounds().y);
G2.dispose();
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Getters and Setters">
@Override
public boolean isLcdVisible() {
return true;
}
@Override
public void setValue(final double VALUE) {
setLcdValue(VALUE);
}
@Override
public double getValue() {
return getLcdValue();
}
@Override
public boolean isValueCoupled() {
return false;
}
@Override
public Paint createCustomLcdBackgroundPaint(final Color[] LCD_COLORS) {
int offset = 1;
if (isFrameVisible()) {
offset = 19;
}
final Point2D FOREGROUND_START = new Point2D.Double(0.0, offset);
final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, getHeight() - offset);
if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
}
final float[] FOREGROUND_FRACTIONS = {
0.0f,
0.03f,
0.49f,
0.5f,
1.0f
};
final Color[] FOREGROUND_COLORS = {
LCD_COLORS[0],
LCD_COLORS[1],
LCD_COLORS[2],
LCD_COLORS[3],
LCD_COLORS[4]
};
Util.INSTANCE.validateGradientPoints(FOREGROUND_START, FOREGROUND_STOP);
return new LinearGradientPaint(FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
}
@Override
public Point2D getCenter() {
return new Point2D.Double(backgroundImage.getWidth() / 2.0 + getInnerBounds().x, backgroundImage.getHeight() / 2.0 + getInnerBounds().y);
}
@Override
public Rectangle2D getBounds2D() {
return new Rectangle2D.Double(0, 0, getWidth(), getHeight());
}
@Override
public Rectangle getLcdBounds() {
int offset = 0;
if (isFrameVisible()) {
offset = 17;
}
return new Rectangle(offset, offset, lcdImage.getWidth(), lcdImage.getHeight());
}
// </editor-fold>
@Override
public String toString() {
return "DisplayRectangular";
}
}
|
[
"[email protected]"
] | |
90ea1f85b7ecb635bc57b041e002d7427dc27bd2
|
c086d9b3393883af961e21c9366a5a1433e26846
|
/app/src/main/java/com/ifanjszalukhu/databindinggdk19/MainActivity.java
|
56895ce47b3b3e1ae86b28e24fd1a558bfae6bf8
|
[] |
no_license
|
ifanzalukhu97/data-binding-gdk19
|
c8a327b27566e49203e6fa8fdb78c9c7422937fe
|
b475aad09102d1a335d71497c5b64dbda2ff91b6
|
refs/heads/master
| 2020-06-24T17:59:42.579008 | 2019-07-28T07:52:21 | 2019-07-28T07:52:21 | 199,038,937 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,077 |
java
|
package com.ifanjszalukhu.databindinggdk19;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.ifanjszalukhu.databindinggdk19.databinding.ActivityMainBinding;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
Movie currentMovie = new Movie(
"Raja Singa (2019)",
"Simba mengidolakan ayahnya, Raja Mufasa, dan mengambil hati takdir kerajaannya sendiri. Tetapi tidak semua orang di kerajaan itu merayakan kedatangan anaknya yang baru.",
"https://image.tmdb.org/t/p/w533_and_h300_bestv2/1TUg5pO1VZ4B0Q1amk3OlXvlpXV.jpg",
true
);
ClickListeners clickListeners = new ClickListeners(this);
binding.setMovie(currentMovie);
binding.setClickListener(clickListeners);
}
}
|
[
"[email protected]"
] | |
739e34cca5d81c83291bd6238ce4fe060e713b12
|
4ba6a1d32a21d8bec9f56ca4223d478f3c2f42de
|
/Calculation.java
|
c5ddea38d6e8b00489fbb0ac65f8c2a763e843a6
|
[] |
no_license
|
P98-clt/java-code
|
ba904227c37dac942673089cc695b1e72639ede4
|
f08e2b593de229cb1a228b07f8a0e269fc58fa3a
|
refs/heads/main
| 2023-01-21T11:02:22.691607 | 2020-12-03T07:33:49 | 2020-12-03T07:33:49 | 318,117,220 | 1 | 0 | null | 2020-12-03T07:55:39 | 2020-12-03T07:55:39 | null |
UTF-8
|
Java
| false | false | 1,043 |
java
|
import java.util.*;
class Cal{
int a,b,sum,subs,mul,div;
Scanner sc=new Scanner(System.in);
void put_data(){
System.out.print("Enter your first number: ");
a=sc.nextInt();
System.out.print("Enter your second number: ");
b=sc.nextInt();
sum=a+b;
if(a>b){
subs=a-b;
}
else{
subs=b-a;
}
mul=a*b;
if(a>b){
div=a/b;
}
else{
div=b/a;
}
}
void get_data(){
System.out.println("The sum of is= "+sum);
System.out.println("The substraction is= "+subs);
System.out.println("The multiplication is= "+mul);
System.out.println("The division is= "+div);
}
}
class Calculation{
public static void main(String[] args){
Cal b=new Cal();
b.put_data();
b.get_data();
}
}
|
[
"[email protected]"
] | |
4063bb90e1511beaf33c939599de12f60fe42dcd
|
eef2f3c97d017a9fc5583ba8f3ddd7245fd0a863
|
/restful_demo/src/main/java/com/framework/model/User.java
|
f0a0677decbd041e2035d9c74ee76ca812bbe96a
|
[
"Apache-2.0"
] |
permissive
|
liuxiangyi86/frameworkAggregate
|
f3ecc32b181a739ec94d348ecb6e5703540a8b35
|
0565c13d00663df8430630a9a907b9ee0744b222
|
refs/heads/master
| 2020-04-24T08:27:04.206254 | 2017-09-04T08:47:59 | 2017-09-04T08:47:59 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 739 |
java
|
package com.framework.model;
public class User {
private String name;
private String sex;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public User(String name, String sex, Integer age) {
super();
this.name = name;
this.sex = sex;
this.age = age;
}
public User() {
super();
// TODO Auto-generated constructor stub
}
@Override
public String toString() {
return "User [name=" + name + ", sex=" + sex + ", age=" + age + "]";
}
}
|
[
"[email protected]"
] | |
7c3e1dd7321f8c78b596a98569533e13aaf1f8c5
|
3fb35f05d5a23bc8cec6f8c137f269786d619497
|
/Honours Project/src/honours/project/PrimeCheck.java
|
fb8283276676c020ee8d61a226e41412f4635d6d
|
[] |
no_license
|
donciavukas/Honours-Project
|
46b322b884e2b2d08b8f73671cc32494c9d659a0
|
a7cf2497adb5960ee638ef794df23397a4933f5d
|
refs/heads/master
| 2020-03-19T02:04:36.770453 | 2018-05-31T14:49:29 | 2018-05-31T14:49:29 | 135,596,964 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,847 |
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 honours.project;
import java.math.BigInteger;
/**
*
* @author Donatas
* The class that is used for input variable N testing
* if the number is certainly prime or a prime power, the methods will return TRUE
*/
public class PrimeCheck {
//A simple function to check wether a number is a prime or not
//The function starts from 2 since 2 by itself is a prime number
public boolean isPrime(BigInteger N) {
//Type changing from BigInteger into a double, as they are easier to manipulate in calculations
double n = N.doubleValue();
//Condition for the loop to stop after the product of 2*i reaches an equal or larger size than n
for (int i = 2; 2 * i < n; i++) {
if (n % i == 0) {
//If N is divisable by i, that means it is not a prime number and the method returns isPrime=false
//If it were a prime number only 1 and n would have 0 remainder,
//because i starts at 2 and can never reach n, this will not pass if the number is prime
return false;
}
}
//Default return statement, isPrime=true
return true;
}
//A function to check whether the input is a power of a prime number like 9=3^3
public boolean primePow(BigInteger n) {
//Start at value of k = 2.0
//This is because the first root would be a square root
//Math.pow(N,1/1) would always give true at the first itteration and fail to perform its purpose
//Type changing to double for simpler manipulation
double N = n.doubleValue();
double k = 2.0;
//Intermediary values that can take advantage of the rounding issue of java, initially set to 0.0
double dres = 0.0;
double ires = 0.0;
double diff = 0.0;
//
//Loop statement, that comparse a natural logarithm that was created by dividing two Math.log() objects to obtain what is required.
while (k <= (Math.log(N) / Math.log(2.0))) {
dres = Math.pow(N, 1.0 / k);
ires = Math.round(dres);
diff = Math.abs(dres - ires);
//Because of rounding errors diff could contain incorrect numbers
//Prime powers diferences however always returns 0.0
if (diff == 0.0) {
return true;
}
//A testing statements that uses the last bits of a number, might work some times
if (diff == Math.ulp(10.0)) {
return true;
}
k++;
}
return false;
}
}
|
[
"[email protected]"
] | |
4263eac62bb359c3efa6a7ce7a681bd8ae77b250
|
880d4fe98b81f82ea8db075fa78dfc3fe8daf1c1
|
/FilterApplication/src/com/servlet/HelloServlet.java
|
683579b3ef4ce1dd8011c20d4a8ec21f023b9f11
|
[] |
no_license
|
personalcodingwork/WebFilter
|
ae0a587466df0de3d3945d4c4c07c56ea29bccf8
|
8111e69b66f76ce655fa0afcceafc51c02b25fb8
|
refs/heads/master
| 2020-05-18T23:20:13.038224 | 2019-05-06T05:24:19 | 2019-05-06T05:24:19 | 184,709,879 | 2 | 0 | null | 2019-05-06T05:00:00 | 2019-05-03T06:40:22 |
Java
|
UTF-8
|
Java
| false | false | 548 |
java
|
package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("<br>welcome to servlet<br>");
}
}
|
[
"[email protected]"
] | |
a9cd75e9421194ec230343e7e796f38c54dd99e0
|
a675b580476a34b3cd20e65efef95bffae060e90
|
/core/src/com/sunday/engine/environment/time/TimerSignal.java
|
b81b3b9a641d2993574369976c61d08d5e91b2fd
|
[] |
no_license
|
tuk2000/sundaygame
|
730f3eea9c2793c9a12ea8456f1bdf77bf248603
|
9cd7840dfc614f3922b19479ba44001a09532a31
|
refs/heads/master
| 2021-09-12T23:59:13.241276 | 2018-04-20T21:47:43 | 2018-04-20T21:47:43 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 183 |
java
|
package com.sunday.engine.environment.time;
import com.sunday.engine.common.signal.SpecificSignal;
public enum TimerSignal implements SpecificSignal {
None, Update, Triggered
}
|
[
"[email protected]"
] | |
b2701c89f8ddbfcc0f38772d7def478dfee56a85
|
fec20ae9d6ecb892df2e35698305e9698a8ee152
|
/spring-boot-learning-validation/src/main/java/com/spring/boot/domian/Person.java
|
fc71c9ca679c5f9873436095ea9b605dcf4d484a
|
[] |
no_license
|
lianpeng0011/spring-boot-learning-example
|
aa7cdc1d8bf32fc9263cd7792f29a13a96f7493a
|
bd4459e9da92e65fad0762e716d7dfc27cbeab95
|
refs/heads/master
| 2020-04-11T12:51:31.816377 | 2019-01-25T10:07:45 | 2019-01-25T10:07:45 | 161,794,616 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,063 |
java
|
package com.spring.boot.domian;
import com.spring.boot.bean.validation.constraints.PersonNamePrefix;
import javax.validation.constraints.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author lianp
* @date 2019/1/3 16:13
* @since
**/
public class Person {
@NotNull
private String id;
@PersonNamePrefix(prefix = "king-")
private String name;
@NotEmpty
private List<String> list = new ArrayList<>( );
@Max( value = 200 ,message = "{Person.age.max.massage}")
@Positive
private int age;
public String getId() {
return id;
}
public void setId( String id ) {
this.id = id;
}
public String getName() {
return name;
}
public void setName( String name ) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge( int age ) {
this.age = age;
}
public List<String> getList() {
return list;
}
public void setList( List<String> list ) {
this.list = list;
}
}
|
[
"[email protected]"
] | |
a1870c23c71f6df7e17bae4e84b547a548f62a83
|
1d319a61a98a834565198d8011908a22269c0a50
|
/src/com/happytap/bangbang/GameActivity.java
|
8494028e53694233ad11b1f8697055fa50576545
|
[] |
no_license
|
snooplsm/bang
|
fe43fb254abf91cf24696dd82aa6cc232f849d91
|
7284672460e6b5ab7b5b368e99e992c0524c4688
|
refs/heads/master
| 2020-05-25T10:01:51.939378 | 2011-04-06T12:45:39 | 2011-04-06T12:45:39 | 1,355,637 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 14,808 |
java
|
package com.happytap.bangbang;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class GameActivity extends BangBangActivity implements SensorEventListener,OnClickListener, View.OnTouchListener {
private static final int CAN_SHOOT_NEEDS_TO_BE_HOLSTERED = -1;
private static final int CAN_SHOOT_NO = 0;
private static byte BEGIN_GAME = 1;
/**
* ARE WE ON PISTOL SCREEN? WHAT SCREEN ARE WE ON?
*/
private static final int INTERNAL_STATE_HOME_SCREEN = 0;
// private static final int INTERNAL_STATE_GAME
private int internalState;
private static final int CAN_SHOOT_YES = 1;
private long beganShowingWinLostOverlay;
private BeginGame beginGame;
private int canShoot;
private boolean gameOver;
private Sensor gyroscope;
HolsterWeaponOverlayView holsterWeaponOverlay;
private boolean isClient;
private GunNotHolstered lastReceivedGunNotHolstered;
private long lastReceivedGunNotHolsteredTimestamp;
private boolean lefty = true;
private AudioManager mAudioManager;
private Vibrator mVibrator;
private boolean onPistolScreen;
private ImageView pistol;
private RelativeLayout pistolContainer;
private Random random;
int sensorCount = 0;
public void onAccuracyChanged(Sensor sensor, int i) {
}
private SensorManager sensorManager;
private boolean sentGunHolstered;
private boolean sentGunNotHolstered;
private boolean showingHolsterWeaponOverlay = false;
private boolean showingWinLostGameOverlay = false;
private SoundPool soundPool;
private Timer timer;
private MediaPlayer whistleMusic;
private boolean whistleWasPlaying;
WinLostGameOverlayView winLostGameOverlay;
private boolean won = false;
private static final String TAG = "GameActivity";
private SensorEvent mLastSensorEvent = null;
private void sendShot() {
// Check that we're actually connected before trying anything
if (bluetooothService.getState() != BluetoothService.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT)
.show();
return;
}
if (mLastSensorEvent != null) {
ShotFired f = new ShotFired();
f.setX(mLastSensorEvent.values[0]);
f.setY(mLastSensorEvent.values[1]);
f.setZ(mLastSensorEvent.values[2]);
send(SHOT, f);
}
}
public boolean onTouch(View view, MotionEvent motionEvent) {
Log.i("bang", "trying to shoot, current canShoot value is " + canShoot);
if (canShoot == CAN_SHOOT_YES) {
sendShot();
}
return false;
}
public void onClick(View view) {
isClient = false;
startGame();
}
@Override
protected void onPause() {
super.onPause();
deRegisterListeners();
whistleWasPlaying = whistleMusic.isPlaying();
if (whistleWasPlaying) {
whistleMusic.pause();
}
}
private void send(byte instruction, Serializable object) {
if (bluetooothService.getState() != BluetoothService.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT)
.show();
return;
}
try {
byte[] previewPacket = new byte[5];
previewPacket[0] = instruction;
byte[] data = mObjectMapper.writeValueAsBytes(object);
int value = data.length;
previewPacket[1] = (byte) (value >>> 24);
previewPacket[2] = (byte) (value >> 16 & 0xff);
previewPacket[3] = (byte) (value >> 8 & 0xff);
previewPacket[4] = (byte) (value & 0xff);
bluetooothService.write(previewPacket, data);
} catch (IOException e) {
e.printStackTrace();
}
}
private static byte GUN_HOLSTERED = 5;
private static byte GUN_NOT_HOLSTERED = 4;
private static byte GUN_NOT_HOLSTERED_ON_BEGIN_DUEL = 6;
private static byte HIT = 3;
private void onGunNotHolstered() {
if (!whistleMusic.isPlaying()) {
if (sensorCount % 3 == 0) {
whistleMusic.start();
if (!sentGunNotHolstered) {
GunNotHolstered gnh = new GunNotHolstered();
gnh.setCurrentPosition(whistleMusic.getCurrentPosition());
send(GUN_NOT_HOLSTERED, gnh);
sentGunNotHolstered = true;
sentGunHolstered = false;
}
}
if (sensorCount % 5 == 0) {
}
}
if (!showingHolsterWeaponOverlay) {
clearViews();
pistolContainer.addView(getHolsterWeaponOverlayView());
showingHolsterWeaponOverlay = true;
}
}
private static byte SHOT = 2;
private void beginGame(BeginGame game) {
Log.i(TAG, "beginGame");
clearViews();
if (timer != null) {
timer.cancel();
}
this.beginGame = game;
Log.i(TAG, "setting can shoot to false, current value is " + canShoot);
mLastSensorEvent = null;
canShoot = CAN_SHOOT_NO;
gameOver = false;
won = false;
timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
Log.i(TAG, "setting can shoot to true, current value is "
+ canShoot);
mVibrator.vibrate(120);
if (isPistolPointingAtGround()) {
canShoot = CAN_SHOOT_YES;
} else {
canShoot = CAN_SHOOT_NEEDS_TO_BE_HOLSTERED;
}
}
};
long time = (long) (beginGame.getSecondsUntilDuel() * 1000f - (isClient ? 80
: 0));
timer.schedule(task, time);
if (pistol == null) {
setContentView(R.layout.pistol);
pistol = (ImageView) findViewById(R.id.pistol);
pistolContainer = (RelativeLayout) findViewById(R.id.pistol_container);
}
onPistolScreen = true;
clearViews();
registerListeners();
}
private void clearViews() {
if (showingHolsterWeaponOverlay) {
pistolContainer.removeView(holsterWeaponOverlay);
showingHolsterWeaponOverlay = false;
}
if (showingWinLostGameOverlay) {
pistolContainer.removeView(winLostGameOverlay);
}
}
private void deRegisterListeners() {
Log.i("bang", "deregistering listeners");
sensorManager.unregisterListener(this);
}
private View getHolsterWeaponOverlayView() {
if (holsterWeaponOverlay == null) {
holsterWeaponOverlay = new HolsterWeaponOverlayView(this);
}
return holsterWeaponOverlay;
}
private Random getRandom() {
if (random == null) {
random = new Random();
}
return random;
}
private View getWinLostGameOverlayView(boolean won) {
if (winLostGameOverlay == null) {
winLostGameOverlay = new WinLostGameOverlayView(this);
winLostGameOverlay.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (System.currentTimeMillis() - beganShowingWinLostOverlay > 3000) {
startGame();
}
return true;
}
});
}
beganShowingWinLostOverlay = System.currentTimeMillis();
if (won) {
winLostGameOverlay.setWinLossText("You Won!");
winLostGameOverlay
.setBackgroundColor(Color.argb(100, 34, 122, 245));
winLostGameOverlay.setTextColor(Color.rgb(255, 255, 255));
} else {
winLostGameOverlay.setWinLossText("You Died!");
winLostGameOverlay.setBackgroundColor(Color.argb(100, 230, 41, 41));
winLostGameOverlay.setTextColor(Color.rgb(255, 255, 255));
}
return winLostGameOverlay;
}
private boolean isPistolPointingAtGround() {
if(mLastSensorEvent==null) {
return false;
}
float y = mLastSensorEvent.values[1];
if (y > -8.5 && y > -9.5) {
return false;
}
return true;
}
private void iWasShot(ShotFired shot) {
if (!won) {
gameOver = true;
ShotHit h = new ShotHit();
send(HIT, h);
mVibrator.vibrate(1000);
deRegisterListeners();
showGameOver(won);
}
}
@Override
protected void onResume() {
super.onResume();
if (onPistolScreen) {
registerListeners();
}
if (whistleWasPlaying) {
whistleMusic.start();
}
}
public void onSensorChanged(SensorEvent sensorEvent) {
mLastSensorEvent = sensorEvent;
sensorCount++;
if (onPistolScreen) {
if (gameOver) {
return;
}
if (canShoot == CAN_SHOOT_YES) {
if (whistleMusic.isPlaying()) {
whistleMusic.pause();
return;
}
if (showingHolsterWeaponOverlay) {
pistolContainer.removeView(getHolsterWeaponOverlayView());
showingHolsterWeaponOverlay = false;
}
}
boolean isPistolPointingAtGround = isPistolPointingAtGround();
if (canShoot == CAN_SHOOT_NO && !isPistolPointingAtGround) {
onGunNotHolstered();
} else if ((canShoot == CAN_SHOOT_NEEDS_TO_BE_HOLSTERED || canShoot == CAN_SHOOT_NO)
&& isPistolPointingAtGround) {
if (canShoot == CAN_SHOOT_NEEDS_TO_BE_HOLSTERED) {
canShoot = CAN_SHOOT_YES;
}
onGunHolstered();
}
}
}
private void registerListeners() {
Log.i(TAG, "registering listeners");
sensorManager.registerListener(this, gyroscope,
SensorManager.SENSOR_DELAY_GAME);
pistol.setOnTouchListener(this);
}
private void onGunHolstered() {
if (sensorCount % 3 == 0) {
whistleMusic.pause();
if (!sentGunNotHolstered) {
GunHolstered gh = new GunHolstered();
send(GUN_NOT_HOLSTERED, gh);
sentGunHolstered = true;
sentGunNotHolstered = false;
}
}
if (showingHolsterWeaponOverlay) {
pistolContainer.removeView(getHolsterWeaponOverlayView());
showingHolsterWeaponOverlay = false;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.new_game);
View startGame = findViewById(R.id.start_game);
startGame.setOnClickListener(this);
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
gyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
whistleMusic = MediaPlayer.create(this, R.raw.whistle_song);
whistleMusic.setLooping(true);
mDataHandler.put(SHOT, new DataHandler<ShotFired>() {
public Class<ShotFired> getDataClass() {
return ShotFired.class;
}
public Byte getInstructionByte() {
return SHOT;
}
public void process(ShotFired data) {
if (data.getY() > -2.21 && data.getY() < 2.21) {
iWasShot(data);
}
}
});
mDataHandler.put(HIT, new DataHandler<ShotHit>() {
public Class<ShotHit> getDataClass() {
return ShotHit.class;
}
public Byte getInstructionByte() {
return HIT;
}
public void process(ShotHit data) {
won = true;
gameOver = true;
deRegisterListeners();
showGameOver(won);
}
});
mDataHandler.put(GUN_NOT_HOLSTERED, new DataHandler<GunNotHolstered>() {
public Class<GunNotHolstered> getDataClass() {
return GunNotHolstered.class;
}
public Byte getInstructionByte() {
return GUN_NOT_HOLSTERED;
}
public void process(GunNotHolstered data) {
lastReceivedGunNotHolsteredTimestamp = System
.currentTimeMillis();
lastReceivedGunNotHolstered = data;
long diff = System.currentTimeMillis()
- lastReceivedGunNotHolsteredTimestamp;
diff += lastReceivedGunNotHolstered.getCurrentPosition();
diff += 5;
whistleMusic.seekTo((int) diff);
}
});
mDataHandler.put(GUN_HOLSTERED, new DataHandler<GunHolstered>() {
public Class<GunHolstered> getDataClass() {
return GunHolstered.class;
}
public Byte getInstructionByte() {
return GUN_HOLSTERED;
}
public void process(GunHolstered data) {
}
});
mDataHandler.put(BEGIN_GAME, new DataHandler<BeginGame>() {
public Class<BeginGame> getDataClass() {
return BeginGame.class;
}
public Byte getInstructionByte() {
return BEGIN_GAME;
}
public void process(BeginGame data) {
isClient = true;
beginGame(data);
}
});
mDataHandler.put(GUN_NOT_HOLSTERED_ON_BEGIN_DUEL,
new DataHandler<GunNotHolsteredOnDuelStart>() {
public Class<GunNotHolsteredOnDuelStart> getDataClass() {
return GunNotHolsteredOnDuelStart.class;
}
public Byte getInstructionByte() {
return GUN_NOT_HOLSTERED_ON_BEGIN_DUEL;
}
public void process(GunNotHolsteredOnDuelStart data) {
}
});
bluetooothService.setmHandler(mHandler);
}
private void startGame() {
BeginGame bg = new BeginGame();
int index = 1;
float seconds;
Random random = getRandom();
switch (index) {
case 0:
seconds = random.nextInt(9);
seconds += random.nextFloat();
break;
case 1:
seconds = random.nextInt(5) + 4;
seconds += random.nextFloat();
case 2:
seconds = 5;
break;
case 3:
seconds = 10;
break;
case 4:
seconds = 0;
break;
default:
seconds = 5;
break;
}
bg.setSecondsUntilDuel(seconds);
send(BEGIN_GAME, bg);
beginGame(bg);
}
protected Map<Byte, DataHandler> mDataHandler = new HashMap<Byte, DataHandler>();
private void showGameOver(boolean won) {
clearViews();
if (won == true) {
System.out.println("I WON!");
}
pistolContainer.addView(getWinLostGameOverlayView(won));
showingWinLostGameOverlay = true;
// if (hasAd) {
// // interstitialAd.show(this);
// }
}
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_STATE_CHANGE:
switch (msg.arg1) {
case BluetoothService.STATE_CONNECTED:
break;
case BluetoothService.STATE_CONNECTING:
// mTitle.setText(R.string.title_connecting);
break;
case BluetoothService.STATE_LISTEN:
case BluetoothService.STATE_NONE:
// mTitle.setText(R.string.title_not_connected);
break;
}
break;
case MESSAGE_READ:
BangBangMessage bbm = (BangBangMessage) msg.obj;
byte[] readBuf = bbm.getPacket();
// construct a string from the valid bytes in the buffer
byte protocol = bbm.getPreviewPacket()[0];
DataHandler<Object> dhandler = mDataHandler.get(protocol);
try {
dhandler.process(mObjectMapper.readValue(readBuf, 0, bbm
.getPacketSize(), dhandler.getDataClass()));
} catch (IOException e) {
e.printStackTrace();
}
// String readMessage = new String(readBuf, 0, msg.arg1);
// mConversationArrayAdapter.add(mConnectedDeviceName+": " +
// readMessage);
break;
case MESSAGE_TOAST:
Toast.makeText(getApplicationContext(),
msg.getData().getString(TOAST), Toast.LENGTH_SHORT)
.show();
break;
}
}
};
}
|
[
"="
] |
=
|
bc5c2e0d7ff802d741f8b88f1a4ea581cf3dfa68
|
69168a52b6731ded89f9e801ab327e30ddd327ae
|
/Test Cases/Testing/TestPuzzle.java
|
20d5c7bcf6f2098045b36a465503e64143fd5f1f
|
[] |
no_license
|
naomitharrison/DoubleSidedPuzzleApplication
|
9b68ba22a1364dbc8c0129986aac31dc2db1083c
|
a645b9b714cc9ec32611fbc17a1145a97e3c5bc8
|
refs/heads/master
| 2020-09-02T10:09:17.998750 | 2019-11-11T17:54:23 | 2019-11-11T17:54:23 | 219,198,143 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 9,154 |
java
|
package Testing;
import static org.junit.jupiter.api.Assertions.*;
import java.awt.Rectangle;
import java.util.ArrayList;
import org.junit.jupiter.api.Test;
import starter.entity.Puzzle;
import starter.entity.Tile;
import starter.entity.TileSet;
class TestPuzzle {
@Test
void testWinFalse1() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse2() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,true);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse3() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,false);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse4() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,true);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse5() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","4",r,false);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse6() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("5","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse7() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","5",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse8() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("5","0",r,false);
Tile w5 = new Tile("0","4",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinFalse9() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("4","0",r,false);
Tile w5 = new Tile("0","5",r,true);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertFalse(win);
}
@Test
void testWinTrue() {
Rectangle r = new Rectangle(0,0,0,0);
Tile w1 = new Tile("1","0",r,false);
Tile w2 = new Tile("2","0",r,false);
Tile w3 = new Tile("3","0",r,false);
Tile w4 = new Tile("0","4",r,true);
Tile w5 = new Tile("4","0",r,false);
Tile w6 = new Tile("0","3",r,true);
Tile w7 = new Tile("0","2",r,true);
Tile w8 = new Tile("0","1",r,true);
Tile[][] winShape = new Tile[][] {{w1, w2, w3},
{w4, null, w5},
{w6, w7, w8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(winShape);
boolean win = p.checkWin();
assertTrue(win);
}
@Test
void testLoseFalse() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
boolean lose = p.checkLose();
assertFalse(lose);
}
@Test
void testLoseTrue() {
Rectangle r = new Rectangle(0,0,0,0);
Tile l1 = new Tile("1", "0", r, false);
Tile l2 = new Tile("4", "0", r, false);
Tile l3 = new Tile("1", "0", r, false);
Tile l4 = new Tile("4", "0", r, false);
Tile l5 = new Tile("1", "0", r, false);
Tile l6 = new Tile("4", "0", r, false);
Tile l7 = new Tile("1", "0", r, false);
Tile l8 = new Tile("4", "0", r, false);
final Tile[][] loseShape = {{l1, l4, null},
{l2, l5, l7},
{l3, l6, l8}};
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.setShape(loseShape);
boolean lose = p.checkLose();
assertTrue(lose);
}
@Test
void testMovableTiles() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
Tile c1 = p.getShape()[0][1];
Tile c2 = p.getShape()[1][2];
ArrayList<Tile> correct = new ArrayList<Tile>();
correct.add(c2);
correct.add(c1);
ArrayList<Tile> test = p.movableTiles();
assertEquals(correct.size(),test.size());
assertTrue(correct.get(0).tileEquals(test.get(0)));
assertTrue(correct.get(1).tileEquals(test.get(1)));
}
@Test
void testMovableTilesMiddle() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
p.updatePuzzle(p.getShape()[0][1]);
p.updatePuzzle(p.getShape()[1][1]);
Tile c1 = p.getShape()[0][1];
Tile c2 = p.getShape()[2][1];
Tile c3 = p.getShape()[1][0];
Tile c4 = p.getShape()[1][2];
ArrayList<Tile> correct = new ArrayList<Tile>();
correct.add(c1);
correct.add(c2);
correct.add(c3);
correct.add(c4);
ArrayList<Tile> test = p.movableTiles();
assertEquals(correct.size(),test.size());
assertTrue(correct.get(0).tileEquals(test.get(0)));
assertTrue(correct.get(1).tileEquals(test.get(1)));
assertTrue(correct.get(2).tileEquals(test.get(2)));
assertTrue(correct.get(3).tileEquals(test.get(3)));
}
@Test
void testUpdatePuzzle() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
Tile t = p.getShape()[0][1];
p.updatePuzzle(t);
int[] test = p.getFindNullTile();
int[] correct = new int[] {0,1};
assertArrayEquals(correct,test);
}
@Test
void testGetTileSet() {
TileSet tiles = new TileSet();
Puzzle p = new Puzzle(tiles);
TileSet test = p.getTileSet();
TileSet correct = tiles;
assertEquals(correct.getAllTiles(),test.getAllTiles());
}
@Test
void testMoves() {
TileSet t = new TileSet();
Puzzle p = new Puzzle(t);
p.addOneMove();
int test = p.getMoves();
int correct = 1;
assertEquals(correct, test);
}
}
|
[
"[email protected]"
] | |
cf9e428282710945708cd2672286eeb1f9db2e48
|
02e47eb5de572493b2260cf204782b8791bcf968
|
/src/test/ca/ubc/cs/cpsc210/translink/tests/model/RoutePatternTest.java
|
f745c071ad8198c2a51b56741be5dd3092e64730
|
[] |
no_license
|
nikkimoteva/BussesAreUs
|
234c386344f516c42f69708ad53ab6083afe3957
|
1cf26dc9761a25741180b2c6e9d164d73b1eb423
|
refs/heads/master
| 2020-04-20T04:24:23.874492 | 2019-02-01T02:08:19 | 2019-02-01T02:08:19 | 168,626,306 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,435 |
java
|
package ca.ubc.cs.cpsc210.translink.tests.model;
import ca.ubc.cs.cpsc210.translink.model.Route;
import ca.ubc.cs.cpsc210.translink.model.RoutePattern;
import ca.ubc.cs.cpsc210.translink.util.LatLon;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class RoutePatternTest {
private RoutePattern testPattern;
private RoutePattern testPattern2;
private RoutePattern testPattern3;
private Route testingRoute;
private Route route;
@BeforeEach
void setup() {
route = new Route("9999");
testingRoute = new Route("9990");
testPattern = new RoutePattern("name", "Home", "West", route);
}
@Test
void testRoutePattern() {
assertEquals("name", testPattern.getName());
assertEquals("Home", testPattern.getDestination());
assertEquals("West", testPattern.getDirection());
assertEquals(0, testPattern.getPath().size());
List<LatLon> testPath = new ArrayList<>();
testPattern.setDirection("East");
testPattern.setDestination("");
testPattern.setPath(testPath);
testPath.add(new LatLon(42.3, -123.2));
testPath.add(new LatLon(43.2, -122.3));
assertEquals("name", testPattern.getName());
assertEquals("", testPattern.getDestination());
assertEquals("East", testPattern.getDirection());
assertEquals(2, testPattern.getPath().size());
assertEquals(43.2, testPath.get(1).getLatitude());
assertEquals(42.3, testPath.get(0).getLatitude());
assertEquals(-123.2, testPath.get(0).getLongitude());
assertEquals(-122.3, testPath.get(1).getLongitude());
testPattern2 = new RoutePattern("name", "School", "West", route);
testPattern3 = new RoutePattern("not", "the", "same", testingRoute);
assertNotEquals(testPattern, testPattern3);
assertFalse(testPattern.equals(testPattern3));
assertEquals(testPattern, testPattern2);
assertEquals(testPattern.hashCode(), testPattern2.hashCode());
}
@Test
void testEquals() {
assertNotEquals(testingRoute, route);
assertFalse(testingRoute.equals(route));
}
}
|
[
"[email protected]"
] | |
277c48916620cd9c4d69730c822974428cb4f2e9
|
4eefccd03b49ed93f9aaa497a3a9aadb5968900e
|
/src/main/java/spring/study/day01/ex03/LgTV.java
|
1b41d8defdf43eea4ea6446ca0da728155240ecb
|
[] |
no_license
|
joeunseong/spring-study
|
8e35a208919c74dcfd5d36515083a90d6119546a
|
12b6a56c09bbae1e7f6eca25636d42ed809f8f15
|
refs/heads/master
| 2022-06-06T06:00:43.448492 | 2020-04-18T07:55:52 | 2020-04-18T07:55:52 | 256,688,269 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 431 |
java
|
package spring.study.day01.ex03;
public class LgTV implements TV {
@Override
public void powerOn() {
System.out.println("LgTV :: powerOn()");
}
@Override
public void powerOff() {
System.out.println("LgTV :: powerOff()");
}
@Override
public void volumeUp() {
System.out.println("LgTV :: volumeUp()");
}
@Override
public void volumeDown() {
System.out.println("LgTV :: volumeDown()");
}
}
|
[
"[email protected]"
] | |
cba5055d6165d92c5f926c94f0806e2004fe387c
|
8bbe6f527c8529c445afca2f165f255a75f3beff
|
/NatureSpotVersaoEntrega/NatureSpot_/app/src/main/java/ua/pt/naturespot/Activities/MapsActivity.java
|
c3b91897dd9f689592008ac1501267d75e2bcd18
|
[] |
no_license
|
lucasaas98/icm2018Animals
|
c1651f2cc5461eee9a92876076c42c9cd3819018
|
8437d8d058862821501e88303aa92bed00394121
|
refs/heads/master
| 2020-04-05T08:42:40.412222 | 2019-01-02T12:44:42 | 2019-01-02T12:44:42 | 156,726,048 | 2 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,734 |
java
|
package ua.pt.naturespot.Activities;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.util.Arrays;
import java.util.List;
import ua.pt.naturespot.R;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private String[] points;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
points = message.split("!");
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng coords = new LatLng(40.6405, 8.6538);
// "lat, long! lat, long! lat, long!"
for(String point : points){
List<String> elephantList = Arrays.asList(point.split(","));
coords = new LatLng(Double.parseDouble(elephantList.get(0)), Double.parseDouble(elephantList.get(1)));
mMap.addMarker(new MarkerOptions().position(coords).title("").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
}
// Add a marker in Sydney and move the camera
//LatLng sydney = new LatLng(-34, 151);
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(coords));
}
}
|
[
"[email protected]"
] | |
4e81de5e82d031381f77f869eccc0800fccf0b10
|
e16a23fa9263cbb1b6603c4e372c1165b6976a25
|
/app/src/main/java/com/komshuu/komshuuandroidfrontend/models/UserOrderList.java
|
7d7c5a8ebdf4cbcc154b9e0d50c5eef749b4ceb9
|
[] |
no_license
|
KomsHuuApp/KomsHuuAndroidFrontend
|
8fb6aba8888186289ab6c5ad89eca1f924d4d7a9
|
f66cbe5fda6ce4f91e79add7bf166ac31c03c0a0
|
refs/heads/master
| 2020-04-17T02:01:24.415156 | 2019-03-23T00:25:14 | 2019-03-23T00:25:14 | 166,088,132 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 944 |
java
|
package com.komshuu.komshuuandroidfrontend.models;
public class UserOrderList {
private String flatNumber;
private String order;
private int orderId;
private long apartmentId;
public UserOrderList() {
}
public UserOrderList(String flatnumber, String str) {
flatNumber = flatnumber;
order = str;
}
public long getApartmentId() {
return apartmentId;
}
public void setApartmentId(long apartmentId) {
this.apartmentId = apartmentId;
}
public int getOrderId() {
return orderId;
}
public void setOrderId(int id) {
orderId = id;
}
public String getFlatNumber() {
return flatNumber;
}
public void setFlatNumber(String flatnumber) {
flatNumber = flatnumber;
}
public String getOrder() {
return order;
}
public void setOrder(String str) {
order = str;
}
}
|
[
"[email protected]"
] | |
0843e9a47776b69a8140e41dbf3180192f5123a0
|
5ce9526df236f8b2fcffef62718a9f0119ec16e3
|
/JavaApplication24/src/condicionais/CondicionaisCompostos.java
|
bd85e45bb0d596e58c74ac337022e380e3bcccb7
|
[] |
no_license
|
Guuisr07/Java
|
e6d0c53b6709b133cd0a9eab3d797382ec046463
|
32f3184b3b3b5451705714a89220a3b476c372ca
|
refs/heads/master
| 2020-06-19T00:35:07.571479 | 2019-08-09T00:19:22 | 2019-08-09T00:19:22 | 196,506,301 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 806 |
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 condicionais;
import java.util.Scanner;
/**
*
* @author Guilherme
*/
public class CondicionaisCompostos {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner teclado = new Scanner(System.in);
System.out.print("Digite o ano do seu nascimento:");
int nasc = teclado.nextInt();
int idade = 2019 - nasc;
if (idade>=18){
System.out.println("Maior de Idade");
} else {
System.out.println("Menor de idade");
}
}
}
|
[
"[email protected]"
] | |
c4c0f76944b819d89cfdb2cedeca44eebce772fb
|
7fa9c6b0fa1d0726ae1cda0199716c811a1ea01b
|
/Crawler/data/HasValueEnumTypeHandler.java
|
b2d98a7a628a3bea7a08f38e6b41719d6ea0fdd5
|
[] |
no_license
|
NayrozD/DD2476-Project
|
b0ca75799793d8ced8d4d3ba3c43c79bb84a72c0
|
94dfb3c0a470527b069e2e0fd9ee375787ee5532
|
refs/heads/master
| 2023-03-18T04:04:59.111664 | 2021-03-10T15:03:07 | 2021-03-10T15:03:07 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,103 |
java
|
15
https://raw.githubusercontent.com/zjjxxlgb/mybatis2sql/master/src/test/java/org/apache/ibatis/submitted/enum_interface_type_handler/HasValueEnumTypeHandler.java
/**
* Copyright ${license.git.copyrightYears} the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.submitted.enum_interface_type_handler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
@MappedTypes(HasValue.class)
public class HasValueEnumTypeHandler<E extends Enum<E> & HasValue> extends
BaseTypeHandler<E> {
private Class<E> type;
private final E[] enums;
public HasValueEnumTypeHandler(Class<E> type) {
if (type == null)
throw new IllegalArgumentException("Type argument cannot be null");
this.type = type;
this.enums = type.getEnumConstants();
if (!type.isInterface() && this.enums == null)
throw new IllegalArgumentException(type.getSimpleName()
+ " does not represent an enum type.");
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, E parameter,
JdbcType jdbcType) throws SQLException {
ps.setInt(i, parameter.getValue());
}
@Override
public E getNullableResult(ResultSet rs, String columnName)
throws SQLException {
int value = rs.getInt(columnName);
if (rs.wasNull()) {
return null;
}
for (E enm : enums) {
if (value == enm.getValue()) {
return enm;
}
}
throw new IllegalArgumentException("Cannot convert "
+ value + " to " + type.getSimpleName());
}
@Override
public E getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
int value = rs.getInt(columnIndex);
if (rs.wasNull()) {
return null;
}
for (E enm : enums) {
if (value == enm.getValue()) {
return enm;
}
}
throw new IllegalArgumentException("Cannot convert "
+ value + " to " + type.getSimpleName());
}
@Override
public E getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
int value = cs.getInt(columnIndex);
if (cs.wasNull()) {
return null;
}
for (E enm : enums) {
if (value == enm.getValue()) {
return enm;
}
}
throw new IllegalArgumentException("Cannot convert "
+ value + " to " + type.getSimpleName());
}
}
|
[
"[email protected]"
] | |
893cd25cacdf85207d1a56c72de8f45ab16a3c63
|
1ce6f9deac932e27a977558345d0df7202c20503
|
/javase_prj/src/kr/co/sist/memo/run/RunJavaMemo.java
|
b3485757c5faaba02b1da12c15134c652bfca56a
|
[] |
no_license
|
minj0i/sist-java
|
3782bfaa6e0561ae2160bab4202f405c324c1894
|
e7c800c8433434617f564d905207f49cbac7733f
|
refs/heads/master
| 2020-04-09T12:00:15.732203 | 2019-04-22T08:11:22 | 2019-04-22T08:11:22 | 160,332,230 | 0 | 0 | null | null | null | null |
UHC
|
Java
| false | false | 1,446 |
java
|
package kr.co.sist.memo.run;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import kr.co.sist.memo.view.JavaMemo;
/**
* 메모장 클래스를 실행하는 일.
* @author owner
*/
public class RunJavaMemo {
/////////////2018-12-21 코드 추가(OIS)//////////
public Font readFontInfo() throws IOException, ClassNotFoundException {
// BufferedReader br= null;
ObjectInputStream ois = null;
Font font = null;
try {
ois = new ObjectInputStream(new FileInputStream("c:/dev/temp/memo.dat"));
font = (Font)ois.readObject();
// br = new BufferedReader(new FileReader("c:/dev/temp/memo.dat"));
// String readFont= br.readLine();
// String[] temp = readFont.split(",");
// font = new Font(temp[0], Integer.parseInt(temp[1]), Integer.parseInt(temp[2]));
}finally {
if(ois!=null) {ois.close();}//end if
// if(br!=null) {br.close();}//end if
}//end finally
return font;
}//readFontInfo
/**
* 자바클래스를 실행하는 일 : Java Application
* @param args
*/
public static void main(String[] args) {
RunJavaMemo rjm = new RunJavaMemo();
Font font = null;
try {
font = rjm.readFontInfo();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}//
new JavaMemo(font);
}//main
}//class
|
[
"[email protected]"
] | |
599005b888b003082623f26603c0b870a311162e
|
cd2593a706c4dcca11fdc31eea5109a16e6535e8
|
/src/main/java/app/springframework/joke/sfjokeapp/config/ChuckConriguration.java
|
8430a16a94812f0b89f0a720104fe4375e03d036
|
[] |
no_license
|
NishantKatoch/sf-jokeapp
|
53b2512ef935da97deaec4cf09a3137da30e15d2
|
b3014be67cdc34889b1ced6a7a04c4392b4be810
|
refs/heads/master
| 2022-12-06T17:48:13.607326 | 2020-08-25T09:45:00 | 2020-08-25T09:45:00 | 290,172,494 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 391 |
java
|
package app.springframework.joke.sfjokeapp.config;
import guru.springframework.norris.chuck.ChuckNorrisQuotes;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//@Configuration
public class ChuckConriguration {
// @Bean
public ChuckNorrisQuotes chuckNorrisQuotes(){
return new ChuckNorrisQuotes();
}
}
|
[
"[email protected]"
] | |
a2e0e473b3aa0f1e6e05ce2dcfe462394ba8b626
|
1163394bf18e8671506fe1d45db8decb1d8938bd
|
/src/main/java/com/grudnik/dto/ProfileDTO.java
|
758596598ef264e03ea243a5c3ef6a729ff562a6
|
[] |
no_license
|
MrKyrtap/JAVASpringForum
|
f3e1b8c4c78b7caa565952aee7caa2b51c5504c8
|
272e2ec6a0b0f37cd2b50f9631f3b286a420a06e
|
refs/heads/master
| 2021-01-20T08:20:38.186700 | 2017-08-27T10:42:08 | 2017-08-27T10:42:08 | 90,132,853 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,003 |
java
|
package com.grudnik.dto;
import com.grudnik.entities.Post;
import com.grudnik.entities.User;
/**
* Created by PatrykGrudnik on 30/07/2017.
*/
public class ProfileDTO {
User user;
int postsCount;
int topicCount;
Post lastPost;
int userAge;
public int getUserAge() {
return userAge;
}
public void setUserAge(int userAge) {
this.userAge = userAge;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public int getPostsCount() {
return postsCount;
}
public void setPostsCount(int postsCount) {
this.postsCount = postsCount;
}
public int getTopicCount() {
return topicCount;
}
public void setTopicCount(int topicCount) {
this.topicCount = topicCount;
}
public Post getLastPost() {
return lastPost;
}
public void setLastPost(Post lastPost) {
this.lastPost = lastPost;
}
}
|
[
"[email protected]"
] | |
3516f1675cfc7453be5d993af79fc8036b849c56
|
7a6c87f6be1e68bbb662bb4cd4092fadaf748d0d
|
/src1/test/TestXML2JSON.java
|
d7b2f4f7b454fa9cb9e354f1677949008032b229
|
[] |
no_license
|
vnamboo/LearnJava
|
5feead0976c4bb29b7e4633d3cd63c326cefe1e6
|
a14e61bc0ad780b8794377d1bc7530a36df13fbe
|
refs/heads/master
| 2020-09-13T08:42:01.115300 | 2014-08-22T15:06:56 | 2014-08-22T15:06:56 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,428 |
java
|
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.CharBuffer;
import java.util.HashMap;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleBindings;
import org.json.JSONObject;
import org.json.XML;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
public class TestXML2JSON {
CompiledScript compiledScript;
public static void main(String[] args) throws Exception{
TestXML2JSON xml2Json=new TestXML2JSON();
String xml=xml2Json.readXML();
System.out.println(xml);
System.out.println("Length : "+xml.length());
long startTime=System.currentTimeMillis();
JSONObject json=XML.toJSONObject(xml);
long endTime=System.currentTimeMillis();
System.out.println(json);
System.out.println("Length : "+json.toString().length());
System.out.println(endTime-startTime);
xml2Json.initialize("c:\\script\\mxml.curr.fxd.fxd.js");
HashMap<String,Object> context = new HashMap<String,Object>() ;
HashMap<String,Object> contextReturn = new HashMap<String,Object>() ;
context.put("message",json.toString()) ;
context.put("tradeIndex", 2);
context.put("mxmlData",contextReturn) ;
int count=1;
//Thread.sleep(10000);
while (count>0) {
xml2Json.process(context);
//Thread.sleep(10000);
count--;
}
for(String key:contextReturn.keySet())
System.out.println(contextReturn.get(key));
}
private String readXML() throws IOException{
FileReader reader=new FileReader(new File("c:\\mxml.xml"));
StringBuffer xmlData=new StringBuffer();
char data[]=new char[1024];
while(reader.read(data)!=-1){
xmlData.append(data);
data=new char[1024];
}
return xmlData.toString();
}
public void initialize(String scriptPath) throws Exception {
try {
ScriptEngineManager manager = new ScriptEngineManager() ;
ScriptEngine scriptEngine = manager.getEngineByName("js") ;
if (scriptEngine == null){
throw new Exception("ScriptProcessor engine not found") ;
}
if (! (scriptEngine instanceof Compilable)){
throw new Exception("ScriptProcessor engine not found") ;
}
Compilable compilable = (Compilable) scriptEngine ;
InputStream input = null ;
try {
input = new FileInputStream(new File(scriptPath));
if (input == null){
throw new Exception("Script not found") ;
}
InputStreamReader reader = new InputStreamReader(input) ;
compiledScript = compilable.compile(reader) ;
} catch (ScriptException x){
throw new Exception("Script cannot be compiled") ;
} finally {
try {
if (input != null){
input.close() ;
}
} catch (Exception x) { }
}
} catch (Exception e){
throw e ;
}
}
/**
* Execute the script against the context.
*
* @param context
*/
public void process(HashMap<String,Object> context) throws Exception {
try {
SimpleBindings bindings = new SimpleBindings(context) ;
compiledScript.eval(bindings) ;
} catch (ScriptException e){
throw new Exception("Runtime script exception in service "+e) ;
}
}
}
|
[
"vnamboo@.(none)"
] |
vnamboo@.(none)
|
d1d41adc6c821e5f27ae839891fff74e4cee09c3
|
ebd0bcf2a5dd9edfab82ff30ca2b952e21dfee88
|
/src/org/jglrxavpok/blocky/ui/UIConfirmMenu.java
|
4291021f89dabd4d750532f8c13d9cde96ec48c6
|
[] |
no_license
|
OurCraft/Blocky
|
044c9f18f9532539e8e663e182a17532b987111f
|
3d4d8e6e00cf1aab5a2952f75134c73f81b9d7a2
|
refs/heads/master
| 2016-09-05T15:46:51.633864 | 2014-10-22T19:51:04 | 2014-10-22T19:51:04 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,293 |
java
|
package org.jglrxavpok.blocky.ui;
import org.jglrxavpok.blocky.ui.UILabel.LabelAlignment;
import org.jglrxavpok.blocky.utils.Lang;
public class UIConfirmMenu extends UIMenu
{
private int color;
private String text;
private UIMenu noMenu;
private UIMenu yesMenu;
private UIButton yesButton;
private UIButton noButton;
public UIConfirmMenu(UIMenu yesMenu, UIMenu noMenu, String questionText, int questionColor)
{
this.yesMenu = yesMenu;
this.noMenu = noMenu;
this.text = questionText;
this.color = questionColor;
}
public void initMenu()
{
UILabel label = new UILabel(text,w/2,h/2+50, LabelAlignment.CENTERED);
comps.add(label);
label.color = color;
yesButton = new UIButton(this, w/2-360,h/2-60,350,40,Lang.getLocalized("confirm.yes"));
noButton = new UIButton(this, w/2+10,h/2-60,350,40,Lang.getLocalized("confirm.no"));
comps.add(yesButton);
comps.add(noButton);
}
public void componentClicked(UIComponentBase b)
{
if(b == yesButton)
{
UI.displayMenu(yesMenu);
}
else if(b == noButton)
{
UI.displayMenu(noMenu);
}
}
public void renderOverlay(int mx, int my, boolean[] buttons)
{
super.renderOverlay(mx, my, buttons);
}
public void render(int mx, int my, boolean[] buttons)
{
super.render(mx, my, buttons);
}
}
|
[
"[email protected]"
] | |
1063d4ed56e0f0f07c17f19ac2b1576a14731c5d
|
080276f4a3e5f4510e6f77a6633b2427c5583ead
|
/src/main/java/pl/czyzniek/openfdareader/drugrecordapplication/fda/DrugRecordApplicationStore.java
|
9a38a4cc16f2c87766f872c5cf4c7b953333be59
|
[] |
no_license
|
czyzniek/openfda-reader
|
97f9ba00f0a8562874b2d3dc87103e1abeb7dbb7
|
1b576fb160ba58d175028ed81f488ca49d4b9b2d
|
refs/heads/master
| 2023-06-27T22:25:35.375308 | 2021-08-01T10:32:59 | 2021-08-01T10:37:00 | 391,585,321 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 438 |
java
|
package pl.czyzniek.openfdareader.drugrecordapplication.fda;
import io.vavr.control.Either;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import pl.czyzniek.openfdareader.error.StructuredError;
interface DrugRecordApplicationStore {
Either<StructuredError, ? extends Page<DrugRecordApplication>> findDrugRecordApplications(String manufacturerName, String brandName, Pageable page);
}
|
[
"[email protected]"
] | |
1ca223a9438673eb415e45b9a26e59fbc61e8f71
|
dc2219ac7ba5267100e9af284bf3f0aa8a15fdac
|
/app/src/main/java/fr/enssat/caronnantel/algorithm/PredictionResult.java
|
b72cc6f8d44a0bf3422b9004164dcb9296caaa7c
|
[] |
no_license
|
MHelenaneves/Pain-Detector-App
|
45c19acc97358a492a0642625009c505a28b2a7f
|
eef3fd9e567b915abed6c5ed51375c2bee394d5b
|
refs/heads/main
| 2023-04-21T03:26:09.374431 | 2021-05-07T09:32:25 | 2021-05-07T09:32:25 | 365,182,829 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 781 |
java
|
package fr.enssat.caronnantel.algorithm;
//import fr.enssat.caronnantel.model.IrisClass;
import fr.enssat.caronnantel.model.PainNopain;
public class PredictionResult {
private PainNopain expected;
private PainNopain predicted;
public PredictionResult(PainNopain expected, PainNopain predicted) {
this.expected = expected;
this.predicted = predicted;
}
public PainNopain getExpected() {
return expected;
} //used in the confusion matrix
public void setExpected(PainNopain expected) {
this.expected = expected;
}
public PainNopain getPredicted() {
return predicted;
}//used in the confusion matrix
public void setPredicted(PainNopain predicted) {
this.predicted = predicted;
}
}
|
[
"[email protected]"
] | |
be140e29168946000ed8ece52abe40f14b74627a
|
7edebe7b68879e40e2df9dfe120f3195cab5a8a8
|
/SDM1/src/com/balu/curd/domain/Student.java
|
b0f2c5b404c4919a5f1c249bd0a5312885578e88
|
[] |
no_license
|
baluv/Student-database-management-System
|
89f054b0b1353a23a3ffd22b6028c0355d8da0a9
|
938af8bcee1d58cd5d9ad76bc399c10d2612924d
|
refs/heads/master
| 2016-08-11T22:17:44.120810 | 2015-12-07T08:28:39 | 2015-12-07T08:28:39 | 47,538,469 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,405 |
java
|
/**
*
*/
package com.balu.curd.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author bmv00_000
*
*/
@SuppressWarnings("serial")
@Entity
@Table(name="Student")
public class Student implements Serializable {
public Student() {
}
@Id
@Column(name="st_id")
private String studId;
@Column(name="st_name")
private String studName;
@Column(name="st_marks")
private double studMarks;
@Column(name="st_Email")
private String studEmail;
@Column(name="st_phNo")
private long studphNo;
public String getStudId() {
return studId;
}
public void setStudId(String studId) {
this.studId = studId;
}
public String getStudName() {
return studName;
}
public void setStudName(String studName) {
this.studName = studName;
}
public double getStudMarks() {
return studMarks;
}
public void setStudMarks(double studMarks) {
this.studMarks = studMarks;
}
public String getStudEmail() {
return studEmail;
}
public void setStudEmail(String studEmail) {
this.studEmail = studEmail;
}
public long getStudphNo() {
return studphNo;
}
public void setStudphNo(long studphNo) {
this.studphNo = studphNo;
}
}
|
[
"[email protected]"
] | |
f909e584f3ae50291e864262e0f0f1fa5fe15df6
|
cd5428d1e04113576d3dd5359dd01ecd8992f360
|
/JavaLearn/src/com/inheritance/EngineType.java
|
2ae7eb040dd9ac6c481515dffb9fc44638dc3d70
|
[] |
no_license
|
EduardVad/Java
|
3fce839b2171d1aaabfd885d1dcbb60097ded917
|
7dccebfe3dbdf021b2ced79334f5ecfc4440eea9
|
refs/heads/master
| 2020-05-04T23:20:13.290872 | 2019-04-04T17:31:50 | 2019-04-04T17:31:50 | 179,540,486 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 78 |
java
|
package com.inheritance;
public enum EngineType {
GAS, DIESEL, ELECTRIC;
}
|
[
"[email protected]"
] | |
02b1ce81e97a4392053549c61778d6c49e93e23f
|
a02dbba3425763cade7b0c23e3b1c23d064aa569
|
/Lab13_ListaDoble/src/CASTRO_TOCAFFONDI/ListaDoble.java
|
d421dc8d966ceb60cae471ec4b43a32358d75a92
|
[
"MIT"
] |
permissive
|
Alexander-CT/LABORATORIO_13
|
692e27a3a71e3618dfe87245d210bf29c4fd0237
|
49ab5e3c1770e669d9a35388032341777a364db2
|
refs/heads/master
| 2020-03-21T21:54:10.492326 | 2018-06-29T03:24:36 | 2018-06-29T03:24:36 | 139,092,048 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,628 |
java
|
package CASTRO_TOCAFFONDI;
//Autor: CASTRO TOCAFFONDI
public class ListaDoble{
private Nodo primero;
private Nodo ultimo;
public ListaDoble(){
primero=null;
ultimo=null;
}
public boolean esVacia(){
return primero==null;
}
public void insertarFinal(int dato){
Nodo nuevo = new Nodo(dato);
if(!esVacia()){
ultimo.setSiguiente(nuevo);
nuevo.setAnterior(ultimo);
ultimo=nuevo;
}else{//si no existe ningún nodo
primero=nuevo;
ultimo=nuevo;
}
}
public void insertarOrdenado(int dato){
Nodo nuevo = new Nodo(dato);
if(esVacia()){
primero=nuevo;
ultimo=nuevo;
}else{
if(dato<primero.getDato()){
nuevo.setSiguiente(primero);
primero.setAnterior(nuevo);
primero=nuevo;
}else{ //¿si dato >= el contenido del primer nodo?
Nodo antes = primero;
Nodo despues = primero.getSiguiente();
while((despues!=null)&&(dato>despues.getDato())){
antes=despues;
despues=despues.getSiguiente();
}
antes.setSiguiente(nuevo);
nuevo.setAnterior(antes);
if(despues==null){
//antes.setSiguiente(nuevo);
//nuevo.setAnterior(antes);
ultimo=nuevo;
}else{
//antes.setSiguiente(nuevo);
//nuevo.setAnterior(antes);
nuevo.setSiguiente(despues);
despues.setAnterior(nuevo);
}
}
}
}
public void mostrarAdelante(){
if(!esVacia()){
Nodo aux=primero;
while(aux!=null){
System.out.print(aux.getDato()+" - ");
aux=aux.getSiguiente();
}
System.out.println("");
}
}
public void mostrarAtras(){
if(!esVacia()){
Nodo aux=ultimo;
while(aux!=null){
System.out.print(aux.getDato()+" - ");
aux=aux.getAnterior();
}
System.out.println("");
}
}
public int cantidad(){
int contador=0;
if(!esVacia()){
Nodo aux=ultimo;
while(aux!=null){
contador++;
aux=aux.getAnterior();
}
}
return contador;
}
}
|
[
"[email protected]"
] | |
4318d36a0d00c06fffbb50f08a40b3549cd9ceb6
|
5cc47bb914bb8a93a1f128ba16546933f00487da
|
/src/test/java/com/so/Test40.java
|
97fb0bb033aa14a52dac4e9fe7e90f0b98c6b114
|
[
"MIT"
] |
permissive
|
MartinDong/SwordOffer
|
853ee07c11e05f835bdb224a01ff1344df8d942b
|
37986acf4394c1afac5acd45f97fff7e1654d05b
|
refs/heads/master
| 2021-06-30T02:24:55.316273 | 2021-04-16T06:57:01 | 2021-04-16T06:57:01 | 227,557,794 | 1 | 0 |
MIT
| 2020-10-13T18:10:13 | 2019-12-12T08:32:52 |
Java
|
UTF-8
|
Java
| false | false | 513 |
java
|
package com.so;
import org.junit.Test;
import java.util.Arrays;
/**
* 第40题
* 一个整型数组里除了两个数字之外,其他的数字都出现了两次,找出这两个只出现了一次的数字
*
* @author qgl
* @date 2019/03/26
*/
public class Test40 {
@Test
public void test40() throws Exception {
int[] array = {4, 6, 7, 4, 9, 8, 6, 8};
System.out.println("只出现了一次的数字:" + Arrays.toString(FindNumAppearOnce40.findNumAppearOnce(array)));
}
}
|
[
"[email protected]"
] | |
5314015a8d7e76285158b3dc84c20b265e6e472d
|
95e06e0dbb44bcd3e5158c58ccf8da8e86c4cb4f
|
/business/src/main/java/com/wyfx/business/controller/commons/SafetyHatException.java
|
66fc6d74882969ddaf64e132b89d57212b6770f5
|
[] |
no_license
|
muyongliang/safety_hat
|
1b7604bf76e493ce2b93e276a6ffba7c7c3e1334
|
a4c4cca9eb15d7eb2f5c6da7a7c0cb1b05d5d663
|
refs/heads/master
| 2023-02-24T11:08:25.195984 | 2021-01-30T11:21:15 | 2021-01-30T11:21:15 | 323,253,868 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 284 |
java
|
package com.wyfx.business.controller.commons;
/**
* @author johnson liu
* @date 2019/11/2
* @description 自定义系统内部异常类
*/
public class SafetyHatException extends RuntimeException {
public SafetyHatException(String message) {
super(message);
}
}
|
[
"[email protected]"
] | |
8eb0ae061db81429a04dcc444aa91240c676d760
|
d43b1cb3c37a7aed947e7d99d97fdea5f25a24f4
|
/org.ualerts.fixed/org.ualerts.fixed.service/src/test/java/org/ualerts/fixed/service/commands/FindAllActiveBuildingsCommandTest.java
|
6eb03dd9f72a8c4090c3c3992fc4dfef7e1ebe7f
|
[
"Apache-2.0"
] |
permissive
|
mukpal/ualerts-server
|
088dbb6ae6f3faaff69e04dedb6f6bc0b682393c
|
58e921d9251e548e86e84b8041df17f64e746bc2
|
refs/heads/master
| 2020-12-31T06:32:28.561201 | 2013-10-21T14:42:16 | 2013-10-21T14:42:16 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,124 |
java
|
/*
* File created on Oct 9, 2013
*
* Copyright 2008-2011 Virginia Polytechnic Institute and State University
*
* 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.ualerts.fixed.service.commands;
import java.util.ArrayList;
import java.util.List;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.ualerts.fixed.Building;
import org.ualerts.fixed.repository.BuildingRepository;
/**
* Unit tests for {@link FindAllActiveBuildingsCommand}.
*
* @author Brian Early
* @author Michael Irwin
*/
public class FindAllActiveBuildingsCommandTest {
private Mockery context;
private BuildingRepository repository;
private FindAllActiveBuildingsCommand command;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
context = new Mockery();
repository = context.mock(BuildingRepository.class);
command = new FindAllActiveBuildingsCommand();
command.setBuildingRepository(repository);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
command = null;
repository = null;
}
/**
* Test method for
* {@link FindAllActiveBuildingsCommand#onExecute()}.
*/
@Test
public void testOnExecute() throws Exception {
final List<Building> buildings = new ArrayList<Building>();
context.checking(new Expectations() { {
oneOf(repository).findAllActiveBuildings();
will(returnValue(buildings));
} });
command.onExecute();
context.assertIsSatisfied();
}
}
|
[
"[email protected]"
] | |
d56d14cdaa400366544c8a17f0d47fe6e293b065
|
14e8cfd10ea780a3a0941683719d5fcf7242447f
|
/JavaGame/src/Game/Game.java
|
cff885197d1b0674f1805148418bb3a93100536f
|
[] |
no_license
|
ankix86/SpaceWar_Game-Java-Edition-
|
3851262ae2d410e35e9f88f9c217abdaa82b5b7a
|
4ff57cd95932f0a67e4ac72bf291b4a739825f6f
|
refs/heads/master
| 2020-07-30T06:41:32.311450 | 2019-09-22T09:31:45 | 2019-09-22T09:31:45 | 210,121,589 | 1 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 5,678 |
java
|
package Game;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.LinkedList;
import javax.swing.JFrame;
import javax.swing.event.MouseInputListener;
import Game.EntityPkg.EntityA;
import Game.EntityPkg.EntityB;
public class Game extends Canvas implements Runnable{
public static final int WIDHT = 250;
public static final int HIEGHT = WIDHT / 12 * 9;
public final static int SCALE = 2;
public static final String TITLE = "Space War";
public boolean running = false;
public Thread thread;
private BufferedImage image = new BufferedImage(WIDHT, HIEGHT,BufferedImage.TYPE_INT_RGB);
private BufferedImage sheet = null;
private BufferedImage background = null;
private player p;
public Controller c;
GameOver go = new GameOver();
private boolean shooted;
private Textures tex;
private int enemy_Count = 1;
private int enemy_Killed = 0;
public static int HELTH = 100;
Menu m = new Menu();
public LinkedList<EntityA> ea;
public LinkedList<EntityB> eb;
public static enum STATE {
GAME,
MENU,
GAMEOVER
};
public static STATE state = STATE.GAME;
public void Init() {
requestFocus();
BufferImageLoader loader = new BufferImageLoader();
try {
sheet = loader.loadImager("/spritesheet2.png");
background = loader.loadImager("/background.png");
} catch (IOException e) {
e.printStackTrace();
}
addKeyListener(new KeysInput(this));
tex = new Textures(this);
c = new Controller(this,tex);
p = new player(WIDHT * SCALE/ 2, 300,tex,c,this);
c.createEmeny(enemy_Count);
ea = c.getenA();
eb = c.getenB();
this.addMouseListener(new MouseInput());
}
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if(state == STATE.GAME) {
if(key == KeyEvent.VK_LEFT) {
p.setValx(-5);
}else if(key == KeyEvent.VK_RIGHT)
{
p.setValx(5);
}else if(key == KeyEvent.VK_UP){
p.setValy(-5);
}else if(key == KeyEvent.VK_DOWN) {
p.setValy(5);
}
else if(key == KeyEvent.VK_SPACE && !shooted) {
c.addEntity(new Bullet(p.getX(),p.getY()-15 ,tex,c,this));
shooted = true;
}
}
}
public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
if(key == KeyEvent.VK_LEFT) {
p.setValx(0);
}else if(key == KeyEvent.VK_RIGHT)
{
p.setValx(0);
}else if(key == KeyEvent.VK_UP){
p.setValy(0);
}else if(key == KeyEvent.VK_DOWN) {
p.setValy(0);
}else if(key == KeyEvent.VK_SPACE) {
shooted = false;
}
}
private synchronized void Start() {
if(running){
return;
}
running = true;
Thread thread = new Thread(this);
thread.start();
}
private synchronized void stop() throws InterruptedException {
if(!running) {
return;
}
running = false;
thread.join();
System.exit(1);
}
public void run() {
Init();
long lastTime = System.nanoTime();
final double amountsOfTicks = 60;
double ns = 1000000000 / amountsOfTicks;
double delta = 0;
int updates = 0, frames = 0;
long timer = System.currentTimeMillis();
while(running) {
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime = now;
if(delta >= 1) {
tick();
updates++;
delta--;
}
render();
frames++;
if(System.currentTimeMillis() - timer > 1000 ) {
timer += 1000;
System.out.println(updates + "TICKS , FPS :" + frames);
frames = 0;
updates = 0;
}
}
try {
stop();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void tick() {
if(state == STATE.GAME) {
p.tick();
c.tick();
if(enemy_Killed == enemy_Count) {
enemy_Count += 2;
enemy_Killed = 0;
c.createEmeny(enemy_Count);
}
}
}
public void render() {
BufferStrategy bs = this.getBufferStrategy();
if(bs == null) {
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0,getWidth(),getHeight(),this);
g.drawImage(background,0, 0,null);
if(state == STATE.GAME) {
g.setColor(Color.gray);
g.fillRect(400, 10, 100, 20);
g.setColor(Color.red);
g.fillRect(400, 10,HELTH,20);
g.setColor(Color.white);
g.drawRect(400, 10,100,20);
p.render(g);
c.render(g);
//sg.render(g);
}else if(state == STATE.MENU) {
m.render(g);
}else if(state == STATE.GAMEOVER) {
go.render(g);
}
g.dispose();
bs.show();
}
public static void main(String[] args) {
Game game = new Game();
game.setPreferredSize(new Dimension(WIDHT * SCALE, HIEGHT * SCALE));
game.setMaximumSize(new Dimension(WIDHT * SCALE, HIEGHT * SCALE ));
game.setMinimumSize(new Dimension(WIDHT * SCALE, HIEGHT * SCALE ));
JFrame frame = new JFrame(TITLE);
frame.add(game);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
game.Start();
}
public BufferedImage getSpritSheet() {
return sheet;
}
public int getEnemy_Killed() {
return enemy_Killed;
}
public int getEnemy_Count() {
return enemy_Count;
}
public void setEnemy_Count(int e_count) {
this.enemy_Count = e_count;
}
public void setEnemy_Killed(int e_killed) {
this.enemy_Killed = e_killed;
}
}
|
[
"[email protected]"
] | |
a9a9fe3b3d327ea1453637d371fdbf76ae5208c9
|
8d5f1dd03e11c394b0898f2bb0f00933b795aee8
|
/app/src/main/java/de/egi/geofence/geozone/bt/MainEgiGeoZone.java
|
34af374b569efb25261f00315555c498fc16953a
|
[] |
no_license
|
egmontr/EgiGeoZoneBT
|
79e8b949bf8c20bff36bc2824c6376d4adf35c7c
|
db64ff2ffaa4cecd1ec81d3f12d186167ad87348
|
refs/heads/master
| 2021-06-18T18:01:55.281349 | 2021-01-07T18:18:22 | 2021-01-07T18:18:22 | 139,263,441 | 2 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 61,083 |
java
|
package de.egi.geofence.geozone.bt;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Location;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.PowerManager;
import android.os.RemoteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.Geofence;
import com.google.android.gms.location.LocationServices;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.Identifier;
import org.altbeacon.beacon.Region;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import java.io.File;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import de.egi.geofence.geozone.bt.beacon.EgiGeoZoneBeacon;
import de.egi.geofence.geozone.bt.beacon.SimpleBeacon;
import de.egi.geofence.geozone.bt.beacon.SimpleBeaconStore;
import de.egi.geofence.geozone.bt.db.DbGlobalsHelper;
import de.egi.geofence.geozone.bt.db.DbZoneHelper;
import de.egi.geofence.geozone.bt.db.ZoneEntity;
import de.egi.geofence.geozone.bt.fences.BtFence;
import de.egi.geofence.geozone.bt.fences.GeoFence;
import de.egi.geofence.geozone.bt.gcm.GcmRegistrationIntentService;
import de.egi.geofence.geozone.bt.geofence.GeofenceRemover;
import de.egi.geofence.geozone.bt.geofence.GeofenceRequester;
import de.egi.geofence.geozone.bt.geofence.PathsenseGeofence;
import de.egi.geofence.geozone.bt.geofence.SimpleGeofence;
import de.egi.geofence.geozone.bt.geofence.SimpleGeofenceStore;
import de.egi.geofence.geozone.bt.profile.Profiles;
import de.egi.geofence.geozone.bt.utils.Constants;
import de.egi.geofence.geozone.bt.utils.NavDrawerItem;
import de.egi.geofence.geozone.bt.utils.NavDrawerListAdapter;
import de.egi.geofence.geozone.bt.utils.NotificationUtil;
import de.egi.geofence.geozone.bt.utils.RuntimePermissionsActivity;
import de.egi.geofence.geozone.bt.utils.Utils;
import de.mindpipe.android.logging.log4j.LogConfigurator;
// http://www.myandroidsolutions.com/2016/07/13/android-navigation-view-tabs/
// https://www.materialui.co/icons
// http://www.flaticon.com/search/13?word=map
// <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
// <div>Icons made by <a href="http://www.flaticon.com/authors/vignesh-oviyan" title="Vignesh Oviyan">Vignesh Oviyan</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
// <div>Icons made by <a href="http://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
// Icon made by Freepik from www.flaticon.com
public class MainEgiGeoZone extends RuntimePermissionsActivity
implements NavigationView.OnNavigationItemSelectedListener, AdapterView.OnItemClickListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, SwipeRefreshLayout.OnRefreshListener{
private GoogleApiClient mLocationClient;
private final String TAG = "MainEgiGeoZone";
private Location locationMerk = null;
private SwipeRefreshLayout mSwipeRefreshLayout;
private boolean typeGeoZone = true;
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
// Dangerous permissions and permission groups.
// http://developer.android.com/guide/topics/security/permissions.html
public static final int REQUEST_LOCATION = 1;
public static final int REQUEST_WRITE_EXTERNAL_STORAGE = 2;
public static final int REQUEST_PHONE_STATE = 3;
public static final int REQUEST_BLUETOOTH = 4; // Location
public static final int REQUEST_SMS = 5;
public static final int REQUEST_GET_ACCOUNTS = 6;
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
// Manifest.permission.READ_PHONE_STATE,
// Manifest.permission.ACCESS_FINE_LOCATION,
// Manifest.permission.SEND_SMS,
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
// Manifest.permission.GET_ACCOUNTS
public static final String SEED_MASTER = "Ok.KOmM_V04_60#_HugeNdubEl";
// Add geofences handler
private GeofenceRequester mGeofenceRequester;
private PathsenseGeofence mPathsenseGeofence;
// Remove geofences handler
private GeofenceRemover mGeofenceRemover;
// Store the list of geofences to remove
private List<String> mGeofenceIdsToRemove;
// Store the current request
private static Constants.REQUEST_TYPE mRequestType;
// Store the current type of removal
public static Constants.REMOVE_TYPE mRemoveType;
private ListView list;
// Persistent storage for geofences
private SimpleGeofenceStore geofenceStore;
// Persistent storage for Beacons
private SimpleBeaconStore beaconStore;
// Store a list of geofences to add
private List<Geofence> mCurrentGeofences;
// Store a list of beacons to add
private List<EgiGeoZoneBeacon> mCurrentBeacons;
private ArrayList<NavDrawerItem> navDrawerItems;
private DbGlobalsHelper dbGlobalsHelper;
final static LogConfigurator logConfigurator = new LogConfigurator();
private Logger log;
private Toolbar toolbar;
//The BroadcastReceiver that listens for bluetooth broadcasts and status of zones
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
//Device is now connected
GlobalSingleton.getInstance().getBtDevicesConnected().add(device.getName());
} else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
//Device has disconnected
GlobalSingleton.getInstance().getBtDevicesConnected().remove(device.getName());
}else if (Constants.ACTION_STATUS_CHANGED.equals(action)) {
// Status einer Zone hat sich geändert
// Zonen im Drawer neu laden
String state = intent.getStringExtra("state");
if (state.equalsIgnoreCase(Constants.GEOZONE)) {
fillListGeofences();
}else {
fillListBTfences();
}
// list.invalidateViews();
}
}
};
@SuppressLint("BatteryLife")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.onActivityCreateSetTheme(this);
setContentView(R.layout.activity_main_nav);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Utils.changeBackGroundToolbar(this, toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
// BLE-Menu entfernen
if (Build.VERSION.SDK_INT < Constants.BEACON_MIN_BUILD) {
navigationView.getMenu().removeItem(R.id.nav_bt);
}
if (!checkAllNeededPermissions()){
requestAppPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE}, R.string.alertPermissions, 2000);
} else {
init();
}
}
// if (!checkAllNeededPermissions()) {
// // Display UI and wait for user interaction
// android.support.v7.app.AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
// alertDialogBuilder.setMessage(getString(R.string.alertPermissions));
// alertDialogBuilder.setTitle(getString(R.string.titleAlertPermissions));
//
// alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface arg0, int arg1) {
// Intent intent = new Intent();
// intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
// intent.setData(Uri.parse("package:" + getPackageName()));
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
// intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// startActivity(intent);
// finish();
// }
// });
// android.support.v7.app.AlertDialog alertDialog = alertDialogBuilder.create();
// alertDialog.show();
// return;
// }
// }
// super.requestAppPermissions(new String[]{
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
// Manifest.permission.ACCESS_FINE_LOCATION,
// Manifest.permission.GET_ACCOUNTS,
// Manifest.permission.READ_PHONE_STATE,
// Manifest.permission.SEND_SMS},
// R.string.checkAll, REQUEST_WRITE_EXTERNAL_STORAGE);
@SuppressLint("BatteryLife")
protected void init() {
dbGlobalsHelper = new DbGlobalsHelper(this);
String level = dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_LOG_LEVEL);
if (level == null || level.equalsIgnoreCase("")){
level = Level.ERROR.toString();
}
log = Logger.getLogger(MainEgiGeoZone.class);
if (logConfigurator.getFileName().equalsIgnoreCase("android-log4j.log")){
logConfigurator.setFileName(Environment.getExternalStorageDirectory() + File.separator + "egigeozone" + File.separator + "egigeozone.log");
logConfigurator.setUseFileAppender(true);
logConfigurator.setRootLevel(Level.toLevel(level));
// Set log level of a specific logger
logConfigurator.setLevel("de.egi.geofence.geozone.bt", Level.toLevel(level));
try {
logConfigurator.configure();
log.info("Logger set!");
Log.i("", "Logger set!");
} catch (Exception e) {
// Nichts tun. Manchmal kann auf den Speicher nicht zugegriffen werden.
}
}
log.debug("onCreate");
// Akku-Optimierung ausschalten, da sonst kein Netzwerkbetrieb möglich wäre
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
Intent intent = new Intent();
try {
//noinspection StatementWithEmptyBody
if (pm.isIgnoringBatteryOptimizations(packageName)) {
// Nichts tun
} else {
intent.setAction(android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
}catch(Exception e){
// Ignore
}
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
if (((TextView) findViewById(R.id.fences)).getText().equals(getString(R.string.geoZones))) {
// Geofences
Intent ig = new Intent(MainEgiGeoZone.this, GeoFence.class);
ig.putExtra("action", "new");
startActivityForResult(ig, 4730);
}else{
Intent ib = new Intent(MainEgiGeoZone.this, BtFence.class);
ib.putExtra("action", "new");
startActivityForResult(ib, 4731);
}
}
});
// checkPermissionsExternalStorage();
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
// Permanent notifcation, if requested
boolean stickyNotification = Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_STICKY_NOTIFICATION));
if (stickyNotification) {
NotificationUtil.sendPermanentNotification(getApplicationContext(), R.drawable.locating_geo, getString(R.string.text_running_notification), 7676);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
// Instantiate a new geofence storage area
geofenceStore = new SimpleGeofenceStore(this);
// Instantiate a new beacon storage area
beaconStore = new SimpleBeaconStore(this);
// Instantiate the current List of geofences
mCurrentGeofences = new ArrayList<>();
mCurrentBeacons = new ArrayList<>();
navDrawerItems = new ArrayList<>();
dbGlobalsHelper = new DbGlobalsHelper(this);
// globalProperties = dbGlobalsHelper.getCursorAllGlobals();
// PathsenseLocationProviderApi mApi = PathsenseLocationProviderApi.getInstance(this);
// Instantiate a Geofence requester
if (mGeofenceRequester == null){
mGeofenceRequester = new GeofenceRequester(this);
}
if (mPathsenseGeofence == null){
mPathsenseGeofence = new PathsenseGeofence(this);
}
// Instantiate a Geofence remover
mGeofenceRemover = new GeofenceRemover(this);
GlobalSingleton.getInstance().setGeofenceRemover(mGeofenceRemover);
list = (ListView) findViewById (R.id.list);
list.setOnItemClickListener(this);
IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
IntentFilter filter2 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
IntentFilter filter3 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED);
IntentFilter statusFilter = new IntentFilter(Constants.ACTION_STATUS_CHANGED);
this.registerReceiver(mReceiver, filter1);
this.registerReceiver(mReceiver, filter2);
this.registerReceiver(mReceiver, filter3);
this.registerReceiver(mReceiver, statusFilter);
// Check device for Play Services APK. If check succeeds, proceed with GCM registration.
if (servicesConnected()) {
if (Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_GCM))){
String regid = GcmRegistrationIntentService.getRegistrationId(this);
if (regid.isEmpty()) {
// Start IntentService to register this application with GCM.
Intent intent = new Intent(this, GcmRegistrationIntentService.class);
startService(intent);
}
}
} else {
Log.i(TAG, "No valid Google Play Services APK found.");
}
refreshFences();
if (!mCurrentGeofences.isEmpty()){
fillListGeofences();
}else if (!mCurrentBeacons.isEmpty()){
fillListBTfences();
}else{
drawer.openDrawer(GravityCompat.START);
}
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch(item.getItemId()) {
case R.id.action_settings:
if (!checkAllNeededPermissions()){
requestAppPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE}, R.string.alertPermissions, 2000);
return true;
}
log.debug("onOptionsItemSelected: menu_settings");
Intent i5 = new Intent(this, Settings.class);
startActivityForResult(i5, 5004);
return true;
case R.id.action_help:
Intent i2 = new Intent(this, Help.class);
startActivity(i2);
return true;
case R.id.action_profiles:
if (!checkAllNeededPermissions()){
requestAppPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE}, R.string.alertPermissions, 2000);
return true;
}
log.debug("onOptionsItemSelected: menu_profiles");
Intent i3 = new Intent(this, Profiles.class);
startActivityForResult(i3, 5005);
return true;
case R.id.action_tech_info:
log.debug("onOptionsItemSelected: menu_item_info");
Intent i4a = new Intent(this, TechInfo.class);
startActivity(i4a);
return true;
case R.id.action_info:
Intent i4 = new Intent(this, Info.class);
startActivityForResult(i4, 6000);
return true;
case R.id.action_privacy:
Intent i6 = new Intent(this, Privacy.class);
startActivityForResult(i6, 6001);
return true;
case R.id.action_map_all:
if (!checkAllNeededPermissions()){
requestAppPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE}, R.string.alertPermissions, 2000);
return true;
}
log.debug("onOptionsItemSelected: menu_item_map_all");
Intent i7 = new Intent(this, KarteAll.class);
startActivityForResult(i7, 6002);
return true;
case R.id.action_refresh:
if (!checkAllNeededPermissions()){
requestAppPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE}, R.string.alertPermissions, 2000);
return true;
}
log.debug("onOptionsItemSelected: menu_item_refresh");
mSwipeRefreshLayout.setRefreshing(true);
if (typeGeoZone) {
fillListGeofences();
}else{
fillListBTfences();
}
mSwipeRefreshLayout.setRefreshing(false);
return true;
// Pass through any other request
default:
return super.onOptionsItemSelected(item);
}
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
item.setChecked(true);
if (id == R.id.nav_geofence) {
((TextView) findViewById(R.id.fences)).setText(R.string.geoZones);
fillListGeofences();
} else if (id == R.id.nav_bt) {
((TextView) findViewById(R.id.fences)).setText(R.string.btZones);
fillListBTfences();
} else if (id == R.id.nav_profiles) {
log.debug("onNavigationItemSelected: menu_item_profile");
Intent i2 = new Intent(this, Profiles.class);
startActivityForResult(i2, 5005);
} else if (id == R.id.nav_settings) {
log.debug("onNavigationItemSelected: menu_item_settings");
Intent i = new Intent(this, Settings.class);
startActivityForResult(i, 5004);
} else if (id == R.id.nav_info) {
log.debug("onNavigationItemSelected: menu_item_info");
Intent i3 = new Intent(this, Info.class);
startActivityForResult(i3, 6000);
} else if (id == R.id.nav_help) {
log.debug("onNavigationItemSelected: menu_item_help");
Intent i3 = new Intent(this, Help.class);
startActivity(i3);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
private void fillListGeofences(){
if (!super.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION)) return;
locationMerk = null;
typeGeoZone = true;
mLocationClient = new GoogleApiClient.Builder(this, this, this).addApi(LocationServices.API).build();
mLocationClient.connect();
((TextView) findViewById(R.id.fences)).setText(R.string.geoZones);
refreshFences();
setGeofenceList2Drawer();
}
private void fillListBTfences(){
if (!super.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION)) return;
locationMerk = null;
typeGeoZone = false;
mLocationClient = new GoogleApiClient.Builder(this, this, this).addApi(LocationServices.API).build();
mLocationClient.connect();
((TextView) findViewById(R.id.fences)).setText(R.string.btZones);
refreshFences();
setBTfenceList2Drawer();
}
private void setGeofenceList2Drawer() {
navDrawerItems.clear();
// Gespeicherte GeoZonen auflisten
for (int i = 0; i < mCurrentGeofences.size(); i++) {
Geofence geofence = mCurrentGeofences.get(i);
String dist = "";
if (locationMerk != null){
// Calculate distance to fence center
try {
DbZoneHelper dbZoneHelper = new DbZoneHelper(this);
ZoneEntity zoneEntity = dbZoneHelper.getCursorZoneByName(geofence.getRequestId());
Location locationZone = new Location("locationZone");
locationZone.setLatitude(Double.valueOf(zoneEntity.getLatitude()));
locationZone.setLongitude(Double.valueOf(zoneEntity.getLongitude()));
float distanceMeters = locationMerk.distanceTo(locationZone);
if (distanceMeters < 50) {
dist = getString(R.string.distanceLess);
} else if (distanceMeters < 1000) {
NumberFormat formatter = NumberFormat.getInstance(Locale.getDefault());
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
formatter.setRoundingMode(RoundingMode.HALF_UP);
String formatedFloat = formatter.format(distanceMeters);
dist = getString(R.string.distance) + " " + formatedFloat + "m";
} else {
NumberFormat formatter = NumberFormat.getInstance(Locale.getDefault());
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
formatter.setRoundingMode(RoundingMode.HALF_UP);
String formatedFloat = formatter.format(distanceMeters / 1000);
dist = getString(R.string.distance) + " " + formatedFloat + "km";
}
}catch(Exception e){
dist = getString(R.string.distanceNa);
}
}else{
dist = getString(R.string.distanceNa);
}
if (geofenceStore.getGeofence(geofence.getRequestId()).isStatus()) {
navDrawerItems.add(new NavDrawerItem(geofence.getRequestId(), R.drawable.ic_green_circle_24dp, dist));
} else {
navDrawerItems.add(new NavDrawerItem(geofence.getRequestId(), R.drawable.ic_red_circle_24dp, dist));
}
}
// Sorting
Collections.sort(navDrawerItems, new Comparator<NavDrawerItem>() {
public int compare(NavDrawerItem item2, NavDrawerItem item1)
{
return item2.getZone().compareToIgnoreCase(item1.getZone());
}
});
// setting the nav drawer list adapter
NavDrawerListAdapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
list.setAdapter(adapter);
}
private void setBTfenceList2Drawer(){
navDrawerItems.clear();
int z = 0;
// Gespeicherte Beacons auflisten
for (int i = 0; i < mCurrentBeacons.size(); i++) {
EgiGeoZoneBeacon beacon = mCurrentBeacons.get(i);
String dist = "";
if (locationMerk != null) {
// Calculate distance to fence center
try {
DbZoneHelper dbZoneHelper = new DbZoneHelper(this);
ZoneEntity zoneEntity = dbZoneHelper.getCursorZoneByName(beacon.getBeaconId());
Location locationZone = new Location("beaconZone");
if (zoneEntity.getLatitude() == null || zoneEntity.getLongitude() == null) {
dist = getString(R.string.distanceNa);
} else {
locationZone.setLatitude(Double.valueOf(zoneEntity.getLatitude()));
locationZone.setLongitude(Double.valueOf(zoneEntity.getLongitude()));
float distanceMeters = locationMerk.distanceTo(locationZone);
if (distanceMeters < 50) {
dist = getString(R.string.distanceLess);
} else if (distanceMeters < 1000) {
NumberFormat formatter = NumberFormat.getInstance(Locale.getDefault());
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
formatter.setRoundingMode(RoundingMode.HALF_UP);
String formatedFloat = formatter.format(distanceMeters);
dist = getString(R.string.distance) + " " + formatedFloat + "m";
} else {
NumberFormat formatter = NumberFormat.getInstance(Locale.getDefault());
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(2);
formatter.setRoundingMode(RoundingMode.HALF_UP);
String formatedFloat = formatter.format(distanceMeters / 1000);
dist = getString(R.string.distance) + " " + formatedFloat + "km";
}
}
} catch (Exception e) {
dist = getString(R.string.distanceNa);
}
} else {
dist = getString(R.string.distanceNa);
}
if (beaconStore.getBeacon(beacon.getBeaconId()).isStatus()){
navDrawerItems.add(new NavDrawerItem(beacon.getBeaconId(), R.drawable.ic_green_circle_24dp, dist));
}else{
navDrawerItems.add(new NavDrawerItem(beacon.getBeaconId(), R.drawable.ic_red_circle_24dp, dist));
}
}
// Sorting
Collections.sort(navDrawerItems, new Comparator<NavDrawerItem>() {
public int compare(NavDrawerItem item2, NavDrawerItem item1)
{
return item2.getZone().compareToIgnoreCase(item1.getZone());
}
});
// setting the nav drawer list adapter
NavDrawerListAdapter adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
list.setAdapter(adapter);
}
private List<SimpleGeofence> refreshFences() {
mCurrentBeacons.clear();
List<SimpleBeacon> beacons = beaconStore.getBeacons();
for (SimpleBeacon simpleBeacon : beacons)
{
mCurrentBeacons.add(simpleBeacon.toBeacon());
}
mCurrentGeofences.clear();
List<SimpleGeofence> geofences = geofenceStore.getGeofences();
for (SimpleGeofence simpleGeofence : geofences)
{
mCurrentGeofences.add(simpleGeofence.toGeofence());
}
return geofences;
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
NavDrawerListAdapter navDrawerListAdapter = (NavDrawerListAdapter)adapterView.getAdapter();
NavDrawerItem navDrawerItem = (NavDrawerItem)navDrawerListAdapter.getItem(i);
String zone = navDrawerItem.getZone();
if (((TextView) findViewById(R.id.fences)).getText().equals(getString(R.string.geoZones))) {
// Geofences
Intent is = new Intent(this, GeoFence.class);
is.putExtra("action", "update");
is.putExtra("zone", zone);
startActivityForResult(is, 4730);
}else{
// BTfences
Intent is = new Intent(this, BtFence.class);
is.putExtra("action", "update");
is.putExtra("beaconName", zone);
startActivityForResult(is, 4731);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
// If the request code matches the code sent in onConnectionFailed
case Constants.CONNECTION_FAILURE_RESOLUTION_REQUEST :
switch (resultCode) {
// If Google Play services resolved the problem
case Activity.RESULT_OK:
// If the request was to add geofences
if (Constants.REQUEST_TYPE.ADD == mRequestType) {
// Restart the process of adding the current geofences
if (mCurrentGeofences.size() > 0) {
mGeofenceRequester.addGeofences(mCurrentGeofences);
}
// If the request was to remove geofences
} else if (Constants.REQUEST_TYPE.REMOVE == mRequestType ){
// Toggle the removal flag and send a new removal request
mGeofenceRemover.setInProgressFlag(false);
// If the removal was by Intent
if (Constants.REMOVE_TYPE.INTENT == mRemoveType) {
// Restart the removal of all geofences for the PendingIntent
mGeofenceRemover.removeGeofencesByIntent(
mGeofenceRequester.getRequestPendingIntent());
// If the removal was by a List of geofence IDs
} else {
// Restart the removal of the geofence list
mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove);
}
}
break;
// If any other result was returned by Google Play services
default:
// Report that Google Play services was unable to resolve the problem.
Log.d(Constants.APPTAG, getString(R.string.no_resolution));
log.info("onActivityResult: " + getString(R.string.no_resolution));
}
// Geofence hinzufügen und starte die Überwachung
case 4730 :
if (resultCode == RESULT_OK) {
String action = null;
if (intent != null) {
action = intent.getStringExtra("action");
}
if (action.equalsIgnoreCase("delete")) {
String zoneToDelete = intent.getStringExtra("zoneToDelete");
if (zoneToDelete == null || zoneToDelete.equalsIgnoreCase("")){
return;
}
deleteNow(zoneToDelete);
// Display Liste mit Zonen
refreshFences();
setGeofenceList2Drawer();
} else {
String zoneToAdd = intent.getStringExtra("zoneToAdd");
if (zoneToAdd == null || zoneToAdd.equalsIgnoreCase("")){
return;
}
// Display Liste mit Zonen
List<SimpleGeofence> geofences = refreshFences();
setGeofenceList2Drawer();
// Start the request. Fail if there's already a request in progress
try {
// Try to add geofences
mRequestType = Constants.REQUEST_TYPE.ADD;
if (mCurrentGeofences.size() > 0) {
// Old style, without trying to repair
// if (!Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_FALSE_POSITIVES))) {
if (!Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_NEW_API))) {
mGeofenceRequester.addGeofences(mCurrentGeofences);
} else {
for (SimpleGeofence simpleGeofence : geofences) {
mPathsenseGeofence.addGeofence(simpleGeofence);
}
}
// } else {
// DbZoneHelper dbZoneHelper = new DbZoneHelper(this);
// ZoneEntity ze = dbZoneHelper.getCursorZoneByName(zoneToAdd);
// if (!Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_NEW_API))) {
// Geofence geof = new Geofence.Builder().setRequestId(zoneToAdd)
// .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
// .setCircularRegion(Double.valueOf(ze.getLatitude()), Double.valueOf(ze.getLongitude()), ze.getRadius())
// .setExpirationDuration(Geofence.NEVER_EXPIRE)
// .build();
//
// List<Geofence> currentGeofence = new ArrayList<>();
// currentGeofence.add(geof);
//
// mGeofenceRequester.addGeofences(currentGeofence);
// } else {
// SimpleGeofence simpleGeofence = new SimpleGeofence(zoneToAdd, ze.getLatitude(), ze.getLongitude(),
// Integer.toString(ze.getRadius()), null, Geofence.NEVER_EXPIRE, Geofence.GEOFENCE_TRANSITION_ENTER, true, null, null);
// mPathsenseGeofence.addGeofence(simpleGeofence);
// }
// }
}
} catch (UnsupportedOperationException e) {
// Notify user that previous request hasn't finished.
Toast.makeText(this, R.string.add_geofences_already_requested_error, Toast.LENGTH_LONG).show();
log.error("Error registering Geofence", e);
showError("Error registering Geofence", e.toString());
}
}
}
break;
// BT fence
case 4731 :
// Display Liste mit Beacons und starte die Überwachung, wenn automatisch
if (resultCode == RESULT_OK) {
String action = null;
String mBeaconId = null;
if (intent != null) {
action = intent.getStringExtra("action");
mBeaconId = intent.getStringExtra("beaconBeaconId");
}
if (action.equalsIgnoreCase("delete")) {
String zoneToDelete = intent.getStringExtra("zoneToDelete");
if (zoneToDelete == null || zoneToDelete.equalsIgnoreCase("")){
return;
}
onDeleteBeaconNow(zoneToDelete, mBeaconId);
// Display Liste mit Zonen
refreshFences();
setBTfenceList2Drawer();
} else {
// action = add
String region = null;
boolean automatic = true;
if (intent != null) {
region = intent.getStringExtra("beaconRegion");
mBeaconId = intent.getStringExtra("beaconBeaconId");
automatic = intent.getBooleanExtra("beaconMode", true);
}
refreshFences();
setBTfenceList2Drawer();
List<Identifier> listB = Utils.getStringIdentifiers(mBeaconId);
BeaconManager mBeaconManager = BeaconManager.getInstanceForApplication(this);
Region singleBeaconRegion = new Region(region, listB);
try {
if (automatic) { // true = automatic
mBeaconManager.startRangingBeaconsInRegion(singleBeaconRegion);
mBeaconManager.startMonitoringBeaconsInRegion(singleBeaconRegion);
}
} catch (RemoteException ignored) {
}
}
}
break;
// Settings
case 5004 :
if (resultCode == RESULT_OK) {
// Nur wenn Import war, dann durchlaufen
boolean imp = intent.getBooleanExtra("import", false);
if (imp){
// Drawer neu setzen
List<SimpleGeofence> geofences = refreshFences();
mRequestType = Constants.REQUEST_TYPE.ADD;
// Start the request. Fail if there's already a request in progress
try {
// Try to add geofences
if (mCurrentGeofences.size() > 0) {
if (!Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_NEW_API))) {
if (!servicesConnected()) {
return;
}
mGeofenceRequester.addGeofences(mCurrentGeofences);
}else {
for (SimpleGeofence simpleGeofence : geofences) {
mPathsenseGeofence.addGeofence(simpleGeofence);
}
}
}
} catch (UnsupportedOperationException e) {
// Notify user that previous request hasn't finished.
Toast.makeText(this, R.string.add_geofences_already_requested_error, Toast.LENGTH_LONG).show();
log.error("Import: Error registering Geofence", e);
showError("Import: Error registering Geofence", e.toString());
}
//
// Settings wieder aufrufen, da Aktion Import war
log.debug("onOptionsItemSelected: menu_settings");
Intent i5 = new Intent(this, Settings.class);
Bundle b = new Bundle();
b.putBoolean("import", true);
i5.putExtras(b);
startActivityForResult(i5, 5004);
}
}
refreshFences();
setGeofenceList2Drawer();
break;
// If any other request code was received
default:
// Report that this Activity received an unknown requestCode
Log.d(Constants.APPTAG, getString(R.string.unknown_activity_request_code, requestCode));
break;
}
}
/**
* Fehlerdialog anzeigen
*/
private void showError(String title, String error){
Log.d(TAG, error);
NotificationUtil.showError(getApplicationContext(), title, error);
}
/**
* Called when the user clicks the "Remove geofence" button #### Eine Zone löschen ####
*/
private void deleteNow(String zone) {
log.info("deleteNow: Remove geofence " + zone);
// Create a List of 1 Geofence with the ID= name and store it in the global list
mGeofenceIdsToRemove = Collections.singletonList(zone);
/*
* Record the removal as remove by list. If a connection error occurs,
* the app can automatically restart the removal if Google Play services
* can fix the error
*/
mRemoveType = Constants.REMOVE_TYPE.LIST;
/*
* Check for Google Play services. Do this after
* setting the request type. If connecting to Google Play services
* fails, onActivityResult is eventually called, and it needs to
* know what type of request was in progress.
*/
// Try to remove the geofence
try {
if (!Utils.isBoolean(dbGlobalsHelper.getCursorGlobalsByKey(Constants.DB_KEY_NEW_API))) {
if (!servicesConnected()) {
return;
}
mGeofenceRemover.removeGeofencesById(mGeofenceIdsToRemove);
}else {
mPathsenseGeofence.removeGeofence(zone);
}
// Catch errors with the provided geofence IDs
} catch (IllegalArgumentException e) {
log.error(zone + ": Error removing Geofence", e);
showError(zone + ": Error removing Geofence", e.toString());
return;
} catch (UnsupportedOperationException e) {
// Notify user that previous request hasn't finished.
Toast.makeText(this, R.string.remove_geofences_already_requested_error, Toast.LENGTH_LONG).show();
log.error(zone + ": Error removing Geofence", e);
showError(zone + ": Error removing Geofence", e.toString());
return;
}
// Remove zone
DbZoneHelper dbZoneHelper = new DbZoneHelper(this);
dbZoneHelper.deleteZone(zone);
}
/**
* Called when the user clicks the "Remove beacon" button #### Ein Beacon löschen ####
*/
private void onDeleteBeaconNow(String region, String mBeaconId) {
/*
* Remove a beacon
*/
log.info("onDeleteBeaconNow: Remove beacon " + region);
/*
* Beaconliste neu aufbauen
*/
if(!mBeaconId.equals("##")) {
List<Identifier> listB = Utils.getStringIdentifiers(mBeaconId);
BeaconManager mBeaconManager = BeaconManager.getInstanceForApplication(this);
Region singleBeaconRegion = new Region(region, listB);
try {
mBeaconManager.stopRangingBeaconsInRegion(singleBeaconRegion);
mBeaconManager.stopMonitoringBeaconsInRegion(singleBeaconRegion);
} catch (RemoteException ignored) {
}
}
// Remove a flattened beacon object from storage
DbZoneHelper dbZoneHelper = new DbZoneHelper(this);
dbZoneHelper.deleteZone(region);
}
/**
* Verify that Google Play services is available before making a request.
*
* @return true if Google Play services is available, otherwise false
*/
private boolean servicesConnected() {
log.debug("servicesConnected");
// Check that Google Play services is available
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int code = api.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == code) {
// In debug mode, log the status
Log.d(Constants.APPTAG, getString(R.string.play_services_available));
log.info("servicesConnected result from Google Play Services: " + getString(R.string.play_services_available));
// Continue
return true;
// Google Play services was not available for some reason
} else if (api.isUserResolvableError(code)){
log.error("servicesConnected result: could not connect to Google Play services");
api.showErrorDialogFragment(this, code, Constants.PLAY_SERVICES_RESOLUTION_REQUEST);
} else {
log.error("servicesConnected result: could not connect to Google Play services");
Toast.makeText(this, api.getErrorString(code), Toast.LENGTH_LONG).show();
}
return false;
}
/**
* Define a DialogFragment to display the error dialog generated in
* showErrorDialog.
*/
public static class ErrorDialogFragment extends DialogFragment {
// Global field to contain the error dialog
private Dialog mDialog;
/**
* Default constructor. Sets the dialog field to null
*/
public ErrorDialogFragment() {
super();
mDialog = null;
}
/**
* Set the dialog to display
*
* @param dialog An error dialog
*/
public void setDialog(Dialog dialog) {
mDialog = dialog;
}
/*
* This method must return a Dialog to the DialogFragment.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return mDialog;
}
}
// // Berechtigungen ExternalStorage
// private void checkPermissionsExternalStorage(){
// //noinspection StatementWithEmptyBody
// if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// // Check Permissions Now
// if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// // Display UI and wait for user interaction
// AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
// alertDialogBuilder.setMessage(getString(R.string.checkExtStorage));
// alertDialogBuilder.setTitle(getString(R.string.titleExtStorage));
//
// alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface arg0, int arg1) {
// ActivityCompat.requestPermissions(MainEgiGeoZone.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_EXTERNAL_STORAGE);
// }
// });
// AlertDialog alertDialog = alertDialogBuilder.create();
// alertDialog.show();
//
// } else {
// ActivityCompat.requestPermissions(MainEgiGeoZone.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_EXTERNAL_STORAGE);
// }
// } else {
// // permission has been granted, continue as usual
//// Toast.makeText(this,"permission has been granted, continue as usual",Toast.LENGTH_LONG).show();
// }
// }
// public void onRequestPermissionsResult(final int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
//// http://stackoverflow.com/questions/30719047/android-m-check-runtime-permission-how-to-determine-if-the-user-checked-nev
// String perm = "";
// String title = "";
// String descNeverAsk = "";
// String descAsk = "";
//// boolean goToSettings = false;
//
// if (requestCode == REQUEST_LOCATION) {
// perm = Manifest.permission.ACCESS_FINE_LOCATION;
// descAsk = getString(R.string.descAskLocation);
// descNeverAsk = getString(R.string.descNeverAskLocation);
// title = getString(R.string.titleLocation);
// }
//
// if (requestCode == REQUEST_BLUETOOTH) {
// perm = Manifest.permission.ACCESS_FINE_LOCATION;
// descAsk = getString(R.string.descAskLocationBT);
// descNeverAsk = getString(R.string.descNeverAskLocationBT);
// title = getString(R.string.titleLocation);
// }
//
// if (requestCode == REQUEST_WRITE_EXTERNAL_STORAGE) {
// perm = Manifest.permission.WRITE_EXTERNAL_STORAGE;
// descAsk = getString(R.string.descAskExtStorage);
// descNeverAsk = getString(R.string.descNeverAskExtStorage);
// title = getString(R.string.titleExtStorage);
// }
//
//
// //noinspection StatementWithEmptyBody
// if(grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// // We can now safely use the API we requested access to
//// Toast.makeText(this,"We can now safely use the API we requested access to",Toast.LENGTH_LONG).show();
// } else {
// // Permission was denied or request was cancelled
// boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0]);
// if (!showRationale) {
//// Toast.makeText(this, "Permission was denied with flag NEVER ASK AGAIN",Toast.LENGTH_LONG).show();
// // user denied flagging NEVER ASK AGAIN
// // you can either enable some fall back,
// // disable features of your app
// // or open another dialog explaining
// // again the permission and directing to
// // the app setting
// AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
// alertDialogBuilder.setMessage(descNeverAsk);
// alertDialogBuilder.setTitle(title);
//
//// final boolean finalGoToSettings = false;
// alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface arg0, int arg1) {
//// Toast.makeText(MainActivity.this,"You clicked yes button",Toast.LENGTH_LONG).show();
// // Benutzer hat mit nicht mehr fragen geantwortet.
// // Dialog mit Erklärung und zu den App-Settings leiten
//// if (finalGoToSettings) {
//// Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
//// Uri uri = Uri.fromParts("package", getPackageName(), null);
//// intent.setData(uri);
//// startActivityForResult(intent, 3);
//// }
// }
// });
// AlertDialog alertDialog = alertDialogBuilder.create();
// alertDialog.show();
//
// } else{
// // user denied WITHOUT never ask again
// // this is a good place to explain the user
// // why you need the permission and ask if he want
// // to accept it (the rationale)
//// Toast.makeText(this, "Permission was denied or request was cancelled",Toast.LENGTH_LONG).show();
// // Nochmals Dialog mit Erklärung und dann wieder anfragen
// AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
// alertDialogBuilder.setMessage(descAsk);
// alertDialogBuilder.setTitle(title);
//
// final String finalPerm = perm;
// alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface arg0, int arg1) {
// ActivityCompat.requestPermissions(MainEgiGeoZone.this, new String[]{finalPerm}, requestCode);
//// Toast.makeText(MainActivity.this,"You clicked yes button",Toast.LENGTH_LONG).show();
// }
// });
// AlertDialog alertDialog = alertDialogBuilder.create();
// alertDialog.show();
// }
// }
// }
@Override
public void onPermissionsGranted(int requestCode) {
init();
}
// private boolean checkPermissionsLocation() {
// //noinspection StatementWithEmptyBody
// if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// // Check Permissions Now
// if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
// // Display UI and wait for user interaction
// android.support.v7.app.AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
// alertDialogBuilder.setMessage(getString(R.string.checkLocation));
// alertDialogBuilder.setTitle(getString(R.string.titleLocation));
//
// alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface arg0, int arg1) {
// ActivityCompat.requestPermissions(MainEgiGeoZone.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MainEgiGeoZone.REQUEST_LOCATION);
// }
// });
// android.support.v7.app.AlertDialog alertDialog = alertDialogBuilder.create();
// alertDialog.show();
// return true;
// } else {
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MainEgiGeoZone.REQUEST_LOCATION);
// }
// } else {
// // permission has been granted, continue as usual
//// Toast.makeText(this, "permission has been granted, continue as usual", Toast.LENGTH_LONG).show();
// }
// return false;
// }
@SuppressLint("SetTextI18n")
@Override
public void onConnected(@Nullable Bundle bundle) {
// If Google Play Services is available
if (servicesConnected()) {
// Get the current location
Location currentLocation = null;
try{
currentLocation = LocationServices.FusedLocationApi.getLastLocation(mLocationClient);
}catch(SecurityException se){
// Display UI and wait for user interaction
android.support.v7.app.AlertDialog.Builder alertDialogBuilder = Utils.onAlertDialogCreateSetTheme(this);
alertDialogBuilder.setMessage(getString(R.string.alertPermissions));
alertDialogBuilder.setTitle(getString(R.string.titleAlertPermissions));
alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
android.support.v7.app.AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
if (currentLocation != null){
// Start test
log.debug("onConnected - location: " + (Double.valueOf(currentLocation.getLatitude()).toString()) + "##" + (Double.valueOf(currentLocation.getLongitude()).toString()));
locationMerk = currentLocation;
}else{
// Toast.makeText(this, "Could not determine location. ", Toast.LENGTH_LONG).show();
log.error("Could not determine location.");
}
}
refreshFences();
if (typeGeoZone){
setGeofenceList2Drawer();
}else{
setBTfenceList2Drawer();
}
mLocationClient.disconnect();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onRefresh() {
log.debug("onRefresh called from SwipeRefreshLayout");
if (typeGeoZone) {
fillListGeofences();
}else{
fillListBTfences();
}
mSwipeRefreshLayout.setRefreshing(false);
}
}
|
[
"armino2001"
] |
armino2001
|
f47ca0ef78ba758caaa5669339936eaf2d158aed
|
d9d26915b60f569cf438bd657d98082bf48e621b
|
/src/main/java/kaptainwutax/featureutils/decorator/ore/overworld/AndesiteOre.java
|
d8b676440ad909a7921442943fc87a2ab47cd808
|
[
"MIT"
] |
permissive
|
KaptainWutax/FeatureUtils
|
42711e63c34c2c8a981c6f25e8bd79a1d64be697
|
a271711f58e283547634ca31e466b9b8b0e5d825
|
refs/heads/master
| 2023-04-25T18:10:33.349979 | 2022-08-17T20:59:19 | 2022-08-17T20:59:19 | 268,331,926 | 30 | 23 |
MIT
| 2023-06-30T21:04:32 | 2020-05-31T17:42:37 |
Java
|
UTF-8
|
Java
| false | false | 1,106 |
java
|
package kaptainwutax.featureutils.decorator.ore.overworld;
import kaptainwutax.featureutils.decorator.ore.HeightProvider;
import kaptainwutax.featureutils.decorator.ore.RegularOreDecorator;
import kaptainwutax.mcutils.block.Blocks;
import kaptainwutax.mcutils.version.MCVersion;
import kaptainwutax.mcutils.version.VersionMap;
public class AndesiteOre extends RegularOreDecorator<RegularOreDecorator.Config, RegularOreDecorator.Data<AndesiteOre>> {
public static final VersionMap<Config> CONFIGS = new VersionMap<Config>()
.add(MCVersion.v1_13, new Config(4, 4, 33, 10, HeightProvider.range(0, 0, 80), Blocks.ANDESITE, BASE_STONE_OVERWORLD))
.add(MCVersion.v1_16, new Config(4, 6, 33, 10, HeightProvider.range(0, 0, 80), Blocks.ANDESITE, BASE_STONE_OVERWORLD))
.add(MCVersion.v1_17, new Config(4, 6, 33, 10, HeightProvider.uniformRange(0, 79), Blocks.ANDESITE, BASE_STONE_OVERWORLD));
public AndesiteOre(MCVersion version) {
super(CONFIGS.getAsOf(version), version);
}
@Override
public String getName() {
return name();
}
public static String name() {
return "andesite_ore";
}
}
|
[
"[email protected]"
] | |
8fe5e292bd960036c754abdc3842e6b59fd39b68
|
d224a60a6bb72701a9f24387c1d6bfdf95a4f08e
|
/Liang/Chapter6/Question6_39.java
|
af3b5d0f63e349556fd65ba941a7c9fd5735aa92
|
[
"MIT"
] |
permissive
|
akinfotech19/IntroductionToJavaProgramming
|
34501122994f24f5fda02efcc47938ec57671e26
|
5006fe23a05658a42c08eb114d62e63c1a107cf4
|
refs/heads/master
| 2022-01-10T23:00:13.181918 | 2019-07-01T15:13:09 | 2019-07-01T15:13:09 | 266,969,874 | 1 | 0 |
MIT
| 2020-05-26T07:07:46 | 2020-05-26T07:07:45 | null |
UTF-8
|
Java
| false | false | 2,029 |
java
|
import java.util.Scanner;
public class Question6_39 {
public static double crossProduct(double x0, double y0, double x1, double y1, double x2, double y2) {
return (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0);
}
public static boolean leftOfTheLine(double x0, double y0, double x1, double y1, double x2, double y2) {
return crossProduct(x0, y0, x1, y1, x2, y2) > 0;
}
public static boolean onTheSameLine(double x0, double y0, double x1, double y1, double x2, double y2) {
return crossProduct(x0, y0, x1, y1, x2, y2) == 0;
}
public static boolean onTheLineSegment(double x0, double y0, double x1, double y1, double x2, double y2) {
return onTheSameLine(x0, y0, x1, y1, x2, y2) && (distanceBetweenPoints(x0, y0, x1, y1) == (distanceBetweenPoints(x0, y0, x2, y2) + distanceBetweenPoints(x1, y1, x2, y2)));
}
public static double distanceBetweenPoints(double x0, double y0, double x1, double y1) {
return Math.sqrt(Math.pow(y1 - y0, 2) + Math.pow(x1 - x0, 2));
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter three points for p0, p1, and p2: ");
double x0 = scanner.nextDouble();
double y0 = scanner.nextDouble();
double x1 = scanner.nextDouble();
double y1 = scanner.nextDouble();
double x2 = scanner.nextDouble();
double y2 = scanner.nextDouble();
if (leftOfTheLine(x0, y0, x1, y1, x2, y2)) {
System.out.printf("(%.1f, %.1f) is on the left side of the line from (%.1f, %.1f) to (%.1f, %.1f)\n", x2, y2, x0, y0, x1, y1);
} else if (onTheLineSegment(x0, y0, x1, y1, x2, y2)) {
System.out.printf("(%.1f, %.1f) is on the line segment from (%.1f, %.1f) to (%.1f, %.1f)\n", x2, y2, x0, y0, x1, y1);
} else if (onTheSameLine(x0, y0, x1, y1, x2, y2)) {
System.out.printf("(%.1f, %.1f) is on the same line from (%.1f, %.1f) to (%.1f, %.1f)\n", x2, y2, x0, y0, x1, y1);
} else {
System.out.printf("(%.1f, %.1f) is on the right side of the line from (%.1f, %.1f) to (%.1f, %.1f)\n", x2, y2, x0, y0, x1, y1);
}
}
}
|
[
"[email protected]"
] | |
dba7d70a8d5be8889dae8b10e2387eff25d50f74
|
ce31f8de02cfa09892e676a11efb349d3ec9b470
|
/weibo/lib-weibo-sina/src/main/java/weibo4j/examples/timeline/GetMentions.java
|
023490ede4b19ed902a2affa0572d2755fa0c602
|
[] |
no_license
|
yingrui/websiteschema
|
2582a62701b218a6ccbe889dbd3639a4e9dfed75
|
329ff626a2331b140ccd97c1c728d76fbfb51dc8
|
refs/heads/master
| 2021-01-16T21:16:18.161400 | 2015-01-21T10:35:09 | 2015-01-21T10:35:28 | 28,562,587 | 2 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 635 |
java
|
package weibo4j.examples.timeline;
import java.util.List;
import weibo4j.Timeline;
import weibo4j.Weibo;
import weibo4j.examples.Log;
import weibo4j.model.Status;
import weibo4j.model.WeiboException;
public class GetMentions {
/**
* @param args
*/
public static void main(String[] args) {
String access_token = args[0];
Weibo weibo = new Weibo();
weibo.setToken(access_token);
Timeline tm = new Timeline();
try {
List<Status> status = tm.getMentions();
for(Status s : status){
Log.logInfo(s.toString());
}
} catch (WeiboException e) {
e.printStackTrace();
}
}
}
|
[
"[email protected]"
] | |
28d63b1da23325861e8f17a95d8ef9b1b7d5eae2
|
50995ba7e56c7ee7f379a02ed78274ad690a46d4
|
/app/src/main/java/com/example/shreyaprabhu/contactsapp/Realm/RealmRecyclerViewAdapater.java
|
59e90af6fdcea15a562bf418c3f39d57c3167370
|
[] |
no_license
|
ShreyaPrabhu/ContactsApp
|
210178c0803e1efb7209834279befeb6c1048360
|
13f73ba3cf7fe6116b725cddebae0cbdebbab829
|
refs/heads/master
| 2020-06-02T22:46:55.324366 | 2017-06-22T17:18:41 | 2017-06-22T17:18:41 | 94,109,888 | 0 | 1 | null | null | null | null |
UTF-8
|
Java
| false | false | 676 |
java
|
package com.example.shreyaprabhu.contactsapp.Realm;
import android.support.v7.widget.RecyclerView;
import io.realm.RealmBaseAdapter;
import io.realm.RealmObject;
/**
* Created by ShreyaPrabhu on 10-06-2017.
*/
public abstract class RealmRecyclerViewAdapater<T extends RealmObject> extends RecyclerView.Adapter {
private RealmBaseAdapter<T> realmBaseAdapter;
public T getItem(int position) {
return realmBaseAdapter.getItem(position);
}
public RealmBaseAdapter<T> getRealmAdapter() {
return realmBaseAdapter;
}
public void setRealmAdapter(RealmBaseAdapter<T> realmAdapter) {
realmBaseAdapter = realmAdapter;
}
}
|
[
"[email protected]"
] | |
fe98ad4a4efffc989c6694ec38cd8b1d5697a4b9
|
63ec88ab4254c47d49e18dbdb9bd1f9215ed6352
|
/src/main/java/com/java/foruforme/services/UserService.java
|
bbdc92a8f3238c2a09f18594aa16bdf00eedb1fb
|
[] |
no_license
|
jcasorla/ForUForMe
|
0f85501c8665267561bc64bbc78033ab1733b902
|
5ddfcdee0ccadc056ba9c8b871b53f3956715d29
|
refs/heads/master
| 2020-08-23T17:53:20.112562 | 2019-10-25T01:38:40 | 2019-10-25T01:38:40 | 216,676,234 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,432 |
java
|
package com.java.foruforme.services;
import java.util.Optional;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
import com.java.foruforme.models.User;
import com.java.foruforme.repositories.UserRepository;
@Service
public class UserService {
private final UserRepository userRepository;
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
public User registerUser(User user) {
String hashed = BCrypt.hashpw(user.getPassword(), BCrypt.gensalt());
user.setPassword(hashed);
return userRepository.save(user);
}
public User findByEmail(String email) {
return userRepository.findByEmail(email);
}
public User findUserById(Long id) {
Optional<User> u = userRepository.findById(id);
if(u.isPresent()) {
return u.get();
} else {
return null;
}
}
public boolean authenticateUser(String email, String password) {
User user = userRepository.findByEmail(email);
if(user == null) {
return false;
} else {
if(BCrypt.checkpw(password, user.getPassword())) {
return true;
} else {
return false;
}
}
}
public User updateProfile(User user) {
userRepository.save(user);
return user;
}
}
|
[
"[email protected]"
] | |
79761406b1a7bb3c20fd457c04509d2f69562f76
|
70d9a8991685c51d4e5756b0b0ffe292d1483577
|
/pathfinding/src/hr/fer/zemris/zavrsni/rts/pathfinding/SearchResult.java
|
24a7755c03b26f71060b9f04a3318e3de9da26ca
|
[] |
no_license
|
LeonLuttenberger/Thesis-RTS
|
9f5e7e5751fb2e51be1c7fc321aca810dcd44d97
|
44427debc30213b450048f434ca59af97eb5ecf5
|
refs/heads/master
| 2021-03-27T09:45:16.485192 | 2017-07-07T08:56:32 | 2017-07-07T08:56:32 | 86,237,917 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 780 |
java
|
package hr.fer.zemris.zavrsni.rts.pathfinding;
import java.util.Map;
import java.util.Queue;
public class SearchResult<T> {
private final Queue<SearchNode<T>> statesQueue;
private final Map<T, Double> closedMap;
private final Queue<SearchNode<T>> frontierQueue;
public SearchResult(Queue<SearchNode<T>> statesQueue, Map<T, Double> closedMap, Queue<SearchNode<T>> frontierQueue) {
this.statesQueue = statesQueue;
this.closedMap = closedMap;
this.frontierQueue = frontierQueue;
}
public Queue<SearchNode<T>> getStatesQueue() {
return statesQueue;
}
public Map<T, Double> getClosedSet() {
return closedMap;
}
public Queue<SearchNode<T>> getFrontierQueue() {
return frontierQueue;
}
}
|
[
"[email protected]"
] | |
208b18f5b6cfa43ed235b374f66c946a316bd2bd
|
899924418ccf8a6ce123d2d25cc28c2acfc64e81
|
/src/main/java/com/linkinstars/Converter.java
|
0bd226e0d1be15aa17a29aab63c66d1f96197390
|
[] |
no_license
|
admin862/http-helper
|
eca1e61088c8e1bbc4b27ffd2612f6b4c2eaa2c0
|
e09725e3cd94de3d9e4222fcd0da4699f4f51a62
|
refs/heads/master
| 2020-03-28T22:27:33.450078 | 2018-09-17T09:31:57 | 2018-09-17T09:31:57 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 1,403 |
java
|
package com.linkinstars;
import com.alibaba.fastjson.JSONObject;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import java.util.Map;
/**
* 转换器
* @author LinkinStar
*/
public class Converter {
/** json MediaType **/
private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8");
/**
* 将请求体转换成OKHTTP可以识别的RequestBody
* @param object 请求对象
* @return RequestBody
*/
public static <T> RequestBody requestBodyConverter(T object) {
return RequestBody.create(JSON_TYPE, JSONObject.toJSONString(object));
}
/**
* 将返回json字符串对象转换为实体对象
* @param object 实体对象类型
* @param jsonStr json字符串
* @return 实体对象
*/
public static <T> T responseBodyConverter(Class<T> object, String jsonStr) {
return JSONObject.parseObject(jsonStr, object);
}
/**
* 将map转换成okhttp可以识别的FormBody对象
* @param map 请求的表单数据
* @return 可以发送的表单数据
*/
public static FormBody formBodyConverter(Map<String, String> map) {
FormBody.Builder builder = new FormBody.Builder();
for (String key : map.keySet()) {
builder.add(key, map.get(key));
}
return builder.build();
}
}
|
[
"[email protected]"
] | |
8af08656fc392ba33f9456fd4c16fbf3b02a5251
|
bf12f960dd796527cd92257c1f2bf7a6d5a2bac6
|
/src/main/java/com/oa/authority/service/IRoleService.java
|
d1c7be0cea2190fe39e0ce221691f97b9cb7f7fa
|
[] |
no_license
|
lucky-plus/OA-System
|
0b8b4ed76ce2198cc1613b424ac77de95bb4a3a5
|
22a7abc8329a5b72dcae09f549a6196f95f3c009
|
refs/heads/master
| 2021-09-15T02:06:42.635837 | 2018-05-24T02:33:00 | 2018-05-24T02:33:00 | 104,549,599 | 0 | 3 | null | 2017-10-09T06:18:03 | 2017-09-23T07:25:35 |
JavaScript
|
UTF-8
|
Java
| false | false | 535 |
java
|
package com.oa.authority.service;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.oa.authority.entity.Role;
import com.oa.authority.entity.dto.RoleDTO;
public interface IRoleService {
public void save(RoleDTO dto);
public void delete(Role entity);
public void delete(Integer id);
public void delete(Integer[] ids);
public List<RoleDTO> findRoleByLevel(Integer roleLevel);
public Page<RoleDTO> findAll(Pageable pageable);
}
|
[
"[email protected]"
] | |
94119ff26ddb59495f1dcdb316891bec5d33a1cb
|
a34c4241c73b75bd10c99ce97a4b575c3e165c10
|
/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/KVTag.java
|
ba0071e37b120f004cd50f296ad63a73978e8ec9
|
[
"MIT"
] |
permissive
|
Mengbuxiu/tutorials
|
cf86ca582896563ab0b75178a2628c24982f64d3
|
3380dba316dc4b2a66796a7be7d98cc7686f12ad
|
refs/heads/master
| 2020-07-01T00:45:38.551964 | 2018-03-10T20:56:29 | 2018-03-10T20:56:29 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 576 |
java
|
package org.baeldung.inmemory.persistence.model;
import javax.persistence.Embeddable;
@Embeddable
public class KVTag {
private String key;
private String value;
public KVTag(){}
public KVTag(String key, String value) {
super();
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
|
[
"[email protected]"
] | |
48b2381d4a29ef0399da068a075eee78c95900a7
|
9b42c11c3756a784e3e2746b5d2adaab9285ab6f
|
/Common/src/main/java/uk/jamierocks/saturn/common/mixin/command/MixinCommandHandler.java
|
2d4af5edf14ba1d8b8ceee6d465443ddcbb3cf53
|
[
"MIT"
] |
permissive
|
Lexteam/Saturn
|
8a753845fdf9092531d3ccf7790fafbbf075ea06
|
ca543bc91084986168608599330165ef96c686f5
|
refs/heads/master
| 2021-01-10T16:57:58.264496 | 2015-10-23T21:03:56 | 2015-10-23T21:03:56 | 44,772,832 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 2,012 |
java
|
/*
* This file is part of Saturn, licensed under the MIT License (MIT).
*
* Copyright (c) 2015, Jamie Mansfield <https://github.com/jamierocks>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package uk.jamierocks.saturn.common.mixin.command;
import net.minecraft.command.CommandHandler;
import net.minecraft.command.ICommand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import uk.jamierocks.saturn.api.command.CommandCallable;
import uk.jamierocks.saturn.api.service.command.CommandService;
import uk.jamierocks.saturn.common.command.MinecraftCommandCallable;
@Mixin(CommandHandler.class)
public abstract class MixinCommandHandler implements CommandService {
@Shadow
public abstract ICommand registerCommand(ICommand command);
@Override
public void registerCommand(CommandCallable command, String name, String... aliases) {
this.registerCommand(new MinecraftCommandCallable(command, name, aliases));
}
}
|
[
"[email protected]"
] | |
78de68788d88b4c60269841ec92a0b274028473e
|
d6b46381b4303bb696f3c4e54434c3907ad6957d
|
/src/main/java/io/jsonwebtoken/impl/JwtMap.java
|
0d000fc4bfa40f89939b8bc950aa61be05028133
|
[] |
no_license
|
Noguik06/ECO-SAT-BACKEND
|
a1eaa4425cc04b7015901ceb014215fe7cd7be5b
|
9902fd7a6e9486aa0322ee3ff1ab56ea31a7db5f
|
refs/heads/master
| 2021-01-20T21:13:13.297096 | 2016-11-29T20:54:59 | 2016-11-29T20:54:59 | 65,094,889 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,720 |
java
|
/*
* Copyright (C) 2014 jsonwebtoken.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.jsonwebtoken.impl;
import io.jsonwebtoken.lang.Assert;
import java.util.*;
public class JwtMap implements Map<String,Object> {
private final Map<String, Object> map;
public JwtMap() {
this(new LinkedHashMap<String, Object>());
}
public JwtMap(Map<String, Object> map) {
Assert.notNull(map, "Map argument cannot be null.");
this.map = map;
}
protected String getString(String name) {
Object v = get(name);
return v != null ? String.valueOf(v) : null;
}
protected static Date toDate(Object v, String name) {
if (v == null) {
return null;
} else if (v instanceof Date) {
return (Date) v;
} else if (v instanceof Number) {
long seconds = ((Number) v).longValue();
long millis = seconds * 1000;
return new Date(millis);
} else if (v instanceof String) {
long seconds = Long.parseLong((String) v);
long millis = seconds * 1000;
return new Date(millis);
} else {
throw new IllegalStateException("Cannot convert '" + name + "' value [" + v + "] to Date instance.");
}
}
protected void setValue(String name, Object v) {
if (v == null) {
map.remove(name);
} else {
map.put(name, v);
}
}
protected Date getDate(String name) {
Object v = map.get(name);
return toDate(v, name);
}
protected void setDate(String name, Date d) {
if (d == null) {
map.remove(name);
} else {
long seconds = d.getTime() / 1000;
map.put(name, seconds);
}
}
@Override
public int size() {
return map.size();
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
@Override
public boolean containsKey(Object o) {
return map.containsKey(o);
}
@Override
public boolean containsValue(Object o) {
return map.containsValue(o);
}
@Override
public Object get(Object o) {
return map.get(o);
}
@Override
public Object put(String s, Object o) {
if (o == null) {
return map.remove(s);
} else {
return map.put(s, o);
}
}
@Override
public Object remove(Object o) {
return map.remove(o);
}
@SuppressWarnings("NullableProblems")
@Override
public void putAll(Map<? extends String, ?> m) {
if (m == null) {
return;
}
for (String s : m.keySet()) {
map.put(s, m.get(s));
}
}
@Override
public void clear() {
map.clear();
}
@Override
public Set<String> keySet() {
return map.keySet();
}
@Override
public Collection<Object> values() {
return map.values();
}
@Override
public Set<Entry<String, Object>> entrySet() {
return map.entrySet();
}
@Override
public String toString() {
return map.toString();
}
}
|
[
"Admin123"
] |
Admin123
|
e63f610cb365416fe3f75181eb8dea7f537965a6
|
f630160b0fe64d9af851b54d368ef1b54207ca6e
|
/spring-boot-10-elasticsearch/src/main/java/cn/edu/ustc/springboot/bean/Book.java
|
15034535729752c2c6442203da6c0ec76a8f664d
|
[] |
no_license
|
NextSemester/SpringBoot_demo
|
b77727a18f464bc2600721a66093ce6220d22f01
|
8e2be6c6e31e1aa897d337518183096788554a53
|
refs/heads/master
| 2023-03-16T00:27:41.896282 | 2020-10-03T04:46:34 | 2020-10-03T04:46:34 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 894 |
java
|
package cn.edu.ustc.springboot.bean;
import org.springframework.data.elasticsearch.annotations.Document;
@Document(indexName = "store",type = "book")
public class Book {
private Integer id;
private String bookName;
private String author;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@Override
public String toString() {
return "Book{" +
"id=" + id +
", bookName='" + bookName + '\'' +
", author='" + author + '\'' +
'}';
}
}
|
[
"[email protected]"
] | |
6cbe6824fa7b8341b4fedcbe81b993d13820949e
|
e55c26af9ef6da50538e4ba9631910a366de1e41
|
/src/main/java/com/upupuup/adapter/demo2/TencentProgrammer.java
|
2cfd382eae4b1f37162f935513690d62c394c18e
|
[] |
no_license
|
upupuup/design_pattern
|
e4134f73e1efb0859e4109ae4fda98ec75767cc6
|
229400d845ce010b1fca89a3b0a064bcc96a759c
|
refs/heads/master
| 2020-06-19T19:23:23.757133 | 2019-07-28T14:22:46 | 2019-07-28T14:22:46 | 196,841,336 | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 343 |
java
|
package com.upupuup.adapter.demo2;
/**
* @Author:upupupuup
* @Date:2019/7/28 12:31 PM
* @Version 1.0
* @Description:[一句话描述该类的功能]
*/
public class TencentProgrammer implements IProgrammer {
/**
* 腾讯程序员写代码
* @return
*/
public String program() {
return "写代码";
}
}
|
[
"[email protected]"
] | |
9722d0148e3260bd68a2f164fcd2d8ad166fccaf
|
4b0e08adf554204c952217529885306c36f2678e
|
/src/com/uncc/gameday/activities/parking/LotViewFragment.java
|
40ed8ab1babffaf403d2ed29fd0a04c8a6fea598
|
[] |
no_license
|
bspeice/UNCCGameDay
|
fed7a47e2c41914d233e8d52bc215d2f02a255c4
|
85d33578a7b62b81349855b28854db52ddd01730
|
refs/heads/master
| 2021-01-21T01:35:10.688674 | 2013-12-09T08:51:17 | 2013-12-09T08:51:17 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Java
| false | false | 3,733 |
java
|
package com.uncc.gameday.activities.parking;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.Toast;
import com.uncc.gameday.R;
import com.uncc.gameday.parking.ParkingChoice;
import com.uncc.gameday.parking.ParkingClient;
import com.uncc.gameday.parking.ParkingLot;
import com.uncc.gameday.parking.RatingChoices;
/**
* The Class LotViewFragment.
*/
public class LotViewFragment extends DialogFragment {
/** The ParkingChoice that we are viewing */
ParkingChoice pc;
/**
* Instantiates a new lot view fragment.
*/
public LotViewFragment(){
}
/**
* Initialize the data when the fragment is started.
* Specifically, set up the MapView to display, and fetch
* other information about the parking lot.
*
* @param pc - The Parking lot we need to get information for
*/
private void initializeData(ParkingLot pl){
ProgressBar bar = (ProgressBar)this.getView().findViewById(R.id.lotViewCurrentFilled);
bar.setProgress(pl.getFilledPct());
// Set up the MapView here.
}
/* (non-Javadoc)
* @see android.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ParkingChoice pc;
Bundle args = this.getArguments();
if (args.containsKey("CHOICE"))
pc = ParkingChoice.valueOf(String.valueOf((char[])args.get("CHOICE")));
else
pc = ParkingChoice.BLACK;
this.pc = pc;
View view = inflater.inflate(R.layout.lot_view, container);
getDialog().setTitle(pc.getValue());
// Initialize our data
new InitializeThread(pc, this).start();
view.findViewById(R.id.lotViewSubmitRating).setOnClickListener(new SubmitListener(this));
return view;
}
/**
* Send a parking lot rating to the server
*/
public void onSubmitRating(View v) {
// Submit a rating to the server
SeekBar bar = (SeekBar)this.getView().findViewById(R.id.lotViewLotRating);
int rating = bar.getProgress();
// Switch between values of parking rating
RatingChoices rc;
if (rating < 25)
rc = RatingChoices.EMP;
else if (rating < 50)
rc = RatingChoices.SCT;
else if (rating < 75)
rc = RatingChoices.BSY;
else
rc = RatingChoices.FLL;
new SubmitThread(this.pc, rc).start();
Toast.makeText(getActivity(), "Rating submitted!", Toast.LENGTH_SHORT).show();
}
private class InitializeThread extends Thread {
ParkingChoice pc;
LotViewFragment f;
public InitializeThread(ParkingChoice pc, LotViewFragment f) {
this.pc = pc;
this.f = f;
}
@Override
public void run() {
ParkingClient client = new ParkingClient(f.getActivity());
ParkingLot pl = client.listLot(this.pc);
f.initializeData(pl);
}
}
private class SubmitThread extends Thread {
ParkingChoice pc;
RatingChoices r;
public SubmitThread(ParkingChoice pc, RatingChoices r) {
this.pc = pc;
this.r = r;
}
public void run() {
ParkingClient pc = new ParkingClient(getActivity());
pc.rateLot(r, this.pc);
}
}
private class SubmitListener implements OnClickListener {
LotViewFragment f;
public SubmitListener(LotViewFragment f) {
this.f = f;
}
@Override
public void onClick(View v) {
f.onSubmitRating(v);
}
}
}
|
[
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.