blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b2c48dadba86ebf5a985c5a09657807450456778
| 17,076,789,995,677 |
d84c7401bac8151674d467f8b59ba3577ec011cc
|
/src/main/java/com/rxy/friday/dao/UserDao.java
|
94164f92d2b8e19a1497617479ef9efca6338d80
|
[] |
no_license
|
raoxy77/friday
|
https://github.com/raoxy77/friday
|
ee9bbdf1fb02402403e199a571176ddcf54de52e
|
dad0a0a3ae4a8e6d1683b2878823a00d211bfd88
|
refs/heads/master
| 2022-06-23T12:20:19.930000 | 2020-02-29T08:34:21 | 2020-02-29T08:34:21 | 243,931,311 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.rxy.friday.dao;
import com.rxy.friday.base.result.Results;
import com.rxy.friday.model.SysUser;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* userDao 接口定义
*/
@Mapper
public interface UserDao {
/**
* 分页查询
*
* @Author: rxy
* @Param: [startPosition:开始位置, limit:一页条数]
* @return: {@link List< SysUser>}
*/
@Select("select * from sys_user order by id limit #{startPosition}, #{limit}")
List<SysUser> getAllUsersByPage(@Param("startPosition") Integer startPosition, @Param("limit") Integer limit);
/**
* 根据条件模糊查询 记录数
*
* @Author: rxy
* @Param: [userName]模糊条件
* @return: {@link Long}
*/
@Select("select count(id) from sys_user where username like '%${userName}%'")
Long countUserByName(@Param("userName") String userName);
/**
* 分页模糊查询
*
* @Author: rxy
* @Param: [userName:模糊条件, startPosition:开始位置, limit:一页条数]
* @return: {@link List< SysUser>}
*/
@Select("select * from sys_user where username like '%${userName}%' Limit #{startPosition},#{limit}")
List<SysUser> findUserByFuzzyUserName(@Param("userName") String userName, @Param("startPosition") Integer startPosition, @Param("limit") Integer limit);
/**
* 返回user总记录数
*
* @Author: rxy
* @Param: []
* @return: {@link Long}
*/
@Select("select count(id) from sys_user")
Long countAllUsers();
/**
* 根据用户id删除
*
* @Author: rxy
* @Param: [id] userId
* @return: {@link int}
*/
@Delete("delete from sys_user where id = #{id}")
int deleteUserById(Long id);
/**
* 根据用户id查询信息服务
*
* @Author: rxy
* @Param: [id] 用户id
* @return: {@link Results< SysUser>}
*/
@Select("select * from sys_user where id = #{id}")
SysUser getUserByUserId(Long id);
/**
* 添加user
*
* @Author: rxy
* @Param: [userDto:userDto]
* @return: {@link Long}
*/
@Options(useGeneratedKeys = true, keyProperty = "id")
@Insert("insert into sys_user(username, password, nickname, headImgUrl, phone, telephone, email, birthday, sex, status, createTime, updateTime) values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{telephone}, #{email}, #{birthday}, #{sex}, #{status}, now(), now())")
Long save(SysUser sysUser);
/**
* 根据用户userName查询信息服务
*
* @Author: rxy
* @Param: [userName]用户名
* @return: {@link SysUser}
*/
@Select("select * from sys_user where username = #{username}")
SysUser getUserByUserName(String userName);
/**
* 根据邮箱查询 用户信息
*
* @Author: rxy
* @Param: [email] 邮箱
* @return: {@link SysUser}
*/
@Select("select * from sys_user t where t.email = #{email}")
SysUser getUserByEmail(String email);
/**
* 根据电话号码查询 用户信息
*
* @Author: rxy
* @Param: [telephone] 电话号码
* @return: {@link SysUser}
*/
@Select("select * from sys_user t where t.telephone = #{telephone}")
SysUser getUserByPhone(String telephone);
/**
* 更新用户信息
*
* @Author: rxy
* @Param: [sysUser] 用户模型
* @return: {@link Long}
*/
Long updateUser(SysUser sysUser);
}
|
UTF-8
|
Java
| 3,517 |
java
|
UserDao.java
|
Java
|
[
{
"context": "erDao {\n /**\n * 分页查询\n *\n * @Author: rxy\n * @Param: [startPosition:开始位置, limit:一页条数]\n ",
"end": 279,
"score": 0.9996957778930664,
"start": 276,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": " /**\n * 根据条件模糊查询 记录数\n *\n * @Author: rxy\n * @Param: [userName]模糊条件\n * @return: {@l",
"end": 628,
"score": 0.9997016191482544,
"start": 625,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "me);\n\n /**\n * 分页模糊查询\n *\n * @Author: rxy\n * @Param: [userName:模糊条件, startPosition:开始位置",
"end": 889,
"score": 0.9996914863586426,
"start": 886,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "\n\n /**\n * 返回user总记录数\n *\n * @Author: rxy\n * @Param: []\n * @return: {@link Long}\n ",
"end": 1317,
"score": 0.9996711015701294,
"start": 1314,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": ");\n\n /**\n * 根据用户id删除\n *\n * @Author: rxy\n * @Param: [id] userId\n * @return: {@link",
"end": 1496,
"score": 0.9996868371963501,
"start": 1493,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": " /**\n * 根据用户id查询信息服务\n *\n * @Author: rxy\n * @Param: [id] 用户id\n * @return: {@link R",
"end": 1702,
"score": 0.9997529983520508,
"start": 1699,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "id);\n\n /**\n * 添加user\n *\n * @Author: rxy\n * @Param: [userDto:userDto]\n * @return: ",
"end": 1920,
"score": 0.9997437596321106,
"start": 1917,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "roperty = \"id\")\n @Insert(\"insert into sys_user(username, password, nickname, headImgUrl, phone, telephone",
"end": 2091,
"score": 0.9492465853691101,
"start": 2083,
"tag": "USERNAME",
"value": "username"
},
{
"context": "ay, sex, status, createTime, updateTime) values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phon",
"end": 2214,
"score": 0.8350282311439514,
"start": 2206,
"tag": "USERNAME",
"value": "username"
},
{
"context": "*\n * 根据用户userName查询信息服务\n *\n * @Author: rxy\n * @Param: [userName]用户名\n * @return: {@li",
"end": 2433,
"score": 0.9997447729110718,
"start": 2430,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "Select(\"select * from sys_user where username = #{username}\")\n SysUser getUserByUserName(String userName)",
"end": 2566,
"score": 0.8755699992179871,
"start": 2558,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\n /**\n * 根据邮箱查询 用户信息\n *\n * @Author: rxy\n * @Param: [email] 邮箱\n * @return: {@link ",
"end": 2672,
"score": 0.9997410774230957,
"start": 2669,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": " /**\n * 根据电话号码查询 用户信息\n *\n * @Author: rxy\n * @Param: [telephone] 电话号码\n * @return: {",
"end": 2902,
"score": 0.999742865562439,
"start": 2899,
"tag": "USERNAME",
"value": "rxy"
},
{
"context": "ne);\n\n /**\n * 更新用户信息\n *\n * @Author: rxy\n * @Param: [sysUser] 用户模型\n * @return: {@l",
"end": 3143,
"score": 0.9997327923774719,
"start": 3140,
"tag": "USERNAME",
"value": "rxy"
}
] | null |
[] |
package com.rxy.friday.dao;
import com.rxy.friday.base.result.Results;
import com.rxy.friday.model.SysUser;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* userDao 接口定义
*/
@Mapper
public interface UserDao {
/**
* 分页查询
*
* @Author: rxy
* @Param: [startPosition:开始位置, limit:一页条数]
* @return: {@link List< SysUser>}
*/
@Select("select * from sys_user order by id limit #{startPosition}, #{limit}")
List<SysUser> getAllUsersByPage(@Param("startPosition") Integer startPosition, @Param("limit") Integer limit);
/**
* 根据条件模糊查询 记录数
*
* @Author: rxy
* @Param: [userName]模糊条件
* @return: {@link Long}
*/
@Select("select count(id) from sys_user where username like '%${userName}%'")
Long countUserByName(@Param("userName") String userName);
/**
* 分页模糊查询
*
* @Author: rxy
* @Param: [userName:模糊条件, startPosition:开始位置, limit:一页条数]
* @return: {@link List< SysUser>}
*/
@Select("select * from sys_user where username like '%${userName}%' Limit #{startPosition},#{limit}")
List<SysUser> findUserByFuzzyUserName(@Param("userName") String userName, @Param("startPosition") Integer startPosition, @Param("limit") Integer limit);
/**
* 返回user总记录数
*
* @Author: rxy
* @Param: []
* @return: {@link Long}
*/
@Select("select count(id) from sys_user")
Long countAllUsers();
/**
* 根据用户id删除
*
* @Author: rxy
* @Param: [id] userId
* @return: {@link int}
*/
@Delete("delete from sys_user where id = #{id}")
int deleteUserById(Long id);
/**
* 根据用户id查询信息服务
*
* @Author: rxy
* @Param: [id] 用户id
* @return: {@link Results< SysUser>}
*/
@Select("select * from sys_user where id = #{id}")
SysUser getUserByUserId(Long id);
/**
* 添加user
*
* @Author: rxy
* @Param: [userDto:userDto]
* @return: {@link Long}
*/
@Options(useGeneratedKeys = true, keyProperty = "id")
@Insert("insert into sys_user(username, password, nickname, headImgUrl, phone, telephone, email, birthday, sex, status, createTime, updateTime) values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{telephone}, #{email}, #{birthday}, #{sex}, #{status}, now(), now())")
Long save(SysUser sysUser);
/**
* 根据用户userName查询信息服务
*
* @Author: rxy
* @Param: [userName]用户名
* @return: {@link SysUser}
*/
@Select("select * from sys_user where username = #{username}")
SysUser getUserByUserName(String userName);
/**
* 根据邮箱查询 用户信息
*
* @Author: rxy
* @Param: [email] 邮箱
* @return: {@link SysUser}
*/
@Select("select * from sys_user t where t.email = #{email}")
SysUser getUserByEmail(String email);
/**
* 根据电话号码查询 用户信息
*
* @Author: rxy
* @Param: [telephone] 电话号码
* @return: {@link SysUser}
*/
@Select("select * from sys_user t where t.telephone = #{telephone}")
SysUser getUserByPhone(String telephone);
/**
* 更新用户信息
*
* @Author: rxy
* @Param: [sysUser] 用户模型
* @return: {@link Long}
*/
Long updateUser(SysUser sysUser);
}
| 3,517 | 0.579773 | 0.579773 | 126 | 24.817461 | 34.18795 | 290 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.373016 | false | false |
14
|
4dbef45a0deb7e0070ab2385800c3ead8e19304c
| 29,102,698,422,751 |
f2adedf83e0f68ccbd33108aa98d04812d987393
|
/CourseAdministration/src/be/abis/courseadmin/test/ExF04.java
|
a84a71e147fa6f91b36ae9fa1623bf9b0c84286b
|
[] |
no_license
|
bvanrooy/extoolsts
|
https://github.com/bvanrooy/extoolsts
|
202ff4af2d548fbce25d24a3ff299eb35b558057
|
a4f7077529d95534d36f31009f89fa31a9bfd146
|
refs/heads/master
| 2022-12-19T00:18:19.922000 | 2020-09-28T13:09:57 | 2020-09-28T13:09:57 | 299,227,904 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package be.abis.courseadmin.test;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import be.abis.courseadmin.model.Course;
import be.abis.courseadmin.model.Instructor;
public class ExF04{
public static void main(String[] args){
ArrayList<Course> courses = new ArrayList<>();
ArrayList<Instructor>instructors=new ArrayList<>();
instructors.add(new Instructor("Sandy","Schillebeeckx",LocalDate.of(1978,1,3),20,2000));
instructors.add(new Instructor("Luigi","Instructore",LocalDate.of(1950,1,3),23,1750));
instructors.add(new Instructor("Bart","Van Rooy",LocalDate.of(1965,8,7),22,2100));
courses.add(new Course("Java fundamentals",5,333,false));
courses.add(new Course("Java advanced",5,253,true));
courses.add(new Course("Spring fundamentals",3,211,true));
courses.get(0).addInstructor(instructors.get(0));
courses.get(0).addInstructor(instructors.get(1));
courses.get(1).addInstructor(instructors.get(0));
courses.get(1).addInstructor(instructors.get(1));
courses.get(1).addInstructor(instructors.get(2));
courses.get(2).addInstructor(instructors.get(2));
for(Course course:courses) {
course.printInfo();
try {
course.writeInfoToFile();
} catch (IOException e) {
e.printStackTrace();
}
}
instructors.get(0).printSalaryHistory();
instructors.get(1).printSalaryHistory();
instructors.get(2).printSalaryHistory();
}
}
|
UTF-8
|
Java
| 1,613 |
java
|
ExF04.java
|
Java
|
[
{
"context": "ist<>();\n\n instructors.add(new Instructor(\"Sandy\",\"Schillebeeckx\",LocalDate.of(1978,1,3),20,2000))",
"end": 434,
"score": 0.9998400211334229,
"start": 429,
"tag": "NAME",
"value": "Sandy"
},
{
"context": "\n\n instructors.add(new Instructor(\"Sandy\",\"Schillebeeckx\",LocalDate.of(1978,1,3),20,2000));\n instru",
"end": 450,
"score": 0.9998270869255066,
"start": 437,
"tag": "NAME",
"value": "Schillebeeckx"
},
{
"context": "0,2000));\n instructors.add(new Instructor(\"Luigi\",\"Instructore\",LocalDate.of(1950,1,3),23,1750));\n",
"end": 531,
"score": 0.9998579025268555,
"start": 526,
"tag": "NAME",
"value": "Luigi"
},
{
"context": ";\n instructors.add(new Instructor(\"Luigi\",\"Instructore\",LocalDate.of(1950,1,3),23,1750));\n instru",
"end": 545,
"score": 0.999724805355072,
"start": 534,
"tag": "NAME",
"value": "Instructore"
},
{
"context": "3,1750));\n instructors.add(new Instructor(\"Bart\",\"Van Rooy\",LocalDate.of(1965,8,7),22,2100));\n\n ",
"end": 625,
"score": 0.9998422265052795,
"start": 621,
"tag": "NAME",
"value": "Bart"
},
{
"context": ");\n instructors.add(new Instructor(\"Bart\",\"Van Rooy\",LocalDate.of(1965,8,7),22,2100));\n\n cours",
"end": 636,
"score": 0.9998244047164917,
"start": 628,
"tag": "NAME",
"value": "Van Rooy"
}
] | null |
[] |
package be.abis.courseadmin.test;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import be.abis.courseadmin.model.Course;
import be.abis.courseadmin.model.Instructor;
public class ExF04{
public static void main(String[] args){
ArrayList<Course> courses = new ArrayList<>();
ArrayList<Instructor>instructors=new ArrayList<>();
instructors.add(new Instructor("Sandy","Schillebeeckx",LocalDate.of(1978,1,3),20,2000));
instructors.add(new Instructor("Luigi","Instructore",LocalDate.of(1950,1,3),23,1750));
instructors.add(new Instructor("Bart","<NAME>",LocalDate.of(1965,8,7),22,2100));
courses.add(new Course("Java fundamentals",5,333,false));
courses.add(new Course("Java advanced",5,253,true));
courses.add(new Course("Spring fundamentals",3,211,true));
courses.get(0).addInstructor(instructors.get(0));
courses.get(0).addInstructor(instructors.get(1));
courses.get(1).addInstructor(instructors.get(0));
courses.get(1).addInstructor(instructors.get(1));
courses.get(1).addInstructor(instructors.get(2));
courses.get(2).addInstructor(instructors.get(2));
for(Course course:courses) {
course.printInfo();
try {
course.writeInfoToFile();
} catch (IOException e) {
e.printStackTrace();
}
}
instructors.get(0).printSalaryHistory();
instructors.get(1).printSalaryHistory();
instructors.get(2).printSalaryHistory();
}
}
| 1,611 | 0.645381 | 0.605084 | 49 | 31.918367 | 27.658882 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.081633 | false | false |
14
|
0bb6fc8319ebd954408269c652a67f569fa004e7
| 6,511,170,448,845 |
20491a09fce195e88996a5d777f053c7a4722587
|
/src/model/connection/RemoteWrite.java
|
a0aad79a94ddce51d1e5eeaca9cff2cf2f8167d4
|
[] |
no_license
|
KateTroshkova/CamerollClient
|
https://github.com/KateTroshkova/CamerollClient
|
7264a64a6053b823ecf56035590c07f1d10628ab
|
4be01d12d74b94c49ef39956458057077706f1dc
|
refs/heads/master
| 2020-05-28T09:13:09.803000 | 2019-05-28T04:01:07 | 2019-05-28T04:01:07 | 188,951,215 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package model.connection;
import request.Request;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.ArrayList;
public class RemoteWrite extends Thread {
private ObjectOutputStream out;
private boolean needToWrite=false;
private ArrayList<Request> request;
private boolean isRunning=true;
public RemoteWrite(Socket client){
request=new ArrayList<>();
try {
out=new ObjectOutputStream(client.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
public void sendRequest(Request request){
this.request.add(request);
needToWrite=true;
}
public void stopWrite(){
isRunning=false;
}
@Override
public void run() {
while (isRunning) {
try {
if (needToWrite) {
for(Request request:this.request) {
out.writeObject(request); // отправляем на сервер
out.flush();
}
request.clear();
needToWrite=false;
}
else{
sleep(100);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
}
|
UTF-8
|
Java
| 1,397 |
java
|
RemoteWrite.java
|
Java
|
[] | null |
[] |
package model.connection;
import request.Request;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.ArrayList;
public class RemoteWrite extends Thread {
private ObjectOutputStream out;
private boolean needToWrite=false;
private ArrayList<Request> request;
private boolean isRunning=true;
public RemoteWrite(Socket client){
request=new ArrayList<>();
try {
out=new ObjectOutputStream(client.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
public void sendRequest(Request request){
this.request.add(request);
needToWrite=true;
}
public void stopWrite(){
isRunning=false;
}
@Override
public void run() {
while (isRunning) {
try {
if (needToWrite) {
for(Request request:this.request) {
out.writeObject(request); // отправляем на сервер
out.flush();
}
request.clear();
needToWrite=false;
}
else{
sleep(100);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
}
| 1,397 | 0.535896 | 0.53372 | 55 | 24.09091 | 17.454639 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.418182 | false | false |
14
|
47e00b4c426ab687ee279afd85389211389b63c6
| 22,711,787,086,136 |
a66a3a43e5d038c59b2171a295faa35eb5f7cb1e
|
/LSH/LSH.java
|
1770fd80d2aca619c7e432a46159f3d72f063252
|
[] |
no_license
|
pengrenlai/Hadoop-MapReduce
|
https://github.com/pengrenlai/Hadoop-MapReduce
|
8d4551003070da0edc3ad8eb771def5b74ac1091
|
4e18c8ab34ec5d8356ef13b1d8c40c225b199e17
|
refs/heads/master
| 2020-08-14T18:45:56.997000 | 2019-10-15T12:56:56 | 2019-10-15T12:56:56 | 215,217,225 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.apache.hadoop.examples;
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import java.util.*;
public class LSH {
public static class Mapper1 extends Mapper<Object, Text, Text, Text>{
private String flag;
protected void setup(Context context) throws IOException, InterruptedException {
FileSplit split = (FileSplit) context.getInputSplit();
flag = split.getPath().getName();
}
private final int k = 3; // k-gram
Text shingle = new Text();
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
String doc = value.toString();
doc = doc.replaceAll("\\.", "");
doc = doc.replaceAll(",", "");
doc = doc.replaceAll("\\-", "");
doc = doc.replaceAll("\"", "");
doc = doc.replaceAll("\\s+"," ");
String[] doc_split = doc.split(" ");
for(int i = 0 ; i < doc_split.length - k ; i++)
{
String s = "";
for(int j = i ; j < i + k ; j++)
s = s + doc_split[j] + " ";
shingle.set(s);
context.write(shingle, new Text("D_" + flag.substring(0, 3)));
}
}
}
public static class Reducer1 extends Reducer<Text,Text,Text,Text> {
private int shingles_num = 0;
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
ArrayList<String> docs = new ArrayList<String>();
for (Text value : values) {
if(!docs.contains(value.toString()))
docs.add(value.toString());
}
String doc_list = "";
for(String doc : docs)
doc_list = doc_list + doc + ",";
context.write(key, new Text(doc_list));
shingles_num += 1;
}
protected void cleanup(Context context)
{
context.getCounter("shingles_num", "shingles_num").increment(shingles_num);
}
}
public static class Mapper2
extends Mapper<Object, Text, Text, Text>{
private int row_num = 1;
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String doc_list = value.toString().split("\t")[1];
StringTokenizer itr = new StringTokenizer(doc_list, ",");
int shingles_num = Integer.parseInt(context.getConfiguration().get("shingles_num"));
int prime = 12569;
while (itr.hasMoreTokens()) {
String doc = itr.nextToken();
for(int i = 1 ; i <= 100 ; i++)
{
int hash = (((i * row_num) + (102 - i)) % prime ) % shingles_num; // 100 hash function
String v = Integer.toString(i) + "," + Integer.toString(hash); // <key, value> = <doc_id, (i, hi(row_num))>
context.write(new Text(doc), new Text(v));
}
}
row_num += 1;
}
}
public static class Reducer2 extends Reducer<Text,Text,Text,Text> {
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
String sig[] = new String[100];
int index = 0;
int hashvalue = 0;
for(int i = 0 ; i < 100; i++)
{
sig[i] = "999999";
}
for(Text value : values)
{
String str = value.toString();
String[] index_sig = str.split(",");
index = Integer.valueOf(index_sig[0]);
hashvalue = Integer.valueOf(index_sig[1]);
if(Integer.valueOf(sig[index-1])>hashvalue)
sig[index-1] = String.valueOf(hashvalue);
}
String sigvalue = "";
for(int i = 0 ; i < 100 ; i++)
{
sigvalue = sigvalue+sig[i]+",";
}
context.write(key,new Text(sigvalue));
}
}
public static class Mapper3
extends Mapper<Object, Text, Text, Text>{
private final int r = 2;
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String tokens[] = value.toString().split("\t");
String sig_col_vec = tokens[1];
String doc_id = tokens[0];
StringTokenizer itr = new StringTokenizer(sig_col_vec, ",");
int i = 0;
String sig = "";
while (itr.hasMoreTokens())
{
sig = sig + itr.nextToken() + ",";
i += 1;
if(i % r == 0)
{
int band = i / r;
context.write(new Text(Integer.toString(band) + "_" + sig + "@@@@@"), new Text(doc_id));
sig = "";
}
}
}
}
public static class Reducer3 extends Reducer<Text,Text,Text,Text> {
private ArrayList<String> candidate = new ArrayList<String>();
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
ArrayList<String> docs = new ArrayList<String>();
for (Text value : values) {
docs.add(value.toString());
}
if(docs.size() > 1)
{
String pairs = "";
String pairs_reverse = "";
for(int i = 0 ; i < docs.size() - 1 ; i++)
{
for(int j = i + 1 ; j < docs.size() ; j++)
{
pairs = docs.get(i) + "," + docs.get(j);
pairs_reverse = docs.get(j) + "," + docs.get(i);
if(!candidate.contains(pairs) && !candidate.contains(pairs_reverse))
{
candidate.add(pairs);
context.write(new Text("candidate pairs"), new Text(pairs));
}
}
}
}
}
}
public static class Mapper4
extends Mapper<Object, Text, Text, Text>{
private String flag;
protected void setup(Context context) throws IOException, InterruptedException {
FileSplit split = (FileSplit) context.getInputSplit();
flag = split.getPath().getParent().getName();
}
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
if(flag.equals("lsh_2"))
{
String tokens[] = value.toString().split("\t");
context.write(new Text("whatever"), new Text(tokens[0] + "#" + tokens[1]));
}
else if(flag.equals("lsh_3"))
{
String tokens[] = value.toString().split("\t");
context.write(new Text("whatever"), new Text(tokens[1]));
}
}
}
public static class Reducer4 extends Reducer<Text,Text,Text,Text> {
private Map<String, String> sig_matrix = new HashMap<String, String>();
private ArrayList<String> pairs = new ArrayList<String>();
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
for (Text value : values) {
String tokens[] = value.toString().split(",");
if(tokens.length > 2)
{
String[] sigs = value.toString().split("#");
sig_matrix.put(sigs[0], sigs[1]);
}
else
{
pairs.add(value.toString());
}
}
Map<Float, String> sorted_pairs = new TreeMap<Float, String>(Collections.reverseOrder());
for(String pair : pairs)
{
String[] p = pair.split(",");
String[] doc_vec_1 = sig_matrix.get(p[0]).split(",");
String[] doc_vec_2 = sig_matrix.get(p[1]).split(",");
int intersection = 0;
for(int i = 0 ; i < doc_vec_1.length ; i++)
{
if(doc_vec_1[i].equals(doc_vec_2[i]))
intersection++;
}
float sim = (float)intersection / doc_vec_1.length;
if(sorted_pairs.containsKey(sim))
{
String dup_pairs = sorted_pairs.get(sim);
dup_pairs = dup_pairs + "#" + pair;
sorted_pairs.remove(sim);
sorted_pairs.put(sim, dup_pairs);
}
else
sorted_pairs.put(sim, pair);
}
for(Map.Entry<Float, String> entry : sorted_pairs.entrySet())
{
String v = entry.getValue();
float k = entry.getKey();
String[] dup_pairs = v.split("#");
for(String dup_pair : dup_pairs)
context.write(new Text("(" + dup_pair + ")"), new Text(Float.toString(k)));
}
}
}
public static void main(String[] args) throws Exception {
Configuration conf1 = new Configuration();
Job job1 = new Job(conf1, "lsh");
job1.setJarByClass(LSH.class);
job1.setMapperClass(Mapper1.class);
job1.setReducerClass(Reducer1.class);
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(Text.class);
for(int i = 1 ; i <= 50 ; i++)
{
FileInputFormat.addInputPath(job1, new Path("data/" + String.format("%03d", i) + ".txt"));
}
FileOutputFormat.setOutputPath(job1, new Path("output/lsh_1"));
job1.waitForCompletion(true);
int shingles_num = (int)job1.getCounters().findCounter("shingles_num", "shingles_num").getValue();
Configuration conf2 = new Configuration();
conf2.set("shingles_num", Integer.toString(shingles_num));
Job job2 = new Job(conf2, "lsh");
job2.setJarByClass(LSH.class);
job2.setMapperClass(Mapper2.class);
job2.setReducerClass(Reducer2.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job2, new Path("output/lsh_1"));
FileOutputFormat.setOutputPath(job2, new Path("output/lsh_2"));
job2.waitForCompletion(true);
Configuration conf3 = new Configuration();
Job job3 = new Job(conf3, "lsh");
job3.setJarByClass(LSH.class);
job3.setMapperClass(Mapper3.class);
job3.setReducerClass(Reducer3.class);
job3.setOutputKeyClass(Text.class);
job3.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job3, new Path("output/lsh_2"));
FileOutputFormat.setOutputPath(job3, new Path("output/lsh_3"));
job3.waitForCompletion(true);
Configuration conf4 = new Configuration();
Job job4 = new Job(conf4, "lsh");
job4.setJarByClass(LSH.class);
job4.setMapperClass(Mapper4.class);
job4.setReducerClass(Reducer4.class);
job4.setOutputKeyClass(Text.class);
job4.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job4, new Path("output/lsh_2"));
FileInputFormat.addInputPath(job4, new Path("output/lsh_3"));
FileOutputFormat.setOutputPath(job4, new Path("output/lsh_4"));
job4.waitForCompletion(true);
}
}
|
UTF-8
|
Java
| 11,995 |
java
|
LSH.java
|
Java
|
[] | null |
[] |
package org.apache.hadoop.examples;
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import java.util.*;
public class LSH {
public static class Mapper1 extends Mapper<Object, Text, Text, Text>{
private String flag;
protected void setup(Context context) throws IOException, InterruptedException {
FileSplit split = (FileSplit) context.getInputSplit();
flag = split.getPath().getName();
}
private final int k = 3; // k-gram
Text shingle = new Text();
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
String doc = value.toString();
doc = doc.replaceAll("\\.", "");
doc = doc.replaceAll(",", "");
doc = doc.replaceAll("\\-", "");
doc = doc.replaceAll("\"", "");
doc = doc.replaceAll("\\s+"," ");
String[] doc_split = doc.split(" ");
for(int i = 0 ; i < doc_split.length - k ; i++)
{
String s = "";
for(int j = i ; j < i + k ; j++)
s = s + doc_split[j] + " ";
shingle.set(s);
context.write(shingle, new Text("D_" + flag.substring(0, 3)));
}
}
}
public static class Reducer1 extends Reducer<Text,Text,Text,Text> {
private int shingles_num = 0;
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
ArrayList<String> docs = new ArrayList<String>();
for (Text value : values) {
if(!docs.contains(value.toString()))
docs.add(value.toString());
}
String doc_list = "";
for(String doc : docs)
doc_list = doc_list + doc + ",";
context.write(key, new Text(doc_list));
shingles_num += 1;
}
protected void cleanup(Context context)
{
context.getCounter("shingles_num", "shingles_num").increment(shingles_num);
}
}
public static class Mapper2
extends Mapper<Object, Text, Text, Text>{
private int row_num = 1;
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String doc_list = value.toString().split("\t")[1];
StringTokenizer itr = new StringTokenizer(doc_list, ",");
int shingles_num = Integer.parseInt(context.getConfiguration().get("shingles_num"));
int prime = 12569;
while (itr.hasMoreTokens()) {
String doc = itr.nextToken();
for(int i = 1 ; i <= 100 ; i++)
{
int hash = (((i * row_num) + (102 - i)) % prime ) % shingles_num; // 100 hash function
String v = Integer.toString(i) + "," + Integer.toString(hash); // <key, value> = <doc_id, (i, hi(row_num))>
context.write(new Text(doc), new Text(v));
}
}
row_num += 1;
}
}
public static class Reducer2 extends Reducer<Text,Text,Text,Text> {
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
String sig[] = new String[100];
int index = 0;
int hashvalue = 0;
for(int i = 0 ; i < 100; i++)
{
sig[i] = "999999";
}
for(Text value : values)
{
String str = value.toString();
String[] index_sig = str.split(",");
index = Integer.valueOf(index_sig[0]);
hashvalue = Integer.valueOf(index_sig[1]);
if(Integer.valueOf(sig[index-1])>hashvalue)
sig[index-1] = String.valueOf(hashvalue);
}
String sigvalue = "";
for(int i = 0 ; i < 100 ; i++)
{
sigvalue = sigvalue+sig[i]+",";
}
context.write(key,new Text(sigvalue));
}
}
public static class Mapper3
extends Mapper<Object, Text, Text, Text>{
private final int r = 2;
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String tokens[] = value.toString().split("\t");
String sig_col_vec = tokens[1];
String doc_id = tokens[0];
StringTokenizer itr = new StringTokenizer(sig_col_vec, ",");
int i = 0;
String sig = "";
while (itr.hasMoreTokens())
{
sig = sig + itr.nextToken() + ",";
i += 1;
if(i % r == 0)
{
int band = i / r;
context.write(new Text(Integer.toString(band) + "_" + sig + "@@@@@"), new Text(doc_id));
sig = "";
}
}
}
}
public static class Reducer3 extends Reducer<Text,Text,Text,Text> {
private ArrayList<String> candidate = new ArrayList<String>();
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
ArrayList<String> docs = new ArrayList<String>();
for (Text value : values) {
docs.add(value.toString());
}
if(docs.size() > 1)
{
String pairs = "";
String pairs_reverse = "";
for(int i = 0 ; i < docs.size() - 1 ; i++)
{
for(int j = i + 1 ; j < docs.size() ; j++)
{
pairs = docs.get(i) + "," + docs.get(j);
pairs_reverse = docs.get(j) + "," + docs.get(i);
if(!candidate.contains(pairs) && !candidate.contains(pairs_reverse))
{
candidate.add(pairs);
context.write(new Text("candidate pairs"), new Text(pairs));
}
}
}
}
}
}
public static class Mapper4
extends Mapper<Object, Text, Text, Text>{
private String flag;
protected void setup(Context context) throws IOException, InterruptedException {
FileSplit split = (FileSplit) context.getInputSplit();
flag = split.getPath().getParent().getName();
}
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
if(flag.equals("lsh_2"))
{
String tokens[] = value.toString().split("\t");
context.write(new Text("whatever"), new Text(tokens[0] + "#" + tokens[1]));
}
else if(flag.equals("lsh_3"))
{
String tokens[] = value.toString().split("\t");
context.write(new Text("whatever"), new Text(tokens[1]));
}
}
}
public static class Reducer4 extends Reducer<Text,Text,Text,Text> {
private Map<String, String> sig_matrix = new HashMap<String, String>();
private ArrayList<String> pairs = new ArrayList<String>();
public void reduce(Text key, Iterable<Text> values,Context context) throws IOException, InterruptedException {
for (Text value : values) {
String tokens[] = value.toString().split(",");
if(tokens.length > 2)
{
String[] sigs = value.toString().split("#");
sig_matrix.put(sigs[0], sigs[1]);
}
else
{
pairs.add(value.toString());
}
}
Map<Float, String> sorted_pairs = new TreeMap<Float, String>(Collections.reverseOrder());
for(String pair : pairs)
{
String[] p = pair.split(",");
String[] doc_vec_1 = sig_matrix.get(p[0]).split(",");
String[] doc_vec_2 = sig_matrix.get(p[1]).split(",");
int intersection = 0;
for(int i = 0 ; i < doc_vec_1.length ; i++)
{
if(doc_vec_1[i].equals(doc_vec_2[i]))
intersection++;
}
float sim = (float)intersection / doc_vec_1.length;
if(sorted_pairs.containsKey(sim))
{
String dup_pairs = sorted_pairs.get(sim);
dup_pairs = dup_pairs + "#" + pair;
sorted_pairs.remove(sim);
sorted_pairs.put(sim, dup_pairs);
}
else
sorted_pairs.put(sim, pair);
}
for(Map.Entry<Float, String> entry : sorted_pairs.entrySet())
{
String v = entry.getValue();
float k = entry.getKey();
String[] dup_pairs = v.split("#");
for(String dup_pair : dup_pairs)
context.write(new Text("(" + dup_pair + ")"), new Text(Float.toString(k)));
}
}
}
public static void main(String[] args) throws Exception {
Configuration conf1 = new Configuration();
Job job1 = new Job(conf1, "lsh");
job1.setJarByClass(LSH.class);
job1.setMapperClass(Mapper1.class);
job1.setReducerClass(Reducer1.class);
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(Text.class);
for(int i = 1 ; i <= 50 ; i++)
{
FileInputFormat.addInputPath(job1, new Path("data/" + String.format("%03d", i) + ".txt"));
}
FileOutputFormat.setOutputPath(job1, new Path("output/lsh_1"));
job1.waitForCompletion(true);
int shingles_num = (int)job1.getCounters().findCounter("shingles_num", "shingles_num").getValue();
Configuration conf2 = new Configuration();
conf2.set("shingles_num", Integer.toString(shingles_num));
Job job2 = new Job(conf2, "lsh");
job2.setJarByClass(LSH.class);
job2.setMapperClass(Mapper2.class);
job2.setReducerClass(Reducer2.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job2, new Path("output/lsh_1"));
FileOutputFormat.setOutputPath(job2, new Path("output/lsh_2"));
job2.waitForCompletion(true);
Configuration conf3 = new Configuration();
Job job3 = new Job(conf3, "lsh");
job3.setJarByClass(LSH.class);
job3.setMapperClass(Mapper3.class);
job3.setReducerClass(Reducer3.class);
job3.setOutputKeyClass(Text.class);
job3.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job3, new Path("output/lsh_2"));
FileOutputFormat.setOutputPath(job3, new Path("output/lsh_3"));
job3.waitForCompletion(true);
Configuration conf4 = new Configuration();
Job job4 = new Job(conf4, "lsh");
job4.setJarByClass(LSH.class);
job4.setMapperClass(Mapper4.class);
job4.setReducerClass(Reducer4.class);
job4.setOutputKeyClass(Text.class);
job4.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job4, new Path("output/lsh_2"));
FileInputFormat.addInputPath(job4, new Path("output/lsh_3"));
FileOutputFormat.setOutputPath(job4, new Path("output/lsh_4"));
job4.waitForCompletion(true);
}
}
| 11,995 | 0.539225 | 0.526636 | 354 | 32.884182 | 27.704058 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.810734 | false | false |
14
|
06d086b6658b308ec922ddee52d6776cf821a993
| 27,573,690,064,303 |
fcee9ba0994ff1643f041e8d71ed334aa7a7a4ea
|
/src/main/java/no/minecraft/Minecraftno/handlers/SandtakHandler.java
|
a374cdce2cb5803317df518fd186e786a0c82da8
|
[] |
no_license
|
Uraxys/Hardwork
|
https://github.com/Uraxys/Hardwork
|
3ed5156512bd11de246ab130540ffab9b3b707af
|
9518375c3f1c16c59eb21f24546609dbb3520005
|
refs/heads/master
| 2020-12-19T09:44:36.492000 | 2016-05-24T12:28:38 | 2016-05-24T12:28:38 | 235,700,410 | 0 | 0 | null | true | 2020-01-23T01:09:13 | 2020-01-23T01:09:12 | 2017-10-16T14:30:23 | 2016-05-24T12:28:40 | 529 | 0 | 0 | 0 | null | false | false |
package no.minecraft.Minecraftno.handlers;
import com.sk89q.worldedit.bukkit.selections.Selection;
import no.minecraft.Minecraftno.Minecraftno;
import no.minecraft.Minecraftno.handlers.data.SandtakData;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.inventory.ItemStack;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
public class SandtakHandler {
private final Minecraftno plugin;
private final MySQLHandler sqlHandler;
private HashMap<String, SandtakData> sandtak = new HashMap<String, SandtakData>();
public SandtakHandler(Minecraftno plugin) {
this.plugin = plugin;
this.sqlHandler = plugin.getSqlHandler();
}
// Prepares all mysql statements
public void initialise() {
this.loadSandtak();
}
/**
* Loads all sandtak entries from the database and into the hashmap
*/
private void loadSandtak() {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
this.sandtak.clear();
conn = this.plugin.getConnection();
ps = conn.prepareStatement("SELECT `id`, `name`, `p1x`, `p1y`, `p1z`, `p2x`, `p2y`, `p2z`, `world` FROM sandtak");
rs = ps.executeQuery();
while (rs.next()) {
int sandtakId = rs.getInt(1);
String sandtakName = rs.getString(2);
String worldName = rs.getString(9);
Location pos1 = new Location(this.plugin.getServer().getWorld(worldName), rs.getInt(3), rs.getInt(4), rs.getInt(5));
Location pos2 = new Location(this.plugin.getServer().getWorld(worldName), rs.getInt(6), rs.getInt(7), rs.getInt(8));
this.sandtak.put(sandtakName, new SandtakData(sandtakId, sandtakName, pos1, pos2, worldName));
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Minecraftno] SQL-feil i: " + Thread.currentThread().getStackTrace()[0].getMethodName(), e);
} finally {
try {
if (ps != null) {
ps.close();
}
if (rs != null) {
rs.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Returns the map containing all loaded sandtak
*
* @return Hashmap
*/
public HashMap<String, SandtakData> getSandtakMap() {
return this.sandtak;
}
/**
* Displays a sorted list of all sandtak
*
* @return List or null if empty
*/
public List<String> getSandtakList() {
if (!this.sandtak.isEmpty()) {
List<String> sandtakList = new ArrayList<String>(this.sandtak.keySet());
Collections.sort(sandtakList);
return sandtakList;
} else {
return null;
}
}
/**
* Adds a new sandtak with the given name and positions
*
* @param name Name of the new sandtak
* @param pos1 Position 1 of the sandtak
* @param pos2 Position 2 of the sandtak
*
* @return true on success, false otherwise
*/
public boolean addSandtak(String name, Location pos1, Location pos2) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("INSERT INTO `sandtak`(`name`, `p1x`, `p1y`, `p1z`, `p2x`, `p2y`, `p2z`, `world`)" + "VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
ps.setString(1, name);
ps.setInt(2, (int) pos1.getX());
ps.setInt(3, (int) pos1.getY());
ps.setInt(4, (int) pos1.getZ());
ps.setInt(5, (int) pos2.getX());
ps.setInt(6, (int) pos2.getY());
ps.setInt(7, (int) pos2.getZ());
ps.setString(8, pos1.getWorld().getName());
ps.executeUpdate();
this.loadSandtak();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke legge til et nytt sandtak: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Deletes a given sandtak
*
* @param name Name of the sandtak to be deleted
*
* @return true on success, false otherwise
*/
public boolean deleteSandtak(String name) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("DELETE FROM `sandtak` WHERE `name` = ?");
ps.setString(1, name);
ps.executeUpdate();
this.loadSandtak();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke fjerne et sandtak: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Verifies if the given sandtak name exists in the database
*
* @param name Name of the sandtak
*
* @return String on success, null otherwise
*/
public String getSandtakName(String name) {
return this.sqlHandler.getColumn("SELECT `name` FROM `sandtak` WHERE `name` = '" + name + "'");
}
/**
* Retrieves the sandtak inventory status for the given player
*
* @param playerName Player of which to retrieve inventory status
* @param material Material in inventory
*
* @return quantitiy of double chests in inventory, or -1 on failure
*/
@SuppressWarnings("deprecation")
public int getSandtakInventoryStatus(String playerName, Material material) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("SELECT `doublechestQuantity` FROM `sandtak_inventory` WHERE userid" + "= (SELECT `id` FROM Minecraftno.users WHERE name = ?) AND material = ?");
ps.setString(1, playerName);
ps.setInt(2, material.getId());
rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt(1);
}
return 0; // if while loop doesn't run, user has no row and no quantity
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke hente sandtakInventoryStatus: ", e);
return -1;
} finally {
try {
if (ps != null) {
ps.close();
}
if (rs != null) {
rs.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Updates information about a players sandtakinventorystatus
*
* @param playerName Name of the player
* @param materialId Id of the material being added
*
* @return true on success, false otherwise
*/
public boolean updateSandtakInventoryStatus(String playerName, int materialId) {
Connection conn = null;
PreparedStatement ps = null;
PreparedStatement ps2 = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("UPDATE `sandtak_inventory` SET `doublechestQuantity` = (`doublechestQuantity` + ?)" + "WHERE `userid` = (SELECT `id` FROM Minecraftno.users WHERE `name` = ?) AND `material` = ?");
ps.setInt(1, 1); // quantity = 1 as we only allow one dk in the selection right now
ps.setString(2, playerName);
ps.setInt(3, materialId);
if (ps.executeUpdate() == 0) { // affects no rows = we need to create a user row!
ps2 = conn.prepareStatement("INSERT INTO `sandtak_inventory`" + "(`userid`, `material`, `doublechestQuantity`) VALUES((SELECT `id` FROM Minecraftno.users WHERE `name` = ?), ?, ?)");
ps2.setString(1, playerName);
ps2.setInt(2, materialId);
ps2.setInt(3, 1); // quantity = 1 as we only allow one dk in the selection right now
ps2.executeUpdate();
}
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke oppdatere sandtakInventoryStatus: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (ps2 != null) {
ps2.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Removes double chests from a players inventory status
*
* @param playerName Name of the player
* @param amountOfDk Amount being removed
* @param material material
*
* @return True on success, false otherwise
*/
@SuppressWarnings("deprecation")
public boolean removeDksFromPlayerSandtakInventory(String playerName, int amountOfDk, Material material) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("UPDATE `sandtak_inventory` SET `doublechestQuantity` = (`doublechestQuantity` - ?)" + "WHERE `userid` = (SELECT `id` FROM Minecraftno.users WHERE `name` = ?) AND `material` = ?");
ps.setInt(1, amountOfDk);
ps.setString(2, playerName);
ps.setInt(3, material.getId());
ps.executeUpdate();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke oppdatere removeDksFromPlayerSandtakInventory: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Checks if there exists any blocks within the area of the sandtak
*
* @param sandtakName The name of the sandtak to check
*
* @return True if the sandtak is empty, false otherwise
*/
public boolean isSandtakEmpty(String sandtakName) {
if (this.sandtak.containsKey(sandtakName)) {
Location pos1 = this.sandtak.get(sandtakName).getPos1();
Location pos2 = this.sandtak.get(sandtakName).getPos2();
String worldName = this.sandtak.get(sandtakName).getWorldName();
int startX, startY, startZ, endX, endY, endZ;
if ((int) pos1.getX() >= (int) pos2.getX()) {
startX = (int) pos1.getX();
endX = (int) pos2.getX();
} else {
startX = (int) pos2.getX();
endX = (int) pos1.getX();
}
if ((int) pos1.getY() >= (int) pos2.getY()) {
startY = (int) pos1.getY();
endY = (int) pos2.getY();
} else {
startY = (int) pos2.getY();
endY = (int) pos1.getY();
}
if ((int) pos1.getZ() >= (int) pos2.getZ()) {
startZ = (int) pos1.getZ();
endZ = (int) pos2.getZ();
} else {
startZ = (int) pos2.getZ();
endZ = (int) pos1.getZ();
}
for (int x = startX; x >= endX; x--) {
for (int y = startY; y >= endY; y--) {
for (int z = startZ; z >= endZ; z--) {
Block block = this.plugin.getServer().getWorld(worldName).getBlockAt(x, y, z);
if (!block.getType().equals(Material.AIR)) {
return false;
}
}
}
}
} else {
return false; // Should never occur as we check if the desired sandtak already exists
}
return true;
}
/**
* Fills the given sandtak with the given amount starting from the bottom
*
* @param sandtakName Name of sandtak
* @param amountOfDk Amount of double chests to fill the sandtak with
* @param material Material id to fill the sandtak with
*/
public void fillSandtak(String sandtakName, int amountOfDk, Material material) {
this.fillSandtak(sandtakName, amountOfDk, material, 0);
}
public void fillSandtak(String sandtakName, int amountOfDk, Material material, int data) {
Location pos1 = this.sandtak.get(sandtakName).getPos1();
Location pos2 = this.sandtak.get(sandtakName).getPos2();
String worldName = this.sandtak.get(sandtakName).getWorldName();
int startX, startY, startZ, endX, endY, endZ;
int counter = 0;
if ((int) pos1.getX() >= (int) pos2.getX()) {
startX = (int) pos1.getX();
endX = (int) pos2.getX();
} else {
startX = (int) pos2.getX();
endX = (int) pos1.getX();
}
if ((int) pos1.getY() < (int) pos2.getY()) {
startY = (int) pos1.getY();
endY = (int) pos2.getY();
} else {
startY = (int) pos2.getY();
endY = (int) pos1.getY();
}
if ((int) pos1.getZ() >= (int) pos2.getZ()) {
startZ = (int) pos1.getZ();
endZ = (int) pos2.getZ();
} else {
startZ = (int) pos2.getZ();
endZ = (int) pos1.getZ();
}
for (int y = startY; y <= endY; y++) {
for (int x = startX; x >= endX; x--) {
for (int z = startZ; z >= endZ; z--) {
if ((counter / 3456) == amountOfDk) {
return;
}
Block block = this.plugin.getServer().getWorld(worldName).getBlockAt(x, y, z);
block.setType(material);
block.setData((byte) data);
counter++;
}
}
}
}
/**
* Verifies a players selection to make sure it contains a double chest filled with either stone or cobblestone
*
* @param sel The players selection
*
* @return true if selection is valid, false otherwise
*/
public boolean verifyValidSelection(Selection sel) {
if (sel.getArea() == 2) {
Location pos1 = sel.getMaximumPoint();
Location pos2 = sel.getMinimumPoint();
if (pos1.getBlock().getType().equals(Material.CHEST) && pos2.getBlock().getType().equals(Material.CHEST)) {
Chest chest = (Chest) pos1.getBlock().getState();
if (chest.getInventory().getContents() != null && chest.getInventory().getItem(0) != null) {
Material slot1Material = chest.getInventory().getItem(0).getType();
for (ItemStack stack : chest.getInventory().getContents()) { // unsure whether this contains the inventory for just one of the sides or the whole chest
if (stack == null || slot1Material != stack.getType() || !((stack.getType().equals(Material.COBBLESTONE) || stack.getType().equals(Material.STONE)) && stack.getAmount() == 64)) {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
return true;
}
/**
* Removes protection from the double chest, clears inventory, and breaks the block
*
* @param sel Selection containing double chest
*/
public void removeDoubleChest(Selection sel) { // this should be updated to include a single block and not two
Location pos1 = sel.getMaximumPoint();
Location pos2 = sel.getMinimumPoint();
this.plugin.getBlockHandler().deleteBlockProtection(pos1.getBlock());
this.plugin.getBlockHandler().deleteBlockProtection(pos2.getBlock());
Chest chest1 = (Chest) pos1.getBlock().getState();
chest1.getInventory().clear();
Chest chest2 = (Chest) pos2.getBlock().getState();
chest2.getInventory().clear();
pos1.getBlock().breakNaturally();
pos2.getBlock().breakNaturally();
}
/**
* Returns the id of the material found inside the chest
*
* @param sel Players selection containing the chest
*
* @return id of material found inside chest
*/
public int getMaterialFromChest(Selection sel) {
Location pos1 = sel.getMaximumPoint();
Chest chest = (Chest) pos1.getBlock().getState();
return chest.getInventory().getItem(0).getTypeId();
}
}
|
UTF-8
|
Java
| 18,315 |
java
|
SandtakHandler.java
|
Java
|
[
{
"context": "takinventorystatus\n *\n * @param playerName Name of the player\n * @param materialId Id of the materia",
"end": 8068,
"score": 0.8406510353088379,
"start": 8057,
"tag": "NAME",
"value": "Name of the"
},
{
"context": "status\n *\n * @param playerName Name of the player\n * @param materialId Id of the material being",
"end": 8075,
"score": 0.44188016653060913,
"start": 8069,
"tag": "NAME",
"value": "player"
},
{
"context": "s inventory status\n *\n * @param playerName Name of the player\n * @param amountOfDk Amount bei",
"end": 10114,
"score": 0.5753529071807861,
"start": 10110,
"tag": "NAME",
"value": "Name"
}
] | null |
[] |
package no.minecraft.Minecraftno.handlers;
import com.sk89q.worldedit.bukkit.selections.Selection;
import no.minecraft.Minecraftno.Minecraftno;
import no.minecraft.Minecraftno.handlers.data.SandtakData;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.inventory.ItemStack;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
public class SandtakHandler {
private final Minecraftno plugin;
private final MySQLHandler sqlHandler;
private HashMap<String, SandtakData> sandtak = new HashMap<String, SandtakData>();
public SandtakHandler(Minecraftno plugin) {
this.plugin = plugin;
this.sqlHandler = plugin.getSqlHandler();
}
// Prepares all mysql statements
public void initialise() {
this.loadSandtak();
}
/**
* Loads all sandtak entries from the database and into the hashmap
*/
private void loadSandtak() {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
this.sandtak.clear();
conn = this.plugin.getConnection();
ps = conn.prepareStatement("SELECT `id`, `name`, `p1x`, `p1y`, `p1z`, `p2x`, `p2y`, `p2z`, `world` FROM sandtak");
rs = ps.executeQuery();
while (rs.next()) {
int sandtakId = rs.getInt(1);
String sandtakName = rs.getString(2);
String worldName = rs.getString(9);
Location pos1 = new Location(this.plugin.getServer().getWorld(worldName), rs.getInt(3), rs.getInt(4), rs.getInt(5));
Location pos2 = new Location(this.plugin.getServer().getWorld(worldName), rs.getInt(6), rs.getInt(7), rs.getInt(8));
this.sandtak.put(sandtakName, new SandtakData(sandtakId, sandtakName, pos1, pos2, worldName));
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Minecraftno] SQL-feil i: " + Thread.currentThread().getStackTrace()[0].getMethodName(), e);
} finally {
try {
if (ps != null) {
ps.close();
}
if (rs != null) {
rs.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Returns the map containing all loaded sandtak
*
* @return Hashmap
*/
public HashMap<String, SandtakData> getSandtakMap() {
return this.sandtak;
}
/**
* Displays a sorted list of all sandtak
*
* @return List or null if empty
*/
public List<String> getSandtakList() {
if (!this.sandtak.isEmpty()) {
List<String> sandtakList = new ArrayList<String>(this.sandtak.keySet());
Collections.sort(sandtakList);
return sandtakList;
} else {
return null;
}
}
/**
* Adds a new sandtak with the given name and positions
*
* @param name Name of the new sandtak
* @param pos1 Position 1 of the sandtak
* @param pos2 Position 2 of the sandtak
*
* @return true on success, false otherwise
*/
public boolean addSandtak(String name, Location pos1, Location pos2) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("INSERT INTO `sandtak`(`name`, `p1x`, `p1y`, `p1z`, `p2x`, `p2y`, `p2z`, `world`)" + "VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
ps.setString(1, name);
ps.setInt(2, (int) pos1.getX());
ps.setInt(3, (int) pos1.getY());
ps.setInt(4, (int) pos1.getZ());
ps.setInt(5, (int) pos2.getX());
ps.setInt(6, (int) pos2.getY());
ps.setInt(7, (int) pos2.getZ());
ps.setString(8, pos1.getWorld().getName());
ps.executeUpdate();
this.loadSandtak();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke legge til et nytt sandtak: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Deletes a given sandtak
*
* @param name Name of the sandtak to be deleted
*
* @return true on success, false otherwise
*/
public boolean deleteSandtak(String name) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("DELETE FROM `sandtak` WHERE `name` = ?");
ps.setString(1, name);
ps.executeUpdate();
this.loadSandtak();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke fjerne et sandtak: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Verifies if the given sandtak name exists in the database
*
* @param name Name of the sandtak
*
* @return String on success, null otherwise
*/
public String getSandtakName(String name) {
return this.sqlHandler.getColumn("SELECT `name` FROM `sandtak` WHERE `name` = '" + name + "'");
}
/**
* Retrieves the sandtak inventory status for the given player
*
* @param playerName Player of which to retrieve inventory status
* @param material Material in inventory
*
* @return quantitiy of double chests in inventory, or -1 on failure
*/
@SuppressWarnings("deprecation")
public int getSandtakInventoryStatus(String playerName, Material material) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("SELECT `doublechestQuantity` FROM `sandtak_inventory` WHERE userid" + "= (SELECT `id` FROM Minecraftno.users WHERE name = ?) AND material = ?");
ps.setString(1, playerName);
ps.setInt(2, material.getId());
rs = ps.executeQuery();
if (rs.next()) {
return rs.getInt(1);
}
return 0; // if while loop doesn't run, user has no row and no quantity
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke hente sandtakInventoryStatus: ", e);
return -1;
} finally {
try {
if (ps != null) {
ps.close();
}
if (rs != null) {
rs.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Updates information about a players sandtakinventorystatus
*
* @param playerName <NAME> player
* @param materialId Id of the material being added
*
* @return true on success, false otherwise
*/
public boolean updateSandtakInventoryStatus(String playerName, int materialId) {
Connection conn = null;
PreparedStatement ps = null;
PreparedStatement ps2 = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("UPDATE `sandtak_inventory` SET `doublechestQuantity` = (`doublechestQuantity` + ?)" + "WHERE `userid` = (SELECT `id` FROM Minecraftno.users WHERE `name` = ?) AND `material` = ?");
ps.setInt(1, 1); // quantity = 1 as we only allow one dk in the selection right now
ps.setString(2, playerName);
ps.setInt(3, materialId);
if (ps.executeUpdate() == 0) { // affects no rows = we need to create a user row!
ps2 = conn.prepareStatement("INSERT INTO `sandtak_inventory`" + "(`userid`, `material`, `doublechestQuantity`) VALUES((SELECT `id` FROM Minecraftno.users WHERE `name` = ?), ?, ?)");
ps2.setString(1, playerName);
ps2.setInt(2, materialId);
ps2.setInt(3, 1); // quantity = 1 as we only allow one dk in the selection right now
ps2.executeUpdate();
}
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke oppdatere sandtakInventoryStatus: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (ps2 != null) {
ps2.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Removes double chests from a players inventory status
*
* @param playerName Name of the player
* @param amountOfDk Amount being removed
* @param material material
*
* @return True on success, false otherwise
*/
@SuppressWarnings("deprecation")
public boolean removeDksFromPlayerSandtakInventory(String playerName, int amountOfDk, Material material) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = this.plugin.getConnection();
ps = conn.prepareStatement("UPDATE `sandtak_inventory` SET `doublechestQuantity` = (`doublechestQuantity` - ?)" + "WHERE `userid` = (SELECT `id` FROM Minecraftno.users WHERE `name` = ?) AND `material` = ?");
ps.setInt(1, amountOfDk);
ps.setString(2, playerName);
ps.setInt(3, material.getId());
ps.executeUpdate();
return true;
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "[Hardwork] Kunne ikke oppdatere removeDksFromPlayerSandtakInventory: ", e);
return false;
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
//conn.close();
}
} catch (SQLException e) {
Minecraftno.log.log(Level.SEVERE, "SQL-error:", e);
}
}
}
/**
* Checks if there exists any blocks within the area of the sandtak
*
* @param sandtakName The name of the sandtak to check
*
* @return True if the sandtak is empty, false otherwise
*/
public boolean isSandtakEmpty(String sandtakName) {
if (this.sandtak.containsKey(sandtakName)) {
Location pos1 = this.sandtak.get(sandtakName).getPos1();
Location pos2 = this.sandtak.get(sandtakName).getPos2();
String worldName = this.sandtak.get(sandtakName).getWorldName();
int startX, startY, startZ, endX, endY, endZ;
if ((int) pos1.getX() >= (int) pos2.getX()) {
startX = (int) pos1.getX();
endX = (int) pos2.getX();
} else {
startX = (int) pos2.getX();
endX = (int) pos1.getX();
}
if ((int) pos1.getY() >= (int) pos2.getY()) {
startY = (int) pos1.getY();
endY = (int) pos2.getY();
} else {
startY = (int) pos2.getY();
endY = (int) pos1.getY();
}
if ((int) pos1.getZ() >= (int) pos2.getZ()) {
startZ = (int) pos1.getZ();
endZ = (int) pos2.getZ();
} else {
startZ = (int) pos2.getZ();
endZ = (int) pos1.getZ();
}
for (int x = startX; x >= endX; x--) {
for (int y = startY; y >= endY; y--) {
for (int z = startZ; z >= endZ; z--) {
Block block = this.plugin.getServer().getWorld(worldName).getBlockAt(x, y, z);
if (!block.getType().equals(Material.AIR)) {
return false;
}
}
}
}
} else {
return false; // Should never occur as we check if the desired sandtak already exists
}
return true;
}
/**
* Fills the given sandtak with the given amount starting from the bottom
*
* @param sandtakName Name of sandtak
* @param amountOfDk Amount of double chests to fill the sandtak with
* @param material Material id to fill the sandtak with
*/
public void fillSandtak(String sandtakName, int amountOfDk, Material material) {
this.fillSandtak(sandtakName, amountOfDk, material, 0);
}
public void fillSandtak(String sandtakName, int amountOfDk, Material material, int data) {
Location pos1 = this.sandtak.get(sandtakName).getPos1();
Location pos2 = this.sandtak.get(sandtakName).getPos2();
String worldName = this.sandtak.get(sandtakName).getWorldName();
int startX, startY, startZ, endX, endY, endZ;
int counter = 0;
if ((int) pos1.getX() >= (int) pos2.getX()) {
startX = (int) pos1.getX();
endX = (int) pos2.getX();
} else {
startX = (int) pos2.getX();
endX = (int) pos1.getX();
}
if ((int) pos1.getY() < (int) pos2.getY()) {
startY = (int) pos1.getY();
endY = (int) pos2.getY();
} else {
startY = (int) pos2.getY();
endY = (int) pos1.getY();
}
if ((int) pos1.getZ() >= (int) pos2.getZ()) {
startZ = (int) pos1.getZ();
endZ = (int) pos2.getZ();
} else {
startZ = (int) pos2.getZ();
endZ = (int) pos1.getZ();
}
for (int y = startY; y <= endY; y++) {
for (int x = startX; x >= endX; x--) {
for (int z = startZ; z >= endZ; z--) {
if ((counter / 3456) == amountOfDk) {
return;
}
Block block = this.plugin.getServer().getWorld(worldName).getBlockAt(x, y, z);
block.setType(material);
block.setData((byte) data);
counter++;
}
}
}
}
/**
* Verifies a players selection to make sure it contains a double chest filled with either stone or cobblestone
*
* @param sel The players selection
*
* @return true if selection is valid, false otherwise
*/
public boolean verifyValidSelection(Selection sel) {
if (sel.getArea() == 2) {
Location pos1 = sel.getMaximumPoint();
Location pos2 = sel.getMinimumPoint();
if (pos1.getBlock().getType().equals(Material.CHEST) && pos2.getBlock().getType().equals(Material.CHEST)) {
Chest chest = (Chest) pos1.getBlock().getState();
if (chest.getInventory().getContents() != null && chest.getInventory().getItem(0) != null) {
Material slot1Material = chest.getInventory().getItem(0).getType();
for (ItemStack stack : chest.getInventory().getContents()) { // unsure whether this contains the inventory for just one of the sides or the whole chest
if (stack == null || slot1Material != stack.getType() || !((stack.getType().equals(Material.COBBLESTONE) || stack.getType().equals(Material.STONE)) && stack.getAmount() == 64)) {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
return true;
}
/**
* Removes protection from the double chest, clears inventory, and breaks the block
*
* @param sel Selection containing double chest
*/
public void removeDoubleChest(Selection sel) { // this should be updated to include a single block and not two
Location pos1 = sel.getMaximumPoint();
Location pos2 = sel.getMinimumPoint();
this.plugin.getBlockHandler().deleteBlockProtection(pos1.getBlock());
this.plugin.getBlockHandler().deleteBlockProtection(pos2.getBlock());
Chest chest1 = (Chest) pos1.getBlock().getState();
chest1.getInventory().clear();
Chest chest2 = (Chest) pos2.getBlock().getState();
chest2.getInventory().clear();
pos1.getBlock().breakNaturally();
pos2.getBlock().breakNaturally();
}
/**
* Returns the id of the material found inside the chest
*
* @param sel Players selection containing the chest
*
* @return id of material found inside chest
*/
public int getMaterialFromChest(Selection sel) {
Location pos1 = sel.getMaximumPoint();
Chest chest = (Chest) pos1.getBlock().getState();
return chest.getInventory().getItem(0).getTypeId();
}
}
| 18,310 | 0.530385 | 0.521922 | 495 | 36.002022 | 32.469254 | 219 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.680808 | false | false |
14
|
f96d4d789c9a9ca21ecbae99484ec418305bc739
| 15,762,529,985,761 |
327b1833bc1e896f992402e2d2409f757c457408
|
/TextAdventure/src/Engine/Main.java
|
50de9155cc1a5956cf7db8b3c3f18186537a94ec
|
[] |
no_license
|
MoloHunt/TextAdventure
|
https://github.com/MoloHunt/TextAdventure
|
917891319576649e3d4d3b9ef6c3400a3005bab9
|
563f3ee55b55c9f057976e887a461e9893675a1c
|
refs/heads/master
| 2016-05-28T10:37:22.666000 | 2014-10-07T11:55:30 | 2014-10-07T11:55:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Engine;
public class Main {
public static void main(String[] args) {
Main m = new Main();
m.Start();
}
private void Start() {
Player p = new Player();
p.CharacterSheet();
}
}
|
UTF-8
|
Java
| 274 |
java
|
Main.java
|
Java
|
[] | null |
[] |
package Engine;
public class Main {
public static void main(String[] args) {
Main m = new Main();
m.Start();
}
private void Start() {
Player p = new Player();
p.CharacterSheet();
}
}
| 274 | 0.448905 | 0.448905 | 19 | 12.421053 | 13.063874 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.263158 | false | false |
14
|
d2d01c33aa30b1198f79b40c6c52d201d5e77b4c
| 19,885,698,616,204 |
59ea3ea599e7c30dd3e82bf257d83001ea76c3f6
|
/src/interview/LoadConfig.java
|
0a390f629d6639f68ae095bab774af11f8ec39da
|
[] |
no_license
|
micheleorsi/exercises
|
https://github.com/micheleorsi/exercises
|
07e84f751eb5c5567fd65f8406539382b45c626b
|
68a156bee9afb4565628f4ffb17b9c86bb4fd75d
|
refs/heads/master
| 2020-12-30T16:27:51.497000 | 2017-11-05T16:43:51 | 2017-11-05T16:43:51 | 90,987,188 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package interview;
public class LoadConfig
{
// // This is the text editor interface.
// // Anything you type or change here will be seen by the other person in real time.
//
// servers = staging,production,test
// staging = 1.2.3.4,http_port
// production = 1.2.3.5,http_port,secret_key
// http_port = 80
// test = localhost
// secret_key = qweasd
//
// load_config(“servers”) = 1.2.3.4,80,1.2.3.5,80,qweasd,localhost
//
// Map<String,List<String>> map = new HashMap<>();
//map.put("servers",Arrays.asList("staging","production","test");
//..
//
// public String load_config(String input)
// {
//
// List<String> valueInTheMap = map.get(input);
// if(valueInTheMap==null)
// {
// return input;
// }
// if(valueInTheMap.size()==1)
// {
// return valueInTheMap.get(0);
// }
// if(valueInTheMap.size()!=0) {
// StringBuilder sb = new StringBuilder();
// for(String actualValue: valueInTheMap)
// {
// // check if it is a string or a key
// if(map.contains(actualValue))
// {
// sb.append(load_config(actualValue));
// } else
// {
// sb.append(actualValue);
// }
// sb.append(",");
// }
// return sb.toString();
// } else
// {
// return "";
// }
//
//
// }
//
// // staging, production, test
// // 1.2.3.4
}
|
UTF-8
|
Java
| 1,365 |
java
|
LoadConfig.java
|
Java
|
[
{
"context": " servers = staging,production,test\n// staging = 1.2.3.4,http_port\n// production = 1.2.3.5,http_port,secr",
"end": 237,
"score": 0.9997487664222717,
"start": 230,
"tag": "IP_ADDRESS",
"value": "1.2.3.4"
},
{
"context": "\n// staging = 1.2.3.4,http_port\n// production = 1.2.3.5,http_port,secret_key\n// http_port = 80\n// test ",
"end": 272,
"score": 0.999742865562439,
"start": 265,
"tag": "IP_ADDRESS",
"value": "1.2.3.5"
},
{
"context": "tp_port = 80\n// test = localhost\n// secret_key = qweasd\n//\n// load_config(“servers”) = 1.2.3.4,80,1.2.3.",
"end": 357,
"score": 0.9992496967315674,
"start": 351,
"tag": "KEY",
"value": "qweasd"
},
{
"context": "cret_key = qweasd\n//\n// load_config(“servers”) = 1.2.3.4,80,1.2.3.5,80,qweasd,localhost\n//\n// Map<String,",
"end": 397,
"score": 0.9997410774230957,
"start": 390,
"tag": "IP_ADDRESS",
"value": "1.2.3.4"
},
{
"context": "qweasd\n//\n// load_config(“servers”) = 1.2.3.4,80,1.2.3.5,80,qweasd,localhost\n//\n// Map<String,List<String",
"end": 408,
"score": 0.9997370839118958,
"start": 401,
"tag": "IP_ADDRESS",
"value": "1.2.3.5"
},
{
"context": "\n// }\n//\n// // staging, production, test\n// // 1.2.3.4\n}\n",
"end": 1358,
"score": 0.9997485876083374,
"start": 1351,
"tag": "IP_ADDRESS",
"value": "1.2.3.4"
}
] | null |
[] |
package interview;
public class LoadConfig
{
// // This is the text editor interface.
// // Anything you type or change here will be seen by the other person in real time.
//
// servers = staging,production,test
// staging = 172.16.31.10,http_port
// production = 172.16.17.32,http_port,secret_key
// http_port = 80
// test = localhost
// secret_key = qweasd
//
// load_config(“servers”) = 172.16.31.10,80,172.16.17.32,80,qweasd,localhost
//
// Map<String,List<String>> map = new HashMap<>();
//map.put("servers",Arrays.asList("staging","production","test");
//..
//
// public String load_config(String input)
// {
//
// List<String> valueInTheMap = map.get(input);
// if(valueInTheMap==null)
// {
// return input;
// }
// if(valueInTheMap.size()==1)
// {
// return valueInTheMap.get(0);
// }
// if(valueInTheMap.size()!=0) {
// StringBuilder sb = new StringBuilder();
// for(String actualValue: valueInTheMap)
// {
// // check if it is a string or a key
// if(map.contains(actualValue))
// {
// sb.append(load_config(actualValue));
// } else
// {
// sb.append(actualValue);
// }
// sb.append(",");
// }
// return sb.toString();
// } else
// {
// return "";
// }
//
//
// }
//
// // staging, production, test
// // 172.16.31.10
}
| 1,390 | 0.550331 | 0.529023 | 58 | 22.465517 | 19.718025 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
14
|
9bbbf17c636052bfa917ff224268cfa0789f0497
| 18,322,330,494,018 |
6f672fb72caedccb841ee23f53e32aceeaf1895e
|
/Photography/amazon_photos_source/src/com/amazon/gallery/framework/network/http/rest/account/SubscriptionInfoCache$8.java
|
7c4fe9951c67e0b350e3e73dd8c626f0908c9578
|
[] |
no_license
|
cha63506/CompSecurity
|
https://github.com/cha63506/CompSecurity
|
5c69743f660b9899146ed3cf21eceabe3d5f4280
|
eee7e74f4088b9c02dd711c061fc04fb1e4e2654
|
refs/heads/master
| 2018-03-23T04:15:18.480000 | 2015-12-19T01:29:58 | 2015-12-19T01:29:58 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package com.amazon.gallery.framework.network.http.rest.account;
import android.content.SharedPreferences;
import com.amazon.gallery.foundation.utils.apilevel.BuildFlavors;
import java.util.concurrent.Callable;
// Referenced classes of package com.amazon.gallery.framework.network.http.rest.account:
// SubscriptionInfoCache
class val.timeout
implements Callable
{
final SubscriptionInfoCache this$0;
final long val$timeout;
public omotion call()
{
if (BuildFlavors.isDebug() && SubscriptionInfoCache.access$600(SubscriptionInfoCache.this).getBoolean("FORCE_DEBUG_PROMOTION", false))
{
SubscriptionInfoCache.access$600(SubscriptionInfoCache.this).edit().putBoolean("FORCE_DEBUG_PROMOTION", false).apply();
return SubscriptionInfoCache.access$700();
}
if (SubscriptionInfoCache.access$800(SubscriptionInfoCache.this) && SubscriptionInfoCache.access$900(SubscriptionInfoCache.this) != null)
{
return SubscriptionInfoCache.access$1000(SubscriptionInfoCache.this, val$timeout);
} else
{
return null;
}
}
public volatile Object call()
throws Exception
{
return call();
}
omotion()
{
this$0 = final_subscriptioninfocache;
val$timeout = J.this;
super();
}
}
|
UTF-8
|
Java
| 1,543 |
java
|
SubscriptionInfoCache$8.java
|
Java
|
[
{
"context": "// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.\n// Jad home page: http://www.geocities.com/kpdus",
"end": 61,
"score": 0.9996118545532227,
"start": 45,
"tag": "NAME",
"value": "Pavel Kouznetsov"
}
] | null |
[] |
// Decompiled by Jad v1.5.8e. Copyright 2001 <NAME>.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package com.amazon.gallery.framework.network.http.rest.account;
import android.content.SharedPreferences;
import com.amazon.gallery.foundation.utils.apilevel.BuildFlavors;
import java.util.concurrent.Callable;
// Referenced classes of package com.amazon.gallery.framework.network.http.rest.account:
// SubscriptionInfoCache
class val.timeout
implements Callable
{
final SubscriptionInfoCache this$0;
final long val$timeout;
public omotion call()
{
if (BuildFlavors.isDebug() && SubscriptionInfoCache.access$600(SubscriptionInfoCache.this).getBoolean("FORCE_DEBUG_PROMOTION", false))
{
SubscriptionInfoCache.access$600(SubscriptionInfoCache.this).edit().putBoolean("FORCE_DEBUG_PROMOTION", false).apply();
return SubscriptionInfoCache.access$700();
}
if (SubscriptionInfoCache.access$800(SubscriptionInfoCache.this) && SubscriptionInfoCache.access$900(SubscriptionInfoCache.this) != null)
{
return SubscriptionInfoCache.access$1000(SubscriptionInfoCache.this, val$timeout);
} else
{
return null;
}
}
public volatile Object call()
throws Exception
{
return call();
}
omotion()
{
this$0 = final_subscriptioninfocache;
val$timeout = J.this;
super();
}
}
| 1,533 | 0.686325 | 0.668179 | 49 | 30.489796 | 36.427799 | 145 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.346939 | false | false |
14
|
005e7bd77442d8b8564b850859b21b50052febbb
| 30,374,008,738,474 |
1b631972a20ab63c202336033ab562fd4d3a6851
|
/src/main/java/com/mars/almtool/gui/component/IpField.java
|
3650852bdaeeaf140583c6d9fd795424a4136da0
|
[] |
no_license
|
garfieldyao/almtool
|
https://github.com/garfieldyao/almtool
|
5f7ddcb56d9f765d81a9db666e190f6d6823ff91
|
c07f9a99cf57149757cfa662f579e570598294e7
|
refs/heads/master
| 2020-05-29T09:49:07.762000 | 2013-08-15T12:50:53 | 2013-08-15T12:50:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* $Id: IpField.java, 2011-12-9 ����1:38:40 Yao Exp $
*
* Copyright (c) 2011 Alcatel-Lucent Shanghai Bell Co., Ltd
* All rights reserved.
*
* This software is copyrighted and owned by ASB or the copyright holder
* specified, unless otherwise noted, and may not be reproduced or distributed
* in whole or in part in any form or medium without express written permission.
*/
package com.mars.almtool.gui.component;
import javax.swing.JComponent;
import com.mars.almtool.gui.MessagePanel;
import com.mars.almtool.utils.GeneralUtils;
/**
* <p>
* Title: IpField
* </p>
* <p>
* Description:
* </p>
*
* @author Yao Liqiang
* @created 2011-12-9 ����1:38:40
* @modified [who date description]
* @check [who date description]
*/
public class IpField extends ValidTextField {
private static final long serialVersionUID = 3063893551601523175L;
/**
* @param title
* @param msgPanel
* @param comp
*/
public IpField(String title, MessagePanel msgPanel, JComponent comp) {
super(title, msgPanel, comp);
}
/**
* (non-Javadoc)
*
* @see com.mars.almtool.gui.component.ValidTextField#valid(java.lang.String)
*/
@Override
public boolean valid(String text) {
return GeneralUtils.isValidAddress(text);
}
}
|
UTF-8
|
Java
| 1,374 |
java
|
IpField.java
|
Java
|
[
{
"context": "\n * <p>\r\n * Description:\r\n * </p>\r\n * \r\n * @author Yao Liqiang\r\n * @created 2011-12-9 ����1:38:40\r\n * @modified ",
"end": 666,
"score": 0.9998151659965515,
"start": 655,
"tag": "NAME",
"value": "Yao Liqiang"
}
] | null |
[] |
/*
* $Id: IpField.java, 2011-12-9 ����1:38:40 Yao Exp $
*
* Copyright (c) 2011 Alcatel-Lucent Shanghai Bell Co., Ltd
* All rights reserved.
*
* This software is copyrighted and owned by ASB or the copyright holder
* specified, unless otherwise noted, and may not be reproduced or distributed
* in whole or in part in any form or medium without express written permission.
*/
package com.mars.almtool.gui.component;
import javax.swing.JComponent;
import com.mars.almtool.gui.MessagePanel;
import com.mars.almtool.utils.GeneralUtils;
/**
* <p>
* Title: IpField
* </p>
* <p>
* Description:
* </p>
*
* @author <NAME>
* @created 2011-12-9 ����1:38:40
* @modified [who date description]
* @check [who date description]
*/
public class IpField extends ValidTextField {
private static final long serialVersionUID = 3063893551601523175L;
/**
* @param title
* @param msgPanel
* @param comp
*/
public IpField(String title, MessagePanel msgPanel, JComponent comp) {
super(title, msgPanel, comp);
}
/**
* (non-Javadoc)
*
* @see com.mars.almtool.gui.component.ValidTextField#valid(java.lang.String)
*/
@Override
public boolean valid(String text) {
return GeneralUtils.isValidAddress(text);
}
}
| 1,369 | 0.641384 | 0.606775 | 53 | 23.622641 | 24.507393 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.283019 | false | false |
14
|
0b2f1148e63db812a563032ab46de4235236992d
| 1,271,310,357,477 |
f6e0f142a338e89b6e98715974dad999664f23b8
|
/NQueens.java
|
539e39197ad3170f00ca147657c720a8db3b2d49
|
[] |
no_license
|
jasch-shah/Java-Programs
|
https://github.com/jasch-shah/Java-Programs
|
8d81ef25dc0b72510cd470608c8591f404076801
|
2adb925b9446967538e3c59afb49c80728eb45f7
|
refs/heads/master
| 2020-04-05T15:12:06.115000 | 2018-11-17T11:53:05 | 2018-11-17T11:53:05 | 156,958,249 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class NQueens
{
final int N = 4;
void printSolution(int board[][])
{
for(int i = 0;i<N;i++)
{
for(int j = 0;j<N;j++)
System.out.print(" "+board[i][j]+" ");
System.out.println();
}
}
boolean isSafe(int board[][], int row, int col){
int i, j;
//check on left side
for(i = 0;i<col;i++)
if(board[row][i] == 1)
return false;
//check for upper diagonal
for(i = row,j = col;i>=0 && j>=0;i--, j--)
if(board[i][j] == 1)
return false;
//check for lower diagonal
for(i = row, j = col; j>=0 && i < N;i++,j--)
if(board[i][j] == 1)
return false;
return true;
}
//utility to sove n queens recursively
boolean solveNQUtil(int board[][], int col){
if(col >= N)
return true;
for(int i = 0;i<N;i++){
if(isSafe(board, i, col)){
board[i][col] = 1;
if(solveNQUtil(board, col+1)==true)
return true;
board[i][col] = 0;
}
}
return false;
}
boolean solveNQ(){
int board[][] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};
if(solveNQUtil(board, 0) == false)
{
System.out.print("Solution does not exist");
return false;
}
printSolution(board);
return true;
}
public static void main(String[] args) {
NQueens queen = new NQueens();
queen.solveNQ();
}
}
|
UTF-8
|
Java
| 1,292 |
java
|
NQueens.java
|
Java
|
[] | null |
[] |
public class NQueens
{
final int N = 4;
void printSolution(int board[][])
{
for(int i = 0;i<N;i++)
{
for(int j = 0;j<N;j++)
System.out.print(" "+board[i][j]+" ");
System.out.println();
}
}
boolean isSafe(int board[][], int row, int col){
int i, j;
//check on left side
for(i = 0;i<col;i++)
if(board[row][i] == 1)
return false;
//check for upper diagonal
for(i = row,j = col;i>=0 && j>=0;i--, j--)
if(board[i][j] == 1)
return false;
//check for lower diagonal
for(i = row, j = col; j>=0 && i < N;i++,j--)
if(board[i][j] == 1)
return false;
return true;
}
//utility to sove n queens recursively
boolean solveNQUtil(int board[][], int col){
if(col >= N)
return true;
for(int i = 0;i<N;i++){
if(isSafe(board, i, col)){
board[i][col] = 1;
if(solveNQUtil(board, col+1)==true)
return true;
board[i][col] = 0;
}
}
return false;
}
boolean solveNQ(){
int board[][] = {{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};
if(solveNQUtil(board, 0) == false)
{
System.out.print("Solution does not exist");
return false;
}
printSolution(board);
return true;
}
public static void main(String[] args) {
NQueens queen = new NQueens();
queen.solveNQ();
}
}
| 1,292 | 0.541022 | 0.517028 | 72 | 16.958334 | 14.37343 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.736111 | false | false |
14
|
771a2546bfed0babf23562bebb4b07b2eddc5b71
| 13,675,175,886,645 |
607bd7c101cc200204e959ea2d73d3f75ba1e36c
|
/Java/TextMining.java
|
a006baae371d5d8393dfe973291f5a8da79a446e
|
[] |
no_license
|
qianwen/LeetCode-Solutions
|
https://github.com/qianwen/LeetCode-Solutions
|
7f989ff17432de8a407c13a7ea616388cfa6bbda
|
b94eb16d3c0f5556ec8ec185d4b0849f27eb0151
|
refs/heads/master
| 2021-01-19T15:32:32.108000 | 2014-08-27T06:23:31 | 2014-08-27T06:23:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Scanner;
public class TextMining {
public static void main(String[] args) {
Scanner wordScanner = new Scanner(System.in);
System.out.print("Enter a search word: ");
String word = wordScanner.next();
Scanner textScanner = new Scanner(System.in);
System.out.print("Enter a string of words(words separated by single spaces or tabs): ");
String text = textScanner.nextLine();
System.out.println("------");
int count = countGivenWord(text, word);
if (count > 0) {
System.out.println("Great, "+ "\"" + word + "\"" + " appears in the text and it's word count is " + count);
}
System.out.println("The total word count is "+ countWords(text));
System.out.println("The total number of unique words in the text " + countUniqueWords(text));
System.out.println("The total number of unique words minus stopwords in the text " + countUniqueWithoutStopword(text, word));
}
public static int countGivenWord(String text, String word) {
int count = 0;
int endOfLine = text.length() - 1;
if (text.indexOf(word) > -1) {
for (int location = text.indexOf(word); location != -1; location = text.indexOf(word, location + word.length())) {
int end = location + word.length();
// Make sure it is not a substring contains the givin word
if (end == text.length() || !Character.isLetter(text.charAt(end))) {
count++;
}
}
}
return count;
}
public static int countWords(String s){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
for (int i = 0; i < s.length(); i++) {
// The current char is a letter.
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
// When the current char isn't a letter but the previous one is, find a word.
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
wordCount++;
isWord = false;
// Hit the end of the string
// Or the end is a non letter.
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
wordCount++;
}
}
return wordCount;
}
public static int countUniqueWords(String s){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < s.length(); i++) {
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
endIndex = i;
// search the current word in the rest of the string and count its occurrences
String currentWord = s.substring(startIndex, endIndex);
String restS = s.substring(endIndex);
if (countGivenWord(restS, currentWord) == 0) {
wordCount++;
}
startIndex = i + 1;
isWord = false;
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
wordCount++;
}
}
return wordCount;
}
public static int countUniqueWithoutStopword(String s, String stopword){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < s.length(); i++) {
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
endIndex = i;
String currentWord = s.substring(startIndex, endIndex);
String restS = s.substring(endIndex);
if (!currentWord.equals(stopword) && countGivenWord(restS, currentWord) == 0) {
wordCount++;
}
startIndex = i + 1;
isWord = false;
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
// make sure the last word is not the stop word
String lastWord = s.substring(startIndex);
if (!lastWord.equals(stopword)) {
wordCount++;
}
}
}
return wordCount;
}
}
|
UTF-8
|
Java
| 3,831 |
java
|
TextMining.java
|
Java
|
[] | null |
[] |
import java.util.Scanner;
public class TextMining {
public static void main(String[] args) {
Scanner wordScanner = new Scanner(System.in);
System.out.print("Enter a search word: ");
String word = wordScanner.next();
Scanner textScanner = new Scanner(System.in);
System.out.print("Enter a string of words(words separated by single spaces or tabs): ");
String text = textScanner.nextLine();
System.out.println("------");
int count = countGivenWord(text, word);
if (count > 0) {
System.out.println("Great, "+ "\"" + word + "\"" + " appears in the text and it's word count is " + count);
}
System.out.println("The total word count is "+ countWords(text));
System.out.println("The total number of unique words in the text " + countUniqueWords(text));
System.out.println("The total number of unique words minus stopwords in the text " + countUniqueWithoutStopword(text, word));
}
public static int countGivenWord(String text, String word) {
int count = 0;
int endOfLine = text.length() - 1;
if (text.indexOf(word) > -1) {
for (int location = text.indexOf(word); location != -1; location = text.indexOf(word, location + word.length())) {
int end = location + word.length();
// Make sure it is not a substring contains the givin word
if (end == text.length() || !Character.isLetter(text.charAt(end))) {
count++;
}
}
}
return count;
}
public static int countWords(String s){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
for (int i = 0; i < s.length(); i++) {
// The current char is a letter.
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
// When the current char isn't a letter but the previous one is, find a word.
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
wordCount++;
isWord = false;
// Hit the end of the string
// Or the end is a non letter.
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
wordCount++;
}
}
return wordCount;
}
public static int countUniqueWords(String s){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < s.length(); i++) {
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
endIndex = i;
// search the current word in the rest of the string and count its occurrences
String currentWord = s.substring(startIndex, endIndex);
String restS = s.substring(endIndex);
if (countGivenWord(restS, currentWord) == 0) {
wordCount++;
}
startIndex = i + 1;
isWord = false;
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
wordCount++;
}
}
return wordCount;
}
public static int countUniqueWithoutStopword(String s, String stopword){
int wordCount = 0;
boolean isWord = false;
int endOfLine = s.length() - 1;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < s.length(); i++) {
if (Character.isLetter(s.charAt(i)) && i != endOfLine) {
isWord = true;
} else if (!Character.isLetter(s.charAt(i)) && isWord) {
endIndex = i;
String currentWord = s.substring(startIndex, endIndex);
String restS = s.substring(endIndex);
if (!currentWord.equals(stopword) && countGivenWord(restS, currentWord) == 0) {
wordCount++;
}
startIndex = i + 1;
isWord = false;
} else if (Character.isLetter(s.charAt(i)) && i == endOfLine) {
// make sure the last word is not the stop word
String lastWord = s.substring(startIndex);
if (!lastWord.equals(stopword)) {
wordCount++;
}
}
}
return wordCount;
}
}
| 3,831 | 0.62438 | 0.618637 | 135 | 27.377777 | 28.039354 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.622222 | false | false |
14
|
83b64e40915eb5d269502f55827581ceb805a2b6
| 14,087,492,741,776 |
480dca155b98ff38d0b936364bf92e48f98304ff
|
/RevaloraG2S2/src/main/ejb/cl/usach/diinf/revalora/persona/dao/PostulanteDAO.java
|
7a1d7bc0b145ba40d8bf8e1a873a754391f452f9
|
[] |
no_license
|
IHC2014/Trabajo-IHC
|
https://github.com/IHC2014/Trabajo-IHC
|
792023de213e2ab8e549c965499f38d0132e80c0
|
4d8ad4ea965c3e7178b594035647fdc4fe5a32c9
|
refs/heads/master
| 2021-01-01T19:38:30.076000 | 2014-06-24T20:03:34 | 2014-06-24T20:03:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cl.usach.diinf.revalora.persona.dao;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.apache.log4j.Logger;
import cl.usach.diinf.revalora.persona.dto.PostulanteDTO;
import cl.usach.diinf.revalora.persona.entities.PostulanteEntity;
/**
* <p>
* PersonaDAO
* </p>
*
* Clase encargada del acceso a la capa de datos para las funciones relevantes
* para una persona.
*
* @author Pablo Gavilan
* @version 1.0
*
*/
public class PostulanteDAO implements PostulanteDAOImpl {
/**
* Logger de la clase
*
* @since 1.0
*/
Logger log = Logger.getLogger(PersonaDAO.class);
/**
* Objeto encargado de la conexion por jpa a la capa de datos
*
* @since 1.0
*/
private EntityManager entityManager;
/**
* Constructor de la clase que instancia al #entityManager
*
* @since 1.0
*/
public PostulanteDAO() {
this.log.info("Crea constructor");
try {
this.entityManager = Persistence.createEntityManagerFactory(
"revalora-pu").createEntityManager();
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Metodo encargado de insertar una persona a la base de datos.
*
* @author Pablo Gavilan (07/05/2014).
* @param p
* Persona a agregar a la base de datos.
* @throws Exception
* exepcion lanzada al insertar la persona.
* @since 1.0
*/
public void insertaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Ingresa metodo");
PostulanteEntity pe = this.transforma(p);
try {
this.log.info("Inicia transacion");
this.entityManager.getTransaction().begin();
this.entityManager.persist(pe);
this.entityManager.getTransaction().commit();
this.log.info("Termina transacion");
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Metodo que retorna la lista de personas.
*
* @since 1.0
* @return Lista de objetos personas.
*/
public List<PostulanteDTO> obtenerPostulantes() throws Exception {
try {
this.log.info("Antes de llamar createNamedQuery");
List<PostulanteEntity> lpe = this.entityManager.createNamedQuery(
PostulanteEntity.SQL_SELECT_ALL, PostulanteEntity.class)
.getResultList();
List<PostulanteDTO> lp = new ArrayList<PostulanteDTO>();
for (PostulanteEntity postulanteEntitie : lpe) {
lp.add(this.transforma(postulanteEntitie));
}
return lp;
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Clase encargada en eliminar a una persona
*
* @since 1.0
* @param p
* Objeto persona a eliminar.
* @throws Exception
*
*/
public void eliminaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Iniciando eliminaPErsona");
try {
this.log.info("Antes de transformar persona a entidad");
PostulanteEntity pe = this.transforma(p);
this.log.info("Busca persona para eliminar");
pe = this.entityManager.find(PostulanteEntity.class, pe.getRut());
this.log.info("Comienza transaccion");
this.entityManager.getTransaction().begin();
this.entityManager.remove(pe);
this.entityManager.getTransaction().commit();
this.log.info("Termina transaccion");
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error e:" + e);
}
}
/**
* Clase encargada en actualziar a una persona
*
* @since 1.0
* @param p
* Datos de objeto persona a actualizar en la base de datos.
* @throws Exception
*
*/
public void actualizaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Iniciando actualzaPostulante");
try {
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error e:" + e);
}
}
/**
* Metodo que recive una persona y lo transforma en su identidad
*
* @since 1.0
* @param p
* Objeto persona a transformar en entidad
* @return entidad de tipo persona
*/
private PostulanteEntity transforma(PostulanteDTO p) {
PostulanteEntity pe = new PostulanteEntity();
pe.setRut(p.getRut());
pe.setCv(p.getCv());
return pe;
}
/**
* Metodo que recive una entidad persona y lo transforma en su objeto
*
* @since 1.0
* @param p
* Entidad persona a tranasforma.
* @return objeto persona.
*/
private PostulanteDTO transforma(PostulanteEntity p) {
PostulanteDTO pos = new PostulanteDTO();
pos.setRut(p.getRut());
pos.setCv(p.getCv());
return pos;
}
}
|
UTF-8
|
Java
| 4,507 |
java
|
PostulanteDAO.java
|
Java
|
[
{
"context": "nes relevantes\n * para una persona.\n * \n * @author Pablo Gavilan\n * @version 1.0\n * \n */\npublic class PostulanteDA",
"end": 500,
"score": 0.9998927712440491,
"start": 487,
"tag": "NAME",
"value": "Pablo Gavilan"
},
{
"context": "r una persona a la base de datos.\n\t * \n\t * @author Pablo Gavilan (07/05/2014).\n\t * @param p\n\t * Persona",
"end": 1267,
"score": 0.9998807311058044,
"start": 1254,
"tag": "NAME",
"value": "Pablo Gavilan"
}
] | null |
[] |
package cl.usach.diinf.revalora.persona.dao;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.apache.log4j.Logger;
import cl.usach.diinf.revalora.persona.dto.PostulanteDTO;
import cl.usach.diinf.revalora.persona.entities.PostulanteEntity;
/**
* <p>
* PersonaDAO
* </p>
*
* Clase encargada del acceso a la capa de datos para las funciones relevantes
* para una persona.
*
* @author <NAME>
* @version 1.0
*
*/
public class PostulanteDAO implements PostulanteDAOImpl {
/**
* Logger de la clase
*
* @since 1.0
*/
Logger log = Logger.getLogger(PersonaDAO.class);
/**
* Objeto encargado de la conexion por jpa a la capa de datos
*
* @since 1.0
*/
private EntityManager entityManager;
/**
* Constructor de la clase que instancia al #entityManager
*
* @since 1.0
*/
public PostulanteDAO() {
this.log.info("Crea constructor");
try {
this.entityManager = Persistence.createEntityManagerFactory(
"revalora-pu").createEntityManager();
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Metodo encargado de insertar una persona a la base de datos.
*
* @author <NAME> (07/05/2014).
* @param p
* Persona a agregar a la base de datos.
* @throws Exception
* exepcion lanzada al insertar la persona.
* @since 1.0
*/
public void insertaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Ingresa metodo");
PostulanteEntity pe = this.transforma(p);
try {
this.log.info("Inicia transacion");
this.entityManager.getTransaction().begin();
this.entityManager.persist(pe);
this.entityManager.getTransaction().commit();
this.log.info("Termina transacion");
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Metodo que retorna la lista de personas.
*
* @since 1.0
* @return Lista de objetos personas.
*/
public List<PostulanteDTO> obtenerPostulantes() throws Exception {
try {
this.log.info("Antes de llamar createNamedQuery");
List<PostulanteEntity> lpe = this.entityManager.createNamedQuery(
PostulanteEntity.SQL_SELECT_ALL, PostulanteEntity.class)
.getResultList();
List<PostulanteDTO> lp = new ArrayList<PostulanteDTO>();
for (PostulanteEntity postulanteEntitie : lpe) {
lp.add(this.transforma(postulanteEntitie));
}
return lp;
} catch (Exception e) {
this.log.error("Error " + e);
throw e;
}
}
/**
* Clase encargada en eliminar a una persona
*
* @since 1.0
* @param p
* Objeto persona a eliminar.
* @throws Exception
*
*/
public void eliminaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Iniciando eliminaPErsona");
try {
this.log.info("Antes de transformar persona a entidad");
PostulanteEntity pe = this.transforma(p);
this.log.info("Busca persona para eliminar");
pe = this.entityManager.find(PostulanteEntity.class, pe.getRut());
this.log.info("Comienza transaccion");
this.entityManager.getTransaction().begin();
this.entityManager.remove(pe);
this.entityManager.getTransaction().commit();
this.log.info("Termina transaccion");
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error e:" + e);
}
}
/**
* Clase encargada en actualziar a una persona
*
* @since 1.0
* @param p
* Datos de objeto persona a actualizar en la base de datos.
* @throws Exception
*
*/
public void actualizaPostulante(PostulanteDTO p) throws Exception {
this.log.info("Iniciando actualzaPostulante");
try {
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error e:" + e);
}
}
/**
* Metodo que recive una persona y lo transforma en su identidad
*
* @since 1.0
* @param p
* Objeto persona a transformar en entidad
* @return entidad de tipo persona
*/
private PostulanteEntity transforma(PostulanteDTO p) {
PostulanteEntity pe = new PostulanteEntity();
pe.setRut(p.getRut());
pe.setCv(p.getCv());
return pe;
}
/**
* Metodo que recive una entidad persona y lo transforma en su objeto
*
* @since 1.0
* @param p
* Entidad persona a tranasforma.
* @return objeto persona.
*/
private PostulanteDTO transforma(PostulanteEntity p) {
PostulanteDTO pos = new PostulanteDTO();
pos.setRut(p.getRut());
pos.setCv(p.getCv());
return pos;
}
}
| 4,493 | 0.673841 | 0.667406 | 186 | 23.231182 | 21.886444 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.634409 | false | false |
14
|
799f404408dd9552345f4c84f2ac6dd3b79c6d77
| 28,862,180,280,271 |
8c706b0cda72bc7a4d931c76210f424ef36a4895
|
/main/java/dtx/src/main/java/io/eguan/dtx/events/HazelcastToEvtBusLifecycleConverter.java
|
31319ef32d3f5b9cce7b0ef5c58901d3d252b333
|
[] |
no_license
|
llbrt/eguan
|
https://github.com/llbrt/eguan
|
6abd812f233648e8b4243d1154faac7283aa3cd5
|
85889da6cd7a6986468baa1019df1a0ccdd85997
|
refs/heads/master
| 2020-09-20T04:07:10.099000 | 2018-09-09T13:09:25 | 2018-09-09T13:09:25 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package io.eguan.dtx.events;
/*
* #%L
* Project eguan
* %%
* Copyright (C) 2012 - 2017 Oodrive
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.Objects;
import java.util.UUID;
import javax.annotation.ParametersAreNonnullByDefault;
import com.google.common.eventbus.EventBus;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleEvent.LifecycleState;
import com.hazelcast.core.LifecycleListener;
/**
* Custom {@link LifecycleListener} implementation to forward {@link LifecycleEvent}s from a given
* {@link HazelcastInstance} to an {@link EventBus}.
*
* @author oodrive
* @author pwehrle
*
*/
public final class HazelcastToEvtBusLifecycleConverter implements LifecycleListener {
private final String nodeId;
private final EventBus[] destBusses;
private LifecycleState previousState;
private HazelcastInstance hzInstance;
/**
* Constructs an instance relaying events from the source {@link HazelcastInstance} to the destination
* {@link EventBus}.
*
* @param nodeId
* the node ID to determine the source {@link HazelcastInstance}
* @param destinations
* the target {@link EventBus}es
* @throws NullPointerException
* if any argument is <code>null</code>
* @throws IllegalArgumentException
* if the {@link HazelcastInstance} cannot be used to subscribe to its life cycle events
*/
@ParametersAreNonnullByDefault
public HazelcastToEvtBusLifecycleConverter(final UUID nodeId, final EventBus... destinations)
throws NullPointerException, IllegalArgumentException {
this.destBusses = Objects.requireNonNull(destinations);
this.nodeId = nodeId.toString();
}
@Override
public final void stateChanged(final LifecycleEvent event) {
final LifecycleState newState = event.getState();
if (newState == previousState) {
return;
}
if (hzInstance == null) {
hzInstance = Hazelcast.getHazelcastInstanceByName(nodeId);
}
final HazelcastNodeEvent newEvent = new HazelcastNodeEvent(hzInstance, previousState, newState);
previousState = newState;
for (final EventBus destBus : this.destBusses) {
destBus.post(newEvent);
}
}
}
|
UTF-8
|
Java
| 2,963 |
java
|
HazelcastToEvtBusLifecycleConverter.java
|
Java
|
[
{
"context": "stInstance} to an {@link EventBus}.\n * \n * @author oodrive\n * @author pwehrle\n * \n */\npublic final class Haz",
"end": 1231,
"score": 0.9996657371520996,
"start": 1224,
"tag": "USERNAME",
"value": "oodrive"
},
{
"context": "@link EventBus}.\n * \n * @author oodrive\n * @author pwehrle\n * \n */\npublic final class HazelcastToEvtBusLifec",
"end": 1250,
"score": 0.9995966553688049,
"start": 1243,
"tag": "USERNAME",
"value": "pwehrle"
}
] | null |
[] |
package io.eguan.dtx.events;
/*
* #%L
* Project eguan
* %%
* Copyright (C) 2012 - 2017 Oodrive
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.Objects;
import java.util.UUID;
import javax.annotation.ParametersAreNonnullByDefault;
import com.google.common.eventbus.EventBus;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleEvent.LifecycleState;
import com.hazelcast.core.LifecycleListener;
/**
* Custom {@link LifecycleListener} implementation to forward {@link LifecycleEvent}s from a given
* {@link HazelcastInstance} to an {@link EventBus}.
*
* @author oodrive
* @author pwehrle
*
*/
public final class HazelcastToEvtBusLifecycleConverter implements LifecycleListener {
private final String nodeId;
private final EventBus[] destBusses;
private LifecycleState previousState;
private HazelcastInstance hzInstance;
/**
* Constructs an instance relaying events from the source {@link HazelcastInstance} to the destination
* {@link EventBus}.
*
* @param nodeId
* the node ID to determine the source {@link HazelcastInstance}
* @param destinations
* the target {@link EventBus}es
* @throws NullPointerException
* if any argument is <code>null</code>
* @throws IllegalArgumentException
* if the {@link HazelcastInstance} cannot be used to subscribe to its life cycle events
*/
@ParametersAreNonnullByDefault
public HazelcastToEvtBusLifecycleConverter(final UUID nodeId, final EventBus... destinations)
throws NullPointerException, IllegalArgumentException {
this.destBusses = Objects.requireNonNull(destinations);
this.nodeId = nodeId.toString();
}
@Override
public final void stateChanged(final LifecycleEvent event) {
final LifecycleState newState = event.getState();
if (newState == previousState) {
return;
}
if (hzInstance == null) {
hzInstance = Hazelcast.getHazelcastInstanceByName(nodeId);
}
final HazelcastNodeEvent newEvent = new HazelcastNodeEvent(hzInstance, previousState, newState);
previousState = newState;
for (final EventBus destBus : this.destBusses) {
destBus.post(newEvent);
}
}
}
| 2,963 | 0.700641 | 0.696591 | 88 | 32.670456 | 29.308207 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352273 | false | false |
14
|
d9d5b592d58ea2db096f51ce51188ace099428ae
| 4,561,255,308,711 |
383250b3fdb661af00b0b023429b69bfba894c96
|
/src/e2e-test/java/com/epam/lab/accounts/e2e/pageobject/PageObject.java
|
376de02d33bb84e113d1eabe5d5acfdf4288d98f
|
[] |
no_license
|
olgmaks/accounts
|
https://github.com/olgmaks/accounts
|
bb26bfe78a7931d0f0afc002f5d4a77de1f8692c
|
19b307c06638b326ab895e8b958a8aab81868b92
|
refs/heads/master
| 2020-04-17T15:32:03.977000 | 2019-03-19T20:06:48 | 2019-03-19T20:06:48 | 166,702,450 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.epam.lab.accounts.e2e.pageobject;
import com.epam.lab.accounts.e2e.config.PageDriver;
import com.epam.lab.accounts.e2e.config.proxy.ElementsLocationUtil;
public abstract class PageObject {
private final PageDriver pageDriver;
public PageObject(PageDriver pageDriver) {
this.pageDriver = pageDriver;
final ElementsLocationUtil locationUtil = new ElementsLocationUtil(pageDriver);
locationUtil.initializePageElements(this);
}
public PageDriver getPageDriver() {
return pageDriver;
}
}
|
UTF-8
|
Java
| 556 |
java
|
PageObject.java
|
Java
|
[] | null |
[] |
package com.epam.lab.accounts.e2e.pageobject;
import com.epam.lab.accounts.e2e.config.PageDriver;
import com.epam.lab.accounts.e2e.config.proxy.ElementsLocationUtil;
public abstract class PageObject {
private final PageDriver pageDriver;
public PageObject(PageDriver pageDriver) {
this.pageDriver = pageDriver;
final ElementsLocationUtil locationUtil = new ElementsLocationUtil(pageDriver);
locationUtil.initializePageElements(this);
}
public PageDriver getPageDriver() {
return pageDriver;
}
}
| 556 | 0.742806 | 0.73741 | 23 | 23.173914 | 25.809759 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.347826 | false | false |
14
|
dc2367f691ca6ff7bcae542b3b25dbc29a0a438e
| 18,322,330,499,966 |
be343bd4e50cab74d2db533ad81f270a56dbeb4f
|
/Idea/xmlParsingTechnics/com/dot/xml/ui/ApplicationContext.java
|
abadd0191d59609b5995c360241fa4f2915ab670
|
[] |
no_license
|
zain0111/workspace
|
https://github.com/zain0111/workspace
|
249606d80ebb1d4ddf993597b3c59c7ca70f05ba
|
367f1aaaf15ef368e1a22ae59a14f5965076329f
|
refs/heads/master
| 2023-03-18T16:06:10.781000 | 2017-07-21T18:29:19 | 2017-07-21T18:29:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/* ********************************************************************************
* All rights reserved.
******************************************************************************* */
package com.dot.xml.ui;
import java.util.HashMap;
import java.util.Map;
import com.dot.xml.parsing.tech.BlockingQueue;
import com.dot.xml.parsing.tech.Message;
public class ApplicationContext {
private static Map<Object,Object> contextMap = new HashMap<Object,Object>();
private static Map<String,Object> keyMap = new HashMap<String,Object>();
private static BlockingQueue<Message> errorMessage = new BlockingQueue<>(1);
public static synchronized Object getObject(String key){
return keyMap.get(key);
}
public static synchronized Object putObject(String key,Object object){
return keyMap.put(key, object);
}
public static synchronized void putErrorMessageInQueue(Message message){
try {
errorMessage.insert(message);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static synchronized Message getErrorMessageFromQueue(){
try {
return errorMessage.remove(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
}
|
UTF-8
|
Java
| 1,377 |
java
|
ApplicationContext.java
|
Java
|
[] | null |
[] |
/* ********************************************************************************
* All rights reserved.
******************************************************************************* */
package com.dot.xml.ui;
import java.util.HashMap;
import java.util.Map;
import com.dot.xml.parsing.tech.BlockingQueue;
import com.dot.xml.parsing.tech.Message;
public class ApplicationContext {
private static Map<Object,Object> contextMap = new HashMap<Object,Object>();
private static Map<String,Object> keyMap = new HashMap<String,Object>();
private static BlockingQueue<Message> errorMessage = new BlockingQueue<>(1);
public static synchronized Object getObject(String key){
return keyMap.get(key);
}
public static synchronized Object putObject(String key,Object object){
return keyMap.put(key, object);
}
public static synchronized void putErrorMessageInQueue(Message message){
try {
errorMessage.insert(message);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static synchronized Message getErrorMessageFromQueue(){
try {
return errorMessage.remove(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
}
| 1,377 | 0.561365 | 0.55846 | 41 | 31.585365 | 27.309406 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.512195 | false | false |
14
|
7a2a4708b1edf7f28c2f0b15267bd0265df7f6ab
| 395,137,017,330 |
86e2e8d5c9beb511e4824a3e028f543f228f0692
|
/排序/src/QuickSort.java
|
608163743e7ad5fa2e92d2ac66d54b3d585d4df4
|
[] |
no_license
|
Ren-Yaqian/data-structure
|
https://github.com/Ren-Yaqian/data-structure
|
dca4f188752be6d13066fd4723cfd499c53e1ad3
|
8b3cc0edddf6da68ef96de1bfc242f6b31359150
|
refs/heads/master
| 2023-07-09T09:16:24.371000 | 2021-08-20T02:32:44 | 2021-08-20T02:32:44 | 315,799,588 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Arrays;
public class QuickSort {
public static void quickSort(long[] array) {
quickSortRange(array, 0, array.length - 1);
}
private static void quickSortRange(long[] array, int from, int to) {
int size = to - from + 1;
// 3. 直到,待排序区间的元素个数 <= 1
if (size <= 1) {
return;
}
// 1. 选择基准值 array[from]
// 2. 做 partition,返回基准值跑到哪里去了 [pivotIdx]
int pivotIdx = partition1(array, from, to);
// 左边的区间如何表示:[from, pivotIdx - 1]
// 右边的区间如何表示:[pivotIdx + 1, to]
// 3. 分别对左右两个小区间按照相同的方式处理(递归调用)
quickSortRange(array, from, pivotIdx - 1);
quickSortRange(array, pivotIdx + 1, to);
}
private static int partition1(long[] array, int from, int to) {
long pivot = array[from];
int left = from;
int right = to;
// 只要还有未比较的元素,循环就得继续
// (left, right] 的元素个数 right - left > 0
while (left < right) {
// 因为我们基准值在左边,所以先走右边
while (left < right && array[right] >= pivot) {
right--;
}
while (left < right && array[left] <= pivot) {
left++;
}
Swap.swap(array, left, right);
}
Swap.swap(array, from, left);
return left;
}
private static int partition2(long[] array, int from, int to) {
int left = from;
int right = to;
long pivot = array[from];
while (left < right) {
while (left < right && array[right] >= pivot) {
right--;
}
array[left] = array[right];
while (left < right&& array[left] <= pivot) {
left++;
}
array[right] = array[left];
}
array[left] = pivot;
return left;
}
public static void main(String[] args) {
long[] array = { 5, 9, 2, 7, 3, 6, 8, 4, 0 };
//long[] array = { 5, 1, 9, 2, 8, 3, 7, 4, 6 };
//long[] array = { 5, 9, 1, 8, 2, 7, 3, 6, 4 };
//long[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
//long[] array = { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
//long[] array = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int from = 0;
int to = 8;
System.out.println(Arrays.toString(array));
partition1(array, from, to);
System.out.println(Arrays.toString(array));
}
}
|
UTF-8
|
Java
| 2,798 |
java
|
QuickSort.java
|
Java
|
[] | null |
[] |
import java.util.Arrays;
public class QuickSort {
public static void quickSort(long[] array) {
quickSortRange(array, 0, array.length - 1);
}
private static void quickSortRange(long[] array, int from, int to) {
int size = to - from + 1;
// 3. 直到,待排序区间的元素个数 <= 1
if (size <= 1) {
return;
}
// 1. 选择基准值 array[from]
// 2. 做 partition,返回基准值跑到哪里去了 [pivotIdx]
int pivotIdx = partition1(array, from, to);
// 左边的区间如何表示:[from, pivotIdx - 1]
// 右边的区间如何表示:[pivotIdx + 1, to]
// 3. 分别对左右两个小区间按照相同的方式处理(递归调用)
quickSortRange(array, from, pivotIdx - 1);
quickSortRange(array, pivotIdx + 1, to);
}
private static int partition1(long[] array, int from, int to) {
long pivot = array[from];
int left = from;
int right = to;
// 只要还有未比较的元素,循环就得继续
// (left, right] 的元素个数 right - left > 0
while (left < right) {
// 因为我们基准值在左边,所以先走右边
while (left < right && array[right] >= pivot) {
right--;
}
while (left < right && array[left] <= pivot) {
left++;
}
Swap.swap(array, left, right);
}
Swap.swap(array, from, left);
return left;
}
private static int partition2(long[] array, int from, int to) {
int left = from;
int right = to;
long pivot = array[from];
while (left < right) {
while (left < right && array[right] >= pivot) {
right--;
}
array[left] = array[right];
while (left < right&& array[left] <= pivot) {
left++;
}
array[right] = array[left];
}
array[left] = pivot;
return left;
}
public static void main(String[] args) {
long[] array = { 5, 9, 2, 7, 3, 6, 8, 4, 0 };
//long[] array = { 5, 1, 9, 2, 8, 3, 7, 4, 6 };
//long[] array = { 5, 9, 1, 8, 2, 7, 3, 6, 4 };
//long[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
//long[] array = { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
//long[] array = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int from = 0;
int to = 8;
System.out.println(Arrays.toString(array));
partition1(array, from, to);
System.out.println(Arrays.toString(array));
}
}
| 2,798 | 0.447819 | 0.419003 | 83 | 28.939758 | 20.483522 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.277108 | false | false |
14
|
e1568857ac65cae77f913f4a19f276b5e76b7ece
| 4,260,607,589,885 |
0fc20712829b8c30d6e4b3e274b752e9c98186e1
|
/src/EjerciciosItroduccion/ejer21.java
|
b8dd53c168541e14e4bbc5c3a9da9202d685bb1c
|
[] |
no_license
|
GuillermoMartinelli/EjercitacionLogicaJava
|
https://github.com/GuillermoMartinelli/EjercitacionLogicaJava
|
85ac2ed5ff4184da6a794a575da75adcaa9754cd
|
5e5c8ac17d0c8ec67470f5d90e1a7b01c706724d
|
refs/heads/main
| 2023-07-12T20:27:17.985000 | 2021-08-20T23:08:28 | 2021-08-20T23:08:28 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package EjerciciosItroduccion;
import java.util.Scanner;
public class ejer21 {
public static void ejer21() {
// . Crea una aplicación que a través de una función nos convierta una cantidad de
// euros introducida por teclado a otra moneda, estas pueden ser a dólares, yenes o
// libras. La función tendrá como parámetros, la cantidad de euros y la moneda a
// converir que será una cadena, este no devolverá ningún valor y mostrará un
// mensaje indicando el cambio (void).
// El cambio de divisas es:
// * 0.86 libras es un 1 €
// * 1.28611 $ es un 1 €
// * 129.852 yenes es un 1 €
double euros = 0;
int mon;
String moneda = "";
Scanner sn = new Scanner(System.in);
do {
System.out.println(" INGRESE\n ->1 para transformar EUROS a DOLARES \n"
+ " ->2 para transformar EUROS a YENES\n" + " ->3 para transformar EUROS a LIBRAS");
mon = sn.nextInt();
switch (mon) {
case 1:
moneda = "dolares";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a DOLARES");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
case 2:
moneda = "yenes";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a YENES");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
case 3:
moneda = "libras";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a LIBRAS");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
default:
System.out.println("Ingreso un numero incorrecto, se repetira el proceso");
System.out.println("---------------------------------------------------");
break;
}
} while (moneda != "yenes" && moneda != "dolares" && moneda != "libras");
convertirEuros(moneda, euros);
}
public static void convertirEuros(String m, double eur) {
double dolar = 1.28611, yen = 129.852, lib = 0.86, result;
switch (m) {
case "dolares":
result = dolar * eur;
System.out.println(eur + " EUROS a DOLARES es = " + result + " DOLARES");
break;
case "yenes":
result = yen * eur;
System.out.println(eur + " EUROS a YENES es = " + result + " YENES");
break;
case "libras":
result = lib * eur;
System.out.println(eur + " EUROS a LIBRAS es = " + result + " LIBRAS");
break;
default:
System.out.println("No se encontro moneda de cambio");
break;
}
}
}
|
WINDOWS-1252
|
Java
| 2,802 |
java
|
ejer21.java
|
Java
|
[] | null |
[] |
package EjerciciosItroduccion;
import java.util.Scanner;
public class ejer21 {
public static void ejer21() {
// . Crea una aplicación que a través de una función nos convierta una cantidad de
// euros introducida por teclado a otra moneda, estas pueden ser a dólares, yenes o
// libras. La función tendrá como parámetros, la cantidad de euros y la moneda a
// converir que será una cadena, este no devolverá ningún valor y mostrará un
// mensaje indicando el cambio (void).
// El cambio de divisas es:
// * 0.86 libras es un 1 €
// * 1.28611 $ es un 1 €
// * 129.852 yenes es un 1 €
double euros = 0;
int mon;
String moneda = "";
Scanner sn = new Scanner(System.in);
do {
System.out.println(" INGRESE\n ->1 para transformar EUROS a DOLARES \n"
+ " ->2 para transformar EUROS a YENES\n" + " ->3 para transformar EUROS a LIBRAS");
mon = sn.nextInt();
switch (mon) {
case 1:
moneda = "dolares";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a DOLARES");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
case 2:
moneda = "yenes";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a YENES");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
case 3:
moneda = "libras";
do {
try {
System.out.println("Ingrese la cantidad de EUROS a pasar a LIBRAS");
euros = sn.nextDouble();
} catch (Exception e) {
System.out.println("Ingreso numero ERRONEO");
euros = -1;
sn.next();
}
;
} while (euros < 0);
break;
default:
System.out.println("Ingreso un numero incorrecto, se repetira el proceso");
System.out.println("---------------------------------------------------");
break;
}
} while (moneda != "yenes" && moneda != "dolares" && moneda != "libras");
convertirEuros(moneda, euros);
}
public static void convertirEuros(String m, double eur) {
double dolar = 1.28611, yen = 129.852, lib = 0.86, result;
switch (m) {
case "dolares":
result = dolar * eur;
System.out.println(eur + " EUROS a DOLARES es = " + result + " DOLARES");
break;
case "yenes":
result = yen * eur;
System.out.println(eur + " EUROS a YENES es = " + result + " YENES");
break;
case "libras":
result = lib * eur;
System.out.println(eur + " EUROS a LIBRAS es = " + result + " LIBRAS");
break;
default:
System.out.println("No se encontro moneda de cambio");
break;
}
}
}
| 2,802 | 0.591741 | 0.573788 | 97 | 27.71134 | 25.098551 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.958763 | false | false |
14
|
ea8ba0583cf0ff944434be745805c6dd17502ce4
| 25,202,868,131,638 |
a49252753ee731f5fd8e9ce48118d5676a922cbc
|
/src/main/java/ru/hz/ejb/cluster/timer/AbstractTimerLauncherResolver.java
|
9d83b8c953057dd27116cf7825c2a954a8285942
|
[
"Unlicense"
] |
permissive
|
vymiheev/Hazelcast-clustered-timers
|
https://github.com/vymiheev/Hazelcast-clustered-timers
|
b8f5e2157b1a5f9c7310b26e6ad69e092352efc7
|
6d802037e018ac81e121d7dc4b647c5793135e20
|
refs/heads/master
| 2021-05-08T19:50:44.352000 | 2018-01-31T11:03:52 | 2018-01-31T11:03:52 | 119,583,429 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ru.hz.ejb.cluster.timer;
/**
* Created by mvj on 26.10.2017.
*/
public abstract class AbstractTimerLauncherResolver implements ITimerLauncherResolver {
private static final long serialVersionUID = -3528978210289833921L;
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractTimerLauncherResolver that = (AbstractTimerLauncherResolver) o;
return !(getName() != null ? !getName().equals(that.getName()) : that.getName() != null);
}
@Override
public final int hashCode() {
return getName() != null ? getName().hashCode() : 0;
}
}
|
UTF-8
|
Java
| 702 |
java
|
AbstractTimerLauncherResolver.java
|
Java
|
[
{
"context": "ackage ru.hz.ejb.cluster.timer;\n\n/**\n * Created by mvj on 26.10.2017.\n */\npublic abstract class Abstract",
"end": 55,
"score": 0.99952232837677,
"start": 52,
"tag": "USERNAME",
"value": "mvj"
}
] | null |
[] |
package ru.hz.ejb.cluster.timer;
/**
* Created by mvj on 26.10.2017.
*/
public abstract class AbstractTimerLauncherResolver implements ITimerLauncherResolver {
private static final long serialVersionUID = -3528978210289833921L;
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractTimerLauncherResolver that = (AbstractTimerLauncherResolver) o;
return !(getName() != null ? !getName().equals(that.getName()) : that.getName() != null);
}
@Override
public final int hashCode() {
return getName() != null ? getName().hashCode() : 0;
}
}
| 702 | 0.653846 | 0.61396 | 24 | 28.25 | 31.411583 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false |
14
|
7d9ed974df848ec1f789e585e3bb08e30fd77c2f
| 24,670,292,192,617 |
cfc5843143a15bab0ab8eeef064aa9c169f67792
|
/Assignment3/assignment3_focussed.java
|
5908d94732d1a6e1a407321194da2f20fcd449af
|
[] |
no_license
|
Anish43/18103039
|
https://github.com/Anish43/18103039
|
604f4bfc09adc62d6341d950c093db320dccb98e
|
f790f0a7b50798b993a09c7ae8e02f86b73ad434
|
refs/heads/master
| 2023-01-10T15:45:45.975000 | 2020-11-12T17:53:17 | 2020-11-12T17:53:17 | 289,261,137 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.company;
import java.util.*;
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.opencsv.CSVWriter;
public class Main {
private static final List<String> faculty_Words= new LinkedList<>();
public static boolean link_related(String link) {
for(String s : faculty_Words)
{
if(link.contains(s) ) {
return true;
}
}
return false;
}
public static void main(String[] args) throws IOException {
ArrayList < String > urlList = new ArrayList<>();
Set < String > urlSet = new HashSet<>();
String url = "https://pec.ac.in/";
urlList.add(url);
urlSet.add(url);
String currUrl;
faculty_Words.addAll(Arrays.asList(("faculty research programmes campus administration members committee institute department centres professor prof assistant teacher teaching engineer doctor scholar chairman qualification director phd ").split(" ")));
CSVWriter csvwriterUrl = new CSVWriter(new FileWriter(new File("faculty_urls.csv")));
CSVWriter csvwriterTag = new CSVWriter(new FileWriter(new File("faculty_text.csv")));
String[] headerUrl = { "TextForURL", "URL" };
String[] headerTag = { "TypeOfTag", "TextEnclosed" };
csvwriterUrl.writeNext(headerUrl);
csvwriterTag.writeNext(headerTag);
for (int i = 0; i < urlList.size(); i++) {
try {
currUrl = urlList.get(i);
Document document = Jsoup.connect(currUrl).get();
String title = document.title();
if (currUrl.contains("faculty")) {
csvwriterTag.writeNext(new String[] {});
csvwriterTag.writeNext(new String[] { "url: " + (i + 1), currUrl });
csvwriterTag.writeNext(new String[] { "titleTag", title });
}
Elements links = document.select("a[href]");
for (Element link: links) {
String pageurl, urlText;
pageurl = link.absUrl("href");
if(!pageurl.contains("http")) {
pageurl = "https://pec.ac.in" + pageurl;
}
urlText = link.text();
if ((!urlSet.contains(pageurl)) && urlText.length() > 0) {
if (link_related(pageurl)) {
if (currUrl.contains("faculty")) {
csvwriterUrl.writeNext(new String[] {});
csvwriterUrl.writeNext(new String[]{urlText, pageurl});
}
urlSet.add(pageurl);
urlList.add(pageurl);
}
}
}
if (currUrl.contains("faculty")) {
Elements paragraphTag = document.select("p");
for (Element p: paragraphTag) {
String text;
text = p.text();
if (text.length() > 2) {
csvwriterTag.writeNext(new String[] { "p", text });
}
}
Elements h1Tag = document.select("h1");
for (Element h: h1Tag) {
String text;
text = h.text();
if (text.length() > 0) {
csvwriterTag.writeNext(new String[] { "h1", text });
}
}
System.out.println("URL: " + currUrl);
}
} catch (Exception e) {
System.out.println(e);
}
}
csvwriterTag.close();
csvwriterUrl.close();
}
}
|
UTF-8
|
Java
| 4,109 |
java
|
assignment3_focussed.java
|
Java
|
[] | null |
[] |
package com.company;
import java.util.*;
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.opencsv.CSVWriter;
public class Main {
private static final List<String> faculty_Words= new LinkedList<>();
public static boolean link_related(String link) {
for(String s : faculty_Words)
{
if(link.contains(s) ) {
return true;
}
}
return false;
}
public static void main(String[] args) throws IOException {
ArrayList < String > urlList = new ArrayList<>();
Set < String > urlSet = new HashSet<>();
String url = "https://pec.ac.in/";
urlList.add(url);
urlSet.add(url);
String currUrl;
faculty_Words.addAll(Arrays.asList(("faculty research programmes campus administration members committee institute department centres professor prof assistant teacher teaching engineer doctor scholar chairman qualification director phd ").split(" ")));
CSVWriter csvwriterUrl = new CSVWriter(new FileWriter(new File("faculty_urls.csv")));
CSVWriter csvwriterTag = new CSVWriter(new FileWriter(new File("faculty_text.csv")));
String[] headerUrl = { "TextForURL", "URL" };
String[] headerTag = { "TypeOfTag", "TextEnclosed" };
csvwriterUrl.writeNext(headerUrl);
csvwriterTag.writeNext(headerTag);
for (int i = 0; i < urlList.size(); i++) {
try {
currUrl = urlList.get(i);
Document document = Jsoup.connect(currUrl).get();
String title = document.title();
if (currUrl.contains("faculty")) {
csvwriterTag.writeNext(new String[] {});
csvwriterTag.writeNext(new String[] { "url: " + (i + 1), currUrl });
csvwriterTag.writeNext(new String[] { "titleTag", title });
}
Elements links = document.select("a[href]");
for (Element link: links) {
String pageurl, urlText;
pageurl = link.absUrl("href");
if(!pageurl.contains("http")) {
pageurl = "https://pec.ac.in" + pageurl;
}
urlText = link.text();
if ((!urlSet.contains(pageurl)) && urlText.length() > 0) {
if (link_related(pageurl)) {
if (currUrl.contains("faculty")) {
csvwriterUrl.writeNext(new String[] {});
csvwriterUrl.writeNext(new String[]{urlText, pageurl});
}
urlSet.add(pageurl);
urlList.add(pageurl);
}
}
}
if (currUrl.contains("faculty")) {
Elements paragraphTag = document.select("p");
for (Element p: paragraphTag) {
String text;
text = p.text();
if (text.length() > 2) {
csvwriterTag.writeNext(new String[] { "p", text });
}
}
Elements h1Tag = document.select("h1");
for (Element h: h1Tag) {
String text;
text = h.text();
if (text.length() > 0) {
csvwriterTag.writeNext(new String[] { "h1", text });
}
}
System.out.println("URL: " + currUrl);
}
} catch (Exception e) {
System.out.println(e);
}
}
csvwriterTag.close();
csvwriterUrl.close();
}
}
| 4,109 | 0.476272 | 0.474081 | 95 | 41.252632 | 31.868799 | 260 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.663158 | false | false |
14
|
bd7569ecfd5505eba3bd4536a5bca40cf0b576cd
| 24,670,292,193,800 |
f20cdd6884a0c86398be3ec52a79a126ce53e03a
|
/user_model/src/main/java/com/davina/user/pojo/FollowKey.java
|
7315c913187e2a5c3cd0606ad067ad6db6a93a3d
|
[] |
no_license
|
HahAmypage/springcloudpro
|
https://github.com/HahAmypage/springcloudpro
|
1e1502292bdd525d62cd768757ab52723662bb99
|
64f38846af07dea15052da12c68f0fe9dc00daea
|
refs/heads/master
| 2022-12-24T09:49:35.461000 | 2020-04-19T06:37:20 | 2020-04-19T06:37:20 | 245,640,889 | 0 | 0 | null | false | 2022-12-14T20:42:04 | 2020-03-07T13:48:42 | 2020-04-19T06:37:23 | 2022-12-14T20:42:03 | 189 | 0 | 0 | 16 |
Java
| false | false |
package com.davina.user.pojo;
import javax.persistence.Table;
import java.io.Serializable;
@Table(name = "tb_follow")
public class FollowKey implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column tb_follow.userid
*
* @mbggenerated
*/
private String userid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column tb_follow.targetuser
*
* @mbggenerated
*/
private String targetuser;
public FollowKey() {
}
public FollowKey(String userid, String targetuser) {
this.userid = userid;
this.targetuser = targetuser;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column tb_follow.userid
*
* @return the value of tb_follow.userid
*
* @mbggenerated
*/
public String getUserid() {
return userid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column tb_follow.userid
*
* @param userid the value for tb_follow.userid
*
* @mbggenerated
*/
public void setUserid(String userid) {
this.userid = userid == null ? null : userid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column tb_follow.targetuser
*
* @return the value of tb_follow.targetuser
*
* @mbggenerated
*/
public String getTargetuser() {
return targetuser;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column tb_follow.targetuser
*
* @param targetuser the value for tb_follow.targetuser
*
* @mbggenerated
*/
public void setTargetuser(String targetuser) {
this.targetuser = targetuser == null ? null : targetuser.trim();
}
}
|
UTF-8
|
Java
| 2,047 |
java
|
FollowKey.java
|
Java
|
[] | null |
[] |
package com.davina.user.pojo;
import javax.persistence.Table;
import java.io.Serializable;
@Table(name = "tb_follow")
public class FollowKey implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column tb_follow.userid
*
* @mbggenerated
*/
private String userid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column tb_follow.targetuser
*
* @mbggenerated
*/
private String targetuser;
public FollowKey() {
}
public FollowKey(String userid, String targetuser) {
this.userid = userid;
this.targetuser = targetuser;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column tb_follow.userid
*
* @return the value of tb_follow.userid
*
* @mbggenerated
*/
public String getUserid() {
return userid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column tb_follow.userid
*
* @param userid the value for tb_follow.userid
*
* @mbggenerated
*/
public void setUserid(String userid) {
this.userid = userid == null ? null : userid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column tb_follow.targetuser
*
* @return the value of tb_follow.targetuser
*
* @mbggenerated
*/
public String getTargetuser() {
return targetuser;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column tb_follow.targetuser
*
* @param targetuser the value for tb_follow.targetuser
*
* @mbggenerated
*/
public void setTargetuser(String targetuser) {
this.targetuser = targetuser == null ? null : targetuser.trim();
}
}
| 2,047 | 0.633122 | 0.633122 | 79 | 24.924051 | 23.869249 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.151899 | false | false |
14
|
6181ad97d2f3bd396a2fb9caae518b1152ba5541
| 26,877,905,368,697 |
f6479b08962887e547f4af409b4ffc5b20a97a8f
|
/datacubic/src/main/java/com/weibo/dip/data/platform/datacubic/batch/test/SparkDemo.java
|
0d08f39efe7823de723db29247a4b3f584289bd8
|
[] |
no_license
|
0Gz2bflQyU0hpW/portal
|
https://github.com/0Gz2bflQyU0hpW/portal
|
52f3cbd3f9ab078df34dcee2713ae64c78b5c041
|
96a71c84bbd550dfb09d97a35c51ec545ccb6d6a
|
refs/heads/master
| 2020-08-02T18:09:00.928000 | 2019-09-28T07:01:13 | 2019-09-28T07:01:13 | 211,459,081 | 0 | 2 | null | true | 2019-09-28T07:04:08 | 2019-09-28T07:04:07 | 2019-09-28T07:02:26 | 2019-09-28T07:02:19 | 0 | 0 | 0 | 0 | null | false | false |
package com.weibo.dip.data.platform.datacubic.batch.test;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by yurun on 17/11/23.
*/
public class SparkDemo {
private static final Logger LOGGER = LoggerFactory.getLogger(SparkDemo.class);
public static void main(String[] args) {
SparkConf conf = new SparkConf();
JavaSparkContext context = new JavaSparkContext(conf);
long count = context.textFile(args[0]).count();
context.stop();
LOGGER.info("count: " + count);
}
}
|
UTF-8
|
Java
| 637 |
java
|
SparkDemo.java
|
Java
|
[
{
"context": "import org.slf4j.LoggerFactory;\n\n/**\n * Created by yurun on 17/11/23.\n */\npublic class SparkDemo {\n\n pr",
"end": 226,
"score": 0.9995660781860352,
"start": 221,
"tag": "USERNAME",
"value": "yurun"
}
] | null |
[] |
package com.weibo.dip.data.platform.datacubic.batch.test;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by yurun on 17/11/23.
*/
public class SparkDemo {
private static final Logger LOGGER = LoggerFactory.getLogger(SparkDemo.class);
public static void main(String[] args) {
SparkConf conf = new SparkConf();
JavaSparkContext context = new JavaSparkContext(conf);
long count = context.textFile(args[0]).count();
context.stop();
LOGGER.info("count: " + count);
}
}
| 637 | 0.692308 | 0.678179 | 27 | 22.592592 | 24.009657 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.407407 | false | false |
14
|
d955fef00902c9f589b340dbc3a7500eb41b6dfc
| 2,353,642,079,588 |
293b1640eba7ddc7dd75a14b33b9aaa803caa906
|
/src/ec/ssr/functions/X613.java
|
bb81f5598518a942688a79996a956c3442ffde1d
|
[] |
no_license
|
luizvbo/ssr
|
https://github.com/luizvbo/ssr
|
a5703087456b3037c64082760c41e98cc31d4dcf
|
522ae0b7d72eb60f19cba30b876950871c7ae6db
|
refs/heads/master
| 2020-03-29T20:53:24.718000 | 2016-12-02T00:08:25 | 2016-12-02T00:08:25 | 150,337,098 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ec.ssr.functions;
public class X613 extends X{
@Override
public String getVariableName() {
return "x613";
}
@Override
public int getInputIndex() {
return 612;
}
}
|
UTF-8
|
Java
| 182 |
java
|
X613.java
|
Java
|
[] | null |
[] |
package ec.ssr.functions;
public class X613 extends X{
@Override
public String getVariableName() {
return "x613";
}
@Override
public int getInputIndex() {
return 612;
}
}
| 182 | 0.703297 | 0.653846 | 13 | 13.076923 | 11.822153 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false |
14
|
c600a9100425c394a72c92c2679b72c6613e07b5
| 30,537,217,496,570 |
e6766717e1f54ce52ae4839bd96219d3ed692cc5
|
/src/yuraMalish/Les3TaskC2.java
|
9f834023c3d070459d267078306036f05f0c6377
|
[] |
no_license
|
Shumski-Sergey/CS2019-05
|
https://github.com/Shumski-Sergey/CS2019-05
|
b9c74884efd3e194735b84d9e96a775024fdabb7
|
ec9669080cb8006dbc87f91ba33d61ecb4577a00
|
refs/heads/master
| 2020-05-17T02:12:15.709000 | 2019-05-04T18:27:16 | 2019-05-04T18:27:16 | 183,448,444 | 0 | 12 | null | false | 2019-05-04T18:27:17 | 2019-04-25T14:14:20 | 2019-05-04T13:34:02 | 2019-05-04T18:27:16 | 59 | 0 | 10 | 0 |
Java
| false | false |
package yuraMalish;
import java.util.Scanner;
public class Les3TaskC2 {
private static int sum(int n){
int a, b, c, d, sum;
a = n/1000;
b = n/100 - (a*10);
c = n/10 - (a*100) - (b*10);
d = n - a*1000 - b*100 - c*10;
sum= a + b + c + d;
return sum;
}
public static void main(String[] args) {
System.out.println("Введите четырех значное число");
Scanner cs = new Scanner(System.in);
int n = cs.nextInt();
int S = sum(n);
System.out.println("Сумма цифр вашего числа равна " + S);
}
}
|
UTF-8
|
Java
| 647 |
java
|
Les3TaskC2.java
|
Java
|
[] | null |
[] |
package yuraMalish;
import java.util.Scanner;
public class Les3TaskC2 {
private static int sum(int n){
int a, b, c, d, sum;
a = n/1000;
b = n/100 - (a*10);
c = n/10 - (a*100) - (b*10);
d = n - a*1000 - b*100 - c*10;
sum= a + b + c + d;
return sum;
}
public static void main(String[] args) {
System.out.println("Введите четырех значное число");
Scanner cs = new Scanner(System.in);
int n = cs.nextInt();
int S = sum(n);
System.out.println("Сумма цифр вашего числа равна " + S);
}
}
| 647 | 0.518456 | 0.473154 | 22 | 26.09091 | 17.508204 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false |
14
|
9f1fb41ecbf625fb36bf12e1b0ea225b3727377f
| 8,486,855,440,957 |
d132d2cd33f314712e5769913c545ab985a84e7a
|
/Implementation/ApplicationServer/src/test/java/it/polimi/travlendarplus/entities/calendar/BreakEventTest.java
|
f7c405aa506d971e3e25c027716d6a0fa7b068b9
|
[] |
no_license
|
JustSalva/MelziPinaSalvadore
|
https://github.com/JustSalva/MelziPinaSalvadore
|
54108d9b601055219e07fb1f7d4a7da5d949f43c
|
47025628dd7024d33a15f775b83e58516361f1fa
|
refs/heads/master
| 2021-09-03T13:22:27.038000 | 2018-01-09T09:53:24 | 2018-01-09T09:53:24 | 105,442,831 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package it.polimi.travlendarplus.entities.calendar;
import it.polimi.travlendarplus.entities.GenericEntityTest;
import it.polimi.travlendarplus.entities.User;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.time.Instant;
@RunWith( Arquillian.class )
public class BreakEventTest extends GenericEntityTest {
private BreakEvent testBreakEvent;
@Deployment
public static JavaArchive createDeployment() {
return GenericEntityTest.createDeployment()
.addClass( BreakEvent.class )
.addClass( GenericEvent.class );
}
public static BreakEvent getTestBreakEvent( int index ) {
return new BreakEvent( "name" + index, Instant.ofEpochSecond( 10 * index ), Instant.ofEpochSecond( 60 * index ),
false, 23 * index );
}
@Before
public void setUp() throws Exception {
User user = new User( "email", "name", "surname", "password" );
testBreakEvent = new BreakEvent( "name", Instant.ofEpochSecond( 120 ), Instant.ofEpochSecond( 500 ),
false, 100 );
testBreakEvent.setUser( user );
super.preparePersistenceTest();
}
@Test
public void eventIsFoundUsingJpqlQuery() {
BreakEvent retrievedEvent =
entityManager.createQuery( " SELECT break FROM BREAK_EVENT break", BreakEvent.class )
.getSingleResult();
assertSameBreakEvents( retrievedEvent );
}
public void assertSameBreakEvents( BreakEvent retrievedEvent ) {
Assert.assertEquals( testBreakEvent.getName(), retrievedEvent.getName() );
Assert.assertEquals( testBreakEvent.getStartingTime(), retrievedEvent.getStartingTime() );
Assert.assertEquals( testBreakEvent.getEndingTime(), retrievedEvent.getEndingTime() );
Assert.assertEquals( testBreakEvent.isScheduled(), retrievedEvent.isScheduled() );
Assert.assertEquals( testBreakEvent.getMinimumTime(), retrievedEvent.getMinimumTime() );
}
public void assertSameBreakEvents(BreakEvent testBreakEvent, BreakEvent retrievedEvent ) {
this.testBreakEvent = testBreakEvent;
assertSameBreakEvents( retrievedEvent );
}
@Override
protected void clearTableQuery() {
entityManager.createQuery( "DELETE FROM BREAK_EVENT " ).executeUpdate();
}
@Override
protected void loadTestData() {
entityManager.persist( testBreakEvent );
}
@After
public void tearDown() throws Exception {
super.commitTransaction();
}
}
|
UTF-8
|
Java
| 2,786 |
java
|
BreakEventTest.java
|
Java
|
[] | null |
[] |
package it.polimi.travlendarplus.entities.calendar;
import it.polimi.travlendarplus.entities.GenericEntityTest;
import it.polimi.travlendarplus.entities.User;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.time.Instant;
@RunWith( Arquillian.class )
public class BreakEventTest extends GenericEntityTest {
private BreakEvent testBreakEvent;
@Deployment
public static JavaArchive createDeployment() {
return GenericEntityTest.createDeployment()
.addClass( BreakEvent.class )
.addClass( GenericEvent.class );
}
public static BreakEvent getTestBreakEvent( int index ) {
return new BreakEvent( "name" + index, Instant.ofEpochSecond( 10 * index ), Instant.ofEpochSecond( 60 * index ),
false, 23 * index );
}
@Before
public void setUp() throws Exception {
User user = new User( "email", "name", "surname", "password" );
testBreakEvent = new BreakEvent( "name", Instant.ofEpochSecond( 120 ), Instant.ofEpochSecond( 500 ),
false, 100 );
testBreakEvent.setUser( user );
super.preparePersistenceTest();
}
@Test
public void eventIsFoundUsingJpqlQuery() {
BreakEvent retrievedEvent =
entityManager.createQuery( " SELECT break FROM BREAK_EVENT break", BreakEvent.class )
.getSingleResult();
assertSameBreakEvents( retrievedEvent );
}
public void assertSameBreakEvents( BreakEvent retrievedEvent ) {
Assert.assertEquals( testBreakEvent.getName(), retrievedEvent.getName() );
Assert.assertEquals( testBreakEvent.getStartingTime(), retrievedEvent.getStartingTime() );
Assert.assertEquals( testBreakEvent.getEndingTime(), retrievedEvent.getEndingTime() );
Assert.assertEquals( testBreakEvent.isScheduled(), retrievedEvent.isScheduled() );
Assert.assertEquals( testBreakEvent.getMinimumTime(), retrievedEvent.getMinimumTime() );
}
public void assertSameBreakEvents(BreakEvent testBreakEvent, BreakEvent retrievedEvent ) {
this.testBreakEvent = testBreakEvent;
assertSameBreakEvents( retrievedEvent );
}
@Override
protected void clearTableQuery() {
entityManager.createQuery( "DELETE FROM BREAK_EVENT " ).executeUpdate();
}
@Override
protected void loadTestData() {
entityManager.persist( testBreakEvent );
}
@After
public void tearDown() throws Exception {
super.commitTransaction();
}
}
| 2,786 | 0.69598 | 0.690596 | 83 | 32.566265 | 31.400328 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.590361 | false | false |
14
|
380cf616ae6ae81498050bc5fc7b1e2e4de52adf
| 14,370,960,588,804 |
0fd922b14735a9715cf30f932342297431d188ac
|
/app/src/main/java/com/example/sharedchecklist/Reminder.java
|
ce8a12ada324a18b90442c3cce9aecdba6758e6c
|
[] |
no_license
|
OutwardThrone/SharedChecklist
|
https://github.com/OutwardThrone/SharedChecklist
|
9dc795c78a897a9b2c757003b5be0e82066f367a
|
e84fade947cc15333fce85b5dafabfc8b8a98ce1
|
refs/heads/main
| 2023-08-02T08:16:42.483000 | 2021-09-26T01:31:10 | 2021-09-26T01:31:10 | 410,407,388 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.sharedchecklist;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.renderscript.ScriptGroup;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.w3c.dom.Text;
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Set;
public class Reminder extends ConstraintLayout {
private String title, description;
private boolean daily, weekly, completed;
private Calendar date;
private TextView titleView, desView, dateView;
private Button delete;
private CheckBox completeBox;
private ReminderUpdateListener listener;
private User user;
private LinearLayout friendLayout;
private Activity a;
public Reminder(@NonNull Context context, Activity a, User user, String title, String description, String date, String daily, String weekly, String completed) { //booleans are 0 or 0, Date is in format YYYY-MM-DD
super(context);
this.title = title;
this.description = description;
this.daily = daily.equals("1");
this.weekly = weekly.equals("1");
this.completed = completed.equals("1");
this.user = user;
String[] dateComps = date.split("-");
this.date = new GregorianCalendar();
this.date.set(Integer.valueOf(dateComps[0]), Integer.valueOf(dateComps[1])-1, Integer.valueOf(dateComps[2]));
this.a = a;
init(context);
//TODO: create linked list for reminder class that extends a list view possibly. Then add the instantiated list to xml and the whole reminder list should pop up
// implement adding friends on the friends tab. Have friend dialog extend an abstract class which create reminder dialog extends
// add friend option to create reminder dialog
// when friend is added to reminder put it in the users_reminders table
}
public Reminder(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public interface ReminderUpdateListener {
void onReminderUpdate(String response);
}
public void setReminderUpdateListener(ReminderUpdateListener listener) {
this.listener = listener;
}
private void init(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.reminder_structure, this, true);
titleView = (TextView) layout.findViewById(R.id.titleText);
desView = (TextView) layout.findViewById(R.id.descriptionText);
dateView = (TextView) layout.findViewById(R.id.dateView);
completeBox = (CheckBox) layout.findViewById(R.id.completeBox);
delete = (Button) layout.findViewById(R.id.deleteButton);
friendLayout = (LinearLayout) layout.findViewById(R.id.horizontalLayout);
titleView.setText(title);
desView.setText(description);
dateView.setText("" + this.date.getDisplayName(Calendar.MONTH, Calendar.SHORT_FORMAT, Locale.US) + " " + this.date.get(Calendar.DAY_OF_MONTH) + ", " + this.date.get(Calendar.YEAR));
getFriendsOnReminder();
completeBox.setChecked(completed);
completeBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitUpdate = new AwaitVolleyResponse<>();
dbhandler.updateCompleted(user.getUsername(), title, description, isChecked, getContext(), awaitUpdate);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitUpdate) {
while (!awaitUpdate.hasGotResponse()) {
awaitUpdate.wait();
}
String res = awaitUpdate.getResponse();
System.out.println("response came back");
listener.onReminderUpdate("Marked " + title + " as " + (isChecked ? "complete" : "incomplete"));
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
});
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitDelete = new AwaitVolleyResponse<>();
dbhandler.deleteReminder(user.getUsername(), title, description, getContext(), awaitDelete);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitDelete) {
while (!awaitDelete.hasGotResponse()) {
awaitDelete.wait();
}
String res = awaitDelete.getResponse();
listener.onReminderUpdate("Deleted: " + title);
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
});
}
private void addFriendOnReminder(String username, String fullname, boolean isOwner, boolean completed) {
Switch s = new Switch(getContext());
s.setText(fullname + (isOwner ? " - Owner" : ""));
s.setClickable(false);
a.runOnUiThread(() -> {
s.setChecked(completed);
friendLayout.addView(s);
});
}
private void getFriendsOnReminder() {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitFriendCheck = new AwaitVolleyResponse<>();
Context ctx = getContext();
dbhandler.getFriendsOnReminder(user.getUsername(), title, description, ctx, awaitFriendCheck);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitFriendCheck) {
while (!awaitFriendCheck.hasGotResponse()) {
awaitFriendCheck.wait();
}
String res = awaitFriendCheck.getResponse();
if (res.substring(0, 7).equals("Success")) {
JsonElement extra = new JsonParser().parse(res.substring(8));
Set<String> usernames = extra.getAsJsonObject().keySet();
for (String username : usernames) {
boolean isOwner = extra.getAsJsonObject().get(username).getAsJsonObject().get("isOwner").getAsString().equals("1");
boolean completed = extra.getAsJsonObject().get(username).getAsJsonObject().get("completed").getAsString().equals("1");
String fullname = extra.getAsJsonObject().get(username).getAsJsonObject().get("fullname").getAsString();
addFriendOnReminder(username, fullname, isOwner, completed);
}
}
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
public String toString() {
return "Reminder: " + title + " || " + description;
}
}
|
UTF-8
|
Java
| 8,715 |
java
|
Reminder.java
|
Java
|
[
{
"context": ");\n dbhandler.updateCompleted(user.getUsername(), title, description, isChecked, getContext(), a",
"end": 4255,
"score": 0.6565754413604736,
"start": 4244,
"tag": "USERNAME",
"value": "getUsername"
}
] | null |
[] |
package com.example.sharedchecklist;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.renderscript.ScriptGroup;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.w3c.dom.Text;
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Set;
public class Reminder extends ConstraintLayout {
private String title, description;
private boolean daily, weekly, completed;
private Calendar date;
private TextView titleView, desView, dateView;
private Button delete;
private CheckBox completeBox;
private ReminderUpdateListener listener;
private User user;
private LinearLayout friendLayout;
private Activity a;
public Reminder(@NonNull Context context, Activity a, User user, String title, String description, String date, String daily, String weekly, String completed) { //booleans are 0 or 0, Date is in format YYYY-MM-DD
super(context);
this.title = title;
this.description = description;
this.daily = daily.equals("1");
this.weekly = weekly.equals("1");
this.completed = completed.equals("1");
this.user = user;
String[] dateComps = date.split("-");
this.date = new GregorianCalendar();
this.date.set(Integer.valueOf(dateComps[0]), Integer.valueOf(dateComps[1])-1, Integer.valueOf(dateComps[2]));
this.a = a;
init(context);
//TODO: create linked list for reminder class that extends a list view possibly. Then add the instantiated list to xml and the whole reminder list should pop up
// implement adding friends on the friends tab. Have friend dialog extend an abstract class which create reminder dialog extends
// add friend option to create reminder dialog
// when friend is added to reminder put it in the users_reminders table
}
public Reminder(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public interface ReminderUpdateListener {
void onReminderUpdate(String response);
}
public void setReminderUpdateListener(ReminderUpdateListener listener) {
this.listener = listener;
}
private void init(Context context) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.reminder_structure, this, true);
titleView = (TextView) layout.findViewById(R.id.titleText);
desView = (TextView) layout.findViewById(R.id.descriptionText);
dateView = (TextView) layout.findViewById(R.id.dateView);
completeBox = (CheckBox) layout.findViewById(R.id.completeBox);
delete = (Button) layout.findViewById(R.id.deleteButton);
friendLayout = (LinearLayout) layout.findViewById(R.id.horizontalLayout);
titleView.setText(title);
desView.setText(description);
dateView.setText("" + this.date.getDisplayName(Calendar.MONTH, Calendar.SHORT_FORMAT, Locale.US) + " " + this.date.get(Calendar.DAY_OF_MONTH) + ", " + this.date.get(Calendar.YEAR));
getFriendsOnReminder();
completeBox.setChecked(completed);
completeBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitUpdate = new AwaitVolleyResponse<>();
dbhandler.updateCompleted(user.getUsername(), title, description, isChecked, getContext(), awaitUpdate);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitUpdate) {
while (!awaitUpdate.hasGotResponse()) {
awaitUpdate.wait();
}
String res = awaitUpdate.getResponse();
System.out.println("response came back");
listener.onReminderUpdate("Marked " + title + " as " + (isChecked ? "complete" : "incomplete"));
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
});
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitDelete = new AwaitVolleyResponse<>();
dbhandler.deleteReminder(user.getUsername(), title, description, getContext(), awaitDelete);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitDelete) {
while (!awaitDelete.hasGotResponse()) {
awaitDelete.wait();
}
String res = awaitDelete.getResponse();
listener.onReminderUpdate("Deleted: " + title);
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
});
}
private void addFriendOnReminder(String username, String fullname, boolean isOwner, boolean completed) {
Switch s = new Switch(getContext());
s.setText(fullname + (isOwner ? " - Owner" : ""));
s.setClickable(false);
a.runOnUiThread(() -> {
s.setChecked(completed);
friendLayout.addView(s);
});
}
private void getFriendsOnReminder() {
DatabaseHandler dbhandler = DatabaseHandler.getInstance();
AwaitVolleyResponse<String> awaitFriendCheck = new AwaitVolleyResponse<>();
Context ctx = getContext();
dbhandler.getFriendsOnReminder(user.getUsername(), title, description, ctx, awaitFriendCheck);
Thread wait = new Thread() {
@Override
public void run() {
try {
synchronized (awaitFriendCheck) {
while (!awaitFriendCheck.hasGotResponse()) {
awaitFriendCheck.wait();
}
String res = awaitFriendCheck.getResponse();
if (res.substring(0, 7).equals("Success")) {
JsonElement extra = new JsonParser().parse(res.substring(8));
Set<String> usernames = extra.getAsJsonObject().keySet();
for (String username : usernames) {
boolean isOwner = extra.getAsJsonObject().get(username).getAsJsonObject().get("isOwner").getAsString().equals("1");
boolean completed = extra.getAsJsonObject().get(username).getAsJsonObject().get("completed").getAsString().equals("1");
String fullname = extra.getAsJsonObject().get(username).getAsJsonObject().get("fullname").getAsString();
addFriendOnReminder(username, fullname, isOwner, completed);
}
}
}
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
};
wait.start();
}
public String toString() {
return "Reminder: " + title + " || " + description;
}
}
| 8,715 | 0.587034 | 0.585313 | 208 | 40.89904 | 36.269085 | 216 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false |
14
|
eaf537eab6559a369d98f373e7a634c1b1a8bc7e
| 27,307,402,128,950 |
eacb48504ef2a6a211aa3017fc078f049ab71186
|
/CS180/Lab02/src/StarGenerator.java
|
b0f10eafc8a419f15af42eba5214cdb1fc90f7a1
|
[] |
no_license
|
samrattennis/CS-files
|
https://github.com/samrattennis/CS-files
|
9ddb582a87cab0b865c63eb56a122c459db24bb7
|
3a7d3ab3dc4d1f23bc9a99ec71f6369100bdee97
|
refs/heads/master
| 2020-05-24T11:19:05.514000 | 2019-05-17T16:10:07 | 2019-05-17T16:10:07 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.*;
public class StarGenerator {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Random r = new Random();
int ran = r.nextInt(4)+1;
System.out.println("Please enter your name:");
String name = scan.nextLine();
System.out.println("Enter the college that you are in:");
String college = scan.nextLine();
String lower = name.toLowerCase();
int space = lower.indexOf(" ");
int length = lower.length();
String first = lower.substring(0,1);
String last = lower.substring(space+1, length);
String email = first + last + "@purdue.edu";
String upper = college.toUpperCase();
String col = upper.substring(0,3);
String star = col + ran;
System.out.println("Your Name: " + name);
System.out.println("Your Email: " + email);
System.out.println("Your College: " + college);
System.out.println("STAR Group: " + star);
}
}
|
UTF-8
|
Java
| 1,042 |
java
|
StarGenerator.java
|
Java
|
[
{
"context": " length);\n String email = first + last + \"@purdue.edu\";\n\n String upper = college.toUpperCase();\n",
"end": 694,
"score": 0.8419008851051331,
"start": 684,
"tag": "EMAIL",
"value": "purdue.edu"
}
] | null |
[] |
import java.util.*;
public class StarGenerator {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Random r = new Random();
int ran = r.nextInt(4)+1;
System.out.println("Please enter your name:");
String name = scan.nextLine();
System.out.println("Enter the college that you are in:");
String college = scan.nextLine();
String lower = name.toLowerCase();
int space = lower.indexOf(" ");
int length = lower.length();
String first = lower.substring(0,1);
String last = lower.substring(space+1, length);
String email = first + last + "@<EMAIL>";
String upper = college.toUpperCase();
String col = upper.substring(0,3);
String star = col + ran;
System.out.println("Your Name: " + name);
System.out.println("Your Email: " + email);
System.out.println("Your College: " + college);
System.out.println("STAR Group: " + star);
}
}
| 1,039 | 0.578695 | 0.571977 | 35 | 28.771429 | 22.009201 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.685714 | false | false |
14
|
2b6b0a795fde8ba0337942c0f21c1bbe8d587d56
| 33,131,377,728,629 |
109b8cf144ec786b7c3bd818eb7275ff0fe9b519
|
/app/src/main/java/com/smokynote/orm/DatabaseHelper.java
|
b95cc1d93046f811a3e29af94ea529a7bf1dc609
|
[] |
no_license
|
SmokyNote/smokynote-pro
|
https://github.com/SmokyNote/smokynote-pro
|
f5906032432dd38bd006ad91d547024f867c5e1b
|
2f5228835beb9ca16870b3b7d49e00eaba637035
|
refs/heads/master
| 2021-01-18T20:31:14.693000 | 2017-06-30T15:09:44 | 2017-06-30T15:09:44 | 15,246,937 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.smokynote.orm;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.smokynote.note.Note;
import java.sql.SQLException;
/**
* @author Maksim Zakharov
* @since 1.0
*/
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String DB_NAME = "smokynote.db";
private static final int DB_VERSION = 1;
public DatabaseHelper(Context context) {
// See http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_4.html#Config-Optimization
// super(context, DB_NAME, null, DB_VERSION, R.raw.ormlite_config);
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, Note.class);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
try {
TableUtils.createTableIfNotExists(connectionSource, Note.class);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
|
UTF-8
|
Java
| 1,421 |
java
|
DatabaseHelper.java
|
Java
|
[
{
"context": "te;\n\nimport java.sql.SQLException;\n\n/**\n * @author Maksim Zakharov\n * @since 1.0\n */\npublic class DatabaseHelper ext",
"end": 359,
"score": 0.9997420310974121,
"start": 344,
"tag": "NAME",
"value": "Maksim Zakharov"
}
] | null |
[] |
package com.smokynote.orm;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.smokynote.note.Note;
import java.sql.SQLException;
/**
* @author <NAME>
* @since 1.0
*/
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String DB_NAME = "smokynote.db";
private static final int DB_VERSION = 1;
public DatabaseHelper(Context context) {
// See http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_4.html#Config-Optimization
// super(context, DB_NAME, null, DB_VERSION, R.raw.ormlite_config);
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, Note.class);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
try {
TableUtils.createTableIfNotExists(connectionSource, Note.class);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
| 1,412 | 0.703026 | 0.693878 | 44 | 31.295454 | 29.661407 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.659091 | false | false |
14
|
55f9d8890aa3682d2a486ae16634976232a650be
| 33,131,377,729,450 |
ea97295158a2981f42c475845595465f48b682f1
|
/src/com/company/deckOfCards/Suite.java
|
482562add7ebb67917d789e7f516c47acba988fe
|
[] |
no_license
|
georgehans1/BlackJackGame
|
https://github.com/georgehans1/BlackJackGame
|
d6e7db54c568de8aac493e10a1e4f7aa9a31e4fb
|
7bb1cc5584abc93da0db224cd1145cab4cddd401
|
refs/heads/main
| 2023-09-02T01:53:29.168000 | 2021-11-20T13:59:15 | 2021-11-20T13:59:15 | 429,816,427 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.company.deckOfCards;
import java.util.List;
import java.util.Vector;
public abstract class Suite {
final private Vector<Card> suite;
public Suite(String suiteName, String symbol) {
suite = new Vector<Card>(List.of(
new Card("2", 2, suiteName, symbol),
new Card("3", 3, suiteName, symbol),
new Card("4", 4, suiteName, symbol),
new Card("5", 5, suiteName, symbol),
new Card("6", 6, suiteName, symbol),
new Card("7", 7, suiteName, symbol),
new Card("8", 8, suiteName, symbol),
new Card("9", 9, suiteName, symbol),
new Card("10", 10, suiteName, symbol),
new Card("Jack", 10, suiteName, symbol),
new Card("Queen", 10, suiteName, symbol),
new Card("King", 10, suiteName, symbol),
new Card("Ace", 11, suiteName, symbol)
));
}
public Vector<Card> getSuite() {
return suite;
}
}
class HeartsSuite extends Suite {
public HeartsSuite(String suite, String symbol) {
super(suite, symbol);
}
}
class DiamondsSuite extends Suite {
public DiamondsSuite(String suite, String symbol) {
super(suite, symbol);
}
}
class ClubsSuite extends Suite {
public ClubsSuite(String suiteName, String symbol) {
super(suiteName, symbol);
}
}
class SpadesSuite extends Suite {
public SpadesSuite(String suiteName, String symbol) {
super(suiteName, symbol);
}
}
|
UTF-8
|
Java
| 1,564 |
java
|
Suite.java
|
Java
|
[
{
"context": "10, suiteName, symbol),\n new Card(\"Jack\", 10, suiteName, symbol),\n new Car",
"end": 756,
"score": 0.9846749901771545,
"start": 752,
"tag": "NAME",
"value": "Jack"
}
] | null |
[] |
package com.company.deckOfCards;
import java.util.List;
import java.util.Vector;
public abstract class Suite {
final private Vector<Card> suite;
public Suite(String suiteName, String symbol) {
suite = new Vector<Card>(List.of(
new Card("2", 2, suiteName, symbol),
new Card("3", 3, suiteName, symbol),
new Card("4", 4, suiteName, symbol),
new Card("5", 5, suiteName, symbol),
new Card("6", 6, suiteName, symbol),
new Card("7", 7, suiteName, symbol),
new Card("8", 8, suiteName, symbol),
new Card("9", 9, suiteName, symbol),
new Card("10", 10, suiteName, symbol),
new Card("Jack", 10, suiteName, symbol),
new Card("Queen", 10, suiteName, symbol),
new Card("King", 10, suiteName, symbol),
new Card("Ace", 11, suiteName, symbol)
));
}
public Vector<Card> getSuite() {
return suite;
}
}
class HeartsSuite extends Suite {
public HeartsSuite(String suite, String symbol) {
super(suite, symbol);
}
}
class DiamondsSuite extends Suite {
public DiamondsSuite(String suite, String symbol) {
super(suite, symbol);
}
}
class ClubsSuite extends Suite {
public ClubsSuite(String suiteName, String symbol) {
super(suiteName, symbol);
}
}
class SpadesSuite extends Suite {
public SpadesSuite(String suiteName, String symbol) {
super(suiteName, symbol);
}
}
| 1,564 | 0.574169 | 0.556266 | 54 | 27.981482 | 21.893251 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.296296 | false | false |
14
|
5975b876af3709be6bb88c3186ffc0cdc027f3a8
| 25,116,968,778,978 |
0b4844d550c8e77cd93940e4a1d8b06d0fbeabf7
|
/JavaSource/common/finder/valid/form/ListOfValForm.java
|
15bb81b7bc492fc3764497512edc478f90683219
|
[] |
no_license
|
eMainTec-DREAM/DREAM
|
https://github.com/eMainTec-DREAM/DREAM
|
bbf928b5c50dd416e1d45db3722f6c9e35d8973c
|
05e3ea85f9adb6ad6cbe02f4af44d941400a1620
|
refs/heads/master
| 2020-12-22T20:44:44.387000 | 2020-01-29T06:47:47 | 2020-01-29T06:47:47 | 236,912,749 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package common.finder.valid.form;
import common.finder.valid.dto.ListOfValDTO;
import common.struts.BaseForm;
import dream.comm.form.MaFinderAcForm;
/**
* List Of Value Form
* @author javaworker
* @version $Id: ListOfValForm.java,v 1.1 2013/08/30 09:12:46 javaworker Exp $
* @since 1.0
*
* @struts.form name="listOfValForm"
*/
public class ListOfValForm extends MaFinderAcForm
{
/** List Of Val DTO */
private ListOfValDTO listOfValDTO = new ListOfValDTO();
public ListOfValDTO getListOfValDTO()
{
return listOfValDTO;
}
public void setListOfValDTO(ListOfValDTO listOfValDTO)
{
this.listOfValDTO = listOfValDTO;
}
}
|
UTF-8
|
Java
| 707 |
java
|
ListOfValForm.java
|
Java
|
[
{
"context": "AcForm;\r\n\r\n/**\r\n * List Of Value Form\r\n * @author javaworker\r\n * @version $Id: ListOfValForm.java,v 1.1 2013/0",
"end": 207,
"score": 0.9995949268341064,
"start": 197,
"tag": "USERNAME",
"value": "javaworker"
}
] | null |
[] |
package common.finder.valid.form;
import common.finder.valid.dto.ListOfValDTO;
import common.struts.BaseForm;
import dream.comm.form.MaFinderAcForm;
/**
* List Of Value Form
* @author javaworker
* @version $Id: ListOfValForm.java,v 1.1 2013/08/30 09:12:46 javaworker Exp $
* @since 1.0
*
* @struts.form name="listOfValForm"
*/
public class ListOfValForm extends MaFinderAcForm
{
/** List Of Val DTO */
private ListOfValDTO listOfValDTO = new ListOfValDTO();
public ListOfValDTO getListOfValDTO()
{
return listOfValDTO;
}
public void setListOfValDTO(ListOfValDTO listOfValDTO)
{
this.listOfValDTO = listOfValDTO;
}
}
| 707 | 0.674682 | 0.649222 | 29 | 22.379311 | 21.629185 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.275862 | false | false |
14
|
fa09bb8b828002736753f9e8d4ce21312c3e7de6
| 901,943,138,613 |
412d3fd78b1505338f7a2473ce88b633ffc1945f
|
/src/main/java/Rover.java
|
563096f8852af508b0a50fe4fe4e6df4af215a18
|
[] |
no_license
|
Dannyang27/MarsRover
|
https://github.com/Dannyang27/MarsRover
|
0e99e573f8784d9ca9f288ed74ceac583718f2cf
|
4a02975d3d53ba2df08c62c6f2bb21f6f9d1c9a0
|
refs/heads/master
| 2020-08-15T11:02:47.045000 | 2019-10-15T15:15:25 | 2019-10-15T15:15:25 | 215,330,021 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Rover {
int x;
int y;
char direction;
String movement;
boolean [][] plateau;
public Rover(int x, int y, char direction, String movement){
this.x = x;
this.y = y;
this.direction = direction;
this.movement = movement;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public char getDirection() {
return direction;
}
public void setDirection(char direction) {
this.direction = direction;
}
public String getMovement() {
return movement;
}
public void setMovement(String movement) {
this.movement = movement;
}
public void initRover(boolean [][] plateau){
this.plateau = plateau;
for(char command: this.movement.toCharArray()){
switch (command){
case 'L': {
rotateLeft();
break;
}
case 'R': {
rotateRight();
break;
}
case 'M': {
moveForward();
break;
}
default: break;
}
}
System.out.println(String.format("%d %d %s", this.x, this.y, this.direction));
}
public void rotateLeft(){
switch (this.direction){
case 'N': {
this.direction = 'W';
break;
}
case 'W': {
this.direction = 'S';
break;
}
case 'S': {
this.direction = 'E';
break;
}
case 'E': {
this.direction = 'N';
break;
}
default: break;
}
}
public void rotateRight(){
switch (this.direction){
case 'N': {
this.direction = 'E';
break;
}
case 'E': {
this.direction = 'S';
break;
}
case 'S': {
this.direction = 'W';
break;
}
case 'W': {
this.direction = 'N';
break;
}
default: break;
}
}
public void moveForward(){
switch (this.direction){
case 'N': {
if(isInsideLimit(this.x, this.y + 1)){
this.y++;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'E': {
if(isInsideLimit(this.x + 1, this.y)){
this.x++;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'S': {
if(isInsideLimit(this.x, this.y - 1)){
this.y--;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'W': {
if(isInsideLimit(this.x - 1, this.y)){
this.x--;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
default: break;
}
}
public boolean isInsideLimit(int x, int y){
return (0 <= x && x < plateau.length) && (0 <= y && y < plateau[0].length);
}
}
|
UTF-8
|
Java
| 3,739 |
java
|
Rover.java
|
Java
|
[] | null |
[] |
public class Rover {
int x;
int y;
char direction;
String movement;
boolean [][] plateau;
public Rover(int x, int y, char direction, String movement){
this.x = x;
this.y = y;
this.direction = direction;
this.movement = movement;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public char getDirection() {
return direction;
}
public void setDirection(char direction) {
this.direction = direction;
}
public String getMovement() {
return movement;
}
public void setMovement(String movement) {
this.movement = movement;
}
public void initRover(boolean [][] plateau){
this.plateau = plateau;
for(char command: this.movement.toCharArray()){
switch (command){
case 'L': {
rotateLeft();
break;
}
case 'R': {
rotateRight();
break;
}
case 'M': {
moveForward();
break;
}
default: break;
}
}
System.out.println(String.format("%d %d %s", this.x, this.y, this.direction));
}
public void rotateLeft(){
switch (this.direction){
case 'N': {
this.direction = 'W';
break;
}
case 'W': {
this.direction = 'S';
break;
}
case 'S': {
this.direction = 'E';
break;
}
case 'E': {
this.direction = 'N';
break;
}
default: break;
}
}
public void rotateRight(){
switch (this.direction){
case 'N': {
this.direction = 'E';
break;
}
case 'E': {
this.direction = 'S';
break;
}
case 'S': {
this.direction = 'W';
break;
}
case 'W': {
this.direction = 'N';
break;
}
default: break;
}
}
public void moveForward(){
switch (this.direction){
case 'N': {
if(isInsideLimit(this.x, this.y + 1)){
this.y++;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'E': {
if(isInsideLimit(this.x + 1, this.y)){
this.x++;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'S': {
if(isInsideLimit(this.x, this.y - 1)){
this.y--;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
case 'W': {
if(isInsideLimit(this.x - 1, this.y)){
this.x--;
}else{
System.out.println("Cannot go, not moving");
}
break;
}
default: break;
}
}
public boolean isInsideLimit(int x, int y){
return (0 <= x && x < plateau.length) && (0 <= y && y < plateau[0].length);
}
}
| 3,739 | 0.374432 | 0.37256 | 172 | 20.738373 | 17.134426 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.424419 | false | false |
14
|
bf32a56e5cf6ef6d605d988e4c4daadeaf1bcdae
| 23,252,952,991,565 |
8765b77d6101de8d0696e8a90e411fe88ce77c51
|
/tamboot-cloud-admin-system-ms/src/main/java/com/tamboot/cloud/admin/systemms/service/SystemMenuService.java
|
c503b2a72beafd1f10a194ed4548ef69e6cef1d2
|
[] |
no_license
|
hemijing/tamboot-cloud-admin
|
https://github.com/hemijing/tamboot-cloud-admin
|
7866723ddbdfba45c8603dc4b218a4b4bed972a2
|
00057a468855d6e4f100c1f144f8304f5f66cd52
|
refs/heads/master
| 2022-02-25T11:37:50.766000 | 2019-08-29T02:52:26 | 2019-08-29T02:52:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.tamboot.cloud.admin.systemms.service;
import com.tamboot.cloud.admin.systemms.dto.MenuTree;
import com.tamboot.cloud.admin.systemms.model.SystemMenuModel;
import java.util.List;
public interface SystemMenuService {
/**
* Build menu tree using given {@code menus}
* @param menus menu items
* @return menu tree, never null
*/
List<MenuTree> buildMenuTree(List<SystemMenuModel> menus);
/**
* Build menu tree for specified user
* @param userId required
* @return menu tree, never null
*/
List<MenuTree> treeForUser(Long userId);
}
|
UTF-8
|
Java
| 600 |
java
|
SystemMenuService.java
|
Java
|
[] | null |
[] |
package com.tamboot.cloud.admin.systemms.service;
import com.tamboot.cloud.admin.systemms.dto.MenuTree;
import com.tamboot.cloud.admin.systemms.model.SystemMenuModel;
import java.util.List;
public interface SystemMenuService {
/**
* Build menu tree using given {@code menus}
* @param menus menu items
* @return menu tree, never null
*/
List<MenuTree> buildMenuTree(List<SystemMenuModel> menus);
/**
* Build menu tree for specified user
* @param userId required
* @return menu tree, never null
*/
List<MenuTree> treeForUser(Long userId);
}
| 600 | 0.696667 | 0.696667 | 23 | 25.086956 | 21.52231 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.347826 | false | false |
14
|
24f6c18359026c8c8195316a8c142d2a5dc2b138
| 20,864,951,153,253 |
794c37b35eafe53179d08a6010a8cd186583cb6a
|
/src/rpg_database/character_sheet/exceptions/InvalidFocusesSetException.java
|
000aefb437905f0657db54ba414bd2c8b65f267a
|
[] |
no_license
|
Grandmagic13/RPGManager
|
https://github.com/Grandmagic13/RPGManager
|
dfa7fdaf9bea705cceaeba5345065a8f7887c73b
|
f5d41fefcd9d48e126882c3ccdf13eebdda2215f
|
refs/heads/master
| 2021-01-09T05:36:47.407000 | 2017-10-15T17:47:15 | 2017-10-15T17:47:15 | 80,768,802 | 0 | 0 | null | false | 2017-10-15T17:47:16 | 2017-02-02T21:07:22 | 2017-02-19T19:02:11 | 2017-10-15T17:47:16 | 357 | 0 | 0 | 42 |
Java
| null | null |
package rpg_database.character_sheet.exceptions;
@SuppressWarnings("serial")
public class InvalidFocusesSetException extends CharacterSheetException {
public InvalidFocusesSetException(String message) {
super(message);
}
}
|
UTF-8
|
Java
| 238 |
java
|
InvalidFocusesSetException.java
|
Java
|
[] | null |
[] |
package rpg_database.character_sheet.exceptions;
@SuppressWarnings("serial")
public class InvalidFocusesSetException extends CharacterSheetException {
public InvalidFocusesSetException(String message) {
super(message);
}
}
| 238 | 0.789916 | 0.789916 | 9 | 24.444445 | 25.781609 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
14
|
75348ee3176aef44e00f2ef0853e6773cabf22e8
| 32,418,413,209,733 |
3bb4b5892439031626b966102c58f22d032d7fcc
|
/src/ciber/TTipos.java
|
d751a772ad369aa570c000d9f949c4cc116ad714
|
[] |
no_license
|
gamalielmendez/ciber
|
https://github.com/gamalielmendez/ciber
|
accd45c1e816a022d973448715b3b0e4c74561b7
|
282026fe70101e50bb8ad8bbda66e47db4896c0a
|
refs/heads/master
| 2019-07-30T22:55:12.919000 | 2016-12-09T13:24:49 | 2016-12-09T13:24:49 | 76,037,203 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ciber;
import Conexion.Cnn;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class TTipos extends javax.swing.JDialog {
public Cnn cnn;
DefaultTableModel modelo;
public Integer TipoID;
Boolean lSeleccionar=false,lModoSeleccionar=false;
public TTipos(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.modelo=(DefaultTableModel) this.tblTipos.getModel();
}
public void LlenaTabla(){
try{
Connection con=cnn.GetConection();
Statement ps=con.createStatement();
ResultSet Result = ps.executeQuery("SELECT TIPO,TIPO_ID FROM tblinvtipos");
if(modelo.getRowCount()>0){
for(int n=modelo.getRowCount()-1;n>=0;n--){
modelo.removeRow(n);
}
}
while(Result.next()){
// Se crea un array que será una de las filas de la tabla.
Object [] fila = new Object[2]; // Hay tres columnas en la tabla
// Se rellena cada posición del array con una de las columnas de la tabla en base de datos.
for (int i=0;i<2;i++)
fila[i] = Result.getObject(i+1); // El primer indice en rs es el 1, no el cero, por eso se suma 1.
// Se añade al modelo la fila completa.
modelo.addRow(fila);
}
if(this.modelo.getRowCount()>0)
this.tblTipos.setRowSelectionInterval(0, 0);
con.close();
}catch(SQLException e){
JOptionPane.showMessageDialog(this,"Error al obtener datos:"+e.getMessage());
this.setVisible(false);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
tblTipos = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
tblTipos.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"TIPO", "CLAVE"
}
));
jScrollPane1.setViewportView(tblTipos);
if (tblTipos.getColumnModel().getColumnCount() > 0) {
tblTipos.getColumnModel().getColumn(1).setMinWidth(50);
tblTipos.getColumnModel().getColumn(1).setPreferredWidth(50);
tblTipos.getColumnModel().getColumn(1).setMaxWidth(50);
}
jButton1.setText("Agregar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Modificar");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Eliminar");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Seleccionar");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4)
.addContainerGap(188, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
AbcTipos abc;
abc = new AbcTipos(null,true);
abc.cnn=this.cnn;
abc.setVisible(true);
if(abc.lGuardar)
this.LlenaTabla();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
AbcTipos abc;
abc = new AbcTipos(null,true);
abc.cnn=this.cnn;
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
abc.TipoID=Integer.parseInt(dato);
abc.setVisible(true);
if(abc.lGuardar)
this.LlenaTabla();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
int result;
if(this.modelo.getRowCount()>0){
result=JOptionPane.showConfirmDialog(this,"Desea eliminar este registro?");
if(result==0){
try{
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
Connection con=cnn.GetConection();
Statement ps=con.createStatement();
int Result = ps.executeUpdate("DELETE FROM tblinvtipos WHERE TIPO_ID="+dato);
con.close();
this.LlenaTabla();
}catch(SQLException e){
if(!e.getMessage().contains("foreign key")){
JOptionPane.showMessageDialog(this,"Error al eliminar registro: "+e.getMessage());
}else{
JOptionPane.showMessageDialog(this,"No se permite eliminar este registro por contener movimientos en el sistema.");
}
}
}
}
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
if(this.modelo.getRowCount()>0 && lModoSeleccionar){
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
this.TipoID=Integer.parseInt(dato);
this.lSeleccionar=true;
this.setVisible(false);
}
}//GEN-LAST:event_jButton4ActionPerformed
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TTipos dialog = new TTipos(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable tblTipos;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 12,044 |
java
|
TTipos.java
|
Java
|
[] | null |
[] |
package ciber;
import Conexion.Cnn;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class TTipos extends javax.swing.JDialog {
public Cnn cnn;
DefaultTableModel modelo;
public Integer TipoID;
Boolean lSeleccionar=false,lModoSeleccionar=false;
public TTipos(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.modelo=(DefaultTableModel) this.tblTipos.getModel();
}
public void LlenaTabla(){
try{
Connection con=cnn.GetConection();
Statement ps=con.createStatement();
ResultSet Result = ps.executeQuery("SELECT TIPO,TIPO_ID FROM tblinvtipos");
if(modelo.getRowCount()>0){
for(int n=modelo.getRowCount()-1;n>=0;n--){
modelo.removeRow(n);
}
}
while(Result.next()){
// Se crea un array que será una de las filas de la tabla.
Object [] fila = new Object[2]; // Hay tres columnas en la tabla
// Se rellena cada posición del array con una de las columnas de la tabla en base de datos.
for (int i=0;i<2;i++)
fila[i] = Result.getObject(i+1); // El primer indice en rs es el 1, no el cero, por eso se suma 1.
// Se añade al modelo la fila completa.
modelo.addRow(fila);
}
if(this.modelo.getRowCount()>0)
this.tblTipos.setRowSelectionInterval(0, 0);
con.close();
}catch(SQLException e){
JOptionPane.showMessageDialog(this,"Error al obtener datos:"+e.getMessage());
this.setVisible(false);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
tblTipos = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
tblTipos.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"TIPO", "CLAVE"
}
));
jScrollPane1.setViewportView(tblTipos);
if (tblTipos.getColumnModel().getColumnCount() > 0) {
tblTipos.getColumnModel().getColumn(1).setMinWidth(50);
tblTipos.getColumnModel().getColumn(1).setPreferredWidth(50);
tblTipos.getColumnModel().getColumn(1).setMaxWidth(50);
}
jButton1.setText("Agregar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Modificar");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Eliminar");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Seleccionar");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4)
.addContainerGap(188, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
AbcTipos abc;
abc = new AbcTipos(null,true);
abc.cnn=this.cnn;
abc.setVisible(true);
if(abc.lGuardar)
this.LlenaTabla();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
AbcTipos abc;
abc = new AbcTipos(null,true);
abc.cnn=this.cnn;
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
abc.TipoID=Integer.parseInt(dato);
abc.setVisible(true);
if(abc.lGuardar)
this.LlenaTabla();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
int result;
if(this.modelo.getRowCount()>0){
result=JOptionPane.showConfirmDialog(this,"Desea eliminar este registro?");
if(result==0){
try{
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
Connection con=cnn.GetConection();
Statement ps=con.createStatement();
int Result = ps.executeUpdate("DELETE FROM tblinvtipos WHERE TIPO_ID="+dato);
con.close();
this.LlenaTabla();
}catch(SQLException e){
if(!e.getMessage().contains("foreign key")){
JOptionPane.showMessageDialog(this,"Error al eliminar registro: "+e.getMessage());
}else{
JOptionPane.showMessageDialog(this,"No se permite eliminar este registro por contener movimientos en el sistema.");
}
}
}
}
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
if(this.modelo.getRowCount()>0 && lModoSeleccionar){
String dato=String.valueOf(modelo.getValueAt(tblTipos.getSelectedRow(),1));
this.TipoID=Integer.parseInt(dato);
this.lSeleccionar=true;
this.setVisible(false);
}
}//GEN-LAST:event_jButton4ActionPerformed
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TTipos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TTipos dialog = new TTipos(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable tblTipos;
// End of variables declaration//GEN-END:variables
}
| 12,044 | 0.614235 | 0.60593 | 274 | 42.945255 | 33.836456 | 156 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.591241 | false | false |
14
|
0016b7fb89ee6da94aba2ac33873bb6ce88de621
| 12,343,736,037,782 |
152e48795266782307dc4bc8a0ad96e368f697a8
|
/CHapter7/ArrayListPractice.java
|
8de50f8e19651ea8027e489733177376e250be93
|
[] |
no_license
|
MonkeyBomb/unit4ArraysArrayLists
|
https://github.com/MonkeyBomb/unit4ArraysArrayLists
|
b6625278626739154da8102c11420403148a8f0e
|
aace7578748be6622b6394ac92ec3afb25bcd68a
|
refs/heads/master
| 2021-01-22T16:32:30.052000 | 2015-12-16T16:18:19 | 2015-12-16T16:18:19 | 46,571,652 | 0 | 0 | null | true | 2015-11-20T15:55:58 | 2015-11-20T15:55:58 | 2015-11-20T15:55:58 | 2015-07-08T05:03:27 | 1,126 | 0 | 0 | 0 |
HTML
| null | null |
import java.util.ArrayList;
public class ArrayListPractice
{
public static void main(String[] args)
{
ArrayList<String> words = new ArrayList<String>();
words.add("test");
words.add("like");
words.add("like");
words.add("cookie");
words.add("monster");
System.out.println(words);
for(int i = words.size() - 1; i >= 0; i--)
{
String word = words.get(i);
if(word.equals("like"))
{
words.remove(i);
}
}
System.out.println(words);
}
}
|
UTF-8
|
Java
| 600 |
java
|
ArrayListPractice.java
|
Java
|
[] | null |
[] |
import java.util.ArrayList;
public class ArrayListPractice
{
public static void main(String[] args)
{
ArrayList<String> words = new ArrayList<String>();
words.add("test");
words.add("like");
words.add("like");
words.add("cookie");
words.add("monster");
System.out.println(words);
for(int i = words.size() - 1; i >= 0; i--)
{
String word = words.get(i);
if(word.equals("like"))
{
words.remove(i);
}
}
System.out.println(words);
}
}
| 600 | 0.488333 | 0.485 | 26 | 22.076923 | 15.216193 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
14
|
704f26d8e3152d6c23ae2742f902a6e4d26a0d75
| 24,885,040,546,719 |
1cc7e1f75513657d4d486f1c2ccd2ff49a769084
|
/MysqlTest/src/java_mysql/Test.java
|
00d016c9dc06d4dbef63a207d1fe21b420e69d58
|
[] |
no_license
|
hiroshi0505/ProGATE1
|
https://github.com/hiroshi0505/ProGATE1
|
daebd90295983da2aeeaf0206978301a399ccf7a
|
917d282a640e5d370b417780e77f61f68de495f7
|
refs/heads/master
| 2023-06-10T23:41:29.024000 | 2021-07-09T07:19:56 | 2021-07-09T07:19:56 | 370,914,187 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package java_mysql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test {
public static void main(String[] args) {
// 変数の準備
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
// SQL文の作成
String sql = "SELECT * FROM test";
try {
// JDBCドライバのロード
Class.forName("com.mysql.cj.jdbc.Driver");
// データベース接続
System.out.println("テスト1");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_db?serverTimezone=JST", "root", "root");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_db?serverTimezone=JST", "root", "a1500095");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb ", "root", "a1500095");
//con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test_db ", "root", "a1500095");
System.out.println("テスト2");
// SQL実行準備
stmt = con.prepareStatement(sql);
// 実行結果取得
rs = stmt.executeQuery();
// データがなくなるまで(rs.next()がfalseになるまで)繰り返す
while (rs.next()) {
String id = rs.getString("id");
String name = rs.getString("name");
System.out.println(id + ":" + name);
}
} catch (ClassNotFoundException e) {
System.out.println("JDBCドライバのロードでエラーが発生しました");
} catch (SQLException e) {
System.out.println("データベースへのアクセスでエラーが発生しました。1");
e.printStackTrace();
System.out.println(e.getErrorCode());
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
System.out.println("データベースへのアクセスでエラーが発生しました。2");
}
}
}
}
|
UTF-8
|
Java
| 2,346 |
java
|
Test.java
|
Java
|
[
{
"context": "alhost:3306/test_db?serverTimezone=JST\", \"root\", \"a1500095\");\r\n con = DriverManager.getConnection",
"end": 843,
"score": 0.6945439577102661,
"start": 835,
"tag": "PASSWORD",
"value": "a1500095"
},
{
"context": "calhost:3306/testdb \", \"root\", \"a1500095\");\r\n //con = DriverManager.getConnecti",
"end": 968,
"score": 0.8097880482673645,
"start": 960,
"tag": "PASSWORD",
"value": "a1500095"
},
{
"context": "//con = DriverManager.getConnection(\"jdbc:mysql://127.0.0.1:3306/test_db \", \"root\", \"a15000",
"end": 1044,
"score": 0.9973121285438538,
"start": 1035,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
},
{
"context": ".0.0.1:3306/test_db \", \"root\", \"a1500095\");\r\n System.out.println(\"テスト2\");\r\n ",
"end": 1096,
"score": 0.7168956398963928,
"start": 1088,
"tag": "PASSWORD",
"value": "a1500095"
}
] | null |
[] |
package java_mysql;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test {
public static void main(String[] args) {
// 変数の準備
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
// SQL文の作成
String sql = "SELECT * FROM test";
try {
// JDBCドライバのロード
Class.forName("com.mysql.cj.jdbc.Driver");
// データベース接続
System.out.println("テスト1");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_db?serverTimezone=JST", "root", "root");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_db?serverTimezone=JST", "root", "<PASSWORD>");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb ", "root", "<PASSWORD>");
//con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test_db ", "root", "<PASSWORD>");
System.out.println("テスト2");
// SQL実行準備
stmt = con.prepareStatement(sql);
// 実行結果取得
rs = stmt.executeQuery();
// データがなくなるまで(rs.next()がfalseになるまで)繰り返す
while (rs.next()) {
String id = rs.getString("id");
String name = rs.getString("name");
System.out.println(id + ":" + name);
}
} catch (ClassNotFoundException e) {
System.out.println("JDBCドライバのロードでエラーが発生しました");
} catch (SQLException e) {
System.out.println("データベースへのアクセスでエラーが発生しました。1");
e.printStackTrace();
System.out.println(e.getErrorCode());
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
System.out.println("データベースへのアクセスでエラーが発生しました。2");
}
}
}
}
| 2,352 | 0.525837 | 0.503349 | 59 | 33.457626 | 29.886974 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.610169 | false | false |
14
|
a080d2c76b1c4a84578ddd10519fc9daedae13af
| 5,411,658,859,073 |
271dcd8c89079ac93c356a419a11329297c782a3
|
/src/com/lyj/pattern/strategy/Plus.java
|
bab6e26c6588f19104923cc82567c9158b742586
|
[] |
no_license
|
BlessL/DP
|
https://github.com/BlessL/DP
|
4c9e1a19984771e215914110b4ff496dea092662
|
a63df0adf4bb7c7ea73e774fad668a59ce317164
|
refs/heads/master
| 2020-04-03T09:54:24.175000 | 2016-10-08T09:53:50 | 2016-10-08T09:53:50 | 70,320,637 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.lyj.pattern.strategy;
import com.lyj.pattern.interfaces.ICalculator;
public class Plus extends AbstractCalculator implements ICalculator
{
@Override
public int calculator(String expression)
{
int arrayInt[] = split(expression, "\\+");
return arrayInt[0] + arrayInt[1];
}
}
|
UTF-8
|
Java
| 297 |
java
|
Plus.java
|
Java
|
[] | null |
[] |
package com.lyj.pattern.strategy;
import com.lyj.pattern.interfaces.ICalculator;
public class Plus extends AbstractCalculator implements ICalculator
{
@Override
public int calculator(String expression)
{
int arrayInt[] = split(expression, "\\+");
return arrayInt[0] + arrayInt[1];
}
}
| 297 | 0.747475 | 0.740741 | 15 | 18.799999 | 22.12751 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.866667 | false | false |
14
|
e997ea617561a894734126cbc242b480418d433f
| 27,419,071,238,798 |
5478f66627242ddf9edd57733de6d0a43e1ff2e3
|
/db/NoValue.java
|
5439e409c401e7c349a9ca22d23b4c09e9609588
|
[] |
no_license
|
jcpagadora/proj2
|
https://github.com/jcpagadora/proj2
|
7a2055f7fd0c9ad4869d3aeb3470c192167a661d
|
6973338a3d979cc5699b2678ab4416bf8ec354e9
|
refs/heads/master
| 2021-01-17T08:11:47.628000 | 2020-10-06T02:11:01 | 2020-10-06T02:11:01 | 83,859,361 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package db;
/**
* Created by Joseph on 3/3/2017.
* NoValue is its own class; integer representation is 0 with
* string representation "NOVALUE"
*/
public class NoValue extends SpecialValue {
private static final String repr = "NOVALUE";
@Override
public String toString() {
return repr;
}
}
|
UTF-8
|
Java
| 340 |
java
|
NoValue.java
|
Java
|
[
{
"context": "package db;\r\n\r\n/**\r\n * Created by Joseph on 3/3/2017.\r\n * NoValue is its own class; intege",
"end": 40,
"score": 0.9996938705444336,
"start": 34,
"tag": "NAME",
"value": "Joseph"
}
] | null |
[] |
package db;
/**
* Created by Joseph on 3/3/2017.
* NoValue is its own class; integer representation is 0 with
* string representation "NOVALUE"
*/
public class NoValue extends SpecialValue {
private static final String repr = "NOVALUE";
@Override
public String toString() {
return repr;
}
}
| 340 | 0.638235 | 0.617647 | 17 | 18 | 19.314732 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.235294 | false | false |
14
|
75b2642d60686b74fb71aba93d310288c7d08701
| 24,618,752,570,612 |
9daf706759ab3978ba43113e25061fad81eb9897
|
/app/src/main/java/com/svs/hztb/PushNotifications/MyGcmListenerService.java
|
2f33f67d7115f806794c595489e112a9d0f80996
|
[] |
no_license
|
svsdigitaltechnologies/hztb-android
|
https://github.com/svsdigitaltechnologies/hztb-android
|
e14469ca39eb141e481fbdd6986c64f589df0f46
|
899199ac18c578c790f7965aa39b5e58b24dd1bb
|
refs/heads/develop
| 2020-12-20T20:57:05.357000 | 2016-08-06T04:43:36 | 2016-08-06T04:43:36 | 54,677,922 | 0 | 0 | null | false | 2016-08-06T04:34:01 | 2016-03-24T22:19:58 | 2016-03-24T22:23:38 | 2016-08-06T04:34:00 | 2,570 | 0 | 0 | 0 |
Java
| null | null |
package com.svs.hztb.PushNotifications;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.support.v4.app.NotificationCompat;
import com.google.android.gms.gcm.GcmListenerService;
import com.svs.hztb.Activities.HomeScreenActivity;
import com.svs.hztb.Activities.PopupViewActivity;
import com.svs.hztb.Activities.ProfileActivity;
import com.svs.hztb.Database.AppSharedPreference;
import com.svs.hztb.R;
import java.util.Timer;
import java.util.TimerTask;
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
private final int VIBRATE_OFF = 0;
private final int VIBRATE_DEFAULT = 1;
private final int VIBRATE_SHORT = 2;
private final int POPUP_OFF = 0;
private final int POPUP_ON_WHEN_SCREEN_ON = 1;
private final int POPUP_ON_WHEN_SCREEN_OFF = 2;
private boolean isConversationTonesEnabled;
private String getNotificationRingtoneUri;
private int vibrateType;
private int popUpType;
private String message;
private Uri notificationSoundURI;
private boolean noVibrate;
private long[] vibrateMode;
private long[] vibrateLong = new long[] { 1000, 1000, 1000, 1000, 1000,1000,1000 };
private long[] vibrateShort = new long[] { 1000, 1000};
private long[] vibrateDefault = new long[] { 1000, 1000, 1000, 1000 };
/**
* Called when message is received.
*
* @param from SenderID of the sender.
* @param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
getDefaultValuesFromSharedPreference(this);
boolean screenLocked = getDisplayStatus(this);
if (getNotificationRingtoneUri.equals("Default ringtone"))
{
// define sound URI, the sound to be played when there's a notification
notificationSoundURI = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
}else {
notificationSoundURI = Uri.parse(getNotificationRingtoneUri);
}
sendNotification(message);
}
/**
* Create and show a simple notification containing the received GCM message.
*
* @param message GCM message received.
*/
private void sendNotification(String message) {
Intent intent = new Intent(this, HomeScreenActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (message.contains("Opinion Request")){
intent.putExtra("request",true);
}else if (message.contains("Opinion response")){
intent.putExtra("response",true);
}
intent.putExtra("true","Excell");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Notification notification;
notification = new Notification.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("HowzthisBuddy")
.setContentIntent(pendingIntent)
.setSound(notificationSoundURI)
.setContentText(message)
.setPriority(Notification.PRIORITY_HIGH).build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//manager.notify(R.string.app_name, notification);
manager.notify(0, notification);
{
// Wake Android Device when notification received
PowerManager pm = (PowerManager) getApplicationContext()
.getSystemService(Context.POWER_SERVICE);
final PowerManager.WakeLock mWakelock = pm.newWakeLock(
PowerManager.FULL_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH");
mWakelock.acquire();
// Timer before putting Android Device to sleep mode.
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
mWakelock.release();
}
};
timer.schedule(task, 5000);
}
}
private void getDefaultValuesFromSharedPreference(Context context) {
AppSharedPreference sharedPreferenceHelper = new AppSharedPreference();
isConversationTonesEnabled = sharedPreferenceHelper.getStoredConversationTones(context);
getNotificationRingtoneUri = sharedPreferenceHelper.getStoreNotificationRingtoneURI(context);
vibrateType = sharedPreferenceHelper.getStoreNotificationSoundposition(context);
popUpType = sharedPreferenceHelper.getStoreNotificationPopUpposition(context);
Log.d("Nme", "Na");
}
private boolean getDisplayStatus(Context context) {
boolean isLocked = false;
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( myKM.inKeyguardRestrictedInputMode()) {
isLocked = true;
} else {
isLocked = false;
}
return isLocked;
}
}
|
UTF-8
|
Java
| 5,769 |
java
|
MyGcmListenerService.java
|
Java
|
[] | null |
[] |
package com.svs.hztb.PushNotifications;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.support.v4.app.NotificationCompat;
import com.google.android.gms.gcm.GcmListenerService;
import com.svs.hztb.Activities.HomeScreenActivity;
import com.svs.hztb.Activities.PopupViewActivity;
import com.svs.hztb.Activities.ProfileActivity;
import com.svs.hztb.Database.AppSharedPreference;
import com.svs.hztb.R;
import java.util.Timer;
import java.util.TimerTask;
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
private final int VIBRATE_OFF = 0;
private final int VIBRATE_DEFAULT = 1;
private final int VIBRATE_SHORT = 2;
private final int POPUP_OFF = 0;
private final int POPUP_ON_WHEN_SCREEN_ON = 1;
private final int POPUP_ON_WHEN_SCREEN_OFF = 2;
private boolean isConversationTonesEnabled;
private String getNotificationRingtoneUri;
private int vibrateType;
private int popUpType;
private String message;
private Uri notificationSoundURI;
private boolean noVibrate;
private long[] vibrateMode;
private long[] vibrateLong = new long[] { 1000, 1000, 1000, 1000, 1000,1000,1000 };
private long[] vibrateShort = new long[] { 1000, 1000};
private long[] vibrateDefault = new long[] { 1000, 1000, 1000, 1000 };
/**
* Called when message is received.
*
* @param from SenderID of the sender.
* @param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
getDefaultValuesFromSharedPreference(this);
boolean screenLocked = getDisplayStatus(this);
if (getNotificationRingtoneUri.equals("Default ringtone"))
{
// define sound URI, the sound to be played when there's a notification
notificationSoundURI = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
}else {
notificationSoundURI = Uri.parse(getNotificationRingtoneUri);
}
sendNotification(message);
}
/**
* Create and show a simple notification containing the received GCM message.
*
* @param message GCM message received.
*/
private void sendNotification(String message) {
Intent intent = new Intent(this, HomeScreenActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (message.contains("Opinion Request")){
intent.putExtra("request",true);
}else if (message.contains("Opinion response")){
intent.putExtra("response",true);
}
intent.putExtra("true","Excell");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Notification notification;
notification = new Notification.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("HowzthisBuddy")
.setContentIntent(pendingIntent)
.setSound(notificationSoundURI)
.setContentText(message)
.setPriority(Notification.PRIORITY_HIGH).build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//manager.notify(R.string.app_name, notification);
manager.notify(0, notification);
{
// Wake Android Device when notification received
PowerManager pm = (PowerManager) getApplicationContext()
.getSystemService(Context.POWER_SERVICE);
final PowerManager.WakeLock mWakelock = pm.newWakeLock(
PowerManager.FULL_WAKE_LOCK
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH");
mWakelock.acquire();
// Timer before putting Android Device to sleep mode.
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
mWakelock.release();
}
};
timer.schedule(task, 5000);
}
}
private void getDefaultValuesFromSharedPreference(Context context) {
AppSharedPreference sharedPreferenceHelper = new AppSharedPreference();
isConversationTonesEnabled = sharedPreferenceHelper.getStoredConversationTones(context);
getNotificationRingtoneUri = sharedPreferenceHelper.getStoreNotificationRingtoneURI(context);
vibrateType = sharedPreferenceHelper.getStoreNotificationSoundposition(context);
popUpType = sharedPreferenceHelper.getStoreNotificationPopUpposition(context);
Log.d("Nme", "Na");
}
private boolean getDisplayStatus(Context context) {
boolean isLocked = false;
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( myKM.inKeyguardRestrictedInputMode()) {
isLocked = true;
} else {
isLocked = false;
}
return isLocked;
}
}
| 5,769 | 0.6658 | 0.654533 | 149 | 37.724831 | 26.254526 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.704698 | false | false |
14
|
1a8039c5d9b7cb0ea0e24b0ef46c0eb47154f23f
| 23,106,924,063,212 |
6afcdda7db621754c30923497cca14143e5ec571
|
/src/main/java/simulator/actors/messages/DefaultMessage.java
|
fea63a93b16c1362fa2e45eaaf6d5f966afe23ba
|
[] |
no_license
|
constantin-ungureanu-github/simulator-fsm
|
https://github.com/constantin-ungureanu-github/simulator-fsm
|
91f28a733a67c75320d52046ca5d6d123ce8bfc9
|
0b0750499d76678298e0c21708175080aec4f38c
|
refs/heads/master
| 2020-05-21T04:22:27.989000 | 2017-05-14T22:50:28 | 2017-05-14T22:50:28 | 45,504,302 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package simulator.actors.messages;
import simulator.actors.interfaces.Message;
public class DefaultMessage implements Message {
}
|
UTF-8
|
Java
| 132 |
java
|
DefaultMessage.java
|
Java
|
[] | null |
[] |
package simulator.actors.messages;
import simulator.actors.interfaces.Message;
public class DefaultMessage implements Message {
}
| 132 | 0.833333 | 0.833333 | 6 | 21 | 21.071308 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
14
|
e8ad3f9ff3e4e417703d15cafb134095e0467d12
| 33,956,011,444,750 |
0ad1413f7e837771d21950183094abbf980c106d
|
/src/cn/bupt/interviewGolden/InsertCircleList.java
|
d18ae097617f7f825469d07bd49eb3c00bd40a57
|
[] |
no_license
|
lichong6232/InterviewGolden
|
https://github.com/lichong6232/InterviewGolden
|
8584181ea1e8fff709f50a6af6b4f97ec7d227b3
|
da92e16ac59d7e394228e8516f6a2a7a04d86a89
|
refs/heads/master
| 2021-04-19T02:48:46.071000 | 2017-07-02T16:36:16 | 2017-07-02T16:36:16 | 94,597,219 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.bupt.interviewGolden;
public class InsertCircleList {
public static void main(String[] args) {
InsertCircleList insertCircleList=new InsertCircleList();
int A[]={1,3,4,5,7};
int nxt[]={1,2,3,4,0};
ListNode root=insertCircleList.insert(A, nxt, 2);
insertCircleList.outPut(root);
}
public void outPut(ListNode root){
System.out.println(root.val);
ListNode curr=root.next;
while(curr!=root){
System.out.println(curr.val);
curr=curr.next;
}
}
public ListNode insert(int[] A, int[] nxt, int val) {
// write code here
ListNode head=new ListNode(A[0]);
ListNode curr=head;
for(int i=0;i<nxt.length-1;i++){
ListNode node=new ListNode(A[nxt[i]]);
curr.next=node;
curr=node;
}
curr.next=head;
ListNode slow=head;
ListNode fast=head.next;
ListNode node=new ListNode(val);
while(fast!=head){
if(val>=slow.val&&val<=fast.val){
slow.next=node;
node.next=fast;
return head;
}
slow=slow.next;
fast=fast.next;
}
fast.next=node;
node.next=head;
if(val<=slow.val)
return node;
return head;
}
}
|
UTF-8
|
Java
| 1,117 |
java
|
InsertCircleList.java
|
Java
|
[] | null |
[] |
package cn.bupt.interviewGolden;
public class InsertCircleList {
public static void main(String[] args) {
InsertCircleList insertCircleList=new InsertCircleList();
int A[]={1,3,4,5,7};
int nxt[]={1,2,3,4,0};
ListNode root=insertCircleList.insert(A, nxt, 2);
insertCircleList.outPut(root);
}
public void outPut(ListNode root){
System.out.println(root.val);
ListNode curr=root.next;
while(curr!=root){
System.out.println(curr.val);
curr=curr.next;
}
}
public ListNode insert(int[] A, int[] nxt, int val) {
// write code here
ListNode head=new ListNode(A[0]);
ListNode curr=head;
for(int i=0;i<nxt.length-1;i++){
ListNode node=new ListNode(A[nxt[i]]);
curr.next=node;
curr=node;
}
curr.next=head;
ListNode slow=head;
ListNode fast=head.next;
ListNode node=new ListNode(val);
while(fast!=head){
if(val>=slow.val&&val<=fast.val){
slow.next=node;
node.next=fast;
return head;
}
slow=slow.next;
fast=fast.next;
}
fast.next=node;
node.next=head;
if(val<=slow.val)
return node;
return head;
}
}
| 1,117 | 0.645479 | 0.632945 | 57 | 18.596491 | 14.90774 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.631579 | false | false |
14
|
ae38cd97a8fc997ce81d79ff6147a5aabb4d8d17
| 25,769,803,821,673 |
f1b5c6069b2c8fe76c52347eaa4ab97c6bd3042d
|
/src/main/java/com/zjj/coursestudy/service/Impl/KeyWordServiceImpl.java
|
c4a1b5bd94b9be1566d958abda211953311137bb
|
[] |
no_license
|
oriwisps/CourseStudySystem
|
https://github.com/oriwisps/CourseStudySystem
|
ff08fdf0989db2784fbfc1b478484f6e4c5f01bd
|
38e6bf5528d955cb373204073d7f3b16ac56e3eb
|
refs/heads/master
| 2023-06-18T18:05:11.269000 | 2021-07-16T03:21:45 | 2021-07-16T03:21:45 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.zjj.coursestudy.service.Impl;
import com.zjj.coursestudy.dao.ExerciseDao;
import com.zjj.coursestudy.dao.KeyWordDao;
import com.zjj.coursestudy.entity.Exercise;
import com.zjj.coursestudy.entity.KeyWord;
import com.zjj.coursestudy.service.KeyWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class KeyWordServiceImpl implements KeyWordService {
@Autowired
private KeyWordDao keyWordDao;
@Autowired
private ExerciseDao exerciseDao;
public KeyWord getKeyWordByID(int ID){
return keyWordDao.findKeyWordByID(ID);
}
public KeyWord saveKeyWord(KeyWord keyWord){
return keyWordDao.save(keyWord);
}
public boolean deleteKeyWord(int keyWordID){
keyWordDao.deleteById(keyWordID);
if(keyWordDao.existsById(keyWordID)){
return false;
}
return true;
}
public List<Exercise> autoGetExercises(String keyWord, Integer number){
return exerciseDao.autoGetExercises(keyWord, number);
}
}
|
UTF-8
|
Java
| 1,118 |
java
|
KeyWordServiceImpl.java
|
Java
|
[] | null |
[] |
package com.zjj.coursestudy.service.Impl;
import com.zjj.coursestudy.dao.ExerciseDao;
import com.zjj.coursestudy.dao.KeyWordDao;
import com.zjj.coursestudy.entity.Exercise;
import com.zjj.coursestudy.entity.KeyWord;
import com.zjj.coursestudy.service.KeyWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class KeyWordServiceImpl implements KeyWordService {
@Autowired
private KeyWordDao keyWordDao;
@Autowired
private ExerciseDao exerciseDao;
public KeyWord getKeyWordByID(int ID){
return keyWordDao.findKeyWordByID(ID);
}
public KeyWord saveKeyWord(KeyWord keyWord){
return keyWordDao.save(keyWord);
}
public boolean deleteKeyWord(int keyWordID){
keyWordDao.deleteById(keyWordID);
if(keyWordDao.existsById(keyWordID)){
return false;
}
return true;
}
public List<Exercise> autoGetExercises(String keyWord, Integer number){
return exerciseDao.autoGetExercises(keyWord, number);
}
}
| 1,118 | 0.740608 | 0.740608 | 41 | 26.268293 | 22.24917 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.463415 | false | false |
14
|
a9c1d0799620cdb997dcd3cefcb154056af227de
| 12,910,671,746,911 |
515b9decc98b2bb7b54ddcc4d590b590f3aef329
|
/src/main/java/by/belstu/alchern/db/courseproject/service/FlightService.java
|
5c95c3f38c8d611a0921df36079e5f1874c0df07
|
[] |
no_license
|
alchern2412/CourseProjectDb
|
https://github.com/alchern2412/CourseProjectDb
|
12f61821589aea4ad86410cc2b9615deb9218910
|
0333b87be44b0430ce3f2ea6d130dbed3d10fcdd
|
refs/heads/master
| 2022-03-20T21:37:53.002000 | 2019-12-09T20:13:20 | 2019-12-09T20:13:20 | 225,135,945 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package by.belstu.alchern.db.courseproject.service;
import by.belstu.alchern.db.courseproject.model.impl.Flight;
import by.belstu.alchern.db.courseproject.service.exception.FlightServiceException;
import by.belstu.alchern.db.courseproject.view.dto.FlightDTO;
import java.util.List;
public interface FlightService {
List<Flight> getByPageNum(int pageNum) throws FlightServiceException;
List<Flight> getFlightsByRequest(FlightDTO flightDTO) throws FlightServiceException;
Flight create(FlightDTO flightDTO) throws FlightServiceException;
Flight get(int flightId) throws FlightServiceException;
Flight edit(Flight flight, FlightDTO flightDTO) throws FlightServiceException;
List<Flight> getAll() throws FlightServiceException;
List<Flight> getOnTheWay(String orderBy) throws FlightServiceException;
List<Flight> getDeparting() throws FlightServiceException;
}
|
UTF-8
|
Java
| 899 |
java
|
FlightService.java
|
Java
|
[] | null |
[] |
package by.belstu.alchern.db.courseproject.service;
import by.belstu.alchern.db.courseproject.model.impl.Flight;
import by.belstu.alchern.db.courseproject.service.exception.FlightServiceException;
import by.belstu.alchern.db.courseproject.view.dto.FlightDTO;
import java.util.List;
public interface FlightService {
List<Flight> getByPageNum(int pageNum) throws FlightServiceException;
List<Flight> getFlightsByRequest(FlightDTO flightDTO) throws FlightServiceException;
Flight create(FlightDTO flightDTO) throws FlightServiceException;
Flight get(int flightId) throws FlightServiceException;
Flight edit(Flight flight, FlightDTO flightDTO) throws FlightServiceException;
List<Flight> getAll() throws FlightServiceException;
List<Flight> getOnTheWay(String orderBy) throws FlightServiceException;
List<Flight> getDeparting() throws FlightServiceException;
}
| 899 | 0.814238 | 0.814238 | 25 | 34.959999 | 33.709915 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56 | false | false |
14
|
9c66881d58b477c9b26b7d1294aed4b54ad7b65d
| 15,135,464,796,508 |
a4470ad46404dc2a5ac48a5c448193f97fcac1df
|
/src/main/java/com/ti/customer/controller/CustomerController.java
|
e10e61762231de51c00848558ae8206668eb74bf
|
[] |
no_license
|
asalome01/demoservice
|
https://github.com/asalome01/demoservice
|
9059c80ed9bfea35f75a3419c20c715646a46bf6
|
553891596d69440c8f4442e765a20a94599f14b1
|
refs/heads/master
| 2020-07-28T16:14:14.278000 | 2019-09-20T03:10:20 | 2019-09-20T03:10:20 | 209,461,946 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ti.customer.controller;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ti.customer.entity.Secret;
@RestController
@RequestMapping("/uri")
public class CustomerController {
@RequestMapping(value="/loginup",produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
method = RequestMethod.GET)
public Secret getLogin() {
Secret secret = new Secret();
secret.setId(1);
secret.setSecret("121212");
return secret;
}
}
|
UTF-8
|
Java
| 670 |
java
|
CustomerController.java
|
Java
|
[] | null |
[] |
package com.ti.customer.controller;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ti.customer.entity.Secret;
@RestController
@RequestMapping("/uri")
public class CustomerController {
@RequestMapping(value="/loginup",produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
method = RequestMethod.GET)
public Secret getLogin() {
Secret secret = new Secret();
secret.setId(1);
secret.setSecret("121212");
return secret;
}
}
| 670 | 0.777612 | 0.767164 | 26 | 24.76923 | 26.804575 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.269231 | false | false |
14
|
1980fa13c5a983b0c62937631d1c45e5e2d7be96
| 738,734,422,589 |
108d2129071cd52465408b4e18a9fe0239734bf9
|
/app/src/main/java/amaz/objects/TwentyfourSeven/data/models/SocialLoginData.java
|
98afdf66b080a85a081ef89a7535c9d004413a4b
|
[] |
no_license
|
eslamhamam22/247Android
|
https://github.com/eslamhamam22/247Android
|
f1b471dc4ff6a835e7a6c3db3b7ef5dc09a70b74
|
d1cadb51506847b810454297f7e6365ff9f31347
|
refs/heads/master
| 2023-04-03T11:53:08.681000 | 2021-04-01T09:05:13 | 2021-04-01T09:05:13 | 297,026,438 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package amaz.objects.TwentyfourSeven.data.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SocialLoginData {
@SerializedName("token")
@Expose
private String token;
@SerializedName("refresh_token")
@Expose
private String refreshToken;
@SerializedName("firebase_token")
@Expose
private String firebaseToken;
@SerializedName("user")
@Expose
private User user;
@SerializedName("registeredBefore")
@Expose
private boolean registeredBefore;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public boolean isRegisteredBefore() {
return registeredBefore;
}
public void setRegisteredBefore(boolean registeredBefore) {
this.registeredBefore = registeredBefore;
}
public String getFirebaseToken() {
return firebaseToken;
}
public void setFirebaseToken(String firebaseToken) {
this.firebaseToken = firebaseToken;
}
}
|
UTF-8
|
Java
| 1,397 |
java
|
SocialLoginData.java
|
Java
|
[] | null |
[] |
package amaz.objects.TwentyfourSeven.data.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SocialLoginData {
@SerializedName("token")
@Expose
private String token;
@SerializedName("refresh_token")
@Expose
private String refreshToken;
@SerializedName("firebase_token")
@Expose
private String firebaseToken;
@SerializedName("user")
@Expose
private User user;
@SerializedName("registeredBefore")
@Expose
private boolean registeredBefore;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public boolean isRegisteredBefore() {
return registeredBefore;
}
public void setRegisteredBefore(boolean registeredBefore) {
this.registeredBefore = registeredBefore;
}
public String getFirebaseToken() {
return firebaseToken;
}
public void setFirebaseToken(String firebaseToken) {
this.firebaseToken = firebaseToken;
}
}
| 1,397 | 0.665712 | 0.665712 | 67 | 19.850746 | 18.171862 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.268657 | false | false |
14
|
0f56348e354eebaf7776a27f47e117dd09b3af39
| 22,033,182,275,658 |
1222c44a4ed7a9c746183d9fe3739c99b4db2f31
|
/src/test/java/com/vampirehemophile/ghosts/math/CoordinatesTest.java
|
53ece11b2f81f14d9644c7870dd7f4cf7b332ef8
|
[
"MIT"
] |
permissive
|
VampireHemophile/Ghosts
|
https://github.com/VampireHemophile/Ghosts
|
737aeef8c3ae6c7e4492820676c35ee34b030dd2
|
a696898ce3668dc399844776020375a8f8bacc9a
|
refs/heads/master
| 2016-08-12T10:14:58.601000 | 2016-01-12T13:59:03 | 2016-01-12T13:59:03 | 46,074,501 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.vampirehemophile.ghosts.math;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import com.vampirehemophile.ghosts.exceptions.BoardTooSmallException;
import com.vampirehemophile.ghosts.exceptions.InvalidCoordinatesException;
import com.vampirehemophile.ghosts.exceptions.OutOfBoardCoordinatesException;
/**
* Unit test for @{link com.vampirehemophile.ghosts.math.Coordinates} class.
*
* All the constructors are tested to ensure coordinates validity.
*/
public class CoordinatesTest {
/**
* testCoordinatesConstructorWorld1.
*/
@Test
public void testCoordinatesConstructorWorld1() {
Coordinates c = new Coordinates("a1", 6);
assertEquals("a", c.x());
assertEquals(1, c.y());
try {
new Coordinates("az~'78", 6);
} catch (InvalidCoordinatesException expected) {}
try {
new Coordinates("b1", 6);
} catch (OutOfBoardCoordinatesException expected) {}
try {
new Coordinates("a2", 6);
} catch (OutOfBoardCoordinatesException expected) {}
}
/**
* testCoordinatesConstructorWorld2.
*/
@Test
public void testCoordinatesConstructorWorld2() {
Coordinates c = new Coordinates("a", 1, 6);
assertEquals("a", c.x());
assertEquals(1, c.y());
try {
new Coordinates("7", 1, 6);
} catch (InvalidCoordinatesException expected) {}
try {
new Coordinates("b", 1, 6);
} catch (OutOfBoardCoordinatesException expected) {}
try {
new Coordinates("a", 2, 6);
} catch (OutOfBoardCoordinatesException expected) {}
}
/**
* testGenXWorld.
*/
@Test
public void testGenXWorld() {
assertEquals("a", (new Coordinates(0, 0, 6)).x());
assertEquals("b", (new Coordinates(1, 1, 6)).x());
assertEquals("c", (new Coordinates(2, 2, 6)).x());
assertEquals("aa", (new Coordinates(26, 26, 27)).x());
}
/**
* testGenYWorld.
*/
@Test
public void testGenYWorld() {
assertEquals(1, (new Coordinates(0, 0, 6)).y());
assertEquals(2, (new Coordinates(1, 1, 6)).y());
assertEquals(3, (new Coordinates(2, 2, 6)).y());
assertEquals(27, (new Coordinates(26, 26, 27)).y());
}
/**
* testGenXMatrix.
*/
@Test
public void testGenXMatrix() {
assertEquals(0, (new Coordinates("a1", 6)).xMatrix());
assertEquals(1, (new Coordinates("b2", 6)).xMatrix());
assertEquals(2, (new Coordinates("c3", 6)).xMatrix());
assertEquals(26, (new Coordinates("aa27", 27)).xMatrix());
}
/**
* testGenYMatrix.
*/
@Test
public void testGenYMatrix() {
assertEquals(0, (new Coordinates("a1", 6)).yMatrix());
assertEquals(1, (new Coordinates("b2", 6)).yMatrix());
assertEquals(2, (new Coordinates("c3", 6)).yMatrix());
assertEquals(26, (new Coordinates("aa27", 27)).yMatrix());
}
/**
* testEquality.
*
* @param c1 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
* @param c2 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
*/
public void testEquality(Coordinates c1, Coordinates c2) {
assertEquals(c1.x(), c2.x());
assertEquals(c1.y(), c2.y());
assertEquals(c1.xMatrix(), c2.xMatrix());
assertEquals(c1.yMatrix(), c2.yMatrix());
assertTrue(c1.equals(c2));
assertTrue(c2.equals(c1));
}
/**
* testNonEquality.
*
* @param c1 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
* @param c2 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
*/
public void testNonEquality(Coordinates c1, Coordinates c2) {
assertTrue(!c1.x().equals(c2.x()) || c1.y() != c2.y());
assertTrue(c1.xMatrix() != c2.xMatrix() || c1.yMatrix() != c2.yMatrix());
assertFalse(c1.equals(c2));
assertFalse(c2.equals(c1));
}
/**
* testEquals.
*/
@Ignore @Test
public void testEquals() {
Coordinates[] equalCoords = {
new Coordinates(0, 0, 6),
new Coordinates(0, 0, 6),
new Coordinates("a1", 6),
new Coordinates("a1", 6),
new Coordinates("a", 1, 6),
new Coordinates("a", 1, 6)
};
for (int i = 0; i < equalCoords.length; i++) {
for (int j = i; j < equalCoords.length; j++) {
assertTrue(equalCoords[i].equals(equalCoords[j]));
testEquality(equalCoords[i], equalCoords[j]);
}
}
Coordinates[] notEqualCoords = {
new Coordinates(2, 0, 6),
new Coordinates(0, 1, 6),
new Coordinates("b2", 6),
new Coordinates("c2", 6),
new Coordinates("a", 3, 6),
new Coordinates("b", 3, 6)
};
for (int i = 0; i < notEqualCoords.length; i++) {
for (int j = i + 1; j < notEqualCoords.length; j++) {
assertFalse(notEqualCoords[i].equals(notEqualCoords[j]));
testNonEquality(notEqualCoords[i], notEqualCoords[j]);
}
}
}
/**
* testCopyConstructor.
*/
@Test
public void testCopyConstructor() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
assertTrue(c1.equals(c2));
testEquality(c1, c2);
}
/*
@Ignore @Test
public void testMoveNorth() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(0, 1, 6);
c2.moveNorth();
testEquality(c1, c2);
c3.moveNorth();
testEquality(c1, c3);
}
@Ignore @Test
public void testMoveSouth() {
Coordinates c1 = new Coordinates(0, 5, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(0, 4, 6);
c2.moveSouth();
assertTrue(c1.equals(c2));
c3.moveSouth();
assertTrue(c1.equals(c3));
}
@Ignore @Test
public void testMoveEast() {
Coordinates c1 = new Coordinates(5, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(4, 0, 6);
c2.moveEast();
assertEquals(c1.x(), c2.x());
assertTrue(c1.equals(c2));
c3.moveEast();
assertEquals(c1.x(), c3.x());
assertTrue(c1.equals(c3));
}
@Ignore @Test
public void testMoveWest() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(1, 0, 6);
c2.moveWest();
assertEquals(c1.x(), c2.x());
assertTrue(c1.equals(c2));
c3.moveWest();
assertEquals(c1.x(), c3.x());
assertTrue(c1.equals(c3));
}
*/
/**
* testNorth.
*/
@Test
public void testNorth() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(0, 1, 6);
assertNull(c1.north());
assertNotNull(c2.north());
assertTrue(c1.equals(c2.north()));
}
/**
* testSouth.
*/
@Test
public void testSouth() {
Coordinates c1 = new Coordinates(0, 5, 6);
Coordinates c2 = new Coordinates(0, 4, 6);
assertNull(c1.south());
assertNotNull(c2.south());
assertTrue(c1.equals(c2.south()));
}
/**
* testEast.
*/
@Test
public void testEast() {
Coordinates c1 = new Coordinates(5, 0, 6);
Coordinates c2 = new Coordinates(4, 0, 6);
assertNull(c1.east());
assertNotNull(c2.east());
assertTrue(c1.equals(c2.east()));
}
/**
* testWest.
*/
@Test
public void testWest() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(1, 0, 6);
assertNull(c1.west());
assertNotNull(c2.west());
assertTrue(c1.equals(c2.west()));
}
}
|
UTF-8
|
Java
| 7,600 |
java
|
CoordinatesTest.java
|
Java
|
[] | null |
[] |
package com.vampirehemophile.ghosts.math;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import com.vampirehemophile.ghosts.exceptions.BoardTooSmallException;
import com.vampirehemophile.ghosts.exceptions.InvalidCoordinatesException;
import com.vampirehemophile.ghosts.exceptions.OutOfBoardCoordinatesException;
/**
* Unit test for @{link com.vampirehemophile.ghosts.math.Coordinates} class.
*
* All the constructors are tested to ensure coordinates validity.
*/
public class CoordinatesTest {
/**
* testCoordinatesConstructorWorld1.
*/
@Test
public void testCoordinatesConstructorWorld1() {
Coordinates c = new Coordinates("a1", 6);
assertEquals("a", c.x());
assertEquals(1, c.y());
try {
new Coordinates("az~'78", 6);
} catch (InvalidCoordinatesException expected) {}
try {
new Coordinates("b1", 6);
} catch (OutOfBoardCoordinatesException expected) {}
try {
new Coordinates("a2", 6);
} catch (OutOfBoardCoordinatesException expected) {}
}
/**
* testCoordinatesConstructorWorld2.
*/
@Test
public void testCoordinatesConstructorWorld2() {
Coordinates c = new Coordinates("a", 1, 6);
assertEquals("a", c.x());
assertEquals(1, c.y());
try {
new Coordinates("7", 1, 6);
} catch (InvalidCoordinatesException expected) {}
try {
new Coordinates("b", 1, 6);
} catch (OutOfBoardCoordinatesException expected) {}
try {
new Coordinates("a", 2, 6);
} catch (OutOfBoardCoordinatesException expected) {}
}
/**
* testGenXWorld.
*/
@Test
public void testGenXWorld() {
assertEquals("a", (new Coordinates(0, 0, 6)).x());
assertEquals("b", (new Coordinates(1, 1, 6)).x());
assertEquals("c", (new Coordinates(2, 2, 6)).x());
assertEquals("aa", (new Coordinates(26, 26, 27)).x());
}
/**
* testGenYWorld.
*/
@Test
public void testGenYWorld() {
assertEquals(1, (new Coordinates(0, 0, 6)).y());
assertEquals(2, (new Coordinates(1, 1, 6)).y());
assertEquals(3, (new Coordinates(2, 2, 6)).y());
assertEquals(27, (new Coordinates(26, 26, 27)).y());
}
/**
* testGenXMatrix.
*/
@Test
public void testGenXMatrix() {
assertEquals(0, (new Coordinates("a1", 6)).xMatrix());
assertEquals(1, (new Coordinates("b2", 6)).xMatrix());
assertEquals(2, (new Coordinates("c3", 6)).xMatrix());
assertEquals(26, (new Coordinates("aa27", 27)).xMatrix());
}
/**
* testGenYMatrix.
*/
@Test
public void testGenYMatrix() {
assertEquals(0, (new Coordinates("a1", 6)).yMatrix());
assertEquals(1, (new Coordinates("b2", 6)).yMatrix());
assertEquals(2, (new Coordinates("c3", 6)).yMatrix());
assertEquals(26, (new Coordinates("aa27", 27)).yMatrix());
}
/**
* testEquality.
*
* @param c1 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
* @param c2 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
*/
public void testEquality(Coordinates c1, Coordinates c2) {
assertEquals(c1.x(), c2.x());
assertEquals(c1.y(), c2.y());
assertEquals(c1.xMatrix(), c2.xMatrix());
assertEquals(c1.yMatrix(), c2.yMatrix());
assertTrue(c1.equals(c2));
assertTrue(c2.equals(c1));
}
/**
* testNonEquality.
*
* @param c1 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
* @param c2 a {@link com.vampirehemophile.ghosts.math.Coordinates} object.
*/
public void testNonEquality(Coordinates c1, Coordinates c2) {
assertTrue(!c1.x().equals(c2.x()) || c1.y() != c2.y());
assertTrue(c1.xMatrix() != c2.xMatrix() || c1.yMatrix() != c2.yMatrix());
assertFalse(c1.equals(c2));
assertFalse(c2.equals(c1));
}
/**
* testEquals.
*/
@Ignore @Test
public void testEquals() {
Coordinates[] equalCoords = {
new Coordinates(0, 0, 6),
new Coordinates(0, 0, 6),
new Coordinates("a1", 6),
new Coordinates("a1", 6),
new Coordinates("a", 1, 6),
new Coordinates("a", 1, 6)
};
for (int i = 0; i < equalCoords.length; i++) {
for (int j = i; j < equalCoords.length; j++) {
assertTrue(equalCoords[i].equals(equalCoords[j]));
testEquality(equalCoords[i], equalCoords[j]);
}
}
Coordinates[] notEqualCoords = {
new Coordinates(2, 0, 6),
new Coordinates(0, 1, 6),
new Coordinates("b2", 6),
new Coordinates("c2", 6),
new Coordinates("a", 3, 6),
new Coordinates("b", 3, 6)
};
for (int i = 0; i < notEqualCoords.length; i++) {
for (int j = i + 1; j < notEqualCoords.length; j++) {
assertFalse(notEqualCoords[i].equals(notEqualCoords[j]));
testNonEquality(notEqualCoords[i], notEqualCoords[j]);
}
}
}
/**
* testCopyConstructor.
*/
@Test
public void testCopyConstructor() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
assertTrue(c1.equals(c2));
testEquality(c1, c2);
}
/*
@Ignore @Test
public void testMoveNorth() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(0, 1, 6);
c2.moveNorth();
testEquality(c1, c2);
c3.moveNorth();
testEquality(c1, c3);
}
@Ignore @Test
public void testMoveSouth() {
Coordinates c1 = new Coordinates(0, 5, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(0, 4, 6);
c2.moveSouth();
assertTrue(c1.equals(c2));
c3.moveSouth();
assertTrue(c1.equals(c3));
}
@Ignore @Test
public void testMoveEast() {
Coordinates c1 = new Coordinates(5, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(4, 0, 6);
c2.moveEast();
assertEquals(c1.x(), c2.x());
assertTrue(c1.equals(c2));
c3.moveEast();
assertEquals(c1.x(), c3.x());
assertTrue(c1.equals(c3));
}
@Ignore @Test
public void testMoveWest() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(c1);
Coordinates c3 = new Coordinates(1, 0, 6);
c2.moveWest();
assertEquals(c1.x(), c2.x());
assertTrue(c1.equals(c2));
c3.moveWest();
assertEquals(c1.x(), c3.x());
assertTrue(c1.equals(c3));
}
*/
/**
* testNorth.
*/
@Test
public void testNorth() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(0, 1, 6);
assertNull(c1.north());
assertNotNull(c2.north());
assertTrue(c1.equals(c2.north()));
}
/**
* testSouth.
*/
@Test
public void testSouth() {
Coordinates c1 = new Coordinates(0, 5, 6);
Coordinates c2 = new Coordinates(0, 4, 6);
assertNull(c1.south());
assertNotNull(c2.south());
assertTrue(c1.equals(c2.south()));
}
/**
* testEast.
*/
@Test
public void testEast() {
Coordinates c1 = new Coordinates(5, 0, 6);
Coordinates c2 = new Coordinates(4, 0, 6);
assertNull(c1.east());
assertNotNull(c2.east());
assertTrue(c1.equals(c2.east()));
}
/**
* testWest.
*/
@Test
public void testWest() {
Coordinates c1 = new Coordinates(0, 0, 6);
Coordinates c2 = new Coordinates(1, 0, 6);
assertNull(c1.west());
assertNotNull(c2.west());
assertTrue(c1.equals(c2.west()));
}
}
| 7,600 | 0.624474 | 0.587368 | 282 | 25.950356 | 21.0438 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.91844 | false | false |
14
|
24cdeadae1a4b221e331833a599a90d7c0ec36a4
| 22,033,182,276,059 |
15eee6d3be739d98d20c6668c5850bf07c09524c
|
/goland/src/main/java/cn/xiaoheiban/antlr4/ApiLexer.java
|
6316ee12d0a6bb2b3ee130a6afbbdf85369cebb1
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
REN-I/goctl-plugins
|
https://github.com/REN-I/goctl-plugins
|
9da289b35ae3c34e547c6600acc162f3ab16911d
|
80d6f1271ff78f1d9916efbe8b63a4624072393a
|
refs/heads/main
| 2023-01-01T05:20:15.634000 | 2020-10-18T13:35:26 | 2020-10-18T13:35:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Generated from /Users/anqiansong/workspace/java/go-zero-idea-plugin/src/main/java/cn/xiaoheiban/antlr4/ApiLexer.g4 by ANTLR 4.8
package cn.xiaoheiban.antlr4;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ApiLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
INFO=1, MAP=2, STRUCT=3, INTERFACE=4, TYPE=5, ATSERVER=6, ATDOC=7, ATHANDLER=8,
SERVICE=9, RETURNS=10, IMPORT=11, KEY=12, TITLE=13, DESC=14, AUTHOR=15,
EMAIL=16, VERSION=17, GROUP=18, JWT=19, SUMMARY=20, HANDLER=21, HTTPMETHOD=22,
GET=23, HEAD=24, POST=25, PUT=26, PATCH=27, DELETE=28, CONNECT=29, OPTIONS=30,
TRACE=31, GOTYPE=32, BOOL=33, UINT8=34, UINT16=35, UINT32=36, UINT64=37,
INT8=38, INT16=39, INT32=40, INT64=41, FLOAT32=42, FLOAT64=43, COMPLEX64=44,
COMPLEX128=45, STRING=46, INT=47, UINT=48, UINTPTR=49, BYTE=50, RUNE=51,
PATH=52, LPAREN=53, RPAREN=54, LBRACE=55, RBRACE=56, LBRACK=57, RBRACK=58,
DOT=59, SMICOLON=60, COMMA=61, STAR=62, BAR=63, ASSIGN=64, COLON=65, NUMBER=66,
HOSTVALUE=67, IDENT=68, WS=69, VALUE=70, RAW_STRING=71, COMMENT=72, ERRCHAR=73;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
public static String[] modeNames = {
"DEFAULT_MODE"
};
private static String[] makeRuleNames() {
return new String[] {
"INFO", "MAP", "STRUCT", "INTERFACE", "TYPE", "ATSERVER", "ATDOC", "ATHANDLER",
"SERVICE", "RETURNS", "IMPORT", "KEY", "TITLE", "DESC", "AUTHOR", "EMAIL",
"VERSION", "GROUP", "JWT", "SUMMARY", "HANDLER", "HTTPMETHOD", "GET",
"HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS", "TRACE",
"GOTYPE", "BOOL", "UINT8", "UINT16", "UINT32", "UINT64", "INT8", "INT16",
"INT32", "INT64", "FLOAT32", "FLOAT64", "COMPLEX64", "COMPLEX128", "STRING",
"INT", "UINT", "UINTPTR", "BYTE", "RUNE", "PATH", "LPAREN", "RPAREN",
"LBRACE", "RBRACE", "LBRACK", "RBRACK", "DOT", "SMICOLON", "COMMA", "STAR",
"BAR", "ASSIGN", "COLON", "NUMBER", "HOSTVALUE", "IDENT", "WS", "VALUE",
"RAW_STRING", "COMMENT", "COMMENT_FLAG", "RAW_STRING_F", "STRING_F",
"DIGIT", "UNDERSCORE", "ALPHA", "HEX_DIGIT", "OCT_DIGIT", "ESC_SEQ",
"OCTAL_ESC", "UNICODE_ESC", "ERRCHAR"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'info'", "'map'", "'struct'", "'interface'", "'type'", "'@server'",
"'@doc'", "'@handler'", "'service'", "'returns'", "'import'", null, "'title'",
"'desc'", "'author'", "'email'", "'version'", "'group'", "'jwt'", "'summary'",
"'handler'", null, "'get'", "'head'", "'post'", "'put'", "'patch'", "'delete'",
"'connect'", "'options'", "'trace'", null, "'bool'", "'uint8'", "'uint16'",
"'uint32'", "'uint64'", "'int8'", "'int16'", "'int32'", "'int64'", "'float32'",
"'float64'", "'complex64'", "'complex128'", "'string'", "'int'", "'uint'",
"'uintptr'", "'byte'", "'rune'", null, "'('", "')'", "'{'", "'}'", "'['",
"']'", "'.'", "';'", "','", "'*'", "'-'", "'='", "':'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, "INFO", "MAP", "STRUCT", "INTERFACE", "TYPE", "ATSERVER", "ATDOC",
"ATHANDLER", "SERVICE", "RETURNS", "IMPORT", "KEY", "TITLE", "DESC",
"AUTHOR", "EMAIL", "VERSION", "GROUP", "JWT", "SUMMARY", "HANDLER", "HTTPMETHOD",
"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS",
"TRACE", "GOTYPE", "BOOL", "UINT8", "UINT16", "UINT32", "UINT64", "INT8",
"INT16", "INT32", "INT64", "FLOAT32", "FLOAT64", "COMPLEX64", "COMPLEX128",
"STRING", "INT", "UINT", "UINTPTR", "BYTE", "RUNE", "PATH", "LPAREN",
"RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", "DOT", "SMICOLON",
"COMMA", "STAR", "BAR", "ASSIGN", "COLON", "NUMBER", "HOSTVALUE", "IDENT",
"WS", "VALUE", "RAW_STRING", "COMMENT", "ERRCHAR"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
public ApiLexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@Override
public String getGrammarFileName() { return "ApiLexer.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public String[] getChannelNames() { return channelNames; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2K\u02b4\b\1\4\2\t"+
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+
"\4U\tU\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4"+
"\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3"+
"\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t"+
"\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13"+
"\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+
"\3\r\5\r\u0101\n\r\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3"+
"\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3"+
"\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3"+
"\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3"+
"\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3"+
"\27\5\27\u0146\n\27\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\32"+
"\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34"+
"\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36"+
"\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \3 \3!\3!"+
"\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\5!\u0191\n!\3\""+
"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3"+
"%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3)"+
"\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3+\3+\3+\3,\3,\3,\3,"+
"\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3.\3.\3."+
"\3.\3.\3/\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3"+
"\61\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3"+
"\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\5\65\u0215\n\65\3\65\6\65"+
"\u0218\n\65\r\65\16\65\u0219\3\66\3\66\3\67\3\67\38\38\39\39\3:\3:\3;"+
"\3;\3<\3<\3=\3=\3>\3>\3?\3?\3@\3@\3A\3A\3B\3B\3C\6C\u0237\nC\rC\16C\u0238"+
"\3D\6D\u023c\nD\rD\16D\u023d\3D\3D\6D\u0242\nD\rD\16D\u0243\3D\3D\6D\u0248"+
"\nD\rD\16D\u0249\3D\3D\6D\u024e\nD\rD\16D\u024f\3E\3E\5E\u0254\nE\3E\3"+
"E\3E\3E\7E\u025a\nE\fE\16E\u025d\13E\3F\6F\u0260\nF\rF\16F\u0261\3F\3"+
"F\3G\3G\7G\u0268\nG\fG\16G\u026b\13G\3G\3G\3H\3H\7H\u0271\nH\fH\16H\u0274"+
"\13H\3H\3H\3I\3I\7I\u027a\nI\fI\16I\u027d\13I\3I\3I\3J\3J\3J\3K\3K\3L"+
"\3L\3M\3M\3N\3N\3O\3O\3P\3P\3Q\3Q\3R\3R\3R\3R\3R\3R\3R\3R\3R\5R\u029b"+
"\nR\3S\3S\3S\3S\3S\3S\3S\3S\3S\3S\3S\5S\u02a8\nS\3T\3T\3T\3T\3T\3T\3T"+
"\3U\3U\3U\3U\2\2V\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31"+
"\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65"+
"\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64"+
"g\65i\66k\67m8o9q:s;u<w=y>{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089"+
"F\u008bG\u008dH\u008fI\u0091J\u0093\2\u0095\2\u0097\2\u0099\2\u009b\2"+
"\u009d\2\u009f\2\u00a1\2\u00a3\2\u00a5\2\u00a7\2\u00a9K\3\2\r\5\2\13\f"+
"\17\17\"\"\5\2\f\f\17\17<<\5\2\f\f\17\17bb\3\2\f\f\3\2\62;\4\2C\\c|\5"+
"\2\62;CHch\3\2\629\f\2$$))AA^^cdhhppttvvxx\4\2ZZzz\3\2\62\65\2\u02e1\2"+
"\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2"+
"\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2"+
"\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2"+
"\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2"+
"\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2"+
"\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2"+
"\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U"+
"\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2"+
"\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2"+
"\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{"+
"\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085"+
"\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2"+
"\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u00a9\3\2\2\2\3\u00ab\3\2\2\2\5\u00b0"+
"\3\2\2\2\7\u00b4\3\2\2\2\t\u00bb\3\2\2\2\13\u00c5\3\2\2\2\r\u00ca\3\2"+
"\2\2\17\u00d2\3\2\2\2\21\u00d7\3\2\2\2\23\u00e0\3\2\2\2\25\u00e8\3\2\2"+
"\2\27\u00f0\3\2\2\2\31\u0100\3\2\2\2\33\u0102\3\2\2\2\35\u0108\3\2\2\2"+
"\37\u010d\3\2\2\2!\u0114\3\2\2\2#\u011a\3\2\2\2%\u0122\3\2\2\2\'\u0128"+
"\3\2\2\2)\u012c\3\2\2\2+\u0134\3\2\2\2-\u0145\3\2\2\2/\u0147\3\2\2\2\61"+
"\u014b\3\2\2\2\63\u0150\3\2\2\2\65\u0155\3\2\2\2\67\u0159\3\2\2\29\u015f"+
"\3\2\2\2;\u0166\3\2\2\2=\u016e\3\2\2\2?\u0176\3\2\2\2A\u0190\3\2\2\2C"+
"\u0192\3\2\2\2E\u0197\3\2\2\2G\u019d\3\2\2\2I\u01a4\3\2\2\2K\u01ab\3\2"+
"\2\2M\u01b2\3\2\2\2O\u01b7\3\2\2\2Q\u01bd\3\2\2\2S\u01c3\3\2\2\2U\u01c9"+
"\3\2\2\2W\u01d1\3\2\2\2Y\u01d9\3\2\2\2[\u01e3\3\2\2\2]\u01ee\3\2\2\2_"+
"\u01f5\3\2\2\2a\u01f9\3\2\2\2c\u01fe\3\2\2\2e\u0206\3\2\2\2g\u020b\3\2"+
"\2\2i\u0217\3\2\2\2k\u021b\3\2\2\2m\u021d\3\2\2\2o\u021f\3\2\2\2q\u0221"+
"\3\2\2\2s\u0223\3\2\2\2u\u0225\3\2\2\2w\u0227\3\2\2\2y\u0229\3\2\2\2{"+
"\u022b\3\2\2\2}\u022d\3\2\2\2\177\u022f\3\2\2\2\u0081\u0231\3\2\2\2\u0083"+
"\u0233\3\2\2\2\u0085\u0236\3\2\2\2\u0087\u023b\3\2\2\2\u0089\u0253\3\2"+
"\2\2\u008b\u025f\3\2\2\2\u008d\u0265\3\2\2\2\u008f\u026e\3\2\2\2\u0091"+
"\u0277\3\2\2\2\u0093\u0280\3\2\2\2\u0095\u0283\3\2\2\2\u0097\u0285\3\2"+
"\2\2\u0099\u0287\3\2\2\2\u009b\u0289\3\2\2\2\u009d\u028b\3\2\2\2\u009f"+
"\u028d\3\2\2\2\u00a1\u028f\3\2\2\2\u00a3\u029a\3\2\2\2\u00a5\u02a7\3\2"+
"\2\2\u00a7\u02a9\3\2\2\2\u00a9\u02b0\3\2\2\2\u00ab\u00ac\7k\2\2\u00ac"+
"\u00ad\7p\2\2\u00ad\u00ae\7h\2\2\u00ae\u00af\7q\2\2\u00af\4\3\2\2\2\u00b0"+
"\u00b1\7o\2\2\u00b1\u00b2\7c\2\2\u00b2\u00b3\7r\2\2\u00b3\6\3\2\2\2\u00b4"+
"\u00b5\7u\2\2\u00b5\u00b6\7v\2\2\u00b6\u00b7\7t\2\2\u00b7\u00b8\7w\2\2"+
"\u00b8\u00b9\7e\2\2\u00b9\u00ba\7v\2\2\u00ba\b\3\2\2\2\u00bb\u00bc\7k"+
"\2\2\u00bc\u00bd\7p\2\2\u00bd\u00be\7v\2\2\u00be\u00bf\7g\2\2\u00bf\u00c0"+
"\7t\2\2\u00c0\u00c1\7h\2\2\u00c1\u00c2\7c\2\2\u00c2\u00c3\7e\2\2\u00c3"+
"\u00c4\7g\2\2\u00c4\n\3\2\2\2\u00c5\u00c6\7v\2\2\u00c6\u00c7\7{\2\2\u00c7"+
"\u00c8\7r\2\2\u00c8\u00c9\7g\2\2\u00c9\f\3\2\2\2\u00ca\u00cb\7B\2\2\u00cb"+
"\u00cc\7u\2\2\u00cc\u00cd\7g\2\2\u00cd\u00ce\7t\2\2\u00ce\u00cf\7x\2\2"+
"\u00cf\u00d0\7g\2\2\u00d0\u00d1\7t\2\2\u00d1\16\3\2\2\2\u00d2\u00d3\7"+
"B\2\2\u00d3\u00d4\7f\2\2\u00d4\u00d5\7q\2\2\u00d5\u00d6\7e\2\2\u00d6\20"+
"\3\2\2\2\u00d7\u00d8\7B\2\2\u00d8\u00d9\7j\2\2\u00d9\u00da\7c\2\2\u00da"+
"\u00db\7p\2\2\u00db\u00dc\7f\2\2\u00dc\u00dd\7n\2\2\u00dd\u00de\7g\2\2"+
"\u00de\u00df\7t\2\2\u00df\22\3\2\2\2\u00e0\u00e1\7u\2\2\u00e1\u00e2\7"+
"g\2\2\u00e2\u00e3\7t\2\2\u00e3\u00e4\7x\2\2\u00e4\u00e5\7k\2\2\u00e5\u00e6"+
"\7e\2\2\u00e6\u00e7\7g\2\2\u00e7\24\3\2\2\2\u00e8\u00e9\7t\2\2\u00e9\u00ea"+
"\7g\2\2\u00ea\u00eb\7v\2\2\u00eb\u00ec\7w\2\2\u00ec\u00ed\7t\2\2\u00ed"+
"\u00ee\7p\2\2\u00ee\u00ef\7u\2\2\u00ef\26\3\2\2\2\u00f0\u00f1\7k\2\2\u00f1"+
"\u00f2\7o\2\2\u00f2\u00f3\7r\2\2\u00f3\u00f4\7q\2\2\u00f4\u00f5\7t\2\2"+
"\u00f5\u00f6\7v\2\2\u00f6\30\3\2\2\2\u00f7\u0101\5\33\16\2\u00f8\u0101"+
"\5\35\17\2\u00f9\u0101\5\37\20\2\u00fa\u0101\5!\21\2\u00fb\u0101\5#\22"+
"\2\u00fc\u0101\5%\23\2\u00fd\u0101\5\'\24\2\u00fe\u0101\5)\25\2\u00ff"+
"\u0101\5+\26\2\u0100\u00f7\3\2\2\2\u0100\u00f8\3\2\2\2\u0100\u00f9\3\2"+
"\2\2\u0100\u00fa\3\2\2\2\u0100\u00fb\3\2\2\2\u0100\u00fc\3\2\2\2\u0100"+
"\u00fd\3\2\2\2\u0100\u00fe\3\2\2\2\u0100\u00ff\3\2\2\2\u0101\32\3\2\2"+
"\2\u0102\u0103\7v\2\2\u0103\u0104\7k\2\2\u0104\u0105\7v\2\2\u0105\u0106"+
"\7n\2\2\u0106\u0107\7g\2\2\u0107\34\3\2\2\2\u0108\u0109\7f\2\2\u0109\u010a"+
"\7g\2\2\u010a\u010b\7u\2\2\u010b\u010c\7e\2\2\u010c\36\3\2\2\2\u010d\u010e"+
"\7c\2\2\u010e\u010f\7w\2\2\u010f\u0110\7v\2\2\u0110\u0111\7j\2\2\u0111"+
"\u0112\7q\2\2\u0112\u0113\7t\2\2\u0113 \3\2\2\2\u0114\u0115\7g\2\2\u0115"+
"\u0116\7o\2\2\u0116\u0117\7c\2\2\u0117\u0118\7k\2\2\u0118\u0119\7n\2\2"+
"\u0119\"\3\2\2\2\u011a\u011b\7x\2\2\u011b\u011c\7g\2\2\u011c\u011d\7t"+
"\2\2\u011d\u011e\7u\2\2\u011e\u011f\7k\2\2\u011f\u0120\7q\2\2\u0120\u0121"+
"\7p\2\2\u0121$\3\2\2\2\u0122\u0123\7i\2\2\u0123\u0124\7t\2\2\u0124\u0125"+
"\7q\2\2\u0125\u0126\7w\2\2\u0126\u0127\7r\2\2\u0127&\3\2\2\2\u0128\u0129"+
"\7l\2\2\u0129\u012a\7y\2\2\u012a\u012b\7v\2\2\u012b(\3\2\2\2\u012c\u012d"+
"\7u\2\2\u012d\u012e\7w\2\2\u012e\u012f\7o\2\2\u012f\u0130\7o\2\2\u0130"+
"\u0131\7c\2\2\u0131\u0132\7t\2\2\u0132\u0133\7{\2\2\u0133*\3\2\2\2\u0134"+
"\u0135\7j\2\2\u0135\u0136\7c\2\2\u0136\u0137\7p\2\2\u0137\u0138\7f\2\2"+
"\u0138\u0139\7n\2\2\u0139\u013a\7g\2\2\u013a\u013b\7t\2\2\u013b,\3\2\2"+
"\2\u013c\u0146\5/\30\2\u013d\u0146\5\61\31\2\u013e\u0146\5\63\32\2\u013f"+
"\u0146\5\65\33\2\u0140\u0146\5\67\34\2\u0141\u0146\59\35\2\u0142\u0146"+
"\5;\36\2\u0143\u0146\5=\37\2\u0144\u0146\5? \2\u0145\u013c\3\2\2\2\u0145"+
"\u013d\3\2\2\2\u0145\u013e\3\2\2\2\u0145\u013f\3\2\2\2\u0145\u0140\3\2"+
"\2\2\u0145\u0141\3\2\2\2\u0145\u0142\3\2\2\2\u0145\u0143\3\2\2\2\u0145"+
"\u0144\3\2\2\2\u0146.\3\2\2\2\u0147\u0148\7i\2\2\u0148\u0149\7g\2\2\u0149"+
"\u014a\7v\2\2\u014a\60\3\2\2\2\u014b\u014c\7j\2\2\u014c\u014d\7g\2\2\u014d"+
"\u014e\7c\2\2\u014e\u014f\7f\2\2\u014f\62\3\2\2\2\u0150\u0151\7r\2\2\u0151"+
"\u0152\7q\2\2\u0152\u0153\7u\2\2\u0153\u0154\7v\2\2\u0154\64\3\2\2\2\u0155"+
"\u0156\7r\2\2\u0156\u0157\7w\2\2\u0157\u0158\7v\2\2\u0158\66\3\2\2\2\u0159"+
"\u015a\7r\2\2\u015a\u015b\7c\2\2\u015b\u015c\7v\2\2\u015c\u015d\7e\2\2"+
"\u015d\u015e\7j\2\2\u015e8\3\2\2\2\u015f\u0160\7f\2\2\u0160\u0161\7g\2"+
"\2\u0161\u0162\7n\2\2\u0162\u0163\7g\2\2\u0163\u0164\7v\2\2\u0164\u0165"+
"\7g\2\2\u0165:\3\2\2\2\u0166\u0167\7e\2\2\u0167\u0168\7q\2\2\u0168\u0169"+
"\7p\2\2\u0169\u016a\7p\2\2\u016a\u016b\7g\2\2\u016b\u016c\7e\2\2\u016c"+
"\u016d\7v\2\2\u016d<\3\2\2\2\u016e\u016f\7q\2\2\u016f\u0170\7r\2\2\u0170"+
"\u0171\7v\2\2\u0171\u0172\7k\2\2\u0172\u0173\7q\2\2\u0173\u0174\7p\2\2"+
"\u0174\u0175\7u\2\2\u0175>\3\2\2\2\u0176\u0177\7v\2\2\u0177\u0178\7t\2"+
"\2\u0178\u0179\7c\2\2\u0179\u017a\7e\2\2\u017a\u017b\7g\2\2\u017b@\3\2"+
"\2\2\u017c\u0191\5C\"\2\u017d\u0191\5E#\2\u017e\u0191\5G$\2\u017f\u0191"+
"\5I%\2\u0180\u0191\5K&\2\u0181\u0191\5M\'\2\u0182\u0191\5O(\2\u0183\u0191"+
"\5Q)\2\u0184\u0191\5S*\2\u0185\u0191\5U+\2\u0186\u0191\5U+\2\u0187\u0191"+
"\5W,\2\u0188\u0191\5Y-\2\u0189\u0191\5[.\2\u018a\u0191\5]/\2\u018b\u0191"+
"\5_\60\2\u018c\u0191\5a\61\2\u018d\u0191\5c\62\2\u018e\u0191\5e\63\2\u018f"+
"\u0191\5g\64\2\u0190\u017c\3\2\2\2\u0190\u017d\3\2\2\2\u0190\u017e\3\2"+
"\2\2\u0190\u017f\3\2\2\2\u0190\u0180\3\2\2\2\u0190\u0181\3\2\2\2\u0190"+
"\u0182\3\2\2\2\u0190\u0183\3\2\2\2\u0190\u0184\3\2\2\2\u0190\u0185\3\2"+
"\2\2\u0190\u0186\3\2\2\2\u0190\u0187\3\2\2\2\u0190\u0188\3\2\2\2\u0190"+
"\u0189\3\2\2\2\u0190\u018a\3\2\2\2\u0190\u018b\3\2\2\2\u0190\u018c\3\2"+
"\2\2\u0190\u018d\3\2\2\2\u0190\u018e\3\2\2\2\u0190\u018f\3\2\2\2\u0191"+
"B\3\2\2\2\u0192\u0193\7d\2\2\u0193\u0194\7q\2\2\u0194\u0195\7q\2\2\u0195"+
"\u0196\7n\2\2\u0196D\3\2\2\2\u0197\u0198\7w\2\2\u0198\u0199\7k\2\2\u0199"+
"\u019a\7p\2\2\u019a\u019b\7v\2\2\u019b\u019c\7:\2\2\u019cF\3\2\2\2\u019d"+
"\u019e\7w\2\2\u019e\u019f\7k\2\2\u019f\u01a0\7p\2\2\u01a0\u01a1\7v\2\2"+
"\u01a1\u01a2\7\63\2\2\u01a2\u01a3\78\2\2\u01a3H\3\2\2\2\u01a4\u01a5\7"+
"w\2\2\u01a5\u01a6\7k\2\2\u01a6\u01a7\7p\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9"+
"\7\65\2\2\u01a9\u01aa\7\64\2\2\u01aaJ\3\2\2\2\u01ab\u01ac\7w\2\2\u01ac"+
"\u01ad\7k\2\2\u01ad\u01ae\7p\2\2\u01ae\u01af\7v\2\2\u01af\u01b0\78\2\2"+
"\u01b0\u01b1\7\66\2\2\u01b1L\3\2\2\2\u01b2\u01b3\7k\2\2\u01b3\u01b4\7"+
"p\2\2\u01b4\u01b5\7v\2\2\u01b5\u01b6\7:\2\2\u01b6N\3\2\2\2\u01b7\u01b8"+
"\7k\2\2\u01b8\u01b9\7p\2\2\u01b9\u01ba\7v\2\2\u01ba\u01bb\7\63\2\2\u01bb"+
"\u01bc\78\2\2\u01bcP\3\2\2\2\u01bd\u01be\7k\2\2\u01be\u01bf\7p\2\2\u01bf"+
"\u01c0\7v\2\2\u01c0\u01c1\7\65\2\2\u01c1\u01c2\7\64\2\2\u01c2R\3\2\2\2"+
"\u01c3\u01c4\7k\2\2\u01c4\u01c5\7p\2\2\u01c5\u01c6\7v\2\2\u01c6\u01c7"+
"\78\2\2\u01c7\u01c8\7\66\2\2\u01c8T\3\2\2\2\u01c9\u01ca\7h\2\2\u01ca\u01cb"+
"\7n\2\2\u01cb\u01cc\7q\2\2\u01cc\u01cd\7c\2\2\u01cd\u01ce\7v\2\2\u01ce"+
"\u01cf\7\65\2\2\u01cf\u01d0\7\64\2\2\u01d0V\3\2\2\2\u01d1\u01d2\7h\2\2"+
"\u01d2\u01d3\7n\2\2\u01d3\u01d4\7q\2\2\u01d4\u01d5\7c\2\2\u01d5\u01d6"+
"\7v\2\2\u01d6\u01d7\78\2\2\u01d7\u01d8\7\66\2\2\u01d8X\3\2\2\2\u01d9\u01da"+
"\7e\2\2\u01da\u01db\7q\2\2\u01db\u01dc\7o\2\2\u01dc\u01dd\7r\2\2\u01dd"+
"\u01de\7n\2\2\u01de\u01df\7g\2\2\u01df\u01e0\7z\2\2\u01e0\u01e1\78\2\2"+
"\u01e1\u01e2\7\66\2\2\u01e2Z\3\2\2\2\u01e3\u01e4\7e\2\2\u01e4\u01e5\7"+
"q\2\2\u01e5\u01e6\7o\2\2\u01e6\u01e7\7r\2\2\u01e7\u01e8\7n\2\2\u01e8\u01e9"+
"\7g\2\2\u01e9\u01ea\7z\2\2\u01ea\u01eb\7\63\2\2\u01eb\u01ec\7\64\2\2\u01ec"+
"\u01ed\7:\2\2\u01ed\\\3\2\2\2\u01ee\u01ef\7u\2\2\u01ef\u01f0\7v\2\2\u01f0"+
"\u01f1\7t\2\2\u01f1\u01f2\7k\2\2\u01f2\u01f3\7p\2\2\u01f3\u01f4\7i\2\2"+
"\u01f4^\3\2\2\2\u01f5\u01f6\7k\2\2\u01f6\u01f7\7p\2\2\u01f7\u01f8\7v\2"+
"\2\u01f8`\3\2\2\2\u01f9\u01fa\7w\2\2\u01fa\u01fb\7k\2\2\u01fb\u01fc\7"+
"p\2\2\u01fc\u01fd\7v\2\2\u01fdb\3\2\2\2\u01fe\u01ff\7w\2\2\u01ff\u0200"+
"\7k\2\2\u0200\u0201\7p\2\2\u0201\u0202\7v\2\2\u0202\u0203\7r\2\2\u0203"+
"\u0204\7v\2\2\u0204\u0205\7t\2\2\u0205d\3\2\2\2\u0206\u0207\7d\2\2\u0207"+
"\u0208\7{\2\2\u0208\u0209\7v\2\2\u0209\u020a\7g\2\2\u020af\3\2\2\2\u020b"+
"\u020c\7t\2\2\u020c\u020d\7w\2\2\u020d\u020e\7p\2\2\u020e\u020f\7g\2\2"+
"\u020fh\3\2\2\2\u0210\u0215\7\61\2\2\u0211\u0212\7\61\2\2\u0212\u0215"+
"\7<\2\2\u0213\u0215\7/\2\2\u0214\u0210\3\2\2\2\u0214\u0211\3\2\2\2\u0214"+
"\u0213\3\2\2\2\u0215\u0216\3\2\2\2\u0216\u0218\5\u0089E\2\u0217\u0214"+
"\3\2\2\2\u0218\u0219\3\2\2\2\u0219\u0217\3\2\2\2\u0219\u021a\3\2\2\2\u021a"+
"j\3\2\2\2\u021b\u021c\7*\2\2\u021cl\3\2\2\2\u021d\u021e\7+\2\2\u021en"+
"\3\2\2\2\u021f\u0220\7}\2\2\u0220p\3\2\2\2\u0221\u0222\7\177\2\2\u0222"+
"r\3\2\2\2\u0223\u0224\7]\2\2\u0224t\3\2\2\2\u0225\u0226\7_\2\2\u0226v"+
"\3\2\2\2\u0227\u0228\7\60\2\2\u0228x\3\2\2\2\u0229\u022a\7=\2\2\u022a"+
"z\3\2\2\2\u022b\u022c\7.\2\2\u022c|\3\2\2\2\u022d\u022e\7,\2\2\u022e~"+
"\3\2\2\2\u022f\u0230\7/\2\2\u0230\u0080\3\2\2\2\u0231\u0232\7?\2\2\u0232"+
"\u0082\3\2\2\2\u0233\u0234\7<\2\2\u0234\u0084\3\2\2\2\u0235\u0237\5\u0099"+
"M\2\u0236\u0235\3\2\2\2\u0237\u0238\3\2\2\2\u0238\u0236\3\2\2\2\u0238"+
"\u0239\3\2\2\2\u0239\u0086\3\2\2\2\u023a\u023c\5\u0099M\2\u023b\u023a"+
"\3\2\2\2\u023c\u023d\3\2\2\2\u023d\u023b\3\2\2\2\u023d\u023e\3\2\2\2\u023e"+
"\u023f\3\2\2\2\u023f\u0241\7\60\2\2\u0240\u0242\5\u0099M\2\u0241\u0240"+
"\3\2\2\2\u0242\u0243\3\2\2\2\u0243\u0241\3\2\2\2\u0243\u0244\3\2\2\2\u0244"+
"\u0245\3\2\2\2\u0245\u0247\7\60\2\2\u0246\u0248\5\u0099M\2\u0247\u0246"+
"\3\2\2\2\u0248\u0249\3\2\2\2\u0249\u0247\3\2\2\2\u0249\u024a\3\2\2\2\u024a"+
"\u024b\3\2\2\2\u024b\u024d\7\60\2\2\u024c\u024e\5\u0099M\2\u024d\u024c"+
"\3\2\2\2\u024e\u024f\3\2\2\2\u024f\u024d\3\2\2\2\u024f\u0250\3\2\2\2\u0250"+
"\u0088\3\2\2\2\u0251\u0254\5\u009dO\2\u0252\u0254\5\u009bN\2\u0253\u0251"+
"\3\2\2\2\u0253\u0252\3\2\2\2\u0254\u025b\3\2\2\2\u0255\u025a\5\u009dO"+
"\2\u0256\u025a\5\u0099M\2\u0257\u025a\5\u009bN\2\u0258\u025a\7/\2\2\u0259"+
"\u0255\3\2\2\2\u0259\u0256\3\2\2\2\u0259\u0257\3\2\2\2\u0259\u0258\3\2"+
"\2\2\u025a\u025d\3\2\2\2\u025b\u0259\3\2\2\2\u025b\u025c\3\2\2\2\u025c"+
"\u008a\3\2\2\2\u025d\u025b\3\2\2\2\u025e\u0260\t\2\2\2\u025f\u025e\3\2"+
"\2\2\u0260\u0261\3\2\2\2\u0261\u025f\3\2\2\2\u0261\u0262\3\2\2\2\u0262"+
"\u0263\3\2\2\2\u0263\u0264\bF\2\2\u0264\u008c\3\2\2\2\u0265\u0269\5\u0097"+
"L\2\u0266\u0268\n\3\2\2\u0267\u0266\3\2\2\2\u0268\u026b\3\2\2\2\u0269"+
"\u0267\3\2\2\2\u0269\u026a\3\2\2\2\u026a\u026c\3\2\2\2\u026b\u0269\3\2"+
"\2\2\u026c\u026d\5\u0097L\2\u026d\u008e\3\2\2\2\u026e\u0272\5\u0095K\2"+
"\u026f\u0271\n\4\2\2\u0270\u026f\3\2\2\2\u0271\u0274\3\2\2\2\u0272\u0270"+
"\3\2\2\2\u0272\u0273\3\2\2\2\u0273\u0275\3\2\2\2\u0274\u0272\3\2\2\2\u0275"+
"\u0276\5\u0095K\2\u0276\u0090\3\2\2\2\u0277\u027b\5\u0093J\2\u0278\u027a"+
"\n\5\2\2\u0279\u0278\3\2\2\2\u027a\u027d\3\2\2\2\u027b\u0279\3\2\2\2\u027b"+
"\u027c\3\2\2\2\u027c\u027e\3\2\2\2\u027d\u027b\3\2\2\2\u027e\u027f\bI"+
"\2\2\u027f\u0092\3\2\2\2\u0280\u0281\7\61\2\2\u0281\u0282\7\61\2\2\u0282"+
"\u0094\3\2\2\2\u0283\u0284\7b\2\2\u0284\u0096\3\2\2\2\u0285\u0286\7$\2"+
"\2\u0286\u0098\3\2\2\2\u0287\u0288\t\6\2\2\u0288\u009a\3\2\2\2\u0289\u028a"+
"\7a\2\2\u028a\u009c\3\2\2\2\u028b\u028c\t\7\2\2\u028c\u009e\3\2\2\2\u028d"+
"\u028e\t\b\2\2\u028e\u00a0\3\2\2\2\u028f\u0290\t\t\2\2\u0290\u00a2\3\2"+
"\2\2\u0291\u0292\7^\2\2\u0292\u029b\t\n\2\2\u0293\u0294\7^\2\2\u0294\u0295"+
"\t\13\2\2\u0295\u0296\5\u009fP\2\u0296\u0297\5\u009fP\2\u0297\u029b\3"+
"\2\2\2\u0298\u029b\5\u00a7T\2\u0299\u029b\5\u00a5S\2\u029a\u0291\3\2\2"+
"\2\u029a\u0293\3\2\2\2\u029a\u0298\3\2\2\2\u029a\u0299\3\2\2\2\u029b\u00a4"+
"\3\2\2\2\u029c\u029d\7^\2\2\u029d\u029e\t\f\2\2\u029e\u029f\5\u00a1Q\2"+
"\u029f\u02a0\5\u00a1Q\2\u02a0\u02a8\3\2\2\2\u02a1\u02a2\7^\2\2\u02a2\u02a3"+
"\5\u00a1Q\2\u02a3\u02a4\5\u00a1Q\2\u02a4\u02a8\3\2\2\2\u02a5\u02a6\7^"+
"\2\2\u02a6\u02a8\5\u00a1Q\2\u02a7\u029c\3\2\2\2\u02a7\u02a1\3\2\2\2\u02a7"+
"\u02a5\3\2\2\2\u02a8\u00a6\3\2\2\2\u02a9\u02aa\7^\2\2\u02aa\u02ab\7w\2"+
"\2\u02ab\u02ac\5\u009fP\2\u02ac\u02ad\5\u009fP\2\u02ad\u02ae\5\u009fP"+
"\2\u02ae\u02af\5\u009fP\2\u02af\u00a8\3\2\2\2\u02b0\u02b1\13\2\2\2\u02b1"+
"\u02b2\3\2\2\2\u02b2\u02b3\bU\2\2\u02b3\u00aa\3\2\2\2\26\2\u0100\u0145"+
"\u0190\u0214\u0219\u0238\u023d\u0243\u0249\u024f\u0253\u0259\u025b\u0261"+
"\u0269\u0272\u027b\u029a\u02a7\3\2\3\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}
|
UTF-8
|
Java
| 24,477 |
java
|
ApiLexer.java
|
Java
|
[
{
"context": "// Generated from /Users/anqiansong/workspace/java/go-zero-idea-plugin/src/main/java/",
"end": 35,
"score": 0.9773163795471191,
"start": 25,
"tag": "USERNAME",
"value": "anqiansong"
}
] | null |
[] |
// Generated from /Users/anqiansong/workspace/java/go-zero-idea-plugin/src/main/java/cn/xiaoheiban/antlr4/ApiLexer.g4 by ANTLR 4.8
package cn.xiaoheiban.antlr4;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ApiLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
INFO=1, MAP=2, STRUCT=3, INTERFACE=4, TYPE=5, ATSERVER=6, ATDOC=7, ATHANDLER=8,
SERVICE=9, RETURNS=10, IMPORT=11, KEY=12, TITLE=13, DESC=14, AUTHOR=15,
EMAIL=16, VERSION=17, GROUP=18, JWT=19, SUMMARY=20, HANDLER=21, HTTPMETHOD=22,
GET=23, HEAD=24, POST=25, PUT=26, PATCH=27, DELETE=28, CONNECT=29, OPTIONS=30,
TRACE=31, GOTYPE=32, BOOL=33, UINT8=34, UINT16=35, UINT32=36, UINT64=37,
INT8=38, INT16=39, INT32=40, INT64=41, FLOAT32=42, FLOAT64=43, COMPLEX64=44,
COMPLEX128=45, STRING=46, INT=47, UINT=48, UINTPTR=49, BYTE=50, RUNE=51,
PATH=52, LPAREN=53, RPAREN=54, LBRACE=55, RBRACE=56, LBRACK=57, RBRACK=58,
DOT=59, SMICOLON=60, COMMA=61, STAR=62, BAR=63, ASSIGN=64, COLON=65, NUMBER=66,
HOSTVALUE=67, IDENT=68, WS=69, VALUE=70, RAW_STRING=71, COMMENT=72, ERRCHAR=73;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
public static String[] modeNames = {
"DEFAULT_MODE"
};
private static String[] makeRuleNames() {
return new String[] {
"INFO", "MAP", "STRUCT", "INTERFACE", "TYPE", "ATSERVER", "ATDOC", "ATHANDLER",
"SERVICE", "RETURNS", "IMPORT", "KEY", "TITLE", "DESC", "AUTHOR", "EMAIL",
"VERSION", "GROUP", "JWT", "SUMMARY", "HANDLER", "HTTPMETHOD", "GET",
"HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS", "TRACE",
"GOTYPE", "BOOL", "UINT8", "UINT16", "UINT32", "UINT64", "INT8", "INT16",
"INT32", "INT64", "FLOAT32", "FLOAT64", "COMPLEX64", "COMPLEX128", "STRING",
"INT", "UINT", "UINTPTR", "BYTE", "RUNE", "PATH", "LPAREN", "RPAREN",
"LBRACE", "RBRACE", "LBRACK", "RBRACK", "DOT", "SMICOLON", "COMMA", "STAR",
"BAR", "ASSIGN", "COLON", "NUMBER", "HOSTVALUE", "IDENT", "WS", "VALUE",
"RAW_STRING", "COMMENT", "COMMENT_FLAG", "RAW_STRING_F", "STRING_F",
"DIGIT", "UNDERSCORE", "ALPHA", "HEX_DIGIT", "OCT_DIGIT", "ESC_SEQ",
"OCTAL_ESC", "UNICODE_ESC", "ERRCHAR"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'info'", "'map'", "'struct'", "'interface'", "'type'", "'@server'",
"'@doc'", "'@handler'", "'service'", "'returns'", "'import'", null, "'title'",
"'desc'", "'author'", "'email'", "'version'", "'group'", "'jwt'", "'summary'",
"'handler'", null, "'get'", "'head'", "'post'", "'put'", "'patch'", "'delete'",
"'connect'", "'options'", "'trace'", null, "'bool'", "'uint8'", "'uint16'",
"'uint32'", "'uint64'", "'int8'", "'int16'", "'int32'", "'int64'", "'float32'",
"'float64'", "'complex64'", "'complex128'", "'string'", "'int'", "'uint'",
"'uintptr'", "'byte'", "'rune'", null, "'('", "')'", "'{'", "'}'", "'['",
"']'", "'.'", "';'", "','", "'*'", "'-'", "'='", "':'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, "INFO", "MAP", "STRUCT", "INTERFACE", "TYPE", "ATSERVER", "ATDOC",
"ATHANDLER", "SERVICE", "RETURNS", "IMPORT", "KEY", "TITLE", "DESC",
"AUTHOR", "EMAIL", "VERSION", "GROUP", "JWT", "SUMMARY", "HANDLER", "HTTPMETHOD",
"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS",
"TRACE", "GOTYPE", "BOOL", "UINT8", "UINT16", "UINT32", "UINT64", "INT8",
"INT16", "INT32", "INT64", "FLOAT32", "FLOAT64", "COMPLEX64", "COMPLEX128",
"STRING", "INT", "UINT", "UINTPTR", "BYTE", "RUNE", "PATH", "LPAREN",
"RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", "DOT", "SMICOLON",
"COMMA", "STAR", "BAR", "ASSIGN", "COLON", "NUMBER", "HOSTVALUE", "IDENT",
"WS", "VALUE", "RAW_STRING", "COMMENT", "ERRCHAR"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
public ApiLexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@Override
public String getGrammarFileName() { return "ApiLexer.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public String[] getChannelNames() { return channelNames; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2K\u02b4\b\1\4\2\t"+
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+
"\4U\tU\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4"+
"\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3"+
"\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t"+
"\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13"+
"\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+
"\3\r\5\r\u0101\n\r\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3"+
"\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3"+
"\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3"+
"\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3"+
"\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3"+
"\27\5\27\u0146\n\27\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\32"+
"\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34"+
"\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36"+
"\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \3 \3!\3!"+
"\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\5!\u0191\n!\3\""+
"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3"+
"%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3)"+
"\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3+\3+\3+\3,\3,\3,\3,"+
"\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3.\3.\3."+
"\3.\3.\3/\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3"+
"\61\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3"+
"\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\5\65\u0215\n\65\3\65\6\65"+
"\u0218\n\65\r\65\16\65\u0219\3\66\3\66\3\67\3\67\38\38\39\39\3:\3:\3;"+
"\3;\3<\3<\3=\3=\3>\3>\3?\3?\3@\3@\3A\3A\3B\3B\3C\6C\u0237\nC\rC\16C\u0238"+
"\3D\6D\u023c\nD\rD\16D\u023d\3D\3D\6D\u0242\nD\rD\16D\u0243\3D\3D\6D\u0248"+
"\nD\rD\16D\u0249\3D\3D\6D\u024e\nD\rD\16D\u024f\3E\3E\5E\u0254\nE\3E\3"+
"E\3E\3E\7E\u025a\nE\fE\16E\u025d\13E\3F\6F\u0260\nF\rF\16F\u0261\3F\3"+
"F\3G\3G\7G\u0268\nG\fG\16G\u026b\13G\3G\3G\3H\3H\7H\u0271\nH\fH\16H\u0274"+
"\13H\3H\3H\3I\3I\7I\u027a\nI\fI\16I\u027d\13I\3I\3I\3J\3J\3J\3K\3K\3L"+
"\3L\3M\3M\3N\3N\3O\3O\3P\3P\3Q\3Q\3R\3R\3R\3R\3R\3R\3R\3R\3R\5R\u029b"+
"\nR\3S\3S\3S\3S\3S\3S\3S\3S\3S\3S\3S\5S\u02a8\nS\3T\3T\3T\3T\3T\3T\3T"+
"\3U\3U\3U\3U\2\2V\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31"+
"\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65"+
"\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64"+
"g\65i\66k\67m8o9q:s;u<w=y>{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089"+
"F\u008bG\u008dH\u008fI\u0091J\u0093\2\u0095\2\u0097\2\u0099\2\u009b\2"+
"\u009d\2\u009f\2\u00a1\2\u00a3\2\u00a5\2\u00a7\2\u00a9K\3\2\r\5\2\13\f"+
"\17\17\"\"\5\2\f\f\17\17<<\5\2\f\f\17\17bb\3\2\f\f\3\2\62;\4\2C\\c|\5"+
"\2\62;CHch\3\2\629\f\2$$))AA^^cdhhppttvvxx\4\2ZZzz\3\2\62\65\2\u02e1\2"+
"\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2"+
"\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2"+
"\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2"+
"\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2"+
"\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2"+
"\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2"+
"\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U"+
"\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2"+
"\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2"+
"\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{"+
"\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085"+
"\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2"+
"\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u00a9\3\2\2\2\3\u00ab\3\2\2\2\5\u00b0"+
"\3\2\2\2\7\u00b4\3\2\2\2\t\u00bb\3\2\2\2\13\u00c5\3\2\2\2\r\u00ca\3\2"+
"\2\2\17\u00d2\3\2\2\2\21\u00d7\3\2\2\2\23\u00e0\3\2\2\2\25\u00e8\3\2\2"+
"\2\27\u00f0\3\2\2\2\31\u0100\3\2\2\2\33\u0102\3\2\2\2\35\u0108\3\2\2\2"+
"\37\u010d\3\2\2\2!\u0114\3\2\2\2#\u011a\3\2\2\2%\u0122\3\2\2\2\'\u0128"+
"\3\2\2\2)\u012c\3\2\2\2+\u0134\3\2\2\2-\u0145\3\2\2\2/\u0147\3\2\2\2\61"+
"\u014b\3\2\2\2\63\u0150\3\2\2\2\65\u0155\3\2\2\2\67\u0159\3\2\2\29\u015f"+
"\3\2\2\2;\u0166\3\2\2\2=\u016e\3\2\2\2?\u0176\3\2\2\2A\u0190\3\2\2\2C"+
"\u0192\3\2\2\2E\u0197\3\2\2\2G\u019d\3\2\2\2I\u01a4\3\2\2\2K\u01ab\3\2"+
"\2\2M\u01b2\3\2\2\2O\u01b7\3\2\2\2Q\u01bd\3\2\2\2S\u01c3\3\2\2\2U\u01c9"+
"\3\2\2\2W\u01d1\3\2\2\2Y\u01d9\3\2\2\2[\u01e3\3\2\2\2]\u01ee\3\2\2\2_"+
"\u01f5\3\2\2\2a\u01f9\3\2\2\2c\u01fe\3\2\2\2e\u0206\3\2\2\2g\u020b\3\2"+
"\2\2i\u0217\3\2\2\2k\u021b\3\2\2\2m\u021d\3\2\2\2o\u021f\3\2\2\2q\u0221"+
"\3\2\2\2s\u0223\3\2\2\2u\u0225\3\2\2\2w\u0227\3\2\2\2y\u0229\3\2\2\2{"+
"\u022b\3\2\2\2}\u022d\3\2\2\2\177\u022f\3\2\2\2\u0081\u0231\3\2\2\2\u0083"+
"\u0233\3\2\2\2\u0085\u0236\3\2\2\2\u0087\u023b\3\2\2\2\u0089\u0253\3\2"+
"\2\2\u008b\u025f\3\2\2\2\u008d\u0265\3\2\2\2\u008f\u026e\3\2\2\2\u0091"+
"\u0277\3\2\2\2\u0093\u0280\3\2\2\2\u0095\u0283\3\2\2\2\u0097\u0285\3\2"+
"\2\2\u0099\u0287\3\2\2\2\u009b\u0289\3\2\2\2\u009d\u028b\3\2\2\2\u009f"+
"\u028d\3\2\2\2\u00a1\u028f\3\2\2\2\u00a3\u029a\3\2\2\2\u00a5\u02a7\3\2"+
"\2\2\u00a7\u02a9\3\2\2\2\u00a9\u02b0\3\2\2\2\u00ab\u00ac\7k\2\2\u00ac"+
"\u00ad\7p\2\2\u00ad\u00ae\7h\2\2\u00ae\u00af\7q\2\2\u00af\4\3\2\2\2\u00b0"+
"\u00b1\7o\2\2\u00b1\u00b2\7c\2\2\u00b2\u00b3\7r\2\2\u00b3\6\3\2\2\2\u00b4"+
"\u00b5\7u\2\2\u00b5\u00b6\7v\2\2\u00b6\u00b7\7t\2\2\u00b7\u00b8\7w\2\2"+
"\u00b8\u00b9\7e\2\2\u00b9\u00ba\7v\2\2\u00ba\b\3\2\2\2\u00bb\u00bc\7k"+
"\2\2\u00bc\u00bd\7p\2\2\u00bd\u00be\7v\2\2\u00be\u00bf\7g\2\2\u00bf\u00c0"+
"\7t\2\2\u00c0\u00c1\7h\2\2\u00c1\u00c2\7c\2\2\u00c2\u00c3\7e\2\2\u00c3"+
"\u00c4\7g\2\2\u00c4\n\3\2\2\2\u00c5\u00c6\7v\2\2\u00c6\u00c7\7{\2\2\u00c7"+
"\u00c8\7r\2\2\u00c8\u00c9\7g\2\2\u00c9\f\3\2\2\2\u00ca\u00cb\7B\2\2\u00cb"+
"\u00cc\7u\2\2\u00cc\u00cd\7g\2\2\u00cd\u00ce\7t\2\2\u00ce\u00cf\7x\2\2"+
"\u00cf\u00d0\7g\2\2\u00d0\u00d1\7t\2\2\u00d1\16\3\2\2\2\u00d2\u00d3\7"+
"B\2\2\u00d3\u00d4\7f\2\2\u00d4\u00d5\7q\2\2\u00d5\u00d6\7e\2\2\u00d6\20"+
"\3\2\2\2\u00d7\u00d8\7B\2\2\u00d8\u00d9\7j\2\2\u00d9\u00da\7c\2\2\u00da"+
"\u00db\7p\2\2\u00db\u00dc\7f\2\2\u00dc\u00dd\7n\2\2\u00dd\u00de\7g\2\2"+
"\u00de\u00df\7t\2\2\u00df\22\3\2\2\2\u00e0\u00e1\7u\2\2\u00e1\u00e2\7"+
"g\2\2\u00e2\u00e3\7t\2\2\u00e3\u00e4\7x\2\2\u00e4\u00e5\7k\2\2\u00e5\u00e6"+
"\7e\2\2\u00e6\u00e7\7g\2\2\u00e7\24\3\2\2\2\u00e8\u00e9\7t\2\2\u00e9\u00ea"+
"\7g\2\2\u00ea\u00eb\7v\2\2\u00eb\u00ec\7w\2\2\u00ec\u00ed\7t\2\2\u00ed"+
"\u00ee\7p\2\2\u00ee\u00ef\7u\2\2\u00ef\26\3\2\2\2\u00f0\u00f1\7k\2\2\u00f1"+
"\u00f2\7o\2\2\u00f2\u00f3\7r\2\2\u00f3\u00f4\7q\2\2\u00f4\u00f5\7t\2\2"+
"\u00f5\u00f6\7v\2\2\u00f6\30\3\2\2\2\u00f7\u0101\5\33\16\2\u00f8\u0101"+
"\5\35\17\2\u00f9\u0101\5\37\20\2\u00fa\u0101\5!\21\2\u00fb\u0101\5#\22"+
"\2\u00fc\u0101\5%\23\2\u00fd\u0101\5\'\24\2\u00fe\u0101\5)\25\2\u00ff"+
"\u0101\5+\26\2\u0100\u00f7\3\2\2\2\u0100\u00f8\3\2\2\2\u0100\u00f9\3\2"+
"\2\2\u0100\u00fa\3\2\2\2\u0100\u00fb\3\2\2\2\u0100\u00fc\3\2\2\2\u0100"+
"\u00fd\3\2\2\2\u0100\u00fe\3\2\2\2\u0100\u00ff\3\2\2\2\u0101\32\3\2\2"+
"\2\u0102\u0103\7v\2\2\u0103\u0104\7k\2\2\u0104\u0105\7v\2\2\u0105\u0106"+
"\7n\2\2\u0106\u0107\7g\2\2\u0107\34\3\2\2\2\u0108\u0109\7f\2\2\u0109\u010a"+
"\7g\2\2\u010a\u010b\7u\2\2\u010b\u010c\7e\2\2\u010c\36\3\2\2\2\u010d\u010e"+
"\7c\2\2\u010e\u010f\7w\2\2\u010f\u0110\7v\2\2\u0110\u0111\7j\2\2\u0111"+
"\u0112\7q\2\2\u0112\u0113\7t\2\2\u0113 \3\2\2\2\u0114\u0115\7g\2\2\u0115"+
"\u0116\7o\2\2\u0116\u0117\7c\2\2\u0117\u0118\7k\2\2\u0118\u0119\7n\2\2"+
"\u0119\"\3\2\2\2\u011a\u011b\7x\2\2\u011b\u011c\7g\2\2\u011c\u011d\7t"+
"\2\2\u011d\u011e\7u\2\2\u011e\u011f\7k\2\2\u011f\u0120\7q\2\2\u0120\u0121"+
"\7p\2\2\u0121$\3\2\2\2\u0122\u0123\7i\2\2\u0123\u0124\7t\2\2\u0124\u0125"+
"\7q\2\2\u0125\u0126\7w\2\2\u0126\u0127\7r\2\2\u0127&\3\2\2\2\u0128\u0129"+
"\7l\2\2\u0129\u012a\7y\2\2\u012a\u012b\7v\2\2\u012b(\3\2\2\2\u012c\u012d"+
"\7u\2\2\u012d\u012e\7w\2\2\u012e\u012f\7o\2\2\u012f\u0130\7o\2\2\u0130"+
"\u0131\7c\2\2\u0131\u0132\7t\2\2\u0132\u0133\7{\2\2\u0133*\3\2\2\2\u0134"+
"\u0135\7j\2\2\u0135\u0136\7c\2\2\u0136\u0137\7p\2\2\u0137\u0138\7f\2\2"+
"\u0138\u0139\7n\2\2\u0139\u013a\7g\2\2\u013a\u013b\7t\2\2\u013b,\3\2\2"+
"\2\u013c\u0146\5/\30\2\u013d\u0146\5\61\31\2\u013e\u0146\5\63\32\2\u013f"+
"\u0146\5\65\33\2\u0140\u0146\5\67\34\2\u0141\u0146\59\35\2\u0142\u0146"+
"\5;\36\2\u0143\u0146\5=\37\2\u0144\u0146\5? \2\u0145\u013c\3\2\2\2\u0145"+
"\u013d\3\2\2\2\u0145\u013e\3\2\2\2\u0145\u013f\3\2\2\2\u0145\u0140\3\2"+
"\2\2\u0145\u0141\3\2\2\2\u0145\u0142\3\2\2\2\u0145\u0143\3\2\2\2\u0145"+
"\u0144\3\2\2\2\u0146.\3\2\2\2\u0147\u0148\7i\2\2\u0148\u0149\7g\2\2\u0149"+
"\u014a\7v\2\2\u014a\60\3\2\2\2\u014b\u014c\7j\2\2\u014c\u014d\7g\2\2\u014d"+
"\u014e\7c\2\2\u014e\u014f\7f\2\2\u014f\62\3\2\2\2\u0150\u0151\7r\2\2\u0151"+
"\u0152\7q\2\2\u0152\u0153\7u\2\2\u0153\u0154\7v\2\2\u0154\64\3\2\2\2\u0155"+
"\u0156\7r\2\2\u0156\u0157\7w\2\2\u0157\u0158\7v\2\2\u0158\66\3\2\2\2\u0159"+
"\u015a\7r\2\2\u015a\u015b\7c\2\2\u015b\u015c\7v\2\2\u015c\u015d\7e\2\2"+
"\u015d\u015e\7j\2\2\u015e8\3\2\2\2\u015f\u0160\7f\2\2\u0160\u0161\7g\2"+
"\2\u0161\u0162\7n\2\2\u0162\u0163\7g\2\2\u0163\u0164\7v\2\2\u0164\u0165"+
"\7g\2\2\u0165:\3\2\2\2\u0166\u0167\7e\2\2\u0167\u0168\7q\2\2\u0168\u0169"+
"\7p\2\2\u0169\u016a\7p\2\2\u016a\u016b\7g\2\2\u016b\u016c\7e\2\2\u016c"+
"\u016d\7v\2\2\u016d<\3\2\2\2\u016e\u016f\7q\2\2\u016f\u0170\7r\2\2\u0170"+
"\u0171\7v\2\2\u0171\u0172\7k\2\2\u0172\u0173\7q\2\2\u0173\u0174\7p\2\2"+
"\u0174\u0175\7u\2\2\u0175>\3\2\2\2\u0176\u0177\7v\2\2\u0177\u0178\7t\2"+
"\2\u0178\u0179\7c\2\2\u0179\u017a\7e\2\2\u017a\u017b\7g\2\2\u017b@\3\2"+
"\2\2\u017c\u0191\5C\"\2\u017d\u0191\5E#\2\u017e\u0191\5G$\2\u017f\u0191"+
"\5I%\2\u0180\u0191\5K&\2\u0181\u0191\5M\'\2\u0182\u0191\5O(\2\u0183\u0191"+
"\5Q)\2\u0184\u0191\5S*\2\u0185\u0191\5U+\2\u0186\u0191\5U+\2\u0187\u0191"+
"\5W,\2\u0188\u0191\5Y-\2\u0189\u0191\5[.\2\u018a\u0191\5]/\2\u018b\u0191"+
"\5_\60\2\u018c\u0191\5a\61\2\u018d\u0191\5c\62\2\u018e\u0191\5e\63\2\u018f"+
"\u0191\5g\64\2\u0190\u017c\3\2\2\2\u0190\u017d\3\2\2\2\u0190\u017e\3\2"+
"\2\2\u0190\u017f\3\2\2\2\u0190\u0180\3\2\2\2\u0190\u0181\3\2\2\2\u0190"+
"\u0182\3\2\2\2\u0190\u0183\3\2\2\2\u0190\u0184\3\2\2\2\u0190\u0185\3\2"+
"\2\2\u0190\u0186\3\2\2\2\u0190\u0187\3\2\2\2\u0190\u0188\3\2\2\2\u0190"+
"\u0189\3\2\2\2\u0190\u018a\3\2\2\2\u0190\u018b\3\2\2\2\u0190\u018c\3\2"+
"\2\2\u0190\u018d\3\2\2\2\u0190\u018e\3\2\2\2\u0190\u018f\3\2\2\2\u0191"+
"B\3\2\2\2\u0192\u0193\7d\2\2\u0193\u0194\7q\2\2\u0194\u0195\7q\2\2\u0195"+
"\u0196\7n\2\2\u0196D\3\2\2\2\u0197\u0198\7w\2\2\u0198\u0199\7k\2\2\u0199"+
"\u019a\7p\2\2\u019a\u019b\7v\2\2\u019b\u019c\7:\2\2\u019cF\3\2\2\2\u019d"+
"\u019e\7w\2\2\u019e\u019f\7k\2\2\u019f\u01a0\7p\2\2\u01a0\u01a1\7v\2\2"+
"\u01a1\u01a2\7\63\2\2\u01a2\u01a3\78\2\2\u01a3H\3\2\2\2\u01a4\u01a5\7"+
"w\2\2\u01a5\u01a6\7k\2\2\u01a6\u01a7\7p\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9"+
"\7\65\2\2\u01a9\u01aa\7\64\2\2\u01aaJ\3\2\2\2\u01ab\u01ac\7w\2\2\u01ac"+
"\u01ad\7k\2\2\u01ad\u01ae\7p\2\2\u01ae\u01af\7v\2\2\u01af\u01b0\78\2\2"+
"\u01b0\u01b1\7\66\2\2\u01b1L\3\2\2\2\u01b2\u01b3\7k\2\2\u01b3\u01b4\7"+
"p\2\2\u01b4\u01b5\7v\2\2\u01b5\u01b6\7:\2\2\u01b6N\3\2\2\2\u01b7\u01b8"+
"\7k\2\2\u01b8\u01b9\7p\2\2\u01b9\u01ba\7v\2\2\u01ba\u01bb\7\63\2\2\u01bb"+
"\u01bc\78\2\2\u01bcP\3\2\2\2\u01bd\u01be\7k\2\2\u01be\u01bf\7p\2\2\u01bf"+
"\u01c0\7v\2\2\u01c0\u01c1\7\65\2\2\u01c1\u01c2\7\64\2\2\u01c2R\3\2\2\2"+
"\u01c3\u01c4\7k\2\2\u01c4\u01c5\7p\2\2\u01c5\u01c6\7v\2\2\u01c6\u01c7"+
"\78\2\2\u01c7\u01c8\7\66\2\2\u01c8T\3\2\2\2\u01c9\u01ca\7h\2\2\u01ca\u01cb"+
"\7n\2\2\u01cb\u01cc\7q\2\2\u01cc\u01cd\7c\2\2\u01cd\u01ce\7v\2\2\u01ce"+
"\u01cf\7\65\2\2\u01cf\u01d0\7\64\2\2\u01d0V\3\2\2\2\u01d1\u01d2\7h\2\2"+
"\u01d2\u01d3\7n\2\2\u01d3\u01d4\7q\2\2\u01d4\u01d5\7c\2\2\u01d5\u01d6"+
"\7v\2\2\u01d6\u01d7\78\2\2\u01d7\u01d8\7\66\2\2\u01d8X\3\2\2\2\u01d9\u01da"+
"\7e\2\2\u01da\u01db\7q\2\2\u01db\u01dc\7o\2\2\u01dc\u01dd\7r\2\2\u01dd"+
"\u01de\7n\2\2\u01de\u01df\7g\2\2\u01df\u01e0\7z\2\2\u01e0\u01e1\78\2\2"+
"\u01e1\u01e2\7\66\2\2\u01e2Z\3\2\2\2\u01e3\u01e4\7e\2\2\u01e4\u01e5\7"+
"q\2\2\u01e5\u01e6\7o\2\2\u01e6\u01e7\7r\2\2\u01e7\u01e8\7n\2\2\u01e8\u01e9"+
"\7g\2\2\u01e9\u01ea\7z\2\2\u01ea\u01eb\7\63\2\2\u01eb\u01ec\7\64\2\2\u01ec"+
"\u01ed\7:\2\2\u01ed\\\3\2\2\2\u01ee\u01ef\7u\2\2\u01ef\u01f0\7v\2\2\u01f0"+
"\u01f1\7t\2\2\u01f1\u01f2\7k\2\2\u01f2\u01f3\7p\2\2\u01f3\u01f4\7i\2\2"+
"\u01f4^\3\2\2\2\u01f5\u01f6\7k\2\2\u01f6\u01f7\7p\2\2\u01f7\u01f8\7v\2"+
"\2\u01f8`\3\2\2\2\u01f9\u01fa\7w\2\2\u01fa\u01fb\7k\2\2\u01fb\u01fc\7"+
"p\2\2\u01fc\u01fd\7v\2\2\u01fdb\3\2\2\2\u01fe\u01ff\7w\2\2\u01ff\u0200"+
"\7k\2\2\u0200\u0201\7p\2\2\u0201\u0202\7v\2\2\u0202\u0203\7r\2\2\u0203"+
"\u0204\7v\2\2\u0204\u0205\7t\2\2\u0205d\3\2\2\2\u0206\u0207\7d\2\2\u0207"+
"\u0208\7{\2\2\u0208\u0209\7v\2\2\u0209\u020a\7g\2\2\u020af\3\2\2\2\u020b"+
"\u020c\7t\2\2\u020c\u020d\7w\2\2\u020d\u020e\7p\2\2\u020e\u020f\7g\2\2"+
"\u020fh\3\2\2\2\u0210\u0215\7\61\2\2\u0211\u0212\7\61\2\2\u0212\u0215"+
"\7<\2\2\u0213\u0215\7/\2\2\u0214\u0210\3\2\2\2\u0214\u0211\3\2\2\2\u0214"+
"\u0213\3\2\2\2\u0215\u0216\3\2\2\2\u0216\u0218\5\u0089E\2\u0217\u0214"+
"\3\2\2\2\u0218\u0219\3\2\2\2\u0219\u0217\3\2\2\2\u0219\u021a\3\2\2\2\u021a"+
"j\3\2\2\2\u021b\u021c\7*\2\2\u021cl\3\2\2\2\u021d\u021e\7+\2\2\u021en"+
"\3\2\2\2\u021f\u0220\7}\2\2\u0220p\3\2\2\2\u0221\u0222\7\177\2\2\u0222"+
"r\3\2\2\2\u0223\u0224\7]\2\2\u0224t\3\2\2\2\u0225\u0226\7_\2\2\u0226v"+
"\3\2\2\2\u0227\u0228\7\60\2\2\u0228x\3\2\2\2\u0229\u022a\7=\2\2\u022a"+
"z\3\2\2\2\u022b\u022c\7.\2\2\u022c|\3\2\2\2\u022d\u022e\7,\2\2\u022e~"+
"\3\2\2\2\u022f\u0230\7/\2\2\u0230\u0080\3\2\2\2\u0231\u0232\7?\2\2\u0232"+
"\u0082\3\2\2\2\u0233\u0234\7<\2\2\u0234\u0084\3\2\2\2\u0235\u0237\5\u0099"+
"M\2\u0236\u0235\3\2\2\2\u0237\u0238\3\2\2\2\u0238\u0236\3\2\2\2\u0238"+
"\u0239\3\2\2\2\u0239\u0086\3\2\2\2\u023a\u023c\5\u0099M\2\u023b\u023a"+
"\3\2\2\2\u023c\u023d\3\2\2\2\u023d\u023b\3\2\2\2\u023d\u023e\3\2\2\2\u023e"+
"\u023f\3\2\2\2\u023f\u0241\7\60\2\2\u0240\u0242\5\u0099M\2\u0241\u0240"+
"\3\2\2\2\u0242\u0243\3\2\2\2\u0243\u0241\3\2\2\2\u0243\u0244\3\2\2\2\u0244"+
"\u0245\3\2\2\2\u0245\u0247\7\60\2\2\u0246\u0248\5\u0099M\2\u0247\u0246"+
"\3\2\2\2\u0248\u0249\3\2\2\2\u0249\u0247\3\2\2\2\u0249\u024a\3\2\2\2\u024a"+
"\u024b\3\2\2\2\u024b\u024d\7\60\2\2\u024c\u024e\5\u0099M\2\u024d\u024c"+
"\3\2\2\2\u024e\u024f\3\2\2\2\u024f\u024d\3\2\2\2\u024f\u0250\3\2\2\2\u0250"+
"\u0088\3\2\2\2\u0251\u0254\5\u009dO\2\u0252\u0254\5\u009bN\2\u0253\u0251"+
"\3\2\2\2\u0253\u0252\3\2\2\2\u0254\u025b\3\2\2\2\u0255\u025a\5\u009dO"+
"\2\u0256\u025a\5\u0099M\2\u0257\u025a\5\u009bN\2\u0258\u025a\7/\2\2\u0259"+
"\u0255\3\2\2\2\u0259\u0256\3\2\2\2\u0259\u0257\3\2\2\2\u0259\u0258\3\2"+
"\2\2\u025a\u025d\3\2\2\2\u025b\u0259\3\2\2\2\u025b\u025c\3\2\2\2\u025c"+
"\u008a\3\2\2\2\u025d\u025b\3\2\2\2\u025e\u0260\t\2\2\2\u025f\u025e\3\2"+
"\2\2\u0260\u0261\3\2\2\2\u0261\u025f\3\2\2\2\u0261\u0262\3\2\2\2\u0262"+
"\u0263\3\2\2\2\u0263\u0264\bF\2\2\u0264\u008c\3\2\2\2\u0265\u0269\5\u0097"+
"L\2\u0266\u0268\n\3\2\2\u0267\u0266\3\2\2\2\u0268\u026b\3\2\2\2\u0269"+
"\u0267\3\2\2\2\u0269\u026a\3\2\2\2\u026a\u026c\3\2\2\2\u026b\u0269\3\2"+
"\2\2\u026c\u026d\5\u0097L\2\u026d\u008e\3\2\2\2\u026e\u0272\5\u0095K\2"+
"\u026f\u0271\n\4\2\2\u0270\u026f\3\2\2\2\u0271\u0274\3\2\2\2\u0272\u0270"+
"\3\2\2\2\u0272\u0273\3\2\2\2\u0273\u0275\3\2\2\2\u0274\u0272\3\2\2\2\u0275"+
"\u0276\5\u0095K\2\u0276\u0090\3\2\2\2\u0277\u027b\5\u0093J\2\u0278\u027a"+
"\n\5\2\2\u0279\u0278\3\2\2\2\u027a\u027d\3\2\2\2\u027b\u0279\3\2\2\2\u027b"+
"\u027c\3\2\2\2\u027c\u027e\3\2\2\2\u027d\u027b\3\2\2\2\u027e\u027f\bI"+
"\2\2\u027f\u0092\3\2\2\2\u0280\u0281\7\61\2\2\u0281\u0282\7\61\2\2\u0282"+
"\u0094\3\2\2\2\u0283\u0284\7b\2\2\u0284\u0096\3\2\2\2\u0285\u0286\7$\2"+
"\2\u0286\u0098\3\2\2\2\u0287\u0288\t\6\2\2\u0288\u009a\3\2\2\2\u0289\u028a"+
"\7a\2\2\u028a\u009c\3\2\2\2\u028b\u028c\t\7\2\2\u028c\u009e\3\2\2\2\u028d"+
"\u028e\t\b\2\2\u028e\u00a0\3\2\2\2\u028f\u0290\t\t\2\2\u0290\u00a2\3\2"+
"\2\2\u0291\u0292\7^\2\2\u0292\u029b\t\n\2\2\u0293\u0294\7^\2\2\u0294\u0295"+
"\t\13\2\2\u0295\u0296\5\u009fP\2\u0296\u0297\5\u009fP\2\u0297\u029b\3"+
"\2\2\2\u0298\u029b\5\u00a7T\2\u0299\u029b\5\u00a5S\2\u029a\u0291\3\2\2"+
"\2\u029a\u0293\3\2\2\2\u029a\u0298\3\2\2\2\u029a\u0299\3\2\2\2\u029b\u00a4"+
"\3\2\2\2\u029c\u029d\7^\2\2\u029d\u029e\t\f\2\2\u029e\u029f\5\u00a1Q\2"+
"\u029f\u02a0\5\u00a1Q\2\u02a0\u02a8\3\2\2\2\u02a1\u02a2\7^\2\2\u02a2\u02a3"+
"\5\u00a1Q\2\u02a3\u02a4\5\u00a1Q\2\u02a4\u02a8\3\2\2\2\u02a5\u02a6\7^"+
"\2\2\u02a6\u02a8\5\u00a1Q\2\u02a7\u029c\3\2\2\2\u02a7\u02a1\3\2\2\2\u02a7"+
"\u02a5\3\2\2\2\u02a8\u00a6\3\2\2\2\u02a9\u02aa\7^\2\2\u02aa\u02ab\7w\2"+
"\2\u02ab\u02ac\5\u009fP\2\u02ac\u02ad\5\u009fP\2\u02ad\u02ae\5\u009fP"+
"\2\u02ae\u02af\5\u009fP\2\u02af\u00a8\3\2\2\2\u02b0\u02b1\13\2\2\2\u02b1"+
"\u02b2\3\2\2\2\u02b2\u02b3\bU\2\2\u02b3\u00aa\3\2\2\2\26\2\u0100\u0145"+
"\u0190\u0214\u0219\u0238\u023d\u0243\u0249\u024f\u0253\u0259\u025b\u0261"+
"\u0269\u0272\u027b\u029a\u02a7\3\2\3\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}
| 24,477 | 0.624464 | 0.271316 | 391 | 61.60358 | 26.379948 | 130 | false | false | 0 | 0 | 72 | 0.006128 | 0 | 0 | 2.780051 | false | false |
14
|
4b3249eb1f2715dc08b695da923a922831107053
| 4,887,672,826,681 |
6bd9c61e356702d151d8566c4348c9d5e5de47be
|
/src/main/java/com/example/bootrabbitmq/BootRabbitmqApplication.java
|
a4b880239d08c1ad4826afcc3eea5b1d2d529152
|
[] |
no_license
|
yoxiyoxiiii/boot-rabbitmq
|
https://github.com/yoxiyoxiiii/boot-rabbitmq
|
02bfac42ed303550a99f55b1b32262c2db4b94dd
|
e89a7e0872243eb0b2d0a8d9f578dc3a6d538afa
|
refs/heads/master
| 2020-04-27T06:37:43.627000 | 2019-03-12T07:51:27 | 2019-03-12T07:51:27 | 174,114,095 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.bootrabbitmq;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class BootRabbitmqApplication {
public static void main(String[] args) {
SpringApplication.run(BootRabbitmqApplication.class, args);
}
}
|
UTF-8
|
Java
| 809 |
java
|
BootRabbitmqApplication.java
|
Java
|
[] | null |
[] |
package com.example.bootrabbitmq;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class BootRabbitmqApplication {
public static void main(String[] args) {
SpringApplication.run(BootRabbitmqApplication.class, args);
}
}
| 809 | 0.851669 | 0.851669 | 23 | 34.173912 | 25.737221 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.73913 | false | false |
14
|
98b8d7e8b9e143002de829e134475c4c554a217d
| 18,811,956,797,227 |
8c4478e793d5fc380abc6306c1eb417239b1a117
|
/iOS/gongan/branch/onlinepolice/server/picStoryServer/src/main/java/com/towne/framework/spring/jdbc/dao/CategoryDao.java
|
4d05ed0a936bccbede9c2356cd4adb0296b5d3a6
|
[] |
no_license
|
dymx101/PicStory
|
https://github.com/dymx101/PicStory
|
464ba10143225eac01f53326ef5bff67b88905ab
|
28a3f767b648a342e219c93a08b7071b2bc8506f
|
refs/heads/master
| 2016-09-06T16:55:01.677000 | 2013-07-14T05:55:45 | 2013-07-14T05:55:45 | 8,771,808 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.towne.framework.spring.jdbc.dao;
import com.towne.framework.common.dao.IDao;
import com.towne.framework.spring.jdbc.model.Category;
public interface CategoryDao extends IDao<Category> {
}
|
UTF-8
|
Java
| 203 |
java
|
CategoryDao.java
|
Java
|
[] | null |
[] |
package com.towne.framework.spring.jdbc.dao;
import com.towne.framework.common.dao.IDao;
import com.towne.framework.spring.jdbc.model.Category;
public interface CategoryDao extends IDao<Category> {
}
| 203 | 0.807882 | 0.807882 | 8 | 24.375 | 24.387177 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false |
14
|
787fdf308c7c9d5c3bc6d7d2fe754a74063d1044
| 17,265,768,583,998 |
73991813c710727ed689b7b19dc1052b06ea492e
|
/src/lolnotepad/Game.java
|
9b1c724272bac6acfbcf1fde5b9306786a810c3e
|
[] |
no_license
|
havlicekdom/league-notepad
|
https://github.com/havlicekdom/league-notepad
|
a628594c7fe0b08fc1f378bf374934f728da2d5b
|
16184709c130c074f15f65406bf526dc4a7d0bd2
|
refs/heads/master
| 2020-02-26T06:45:54.850000 | 2013-10-26T08:09:21 | 2013-10-26T08:09:21 | 34,659,928 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package lolnotepad;
/**
*
* @author havlicekdom@gmail.com
*/
public class Game {
private String champion, role, enemy, difficulty, result, score, gameType, currentPoints, currentLeague, notes;
public Game(String[] setTo) {
this.champion = setTo[0];
this.role = setTo[1];
this.enemy = setTo[2];
this.difficulty = setTo[3];
this.result = setTo[4];
this.score = setTo[5];
this.gameType = setTo[6];
this.currentPoints = setTo[7];
this.currentLeague = setTo[8];
this.notes = setTo[9];
}
public void unset() {
this.champion = "";
this.role = "";
this.enemy = "";
this.difficulty = "";
this.result = "";
this.score = "";
this.gameType = "";
this.currentPoints = "";
this.currentLeague = "";
this.notes = "";
}
public void setChampion(String setTo) {
this.champion = setTo;
}
public void setLeague(String setTo) {
this.currentLeague = setTo;
}
public void setRole(String setTo) {
this.role = setTo;
}
public void setEnemy(String setTo) {
this.enemy = setTo;
}
public void setDifficulty(String setTo) {
this.difficulty = setTo;
}
public void setResult(String setTo) {
this.result = setTo;
}
public void setScore(String setTo) {
this.score = setTo;
}
public void setGameType(String setTo) {
this.gameType = setTo;
}
public void setPoints(String setTo) {
this.currentPoints = setTo;
}
public void setNotes(String setTo) {
this.notes = setTo;
}
public String getChampion() {
return this.champion;
}
public String getRole() {
return this.role;
}
public String getEnemy() {
return this.enemy;
}
public String getDifficulty() {
return this.difficulty;
}
public String getResult() {
return this.result;
}
public String getScore() {
return this.score;
}
public String getGameType() {
return this.gameType;
}
public String getPoints() {
return this.currentPoints;
}
public String getLeague() {
return this.currentLeague;
}
public String getNotes() {
return this.notes;
}
}
|
UTF-8
|
Java
| 2,506 |
java
|
Game.java
|
Java
|
[
{
"context": "package lolnotepad;\r\n\r\n/**\r\n *\r\n * @author havlicekdom@gmail.com\r\n */\r\npublic class Game {\r\n\r\n private String c",
"end": 64,
"score": 0.9999065399169922,
"start": 43,
"tag": "EMAIL",
"value": "havlicekdom@gmail.com"
}
] | null |
[] |
package lolnotepad;
/**
*
* @author <EMAIL>
*/
public class Game {
private String champion, role, enemy, difficulty, result, score, gameType, currentPoints, currentLeague, notes;
public Game(String[] setTo) {
this.champion = setTo[0];
this.role = setTo[1];
this.enemy = setTo[2];
this.difficulty = setTo[3];
this.result = setTo[4];
this.score = setTo[5];
this.gameType = setTo[6];
this.currentPoints = setTo[7];
this.currentLeague = setTo[8];
this.notes = setTo[9];
}
public void unset() {
this.champion = "";
this.role = "";
this.enemy = "";
this.difficulty = "";
this.result = "";
this.score = "";
this.gameType = "";
this.currentPoints = "";
this.currentLeague = "";
this.notes = "";
}
public void setChampion(String setTo) {
this.champion = setTo;
}
public void setLeague(String setTo) {
this.currentLeague = setTo;
}
public void setRole(String setTo) {
this.role = setTo;
}
public void setEnemy(String setTo) {
this.enemy = setTo;
}
public void setDifficulty(String setTo) {
this.difficulty = setTo;
}
public void setResult(String setTo) {
this.result = setTo;
}
public void setScore(String setTo) {
this.score = setTo;
}
public void setGameType(String setTo) {
this.gameType = setTo;
}
public void setPoints(String setTo) {
this.currentPoints = setTo;
}
public void setNotes(String setTo) {
this.notes = setTo;
}
public String getChampion() {
return this.champion;
}
public String getRole() {
return this.role;
}
public String getEnemy() {
return this.enemy;
}
public String getDifficulty() {
return this.difficulty;
}
public String getResult() {
return this.result;
}
public String getScore() {
return this.score;
}
public String getGameType() {
return this.gameType;
}
public String getPoints() {
return this.currentPoints;
}
public String getLeague() {
return this.currentLeague;
}
public String getNotes() {
return this.notes;
}
}
| 2,492 | 0.53352 | 0.529529 | 118 | 19.237288 | 17.417933 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.432203 | false | false |
14
|
788ab163b8403ff98a82cff5733c919501d65823
| 12,163,347,427,037 |
a7ce737f8c48794a0757d7c7db7068bf3d814f45
|
/Arkanoid/src/ABoard.java
|
c805d58048b5f601e7f940697c51b6ab7bb1d2e6
|
[] |
no_license
|
Hydrapanther/Games
|
https://github.com/Hydrapanther/Games
|
1891f12b1b52a39ea8eece9d23e638d3621da86b
|
5fcc76b546a149d39a292853be93809985ca01e9
|
refs/heads/main
| 2023-02-02T06:16:58.604000 | 2020-12-21T04:06:40 | 2020-12-21T04:06:40 | 311,573,269 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.*;
public class ABoard
{
private int rows;
private int cols;
private int total;
final static int OFFSETX = 10;
final static int OFFSETY = 20;
static Block[][] grid;
private boolean firstClick = true;
JPanel panel;
Bumper b;
Ball ball;
public ABoard(int rows, int cols, Bumper bee, Ball bleh)
{
this.rows = rows;
this.cols = cols;
total = rows*cols;
this.setup();
b = bee;
ball = bleh;
}
public void setup()
{
grid = new Block[rows][cols];
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c] = new Block(r, c);
}
}
}
public int deconstructComponent(int x, int y)
{
//TODO goal to determine if ball is touching a block, and how the ball should ricochet (horizontal or vertical), as well as break the block touched.
int[] coords = findCords(x,y);
if(coords[0] < grid.length && coords[1] < grid[0].length && coords[0] >= 0 && coords[1] >= 0)
{
if(grid[coords[0]][coords[1]].getState() != 1)
{
grid[coords[0]][coords[1]].breakit();
if((x - this.OFFSETX)%Block.getLength() <=5 || (x - this.OFFSETX)%Block.getLength() >= Block.getLength()-5)
{
ball.bounceHor();
}
if((y - this.OFFSETY)%Block.getHeight() <=5 || (y - this.OFFSETY)%Block.getHeight() >= Block.getHeight()-5)
{
ball.bounceVert();
}
}
}
return -1;
}
public int[] findCords(int x, int y)
{
//finds the coordinates of the block to be hit
int cCord = (x - this.OFFSETX)/Block.getLength();
int rCord = (y - this.OFFSETY)/Block.getHeight();
int[] returnval = new int[]{rCord, cCord};
return returnval;
}
public void draw(Graphics g)
{
Block.counter = 0;
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c].draw(g);
}
}
b.draw(g);
ball.draw(g);
}
public void reset()
{
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c].reset();
}
}
}
public void sayHi() //testing purposes
{
System.out.println("hi!");
}
}
|
UTF-8
|
Java
| 2,411 |
java
|
ABoard.java
|
Java
|
[] | null |
[] |
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.*;
public class ABoard
{
private int rows;
private int cols;
private int total;
final static int OFFSETX = 10;
final static int OFFSETY = 20;
static Block[][] grid;
private boolean firstClick = true;
JPanel panel;
Bumper b;
Ball ball;
public ABoard(int rows, int cols, Bumper bee, Ball bleh)
{
this.rows = rows;
this.cols = cols;
total = rows*cols;
this.setup();
b = bee;
ball = bleh;
}
public void setup()
{
grid = new Block[rows][cols];
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c] = new Block(r, c);
}
}
}
public int deconstructComponent(int x, int y)
{
//TODO goal to determine if ball is touching a block, and how the ball should ricochet (horizontal or vertical), as well as break the block touched.
int[] coords = findCords(x,y);
if(coords[0] < grid.length && coords[1] < grid[0].length && coords[0] >= 0 && coords[1] >= 0)
{
if(grid[coords[0]][coords[1]].getState() != 1)
{
grid[coords[0]][coords[1]].breakit();
if((x - this.OFFSETX)%Block.getLength() <=5 || (x - this.OFFSETX)%Block.getLength() >= Block.getLength()-5)
{
ball.bounceHor();
}
if((y - this.OFFSETY)%Block.getHeight() <=5 || (y - this.OFFSETY)%Block.getHeight() >= Block.getHeight()-5)
{
ball.bounceVert();
}
}
}
return -1;
}
public int[] findCords(int x, int y)
{
//finds the coordinates of the block to be hit
int cCord = (x - this.OFFSETX)/Block.getLength();
int rCord = (y - this.OFFSETY)/Block.getHeight();
int[] returnval = new int[]{rCord, cCord};
return returnval;
}
public void draw(Graphics g)
{
Block.counter = 0;
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c].draw(g);
}
}
b.draw(g);
ball.draw(g);
}
public void reset()
{
for(int r = 0; r < grid.length; r++)
{
for(int c = 0; c < grid[0].length; c++)
{
grid[r][c].reset();
}
}
}
public void sayHi() //testing purposes
{
System.out.println("hi!");
}
}
| 2,411 | 0.568644 | 0.555786 | 114 | 19.149122 | 24.263985 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.350877 | false | false |
14
|
ff07ac7b234bd27ef2f49b49fe975d02b93113f3
| 26,749,056,371,786 |
3661156f54912147f68bafd3fab26201a5e65d0a
|
/src/coffeetable/algorithms/MatrixMultiplier.java
|
6ff01768208aba8c66212003d7f85e334bcf1bc2
|
[
"MIT"
] |
permissive
|
ewake24/CoffeeTable
|
https://github.com/ewake24/CoffeeTable
|
1353ede185ea30f9f9fe58da008480d80ae3c01b
|
c8a512f642490abbd5385c237ffebe83d14278f6
|
refs/heads/master
| 2020-12-28T20:20:09.711000 | 2015-01-04T20:04:08 | 2015-01-04T20:04:08 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package coffeetable.algorithms;
import java.util.TreeMap;
import coffeetable.datastructures.DataColumn;
import coffeetable.datastructures.DataRow;
import coffeetable.utils.MatrixViabilityException;
import coffeetable.datastructures.Matrix;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class MatrixMultiplier {
private final Matrix<? extends Number> arg0;
private final Matrix<? extends Number> arg1;
public MatrixMultiplier(Matrix<? extends Number> arg0, Matrix<? extends Number> arg1) {
if(!checkViability(arg0, arg1))
throw new MatrixViabilityException();
this.arg0 = arg0;
this.arg1 = arg1;
}
public final static boolean checkViability(Matrix arg0, Matrix arg1) {
return arg0.ncol() == arg1.nrow() && !arg0.containsNA() && !arg1.containsNA();
}
public static Matrix multiply(Matrix arg0, Matrix arg1) {
if(!checkViability(arg0, arg1))
throw new MatrixViabilityException();
int outDims = arg0.nrow();
TreeMap<Integer, DataColumn> mapOut = new TreeMap<Integer, DataColumn>();
for(int i=0; i < outDims; i++)
mapOut.put(i, new DataColumn("Col"+Integer.valueOf(i+1).toString()));
for(Object row : arg0.rows()) {
int colIdx = 0;
DataColumn leftTmp = ((DataRow)row).toDataColumn();
for(Object column : arg1.columns())
mapOut.get(colIdx++).add( leftTmp.innerProduct((DataColumn)column) );
}
return new Matrix(mapOut.values());
}
public Matrix<? extends Number> multiply() {
if(null == arg0 || null == arg1)
throw new NullPointerException();
return multiply(arg0, arg1);
}
}
|
UTF-8
|
Java
| 1,560 |
java
|
MatrixMultiplier.java
|
Java
|
[] | null |
[] |
package coffeetable.algorithms;
import java.util.TreeMap;
import coffeetable.datastructures.DataColumn;
import coffeetable.datastructures.DataRow;
import coffeetable.utils.MatrixViabilityException;
import coffeetable.datastructures.Matrix;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class MatrixMultiplier {
private final Matrix<? extends Number> arg0;
private final Matrix<? extends Number> arg1;
public MatrixMultiplier(Matrix<? extends Number> arg0, Matrix<? extends Number> arg1) {
if(!checkViability(arg0, arg1))
throw new MatrixViabilityException();
this.arg0 = arg0;
this.arg1 = arg1;
}
public final static boolean checkViability(Matrix arg0, Matrix arg1) {
return arg0.ncol() == arg1.nrow() && !arg0.containsNA() && !arg1.containsNA();
}
public static Matrix multiply(Matrix arg0, Matrix arg1) {
if(!checkViability(arg0, arg1))
throw new MatrixViabilityException();
int outDims = arg0.nrow();
TreeMap<Integer, DataColumn> mapOut = new TreeMap<Integer, DataColumn>();
for(int i=0; i < outDims; i++)
mapOut.put(i, new DataColumn("Col"+Integer.valueOf(i+1).toString()));
for(Object row : arg0.rows()) {
int colIdx = 0;
DataColumn leftTmp = ((DataRow)row).toDataColumn();
for(Object column : arg1.columns())
mapOut.get(colIdx++).add( leftTmp.innerProduct((DataColumn)column) );
}
return new Matrix(mapOut.values());
}
public Matrix<? extends Number> multiply() {
if(null == arg0 || null == arg1)
throw new NullPointerException();
return multiply(arg0, arg1);
}
}
| 1,560 | 0.716026 | 0.696795 | 50 | 30.200001 | 24.593494 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.16 | false | false |
14
|
9cc8fa4d4183518564f39dd1e1b9219f7af28e63
| 26,482,768,392,195 |
1e96133bd0b00a84f67e9ea9c365cf21cf572189
|
/app/src/main/java/com/weaver/teams/task/TargetListLoader.java
|
41bbb3c34c737afbc528132d928e3820446e9d6f
|
[] |
no_license
|
BingYeh/SecondWorkSrc
|
https://github.com/BingYeh/SecondWorkSrc
|
880a1aa71efb3bd55c808111ec3ea5d3019f2d05
|
28bec15f97ff52afeae3a17f653aae58b1f023c4
|
refs/heads/master
| 2016-09-13T19:05:22.009000 | 2016-05-10T09:12:48 | 2016-05-10T09:12:48 | 58,446,472 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.weaver.teams.task;
import java.util.ArrayList;
import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import com.weaver.teams.logic.EmployeeManage;
import com.weaver.teams.logic.MainlineManage;
import com.weaver.teams.model.Mainline;
import com.weaver.teams.model.SearchParam;
public class TargetListLoader extends AsyncTaskLoader<ArrayList<Mainline>> {
private ArrayList<Mainline> mData;
private Context mContext;
private String userId;
private SearchParam searchParam;
private MainlineManage mMainlineManage;
private EmployeeManage mEmployeeManage;
public TargetListLoader(Context context, SearchParam searchParam,
String userId) {
super(context);
this.userId = userId;
mContext = context;
this.searchParam = searchParam;
mMainlineManage = MainlineManage.getInstance(mContext);
mEmployeeManage = EmployeeManage.getInstance(mContext);
}
@Override
public ArrayList<Mainline> loadInBackground() {
ArrayList<Mainline> mainlines = new ArrayList<Mainline>();
if (searchParam != null) {
mainlines = mMainlineManage.loadAllMainlineByFilter(userId,
searchParam);
}
return mainlines;
}
@Override
public void onCanceled(ArrayList<Mainline> data) {
super.onCanceled(data);
onReleaseResources(mData);
}
@Override
public void deliverResult(ArrayList<Mainline> data) {
super.deliverResult(data);
if (isReset()) {
onReleaseResources(mData);
return;
}
ArrayList<Mainline> oldData = mData;
mData = data;
if (isStarted()) {
super.deliverResult(data);
}
if (oldData != null && oldData != data) {
onReleaseResources(oldData);
}
}
@Override
protected void onReset() {
onStopLoading();
if (mData != null) {
onReleaseResources(mData);
mData = null;
}
}
@Override
protected void onStartLoading() {
super.onStartLoading();
if (mData != null)
deliverResult(mData);
if (takeContentChanged() || mData == null)
forceLoad();
}
@Override
protected void onStopLoading() {
cancelLoad();
}
protected void onReleaseResources(ArrayList<Mainline> data) {
}
}
|
UTF-8
|
Java
| 2,455 |
java
|
TargetListLoader.java
|
Java
|
[] | null |
[] |
package com.weaver.teams.task;
import java.util.ArrayList;
import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import com.weaver.teams.logic.EmployeeManage;
import com.weaver.teams.logic.MainlineManage;
import com.weaver.teams.model.Mainline;
import com.weaver.teams.model.SearchParam;
public class TargetListLoader extends AsyncTaskLoader<ArrayList<Mainline>> {
private ArrayList<Mainline> mData;
private Context mContext;
private String userId;
private SearchParam searchParam;
private MainlineManage mMainlineManage;
private EmployeeManage mEmployeeManage;
public TargetListLoader(Context context, SearchParam searchParam,
String userId) {
super(context);
this.userId = userId;
mContext = context;
this.searchParam = searchParam;
mMainlineManage = MainlineManage.getInstance(mContext);
mEmployeeManage = EmployeeManage.getInstance(mContext);
}
@Override
public ArrayList<Mainline> loadInBackground() {
ArrayList<Mainline> mainlines = new ArrayList<Mainline>();
if (searchParam != null) {
mainlines = mMainlineManage.loadAllMainlineByFilter(userId,
searchParam);
}
return mainlines;
}
@Override
public void onCanceled(ArrayList<Mainline> data) {
super.onCanceled(data);
onReleaseResources(mData);
}
@Override
public void deliverResult(ArrayList<Mainline> data) {
super.deliverResult(data);
if (isReset()) {
onReleaseResources(mData);
return;
}
ArrayList<Mainline> oldData = mData;
mData = data;
if (isStarted()) {
super.deliverResult(data);
}
if (oldData != null && oldData != data) {
onReleaseResources(oldData);
}
}
@Override
protected void onReset() {
onStopLoading();
if (mData != null) {
onReleaseResources(mData);
mData = null;
}
}
@Override
protected void onStartLoading() {
super.onStartLoading();
if (mData != null)
deliverResult(mData);
if (takeContentChanged() || mData == null)
forceLoad();
}
@Override
protected void onStopLoading() {
cancelLoad();
}
protected void onReleaseResources(ArrayList<Mainline> data) {
}
}
| 2,455 | 0.631772 | 0.631365 | 93 | 25.39785 | 20.090195 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.473118 | false | false |
14
|
ebd63bf4688df2dcdb0f8db3d6b85dc828e309c3
| 25,400,436,635,451 |
f6492aeb1541a28929443b1059c57fec149d5030
|
/ImperiusB/CustomControls/src/com/beta/UIControls/CAbLinearSeekBar.java
|
eda5b3c432bb3c7be5db06e4b9a44d833d63feb2
|
[] |
no_license
|
MIDIeval/MIDIeval
|
https://github.com/MIDIeval/MIDIeval
|
9d24947b426eb379fcef91d0828b522ff6cc6d9c
|
6e30a273b6d75b1bac15724242baf24276aa435a
|
refs/heads/master
| 2020-12-24T08:15:07.033000 | 2016-08-08T20:47:50 | 2016-08-08T20:47:50 | 13,016,176 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.beta.UIControls;
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import com.beta.UIControls.CProgressBar.IThumbConflictListener;
import com.customcontrol.seekbar.R;
public abstract class CAbLinearSeekBar extends CProgressBar implements IThumbConflictListener {
// private Drawable thumbDrawable_m;
// private Drawable thumbDrawableHigh_m;
private ThumbManager[] thumbManagerVector_m;
private Drawable selectedThumb_m;
private int i_ThumbOffset_m;
private int mPaddingLeft;
private int mPaddingTop;
private int mPaddingRight;
private int mPaddingBottom;
private Rect[] rectBounds_m = new Rect[2];;//[0] low Thumb bound; [1] hight Thumb bound
private boolean b_IsIncreasing_m = false;
/**
* On touch, this offset plus the scaled value from the position of the
* touch will form the progress value. Usually 0.
*/
float f_TouchProgressOffset_m;
/**
* Whether this is user seekable.
*/
boolean bIsUserSeekable_m = true;
/**
* On key presses (right or left), the amount to increment/decrement the
* progress.
*/
private int iKeyProgressIncrement_m = 1;
private static final int NO_ALPHA = 0xFF;
private float f_DisabledAlpha_m;
public CAbLinearSeekBar(Context context) {
super(context);
}
public CAbLinearSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CAbLinearSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray attributeSetSpecified_f = context.obtainStyledAttributes(attrs,
R.styleable.CLinearSeekBar, defStyle, 0);
Drawable thumbDrawable_f = attributeSetSpecified_f.getDrawable(R.styleable.CLinearSeekBar_android_thumb);
Drawable thumbDrawableHigh_f= attributeSetSpecified_f.getDrawable(R.styleable.CLinearSeekBar_thumb_high);
if ( this.getProgressType() == 0){
this.thumbManagerVector_m = new ThumbManager[1];
this.thumbManagerVector_m[0] = new ThumbManager(thumbDrawable_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.LOW, super.getProgressType());
}
else{
this.thumbManagerVector_m = new ThumbManager[2];
this.thumbManagerVector_m[0] = new ThumbManager(thumbDrawable_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.LOW, super.getProgressType());
this.thumbManagerVector_m[1] = new ThumbManager(thumbDrawableHigh_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.HIGH, super.getProgressType());
}
int i_ThumbOffset_f =
attributeSetSpecified_f.getDimensionPixelOffset(R.styleable.CLinearSeekBar_android_thumbOffset, 0);
setThumbOffset(i_ThumbOffset_f);
this.f_DisabledAlpha_m = attributeSetSpecified_f.getFloat(R.styleable.CLinearSeekBar_android_disabledAlpha, 0.5f);
if(thumbDrawableHigh_f != null ){
setThumbOffset(i_ThumbOffset_f);//Look to set a second offset for the second thumb, the high thumb
}
attributeSetSpecified_f.recycle();
this.mPaddingBottom = this.getPaddingBottom();
this.mPaddingLeft = this.getPaddingLeft();
this.mPaddingTop = this.getPaddingTop();
this.mPaddingRight = this.getPaddingRight();
this.setThumbConflictListener(this);
}
/**
* Sets the thumb that will be drawn at the end of the progress meter within the SeekBar
*
* @param thumb Drawable representing the thumb
*/
/**
* @see #setThumbOffset(int)
*/
public int getThumbOffset() {
return this.i_ThumbOffset_m;
}
/**
* Sets the thumb offset that allows the thumb to extend out of the range of
* the track.
*
* @param thumbOffset The offset amount in pixels.
*/
public void setThumbOffset(int thumbOffset) {
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( this.thumbManagerVector_m[iCount] != null ){
this.thumbManagerVector_m[iCount].setThumbOffset(thumbOffset);
}
}
invalidate();
}
/**
* Sets the amount of progress changed via the arrow keys.
*
* @param increment The amount to increment or decrement when the user
* presses the arrow keys.
*/
public void setKeyProgressIncrement(int increment) {
this.iKeyProgressIncrement_m = increment < 0 ? -increment : increment;
}
/**
* Returns the amount of progress changed via the arrow keys.
* <p>
* By default, this will be a value that is derived from the max progress.
*
* @return The amount to increment or decrement when the user presses the
* arrow keys. This will be positive.
*/
public int getKeyProgressIncrement() {
return this.iKeyProgressIncrement_m;
}
@Override
public synchronized void setMax(int max) {
super.setMax(max);
if ((this.iKeyProgressIncrement_m == 0) || (getMax() / this.iKeyProgressIncrement_m > 20)) {
// It will take the user too long to change this via keys, change it
// to something more reasonable
setKeyProgressIncrement(Math.max(1, Math.round((float) getMax() / 20)));
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable progressDrawable = getProgressDrawable();
if (progressDrawable != null) {
progressDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * this.f_DisabledAlpha_m));
}
if ( this.thumbManagerVector_m == null )
return;
Drawable thumbDrawable = null;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null){
thumbDrawable = this.thumbManagerVector_m[iCount].getThumbDrawable();
if (thumbDrawable != null && thumbDrawable.isStateful()){
int[] state = getDrawableState();
this.thumbManagerVector_m[iCount].getThumbDrawable().setState(state);
}
}
}
}
@Override
protected void onProgressRefresh(float[] scale, boolean fromUser) {
if ( this.thumbManagerVector_m == null )
return;
Drawable thumbDrawable_f = this.selectedThumb_m;
if ( thumbDrawable_f == null )
return;
for (int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if (this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
if ( this.thumbManagerVector_m[iCount].getThumbType() == THUMB_TYPE.HIGH)
scale[iCount] = 1 - scale[iCount];
if(this.thumbManagerVector_m[iCount].fn_IsThisThumb(this.selectedThumb_m)){
setThumbPos((this.getOrientation() == 0)?getWidth():getHeight(), this.thumbManagerVector_m[iCount], scale[iCount], Integer.MIN_VALUE);
}
else{
if ( this.thumbManagerVector_m[iCount].fn_IsConnectedToOtherThumb(selectedThumb_m)){
Log.i("CONNECTED", "THUMBS CONNECTED");
setThumbPos((this.getOrientation() == 0)?getWidth():getHeight(), this.thumbManagerVector_m[iCount], scale[iCount], Integer.MIN_VALUE);
}
}
}
}
}
/*
* Since we draw translated, the drawable's bounds that it signals
* for invalidation won't be the actual bounds we want invalidated,
* so just invalidate this whole view.
*/
invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
//Get the progress bar details and set the size information as required
Drawable d = getCurrentDrawable();
int i_TrackAvailableDimension_f = (this.getOrientation() == 0 )? Math.min(super.i_MaxHeight_m, h - super.getPaddingTop() - super.getPaddingBottom()):
Math.min(super.i_MaxWidth_m, w - super.getPaddingLeft() - super.getPaddingRight());
i_TrackAvailableDimension_f = (this.getOrientation() == 0)?Math.min(d.getIntrinsicHeight(), h - super.getPaddingTop() - super.getPaddingBottom()):
Math.min(d.getIntrinsicWidth(), w - super.getPaddingLeft() - super.getPaddingRight());
if ( this.thumbManagerVector_m == null )
return;
//Parameters comoon for both SINGLE and DUAL mode
Drawable thumbDrawable_f;
int max = getMax();
float[] f_Progress_f = new float[this.thumbManagerVector_m.length];
float[] scale = new float[this.thumbManagerVector_m.length];
int gapForCenteringTrack = 0;
int i_PreviousThumbDimension_f = 0;
Rect progressDrawableBounds_f = new Rect();
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
this.thumbManagerVector_m[iCount].setContainerView(this);
this.thumbManagerVector_m[iCount].setMinThumbPadding((int)((super.getMinMaxPadding()/(float)super.getMax())*((this.getOrientation() == 0)?this.getWidth():this.getHeight())));
thumbDrawable_f = this.thumbManagerVector_m[iCount].getThumbDrawable();
int i_ThumbAvailableDimension_f = thumbDrawable_f == null ? 0 : ((this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth());
f_Progress_f[iCount] = getProgress()[iCount];
scale[iCount] = (max > 0 ? (f_Progress_f[iCount]) / (float) max : 0);
int gap = 0;
if ( i_ThumbAvailableDimension_f >= i_PreviousThumbDimension_f){
if ( i_ThumbAvailableDimension_f > i_TrackAvailableDimension_f ){
gapForCenteringTrack = (i_ThumbAvailableDimension_f - i_TrackAvailableDimension_f) / 2;
progressDrawableBounds_f.left = (this.getOrientation() == 0)?0:gapForCenteringTrack;
progressDrawableBounds_f.top = (this.getOrientation() == 0)?gapForCenteringTrack:0;
progressDrawableBounds_f.right = (this.getOrientation() == 0)? (w - this.getPaddingRight() - this.getPaddingLeft()):
(w - this.getPaddingRight() - this.getPaddingLeft() - gapForCenteringTrack);
progressDrawableBounds_f.bottom = (this.getOrientation() == 0)? (h - this.getPaddingBottom() - gapForCenteringTrack - this.getPaddingTop())
:h - this.getPaddingBottom() - this.getPaddingTop();
}
else {
progressDrawableBounds_f.left = 0;
progressDrawableBounds_f.top = 0;
progressDrawableBounds_f.right = (w - this.getPaddingTop() - this.getPaddingRight());
progressDrawableBounds_f.bottom = (h - this.getPaddingBottom() - this.getPaddingTop());
gap = (i_TrackAvailableDimension_f - i_ThumbAvailableDimension_f) / 2;
}
}
if (thumbDrawable_f != null) {
setThumbPos((this.getOrientation() == 0)?w:h, thumbManagerVector_m[iCount], scale[iCount], gap);
}
i_PreviousThumbDimension_f = i_ThumbAvailableDimension_f;
}
}
}
//Draw the track, irrespective of how many thumbs there are in the View
if (d != null) {
// Canvas will be translated by the padding, so 0,0 is where we start drawing
d.setBounds(progressDrawableBounds_f);
}
}
/**
* @param gap If set to {@link Integer#MIN_VALUE}, this will be ignored and
*/
private void setThumbPos(int dimension, ThumbManager thumbManager, float scale, int gap) {
if ( thumbManager == null )
return;
Drawable thumbDrawable_f = thumbManager.getThumbDrawable();
if ( thumbDrawable_f == null )
return;
int i_AvailableDimension_f = ( this.getOrientation() == 0 )? (dimension - mPaddingLeft - mPaddingRight):
(dimension - mPaddingTop - mPaddingBottom) ;
int i_ThumbSliderDimension_f = (this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicWidth():thumbDrawable_f.getIntrinsicHeight();
int i_ThumbStaticDimension_f = (this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth();
i_AvailableDimension_f = i_AvailableDimension_f - i_ThumbSliderDimension_f;
i_AvailableDimension_f += thumbManager.getThumbOffset() * 2;
int i_ThumbPos_f = (int) (scale * i_AvailableDimension_f);
int i_Border_Bound_0, i_Border_Bound_1;
if (gap == Integer.MIN_VALUE) {
Rect oldBounds = thumbDrawable_f.getBounds();
i_Border_Bound_0 = (this.getOrientation() == 0)?oldBounds.top:oldBounds.left;
i_Border_Bound_1 = (this.getOrientation() == 0)?oldBounds.bottom:oldBounds.right;
}
else
{
i_Border_Bound_0 = gap;
i_Border_Bound_1 = gap + i_ThumbStaticDimension_f;
}
Rect rectBoundsForDraw = thumbManager.getRectBoundsForDraw();
rectBoundsForDraw.left = (this.getOrientation() == 0) ? i_ThumbPos_f:i_Border_Bound_0;
rectBoundsForDraw.top = (this.getOrientation() == 0)? i_Border_Bound_0:(dimension - i_ThumbSliderDimension_f - i_ThumbPos_f);
rectBoundsForDraw.right = (this.getOrientation() == 0)? (i_ThumbPos_f + i_ThumbSliderDimension_f):i_Border_Bound_1;
rectBoundsForDraw.bottom = (this.getOrientation() == 0)?i_Border_Bound_1:(dimension - i_ThumbPos_f);
//set the drawable region for the Thumb
thumbManager.setRectBoundsForDraw(rectBoundsForDraw);
thumbDrawable_f.setBounds(rectBoundsForDraw);
this.fn_SetDualProgressTypeBound(this.getProgress());//This is the corrected progress vector
}
public void fn_SetDualProgressTypeBound(int[] progress){
if ( this.getProgressType() == 0 ){
this.thumbManagerVector_m[0].setRectBoundsForTouchResponse(null);
return;
}
Rect rectBounds_f[] = new Rect[2];
float difference_f = (progress[1] - progress[0])/2;
float midPoint_f = difference_f + progress[0];
float scale_f = midPoint_f/this.getMax();
float location_f = scale_f*((this.getOrientation() == 0)?this.getWidth():this.getHeight());
if ( this.getOrientation() == 0){
for(int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().top = 0;
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().bottom = this.getHeight() + 1;
}
}
else if ( this.getOrientation() == 1){
for(int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().left = 0;
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().right = this.getWidth()+ 1;
}
}
if ( this.thumbManagerVector_m == null )
return;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( this.thumbManagerVector_m[iCount] != null ){
Log.i(VIEW_LOG_TAG, String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().left)
+","+String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().top)
+","+String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().right)
+","+ String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().bottom));
rectBounds_f[iCount] = this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse();
if ( super.getOrientation() == 0 ){
if ( iCount == 0)
rectBounds_f[iCount].right = (int)Math.floor(location_f) + 1;
else{
rectBounds_f[iCount].left = (int)Math.ceil(location_f);
rectBounds_f[iCount].right = (int)Math.ceil(this.getWidth()) + 1;
}
}
else if ( super.getOrientation() == 1){
if ( iCount == 0 ){
rectBounds_f[iCount].bottom = (int)Math.ceil(this.getHeight()) + 1;
rectBounds_f[iCount].top = (int)(this.getHeight() - Math.ceil(location_f));
}
else{
rectBounds_f[iCount].bottom = (int)(this.getHeight() - Math.ceil(location_f)) + 1;
}
}
this.thumbManagerVector_m[iCount].setRectBoundsForTouchResponse(rectBounds_f[iCount]);
}
}
}
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
if ( thumbManagerVector_m == null )
return;
canvas.save();
// Translate the padding. For the x, we need to allow the thumb to
// draw in its extra space
canvas.translate(mPaddingLeft - mPaddingLeft, mPaddingTop);
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if (this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
this.thumbManagerVector_m[iCount].getThumbDrawable().draw(canvas);
}
}
}
canvas.restore();
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if ( this.thumbManagerVector_m == null )
return;
Drawable progressDrawable_f = getCurrentDrawable();
int dw = 0;
int dh = 0;
int i_PreviousDimension_f = 0;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
Drawable thumbDrawable_f = this.thumbManagerVector_m[iCount].getThumbDrawable();
int i_ThumbDimension_f = (this.getOrientation() == 0)? thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth();
if ( progressDrawable_f != null ){
dw = Math.max(super.i_MinWidth_m, Math.min(super.i_MaxWidth_m, progressDrawable_f.getIntrinsicWidth()));
dh = Math.max(super.i_MinHeight_m, Math.min(super.i_MaxHeight_m, progressDrawable_f.getIntrinsicHeight()));
if ( this.getOrientation() == 0 ){
dh = Math.max(i_ThumbDimension_f, dh);
dh = Math.max(dh, i_PreviousDimension_f);
}
else if (this.getOrientation() == 1 ){
dw = Math.max(i_ThumbDimension_f, dw);
dw = Math.max(dw, i_PreviousDimension_f);
}
i_PreviousDimension_f = i_ThumbDimension_f;
}
}
}
}
dw += mPaddingLeft + mPaddingRight;
dh += mPaddingTop + mPaddingBottom;
setMeasuredDimension(resolveSize(dw, widthMeasureSpec),
resolveSize(dh, heightMeasureSpec));
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.bIsUserSeekable_m || !isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
setPressed(true);
this.selectedThumb_m = this.thumbManagerVector_m[0].getThumbDrawable();//If touch response bound is null, select first element
for (int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse() != null ){
if ( thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().contains((int)event.getX(), (int)event.getY())){
this.selectedThumb_m = this.thumbManagerVector_m[iCount].getThumbDrawable();
Log.e(VIEW_LOG_TAG, "SELECTED THUMB: " + this.thumbManagerVector_m[iCount].getThumbType());
break;
}
}
}
}
onStartTrackingTouch();
trackTouchEvent(event);
break;
case MotionEvent.ACTION_MOVE:
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
onStopTrackingTouch();
setPressed(false);
break;
}
return true;
}
private void trackTouchEvent(MotionEvent event) {
if ( this.thumbManagerVector_m == null )
return;
Log.i(VIEW_LOG_TAG, "X: " + event.getX() + " Y: "+ event.getY());
float scale = 0.0f;
int[] i_Progress_f = new int[]{-1,-1};
float[] progress = new float[]{-1, -1};
int i_ViewDimension_f = (this.getOrientation() == 0)?getWidth(): getHeight();
int i_AvailableDimension_f = i_ViewDimension_f - ((this.getOrientation() == 0)? ( mPaddingLeft - mPaddingRight ):(mPaddingTop - mPaddingBottom));
int x = (int)event.getX();
int y = (int)event.getY();
int coordinateOfChange_f = (this.getOrientation() == 0)?x:y;
int i_historySize_f = event.getHistorySize();
int iCount = 0;
int i_ActualCoordinateValue_f = (this.getOrientation() == 0)?coordinateOfChange_f:i_AvailableDimension_f - coordinateOfChange_f;
//Find the selected thumb
for ( ; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if(this.thumbManagerVector_m[iCount].fn_IsThisThumb(this.selectedThumb_m))
break;
}
}
if ( this.selectedThumb_m == null ){
Log.e(VIEW_LOG_TAG, "NO SELECTED THUMB");
return;
}
if ( i_historySize_f > 0 ){
int i_HistoryValueOfDimension_f = (this.getOrientation() == 0 )?
(int)event.getHistoricalX(0, 0):
(i_ViewDimension_f - (int)event.getHistoricalY(0, 0));
if ( i_HistoryValueOfDimension_f < i_ActualCoordinateValue_f )
this.b_IsIncreasing_m = true;
else
this.b_IsIncreasing_m = false;
if ( this.b_IsIncreasing_m ){
super.e_InConflictMoveTowards_m = DUAL_PROGRESS_MOVE_TOWARDS.MAX;
if ( !thumbManagerVector_m[iCount].isCanIncrease() ){
Log.e("CSEEKBAR", "CANNOT INCREASE ANYMORE");
return;
}
}
else{
super.e_InConflictMoveTowards_m = DUAL_PROGRESS_MOVE_TOWARDS.MIN;
if ( !thumbManagerVector_m[iCount].isCanDecrease() ){
Log.e("CSEEKBAR", "CANNOT DECREASE ANYMORE");
return;
}
}
}
if ( !this.thumbManagerVector_m[iCount].fn_IsCoordinateWithinBound(coordinateOfChange_f)){
return;
}
//Fetch previous progress values
i_Progress_f = this.getProgress();
for ( int iCounter = 0; iCounter < i_Progress_f.length; iCounter++){
progress[iCounter] = i_Progress_f[iCounter];
}
int i_Selector_f = iCount ;
if (coordinateOfChange_f < ((this.getOrientation() == 0) ? mPaddingRight : mPaddingTop)) {
scale = 1.0f;
} else if (coordinateOfChange_f > i_AvailableDimension_f - ((this.getOrientation()==0)?mPaddingLeft:mPaddingBottom)) {
scale = 0.0f;
} else {
scale = (float)(i_ActualCoordinateValue_f - ((this.getOrientation() == 0)?mPaddingLeft:mPaddingBottom) )/ (float)i_AvailableDimension_f;
progress[i_Selector_f] = this.f_TouchProgressOffset_m;
}
final int max = getMax();
progress[i_Selector_f] += scale * max;
if ( progress[i_Selector_f] < 0) {
progress[i_Selector_f] = 0;
} else if ( progress[i_Selector_f] > max) {
progress[i_Selector_f] = max;
}
int[] truncatedProgress_f = new int[]{(int)progress[0], (int)progress[1]};
this.fn_SetProgress(truncatedProgress_f, true);
}
/**
* Tries to claim the user's drag motion, and requests disallowing any
* ancestors from stealing events in the drag.
*/
private void attemptClaimDrag() {
if (super.getParent() != null) {
super.getParent().requestDisallowInterceptTouchEvent(true);
}
}
/**
* This is called when the user has started touching this widget.
*/
void onStartTrackingTouch() {
}
/**
* This is called when the user either releases his touch or the touch is
* canceled.
*/
void onStopTrackingTouch() {
this.selectedThumb_m = null;
}
/**
* Called when the user changes the seekbar's progress by using a key event.
*/
void onKeyChange() {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
int[] progress = getProgress();
if ( this.getProgressType() == 0 ){
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (progress[0] <= 0) break;
progress[0] = progress[0] - this.iKeyProgressIncrement_m;
super.fn_SetProgress(progress, true);
onKeyChange();
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (progress[0] >= getMax()) break;
progress[0] = progress[0] + this.iKeyProgressIncrement_m;
this.fn_SetProgress(progress, true);
onKeyChange();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onConflictingProgress(int[] newProgress){
// if ( this.selectedThumb_m == null )
// return;
// int i_Selector_f = -1;
// if ( this.selectedThumb_m.equals(this.thumbDrawable_m)){
// this.selectedThumb_m = this.thumbDrawableHigh_m;
// i_Selector_f = 1;
// }
// else if ( this.selectedThumb_m.equals(this.thumbDrawableHigh_m)){
// this.selectedThumb_m = this.thumbDrawable_m;
// i_Selector_f = 0;
// }
// int max = super.getMax();
// float []scale = new float[]{(max > 0 ? (newProgress[0]) / (float) max : 0), (this.getMin() >= 0 ? (newProgress[1]) / (float) max : 0)};
// this.setThumbPos((super.getOrientation() == 0)?this.getWidth():this.getHeight(), this.selectedThumb_m, scale[i_Selector_f], Integer.MIN_VALUE);
//
// int[] progress = new int[]{0, 0};
// progress[i_Selector_f] += scale[i_Selector_f] * max;
// if ( progress[i_Selector_f] < 0) {
// progress[i_Selector_f] = 0;
// } else if ( progress[0] > max) {
// progress[i_Selector_f] = max;
// }
// int[] truncatedProgress_f = new int[]{(int)progress[0], (int)progress[1]};
// this.fn_SetProgress(newProgress, false);
}
public class ThumbManager{
private THUMB_TYPE e_ThumbType_m;
//To be set after drawing on device
private Rect rectBoundsForTouchResponse_m;
private Rect rectBoundsForDraw_m;
private boolean b_CanDecrease_m = true;
private boolean b_CanIncrease_m = true;
private View containerView_m;
private float[] maxBoundVector_m = new float[2];
//To be set after drawing on device
private Drawable thumbDrawable_m;
private int i_MinThumbPadding_m;
private int i_Orientation_m;
private int i_ThumbOffset_m;
private int i_ProgressType_m;
public boolean fn_IsConnectedToOtherThumb(Drawable thumb){
if ( this.i_Orientation_m == 0 ){
Log.i(VIEW_LOG_TAG, " IS CONNECTED TO OTHER THUMB: " + Math.abs((this.thumbDrawable_m.getBounds().left - thumb.getBounds().left)));
return ( Math.abs((this.thumbDrawable_m.getBounds().left - thumb.getBounds().left)) <= this.i_MinThumbPadding_m);
}
else if ( this.i_Orientation_m == 1)
return ( Math.abs(this.thumbDrawable_m.getBounds().top - thumb.getBounds().top) <= this.i_MinThumbPadding_m);
else
return false;
}
public boolean fn_IsThisThumb(Drawable selectedThumb){
if (selectedThumb == null)
return false;
return (selectedThumb.equals(this.thumbDrawable_m));
}
public boolean fn_IsCoordinateWithinBound(int coordinate){
return (coordinate >= this.maxBoundVector_m[0] && coordinate <= this.maxBoundVector_m[1] );
}
public ThumbManager(Drawable thumbDrawable, int orientation, int minThumbPadding, THUMB_TYPE thumbType,int progressType){
this.setThumbDrawable(thumbDrawable);
this.i_Orientation_m = orientation;
this.i_ProgressType_m = progressType;
this.i_MinThumbPadding_m = minThumbPadding;
this.e_ThumbType_m = thumbType;
this.rectBoundsForDraw_m = new Rect();
this.rectBoundsForTouchResponse_m = new Rect();
}
public THUMB_TYPE getThumbType() {
return e_ThumbType_m;
}
public void setThumbType(THUMB_TYPE e_ThumbType_m) {
this.e_ThumbType_m = e_ThumbType_m;
}
public Rect getRectBoundsForTouchResponse() {
return rectBoundsForTouchResponse_m;
}
public void setRectBoundsForTouchResponse(
Rect rectBoundsForTouchResponse_m) {
this.rectBoundsForTouchResponse_m = rectBoundsForTouchResponse_m;
}
public Rect getRectBoundsForDraw() {
return rectBoundsForDraw_m;
}
public void setRectBoundsForDraw(Rect rectBoundsForDraw_m) {
this.rectBoundsForDraw_m = rectBoundsForDraw_m;
if ( this.i_Orientation_m == 0){
if ( this.i_ProgressType_m == 0 ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getWidth();
return;
}
if ( this.e_ThumbType_m == THUMB_TYPE.LOW){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getWidth() - this.thumbDrawable_m.getIntrinsicWidth();
if ( this.rectBoundsForDraw_m.left == 0){
Log.e(VIEW_LOG_TAG, "CANNOT DECREASE ANYMORE");
this.b_CanDecrease_m = false;
this.b_CanIncrease_m = true;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
else if ( this.e_ThumbType_m == THUMB_TYPE.HIGH ){
this.maxBoundVector_m[0] = this.i_MinThumbPadding_m;
this.maxBoundVector_m[1] = this.containerView_m.getWidth();
if ( this.rectBoundsForDraw_m.right == this.containerView_m.getMeasuredWidth()){
Log.e(VIEW_LOG_TAG, "CANNOT INCREASE ANYMORE");
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = false;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
}
else if ( this.i_Orientation_m == 1){
if ( this.i_ProgressType_m == 0 ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getHeight();
}
if ( this.e_ThumbType_m == THUMB_TYPE.LOW){
this.maxBoundVector_m[0] = this.i_MinThumbPadding_m;
this.maxBoundVector_m[1] = this.containerView_m.getHeight();
if ( this.rectBoundsForDraw_m.bottom == this.containerView_m.getMeasuredHeight()){
this.b_CanDecrease_m = false;
this.b_CanIncrease_m = true;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
else if ( this.e_ThumbType_m == THUMB_TYPE.HIGH ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getHeight() - (this.i_MinThumbPadding_m);
if ( this.rectBoundsForDraw_m.top == 0){
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = false;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
}
}
public boolean isCanDecrease() {
return b_CanDecrease_m;
}
public void setCanDecrease(boolean b_CanDecrease_m) {
this.b_CanDecrease_m = b_CanDecrease_m;
}
public boolean isCanIncrease() {
return b_CanIncrease_m;
}
public void setCanIncrease(boolean b_CanIncrease_m) {
this.b_CanIncrease_m = b_CanIncrease_m;
}
public Drawable getThumbDrawable() {
return thumbDrawable_m;
}
public void setThumbDrawable(Drawable thumbDrawable_m) {
this.thumbDrawable_m = thumbDrawable_m;
}
public int getMinThumbPadding() {
return i_MinThumbPadding_m;
}
public void setMinThumbPadding(int i_MinThumbPadding_m) {
this.i_MinThumbPadding_m = i_MinThumbPadding_m;
}
public int getOrientation() {
return i_Orientation_m;
}
public void setOrientation(int i_Orientation_m) {
this.i_Orientation_m = i_Orientation_m;
}
public View getContainerView() {
return containerView_m;
}
public void setContainerView(View containerView_m) {
this.containerView_m = containerView_m;
}
public int getThumbOffset() {
return i_ThumbOffset_m;
}
public void setThumbOffset(int i_ThumbOffset_m) {
this.i_ThumbOffset_m = i_ThumbOffset_m;
}
}
public enum THUMB_TYPE{
LOW, HIGH;
}
}
|
UTF-8
|
Java
| 34,911 |
java
|
CAbLinearSeekBar.java
|
Java
|
[] | null |
[] |
package com.beta.UIControls;
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import com.beta.UIControls.CProgressBar.IThumbConflictListener;
import com.customcontrol.seekbar.R;
public abstract class CAbLinearSeekBar extends CProgressBar implements IThumbConflictListener {
// private Drawable thumbDrawable_m;
// private Drawable thumbDrawableHigh_m;
private ThumbManager[] thumbManagerVector_m;
private Drawable selectedThumb_m;
private int i_ThumbOffset_m;
private int mPaddingLeft;
private int mPaddingTop;
private int mPaddingRight;
private int mPaddingBottom;
private Rect[] rectBounds_m = new Rect[2];;//[0] low Thumb bound; [1] hight Thumb bound
private boolean b_IsIncreasing_m = false;
/**
* On touch, this offset plus the scaled value from the position of the
* touch will form the progress value. Usually 0.
*/
float f_TouchProgressOffset_m;
/**
* Whether this is user seekable.
*/
boolean bIsUserSeekable_m = true;
/**
* On key presses (right or left), the amount to increment/decrement the
* progress.
*/
private int iKeyProgressIncrement_m = 1;
private static final int NO_ALPHA = 0xFF;
private float f_DisabledAlpha_m;
public CAbLinearSeekBar(Context context) {
super(context);
}
public CAbLinearSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CAbLinearSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray attributeSetSpecified_f = context.obtainStyledAttributes(attrs,
R.styleable.CLinearSeekBar, defStyle, 0);
Drawable thumbDrawable_f = attributeSetSpecified_f.getDrawable(R.styleable.CLinearSeekBar_android_thumb);
Drawable thumbDrawableHigh_f= attributeSetSpecified_f.getDrawable(R.styleable.CLinearSeekBar_thumb_high);
if ( this.getProgressType() == 0){
this.thumbManagerVector_m = new ThumbManager[1];
this.thumbManagerVector_m[0] = new ThumbManager(thumbDrawable_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.LOW, super.getProgressType());
}
else{
this.thumbManagerVector_m = new ThumbManager[2];
this.thumbManagerVector_m[0] = new ThumbManager(thumbDrawable_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.LOW, super.getProgressType());
this.thumbManagerVector_m[1] = new ThumbManager(thumbDrawableHigh_f, super.getOrientation(), super.getMinMaxPadding(), THUMB_TYPE.HIGH, super.getProgressType());
}
int i_ThumbOffset_f =
attributeSetSpecified_f.getDimensionPixelOffset(R.styleable.CLinearSeekBar_android_thumbOffset, 0);
setThumbOffset(i_ThumbOffset_f);
this.f_DisabledAlpha_m = attributeSetSpecified_f.getFloat(R.styleable.CLinearSeekBar_android_disabledAlpha, 0.5f);
if(thumbDrawableHigh_f != null ){
setThumbOffset(i_ThumbOffset_f);//Look to set a second offset for the second thumb, the high thumb
}
attributeSetSpecified_f.recycle();
this.mPaddingBottom = this.getPaddingBottom();
this.mPaddingLeft = this.getPaddingLeft();
this.mPaddingTop = this.getPaddingTop();
this.mPaddingRight = this.getPaddingRight();
this.setThumbConflictListener(this);
}
/**
* Sets the thumb that will be drawn at the end of the progress meter within the SeekBar
*
* @param thumb Drawable representing the thumb
*/
/**
* @see #setThumbOffset(int)
*/
public int getThumbOffset() {
return this.i_ThumbOffset_m;
}
/**
* Sets the thumb offset that allows the thumb to extend out of the range of
* the track.
*
* @param thumbOffset The offset amount in pixels.
*/
public void setThumbOffset(int thumbOffset) {
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( this.thumbManagerVector_m[iCount] != null ){
this.thumbManagerVector_m[iCount].setThumbOffset(thumbOffset);
}
}
invalidate();
}
/**
* Sets the amount of progress changed via the arrow keys.
*
* @param increment The amount to increment or decrement when the user
* presses the arrow keys.
*/
public void setKeyProgressIncrement(int increment) {
this.iKeyProgressIncrement_m = increment < 0 ? -increment : increment;
}
/**
* Returns the amount of progress changed via the arrow keys.
* <p>
* By default, this will be a value that is derived from the max progress.
*
* @return The amount to increment or decrement when the user presses the
* arrow keys. This will be positive.
*/
public int getKeyProgressIncrement() {
return this.iKeyProgressIncrement_m;
}
@Override
public synchronized void setMax(int max) {
super.setMax(max);
if ((this.iKeyProgressIncrement_m == 0) || (getMax() / this.iKeyProgressIncrement_m > 20)) {
// It will take the user too long to change this via keys, change it
// to something more reasonable
setKeyProgressIncrement(Math.max(1, Math.round((float) getMax() / 20)));
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable progressDrawable = getProgressDrawable();
if (progressDrawable != null) {
progressDrawable.setAlpha(isEnabled() ? NO_ALPHA : (int) (NO_ALPHA * this.f_DisabledAlpha_m));
}
if ( this.thumbManagerVector_m == null )
return;
Drawable thumbDrawable = null;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null){
thumbDrawable = this.thumbManagerVector_m[iCount].getThumbDrawable();
if (thumbDrawable != null && thumbDrawable.isStateful()){
int[] state = getDrawableState();
this.thumbManagerVector_m[iCount].getThumbDrawable().setState(state);
}
}
}
}
@Override
protected void onProgressRefresh(float[] scale, boolean fromUser) {
if ( this.thumbManagerVector_m == null )
return;
Drawable thumbDrawable_f = this.selectedThumb_m;
if ( thumbDrawable_f == null )
return;
for (int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if (this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
if ( this.thumbManagerVector_m[iCount].getThumbType() == THUMB_TYPE.HIGH)
scale[iCount] = 1 - scale[iCount];
if(this.thumbManagerVector_m[iCount].fn_IsThisThumb(this.selectedThumb_m)){
setThumbPos((this.getOrientation() == 0)?getWidth():getHeight(), this.thumbManagerVector_m[iCount], scale[iCount], Integer.MIN_VALUE);
}
else{
if ( this.thumbManagerVector_m[iCount].fn_IsConnectedToOtherThumb(selectedThumb_m)){
Log.i("CONNECTED", "THUMBS CONNECTED");
setThumbPos((this.getOrientation() == 0)?getWidth():getHeight(), this.thumbManagerVector_m[iCount], scale[iCount], Integer.MIN_VALUE);
}
}
}
}
}
/*
* Since we draw translated, the drawable's bounds that it signals
* for invalidation won't be the actual bounds we want invalidated,
* so just invalidate this whole view.
*/
invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
//Get the progress bar details and set the size information as required
Drawable d = getCurrentDrawable();
int i_TrackAvailableDimension_f = (this.getOrientation() == 0 )? Math.min(super.i_MaxHeight_m, h - super.getPaddingTop() - super.getPaddingBottom()):
Math.min(super.i_MaxWidth_m, w - super.getPaddingLeft() - super.getPaddingRight());
i_TrackAvailableDimension_f = (this.getOrientation() == 0)?Math.min(d.getIntrinsicHeight(), h - super.getPaddingTop() - super.getPaddingBottom()):
Math.min(d.getIntrinsicWidth(), w - super.getPaddingLeft() - super.getPaddingRight());
if ( this.thumbManagerVector_m == null )
return;
//Parameters comoon for both SINGLE and DUAL mode
Drawable thumbDrawable_f;
int max = getMax();
float[] f_Progress_f = new float[this.thumbManagerVector_m.length];
float[] scale = new float[this.thumbManagerVector_m.length];
int gapForCenteringTrack = 0;
int i_PreviousThumbDimension_f = 0;
Rect progressDrawableBounds_f = new Rect();
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
this.thumbManagerVector_m[iCount].setContainerView(this);
this.thumbManagerVector_m[iCount].setMinThumbPadding((int)((super.getMinMaxPadding()/(float)super.getMax())*((this.getOrientation() == 0)?this.getWidth():this.getHeight())));
thumbDrawable_f = this.thumbManagerVector_m[iCount].getThumbDrawable();
int i_ThumbAvailableDimension_f = thumbDrawable_f == null ? 0 : ((this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth());
f_Progress_f[iCount] = getProgress()[iCount];
scale[iCount] = (max > 0 ? (f_Progress_f[iCount]) / (float) max : 0);
int gap = 0;
if ( i_ThumbAvailableDimension_f >= i_PreviousThumbDimension_f){
if ( i_ThumbAvailableDimension_f > i_TrackAvailableDimension_f ){
gapForCenteringTrack = (i_ThumbAvailableDimension_f - i_TrackAvailableDimension_f) / 2;
progressDrawableBounds_f.left = (this.getOrientation() == 0)?0:gapForCenteringTrack;
progressDrawableBounds_f.top = (this.getOrientation() == 0)?gapForCenteringTrack:0;
progressDrawableBounds_f.right = (this.getOrientation() == 0)? (w - this.getPaddingRight() - this.getPaddingLeft()):
(w - this.getPaddingRight() - this.getPaddingLeft() - gapForCenteringTrack);
progressDrawableBounds_f.bottom = (this.getOrientation() == 0)? (h - this.getPaddingBottom() - gapForCenteringTrack - this.getPaddingTop())
:h - this.getPaddingBottom() - this.getPaddingTop();
}
else {
progressDrawableBounds_f.left = 0;
progressDrawableBounds_f.top = 0;
progressDrawableBounds_f.right = (w - this.getPaddingTop() - this.getPaddingRight());
progressDrawableBounds_f.bottom = (h - this.getPaddingBottom() - this.getPaddingTop());
gap = (i_TrackAvailableDimension_f - i_ThumbAvailableDimension_f) / 2;
}
}
if (thumbDrawable_f != null) {
setThumbPos((this.getOrientation() == 0)?w:h, thumbManagerVector_m[iCount], scale[iCount], gap);
}
i_PreviousThumbDimension_f = i_ThumbAvailableDimension_f;
}
}
}
//Draw the track, irrespective of how many thumbs there are in the View
if (d != null) {
// Canvas will be translated by the padding, so 0,0 is where we start drawing
d.setBounds(progressDrawableBounds_f);
}
}
/**
* @param gap If set to {@link Integer#MIN_VALUE}, this will be ignored and
*/
private void setThumbPos(int dimension, ThumbManager thumbManager, float scale, int gap) {
if ( thumbManager == null )
return;
Drawable thumbDrawable_f = thumbManager.getThumbDrawable();
if ( thumbDrawable_f == null )
return;
int i_AvailableDimension_f = ( this.getOrientation() == 0 )? (dimension - mPaddingLeft - mPaddingRight):
(dimension - mPaddingTop - mPaddingBottom) ;
int i_ThumbSliderDimension_f = (this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicWidth():thumbDrawable_f.getIntrinsicHeight();
int i_ThumbStaticDimension_f = (this.getOrientation() == 0)?thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth();
i_AvailableDimension_f = i_AvailableDimension_f - i_ThumbSliderDimension_f;
i_AvailableDimension_f += thumbManager.getThumbOffset() * 2;
int i_ThumbPos_f = (int) (scale * i_AvailableDimension_f);
int i_Border_Bound_0, i_Border_Bound_1;
if (gap == Integer.MIN_VALUE) {
Rect oldBounds = thumbDrawable_f.getBounds();
i_Border_Bound_0 = (this.getOrientation() == 0)?oldBounds.top:oldBounds.left;
i_Border_Bound_1 = (this.getOrientation() == 0)?oldBounds.bottom:oldBounds.right;
}
else
{
i_Border_Bound_0 = gap;
i_Border_Bound_1 = gap + i_ThumbStaticDimension_f;
}
Rect rectBoundsForDraw = thumbManager.getRectBoundsForDraw();
rectBoundsForDraw.left = (this.getOrientation() == 0) ? i_ThumbPos_f:i_Border_Bound_0;
rectBoundsForDraw.top = (this.getOrientation() == 0)? i_Border_Bound_0:(dimension - i_ThumbSliderDimension_f - i_ThumbPos_f);
rectBoundsForDraw.right = (this.getOrientation() == 0)? (i_ThumbPos_f + i_ThumbSliderDimension_f):i_Border_Bound_1;
rectBoundsForDraw.bottom = (this.getOrientation() == 0)?i_Border_Bound_1:(dimension - i_ThumbPos_f);
//set the drawable region for the Thumb
thumbManager.setRectBoundsForDraw(rectBoundsForDraw);
thumbDrawable_f.setBounds(rectBoundsForDraw);
this.fn_SetDualProgressTypeBound(this.getProgress());//This is the corrected progress vector
}
public void fn_SetDualProgressTypeBound(int[] progress){
if ( this.getProgressType() == 0 ){
this.thumbManagerVector_m[0].setRectBoundsForTouchResponse(null);
return;
}
Rect rectBounds_f[] = new Rect[2];
float difference_f = (progress[1] - progress[0])/2;
float midPoint_f = difference_f + progress[0];
float scale_f = midPoint_f/this.getMax();
float location_f = scale_f*((this.getOrientation() == 0)?this.getWidth():this.getHeight());
if ( this.getOrientation() == 0){
for(int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().top = 0;
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().bottom = this.getHeight() + 1;
}
}
else if ( this.getOrientation() == 1){
for(int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().left = 0;
this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().right = this.getWidth()+ 1;
}
}
if ( this.thumbManagerVector_m == null )
return;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( this.thumbManagerVector_m[iCount] != null ){
Log.i(VIEW_LOG_TAG, String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().left)
+","+String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().top)
+","+String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().right)
+","+ String.valueOf(this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().bottom));
rectBounds_f[iCount] = this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse();
if ( super.getOrientation() == 0 ){
if ( iCount == 0)
rectBounds_f[iCount].right = (int)Math.floor(location_f) + 1;
else{
rectBounds_f[iCount].left = (int)Math.ceil(location_f);
rectBounds_f[iCount].right = (int)Math.ceil(this.getWidth()) + 1;
}
}
else if ( super.getOrientation() == 1){
if ( iCount == 0 ){
rectBounds_f[iCount].bottom = (int)Math.ceil(this.getHeight()) + 1;
rectBounds_f[iCount].top = (int)(this.getHeight() - Math.ceil(location_f));
}
else{
rectBounds_f[iCount].bottom = (int)(this.getHeight() - Math.ceil(location_f)) + 1;
}
}
this.thumbManagerVector_m[iCount].setRectBoundsForTouchResponse(rectBounds_f[iCount]);
}
}
}
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
if ( thumbManagerVector_m == null )
return;
canvas.save();
// Translate the padding. For the x, we need to allow the thumb to
// draw in its extra space
canvas.translate(mPaddingLeft - mPaddingLeft, mPaddingTop);
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if (this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
this.thumbManagerVector_m[iCount].getThumbDrawable().draw(canvas);
}
}
}
canvas.restore();
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if ( this.thumbManagerVector_m == null )
return;
Drawable progressDrawable_f = getCurrentDrawable();
int dw = 0;
int dh = 0;
int i_PreviousDimension_f = 0;
for ( int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getThumbDrawable() != null ){
Drawable thumbDrawable_f = this.thumbManagerVector_m[iCount].getThumbDrawable();
int i_ThumbDimension_f = (this.getOrientation() == 0)? thumbDrawable_f.getIntrinsicHeight():thumbDrawable_f.getIntrinsicWidth();
if ( progressDrawable_f != null ){
dw = Math.max(super.i_MinWidth_m, Math.min(super.i_MaxWidth_m, progressDrawable_f.getIntrinsicWidth()));
dh = Math.max(super.i_MinHeight_m, Math.min(super.i_MaxHeight_m, progressDrawable_f.getIntrinsicHeight()));
if ( this.getOrientation() == 0 ){
dh = Math.max(i_ThumbDimension_f, dh);
dh = Math.max(dh, i_PreviousDimension_f);
}
else if (this.getOrientation() == 1 ){
dw = Math.max(i_ThumbDimension_f, dw);
dw = Math.max(dw, i_PreviousDimension_f);
}
i_PreviousDimension_f = i_ThumbDimension_f;
}
}
}
}
dw += mPaddingLeft + mPaddingRight;
dh += mPaddingTop + mPaddingBottom;
setMeasuredDimension(resolveSize(dw, widthMeasureSpec),
resolveSize(dh, heightMeasureSpec));
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.bIsUserSeekable_m || !isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
setPressed(true);
this.selectedThumb_m = this.thumbManagerVector_m[0].getThumbDrawable();//If touch response bound is null, select first element
for (int iCount = 0; iCount < this.thumbManagerVector_m.length; iCount++ ){
if ( thumbManagerVector_m[iCount] != null ){
if ( this.thumbManagerVector_m[iCount].getRectBoundsForTouchResponse() != null ){
if ( thumbManagerVector_m[iCount].getRectBoundsForTouchResponse().contains((int)event.getX(), (int)event.getY())){
this.selectedThumb_m = this.thumbManagerVector_m[iCount].getThumbDrawable();
Log.e(VIEW_LOG_TAG, "SELECTED THUMB: " + this.thumbManagerVector_m[iCount].getThumbType());
break;
}
}
}
}
onStartTrackingTouch();
trackTouchEvent(event);
break;
case MotionEvent.ACTION_MOVE:
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
onStopTrackingTouch();
setPressed(false);
break;
}
return true;
}
private void trackTouchEvent(MotionEvent event) {
if ( this.thumbManagerVector_m == null )
return;
Log.i(VIEW_LOG_TAG, "X: " + event.getX() + " Y: "+ event.getY());
float scale = 0.0f;
int[] i_Progress_f = new int[]{-1,-1};
float[] progress = new float[]{-1, -1};
int i_ViewDimension_f = (this.getOrientation() == 0)?getWidth(): getHeight();
int i_AvailableDimension_f = i_ViewDimension_f - ((this.getOrientation() == 0)? ( mPaddingLeft - mPaddingRight ):(mPaddingTop - mPaddingBottom));
int x = (int)event.getX();
int y = (int)event.getY();
int coordinateOfChange_f = (this.getOrientation() == 0)?x:y;
int i_historySize_f = event.getHistorySize();
int iCount = 0;
int i_ActualCoordinateValue_f = (this.getOrientation() == 0)?coordinateOfChange_f:i_AvailableDimension_f - coordinateOfChange_f;
//Find the selected thumb
for ( ; iCount < this.thumbManagerVector_m.length; iCount++){
if ( this.thumbManagerVector_m[iCount] != null ){
if(this.thumbManagerVector_m[iCount].fn_IsThisThumb(this.selectedThumb_m))
break;
}
}
if ( this.selectedThumb_m == null ){
Log.e(VIEW_LOG_TAG, "NO SELECTED THUMB");
return;
}
if ( i_historySize_f > 0 ){
int i_HistoryValueOfDimension_f = (this.getOrientation() == 0 )?
(int)event.getHistoricalX(0, 0):
(i_ViewDimension_f - (int)event.getHistoricalY(0, 0));
if ( i_HistoryValueOfDimension_f < i_ActualCoordinateValue_f )
this.b_IsIncreasing_m = true;
else
this.b_IsIncreasing_m = false;
if ( this.b_IsIncreasing_m ){
super.e_InConflictMoveTowards_m = DUAL_PROGRESS_MOVE_TOWARDS.MAX;
if ( !thumbManagerVector_m[iCount].isCanIncrease() ){
Log.e("CSEEKBAR", "CANNOT INCREASE ANYMORE");
return;
}
}
else{
super.e_InConflictMoveTowards_m = DUAL_PROGRESS_MOVE_TOWARDS.MIN;
if ( !thumbManagerVector_m[iCount].isCanDecrease() ){
Log.e("CSEEKBAR", "CANNOT DECREASE ANYMORE");
return;
}
}
}
if ( !this.thumbManagerVector_m[iCount].fn_IsCoordinateWithinBound(coordinateOfChange_f)){
return;
}
//Fetch previous progress values
i_Progress_f = this.getProgress();
for ( int iCounter = 0; iCounter < i_Progress_f.length; iCounter++){
progress[iCounter] = i_Progress_f[iCounter];
}
int i_Selector_f = iCount ;
if (coordinateOfChange_f < ((this.getOrientation() == 0) ? mPaddingRight : mPaddingTop)) {
scale = 1.0f;
} else if (coordinateOfChange_f > i_AvailableDimension_f - ((this.getOrientation()==0)?mPaddingLeft:mPaddingBottom)) {
scale = 0.0f;
} else {
scale = (float)(i_ActualCoordinateValue_f - ((this.getOrientation() == 0)?mPaddingLeft:mPaddingBottom) )/ (float)i_AvailableDimension_f;
progress[i_Selector_f] = this.f_TouchProgressOffset_m;
}
final int max = getMax();
progress[i_Selector_f] += scale * max;
if ( progress[i_Selector_f] < 0) {
progress[i_Selector_f] = 0;
} else if ( progress[i_Selector_f] > max) {
progress[i_Selector_f] = max;
}
int[] truncatedProgress_f = new int[]{(int)progress[0], (int)progress[1]};
this.fn_SetProgress(truncatedProgress_f, true);
}
/**
* Tries to claim the user's drag motion, and requests disallowing any
* ancestors from stealing events in the drag.
*/
private void attemptClaimDrag() {
if (super.getParent() != null) {
super.getParent().requestDisallowInterceptTouchEvent(true);
}
}
/**
* This is called when the user has started touching this widget.
*/
void onStartTrackingTouch() {
}
/**
* This is called when the user either releases his touch or the touch is
* canceled.
*/
void onStopTrackingTouch() {
this.selectedThumb_m = null;
}
/**
* Called when the user changes the seekbar's progress by using a key event.
*/
void onKeyChange() {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
int[] progress = getProgress();
if ( this.getProgressType() == 0 ){
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (progress[0] <= 0) break;
progress[0] = progress[0] - this.iKeyProgressIncrement_m;
super.fn_SetProgress(progress, true);
onKeyChange();
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (progress[0] >= getMax()) break;
progress[0] = progress[0] + this.iKeyProgressIncrement_m;
this.fn_SetProgress(progress, true);
onKeyChange();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onConflictingProgress(int[] newProgress){
// if ( this.selectedThumb_m == null )
// return;
// int i_Selector_f = -1;
// if ( this.selectedThumb_m.equals(this.thumbDrawable_m)){
// this.selectedThumb_m = this.thumbDrawableHigh_m;
// i_Selector_f = 1;
// }
// else if ( this.selectedThumb_m.equals(this.thumbDrawableHigh_m)){
// this.selectedThumb_m = this.thumbDrawable_m;
// i_Selector_f = 0;
// }
// int max = super.getMax();
// float []scale = new float[]{(max > 0 ? (newProgress[0]) / (float) max : 0), (this.getMin() >= 0 ? (newProgress[1]) / (float) max : 0)};
// this.setThumbPos((super.getOrientation() == 0)?this.getWidth():this.getHeight(), this.selectedThumb_m, scale[i_Selector_f], Integer.MIN_VALUE);
//
// int[] progress = new int[]{0, 0};
// progress[i_Selector_f] += scale[i_Selector_f] * max;
// if ( progress[i_Selector_f] < 0) {
// progress[i_Selector_f] = 0;
// } else if ( progress[0] > max) {
// progress[i_Selector_f] = max;
// }
// int[] truncatedProgress_f = new int[]{(int)progress[0], (int)progress[1]};
// this.fn_SetProgress(newProgress, false);
}
public class ThumbManager{
private THUMB_TYPE e_ThumbType_m;
//To be set after drawing on device
private Rect rectBoundsForTouchResponse_m;
private Rect rectBoundsForDraw_m;
private boolean b_CanDecrease_m = true;
private boolean b_CanIncrease_m = true;
private View containerView_m;
private float[] maxBoundVector_m = new float[2];
//To be set after drawing on device
private Drawable thumbDrawable_m;
private int i_MinThumbPadding_m;
private int i_Orientation_m;
private int i_ThumbOffset_m;
private int i_ProgressType_m;
public boolean fn_IsConnectedToOtherThumb(Drawable thumb){
if ( this.i_Orientation_m == 0 ){
Log.i(VIEW_LOG_TAG, " IS CONNECTED TO OTHER THUMB: " + Math.abs((this.thumbDrawable_m.getBounds().left - thumb.getBounds().left)));
return ( Math.abs((this.thumbDrawable_m.getBounds().left - thumb.getBounds().left)) <= this.i_MinThumbPadding_m);
}
else if ( this.i_Orientation_m == 1)
return ( Math.abs(this.thumbDrawable_m.getBounds().top - thumb.getBounds().top) <= this.i_MinThumbPadding_m);
else
return false;
}
public boolean fn_IsThisThumb(Drawable selectedThumb){
if (selectedThumb == null)
return false;
return (selectedThumb.equals(this.thumbDrawable_m));
}
public boolean fn_IsCoordinateWithinBound(int coordinate){
return (coordinate >= this.maxBoundVector_m[0] && coordinate <= this.maxBoundVector_m[1] );
}
public ThumbManager(Drawable thumbDrawable, int orientation, int minThumbPadding, THUMB_TYPE thumbType,int progressType){
this.setThumbDrawable(thumbDrawable);
this.i_Orientation_m = orientation;
this.i_ProgressType_m = progressType;
this.i_MinThumbPadding_m = minThumbPadding;
this.e_ThumbType_m = thumbType;
this.rectBoundsForDraw_m = new Rect();
this.rectBoundsForTouchResponse_m = new Rect();
}
public THUMB_TYPE getThumbType() {
return e_ThumbType_m;
}
public void setThumbType(THUMB_TYPE e_ThumbType_m) {
this.e_ThumbType_m = e_ThumbType_m;
}
public Rect getRectBoundsForTouchResponse() {
return rectBoundsForTouchResponse_m;
}
public void setRectBoundsForTouchResponse(
Rect rectBoundsForTouchResponse_m) {
this.rectBoundsForTouchResponse_m = rectBoundsForTouchResponse_m;
}
public Rect getRectBoundsForDraw() {
return rectBoundsForDraw_m;
}
public void setRectBoundsForDraw(Rect rectBoundsForDraw_m) {
this.rectBoundsForDraw_m = rectBoundsForDraw_m;
if ( this.i_Orientation_m == 0){
if ( this.i_ProgressType_m == 0 ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getWidth();
return;
}
if ( this.e_ThumbType_m == THUMB_TYPE.LOW){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getWidth() - this.thumbDrawable_m.getIntrinsicWidth();
if ( this.rectBoundsForDraw_m.left == 0){
Log.e(VIEW_LOG_TAG, "CANNOT DECREASE ANYMORE");
this.b_CanDecrease_m = false;
this.b_CanIncrease_m = true;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
else if ( this.e_ThumbType_m == THUMB_TYPE.HIGH ){
this.maxBoundVector_m[0] = this.i_MinThumbPadding_m;
this.maxBoundVector_m[1] = this.containerView_m.getWidth();
if ( this.rectBoundsForDraw_m.right == this.containerView_m.getMeasuredWidth()){
Log.e(VIEW_LOG_TAG, "CANNOT INCREASE ANYMORE");
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = false;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
}
else if ( this.i_Orientation_m == 1){
if ( this.i_ProgressType_m == 0 ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getHeight();
}
if ( this.e_ThumbType_m == THUMB_TYPE.LOW){
this.maxBoundVector_m[0] = this.i_MinThumbPadding_m;
this.maxBoundVector_m[1] = this.containerView_m.getHeight();
if ( this.rectBoundsForDraw_m.bottom == this.containerView_m.getMeasuredHeight()){
this.b_CanDecrease_m = false;
this.b_CanIncrease_m = true;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
else if ( this.e_ThumbType_m == THUMB_TYPE.HIGH ){
this.maxBoundVector_m[0] = 0;
this.maxBoundVector_m[1] = this.containerView_m.getHeight() - (this.i_MinThumbPadding_m);
if ( this.rectBoundsForDraw_m.top == 0){
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = false;
}
else{
this.b_CanDecrease_m = true;
this.b_CanIncrease_m = true;
}
}
}
}
public boolean isCanDecrease() {
return b_CanDecrease_m;
}
public void setCanDecrease(boolean b_CanDecrease_m) {
this.b_CanDecrease_m = b_CanDecrease_m;
}
public boolean isCanIncrease() {
return b_CanIncrease_m;
}
public void setCanIncrease(boolean b_CanIncrease_m) {
this.b_CanIncrease_m = b_CanIncrease_m;
}
public Drawable getThumbDrawable() {
return thumbDrawable_m;
}
public void setThumbDrawable(Drawable thumbDrawable_m) {
this.thumbDrawable_m = thumbDrawable_m;
}
public int getMinThumbPadding() {
return i_MinThumbPadding_m;
}
public void setMinThumbPadding(int i_MinThumbPadding_m) {
this.i_MinThumbPadding_m = i_MinThumbPadding_m;
}
public int getOrientation() {
return i_Orientation_m;
}
public void setOrientation(int i_Orientation_m) {
this.i_Orientation_m = i_Orientation_m;
}
public View getContainerView() {
return containerView_m;
}
public void setContainerView(View containerView_m) {
this.containerView_m = containerView_m;
}
public int getThumbOffset() {
return i_ThumbOffset_m;
}
public void setThumbOffset(int i_ThumbOffset_m) {
this.i_ThumbOffset_m = i_ThumbOffset_m;
}
}
public enum THUMB_TYPE{
LOW, HIGH;
}
}
| 34,911 | 0.616482 | 0.610839 | 875 | 38.898285 | 34.932716 | 185 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.938286 | false | false |
14
|
ce09756c9b9e2f2d11b3644dd8ede4751e885b69
| 22,686,017,303,702 |
be2eb9c583598eb195448f98f228570a745535e6
|
/src/PostFixCalculator/StackLinkedList.java
|
65289ad8ed1a88539e71ff23df48d69651a3b0fa
|
[
"MIT"
] |
permissive
|
tylerh95/Post-Fix-Calculator
|
https://github.com/tylerh95/Post-Fix-Calculator
|
d66c1f65164e90490aae29d2731348f302c1a055
|
5b17a99bf11b510ca84f9b96d4158ff27abdf594
|
refs/heads/master
| 2020-03-23T06:25:24.274000 | 2018-07-18T01:36:13 | 2018-07-18T01:36:13 | 141,209,264 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Author: Tyler Hickam
// Purpose: implementation of both a stack and linked list
package PostFixCalculator;
public class StackLinkedList<T> {
private Node<T> top;
public StackLinkedList( ) {
top = null;
}
public void push(T data) {
top = new Node<T>(data, top);
}
public T pop( ) {
T data = top.data;
top = top.next;
return data;
}
public T peek( ) {
return top.data;
}
public void clear( ) {
top = null;
}
public boolean isEmpty( ) {
return top == null;
}
public String toString() {
if(isEmpty()) return "";
String stackString = "";
Node<T> tmp = top;
while(tmp != null)
{
stackString += (tmp.data + " ");
tmp = tmp.next;
}
return stackString;
}
private class Node<T>
{
public T data;
public Node<T> next;
public Node(T data)
{
this(data, null);
}
public Node(T data, Node<T> n)
{
this.data = data; next = n;
}
}
}
|
UTF-8
|
Java
| 1,110 |
java
|
StackLinkedList.java
|
Java
|
[
{
"context": "// Author: Tyler Hickam\n// Purpose: implementation of both a stack and li",
"end": 23,
"score": 0.9998677968978882,
"start": 11,
"tag": "NAME",
"value": "Tyler Hickam"
}
] | null |
[] |
// Author: <NAME>
// Purpose: implementation of both a stack and linked list
package PostFixCalculator;
public class StackLinkedList<T> {
private Node<T> top;
public StackLinkedList( ) {
top = null;
}
public void push(T data) {
top = new Node<T>(data, top);
}
public T pop( ) {
T data = top.data;
top = top.next;
return data;
}
public T peek( ) {
return top.data;
}
public void clear( ) {
top = null;
}
public boolean isEmpty( ) {
return top == null;
}
public String toString() {
if(isEmpty()) return "";
String stackString = "";
Node<T> tmp = top;
while(tmp != null)
{
stackString += (tmp.data + " ");
tmp = tmp.next;
}
return stackString;
}
private class Node<T>
{
public T data;
public Node<T> next;
public Node(T data)
{
this(data, null);
}
public Node(T data, Node<T> n)
{
this.data = data; next = n;
}
}
}
| 1,104 | 0.489189 | 0.489189 | 64 | 16.359375 | 13.312784 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false |
14
|
d5a6f1aac4a70adad93cd9daf24164fb8b7f5d08
| 5,523,327,998,521 |
ee2eb3d9c40896f6309bf7abd6ea502046955c24
|
/src/civ/controller/Util.java
|
74dfedebc9b9ebb3cd0d84ce029fe58bb0119286
|
[] |
no_license
|
alestrooisma/CivGame
|
https://github.com/alestrooisma/CivGame
|
6c4e38c626df0015fcdd105c09abb4dd745f1e44
|
9d3c1b6f3f743f51e1f0c5ffb14b0e1d3b1f4e3f
|
refs/heads/master
| 2016-09-09T21:26:40.098000 | 2014-03-18T19:55:14 | 2014-03-18T19:55:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package civ.controller;
import java.awt.Point;
import static java.lang.Math.*;
/**
*
* @author ale
*/
public class Util {
public static int distanceSquared(Point a, Point b) {
return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
}
public static double distance(Point a, Point b) {
return sqrt(distanceSquared(a, b));
}
public static double walkDistance(Point a, Point b) {
int dx = abs(b.x - a.x);
int dy = abs(b.y - a.y);
int min, max;
if (dx > dy) {
min = dy;
max = dx;
} else {
min = dx;
max = dy;
}
return min*1.5 + max-min;
}
}
|
UTF-8
|
Java
| 686 |
java
|
Util.java
|
Java
|
[
{
"context": "mport static java.lang.Math.*;\n\n\n/**\n *\n * @author ale\n */\npublic class Util {\n\t\n\tpublic static int dist",
"end": 203,
"score": 0.9921454191207886,
"start": 200,
"tag": "USERNAME",
"value": "ale"
}
] | null |
[] |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package civ.controller;
import java.awt.Point;
import static java.lang.Math.*;
/**
*
* @author ale
*/
public class Util {
public static int distanceSquared(Point a, Point b) {
return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
}
public static double distance(Point a, Point b) {
return sqrt(distanceSquared(a, b));
}
public static double walkDistance(Point a, Point b) {
int dx = abs(b.x - a.x);
int dy = abs(b.y - a.y);
int min, max;
if (dx > dy) {
min = dy;
max = dx;
} else {
min = dx;
max = dy;
}
return min*1.5 + max-min;
}
}
| 686 | 0.591837 | 0.588921 | 38 | 17.052631 | 17.907581 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.552632 | false | false |
14
|
6b48a5946323c64825a240e46843de1eb0388d97
| 2,370,821,996,601 |
7f6fae98670ec6f2306c52f001facec811da44e4
|
/src/main/java/it/polimi/eftaios/model/deck/DeckShallop.java
|
def76abfcf327c60d2e44c1627fc2ecbcd12dd2c
|
[
"Apache-2.0"
] |
permissive
|
federicogatti/eftaios
|
https://github.com/federicogatti/eftaios
|
9c8b26b9da99d51360b2fbbff4db6cc37c080525
|
272e460422127048fe212bd0266d5794fdf0020e
|
refs/heads/main
| 2021-12-02T12:26:08.970000 | 2021-09-03T17:05:06 | 2021-09-03T17:05:06 | 400,543,280 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package it.polimi.eftaios.model.deck;
import it.polimi.eftaios.exception.NoElementException;
import it.polimi.eftaios.model.card.ShallopCard;
/**
* Fornisce il deck popolato delle carte scialuppa
*
* @author Federico
*
*/
public class DeckShallop extends AbstractDeck {
private static final long serialVersionUID = 1L;
private static final int NUM_SHALLOP_DAMAGE = 3;
private static final int NUM_SHALLOP_NOTDAMAGE = 3;
public DeckShallop() {
super();
for (int cardCounter = 1; cardCounter <= NUM_SHALLOP_DAMAGE; cardCounter++)
addCardToDeck(new ShallopCard(true));
for (int cardCounter = 1; cardCounter <= NUM_SHALLOP_NOTDAMAGE; cardCounter++)
addCardToDeck(new ShallopCard(false));
shuffle();
}
@Override
public ShallopCard draw() {
try {
return (ShallopCard) deck.remove(deck.size() - 1);
} catch (IndexOutOfBoundsException e) {
throw new NoElementException(e);
}
}
/**
* Ritorna il numero di carte presenti nel deck
*
* @return numero di carte nel deck
*/
public int getDeckSize() {
return deck.size();
}
}
|
UTF-8
|
Java
| 1,158 |
java
|
DeckShallop.java
|
Java
|
[
{
"context": "ck popolato delle carte scialuppa\r\n * \r\n * @author Federico\r\n *\r\n */\r\npublic class DeckShallop extends Abstra",
"end": 230,
"score": 0.9998243451118469,
"start": 222,
"tag": "NAME",
"value": "Federico"
}
] | null |
[] |
package it.polimi.eftaios.model.deck;
import it.polimi.eftaios.exception.NoElementException;
import it.polimi.eftaios.model.card.ShallopCard;
/**
* Fornisce il deck popolato delle carte scialuppa
*
* @author Federico
*
*/
public class DeckShallop extends AbstractDeck {
private static final long serialVersionUID = 1L;
private static final int NUM_SHALLOP_DAMAGE = 3;
private static final int NUM_SHALLOP_NOTDAMAGE = 3;
public DeckShallop() {
super();
for (int cardCounter = 1; cardCounter <= NUM_SHALLOP_DAMAGE; cardCounter++)
addCardToDeck(new ShallopCard(true));
for (int cardCounter = 1; cardCounter <= NUM_SHALLOP_NOTDAMAGE; cardCounter++)
addCardToDeck(new ShallopCard(false));
shuffle();
}
@Override
public ShallopCard draw() {
try {
return (ShallopCard) deck.remove(deck.size() - 1);
} catch (IndexOutOfBoundsException e) {
throw new NoElementException(e);
}
}
/**
* Ritorna il numero di carte presenti nel deck
*
* @return numero di carte nel deck
*/
public int getDeckSize() {
return deck.size();
}
}
| 1,158 | 0.660622 | 0.65544 | 44 | 24.318182 | 23.270906 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.386364 | false | false |
14
|
48b7e42bc900cf2621668bd027479865c5001f7b
| 32,573,032,021,553 |
b163450248603e4da56827a55a1b1d5cab7be91c
|
/src/test/java/com/ballot/rigging/stream/StreamDistinct.java
|
948082c8cf2e1fb4c5cfed02db89b7ef0c3cfbe0
|
[] |
no_license
|
TiAmowkd/likou
|
https://github.com/TiAmowkd/likou
|
0938ce1fc0ce51da99606ae0056238179f3cd8a0
|
039c27ddfec9b4946c5072a243a941c9c4fe608d
|
refs/heads/master
| 2022-06-29T10:20:30.812000 | 2021-05-11T09:38:40 | 2021-05-11T09:38:40 | 225,582,293 | 0 | 0 | null | false | 2022-06-17T02:44:01 | 2019-12-03T09:36:26 | 2021-05-11T09:38:52 | 2022-06-17T02:44:01 | 144 | 0 | 0 | 2 |
Java
| false | false |
package com.ballot.rigging.stream;
import com.ballot.rigging.pojo.Book;
import org.junit.Test;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* @Auther: wkd
* @Date: 2019/12/26 11:28
* @Description:
*/
public class StreamDistinct {
@Test
public void StreamDistinctTest() {
List<String> list = Arrays.asList("AA", "GG", "BB", "CC", "BB", "CC", "AA", "AA");
long l = list.stream().distinct().count();
System.out.println("No. of distinct elements:" + l);
String output = list.stream().distinct().collect(Collectors.joining(","));
System.out.println(output);
List<String> listStreamResult = list.stream().sorted(Comparator.comparing(String::toString))
.distinct().collect(Collectors.toList());
System.out.println(listStreamResult);
}
@Test
public void StreamDistinctTargetTest() {
List<Book> list = new ArrayList<>();
{
list.add(new Book("Core Java", 200));
list.add(new Book("Core Java", 300));
list.add(new Book("Learning Freemarker", 150));
list.add(new Book("Spring MVC", 200));
list.add(new Book("Hibernate", 300));
}
list.stream().filter(distinctByKey(b -> b.getName()))
.forEach(b -> System.out.println(b.getName() + "," + b.getPrice()));
}
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
//如果keyExtractor.apply(t)第一次出现则绑定一个值,返回null,若已绑定则返回值
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
}
|
UTF-8
|
Java
| 1,838 |
java
|
StreamDistinct.java
|
Java
|
[
{
"context": "port java.util.stream.Collectors;\n\n/**\n * @Auther: wkd\n * @Date: 2019/12/26 11:28\n * @Description:\n */\np",
"end": 293,
"score": 0.9996153116226196,
"start": 290,
"tag": "USERNAME",
"value": "wkd"
}
] | null |
[] |
package com.ballot.rigging.stream;
import com.ballot.rigging.pojo.Book;
import org.junit.Test;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* @Auther: wkd
* @Date: 2019/12/26 11:28
* @Description:
*/
public class StreamDistinct {
@Test
public void StreamDistinctTest() {
List<String> list = Arrays.asList("AA", "GG", "BB", "CC", "BB", "CC", "AA", "AA");
long l = list.stream().distinct().count();
System.out.println("No. of distinct elements:" + l);
String output = list.stream().distinct().collect(Collectors.joining(","));
System.out.println(output);
List<String> listStreamResult = list.stream().sorted(Comparator.comparing(String::toString))
.distinct().collect(Collectors.toList());
System.out.println(listStreamResult);
}
@Test
public void StreamDistinctTargetTest() {
List<Book> list = new ArrayList<>();
{
list.add(new Book("Core Java", 200));
list.add(new Book("Core Java", 300));
list.add(new Book("Learning Freemarker", 150));
list.add(new Book("Spring MVC", 200));
list.add(new Book("Hibernate", 300));
}
list.stream().filter(distinctByKey(b -> b.getName()))
.forEach(b -> System.out.println(b.getName() + "," + b.getPrice()));
}
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
//如果keyExtractor.apply(t)第一次出现则绑定一个值,返回null,若已绑定则返回值
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
}
| 1,838 | 0.621365 | 0.606264 | 51 | 34.058823 | 27.894346 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.803922 | false | false |
14
|
0eaa69f43c9763756b47f729f4ec652aedb17d7e
| 9,251,359,621,567 |
0dadff778f8b22081f74e0d6e35831132de453b2
|
/src/main/java/com/example/controller/DeployProcessController2.java
|
f7e5e8cec6968a41f3db2e6f77bf85845191b26c
|
[] |
no_license
|
snmaddula-fl/ud-deployment-process
|
https://github.com/snmaddula-fl/ud-deployment-process
|
f96f1550556bceca60ebe174bfd4a48cdabf8491
|
dee0f887b8a46a834d471865d8d1eeaa6c80147a
|
refs/heads/master
| 2020-07-14T17:05:19.147000 | 2019-09-25T12:22:34 | 2019-09-25T12:22:34 | 205,359,259 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.controller;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import com.example.config.UDeployManifest;
import com.example.domain.Deploy;
import com.example.dto.DeployRequest;
import com.example.dto.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class DeployProcessController2 {
private final RestTemplate rest;
private final UDeployManifest manifest;
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static final DateFormat UTC_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@PostConstruct
public void init() {
UTC_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@GetMapping("/")
public ModelAndView showView() {
ModelAndView mav = new ModelAndView();
mav.setViewName("deploy-process");
return mav;
}
@ResponseBody
@GetMapping("/apps")
public List<String> getApps() {
return Arrays.asList("A1", "A2", "A3");
}
@ResponseBody
@GetMapping("/{app-name}/environments")
public List<String> getEnvironments(@PathVariable("app-name") String app) {
return Arrays.asList("E1", "E2", "E3");
}
@ResponseBody
@GetMapping("/{app-name}/processes")
public List<String> getProcesses(@PathVariable("app-name") String app) {
return Arrays.asList("P1", "P2", "P3");
}
@ResponseBody
@GetMapping("/{app-name}/snapshots")
public List<String> getSnapshots(@PathVariable("app-name") String app) {
return Arrays.asList("S1", "S2", "S3");
}
@ResponseBody
@GetMapping("/{app-name}/components")
public List<String> getComponents(@PathVariable("app-name") String app) {
return Arrays.asList("C1", "C2", "C3");
}
@ResponseBody
@GetMapping("/{component-name}/versions")
public List<String> getComponentVersions(@PathVariable("component-name") String component) {
return Arrays.asList("V1", "V2", "V3");
}
@ResponseBody
@GetMapping("/{app-name}/{env}/agents")
public List<String> getAgents(@PathVariable("app-name") String app, @PathVariable("env") String env) {
return Arrays.asList("A1", "A2", "A3", "A4");
}
private String deploySnapshot(String scheduleDate, String snapshot, String proc, String env, String app) {
DeployRequest dr = new DeployRequest();
dr.setSnapshot(snapshot);
dr.setDate(scheduleDate);
dr.setApplication(app);
dr.setEnvironment(env);
dr.setApplicationProcess(proc);
try {
return rest.exchange(manifest.deployProcessUri().toString(), HttpMethod.PUT, new HttpEntity<DeployRequest>(dr, manifest.getBasicAuthHeaders()),
String.class).getBody();
}catch(Exception ex) {
ex.printStackTrace();
return "ERROR";
}
}
@ResponseBody
@PostMapping("/deploy")
public List<String> deployProcess(@RequestBody Deploy deploy) throws Exception {
System.out.println("INPUT = \n" + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(deploy));
String snapshot = null;
final String scheduleDate = StringUtils.hasText(deploy.getDate()) ? UTC_DATE_FORMAT.format(DATE_FORMAT.parse(deploy.getDate())) : "";
if(StringUtils.hasText(deploy.getSnapshot())) {
snapshot = deploy.getSnapshot();
return Arrays.asList(deploySnapshot(scheduleDate, snapshot, deploy.getProcess(), deploy.getEnv(), deploy.getApp()));
}else {
return
deploy.getRequests().stream().map(req -> new DeployRequest() {{
setDate(scheduleDate);
setVersions(Arrays.asList(new Version() {{
setComponent(req.getComp());
setVersion(req.getVer());
}}));
setApplication(req.getApp());
setEnvironment(req.getEnv());
setApplicationProcess(req.getProc());
}}).map(dr -> {
try {
System.out.println("INPUT = \n" + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(dr));
return rest
.exchange(manifest.deployProcessUri().toString(), HttpMethod.PUT,
new HttpEntity<DeployRequest>(dr, manifest.getBasicAuthHeaders()), String.class)
.getBody();
} catch (Exception ex) {
ex.printStackTrace();
return "ERROR";
}
}).collect(Collectors.toList());
}
}
}
|
UTF-8
|
Java
| 4,888 |
java
|
DeployProcessController2.java
|
Java
|
[] | null |
[] |
package com.example.controller;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import com.example.config.UDeployManifest;
import com.example.domain.Deploy;
import com.example.dto.DeployRequest;
import com.example.dto.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class DeployProcessController2 {
private final RestTemplate rest;
private final UDeployManifest manifest;
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static final DateFormat UTC_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@PostConstruct
public void init() {
UTC_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@GetMapping("/")
public ModelAndView showView() {
ModelAndView mav = new ModelAndView();
mav.setViewName("deploy-process");
return mav;
}
@ResponseBody
@GetMapping("/apps")
public List<String> getApps() {
return Arrays.asList("A1", "A2", "A3");
}
@ResponseBody
@GetMapping("/{app-name}/environments")
public List<String> getEnvironments(@PathVariable("app-name") String app) {
return Arrays.asList("E1", "E2", "E3");
}
@ResponseBody
@GetMapping("/{app-name}/processes")
public List<String> getProcesses(@PathVariable("app-name") String app) {
return Arrays.asList("P1", "P2", "P3");
}
@ResponseBody
@GetMapping("/{app-name}/snapshots")
public List<String> getSnapshots(@PathVariable("app-name") String app) {
return Arrays.asList("S1", "S2", "S3");
}
@ResponseBody
@GetMapping("/{app-name}/components")
public List<String> getComponents(@PathVariable("app-name") String app) {
return Arrays.asList("C1", "C2", "C3");
}
@ResponseBody
@GetMapping("/{component-name}/versions")
public List<String> getComponentVersions(@PathVariable("component-name") String component) {
return Arrays.asList("V1", "V2", "V3");
}
@ResponseBody
@GetMapping("/{app-name}/{env}/agents")
public List<String> getAgents(@PathVariable("app-name") String app, @PathVariable("env") String env) {
return Arrays.asList("A1", "A2", "A3", "A4");
}
private String deploySnapshot(String scheduleDate, String snapshot, String proc, String env, String app) {
DeployRequest dr = new DeployRequest();
dr.setSnapshot(snapshot);
dr.setDate(scheduleDate);
dr.setApplication(app);
dr.setEnvironment(env);
dr.setApplicationProcess(proc);
try {
return rest.exchange(manifest.deployProcessUri().toString(), HttpMethod.PUT, new HttpEntity<DeployRequest>(dr, manifest.getBasicAuthHeaders()),
String.class).getBody();
}catch(Exception ex) {
ex.printStackTrace();
return "ERROR";
}
}
@ResponseBody
@PostMapping("/deploy")
public List<String> deployProcess(@RequestBody Deploy deploy) throws Exception {
System.out.println("INPUT = \n" + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(deploy));
String snapshot = null;
final String scheduleDate = StringUtils.hasText(deploy.getDate()) ? UTC_DATE_FORMAT.format(DATE_FORMAT.parse(deploy.getDate())) : "";
if(StringUtils.hasText(deploy.getSnapshot())) {
snapshot = deploy.getSnapshot();
return Arrays.asList(deploySnapshot(scheduleDate, snapshot, deploy.getProcess(), deploy.getEnv(), deploy.getApp()));
}else {
return
deploy.getRequests().stream().map(req -> new DeployRequest() {{
setDate(scheduleDate);
setVersions(Arrays.asList(new Version() {{
setComponent(req.getComp());
setVersion(req.getVer());
}}));
setApplication(req.getApp());
setEnvironment(req.getEnv());
setApplicationProcess(req.getProc());
}}).map(dr -> {
try {
System.out.println("INPUT = \n" + new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(dr));
return rest
.exchange(manifest.deployProcessUri().toString(), HttpMethod.PUT,
new HttpEntity<DeployRequest>(dr, manifest.getBasicAuthHeaders()), String.class)
.getBody();
} catch (Exception ex) {
ex.printStackTrace();
return "ERROR";
}
}).collect(Collectors.toList());
}
}
}
| 4,888 | 0.73527 | 0.730565 | 145 | 32.710346 | 29.92771 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.268965 | false | false |
14
|
cd3493a1b43137372f4405a8670fae8669591efe
| 6,021,544,165,127 |
38ea111fb2484413c56bfb3b56b7381d70919127
|
/pprog/2015_2016/TPG_SOGE/src/SOGE/UIs/MenuUI.java
|
a70a8b278e88d32c5e4d799a2b8b6f66aec2cfe8
|
[
"LicenseRef-scancode-other-permissive"
] |
permissive
|
jbbmb/pt.isep.dei.lei
|
https://github.com/jbbmb/pt.isep.dei.lei
|
27ab68bbc63aec791c18317375a5c7ff563a4e0c
|
8d34e6f81844955766cd101ad5af057e2797f81e
|
refs/heads/master
| 2023-07-03T00:34:43.535000 | 2021-07-26T13:39:53 | 2021-07-26T13:39:53 | 272,506,607 | 0 | 0 |
NOASSERTION
| false | 2021-07-26T13:31:39 | 2020-06-15T17:49:34 | 2021-07-26T13:31:22 | 2021-07-26T13:31:38 | 1 | 0 | 0 | 1 |
Java
| false | false |
package SOGE.UIs;
/** @package SOGauthor Débora Costa (1150433), João Borges (1150475) e Luís Gouveia (1150437) @ LEI-ISEP */
import SOGE.CentroExposicoes;
import SOGE.Controllers.AtribuirCandidaturaController;
import java.awt.Desktop;
import java.awt.Label;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import utils.FicheirosBinarios;
public class MenuUI extends javax.swing.JFrame {
private CentroExposicoes centroExposicoes;
/**
* Cria uma nova instância do SOGE
*/
public MenuUI(CentroExposicoes ce) {
initComponents();
this.centroExposicoes = ce;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jDialog1 = new javax.swing.JDialog();
jDialog2 = new javax.swing.JDialog();
jDialog3 = new javax.swing.JDialog();
jPopupMenu1 = new javax.swing.JPopupMenu();
label3 = new java.awt.Label();
label1 = new java.awt.Label();
button2 = new java.awt.Button();
button3 = new java.awt.Button();
jLabel1 = new javax.swing.JLabel();
label2 = new java.awt.Label();
button4 = new java.awt.Button();
button5 = new java.awt.Button();
label5 = new java.awt.Label();
button11 = new java.awt.Button();
button12 = new java.awt.Button();
jLabel2 = new javax.swing.JLabel();
button6 = new java.awt.Button();
jSeparator3 = new javax.swing.JSeparator();
jSeparator4 = new javax.swing.JSeparator();
jSeparator5 = new javax.swing.JSeparator();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
jDialog2.getContentPane().setLayout(jDialog2Layout);
jDialog2Layout.setHorizontalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog2Layout.setVerticalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jDialog3Layout = new javax.swing.GroupLayout(jDialog3.getContentPane());
jDialog3.getContentPane().setLayout(jDialog3Layout);
jDialog3Layout.setHorizontalGroup(
jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog3Layout.setVerticalGroup(
jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
label3.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
label3.setText("Bem-vindo ao Sistema de Organização e Gestão de Exposições");
label3.setAlignment(Label.CENTER);
label1.setText("Candidaturas");
button2.setLabel("Avaliar candidatura");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
button3.setLabel("Registar candidatura");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button3ActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
jLabel1.setText("Sessão iniciada como Administrador - Centro de Exposições 1");
label2.setText("Exposição");
button4.setLabel("Criar demonstração de exposição");
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button4ActionPerformed(evt);
}
});
button5.setLabel("Criar exposição");
button5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button5ActionPerformed(evt);
}
});
label5.setText("Outros");
button11.setLabel("Definir recurso");
button11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button11ActionPerformed(evt);
}
});
button12.setLabel("Definir FAE");
button12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button12ActionPerformed(evt);
}
});
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
button6.setLabel("Atribuir candidatura");
button6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button6ActionPerformed(evt);
}
});
jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);
jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);
jMenu1.setText("Ficheiro");
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
jMenuItem1.setText("Importar dados");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK));
jMenuItem2.setText("Exportar dados");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenu1.add(jSeparator2);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
jMenuItem4.setText("Sair");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
jMenu3.setText("Utilizadores");
jMenu4.setText("Gestão de perfis");
jMenuItem7.setText("Criar perfil");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem7);
jMenuItem8.setText("Confirmar perfil");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem8);
jMenu3.add(jMenu4);
jMenu3.add(jSeparator1);
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK));
jMenuItem3.setText("Terminar sessão");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem3);
jMenuItem3.setEnabled(false);
jMenuBar1.add(jMenu3);
jMenu2.setText("Ajuda");
jMenuItem5.setText("Documentação online");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem5);
jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.ALT_MASK));
jMenuItem6.setText("Sobre o SOGE");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(340, 340, 340))))
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(87, 87, 87))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(button12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 108, Short.MAX_VALUE)
.addComponent(jLabel1))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Importar dados");
int userSelection = fileChooser.showOpenDialog(parentFrame);
File fileBin = fileChooser.getSelectedFile();
FicheirosBinarios novoFicheiro = new FicheirosBinarios(centroExposicoes);
try {
centroExposicoes = novoFicheiro.ler(fileBin.getPath());
} catch (IOException | ClassNotFoundException ex) {
JOptionPane.showMessageDialog(parentFrame, "O ficheiro não foi encontrado");
}
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
this.dispose();
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
Desktop d=Desktop.getDesktop();
try {
try {
d.browse(new URI("http://tinyurl.com/gm4pl47"));
} catch (URISyntaxException ex) {
Logger.getLogger(MenuUI.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (IOException ex) {
Logger.getLogger(MenuUI.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new AboutUI().setVisible(true);
});
}//GEN-LAST:event_jMenuItem6ActionPerformed
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button4ActionPerformed
private void button11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button11ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button11ActionPerformed
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button5ActionPerformed
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new EscolherCandidaturaUI().setVisible(true);
});
}//GEN-LAST:event_button2ActionPerformed
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new RegistarCandidaturaUI().setVisible(true);
});
}//GEN-LAST:event_button3ActionPerformed
private void button12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button12ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button12ActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Exportar dados");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileBin = fileChooser.getSelectedFile();
FicheirosBinarios file = new FicheirosBinarios(centroExposicoes);
try{
if(!fileBin.getName().endsWith(".bin")){
fileBin = new File(fileBin.getPath().trim() + ".bin");
}
if(file.gravar(fileBin.getPath())){
JOptionPane.showMessageDialog(parentFrame, "Ficheiro guardado com sucesso");
}
}catch (IOException ex){
JOptionPane.showMessageDialog(parentFrame, "Ficheiro não encontrado");
}
}
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_jMenuItem7ActionPerformed
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// NOTHING HERE
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_jMenuItem8ActionPerformed
private void button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button6ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new AtribuirCandidaturaUI(centroExposicoes).setVisible(true);
});
}//GEN-LAST:event_button6ActionPerformed
/**
* @param args the command line arguments
*/
public void run(){
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> {
new MenuUI(centroExposicoes).setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private java.awt.Button button11;
private java.awt.Button button12;
private java.awt.Button button2;
private java.awt.Button button3;
private java.awt.Button button4;
private java.awt.Button button5;
private java.awt.Button button6;
private javax.swing.JDialog jDialog1;
private javax.swing.JDialog jDialog2;
private javax.swing.JDialog jDialog3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private javax.swing.JSeparator jSeparator5;
private java.awt.Label label1;
private java.awt.Label label2;
private java.awt.Label label3;
private java.awt.Label label5;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 28,425 |
java
|
MenuUI.java
|
Java
|
[
{
"context": "package SOGE.UIs;\n/** @package SOGauthor Débora Costa (1150433), João Borges (1150475) e Luís Gouveia (",
"end": 53,
"score": 0.9998728632926941,
"start": 41,
"tag": "NAME",
"value": "Débora Costa"
},
{
"context": "Is;\n/** @package SOGauthor Débora Costa (1150433), João Borges (1150475) e Luís Gouveia (1150437) @ LEI-ISEP */\n",
"end": 76,
"score": 0.9998769760131836,
"start": 65,
"tag": "NAME",
"value": "João Borges"
},
{
"context": "or Débora Costa (1150433), João Borges (1150475) e Luís Gouveia (1150437) @ LEI-ISEP */\n\nimport SOGE.CentroExposi",
"end": 101,
"score": 0.9998670220375061,
"start": 89,
"tag": "NAME",
"value": "Luís Gouveia"
}
] | null |
[] |
package SOGE.UIs;
/** @package SOGauthor <NAME> (1150433), <NAME> (1150475) e <NAME> (1150437) @ LEI-ISEP */
import SOGE.CentroExposicoes;
import SOGE.Controllers.AtribuirCandidaturaController;
import java.awt.Desktop;
import java.awt.Label;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import utils.FicheirosBinarios;
public class MenuUI extends javax.swing.JFrame {
private CentroExposicoes centroExposicoes;
/**
* Cria uma nova instância do SOGE
*/
public MenuUI(CentroExposicoes ce) {
initComponents();
this.centroExposicoes = ce;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jDialog1 = new javax.swing.JDialog();
jDialog2 = new javax.swing.JDialog();
jDialog3 = new javax.swing.JDialog();
jPopupMenu1 = new javax.swing.JPopupMenu();
label3 = new java.awt.Label();
label1 = new java.awt.Label();
button2 = new java.awt.Button();
button3 = new java.awt.Button();
jLabel1 = new javax.swing.JLabel();
label2 = new java.awt.Label();
button4 = new java.awt.Button();
button5 = new java.awt.Button();
label5 = new java.awt.Label();
button11 = new java.awt.Button();
button12 = new java.awt.Button();
jLabel2 = new javax.swing.JLabel();
button6 = new java.awt.Button();
jSeparator3 = new javax.swing.JSeparator();
jSeparator4 = new javax.swing.JSeparator();
jSeparator5 = new javax.swing.JSeparator();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
jDialog2.getContentPane().setLayout(jDialog2Layout);
jDialog2Layout.setHorizontalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog2Layout.setVerticalGroup(
jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jDialog3Layout = new javax.swing.GroupLayout(jDialog3.getContentPane());
jDialog3.getContentPane().setLayout(jDialog3Layout);
jDialog3Layout.setHorizontalGroup(
jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog3Layout.setVerticalGroup(
jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
label3.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
label3.setText("Bem-vindo ao Sistema de Organização e Gestão de Exposições");
label3.setAlignment(Label.CENTER);
label1.setText("Candidaturas");
button2.setLabel("Avaliar candidatura");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
button3.setLabel("Registar candidatura");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button3ActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
jLabel1.setText("Sessão iniciada como Administrador - Centro de Exposições 1");
label2.setText("Exposição");
button4.setLabel("Criar demonstração de exposição");
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button4ActionPerformed(evt);
}
});
button5.setLabel("Criar exposição");
button5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button5ActionPerformed(evt);
}
});
label5.setText("Outros");
button11.setLabel("Definir recurso");
button11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button11ActionPerformed(evt);
}
});
button12.setLabel("Definir FAE");
button12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button12ActionPerformed(evt);
}
});
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
button6.setLabel("Atribuir candidatura");
button6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button6ActionPerformed(evt);
}
});
jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);
jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);
jMenu1.setText("Ficheiro");
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
jMenuItem1.setText("Importar dados");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK));
jMenuItem2.setText("Exportar dados");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenu1.add(jSeparator2);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
jMenuItem4.setText("Sair");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
jMenu3.setText("Utilizadores");
jMenu4.setText("Gestão de perfis");
jMenuItem7.setText("Criar perfil");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem7);
jMenuItem8.setText("Confirmar perfil");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem8);
jMenu3.add(jMenu4);
jMenu3.add(jSeparator1);
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK));
jMenuItem3.setText("Terminar sessão");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem3);
jMenuItem3.setEnabled(false);
jMenuBar1.add(jMenu3);
jMenu2.setText("Ajuda");
jMenuItem5.setText("Documentação online");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem5);
jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.ALT_MASK));
jMenuItem6.setText("Sobre o SOGE");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(label3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(340, 340, 340))))
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(87, 87, 87))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(button12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(button11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 108, Short.MAX_VALUE)
.addComponent(jLabel1))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Importar dados");
int userSelection = fileChooser.showOpenDialog(parentFrame);
File fileBin = fileChooser.getSelectedFile();
FicheirosBinarios novoFicheiro = new FicheirosBinarios(centroExposicoes);
try {
centroExposicoes = novoFicheiro.ler(fileBin.getPath());
} catch (IOException | ClassNotFoundException ex) {
JOptionPane.showMessageDialog(parentFrame, "O ficheiro não foi encontrado");
}
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
this.dispose();
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
Desktop d=Desktop.getDesktop();
try {
try {
d.browse(new URI("http://tinyurl.com/gm4pl47"));
} catch (URISyntaxException ex) {
Logger.getLogger(MenuUI.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (IOException ex) {
Logger.getLogger(MenuUI.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new AboutUI().setVisible(true);
});
}//GEN-LAST:event_jMenuItem6ActionPerformed
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button4ActionPerformed
private void button11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button11ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button11ActionPerformed
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button5ActionPerformed
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new EscolherCandidaturaUI().setVisible(true);
});
}//GEN-LAST:event_button2ActionPerformed
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new RegistarCandidaturaUI().setVisible(true);
});
}//GEN-LAST:event_button3ActionPerformed
private void button12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button12ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_button12ActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Exportar dados");
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileBin = fileChooser.getSelectedFile();
FicheirosBinarios file = new FicheirosBinarios(centroExposicoes);
try{
if(!fileBin.getName().endsWith(".bin")){
fileBin = new File(fileBin.getPath().trim() + ".bin");
}
if(file.gravar(fileBin.getPath())){
JOptionPane.showMessageDialog(parentFrame, "Ficheiro guardado com sucesso");
}
}catch (IOException ex){
JOptionPane.showMessageDialog(parentFrame, "Ficheiro não encontrado");
}
}
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_jMenuItem7ActionPerformed
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// NOTHING HERE
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
JOptionPane.showMessageDialog(null, "Esta função não se encontra disponível.");
}//GEN-LAST:event_jMenuItem8ActionPerformed
private void button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button6ActionPerformed
java.awt.EventQueue.invokeLater(() -> {
new AtribuirCandidaturaUI(centroExposicoes).setVisible(true);
});
}//GEN-LAST:event_button6ActionPerformed
/**
* @param args the command line arguments
*/
public void run(){
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MenuUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> {
new MenuUI(centroExposicoes).setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private java.awt.Button button11;
private java.awt.Button button12;
private java.awt.Button button2;
private java.awt.Button button3;
private java.awt.Button button4;
private java.awt.Button button5;
private java.awt.Button button6;
private javax.swing.JDialog jDialog1;
private javax.swing.JDialog jDialog2;
private javax.swing.JDialog jDialog3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private javax.swing.JSeparator jSeparator5;
private java.awt.Label label1;
private java.awt.Label label2;
private java.awt.Label label3;
private java.awt.Label label5;
// End of variables declaration//GEN-END:variables
}
| 28,405 | 0.663789 | 0.649269 | 543 | 51.257828 | 41.491661 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.703499 | false | false |
14
|
3fe8dbee84e628405dc2a9db8f0a62c28df33606
| 23,072,564,358,681 |
a354ddb5559ae048519814aa3d2f6c1513a3a1d3
|
/book4/src/Module20.java
|
aa560baf4859e4191f978fa742d6bc035a3cf43c
|
[] |
no_license
|
ufdilla/backUp
|
https://github.com/ufdilla/backUp
|
4050309674f00423bcc2ba62247fa629b4927ed9
|
bcdce3d34bee9a0ba3157d2641ab41c086094312
|
refs/heads/master
| 2021-05-11T23:04:48.149000 | 2018-01-15T06:34:36 | 2018-01-15T06:34:36 | 117,506,517 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Module20
{
int column1; // not yet explained why it is a column
private void operation1() // looks like nullary operation
{
System.out.println(column1);
}
private void operation2 (/*Module20 this*/)
{ // similiar, look like nullary operation
System.out.println(this.column1);
}
public static void main(String[] args)
{
Module20 RecObject1 = new Module20();
RecObject1.column1 = 1;
Module20 RecObject2 = new Module20();
RecObject2.column1 = 2;
RecObject1.operation1(); // operation1 (RecObject1);
RecObject2.operation1(); // operation1 (RecObject2);
RecObject1.operation2(); // operation2 (RecObject1);
RecObject2.operation2(); // operation2 (RecObject2);
}
}
|
UTF-8
|
Java
| 788 |
java
|
Module20.java
|
Java
|
[] | null |
[] |
public class Module20
{
int column1; // not yet explained why it is a column
private void operation1() // looks like nullary operation
{
System.out.println(column1);
}
private void operation2 (/*Module20 this*/)
{ // similiar, look like nullary operation
System.out.println(this.column1);
}
public static void main(String[] args)
{
Module20 RecObject1 = new Module20();
RecObject1.column1 = 1;
Module20 RecObject2 = new Module20();
RecObject2.column1 = 2;
RecObject1.operation1(); // operation1 (RecObject1);
RecObject2.operation1(); // operation1 (RecObject2);
RecObject1.operation2(); // operation2 (RecObject1);
RecObject2.operation2(); // operation2 (RecObject2);
}
}
| 788 | 0.638325 | 0.586294 | 24 | 31.833334 | 22.180447 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
14
|
8e85d88a58cd2c6b06ef19377c2148b778519616
| 34,583,076,675,038 |
5b3967c0ba4503308ddc3c840bfa96c5f10665e1
|
/multiplicity3-parent/multiplicity3-contentsystem/src/main/java/multiplicity3/csys/zorder/ZOrderManager.java
|
690f06a0e61a5ecd6a18b363ee2006e9e8aa56f7
|
[
"BSD-3-Clause"
] |
permissive
|
jamcnaughton/synergynet3
|
https://github.com/jamcnaughton/synergynet3
|
ce549f841190fee4f9b39264a5b3df4aebad2b2b
|
8ef37a03253b39515c914efa021309428b63ef53
|
refs/heads/master
| 2020-04-18T22:41:47.206000 | 2017-07-07T15:21:20 | 2017-07-07T15:21:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package multiplicity3.csys.zorder;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import multiplicity3.csys.items.item.IItem;
import multiplicity3.input.events.MultiTouchCursorEvent;
public class ZOrderManager implements IZOrderManager {
private static final Logger log = Logger.getLogger(ZOrderManager.class.getName());
protected List<IItem> registeredItems = new ArrayList<IItem>();
private int capacity = 1;
protected int startZOrder = 1000;
protected int usedZSpace = 1;
private IItem itemBeingManaged;
private boolean autoBringToTop = true;
private boolean bringToTopPropagatesUp = true;
public ZOrderManager(IItem itemBeingManaged, int initialCapacity) {
capacity = initialCapacity;
this.itemBeingManaged = itemBeingManaged;
}
public IZOrderManager getParentZOrderManager() {
if(itemBeingManaged != null && itemBeingManaged.getParentItem() != null) {
return itemBeingManaged.getParentItem().getZOrderManager();
}
return null;
}
@Override
public void itemCursorPressed(IItem item, MultiTouchCursorEvent event) {
if(autoBringToTop) {
log.fine("Bringing " + item + " to the top");
bringToTop(item);
}
if(bringToTopPropagatesUp && getParentZOrderManager() != null) {
getParentZOrderManager().bringToTop(item.getParentItem());
}
}
@Override
public int getItemZOrder() {
return this.startZOrder;
}
@Override
public void setItemZOrder(int zValue) {
this.startZOrder = zValue;
updateOrder();
}
@Override
public void notifyChildZCapacityChanged(IItem item, IZOrderManager manager) {
log.fine(this.itemBeingManaged + " has item that changed capacity: " + item);
int zReq = capacity;
for(IItem i : registeredItems) {
zReq += i.getZOrderManager().getZCapacity();
}
this.usedZSpace = zReq;
if(usedZSpace > capacity) {
doubleZSpaceCapacity();
}
updateOrder();
}
@Override
public int getZCapacity() {
return capacity;
}
@Override
public void setZCapacity(int c) {
log.fine(this.itemBeingManaged + " setCapacity " + c);
if(c > capacity) {
this.capacity = c;
log.fine(this.itemBeingManaged + " now has z capacity of " + this.capacity);
informParentThatCapacityChanged();
}
}
@Override
public void updateOrder() {
if(itemBeingManaged != null) {
itemBeingManaged.setZOrder(startZOrder);
}
int z = startZOrder;
for(IItem i : registeredItems) {
i.getZOrderManager().setItemZOrder(z);
z -= i.getZOrderManager().getZCapacity();
}
}
@Override
public void registerForZOrdering(IItem item) {
if(!registeredItems.contains(item)) {
registeredItems.add(0, item);
item.getZOrderManager().setItemZOrder(usedZSpace);
usedZSpace += item.getZOrderManager().getZCapacity();
if(usedZSpace > capacity) {
doubleZSpaceCapacity();
}
item.addItemListener(this);
}
updateOrder();
}
@Override
public void unregisterForZOrdering(IItem item) {
if(registeredItems.contains(item)) {
registeredItems.remove(item);
usedZSpace -= item.getZOrderManager().getZCapacity();
item.removeItemListener(this);
}
updateOrder();
}
@Override
public void bringToTop(IItem item) {
registeredItems.remove(item);
registeredItems.add(0, item);
updateOrder();
}
@Override
public void sendToBottom(IItem item) {
registeredItems.remove(item);
registeredItems.add(item);
updateOrder();
}
@Override
public void setAutoBringToTop(boolean enabled) {
this.autoBringToTop = enabled;
updateOrder();
}
@Override
public void setBringToTopPropagatesUp(boolean should) {
this.bringToTopPropagatesUp = should;
}
@Override
public void ignoreItemClickedBehaviour(IItem item) {
item.removeItemListener(this);
}
// ****** unused ********
@Override
public void itemMoved(IItem item) {}
@Override
public void itemRotated(IItem item) {}
@Override
public void itemScaled(IItem item) {}
@Override
public void itemCursorReleased(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemCursorChanged(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemCursorClicked(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemZOrderChanged(IItem item) {}
@Override
public void itemVisibilityChanged(IItem item, boolean isVisible) {}
// ****** private methods *****
private void doubleZSpaceCapacity() {
setZCapacity(getZCapacity() * 2);
}
private void informParentThatCapacityChanged() {
if(getParentZOrderManager() != null) {
getParentZOrderManager().notifyChildZCapacityChanged(itemBeingManaged, this);
}
}
}
|
UTF-8
|
Java
| 4,616 |
java
|
ZOrderManager.java
|
Java
|
[] | null |
[] |
package multiplicity3.csys.zorder;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import multiplicity3.csys.items.item.IItem;
import multiplicity3.input.events.MultiTouchCursorEvent;
public class ZOrderManager implements IZOrderManager {
private static final Logger log = Logger.getLogger(ZOrderManager.class.getName());
protected List<IItem> registeredItems = new ArrayList<IItem>();
private int capacity = 1;
protected int startZOrder = 1000;
protected int usedZSpace = 1;
private IItem itemBeingManaged;
private boolean autoBringToTop = true;
private boolean bringToTopPropagatesUp = true;
public ZOrderManager(IItem itemBeingManaged, int initialCapacity) {
capacity = initialCapacity;
this.itemBeingManaged = itemBeingManaged;
}
public IZOrderManager getParentZOrderManager() {
if(itemBeingManaged != null && itemBeingManaged.getParentItem() != null) {
return itemBeingManaged.getParentItem().getZOrderManager();
}
return null;
}
@Override
public void itemCursorPressed(IItem item, MultiTouchCursorEvent event) {
if(autoBringToTop) {
log.fine("Bringing " + item + " to the top");
bringToTop(item);
}
if(bringToTopPropagatesUp && getParentZOrderManager() != null) {
getParentZOrderManager().bringToTop(item.getParentItem());
}
}
@Override
public int getItemZOrder() {
return this.startZOrder;
}
@Override
public void setItemZOrder(int zValue) {
this.startZOrder = zValue;
updateOrder();
}
@Override
public void notifyChildZCapacityChanged(IItem item, IZOrderManager manager) {
log.fine(this.itemBeingManaged + " has item that changed capacity: " + item);
int zReq = capacity;
for(IItem i : registeredItems) {
zReq += i.getZOrderManager().getZCapacity();
}
this.usedZSpace = zReq;
if(usedZSpace > capacity) {
doubleZSpaceCapacity();
}
updateOrder();
}
@Override
public int getZCapacity() {
return capacity;
}
@Override
public void setZCapacity(int c) {
log.fine(this.itemBeingManaged + " setCapacity " + c);
if(c > capacity) {
this.capacity = c;
log.fine(this.itemBeingManaged + " now has z capacity of " + this.capacity);
informParentThatCapacityChanged();
}
}
@Override
public void updateOrder() {
if(itemBeingManaged != null) {
itemBeingManaged.setZOrder(startZOrder);
}
int z = startZOrder;
for(IItem i : registeredItems) {
i.getZOrderManager().setItemZOrder(z);
z -= i.getZOrderManager().getZCapacity();
}
}
@Override
public void registerForZOrdering(IItem item) {
if(!registeredItems.contains(item)) {
registeredItems.add(0, item);
item.getZOrderManager().setItemZOrder(usedZSpace);
usedZSpace += item.getZOrderManager().getZCapacity();
if(usedZSpace > capacity) {
doubleZSpaceCapacity();
}
item.addItemListener(this);
}
updateOrder();
}
@Override
public void unregisterForZOrdering(IItem item) {
if(registeredItems.contains(item)) {
registeredItems.remove(item);
usedZSpace -= item.getZOrderManager().getZCapacity();
item.removeItemListener(this);
}
updateOrder();
}
@Override
public void bringToTop(IItem item) {
registeredItems.remove(item);
registeredItems.add(0, item);
updateOrder();
}
@Override
public void sendToBottom(IItem item) {
registeredItems.remove(item);
registeredItems.add(item);
updateOrder();
}
@Override
public void setAutoBringToTop(boolean enabled) {
this.autoBringToTop = enabled;
updateOrder();
}
@Override
public void setBringToTopPropagatesUp(boolean should) {
this.bringToTopPropagatesUp = should;
}
@Override
public void ignoreItemClickedBehaviour(IItem item) {
item.removeItemListener(this);
}
// ****** unused ********
@Override
public void itemMoved(IItem item) {}
@Override
public void itemRotated(IItem item) {}
@Override
public void itemScaled(IItem item) {}
@Override
public void itemCursorReleased(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemCursorChanged(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemCursorClicked(IItem item, MultiTouchCursorEvent event) {}
@Override
public void itemZOrderChanged(IItem item) {}
@Override
public void itemVisibilityChanged(IItem item, boolean isVisible) {}
// ****** private methods *****
private void doubleZSpaceCapacity() {
setZCapacity(getZCapacity() * 2);
}
private void informParentThatCapacityChanged() {
if(getParentZOrderManager() != null) {
getParentZOrderManager().notifyChildZCapacityChanged(itemBeingManaged, this);
}
}
}
| 4,616 | 0.72812 | 0.72552 | 201 | 21.965174 | 22.549973 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.671642 | false | false |
14
|
1964a60caada6636b15dc1d08e3bb6e6c1a41c2c
| 14,259,291,423,204 |
b63799eadf94cfcb7899825aa83045bb9e322241
|
/Examen12/app/src/main/java/cr/ac/itcr/examen1/MainActivity.java
|
6e80bb1093a3c5e5b70b3f843a7541e400ee9d0d
|
[] |
no_license
|
Jona1095/Examen-1
|
https://github.com/Jona1095/Examen-1
|
33e6d274a968fd73d9175cef6382752c675daf14
|
b7a2fd921a7a471814a37ab590a3f5bd67481fda
|
refs/heads/master
| 2016-09-12T22:14:05.126000 | 2016-04-14T01:40:07 | 2016-04-14T01:40:07 | 56,197,938 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cr.ac.itcr.examen1;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import cr.ac.itcr.examen1.Class.Bird;
import cr.ac.itcr.examen1.Class.User;
import cr.ac.itcr.examen1.Data.BirdRepository;
import cr.ac.itcr.examen1.Data.IRepository;
import cr.ac.itcr.examen1.Data.UserRepository;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onClickSignIn(View view) {
Intent i = new Intent(getApplicationContext(),SignInActivity.class);;
startActivity(i);
}
public void onClickLogin(View view) {
EditText username = (EditText) findViewById(R.id.txtUsername);
EditText password = (EditText) findViewById(R.id.txtPassword);
ArrayList<User> listUser;
IRepository allUser = new UserRepository(getBaseContext().getApplicationContext());
listUser = allUser.GetAll();
if(username.getText().toString().equals("") && password.getText().toString().equals("")){
Toast.makeText(getApplicationContext(), "Some fields are empty",
Toast.LENGTH_SHORT).show();
}
else{
for(int i = 0; i < listUser.size(); i++)
{
if(listUser.get(i).getUsername().equals(username.getText().toString()) &&
listUser.get(i).getPassword().equals(password.getText().toString())) {
Intent x = new Intent(getApplicationContext(), DashboardActivity.class);
startActivity(x);
this.finish();
return;
}
}
Toast.makeText(getApplicationContext(), "Invalid User",
Toast.LENGTH_SHORT).show();
}
}
}
|
UTF-8
|
Java
| 3,144 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package cr.ac.itcr.examen1;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import cr.ac.itcr.examen1.Class.Bird;
import cr.ac.itcr.examen1.Class.User;
import cr.ac.itcr.examen1.Data.BirdRepository;
import cr.ac.itcr.examen1.Data.IRepository;
import cr.ac.itcr.examen1.Data.UserRepository;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onClickSignIn(View view) {
Intent i = new Intent(getApplicationContext(),SignInActivity.class);;
startActivity(i);
}
public void onClickLogin(View view) {
EditText username = (EditText) findViewById(R.id.txtUsername);
EditText password = (EditText) findViewById(R.id.txtPassword);
ArrayList<User> listUser;
IRepository allUser = new UserRepository(getBaseContext().getApplicationContext());
listUser = allUser.GetAll();
if(username.getText().toString().equals("") && password.getText().toString().equals("")){
Toast.makeText(getApplicationContext(), "Some fields are empty",
Toast.LENGTH_SHORT).show();
}
else{
for(int i = 0; i < listUser.size(); i++)
{
if(listUser.get(i).getUsername().equals(username.getText().toString()) &&
listUser.get(i).getPassword().equals(password.getText().toString())) {
Intent x = new Intent(getApplicationContext(), DashboardActivity.class);
startActivity(x);
this.finish();
return;
}
}
Toast.makeText(getApplicationContext(), "Invalid User",
Toast.LENGTH_SHORT).show();
}
}
}
| 3,144 | 0.659669 | 0.656807 | 92 | 33.173912 | 26.246162 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.597826 | false | false |
14
|
43b1eed3403136b8d5eba73b3edd3ebd9633a8ab
| 11,184,094,870,819 |
b6772bf99b6e55e61f3defac401311b9d1fb34db
|
/src/main/java/cn/bysj/yty/qyyg/controller/JobRest.java
|
39f656e783dc053a07a4eb5c1c603134e74dda7d
|
[] |
no_license
|
candy-yyyyy/qyyg
|
https://github.com/candy-yyyyy/qyyg
|
4fd5c5ade057b1c2fe10c9380ded3793b35fe548
|
f81f122992430bbff749409f3874496816be37db
|
refs/heads/master
| 2020-04-19T11:58:54.665000 | 2019-04-26T14:12:32 | 2019-04-26T14:12:32 | 168,181,437 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.bysj.yty.qyyg.controller;
import cn.bysj.yty.qyyg.common.ControllerMapping;
import cn.bysj.yty.qyyg.common.UrlMapping;
import cn.bysj.yty.qyyg.service.JobService;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.util.StringUtils;
@RestController
@RequestMapping(value= ControllerMapping.JOB)
public class JobRest {
private final Logger logger = LoggerFactory.getLogger(JobRest.class);
@Autowired
private JobService jobService;
@RequestMapping(value = UrlMapping.ADD_JOB, method = RequestMethod.POST)
public JSONObject addJob(String jobName, String jobDesc) {
JSONObject rspJson = new JSONObject();
if(StringUtils.isEmpty(jobName)){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数jobName不能为空!");
return rspJson;
}
try{
rspJson = jobService.addJob(jobName, jobDesc);
}catch(Exception e){
logger.error("新增工种异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","新增工种异常");
}
return rspJson;
}
@RequestMapping(value = UrlMapping.GET_JOB, method = RequestMethod.POST)
public JSONObject getJob(String jobName, String state,Integer pageNo,Integer pageSize) {
JSONObject rspJson = new JSONObject();
if(pageNo==null){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数pageNo不能为空!");
return rspJson;
}
if(pageSize==null){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数pageSize不能为空!");
return rspJson;
}
try{
rspJson = jobService.qryJobByCondition(jobName, state, pageNo, pageSize);
if(rspJson!=null){
rspJson.put("respCode","0000");
rspJson.put("respDesc","查询工种列表成功!");
}else{
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","查询工种列表失败!");
}
}catch(Exception e){
logger.error("查询工种列表异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","查询工种列表异常!");
}
return rspJson;
}
@RequestMapping(value = UrlMapping.UPDATE_JOB_STATE, method = RequestMethod.POST)
public JSONObject updateJobState(Integer jobId, Integer state) {
JSONObject rspJson = new JSONObject();
try{
rspJson = jobService.updateJobState(jobId, state);
}catch(Exception e){
logger.error("修改工种状态异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","修改工种状态异常");
}
return rspJson;
}
}
|
UTF-8
|
Java
| 3,342 |
java
|
JobRest.java
|
Java
|
[] | null |
[] |
package cn.bysj.yty.qyyg.controller;
import cn.bysj.yty.qyyg.common.ControllerMapping;
import cn.bysj.yty.qyyg.common.UrlMapping;
import cn.bysj.yty.qyyg.service.JobService;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.util.StringUtils;
@RestController
@RequestMapping(value= ControllerMapping.JOB)
public class JobRest {
private final Logger logger = LoggerFactory.getLogger(JobRest.class);
@Autowired
private JobService jobService;
@RequestMapping(value = UrlMapping.ADD_JOB, method = RequestMethod.POST)
public JSONObject addJob(String jobName, String jobDesc) {
JSONObject rspJson = new JSONObject();
if(StringUtils.isEmpty(jobName)){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数jobName不能为空!");
return rspJson;
}
try{
rspJson = jobService.addJob(jobName, jobDesc);
}catch(Exception e){
logger.error("新增工种异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","新增工种异常");
}
return rspJson;
}
@RequestMapping(value = UrlMapping.GET_JOB, method = RequestMethod.POST)
public JSONObject getJob(String jobName, String state,Integer pageNo,Integer pageSize) {
JSONObject rspJson = new JSONObject();
if(pageNo==null){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数pageNo不能为空!");
return rspJson;
}
if(pageSize==null){
rspJson.put("respCode","9999");
rspJson.put("respDesc","参数pageSize不能为空!");
return rspJson;
}
try{
rspJson = jobService.qryJobByCondition(jobName, state, pageNo, pageSize);
if(rspJson!=null){
rspJson.put("respCode","0000");
rspJson.put("respDesc","查询工种列表成功!");
}else{
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","查询工种列表失败!");
}
}catch(Exception e){
logger.error("查询工种列表异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","查询工种列表异常!");
}
return rspJson;
}
@RequestMapping(value = UrlMapping.UPDATE_JOB_STATE, method = RequestMethod.POST)
public JSONObject updateJobState(Integer jobId, Integer state) {
JSONObject rspJson = new JSONObject();
try{
rspJson = jobService.updateJobState(jobId, state);
}catch(Exception e){
logger.error("修改工种状态异常:",e);
rspJson = new JSONObject();
rspJson.put("respCode","9999");
rspJson.put("respDesc","修改工种状态异常");
}
return rspJson;
}
}
| 3,342 | 0.61995 | 0.609217 | 87 | 35.413792 | 22.063416 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.931035 | false | false |
14
|
6b74c419bba546af0b8603fd4779b714e1fe1046
| 3,255,585,228,642 |
fd532dafb44e74703e1e9417070b123f0de18b9f
|
/src/main/java/cn/com/xinli/portal/core/redirection/RedirectService.java
|
5e34d5bb7800a45a40be27a1ef01ef0c22da9a33
|
[] |
no_license
|
Morcal/SpringBootServer
|
https://github.com/Morcal/SpringBootServer
|
865b998255299c203f5fe07e8ce046933527d59a
|
5d4e254b76c342d913db37f5bf69d6258aecd1c0
|
refs/heads/master
| 2021-01-20T19:27:02.899000 | 2016-07-06T13:27:40 | 2016-07-06T13:27:40 | 62,722,827 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.com.xinli.portal.core.redirection;
import cn.com.xinli.portal.core.RemoteException;
/**
* Portal web redirect service.
*
* <p>Project: xpws
*
* @author zhoupeng 2016/2/21.
*/
public interface RedirectService {
/**
* Verify redirection.
* @param redirection redirection.
* @param ip user ip address.
* @param mac user mac address.
* @return full populated redirection.
* @throws RemoteException
*/
Redirection verify(Redirection redirection, String ip, String mac) throws RemoteException;
}
|
UTF-8
|
Java
| 552 |
java
|
RedirectService.java
|
Java
|
[
{
"context": "rect service.\n *\n * <p>Project: xpws\n *\n * @author zhoupeng 2016/2/21.\n */\npublic interface RedirectService {",
"end": 178,
"score": 0.998450517654419,
"start": 170,
"tag": "USERNAME",
"value": "zhoupeng"
}
] | null |
[] |
package cn.com.xinli.portal.core.redirection;
import cn.com.xinli.portal.core.RemoteException;
/**
* Portal web redirect service.
*
* <p>Project: xpws
*
* @author zhoupeng 2016/2/21.
*/
public interface RedirectService {
/**
* Verify redirection.
* @param redirection redirection.
* @param ip user ip address.
* @param mac user mac address.
* @return full populated redirection.
* @throws RemoteException
*/
Redirection verify(Redirection redirection, String ip, String mac) throws RemoteException;
}
| 552 | 0.688406 | 0.675725 | 22 | 24.09091 | 22.358461 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.227273 | false | false |
14
|
0192f2c66d24c3958e4f3ce6f999238d1f2235d3
| 31,851,477,525,762 |
2ebabea7d16dc4d2a9ffdc1153c60bd9073fe9d8
|
/pet-clinic/pet-clinic-data/src/test/java/com/sletras/services/OwnerServiceMapTest.java
|
d45005cf34f8ac1aaf4d00876467ce974d469f6b
|
[] |
no_license
|
sefrota/spring5
|
https://github.com/sefrota/spring5
|
a9c24639d29dde7c472c73d3259162bcac40b8c1
|
602a9e60ed0c3e3aa28f70ea72c2a5a0f2d8fcfe
|
refs/heads/master
| 2020-04-20T11:32:00.750000 | 2019-02-25T23:55:27 | 2019-02-25T23:55:27 | 168,819,071 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sletras.services;
import com.sletras.services.map.PetServiceMap;
import com.sletras.services.map.PetTypeServiceMap;
import org.junit.Before;
import com.sletras.services.map.OwnerServiceMap;
import org.junit.Test;
/**
* Created by sergioletras on 12/02/19.
*/
public class OwnerServiceMapTest {
OwnerServiceMap ownerServiceMap;
PetTypeServiceMap petTypeService;
PetServiceMap petService;
@Before
public void setup(){
ownerServiceMap = new OwnerServiceMap(petService, petTypeService);
}
@Test
public void test(){
System.out.print("A");
}
}
|
UTF-8
|
Java
| 609 |
java
|
OwnerServiceMapTest.java
|
Java
|
[
{
"context": "viceMap;\nimport org.junit.Test;\n\n/**\n * Created by sergioletras on 12/02/19.\n */\npublic class OwnerServiceMapTest",
"end": 257,
"score": 0.9994251132011414,
"start": 245,
"tag": "USERNAME",
"value": "sergioletras"
}
] | null |
[] |
package com.sletras.services;
import com.sletras.services.map.PetServiceMap;
import com.sletras.services.map.PetTypeServiceMap;
import org.junit.Before;
import com.sletras.services.map.OwnerServiceMap;
import org.junit.Test;
/**
* Created by sergioletras on 12/02/19.
*/
public class OwnerServiceMapTest {
OwnerServiceMap ownerServiceMap;
PetTypeServiceMap petTypeService;
PetServiceMap petService;
@Before
public void setup(){
ownerServiceMap = new OwnerServiceMap(petService, petTypeService);
}
@Test
public void test(){
System.out.print("A");
}
}
| 609 | 0.727422 | 0.71757 | 27 | 21.555555 | 19.446667 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false |
14
|
7b856ddf251383aa974722d94d5e8882ad319013
| 33,758,442,946,730 |
3c29cecfc933323ea83ba153077844ef82f6663a
|
/src/main/java/com/thinkgem/jeesite/modules/mmy/book/dao/LessionClassBindDao.java
|
96d0ae1aa4b2a31451ae823ed77fd40a1cc738bc
|
[
"Apache-2.0"
] |
permissive
|
rjp1234/mmg-manager
|
https://github.com/rjp1234/mmg-manager
|
33f6754068d610ca21c1b1c44fa5886f50dda786
|
727bf1c4f4dd5b842f733d1b8537da782110be5c
|
refs/heads/master
| 2020-03-19T06:38:18.826000 | 2018-07-27T16:00:30 | 2018-07-27T16:00:30 | 136,041,524 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* 文件名:LessionClassBindDao.java
*
* 版本信息:
* 日期:2018年6月12日
* Copyright 足下 Corporation 2018
* 版权所有
*
*/
package com.thinkgem.jeesite.modules.mmy.book.dao;
import java.util.List;
import com.thinkgem.jeesite.common.persistence.CrudDao;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.mmy.book.entity.LessionClassBindInfo;
/**
*
* 项目名称:mmg-manager 类名称:LessionClassBindDao 类描述: 创建人:Administrator
* 创建时间:2018年6月12日 上午11:25:53 修改人:Administrator 修改时间:2018年6月12日 上午11:25:53 修改备注:
*
* @version
*
*/
@MyBatisDao
public interface LessionClassBindDao extends CrudDao<LessionClassBindInfo> {
/**
*
* lessionBindClass(这里用一句话描述这个方法的作用)
*
*
*/
int lessionBindClass(LessionClassBindInfo bind);
List<LessionClassBindInfo> getByLessionId(LessionClassBindInfo bind);
List<LessionClassBindInfo> getByClassId(LessionClassBindInfo bind);
int countSameBind(LessionClassBindInfo bind);
/**
*
* delById(这里用一句话描述这个方法的作用)
*
*
*/
int delById(LessionClassBindInfo bind);
int delByClassIdAndLessionId(LessionClassBindInfo bind);
LessionClassBindInfo getById(LessionClassBindInfo bind);
}
|
UTF-8
|
Java
| 1,464 |
java
|
LessionClassBindDao.java
|
Java
|
[
{
"context": "项目名称:mmg-manager 类名称:LessionClassBindDao 类描述: 创建人:Administrator\n * 创建时间:2018年6月12日 上午11:25:53 修改人:Administrator 修",
"end": 497,
"score": 0.8912829160690308,
"start": 484,
"tag": "NAME",
"value": "Administrator"
},
{
"context": "人:Administrator\n * 创建时间:2018年6月12日 上午11:25:53 修改人:Administrator 修改时间:2018年6月12日 上午11:25:53 修改备注:\n * \n * @version\n",
"end": 545,
"score": 0.8923712968826294,
"start": 532,
"tag": "NAME",
"value": "Administrator"
}
] | null |
[] |
/**
* 文件名:LessionClassBindDao.java
*
* 版本信息:
* 日期:2018年6月12日
* Copyright 足下 Corporation 2018
* 版权所有
*
*/
package com.thinkgem.jeesite.modules.mmy.book.dao;
import java.util.List;
import com.thinkgem.jeesite.common.persistence.CrudDao;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.mmy.book.entity.LessionClassBindInfo;
/**
*
* 项目名称:mmg-manager 类名称:LessionClassBindDao 类描述: 创建人:Administrator
* 创建时间:2018年6月12日 上午11:25:53 修改人:Administrator 修改时间:2018年6月12日 上午11:25:53 修改备注:
*
* @version
*
*/
@MyBatisDao
public interface LessionClassBindDao extends CrudDao<LessionClassBindInfo> {
/**
*
* lessionBindClass(这里用一句话描述这个方法的作用)
*
*
*/
int lessionBindClass(LessionClassBindInfo bind);
List<LessionClassBindInfo> getByLessionId(LessionClassBindInfo bind);
List<LessionClassBindInfo> getByClassId(LessionClassBindInfo bind);
int countSameBind(LessionClassBindInfo bind);
/**
*
* delById(这里用一句话描述这个方法的作用)
*
*
*/
int delById(LessionClassBindInfo bind);
int delByClassIdAndLessionId(LessionClassBindInfo bind);
LessionClassBindInfo getById(LessionClassBindInfo bind);
}
| 1,464 | 0.711024 | 0.68189 | 55 | 22.09091 | 25.951895 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.218182 | false | false |
14
|
a593c0963e9e7413e22fe5a45d8d22cdf062ae30
| 7,876,970,036,236 |
1de8def607b6718f7aa762c13762d94392d0df6e
|
/src/main/java/niche/newres/timedevents2owl/generator/io/JenaBeansWriter.java
|
ebcd356c40b4815005ef0d5069ecb18e79ef2637
|
[
"Apache-2.0"
] |
permissive
|
Newres/TimedEvents2OWL
|
https://github.com/Newres/TimedEvents2OWL
|
a2f398f4ef9139513b02415eab010d849436eb1a
|
699e2b865ff2e98c7b94ad23d6d7971a95304c2c
|
refs/heads/master
| 2016-09-07T02:19:54.389000 | 2014-07-16T05:30:12 | 2014-07-16T05:30:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* 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 niche.newres.timedevents2owl.generator.io;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.beanutils.BeanUtils;
import thewebsemantic.Bean2RDF;
/**
*
* @author newres
*/
public class JenaBeansWriter {
OntModel model;
Bean2RDF rdfWriter;
String defaultLocation;
public JenaBeansWriter()
{
model = ModelFactory.createOntologyModel();
rdfWriter = new Bean2RDF(model);
}
public void saveInModel(Object o)
{
rdfWriter.save(o);
}
public void write(OutputStream out)
{
model.write(out, "N-TRIPLE" );
System.out.println("JenaBeansWriter model size: " + model.size());
}
public void write(OutputStream out, Object o)
{
this.saveInModel(o);
this.write(out);
}
public void write(String fileLocation, Object o)
{
File file;
FileOutputStream fos;
try {
file = new File(fileLocation);
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
fos = new FileOutputStream(file);
this.write(fos, o);
fos.flush();
fos.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
|
UTF-8
|
Java
| 1,891 |
java
|
JenaBeansWriter.java
|
Java
|
[
{
"context": "import thewebsemantic.Bean2RDF;\n\n/**\n *\n * @author newres\n */\npublic class JenaBeansWriter {\n \n \n ",
"end": 659,
"score": 0.9984400868415833,
"start": 653,
"tag": "USERNAME",
"value": "newres"
}
] | null |
[] |
/*
* 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 niche.newres.timedevents2owl.generator.io;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.beanutils.BeanUtils;
import thewebsemantic.Bean2RDF;
/**
*
* @author newres
*/
public class JenaBeansWriter {
OntModel model;
Bean2RDF rdfWriter;
String defaultLocation;
public JenaBeansWriter()
{
model = ModelFactory.createOntologyModel();
rdfWriter = new Bean2RDF(model);
}
public void saveInModel(Object o)
{
rdfWriter.save(o);
}
public void write(OutputStream out)
{
model.write(out, "N-TRIPLE" );
System.out.println("JenaBeansWriter model size: " + model.size());
}
public void write(OutputStream out, Object o)
{
this.saveInModel(o);
this.write(out);
}
public void write(String fileLocation, Object o)
{
File file;
FileOutputStream fos;
try {
file = new File(fileLocation);
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
fos = new FileOutputStream(file);
this.write(fos, o);
fos.flush();
fos.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
| 1,891 | 0.59651 | 0.594395 | 85 | 21.247059 | 18.936367 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705882 | false | false |
10
|
017e4df9d2d0f8d8a779a259ea00bea68870e175
| 22,926,535,491,693 |
95e944448000c08dd3d6915abb468767c9f29d3c
|
/sources/com/google/android/gms/internal/ads/zzacq.java
|
f14516e7e664c906f11f9b17a19a361b88462a90
|
[] |
no_license
|
xrealm/tiktok-src
|
https://github.com/xrealm/tiktok-src
|
261b1faaf7b39d64bb7cb4106dc1a35963bd6868
|
90f305b5f981d39cfb313d75ab231326c9fca597
|
refs/heads/master
| 2022-11-12T06:43:07.401000 | 2020-07-04T20:21:12 | 2020-07-04T20:21:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.google.android.gms.internal.ads;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.google.android.gms.ads.C14873l;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.C15269a;
@C6505uv
public final class zzacq extends AbstractSafeParcelable {
public static final Creator<zzacq> CREATOR = new C15567bg();
/* renamed from: a */
public final boolean f45503a;
/* renamed from: b */
public final boolean f45504b;
/* renamed from: c */
public final boolean f45505c;
public zzacq(C14873l lVar) {
this(lVar.f38508a, lVar.f38509b, lVar.f38510c);
}
public zzacq(boolean z, boolean z2, boolean z3) {
this.f45503a = z;
this.f45504b = z2;
this.f45505c = z3;
}
public final void writeToParcel(Parcel parcel, int i) {
int a = C15269a.m44442a(parcel);
C15269a.m44459a(parcel, 2, this.f45503a);
C15269a.m44459a(parcel, 3, this.f45504b);
C15269a.m44459a(parcel, 4, this.f45505c);
C15269a.m44443a(parcel, a);
}
}
|
UTF-8
|
Java
| 1,149 |
java
|
zzacq.java
|
Java
|
[] | null |
[] |
package com.google.android.gms.internal.ads;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.google.android.gms.ads.C14873l;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.C15269a;
@C6505uv
public final class zzacq extends AbstractSafeParcelable {
public static final Creator<zzacq> CREATOR = new C15567bg();
/* renamed from: a */
public final boolean f45503a;
/* renamed from: b */
public final boolean f45504b;
/* renamed from: c */
public final boolean f45505c;
public zzacq(C14873l lVar) {
this(lVar.f38508a, lVar.f38509b, lVar.f38510c);
}
public zzacq(boolean z, boolean z2, boolean z3) {
this.f45503a = z;
this.f45504b = z2;
this.f45505c = z3;
}
public final void writeToParcel(Parcel parcel, int i) {
int a = C15269a.m44442a(parcel);
C15269a.m44459a(parcel, 2, this.f45503a);
C15269a.m44459a(parcel, 3, this.f45504b);
C15269a.m44459a(parcel, 4, this.f45505c);
C15269a.m44443a(parcel, a);
}
}
| 1,149 | 0.684073 | 0.561358 | 39 | 28.461538 | 22.473742 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.794872 | false | false |
10
|
8a9a3899f4f2dc0236674f85b87fe9c5ac372ed8
| 12,429,635,398,458 |
bd72d7b67f59bb2b8fb82697f04a71b8195e66c9
|
/src/Kur.java
|
9bd8775bb202d86931f4b99faeedace79f08aa37
|
[] |
no_license
|
bkansu/BankCustomerLoginScreen
|
https://github.com/bkansu/BankCustomerLoginScreen
|
d588cc437dd6bc4ab0dbf7f6bdaca34189897e0b
|
24d2131f1bc192a67d77983401e32dfb6388869c
|
refs/heads/master
| 2022-11-16T17:19:02.166000 | 2020-07-05T21:37:27 | 2020-07-05T21:37:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Kur {
public double getDolar() {
return Dolar;
}
public double getEuro() {
return Euro;
}
public double Dolar = 7.1094;
public double Euro = 7.9283;
}
|
UTF-8
|
Java
| 207 |
java
|
Kur.java
|
Java
|
[] | null |
[] |
public class Kur {
public double getDolar() {
return Dolar;
}
public double getEuro() {
return Euro;
}
public double Dolar = 7.1094;
public double Euro = 7.9283;
}
| 207 | 0.565217 | 0.516908 | 12 | 16.166666 | 12.694049 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
10
|
147937bbf46386fe2477c5e70b5b84f276ce29fa
| 32,684,701,136,320 |
caa3b8e009c9758b17a22a6b9d41eedccc0192b3
|
/app/src/main/java/com/example/dllo/food/library/search/SearchActivity.java
|
d6127bedef8e00905adadc6bfcc798f50bb72ef4
|
[] |
no_license
|
xiaoyulu1105/Food
|
https://github.com/xiaoyulu1105/Food
|
f4d36b7ccf7296f39a3f0625b980338ddd411b54
|
ba365384aca83843f5f74c604874027218de2cb8
|
refs/heads/master
| 2021-01-12T12:17:19.755000 | 2016-11-17T12:01:50 | 2016-11-17T12:01:50 | 72,412,997 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.dllo.food.library.search;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.dllo.food.R;
import com.example.dllo.food.base.BaseActivity;
import com.example.dllo.food.beans.event.TextEvent;
import com.example.dllo.food.library.LibraryFragment;
import com.example.dllo.food.dbtools.DBTool;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/**
* Created by XiaoyuLu on 16/11/1.
*
* 食物百科 查询的 Activity
*
* 使用EventBus 实现传值, 接收F1 中的ListView的点击的Item
* 和 F1中的RecyclerView 中的点击 的 Item
*
*/
public class SearchActivity extends BaseActivity implements View.OnClickListener{
private ImageView returnIV;
private EditText textEdt;
private ImageView deleteIV;
private ImageView searchIV;
private String textStr; // 输入框的字符串, 设置GetSet方法
private DBTool dbTool;
// 当其他页跳到该页时, 需要传一个值,
// 用于判断是简单搜索还是对比搜索, 这是传值时的KEY值
public static final String INTENT_SEARCH_TYPE = "searchType";
private String getSearchType; // 存放搜索的类型的字符串
private FragmentManager manager; // 用于实现替换 Fragment 的管理员
@Override
protected int getLayout() {
return R.layout.activity_library_search;
}
@Override
protected void initViews() {
returnIV = bindView(R.id.library_search_return);
textEdt = bindView(R.id.library_search_edt);
deleteIV = bindView(R.id.library_search_delete);
searchIV = bindView(R.id.library_search_search);
setClick(this, returnIV, deleteIV, searchIV);
dbTool = new DBTool();
manager = getSupportFragmentManager();
// 注册 EventBus 订阅者
EventBus.getDefault().register(this);
}
@Override
protected void initData() {
transactToSearchFragment();
textEdtListenerMethod(textEdt);
Intent intent = getIntent();
getSearchType = intent.getStringExtra(SearchActivity.INTENT_SEARCH_TYPE);
Log.d("SearchActivity", getSearchType);
}
@Override
protected void onDestroy() {
super.onDestroy();
// 取消注册
EventBus.getDefault().unregister(this);
}
// 第二步, 注册订阅者, 实现 订阅者的方法
// @Subscribe 必须写,手动添加 至少有一个方法需要要被 @Subscribe 修饰
@Subscribe(threadMode = ThreadMode.MAIN)
public TextEvent getTextEvent(TextEvent textEvent) {
String getText = textEvent.getText();
textEdt.setText(getText);
return textEvent;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.library_search_return:
finish();
break;
case R.id.library_search_delete:
textEdt.getText().clear();
transactToSearchFragment();
break;
case R.id.library_search_search:
textStr = textEdt.getText().toString();
if (textStr.length() <= 0) {
Toast.makeText(this, "输入不能为空", Toast.LENGTH_SHORT).show();
} else {
// 实现Fragment的跳转, 将搜索数据存入数据库
setTextStr(textStr);
clickSearchSaveAndTransact(textStr);
}
break;
default:
Log.d("SearchActivity", "出错啦!");
break;
}
}
/** textEdt 的文本变化时 的监听事件 */
private void textEdtListenerMethod(final EditText textEdt) {
textEdt.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
judgeIfTextNull(textEdt);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void afterTextChanged(Editable s) {
judgeIfTextNull(textEdt);
}
});
}
/** 判断输入框是否为空 */
private void judgeIfTextNull(EditText textEdt) {
if (textEdt.getText().length() <= 0) {
deleteIV.setVisibility(View.INVISIBLE);
transactToSearchFragment();
} else {
deleteIV.setVisibility(View.VISIBLE);
transactToSearchFragment();
}
}
/** 点击搜索 保存和跳转 事件 */
private void clickSearchSaveAndTransact(String textStr) {
dbTool.insertHistory(textStr);
FragmentTransaction transaction = manager.beginTransaction();
if (getSearchType.equals(LibraryFragment.INTENT_SEARCH_SIMPLE_TYPE)) {
// 如果是简单的搜索
transaction.replace(R.id.library_search_frame, new SearchSimpleFragment());
transaction.commit();
} else {
// 对比搜索
transaction.replace(R.id.library_search_frame, new SearchCompareFragment());
transaction.commit();
}
}
/** fragment 转换为 搜索的 Fragment */
private void transactToSearchFragment() {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.library_search_frame, new SearchSearchFragment());
transaction.commit();
}
/** textStr 存放 输入框的字符串, 为其设置Get Set方法 */
// 作用, 在 显示的 Fragment 中可以通过get方法获取到 搜索的字符,
// 再将其变换为UTF-8格式, 实现网络请求
public String getTextStr() {
return textStr;
}
public void setTextStr(String textStr) {
this.textStr = textStr;
}
}
|
UTF-8
|
Java
| 6,310 |
java
|
SearchActivity.java
|
Java
|
[
{
"context": "greenrobot.eventbus.ThreadMode;\n\n/**\n * Created by XiaoyuLu on 16/11/1.\n *\n * 食物百科 查询的 Activity\n *\n * 使用Eve",
"end": 768,
"score": 0.7538716793060303,
"start": 762,
"tag": "NAME",
"value": "Xiaoyu"
},
{
"context": "bot.eventbus.ThreadMode;\n\n/**\n * Created by XiaoyuLu on 16/11/1.\n *\n * 食物百科 查询的 Activity\n *\n * 使用Event",
"end": 770,
"score": 0.5214163064956665,
"start": 768,
"tag": "USERNAME",
"value": "Lu"
}
] | null |
[] |
package com.example.dllo.food.library.search;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.dllo.food.R;
import com.example.dllo.food.base.BaseActivity;
import com.example.dllo.food.beans.event.TextEvent;
import com.example.dllo.food.library.LibraryFragment;
import com.example.dllo.food.dbtools.DBTool;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/**
* Created by XiaoyuLu on 16/11/1.
*
* 食物百科 查询的 Activity
*
* 使用EventBus 实现传值, 接收F1 中的ListView的点击的Item
* 和 F1中的RecyclerView 中的点击 的 Item
*
*/
public class SearchActivity extends BaseActivity implements View.OnClickListener{
private ImageView returnIV;
private EditText textEdt;
private ImageView deleteIV;
private ImageView searchIV;
private String textStr; // 输入框的字符串, 设置GetSet方法
private DBTool dbTool;
// 当其他页跳到该页时, 需要传一个值,
// 用于判断是简单搜索还是对比搜索, 这是传值时的KEY值
public static final String INTENT_SEARCH_TYPE = "searchType";
private String getSearchType; // 存放搜索的类型的字符串
private FragmentManager manager; // 用于实现替换 Fragment 的管理员
@Override
protected int getLayout() {
return R.layout.activity_library_search;
}
@Override
protected void initViews() {
returnIV = bindView(R.id.library_search_return);
textEdt = bindView(R.id.library_search_edt);
deleteIV = bindView(R.id.library_search_delete);
searchIV = bindView(R.id.library_search_search);
setClick(this, returnIV, deleteIV, searchIV);
dbTool = new DBTool();
manager = getSupportFragmentManager();
// 注册 EventBus 订阅者
EventBus.getDefault().register(this);
}
@Override
protected void initData() {
transactToSearchFragment();
textEdtListenerMethod(textEdt);
Intent intent = getIntent();
getSearchType = intent.getStringExtra(SearchActivity.INTENT_SEARCH_TYPE);
Log.d("SearchActivity", getSearchType);
}
@Override
protected void onDestroy() {
super.onDestroy();
// 取消注册
EventBus.getDefault().unregister(this);
}
// 第二步, 注册订阅者, 实现 订阅者的方法
// @Subscribe 必须写,手动添加 至少有一个方法需要要被 @Subscribe 修饰
@Subscribe(threadMode = ThreadMode.MAIN)
public TextEvent getTextEvent(TextEvent textEvent) {
String getText = textEvent.getText();
textEdt.setText(getText);
return textEvent;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.library_search_return:
finish();
break;
case R.id.library_search_delete:
textEdt.getText().clear();
transactToSearchFragment();
break;
case R.id.library_search_search:
textStr = textEdt.getText().toString();
if (textStr.length() <= 0) {
Toast.makeText(this, "输入不能为空", Toast.LENGTH_SHORT).show();
} else {
// 实现Fragment的跳转, 将搜索数据存入数据库
setTextStr(textStr);
clickSearchSaveAndTransact(textStr);
}
break;
default:
Log.d("SearchActivity", "出错啦!");
break;
}
}
/** textEdt 的文本变化时 的监听事件 */
private void textEdtListenerMethod(final EditText textEdt) {
textEdt.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
judgeIfTextNull(textEdt);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void afterTextChanged(Editable s) {
judgeIfTextNull(textEdt);
}
});
}
/** 判断输入框是否为空 */
private void judgeIfTextNull(EditText textEdt) {
if (textEdt.getText().length() <= 0) {
deleteIV.setVisibility(View.INVISIBLE);
transactToSearchFragment();
} else {
deleteIV.setVisibility(View.VISIBLE);
transactToSearchFragment();
}
}
/** 点击搜索 保存和跳转 事件 */
private void clickSearchSaveAndTransact(String textStr) {
dbTool.insertHistory(textStr);
FragmentTransaction transaction = manager.beginTransaction();
if (getSearchType.equals(LibraryFragment.INTENT_SEARCH_SIMPLE_TYPE)) {
// 如果是简单的搜索
transaction.replace(R.id.library_search_frame, new SearchSimpleFragment());
transaction.commit();
} else {
// 对比搜索
transaction.replace(R.id.library_search_frame, new SearchCompareFragment());
transaction.commit();
}
}
/** fragment 转换为 搜索的 Fragment */
private void transactToSearchFragment() {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.library_search_frame, new SearchSearchFragment());
transaction.commit();
}
/** textStr 存放 输入框的字符串, 为其设置Get Set方法 */
// 作用, 在 显示的 Fragment 中可以通过get方法获取到 搜索的字符,
// 再将其变换为UTF-8格式, 实现网络请求
public String getTextStr() {
return textStr;
}
public void setTextStr(String textStr) {
this.textStr = textStr;
}
}
| 6,310 | 0.630668 | 0.628591 | 200 | 27.889999 | 23.053154 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.535 | false | false |
10
|
c8c733eb892034cbfcefc96a7b335fac6ad28835
| 21,148,419,006,091 |
20a06a95a1c9ddad001520fb5e1e91ce437f1418
|
/src/com/craftinginterpreters/lox/Lox.java
|
2decd142c83742bc03495249e688c08a8982297a
|
[] |
no_license
|
thanhanofhcmus/CratfingIterpreterJava
|
https://github.com/thanhanofhcmus/CratfingIterpreterJava
|
4a590525ab4db3e34fb8d5b779e00c090afbc67f
|
a4a45d158730b99df41af77aa36c2239163e048a
|
refs/heads/master
| 2023-08-11T01:50:57.221000 | 2021-10-02T10:02:42 | 2021-10-02T10:02:42 | 371,037,264 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.craftinginterpreters.lox;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class Lox {
private static final Interpreter interpreter = new Interpreter();
private static boolean runPrompt = false;
public static void main(String[] args) throws IOException {
if (args.length > 1) {
System.out.println("Usage: jlox [script]");
System.exit(64);
} else if (args.length == 1) {
runFile(args[0]);
} else {
runPrompt();
}
}
public static void runFile(String path) throws IOException {
runPrompt = false;
byte[] bytes = Files.readAllBytes(Paths.get(path));
run(new String(bytes, Charset.defaultCharset()));
if (ErrorReporter.hadError()) { System.exit(65); }
if (ErrorReporter.hadRuntimeError()) { System.exit(70); }
}
public static void runPrompt() throws IOException {
runPrompt = true;
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
for (;;) {
ErrorReporter.printPrompt();
String line = reader.readLine();
if (null == line) { break; }
if (line.isEmpty()) { continue; }
run(line);
}
}
public static void run(String source) {
Scanner scanner = new Scanner(source);
List<Token> tokens = scanner.scanTokens();
List<Stmt> statements = new Parser(tokens).parse();
if (ErrorReporter.hadError()) { return; }
interpreter.interpret(statements);
}
public static boolean isRunPrompt() { return runPrompt; }
}
|
UTF-8
|
Java
| 1,849 |
java
|
Lox.java
|
Java
|
[] | null |
[] |
package com.craftinginterpreters.lox;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class Lox {
private static final Interpreter interpreter = new Interpreter();
private static boolean runPrompt = false;
public static void main(String[] args) throws IOException {
if (args.length > 1) {
System.out.println("Usage: jlox [script]");
System.exit(64);
} else if (args.length == 1) {
runFile(args[0]);
} else {
runPrompt();
}
}
public static void runFile(String path) throws IOException {
runPrompt = false;
byte[] bytes = Files.readAllBytes(Paths.get(path));
run(new String(bytes, Charset.defaultCharset()));
if (ErrorReporter.hadError()) { System.exit(65); }
if (ErrorReporter.hadRuntimeError()) { System.exit(70); }
}
public static void runPrompt() throws IOException {
runPrompt = true;
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
for (;;) {
ErrorReporter.printPrompt();
String line = reader.readLine();
if (null == line) { break; }
if (line.isEmpty()) { continue; }
run(line);
}
}
public static void run(String source) {
Scanner scanner = new Scanner(source);
List<Token> tokens = scanner.scanTokens();
List<Stmt> statements = new Parser(tokens).parse();
if (ErrorReporter.hadError()) { return; }
interpreter.interpret(statements);
}
public static boolean isRunPrompt() { return runPrompt; }
}
| 1,849 | 0.616549 | 0.611682 | 60 | 29.816668 | 22.410929 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false |
10
|
871827f8cb257c70b434a1b6d31c4ad2eafbb449
| 33,157,147,550,574 |
bb28d81f96b5769a7f944d1b03c8cf837571d217
|
/cp/java/lang/SecurityException.java
|
17459e8c32c534e61b0df363639142db838b4f22
|
[
"MIT"
] |
permissive
|
juur/fail-jvm
|
https://github.com/juur/fail-jvm
|
5616b4aa8c9f424214d43d5058305ca2838934ea
|
6dd2a075f3101a7b1a6b1534acf30dda695f55f4
|
refs/heads/master
| 2022-09-27T15:06:18.138000 | 2022-09-25T19:53:40 | 2022-09-25T19:53:40 | 185,074,533 | 8 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package java.lang;
public class SecurityException extends RuntimeException {
}
|
UTF-8
|
Java
| 88 |
java
|
SecurityException.java
|
Java
|
[] | null |
[] |
package java.lang;
public class SecurityException extends RuntimeException {
}
| 88 | 0.75 | 0.75 | 6 | 12.666667 | 20.86198 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false |
10
|
5cbc135cfa65f7f6e7ea27006b054859f1ac2e79
| 7,249,904,866,880 |
f80fcb5ba1de922083a5a17311b53fc4f9e5a7dd
|
/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
|
9d83d366e6e80b3169fb83bcc5e0dafd75634881
|
[] |
no_license
|
SummaNetworks/jbosscache-core
|
https://github.com/SummaNetworks/jbosscache-core
|
c93d588aebab91f94cf36470c2939799e7b3717c
|
7d880bbe35274d1a00bd6b06a00d9416005f871e
|
refs/heads/master
| 2020-04-05T12:08:14.889000 | 2019-09-25T15:44:22 | 2019-09-25T15:44:22 | 156,860,363 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.jmx.deprecated;
import org.jboss.cache.Version;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.eviction.FIFOAlgorithm;
import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithm;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.eviction.MRUAlgorithm;
import org.jboss.cache.eviction.MRUAlgorithmConfig;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
import org.jboss.cache.loader.jdbm.JdbmCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.multiplexer.MultiplexerTestHelper;
import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
import org.jgroups.ChannelFactory;
import org.jgroups.JChannelFactory;
import org.jgroups.jmx.JChannelFactoryMBean;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import java.util.Properties;
/**
* Test of the CacheLegacyJmxWrapper.
*
* @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision: 7696 $
*/
@Test(groups = "functional", testName = "jmx.deprecated.LegacyConfigurationTest")
public class LegacyConfigurationTest extends CacheJmxWrapperTestBase
{
public void testLocalCache() throws Exception
{
doTest(false);
}
public void testLocalCacheWithLegacyXML() throws Exception
{
doTest(true);
}
@SuppressWarnings({"deprecation", "unchecked"})
private void doTest(boolean legacy) throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig(legacy));
wrapper.setCacheLoaderConfig(getCacheLoaderConfig(legacy));
wrapper.setCacheMode("REPL_SYNC");
wrapper.setClusterName("LocalTest");
wrapper.setClusterConfig(getClusterConfig());
wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig(legacy));
wrapper.setFetchInMemoryState(false);
wrapper.setInitialStateRetrievalTimeout(100);
wrapper.setInactiveOnStartup(true);
wrapper.setNodeLockingScheme("OPTIMISTIC");
wrapper.setIsolationLevel("READ_UNCOMMITTED");
wrapper.setLockAcquisitionTimeout(200);
wrapper.setReplicationVersion("1.0.1");
wrapper.setReplQueueInterval(15);
wrapper.setReplQueueMaxElements(50);
wrapper.setSyncReplTimeout(300);
wrapper.setSyncCommitPhase(true);
wrapper.setSyncRollbackPhase(true);
wrapper.setTransactionManagerLookupClass(BatchModeTransactionManagerLookup.class.getName());
wrapper.setExposeManagementStatistics(false);
wrapper.setUseRegionBasedMarshalling(true);
wrapper.setUseReplQueue(true);
Configuration c = wrapper.getConfiguration();
assertEquals("CacheMode", "REPL_SYNC", wrapper.getCacheMode());
assertEquals("CacheMode", CacheMode.REPL_SYNC, c.getCacheMode());
assertEquals("ClusterName", "LocalTest", wrapper.getClusterName());
assertEquals("ClusterName", "LocalTest", c.getClusterName());
assertEquals("FetchInMemoryState", false, wrapper.getFetchInMemoryState());
assertEquals("FetchInMemoryState", false, c.isFetchInMemoryState());
assertEquals("InitialStateRetrievalTimeout", 100, wrapper.getInitialStateRetrievalTimeout());
assertEquals("InitialStateRetrievalTimeout", 100, c.getStateRetrievalTimeout());
assertEquals("InactiveOnStartup", true, wrapper.isInactiveOnStartup());
assertEquals("InactiveOnStartup", true, c.isInactiveOnStartup());
assertEquals("NodeLockingScheme", "OPTIMISTIC", wrapper.getNodeLockingScheme());
assertEquals("NodeLockingScheme", NodeLockingScheme.OPTIMISTIC, c.getNodeLockingScheme());
assertEquals("IsolationLevel", "READ_UNCOMMITTED", wrapper.getIsolationLevel());
assertEquals("IsolationLevel", IsolationLevel.READ_UNCOMMITTED, c.getIsolationLevel());
assertEquals("LockAcquisitionTimeout", 200, wrapper.getLockAcquisitionTimeout());
assertEquals("LockAcquisitionTimeout", 200, c.getLockAcquisitionTimeout());
assertEquals("ReplicationVersion", "1.0.1", wrapper.getReplicationVersion());
assertEquals("ReplicationVersion", Version.getVersionShort("1.0.1"), c.getReplicationVersion());
assertEquals("ReplQueueInterval", 15, wrapper.getReplQueueInterval());
assertEquals("ReplQueueInterval", 15, c.getReplQueueInterval());
assertEquals("ReplQueueMaxElements", 50, wrapper.getReplQueueMaxElements());
assertEquals("ReplQueueMaxElements", 50, c.getReplQueueMaxElements());
assertEquals("SyncReplTimeout", 300, wrapper.getSyncReplTimeout());
assertEquals("SyncReplTimeout", 300, c.getSyncReplTimeout());
assertEquals("SyncCommitPhase", true, wrapper.getSyncCommitPhase());
assertEquals("SyncCommitPhase", true, c.isSyncCommitPhase());
assertEquals("SyncRollbackPhase", true, wrapper.getSyncRollbackPhase());
assertEquals("SyncRollbackPhase", true, c.isSyncRollbackPhase());
assertEquals("TransactionManagerLookupClass", BatchModeTransactionManagerLookup.class.getName(), wrapper.getTransactionManagerLookupClass());
assertEquals("TransactionManagerLookupClass", BatchModeTransactionManagerLookup.class.getName(), c.getTransactionManagerLookupClass());
assertEquals("ExposeManagementStatistics", false, wrapper.getExposeManagementStatistics());
assertEquals("ExposeManagementStatistics", false, c.getExposeManagementStatistics());
assertEquals("UseRegionBasedMarshalling", true, wrapper.getUseRegionBasedMarshalling());
assertEquals("UseRegionBasedMarshalling", true, c.isUseRegionBasedMarshalling());
assertEquals("UseReplQueue", true, wrapper.getUseReplQueue());
assertEquals("UseReplQueue", true, c.isUseReplQueue());
assertEquals("ClusterConfig", getClusterConfig().toString(), wrapper.getClusterConfig().toString());
assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig(legacy).toString(), wrapper.getBuddyReplicationConfig().toString());
BuddyReplicationConfig brc = c.getBuddyReplicationConfig();
assertEquals("BR enabled", true, brc.isEnabled());
assertEquals("BR auto grav", false, brc.isAutoDataGravitation());
assertEquals("BR remove find", false, brc.isDataGravitationRemoveOnFind());
assertEquals("BR search backup", false, brc.isDataGravitationSearchBackupTrees());
assertEquals("BR comm timeout", 600000, brc.getBuddyCommunicationTimeout());
assertEquals("BR poolname", "testpool", brc.getBuddyPoolName());
BuddyLocatorConfig blc = brc.getBuddyLocatorConfig();
assertEquals("BR locator", "org.jboss.cache.buddyreplication.TestBuddyLocator", blc.getBuddyLocatorClass());
Properties props = blc.getBuddyLocatorProperties();
assertEquals("BR props", "2", props.get("numBuddies"));
assertEquals("CacheLoaderConfig", getCacheLoaderConfig(legacy).toString(), wrapper.getCacheLoaderConfig().toString());
CacheLoaderConfig clc = c.getCacheLoaderConfig();
assertEquals("CL passivation", false, clc.isPassivation());
assertEquals("CL passivation", true, clc.isShared());
assertEquals("CL preload", "/foo", clc.getPreload());
List<IndividualCacheLoaderConfig> iclcs = clc.getIndividualCacheLoaderConfigs();
IndividualCacheLoaderConfig iclc = iclcs.get(0);
assertEquals("CL0 class", FileCacheLoader.class.getName(), iclc.getClassName());
assertEquals("CL0 async", false, iclc.isAsync());
assertEquals("CL0 fetch", true, iclc.isFetchPersistentState());
assertEquals("CL0 ignore", true, iclc.isIgnoreModifications());
assertEquals("CL0 purge", true, iclc.isPurgeOnStartup());
assertEquals("CL0 singleton", true, iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("CL0 singleton class", SingletonStoreCacheLoader.class.getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass());
iclc = iclcs.get(1);
assertEquals("CL1 class", JdbmCacheLoader.class.getName(), iclc.getClassName());
assertEquals("CL1 async", true, iclc.isAsync());
assertEquals("CL1 fetch", false, iclc.isFetchPersistentState());
assertEquals("CL1 ignore", false, iclc.isIgnoreModifications());
assertEquals("CL1 purge", false, iclc.isPurgeOnStartup());
assertEquals("CL1 singleton", false, iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("CL1 singleton class", SingletonStoreCacheLoader.class.getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass());
assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig(legacy).toString(), wrapper.getEvictionPolicyConfig().toString());
EvictionConfig ec = c.getEvictionConfig();
assertEquals("EC queue size", 1000, ec.getDefaultEvictionRegionConfig().getEventQueueSize());
assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
assertEquals("EC default pol", LRUAlgorithm.class.getName(), ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig().getEvictionAlgorithmClassName());
List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
EvictionRegionConfig erc = ercs.get(0);
assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName());
assertEquals("ERC1 queue size", 1000, erc.getEventQueueSize());
FIFOAlgorithmConfig fifo = (FIFOAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC1 pol", FIFOAlgorithm.class.getName(), fifo.getEvictionAlgorithmClassName());
assertEquals("EPC1 maxnodes", 5000, fifo.getMaxNodes());
erc = ercs.get(1);
assertEquals("ERC2 name", "/test", erc.getRegionName());
assertEquals("ERC2 queue size", 1000, erc.getEventQueueSize());
MRUAlgorithmConfig mru = (MRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC2 pol", MRUAlgorithm.class.getName(), mru.getEvictionAlgorithmClassName());
assertEquals("EPC2 maxnodes", 10000, mru.getMaxNodes());
erc = ercs.get(2);
assertEquals("ERC3 name", "/maxAgeTest", erc.getRegionName());
assertEquals("ERC3 queue size", 1000, erc.getEventQueueSize());
LRUAlgorithmConfig lru = (LRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
assertEquals("EPC3 maxage", 10000, lru.getMaxAge());
assertEquals("EPC3 ttl", 8000, lru.getTimeToLive());
}
@SuppressWarnings("unchecked")
public void testRuntimeConfig() throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
// Fake a TM by making a bogus proxy
TransactionManager tm = (TransactionManager) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{TransactionManager.class}, new MockInvocationHandler());
wrapper.setTransactionManager(tm);
ChannelFactory cf = new JChannelFactory();
wrapper.setMuxChannelFactory(cf);
RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
assertSame("Same TM", tm, wrapper.getTransactionManager());
assertSame("Same TM", tm, rc.getTransactionManager());
assertSame("Same ChannelFactory", cf, wrapper.getMuxChannelFactory());
assertSame("Same ChannelFactory", cf, rc.getMuxChannelFactory());
}
@SuppressWarnings("unchecked")
public void testLegacyMuxChannelCreation() throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK + Thread.currentThread().getName());
JChannelFactory factory = new JChannelFactory();
factory.setDomain("jbc.mux.test");
factory.setExposeChannels(false);
factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigElement(getDefaultProperties()));
ObjectName on = new ObjectName("jgroups:service=Mux");
mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factory), on);
wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class, false));
wrapper.start();
RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
assertNotNull("Channel created", rc.getChannel());
//wrapper.stop();
//wrapper.destroy();
}
protected static Element getBuddyReplicationConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = "<config>\n" +
" <buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
" <buddyLocatorClass>org.jboss.cache.buddyreplication.TestBuddyLocator</buddyLocatorClass>\n" +
" <buddyLocatorProperties>\n" +
" numBuddies = 2\n" +
" </buddyLocatorProperties>\n" +
" <buddyPoolName>testpool</buddyPoolName>\n" +
" <buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
" <dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
" <dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>\n" +
" <autoDataGravitation>false</autoDataGravitation>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <buddy enabled=\"true\" poolName=\"testpool\" communicationTimeout=\"600000\">\n" +
" <dataGravitation auto=\"false\" removeOnFind=\"false\" searchBackupTrees=\"false\"/>\n" +
" <locator class=\"org.jboss.cache.buddyreplication.TestBuddyLocator\">\n" +
" <properties>\n" +
" numBuddies = 2\n" +
" </properties>\n" +
" </locator>\n" +
" </buddy>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getCacheLoaderConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = "<config>\n" +
" <passivation>false</passivation>\n" +
" <preload>/foo</preload>\n" +
" <shared>true</shared>\n" +
" <cacheloader>\n" +
" <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
" <properties>\n" +
" location=/tmp\n " +
" </properties>\n" +
" <async>false</async>\n" +
" <fetchPersistentState>true</fetchPersistentState>\n" +
" <ignoreModifications>true</ignoreModifications>\n" +
" <purgeOnStartup>true</purgeOnStartup>\n" +
" <singletonStore>\n" +
" <enabled>true</enabled>\n" +
" </singletonStore>\n" +
" </cacheloader> \n " +
" <cacheloader>\n" +
" <class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>\n" +
" <properties>\n" +
" location=/home/bstansberry\n " +
" </properties>\n" +
" <async>true</async>\n" +
" <fetchPersistentState>false</fetchPersistentState>\n" +
" <ignoreModifications>false</ignoreModifications>\n" +
" <purgeOnStartup>false</purgeOnStartup>\n" +
" <singletonStore>\n" +
" <enabled>false</enabled>\n" +
" </singletonStore>\n" +
" </cacheloader>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <loaders passivation=\"false\" shared=\"true\">\n" +
" <preload>\n" +
" <node fqn=\"/foo\"/>\n" +
" </preload>\n" +
" <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
" ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
" <properties>\n" +
" location=/tmp\n " +
" </properties>\n" +
" <singletonStore enabled=\"true\" /> \n" +
" </loader>\n" +
" <loader class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\" fetchPersistentState=\"false\"\n" +
" ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
" <properties>\n" +
" location=/home/bstansberry\n" +
" </properties>\n" +
" <singletonStore enabled=\"false\" /> \n" +
" </loader>\n" +
" </loaders>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getEvictionPolicyConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = " <config>\n" +
" <attribute name=\"wakeUpIntervalSeconds\">5</attribute>\n" +
" <attribute name=\"eventQueueSize\">1000</attribute>\n" +
" <attribute name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n" +
" <region name=\"/_default_\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
" </region>\n" +
" <region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" </region>\n" +
" <region name=\"/test\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
" <attribute name=\"maxNodes\">10000</attribute>\n" +
" </region>\n" +
" <region name=\"/maxAgeTest\">\n" +
" <attribute name=\"maxNodes\">10000</attribute>\n" +
" <attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
" <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
" </region>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <eviction wakeUpInterval=\"5000\">\n" +
" <default eventQueueSize=\"1000\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"5000\"></property>\n" +
" <property name=\"timeToLive\" value=\"1000000\"></property>\n" +
" </default>\n" +
"<region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"5000\"></property>\n" +
"</region>\n" +
"<region name=\"/test/\" algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"10000\"></property>\n" +
"</region>\n" +
"<region name=\"/maxAgeTest/\">\n" +
" <property name=\"maxNodes\" value=\"10000\"></property>\n" +
" <property name=\"timeToLive\" value=\"8000\"></property>\n" +
" <property name=\"maxAge\" value=\"10000\"></property>\n" +
"</region>\n" +
" </eviction>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getClusterConfig() throws Exception
{
String xml =
"<jgroupsConfig>\n" +
"<UDP mcast_addr=\"228.10.10.10\"\n" +
" mcast_port=\"45588\"\n" +
" tos=\"8\"\n" +
" ucast_recv_buf_size=\"20000000\"\n" +
" ucast_send_buf_size=\"640000\"\n" +
" mcast_recv_buf_size=\"25000000\"\n" +
" mcast_send_buf_size=\"640000\"\n" +
" loopback=\"false\"\n" +
" discard_incompatible_packets=\"true\"\n" +
" max_bundle_size=\"64000\"\n" +
" max_bundle_timeout=\"30\"\n" +
" use_incoming_packet_handler=\"true\"\n" +
" ip_ttl=\"2\"\n" +
" enable_bundling=\"false\"\n" +
" enable_diagnostics=\"true\"\n" +
" use_concurrent_stack=\"true\"\n" +
" thread_naming_pattern=\"pl\"\n" +
" thread_pool.enabled=\"true\"\n" +
" thread_pool.min_threads=\"1\"\n" +
" thread_pool.max_threads=\"25\"\n" +
" thread_pool.keep_alive_time=\"30000\"\n" +
" thread_pool.queue_enabled=\"true\"\n" +
" thread_pool.queue_max_size=\"10\"\n" +
" thread_pool.rejection_policy=\"Run\"\n" +
" oob_thread_pool.enabled=\"true\"\n" +
" oob_thread_pool.min_threads=\"1\"\n" +
" oob_thread_pool.max_threads=\"4\"\n" +
" oob_thread_pool.keep_alive_time=\"10000\"\n" +
" oob_thread_pool.queue_enabled=\"true\"\n" +
" oob_thread_pool.queue_max_size=\"10\"\n" +
" oob_thread_pool.rejection_policy=\"Run\"/>\n" +
" <PING timeout=\"2000\" num_initial_members=\"3\"/>\n" +
" <MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>\n" +
" <FD_SOCK/>\n" +
" <FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>\n" +
" <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
" <pbcast.NAKACK max_xmit_size=\"60000\"\n" +
" use_mcast_xmit=\"false\" gc_lag=\"0\"\n" +
" retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
" discard_delivered_msgs=\"true\"/>\n" +
" <UNICAST timeout=\"300,600,1200,2400,3600\"/>\n" +
" <pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"\n" +
" max_bytes=\"400000\"/>\n" +
" <pbcast.GMS print_local_addr=\"true\" join_timeout=\"5000\"\n" +
" join_retry_timeout=\"2000\" shun=\"false\"\n" +
" view_bundling=\"true\" view_ack_collection_timeout=\"5000\"/>\n" +
" <FRAG2 frag_size=\"60000\"/>\n" +
" <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
" <pbcast.FLUSH timeout=\"0\"/>\n" +
"</jgroupsConfig>";
return XmlConfigHelper.stringToElementInCoreNS(xml);
}
protected String getDefaultProperties()
{
return "UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;" +
"mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
"PING(timeout=1000;num_initial_members=2):" +
"MERGE2(min_interval=5000;max_interval=10000):" +
"FD_SOCK:" +
"VERIFY_SUSPECT(timeout=1500):" +
"pbcast.NAKACK(gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800):" +
"UNICAST(timeout=600,1200,2400,4800):" +
"pbcast.STABLE(desired_avg_gossip=20000):" +
"FRAG(frag_size=8192;down_thread=false;up_thread=false):" +
"pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
"shun=false;print_local_addr=true):" +
"pbcast.STATE_TRANSFER";
}
class MockInvocationHandler implements InvocationHandler
{
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
return null;
}
}
}
|
UTF-8
|
Java
| 27,730 |
java
|
LegacyConfigurationTest.java
|
Java
|
[
{
"context": "the CacheLegacyJmxWrapper.\n *\n * @author <a href=\"brian.stansberry@jboss.com\">Brian Stansberry</a>\n * @version $Revision: 7696",
"end": 3046,
"score": 0.9999260902404785,
"start": 3020,
"tag": "EMAIL",
"value": "brian.stansberry@jboss.com"
},
{
"context": "*\n * @author <a href=\"brian.stansberry@jboss.com\">Brian Stansberry</a>\n * @version $Revision: 7696 $\n */\n@Test(group",
"end": 3064,
"score": 0.9998873472213745,
"start": 3048,
"tag": "NAME",
"value": "Brian Stansberry"
},
{
"context": "imeout());\n assertEquals(\"BR poolname\", \"testpool\", brc.getBuddyPoolName());\n BuddyLocatorConf",
"end": 8771,
"score": 0.583191454410553,
"start": 8767,
"tag": "USERNAME",
"value": "pool"
},
{
"context": "Config>\\n\" +\n \"<UDP mcast_addr=\\\"228.10.10.10\\\"\\n\" +\n \" mcast_p",
"end": 23291,
"score": 0.9996939897537231,
"start": 23286,
"tag": "IP_ADDRESS",
"value": "228.1"
},
{
"context": "ultProperties()\n {\n return \"UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;\" +\n \"mcast",
"end": 26791,
"score": 0.9997550845146179,
"start": 26781,
"tag": "IP_ADDRESS",
"value": "224.0.0.36"
}
] | null |
[] |
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.jmx.deprecated;
import org.jboss.cache.Version;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.eviction.FIFOAlgorithm;
import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithm;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.eviction.MRUAlgorithm;
import org.jboss.cache.eviction.MRUAlgorithmConfig;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
import org.jboss.cache.loader.jdbm.JdbmCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.multiplexer.MultiplexerTestHelper;
import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
import org.jgroups.ChannelFactory;
import org.jgroups.JChannelFactory;
import org.jgroups.jmx.JChannelFactoryMBean;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import java.util.Properties;
/**
* Test of the CacheLegacyJmxWrapper.
*
* @author <a href="<EMAIL>"><NAME></a>
* @version $Revision: 7696 $
*/
@Test(groups = "functional", testName = "jmx.deprecated.LegacyConfigurationTest")
public class LegacyConfigurationTest extends CacheJmxWrapperTestBase
{
public void testLocalCache() throws Exception
{
doTest(false);
}
public void testLocalCacheWithLegacyXML() throws Exception
{
doTest(true);
}
@SuppressWarnings({"deprecation", "unchecked"})
private void doTest(boolean legacy) throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig(legacy));
wrapper.setCacheLoaderConfig(getCacheLoaderConfig(legacy));
wrapper.setCacheMode("REPL_SYNC");
wrapper.setClusterName("LocalTest");
wrapper.setClusterConfig(getClusterConfig());
wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig(legacy));
wrapper.setFetchInMemoryState(false);
wrapper.setInitialStateRetrievalTimeout(100);
wrapper.setInactiveOnStartup(true);
wrapper.setNodeLockingScheme("OPTIMISTIC");
wrapper.setIsolationLevel("READ_UNCOMMITTED");
wrapper.setLockAcquisitionTimeout(200);
wrapper.setReplicationVersion("1.0.1");
wrapper.setReplQueueInterval(15);
wrapper.setReplQueueMaxElements(50);
wrapper.setSyncReplTimeout(300);
wrapper.setSyncCommitPhase(true);
wrapper.setSyncRollbackPhase(true);
wrapper.setTransactionManagerLookupClass(BatchModeTransactionManagerLookup.class.getName());
wrapper.setExposeManagementStatistics(false);
wrapper.setUseRegionBasedMarshalling(true);
wrapper.setUseReplQueue(true);
Configuration c = wrapper.getConfiguration();
assertEquals("CacheMode", "REPL_SYNC", wrapper.getCacheMode());
assertEquals("CacheMode", CacheMode.REPL_SYNC, c.getCacheMode());
assertEquals("ClusterName", "LocalTest", wrapper.getClusterName());
assertEquals("ClusterName", "LocalTest", c.getClusterName());
assertEquals("FetchInMemoryState", false, wrapper.getFetchInMemoryState());
assertEquals("FetchInMemoryState", false, c.isFetchInMemoryState());
assertEquals("InitialStateRetrievalTimeout", 100, wrapper.getInitialStateRetrievalTimeout());
assertEquals("InitialStateRetrievalTimeout", 100, c.getStateRetrievalTimeout());
assertEquals("InactiveOnStartup", true, wrapper.isInactiveOnStartup());
assertEquals("InactiveOnStartup", true, c.isInactiveOnStartup());
assertEquals("NodeLockingScheme", "OPTIMISTIC", wrapper.getNodeLockingScheme());
assertEquals("NodeLockingScheme", NodeLockingScheme.OPTIMISTIC, c.getNodeLockingScheme());
assertEquals("IsolationLevel", "READ_UNCOMMITTED", wrapper.getIsolationLevel());
assertEquals("IsolationLevel", IsolationLevel.READ_UNCOMMITTED, c.getIsolationLevel());
assertEquals("LockAcquisitionTimeout", 200, wrapper.getLockAcquisitionTimeout());
assertEquals("LockAcquisitionTimeout", 200, c.getLockAcquisitionTimeout());
assertEquals("ReplicationVersion", "1.0.1", wrapper.getReplicationVersion());
assertEquals("ReplicationVersion", Version.getVersionShort("1.0.1"), c.getReplicationVersion());
assertEquals("ReplQueueInterval", 15, wrapper.getReplQueueInterval());
assertEquals("ReplQueueInterval", 15, c.getReplQueueInterval());
assertEquals("ReplQueueMaxElements", 50, wrapper.getReplQueueMaxElements());
assertEquals("ReplQueueMaxElements", 50, c.getReplQueueMaxElements());
assertEquals("SyncReplTimeout", 300, wrapper.getSyncReplTimeout());
assertEquals("SyncReplTimeout", 300, c.getSyncReplTimeout());
assertEquals("SyncCommitPhase", true, wrapper.getSyncCommitPhase());
assertEquals("SyncCommitPhase", true, c.isSyncCommitPhase());
assertEquals("SyncRollbackPhase", true, wrapper.getSyncRollbackPhase());
assertEquals("SyncRollbackPhase", true, c.isSyncRollbackPhase());
assertEquals("TransactionManagerLookupClass", BatchModeTransactionManagerLookup.class.getName(), wrapper.getTransactionManagerLookupClass());
assertEquals("TransactionManagerLookupClass", BatchModeTransactionManagerLookup.class.getName(), c.getTransactionManagerLookupClass());
assertEquals("ExposeManagementStatistics", false, wrapper.getExposeManagementStatistics());
assertEquals("ExposeManagementStatistics", false, c.getExposeManagementStatistics());
assertEquals("UseRegionBasedMarshalling", true, wrapper.getUseRegionBasedMarshalling());
assertEquals("UseRegionBasedMarshalling", true, c.isUseRegionBasedMarshalling());
assertEquals("UseReplQueue", true, wrapper.getUseReplQueue());
assertEquals("UseReplQueue", true, c.isUseReplQueue());
assertEquals("ClusterConfig", getClusterConfig().toString(), wrapper.getClusterConfig().toString());
assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig(legacy).toString(), wrapper.getBuddyReplicationConfig().toString());
BuddyReplicationConfig brc = c.getBuddyReplicationConfig();
assertEquals("BR enabled", true, brc.isEnabled());
assertEquals("BR auto grav", false, brc.isAutoDataGravitation());
assertEquals("BR remove find", false, brc.isDataGravitationRemoveOnFind());
assertEquals("BR search backup", false, brc.isDataGravitationSearchBackupTrees());
assertEquals("BR comm timeout", 600000, brc.getBuddyCommunicationTimeout());
assertEquals("BR poolname", "testpool", brc.getBuddyPoolName());
BuddyLocatorConfig blc = brc.getBuddyLocatorConfig();
assertEquals("BR locator", "org.jboss.cache.buddyreplication.TestBuddyLocator", blc.getBuddyLocatorClass());
Properties props = blc.getBuddyLocatorProperties();
assertEquals("BR props", "2", props.get("numBuddies"));
assertEquals("CacheLoaderConfig", getCacheLoaderConfig(legacy).toString(), wrapper.getCacheLoaderConfig().toString());
CacheLoaderConfig clc = c.getCacheLoaderConfig();
assertEquals("CL passivation", false, clc.isPassivation());
assertEquals("CL passivation", true, clc.isShared());
assertEquals("CL preload", "/foo", clc.getPreload());
List<IndividualCacheLoaderConfig> iclcs = clc.getIndividualCacheLoaderConfigs();
IndividualCacheLoaderConfig iclc = iclcs.get(0);
assertEquals("CL0 class", FileCacheLoader.class.getName(), iclc.getClassName());
assertEquals("CL0 async", false, iclc.isAsync());
assertEquals("CL0 fetch", true, iclc.isFetchPersistentState());
assertEquals("CL0 ignore", true, iclc.isIgnoreModifications());
assertEquals("CL0 purge", true, iclc.isPurgeOnStartup());
assertEquals("CL0 singleton", true, iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("CL0 singleton class", SingletonStoreCacheLoader.class.getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass());
iclc = iclcs.get(1);
assertEquals("CL1 class", JdbmCacheLoader.class.getName(), iclc.getClassName());
assertEquals("CL1 async", true, iclc.isAsync());
assertEquals("CL1 fetch", false, iclc.isFetchPersistentState());
assertEquals("CL1 ignore", false, iclc.isIgnoreModifications());
assertEquals("CL1 purge", false, iclc.isPurgeOnStartup());
assertEquals("CL1 singleton", false, iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
assertEquals("CL1 singleton class", SingletonStoreCacheLoader.class.getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass());
assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig(legacy).toString(), wrapper.getEvictionPolicyConfig().toString());
EvictionConfig ec = c.getEvictionConfig();
assertEquals("EC queue size", 1000, ec.getDefaultEvictionRegionConfig().getEventQueueSize());
assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
assertEquals("EC default pol", LRUAlgorithm.class.getName(), ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig().getEvictionAlgorithmClassName());
List<EvictionRegionConfig> ercs = ec.getEvictionRegionConfigs();
EvictionRegionConfig erc = ercs.get(0);
assertEquals("ERC1 name", "/org/jboss/data", erc.getRegionName());
assertEquals("ERC1 queue size", 1000, erc.getEventQueueSize());
FIFOAlgorithmConfig fifo = (FIFOAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC1 pol", FIFOAlgorithm.class.getName(), fifo.getEvictionAlgorithmClassName());
assertEquals("EPC1 maxnodes", 5000, fifo.getMaxNodes());
erc = ercs.get(1);
assertEquals("ERC2 name", "/test", erc.getRegionName());
assertEquals("ERC2 queue size", 1000, erc.getEventQueueSize());
MRUAlgorithmConfig mru = (MRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC2 pol", MRUAlgorithm.class.getName(), mru.getEvictionAlgorithmClassName());
assertEquals("EPC2 maxnodes", 10000, mru.getMaxNodes());
erc = ercs.get(2);
assertEquals("ERC3 name", "/maxAgeTest", erc.getRegionName());
assertEquals("ERC3 queue size", 1000, erc.getEventQueueSize());
LRUAlgorithmConfig lru = (LRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
assertEquals("EPC3 maxage", 10000, lru.getMaxAge());
assertEquals("EPC3 ttl", 8000, lru.getTimeToLive());
}
@SuppressWarnings("unchecked")
public void testRuntimeConfig() throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
// Fake a TM by making a bogus proxy
TransactionManager tm = (TransactionManager) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{TransactionManager.class}, new MockInvocationHandler());
wrapper.setTransactionManager(tm);
ChannelFactory cf = new JChannelFactory();
wrapper.setMuxChannelFactory(cf);
RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
assertSame("Same TM", tm, wrapper.getTransactionManager());
assertSame("Same TM", tm, rc.getTransactionManager());
assertSame("Same ChannelFactory", cf, wrapper.getMuxChannelFactory());
assertSame("Same ChannelFactory", cf, rc.getMuxChannelFactory());
}
@SuppressWarnings("unchecked")
public void testLegacyMuxChannelCreation() throws Exception
{
CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
registerWrapper(wrapper);
wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK + Thread.currentThread().getName());
JChannelFactory factory = new JChannelFactory();
factory.setDomain("jbc.mux.test");
factory.setExposeChannels(false);
factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigElement(getDefaultProperties()));
ObjectName on = new ObjectName("jgroups:service=Mux");
mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factory), on);
wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class, false));
wrapper.start();
RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
assertNotNull("Channel created", rc.getChannel());
//wrapper.stop();
//wrapper.destroy();
}
protected static Element getBuddyReplicationConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = "<config>\n" +
" <buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
" <buddyLocatorClass>org.jboss.cache.buddyreplication.TestBuddyLocator</buddyLocatorClass>\n" +
" <buddyLocatorProperties>\n" +
" numBuddies = 2\n" +
" </buddyLocatorProperties>\n" +
" <buddyPoolName>testpool</buddyPoolName>\n" +
" <buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
" <dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
" <dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>\n" +
" <autoDataGravitation>false</autoDataGravitation>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <buddy enabled=\"true\" poolName=\"testpool\" communicationTimeout=\"600000\">\n" +
" <dataGravitation auto=\"false\" removeOnFind=\"false\" searchBackupTrees=\"false\"/>\n" +
" <locator class=\"org.jboss.cache.buddyreplication.TestBuddyLocator\">\n" +
" <properties>\n" +
" numBuddies = 2\n" +
" </properties>\n" +
" </locator>\n" +
" </buddy>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getCacheLoaderConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = "<config>\n" +
" <passivation>false</passivation>\n" +
" <preload>/foo</preload>\n" +
" <shared>true</shared>\n" +
" <cacheloader>\n" +
" <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
" <properties>\n" +
" location=/tmp\n " +
" </properties>\n" +
" <async>false</async>\n" +
" <fetchPersistentState>true</fetchPersistentState>\n" +
" <ignoreModifications>true</ignoreModifications>\n" +
" <purgeOnStartup>true</purgeOnStartup>\n" +
" <singletonStore>\n" +
" <enabled>true</enabled>\n" +
" </singletonStore>\n" +
" </cacheloader> \n " +
" <cacheloader>\n" +
" <class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>\n" +
" <properties>\n" +
" location=/home/bstansberry\n " +
" </properties>\n" +
" <async>true</async>\n" +
" <fetchPersistentState>false</fetchPersistentState>\n" +
" <ignoreModifications>false</ignoreModifications>\n" +
" <purgeOnStartup>false</purgeOnStartup>\n" +
" <singletonStore>\n" +
" <enabled>false</enabled>\n" +
" </singletonStore>\n" +
" </cacheloader>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <loaders passivation=\"false\" shared=\"true\">\n" +
" <preload>\n" +
" <node fqn=\"/foo\"/>\n" +
" </preload>\n" +
" <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
" ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
" <properties>\n" +
" location=/tmp\n " +
" </properties>\n" +
" <singletonStore enabled=\"true\" /> \n" +
" </loader>\n" +
" <loader class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\" fetchPersistentState=\"false\"\n" +
" ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
" <properties>\n" +
" location=/home/bstansberry\n" +
" </properties>\n" +
" <singletonStore enabled=\"false\" /> \n" +
" </loader>\n" +
" </loaders>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getEvictionPolicyConfig(boolean legacy) throws Exception
{
if (legacy)
{
String xmlStr = " <config>\n" +
" <attribute name=\"wakeUpIntervalSeconds\">5</attribute>\n" +
" <attribute name=\"eventQueueSize\">1000</attribute>\n" +
" <attribute name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n" +
" <region name=\"/_default_\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" <attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
" </region>\n" +
" <region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
" </region>\n" +
" <region name=\"/test\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
" <attribute name=\"maxNodes\">10000</attribute>\n" +
" </region>\n" +
" <region name=\"/maxAgeTest\">\n" +
" <attribute name=\"maxNodes\">10000</attribute>\n" +
" <attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
" <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
" </region>\n" +
" </config>";
return XmlConfigHelper.stringToElement(xmlStr);
}
else
{
String xmlStr =
" <eviction wakeUpInterval=\"5000\">\n" +
" <default eventQueueSize=\"1000\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"5000\"></property>\n" +
" <property name=\"timeToLive\" value=\"1000000\"></property>\n" +
" </default>\n" +
"<region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"5000\"></property>\n" +
"</region>\n" +
"<region name=\"/test/\" algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
" <property name=\"maxNodes\" value=\"10000\"></property>\n" +
"</region>\n" +
"<region name=\"/maxAgeTest/\">\n" +
" <property name=\"maxNodes\" value=\"10000\"></property>\n" +
" <property name=\"timeToLive\" value=\"8000\"></property>\n" +
" <property name=\"maxAge\" value=\"10000\"></property>\n" +
"</region>\n" +
" </eviction>";
return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
}
}
protected static Element getClusterConfig() throws Exception
{
String xml =
"<jgroupsConfig>\n" +
"<UDP mcast_addr=\"228.10.10.10\"\n" +
" mcast_port=\"45588\"\n" +
" tos=\"8\"\n" +
" ucast_recv_buf_size=\"20000000\"\n" +
" ucast_send_buf_size=\"640000\"\n" +
" mcast_recv_buf_size=\"25000000\"\n" +
" mcast_send_buf_size=\"640000\"\n" +
" loopback=\"false\"\n" +
" discard_incompatible_packets=\"true\"\n" +
" max_bundle_size=\"64000\"\n" +
" max_bundle_timeout=\"30\"\n" +
" use_incoming_packet_handler=\"true\"\n" +
" ip_ttl=\"2\"\n" +
" enable_bundling=\"false\"\n" +
" enable_diagnostics=\"true\"\n" +
" use_concurrent_stack=\"true\"\n" +
" thread_naming_pattern=\"pl\"\n" +
" thread_pool.enabled=\"true\"\n" +
" thread_pool.min_threads=\"1\"\n" +
" thread_pool.max_threads=\"25\"\n" +
" thread_pool.keep_alive_time=\"30000\"\n" +
" thread_pool.queue_enabled=\"true\"\n" +
" thread_pool.queue_max_size=\"10\"\n" +
" thread_pool.rejection_policy=\"Run\"\n" +
" oob_thread_pool.enabled=\"true\"\n" +
" oob_thread_pool.min_threads=\"1\"\n" +
" oob_thread_pool.max_threads=\"4\"\n" +
" oob_thread_pool.keep_alive_time=\"10000\"\n" +
" oob_thread_pool.queue_enabled=\"true\"\n" +
" oob_thread_pool.queue_max_size=\"10\"\n" +
" oob_thread_pool.rejection_policy=\"Run\"/>\n" +
" <PING timeout=\"2000\" num_initial_members=\"3\"/>\n" +
" <MERGE2 max_interval=\"30000\" min_interval=\"10000\"/>\n" +
" <FD_SOCK/>\n" +
" <FD timeout=\"10000\" max_tries=\"5\" shun=\"true\"/>\n" +
" <VERIFY_SUSPECT timeout=\"1500\"/>\n" +
" <pbcast.NAKACK max_xmit_size=\"60000\"\n" +
" use_mcast_xmit=\"false\" gc_lag=\"0\"\n" +
" retransmit_timeout=\"300,600,1200,2400,4800\"\n" +
" discard_delivered_msgs=\"true\"/>\n" +
" <UNICAST timeout=\"300,600,1200,2400,3600\"/>\n" +
" <pbcast.STABLE stability_delay=\"1000\" desired_avg_gossip=\"50000\"\n" +
" max_bytes=\"400000\"/>\n" +
" <pbcast.GMS print_local_addr=\"true\" join_timeout=\"5000\"\n" +
" join_retry_timeout=\"2000\" shun=\"false\"\n" +
" view_bundling=\"true\" view_ack_collection_timeout=\"5000\"/>\n" +
" <FRAG2 frag_size=\"60000\"/>\n" +
" <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
" <pbcast.FLUSH timeout=\"0\"/>\n" +
"</jgroupsConfig>";
return XmlConfigHelper.stringToElementInCoreNS(xml);
}
protected String getDefaultProperties()
{
return "UDP(mcast_addr=172.16.17.32;mcast_port=55566;ip_ttl=32;" +
"mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
"PING(timeout=1000;num_initial_members=2):" +
"MERGE2(min_interval=5000;max_interval=10000):" +
"FD_SOCK:" +
"VERIFY_SUSPECT(timeout=1500):" +
"pbcast.NAKACK(gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800):" +
"UNICAST(timeout=600,1200,2400,4800):" +
"pbcast.STABLE(desired_avg_gossip=20000):" +
"FRAG(frag_size=8192;down_thread=false;up_thread=false):" +
"pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
"shun=false;print_local_addr=true):" +
"pbcast.STATE_TRANSFER";
}
class MockInvocationHandler implements InvocationHandler
{
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
return null;
}
}
}
| 27,703 | 0.614497 | 0.596213 | 504 | 54.01984 | 33.212753 | 165 | true | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.892857 | false | false |
10
|
5eaefc42409725a65589090ec39420851d8e0280
| 7,249,904,866,909 |
d011ff95bee0fcd95146566d692d94f0337f915d
|
/src/main/java/io/github/rowak/nanoleafdesktop/ambilight/CaptureAreaWindow.java
|
993d1b49c28a667248f73f185d1aa448bdc164e1
|
[
"MIT"
] |
permissive
|
rowak/nanoleaf-desktop
|
https://github.com/rowak/nanoleaf-desktop
|
81f8939b9d9006304773fe6c7676c9ab5c9b8ce4
|
0e298f1a19c032570368d31105416e493480e5fd
|
refs/heads/master
| 2022-07-10T08:13:45.586000 | 2022-06-25T14:30:22 | 2022-06-25T14:30:22 | 162,864,929 | 171 | 13 |
MIT
| false | 2021-05-30T05:03:42 | 2018-12-23T05:28:10 | 2021-05-30T04:56:17 | 2021-05-30T05:03:41 | 920 | 95 | 7 | 12 |
Java
| false | false |
package io.github.rowak.nanoleafdesktop.ambilight;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import io.github.rowak.nanoleafdesktop.Main;
import io.github.rowak.nanoleafdesktop.tools.PropertyManager;
import io.github.rowak.nanoleafdesktop.ui.dialog.TextDialog;
import io.github.rowak.nanoleafdesktop.ui.panel.AmbilightPanel;
public class CaptureAreaWindow extends JFrame {
private int monitor;
private Rectangle maxArea;
private Rectangle selectedArea;
private AmbilightPanel parent;
public CaptureAreaWindow(int monitor, AmbilightPanel parent) {
this.monitor = monitor;
this.parent = parent;
loadSettings();
initUI();
showInfoMessage();
}
@Override
public void paint(Graphics g) {
super.paint(g);
drawSelectionBox(g);
}
private void drawSelectionBox(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setStroke(new BasicStroke(5));
g.setColor(Color.RED);
g.drawRect(selectedArea.x, selectedArea.y,
selectedArea.width, selectedArea.height);
g2d.setStroke(new BasicStroke(1));
}
private Rectangle getMaxCaptureArea() {
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
GraphicsConfiguration config = gs[monitor].getConfigurations()[0];
return config.getBounds();
}
private Rectangle getDefaultSelectionArea() {
maxArea = getMaxCaptureArea();
return new Rectangle(maxArea.width/2 - 400, maxArea.height/2 - 200, 800, 400);
}
private void loadSettings() {
PropertyManager manager = new PropertyManager(Main.PROPERTIES_FILEPATH);
String lastSelection = manager.getProperty("ambilightSelection");
Rectangle defaultSelection = getDefaultSelectionArea();
if (lastSelection != null) {
String[] data = manager.getProperty("ambilightSelection").split(" ");
if (data.length == 4) {
int x = Integer.parseInt(data[0]);
int y = Integer.parseInt(data[1]);
int width = Integer.parseInt(data[2]);
int height = Integer.parseInt(data[3]);
selectedArea = new Rectangle(x, y, width, height);
return;
}
}
selectedArea = defaultSelection;
}
private void saveChanges() {
PropertyManager manager = new PropertyManager(Main.PROPERTIES_FILEPATH);
String selection = selectedArea.x + " " + selectedArea.y + " " +
selectedArea.width + " " + selectedArea.height;
manager.setProperty("ambilightSelection", selection);
parent.setCaptureArea(selectedArea);
}
private void showInfoMessage() {
EventQueue.invokeLater(() ->
{
String message = "You can move around and resize the red box to change your selection. " +
"Press the escape key when you are done.";
new TextDialog(this, message).setVisible(true);
});
}
private void initUI() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(maxArea.x, maxArea.y, maxArea.width, maxArea.height);
setUndecorated(true);
setBackground(new Color(255, 255, 255, 1));
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
saveChanges();
dispose();
}
}
});
BoxDragListener bdl = new BoxDragListener(this);
addMouseListener(bdl);
addMouseMotionListener(bdl);
setVisible(true);
}
private class BoxDragListener extends MouseAdapter {
private boolean inArea;
private int edge;
private Point mouseLast;
private Point lastLocation;
private Dimension lastSize;
private CaptureAreaWindow window;
public BoxDragListener(CaptureAreaWindow window) {
this.window = window;
lastLocation = new Point(selectedArea.x, selectedArea.y);
lastSize = new Dimension(selectedArea.width, selectedArea.height);
}
private void moveBox(Point mouse) {
int xdiff = mouse.x - mouseLast.x;
int ydiff = mouse.y - mouseLast.y;
selectedArea.setLocation(lastLocation.x + xdiff,
lastLocation.y + ydiff);
repaint();
}
private void resizeBox(Point mouse, Dimension direction) {
int xdiff = mouse.x - mouseLast.x;
int ydiff = mouse.y - mouseLast.y;
int xdirection = direction.width;
int ydirection = direction.height;
selectedArea.setSize(lastSize.width + xdiff*xdirection,
lastSize.height + ydiff*ydirection);
if (xdirection == -1 || ydirection == -1) {
selectedArea.setLocation(lastLocation.x - xdiff * xdirection,
lastLocation.y - ydiff * ydirection);
}
repaint();
}
private Dimension getResizeXY(int edge) {
switch (edge) {
case 0:
return new Dimension(0, -1);
case 1:
return new Dimension(1, 0);
case 2:
return new Dimension(0, 1);
case 3:
return new Dimension(-1, 0);
default:
return new Dimension(0, 0);
}
}
private int getEdge(Point mouse) {
int leftEdge = selectedArea.x;
int topEdge = selectedArea.y;
int rightEdge = selectedArea.x + selectedArea.width;
int bottomEdge = selectedArea.y + selectedArea.height;
// check top edge
if (mouse.x >= leftEdge && mouse.x <= rightEdge &&
mouse.y >= topEdge - 5 && mouse.y <= topEdge + 5) {
window.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
return 0;
}
// check right edge
else if (mouse.x >= rightEdge - 5 && mouse.x <= rightEdge + 5 &&
mouse.y >= topEdge && mouse.y <= bottomEdge) {
window.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
return 1;
}
// check bottom edge
else if (mouse.x >= leftEdge && mouse.x <= rightEdge &&
mouse.y >= bottomEdge - 5 && mouse.y <= bottomEdge + 5) {
window.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
return 2;
}
// check left edge
else if (mouse.x >= leftEdge - 5 && mouse.x <= leftEdge + 5 &&
mouse.y >= topEdge && mouse.y <= bottomEdge) {
window.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
return 3;
}
return -1;
}
@Override
public void mousePressed(MouseEvent e) {
mouseLast = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e) {
mouseLast = null;
inArea = false;
edge = -1;
lastLocation = new Point(selectedArea.x, selectedArea.y);
lastSize = new Dimension(selectedArea.width, selectedArea.height);
window.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@Override
public void mouseDragged(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
if (edge != -1) {
resizeBox(e.getPoint(), getResizeXY(edge));
}
else if (inArea) {
moveBox(e.getPoint());
}
}
}
@Override
public void mouseMoved(MouseEvent e) {
edge = getEdge(e.getPoint());
if (selectedArea.contains(e.getPoint()) && edge == -1) {
window.setCursor(new Cursor(Cursor.MOVE_CURSOR));
inArea = true;
}
}
}
}
|
UTF-8
|
Java
| 7,200 |
java
|
CaptureAreaWindow.java
|
Java
|
[
{
"context": "package io.github.rowak.nanoleafdesktop.ambilight;\n\nimport java.awt.Basic",
"end": 23,
"score": 0.7120906114578247,
"start": 18,
"tag": "USERNAME",
"value": "rowak"
},
{
"context": "thub.rowak.nanoleafdesktop.Main;\nimport io.github.rowak.nanoleafdesktop.tools.PropertyManager;\nimport io.",
"end": 662,
"score": 0.7353913187980652,
"start": 657,
"tag": "USERNAME",
"value": "rowak"
},
{
"context": "afdesktop.tools.PropertyManager;\nimport io.github.rowak.nanoleafdesktop.ui.dialog.TextDialog;\nimport io.g",
"end": 724,
"score": 0.755186915397644,
"start": 719,
"tag": "USERNAME",
"value": "rowak"
},
{
"context": "eafdesktop.ui.dialog.TextDialog;\nimport io.github.rowak.nanoleafdesktop.ui.panel.AmbilightPanel;\n\npublic ",
"end": 785,
"score": 0.5299923419952393,
"start": 780,
"tag": "USERNAME",
"value": "rowak"
}
] | null |
[] |
package io.github.rowak.nanoleafdesktop.ambilight;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import io.github.rowak.nanoleafdesktop.Main;
import io.github.rowak.nanoleafdesktop.tools.PropertyManager;
import io.github.rowak.nanoleafdesktop.ui.dialog.TextDialog;
import io.github.rowak.nanoleafdesktop.ui.panel.AmbilightPanel;
public class CaptureAreaWindow extends JFrame {
private int monitor;
private Rectangle maxArea;
private Rectangle selectedArea;
private AmbilightPanel parent;
public CaptureAreaWindow(int monitor, AmbilightPanel parent) {
this.monitor = monitor;
this.parent = parent;
loadSettings();
initUI();
showInfoMessage();
}
@Override
public void paint(Graphics g) {
super.paint(g);
drawSelectionBox(g);
}
private void drawSelectionBox(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setStroke(new BasicStroke(5));
g.setColor(Color.RED);
g.drawRect(selectedArea.x, selectedArea.y,
selectedArea.width, selectedArea.height);
g2d.setStroke(new BasicStroke(1));
}
private Rectangle getMaxCaptureArea() {
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
GraphicsConfiguration config = gs[monitor].getConfigurations()[0];
return config.getBounds();
}
private Rectangle getDefaultSelectionArea() {
maxArea = getMaxCaptureArea();
return new Rectangle(maxArea.width/2 - 400, maxArea.height/2 - 200, 800, 400);
}
private void loadSettings() {
PropertyManager manager = new PropertyManager(Main.PROPERTIES_FILEPATH);
String lastSelection = manager.getProperty("ambilightSelection");
Rectangle defaultSelection = getDefaultSelectionArea();
if (lastSelection != null) {
String[] data = manager.getProperty("ambilightSelection").split(" ");
if (data.length == 4) {
int x = Integer.parseInt(data[0]);
int y = Integer.parseInt(data[1]);
int width = Integer.parseInt(data[2]);
int height = Integer.parseInt(data[3]);
selectedArea = new Rectangle(x, y, width, height);
return;
}
}
selectedArea = defaultSelection;
}
private void saveChanges() {
PropertyManager manager = new PropertyManager(Main.PROPERTIES_FILEPATH);
String selection = selectedArea.x + " " + selectedArea.y + " " +
selectedArea.width + " " + selectedArea.height;
manager.setProperty("ambilightSelection", selection);
parent.setCaptureArea(selectedArea);
}
private void showInfoMessage() {
EventQueue.invokeLater(() ->
{
String message = "You can move around and resize the red box to change your selection. " +
"Press the escape key when you are done.";
new TextDialog(this, message).setVisible(true);
});
}
private void initUI() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(maxArea.x, maxArea.y, maxArea.width, maxArea.height);
setUndecorated(true);
setBackground(new Color(255, 255, 255, 1));
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
saveChanges();
dispose();
}
}
});
BoxDragListener bdl = new BoxDragListener(this);
addMouseListener(bdl);
addMouseMotionListener(bdl);
setVisible(true);
}
private class BoxDragListener extends MouseAdapter {
private boolean inArea;
private int edge;
private Point mouseLast;
private Point lastLocation;
private Dimension lastSize;
private CaptureAreaWindow window;
public BoxDragListener(CaptureAreaWindow window) {
this.window = window;
lastLocation = new Point(selectedArea.x, selectedArea.y);
lastSize = new Dimension(selectedArea.width, selectedArea.height);
}
private void moveBox(Point mouse) {
int xdiff = mouse.x - mouseLast.x;
int ydiff = mouse.y - mouseLast.y;
selectedArea.setLocation(lastLocation.x + xdiff,
lastLocation.y + ydiff);
repaint();
}
private void resizeBox(Point mouse, Dimension direction) {
int xdiff = mouse.x - mouseLast.x;
int ydiff = mouse.y - mouseLast.y;
int xdirection = direction.width;
int ydirection = direction.height;
selectedArea.setSize(lastSize.width + xdiff*xdirection,
lastSize.height + ydiff*ydirection);
if (xdirection == -1 || ydirection == -1) {
selectedArea.setLocation(lastLocation.x - xdiff * xdirection,
lastLocation.y - ydiff * ydirection);
}
repaint();
}
private Dimension getResizeXY(int edge) {
switch (edge) {
case 0:
return new Dimension(0, -1);
case 1:
return new Dimension(1, 0);
case 2:
return new Dimension(0, 1);
case 3:
return new Dimension(-1, 0);
default:
return new Dimension(0, 0);
}
}
private int getEdge(Point mouse) {
int leftEdge = selectedArea.x;
int topEdge = selectedArea.y;
int rightEdge = selectedArea.x + selectedArea.width;
int bottomEdge = selectedArea.y + selectedArea.height;
// check top edge
if (mouse.x >= leftEdge && mouse.x <= rightEdge &&
mouse.y >= topEdge - 5 && mouse.y <= topEdge + 5) {
window.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
return 0;
}
// check right edge
else if (mouse.x >= rightEdge - 5 && mouse.x <= rightEdge + 5 &&
mouse.y >= topEdge && mouse.y <= bottomEdge) {
window.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
return 1;
}
// check bottom edge
else if (mouse.x >= leftEdge && mouse.x <= rightEdge &&
mouse.y >= bottomEdge - 5 && mouse.y <= bottomEdge + 5) {
window.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
return 2;
}
// check left edge
else if (mouse.x >= leftEdge - 5 && mouse.x <= leftEdge + 5 &&
mouse.y >= topEdge && mouse.y <= bottomEdge) {
window.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
return 3;
}
return -1;
}
@Override
public void mousePressed(MouseEvent e) {
mouseLast = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e) {
mouseLast = null;
inArea = false;
edge = -1;
lastLocation = new Point(selectedArea.x, selectedArea.y);
lastSize = new Dimension(selectedArea.width, selectedArea.height);
window.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@Override
public void mouseDragged(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
if (edge != -1) {
resizeBox(e.getPoint(), getResizeXY(edge));
}
else if (inArea) {
moveBox(e.getPoint());
}
}
}
@Override
public void mouseMoved(MouseEvent e) {
edge = getEdge(e.getPoint());
if (selectedArea.contains(e.getPoint()) && edge == -1) {
window.setCursor(new Cursor(Cursor.MOVE_CURSOR));
inArea = true;
}
}
}
}
| 7,200 | 0.69375 | 0.684028 | 252 | 27.571428 | 21.265863 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.924603 | false | false |
10
|
c8c87cde1b02b7255731ecf05c802b532cfe0016
| 21,354,577,450,954 |
74d6c588d213f596c4c41f463be5d554402aa5b3
|
/src/main/java/pe/edu/upc/market/services/impls/TiendaServiceImpl.java
|
4b0c737fe9e6a7e13d87a78290b898e816738e08
|
[] |
no_license
|
Dylan1234094/pw-java-market-flow
|
https://github.com/Dylan1234094/pw-java-market-flow
|
4e7daf645f8d5420364fdf9c2add69d4eb415ca8
|
b9ff4f6993ad4b7c4f131ad3e4d68bfa3124dcc8
|
refs/heads/master
| 2022-12-25T08:06:24.656000 | 2020-10-12T19:04:48 | 2020-10-12T19:04:48 | 303,493,004 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pe.edu.upc.market.services.impls;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import javax.transaction.Transactional;
import pe.edu.upc.market.models.entities.Tienda;
import pe.edu.upc.market.models.repositories.TiendaRepository;
import pe.edu.upc.market.services.TiendaService;
public class TiendaServiceImpl implements TiendaService, Serializable {
private static final long serialVersionUID = 1L;
@Inject
private TiendaRepository tiendaRepository;
@Transactional
@Override
public Tienda save(Tienda entity) throws Exception {
return tiendaRepository.save(entity);
}
@Transactional
@Override
public Tienda update(Tienda entity) throws Exception {
return tiendaRepository.update(entity);
}
@Transactional
@Override
public void deleteById(Integer id) throws Exception {
tiendaRepository.deleteById(id);
}
@Override
public Optional<Tienda> findById(Integer id) throws Exception {
return tiendaRepository.findById(id);
}
@Override
public List<Tienda> findAll() throws Exception {
return tiendaRepository.findAll();
}
@Override
public List<Tienda> findByNombre(String nombre) throws Exception {
return tiendaRepository.findByNombre(nombre);
}
}
|
UTF-8
|
Java
| 1,265 |
java
|
TiendaServiceImpl.java
|
Java
|
[] | null |
[] |
package pe.edu.upc.market.services.impls;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import javax.transaction.Transactional;
import pe.edu.upc.market.models.entities.Tienda;
import pe.edu.upc.market.models.repositories.TiendaRepository;
import pe.edu.upc.market.services.TiendaService;
public class TiendaServiceImpl implements TiendaService, Serializable {
private static final long serialVersionUID = 1L;
@Inject
private TiendaRepository tiendaRepository;
@Transactional
@Override
public Tienda save(Tienda entity) throws Exception {
return tiendaRepository.save(entity);
}
@Transactional
@Override
public Tienda update(Tienda entity) throws Exception {
return tiendaRepository.update(entity);
}
@Transactional
@Override
public void deleteById(Integer id) throws Exception {
tiendaRepository.deleteById(id);
}
@Override
public Optional<Tienda> findById(Integer id) throws Exception {
return tiendaRepository.findById(id);
}
@Override
public List<Tienda> findAll() throws Exception {
return tiendaRepository.findAll();
}
@Override
public List<Tienda> findByNombre(String nombre) throws Exception {
return tiendaRepository.findByNombre(nombre);
}
}
| 1,265 | 0.788933 | 0.788142 | 54 | 22.425926 | 22.374424 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.037037 | false | false |
10
|
cb6ff533c7aa2da05d03bee0c53411759cec7ee5
| 26,938,034,935,816 |
dd2eb8c4bc9efb22f9e1a49b137204d942045d55
|
/Administrare Comenzi Restaurant v2/src/administrare/ServiciuAudit.java
|
6a84e579d536aea83019d9f479687b48ea4cc9c0
|
[] |
no_license
|
MihaiDragutescu/Administrare-Comenzi-Restaurant
|
https://github.com/MihaiDragutescu/Administrare-Comenzi-Restaurant
|
173f7cd35b0c3ce75fb63e7606343d8853b677d2
|
69bffa9f60ba7f9c76b3c043c245757ba044ad0f
|
refs/heads/master
| 2020-05-03T23:14:33.055000 | 2019-06-04T21:45:04 | 2019-06-04T21:45:04 | 178,860,648 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package administrare;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Timestamp;
import java.time.Instant;
public class ServiciuAudit {
private String path;
public ServiciuAudit(String path) {
this.path = path;
}
//Metoda care scrie in fisier de fiecare data când este executata o actiune (numele actiunii si data+ora)
public void scrie(String actiune) {
try {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path, true));
bufferedWriter.write(actiune + "," + Timestamp.from(Instant.now()) + "\n");
bufferedWriter.close();
} catch (IOException ex) {
System.out.println("A aparut o eroare la scrierea in fisier.");
}
}
}
|
UTF-8
|
Java
| 801 |
java
|
ServiciuAudit.java
|
Java
|
[] | null |
[] |
package administrare;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Timestamp;
import java.time.Instant;
public class ServiciuAudit {
private String path;
public ServiciuAudit(String path) {
this.path = path;
}
//Metoda care scrie in fisier de fiecare data când este executata o actiune (numele actiunii si data+ora)
public void scrie(String actiune) {
try {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path, true));
bufferedWriter.write(actiune + "," + Timestamp.from(Instant.now()) + "\n");
bufferedWriter.close();
} catch (IOException ex) {
System.out.println("A aparut o eroare la scrierea in fisier.");
}
}
}
| 801 | 0.66375 | 0.66375 | 26 | 29.76923 | 29.13537 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.538462 | false | false |
10
|
5b2f213dad1e91c3b7fcd8c6311fc48c225a0e65
| 32,212,254,758,872 |
91ce06b2cb9f45f17b15c1b5a4752de5a8534491
|
/src/Fabriques/FabriqueRelationExtends.java
|
7caffb1b5083b8fc3ced00638b68767e2714272f
|
[] |
no_license
|
Fitousimon/Projet_ArchitectureLog_Romann-Fitoussi-Ketheeswaran
|
https://github.com/Fitousimon/Projet_ArchitectureLog_Romann-Fitoussi-Ketheeswaran
|
78471e0d35c824505d8a024d5bf5f22b6ec6b746
|
4fc4d773fda6a0ef30619debf19d9e2be0db8aa4
|
refs/heads/master
| 2020-07-02T12:01:42.418000 | 2016-12-12T10:40:06 | 2016-12-12T10:40:06 | 74,304,531 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Fabriques;
public class FabriqueRelationExtends extends FabriqueRelation {
}
|
UTF-8
|
Java
| 87 |
java
|
FabriqueRelationExtends.java
|
Java
|
[] | null |
[] |
package Fabriques;
public class FabriqueRelationExtends extends FabriqueRelation {
}
| 87 | 0.83908 | 0.83908 | 5 | 16.4 | 24.286621 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false |
10
|
a819731eb12ec9d890fd075119ca42087d7dbd20
| 13,091,060,349,254 |
12bc446af78063b46d771d8f992b15358cc31782
|
/chapter_007/src/test/java/ru/job4j/userstore/package-info.java
|
0f40a1b1fae2d423b811006e9e679307545d1f76
|
[
"Apache-2.0"
] |
permissive
|
Malamut54/dbobrov
|
https://github.com/Malamut54/dbobrov
|
804ea3f53d910c56a7379c94bc793530bfc9fe15
|
2436fa9a04d0dbde71b4a3f8af167604835afda9
|
refs/heads/master
| 2021-10-25T22:18:45.733000 | 2021-09-25T10:15:22 | 2021-09-25T10:15:22 | 86,559,507 | 0 | 0 |
Apache-2.0
| false | 2021-03-29T19:07:08 | 2017-03-29T08:51:27 | 2021-03-29T19:06:17 | 2021-03-29T19:07:07 | 406 | 0 | 0 | 1 |
Java
| false | false |
/**
* Task User storage.
*
* @author Dmitriy Bobrov (bobrov.dmitriy@gmail.com)
* @since 20.10.2017
*/
package ru.job4j.userstore;
|
UTF-8
|
Java
| 135 |
java
|
package-info.java
|
Java
|
[
{
"context": "/**\n * Task User storage.\n *\n * @author Dmitriy Bobrov (bobrov.dmitriy@gmail.com)\n * @since 20.10.2017\n ",
"end": 54,
"score": 0.9998863339424133,
"start": 40,
"tag": "NAME",
"value": "Dmitriy Bobrov"
},
{
"context": " Task User storage.\n *\n * @author Dmitriy Bobrov (bobrov.dmitriy@gmail.com)\n * @since 20.10.2017\n */\n\npackage ru.job4j.users",
"end": 80,
"score": 0.9999351501464844,
"start": 56,
"tag": "EMAIL",
"value": "bobrov.dmitriy@gmail.com"
}
] | null |
[] |
/**
* Task User storage.
*
* @author <NAME> (<EMAIL>)
* @since 20.10.2017
*/
package ru.job4j.userstore;
| 110 | 0.674074 | 0.607407 | 8 | 16 | 16.763054 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | false | false |
10
|
54da865443b20e1fe3c2e59ed2eb1e629e890ce4
| 31,868,657,352,121 |
03fec3aec6b32a8d93d412e7690e66e2934c686a
|
/src/main/java/com/cemgunduz/espn/scrape/App.java
|
7f22d2b5ef632ac14ef06191943f3302eb45984e
|
[] |
no_license
|
cgunduz/espn
|
https://github.com/cgunduz/espn
|
00cfdb93454663e2ed7ba9f49834558bf7aa7360
|
44696d4991a981b64213b7b83d2c32cc51d3ffcb
|
refs/heads/master
| 2021-01-10T13:29:03.308000 | 2015-12-24T20:03:50 | 2015-12-24T20:03:50 | 48,625,253 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cemgunduz.espn.scrape;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.cemgunduz.espn.entity.BasketballPlayer;
import com.cemgunduz.espn.entity.SheetType;
public class App {
public static void main(String[] args) throws IOException {
List<BasketballPlayer> players = new ArrayList<BasketballPlayer>();
System.out.println("startin");
players = Scraper.scrapePlayers(players, 400, SheetType.SEASON);
System.out.println("done");
players = Scraper.scrapePlayers(players, 400, SheetType.LAST_SEASON);
System.out.println("done");
players = Scraper.scrapePlayers(players, 400, SheetType.PROJECTION);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_30);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_15);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_7);
System.out.println("hey");
}
}
|
UTF-8
|
Java
| 906 |
java
|
App.java
|
Java
|
[] | null |
[] |
package com.cemgunduz.espn.scrape;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.cemgunduz.espn.entity.BasketballPlayer;
import com.cemgunduz.espn.entity.SheetType;
public class App {
public static void main(String[] args) throws IOException {
List<BasketballPlayer> players = new ArrayList<BasketballPlayer>();
System.out.println("startin");
players = Scraper.scrapePlayers(players, 400, SheetType.SEASON);
System.out.println("done");
players = Scraper.scrapePlayers(players, 400, SheetType.LAST_SEASON);
System.out.println("done");
players = Scraper.scrapePlayers(players, 400, SheetType.PROJECTION);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_30);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_15);
players = Scraper.scrapePlayers(players, 400, SheetType.DAYS_7);
System.out.println("hey");
}
}
| 906 | 0.762693 | 0.737307 | 26 | 33.846153 | 25.926956 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.115385 | false | false |
10
|
31c946ca2f48e898ce0bcfc3b7a52c0d3cf30d75
| 13,039,520,722,056 |
33926ee20e932bed6a724114667c3a7109fbb9e6
|
/com.fintech.insurance.micro.finance/src/main/java/com/fintech/insurance/micro/finance/service/yjf/YjfPaymentServiceImpl.java
|
9fdb59dc865c74759f8c7930fe3b3aa623e354bc
|
[] |
no_license
|
cckmit/Insurance-1
|
https://github.com/cckmit/Insurance-1
|
fbfb23582af06e510d7416451b84186e3031a3e0
|
5e2f900ce3dfa81eb73e5e5b66b20cea7ff257eb
|
refs/heads/main
| 2023-07-06T06:30:26.731000 | 2021-08-11T00:00:13 | 2021-08-11T00:00:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.fintech.insurance.micro.finance.service.yjf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.fintech.insurance.commons.constants.YjfConstants;
import com.fintech.insurance.commons.enums.*;
import com.fintech.insurance.commons.utils.DateCommonUtils;
import com.fintech.insurance.commons.utils.ToolUtils;
import com.fintech.insurance.components.cache.RedisSequenceFactory;
import com.fintech.insurance.micro.dto.finance.BankCardVerifyResult;
import com.fintech.insurance.micro.dto.finance.DebtNotification;
import com.fintech.insurance.micro.dto.finance.DebtResult;
import com.fintech.insurance.micro.dto.finance.YjfNotification;
import com.fintech.insurance.micro.feign.biz.RequisitionServiceFeign;
import com.fintech.insurance.micro.finance.event.RepaymentPlanEvent;
import com.fintech.insurance.micro.finance.event.RepaymentPlanOverdueEvent;
import com.fintech.insurance.micro.finance.event.RepaymentPlanRefundEvent;
import com.fintech.insurance.micro.finance.model.UserDebtInfoRedisVO;
import com.fintech.insurance.micro.finance.persist.dao.*;
import com.fintech.insurance.micro.finance.persist.entity.*;
import com.fintech.insurance.micro.finance.service.*;
import com.fintech.insurance.micro.finance.service.yjf.enums.ResultCodeType;
import com.fintech.insurance.micro.finance.service.yjf.enums.VerifyCardStatus;
import com.fintech.insurance.micro.finance.service.yjf.enums.YJFDebtProcessStatus;
import com.fintech.insurance.micro.finance.service.yjf.exception.YijifuClientException;
import com.fintech.insurance.micro.finance.service.yjf.model.*;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Description: 易极付支付接口实现
* @Author: Yong Li
* @Date: 2017/12/8 17:20
*/
@Service
public class YjfPaymentServiceImpl implements PaymentService , ApplicationContextAware {
private static final Logger LOG = LoggerFactory.getLogger(YjfPaymentServiceImpl.class);
@Value("${fintech.common.verificationEffectiveDays}")
private Integer maxEffectiveDays;
@Autowired
private RepaymentPlanService repaymentPlanService;
@Autowired
private PaymentOrderService paymentOrderService;
@Autowired
private PaymentOrderDao paymentOrderDao;
@Autowired
private RequisitionServiceFeign requisitionServiceFeign;
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
private static final List<String> DEBT_PROCESSING_STATUSES = new ArrayList<String>();
private static final List<String> DEBT_FAILED_STATUSES = new ArrayList<String>();
static {
DEBT_PROCESSING_STATUSES.add("VERIFY_CARD_DEALING");
DEBT_PROCESSING_STATUSES.add("CHECK_NEEDED");
DEBT_PROCESSING_STATUSES.add("INIT");
DEBT_PROCESSING_STATUSES.add("WITHHOLD_DEALING");
DEBT_FAILED_STATUSES.add("VERIFY_CARD_FAIL");
DEBT_FAILED_STATUSES.add("CHECK_REJECT");
DEBT_FAILED_STATUSES.add("WITHHOLD_FAIL");
}
@Autowired
private RedisSequenceFactory redisSequenceFactory;
@Autowired
private YjfLogDao logDao;
@Autowired
private YjfHttpClient yjfHttpClient;
@Autowired
private YjfPropertiesBean propertiesBean;
@Autowired
private RepaymentRecordDao repaymentRecordDao;
@Autowired
private RepaymentPlanDao repaymentPlanDao;
@Autowired
private UserDebtRedisService userDebtRedisService;
@Autowired
private RepaymentRecordService repaymentRecordService;
@Autowired
private BankcardVerifyRecordDao bankcardVerifyRecordDao;
private static ValueFilter nullValueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (null == value) {
return "";
}
return value.toString();
}
};
/**
* 根据用户的姓名 身份证号 银行卡号 银行卡预留手机号码做四要素+短信验证
*
* @param userName 用户真实姓名
* @param certNum 身份证号
* @param bankCardNum 银行卡号
* @param reservedMobile 银行卡预留手机号码
*/
public BankCardVerifyResult verifyBankCard(String userName, String certNum, String bankCardNum, String reservedMobile) {
if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile)) {
throw new IllegalArgumentException("the parameter for verifyBankCard can not be null or empty.");
}
BankCardVerifyResult result = this.verifyBankCardByLocalData(userName, certNum, bankCardNum, reservedMobile);
if(result.getIsSuccess()) {
return result;
}
result = this.verifyBankCardByYijifu(userName, certNum, bankCardNum, reservedMobile);
BankcardVerifyRecord verifyRecord = new BankcardVerifyRecord();
verifyRecord.setUserName(userName);
verifyRecord.setIdNumber(certNum);
verifyRecord.setBankCardNumber(bankCardNum);
verifyRecord.setReservedMobile(reservedMobile);
verifyRecord.setBankCode(result.getBankCode());
verifyRecord.setBankName(result.getBankName());
verifyRecord.setPlatformOrderNumber(result.getRequestSerialNum());
verifyRecord.setVerificationStatus(result.getVerificationStatus());
verifyRecord.setVerificationTime(new Date());
verifyRecord.setRemarks(result.getFailedMessage());
bankcardVerifyRecordDao.save(verifyRecord);
return result;
}
// 通过数据库数据验卡
private BankCardVerifyResult verifyBankCardByLocalData(String userName, String certNum, String bankCardNum, String reservedMobile) {
BankCardVerifyResult result = new BankCardVerifyResult();
result.setIsSuccess(false);
List<BankcardVerifyRecord> successRecords = bankcardVerifyRecordDao.querySuccessResultByFourElements(userName,
certNum, bankCardNum, reservedMobile);
if(successRecords != null && successRecords.size() > 0 && maxEffectiveDays != null) {
BankcardVerifyRecord recentRecord = successRecords.get(0);
result.setBankCode(recentRecord.getBankCode());
result.setBankName(recentRecord.getBankName());
result.setRequestSerialNum(recentRecord.getPlatformOrderNumber());
Date effectiveTime = DateCommonUtils.getAfterDay(recentRecord.getVerificationTime(), maxEffectiveDays);
if(effectiveTime.after(new Date())) {
// 本地验卡通过 并且本地验卡数据的有效截止时间未到
result.setIsSuccess(true);
}
}
return result;
}
private BankCardVerifyResult verifyBankCardByYijifu(String userName, String certNum, String bankCardNum, String reservedMobile) {
BankCardVerifyRequest request = new BankCardVerifyRequest();
request.setPlatformOrderNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF_VB));
request.setCustomerName(userName);
request.setCertNo(certNum);
request.setBankCardNo(bankCardNum);
request.setMobileNo(reservedMobile);
BankCardVerifyResponse response = this.callYjfService(request, BankCardVerifyResponse.class);
BankCardVerifyResult result = new BankCardVerifyResult();
// 只有验证成功
result.setIsSuccess(VerifyCardStatus.VERIFY_CARD_SUCCESS == response.getVerifyCardStatus());
result.setVerificationStatus(response.getVerifyCardStatus() == null ? null : response.getVerifyCardStatus().getCode());
result.setRequestSerialNum(response.getPlatformOrderNum());
if (!result.getIsSuccess()) {
if ("comn_04_0003".equals(response.getErrorCode())) {
result.setFailedMessage("请输入正确的身份证号码");
} else {
result.setFailedMessage(response.getResultMessage());
}
} else {
result.setBankName(response.getBankName());
result.setBankCode(response.getBankCode());
}
return result;
}
/***
* 代扣接口
*
* @param userName 用户真实姓名
* @param certNum 身份证号
* @param bankCardNum 银行卡号
* @param reservedMobile 银行卡预留手机号码
* @param amount 扣款金额
* @param contactInfo 合同信息
*
* @return 是否受理成功
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public DebtResult debtAmount(String userName, String certNum, String bankCardNum, String reservedMobile, Double amount, String contactInfo) {
if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile, contactInfo)) {
throw new IllegalArgumentException("the parameter for verifyBankCard can not be null or empty.");
}
if (null == amount) {
throw new IllegalArgumentException("the debt amount can not be null or empty.");
}
DebtRequest request = new DebtRequest();
request.setPlatformOrderNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF_DM));
request.setCustomerName(userName);
request.setCertNo(certNum);
request.setBankCardNo(bankCardNum);
request.setMobileNo(reservedMobile);
request.setAmount(amount / 100); // 单位从分换算成元
request.setContractInfo(contactInfo);
// 设置通知URL
request.setNotifyUrl(propertiesBean.getDebtNotifyUrl());
YjfResponse response = this.callYjfService(request, YjfResponse.class);
DebtResult result = new DebtResult();
result.setIsSuccess(ResultCodeType.EXECUTE_SUCCESS == response.getResultCodeType() || ResultCodeType.EXECUTE_PROCESSING == response.getResultCodeType());
result.setRequestSerialNum(request.getPlatformOrderNum());
result.setAmount(amount);
if (!result.getIsSuccess()) {
result.setFailedMessage(response.getResultMessage());
}
// 更新扣款信息进入缓存
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(bankCardNum, request.getPlatformOrderNum(), amount,
result.getIsSuccess() ? DebtStatus.PROCESSING: DebtStatus.FAILED));
return result;
}
@Override
public DebtStatus queryDebtStatus(String platformDebtOrderNum, String debtBankcardNum) {
DebtQueryResponse response = this.queryDebtStatusWithYjfResponse(platformDebtOrderNum, debtBankcardNum);
return this.convertDebtQueryResponseToDebtStatus(platformDebtOrderNum, debtBankcardNum, response);
}
@Override
public DebtQueryResponse queryDebtStatusWithYjfResponse(String platformDebtOrderNum, String debtBankcardNum) {
if (StringUtils.isBlank(platformDebtOrderNum) || StringUtils.isBlank(debtBankcardNum)) {
throw new IllegalArgumentException("the parameter for platformDebtOrderNum or debtBankcardNum can not be null or empty.");
}
DebtQueryRequest request = new DebtQueryRequest();
request.setPlatformOrderNum(platformDebtOrderNum);
try {
return this.callYjfService(request, DebtQueryResponse.class);
} catch (Exception e) {
LOG.error("YJF query failed:" + e.getMessage(), e);
return null;
}
}
@Override
public DebtStatus convertDebtQueryResponseToDebtStatus(String platformDebtOrderNum, String debtBankcardNum, DebtQueryResponse response) {
if (StringUtils.isBlank(platformDebtOrderNum) || StringUtils.isBlank(debtBankcardNum)) {
throw new IllegalArgumentException("the parameter for platformDebtOrderNum or debtBankcardNum can not be null or empty.");
}
if (response == null) {
return null;
}
try {
if (ResultCodeType.EXECUTE_SUCCESS == response.getResultCodeType()) {
//将易极付的处理状态映射成扣款状态
DebtStatus newStatus = null;
if (DEBT_PROCESSING_STATUSES.contains(response.getServiceStatus())) {
newStatus = DebtStatus.PROCESSING;
} else if (DEBT_FAILED_STATUSES.contains(response.getServiceStatus())) {
newStatus = DebtStatus.FAILED;
} else {
if ("WITHHOLD_SUCCESS".equals(response.getServiceStatus())) {
newStatus = DebtStatus.CONFIRMED;
} else if ("SETTLE_SUCCESS".equals(response.getServiceStatus())) {
newStatus = DebtStatus.SETTLED;
}
}
if (null == newStatus) {
throw new NotImplementedException("Unknow the process status " + response.getServiceStatus());
} else {
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(debtBankcardNum, platformDebtOrderNum, response.getAmount(), newStatus));
return newStatus;
}
} else if (ResultCodeType.INSTALLMENT_TRANS_ORDER_NO_DATA == response.getResultCodeType()) {//交易数据在支付方无数据
return DebtStatus.FAILED;
}
} catch (Exception e) {
LOG.error("YJF query failed:" + e.getMessage(), e);
}
return null;
}
@Transactional
@Override
public void saveNotification(YjfNotification notification) {
logDao.save(YjfLog.createNotificationLog(notification.getService(), notification.getOrderNo(), ToolUtils.toJsonString(notification)));
LOG.info("persistent Yijifu notification success. ");
}
@Transactional
@Override
public void updateDebtStatusByNotification(DebtNotification debtNotification) {
if (!YjfConstants.SERVICE_CODE_DEBT.equals(debtNotification.getService())) {
LOG.error("The notification: {} does not match the DEBT business. ", debtNotification.toString());
return;
}
String bizSerialNum = debtNotification.getMerchOrderNo();//也即为合并扣款的批次号
YJFDebtProcessStatus processStatus = YJFDebtProcessStatus.codeOf(debtNotification.getServiceStatus());
DebtStatus newDebtStatus = YJFDebtProcessStatus.convertToDebtStatus(processStatus);
// 更新扣款状态到缓存
String repaymentBankcardNum = repaymentRecordService.getRepaymentBankcardByDebtOrder(bizSerialNum);
if (repaymentBankcardNum == null) {
repaymentBankcardNum = paymentOrderService.getBankcardNumByDebtSerialNum(bizSerialNum);
}
if (null == repaymentBankcardNum) {
LOG.error("can not find the payment order or repayment plan by the debt serial num: {}, skip at first", bizSerialNum);
return ;
}
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(repaymentBankcardNum, bizSerialNum,
debtNotification.getTransAmount(), newDebtStatus));
// 根据还款记录的状态更新还款计划的状态- 扣款主要用于服务单支付以及分期还款的支付
if (null != paymentOrderDao.getByTransactionSerial(bizSerialNum)) {
this.updatePaymentOrderDebtStatus(bizSerialNum, newDebtStatus);
} else {
this.updateRepaymentRecordsDebtStatus(bizSerialNum, newDebtStatus, debtNotification.getResultMessage());
}
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void updatePaymentOrderDebtStatus(String debtOrderNum, DebtStatus newDebtStatus) {
PaymentOrder paymentOrder = paymentOrderDao.getByTransactionSerial(debtOrderNum);
if (null != paymentOrder) {
LOG.info("prepare to update payment order for debut order num: {} with status: {}", debtOrderNum, newDebtStatus);
if (paymentOrder.getPaymentStatus() != null && null != newDebtStatus && !newDebtStatus.getCode().equals(paymentOrder.getPaymentStatus())) {
paymentOrder.setPaymentStatus(newDebtStatus.getCode()); // 更新
paymentOrderDao.save(paymentOrder);
// 申请单的状态可重复更新
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {
requisitionServiceFeign.changeRequisitionStatusByPaymentOrder(paymentOrder.getOrderNumber(), RequisitionStatus.WaitingLoan);
} else if (DebtStatus.FAILED == newDebtStatus) {
requisitionServiceFeign.changeRequisitionStatusByPaymentOrder(paymentOrder.getOrderNumber(), RequisitionStatus.FailedPayment);
}
}
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void updateRepaymentRecordsDebtStatus(String debtOrderNum, DebtStatus newDebtStatus, String resultMessage) {
//List<RepaymentRecord> repaymentRecords = repaymentRecordDao.getByRepayBatchNo(debtOrderNum);
List<RepaymentRecord> repaymentRecords = repaymentRecordDao.listByTransactionSerial(debtOrderNum);
if (repaymentRecords.isEmpty()) {
LOG.error("No repayment record match the debt batch order number: {}", debtOrderNum);
return ;
}
Integer customerId = null;
double totalRepayAmount = 0.0;
long totalOverdueInterestAmount = 0L;
Date repayDate = null;
String repayBankNumber = null;
boolean isNeedTryDebtAgain = false; // 是否需要再次发起扣款: 如果是自动还款并且成功, 则继续发起扣款
for (RepaymentRecord repaymentRecord : repaymentRecords) {
LOG.info("prepare to update repayment record {} with status: {}", repaymentRecord.getId(), newDebtStatus);
if (null != newDebtStatus && !StringUtils.equals(newDebtStatus.getCode(), repaymentRecord.getConfirmStatus())) {
//更新支付记录的扣款状态
LOG.info("update repayment record {} status from {} to {}", repaymentRecord.getId(),
repaymentRecord.getConfirmStatus(), newDebtStatus);
repaymentRecord.setConfirmStatus(newDebtStatus.getCode());
// 由于扣款接口中没有支付方的记录号, 暂时也用合并扣款的批次号替代
/*if (StringUtils.isBlank(repaymentRecord.getTransactionSerial())) {
repaymentRecord.setTransactionSerial(debtOrderNum);
}*/
//如果扣款已经成功 或 失败 或已结算,需要更新还款计划的状态
RepaymentPlan repaymentPlan = repaymentRecord.getRepaymentPlan();
//设置发送微信消息的参数
if (customerId == null) {
customerId = repaymentPlan.getCustomerId();
}
if (repayDate == null) {
repayDate = repaymentPlan.getRepayDate();
}
if (StringUtils.isEmpty(repayBankNumber)) {
repayBankNumber = repaymentRecord.getBankAccountNumber();
}
totalRepayAmount += repaymentRecord.getRepayTotalAmount().doubleValue();
totalOverdueInterestAmount += repaymentRecord.getOverdueInterestAmount().longValue();
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {//更新还款计划的状态
if (RefundStatus.HAS_REFUND != repaymentPlan.getRepayStatus()) {
LOG.info("update repayment plan {} status {} to {} by repayment record status {}", repaymentPlan.getId(),
repaymentPlan.getRepayStatus(), RefundStatus.HAS_REFUND, DebtStatus.CONFIRMED);
//更新还款状态及合同状态
repaymentPlanService.updateRepaymentPlanStatusByEvent(repaymentPlan, InstallmentEvent.AutoRefundSuccessEvent);
isNeedTryDebtAgain = true; // 只要是自动还款, 则还可以发起扣款
}
} else if (DebtStatus.FAILED == newDebtStatus) {// 更新还款计划的状态
if (RefundStatus.FAIL_REFUND != repaymentPlan.getRepayStatus()) {
LOG.info("update repayment plan {} status {} to {} by repayment record status {}", repaymentPlan.getId(),
repaymentPlan.getRepayStatus(), RefundStatus.FAIL_REFUND, DebtStatus.FAILED);
//更新还款状态及合同状态
repaymentPlanService.updateRepaymentPlanStatusByEvent(repaymentPlan, InstallmentEvent.AutoRefundFailedEvent);
}
}
repaymentRecord.setUpdateAt(new Date());
repaymentRecordDao.save(repaymentRecord);
LOG.info("update repayment record status success: {}", repaymentRecord.getId());
}
}
//发送通知并不触发事务回滚(捕获异常)
try {
RepaymentPlanEvent repaymentPlanEvent = null;
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {
repaymentPlanEvent = RepaymentPlanRefundEvent.refundSuccessEvent(customerId, totalRepayAmount, repayDate, repayBankNumber);
} else if (DebtStatus.FAILED == newDebtStatus) {
repaymentPlanEvent = RepaymentPlanRefundEvent.refundFailEvent(customerId, totalRepayAmount, repayDate, resultMessage);
}
if (null != repaymentPlanEvent) {
this.applicationContext.publishEvent(repaymentPlanEvent);
LOG.info("代扣状态提醒发送成功");
}
} catch (Exception e) { // 不触发事务回滚
LOG.error("Fail to send yjf payment notification to user", e);
}
try {
//在扣款失败后查看还款计划的状态是否为已逾期,如果为已逾期则发送微信消息给客户
RepaymentPlan samplePlan = repaymentRecords.get(0).getRepaymentPlan();
LOG.info("sample plan is the first debt on today: {}", userDebtRedisService.isFirstDebtOnToday(repaymentRecords.get(0).getBankAccountNumber(), debtOrderNum));
LOG.info("sample plan: {}, repayStatus: {}, new debt status: {}", samplePlan.getId(), samplePlan.getRepayStatus(), newDebtStatus);
if (samplePlan != null && userDebtRedisService.isFirstDebtOnToday(repaymentRecords.get(0).getBankAccountNumber(), debtOrderNum)
&& RefundStatus.OVERDUE == samplePlan.getRepayStatus() && DebtStatus.FAILED == newDebtStatus) { //逾期还款第一次还款失败发送微信消息给用户
LOG.info("prepare to send overdue reminder on plan: {}", samplePlan.getId());
RepaymentPlanOverdueEvent repaymentPlanOverdueEvent = new RepaymentPlanOverdueEvent(samplePlan.getCustomerId(),
samplePlan.getRepayDate(), DateCommonUtils.intervalDays(samplePlan.getRepayDate(), DateCommonUtils.getCurrentDate()),
totalRepayAmount, totalOverdueInterestAmount);
applicationContext.publishEvent(repaymentPlanOverdueEvent);
LOG.info("send overdue reminder success on plan: {}", samplePlan.getId());
}
} catch (Exception e) { // 不触发事务回滚
LOG.error(e.getMessage(), e);
}
LOG.info("Finish update all repayment records status by debt order serial number: {}", debtOrderNum);
// 自动还款成功后可发起下一次还款
if ( !repaymentRecords.get(0).getRepaymentPlan().getManualFlag() && isNeedTryDebtAgain) {
LOG.info("Auto debt for the second debt for customer:" + customerId);
try {
this.tryTheSecondDebt(repaymentRecords.get(0));
} catch (Exception e) {
LOG.error("Failed to finished the second debt for " + e.getMessage(), e);
}
}
}
@Transactional(propagation = Propagation.REQUIRED) //不能开启新事务,如果父层事务对repaymentPlan进行变更, 子事务是查询不到结果的- 脏数据。
@Override
public void tryTheSecondDebt(RepaymentRecord sampleRecord) {
LOG.info("the last repayment success and raise the second repayment...");
if (DateCommonUtils.intervalDays(DateCommonUtils.getCurrentDate(), sampleRecord.getRepaymentPlan().getRepayDate()) == 0) { // 还款日正常还款
LOG.info("start to the second to debt for Repay Day for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
repaymentPlanService.debitForRepayDay(sampleRecord.getRepaymentPlan().getCustomerId());
LOG.info("done to the second to debt for Repay Day for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
} else { // 逾期还款
LOG.info("start to the second to debt for Overdue for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
repaymentPlanService.debitForOverdue(sampleRecord.getRepaymentPlan().getCustomerId());
LOG.info("done to the second to debt for Overdue for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
}
}
private Map<String, String> convertObjectToMap(Object obj) {
String jsonStr = JSON.toJSONString(obj, nullValueFilter, SerializerFeature.WriteEnumUsingToString, SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteNonStringValueAsString);
return (Map<String, String>) JSON.parse(jsonStr);
}
private <R extends YjfRequest, Q extends YjfResponse> Q callYjfService(R request, Class<Q> clazz) {
try {
YjfService serviceCodeAnnation = request.getClass().getAnnotation(YjfService.class);
if (null == serviceCodeAnnation || StringUtils.isBlank(serviceCodeAnnation.name())) {
throw new IllegalStateException(String.format("%s do not have YjfService annotation or name property is empty."));
}
request.setServiceCode(serviceCodeAnnation.name());
request.setPartnerId(propertiesBean.getPartnerId());
request.setPlatformSerialNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF));
Map<String, String> paramMap = this.convertObjectToMap(request);
String responseStr = yjfHttpClient.doPost(propertiesBean.getGatewayUrl(), paramMap, propertiesBean.getPrivateKey());
Q yjfResponse = JSON.parseObject(responseStr, clazz);
if (yjfResponse.getResultCodeType() == ResultCodeType.PARAMETER_ERROR) {
yjfResponse.setResultMessage(this.convertParameterErrorMsg(yjfResponse.getResultMessage()));
}
return yjfResponse;
} catch (Exception e) {
throw new YijifuClientException(String.format("Yijifu Request process failed on service code:%s, request ID:%s, reason: %s",
request.getServiceCode(), request.getPlatformSerialNum(), e.getMessage()), e);
}
}
private String convertParameterErrorMsg(String originalMsg) {
// 原始消息类似于:“失败,参数错误:mobileNo:请传入正确格式的手机号”
String convertedMsg = originalMsg;
if (StringUtils.isNotBlank(originalMsg) && originalMsg.contains(":") && originalMsg.lastIndexOf(":") < originalMsg.length() - 1) {
convertedMsg = originalMsg.substring(originalMsg.lastIndexOf(":") + 1);
}
return convertedMsg;
}
public void queryAndUpdateVerifyBankcardRecord() {
List<BankcardVerifyRecord> verificationUserResults = bankcardVerifyRecordDao.queryByVerificationStatus(VerifyCardStatus.VERIFY_CARD_PROCESSING.getCode());
for (BankcardVerifyRecord record : verificationUserResults) {
QueryBankCardVerifyRequest request = new QueryBankCardVerifyRequest();
request.setPlatformOrderNum(record.getPlatformOrderNumber());
QueryBankCardVerifyResponse response = this.callYjfService(request, QueryBankCardVerifyResponse.class);
if(response != null && response.getIsSuccess()) {
record.setVerificationStatus(VerifyCardStatus.VERIFY_CARD_SUCCESS.getCode());
bankcardVerifyRecordDao.save(record);
} else if(response != null && VerifyCardStatus.VERIFY_CARD_FAIL.equals(response.getVerifyCardStatus())) {
record.setVerificationStatus(VerifyCardStatus.VERIFY_CARD_FAIL.getCode());
record.setRemarks(response.getResultMessage());
bankcardVerifyRecordDao.save(record);
}
}
}
}
|
UTF-8
|
Java
| 29,697 |
java
|
YjfPaymentServiceImpl.java
|
Java
|
[
{
"context": "l.Map;\n\n/**\n * @Description: 易极付支付接口实现\n * @Author: Yong Li\n * @Date: 2017/12/8 17:20\n */\n@Service\npublic cla",
"end": 2440,
"score": 0.999029815196991,
"start": 2433,
"tag": "NAME",
"value": "Yong Li"
},
{
"context": "身份证号 银行卡号 银行卡预留手机号码做四要素+短信验证\n *\n * @param userName 用户真实姓名\n * @param certNum 身份证号\n * @param b",
"end": 4800,
"score": 0.8867287635803223,
"start": 4792,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "号 银行卡预留手机号码做四要素+短信验证\n *\n * @param userName 用户真实姓名\n * @param certNum 身份证号\n * @param bankCard",
"end": 4807,
"score": 0.6377472281455994,
"start": 4801,
"tag": "USERNAME",
"value": "用户真实姓名"
},
{
"context": " public BankCardVerifyResult verifyBankCard(String userName, String certNum, String bankCardNum, String reser",
"end": 4975,
"score": 0.9815950989723206,
"start": 4967,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "vedMobile) {\n if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile)) {\n ",
"end": 5083,
"score": 0.9741175174713135,
"start": 5075,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "ifyResult result = this.verifyBankCardByLocalData(userName, certNum, bankCardNum, reservedMobile);\n i",
"end": 5323,
"score": 0.9809781312942505,
"start": 5315,
"tag": "USERNAME",
"value": "userName"
},
{
"context": " }\n\n result = this.verifyBankCardByYijifu(userName, certNum, bankCardNum, reservedMobile);\n B",
"end": 5491,
"score": 0.9893553853034973,
"start": 5483,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "dVerifyRecord();\n verifyRecord.setUserName(userName);\n verifyRecord.setIdNumber(certNum);\n ",
"end": 5645,
"score": 0.9957627654075623,
"start": 5637,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "kCardVerifyResult verifyBankCardByLocalData(String userName, String certNum, String bankCardNum, String reser",
"end": 6351,
"score": 0.996302604675293,
"start": 6343,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "dVerifyRecordDao.querySuccessResultByFourElements(userName,\n certNum, bankCardNum, reservedMo",
"end": 6633,
"score": 0.9809070229530334,
"start": 6625,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "BankCardVerifyResult verifyBankCardByYijifu(String userName, String certNum, String bankCardNum, String reser",
"end": 7432,
"score": 0.997384250164032,
"start": 7424,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "ategory.YJF_VB));\n request.setCustomerName(userName);\n request.setCertNo(certNum);\n req",
"end": 7704,
"score": 0.9982683658599854,
"start": 7696,
"tag": "USERNAME",
"value": "userName"
},
{
"context": ";\n }\n\n /***\n * 代扣接口\n *\n * @param userName 用户真实姓名\n * @param certNum 身份证号\n * @param b",
"end": 8802,
"score": 0.9915004968643188,
"start": 8794,
"tag": "USERNAME",
"value": "userName"
},
{
"context": " /***\n * 代扣接口\n *\n * @param userName 用户真实姓名\n * @param certNum 身份证号\n * @param bankCard",
"end": 8809,
"score": 0.9940034747123718,
"start": 8803,
"tag": "USERNAME",
"value": "用户真实姓名"
},
{
"context": "UIRES_NEW)\n public DebtResult debtAmount(String userName, String certNum, String bankCardNum, String reser",
"end": 9108,
"score": 0.9944186210632324,
"start": 9100,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "ntactInfo) {\n if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile, contactInf",
"end": 9251,
"score": 0.9942395687103271,
"start": 9243,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "ategory.YJF_DM));\n request.setCustomerName(userName);\n request.setCertNo(certNum);\n req",
"end": 9749,
"score": 0.9966907501220703,
"start": 9741,
"tag": "USERNAME",
"value": "userName"
}
] | null |
[] |
package com.fintech.insurance.micro.finance.service.yjf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.fintech.insurance.commons.constants.YjfConstants;
import com.fintech.insurance.commons.enums.*;
import com.fintech.insurance.commons.utils.DateCommonUtils;
import com.fintech.insurance.commons.utils.ToolUtils;
import com.fintech.insurance.components.cache.RedisSequenceFactory;
import com.fintech.insurance.micro.dto.finance.BankCardVerifyResult;
import com.fintech.insurance.micro.dto.finance.DebtNotification;
import com.fintech.insurance.micro.dto.finance.DebtResult;
import com.fintech.insurance.micro.dto.finance.YjfNotification;
import com.fintech.insurance.micro.feign.biz.RequisitionServiceFeign;
import com.fintech.insurance.micro.finance.event.RepaymentPlanEvent;
import com.fintech.insurance.micro.finance.event.RepaymentPlanOverdueEvent;
import com.fintech.insurance.micro.finance.event.RepaymentPlanRefundEvent;
import com.fintech.insurance.micro.finance.model.UserDebtInfoRedisVO;
import com.fintech.insurance.micro.finance.persist.dao.*;
import com.fintech.insurance.micro.finance.persist.entity.*;
import com.fintech.insurance.micro.finance.service.*;
import com.fintech.insurance.micro.finance.service.yjf.enums.ResultCodeType;
import com.fintech.insurance.micro.finance.service.yjf.enums.VerifyCardStatus;
import com.fintech.insurance.micro.finance.service.yjf.enums.YJFDebtProcessStatus;
import com.fintech.insurance.micro.finance.service.yjf.exception.YijifuClientException;
import com.fintech.insurance.micro.finance.service.yjf.model.*;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Description: 易极付支付接口实现
* @Author: <NAME>
* @Date: 2017/12/8 17:20
*/
@Service
public class YjfPaymentServiceImpl implements PaymentService , ApplicationContextAware {
private static final Logger LOG = LoggerFactory.getLogger(YjfPaymentServiceImpl.class);
@Value("${fintech.common.verificationEffectiveDays}")
private Integer maxEffectiveDays;
@Autowired
private RepaymentPlanService repaymentPlanService;
@Autowired
private PaymentOrderService paymentOrderService;
@Autowired
private PaymentOrderDao paymentOrderDao;
@Autowired
private RequisitionServiceFeign requisitionServiceFeign;
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
private static final List<String> DEBT_PROCESSING_STATUSES = new ArrayList<String>();
private static final List<String> DEBT_FAILED_STATUSES = new ArrayList<String>();
static {
DEBT_PROCESSING_STATUSES.add("VERIFY_CARD_DEALING");
DEBT_PROCESSING_STATUSES.add("CHECK_NEEDED");
DEBT_PROCESSING_STATUSES.add("INIT");
DEBT_PROCESSING_STATUSES.add("WITHHOLD_DEALING");
DEBT_FAILED_STATUSES.add("VERIFY_CARD_FAIL");
DEBT_FAILED_STATUSES.add("CHECK_REJECT");
DEBT_FAILED_STATUSES.add("WITHHOLD_FAIL");
}
@Autowired
private RedisSequenceFactory redisSequenceFactory;
@Autowired
private YjfLogDao logDao;
@Autowired
private YjfHttpClient yjfHttpClient;
@Autowired
private YjfPropertiesBean propertiesBean;
@Autowired
private RepaymentRecordDao repaymentRecordDao;
@Autowired
private RepaymentPlanDao repaymentPlanDao;
@Autowired
private UserDebtRedisService userDebtRedisService;
@Autowired
private RepaymentRecordService repaymentRecordService;
@Autowired
private BankcardVerifyRecordDao bankcardVerifyRecordDao;
private static ValueFilter nullValueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (null == value) {
return "";
}
return value.toString();
}
};
/**
* 根据用户的姓名 身份证号 银行卡号 银行卡预留手机号码做四要素+短信验证
*
* @param userName 用户真实姓名
* @param certNum 身份证号
* @param bankCardNum 银行卡号
* @param reservedMobile 银行卡预留手机号码
*/
public BankCardVerifyResult verifyBankCard(String userName, String certNum, String bankCardNum, String reservedMobile) {
if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile)) {
throw new IllegalArgumentException("the parameter for verifyBankCard can not be null or empty.");
}
BankCardVerifyResult result = this.verifyBankCardByLocalData(userName, certNum, bankCardNum, reservedMobile);
if(result.getIsSuccess()) {
return result;
}
result = this.verifyBankCardByYijifu(userName, certNum, bankCardNum, reservedMobile);
BankcardVerifyRecord verifyRecord = new BankcardVerifyRecord();
verifyRecord.setUserName(userName);
verifyRecord.setIdNumber(certNum);
verifyRecord.setBankCardNumber(bankCardNum);
verifyRecord.setReservedMobile(reservedMobile);
verifyRecord.setBankCode(result.getBankCode());
verifyRecord.setBankName(result.getBankName());
verifyRecord.setPlatformOrderNumber(result.getRequestSerialNum());
verifyRecord.setVerificationStatus(result.getVerificationStatus());
verifyRecord.setVerificationTime(new Date());
verifyRecord.setRemarks(result.getFailedMessage());
bankcardVerifyRecordDao.save(verifyRecord);
return result;
}
// 通过数据库数据验卡
private BankCardVerifyResult verifyBankCardByLocalData(String userName, String certNum, String bankCardNum, String reservedMobile) {
BankCardVerifyResult result = new BankCardVerifyResult();
result.setIsSuccess(false);
List<BankcardVerifyRecord> successRecords = bankcardVerifyRecordDao.querySuccessResultByFourElements(userName,
certNum, bankCardNum, reservedMobile);
if(successRecords != null && successRecords.size() > 0 && maxEffectiveDays != null) {
BankcardVerifyRecord recentRecord = successRecords.get(0);
result.setBankCode(recentRecord.getBankCode());
result.setBankName(recentRecord.getBankName());
result.setRequestSerialNum(recentRecord.getPlatformOrderNumber());
Date effectiveTime = DateCommonUtils.getAfterDay(recentRecord.getVerificationTime(), maxEffectiveDays);
if(effectiveTime.after(new Date())) {
// 本地验卡通过 并且本地验卡数据的有效截止时间未到
result.setIsSuccess(true);
}
}
return result;
}
private BankCardVerifyResult verifyBankCardByYijifu(String userName, String certNum, String bankCardNum, String reservedMobile) {
BankCardVerifyRequest request = new BankCardVerifyRequest();
request.setPlatformOrderNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF_VB));
request.setCustomerName(userName);
request.setCertNo(certNum);
request.setBankCardNo(bankCardNum);
request.setMobileNo(reservedMobile);
BankCardVerifyResponse response = this.callYjfService(request, BankCardVerifyResponse.class);
BankCardVerifyResult result = new BankCardVerifyResult();
// 只有验证成功
result.setIsSuccess(VerifyCardStatus.VERIFY_CARD_SUCCESS == response.getVerifyCardStatus());
result.setVerificationStatus(response.getVerifyCardStatus() == null ? null : response.getVerifyCardStatus().getCode());
result.setRequestSerialNum(response.getPlatformOrderNum());
if (!result.getIsSuccess()) {
if ("comn_04_0003".equals(response.getErrorCode())) {
result.setFailedMessage("请输入正确的身份证号码");
} else {
result.setFailedMessage(response.getResultMessage());
}
} else {
result.setBankName(response.getBankName());
result.setBankCode(response.getBankCode());
}
return result;
}
/***
* 代扣接口
*
* @param userName 用户真实姓名
* @param certNum 身份证号
* @param bankCardNum 银行卡号
* @param reservedMobile 银行卡预留手机号码
* @param amount 扣款金额
* @param contactInfo 合同信息
*
* @return 是否受理成功
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public DebtResult debtAmount(String userName, String certNum, String bankCardNum, String reservedMobile, Double amount, String contactInfo) {
if (!StringUtils.isNoneBlank(userName, certNum, bankCardNum, reservedMobile, contactInfo)) {
throw new IllegalArgumentException("the parameter for verifyBankCard can not be null or empty.");
}
if (null == amount) {
throw new IllegalArgumentException("the debt amount can not be null or empty.");
}
DebtRequest request = new DebtRequest();
request.setPlatformOrderNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF_DM));
request.setCustomerName(userName);
request.setCertNo(certNum);
request.setBankCardNo(bankCardNum);
request.setMobileNo(reservedMobile);
request.setAmount(amount / 100); // 单位从分换算成元
request.setContractInfo(contactInfo);
// 设置通知URL
request.setNotifyUrl(propertiesBean.getDebtNotifyUrl());
YjfResponse response = this.callYjfService(request, YjfResponse.class);
DebtResult result = new DebtResult();
result.setIsSuccess(ResultCodeType.EXECUTE_SUCCESS == response.getResultCodeType() || ResultCodeType.EXECUTE_PROCESSING == response.getResultCodeType());
result.setRequestSerialNum(request.getPlatformOrderNum());
result.setAmount(amount);
if (!result.getIsSuccess()) {
result.setFailedMessage(response.getResultMessage());
}
// 更新扣款信息进入缓存
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(bankCardNum, request.getPlatformOrderNum(), amount,
result.getIsSuccess() ? DebtStatus.PROCESSING: DebtStatus.FAILED));
return result;
}
@Override
public DebtStatus queryDebtStatus(String platformDebtOrderNum, String debtBankcardNum) {
DebtQueryResponse response = this.queryDebtStatusWithYjfResponse(platformDebtOrderNum, debtBankcardNum);
return this.convertDebtQueryResponseToDebtStatus(platformDebtOrderNum, debtBankcardNum, response);
}
@Override
public DebtQueryResponse queryDebtStatusWithYjfResponse(String platformDebtOrderNum, String debtBankcardNum) {
if (StringUtils.isBlank(platformDebtOrderNum) || StringUtils.isBlank(debtBankcardNum)) {
throw new IllegalArgumentException("the parameter for platformDebtOrderNum or debtBankcardNum can not be null or empty.");
}
DebtQueryRequest request = new DebtQueryRequest();
request.setPlatformOrderNum(platformDebtOrderNum);
try {
return this.callYjfService(request, DebtQueryResponse.class);
} catch (Exception e) {
LOG.error("YJF query failed:" + e.getMessage(), e);
return null;
}
}
@Override
public DebtStatus convertDebtQueryResponseToDebtStatus(String platformDebtOrderNum, String debtBankcardNum, DebtQueryResponse response) {
if (StringUtils.isBlank(platformDebtOrderNum) || StringUtils.isBlank(debtBankcardNum)) {
throw new IllegalArgumentException("the parameter for platformDebtOrderNum or debtBankcardNum can not be null or empty.");
}
if (response == null) {
return null;
}
try {
if (ResultCodeType.EXECUTE_SUCCESS == response.getResultCodeType()) {
//将易极付的处理状态映射成扣款状态
DebtStatus newStatus = null;
if (DEBT_PROCESSING_STATUSES.contains(response.getServiceStatus())) {
newStatus = DebtStatus.PROCESSING;
} else if (DEBT_FAILED_STATUSES.contains(response.getServiceStatus())) {
newStatus = DebtStatus.FAILED;
} else {
if ("WITHHOLD_SUCCESS".equals(response.getServiceStatus())) {
newStatus = DebtStatus.CONFIRMED;
} else if ("SETTLE_SUCCESS".equals(response.getServiceStatus())) {
newStatus = DebtStatus.SETTLED;
}
}
if (null == newStatus) {
throw new NotImplementedException("Unknow the process status " + response.getServiceStatus());
} else {
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(debtBankcardNum, platformDebtOrderNum, response.getAmount(), newStatus));
return newStatus;
}
} else if (ResultCodeType.INSTALLMENT_TRANS_ORDER_NO_DATA == response.getResultCodeType()) {//交易数据在支付方无数据
return DebtStatus.FAILED;
}
} catch (Exception e) {
LOG.error("YJF query failed:" + e.getMessage(), e);
}
return null;
}
@Transactional
@Override
public void saveNotification(YjfNotification notification) {
logDao.save(YjfLog.createNotificationLog(notification.getService(), notification.getOrderNo(), ToolUtils.toJsonString(notification)));
LOG.info("persistent Yijifu notification success. ");
}
@Transactional
@Override
public void updateDebtStatusByNotification(DebtNotification debtNotification) {
if (!YjfConstants.SERVICE_CODE_DEBT.equals(debtNotification.getService())) {
LOG.error("The notification: {} does not match the DEBT business. ", debtNotification.toString());
return;
}
String bizSerialNum = debtNotification.getMerchOrderNo();//也即为合并扣款的批次号
YJFDebtProcessStatus processStatus = YJFDebtProcessStatus.codeOf(debtNotification.getServiceStatus());
DebtStatus newDebtStatus = YJFDebtProcessStatus.convertToDebtStatus(processStatus);
// 更新扣款状态到缓存
String repaymentBankcardNum = repaymentRecordService.getRepaymentBankcardByDebtOrder(bizSerialNum);
if (repaymentBankcardNum == null) {
repaymentBankcardNum = paymentOrderService.getBankcardNumByDebtSerialNum(bizSerialNum);
}
if (null == repaymentBankcardNum) {
LOG.error("can not find the payment order or repayment plan by the debt serial num: {}, skip at first", bizSerialNum);
return ;
}
userDebtRedisService.saveOrUpdate(new UserDebtInfoRedisVO(repaymentBankcardNum, bizSerialNum,
debtNotification.getTransAmount(), newDebtStatus));
// 根据还款记录的状态更新还款计划的状态- 扣款主要用于服务单支付以及分期还款的支付
if (null != paymentOrderDao.getByTransactionSerial(bizSerialNum)) {
this.updatePaymentOrderDebtStatus(bizSerialNum, newDebtStatus);
} else {
this.updateRepaymentRecordsDebtStatus(bizSerialNum, newDebtStatus, debtNotification.getResultMessage());
}
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void updatePaymentOrderDebtStatus(String debtOrderNum, DebtStatus newDebtStatus) {
PaymentOrder paymentOrder = paymentOrderDao.getByTransactionSerial(debtOrderNum);
if (null != paymentOrder) {
LOG.info("prepare to update payment order for debut order num: {} with status: {}", debtOrderNum, newDebtStatus);
if (paymentOrder.getPaymentStatus() != null && null != newDebtStatus && !newDebtStatus.getCode().equals(paymentOrder.getPaymentStatus())) {
paymentOrder.setPaymentStatus(newDebtStatus.getCode()); // 更新
paymentOrderDao.save(paymentOrder);
// 申请单的状态可重复更新
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {
requisitionServiceFeign.changeRequisitionStatusByPaymentOrder(paymentOrder.getOrderNumber(), RequisitionStatus.WaitingLoan);
} else if (DebtStatus.FAILED == newDebtStatus) {
requisitionServiceFeign.changeRequisitionStatusByPaymentOrder(paymentOrder.getOrderNumber(), RequisitionStatus.FailedPayment);
}
}
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void updateRepaymentRecordsDebtStatus(String debtOrderNum, DebtStatus newDebtStatus, String resultMessage) {
//List<RepaymentRecord> repaymentRecords = repaymentRecordDao.getByRepayBatchNo(debtOrderNum);
List<RepaymentRecord> repaymentRecords = repaymentRecordDao.listByTransactionSerial(debtOrderNum);
if (repaymentRecords.isEmpty()) {
LOG.error("No repayment record match the debt batch order number: {}", debtOrderNum);
return ;
}
Integer customerId = null;
double totalRepayAmount = 0.0;
long totalOverdueInterestAmount = 0L;
Date repayDate = null;
String repayBankNumber = null;
boolean isNeedTryDebtAgain = false; // 是否需要再次发起扣款: 如果是自动还款并且成功, 则继续发起扣款
for (RepaymentRecord repaymentRecord : repaymentRecords) {
LOG.info("prepare to update repayment record {} with status: {}", repaymentRecord.getId(), newDebtStatus);
if (null != newDebtStatus && !StringUtils.equals(newDebtStatus.getCode(), repaymentRecord.getConfirmStatus())) {
//更新支付记录的扣款状态
LOG.info("update repayment record {} status from {} to {}", repaymentRecord.getId(),
repaymentRecord.getConfirmStatus(), newDebtStatus);
repaymentRecord.setConfirmStatus(newDebtStatus.getCode());
// 由于扣款接口中没有支付方的记录号, 暂时也用合并扣款的批次号替代
/*if (StringUtils.isBlank(repaymentRecord.getTransactionSerial())) {
repaymentRecord.setTransactionSerial(debtOrderNum);
}*/
//如果扣款已经成功 或 失败 或已结算,需要更新还款计划的状态
RepaymentPlan repaymentPlan = repaymentRecord.getRepaymentPlan();
//设置发送微信消息的参数
if (customerId == null) {
customerId = repaymentPlan.getCustomerId();
}
if (repayDate == null) {
repayDate = repaymentPlan.getRepayDate();
}
if (StringUtils.isEmpty(repayBankNumber)) {
repayBankNumber = repaymentRecord.getBankAccountNumber();
}
totalRepayAmount += repaymentRecord.getRepayTotalAmount().doubleValue();
totalOverdueInterestAmount += repaymentRecord.getOverdueInterestAmount().longValue();
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {//更新还款计划的状态
if (RefundStatus.HAS_REFUND != repaymentPlan.getRepayStatus()) {
LOG.info("update repayment plan {} status {} to {} by repayment record status {}", repaymentPlan.getId(),
repaymentPlan.getRepayStatus(), RefundStatus.HAS_REFUND, DebtStatus.CONFIRMED);
//更新还款状态及合同状态
repaymentPlanService.updateRepaymentPlanStatusByEvent(repaymentPlan, InstallmentEvent.AutoRefundSuccessEvent);
isNeedTryDebtAgain = true; // 只要是自动还款, 则还可以发起扣款
}
} else if (DebtStatus.FAILED == newDebtStatus) {// 更新还款计划的状态
if (RefundStatus.FAIL_REFUND != repaymentPlan.getRepayStatus()) {
LOG.info("update repayment plan {} status {} to {} by repayment record status {}", repaymentPlan.getId(),
repaymentPlan.getRepayStatus(), RefundStatus.FAIL_REFUND, DebtStatus.FAILED);
//更新还款状态及合同状态
repaymentPlanService.updateRepaymentPlanStatusByEvent(repaymentPlan, InstallmentEvent.AutoRefundFailedEvent);
}
}
repaymentRecord.setUpdateAt(new Date());
repaymentRecordDao.save(repaymentRecord);
LOG.info("update repayment record status success: {}", repaymentRecord.getId());
}
}
//发送通知并不触发事务回滚(捕获异常)
try {
RepaymentPlanEvent repaymentPlanEvent = null;
if (DebtStatus.CONFIRMED == newDebtStatus || DebtStatus.SETTLED == newDebtStatus) {
repaymentPlanEvent = RepaymentPlanRefundEvent.refundSuccessEvent(customerId, totalRepayAmount, repayDate, repayBankNumber);
} else if (DebtStatus.FAILED == newDebtStatus) {
repaymentPlanEvent = RepaymentPlanRefundEvent.refundFailEvent(customerId, totalRepayAmount, repayDate, resultMessage);
}
if (null != repaymentPlanEvent) {
this.applicationContext.publishEvent(repaymentPlanEvent);
LOG.info("代扣状态提醒发送成功");
}
} catch (Exception e) { // 不触发事务回滚
LOG.error("Fail to send yjf payment notification to user", e);
}
try {
//在扣款失败后查看还款计划的状态是否为已逾期,如果为已逾期则发送微信消息给客户
RepaymentPlan samplePlan = repaymentRecords.get(0).getRepaymentPlan();
LOG.info("sample plan is the first debt on today: {}", userDebtRedisService.isFirstDebtOnToday(repaymentRecords.get(0).getBankAccountNumber(), debtOrderNum));
LOG.info("sample plan: {}, repayStatus: {}, new debt status: {}", samplePlan.getId(), samplePlan.getRepayStatus(), newDebtStatus);
if (samplePlan != null && userDebtRedisService.isFirstDebtOnToday(repaymentRecords.get(0).getBankAccountNumber(), debtOrderNum)
&& RefundStatus.OVERDUE == samplePlan.getRepayStatus() && DebtStatus.FAILED == newDebtStatus) { //逾期还款第一次还款失败发送微信消息给用户
LOG.info("prepare to send overdue reminder on plan: {}", samplePlan.getId());
RepaymentPlanOverdueEvent repaymentPlanOverdueEvent = new RepaymentPlanOverdueEvent(samplePlan.getCustomerId(),
samplePlan.getRepayDate(), DateCommonUtils.intervalDays(samplePlan.getRepayDate(), DateCommonUtils.getCurrentDate()),
totalRepayAmount, totalOverdueInterestAmount);
applicationContext.publishEvent(repaymentPlanOverdueEvent);
LOG.info("send overdue reminder success on plan: {}", samplePlan.getId());
}
} catch (Exception e) { // 不触发事务回滚
LOG.error(e.getMessage(), e);
}
LOG.info("Finish update all repayment records status by debt order serial number: {}", debtOrderNum);
// 自动还款成功后可发起下一次还款
if ( !repaymentRecords.get(0).getRepaymentPlan().getManualFlag() && isNeedTryDebtAgain) {
LOG.info("Auto debt for the second debt for customer:" + customerId);
try {
this.tryTheSecondDebt(repaymentRecords.get(0));
} catch (Exception e) {
LOG.error("Failed to finished the second debt for " + e.getMessage(), e);
}
}
}
@Transactional(propagation = Propagation.REQUIRED) //不能开启新事务,如果父层事务对repaymentPlan进行变更, 子事务是查询不到结果的- 脏数据。
@Override
public void tryTheSecondDebt(RepaymentRecord sampleRecord) {
LOG.info("the last repayment success and raise the second repayment...");
if (DateCommonUtils.intervalDays(DateCommonUtils.getCurrentDate(), sampleRecord.getRepaymentPlan().getRepayDate()) == 0) { // 还款日正常还款
LOG.info("start to the second to debt for Repay Day for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
repaymentPlanService.debitForRepayDay(sampleRecord.getRepaymentPlan().getCustomerId());
LOG.info("done to the second to debt for Repay Day for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
} else { // 逾期还款
LOG.info("start to the second to debt for Overdue for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
repaymentPlanService.debitForOverdue(sampleRecord.getRepaymentPlan().getCustomerId());
LOG.info("done to the second to debt for Overdue for customer id:" + sampleRecord.getRepaymentPlan().getCustomerId());
}
}
private Map<String, String> convertObjectToMap(Object obj) {
String jsonStr = JSON.toJSONString(obj, nullValueFilter, SerializerFeature.WriteEnumUsingToString, SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteNonStringValueAsString);
return (Map<String, String>) JSON.parse(jsonStr);
}
private <R extends YjfRequest, Q extends YjfResponse> Q callYjfService(R request, Class<Q> clazz) {
try {
YjfService serviceCodeAnnation = request.getClass().getAnnotation(YjfService.class);
if (null == serviceCodeAnnation || StringUtils.isBlank(serviceCodeAnnation.name())) {
throw new IllegalStateException(String.format("%s do not have YjfService annotation or name property is empty."));
}
request.setServiceCode(serviceCodeAnnation.name());
request.setPartnerId(propertiesBean.getPartnerId());
request.setPlatformSerialNum(redisSequenceFactory.generateSerialNumber(BizCategory.YJF));
Map<String, String> paramMap = this.convertObjectToMap(request);
String responseStr = yjfHttpClient.doPost(propertiesBean.getGatewayUrl(), paramMap, propertiesBean.getPrivateKey());
Q yjfResponse = JSON.parseObject(responseStr, clazz);
if (yjfResponse.getResultCodeType() == ResultCodeType.PARAMETER_ERROR) {
yjfResponse.setResultMessage(this.convertParameterErrorMsg(yjfResponse.getResultMessage()));
}
return yjfResponse;
} catch (Exception e) {
throw new YijifuClientException(String.format("Yijifu Request process failed on service code:%s, request ID:%s, reason: %s",
request.getServiceCode(), request.getPlatformSerialNum(), e.getMessage()), e);
}
}
private String convertParameterErrorMsg(String originalMsg) {
// 原始消息类似于:“失败,参数错误:mobileNo:请传入正确格式的手机号”
String convertedMsg = originalMsg;
if (StringUtils.isNotBlank(originalMsg) && originalMsg.contains(":") && originalMsg.lastIndexOf(":") < originalMsg.length() - 1) {
convertedMsg = originalMsg.substring(originalMsg.lastIndexOf(":") + 1);
}
return convertedMsg;
}
public void queryAndUpdateVerifyBankcardRecord() {
List<BankcardVerifyRecord> verificationUserResults = bankcardVerifyRecordDao.queryByVerificationStatus(VerifyCardStatus.VERIFY_CARD_PROCESSING.getCode());
for (BankcardVerifyRecord record : verificationUserResults) {
QueryBankCardVerifyRequest request = new QueryBankCardVerifyRequest();
request.setPlatformOrderNum(record.getPlatformOrderNumber());
QueryBankCardVerifyResponse response = this.callYjfService(request, QueryBankCardVerifyResponse.class);
if(response != null && response.getIsSuccess()) {
record.setVerificationStatus(VerifyCardStatus.VERIFY_CARD_SUCCESS.getCode());
bankcardVerifyRecordDao.save(record);
} else if(response != null && VerifyCardStatus.VERIFY_CARD_FAIL.equals(response.getVerifyCardStatus())) {
record.setVerificationStatus(VerifyCardStatus.VERIFY_CARD_FAIL.getCode());
record.setRemarks(response.getResultMessage());
bankcardVerifyRecordDao.save(record);
}
}
}
}
| 29,696 | 0.684632 | 0.683332 | 566 | 49.252651 | 40.861588 | 170 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.706714 | false | false |
10
|
8f5b1f1515624007e8f2edf0417d0a8cebeb0a79
| 20,916,490,740,598 |
ba9a356ed42d42931a66506fbbe83ef387e0b23b
|
/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADNameSampleStream.java
|
ab5b54f6622f8bbe38b7f4c55ccab71782d9e3c0
|
[
"Apache-2.0",
"MIT",
"BSD-3-Clause"
] |
permissive
|
apache/opennlp
|
https://github.com/apache/opennlp
|
9285e775da528f806621815af87bac2187e47bd6
|
9dc0131b4ed3d28364e7e7525c5b73e979953f6c
|
refs/heads/main
| 2023-08-31T23:09:12.767000 | 2023-08-27T17:48:36 | 2023-08-28T06:25:55 | 2,740,148 | 1,330 | 615 |
Apache-2.0
| false | 2023-09-14T14:47:44 | 2011-11-09T08:00:09 | 2023-09-10T14:30:37 | 2023-09-14T14:47:42 | 16,412 | 1,276 | 430 | 6 |
Java
| false | false |
/*
* 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 opennlp.tools.formats.ad;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import opennlp.tools.commons.Internal;
import opennlp.tools.formats.ad.ADSentenceStream.Sentence;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.Leaf;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.Node;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.TreeElement;
import opennlp.tools.namefind.NameSample;
import opennlp.tools.util.InputStreamFactory;
import opennlp.tools.util.ObjectStream;
import opennlp.tools.util.PlainTextByLineStream;
import opennlp.tools.util.Span;
/**
* Parser for Floresta Sita(c)tica Arvores Deitadas corpus, output to for the
* Portuguese NER training.
* <p>
* The data contains four named entity types: Person, Organization, Group,
* Place, Event, ArtProd, Abstract, Thing, Time and Numeric.<br>
* <p>
* Data can be found on
* <a href="http://www.linguateca.pt/floresta/corpus.html">this web site</a>.
*
* <p>
* Information about the format:<br>
* Susana Afonso.
* <a href="http://www.linguateca.pt/documentos/Afonso2006ArvoresDeitadas.pdf">
* "Árvores deitadas: Descrição do formato e das opções de análise na Floresta Sintáctica"</a>.
* <br>
* 12 de Fevereiro de 2006.
* <p>
* Detailed info about the
* <a href="http://beta.visl.sdu.dk/visl/pt/info/portsymbol.html#semtags_names">NER tagset</a>.
* <p>
* <b>Note:</b>
* Do not use this class, internal use only!
*/
@Internal
public class ADNameSampleStream implements ObjectStream<NameSample> {
/*
* Pattern of a NER tag in Arvores Deitadas
*/
private static final Pattern TAG_PATTERN = Pattern.compile("<(NER:)?(.*?)>");
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");
private static final Pattern UNDERLINE_PATTERN = Pattern.compile("[_]+");
private static final Pattern HYPHEN_PATTERN =
Pattern.compile("((\\p{L}+)-$)|(^-(\\p{L}+)(.*))|((\\p{L}+)-(\\p{L}+)(.*))");
private static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("^[\\p{L}\\p{Nd}]+$");
/*
* Map to the Arvores Deitadas types to our types. It is read-only.
*/
private static final Map<String, String> HAREM;
static {
Map<String, String> harem = new HashMap<>();
final String person = "person";
harem.put("hum", person);
harem.put("official", person);
harem.put("member", person);
final String organization = "organization";
harem.put("admin", organization);
harem.put("org", organization);
harem.put("inst", organization);
harem.put("media", organization);
harem.put("party", organization);
harem.put("suborg", organization);
final String group = "group";
harem.put("groupind", group);
harem.put("groupofficial", group);
final String place = "place";
harem.put("top", place);
harem.put("civ", place);
harem.put("address", place);
harem.put("site", place);
harem.put("virtual", place);
harem.put("astro", place);
final String event = "event";
harem.put("occ", event);
harem.put("event", event);
harem.put("history", event);
final String artprod = "artprod";
harem.put("tit", artprod);
harem.put("pub", artprod);
harem.put("product", artprod);
harem.put("V", artprod);
harem.put("artwork", artprod);
final String _abstract = "abstract";
harem.put("brand", _abstract);
harem.put("genre", _abstract);
harem.put("school", _abstract);
harem.put("idea", _abstract);
harem.put("plan", _abstract);
harem.put("author", _abstract);
harem.put("absname", _abstract);
harem.put("disease", _abstract);
final String thing = "thing";
harem.put("object", thing);
harem.put("common", thing);
harem.put("mat", thing);
harem.put("class", thing);
harem.put("plant", thing);
harem.put("currency", thing);
final String time = "time";
harem.put("date", time);
harem.put("hour", time);
harem.put("period", time);
harem.put("cyclic", time);
final String numeric = "numeric";
harem.put("quantity", numeric);
harem.put("prednum", numeric);
harem.put("currency", numeric);
HAREM = Collections.unmodifiableMap(harem);
}
private final ObjectStream<ADSentenceStream.Sentence> adSentenceStream;
/*
* To keep the last left contraction part
*/
private String leftContractionPart = null;
private final boolean splitHyphenatedTokens;
/**
* Initializes a new {@link ADNameSampleStream} stream from a {@link ObjectStream<String>},
* that could be a {@link PlainTextByLineStream} object.
*
* @param lineStream An {@link ObjectStream<String>} as input.
* @param splitHyphenatedTokens If {@code true} hyphenated tokens will be separated:
* "carros-monstro" > "carros" "-" "monstro".
*/
public ADNameSampleStream(ObjectStream<String> lineStream, boolean splitHyphenatedTokens) {
this.adSentenceStream = new ADSentenceStream(lineStream);
this.splitHyphenatedTokens = splitHyphenatedTokens;
}
/**
* Initializes a new {@link ADNameSampleStream} from an {@link InputStreamFactory}
*
* @param in The Corpus {@link InputStreamFactory}.
* @param charsetName The {@link java.nio.charset.Charset charset} to use
* for reading of the corpus.
* @param splitHyphenatedTokens If {@code true} hyphenated tokens will be separated:
* "carros-monstro" > "carros" "-" "monstro".
*/
@Deprecated
public ADNameSampleStream(InputStreamFactory in, String charsetName,
boolean splitHyphenatedTokens) throws IOException {
this(new PlainTextByLineStream(in, charsetName), splitHyphenatedTokens);
}
private int textID = -1;
@Override
public NameSample read() throws IOException {
Sentence paragraph;
// we should look for text here.
if ((paragraph = this.adSentenceStream.read()) != null) {
int currentTextID = getTextID(paragraph);
boolean clearData = false;
if (currentTextID != textID) {
clearData = true;
textID = currentTextID;
}
Node root = paragraph.getRoot();
List<String> sentence = new ArrayList<>();
List<Span> names = new ArrayList<>();
process(root, sentence, names);
return new NameSample(sentence.toArray(new String[0]),
names.toArray(new Span[0]), clearData);
}
return null;
}
/**
* Recursive method to process a {@link Node} in Arvores Deitadas format.
*
* @param node The {@link Node} to be processed.
* @param sentence The {@link List<String> sentence tokens} processed so far.
* @param names The {@link List<Span> names} processed so far.
*/
private void process(Node node, List<String> sentence, List<Span> names) {
if (node != null) {
for (TreeElement element : node.getElements()) {
if (element.isLeaf()) {
processLeaf((Leaf) element, sentence, names);
} else {
process((Node) element, sentence, names);
}
}
}
}
/**
* Processes a {@link Leaf} of Arvores Detaitadas format
*
* @param leaf The {@link Leaf} to be processed
* @param sentence The {@link List<String> sentence tokens} processed so far.
* @param names The {@link List<Span> names} processed so far.
*/
private void processLeaf(Leaf leaf, List<String> sentence, List<Span> names) {
boolean alreadyAdded = false;
if (leftContractionPart != null) {
// will handle the contraction
String right = leaf.getLexeme();
String c = PortugueseContractionUtility.toContraction(
leftContractionPart, right);
if (c != null) {
String[] parts = WHITESPACE_PATTERN.split(c);
sentence.addAll(Arrays.asList(parts));
alreadyAdded = true;
} else {
// contraction was missing! why?
sentence.add(leftContractionPart);
// keep alreadyAdded false.
}
leftContractionPart = null;
}
String namedEntityTag = null;
int startOfNamedEntity = -1;
String leafTag = leaf.getSecondaryTag();
boolean expandLastNER = false; // used when we find a <NER2> tag
if (leafTag != null) {
if (leafTag.contains("<sam->") && !alreadyAdded) {
String[] lexemes = UNDERLINE_PATTERN.split(leaf.getLexeme());
if (lexemes.length > 1) {
sentence.addAll(Arrays.asList(lexemes).subList(0, lexemes.length - 1));
}
leftContractionPart = lexemes[lexemes.length - 1];
return;
}
if (leafTag.contains("<NER2>")) {
// this one an be part of the last name
expandLastNER = true;
}
namedEntityTag = getNER(leafTag);
}
if (namedEntityTag != null) {
startOfNamedEntity = sentence.size();
}
if (!alreadyAdded) {
sentence.addAll(processLexeme(leaf.getLexeme()));
}
if (namedEntityTag != null) {
names
.add(new Span(startOfNamedEntity, sentence.size(), namedEntityTag));
}
if (expandLastNER) {
// if the current leaf has the tag <NER2>, it can be the continuation of
// a NER.
// we check if it is true, and expand the last NER
int lastIndex = names.size() - 1;
if (names.size() > 0) {
Span last = names.get(lastIndex);
if (last.getEnd() == sentence.size() - 1) {
names.set(lastIndex, new Span(last.getStart(), sentence.size(),
last.getType()));
}
}
}
}
private List<String> processLexeme(String lexemeStr) {
List<String> out = new ArrayList<>();
String[] parts = UNDERLINE_PATTERN.split(lexemeStr);
for (String tok : parts) {
if (tok.length() > 1 && !ALPHANUMERIC_PATTERN.matcher(tok).matches()) {
out.addAll(processTok(tok));
} else {
out.add(tok);
}
}
return out;
}
private List<String> processTok(String tok) {
boolean tokAdded = false;
String original = tok;
List<String> out = new ArrayList<>();
LinkedList<String> suffix = new LinkedList<>();
char first = tok.charAt(0);
if (first == '«') {
out.add(Character.toString(first));
tok = tok.substring(1);
}
char last = tok.charAt(tok.length() - 1);
if (last == '»' || last == ':' || last == ',' || last == '!' ) {
suffix.add(Character.toString(last));
tok = tok.substring(0, tok.length() - 1);
}
// lets split all hyphens
if (this.splitHyphenatedTokens && tok.contains("-") && tok.length() > 1) {
Matcher matcher = HYPHEN_PATTERN.matcher(tok);
String firstTok = null;
String hyphen = "-";
String secondTok = null;
String rest = null;
if (matcher.matches()) {
if (matcher.group(1) != null) {
firstTok = matcher.group(2);
} else if (matcher.group(3) != null) {
secondTok = matcher.group(4);
rest = matcher.group(5);
} else if (matcher.group(6) != null) {
firstTok = matcher.group(7);
secondTok = matcher.group(8);
rest = matcher.group(9);
}
addIfNotEmpty(firstTok, out);
addIfNotEmpty(hyphen, out);
addIfNotEmpty(secondTok, out);
addIfNotEmpty(rest, out);
tokAdded = true;
}
}
if (!tokAdded) {
if (!original.equals(tok) && tok.length() > 1
&& !ALPHANUMERIC_PATTERN.matcher(tok).matches()) {
out.addAll(processTok(tok));
} else {
out.add(tok);
}
}
out.addAll(suffix);
return out;
}
private void addIfNotEmpty(String firstTok, List<String> out) {
if (firstTok != null && firstTok.length() > 0) {
out.addAll(processTok(firstTok));
}
}
/**
* Parses a NER tag in Arvores Deitadas format.
*
* @param tags The NER tag in Arvores Deitadas format.
* @return The NER tag, or {@code null} if not a NER tag in Arvores Deitadas format.
*/
private static String getNER(String tags) {
if (tags.contains("<NER2>")) {
return null;
}
String[] tag = tags.split("\\s+");
for (String t : tag) {
Matcher matcher = TAG_PATTERN.matcher(t);
if (matcher.matches()) {
String ner = matcher.group(2);
if (HAREM.containsKey(ner)) {
return HAREM.get(ner);
}
}
}
return null;
}
@Override
public void reset() throws IOException, UnsupportedOperationException {
adSentenceStream.reset();
}
@Override
public void close() throws IOException {
adSentenceStream.close();
}
enum Type {
ama, cie, lit
}
// works for Amazonia
// private static final Pattern meta1 = Pattern
// .compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
//
// // works for selva cie
// private static final Pattern meta2 = Pattern
// .compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
private int getTextID(Sentence paragraph) {
final String meta = paragraph.getMetadata();
Type corpusType;
Pattern metaPattern;
int textIdMeta2 = -1;
String textMeta2 = "";
if (meta.startsWith("LIT")) {
corpusType = Type.lit;
metaPattern = Pattern.compile("^([a-zA-Z\\-]+)(\\d+).*?p=(\\d+).*");
} else if (meta.startsWith("CIE")) {
corpusType = Type.cie;
metaPattern = Pattern.compile("^.*?source=\"(.*?)\".*");
} else { // ama
corpusType = Type.ama;
metaPattern = Pattern.compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
}
if (corpusType.equals(Type.lit)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
String textId = m2.group(1);
if (!textId.equals(textMeta2)) {
textIdMeta2++;
textMeta2 = textId;
}
return textIdMeta2;
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
} else if (corpusType.equals(Type.cie)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
String textId = m2.group(1);
if (!textId.equals(textMeta2)) {
textIdMeta2++;
textMeta2 = textId;
}
return textIdMeta2;
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
} else if (corpusType.equals(Type.ama)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
return Integer.parseInt(m2.group(1));
// currentPara = Integer.parseInt(m.group(2));
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
}
return 0;
}
}
|
UTF-8
|
Java
| 15,606 |
java
|
ADNameSampleStream.java
|
Java
|
[
{
"context": "\n *\n * <p>\n * Information about the format:<br>\n * Susana Afonso.\n * <a href=\"http://www.linguateca.pt/documentos/",
"end": 2067,
"score": 0.8588681817054749,
"start": 2054,
"tag": "NAME",
"value": "Susana Afonso"
}
] | null |
[] |
/*
* 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 opennlp.tools.formats.ad;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import opennlp.tools.commons.Internal;
import opennlp.tools.formats.ad.ADSentenceStream.Sentence;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.Leaf;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.Node;
import opennlp.tools.formats.ad.ADSentenceStream.SentenceParser.TreeElement;
import opennlp.tools.namefind.NameSample;
import opennlp.tools.util.InputStreamFactory;
import opennlp.tools.util.ObjectStream;
import opennlp.tools.util.PlainTextByLineStream;
import opennlp.tools.util.Span;
/**
* Parser for Floresta Sita(c)tica Arvores Deitadas corpus, output to for the
* Portuguese NER training.
* <p>
* The data contains four named entity types: Person, Organization, Group,
* Place, Event, ArtProd, Abstract, Thing, Time and Numeric.<br>
* <p>
* Data can be found on
* <a href="http://www.linguateca.pt/floresta/corpus.html">this web site</a>.
*
* <p>
* Information about the format:<br>
* <NAME>.
* <a href="http://www.linguateca.pt/documentos/Afonso2006ArvoresDeitadas.pdf">
* "Árvores deitadas: Descrição do formato e das opções de análise na Floresta Sintáctica"</a>.
* <br>
* 12 de Fevereiro de 2006.
* <p>
* Detailed info about the
* <a href="http://beta.visl.sdu.dk/visl/pt/info/portsymbol.html#semtags_names">NER tagset</a>.
* <p>
* <b>Note:</b>
* Do not use this class, internal use only!
*/
@Internal
public class ADNameSampleStream implements ObjectStream<NameSample> {
/*
* Pattern of a NER tag in Arvores Deitadas
*/
private static final Pattern TAG_PATTERN = Pattern.compile("<(NER:)?(.*?)>");
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");
private static final Pattern UNDERLINE_PATTERN = Pattern.compile("[_]+");
private static final Pattern HYPHEN_PATTERN =
Pattern.compile("((\\p{L}+)-$)|(^-(\\p{L}+)(.*))|((\\p{L}+)-(\\p{L}+)(.*))");
private static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("^[\\p{L}\\p{Nd}]+$");
/*
* Map to the Arvores Deitadas types to our types. It is read-only.
*/
private static final Map<String, String> HAREM;
static {
Map<String, String> harem = new HashMap<>();
final String person = "person";
harem.put("hum", person);
harem.put("official", person);
harem.put("member", person);
final String organization = "organization";
harem.put("admin", organization);
harem.put("org", organization);
harem.put("inst", organization);
harem.put("media", organization);
harem.put("party", organization);
harem.put("suborg", organization);
final String group = "group";
harem.put("groupind", group);
harem.put("groupofficial", group);
final String place = "place";
harem.put("top", place);
harem.put("civ", place);
harem.put("address", place);
harem.put("site", place);
harem.put("virtual", place);
harem.put("astro", place);
final String event = "event";
harem.put("occ", event);
harem.put("event", event);
harem.put("history", event);
final String artprod = "artprod";
harem.put("tit", artprod);
harem.put("pub", artprod);
harem.put("product", artprod);
harem.put("V", artprod);
harem.put("artwork", artprod);
final String _abstract = "abstract";
harem.put("brand", _abstract);
harem.put("genre", _abstract);
harem.put("school", _abstract);
harem.put("idea", _abstract);
harem.put("plan", _abstract);
harem.put("author", _abstract);
harem.put("absname", _abstract);
harem.put("disease", _abstract);
final String thing = "thing";
harem.put("object", thing);
harem.put("common", thing);
harem.put("mat", thing);
harem.put("class", thing);
harem.put("plant", thing);
harem.put("currency", thing);
final String time = "time";
harem.put("date", time);
harem.put("hour", time);
harem.put("period", time);
harem.put("cyclic", time);
final String numeric = "numeric";
harem.put("quantity", numeric);
harem.put("prednum", numeric);
harem.put("currency", numeric);
HAREM = Collections.unmodifiableMap(harem);
}
private final ObjectStream<ADSentenceStream.Sentence> adSentenceStream;
/*
* To keep the last left contraction part
*/
private String leftContractionPart = null;
private final boolean splitHyphenatedTokens;
/**
* Initializes a new {@link ADNameSampleStream} stream from a {@link ObjectStream<String>},
* that could be a {@link PlainTextByLineStream} object.
*
* @param lineStream An {@link ObjectStream<String>} as input.
* @param splitHyphenatedTokens If {@code true} hyphenated tokens will be separated:
* "carros-monstro" > "carros" "-" "monstro".
*/
public ADNameSampleStream(ObjectStream<String> lineStream, boolean splitHyphenatedTokens) {
this.adSentenceStream = new ADSentenceStream(lineStream);
this.splitHyphenatedTokens = splitHyphenatedTokens;
}
/**
* Initializes a new {@link ADNameSampleStream} from an {@link InputStreamFactory}
*
* @param in The Corpus {@link InputStreamFactory}.
* @param charsetName The {@link java.nio.charset.Charset charset} to use
* for reading of the corpus.
* @param splitHyphenatedTokens If {@code true} hyphenated tokens will be separated:
* "carros-monstro" > "carros" "-" "monstro".
*/
@Deprecated
public ADNameSampleStream(InputStreamFactory in, String charsetName,
boolean splitHyphenatedTokens) throws IOException {
this(new PlainTextByLineStream(in, charsetName), splitHyphenatedTokens);
}
private int textID = -1;
@Override
public NameSample read() throws IOException {
Sentence paragraph;
// we should look for text here.
if ((paragraph = this.adSentenceStream.read()) != null) {
int currentTextID = getTextID(paragraph);
boolean clearData = false;
if (currentTextID != textID) {
clearData = true;
textID = currentTextID;
}
Node root = paragraph.getRoot();
List<String> sentence = new ArrayList<>();
List<Span> names = new ArrayList<>();
process(root, sentence, names);
return new NameSample(sentence.toArray(new String[0]),
names.toArray(new Span[0]), clearData);
}
return null;
}
/**
* Recursive method to process a {@link Node} in Arvores Deitadas format.
*
* @param node The {@link Node} to be processed.
* @param sentence The {@link List<String> sentence tokens} processed so far.
* @param names The {@link List<Span> names} processed so far.
*/
private void process(Node node, List<String> sentence, List<Span> names) {
if (node != null) {
for (TreeElement element : node.getElements()) {
if (element.isLeaf()) {
processLeaf((Leaf) element, sentence, names);
} else {
process((Node) element, sentence, names);
}
}
}
}
/**
* Processes a {@link Leaf} of Arvores Detaitadas format
*
* @param leaf The {@link Leaf} to be processed
* @param sentence The {@link List<String> sentence tokens} processed so far.
* @param names The {@link List<Span> names} processed so far.
*/
private void processLeaf(Leaf leaf, List<String> sentence, List<Span> names) {
boolean alreadyAdded = false;
if (leftContractionPart != null) {
// will handle the contraction
String right = leaf.getLexeme();
String c = PortugueseContractionUtility.toContraction(
leftContractionPart, right);
if (c != null) {
String[] parts = WHITESPACE_PATTERN.split(c);
sentence.addAll(Arrays.asList(parts));
alreadyAdded = true;
} else {
// contraction was missing! why?
sentence.add(leftContractionPart);
// keep alreadyAdded false.
}
leftContractionPart = null;
}
String namedEntityTag = null;
int startOfNamedEntity = -1;
String leafTag = leaf.getSecondaryTag();
boolean expandLastNER = false; // used when we find a <NER2> tag
if (leafTag != null) {
if (leafTag.contains("<sam->") && !alreadyAdded) {
String[] lexemes = UNDERLINE_PATTERN.split(leaf.getLexeme());
if (lexemes.length > 1) {
sentence.addAll(Arrays.asList(lexemes).subList(0, lexemes.length - 1));
}
leftContractionPart = lexemes[lexemes.length - 1];
return;
}
if (leafTag.contains("<NER2>")) {
// this one an be part of the last name
expandLastNER = true;
}
namedEntityTag = getNER(leafTag);
}
if (namedEntityTag != null) {
startOfNamedEntity = sentence.size();
}
if (!alreadyAdded) {
sentence.addAll(processLexeme(leaf.getLexeme()));
}
if (namedEntityTag != null) {
names
.add(new Span(startOfNamedEntity, sentence.size(), namedEntityTag));
}
if (expandLastNER) {
// if the current leaf has the tag <NER2>, it can be the continuation of
// a NER.
// we check if it is true, and expand the last NER
int lastIndex = names.size() - 1;
if (names.size() > 0) {
Span last = names.get(lastIndex);
if (last.getEnd() == sentence.size() - 1) {
names.set(lastIndex, new Span(last.getStart(), sentence.size(),
last.getType()));
}
}
}
}
private List<String> processLexeme(String lexemeStr) {
List<String> out = new ArrayList<>();
String[] parts = UNDERLINE_PATTERN.split(lexemeStr);
for (String tok : parts) {
if (tok.length() > 1 && !ALPHANUMERIC_PATTERN.matcher(tok).matches()) {
out.addAll(processTok(tok));
} else {
out.add(tok);
}
}
return out;
}
private List<String> processTok(String tok) {
boolean tokAdded = false;
String original = tok;
List<String> out = new ArrayList<>();
LinkedList<String> suffix = new LinkedList<>();
char first = tok.charAt(0);
if (first == '«') {
out.add(Character.toString(first));
tok = tok.substring(1);
}
char last = tok.charAt(tok.length() - 1);
if (last == '»' || last == ':' || last == ',' || last == '!' ) {
suffix.add(Character.toString(last));
tok = tok.substring(0, tok.length() - 1);
}
// lets split all hyphens
if (this.splitHyphenatedTokens && tok.contains("-") && tok.length() > 1) {
Matcher matcher = HYPHEN_PATTERN.matcher(tok);
String firstTok = null;
String hyphen = "-";
String secondTok = null;
String rest = null;
if (matcher.matches()) {
if (matcher.group(1) != null) {
firstTok = matcher.group(2);
} else if (matcher.group(3) != null) {
secondTok = matcher.group(4);
rest = matcher.group(5);
} else if (matcher.group(6) != null) {
firstTok = matcher.group(7);
secondTok = matcher.group(8);
rest = matcher.group(9);
}
addIfNotEmpty(firstTok, out);
addIfNotEmpty(hyphen, out);
addIfNotEmpty(secondTok, out);
addIfNotEmpty(rest, out);
tokAdded = true;
}
}
if (!tokAdded) {
if (!original.equals(tok) && tok.length() > 1
&& !ALPHANUMERIC_PATTERN.matcher(tok).matches()) {
out.addAll(processTok(tok));
} else {
out.add(tok);
}
}
out.addAll(suffix);
return out;
}
private void addIfNotEmpty(String firstTok, List<String> out) {
if (firstTok != null && firstTok.length() > 0) {
out.addAll(processTok(firstTok));
}
}
/**
* Parses a NER tag in Arvores Deitadas format.
*
* @param tags The NER tag in Arvores Deitadas format.
* @return The NER tag, or {@code null} if not a NER tag in Arvores Deitadas format.
*/
private static String getNER(String tags) {
if (tags.contains("<NER2>")) {
return null;
}
String[] tag = tags.split("\\s+");
for (String t : tag) {
Matcher matcher = TAG_PATTERN.matcher(t);
if (matcher.matches()) {
String ner = matcher.group(2);
if (HAREM.containsKey(ner)) {
return HAREM.get(ner);
}
}
}
return null;
}
@Override
public void reset() throws IOException, UnsupportedOperationException {
adSentenceStream.reset();
}
@Override
public void close() throws IOException {
adSentenceStream.close();
}
enum Type {
ama, cie, lit
}
// works for Amazonia
// private static final Pattern meta1 = Pattern
// .compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
//
// // works for selva cie
// private static final Pattern meta2 = Pattern
// .compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
private int getTextID(Sentence paragraph) {
final String meta = paragraph.getMetadata();
Type corpusType;
Pattern metaPattern;
int textIdMeta2 = -1;
String textMeta2 = "";
if (meta.startsWith("LIT")) {
corpusType = Type.lit;
metaPattern = Pattern.compile("^([a-zA-Z\\-]+)(\\d+).*?p=(\\d+).*");
} else if (meta.startsWith("CIE")) {
corpusType = Type.cie;
metaPattern = Pattern.compile("^.*?source=\"(.*?)\".*");
} else { // ama
corpusType = Type.ama;
metaPattern = Pattern.compile("^(?:[a-zA-Z\\-]*(\\d+)).*?p=(\\d+).*");
}
if (corpusType.equals(Type.lit)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
String textId = m2.group(1);
if (!textId.equals(textMeta2)) {
textIdMeta2++;
textMeta2 = textId;
}
return textIdMeta2;
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
} else if (corpusType.equals(Type.cie)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
String textId = m2.group(1);
if (!textId.equals(textMeta2)) {
textIdMeta2++;
textMeta2 = textId;
}
return textIdMeta2;
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
} else if (corpusType.equals(Type.ama)) {
Matcher m2 = metaPattern.matcher(meta);
if (m2.matches()) {
return Integer.parseInt(m2.group(1));
// currentPara = Integer.parseInt(m.group(2));
} else {
throw new RuntimeException("Invalid metadata: " + meta);
}
}
return 0;
}
}
| 15,599 | 0.624736 | 0.619927 | 495 | 30.50909 | 24.064043 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.634343 | false | false |
10
|
a2c3d6ad8683b0659d4c21ef5929100d9e8d1a68
| 21,552,145,894,353 |
aa4ea0058c14ce198d14b8c780be13737d784bcc
|
/src/main/java/com/turkcell/poc/converter/ProductMapperDecorator.java
|
ce5019fb1026db1469ca9e5d41a98bf7c9da51c1
|
[] |
no_license
|
sencerseven/TurkcellPoc
|
https://github.com/sencerseven/TurkcellPoc
|
2d1293322ab0f946152fa82ad1679e2a7de377fc
|
2d74f066a561dcaa344fef2775601c43a3725462
|
refs/heads/master
| 2023-04-03T05:36:24.672000 | 2021-04-08T08:04:26 | 2021-04-08T08:04:26 | 355,781,915 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.turkcell.poc.converter;
import com.turkcell.poc.entity.Product;
import com.turkcell.poc.model.ProductCreateDto;
import com.turkcell.poc.model.ProductDto;
import com.turkcell.poc.model.ProductUpdateDto;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class ProductMapperDecorator implements ProductMapper {
@Autowired
ProductMapper delegate;
@Override
public List<ProductDto> productsToProductDtos(List<Product> productList) {
if (productList == null || productList.isEmpty()) {
return null;
}
return productList.stream().map(delegate::productToProductDto).collect(Collectors.toList());
}
@Override
public List<Product> productCreateDtosToProductDtos(List<ProductCreateDto> productCreateDtoList) {
if (productCreateDtoList == null || productCreateDtoList.isEmpty()) {
return null;
}
return productCreateDtoList.stream().map(delegate::productCreateDtoToProduct)
.collect(Collectors.toList());
}
@Override
public List<Product> productUpdateDtosToProductDtos(
List<ProductUpdateDto> productUpdateDtos) {
if (productUpdateDtos == null || productUpdateDtos.isEmpty()) {
return null;
}
return productUpdateDtos.stream().map(delegate::productUpdateDtoProduct)
.collect(Collectors.toList());
}
}
|
UTF-8
|
Java
| 1,397 |
java
|
ProductMapperDecorator.java
|
Java
|
[] | null |
[] |
package com.turkcell.poc.converter;
import com.turkcell.poc.entity.Product;
import com.turkcell.poc.model.ProductCreateDto;
import com.turkcell.poc.model.ProductDto;
import com.turkcell.poc.model.ProductUpdateDto;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class ProductMapperDecorator implements ProductMapper {
@Autowired
ProductMapper delegate;
@Override
public List<ProductDto> productsToProductDtos(List<Product> productList) {
if (productList == null || productList.isEmpty()) {
return null;
}
return productList.stream().map(delegate::productToProductDto).collect(Collectors.toList());
}
@Override
public List<Product> productCreateDtosToProductDtos(List<ProductCreateDto> productCreateDtoList) {
if (productCreateDtoList == null || productCreateDtoList.isEmpty()) {
return null;
}
return productCreateDtoList.stream().map(delegate::productCreateDtoToProduct)
.collect(Collectors.toList());
}
@Override
public List<Product> productUpdateDtosToProductDtos(
List<ProductUpdateDto> productUpdateDtos) {
if (productUpdateDtos == null || productUpdateDtos.isEmpty()) {
return null;
}
return productUpdateDtos.stream().map(delegate::productUpdateDtoProduct)
.collect(Collectors.toList());
}
}
| 1,397 | 0.753758 | 0.753758 | 46 | 29.369566 | 29.615183 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.456522 | false | false |
10
|
3b1166dd6de31492d3bbe723b83e1b3230da2fac
| 25,658,134,679,657 |
06c76b60ebe93739b2b9c94aa1eccfc1b51fba5b
|
/string13.java
|
b6c4591f31bdf8d63da5abb5447a940a92a17124
|
[] |
no_license
|
mayankk67/algorithms
|
https://github.com/mayankk67/algorithms
|
31387acbe9c0ed85779538bbb6f52e3fa2907327
|
efa2481dd71abb8a3b27bf97416f6ace42dcaee7
|
refs/heads/master
| 2021-01-01T05:52:15.225000 | 2018-07-12T18:51:26 | 2018-07-12T18:51:26 | 97,291,438 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*Given a string and a non-empty word string,
return a string made of each char just before and just after every appearance of the word in the string.
Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words.
If inputs are "abcXY123XYijk" and "XY", output should be "c13i".
If inputs are "XY123XY" and "XY", output should be "13".
If inputs are "XY1XY" and "XY", output should be "11".*/
import java.util.*;
class stee
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String str1,str2;
System.out.println("Enter the main string");
str1=sc.nextLine();
System.out.println("Enter the other string");
str2=sc.nextLine();
for(i=0;i<str1.length;i++)
{
|
UTF-8
|
Java
| 790 |
java
|
string13.java
|
Java
|
[] | null |
[] |
/*Given a string and a non-empty word string,
return a string made of each char just before and just after every appearance of the word in the string.
Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words.
If inputs are "abcXY123XYijk" and "XY", output should be "c13i".
If inputs are "XY123XY" and "XY", output should be "13".
If inputs are "XY1XY" and "XY", output should be "11".*/
import java.util.*;
class stee
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String str1,str2;
System.out.println("Enter the main string");
str1=sc.nextLine();
System.out.println("Enter the other string");
str2=sc.nextLine();
for(i=0;i<str1.length;i++)
{
| 790 | 0.689873 | 0.665823 | 21 | 35.285713 | 32.286137 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.571429 | false | false |
10
|
1476ed17dbb36920983f52b6fda79c5c429fd824
| 25,658,134,678,889 |
ac78ad6c2f21982a6f4d9a89c2ecb64dd8ed0dc3
|
/src/main/java/com/beta/replyservice/ReplyMessage.java
|
08dff914186a5c9367c39bf5056ebd62ad40de90
|
[] |
no_license
|
thatcoderagain/java-assignment
|
https://github.com/thatcoderagain/java-assignment
|
086d4ce17b1307cfa4c37b93454760482d31032c
|
268a986af1da8eac6e1191713dcdbc4e303d9b6e
|
refs/heads/master
| 2023-07-27T15:44:32.337000 | 2021-09-08T18:33:42 | 2021-09-08T18:33:42 | 404,456,299 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.beta.replyservice;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ReplyMessage {
private final String message;
/**
* Method accepts a string and operator and perform the operation on string and returns result string
*
* @param message
* @param operation
* @return
* @throws NoSuchAlgorithmException
*/
public String Process(String message, char operation) throws NoSuchAlgorithmException {
switch (operation) {
case '1': return new StringBuilder(message).reverse().toString();
case '2': byte[] bytesOfMessage = message.getBytes(StandardCharsets.UTF_8);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bytes = md.digest(bytesOfMessage);
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
default:
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "Invalid input");
}
}
/**
* Method accepts the payload string and separates operators from data and calls process.
* Returns the resulting string after performing operations specified in payload string.
* @param message
* @return
*/
public String Parse(String message) {
try {
String[] parts = message.split("-");
String operations = String.valueOf(parts[0]);
if (parts.length != 2 || operations.length() != 2) {
throw new Exception("Invalid input");
}
String result = parts[1];
result = this.Process(result, operations.charAt(0));
result = this.Process(result, operations.charAt(1));
return result;
} catch (Exception exception) {
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "Invalid input");
}
}
public ReplyMessage(String message) {
this.message = this.Parse(message);
}
public String getMessage() {
return message;
}
}
|
UTF-8
|
Java
| 2,028 |
java
|
ReplyMessage.java
|
Java
|
[] | null |
[] |
package com.beta.replyservice;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ReplyMessage {
private final String message;
/**
* Method accepts a string and operator and perform the operation on string and returns result string
*
* @param message
* @param operation
* @return
* @throws NoSuchAlgorithmException
*/
public String Process(String message, char operation) throws NoSuchAlgorithmException {
switch (operation) {
case '1': return new StringBuilder(message).reverse().toString();
case '2': byte[] bytesOfMessage = message.getBytes(StandardCharsets.UTF_8);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bytes = md.digest(bytesOfMessage);
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
default:
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "Invalid input");
}
}
/**
* Method accepts the payload string and separates operators from data and calls process.
* Returns the resulting string after performing operations specified in payload string.
* @param message
* @return
*/
public String Parse(String message) {
try {
String[] parts = message.split("-");
String operations = String.valueOf(parts[0]);
if (parts.length != 2 || operations.length() != 2) {
throw new Exception("Invalid input");
}
String result = parts[1];
result = this.Process(result, operations.charAt(0));
result = this.Process(result, operations.charAt(1));
return result;
} catch (Exception exception) {
throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "Invalid input");
}
}
public ReplyMessage(String message) {
this.message = this.Parse(message);
}
public String getMessage() {
return message;
}
}
| 2,028 | 0.715483 | 0.709566 | 68 | 28.82353 | 25.516973 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.264706 | false | false |
10
|
f8270fc6d06ce24cacd4d773ceaf10f6f796d566
| 32,203,664,803,373 |
54990ee4e7435d56dd2fbfb62e26c700e510b8c7
|
/demo/shipperApp/src/cn/qm/activity/Activity_Score.java
|
d903561481a90ef36e7c31d3cc73c2853e5ab888
|
[] |
no_license
|
haibo18/allannotation
|
https://github.com/haibo18/allannotation
|
76312f318729793024124ce5b97635cbbae5c3f0
|
3e9d9e280f9ae82fc0bef3debf5a1ac0eb1f3220
|
refs/heads/master
| 2021-01-11T20:16:44.695000 | 2017-01-16T09:03:23 | 2017-01-16T09:03:23 | 79,078,199 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* @author 郭海波
* @ClassName Activity_Score
* @Version 版本
* @ModifiedBy 修改人
* @Copyright 启明电子信息
* @Create 2017年1月9日 下午2:09:52
* @Modify 修改时间
*/
package cn.qm.activity;
import java.util.List;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import cn.qm.annotation.OnClick;
import cn.qm.annotation.ViewId;
import cn.qm.bean.Score;
import cn.qm.shipperapp.R;
import cn.qm.template.BaseFragmentActivity;
import cn.qm.until.Utils;
@ViewId(R.layout.activity_score)
public class Activity_Score extends BaseFragmentActivity {
@ViewId(R.id.back)
private TextView back;
@ViewId(R.id.lv)
private ListView lv;
/** 订单数据集 */
private List<Score> scores = Utils.structure.newArrayList();
/** 适配器 */
private BaseAdapter_Score adapter;
@Override
protected void onStart() {
super.onStart();
adapter = new BaseAdapter_Score();
lv.setAdapter(adapter);
}
@OnClick(R.id.back)
private void back(View v) {
finish();
}
private class BaseAdapter_Score extends BaseAdapter {
@Override
public int getCount() {
return scores.size();
}
@Override
public Object getItem(int position) {
return scores.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return null;
}
}
}
|
UTF-8
|
Java
| 1,508 |
java
|
Activity_Score.java
|
Java
|
[
{
"context": "/**\n * @author 郭海波\n * @ClassName Activity_Score\n * @Version 版本\n * @M",
"end": 18,
"score": 0.9998447299003601,
"start": 15,
"tag": "NAME",
"value": "郭海波"
}
] | null |
[] |
/**
* @author 郭海波
* @ClassName Activity_Score
* @Version 版本
* @ModifiedBy 修改人
* @Copyright 启明电子信息
* @Create 2017年1月9日 下午2:09:52
* @Modify 修改时间
*/
package cn.qm.activity;
import java.util.List;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import cn.qm.annotation.OnClick;
import cn.qm.annotation.ViewId;
import cn.qm.bean.Score;
import cn.qm.shipperapp.R;
import cn.qm.template.BaseFragmentActivity;
import cn.qm.until.Utils;
@ViewId(R.layout.activity_score)
public class Activity_Score extends BaseFragmentActivity {
@ViewId(R.id.back)
private TextView back;
@ViewId(R.id.lv)
private ListView lv;
/** 订单数据集 */
private List<Score> scores = Utils.structure.newArrayList();
/** 适配器 */
private BaseAdapter_Score adapter;
@Override
protected void onStart() {
super.onStart();
adapter = new BaseAdapter_Score();
lv.setAdapter(adapter);
}
@OnClick(R.id.back)
private void back(View v) {
finish();
}
private class BaseAdapter_Score extends BaseAdapter {
@Override
public int getCount() {
return scores.size();
}
@Override
public Object getItem(int position) {
return scores.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return null;
}
}
}
| 1,508 | 0.7213 | 0.713693 | 77 | 17.779221 | 16.205357 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.12987 | false | false |
10
|
d67bc8fcbd20f6b4f3c67b7b90eee0b8324c0346
| 2,757,369,030,725 |
d6090d64690ba0bc0df06649066ae0e6d98c09c7
|
/cgiats_new/WebContent/src/main/java/com/uralian/cgiats/util/RecActivityExcelGenerator.java
|
a545cbae1d748302577b756358a5c810017806f1
|
[] |
no_license
|
sivakurapati87/cgiats_new
|
https://github.com/sivakurapati87/cgiats_new
|
9db29fd91084e04946ee5569fd0bdacc5336ddc5
|
da208d777ea25de6ecadf521b1d00f216adec67c
|
refs/heads/master
| 2021-01-21T02:11:42.444000 | 2017-08-30T14:29:00 | 2017-08-30T14:34:58 | 101,885,692 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
//package com.uralian.cgiats.util;
//
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.Map;
//import java.util.StringTokenizer;
//
//import javax.faces.context.FacesContext;
//import javax.servlet.ServletOutputStream;
//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.HSSFFont;
//import org.apache.poi.hssf.usermodel.HSSFRow;
//import org.apache.poi.hssf.usermodel.HSSFSheet;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//import org.apache.poi.hssf.util.HSSFColor;
//
//import com.uralian.cgiats.model.SubmittalStatus;
//
//public class RecActivityExcelGenerator {
// private HSSFCellStyle cs = null;
// private HSSFCellStyle csBold = null;
//
// public byte[] createRecActivityExcel(Map<String,String> recData, Map<String,Integer> submittalTotalsByUser,Map<String, Map<SubmittalStatus,Integer>> submittalsByRecruiter) {
//
// byte[] output = null;
// try {
//
// HSSFWorkbook wb = new HSSFWorkbook();
// HSSFSheet sheet = wb.createSheet("All Recruiters Activity Report");
//
// // Setup some styles that we need for the Cells
// setCellStyles(wb);
// setColWidthAndMargin(sheet);
//
// int rowIndex = 0;
// rowIndex = insertHeaderInfo(sheet, rowIndex);
// System.out.println("rowIndex:::"+rowIndex);
// rowIndex = insertRecSubmittalsInfo(sheet, rowIndex, recData,submittalTotalsByUser,submittalsByRecruiter);
// String timeStamp = new SimpleDateFormat("MMddyyyy_HHmmss").format(Calendar.getInstance().getTime());
// String fileName = "attachment;filename=Activity_Report_of_AllRecruiters_"+timeStamp+".xls";
// output = wb.getBytes();
// System.out.println("Workbook length in bytes: "+output.length);
// FacesContext context = FacesContext.getCurrentInstance();
// HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse();
// res.setContentType("application/vnd.ms-excel");
// res.setHeader("Content-disposition", fileName);
// ServletOutputStream out = res.getOutputStream();
// wb.write(out);
// out.flush();
// out.close();
// FacesContext.getCurrentInstance().responseComplete();
//
// } catch (Exception e) {
// System.out.println("Exception in exporting all records to excel :: " + e);
// e.printStackTrace();
// }
// return output;
// }
//
// public void setColWidthAndMargin(HSSFSheet sheet) {
// // Set Column Widths
// sheet.setColumnWidth(0, 5000);
// sheet.setColumnWidth(1, 4000);
// sheet.setColumnWidth(2, 5000);
// sheet.setColumnWidth(3, 3000);
// sheet.setColumnWidth(4, 3000);
// sheet.setColumnWidth(5, 3500);
// sheet.setColumnWidth(6, 4000);
// sheet.setColumnWidth(7, 3000);
// sheet.setColumnWidth(8, 3000);
// sheet.setColumnWidth(9, 3000);
// sheet.setColumnWidth(10, 3000);
// sheet.setColumnWidth(11, 4000);
//
// // Setup the Page margins - Left, Right, Top and Bottom
// sheet.setMargin(HSSFSheet.LeftMargin, 0.25);
// sheet.setMargin(HSSFSheet.RightMargin, 0.25);
// sheet.setMargin(HSSFSheet.TopMargin, 0.75);
// sheet.setMargin(HSSFSheet.BottomMargin, 0.75);
// }
//
// private void setCellStyles(HSSFWorkbook wb) {
//
// // font size 10
// HSSFFont f = wb.createFont();
// f.setFontHeightInPoints((short) 10);
//
// // Simple style
// cs = wb.createCellStyle();
// cs.setFont(f);
//
// // Bold Fond
// HSSFFont bold = wb.createFont();
// bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// bold.setFontHeightInPoints((short) 10);
//
// // Bold style
// csBold = wb.createCellStyle();
// csBold.setBorderBottom(HSSFCellStyle.BORDER_THIN);
// csBold.setBorderRight(HSSFCellStyle.BORDER_THIN);
// csBold.setBottomBorderColor(HSSFColor.BLACK.index);
// csBold.setFont(bold);
//
// cs.setBorderTop((short) 1);
// cs.setBorderBottom((short) 1);
// cs.setBorderLeft((short) 1);
// cs.setBorderRight((short) 1);
// cs.setFont(f);
// }
//
// private int insertHeaderInfo(HSSFSheet sheet, int index) {
//
// int rowIndex = index;
// HSSFRow row = null;
// HSSFCell c = null;
//
// row = sheet.createRow(rowIndex);
// c = row.createCell(0);
// c.setCellValue("RECRUITER");
// c.setCellStyle(csBold);
//
// c = row.createCell(1);
// c.setCellValue("LOC");
// c.setCellStyle(csBold);
//
// c = row.createCell(2);
// c.setCellValue("SUBMITTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(3);
// c.setCellValue("DMREJ");
// c.setCellStyle(csBold);
//
// c = row.createCell(4);
// c.setCellValue("ACCEPTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(5);
// c.setCellValue("INTERVIEWING");
// c.setCellStyle(csBold);
//
// c = row.createCell(6);
// c.setCellValue("CONFIRMED");
// c.setCellStyle(csBold);
//
// c = row.createCell(7);
// c.setCellValue("REJECTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(8);
// c.setCellValue("STARTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(9);
// c.setCellValue("BACKOUT");
// c.setCellStyle(csBold);
//
// c = row.createCell(10);
// c.setCellValue("OUTOFPROJ");
// c.setCellStyle(csBold);
//
// rowIndex++;
// return rowIndex;
// }
//
// private int insertDetailInfo(HSSFSheet sheet, int index,String recName , String recLoc, String recCount) {
//
// HSSFRow row = null;
// HSSFCell c = null;
// row = sheet.createRow(index);
//
// c = row.createCell(0);
// c.setCellValue(recName);
// c.setCellStyle(cs);
//
// c = row.createCell(1);
// c.setCellValue(recLoc);
// c.setCellStyle(cs);
//
// StringTokenizer st = new StringTokenizer(recCount,",");
// int i=2;
// while(st.hasMoreTokens()){
// c = row.createCell(i);
// c.setCellValue(st.nextToken());
// c.setCellStyle(cs);
// i =i+1;
// }
// return index;
// }
//
// private int insertDetailInfoTotal(HSSFSheet sheet, int index,String columnRow) {
// HSSFRow row = null;
// HSSFCell c = null;
// row = sheet.createRow(index+1);
//
// c = row.createCell(0);
// c.setCellValue("TOTAL:");
// c.setCellStyle(csBold);
//
// StringTokenizer st1 = new StringTokenizer(columnRow,",");
//
// int i=2;
// while(st1.hasMoreTokens()){
// c = row.createCell(i);
// c.setCellValue(st1.nextToken());
// c.setCellStyle(cs);
// i =i+1;
// }
// return index;
// }
//
// private int insertRecSubmittalsInfo(HSSFSheet sheet, int index, Map<String,String> recData, Map<String,Integer> submittalTotalsByUser,Map<String, Map<SubmittalStatus,Integer>> submittalsByRecruiter) {
//
// int rowIndex = 0;
// Integer recBDMREJ = 0;
// Integer recOUTOFPROJ = 0;
// Integer recACCEPTED = 0;
// Integer recSUBMITTED =0;
// Integer recINTERVIEWING= 0;
// Integer recCONFIRMED = 0;
// Integer recSTARTED= 0;
// Integer recBACKOUT = 0;
// Integer recCLOSED = 0;
// Integer recREJECTED = 0;
// Integer recACCEPTEDTotal = 0;
// Integer recSUBMITTEDTotal =0;
// Integer recINTERVIEWINGTotal= 0;
// Integer recCONFIRMEDTotal = 0;
// Integer recSTARTEDTotal= 0;
// Integer recBACKOUTTotal= 0;
// Integer recREJECTEDTotal = 0;
// Integer recBDMREJTotal = 0;
// Integer recOUTOFPROJTotal = 0;
// String strRow = null;
// String recCount = null;
// String recColValue = null;
// int total =0;
// int count = 0;
// String columnRow = null;
// try {
// for (Map.Entry<String,Map<SubmittalStatus, Integer> > entry : submittalsByRecruiter.entrySet()){
// rowIndex = rowIndex + 1;
// String recName = entry.getKey();
// String recLoc = recData.get(recName);
// for(Map.Entry<SubmittalStatus,Integer> submittedEntry : entry.getValue().entrySet()){
// if((submittedEntry.getKey()).toString().equals("SUBMITTED")){
// recSUBMITTED = submittedEntry.getValue();
// recSUBMITTEDTotal = recSUBMITTEDTotal + recSUBMITTED;
// }else if((submittedEntry.getKey()).toString().equals("DMREJ")){
// recBDMREJ = submittedEntry.getValue();
// recBDMREJTotal = recBDMREJTotal + recBDMREJ;
// }else if((submittedEntry.getKey()).toString().equals("ACCEPTED")){
// recACCEPTED = submittedEntry.getValue();
// recACCEPTEDTotal = recACCEPTEDTotal + recACCEPTED;
// }else if((submittedEntry.getKey()).toString().equals("INTERVIEWING")){
// recINTERVIEWING = submittedEntry.getValue();
// recINTERVIEWINGTotal = recINTERVIEWINGTotal + recINTERVIEWING;
// }else if((submittedEntry.getKey()).toString().equals("CONFIRMED")){
// recCONFIRMED = submittedEntry.getValue();
// recCONFIRMEDTotal = recCONFIRMEDTotal + recCONFIRMED;
// }else if((submittedEntry.getKey()).toString().equals("STARTED")){
// recSTARTED = submittedEntry.getValue();
// recSTARTEDTotal = recSTARTEDTotal + recSTARTED;
// }else if((submittedEntry.getKey()).toString().equals("BACKOUT")){
// recBACKOUT = submittedEntry.getValue();
// recBACKOUTTotal = recBACKOUTTotal + recBACKOUT;
// }else if((submittedEntry.getKey()).toString().equals("REJECTED")){
// recREJECTED = submittedEntry.getValue();
// recREJECTEDTotal = recREJECTEDTotal + recREJECTED;
// }else if((submittedEntry.getKey()).toString().equals("OUTOFPROJ")){
// recOUTOFPROJ = submittedEntry.getValue();
// recOUTOFPROJTotal = recOUTOFPROJTotal + recOUTOFPROJ;
// }
// }
// total = recSUBMITTED+recBDMREJ+recACCEPTED+recINTERVIEWING+recCONFIRMED+recSTARTED+recBACKOUT+recREJECTED+recOUTOFPROJ;
// count = recSUBMITTEDTotal+recBDMREJTotal+recACCEPTEDTotal+recINTERVIEWINGTotal+recCONFIRMEDTotal+recSTARTEDTotal+recBACKOUTTotal+recOUTOFPROJTotal+recREJECTEDTotal;
// strRow = recSUBMITTED+","+recBDMREJ+","+recACCEPTED+","+recINTERVIEWING+","+recCONFIRMED+","+recREJECTED+","+recSTARTED+","+recBACKOUT+","+recOUTOFPROJ+","+total;
// recCount = total +","+recBDMREJ+","+recACCEPTED+","+recINTERVIEWING+","+recCONFIRMED+","+recREJECTED+","+recSTARTED+","+recBACKOUT+","+recOUTOFPROJ;
// insertDetailInfo(sheet, rowIndex,recName,recLoc,recCount);
// }
// columnRow = recSUBMITTEDTotal+","+recBDMREJTotal+","+recACCEPTEDTotal+","+recINTERVIEWINGTotal+","+recCONFIRMEDTotal+","+recREJECTEDTotal+","+recSTARTEDTotal+","+recBACKOUTTotal+","+recOUTOFPROJTotal+","+count;
// recColValue = count+","+recBDMREJTotal+","+recACCEPTEDTotal+","+recINTERVIEWINGTotal+","+recCONFIRMEDTotal+","+recREJECTEDTotal+","+recSTARTEDTotal+","+recBACKOUTTotal+","+recOUTOFPROJTotal;
// insertDetailInfoTotal(sheet, rowIndex,recColValue);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return rowIndex;
// }
//}
|
UTF-8
|
Java
| 10,882 |
java
|
RecActivityExcelGenerator.java
|
Java
|
[
{
"context": "\r\n//\t\tc = row.createCell(0);\r\n//\t\tc.setCellValue(\"RECRUITER\");\r\n//\t\tc.setCellStyle(csBold);\r\n//\r\n//\t\tc = row.",
"end": 4364,
"score": 0.6800902485847473,
"start": 4355,
"tag": "NAME",
"value": "RECRUITER"
},
{
"context": "\r\n//\t\tc = row.createCell(3);\r\n//\t\tc.setCellValue(\"DMREJ\");\r\n//\t\tc.setCellStyle(csBold);\r\n//\r\n//\t\tc = row.",
"end": 4642,
"score": 0.9589981436729431,
"start": 4637,
"tag": "NAME",
"value": "DMREJ"
}
] | null |
[] |
//package com.uralian.cgiats.util;
//
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.Map;
//import java.util.StringTokenizer;
//
//import javax.faces.context.FacesContext;
//import javax.servlet.ServletOutputStream;
//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.HSSFFont;
//import org.apache.poi.hssf.usermodel.HSSFRow;
//import org.apache.poi.hssf.usermodel.HSSFSheet;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//import org.apache.poi.hssf.util.HSSFColor;
//
//import com.uralian.cgiats.model.SubmittalStatus;
//
//public class RecActivityExcelGenerator {
// private HSSFCellStyle cs = null;
// private HSSFCellStyle csBold = null;
//
// public byte[] createRecActivityExcel(Map<String,String> recData, Map<String,Integer> submittalTotalsByUser,Map<String, Map<SubmittalStatus,Integer>> submittalsByRecruiter) {
//
// byte[] output = null;
// try {
//
// HSSFWorkbook wb = new HSSFWorkbook();
// HSSFSheet sheet = wb.createSheet("All Recruiters Activity Report");
//
// // Setup some styles that we need for the Cells
// setCellStyles(wb);
// setColWidthAndMargin(sheet);
//
// int rowIndex = 0;
// rowIndex = insertHeaderInfo(sheet, rowIndex);
// System.out.println("rowIndex:::"+rowIndex);
// rowIndex = insertRecSubmittalsInfo(sheet, rowIndex, recData,submittalTotalsByUser,submittalsByRecruiter);
// String timeStamp = new SimpleDateFormat("MMddyyyy_HHmmss").format(Calendar.getInstance().getTime());
// String fileName = "attachment;filename=Activity_Report_of_AllRecruiters_"+timeStamp+".xls";
// output = wb.getBytes();
// System.out.println("Workbook length in bytes: "+output.length);
// FacesContext context = FacesContext.getCurrentInstance();
// HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse();
// res.setContentType("application/vnd.ms-excel");
// res.setHeader("Content-disposition", fileName);
// ServletOutputStream out = res.getOutputStream();
// wb.write(out);
// out.flush();
// out.close();
// FacesContext.getCurrentInstance().responseComplete();
//
// } catch (Exception e) {
// System.out.println("Exception in exporting all records to excel :: " + e);
// e.printStackTrace();
// }
// return output;
// }
//
// public void setColWidthAndMargin(HSSFSheet sheet) {
// // Set Column Widths
// sheet.setColumnWidth(0, 5000);
// sheet.setColumnWidth(1, 4000);
// sheet.setColumnWidth(2, 5000);
// sheet.setColumnWidth(3, 3000);
// sheet.setColumnWidth(4, 3000);
// sheet.setColumnWidth(5, 3500);
// sheet.setColumnWidth(6, 4000);
// sheet.setColumnWidth(7, 3000);
// sheet.setColumnWidth(8, 3000);
// sheet.setColumnWidth(9, 3000);
// sheet.setColumnWidth(10, 3000);
// sheet.setColumnWidth(11, 4000);
//
// // Setup the Page margins - Left, Right, Top and Bottom
// sheet.setMargin(HSSFSheet.LeftMargin, 0.25);
// sheet.setMargin(HSSFSheet.RightMargin, 0.25);
// sheet.setMargin(HSSFSheet.TopMargin, 0.75);
// sheet.setMargin(HSSFSheet.BottomMargin, 0.75);
// }
//
// private void setCellStyles(HSSFWorkbook wb) {
//
// // font size 10
// HSSFFont f = wb.createFont();
// f.setFontHeightInPoints((short) 10);
//
// // Simple style
// cs = wb.createCellStyle();
// cs.setFont(f);
//
// // Bold Fond
// HSSFFont bold = wb.createFont();
// bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// bold.setFontHeightInPoints((short) 10);
//
// // Bold style
// csBold = wb.createCellStyle();
// csBold.setBorderBottom(HSSFCellStyle.BORDER_THIN);
// csBold.setBorderRight(HSSFCellStyle.BORDER_THIN);
// csBold.setBottomBorderColor(HSSFColor.BLACK.index);
// csBold.setFont(bold);
//
// cs.setBorderTop((short) 1);
// cs.setBorderBottom((short) 1);
// cs.setBorderLeft((short) 1);
// cs.setBorderRight((short) 1);
// cs.setFont(f);
// }
//
// private int insertHeaderInfo(HSSFSheet sheet, int index) {
//
// int rowIndex = index;
// HSSFRow row = null;
// HSSFCell c = null;
//
// row = sheet.createRow(rowIndex);
// c = row.createCell(0);
// c.setCellValue("RECRUITER");
// c.setCellStyle(csBold);
//
// c = row.createCell(1);
// c.setCellValue("LOC");
// c.setCellStyle(csBold);
//
// c = row.createCell(2);
// c.setCellValue("SUBMITTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(3);
// c.setCellValue("DMREJ");
// c.setCellStyle(csBold);
//
// c = row.createCell(4);
// c.setCellValue("ACCEPTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(5);
// c.setCellValue("INTERVIEWING");
// c.setCellStyle(csBold);
//
// c = row.createCell(6);
// c.setCellValue("CONFIRMED");
// c.setCellStyle(csBold);
//
// c = row.createCell(7);
// c.setCellValue("REJECTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(8);
// c.setCellValue("STARTED");
// c.setCellStyle(csBold);
//
// c = row.createCell(9);
// c.setCellValue("BACKOUT");
// c.setCellStyle(csBold);
//
// c = row.createCell(10);
// c.setCellValue("OUTOFPROJ");
// c.setCellStyle(csBold);
//
// rowIndex++;
// return rowIndex;
// }
//
// private int insertDetailInfo(HSSFSheet sheet, int index,String recName , String recLoc, String recCount) {
//
// HSSFRow row = null;
// HSSFCell c = null;
// row = sheet.createRow(index);
//
// c = row.createCell(0);
// c.setCellValue(recName);
// c.setCellStyle(cs);
//
// c = row.createCell(1);
// c.setCellValue(recLoc);
// c.setCellStyle(cs);
//
// StringTokenizer st = new StringTokenizer(recCount,",");
// int i=2;
// while(st.hasMoreTokens()){
// c = row.createCell(i);
// c.setCellValue(st.nextToken());
// c.setCellStyle(cs);
// i =i+1;
// }
// return index;
// }
//
// private int insertDetailInfoTotal(HSSFSheet sheet, int index,String columnRow) {
// HSSFRow row = null;
// HSSFCell c = null;
// row = sheet.createRow(index+1);
//
// c = row.createCell(0);
// c.setCellValue("TOTAL:");
// c.setCellStyle(csBold);
//
// StringTokenizer st1 = new StringTokenizer(columnRow,",");
//
// int i=2;
// while(st1.hasMoreTokens()){
// c = row.createCell(i);
// c.setCellValue(st1.nextToken());
// c.setCellStyle(cs);
// i =i+1;
// }
// return index;
// }
//
// private int insertRecSubmittalsInfo(HSSFSheet sheet, int index, Map<String,String> recData, Map<String,Integer> submittalTotalsByUser,Map<String, Map<SubmittalStatus,Integer>> submittalsByRecruiter) {
//
// int rowIndex = 0;
// Integer recBDMREJ = 0;
// Integer recOUTOFPROJ = 0;
// Integer recACCEPTED = 0;
// Integer recSUBMITTED =0;
// Integer recINTERVIEWING= 0;
// Integer recCONFIRMED = 0;
// Integer recSTARTED= 0;
// Integer recBACKOUT = 0;
// Integer recCLOSED = 0;
// Integer recREJECTED = 0;
// Integer recACCEPTEDTotal = 0;
// Integer recSUBMITTEDTotal =0;
// Integer recINTERVIEWINGTotal= 0;
// Integer recCONFIRMEDTotal = 0;
// Integer recSTARTEDTotal= 0;
// Integer recBACKOUTTotal= 0;
// Integer recREJECTEDTotal = 0;
// Integer recBDMREJTotal = 0;
// Integer recOUTOFPROJTotal = 0;
// String strRow = null;
// String recCount = null;
// String recColValue = null;
// int total =0;
// int count = 0;
// String columnRow = null;
// try {
// for (Map.Entry<String,Map<SubmittalStatus, Integer> > entry : submittalsByRecruiter.entrySet()){
// rowIndex = rowIndex + 1;
// String recName = entry.getKey();
// String recLoc = recData.get(recName);
// for(Map.Entry<SubmittalStatus,Integer> submittedEntry : entry.getValue().entrySet()){
// if((submittedEntry.getKey()).toString().equals("SUBMITTED")){
// recSUBMITTED = submittedEntry.getValue();
// recSUBMITTEDTotal = recSUBMITTEDTotal + recSUBMITTED;
// }else if((submittedEntry.getKey()).toString().equals("DMREJ")){
// recBDMREJ = submittedEntry.getValue();
// recBDMREJTotal = recBDMREJTotal + recBDMREJ;
// }else if((submittedEntry.getKey()).toString().equals("ACCEPTED")){
// recACCEPTED = submittedEntry.getValue();
// recACCEPTEDTotal = recACCEPTEDTotal + recACCEPTED;
// }else if((submittedEntry.getKey()).toString().equals("INTERVIEWING")){
// recINTERVIEWING = submittedEntry.getValue();
// recINTERVIEWINGTotal = recINTERVIEWINGTotal + recINTERVIEWING;
// }else if((submittedEntry.getKey()).toString().equals("CONFIRMED")){
// recCONFIRMED = submittedEntry.getValue();
// recCONFIRMEDTotal = recCONFIRMEDTotal + recCONFIRMED;
// }else if((submittedEntry.getKey()).toString().equals("STARTED")){
// recSTARTED = submittedEntry.getValue();
// recSTARTEDTotal = recSTARTEDTotal + recSTARTED;
// }else if((submittedEntry.getKey()).toString().equals("BACKOUT")){
// recBACKOUT = submittedEntry.getValue();
// recBACKOUTTotal = recBACKOUTTotal + recBACKOUT;
// }else if((submittedEntry.getKey()).toString().equals("REJECTED")){
// recREJECTED = submittedEntry.getValue();
// recREJECTEDTotal = recREJECTEDTotal + recREJECTED;
// }else if((submittedEntry.getKey()).toString().equals("OUTOFPROJ")){
// recOUTOFPROJ = submittedEntry.getValue();
// recOUTOFPROJTotal = recOUTOFPROJTotal + recOUTOFPROJ;
// }
// }
// total = recSUBMITTED+recBDMREJ+recACCEPTED+recINTERVIEWING+recCONFIRMED+recSTARTED+recBACKOUT+recREJECTED+recOUTOFPROJ;
// count = recSUBMITTEDTotal+recBDMREJTotal+recACCEPTEDTotal+recINTERVIEWINGTotal+recCONFIRMEDTotal+recSTARTEDTotal+recBACKOUTTotal+recOUTOFPROJTotal+recREJECTEDTotal;
// strRow = recSUBMITTED+","+recBDMREJ+","+recACCEPTED+","+recINTERVIEWING+","+recCONFIRMED+","+recREJECTED+","+recSTARTED+","+recBACKOUT+","+recOUTOFPROJ+","+total;
// recCount = total +","+recBDMREJ+","+recACCEPTED+","+recINTERVIEWING+","+recCONFIRMED+","+recREJECTED+","+recSTARTED+","+recBACKOUT+","+recOUTOFPROJ;
// insertDetailInfo(sheet, rowIndex,recName,recLoc,recCount);
// }
// columnRow = recSUBMITTEDTotal+","+recBDMREJTotal+","+recACCEPTEDTotal+","+recINTERVIEWINGTotal+","+recCONFIRMEDTotal+","+recREJECTEDTotal+","+recSTARTEDTotal+","+recBACKOUTTotal+","+recOUTOFPROJTotal+","+count;
// recColValue = count+","+recBDMREJTotal+","+recACCEPTEDTotal+","+recINTERVIEWINGTotal+","+recCONFIRMEDTotal+","+recREJECTEDTotal+","+recSTARTEDTotal+","+recBACKOUTTotal+","+recOUTOFPROJTotal;
// insertDetailInfoTotal(sheet, rowIndex,recColValue);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return rowIndex;
// }
//}
| 10,882 | 0.663205 | 0.651167 | 293 | 35.139931 | 32.603695 | 216 | false | false | 0 | 0 | 0 | 0 | 155 | 0.024352 | 3.269624 | false | false |
10
|
505a33d6616b6e26b99c1b5110bed2821397cad8
| 29,918,742,214,018 |
5358dab7aedfe9ff1ac13a4d4e2315221ca94f8d
|
/src/abstraction/HourlySalaryEmp.java
|
85fdb47710366b3f3d3fc47a36316610ad2cb5d3
|
[] |
no_license
|
TheHasnatBD/JavaBasicCode
|
https://github.com/TheHasnatBD/JavaBasicCode
|
30a026e0c95a7729e898058db8720c0fb16799e1
|
f91ba28761b234de45f74f4b7afb5d63b0217e24
|
refs/heads/master
| 2021-03-27T15:41:08.888000 | 2018-08-04T18:01:02 | 2018-08-04T18:01:02 | 124,214,845 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package abstraction;
public class HourlySalaryEmp extends Employee {
private double hour_rate, total_hour;
public HourlySalaryEmp(String name, String id, double hour_rate, double total_hour) {
super(name, id);
this.hour_rate = hour_rate;
this.total_hour = total_hour;
}
public double getHour_rate() {
return hour_rate;
}
public void setHour_rate(double hour_rate) {
this.hour_rate = hour_rate;
}
public double getTotal_hour() {
return total_hour;
}
public void setTotal_hour(double total_hour) {
this.total_hour = total_hour;
}
@Override
public double getSalary() {
return getHour_rate() * getTotal_hour();
}
}
|
UTF-8
|
Java
| 741 |
java
|
HourlySalaryEmp.java
|
Java
|
[] | null |
[] |
package abstraction;
public class HourlySalaryEmp extends Employee {
private double hour_rate, total_hour;
public HourlySalaryEmp(String name, String id, double hour_rate, double total_hour) {
super(name, id);
this.hour_rate = hour_rate;
this.total_hour = total_hour;
}
public double getHour_rate() {
return hour_rate;
}
public void setHour_rate(double hour_rate) {
this.hour_rate = hour_rate;
}
public double getTotal_hour() {
return total_hour;
}
public void setTotal_hour(double total_hour) {
this.total_hour = total_hour;
}
@Override
public double getSalary() {
return getHour_rate() * getTotal_hour();
}
}
| 741 | 0.618084 | 0.618084 | 35 | 20.171429 | 21.250191 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false |
10
|
862ca0ae188d45e6a99a149575fc08d5f62d0864
| 29,918,742,215,014 |
ecdd66391f206c348dbeb3d527922bde30e49a67
|
/my_web_project/src/main/java/my/project/servlet/employee/EmployeeListServlet.java
|
c6e1ae594fefec7256dd3eb09bc948106edec5f5
|
[] |
no_license
|
iharMarkevich/learning_web_java
|
https://github.com/iharMarkevich/learning_web_java
|
bee3df5c7267f1b64e44c095ff1cfcac8ee3af9f
|
b72a90ddae2142094133ab98e1370b0becdc426d
|
refs/heads/master
| 2023-06-05T00:35:41.573000 | 2021-06-26T07:02:27 | 2021-06-26T07:02:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package my.project.servlet.employee;
import my.project.entity.Employee;
import my.project.service.employee.entity.EmployeeService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/employees")
public class EmployeeListServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
List<Employee> employeeList = new EmployeeService().readAllEmployee();
req.setAttribute("employeesList", employeeList);
req.getRequestDispatcher("/pages/employee/employees/index.jsp").forward(req, resp);
}
@Override
public void destroy() {
super.destroy();
}
}
|
UTF-8
|
Java
| 922 |
java
|
EmployeeListServlet.java
|
Java
|
[] | null |
[] |
package my.project.servlet.employee;
import my.project.entity.Employee;
import my.project.service.employee.entity.EmployeeService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/employees")
public class EmployeeListServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
List<Employee> employeeList = new EmployeeService().readAllEmployee();
req.setAttribute("employeesList", employeeList);
req.getRequestDispatcher("/pages/employee/employees/index.jsp").forward(req, resp);
}
@Override
public void destroy() {
super.destroy();
}
}
| 922 | 0.77115 | 0.77115 | 28 | 31.928572 | 28.86165 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.642857 | false | false |
10
|
f851cdfee076bbe6764f4093f38ca50288d44584
| 4,724,464,039,605 |
28a94f2591590f196f2d0ea2317270525a1d53bb
|
/core-java-14/src/main/java/com/ripjava/textblocks/TextBlocks.java
|
ddcb30f43efd8003d410eed86142cee8894ef6f7
|
[] |
no_license
|
peijd/tutorials
|
https://github.com/peijd/tutorials
|
e6843365693858709fdc3780e205f91ebe88bc35
|
8249bd2a825ca7231e825e49f9ea59ecb7c7c318
|
refs/heads/master
| 2022-12-22T14:02:55.076000 | 2021-12-01T13:25:27 | 2021-12-01T13:25:27 | 189,739,040 | 2 | 1 | null | false | 2022-12-16T15:45:21 | 2019-06-01T13:57:53 | 2021-12-01T14:04:18 | 2022-12-16T15:45:18 | 405 | 1 | 1 | 9 |
Java
| false | false |
package com.ripjava.textblocks;
public class TextBlocks {
public String getBlockOfHtml() {
return """
<html>
<body>
<span>example text</span>
</body>
</html>""";
}
}
|
UTF-8
|
Java
| 259 |
java
|
TextBlocks.java
|
Java
|
[] | null |
[] |
package com.ripjava.textblocks;
public class TextBlocks {
public String getBlockOfHtml() {
return """
<html>
<body>
<span>example text</span>
</body>
</html>""";
}
}
| 259 | 0.444015 | 0.444015 | 12 | 20.583334 | 13.034943 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false |
10
|
1a7a4f69e5a19a00946e3f79a3f7f25e5ab181ff
| 26,560,077,779,855 |
da3ee4dc84e7d87e4b32ad2e29a71a0dc1a52614
|
/Ejercicio3IsmaelJimenez/app/src/main/java/com/example/ejercicio3ismaeljimenez/MainActivity.java
|
eb4d43d053e926c4a8c6a6f2dd25120fc39141cb
|
[] |
no_license
|
CodeInBars/AndroidEjercicios
|
https://github.com/CodeInBars/AndroidEjercicios
|
78a20693f555996faceec4b23ec1591ed30e5299
|
1205f2beb7b752f0e03ac5586545815c6a3c4b67
|
refs/heads/master
| 2021-01-02T07:26:09.987000 | 2020-02-10T15:43:48 | 2020-02-10T15:43:48 | 239,547,156 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.ejercicio3ismaeljimenez;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Spinner spin;
Button btnActivity;
String mes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spin = findViewById(R.id.spinner);
btnActivity = findViewById(R.id.btnActivity);
ArrayAdapter ar = new ArrayAdapter(MainActivity.this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.meses));
spin.setAdapter(ar);
spin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mes = spin.getItemAtPosition(position).toString();
Toast.makeText(MainActivity.this, "Mes: " + mes, Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
btnActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Main2Activity.class);
myIntent.putExtra("mes", mes);
startActivity(myIntent);
}
});
}
}
|
UTF-8
|
Java
| 1,730 |
java
|
MainActivity.java
|
Java
|
[] | null |
[] |
package com.example.ejercicio3ismaeljimenez;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Spinner spin;
Button btnActivity;
String mes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spin = findViewById(R.id.spinner);
btnActivity = findViewById(R.id.btnActivity);
ArrayAdapter ar = new ArrayAdapter(MainActivity.this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.meses));
spin.setAdapter(ar);
spin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mes = spin.getItemAtPosition(position).toString();
Toast.makeText(MainActivity.this, "Mes: " + mes, Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
btnActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Main2Activity.class);
myIntent.putExtra("mes", mes);
startActivity(myIntent);
}
});
}
}
| 1,730 | 0.663006 | 0.66185 | 55 | 30.454546 | 30.309805 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false |
10
|
c866c2d095b008b1eea35292ab1509ad400b03fa
| 9,509,057,650,549 |
75f339023e775778e437cbfcffa6f68df1d2891c
|
/sources/org/lwjgl/opengl/MacOSXNativeKeyboard.java
|
5bf1d07d5adacf5fc065ce5e25ef76cabd654cd2
|
[] |
no_license
|
KamenkoTV/Qlauncher-mcpc-android
|
https://github.com/KamenkoTV/Qlauncher-mcpc-android
|
ebf08f2ca7a0fd0ef0eff7f6b725cb68cb1e09fe
|
338f5c19a38a679dd52c4b45a76cc83de155152f
|
refs/heads/master
| 2020-09-02T10:09:10.560000 | 2019-11-02T18:29:59 | 2019-11-02T18:29:59 | 219,195,220 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.lwjgl.opengl;
import java.awt.event.KeyEvent;
import java.io.PrintStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.HashMap;
final class MacOSXNativeKeyboard extends EventQueue {
private int deferred_character;
private int deferred_key_code;
private byte deferred_key_state;
private long deferred_nanos;
private final ByteBuffer event = ByteBuffer.allocate(18);
private boolean has_deferred_event;
private final byte[] key_states = new byte[256];
private HashMap<Short, Integer> nativeToLwjglMap;
private ByteBuffer window_handle;
MacOSXNativeKeyboard(ByteBuffer byteBuffer) {
HashMap<Short, Integer> hashMap;
ByteBuffer byteBuffer2 = byteBuffer;
super(18);
HashMap<Short, Integer> hashMap2 = hashMap;
HashMap<Short, Integer> hashMap3 = new HashMap<>();
this.nativeToLwjglMap = hashMap2;
initKeyboardMappings();
this.window_handle = byteBuffer2;
}
private void flushDeferredEvent() {
if (this.has_deferred_event) {
putKeyEvent(this.deferred_key_code, this.deferred_key_state, this.deferred_character, this.deferred_nanos, false);
this.has_deferred_event = false;
}
}
private int getMappedKeyCode(short s) {
short s2 = s;
if (this.nativeToLwjglMap.containsKey(Short.valueOf(s2))) {
return ((Integer) this.nativeToLwjglMap.get(Short.valueOf(s2))).intValue();
}
return -1;
}
/* JADX INFO: finally extract failed */
private void handleKey(int i, byte b, int i2, long j) {
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
synchronized (this) {
if (i4 == 65535) {
i4 = 0;
}
if (b2 == 1) {
try {
boolean z = false;
if (this.has_deferred_event) {
if (j2 == this.deferred_nanos && this.deferred_key_code == i3) {
this.has_deferred_event = false;
z = true;
} else {
flushDeferredEvent();
z = false;
}
}
putKeyEvent(i3, b2, i4, j2, z);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
} else {
flushDeferredEvent();
this.has_deferred_event = true;
this.deferred_nanos = j2;
this.deferred_key_code = i3;
this.deferred_key_state = b2;
this.deferred_character = i4;
}
}
}
private void initKeyboardMappings() {
Object put = this.nativeToLwjglMap.put(Short.valueOf(29), Integer.valueOf(11));
Object put2 = this.nativeToLwjglMap.put(Short.valueOf(18), Integer.valueOf(2));
Object put3 = this.nativeToLwjglMap.put(Short.valueOf(19), Integer.valueOf(3));
Object put4 = this.nativeToLwjglMap.put(Short.valueOf(20), Integer.valueOf(4));
Object put5 = this.nativeToLwjglMap.put(Short.valueOf(21), Integer.valueOf(5));
Object put6 = this.nativeToLwjglMap.put(Short.valueOf(23), Integer.valueOf(6));
Object put7 = this.nativeToLwjglMap.put(Short.valueOf(22), Integer.valueOf(7));
Object put8 = this.nativeToLwjglMap.put(Short.valueOf(26), Integer.valueOf(8));
Object put9 = this.nativeToLwjglMap.put(Short.valueOf(28), Integer.valueOf(9));
Object put10 = this.nativeToLwjglMap.put(Short.valueOf(25), Integer.valueOf(10));
Object put11 = this.nativeToLwjglMap.put(Short.valueOf(0), Integer.valueOf(30));
Object put12 = this.nativeToLwjglMap.put(Short.valueOf(11), Integer.valueOf(48));
Object put13 = this.nativeToLwjglMap.put(Short.valueOf(8), Integer.valueOf(46));
Object put14 = this.nativeToLwjglMap.put(Short.valueOf(2), Integer.valueOf(32));
Object put15 = this.nativeToLwjglMap.put(Short.valueOf(14), Integer.valueOf(18));
Object put16 = this.nativeToLwjglMap.put(Short.valueOf(3), Integer.valueOf(33));
Object put17 = this.nativeToLwjglMap.put(Short.valueOf(5), Integer.valueOf(34));
Object put18 = this.nativeToLwjglMap.put(Short.valueOf(4), Integer.valueOf(35));
Object put19 = this.nativeToLwjglMap.put(Short.valueOf(34), Integer.valueOf(23));
Object put20 = this.nativeToLwjglMap.put(Short.valueOf(38), Integer.valueOf(36));
Object put21 = this.nativeToLwjglMap.put(Short.valueOf(40), Integer.valueOf(37));
Object put22 = this.nativeToLwjglMap.put(Short.valueOf(37), Integer.valueOf(38));
Object put23 = this.nativeToLwjglMap.put(Short.valueOf(46), Integer.valueOf(50));
Object put24 = this.nativeToLwjglMap.put(Short.valueOf(45), Integer.valueOf(49));
Object put25 = this.nativeToLwjglMap.put(Short.valueOf(31), Integer.valueOf(24));
Object put26 = this.nativeToLwjglMap.put(Short.valueOf(35), Integer.valueOf(25));
Object put27 = this.nativeToLwjglMap.put(Short.valueOf(12), Integer.valueOf(16));
Object put28 = this.nativeToLwjglMap.put(Short.valueOf(15), Integer.valueOf(19));
Object put29 = this.nativeToLwjglMap.put(Short.valueOf(1), Integer.valueOf(31));
Object put30 = this.nativeToLwjglMap.put(Short.valueOf(17), Integer.valueOf(20));
Object put31 = this.nativeToLwjglMap.put(Short.valueOf(32), Integer.valueOf(22));
Object put32 = this.nativeToLwjglMap.put(Short.valueOf(9), Integer.valueOf(47));
Object put33 = this.nativeToLwjglMap.put(Short.valueOf(13), Integer.valueOf(17));
Object put34 = this.nativeToLwjglMap.put(Short.valueOf(7), Integer.valueOf(45));
Object put35 = this.nativeToLwjglMap.put(Short.valueOf(16), Integer.valueOf(21));
Object put36 = this.nativeToLwjglMap.put(Short.valueOf(6), Integer.valueOf(44));
Object put37 = this.nativeToLwjglMap.put(Short.valueOf(42), Integer.valueOf(43));
Object put38 = this.nativeToLwjglMap.put(Short.valueOf(43), Integer.valueOf(51));
Object put39 = this.nativeToLwjglMap.put(Short.valueOf(24), Integer.valueOf(13));
Object put40 = this.nativeToLwjglMap.put(Short.valueOf(33), Integer.valueOf(26));
Object put41 = this.nativeToLwjglMap.put(Short.valueOf(27), Integer.valueOf(12));
Object put42 = this.nativeToLwjglMap.put(Short.valueOf(39), Integer.valueOf(40));
Object put43 = this.nativeToLwjglMap.put(Short.valueOf(30), Integer.valueOf(27));
Object put44 = this.nativeToLwjglMap.put(Short.valueOf(41), Integer.valueOf(39));
Object put45 = this.nativeToLwjglMap.put(Short.valueOf(44), Integer.valueOf(53));
Object put46 = this.nativeToLwjglMap.put(Short.valueOf(47), Integer.valueOf(52));
Object put47 = this.nativeToLwjglMap.put(Short.valueOf(50), Integer.valueOf(144));
Object put48 = this.nativeToLwjglMap.put(Short.valueOf(65), Integer.valueOf(83));
Object put49 = this.nativeToLwjglMap.put(Short.valueOf(67), Integer.valueOf(55));
Object put50 = this.nativeToLwjglMap.put(Short.valueOf(69), Integer.valueOf(78));
Object put51 = this.nativeToLwjglMap.put(Short.valueOf(71), Integer.valueOf(218));
Object put52 = this.nativeToLwjglMap.put(Short.valueOf(75), Integer.valueOf(181));
Object put53 = this.nativeToLwjglMap.put(Short.valueOf(76), Integer.valueOf(156));
Object put54 = this.nativeToLwjglMap.put(Short.valueOf(78), Integer.valueOf(74));
Object put55 = this.nativeToLwjglMap.put(Short.valueOf(81), Integer.valueOf(141));
Object put56 = this.nativeToLwjglMap.put(Short.valueOf(82), Integer.valueOf(82));
Object put57 = this.nativeToLwjglMap.put(Short.valueOf(83), Integer.valueOf(79));
Object put58 = this.nativeToLwjglMap.put(Short.valueOf(84), Integer.valueOf(80));
Object put59 = this.nativeToLwjglMap.put(Short.valueOf(85), Integer.valueOf(81));
Object put60 = this.nativeToLwjglMap.put(Short.valueOf(86), Integer.valueOf(75));
Object put61 = this.nativeToLwjglMap.put(Short.valueOf(87), Integer.valueOf(76));
Object put62 = this.nativeToLwjglMap.put(Short.valueOf(88), Integer.valueOf(77));
Object put63 = this.nativeToLwjglMap.put(Short.valueOf(89), Integer.valueOf(71));
Object put64 = this.nativeToLwjglMap.put(Short.valueOf(91), Integer.valueOf(72));
Object put65 = this.nativeToLwjglMap.put(Short.valueOf(92), Integer.valueOf(73));
Object put66 = this.nativeToLwjglMap.put(Short.valueOf(36), Integer.valueOf(28));
Object put67 = this.nativeToLwjglMap.put(Short.valueOf(48), Integer.valueOf(15));
Object put68 = this.nativeToLwjglMap.put(Short.valueOf(49), Integer.valueOf(57));
Object put69 = this.nativeToLwjglMap.put(Short.valueOf(51), Integer.valueOf(14));
Object put70 = this.nativeToLwjglMap.put(Short.valueOf(53), Integer.valueOf(1));
Object put71 = this.nativeToLwjglMap.put(Short.valueOf(54), Integer.valueOf(220));
Object put72 = this.nativeToLwjglMap.put(Short.valueOf(55), Integer.valueOf(219));
Object put73 = this.nativeToLwjglMap.put(Short.valueOf(56), Integer.valueOf(42));
Object put74 = this.nativeToLwjglMap.put(Short.valueOf(57), Integer.valueOf(58));
Object put75 = this.nativeToLwjglMap.put(Short.valueOf(58), Integer.valueOf(56));
Object put76 = this.nativeToLwjglMap.put(Short.valueOf(59), Integer.valueOf(29));
Object put77 = this.nativeToLwjglMap.put(Short.valueOf(60), Integer.valueOf(54));
Object put78 = this.nativeToLwjglMap.put(Short.valueOf(61), Integer.valueOf(184));
Object put79 = this.nativeToLwjglMap.put(Short.valueOf(62), Integer.valueOf(157));
Object put80 = this.nativeToLwjglMap.put(Short.valueOf(63), Integer.valueOf(196));
Object put81 = this.nativeToLwjglMap.put(Short.valueOf(119), Integer.valueOf(207));
Object put82 = this.nativeToLwjglMap.put(Short.valueOf(122), Integer.valueOf(59));
Object put83 = this.nativeToLwjglMap.put(Short.valueOf(120), Integer.valueOf(60));
Object put84 = this.nativeToLwjglMap.put(Short.valueOf(99), Integer.valueOf(61));
Object put85 = this.nativeToLwjglMap.put(Short.valueOf(118), Integer.valueOf(62));
Object put86 = this.nativeToLwjglMap.put(Short.valueOf(96), Integer.valueOf(63));
Object put87 = this.nativeToLwjglMap.put(Short.valueOf(97), Integer.valueOf(64));
Object put88 = this.nativeToLwjglMap.put(Short.valueOf(98), Integer.valueOf(65));
Object put89 = this.nativeToLwjglMap.put(Short.valueOf(100), Integer.valueOf(66));
Object put90 = this.nativeToLwjglMap.put(Short.valueOf(101), Integer.valueOf(67));
Object put91 = this.nativeToLwjglMap.put(Short.valueOf(109), Integer.valueOf(68));
Object put92 = this.nativeToLwjglMap.put(Short.valueOf(103), Integer.valueOf(87));
Object put93 = this.nativeToLwjglMap.put(Short.valueOf(111), Integer.valueOf(88));
Object put94 = this.nativeToLwjglMap.put(Short.valueOf(105), Integer.valueOf(100));
Object put95 = this.nativeToLwjglMap.put(Short.valueOf(107), Integer.valueOf(101));
Object put96 = this.nativeToLwjglMap.put(Short.valueOf(113), Integer.valueOf(102));
Object put97 = this.nativeToLwjglMap.put(Short.valueOf(106), Integer.valueOf(103));
Object put98 = this.nativeToLwjglMap.put(Short.valueOf(64), Integer.valueOf(104));
Object put99 = this.nativeToLwjglMap.put(Short.valueOf(79), Integer.valueOf(105));
Object put100 = this.nativeToLwjglMap.put(Short.valueOf(80), Integer.valueOf(113));
Object put101 = this.nativeToLwjglMap.put(Short.valueOf(117), Integer.valueOf(211));
Object put102 = this.nativeToLwjglMap.put(Short.valueOf(114), Integer.valueOf(210));
Object put103 = this.nativeToLwjglMap.put(Short.valueOf(115), Integer.valueOf(199));
Object put104 = this.nativeToLwjglMap.put(Short.valueOf(121), Integer.valueOf(209));
Object put105 = this.nativeToLwjglMap.put(Short.valueOf(116), Integer.valueOf(201));
Object put106 = this.nativeToLwjglMap.put(Short.valueOf(123), Integer.valueOf(203));
Object put107 = this.nativeToLwjglMap.put(Short.valueOf(124), Integer.valueOf(205));
Object put108 = this.nativeToLwjglMap.put(Short.valueOf(125), Integer.valueOf(208));
Object put109 = this.nativeToLwjglMap.put(Short.valueOf(126), Integer.valueOf(200));
Object put110 = this.nativeToLwjglMap.put(Short.valueOf(10), Integer.valueOf(167));
Object put111 = this.nativeToLwjglMap.put(Short.valueOf(110), Integer.valueOf(221));
Object put112 = this.nativeToLwjglMap.put(Short.valueOf(297), Integer.valueOf(146));
}
private native void nRegisterKeyListener(ByteBuffer byteBuffer);
private native void nUnregisterKeyListener(ByteBuffer byteBuffer);
public void copyEvents(ByteBuffer byteBuffer) {
ByteBuffer byteBuffer2 = byteBuffer;
synchronized (this) {
try {
flushDeferredEvent();
super.copyEvents(byteBuffer2);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
}
}
public void keyPressed(int i, int i2, long j) {
handleKey(i, 1, i2, j);
}
public void keyReleased(int i, int i2, long j) {
handleKey(i, 0, i2, j);
}
public void keyTyped(KeyEvent keyEvent) {
}
public void poll(ByteBuffer byteBuffer) {
ByteBuffer byteBuffer2 = byteBuffer;
synchronized (this) {
try {
flushDeferredEvent();
int position = byteBuffer2.position();
ByteBuffer put = byteBuffer2.put(this.key_states);
Buffer position2 = byteBuffer2.position(position);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
}
}
public void putKeyEvent(int i, byte b, int i2, long j, boolean z) {
StringBuilder sb;
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
boolean z2 = z;
int mappedKeyCode = getMappedKeyCode((short) i3);
if (mappedKeyCode < 0) {
PrintStream printStream = System.out;
StringBuilder sb2 = sb;
StringBuilder sb3 = new StringBuilder();
printStream.println(sb2.append("Unrecognized keycode: ").append(i3).toString());
return;
}
if (this.key_states[mappedKeyCode] == b2) {
z2 = true;
}
this.key_states[mappedKeyCode] = b2;
putKeyboardEvent(mappedKeyCode, b2, i4 & 65535, j2, z2);
}
public void putKeyboardEvent(int i, byte b, int i2, long j, boolean z) {
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
boolean z2 = z;
Buffer clear = this.event.clear();
ByteBuffer put = this.event.putInt(i3).put(b2).putInt(i4).putLong(j2).put(z2 ? (byte) 1 : 0);
Buffer flip = this.event.flip();
boolean putEvent = putEvent(this.event);
}
public void register() {
nRegisterKeyListener(this.window_handle);
}
public void unregister() {
nUnregisterKeyListener(this.window_handle);
}
}
|
UTF-8
|
Java
| 15,573 |
java
|
MacOSXNativeKeyboard.java
|
Java
|
[] | null |
[] |
package org.lwjgl.opengl;
import java.awt.event.KeyEvent;
import java.io.PrintStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.HashMap;
final class MacOSXNativeKeyboard extends EventQueue {
private int deferred_character;
private int deferred_key_code;
private byte deferred_key_state;
private long deferred_nanos;
private final ByteBuffer event = ByteBuffer.allocate(18);
private boolean has_deferred_event;
private final byte[] key_states = new byte[256];
private HashMap<Short, Integer> nativeToLwjglMap;
private ByteBuffer window_handle;
MacOSXNativeKeyboard(ByteBuffer byteBuffer) {
HashMap<Short, Integer> hashMap;
ByteBuffer byteBuffer2 = byteBuffer;
super(18);
HashMap<Short, Integer> hashMap2 = hashMap;
HashMap<Short, Integer> hashMap3 = new HashMap<>();
this.nativeToLwjglMap = hashMap2;
initKeyboardMappings();
this.window_handle = byteBuffer2;
}
private void flushDeferredEvent() {
if (this.has_deferred_event) {
putKeyEvent(this.deferred_key_code, this.deferred_key_state, this.deferred_character, this.deferred_nanos, false);
this.has_deferred_event = false;
}
}
private int getMappedKeyCode(short s) {
short s2 = s;
if (this.nativeToLwjglMap.containsKey(Short.valueOf(s2))) {
return ((Integer) this.nativeToLwjglMap.get(Short.valueOf(s2))).intValue();
}
return -1;
}
/* JADX INFO: finally extract failed */
private void handleKey(int i, byte b, int i2, long j) {
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
synchronized (this) {
if (i4 == 65535) {
i4 = 0;
}
if (b2 == 1) {
try {
boolean z = false;
if (this.has_deferred_event) {
if (j2 == this.deferred_nanos && this.deferred_key_code == i3) {
this.has_deferred_event = false;
z = true;
} else {
flushDeferredEvent();
z = false;
}
}
putKeyEvent(i3, b2, i4, j2, z);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
} else {
flushDeferredEvent();
this.has_deferred_event = true;
this.deferred_nanos = j2;
this.deferred_key_code = i3;
this.deferred_key_state = b2;
this.deferred_character = i4;
}
}
}
private void initKeyboardMappings() {
Object put = this.nativeToLwjglMap.put(Short.valueOf(29), Integer.valueOf(11));
Object put2 = this.nativeToLwjglMap.put(Short.valueOf(18), Integer.valueOf(2));
Object put3 = this.nativeToLwjglMap.put(Short.valueOf(19), Integer.valueOf(3));
Object put4 = this.nativeToLwjglMap.put(Short.valueOf(20), Integer.valueOf(4));
Object put5 = this.nativeToLwjglMap.put(Short.valueOf(21), Integer.valueOf(5));
Object put6 = this.nativeToLwjglMap.put(Short.valueOf(23), Integer.valueOf(6));
Object put7 = this.nativeToLwjglMap.put(Short.valueOf(22), Integer.valueOf(7));
Object put8 = this.nativeToLwjglMap.put(Short.valueOf(26), Integer.valueOf(8));
Object put9 = this.nativeToLwjglMap.put(Short.valueOf(28), Integer.valueOf(9));
Object put10 = this.nativeToLwjglMap.put(Short.valueOf(25), Integer.valueOf(10));
Object put11 = this.nativeToLwjglMap.put(Short.valueOf(0), Integer.valueOf(30));
Object put12 = this.nativeToLwjglMap.put(Short.valueOf(11), Integer.valueOf(48));
Object put13 = this.nativeToLwjglMap.put(Short.valueOf(8), Integer.valueOf(46));
Object put14 = this.nativeToLwjglMap.put(Short.valueOf(2), Integer.valueOf(32));
Object put15 = this.nativeToLwjglMap.put(Short.valueOf(14), Integer.valueOf(18));
Object put16 = this.nativeToLwjglMap.put(Short.valueOf(3), Integer.valueOf(33));
Object put17 = this.nativeToLwjglMap.put(Short.valueOf(5), Integer.valueOf(34));
Object put18 = this.nativeToLwjglMap.put(Short.valueOf(4), Integer.valueOf(35));
Object put19 = this.nativeToLwjglMap.put(Short.valueOf(34), Integer.valueOf(23));
Object put20 = this.nativeToLwjglMap.put(Short.valueOf(38), Integer.valueOf(36));
Object put21 = this.nativeToLwjglMap.put(Short.valueOf(40), Integer.valueOf(37));
Object put22 = this.nativeToLwjglMap.put(Short.valueOf(37), Integer.valueOf(38));
Object put23 = this.nativeToLwjglMap.put(Short.valueOf(46), Integer.valueOf(50));
Object put24 = this.nativeToLwjglMap.put(Short.valueOf(45), Integer.valueOf(49));
Object put25 = this.nativeToLwjglMap.put(Short.valueOf(31), Integer.valueOf(24));
Object put26 = this.nativeToLwjglMap.put(Short.valueOf(35), Integer.valueOf(25));
Object put27 = this.nativeToLwjglMap.put(Short.valueOf(12), Integer.valueOf(16));
Object put28 = this.nativeToLwjglMap.put(Short.valueOf(15), Integer.valueOf(19));
Object put29 = this.nativeToLwjglMap.put(Short.valueOf(1), Integer.valueOf(31));
Object put30 = this.nativeToLwjglMap.put(Short.valueOf(17), Integer.valueOf(20));
Object put31 = this.nativeToLwjglMap.put(Short.valueOf(32), Integer.valueOf(22));
Object put32 = this.nativeToLwjglMap.put(Short.valueOf(9), Integer.valueOf(47));
Object put33 = this.nativeToLwjglMap.put(Short.valueOf(13), Integer.valueOf(17));
Object put34 = this.nativeToLwjglMap.put(Short.valueOf(7), Integer.valueOf(45));
Object put35 = this.nativeToLwjglMap.put(Short.valueOf(16), Integer.valueOf(21));
Object put36 = this.nativeToLwjglMap.put(Short.valueOf(6), Integer.valueOf(44));
Object put37 = this.nativeToLwjglMap.put(Short.valueOf(42), Integer.valueOf(43));
Object put38 = this.nativeToLwjglMap.put(Short.valueOf(43), Integer.valueOf(51));
Object put39 = this.nativeToLwjglMap.put(Short.valueOf(24), Integer.valueOf(13));
Object put40 = this.nativeToLwjglMap.put(Short.valueOf(33), Integer.valueOf(26));
Object put41 = this.nativeToLwjglMap.put(Short.valueOf(27), Integer.valueOf(12));
Object put42 = this.nativeToLwjglMap.put(Short.valueOf(39), Integer.valueOf(40));
Object put43 = this.nativeToLwjglMap.put(Short.valueOf(30), Integer.valueOf(27));
Object put44 = this.nativeToLwjglMap.put(Short.valueOf(41), Integer.valueOf(39));
Object put45 = this.nativeToLwjglMap.put(Short.valueOf(44), Integer.valueOf(53));
Object put46 = this.nativeToLwjglMap.put(Short.valueOf(47), Integer.valueOf(52));
Object put47 = this.nativeToLwjglMap.put(Short.valueOf(50), Integer.valueOf(144));
Object put48 = this.nativeToLwjglMap.put(Short.valueOf(65), Integer.valueOf(83));
Object put49 = this.nativeToLwjglMap.put(Short.valueOf(67), Integer.valueOf(55));
Object put50 = this.nativeToLwjglMap.put(Short.valueOf(69), Integer.valueOf(78));
Object put51 = this.nativeToLwjglMap.put(Short.valueOf(71), Integer.valueOf(218));
Object put52 = this.nativeToLwjglMap.put(Short.valueOf(75), Integer.valueOf(181));
Object put53 = this.nativeToLwjglMap.put(Short.valueOf(76), Integer.valueOf(156));
Object put54 = this.nativeToLwjglMap.put(Short.valueOf(78), Integer.valueOf(74));
Object put55 = this.nativeToLwjglMap.put(Short.valueOf(81), Integer.valueOf(141));
Object put56 = this.nativeToLwjglMap.put(Short.valueOf(82), Integer.valueOf(82));
Object put57 = this.nativeToLwjglMap.put(Short.valueOf(83), Integer.valueOf(79));
Object put58 = this.nativeToLwjglMap.put(Short.valueOf(84), Integer.valueOf(80));
Object put59 = this.nativeToLwjglMap.put(Short.valueOf(85), Integer.valueOf(81));
Object put60 = this.nativeToLwjglMap.put(Short.valueOf(86), Integer.valueOf(75));
Object put61 = this.nativeToLwjglMap.put(Short.valueOf(87), Integer.valueOf(76));
Object put62 = this.nativeToLwjglMap.put(Short.valueOf(88), Integer.valueOf(77));
Object put63 = this.nativeToLwjglMap.put(Short.valueOf(89), Integer.valueOf(71));
Object put64 = this.nativeToLwjglMap.put(Short.valueOf(91), Integer.valueOf(72));
Object put65 = this.nativeToLwjglMap.put(Short.valueOf(92), Integer.valueOf(73));
Object put66 = this.nativeToLwjglMap.put(Short.valueOf(36), Integer.valueOf(28));
Object put67 = this.nativeToLwjglMap.put(Short.valueOf(48), Integer.valueOf(15));
Object put68 = this.nativeToLwjglMap.put(Short.valueOf(49), Integer.valueOf(57));
Object put69 = this.nativeToLwjglMap.put(Short.valueOf(51), Integer.valueOf(14));
Object put70 = this.nativeToLwjglMap.put(Short.valueOf(53), Integer.valueOf(1));
Object put71 = this.nativeToLwjglMap.put(Short.valueOf(54), Integer.valueOf(220));
Object put72 = this.nativeToLwjglMap.put(Short.valueOf(55), Integer.valueOf(219));
Object put73 = this.nativeToLwjglMap.put(Short.valueOf(56), Integer.valueOf(42));
Object put74 = this.nativeToLwjglMap.put(Short.valueOf(57), Integer.valueOf(58));
Object put75 = this.nativeToLwjglMap.put(Short.valueOf(58), Integer.valueOf(56));
Object put76 = this.nativeToLwjglMap.put(Short.valueOf(59), Integer.valueOf(29));
Object put77 = this.nativeToLwjglMap.put(Short.valueOf(60), Integer.valueOf(54));
Object put78 = this.nativeToLwjglMap.put(Short.valueOf(61), Integer.valueOf(184));
Object put79 = this.nativeToLwjglMap.put(Short.valueOf(62), Integer.valueOf(157));
Object put80 = this.nativeToLwjglMap.put(Short.valueOf(63), Integer.valueOf(196));
Object put81 = this.nativeToLwjglMap.put(Short.valueOf(119), Integer.valueOf(207));
Object put82 = this.nativeToLwjglMap.put(Short.valueOf(122), Integer.valueOf(59));
Object put83 = this.nativeToLwjglMap.put(Short.valueOf(120), Integer.valueOf(60));
Object put84 = this.nativeToLwjglMap.put(Short.valueOf(99), Integer.valueOf(61));
Object put85 = this.nativeToLwjglMap.put(Short.valueOf(118), Integer.valueOf(62));
Object put86 = this.nativeToLwjglMap.put(Short.valueOf(96), Integer.valueOf(63));
Object put87 = this.nativeToLwjglMap.put(Short.valueOf(97), Integer.valueOf(64));
Object put88 = this.nativeToLwjglMap.put(Short.valueOf(98), Integer.valueOf(65));
Object put89 = this.nativeToLwjglMap.put(Short.valueOf(100), Integer.valueOf(66));
Object put90 = this.nativeToLwjglMap.put(Short.valueOf(101), Integer.valueOf(67));
Object put91 = this.nativeToLwjglMap.put(Short.valueOf(109), Integer.valueOf(68));
Object put92 = this.nativeToLwjglMap.put(Short.valueOf(103), Integer.valueOf(87));
Object put93 = this.nativeToLwjglMap.put(Short.valueOf(111), Integer.valueOf(88));
Object put94 = this.nativeToLwjglMap.put(Short.valueOf(105), Integer.valueOf(100));
Object put95 = this.nativeToLwjglMap.put(Short.valueOf(107), Integer.valueOf(101));
Object put96 = this.nativeToLwjglMap.put(Short.valueOf(113), Integer.valueOf(102));
Object put97 = this.nativeToLwjglMap.put(Short.valueOf(106), Integer.valueOf(103));
Object put98 = this.nativeToLwjglMap.put(Short.valueOf(64), Integer.valueOf(104));
Object put99 = this.nativeToLwjglMap.put(Short.valueOf(79), Integer.valueOf(105));
Object put100 = this.nativeToLwjglMap.put(Short.valueOf(80), Integer.valueOf(113));
Object put101 = this.nativeToLwjglMap.put(Short.valueOf(117), Integer.valueOf(211));
Object put102 = this.nativeToLwjglMap.put(Short.valueOf(114), Integer.valueOf(210));
Object put103 = this.nativeToLwjglMap.put(Short.valueOf(115), Integer.valueOf(199));
Object put104 = this.nativeToLwjglMap.put(Short.valueOf(121), Integer.valueOf(209));
Object put105 = this.nativeToLwjglMap.put(Short.valueOf(116), Integer.valueOf(201));
Object put106 = this.nativeToLwjglMap.put(Short.valueOf(123), Integer.valueOf(203));
Object put107 = this.nativeToLwjglMap.put(Short.valueOf(124), Integer.valueOf(205));
Object put108 = this.nativeToLwjglMap.put(Short.valueOf(125), Integer.valueOf(208));
Object put109 = this.nativeToLwjglMap.put(Short.valueOf(126), Integer.valueOf(200));
Object put110 = this.nativeToLwjglMap.put(Short.valueOf(10), Integer.valueOf(167));
Object put111 = this.nativeToLwjglMap.put(Short.valueOf(110), Integer.valueOf(221));
Object put112 = this.nativeToLwjglMap.put(Short.valueOf(297), Integer.valueOf(146));
}
private native void nRegisterKeyListener(ByteBuffer byteBuffer);
private native void nUnregisterKeyListener(ByteBuffer byteBuffer);
public void copyEvents(ByteBuffer byteBuffer) {
ByteBuffer byteBuffer2 = byteBuffer;
synchronized (this) {
try {
flushDeferredEvent();
super.copyEvents(byteBuffer2);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
}
}
public void keyPressed(int i, int i2, long j) {
handleKey(i, 1, i2, j);
}
public void keyReleased(int i, int i2, long j) {
handleKey(i, 0, i2, j);
}
public void keyTyped(KeyEvent keyEvent) {
}
public void poll(ByteBuffer byteBuffer) {
ByteBuffer byteBuffer2 = byteBuffer;
synchronized (this) {
try {
flushDeferredEvent();
int position = byteBuffer2.position();
ByteBuffer put = byteBuffer2.put(this.key_states);
Buffer position2 = byteBuffer2.position(position);
} catch (Throwable th) {
Throwable th2 = th;
throw th2;
}
}
}
public void putKeyEvent(int i, byte b, int i2, long j, boolean z) {
StringBuilder sb;
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
boolean z2 = z;
int mappedKeyCode = getMappedKeyCode((short) i3);
if (mappedKeyCode < 0) {
PrintStream printStream = System.out;
StringBuilder sb2 = sb;
StringBuilder sb3 = new StringBuilder();
printStream.println(sb2.append("Unrecognized keycode: ").append(i3).toString());
return;
}
if (this.key_states[mappedKeyCode] == b2) {
z2 = true;
}
this.key_states[mappedKeyCode] = b2;
putKeyboardEvent(mappedKeyCode, b2, i4 & 65535, j2, z2);
}
public void putKeyboardEvent(int i, byte b, int i2, long j, boolean z) {
int i3 = i;
byte b2 = b;
int i4 = i2;
long j2 = j;
boolean z2 = z;
Buffer clear = this.event.clear();
ByteBuffer put = this.event.putInt(i3).put(b2).putInt(i4).putLong(j2).put(z2 ? (byte) 1 : 0);
Buffer flip = this.event.flip();
boolean putEvent = putEvent(this.event);
}
public void register() {
nRegisterKeyListener(this.window_handle);
}
public void unregister() {
nUnregisterKeyListener(this.window_handle);
}
}
| 15,573 | 0.652026 | 0.600013 | 283 | 54.028267 | 33.510601 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.236749 | false | false |
10
|
af635c0b0cd371c6ab55b2d56120ee327909ae4b
| 32,280,974,220,524 |
38700763a7877a0bef8050c66da49b29f977c4ce
|
/src/build/_10second/containers/docker/DockerProcess.java
|
b76d9709cd322aad53ef6880b4cfeffb15ca22eb
|
[] |
no_license
|
bodar/10second.build
|
https://github.com/bodar/10second.build
|
d0c555285c7de5508c23d236ee86ef2b80f5ee9f
|
5a68be79eb930dd045897481db8b4c969ab744e1
|
refs/heads/master
| 2021-01-21T21:47:28.040000 | 2016-03-11T14:31:23 | 2016-03-11T14:31:23 | 42,198,381 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package build._10second.containers.docker;
import build._10second.containers.ContainerConfig;
import build._10second.containers.ContainerProcess;
import build._10second.containers.Result;
import com.googlecode.totallylazy.Sequences;
import com.googlecode.totallylazy.Strings;
import java.io.File;
import java.io.InputStream;
import static com.googlecode.totallylazy.Sequences.cons;
import static com.googlecode.totallylazy.Sequences.sequence;
public class DockerProcess extends ContainerProcess {
protected String processName() {
return "docker";
}
@Override
public Result<String> create(ContainerConfig config) throws Exception{
Result<File> result = process(cons(processName(), cons("create", cons(config.image, sequence(config.command)))));
result.success(); // force wait
return result.map(f -> Strings.string(f).trim());
}
}
|
UTF-8
|
Java
| 888 |
java
|
DockerProcess.java
|
Java
|
[] | null |
[] |
package build._10second.containers.docker;
import build._10second.containers.ContainerConfig;
import build._10second.containers.ContainerProcess;
import build._10second.containers.Result;
import com.googlecode.totallylazy.Sequences;
import com.googlecode.totallylazy.Strings;
import java.io.File;
import java.io.InputStream;
import static com.googlecode.totallylazy.Sequences.cons;
import static com.googlecode.totallylazy.Sequences.sequence;
public class DockerProcess extends ContainerProcess {
protected String processName() {
return "docker";
}
@Override
public Result<String> create(ContainerConfig config) throws Exception{
Result<File> result = process(cons(processName(), cons("create", cons(config.image, sequence(config.command)))));
result.success(); // force wait
return result.map(f -> Strings.string(f).trim());
}
}
| 888 | 0.754505 | 0.745495 | 27 | 31.888889 | 28.830711 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62963 | false | false |
10
|
9763591e47a75269ca7d54dff9badf18644a6a6a
| 515,396,090,383 |
86f58daa71f8e8b5b5a5b93ad6ed6dacc4354d41
|
/chapter_004/src/test/java/ru/job4j/stream/ProfileTest.java
|
0b555b2e6893a8513b961a996df5c3daff4c1560
|
[] |
no_license
|
ilyapavlovru/job4j
|
https://github.com/ilyapavlovru/job4j
|
e05e5c6b497ca7a6db49f3563427978334e5339b
|
89733a2198830ec4d20a1d63a25309393d64ae62
|
refs/heads/master
| 2022-12-27T14:23:34.676000 | 2021-11-06T09:34:17 | 2021-11-06T09:34:17 | 233,387,413 | 0 | 0 | null | false | 2022-12-16T05:14:41 | 2020-01-12T12:15:50 | 2021-11-06T09:34:21 | 2022-12-16T05:14:38 | 493 | 0 | 0 | 4 |
Java
| false | false |
package ru.job4j.stream;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
public class ProfileTest {
@Test
public void collectAddressesFromProfilesTest() {
List<Profile> clients = List.of(
new Profile("Ivanov", new Address("Moscow", "Abrikosovaya", 3, 4)),
new Profile("Petrov", new Address("Moscow", "Vinogradnaya", 5, 6)),
new Profile("Sidorov", new Address("Moscow", "Tenistaya", 7, 8))
);
Profiles profiles = new Profiles();
List<Address> result = profiles.collect(clients);
List<Address> expected = Arrays.asList(
new Address("Moscow", "Abrikosovaya", 3, 4),
new Address("Moscow", "Vinogradnaya", 5, 6),
new Address("Moscow", "Tenistaya", 7, 8)
);
assertThat(result, is(expected));
}
@Test
public void collectSortedDistinctAddressesFromAddressesTest() {
List<Profile> clients = List.of(
new Profile("Ivanov", new Address("Spb", "Tenistaya", 3, 4)),
new Profile("Sidorov", new Address("Moscow", "Vinogradnaya", 5, 6)),
new Profile("Sidorova", new Address("Moscow", "Vinogradnaya", 5, 6))
);
Profiles profiles = new Profiles();
List<Address> result = profiles.collectSortedDistinctAddresses(clients);
List<Address> expected = Arrays.asList(
new Address("Moscow", "Vinogradnaya", 5, 6),
new Address("Spb", "Tenistaya", 3, 4)
);
assertThat(result, is(expected));
}
}
|
UTF-8
|
Java
| 1,683 |
java
|
ProfileTest.java
|
Java
|
[
{
"context": "> clients = List.of(\n new Profile(\"Ivanov\", new Address(\"Moscow\", \"Abrikosovaya\", 3, 4)),\n ",
"end": 341,
"score": 0.9995244145393372,
"start": 335,
"tag": "NAME",
"value": "Ivanov"
},
{
"context": "rikosovaya\", 3, 4)),\n new Profile(\"Petrov\", new Address(\"Moscow\", \"Vinogradnaya\", 5, 6)),\n ",
"end": 425,
"score": 0.9995332956314087,
"start": 419,
"tag": "NAME",
"value": "Petrov"
},
{
"context": "nogradnaya\", 5, 6)),\n new Profile(\"Sidorov\", new Address(\"Moscow\", \"Tenistaya\", 7, 8))\n ",
"end": 510,
"score": 0.9993975758552551,
"start": 503,
"tag": "NAME",
"value": "Sidorov"
},
{
"context": "> clients = List.of(\n new Profile(\"Ivanov\", new Address(\"Spb\", \"Tenistaya\", 3, 4)),\n ",
"end": 1110,
"score": 0.9994184374809265,
"start": 1104,
"tag": "NAME",
"value": "Ivanov"
},
{
"context": "\"Tenistaya\", 3, 4)),\n new Profile(\"Sidorov\", new Address(\"Moscow\", \"Vinogradnaya\", 5, 6)),\n ",
"end": 1189,
"score": 0.9994761347770691,
"start": 1182,
"tag": "NAME",
"value": "Sidorov"
},
{
"context": "nogradnaya\", 5, 6)),\n new Profile(\"Sidorova\", new Address(\"Moscow\", \"Vinogradnaya\", 5, 6))\n ",
"end": 1275,
"score": 0.9995469450950623,
"start": 1267,
"tag": "NAME",
"value": "Sidorova"
}
] | null |
[] |
package ru.job4j.stream;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
public class ProfileTest {
@Test
public void collectAddressesFromProfilesTest() {
List<Profile> clients = List.of(
new Profile("Ivanov", new Address("Moscow", "Abrikosovaya", 3, 4)),
new Profile("Petrov", new Address("Moscow", "Vinogradnaya", 5, 6)),
new Profile("Sidorov", new Address("Moscow", "Tenistaya", 7, 8))
);
Profiles profiles = new Profiles();
List<Address> result = profiles.collect(clients);
List<Address> expected = Arrays.asList(
new Address("Moscow", "Abrikosovaya", 3, 4),
new Address("Moscow", "Vinogradnaya", 5, 6),
new Address("Moscow", "Tenistaya", 7, 8)
);
assertThat(result, is(expected));
}
@Test
public void collectSortedDistinctAddressesFromAddressesTest() {
List<Profile> clients = List.of(
new Profile("Ivanov", new Address("Spb", "Tenistaya", 3, 4)),
new Profile("Sidorov", new Address("Moscow", "Vinogradnaya", 5, 6)),
new Profile("Sidorova", new Address("Moscow", "Vinogradnaya", 5, 6))
);
Profiles profiles = new Profiles();
List<Address> result = profiles.collectSortedDistinctAddresses(clients);
List<Address> expected = Arrays.asList(
new Address("Moscow", "Vinogradnaya", 5, 6),
new Address("Spb", "Tenistaya", 3, 4)
);
assertThat(result, is(expected));
}
}
| 1,683 | 0.590018 | 0.576352 | 47 | 34.829788 | 28.241602 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.361702 | false | false |
10
|
95939abc6532ca798966eb01b2ade8c20a1cc176
| 14,774,687,516,082 |
8ca3d0e278784ab9e5ababd363a9c44773738714
|
/src/org/apollo/game/content/skills/herblore/FinishedPotion.java
|
a388b69351ed708c7753ad7cb404e98f25dc5a6b
|
[
"ISC"
] |
permissive
|
LukeSAV/ProtoScape
|
https://github.com/LukeSAV/ProtoScape
|
fa9dd5be9b24b949f08ea14cf41911bf4af5fb6a
|
ba6c21b3a8b36e8bd8c750a5e13dc000ef88a4fa
|
refs/heads/master
| 2020-12-11T01:38:29.980000 | 2014-10-30T04:10:46 | 2014-10-30T04:10:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.apollo.game.content.skills.herblore;
import java.util.HashMap;
import java.util.Map;
/**
* The finished product of HerbloreVariables
*
* @author Ares_
*/
public enum FinishedPotion {
ATTACK(121, 221, HerbloreVariables.GUAM_UNF, 3, 25),
ANTIPOISON(175, 235, HerbloreVariables.MARRENTILL_UNF, 5, 37.5),
RELICYMSBALM(4844, HerbloreVariables.SNAKEWEED, HerbloreVariables.ROGUESPURSE_UNF, 8, 40),
STRENGTH(116, 225, HerbloreVariables.TARROMIN_UNF, 12, 50),
STATRESTORE(127, 223, HerbloreVariables.HARRALANDER_UNF, 22, 62.6),
BLAMISHOIL(1582, 1581, HerbloreVariables.HARRALANDER_UNF, 25, 80),
ENERGY(3010, 1975, HerbloreVariables.HARRALANDER_UNF, 26, 67.6),
DEFENCE(133, 239, HerbloreVariables.RANARR_UNF, 30, 75),
AGILITY(3034, 2152, HerbloreVariables.TOADFLAX_UNF, 34, 80),
COMBAT(9741, 9736, HerbloreVariables.HARRALANDER_UNF, 36, 84),
PRAY(139, 231, HerbloreVariables.RANARR_UNF, 38, 87.5),
SUPERATTACK(145, 221, HerbloreVariables.IRIT_UNF, 45, 100),
SUPERANTIPOISON(181, 235, HerbloreVariables.IRIT_UNF, 48, 106.3),
FISHING(151, 231, HerbloreVariables.AVANTOE_UNF, 50, 112.5),
SUPERENERGY(3018, 2970, HerbloreVariables.AVANTOE_UNF, 52, 117.5),
SUPERSTRENGTH(157, 225, HerbloreVariables.KWUARM_UNF, 55, 125),
WEAPONPOISON(187, 241, HerbloreVariables.KWUARM_UNF, 60, 137.5),
SUPERRESTORE(3025, 223, HerbloreVariables.SNAPDRAONG_UNF, 63, 142.5),
SUPERDEFENCE(163, 239, HerbloreVariables.CADANTINE_UNF, 66, 150),
ANTIPOISONPLUS(5945, 6049, HerbloreVariables.ANTIPOISONPLUS_UNF, 68, 155),
ANTIFIREBREATH(2454, 241, HerbloreVariables.LANTADYME_UNF, 69, 157.5),
RANGING(169, 245, HerbloreVariables.DWARF_UNF, 72, 162.5),
WEAPONPOISNPLUS(5937, 223, HerbloreVariables.WEAPONPOISONPLUS_UNF, 73, 165),
MAGIC(3042, 3138, HerbloreVariables.LANTADYME_UNF, 76, 172.5),
ZAMORAKBREW(189, 247, HerbloreVariables.TORSTOL_UNF, 78, 175),
ANTIPOISONPLUSPLUS(5954, 6051, HerbloreVariables.ANTIPOISONPLUSPLUS_UNF, 79, 177.5),
SARADOMINBREW(6687, 6693, HerbloreVariables.TOADFLAX_UNF, 81, 180),
WEAPONPOISONPLUSPLUS(5954, 6018, HerbloreVariables.WEAPONPOISONPLUSPLUS_UNF, 82, 190);
private int ingredient;
private int potion;
private int finishedPotion;
private int level;
private double exp;
private static Map<Integer, FinishedPotion> finList = new HashMap<Integer, FinishedPotion>();
FinishedPotion(int finishedPotion, int ingredient, int potion, int level, double exp) {
this.finishedPotion = finishedPotion;
this.ingredient = ingredient;
this.potion = potion;
this.level = level;
this.exp = exp;
}
static {
for(FinishedPotion fin : FinishedPotion.values()) {
finList.put(fin.getPot(), fin);
}
}
public static FinishedPotion finForId(int id) {
return finList.get(id);
}
public int getIngredient() {
return ingredient;
}
public int getPot() {
return potion;
}
public int getFinPot() {
return finishedPotion;
}
public int getLevel() {
return level;
}
public double getExp() {
return exp;
}
}
|
UTF-8
|
Java
| 3,086 |
java
|
FinishedPotion.java
|
Java
|
[
{
"context": "shed product of HerbloreVariables\r\n * \r\n * @author Ares_\r\n */\r\npublic enum FinishedPotion {\r\n\tATTACK(121, ",
"end": 176,
"score": 0.998694896697998,
"start": 171,
"tag": "USERNAME",
"value": "Ares_"
}
] | null |
[] |
package org.apollo.game.content.skills.herblore;
import java.util.HashMap;
import java.util.Map;
/**
* The finished product of HerbloreVariables
*
* @author Ares_
*/
public enum FinishedPotion {
ATTACK(121, 221, HerbloreVariables.GUAM_UNF, 3, 25),
ANTIPOISON(175, 235, HerbloreVariables.MARRENTILL_UNF, 5, 37.5),
RELICYMSBALM(4844, HerbloreVariables.SNAKEWEED, HerbloreVariables.ROGUESPURSE_UNF, 8, 40),
STRENGTH(116, 225, HerbloreVariables.TARROMIN_UNF, 12, 50),
STATRESTORE(127, 223, HerbloreVariables.HARRALANDER_UNF, 22, 62.6),
BLAMISHOIL(1582, 1581, HerbloreVariables.HARRALANDER_UNF, 25, 80),
ENERGY(3010, 1975, HerbloreVariables.HARRALANDER_UNF, 26, 67.6),
DEFENCE(133, 239, HerbloreVariables.RANARR_UNF, 30, 75),
AGILITY(3034, 2152, HerbloreVariables.TOADFLAX_UNF, 34, 80),
COMBAT(9741, 9736, HerbloreVariables.HARRALANDER_UNF, 36, 84),
PRAY(139, 231, HerbloreVariables.RANARR_UNF, 38, 87.5),
SUPERATTACK(145, 221, HerbloreVariables.IRIT_UNF, 45, 100),
SUPERANTIPOISON(181, 235, HerbloreVariables.IRIT_UNF, 48, 106.3),
FISHING(151, 231, HerbloreVariables.AVANTOE_UNF, 50, 112.5),
SUPERENERGY(3018, 2970, HerbloreVariables.AVANTOE_UNF, 52, 117.5),
SUPERSTRENGTH(157, 225, HerbloreVariables.KWUARM_UNF, 55, 125),
WEAPONPOISON(187, 241, HerbloreVariables.KWUARM_UNF, 60, 137.5),
SUPERRESTORE(3025, 223, HerbloreVariables.SNAPDRAONG_UNF, 63, 142.5),
SUPERDEFENCE(163, 239, HerbloreVariables.CADANTINE_UNF, 66, 150),
ANTIPOISONPLUS(5945, 6049, HerbloreVariables.ANTIPOISONPLUS_UNF, 68, 155),
ANTIFIREBREATH(2454, 241, HerbloreVariables.LANTADYME_UNF, 69, 157.5),
RANGING(169, 245, HerbloreVariables.DWARF_UNF, 72, 162.5),
WEAPONPOISNPLUS(5937, 223, HerbloreVariables.WEAPONPOISONPLUS_UNF, 73, 165),
MAGIC(3042, 3138, HerbloreVariables.LANTADYME_UNF, 76, 172.5),
ZAMORAKBREW(189, 247, HerbloreVariables.TORSTOL_UNF, 78, 175),
ANTIPOISONPLUSPLUS(5954, 6051, HerbloreVariables.ANTIPOISONPLUSPLUS_UNF, 79, 177.5),
SARADOMINBREW(6687, 6693, HerbloreVariables.TOADFLAX_UNF, 81, 180),
WEAPONPOISONPLUSPLUS(5954, 6018, HerbloreVariables.WEAPONPOISONPLUSPLUS_UNF, 82, 190);
private int ingredient;
private int potion;
private int finishedPotion;
private int level;
private double exp;
private static Map<Integer, FinishedPotion> finList = new HashMap<Integer, FinishedPotion>();
FinishedPotion(int finishedPotion, int ingredient, int potion, int level, double exp) {
this.finishedPotion = finishedPotion;
this.ingredient = ingredient;
this.potion = potion;
this.level = level;
this.exp = exp;
}
static {
for(FinishedPotion fin : FinishedPotion.values()) {
finList.put(fin.getPot(), fin);
}
}
public static FinishedPotion finForId(int id) {
return finList.get(id);
}
public int getIngredient() {
return ingredient;
}
public int getPot() {
return potion;
}
public int getFinPot() {
return finishedPotion;
}
public int getLevel() {
return level;
}
public double getExp() {
return exp;
}
}
| 3,086 | 0.723266 | 0.61698 | 90 | 32.288887 | 28.868378 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.888889 | false | false |
10
|
84080d59e701188eaa58703639b99d82eb44b22a
| 1,005,022,363,146 |
c947a87aa11c3439b71e75bd11d237382cf40ef5
|
/webapps/portalGUI/WEB-INF/src/com/colt/struts/action/smarts/SmartsTopAction.java
|
66fa92e449ad97a103dbd9f978cf23fc7d280e80
|
[] |
no_license
|
samishra77/APT
|
https://github.com/samishra77/APT
|
328df8e2180c493936d30421c253c5696ccd2e82
|
ec8dad5e4764570ef15a3dd8a4e7054f19e3c23a
|
HEAD
| 2016-04-17T23:02:06.230000 | 2016-02-19T10:32:04 | 2016-02-19T10:58:33 | 52,968,763 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.colt.struts.action.smarts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.colt.struts.action.ColtAction;
public class SmartsTopAction extends ColtAction {
/**
*
*/
public ActionForward exec(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if( request.isUserInRole("customerOthersAdmin") )
return showForm(mapping, form, request, response);
return mapping.findForward("accessDenied");
}
/**
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward showForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward("show");
}
}
|
UTF-8
|
Java
| 1,004 |
java
|
SmartsTopAction.java
|
Java
|
[] | null |
[] |
package com.colt.struts.action.smarts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.colt.struts.action.ColtAction;
public class SmartsTopAction extends ColtAction {
/**
*
*/
public ActionForward exec(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if( request.isUserInRole("customerOthersAdmin") )
return showForm(mapping, form, request, response);
return mapping.findForward("accessDenied");
}
/**
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward showForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward("show");
}
}
| 1,004 | 0.767928 | 0.767928 | 36 | 26.916666 | 34.348198 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.222222 | false | false |
10
|
1fec6239ea5ab2f012d07d66eeddd9b136a098ef
| 3,289,944,962,167 |
ff7a45e258b126571ea20b0fa3154b16a705af24
|
/src/com/powerbot/winedrinker/Jugs.java
|
01b4c1a23dd79077c7717dca61fa54b4868671a7
|
[] |
no_license
|
GiveMeCofee/DrunkWineDrinker
|
https://github.com/GiveMeCofee/DrunkWineDrinker
|
17de5c7f203973f8da0becb6e0d0666f778ff741
|
e5d2d222c100bc3f790e5c7cd92a5c1de93bf49f
|
refs/heads/master
| 2021-01-20T10:13:30.906000 | 2015-09-26T20:02:20 | 2015-09-26T20:02:20 | 31,034,157 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.powerbot.winedrinker;
public enum Jugs {
WINE(1993), EMPTY(1935), WATER(1937);
private final int code;
Jugs(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
|
UTF-8
|
Java
| 206 |
java
|
Jugs.java
|
Java
|
[] | null |
[] |
package com.powerbot.winedrinker;
public enum Jugs {
WINE(1993), EMPTY(1935), WATER(1937);
private final int code;
Jugs(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
| 206 | 0.665049 | 0.606796 | 15 | 12.733334 | 12.609344 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.133333 | false | false |
10
|
b5ffe06ba30f1005d57f034488e9c878fb46ab1b
| 18,373,870,158,713 |
8d3f3b428c6e90dd0d544684d8e97136f99b7539
|
/src/main/java/com/mofanghr/common/GlobayContext.java
|
9bd818f04e49ed71515689abdef52f7958a62d95
|
[] |
no_license
|
livable-liu/log-analysis
|
https://github.com/livable-liu/log-analysis
|
5fb19aab68381649b52a8c8f86ebdf0a30ab7f0d
|
dee97fe24f158662aa8c2b6c50d571a8d980d5a9
|
refs/heads/master
| 2018-03-30T11:44:43.673000 | 2018-02-27T06:36:23 | 2018-02-27T06:36:23 | 87,918,667 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mofanghr.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mofang on 12/22/16.
*/
public class GlobayContext {
private static final Logger LOGGER = LoggerFactory.getLogger(GlobayContext.class);
private static GlobayContext contextInstance = null;
private GlobayContext() {
}
public static GlobayContext getInstance() {
if (contextInstance == null) {
contextInstance = new GlobayContext();
}
return contextInstance;
}
}
|
UTF-8
|
Java
| 532 |
java
|
GlobayContext.java
|
Java
|
[
{
"context": "import org.slf4j.LoggerFactory;\n\n/**\n * Created by mofang on 12/22/16.\n */\npublic class GlobayContext {\n\n ",
"end": 112,
"score": 0.999572217464447,
"start": 106,
"tag": "USERNAME",
"value": "mofang"
}
] | null |
[] |
package com.mofanghr.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mofang on 12/22/16.
*/
public class GlobayContext {
private static final Logger LOGGER = LoggerFactory.getLogger(GlobayContext.class);
private static GlobayContext contextInstance = null;
private GlobayContext() {
}
public static GlobayContext getInstance() {
if (contextInstance == null) {
contextInstance = new GlobayContext();
}
return contextInstance;
}
}
| 532 | 0.680451 | 0.665414 | 25 | 20.280001 | 22.404499 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.28 | false | false |
10
|
c57c4f83ebdf931d746c00a969ec156b55080ea6
| 23,330,262,360,155 |
a5b039cffb0b0ddf009a441056416b11468cd524
|
/VideoAula06/ContaEspecial.java
|
8833fc6842cf137a1099ba3c173be58680c93ca5
|
[] |
no_license
|
WendreoLucianoFernandes/POO_IFSP
|
https://github.com/WendreoLucianoFernandes/POO_IFSP
|
17c46e51aaff58763589cdbb3e2c69e4c274e266
|
1a996f7e9aadbbb84aac39fa190bf630016b7027
|
refs/heads/master
| 2017-12-01T23:00:44.301000 | 2016-06-25T20:10:28 | 2016-06-25T20:10:28 | 61,959,666 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package VideoAula06;
public class ContaEspecial extends Conta {
public Double getDescontoMensalidade() {
return getDescontoMensalidade()/0.1;
}
public Double getImposto() {
return getImposto()/0.30;
}
}
|
UTF-8
|
Java
| 237 |
java
|
ContaEspecial.java
|
Java
|
[] | null |
[] |
package VideoAula06;
public class ContaEspecial extends Conta {
public Double getDescontoMensalidade() {
return getDescontoMensalidade()/0.1;
}
public Double getImposto() {
return getImposto()/0.30;
}
}
| 237 | 0.670886 | 0.64135 | 15 | 14.866667 | 16.177626 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false |
10
|
f5a9ea2c4e5f61e2bb464fed127c59a17d8c2c90
| 5,480,378,283,354 |
96a6ca2459cb2e50303cfcc307d77e02810b80e6
|
/net.sf.jmoney.gnucashXML/src/net/sf/jmoney/gnucashXML/FileFormat.java
|
e285ee91ac8ed4536627f7d5760b2963643a5211
|
[] |
no_license
|
p07r0457/jmoney
|
https://github.com/p07r0457/jmoney
|
3618ff7169c9ae9c613170f69102207ed754fe6d
|
c9db28b82ca7f5cd3c2d54ba3ecfc5c61fbc7013
|
refs/heads/master
| 2021-01-01T17:37:25.109000 | 2012-10-16T10:17:47 | 2012-10-16T10:17:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
*
* JMoney - A Personal Finance Manager
* Copyright (c) 2001-2003 Johann Gyger <jgyger@users.sf.net>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package net.sf.jmoney.gnucashXML;
import java.io.File;
import net.sf.jmoney.model2.CapitalAccount;
import net.sf.jmoney.model2.Session;
/**
* Operations to import from (export to) a specific file format.
*
* @author Jan-Pascal van Best
* @author Johann Gyger
*
* TODO: This interface defines what an Export/Import tool has to do.
* It should be directly defined in the jmoney-Plugin, not in the gnucashXML
*/
public interface FileFormat {
/**
* Import data from "file" into "session".
*
* @param session Session where data is being imported
* @param file Import file
*/
public void importFile(Session session, File file);
/**
* Export "account" data from "session" into "file".
*
* @param session Session that contains account
* @param account CapitalAccount to export
* @param file Export file
*/
void exportAccount(Session session, CapitalAccount account, File file);
}
|
UTF-8
|
Java
| 1,796 |
java
|
FileFormat.java
|
Java
|
[
{
"context": "rsonal Finance Manager\n * Copyright (c) 2001-2003 Johann Gyger <jgyger@users.sf.net>\n *\n *\n * This program is f",
"end": 86,
"score": 0.9998803734779358,
"start": 74,
"tag": "NAME",
"value": "Johann Gyger"
},
{
"context": "Manager\n * Copyright (c) 2001-2003 Johann Gyger <jgyger@users.sf.net>\n *\n *\n * This program is free software; you can",
"end": 107,
"score": 0.9999274015426636,
"start": 88,
"tag": "EMAIL",
"value": "jgyger@users.sf.net"
},
{
"context": "(export to) a specific file format.\n * \n * @author Jan-Pascal van Best\n * @author Johann Gyger\n * \n * TODO: This interfa",
"end": 1073,
"score": 0.9998485445976257,
"start": 1054,
"tag": "NAME",
"value": "Jan-Pascal van Best"
},
{
"context": "mat.\n * \n * @author Jan-Pascal van Best\n * @author Johann Gyger\n * \n * TODO: This interface defines what an Expor",
"end": 1097,
"score": 0.9998648166656494,
"start": 1085,
"tag": "NAME",
"value": "Johann Gyger"
}
] | null |
[] |
/*
*
* JMoney - A Personal Finance Manager
* Copyright (c) 2001-2003 <NAME> <<EMAIL>>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package net.sf.jmoney.gnucashXML;
import java.io.File;
import net.sf.jmoney.model2.CapitalAccount;
import net.sf.jmoney.model2.Session;
/**
* Operations to import from (export to) a specific file format.
*
* @author <NAME>
* @author <NAME>
*
* TODO: This interface defines what an Export/Import tool has to do.
* It should be directly defined in the jmoney-Plugin, not in the gnucashXML
*/
public interface FileFormat {
/**
* Import data from "file" into "session".
*
* @param session Session where data is being imported
* @param file Import file
*/
public void importFile(Session session, File file);
/**
* Export "account" data from "session" into "file".
*
* @param session Session that contains account
* @param account CapitalAccount to export
* @param file Export file
*/
void exportAccount(Session session, CapitalAccount account, File file);
}
| 1,759 | 0.699889 | 0.68931 | 57 | 30.508772 | 27.351591 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.385965 | false | false |
10
|
88bcdb3ed09d4edd035d12dddeb08873f5ef2831
| 33,217,277,092,801 |
9da2a09470cf24ac982653082ec4cc33560a8d4e
|
/src/com/extant/utilities/StatusBox1.java
|
388eebbd14b591de958876903554566202b327e9
|
[] |
no_license
|
jms007/Utilities
|
https://github.com/jms007/Utilities
|
2e533af97172111285de9087909b09f726411ea6
|
81fa795abdc9ce35f2a5f29159381549e970f52d
|
refs/heads/master
| 2021-04-29T17:15:55.330000 | 2018-10-11T15:29:49 | 2018-10-11T15:29:49 | 121,664,884 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* StatusBox1.java
*
* Created on October 20, 2006, 3:03 PM
*/
package com.extant.utilities;
import javax.swing.JFrame;
import java.awt.Point;
/**
*
* @author jms
*/
public class StatusBox1
extends JFrame
{
public StatusBox1( String msg)
{ // Location defaults to centered, Border Title defaults to "Status"
this(msg, null, null);
}
public StatusBox1(String msg, Point location)
{ // Border Title defaults to "Status"
this(msg, location, null);
}
public StatusBox1(String msg, Point location, String borderTitle)
{
//super(parent, false);
initComponents();
setup( msg, location, borderTitle );
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
txtMessage = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAlwaysOnTop(true);
setResizable(false);
setUndecorated(true);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
txtMessage.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jPanel1.add(txtMessage);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>//GEN-END:initComponents
void setup( String msg, Point location, String borderTitle )
{
if ( location == null )
{ // This will center the dialog
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width-this.getWidth())/2,(screenSize.height-this.getHeight())/2);
}
else setLocation( location );
txtMessage.setBackground( jPanel1.getBackground() );
if (borderTitle != null) setBorderTitle( borderTitle );
updateMsg(msg);
setVisible(true);
}
public void updateMsg( String newMessage )
{
txtMessage.setText( newMessage );
pack();
}
public void setBorderTitle(String title)
{
jPanel1.setBorder(new javax.swing.border.TitledBorder
(null, title, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)
) );
}
public void close()
{
dispose();
}
/**
* @param args the command line arguments
*/
/***** FOR TESTING *****/
public static void main(String args[])
{
try
{
StatusBox1 statusBox = new StatusBox1("This is the initial message", null, "Original Title" );
Thread.sleep(5000L);
statusBox.updateMsg( "This is a longer message that requires more width" );
Thread.sleep(5000L);
statusBox.setBorderTitle("New Title");
statusBox.updateMsg( "This message is really long and has a lot of information\nthat requires more than one\nline\ntodisplay" );
Thread.sleep(5000L);
statusBox.updateMsg( "Message #3" );
Thread.sleep(5000L);
statusBox.close();
System.exit(0);
}
catch (Exception x) { Console.println( x.getMessage() ); }
}
/*****/
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
private javax.swing.JTextArea txtMessage;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 3,735 |
java
|
StatusBox1.java
|
Java
|
[
{
"context": "JFrame;\nimport java.awt.Point;\n\n/**\n *\n * @author jms\n */\npublic class StatusBox1\nextends JFrame\n{\n ",
"end": 173,
"score": 0.9997063279151917,
"start": 170,
"tag": "USERNAME",
"value": "jms"
}
] | null |
[] |
/*
* StatusBox1.java
*
* Created on October 20, 2006, 3:03 PM
*/
package com.extant.utilities;
import javax.swing.JFrame;
import java.awt.Point;
/**
*
* @author jms
*/
public class StatusBox1
extends JFrame
{
public StatusBox1( String msg)
{ // Location defaults to centered, Border Title defaults to "Status"
this(msg, null, null);
}
public StatusBox1(String msg, Point location)
{ // Border Title defaults to "Status"
this(msg, location, null);
}
public StatusBox1(String msg, Point location, String borderTitle)
{
//super(parent, false);
initComponents();
setup( msg, location, borderTitle );
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
txtMessage = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAlwaysOnTop(true);
setResizable(false);
setUndecorated(true);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10))); // NOI18N
txtMessage.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
jPanel1.add(txtMessage);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>//GEN-END:initComponents
void setup( String msg, Point location, String borderTitle )
{
if ( location == null )
{ // This will center the dialog
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width-this.getWidth())/2,(screenSize.height-this.getHeight())/2);
}
else setLocation( location );
txtMessage.setBackground( jPanel1.getBackground() );
if (borderTitle != null) setBorderTitle( borderTitle );
updateMsg(msg);
setVisible(true);
}
public void updateMsg( String newMessage )
{
txtMessage.setText( newMessage );
pack();
}
public void setBorderTitle(String title)
{
jPanel1.setBorder(new javax.swing.border.TitledBorder
(null, title, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 10)
) );
}
public void close()
{
dispose();
}
/**
* @param args the command line arguments
*/
/***** FOR TESTING *****/
public static void main(String args[])
{
try
{
StatusBox1 statusBox = new StatusBox1("This is the initial message", null, "Original Title" );
Thread.sleep(5000L);
statusBox.updateMsg( "This is a longer message that requires more width" );
Thread.sleep(5000L);
statusBox.setBorderTitle("New Title");
statusBox.updateMsg( "This message is really long and has a lot of information\nthat requires more than one\nline\ntodisplay" );
Thread.sleep(5000L);
statusBox.updateMsg( "Message #3" );
Thread.sleep(5000L);
statusBox.close();
System.exit(0);
}
catch (Exception x) { Console.println( x.getMessage() ); }
}
/*****/
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
private javax.swing.JTextArea txtMessage;
// End of variables declaration//GEN-END:variables
}
| 3,735 | 0.625703 | 0.610709 | 118 | 30.644068 | 34.465294 | 238 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.652542 | false | false |
10
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.