blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e536d4aa159cd5d4ca29995ca31b05921c757d17 | 20626b983ba3c12f49393fc1b4d0c4fc7b8fad0a | /app/src/androidTest/java/com/example/aleks/movies/MoviesInstrumentedTest.java | 74dae34b6a83e6c8967453cdd61f43a92fbd1762 | [] | no_license | Alex12111/Movies | 55f12716eabaeff1f0a8f4f2eed3f6e608b52d97 | fc5e2a2bb7fd7ec272a316d86f84b43a72dae3a5 | refs/heads/master | 2020-05-03T11:52:49.909810 | 2019-04-01T16:30:54 | 2019-04-01T16:30:54 | 178,610,850 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 731 | java | package com.example.aleks.movies;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class MoviesInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.aleks.movies", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
8280c7b97801ffe79c6a7713340e824ddf742f4c | d23d1b1465034245a4623f846c1aa610e53c1585 | /Lab3/src/Test/CounterTestCase.java | c915f8c5a7a2091d0dbb91cf027eb9163526a0ff | [] | no_license | IgorXY/Web-Tech-Lab1 | 2f8d4e6d11000f33f39ba009e75d6b7a6ffd4e5b | c63f057d0f938f46f94b728d09e7556ad1ff8341 | refs/heads/master | 2020-04-13T17:41:57.044315 | 2016-09-30T06:48:33 | 2016-09-30T06:48:33 | 68,271,710 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 287 | java | package Test;
import static org.junit.Assert.*;
import org.junit.Test;
import Logic.Counter;
public class CounterTestCase {
Counter counter = new Counter();
double res[];
@Test
public void TestRight() {
res = counter.CountFunction(0, 0, 0);
assertEquals(0, res[0], 0);
}
}
| [
"[email protected]"
] | |
56c4a12c11b4144fd61c733fbbd80c9d61069ac5 | 8ca98ba87398a2c9a3a545a3e93b6f1a4e64226a | /Vector.java | 0dc54765fcc0f1a6db8eb2a3c72add6c04c1111d | [] | no_license | Sthakur27/differential | c24ec56676428143b62c1770a0b730bba4ba2ef1 | 67b733b9d959b4c6d398f6c03d27678d35dbd0d6 | refs/heads/master | 2021-01-01T05:45:56.261871 | 2017-09-25T02:14:46 | 2017-09-25T02:14:46 | 58,688,509 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,232 | java | import java.lang.Math;
public class Vector{
float xpos,ypos,angle;
static double forceDegree=0.5;
Vector(float x,float y){
xpos=x;ypos=y;
}
Vector(double x,double y){
this((float)x,(float)y);
}
public void add(Vector v){
this.xpos+=v.xpos;
this.ypos+=v.ypos;
}
public void scaleVector(float scale){
float len=(float)length();
this.xpos*=scale/len;
this.ypos*=scale/len;
}
public Vector unitVector(){
double len=length();
return (new Vector(xpos/len,ypos/len));
}
public double length(){
return(Math.pow( (xpos*xpos)+(ypos*ypos),0.5));
}
public float speed(){
return((float)Math.pow((this.xpos*this.xpos)+(this.ypos+this.ypos),0.5));
}
static public double findAngle(float x,float y){
return (Math.atan2(y,x));
}
static public double findAngle(Field f){
return(Vector.findAngle(f.myvector.xpos,f.myvector.ypos));
}
static public double findAngle(float x1,float y1,float x2,float y2){
return(Math.atan2(y2-y1,x2-x1));
}
public String toString(){
return("x: "+this.xpos+" y: "+this.ypos);
}
public void reset(){
this.xpos=0;this.ypos=0;
}
} | [
"[email protected]"
] | |
9c9b4b924bd493c413fe29268fb4923b970255ff | 20ecf8e6df8f87731dafad4ab21f54f2bd8f0dc6 | /DesignPatternDemo/src/main/java/designPatternCode/BuilderPattern/Demo1/Bottle.java | f89e19ab7fb9ef4d07aa2655feb6438544b01cb3 | [] | no_license | lanSeFangZhou/algorithms | 12324737b9f7312f1a5031bf452f8a0a4426273e | 6df8bcde72c5c696789f4216f2a8e492e106a7ae | refs/heads/main | 2023-03-16T22:16:28.033516 | 2021-03-18T09:41:36 | 2021-03-18T09:41:36 | 349,015,803 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 150 | java | package designPatternCode.BuilderPattern.Demo1;
public class Bottle implements Packing {
public String pack() {
return "Bottle";
}
}
| [
"[email protected]"
] | |
f441c5ba696c6688e5580d5a6c39ded3377a5261 | 7bfa69eda5bc5c95f3196ee6c81928e8d70f5b52 | /app/src/main/java/com/example/download/demo/ui/MainActivity.java | 960b0fecdfe37bb4b4cd2bffe29f8ff538eca47e | [] | no_license | levinli/downloadSample | c935508d0ba677e6ee223ecda6fc4da952644e4a | 1d1af04379986ecaddd05de5377e9b2f75d5019e | refs/heads/master | 2021-06-27T09:29:54.460607 | 2017-09-13T11:35:42 | 2017-09-13T11:35:42 | 103,390,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,216 | java | package com.example.download.demo.ui;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import com.example.download.demo.R;
import com.example.download.demo.service.DownloadService;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 下载demo
*/
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
@BindView(R.id.start_btn)
Button startBtn;
@BindView(R.id.cancel_btn)
Button cancelBtn;
@BindView(R.id.pause_btn)
Button pauseBtn;
private DownloadService.DownloadBinder binder;
private ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
binder = (DownloadService.DownloadBinder) iBinder;
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
startBtn.setOnClickListener(this);
cancelBtn.setOnClickListener(this);
pauseBtn.setOnClickListener(this);
Intent intent = new Intent(this,DownloadService.class);
bindService(intent,connection,BIND_AUTO_CREATE);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.start_btn:
String url = "http://sw.bos.baidu.com/sw-search-sp/software/d2831b71fc397/eclipse_v4.7.0.exe";
binder.startDownlaod(url);
break;
case R.id.pause_btn:
binder.pauseDownload();
break;
case R.id.cancel_btn:
binder.cancelDownload();
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unbindService(connection);
}
}
| [
"liwen@kugou .net"
] | liwen@kugou .net |
7ba37aa0e628b88b32c6a489940d0acc5e4bfd48 | 048aad80282985b52352eb35778e22bf18a05b22 | /src/main/java/io/github/manuelarte/spring/queryparameter/config/QueryParameterConfig.java | 04aeecf8fbcd40aed931e8cb3ec8a93e38a76de1 | [] | no_license | manuelarte/query-parameter-model | a8ef6158a831d991d6a8038092d724b648c6840e | 8bcb4ca4c6e4d6d144e69730349e686bd092fe4f | refs/heads/master | 2022-04-21T12:23:23.906533 | 2020-04-23T19:27:47 | 2020-04-23T19:27:47 | 254,645,466 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 316 | java | package io.github.manuelarte.spring.queryparameter.config;
import io.github.manuelarte.spring.queryparameter.model.TypeTransformerRegistry;
/**
* Interface to add custom type transformers.
*/
public interface QueryParameterConfig {
void addTypeTransformer(TypeTransformerRegistry typeTransformerRegistry);
}
| [
"[email protected]"
] | |
ed0d42ea06d56cf0eaec34bd4e66859f0f3a2847 | 01340816f7165798fd857f33b4b4414fa9bf192c | /src/main/java/leetcode/Eight/backspaceCompare/backspaceCompare.java | c71da942bba9ce02a939e4ca1c1806b913a04df9 | [] | no_license | EarWheat/LeetCode | 250f181c2c697af29ce6f76b1fdf7c7b0d7fb02c | f440e6c76efb4554e0404cacf137dc1f6677e2e1 | refs/heads/master | 2023-08-31T06:25:35.460107 | 2023-08-30T06:41:10 | 2023-08-30T06:41:10 | 145,558,499 | 2 | 1 | null | 2023-06-14T22:51:49 | 2018-08-21T12:05:56 | Java | UTF-8 | Java | false | false | 2,495 | java | package leetcode.Eight.backspaceCompare;
import java.util.Queue;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingDeque;
/**
* @author liuzhaoluliuzhaolu
* @date 2020-10-19 10:02
* @desc 给定 S 和 T 两个字符串,当它们分别被输入到空白的文本编辑器后,判断二者是否相等,并返回结果。 # 代表退格字符。
*
* 注意:如果对空文本输入退格字符,文本继续为空。
*
*
*
* 示例 1:
*
* 输入:S = "ab#c", T = "ad#c"
* 输出:true
* 解释:S 和 T 都会变成 “ac”。
* 示例 2:
*
* 输入:S = "ab##", T = "c#d#"
* 输出:true
* 解释:S 和 T 都会变成 “”。
* 示例 3:
*
* 输入:S = "a##c", T = "#a#c"
* 输出:true
* 解释:S 和 T 都会变成 “c”。
* 示例 4:
*
* 输入:S = "a#c", T = "b"
* 输出:false
* 解释:S 会变成 “c”,但 T 仍然是 “b”。
*
*
* 提示:
*
* 1 <= S.length <= 200
* 1 <= T.length <= 200
* S 和 T 只含有小写字母以及字符 '#'。
*
* 链接:https://leetcode-cn.com/problems/backspace-string-compare
* @prd
* @Modification History:
* Date Author Description
* ------------------------------------------ *
*/
public class backspaceCompare {
public static boolean backspaceCompare(String S, String T) {
if(S.equals(T)){
return true;
}
Stack stack = new Stack();
for(int i = 0; i < S.length(); i++){
if(S.charAt(i) != '#'){
stack.push(S.charAt(i));
} else {
if(stack.size() > 0){
stack.pop();
}
}
}
S = stack2String(stack);
for(int i = 0; i < T.length(); i++){
if(T.charAt(i) != '#'){
stack.push(T.charAt(i));
} else {
if(stack.size() > 0){
stack.pop();
}
}
}
T = stack2String(stack);
return S.equals(T);
}
public static String stack2String(Stack stack){
StringBuilder stringBuilder = new StringBuilder();
while (stack.size() != 0){
stringBuilder.append(stack.pop());
}
return stringBuilder.toString();
}
public static void main(String[] args) {
// System.out.println(backspaceCompare("ab##","c#d#"));
System.out.println(backspaceCompare("#####abc","abb#c"));
}
}
| [
"[email protected]"
] | |
aa9ad3a1f2629e7d021b65242b8f5cf6e42646a6 | 866429ea460387b2668e6a80830368ac47560e65 | /src/main/java/com/lwl/parser/ParseTest.java | 1ebbc4fb83cccc5b91452676a13cc77262ecb5d3 | [] | no_license | LiuWillow/html-parse | 96f7cfc4e765d5f31d3ddf4559a20f07332f2b08 | 8ef17447179355266d6ad260b9d11b46b98c076a | refs/heads/master | 2020-05-20T05:34:15.160600 | 2019-05-08T10:48:19 | 2019-05-08T10:48:19 | 185,409,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,639 | java | package com.lwl.parser;
import java.io.File;
import java.util.*;
/**
* @author liuweilong
* @description
* @date 2019/5/8 15:53
*/
public class ParseTest {
public static void main(String[] args) throws InterruptedException {
//TODO 要获取上传后的图片url,key为文件名(id),value为上传后的url
Map<String, String> realImgMap = new HashMap<>();
//TODO key为上传之前的url,value为文件名(id)
File file = new File("D:\\中非\\线上问题\\2019-05-07海关爬数据\\海关总署-需求1\\实际要上传数据\\第一批上传数据.xlsx");
List<BackgroundNews> newsOrigin = handle(file);
List<BackgroundNews> newsNeedSort = new ArrayList<>();
Iterator<BackgroundNews> newsIterator = newsOrigin.iterator();
while (newsIterator.hasNext()) {
BackgroundNews backgroundNews = newsIterator.next();
String content = backgroundNews.getContent();
// 先解析html,获取img和file的列表
ImgAndDoc imgAndDoc = HtmlParser.parseImagAndDoc(backgroundNews.getContent());
// 判断是否有file,将have_file字段修改
List<FileContent> fileContents = imgAndDoc.getFileContents();
if (fileContents != null && !fileContents.isEmpty()) {
backgroundNews.setHaveFile((byte) 1);
// 取消file链接,保留链接中的文字
for (FileContent fileContent: fileContents) {
content = content.replace(fileContent.getFileAString(), fileContent.getFileText());
}
}
//TODO 替换img
List<String> imgs = imgAndDoc.getImgs();
if (imgs != null && !imgs.isEmpty()) {
for (String img : imgs) {
content = content.replaceAll(img, realImgMap.get(img) == null ? "" : realImgMap.get(img));
}
}
backgroundNews.setContent(content);
//TODO 按日期排序问题,数据库排序规则,按照priority倒叙
if (backgroundNews.getYear() != null){
newsIterator.remove();
newsNeedSort.add(backgroundNews);
}
}
System.out.println();
}
private static List<BackgroundNews> handle(File file) {
List<BackgroundNews> newsList = new ArrayList<>();
ExcelEventParser excelEventParser = new ExcelEventParser(file.getAbsolutePath())
.setHandler(new SimpleSheetContentsHandler(newsList));
excelEventParser.parse();
return newsList;
}
}
| [
"[email protected]"
] | |
21a20276ea701e4fb57fe7386d2d45babb1ecaca | 84fc004299a23375cf132a1eb9b323aa649ff03d | /week1/src/main/java/com/example/week1/dao/MyDao.java | dd31fa1ddc9a0493bb2f85f322bf9509d3c41a7a | [] | no_license | StartLn/Week1 | 279c65e601e32e5e039375ed3f1c9c82bcfe9d98 | 75e7d82e0eafcb4294f87902bcd444290e6e0ad1 | refs/heads/master | 2020-04-09T06:41:53.088595 | 2018-12-03T03:41:05 | 2018-12-03T03:41:05 | 160,123,610 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,231 | java | package com.example.week1.dao;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;
import java.util.ArrayList;
public class MyDao {
private Context mContext;
private final MyOpenHelper helper;
private final SQLiteDatabase mData;
public MyDao(Context mContext) {
this.mContext = mContext;
helper = new MyOpenHelper(mContext);
mData = helper.getWritableDatabase();
}
public void insertSqlite(String name) {
ContentValues values = new ContentValues();
values.put("name",name);
mData.insert("liu",null,values);
//Toast.makeText(mContext,"插入成功",Toast.LENGTH_SHORT).show();
}
public ArrayList<String> selectName() {
ArrayList<String>list = new ArrayList<>();
Cursor cursor = mData.query("liu", null, null, null, null, null, null, null);
while (cursor.moveToNext()){
String name = cursor.getString(cursor.getColumnIndex("name"));
list.add(name);
}
return list;
}
public void delete() {
mData.execSQL("delete from liu");
}
}
| [
"[email protected]"
] | |
5cfa4aa9385228d90b39cf1bb626b50405410dd4 | 8b1ac93843c58a882814b6be0eb6b5ee172d6174 | /src/main/java/top/maplefix/model/Comment.java | 35ddfdacf0d5168d80dce522a3bba16e9053a9e0 | [
"MIT"
] | permissive | maplefix/maple-blog | 5f66b19d23ae59672f5f896f038e8daa55403f4d | dd70c57ad5286fe939d7ef0802a20bb344a1e5d9 | refs/heads/master | 2023-06-25T04:59:38.994707 | 2023-06-13T07:22:55 | 2023-06-13T07:22:55 | 138,957,242 | 2 | 0 | MIT | 2023-06-14T22:33:41 | 2018-06-28T02:41:11 | Java | UTF-8 | Java | false | false | 2,416 | java | package top.maplefix.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.maplefix.annotation.Excel;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author Maple
* @description 评论实体类
* @date 2020/1/15 15:19
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Comment extends BaseEntity implements Serializable {
/**
* 主键
*/
@Excel(name = "主键")
private Long id;
/**
* 昵称
*/
@NotNull(message = "昵称不能为空")
@Length(min = 1, max = 100, message = "昵称长度为{min}~{max}个字符")
private String nickName;
/**
*Email地址
*/
@Email(message = "Email地址不合法")
private String email;
/**
*IP地址
*/
private String ip;
/**
* 地理位置
*/
private String location;
/**
* 操作系统
*/
private String os;
/**
* 浏览器
*/
private String browser;
/**
* 父评论的id
*/
private Long parentId;
/**
* QQ号
*/
@Length(max = 11, message = "QQ号码长度不能超过{max}")
private String qqNum;
/**
* 头像地址
*/
@Length(max = 256, message = "头像地址长度不能超过{max}")
private String avatar;
/**
* 页面id
*/
private Long pageId;
/**
* 页面url
*/
private String url;
/**
* 是否显示,1显示,0不显示
*/
private Boolean display;
/**
* 点赞
*/
private Long good;
/**
* 踩
*/
private Long bad;
/**
* 评论内容
*/
@NotNull(message = "内容不能为空")
private String content;
/**
* html内容
*/
@NotNull(message = "内容不能为空")
private String htmlContent;
/**
* 是否接收回复邮件,1是,0否
*/
private Boolean reply;
/**
* 回复的id
*/
private String replyId;
/**
* 是否管理员回复,1是,0否
*/
private Boolean adminReply;
private Comment parentComment;
/**
* 子评论
*/
private List<Comment> subCommentList;
/**
* 回复的NickName
*/
private String replyNickName;
}
| [
"[email protected]"
] | |
f7d7875e7927a76ab269abc6afe0a1e6daf8b896 | fd36aa88b84940465de46cea1e8bfd8af00ed502 | /src/main/java/org/springframework/social/lastfm/pseudooauth2/connect/LastFmPseudoOAuth2AccessGrant.java | bea1138deb9e9b446fee3bd93a2ec329427af536 | [] | no_license | eltmon/spring-social-lastfm | be461cfa32b5ca42a7926e3b061929250123a558 | c74ed59cae375bcdd3a98f04a65b380c31e924f3 | refs/heads/master | 2021-01-20T14:02:33.116497 | 2014-03-15T00:29:32 | 2014-03-15T00:29:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,702 | java | /*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.social.lastfm.pseudooauth2.connect;
import org.springframework.social.lastfm.auth.LastFmAccessGrant;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Michael Lavelle
*/
public class LastFmPseudoOAuth2AccessGrant extends LastFmAccessGrant {
private static final long serialVersionUID = 1L;
private static ObjectMapper objectMapper = new ObjectMapper();
@JsonCreator
public LastFmPseudoOAuth2AccessGrant(@JsonProperty("token") String token,
@JsonProperty("sessionKey") String sessionKey) {
super(token, sessionKey);
}
public String toAccessToken() {
try {
return objectMapper.writeValueAsString(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static LastFmPseudoOAuth2AccessGrant fromAccessToken(String string) {
try {
return objectMapper.readValue(string,
LastFmPseudoOAuth2AccessGrant.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| [
"[email protected]"
] | |
2b5b6d7035d4ba6f61a39160e36119af0a36a402 | f7c2367b1aabfa8be42af81e8df54ccbde376594 | /Estado/src/java/DAO/TipoPapelDAO.java | c45eff73f28a29a19d6099cc1c8bdb00a6fa585b | [] | no_license | AlessandroRodrigo/gibizera-fef | 940f8602a082d2e1924d6514ced51bfd76e35e1c | ded43ef48081eea82337261a8e40503ea905a803 | refs/heads/master | 2022-04-29T04:45:51.834382 | 2020-03-10T03:18:48 | 2020-03-10T03:18:48 | 245,030,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,553 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import Database.ConnectionFactory;
import Models.TipoPapel;
import Models.TipoPapel;
import Models.TipoPapel;
import Models.TipoPapel;
import Models.TipoPapel;
import Models.TipoPapel;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Aluno
*/
public class TipoPapelDAO implements GenericDAO {
private Connection Connection;
public TipoPapelDAO() throws Exception {
try {
this.Connection = ConnectionFactory.getConnection();
System.out.println("Conectado com Sucesso!");
} catch (Exception ex) {
throw new Exception(ex.getMessage());
}
}
@Override
public Boolean Cadastrar(Object objeto) {
TipoPapel cTipoPapel = (TipoPapel) objeto;
Boolean bRetorno = false;
if (cTipoPapel.getIdTipoPapel() == 0 || cTipoPapel.getIdTipoPapel() == null) {
bRetorno = this.Inserir(cTipoPapel);
} else {
bRetorno = this.Alterar(cTipoPapel);
}
return bRetorno;
}
@Override
public Boolean Inserir(Object objeto) {
TipoPapel cTipoPapel = (TipoPapel) objeto;
PreparedStatement Stmt = null;
//Prepara comando SQL
String strSQL = "Insert Into TipoPapel (descricaoTipoPapel, situacaoTipoPapel) Values (?, ?);";
try {
Stmt = Connection.prepareStatement(strSQL);
try {
Stmt.setString(1, cTipoPapel.getDescricaoTipoPapel());
Stmt.setString(2, cTipoPapel.getSituacaoTipoPapel());
} catch (Exception ex) {
System.out.println("Problemas ao cadastrar TipoPapel! Erro:" + ex.getMessage());
ex.printStackTrace();
}
Stmt.execute();
return true;
} catch (SQLException ex) {
System.out.println("Problemas ao cadastrar TipoPapel! Erro:" + ex.getMessage());
ex.printStackTrace();
return false;
} finally {
try {
ConnectionFactory.CloseConnection(Connection, Stmt);
} catch (Exception ex) {
System.out.println("Problemas ao fechar os parâmetros de conexão! Erro:" + ex.getMessage());
ex.printStackTrace();
}
}
}
@Override
public Boolean Alterar(Object objeto) {
TipoPapel cTipoPapel = (TipoPapel) objeto;
PreparedStatement Stmt = null;
/*PreparedStatement = prepara a intrução SQL*/
String strSQL = " Update TipoPapel set descricaoTipoPapel = ?, situacaoTipoPapel = ? Where IdTipoPapel = ?;";
try {
Stmt = Connection.prepareStatement(strSQL);
Stmt.setString(1, cTipoPapel.getDescricaoTipoPapel());
Stmt.setString(2, cTipoPapel.getSituacaoTipoPapel());
Stmt.setInt(3, cTipoPapel.getIdTipoPapel());
Stmt.executeUpdate();
return true;
} catch (SQLException ex) {
System.out.println("Problemas ao alterar TipoPapel! Erro:" + ex.getMessage());
ex.printStackTrace();
return false;
} finally {
try {
ConnectionFactory.CloseConnection(Connection, Stmt);
} catch (Exception ex) {
System.out.println("Problemas ao fechar os parâmetros de conexão! Erro:" + ex.getMessage());
ex.printStackTrace();
}
}
}
@Override
public Boolean Excluir(Object objeto) {
TipoPapel cTipoPapel = (TipoPapel) objeto;
int idTipoPapel = cTipoPapel.getIdTipoPapel();
String strSQL = "";
String Situacao = cTipoPapel.getSituacaoTipoPapel();
PreparedStatement stmt = null;
//String strSQL = "Delete From TipoPapel Where idTipoPapel = ?";
if (Situacao.equals("A")) {
strSQL = "Update TipoPapel Set SituacaoTipoPapel = 'I' Where idTipoPapel = ?";
}else{
strSQL = "Update TipoPapel Set SituacaoTipoPapel = 'A' Where idTipoPapel = ?";
};
try {
stmt = Connection.prepareStatement(strSQL);
stmt.setInt(1, idTipoPapel);
stmt.execute();
return true;
} catch (Exception e) {
System.out.println("Problemas ao excluir TipoPapel! Erro: " + e.getMessage());
return false;
}
}
@Override
public Object Carregar(int Numero) {
PreparedStatement Stmt = null;
ResultSet rs = null;
TipoPapel cTipoPapel = null;
String strSQL = "Select E.* From TipoPapel E Where E.IdTipoPapel = ?;";
try {
Stmt = Connection.prepareStatement(strSQL);
Stmt.setInt(1, Numero);
rs = Stmt.executeQuery();
while (rs.next()) {
cTipoPapel = new TipoPapel();
cTipoPapel.setIdTipoPapel(rs.getInt("IdTipoPapel"));
cTipoPapel.setDescricaoTipoPapel(rs.getString("descricaoTipoPapel"));
cTipoPapel.setSituacaoTipoPapel(rs.getString("situacaoTipoPapel"));
}
return cTipoPapel;
} catch (SQLException ex) {
System.out.println("Problemas ao carregar TipoPapel! Erro: " + ex.getMessage());
ex.printStackTrace();
} finally {
try {
ConnectionFactory.CloseConnection(Connection, Stmt, rs);
} catch (Exception ex) {
System.out.println("Problemas ao fechar os parâmetros de conexão! Erro:" + ex.getMessage());
ex.printStackTrace();
}
}
return cTipoPapel;
}
@Override
public List<Object> Listar() {
List<Object> listaTipoPapel = new ArrayList<>();
PreparedStatement Stmt = null;
ResultSet rs = null;
String strSQL = "Select E.* From TipoPapel E Order By E.descricaoTipoPapel";
try {
Stmt = Connection.prepareStatement(strSQL);
rs = Stmt.executeQuery();
while (rs.next()) {
TipoPapel cTipoPapel = new TipoPapel();
cTipoPapel.setIdTipoPapel(rs.getInt("IdTipoPapel"));
cTipoPapel.setDescricaoTipoPapel(rs.getString("DescricaoTipoPapel"));
cTipoPapel.setSituacaoTipoPapel(rs.getString("situacaoTipoPapel"));
listaTipoPapel.add(cTipoPapel);
}
} catch (SQLException ex) {
System.out.println("Problemas ao listar TipoPapel! Erro: " + ex.getMessage());
ex.printStackTrace();
} finally {
try {
ConnectionFactory.CloseConnection(Connection, Stmt, rs);
} catch (Exception ex) {
System.out.println("Problemas ao fechar os parâmetros de conexão! Erro:" + ex.getMessage());
ex.printStackTrace();
}
}
return listaTipoPapel;
}
}
| [
"[email protected]"
] | |
2d61c9611a032803ad0d8dc30b1eec0523800f63 | 977fc8369d63c0b9f6b40653283978a82b028f3d | /src/main/java/com/springbatch/EDIscheduler/part1/HelloConfiguration.java | f21837d539f316400064a2c528be5019ecb2cfc3 | [] | no_license | D0ctrine/edibatch | ff854253e5593d33a88f7d9578c2900331b32f10 | c91323ecfa5ba8c7086e2edee3b6b6f067b79835 | refs/heads/main | 2023-07-13T17:23:25.010939 | 2021-08-20T08:37:31 | 2021-08-20T08:37:31 | 397,748,947 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,500 | java | package com.springbatch.EDIscheduler.part1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@Slf4j
public class HelloConfiguration {
private final JobBuilderFactory jobBuilderFactory;
private final StepBuilderFactory stepBuilderFactory;
public HelloConfiguration(JobBuilderFactory jobBuilderFactory,StepBuilderFactory stepBuilderFactory){
this.jobBuilderFactory = jobBuilderFactory;
this.stepBuilderFactory = stepBuilderFactory;
}
@Bean
public Job HelloJob(){
return jobBuilderFactory.get("helloJob")
.incrementer(new RunIdIncrementer())
.start(this.helloStep())
.build();
}
@Bean
public Step helloStep(){
return stepBuilderFactory.get("helloStep")
.tasklet((contribution, chunkContext) -> {
log.info("hello spring batch");
return RepeatStatus.FINISHED;
}).build();
}
}
| [
"[email protected]"
] | |
28799bf861eda7ebae198a3659b659594f3ef356 | bfb2ae0a28a6fb6a2e302b2509ab7bf71238c795 | /usd.dal/src/main/java/com/xrk/usd/dal/dao/DaoBase.java | 1884d82335913083acc9c5f05df41d6ce658bc88 | [] | no_license | mendylee/ugs | 9c8240548c0362765081c5f5be8811fbf3e5d78f | 83fcb1165a80415f35d8ce313bbce24ebd7a2096 | refs/heads/master | 2020-04-07T01:56:56.891121 | 2018-11-17T06:43:41 | 2018-11-17T06:43:41 | 157,958,156 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,777 | java | package com.xrk.usd.dal.dao;
import org.hibernate.exception.JDBCConnectionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xrk.usd.dal.DalService;
import javax.persistence.*;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* 数据操作基础类,实现常见的数据库实体操作方法
* DaoBase: DaoBase.java.
* <p>
* <br>==========================
* <br> 公司:广州向日葵信息科技有限公司
* <br> 开发:shunchiguo<[email protected]>
* <br> 版本:1.0
* <br> 创建时间:2015年9月10日
* <br> JDK版本:1.7
* <br>==========================
*/
public abstract class DaoBase<T extends java.io.Serializable> {
protected Class<T> clazz;
protected Logger logger;
protected static EntityManagerFactory factory = null;
public static void setFactory(EntityManagerFactory ef) {
factory = ef;
}
public DaoBase() {
doGetClass();
logger = LoggerFactory.getLogger(this.getClass());
// try {
// this.factory = factory;
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// e.printStackTrace();
// }
}
private void doGetClass() {
Type genType = this.getClass().getGenericSuperclass();
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
this.clazz = (Class<T>) params[0];
}
/**
* 执行一个数据处理对象
*
* @param procObj
* @return
*/
protected int execute(DaoProcessObj procObj) {
List<DaoProcessObj> lsProcObj = new ArrayList<DaoProcessObj>();
lsProcObj.add(procObj);
return execute(lsProcObj);
}
/**
* 在一个事务中执行多个数据处理对象
*
* @param lsProcObj
* @return
*/
protected int execute(List<DaoProcessObj> lsProcObj) {
int bRtn = 0;
if (lsProcObj.size() < 1) {
return bRtn;
}
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return bRtn;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
for (DaoProcessObj procObj : lsProcObj) {
Query query = entityManager.createQuery(procObj.getHsql());
if (procObj.isMapParams()) {
Map<String, Object> dictParams = procObj.getMapParams();
for (Entry<String, Object> kv : dictParams.entrySet()) {
query = query.setParameter(kv.getKey(), kv.getValue());
}
} else {
List<Object> lsParams = procObj.getParams();
int position = 0;
for (Object obj : lsParams) {
query = query.setParameter(position++, obj);
}
}
bRtn = query.executeUpdate();
}
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
public T getSingleResult(DaoProcessObj procObj) {
EntityManager entityManager = factory.createEntityManager();
try {
List<T> list = this.setParamters(entityManager.createQuery(procObj.getHsql(), this.clazz), procObj).setMaxResults(1).getResultList();
return (null==list||list.isEmpty())?null:list.get(0);
}
catch (Exception e) {
logger.error(e.getMessage(), e);
DalService.onError(e);
throw e;
}
finally {
entityManager.close();
}
}
public int getCount(DaoProcessObj procObj){
int ret = 0;
EntityManager entityManager;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return ret;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
Query query = entityManager.createQuery(procObj.getHsql());
if (procObj.isMapParams()) {
Map<String, Object> dictParams = procObj.getMapParams();
for (Entry<String, Object> kv : dictParams.entrySet()) {
query = query.setParameter(kv.getKey(), kv.getValue());
}
} else {
List<Object> lsParams = procObj.getParams();
int position = 0;
for (Object obj : lsParams) {
query = query.setParameter(position++, obj);
}
}
Object obj = query.getSingleResult();
ret = null==obj?0:Integer.parseInt(obj.toString());
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return ret;
}
protected <Q extends Query> Q setParamters(Q query, DaoProcessObj procObj) {
if (procObj.isMapParams()) {
Map<String, Object> dictParams = procObj.getMapParams();
for (Entry<String, Object> kv : dictParams.entrySet()) {
query = (Q) query.setParameter(kv.getKey(), kv.getValue());
}
} else {
List<Object> lsParams = procObj.getParams();
int position = 0;
for (Object obj : lsParams) {
query = (Q) query.setParameter(position++, obj);
}
}
return query;
}
public List<T> query(DaoProcessObj procObj, int pageSize, int pageIndex) {
EntityManager entityManager = factory.createEntityManager();
try {
return this.setParamters(entityManager.createQuery(procObj.getHsql(), this.clazz), procObj)
.setFirstResult((pageIndex - 1) * pageSize)
.setMaxResults(pageSize)
.getResultList();
}catch (Exception e) {
logger.error(e.getMessage(), e);
DalService.onError(e);
throw e;
} finally {
entityManager.close();
}
}
/**
* 执行一个数据查询操作
*
* @param procObj
* @return
*/
protected List<T> query(DaoProcessObj procObj) {
List<T> lsRtn = null;
EntityManager entityManager;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return lsRtn;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
TypedQuery<T> query = entityManager.createQuery(procObj.getHsql(), this.clazz);
if (procObj.isMapParams()) {
Map<String, Object> dictParams = procObj.getMapParams();
for (Entry<String, Object> kv : dictParams.entrySet()) {
query = query.setParameter(kv.getKey(), kv.getValue());
}
} else {
List<Object> lsParams = procObj.getParams();
int position = 0;
for (Object obj : lsParams) {
query = query.setParameter(position++, obj);
}
}
lsRtn = query.getResultList();
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return lsRtn;
}
/**
* 检查指定的对象是否存在
*
* @param entity
* @return
*/
protected boolean contains(T entity) {
EntityManager entityManager = null;
boolean bRtn = true;
try {
entityManager = factory.createEntityManager();
bRtn = entityManager.contains(entity);
} catch (Exception e) {
bRtn = false;
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
/**
* 添加一个实体对象
*
* @param entity
* @return
*/
public boolean persist(Object entity) {
boolean bRtn = true;
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return false;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
entityManager.persist(entity);
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
bRtn = false;
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
/**
* 添加一系列对象或多个对象
*
* @param lsEntity
* @return
*/
public boolean persist(List<T> lsEntity) {
boolean bRtn = true;
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return false;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
for (Object entity : lsEntity) {
entityManager.persist(entity);
}
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
bRtn = false;
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
/**
* @param entity
* @return
*/
public boolean merge(Object entity) {
boolean bRtn = true;
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return false;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
entityManager.merge(entity);
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
bRtn = false;
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
/**
* 移除指定的队列
*
* @param entity
* @return
*/
public boolean remove(Object entity) {
List<Object> lsEntity = new ArrayList<Object>();
lsEntity.add(entity);
return remove(lsEntity);
}
/**
* 移除指定队列的实体对象
*
* @param lsEntity
* @return
*/
public boolean removeList(List<T> lsEntity) {
boolean bRtn = true;
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
} catch (Exception e) {
return false;
}
EntityTransaction transaction = entityManager.getTransaction();
try {
transaction.begin();
for (Object entity : lsEntity) {
entityManager.remove(entityManager.contains(entity) ? entity : entityManager.merge(entity));
}
transaction.commit();
} catch (Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
bRtn = false;
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return bRtn;
}
/**
* 根据主键ID查找记录
*
* @param entityClass
* @param primaryKey
* @return
*/
protected T findById(Class<T> entityClass, Object primaryKey) {
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
return entityManager.find(entityClass, primaryKey);
} catch (Exception e) {
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return null;
}
public T findById(Object primaryKey) {
return this.findById(clazz, primaryKey);
}
/**
* 查询所有的记录
*
* @param entityClass
* @return
*/
protected List<T> findAll(Class<T> entityClass) {
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<T> query = builder.createQuery(entityClass);
Root<T> variableRoot = query.from(entityClass);
query.select(variableRoot);
return entityManager.createQuery(query).getResultList();
} catch (Exception e) {
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return null;
}
public List<T> findAll() {
return this.findAll(clazz);
}
protected List<T> findByPage(Integer pageIndex, Integer pageSize) {
EntityManager entityManager = null;
try {
entityManager = factory.createEntityManager();
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<T> query = builder.createQuery(clazz);
Root<T> variableRoot = query.from(clazz);
query.select(variableRoot);
return entityManager.createQuery(query).setFirstResult((pageIndex - 1) * pageSize).setMaxResults(pageSize).getResultList();
} catch (Exception e) {
logger.error(e.getMessage(), e);
DalService.onError(e);
} finally {
if (entityManager != null) {
entityManager.close();
}
}
return null;
}
}
| [
"[email protected]"
] | |
74375fb30efed86b5b0542b613b4c8d48d952607 | 0967a0932f52307406be335c6c5859f0d7181c1e | /zfw/src/main/java/com/baidu/ueditor/ConfigManager.java | 9b9eb53e08f67bde6f4ff58306da856235cfe12b | [] | no_license | lilJay-lin/zfw | 79823414004af8d741397a5bf0f4611d6e2660e9 | 8423b2db4d2d25c2aa9f85ca85226ef6919c60fe | refs/heads/master | 2021-01-01T05:31:50.692973 | 2015-07-05T12:06:32 | 2015-07-05T12:06:32 | 33,930,103 | 0 | 0 | null | 2015-04-14T12:24:14 | 2015-04-14T12:24:14 | null | UTF-8 | Java | false | false | 7,077 | java | package com.baidu.ueditor;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import com.baidu.ueditor.define.ActionMap;
/**
* 配置管理器
* @author [email protected]
*
*/
public final class ConfigManager {
private final String rootPath;
private final String originalPath;
private final String contextPath;
// private static final String configFileName = "config.json";
private static final String configFileName = "ueditor-config.json";
private String parentPath = null;
private JSONObject jsonConfig = null;
// 涂鸦上传filename定义
private final static String SCRAWL_FILE_NAME = "scrawl";
// 远程图片抓取filename定义
private final static String REMOTE_FILE_NAME = "remote";
/*
* 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件
*/
private ConfigManager ( String rootPath, String contextPath, String uri ) throws FileNotFoundException, IOException {
rootPath = rootPath.replace( "\\", "/" );
this.rootPath = rootPath;
this.contextPath = contextPath;
if ( contextPath.length() > 0 ) {
this.originalPath = this.rootPath + uri.substring( contextPath.length() );
} else {
this.originalPath = this.rootPath + uri;
}
this.initEnv();
}
/**
* 配置管理器构造工厂
* @param rootPath 服务器根路径
* @param contextPath 服务器所在项目路径
* @param uri 当前访问的uri
* @return 配置管理器实例或者null
*/
public static ConfigManager getInstance ( String rootPath, String contextPath, String uri ) {
try {
return new ConfigManager(rootPath, contextPath, uri);
} catch ( Exception e ) {
return null;
}
}
// 验证配置文件加载是否正确
public boolean valid () {
return this.jsonConfig != null;
}
public JSONObject getAllConfig () {
return this.jsonConfig;
}
public Map<String, Object> getConfig ( int type ) {
Map<String, Object> conf = new HashMap<String, Object>();
String savePath = null;
switch ( type ) {
case ActionMap.UPLOAD_FILE:
conf.put( "isBase64", "false" );
conf.put( "maxSize", this.jsonConfig.getLong( "fileMaxSize" ) );
conf.put( "allowFiles", this.getArray( "fileAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "fileFieldName" ) );
savePath = this.jsonConfig.getString( "filePathFormat" );
break;
case ActionMap.UPLOAD_IMAGE:
conf.put( "isBase64", "false" );
conf.put( "maxSize", this.jsonConfig.getLong( "imageMaxSize" ) );
conf.put( "allowFiles", this.getArray( "imageAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "imageFieldName" ) );
savePath = this.jsonConfig.getString( "imagePathFormat" );
break;
case ActionMap.UPLOAD_VIDEO:
conf.put( "maxSize", this.jsonConfig.getLong( "videoMaxSize" ) );
conf.put( "allowFiles", this.getArray( "videoAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "videoFieldName" ) );
savePath = this.jsonConfig.getString( "videoPathFormat" );
break;
case ActionMap.UPLOAD_SCRAWL:
conf.put( "filename", ConfigManager.SCRAWL_FILE_NAME );
conf.put( "maxSize", this.jsonConfig.getLong( "scrawlMaxSize" ) );
conf.put( "fieldName", this.jsonConfig.getString( "scrawlFieldName" ) );
conf.put( "isBase64", "true" );
savePath = this.jsonConfig.getString( "scrawlPathFormat" );
break;
case ActionMap.CATCH_IMAGE:
conf.put( "filename", ConfigManager.REMOTE_FILE_NAME );
conf.put( "filter", this.getArray( "catcherLocalDomain" ) );
conf.put( "maxSize", this.jsonConfig.getLong( "catcherMaxSize" ) );
conf.put( "allowFiles", this.getArray( "catcherAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "catcherFieldName" ) + "[]" );
savePath = this.jsonConfig.getString( "catcherPathFormat" );
break;
case ActionMap.LIST_IMAGE:
conf.put( "allowFiles", this.getArray( "imageManagerAllowFiles" ) );
conf.put( "dir", this.jsonConfig.getString( "imageManagerListPath" ) );
conf.put( "count", this.jsonConfig.getInt( "imageManagerListSize" ) );
break;
case ActionMap.LIST_FILE:
conf.put( "allowFiles", this.getArray( "fileManagerAllowFiles" ) );
conf.put( "dir", this.jsonConfig.getString( "fileManagerListPath" ) );
conf.put( "count", this.jsonConfig.getInt( "fileManagerListSize" ) );
break;
}
conf.put( "savePath", savePath );
conf.put( "rootPath", this.rootPath );
return conf;
}
private void initEnv () throws FileNotFoundException, IOException {
// File file = new File( this.originalPath );
// if ( !file.isAbsolute() ) {
// file = new File( file.getAbsolutePath() );
// }
// this.parentPath = file.getParent();
try{
String configContent = this.readFile( this.getConfigPath() );
JSONObject jsonConfig = new JSONObject( configContent );
this.jsonConfig = jsonConfig;
} catch ( Exception e ) {
this.jsonConfig = null;
e.printStackTrace();
}
}
private String getConfigPath () {
String url = this.getClass().getResource("/")+ConfigManager.configFileName;
url = url.replace("file:/", "");
return url;
// return this.getClass().getResource("/")+ConfigManager.configFileName;
// return "D:\\Workspaces\\javaWorkspace20140504\\zfw\\target\\classes\\"+ConfigManager.configFileName;
// return this.parentPath + File.separator + ConfigManager.configFileName;
}
private String[] getArray ( String key ) {
JSONArray jsonArray = this.jsonConfig.getJSONArray( key );
String[] result = new String[ jsonArray.length() ];
for ( int i = 0, len = jsonArray.length(); i < len; i++ ) {
result[i] = jsonArray.getString( i );
}
return result;
}
private String readFile ( String path ) throws IOException {
StringBuilder builder = new StringBuilder();
try {
InputStreamReader reader = new InputStreamReader( new FileInputStream( path ), "UTF-8" );
BufferedReader bfReader = new BufferedReader( reader );
String tmpContent = null;
while ( ( tmpContent = bfReader.readLine() ) != null ) {
builder.append( tmpContent );
}
bfReader.close();
} catch ( UnsupportedEncodingException e ) {
// 忽略
}
return this.filter( builder.toString() );
}
// 过滤输入字符串, 剔除多行注释以及替换掉反斜杠
private String filter ( String input ) {
return input.replaceAll( "/\\*[\\s\\S]*?\\*/", "" );
}
}
| [
"[email protected]"
] | |
fa60a626a8c9cf652d4ba9e9bafd699327771d1c | 4ac581dabb82a3d90510ebc5024171c90ad63aee | /src/main/java/commands/admin/attendance/AttendanceList.java | 47b71cb890ee74d802a059eb2c07f8e262240ece | [] | no_license | Excaliburns/NoleBot | 8b012e3121c1d985d19c9d4975e63381b90fd241 | 6f13d39091ef2400500081c0d63c8e5d4402a75a | refs/heads/master | 2021-06-15T05:15:58.618465 | 2021-03-18T18:59:24 | 2021-03-18T18:59:24 | 170,753,530 | 5 | 2 | null | 2019-03-14T05:44:23 | 2019-02-14T20:28:02 | Java | UTF-8 | Java | false | false | 1,194 | java | package commands.admin.attendance;
import commands.util.Command;
import commands.util.CommandEvent;
import net.dv8tion.jda.api.entities.MessageChannel;
import util.DBUtils;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
public class AttendanceList extends Command {
public AttendanceList() {
name = "attendancelist";
description = "Used for listing attendance.";
helpDescription = "Used for listing attendance.";
requiredPermission = 1000;
usages.add("attendancelist all");
usages.add("attendancelist <Since Date> <Percentage>");
}
@Override
public void onCommandReceived(CommandEvent event) {
String[] args = event.getMessage();
MessageChannel messageChannel = event.getChannel();
if (args[1] == null) {
messageChannel.sendMessage("Please enter an argument").queue();
} else if (!args[1].isEmpty()){
ArrayList<String> message = new ArrayList<>(Arrays.asList(args[1].split("\\s")));
if (message.get(0).toLowerCase().equals("all")) {
}
}
}
}
| [
"[email protected]"
] | |
23f425e1b7d1b267e7317a92a16a30399ddc3882 | 73095d26e755b5163c157b288b46d2ef11984066 | /LeetCode/src/scu/edu/cn/datastructure/linkedlist/SingleCircleLinkedListTest.java | 9858a516098ff114bffcd67052e92c583979de3f | [] | no_license | zzy0620/leetcode | a2c91229bb0d3f7e5319bae259402f398ff69259 | 98031cf4911909e2a35d4ac0dd90302b3882749a | refs/heads/master | 2023-03-26T23:35:16.459577 | 2021-03-27T09:22:53 | 2021-03-27T09:22:53 | 302,240,574 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,204 | java | package scu.edu.cn.datastructure.linkedlist;
/**
* @program: DataStructures
* @description: 单向环形链表
* @author: zzy
* @create: 2021-03-06 15:17
**/
public class SingleCircleLinkedListTest {
public static void main(String[] args) {
Node node1 = new Node(1);
Node node2 = new Node(2);
Node node3 = new Node(3);
Node node4 = new Node(4);
Node node5 = new Node(5);
SingleCircleLinkedList singleCircleLinkedList = new SingleCircleLinkedList();
singleCircleLinkedList.addNode(node1);
singleCircleLinkedList.addNode(node2);
singleCircleLinkedList.addNode(node3);
singleCircleLinkedList.addNode(node4);
singleCircleLinkedList.addNode(node5);
singleCircleLinkedList.list();
singleCircleLinkedList.deleteNode(1);
System.out.println("==========================");
singleCircleLinkedList.list();
singleCircleLinkedList.deleteNode(5);
System.out.println("==========================");
singleCircleLinkedList.list();
singleCircleLinkedList.deleteNode(2);
singleCircleLinkedList.deleteNode(3);
singleCircleLinkedList.deleteNode(4);
System.out.println("==========================");
singleCircleLinkedList.list();
}
}
class SingleCircleLinkedList{
private Node first = null;
private Node cur = null;
public void addNode(Node node){
if (first == null){
first = node;
cur = first;
first.next = first;
}else {
cur.next = node;
node.next = first;
cur = node;
}
}
public void deleteNode(int no){
if (first == null){
System.out.println("链表为空,不能进行删除");
return;
}
//如果只有一个节点,并且该节点是要被删除的节点
if (first.next.no == first.no && first.no == no){
first = null;
cur = null;
return;
}
//要删除头结点
if (first.no == no){
cur.next = first.next;
first = first.next;
return;
}
Node temp = first;
boolean flag = false;
while (temp.next.no != first.no){
if (temp.next.no == no){
flag = true;
break;
}
temp = temp.next;
}
if (flag){
if (temp.next.no == cur.no){
cur = temp;
cur.next = first;
}else {
temp.next = temp.next.next;
}
}
}
public void list(){
if (first == null){
System.out.println("链表为空");
return;
}
Node temp = first;
do {
System.out.println(temp);
temp = temp.next;
}while (temp.no != first.no);
}
}
class Node{
public int no;//编号
public Node next; //指向下一个节点
public Node(int no){
this.no = no;
}
@Override
public String toString() {
return "Node{" +
"no=" + no +
'}';
}
} | [
"[email protected]"
] | |
02dae3ca9f9d66bc33805e8ef97427304d0677c9 | 0880c902f98c8ba26c30726106c5919cba776a6d | /kagubuzzsite/src/main/java/com/kagubuzz/controllers/Messages.java | 2912634f4e35388ecb06a9fb1f4e905ebf38671a | [] | no_license | catch-twenty-two/kagubuzz | 3f8a939f520dbe8ac90d09f265de389d4690c3f5 | cca9d94a6d876ab1fac479c274b769bd94b3663a | refs/heads/master | 2021-01-17T07:54:17.981937 | 2017-01-24T01:51:11 | 2017-01-24T01:51:11 | 51,226,456 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 714 | java | package com.kagubuzz.controllers;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$
private static final ClassLoader cl = Thread.currentThread().getContextClassLoader();
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale("en", "US"), cl);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
| [
"[email protected]"
] | |
3851b1ad85be69f2b93ca54e0662a5d4b63673d7 | 57693850056550cc64d1a21c23ec67a7fa21c36b | /src/model/board/level/Levels.java | 431d02b775744f92eaa2272bcb058a2052f7f941 | [] | no_license | AngieArlanti/dSonoro-videojuego | 5f645b4c3675f9faaa2f83380fd565a4803696b3 | e8f91fd78c125ee8b9a893854a81eef58b333ea3 | refs/heads/master | 2021-01-17T12:56:50.609377 | 2016-06-17T16:44:29 | 2016-06-17T16:44:29 | 58,774,310 | 0 | 0 | null | 2016-06-14T07:06:59 | 2016-05-13T21:46:07 | Java | UTF-8 | Java | false | false | 77 | java | package model.board.level;
public enum Levels {
HELL, PURGATORY, HEAVEN
}
| [
"[email protected]"
] | |
6234392f6de3fb33ad7fe74860d163993d509922 | 71e87d58cbb1e9f1f6de2b1e5abdd1675b382902 | /JChess/src/com/chess/engine/board/Board.java | 51e7ddb4d65e60853ea4589c1fd3ad98765a942b | [] | no_license | sbyt2/GAMES | c2dbe7d9c7c2ea60a1acc796bc15c47d73d55f8e | f9435024719dcd983e85b1c88758f76ec838b25d | refs/heads/master | 2023-03-19T18:02:48.260939 | 2020-11-27T14:42:30 | 2020-11-27T14:42:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,578 | java | package com.chess.engine.board;
import com.chess.engine.Alliance;
import com.chess.engine.pieces.*;
import com.chess.engine.player.BlackPlayer;
import com.chess.engine.player.Player;
import com.chess.engine.player.WhitePlayer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import java.util.*;
public class Board {
private final List<Tile> gameBoard;
private final Collection<Piece> whitePieces;
private final Collection<Piece> blackPieces;
private final WhitePlayer whitePlayer;
private final BlackPlayer blackPlayer;
private final Player currentPlayer;
private final Pawn enPassantPawn;
private Board(final Builder builder) {
// in gameBoard contains occupied or not occupied tiles..
// builder.boardConfig + Tile.createAllPossibleEmptyTiles()
// we can change builder.boardConfig to get different gameBoard!
this.gameBoard = createGameBoard(builder); // creating tiles..
// in whitePieces/blackPieces contains only occupied tiles!
this.whitePieces = calculateActivePieces(this.gameBoard, Alliance.WHITE);
this.blackPieces = calculateActivePieces(this.gameBoard, Alliance.BLACK);
this.enPassantPawn = builder.enPassantPawn;
// calculating the all possible legal moves of the all pieces..
final Collection<Move> whiteStandardLegalMoves = calculateLegalMoves(this.whitePieces);
final Collection<Move> blackStandardLegalMoves = calculateLegalMoves(this.blackPieces);
// so it turns out that each player contains all possible moves of all pieces..
this.whitePlayer = new WhitePlayer(this, whiteStandardLegalMoves, blackStandardLegalMoves);
this.blackPlayer = new BlackPlayer(this, whiteStandardLegalMoves, blackStandardLegalMoves);
this.currentPlayer = builder.nextMoveMaker.choosePlayer(this.whitePlayer, this.blackPlayer);
// board -> builder -> moveMaker -> alliance -> choosePlayer() -> player
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < BoardUtils.NUN_TILES; i++) {
final String tileText = this.getTile(i).toString();
builder.append(String.format("%3s", tileText));
if ((i + 1) % BoardUtils.NUN_TILES_PER_ROW == 0) {
builder.append("\n");
}
}
return builder.toString();
}
public Player whitePlayer() {
return this.whitePlayer;
}
public Player blackPlayer() {
return this.blackPlayer;
}
public Player currentPlayer() {
return this.currentPlayer;
}
public Pawn getEnPassantPawn() {
return this.enPassantPawn;
}
public Collection<Piece> getBlackPieces() {
return this.blackPieces;
}
public Collection<Piece> getWhitePieces() {
return whitePieces;
}
// in comes Collections of white/black exists pieces -> piece.calculateLegalMoves(Board board) -> moves
private Collection<Move> calculateLegalMoves(final Collection<Piece> pieces) {
final List<Move> legalMoves = new ArrayList<>();
for (final Piece piece : pieces) {
legalMoves.addAll(piece.calculateLegalMoves(this));
}
return ImmutableList.copyOf(legalMoves);
}
//gameBoard -> tile -> isTileOccupied() -> tile.getPiece() -> piece.getPieceAlliance() -> activePiece.add(piece)
private static Collection<Piece> calculateActivePieces(final List<Tile> gameBoard, final Alliance alliance) {
final List<Piece> activePiece = new ArrayList<>();
// gameBoard contains occupied and not occupied tiles!
for (final Tile tile : gameBoard) {
if (tile.isTileOccupied()) {
final Piece piece = tile.getPiece();
if (piece.getPieceAlliance() == alliance) {
activePiece.add(piece);
}
}
}
return ImmutableList.copyOf(activePiece);
}
private List<Tile> createGameBoard(final Builder builder) {
final Tile[] tiles = new Tile[BoardUtils.NUN_TILES];
//coincidence i between tiles[] and Map<>boardConfig..
for (int i = 0; i < BoardUtils.NUN_TILES; i++) {
tiles[i] = Tile.createTile(i, builder.boardConfig.get(i)); // pieces -> tiles
}
return ImmutableList.copyOf(tiles);
}
public static Board createStandardBoard() {
final Builder builder = new Builder();
builder.setPiece(new Rook(Alliance.BLACK, 0));
builder.setPiece(new Knight(Alliance.BLACK, 1));
builder.setPiece(new Bishop(Alliance.BLACK, 2));
builder.setPiece(new Queen(Alliance.BLACK, 3));
builder.setPiece(new King(Alliance.BLACK, 4, true, true));
builder.setPiece(new Bishop(Alliance.BLACK, 5));
builder.setPiece(new Knight(Alliance.BLACK, 6));
builder.setPiece(new Rook(Alliance.BLACK, 7));
builder.setPiece(new Pawn(Alliance.BLACK, 8));
builder.setPiece(new Pawn(Alliance.BLACK, 9));
builder.setPiece(new Pawn(Alliance.BLACK, 10));
builder.setPiece(new Pawn(Alliance.BLACK, 11));
builder.setPiece(new Pawn(Alliance.BLACK, 12));
builder.setPiece(new Pawn(Alliance.BLACK, 13));
builder.setPiece(new Pawn(Alliance.BLACK, 14));
builder.setPiece(new Pawn(Alliance.BLACK, 15));
builder.setPiece(new Pawn(Alliance.WHITE, 48));
builder.setPiece(new Pawn(Alliance.WHITE, 49));
builder.setPiece(new Pawn(Alliance.WHITE, 50));
builder.setPiece(new Pawn(Alliance.WHITE, 51));
builder.setPiece(new Pawn(Alliance.WHITE, 52));
builder.setPiece(new Pawn(Alliance.WHITE, 53));
builder.setPiece(new Pawn(Alliance.WHITE, 54));
builder.setPiece(new Pawn(Alliance.WHITE, 55));
builder.setPiece(new Rook(Alliance.WHITE, 56));
builder.setPiece(new Knight(Alliance.WHITE, 57));
builder.setPiece(new Bishop(Alliance.WHITE, 58));
builder.setPiece(new King(Alliance.WHITE, 59, true, true));
builder.setPiece(new Queen(Alliance.WHITE, 60));
builder.setPiece(new Bishop(Alliance.WHITE, 61));
builder.setPiece(new Knight(Alliance.WHITE, 62));
builder.setPiece(new Rook(Alliance.WHITE, 63));
builder.setMoveMaker(Alliance.WHITE);
return builder.build(); // to create all on the board..
}
public Tile getTile(final int tileCoordinate) {
return gameBoard.get(tileCoordinate);
}
public Iterable<Move> getAllLegalMoves() {
return Iterables.unmodifiableIterable(Iterables.concat(this.whitePlayer.getLegalMoves(),
this.blackPlayer.getLegalMoves()));
}
public static class Builder {
Map<Integer, Piece> boardConfig;
Alliance nextMoveMaker;
Pawn enPassantPawn;
public Builder() {
boardConfig = new HashMap<>();
}
public Builder setPiece(final Piece piece) {
this.boardConfig.put(piece.getPiecePosition(), piece);
return this;
}
public Builder setMoveMaker(final Alliance nextMoveMaker) {
this.nextMoveMaker = nextMoveMaker;
return this;
}
public Board build() {
return new Board(this);
}
public void setEnPassantPawn(Pawn enPassantPawn) {
this.enPassantPawn = enPassantPawn;
}
}
}
// pieces -> builder -> board -> tiles | [
"[email protected]"
] | |
63b10c211e8e613249361c6486834d40125fc5dd | 8c3eed0cec9d52e9643226d43c6b88f4bc68883d | /云上果洛java/bxl/系统框架/Java/com/vieking/sys/utils/ExcelUtils.java | 34f9b72032b0c609fd25c067cc061dc3c5507e1b | [] | no_license | yilongchun/ysgljava | 0ad8f25ed8e52896f40c381bfc34aa233b8de16f | 83ba0f1284f82790bc9cb265eac8526eed1f5d97 | refs/heads/master | 2021-05-23T05:33:10.179156 | 2018-07-31T01:27:12 | 2018-07-31T01:27:12 | 95,066,206 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,527 | java | package com.vieking.sys.utils;
import java.io.FileInputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hibernate.annotations.BatchSize;
import com.vieking.basicdata.model.Department;
import com.vieking.basicdata.model.Dictionary;
import com.vieking.functions.model.Contact;
import com.vieking.functions.model.ContactPost;
import com.vieking.role.model.User;
public class ExcelUtils {
public static final String OFFICE_EXCEL_2003_POSTFIX = "xls";
public static final String OFFICE_EXCEL_2010_POSTFIX = "xlsx";
public static final String EMPTY = "";
public static final String POINT = ".";
public static final String LIB_PATH = "lib";
public static final String STUDENT_INFO_XLS_PATH = LIB_PATH
+ "/student_info" + POINT + OFFICE_EXCEL_2003_POSTFIX;
public static final String STUDENT_INFO_XLSX_PATH = LIB_PATH
+ "/student_info" + POINT + OFFICE_EXCEL_2010_POSTFIX;
public static final String NOT_EXCEL_FILE = " : Not the Excel file!";
public static final String PROCESSING = "Processing...";
/**
* read the Excel file
* @param path the path of the Excel file
* @return
* @throws IOException
*/
// public List<Student> readExcel(String path) throws IOException {
// if (path == null || Common.EMPTY.equals(path)) {
// return null;
// } else {
// String postfix = Util.getPostfix(path);
// if (!Common.EMPTY.equals(postfix)) {
// if (Common.OFFICE_EXCEL_2003_POSTFIX.equals(postfix)) {
// return readXls(path);
// } else if (Common.OFFICE_EXCEL_2010_POSTFIX.equals(postfix)) {
// return readXlsx(path);
// }
// } else {
// System.out.println(path + Common.NOT_EXCEL_FILE);
// }
// }
// return null;
// }
public static void main(String[] args) {
try {
String file = "e:/1.xlsx";
// readXlsx(file);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Read the Excel 2010
* @param path the path of the excel file
* @return
* @throws IOException
*/
public static List<String[]> readXlsx(InputStream is) throws Exception{
// System.out.println(PROCESSING + path);
// InputStream is = new FileInputStream(path);
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
List<String[]> list = new ArrayList<String[]>();
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(2);
// Read the Row
for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
XSSFRow xssfRow = xssfSheet.getRow(rowNum);
if (xssfRow != null) {
XSSFCell cell1 = xssfRow.getCell(0);
XSSFCell cell2 = xssfRow.getCell(1);
XSSFCell cell3 = xssfRow.getCell(2);
// XSSFCell cell4 = xssfRow.getCell(3);
XSSFCell cell5 = xssfRow.getCell(4);
XSSFCell cell6 = xssfRow.getCell(5);
XSSFCell cell7 = xssfRow.getCell(6);
XSSFCell cell8 = xssfRow.getCell(7);
XSSFCell cell9 = xssfRow.getCell(8);
String name = getValue(cell1);
String phone = getValue(cell2);
String sex = getValue(cell3);
// String bm = getValue(cell4);
String level = getValue(cell5);
String telephone = getValue(cell6);
String post = getValue(cell7);
String email = getValue(cell8);
String jianjie = getValue(cell9);
String[] strArr = new String[9];
strArr[0] = name;
strArr[1] = phone;
strArr[2] = sex;
// strArr[3] = bm;
strArr[4] = level;
strArr[5] = telephone;
strArr[6] = post;
strArr[7] = email;
strArr[8] = jianjie;
if (!phone.trim().equals("")) {
list.add(strArr);
System.out.println(rowNum + "\t" + name + "\t\t" + phone + "\t" + sex + "\t" + level + "\t" + post + "\t" + email + "\t" + jianjie);
}
}
}
return list;
// Read the Sheet
// for (int numSheet = 0; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++) {
// XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(numSheet);
// if (xssfSheet == null) {
// continue;
// }
// // Read the Row
// for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
// XSSFRow xssfRow = xssfSheet.getRow(rowNum);
// if (xssfRow != null) {
//
// XSSFCell cell1 = xssfRow.getCell(0);
// XSSFCell cell2 = xssfRow.getCell(1);
// XSSFCell cell3 = xssfRow.getCell(2);
// XSSFCell cell4 = xssfRow.getCell(3);
//
// }
// }
// }
// return list;
}
/**
* Read the Excel 2003-2007
* @param path the path of the Excel
* @return
* @throws IOException
*/
// public List<Student> readXls(String path) throws IOException {
// System.out.println(Common.PROCESSING + path);
// InputStream is = new FileInputStream(path);
// HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
// Student student = null;
// List<Student> list = new ArrayList<Student>();
// // Read the Sheet
// for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) {
// HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
// if (hssfSheet == null) {
// continue;
// }
// // Read the Row
// for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
// HSSFRow hssfRow = hssfSheet.getRow(rowNum);
// if (hssfRow != null) {
// student = new Student();
// HSSFCell no = hssfRow.getCell(0);
// HSSFCell name = hssfRow.getCell(1);
// HSSFCell age = hssfRow.getCell(2);
// HSSFCell score = hssfRow.getCell(3);
// student.setNo(getValue(no));
// student.setName(getValue(name));
// student.setAge(getValue(age));
// student.setScore(Float.valueOf(getValue(score)));
// list.add(student);
// }
// }
// }
// return list;
// }
@SuppressWarnings("static-access")
private static String getValue(XSSFCell xssfRow) {
if(xssfRow == null){
return "";
}
if (xssfRow.getCellType() == xssfRow.CELL_TYPE_BOOLEAN) {
return String.valueOf(xssfRow.getBooleanCellValue());
} else if (xssfRow.getCellType() == xssfRow.CELL_TYPE_NUMERIC) {
BigDecimal bd = new BigDecimal(xssfRow.getNumericCellValue());
String str = bd.toPlainString();
return str;
} else {
return String.valueOf(xssfRow.getStringCellValue());
}
}
// @SuppressWarnings("static-access")
// private String getValue(HSSFCell hssfCell) {
// if (hssfCell.getCellType() == hssfCell.CELL_TYPE_BOOLEAN) {
// return String.valueOf(hssfCell.getBooleanCellValue());
// } else if (hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC) {
// return String.valueOf(hssfCell.getNumericCellValue());
// } else {
// return String.valueOf(hssfCell.getStringCellValue());
// }
// }
}
| [
"[email protected]"
] | |
27d7abcb8f1bde541dfb22029173ec2c384d4f36 | 76d6c423e3b5845cf4ec0ae555091f5077feec56 | /src/main/java/LeetcodeAlgorithm/N201_300/N240搜索二维数组2/Solution.java | 6e1afad895f2cab350b1ac4b6667d28599a2affe | [] | no_license | karmanluo/LeetcodeAlgorithm | 9d29b3010ab1079cbb15aac1fb96387f94e71217 | 811ed1804cb4f8a5181b44331c199ce726b989b7 | refs/heads/master | 2021-07-10T21:09:35.330519 | 2020-10-08T09:41:00 | 2020-10-08T09:41:00 | 207,490,261 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 473 | java | package LeetcodeAlgorithm.N201_300.N240搜索二维数组2;
public class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
if (matrix == null || matrix.length == 0) return false;
int m = matrix.length - 1, n = 0;
while (m >= 0 && n <= matrix[0].length - 1) {
if (target == matrix[m][n]) return true;
else if (target > matrix[m][n]) n++;
else m--;
}
return false;
}
}
| [
"[email protected]"
] | |
e3fe5c9e8822d251558d77daa93decc085747528 | 251ae087d6b27be4501fee35a622f2c86859bd17 | /backend-goods/backend-goods-api/src/main/java/com/hyf/backend/goods/dto/ApiQueryGoodsDTO.java | 84d488ae566b09a1fe25b0942c927e6726c3e86e | [] | no_license | arraycto/backend-parent | f9565dab56ec9e6a863ab9d7908c7d330a3705d8 | 44998a7ddca52a5f7df1974c72e9f57eb80656dc | refs/heads/master | 2022-04-24T01:51:31.444199 | 2020-04-25T01:44:52 | 2020-04-25T01:44:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 459 | java | package com.hyf.backend.goods.dto;
import com.hyf.backend.common.domain.QueryPageDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* @Author: Elvis on 2020/4/9
* @Email: [email protected]
* @Desc: TODO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class ApiQueryGoodsDTO extends QueryPageDTO {
private Integer categoryId;
}
| [
"[email protected]"
] | |
c03b9748d2868284ab2227bc04bf357051e77dde | 79bf18b8698082c79bfac968398f234377f63482 | /newHW/src/ru/ifmo/nechaev/MyActivity.java | 52c91ba8edbb54c12e8f0910ca9d3d37f38c3332 | [] | no_license | Viruzix/lesson2 | 6a1409c2bd70653d49c8d934e4cbf7d348a75fd9 | 48e5d579ff1fb6aaa8c570d5fa1883ab11e1e490 | refs/heads/master | 2021-01-17T14:34:03.181502 | 2014-01-13T21:50:53 | 2014-01-13T21:50:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,358 | java | package ru.ifmo.nechaev;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
Bitmap picture;
int w, h;
boolean renew = true, thatfirst = true;
int[] intpic;
int miniw, minih;
int[] minipic;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
picture = BitmapFactory.decodeResource(getResources(), R.drawable.source);
w = picture.getWidth();
h = picture.getHeight();
intpic = new int[w * h];
miniw = (int) (w / 1.73) + 1;
minih = (int) (h / 1.73) + 1;
minipic = new int[miniw * minih];
setContentView(new PictureRenew(this));
}
class PictureRenew extends View {
PictureRenew(Context context) {
super(context);
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
renew = !renew;
invalidate();
}
});
}
public void slowCompres(Canvas canvas) {
int x, y;
int hh, ww;
float t, u, tmp;
float d1, d2, d3, d4;
int p1, p2, p3, p4;
int red, green, blue;
for (y = 0; y < minih; y++) {
tmp = (float) (y) / (float) (minih - 1) * (h - 1);
hh = (int) Math.floor(tmp);
if (hh < 0) {
hh = 0;
} else {
if (hh >= h - 1)
hh = h - 2;
}
u = tmp - hh;
for (x = 0; x < miniw; x++) {
tmp = (float) (x) / (float) (miniw - 1) * (w - 1);
ww = (int) Math.floor(tmp);
if (ww < 0) {
ww = 0;
} else {
if (ww >= w - 1)
ww = w - 2;
}
t = tmp - ww;
d1 = (1 - t) * (1 - u);
d2 = t * (1 - u);
d3 = t * u;
d4 = (1 - t) * u;
p1 = intpic[hh * w + ww];
p2 = intpic[hh * w + ww + 1];
p3 = intpic[(hh + 1) * w + ww + 1];
p4 = intpic[(hh + 1) * w + ww];
blue = ((int) ((p1 & 0xff0000) * d1 + (p2 & 0xff0000) * d2 + (p3 & 0xff0000) * d3 + (p4 & 0xff0000) * d4)) & 0xff0000;
green = ((int) ((p1 & 0x00ff00) * d1 + (p2 & 0x00ff00) * d2 + (p3 & 0x00ff00) * d3 + (p4 & 0x00ff00) * d4)) & 0x00ff00;
red = ((int) ((p1 & 0x0000ff) * d1 + (p2 & 0x0000ff) * d2 + (p3 & 0x0000ff) * d3 + (p4 & 0x0000ff) * d4)) & 0x0000ff;
minipic[y * miniw + x] = red | green | blue;
}
}
canvas.drawBitmap(minipic, 0, miniw, 0, 0, miniw, minih, false, null);
}
public void fastCompres(Canvas canvas) {
int xScale = (w << 16) / miniw;
int yScale = (h << 16) / minih;
for (int color = 0, x = 0, y = 0; color < minipic.length; ++color, ++x) {
if (x == miniw) {
x = 0;
++y;
}
minipic[color] = intpic[((yScale * y) >> 16) * w + ((xScale * x) >> 16)];
}
canvas.drawBitmap(minipic, 0, miniw, 0, 0, miniw, minih, false, null);
}
private void LightAndRotate() {
int[] tmp = new int[w * h];
picture.getPixels(intpic, 0, w, 0, 0, w, h);
int r, g, b;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int t = y * w + x;
r = intpic[t] & 0x00FF0000;
g = intpic[t] & 0x0000FF00;
b = intpic[t] & 0x000000FF;
r = r >> 16;
g = g >> 8;
r = (r * 1.5 <= 255) ? (int) (r * 1.5) : 255;
g = (g * 1.5 <= 255) ? (int) (g * 1.5) : 255;
b = (b * 1.5 <= 255) ? (int) (b * 1.5) : 255;
tmp[x * w + h - y - 1] = 0xFF000000 | r << 16 | g << 8 | b;
}
}
intpic = tmp;
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawBitmap(minipic, 0, miniw, 0, 0, miniw, minih, false, null);
if (thatfirst) {
LightAndRotate();
thatfirst = !thatfirst;
}
if (renew) {
fastCompres(canvas);
} else {
slowCompres(canvas);
}
}
}
} | [
"[email protected]"
] | |
2d204fed5cb12713ddd4f7ea11d824161b758196 | 1ee29fce36a8deab98d74548457fad35a4324dfb | /task08/src/main/java/by/trainng/task08/service/HouseService.java | e3f4d2ff4c791bd58ba144da30549ec1b4852867 | [] | no_license | ArtemKolganow/trainingRep | ca907dc2374d10dfdf888ad40131855e20fbd2a2 | e728c979e885680cde8b4d685d2d7f03eefa7e5b | refs/heads/master | 2022-06-30T17:28:24.307304 | 2020-05-09T20:39:23 | 2020-05-09T20:39:23 | 227,861,196 | 0 | 0 | null | 2022-01-04T16:39:59 | 2019-12-13T14:48:37 | Java | UTF-8 | Java | false | false | 2,072 | java | package by.trainng.task08.service;
import by.trainng.task08.dal.DataAccess;
import by.trainng.task08.entity.House;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
public class HouseService {
public void writeToFile(List<House> houses) throws IOException {
DataAccess data = new DataAccess();
data.writeHouses(houses);
}
public List<House> readFromFile() throws FileNotFoundException {
DataAccess data = new DataAccess();
return data.readHouses();
}
public List<House> parseByRooms(int numberOfRooms) throws FileNotFoundException {
List<House> houses = readFromFile();
for(int i =0; i<houses.size();i++){
if(houses.get(i).getNumberOfRooms()!=numberOfRooms){
houses.remove(i);
}
}
return houses;
}
public List<House> parseByRoomsAndFloor(int numberOfRooms, int low, int high) throws FileNotFoundException {
List<House> houses = readFromFile();
for(int i =0; i<houses.size();i++){
if(houses.get(i).getNumberOfRooms()!=numberOfRooms){
houses.remove(i);
}
if(houses.get(i).getFloor()<low||houses.get(i).getFloor()>high){
houses.remove(i);
}
}
return houses;
}
public List<House> parseByArea(int area) throws FileNotFoundException {
List<House> houses = readFromFile();
for(int i =0; i<houses.size();i++){
if(houses.get(i).getArea()<area){
houses.remove(i);
}
}
return houses;
}
public List<House> parseByAreaAndType(int area,String type) throws FileNotFoundException {
List<House> houses = readFromFile();
for(int i =0; i<houses.size();i++){
if(houses.get(i).getArea()<area){
houses.remove(i);
}
if(!houses.get(i).getType().equals(type)){
houses.remove(i);
}
}
return houses;
}
}
| [
"[email protected]"
] | |
1e997f61d4aa5af7dcf087d9714cd380bd3535b6 | f4a4c073a6fcc754e35644c59bdbd576fc1c227a | /src/controller/addFriendController.java | 2b25d5f0b4ff28e94c37c25938c84785ae8bd451 | [] | no_license | manish1996/Bumpy | 02a68675872b87fab5b719c5cc4438358aedcdf9 | 870c50baa6d83a97d24a02cb5978373216953fcb | refs/heads/master | 2021-01-02T09:30:34.023431 | 2017-08-03T13:04:51 | 2017-08-03T13:04:51 | 99,231,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,810 | java | package controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dao.ProfileDAO;
/**
* Servlet implementation class addFriendController
*/
@WebServlet("/addFriendController")
public class addFriendController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public addFriendController() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
PrintWriter out = response.getWriter();
int pid=Integer.parseInt(request.getParameter("id"));
int u_id=Integer.parseInt(request.getParameter("uid"));
ProfileDAO profile=new ProfileDAO();
String results=profile.addfriend(pid, u_id);
System.out.println("redirected");
//rd.forward(request, response);
if(results==null){
out.println("You are Already friend or you have already sent the request");
}else
out.println(results);
//response.sendRedirect("profileController");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
] | |
9f308a986ba368a116594c6dc71e0c8241f90315 | 66f8deed6d9d411d5a52d4fa830ca7c1e1fabbad | /NoobBeginnings/src/Lab9.java | 44df7a2ffc8f2b724c863b06861201a26147fc84 | [] | no_license | MarleeG/Java-Noobs | a11463ccc68da085ba554d6a3ecfa406ba41e957 | d7451e4d30e9ce439a043c0bb15f4d9ad8707d0b | refs/heads/master | 2020-03-17T22:14:25.708304 | 2018-05-18T23:21:36 | 2018-05-18T23:21:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,265 | java | //Details: Create a restaurant. You have been approached to create a computer program that will accurately calculate bills for each customer.
import java.util.Scanner;
public class Lab9 {
public static void main(String[] args) {
//Scanner Object
Scanner input = new Scanner(System.in);
//Variables
int totalGuest;
int discount = 0;
double entireTotal= 0;
int selectOne = 0;
int selectTwo;
double wingAmount;
int i;
double optionTotalOne = 0;
double optionTotalTwo = 0;
double optionTotalThree = 0;
//Total
double personTotal = 0;
double addedTotal = 0;
//Menu Array
String menu[] = new String[9];
menu[0] = "Soup";
menu[1] = "Wings";
menu[2] = "Burger";
menu[3] = "Chicken Sandwhich";
menu[4] = "Fries";
menu[5] = "Pie";
menu[6] = "Ice cream";
menu[7] = "Soft drink";
menu[8] = "Coffee";
//Price Array
double prices[] = new double[9];
prices[0] = 2.50;
prices[1] = .15;
prices[2] = 4.95;
prices[3] = 5.95;
prices[4] = 1.99;
prices[5] = 2.95;
prices[6] = 2.99;
prices[7] = 1.5;
prices[8] = 1;
//Party amount
System.out.println("Welcome to Sand Castle Shack!");
System.out.println("How many people are in your party? ");
totalGuest = input.nextInt();
//for-loop
for (i = 1; i <= totalGuest; i++) {
//Order input
System.out.println("\nPlease input order information for person " + i + "\n");
//Discount menu displayed
System.out.println("Is this person eligible for a discount? (enter a number 1 - 4)" +
"\n1 - if CHILD 5 years of age or younger \n2 - if TEEN between 13 and 19 years of age"
+ "\n3 - if SENIOR 65 years of age or older \n4 - if NONE of the above \nPlease type a value for DISCOUNT_TYPE: ");
discount = input.nextInt();
//Switch statement - Discount Prices
switch (discount) {
case 1:
prices[0] = 0;
prices[1] = 0;
prices[2] = 0;
prices[3] = 0;
prices[4] = 0;
prices[5] = 0;
prices[6] = 0;
prices[7] = 0;
prices[8] = 0;
break;
case 2:
case 3:
prices[0] *= .75;
prices[1] *= .75;
prices[2] *= .75;
prices[3] *= .75;
prices[4] *= .75;
prices[5] *= .75;
prices[6] *= .75;
prices[7] *= .75;
prices[8] *= .75;
break;
case 4:
prices[0] += (.05 * prices[0]);
prices[1] += (.05 * prices[1]);
prices[2] += (.05 * prices[2]);
prices[3] += (.05 * prices[3]);
prices[4] += (.05 * prices[4]);
prices[5] += (.05 * prices[5]);
prices[6] += (.05 * prices[6]);
prices[7] += (.05 * prices[7]);
prices[8] += (.05 * prices[8]);
break;
default: System.out.println("This is not a discount option.");
}
//Menu output
System.out.println("Menu items that may be selected: \n1 " + menu[0] + "\n2 " +
menu[1] + "\n3 " + menu[2] + "\n4 " + menu[3] + "\n5 " + menu[4] + "\n6 " + menu[5] +
"\n7 " + menu[6] + "\n8 " + menu[7] + "\n9 " + menu[8]);
//Menu Item 1 prompt
System.out.println("\n \nPlease select menu item 1 (enter a number 1 - 9) \nPlease type a value for SELECTED_ITEM: ");
selectOne = input.nextInt();
switch(selectOne) {
case 1: optionTotalOne = prices[0];
break;
case 2: System.out.println("Please enter number of wings to be ordered \nPlease type a value for NUMBER_OF_WINGS: ");
wingAmount = input.nextInt();
optionTotalOne = wingAmount * prices[1];
break;
case 3: optionTotalOne = prices[2];
break;
case 4: optionTotalOne = prices[3];
break;
case 5: optionTotalOne = prices[4];
break;
case 6: optionTotalOne = prices[5];
break;
case 7: optionTotalOne = prices[6];
break;
case 8: optionTotalOne = prices[7];
break;
case 9: optionTotalOne = prices[8];
break;
default: System.out.println("This is not an option on the menu.");
}
//Menu Item 2 prompt
System.out.println("Please select menu item 2 (enter a number 1 - 9) \nPlease type a value for SELECTED_ITEM: ");
selectTwo = input.nextInt();
//Switch Statement
switch(selectTwo) {
case 1: optionTotalTwo = prices[0];
break;
case 2: System.out.println("Please enter number of wings to be ordered \nPlease type a value for NUMBER_OF_WINGS: ");
wingAmount = input.nextInt();
optionTotalTwo = wingAmount * prices[1];
break;
case 3: optionTotalTwo = prices[2];
break;
case 4: optionTotalTwo = prices[3];
break;
case 5: optionTotalTwo = prices[4];
break;
case 6: optionTotalTwo = prices[5];
break;
case 7: optionTotalTwo = prices[6];
break;
case 8: optionTotalTwo = prices[7];
break;
case 9: optionTotalTwo = prices[8];
break;
default: System.out.println("This is not an option on the menu.");
}
//Menu Item 3 prompt
System.out.println("Please select menu item 3 (enter a number 1 - 9) \nPlease type a value for SELECTED_ITEM: ");
int selectThree = input.nextInt();
//Switch Statement
switch(selectThree) {
case 1: optionTotalThree = prices[0];
break;
case 2: System.out.println("Please enter number of wings to be ordered \nPlease type a value for NUMBER_OF_WINGS: ");
wingAmount = input.nextInt();
optionTotalThree = wingAmount * prices[1];
break;
case 3: optionTotalThree = prices[2];
break;
case 4: optionTotalThree = prices[3];
break;
case 5: optionTotalThree = prices[4];
break;
case 6: optionTotalThree = prices[5];
break;
case 7: optionTotalThree = prices[6];
break;
case 8: optionTotalThree = prices[7];
break;
case 9: optionTotalThree = prices[8];
break;
default: System.out.println("This is not an option on the menu.");
}
//Totals
personTotal = optionTotalOne + optionTotalTwo + optionTotalThree;
addedTotal += optionTotalOne + optionTotalTwo + optionTotalThree;
//Person Total
System.out.printf("Person " + i + " Total: $%.2f" + " (Discount Type " + discount + ")", personTotal);
//Price Array
prices[0] = 2.50;
prices[1] = .15;
prices[2] = 4.95;
prices[3] = 5.95;
prices[4] = 1.99;
prices[5] = 2.95;
prices[6] = 2.99;
prices[7] = 1.5;
prices[8] = 1;
}
//entire total
entireTotal = addedTotal;
System.out.printf("\n \nGrand Total for Order: $%.2f ", entireTotal);
//Closed Scanner
input.close();
}
} | [
"[email protected]"
] | |
8cc8f5e707afca60732364b853d6a1505b4ecae1 | cbdb7891230c83b61be509bc0c8cd02ff5f420d8 | /jcst/jcst_common_webservice/src/main/java/com/kaiwait/webservice/mst/UserInitInfo.java | cbc55e1e4a1641bdff6c0dd0b18eb29351f1b488 | [] | no_license | zhanglixye/jcyclic | 87e26d1412131e441279240b4468993cb9b08bc3 | 8a311f8b1e6a81fb40f093d725b5182763d6624e | refs/heads/master | 2023-01-04T11:23:22.001517 | 2020-11-02T05:20:08 | 2020-11-02T05:20:08 | 309,265,334 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,128 | java | package com.kaiwait.webservice.mst;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.kaiwait.bean.mst.io.UserInfoInput;
import com.kaiwait.core.process.SingleFunctionIF;
import com.kaiwait.core.process.ValidateResult;
import com.kaiwait.service.mst.CommonmstService;
import com.kaiwait.service.mst.UserService;
import com.kaiwait.thrift.common.server.annotation.MatchEnum;
import com.kaiwait.thrift.common.server.annotation.Privilege;
@Component("userInitInfo")
@Privilege(keys= {"76","77","78"}, match=MatchEnum.ANY)
public class UserInitInfo implements SingleFunctionIF<UserInfoInput>{
@Resource
private UserService userService;
@Resource
private CommonmstService commService;
@Override
public Object process(UserInfoInput inputParam) {
return userService.userInfoInit(inputParam.getUserCD(),inputParam.getCompanyID());
}
@Override
public ValidateResult validate(UserInfoInput inputParam) {
return null;
}
@SuppressWarnings("rawtypes")
@Override
public Class getParamType() {
// TODO Auto-generated method stub
return UserInfoInput.class;
}
}
| [
"[email protected]"
] | |
94fab4f9e9250bc6ea7abfad82bcc2b8df8fc82c | f777373e1e30b168d8d6c1a38e69db036e058985 | /src/main/java/tsp/Path.java | 92540729dd06c5a743e974baa39ca74985e05dbc | [] | no_license | jagodawieczorek/tsp | 5c5fdf8a4ef1b0f9399fd525e4656ef556dbb93f | 024ccc641f7a0d9ff64d6ce2d9914fa24187d713 | refs/heads/master | 2022-12-14T17:15:43.937534 | 2020-09-12T20:33:13 | 2020-09-12T20:33:13 | 260,964,749 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 580 | java | package tsp;
import java.util.ArrayList;
import java.util.TreeMap;
/**
* Path class
*
* @author Jagoda Wieczorek
*/
public class Path {
private final ArrayList<Integer> order;
private final TreeMap<Integer, Place> places;
private final ArrayList<Place> path;
public Path(final TreeMap<Integer, Place> places, final ArrayList<Integer> order) {
this.places = places;
this.order = order;
this.path = new ArrayList<>();
for (final Integer index: order) {
this.path.add(places.get(index));
}
}
public ArrayList<Place> getPath() {
return this.path;
}
}
| [
"[email protected]"
] | |
1537d6d4ce7ce876f085caffb3db4ce3723bb720 | 8bfec6b40033701a809c6daf03389f1631507fec | /src/main/java/com/packtpub/springhibernate/ch03/SetterInfoDBPrinter.java | 6d1181adf41d50d41428f59e58ade328e7794430 | [] | no_license | hamiddoosty/FirstSpringHibernate | 03928996d5efe30761d73a6d86844a80c46286ee | 37d05d85ff6e72d13e16fa2b796692498c1d4403 | refs/heads/master | 2022-01-26T07:20:47.773945 | 2019-07-22T08:48:29 | 2019-07-22T08:48:29 | 198,183,084 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 240 | java | package com.packtpub.springhibernate.ch03;
public class SetterInfoDBPrinter implements SetterInfoPrinter{
public void print(String methodName, Object oldValue,Object newValue){
System.out.println("From DB ... ");
}
}
| [
"[email protected]"
] | |
f71cb3a04e015d0b01302b3291374e7b3b574565 | 2ec2dacb11bc35998614f55816631a075b6ae145 | /src/com/training/Spring_BankingApp/src/main/java/com/day7/model/Contact.java | ba2a01f20bc21749849f6c823da4f953c42a06e9 | [] | no_license | jigglypuffff/Training- | cc3d3861a334699edc2f36ee90cfd72ce4d5db34 | 321dd28faab72ebd46e43bed92ee387aee52620a | refs/heads/master | 2020-03-11T01:35:53.712923 | 2018-11-12T06:50:14 | 2018-11-12T06:50:14 | 129,696,149 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 825 | java | package com.day7.model;
public class Contact {
/**
phone no of customer
*/
private String phone;
/**
mobile no of customer
*/
private String mobile;
/**
email id of customer
*/
private String email;
public Contact(final String phone,final String mobile, final String email) {
super();
this.phone = phone;
this.mobile = mobile;
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(final String phone) {
this.phone = phone;
}
public String getMobile() {
return mobile;
}
public void setMobile(final String mobile) {
this.mobile = mobile;
}
public Contact() {
super();
// TODO Auto-generated constructor stub
}
public String getEmail() {
return email;
}
public void setEmail(final String email) {
this.email = email;
}
}
| [
"[email protected]"
] | |
973be3eacc4b2be1dffe189b1561f8de14dc0027 | 02f4ea3f8f95d49ac3c0633f103ca9602fb69f9d | /jmspy-core/src/main/java/com/github/dmgcodevil/jmspy/Snapshot.java | 259d455003fbaade8327dc4f555b37596db3bbd0 | [] | no_license | dmgcodevil/jmspy | c0448ce2804b5f79636ad6ba2a7a24939345b86b | 025e3f5bae8b76250ea29a828f3684366555688a | refs/heads/master | 2021-01-01T05:47:56.116457 | 2019-08-20T18:54:07 | 2019-08-20T18:54:07 | 26,402,850 | 5 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,181 | java | package com.github.dmgcodevil.jmspy;
import com.google.common.base.Throwables;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import static org.slf4j.helpers.MessageFormatter.format;
/**
* Represents a snapshot of invocations.
*
* @author dmgcodevil
*/
public class Snapshot implements Serializable {
private static final long serialVersionUID = -651468933350929861L;
private List<InvocationRecord> invocationRecords = Collections.emptyList();
private static final String PREFIX = "snapshot_{}.jmspy";
public Snapshot() {
}
public Snapshot(List<InvocationRecord> invocationRecords) {
this.invocationRecords = invocationRecords;
}
public List<InvocationRecord> getInvocationRecords() {
return invocationRecords;
}
public static Snapshot save(Snapshot snapshot) {
return save(snapshot, generateName());
}
public static Snapshot save(Snapshot snapshot, String fileName) {
try (
FileOutputStream fout = new FileOutputStream(fileName);
ObjectOutputStream oos = new ObjectOutputStream(fout)
) {
oos.writeObject(snapshot);
return snapshot;
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
public static Snapshot load(File file) {
try (
FileInputStream fin = new FileInputStream(file);
ObjectInputStream objectInputStream = new ObjectInputStream(fin)
) {
return (Snapshot) objectInputStream.readObject();
} catch (IOException | ClassNotFoundException e) {
throw Throwables.propagate(e);
}
}
private static String generateName() {
Date date = new Date();
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
return format(PREFIX, dt.format(date)).getMessage();
}
}
| [
"[email protected]"
] | |
02111c903fa2924f05e5af4caa3fd8300cbc18d6 | e3b91442a00faf3d89622072ec410c4fb6ee62de | /872. Leaf-Similar Trees/main.java | 71db45c4917ec0848d552cf2f999c3d29fe55fc5 | [] | no_license | HoweChen/leetcodeCYH | ade42f70a12a94e8ca410044db6ecc108edc171d | 1409d7bde8cf056e61e21ee487e66bff86e2e9b9 | refs/heads/master | 2021-06-03T19:32:36.618821 | 2021-03-02T14:27:56 | 2021-03-02T14:27:56 | 68,834,849 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 962 | java | /**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public boolean leafSimilar(TreeNode root1, TreeNode root2) {
if (root1 == null || root2==null){
return false;
} else if (root1==null && root2==null){
return true;
} else {
List<Integer> lvsOne = new ArrayList<>();
List<Integer> lvsTwo = new ArrayList<>();
dfs(root1,lvsOne);
dfs(root2,lvsTwo);
return lvsOne.equals(lvsTwo);
}
}
public void dfs(TreeNode node, List<Integer> lvs){
if (node!=null){
if (node.left == null && node.right ==null){
lvs.add(node.val);
} else {
dfs(node.left,lvs);
dfs(node.right,lvs);
}
}
return;
}
} | [
"[email protected]"
] | |
6eb481fadff440584ad7a953ca3eb8318b5dc128 | b34654bd96750be62556ed368ef4db1043521ff2 | /ball/Forums_0.1/src/java/main/com/orpheus/game/server/handler/admin/AdminWinnerApprovalPostHandler.java | 945604d8054814bedbd6389855169dc3fcfc0e45 | [] | no_license | topcoder-platform/tcs-cronos | 81fed1e4f19ef60cdc5e5632084695d67275c415 | c4ad087bb56bdaa19f9890e6580fcc5a3121b6c6 | refs/heads/master | 2023-08-03T22:21:52.216762 | 2019-03-19T08:53:31 | 2019-03-19T08:53:31 | 89,589,444 | 0 | 1 | null | 2019-03-19T08:53:32 | 2017-04-27T11:19:01 | null | UTF-8 | Java | false | false | 10,420 | java | /*
* Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
*/
package com.orpheus.game.server.handler.admin;
import com.topcoder.web.frontcontroller.Handler;
import com.topcoder.web.frontcontroller.HandlerExecutionException;
import com.topcoder.web.frontcontroller.ActionContext;
import com.topcoder.user.profile.manager.UserProfileManager;
import com.topcoder.user.profile.UserProfile;
import com.topcoder.user.profile.BaseProfileType;
import com.topcoder.util.file.DocumentGenerator;
import com.topcoder.util.file.Template;
import com.topcoder.util.file.fieldconfig.Field;
import com.topcoder.util.file.fieldconfig.TemplateFields;
import com.orpheus.game.server.handler.AbstractGameServerHandler;
import com.orpheus.game.server.util.GameDataEJBAdapter;
import com.orpheus.game.server.OrpheusFunctions;
import com.orpheus.game.persistence.Game;
import com.orpheus.administration.entities.HandlerResult;
import com.orpheus.administration.entities.ResultCode;
import com.orpheus.user.persistence.UserConstants;
import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
import javax.naming.Context;
/**
* <p>A custom implementation of {@link Handler} interface which is to be used in conjunction with <code>
* PendingWinnerApprovalHandler</code> and is intended to send the notification email to a game winner as well as
* prepare a <code>RSS</code> feed to notify the game players that the game have been won.</p>
*
* @author isv
* @version 1.0
*/
public class AdminWinnerApprovalPostHandler extends AbstractGameServerHandler implements Handler {
/**
* <p>A <code>String</code> providing the name which could be used as name for configuration parameter providing the
* name of request parameter to get the user ID from.</p>
*/
public static final String USER_ID_PARAM_NAME_CONFIG = "user-id-request-param";
/**
* <p>A <code>String</code> providing the name which could be used as name for configuration parameter providing the
* name of request parameter to get the user ID from.</p>
*/
public static final String FAILURE_RESULT_ATTR_NAME_CONFIG = "fail-request-attribute";
/**
* <p>A <code>String</code> providing the name which could be used as name for configuration parameter providing the
* name of request parameter to get the user ID from.</p>
*/
public static final String FAILURE_RESULT_NAME_CONFIG = "fail-result";
/**
* <p>A <code>String</code> providing the name which could be used as name for configuration parameter providing the
* name of request parameter to get the user ID from.</p>
*/
public static final String MESSAGE_SUBJECT_CONFIG = "message-subject";
/**
* <p>A <code>String</code> providing the name which could be used as name for configuration parameter providing the
* name of request parameter to get the user ID from.</p>
*/
public static final String TEMPLATE_FILE_CONFIG = "template-file";
/**
* <p>A <code>UserProfileManager</code> instance which will be used to search for sponsor.</p>
*/
private final UserProfileManager userProfileManager;
/**
* <p>A <code>Context</code> providing a <code>JNDI</code> context to be used for looking up the home interface for
* <code>Game Data EJB</code>.</p>
*/
private final Context jndiContext;
/**
* Creates a AdminWinnerApprovalPostHandler instance configured from the given xml element. It will initialize the
* userProfileManager instance and other instance variables. It will throw an IllegalArgumentException if
* configuration details are missing in the handlerElement argument.<br/> Impl Notes: <ol> <li>If
* handlerElement.getTagName() is not "handler", throw an IllegalArgumentException.</li> <li>Initialize
* objFactoryNS with the value of "object-factory-ns" child element. If element or value is missing throw
* an IllegalArgumentException.</li> <li>ObjectFactory factory = new ObjectFactory(new
* ConfigManagerSpecificationFactory(objFactoryNS), ObjectFactory.BOTH);<br/> userProfileManager =
* objectFactory.createObject("UserProfileManager");</li> <li>Initialize sponsorIdRequestParamName with
* the value of "sponsor-id-request-param" child element. If element or value is missing throw an
* IllegalArgumentException.</li> <li>Initialize failedResult with the value of "fail-result" child
* element. If element or value is missing throw an IllegalArgumentException.</li> <li>Initialize
* failRequestAttrName with the value of "fail-request-attribute" child element. If element or value is
* missing throw an IllegalArgumentException.</li> </ol>
*
* @param element the XML element containing configuration for this handler.
* @throws IllegalArgumentException if handlerElement is null, or contains invalid data.
*/
public AdminWinnerApprovalPostHandler(Element element) {
if (element == null) {
throw new IllegalArgumentException("The parameter [handlerElement] is NULL");
}
readAsString(element, USER_ID_PARAM_NAME_CONFIG, true);
readAsString(element, GAME_ID_PARAM_NAME_CONFIG, true);
readAsString(element, TEMPLATE_FILE_CONFIG, true);
readAsString(element, MESSAGE_SUBJECT_CONFIG, true);
readAsString(element, EMAIL_RECIPIENTS_CONFIG, true);
readAsString(element, FAILURE_RESULT_NAME_CONFIG, true);
readAsString(element, FAILURE_RESULT_ATTR_NAME_CONFIG, true);
readAsString(element, GAME_EJB_JNDI_NAME_CONFIG, true);
readAsBoolean(element, USER_REMOTE_INTERFACE_CONFIG, true);
this.jndiContext = getJNDIContext(element);
this.userProfileManager = getUserProfileManager(element);
}
/**
* <p>Process the user request. Null should be returned, if it wants Action object to continue to execute the next
* handler (if there is no handler left, the 'success' Result will be executed). It should return a non-empty
* resultCode if it want to execute a corresponding Result immediately, and ignore all following handlers.</p>
*
* @param context the ActionContext object.
* @return null or a non-empty resultCode string.
* @throws HandlerExecutionException if fail to execute this handler.
*/
public String execute(ActionContext context) throws HandlerExecutionException {
if (context == null) {
throw new IllegalArgumentException("The parameter [context] is NULL");
}
HttpServletRequest request = context.getRequest();
try {
long userId = getLong(USER_ID_PARAM_NAME_CONFIG, request);
long gameId = getLong(GAME_ID_PARAM_NAME_CONFIG, request);
GameDataEJBAdapter gameDataEJBAdapter = getGameDataEJBAdapter(this.jndiContext);
Game game = gameDataEJBAdapter.getGame(gameId);
// Send an email to game winner
UserProfile userProfile = this.userProfileManager.getUserProfile(userId);
String emailAddress = (String) userProfile.getProperty(BaseProfileType.EMAIL_ADDRESS);
String body = getMessageBody(getString(TEMPLATE_FILE_CONFIG), game);
String subject = getString(MESSAGE_SUBJECT_CONFIG);
sendEmail(context, emailAddress, body, subject);
// Send an email to administrators
String adminMessageBody = "The claim from player "
+ userProfile.getProperty(UserConstants.CREDENTIALS_HANDLE)
+ " for winning the game " + game.getName()
+ " is approved by Administrator\n\nThe Ball Team";
String adminMessageSubject = "Game Winner Approved";
String[] recipients = getString(EMAIL_RECIPIENTS_CONFIG).split(",");
for (int i = 0; i < recipients.length; i++) {
sendEmail(context, recipients[i], adminMessageBody, adminMessageSubject);
}
// Notify all other players on game winning
String s = "Congratulations to " + OrpheusFunctions.getHandle(userProfile) + " for winning Ball Game "
+ game.getName() + "! This game is now over, but remember, there are still many other chances "
+ "for you to Find The Ball and WIN SOME MONEY!!!";
broadcastGameMessage(game, s);
} catch (Exception e) {
HandlerResult handlerResult
= new HandlerResult(ResultCode.EXCEPTION_OCCURRED,
"Could not prepare message for user ["
+ getLong(USER_ID_PARAM_NAME_CONFIG, request) + "]", e);
request.setAttribute(getString(FAILURE_RESULT_ATTR_NAME_CONFIG), handlerResult);
return getString(FAILURE_RESULT_NAME_CONFIG);
}
// return null for successful execution.
return null;
}
/**
* <p>Generates the body of an email message to be sent to user.</p>
*
* @param templateFile a <code>String</code> providing the name of the template file.
* @param game a <code>Game</code> providing the details for game account.
* @return a <code>String</code> providing the content of the email body.
* @throws Exception if an unrecoverable error is reported by document generator.
*/
private String getMessageBody(String templateFile, Game game) throws Exception {
// Locate the desired template
DocumentGenerator docGenerator = DocumentGenerator.getInstance();
Template template = docGenerator.getTemplate(TEMPLATE_SOURCE_ID, templateFile);
// Build the list of template fields populated with values from parameters map
com.topcoder.util.file.fieldconfig.Node[] nodes
= new com.topcoder.util.file.fieldconfig.Node[1];
nodes[0] = new Field("GAME_NAME", game.getName(), "game-name", true);
// Generate the message body from template
TemplateFields fields = new TemplateFields(nodes, template);
return docGenerator.applyTemplate(fields);
}
}
| [
"mtong@fb370eea-3af6-4597-97f7-f7400a59c12a"
] | mtong@fb370eea-3af6-4597-97f7-f7400a59c12a |
b51629399038ec3aa8c9a470cc27d74bfdf70573 | 1eb26a26c6d966c00dc6bc215ce15d5e63136fd2 | /src/main/java/tcm/com/gistone/controller/WordController.java | 72376b727e5b1d7d33f70fef046c2ceaf2ff5b9b | [] | no_license | wangfan0840/tcm | 72216735a1a68d7b6556fab525f05e0846a7f6c7 | d745659cd6208d65dd1e58915a1c777e00620399 | refs/heads/master | 2021-01-01T18:19:30.818654 | 2017-07-25T15:00:51 | 2017-07-25T15:00:51 | 98,303,754 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,013 | java | package tcm.com.gistone.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import tcm.com.gistone.database.config.GetBySqlMapper;
import tcm.com.gistone.database.entity.Section;
import tcm.com.gistone.database.entity.Word;
import tcm.com.gistone.database.entity.WordRelation;
import tcm.com.gistone.database.entity.WsRelation;
import tcm.com.gistone.database.mapper.SectionMapper;
import tcm.com.gistone.database.mapper.ThemeMapper;
import tcm.com.gistone.database.mapper.WordMapper;
import tcm.com.gistone.database.mapper.WordRelationMapper;
import tcm.com.gistone.database.mapper.WsRelationMapper;
import tcm.com.gistone.util.ClientUtil;
import tcm.com.gistone.util.EdatResult;
import tcm.com.gistone.util.ExcelUtil;
@RestController
@RequestMapping
public class WordController {
@Autowired
private SectionMapper sm;
@Autowired
private WordMapper wm;
@Autowired
private WsRelationMapper wsm;
@Autowired
private WordRelationMapper wrm;
@Autowired
private ThemeMapper tm;
@Autowired
GetBySqlMapper gm;
@ResponseBody
@RequestMapping(value = "/word/recordWord", method = RequestMethod.POST)
public EdatResult recordWord(HttpServletRequest request,
HttpServletResponse response) {
try {
ClientUtil.SetCharsetAndHeader(request, response);
JSONObject data = JSONObject.fromObject(request
.getParameter("data"));
String word = data.getString("word");
String alias = data.getString("alias");
String wordType = data.getString("wordType");
Word w = wm.selectByWord(word);
Word nw = new Word();
//nw.setParentId();
nw.setThemeType(wordType);
nw.setWord(word);
nw.setAlias(alias);
if (w != null) {
if (w.getThemeType().equals(wordType)) {
return EdatResult.build(0, "录入失败,关键词重复");
} else {
wm.insert(nw);
return EdatResult.build(1, "录入成功");
}
} else {
wm.insert(nw);
return EdatResult.build(0, "录入成功");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return EdatResult.build(1, "fail");
}
}
@ResponseBody
@RequestMapping(value = "/word/deleteWord", method = RequestMethod.POST)
public EdatResult deleteWord(HttpServletRequest request,
HttpServletResponse response) {
try {
ClientUtil.SetCharsetAndHeader(request, response);
JSONObject data = JSONObject.fromObject(request
.getParameter("data"));
JSONArray array = data.getJSONArray("wordIds");
for(int i=0;i<array.size();i++){
long wordId = array.getLong(i);
wm.deleteByPrimaryKey(wordId);
}
return EdatResult.build(0, "删除成功");
} catch (Exception e) {
e.printStackTrace();
return EdatResult.build(1, "fail");
}
}
@ResponseBody
@RequestMapping(value = "/word/updateWord", method = RequestMethod.POST)
public EdatResult updateWord(HttpServletRequest request,
HttpServletResponse response) {
try {
ClientUtil.SetCharsetAndHeader(request, response);
JSONObject data = JSONObject.fromObject(request
.getParameter("data"));
long wordId = data.getLong("id");
String word = data.getString("word");
String alias = data.getString("alias");
String wordType = data.getString("wordType");
Word word1=new Word();
word1.setWord(word);
word1.setWordId(wordId);
word1.setThemeType(wordType);
word1.setAlias(alias);
wm.updateByPrimaryKeySelective(word1);
return EdatResult.build(0, "删除成功");
} catch (Exception e) {
e.printStackTrace();
return EdatResult.build(1, "fail");
}
}
@ResponseBody
@RequestMapping(value = "/word/selectWord", method = RequestMethod.POST)
public Map selectWord(HttpServletRequest request,
HttpServletResponse response) {
try {
ClientUtil.SetCharsetAndHeader(request, response);
ClientUtil.SetCharsetAndHeader(request, response);
int pageNumber=Integer.parseInt(request
.getParameter("pageNumber"));
int pageSize=Integer.parseInt(request
.getParameter("pageSize"));
String keyWord = request.getParameter("keyWord");
String sql = "select word_id as id,theme_type,word,alias from tb_word where word like '%"+keyWord+"%'or alias like '%"+keyWord+"%' limit "+pageNumber+","+pageSize ;
List<Map> result = new ArrayList<>();
result = gm.findRecords(sql);
String sql1 = "select count(*) as total from tb_word where word like '%"+keyWord+"%'or alias like '%"+keyWord+"%'";
int total= gm.findrows(sql1);
//List<Map> list = new ArrayList<>();
Map map = new HashMap();
map.put("total",total);
map.put("rows",result);
map.put("page",pageNumber/pageSize);
return map;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public void recordWords() throws IOException {
String path = "D:/zydata/中医古籍知识库-示例数据/示例数据/术语词典";
/*
* String path="D:/zydata/中医古籍知识库-示例数据/示例数据/术语词典"; File file = new
* File(path); File[] list =file.listFiles(); for(int
* i=0;i<list.length;i++){ recordingWords(list[i].getAbsolutePath()); }
*/
recordingWords(path + "/病因病机.xlsx", "by");
recordingWords(path + "/方剂.xlsx", "fj");
recordingWords(path + "/疾病.xlsx", "jb");
recordingWords(path + "/医籍.xlsx", "yj");
recordingWords(path + "/医家.xlsx", "ya");
recordingWords(path + "/证候.xlsx", "zh");
recordingWords(path + "/症状.xlsx", "zz");
recordingWords(path + "/治法.xlsx", "zf");
recordingWords(path + "/中药.xlsx", "zy");
}
public void recordingWords(String path, String type) throws IOException {
Workbook book = null;
try {
book = ExcelUtil.getExcelWorkbook(path);
Sheet sheet = book.getSheetAt(0);
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
long num = 1;
if (wm.selectMaxId() != null) {
num = wm.selectMaxId() + 1;
}
for (int i = firstRowNum + 1; i < lastRowNum; i++) {
Row row = sheet.getRow(i);
if (row != null) {
int first = row.getFirstCellNum();
// int last = row.getLastCellNum();
Cell cell = row.getCell(first);
if (cell != null
&& cell.getCellType() != Cell.CELL_TYPE_BLANK) {
Word word = new Word();
word.setWordId(num);
word.setParentId(num);
word.setWord(ExcelUtil.getCellValue(row.getCell(0)));
word.setThemeType(type);
wm.insert(word);
num++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
book.close();
}
}
public void recordWordRelation() {
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("by", 1);
map.put("fj", 2);
map.put("jb", 3);
map.put("yj", 4);
map.put("ya", 5);
map.put("zh", 6);
map.put("zz", 7);
map.put("zf", 8);
map.put("zy", 9);
long t1 = System.currentTimeMillis();
List<Section> list = sm.selectByBookId((long) 2);
for (Section sec : list) {
List<WsRelation> list1 = wsm.selectBySId(sec.getSectionId());
for (int i = 0; i < list1.size(); i++) {
WsRelation wr1 = list1.get(i);
for (int j = i + 1; j < list1.size(); j++) {
WsRelation wr2 = list1.get(j);
int type1 = map.get(wm.selectTypeById(wr1.getWordId()));
int type2 = map.get(wm.selectTypeById(wr2.getWordId()));
if (type1 != type2) {
WordRelation wr = new WordRelation();
int num = wr1.getWordNum() > wr2.getWordNum() ? wr1
.getWordNum() : wr2.getWordNum();
if (type1 < type2) {
WordRelation w = wrm.getByWords(type1, type2,
wr1.getWordId(), wr2.getWordId());
wr.setWordId(wr1.getWordId());
wr.setAnoWordId(wr2.getWordId());
wr.setNum(num);
if (w == null) {
wrm.insert(type1, type2, wr);
} else {
int num1 = w.getNum();
w.setNum(num1 + num);
}
} else {
WordRelation w = wrm.getByWords(type2, type1,
wr2.getWordId(), wr1.getWordId());
wr.setWordId(wr2.getWordId());
wr.setAnoWordId(wr1.getWordId());
wr.setNum(num);
if (w == null) {
wrm.insert(type1, type2, wr);
} else {
int num1 = w.getNum();
w.setNum(num1 + num);
}
}
}
}
}
}
long t2 = System.currentTimeMillis();
System.out.println(t2 - t1);
}
}
| [
"[email protected]"
] | |
69463f6e55ceb106374f57c2b2d05365c05c8d75 | 46aafb8cff58848903ed5e007bfc0274527e0ae3 | /04-Heap/Course Code(Java)/04-Shift-Down/src/MaxHeap.java | 47f642947b634b865507bc745e2c28201afcd7b3 | [] | no_license | bianxinhuan/Play-with-Algorithms | 500290a8fa149bd58cd9fa19279ed6a89b87217f | 9dbf7acf99cd951ec56d2e321f6120cc2e6af20b | refs/heads/master | 2020-06-09T23:07:56.588177 | 2019-07-26T14:47:31 | 2019-07-26T14:47:31 | 193,524,991 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,908 | java | /**
* 在堆的有关操作中,需要比较堆中元素的大小,所以E需要extends Comparable
*
* @author bianxinhuan
* @date 2019-07-10 21:04:20
*/
public class MaxHeap<E extends Comparable> {
protected E[] data;
protected int count;
protected int capacity;
/**
* 构造一个空堆,可容纳capacity个元素
*
* @param capacity
*/
public MaxHeap(int capacity) {
// 由于我们的索引是从1开始的(0的位置留空),所以capacity需要+1
this.data = (E[]) new Comparable[capacity + 1];
this.count = 0;
this.capacity = capacity;
}
/**
* 返回堆中的元素个数
*
* @return
*/
public int size() {
return count;
}
/**
* 返回一个布尔值,表示堆中是否为空
*
* @return
*/
public boolean isEmpty() {
return count == 0;
}
/**
* 向最大堆中插入一个新的元素 e
*
* @param e
*/
public void insert(E e) {
assert count + 1 <= capacity;
data[count + 1] = e;
count++;
shiftUp(count);
}
/**
* 从最大堆中取出堆顶元素,即堆中所存储的最大元素
*
* @return
*/
public E extractMax() {
assert count > 0;
E ret = data[1];
swap(1, count);
count--;
// 元素下沉
shiftDown(1);
return ret;
}
/**
* 获取最大堆中的堆顶元素
*
* @return
*/
public E getMax() {
assert count > 0;
return data[1];
}
/**
* 交换堆中索引为i和j的两个元素
*
* @param i
* @param j
*/
private void swap(int i, int j) {
E e = data[i];
data[i] = data[j];
data[j] = e;
}
/**
* ********************
* * 最大堆核心辅助函数
* ********************
*
* @param k
*/
private void shiftUp(int k) {
// 如果元素小于它的父亲节点,则交换位置,继续向上比较
while (k > 1 && data[k].compareTo(data[k / 2]) > 0) {
swap(k, k / 2);
k /= 2;
}
}
/**
* 元素下沉
*
* @param k
*/
private void shiftDown(int k) {
while (2 * k <= count) {
// 在此轮循环中,data[k]和data[j]交换位置(元素k下沉)
// j表示k的子节点中的最大的那个
int j = 2 * k;
// 如果k有2个子节点,并且右孩子比左孩子大,则j表示右孩子节点
if (j + 1 <= count && data[j + 1].compareTo(data[j]) > 0) {
j++;
}
// 如果当前元素大于它的孩子节点,则不需要下沉
if (data[k].compareTo(data[j]) >= 0) {
break;
}
// 下沉:把k和它的孩子节点交换
swap(k, j);
k = j;
}
}
/**
* 测试MaxHeap
*
* @param args
*/
public static void main(String[] args) {
MaxHeap<Integer> maxHeap = new MaxHeap<>(100);
// 堆中元素个数
int N = 100;
// 堆中元素取值范围[0,M]
int M = 100;
for (int i = 0; i < N; i++) {
maxHeap.insert((int) (Math.random() * M));
}
Integer[] arr = new Integer[N];
// 将maxheap中的数据逐渐使用extractMax取出来
// 取出来的顺序应该是按照从大到小的顺序取出来的
for (int i = 0; i < N; i++) {
arr[i] = maxHeap.extractMax();
System.out.print(arr[i] + " ");
}
System.out.println();
// 确保arr数组是从大到小排列的
for (int i = 0; i < N; i++) {
assert arr[i - 1] >= arr[i];
}
}
}
| [
"[email protected]"
] | |
70d19991fc0b9d523c190939ba49bada0d99bc23 | f083270453dbc91afc3049a8a8ac6b6aa21dd867 | /src/main/java/uk/ac/hud/postroom/ui/table/ColourCellRenderer.java | c773f6215558c2f2c3e32cddb36f308bf8bad81a | [] | no_license | Richard-Walton/The-Post-Room-Computer | 57869c787514fcf4f891223593ef0e3d7a354d72 | fcf77911292c9a4363b5a239f4a551a380e8409e | refs/heads/master | 2021-01-17T07:49:53.013982 | 2016-07-07T08:41:45 | 2016-07-07T08:41:45 | 3,291,750 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,329 | java | package uk.ac.hud.postroom.ui.table;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.awt.*;
/**
* Custom Cell Renderer for displaying colours
* @author Richard Walton ([email protected])
*/
public class ColourCellRenderer extends JLabel implements TableCellRenderer {
// Shared Border for all selected cells
private static Border selectedBorder;
// Shared Border for all un-selected cells
private static Border unSelectedBorder;
static {
// Border to show when cell is selected
selectedBorder = BorderFactory.createMatteBorder(
1,3,1,3, UIManager.getColor("Table.selectionBackground"));
// Border to show when cell is un-selected
unSelectedBorder = BorderFactory.createMatteBorder(
2,4,2,4, UIManager.getColor("Table.background"));
}
public ColourCellRenderer() {
// Force the background to be shown
setOpaque(true);
}
/** @inheritDoc **/
public Component getTableCellRendererComponent(
JTable table, Object color, boolean selected, boolean focus, int row, int column) {
setBackground((Color) color);
setBorder(selected ? selectedBorder : unSelectedBorder);
return this;
}
} | [
"[email protected]"
] | |
465099bf562e9b0b0340ac9f8e4e23acba16fa28 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/JetBrains--intellij-community/41c366b566ccf99fb0872642f0c0171e1055e114/after/TargetFilter.java | e709906e8c1a994103d8c42465c780643f69652d | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,771 | java | package com.intellij.lang.ant.config.impl;
import com.intellij.lang.ant.config.AntBuildTarget;
import com.intellij.openapi.util.JDOMExternalizable;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
public final class TargetFilter implements JDOMExternalizable {
@NonNls private static final String FILTER_TARGET_NAME = "targetName";
@NonNls private static final String FILTER_IS_VISIBLE = "isVisible";
private String myTargetName;
private boolean myVisible;
private String myDescription = "";
public TargetFilter() {}
public TargetFilter(String targetName, boolean isVisible) {
myTargetName = targetName;
myVisible = isVisible;
}
public String getTargetName() {
return myTargetName;
}
public boolean isVisible() {
return myVisible;
}
public void setVisible(boolean isVisible) {
myVisible = isVisible;
}
public void readExternal(Element element) {
myTargetName = element.getAttributeValue(FILTER_TARGET_NAME);
myVisible = Boolean.valueOf(element.getAttributeValue(FILTER_IS_VISIBLE));
}
public void writeExternal(Element element) {
element.setAttribute(FILTER_TARGET_NAME, getTargetName());
element.setAttribute(FILTER_IS_VISIBLE, Boolean.valueOf(isVisible()).toString());
}
public String getDescription() {
return myDescription;
}
public void updateDescription(AntBuildTarget target) {
if (target == null) return;
myDescription = target.getNotEmptyDescription();
}
public static TargetFilter fromTarget(AntBuildTarget target) {
TargetFilter filter = new TargetFilter(target.getName(), target.isDefault());
filter.myDescription = target.getNotEmptyDescription();
filter.myVisible = (filter.myDescription != null);
return filter;
}
} | [
"[email protected]"
] | |
3c15ebfc6fdf2c424295a7ea6d50592fd354c89a | 2991fc074be81cdf8fbc842cfd8b6fbd5bd46c3f | /MVCProject/src/controllers/ReceiptTrackerController.java | 0f13379af67a49ddb5a00b014cecd749f77f02f5 | [] | no_license | Airik-Leon/AccountTracker | 00076ae235069e4c65f0967d7a914728e6211e49 | b25f0799bf69e53639d381caa66a362083b7008a | refs/heads/master | 2021-09-03T10:55:40.516459 | 2018-01-08T13:44:05 | 2018-01-08T13:44:05 | 115,889,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,452 | java | package controllers;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import data.AccountDAO;
import data.UserDAO;
import entities.Account;
import entities.AccountType;
import entities.TradeType;
import entities.Transaction;
import entities.User;
@CrossOrigin
@RestController
public class ReceiptTrackerController {
@Autowired
UserDAO userDAO;
@Autowired
AccountDAO accountDAO;
//User Methods
@RequestMapping(path="/users", method=RequestMethod.GET)
public List<User> usersIndex() {
return userDAO.index();
}
@RequestMapping(path="/users/{id}", method=RequestMethod.GET)
public User showUsers(@PathVariable int id) {
return userDAO.show(id);
}
@RequestMapping(path="/users", method=RequestMethod.POST)
public User createUsers(@RequestBody String json, HttpServletResponse res) {
User u = userDAO.create(json);
if(u == null) {
res.setStatus(400);
}
else {
res.setStatus(202);
}
return u;
}
@RequestMapping(path="/users/{id}", method=RequestMethod.PUT)
public User updateUsers(@PathVariable int id, @RequestBody String json, HttpServletResponse res) {
User u = userDAO.update(id, json);
if(u == null) {
res.setStatus(400);
}
else {
res.setStatus(202);
}
return u;
}
@RequestMapping(path="/users/{id}", method=RequestMethod.DELETE)
public User deleteUsers(@PathVariable int id) {
User u = userDAO.delete(id);
return u;
}
//
//Account Methods
//
@RequestMapping(path="/users/{id}/accounts", method=RequestMethod.GET)
public List<Account> indexUserAccounts(@PathVariable int id) {
List<Account> userAccounts = accountDAO.indexUserAccounts(id);
return userAccounts;
}
@RequestMapping(path="/users/{uId}/accounts", method=RequestMethod.POST)
public Account createAccounts(@PathVariable int uId, @RequestBody String json, HttpServletResponse res) {
System.out.println(json);
Account a = accountDAO.create(uId, json);
return a;
}
@RequestMapping(path="/users/{uId}/accounts/{aId}", method=RequestMethod.PUT)
public Account updateAccounts( @RequestBody String json, @PathVariable int uId,@PathVariable int aId, HttpServletResponse res) {
Account a = accountDAO.update(aId, json);
return a;
}
@RequestMapping(path="/users/{uId}/accounts/{aId}", method=RequestMethod.DELETE)
public Account deleteAccount(@PathVariable int aId, @PathVariable int uId) {
Account a = accountDAO.delete(aId);
return a;
}
/*
* Transaction methods
*/
@RequestMapping(path="/users/{uId}/accounts/{aId}/transactions", method=RequestMethod.GET)
public List<Transaction> indexUserAccountsTransactions(@PathVariable int uId, @PathVariable int aId) {
List<Transaction> userAccounts = accountDAO.indexUserAccountsTransactions(uId, aId);
return userAccounts;
}
@RequestMapping(path="/users/{uId}/accounts/{aId}/transactions", method=RequestMethod.POST)
public Transaction createAccountTransaction(@PathVariable int uId, @PathVariable int aId, @RequestBody String json, HttpServletResponse res) {
Transaction t = accountDAO.createTransaction(uId, aId, json);
return t;
}
@RequestMapping(path="users/{uId}/accounts/{aId}/transactions/{tId}", method=RequestMethod.PUT)
public Transaction updateAccountTransaction(@PathVariable int uId, @PathVariable int aId, @PathVariable int tId, @RequestBody String json, HttpServletResponse res) {
Transaction t = accountDAO.updateTransaction(uId, aId, tId, json);
return t;
}
@RequestMapping(path="users/{uId}/accounts/{aId}/transactions/{tId}", method=RequestMethod.DELETE)
public Transaction deleteAccountTransactions(@PathVariable int tId) {
Transaction t = accountDAO.deleteTransaction(tId);
return t;
}
//Send types of trades
@RequestMapping(path="/transactionType", method=RequestMethod.GET)
public List<TradeType> TradeTypes(){
return accountDAO.indexTradeType();
}
@RequestMapping(path="/accountType", method=RequestMethod.GET)
public List<AccountType> accountTypes(){
return accountDAO.indexAccountType();
}
}
| [
"[email protected]"
] | |
3ef276e3d11702b9431c6e9a47e28b5f61bc6468 | a8d1ed799ee32567c559cc94bd8c10e56e91b956 | /src/samplejava/objectRepository.java | 78ea00d0298f3548b926858e64e4ef967acc5346 | [] | no_license | yamini1312/demoproject | 6e23dd32bdbd7e34db08cd02c063f1a5ed4926ba | 21262c08cdcde9f3f1b2d4e84d5e1c4f1bda9d6a | refs/heads/master | 2021-04-15T16:43:49.837147 | 2018-03-23T05:28:28 | 2018-03-23T05:28:28 | 126,329,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 61 | java | package samplejava;
public class objectRepository {
}
| [
"IT-Admin@lpch-trng05"
] | IT-Admin@lpch-trng05 |
3ede21b0730cfcc837ece8bf3f62a3f7072a0826 | dc9e616737ff989e5eb3b0f85f1173279ef06312 | /app/src/androidTest/java/com/example/homework/ExampleInstrumentedTest.java | db2d0c989576c80fbc71b614bd162892e2f85729 | [] | no_license | Overbyaka/Samsung | d6a75f97d273fa0b4ecc15d96d209c0fef81cfa7 | b4a54e53c3fdbca1654ebc013843e60765e176b6 | refs/heads/master | 2020-08-14T00:15:21.632929 | 2019-12-01T16:42:36 | 2019-12-01T16:42:36 | 215,062,063 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 783 | java | package com.example.homework;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.homework", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
a439eb0fea37a86fd80a0dc52fbf0495cc86db5b | 769d534fe7a224bebbb876e68f052ee379b07088 | /src/test/java/chapter6Revision/Employee.java | 5c10f6e47eae69b5e514e1bea4fea3bdd7fc9cc7 | [] | no_license | llmr2005/JavaLearningtest | 87b694e7997ba4bf7c7f0d33228d8389894f5bea | 253afd4a68a4dfb52f03e1a003c27120701cb0fa | refs/heads/master | 2022-12-28T06:13:09.093009 | 2020-06-20T16:23:39 | 2020-06-20T16:23:39 | 273,741,644 | 0 | 0 | null | 2020-10-13T22:56:25 | 2020-06-20T16:13:05 | Java | UTF-8 | Java | false | false | 792 | java | package chapter6Revision;
/**
* Created by lingalal on 14/06/2020.
*/
public class Employee {
private String empname;
public Employee(String name){
this.empname=name;
}
public String getEmpname(){return empname;}
public String toString(){return this.empname;}
public static void main(String[] args) {
Employee []emparr = { new Employee("Test1"),new Employee("Test2"),new Employee("Test3")};
/*for(int i=0;i<emparr.length;i++)
{
Employee e= emparr[i];
System.out.println(e.getEmpname());
System.out.println(e);
}*/
for(Employee e:emparr) {
System.out.println(e.getEmpname());
System.out.println(e);
}
}
}
| [
"[email protected]"
] | |
fe3e8869a38c6fcd6d8db50cae47846907b47519 | ed5159d056e98d6715357d0d14a9b3f20b764f89 | /test/irvine/oeis/a003/A003719Test.java | b113e6f26ecfc437ca90f1ca25b2bfd7f0cf23cb | [] | no_license | flywind2/joeis | c5753169cf562939b04dd246f8a2958e97f74558 | e5efd6971a0062ac99f4fae21a7c78c9f9e74fea | refs/heads/master | 2020-09-13T18:34:35.080552 | 2019-11-19T05:40:55 | 2019-11-19T05:40:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package irvine.oeis.a003;
import irvine.oeis.AbstractSequenceTest;
/**
* Tests the corresponding class.
* @author Sean A. Irvine
*/
public class A003719Test extends AbstractSequenceTest {
}
| [
"[email protected]"
] | |
4366559e8f6a8b2ed17718baa4e51c4a616605e1 | 4e3d418a39224457a3f982b7f6d6bc46136a9733 | /src/com/gargoylesoftware/htmlunit/html/DomDocumentFragment.java | 88fc2acbfcaa7d314664f9ca558dc0e4e61bdd27 | [] | no_license | AdityaRaju/StoryBoard | 68f4a075accc5843926be30ecaded6c839d8c563 | b358dbcb730f2637560bf97c28ec6b77f77b81b0 | refs/heads/master | 2021-01-18T05:19:31.967515 | 2013-11-10T18:57:03 | 2013-11-10T18:57:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,045 | java | /*
* Copyright (c) 2002-2013 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gargoylesoftware.htmlunit.html;
import org.w3c.dom.DocumentFragment;
import com.gargoylesoftware.htmlunit.SgmlPage;
/**
* A DOM object for DocumentFragment.
*
* @version $Revision: 7931 $
* @author Ahmed Ashour
*/
public class DomDocumentFragment extends DomNode implements DocumentFragment {
/** The symbolic node name. */
public static final String NODE_NAME = "#document-fragment";
/**
* Creates a new instance.
* @param page the page which contains this node
*/
public DomDocumentFragment(final SgmlPage page) {
super(page);
}
/**
* {@inheritDoc}
* @return the node name, in this case {@link #NODE_NAME}
*/
@Override
public String getNodeName() {
return NODE_NAME;
}
/**
* {@inheritDoc}
* @return the node type constant, in this case {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE}
*/
@Override
public short getNodeType() {
return org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE;
}
/**
* {@inheritDoc}
*/
@Override
public String asXml() {
final StringBuilder sb = new StringBuilder();
for (final DomNode node : getChildren()) {
sb.append(node.asXml());
}
return sb.toString();
}
/**
* @return <code>false</code>
*/
@Override
protected boolean isDirectlyAttachedToPage() {
return false;
}
}
| [
"[email protected]"
] | |
2e5a2203784104d2ca9eb57ad1bc9b7e04c3b17a | ecf376a66c871a6df50f6edab1e9f0bb01342b46 | /app/src/main/java/com/weatherassignmentapplication/data/Webservice.java | def4ecbea54d7c8269fe43eae3ac8ac72d60f883 | [] | no_license | SableSonal/Weather-Analytics | 08d4416c52ee82671f3aa454ed691f4da7b1bf8d | 788fab5a07eda58f99678f202c5b29b0f0e927b6 | refs/heads/master | 2020-05-03T03:43:15.589119 | 2019-03-29T12:52:28 | 2019-03-29T12:52:28 | 178,404,489 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 294 | java | package com.weatherassignmentapplication.data;
import org.json.JSONObject;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
public interface Webservice {
@GET("/v1/current.json?key=23f8d0450ac946e58ae155120192803&q=Pune")
Call<ResponseBody> jquery();
}
| [
"[email protected]"
] | |
cbdae2ebc303aea9e73f0cd1a9b55d1653c2c671 | c01c5b769cef12832c31111b726e669158628625 | /project/src/DQL/DQLQueryExecution.java | 24ec672ec00fad105853847caad855bd9878f5b5 | [] | no_license | DhruvilSavliya/Distributed-Database-Management-System | 9983ac23de78ece7e23c20ba216511fd28f08f3f | 63aa9735e6961ea2e8a5153c646600612f062a48 | refs/heads/master | 2023-08-12T03:38:00.363004 | 2021-04-09T22:38:09 | 2021-04-09T22:38:09 | 406,135,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,469 | java | package DQL;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.*;
public class DQLQueryExecution {
private String tableName="";
public void selectTable(String username,String operation,String columns,String tableName,String conditions)
{
try
{
String[] conditionsArray = conditions.trim().split("=");
File myObj = new File("Data/" + username + "_" + tableName + ".txt");
Scanner myReader = new Scanner(myObj);
if(conditionsArray.length != 0)
{
String s = "";
Map<String, String> readMap = new HashMap<String, String>();
String nextLine;
while (myReader.hasNextLine())
{
nextLine = myReader.nextLine();
while (nextLine.trim().length() > 0) {
String[] row = nextLine.trim().split(" ");
readMap.put(row[0], row[1]);
if (myReader.hasNextLine()) {
nextLine = myReader.nextLine();
} else {
nextLine = "";
}
}
if (nextLine.trim().length() == 0) {
String value = readMap.get(conditionsArray[0]);
if (value.trim().equalsIgnoreCase(conditionsArray[1].trim())) {
readMap.put(conditionsArray[0], conditionsArray[1]);
Iterator<String> iterator = readMap.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
s = s + key + " " + readMap.get(key) + "\n";
}
s = s + "\n";
}
}
}
System.out.println(s);
}else{
while (myReader.hasNextLine())
{
String data = myReader.nextLine();
System.out.println(data);
}
}
myReader.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
public void dump(String username) {
try {
File dataDictionary = new File("Data/UserTableDictionary.txt");
FileReader readDictionary = new FileReader(dataDictionary);
BufferedReader bufferedReader = new BufferedReader(readDictionary);
File dumpfile = new File(username + "_data_dump.txt");
FileWriter writeFile = new FileWriter(dumpfile, true);
String readLine = bufferedReader.readLine();
if (readLine.equalsIgnoreCase(username)) {
readLine = bufferedReader.readLine();
while (!readLine.isBlank()) {
writeFile.write(readLine);
writeFile.write("\n");
readLine = bufferedReader.readLine();
}
writeFile.write("\n");
}
bufferedReader.close();
writeFile.close();
readDictionary.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void generateERD(String username) {
try {
FileReader fileReader = new FileReader("Data/UserTableDictionary.txt");
BufferedReader bufferedReader = new BufferedReader(fileReader);
List<String> dataColumns = new ArrayList<String>();
String s = "";
String line="";
while( (line=bufferedReader.readLine())!=null) {
dataColumns.add(line);
}
for( int i=0; i<dataColumns.size(); i++)
{
if (dataColumns.get(i).contains("fk"))
{
s = s + dataColumns.get(i) +"\n";
}
}
bufferedReader.close();
System.out.println("ERD has been generated successfully !!");
FileWriter myfile=new FileWriter("Data/" + username +"_ERD.txt");
myfile.write(s);
myfile.flush();
myfile.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
} | [
"[email protected]"
] | |
084c37b5d0d94a99c2fc7f555b9454ec1664797f | 6a3c2d5cdbaac4e33370323fd4f2e66388e413ce | /src/main/java/com/smartling/connector/eloqua/sdk/rest/model/login/AccountInfo.java | 24b439c15c1972ce44f019e4d1a8c7e0560905d1 | [] | no_license | isabella232/eloqua-rest-sdk-java | 2a536a797c8fa84eb64eb58e4c73b5c42b7aa163 | 0aeab7b6c194604b0b68b5e28fe5714820a644e4 | refs/heads/master | 2023-03-04T14:12:39.523968 | 2021-02-01T16:30:54 | 2021-02-01T16:30:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 404 | java | package com.smartling.connector.eloqua.sdk.rest.model.login;
public class AccountInfo
{
private Site site;
private ApiAccount user;
private Urls urls;
public String getBaseUrl()
{
return urls.getBase();
}
public Urls getUrls()
{
return urls;
}
public void setUrls(final Urls urls)
{
this.urls = urls;
}
}
| [
"[email protected]"
] | |
f0b9434ef6b1838e554312f4c29e4e012cc10d9d | 90a2a16ca563b9815340a5e775142ee892275607 | /src/main/java/com/mario1oreo/projects/business/pontus/dao/PrdVoucherInfoDao.java | 93ac9846502e2dff428a3a6973f129f6fdad1935 | [] | no_license | mario1oreo/pontus | 37603f51a2d04d2fa269bb8e8b3d3691f7297f05 | 64e959df0b4bc877283c002b765584c7cd38d559 | refs/heads/master | 2022-02-05T16:05:48.284134 | 2020-05-11T19:21:32 | 2020-05-11T19:21:32 | 218,559,082 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,408 | java | package com.mario1oreo.projects.business.pontus.dao;
import com.mario1oreo.projects.business.pontus.dto.PrdVoucherInfoDTO;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @author mario1oreo
*
* @date 2019-11-13
*
*/
@Mapper
public interface PrdVoucherInfoDao {
@Select("SELECT ID, VOUCHER_ID, VOUCHER_TYPE, VOUCHER_AMOUNT, VOUCHER_REAL_AMOUNT, INVOICE_DEMAND, INVOICE_RATE, INVOICE_AMOUNT, INVOICE_NO, TRANSACTION_TYPE, TRANSACTION_TIME, PRODUCT_ID, BATCH_NO, PRODUCT_QUANTITY, SALE_CHANNEL, STATE, CREATE_TIME, CREATE_BY, UPDATE_TIME, UPDATE_BY FROM PRD_VOUCHER_INFO")
@Results({
@Result(column = "ID", property = "id"),
@Result(column = "VOUCHER_ID", property = "voucherId"),
@Result(column = "VOUCHER_TYPE", property = "voucherType"),
@Result(column = "VOUCHER_AMOUNT", property = "voucherAmount"),
@Result(column = "VOUCHER_REAL_AMOUNT", property = "voucherRealAmount"),
@Result(column = "INVOICE_DEMAND", property = "invoiceDemand"),
@Result(column = "INVOICE_RATE", property = "invoiceRate"),
@Result(column = "INVOICE_AMOUNT", property = "invoiceAmount"),
@Result(column = "INVOICE_NO", property = "invoiceNo"),
@Result(column = "TRANSACTION_TYPE", property = "transactionType"),
@Result(column = "TRANSACTION_TIME", property = "transactionTime"),
@Result(column = "PRODUCT_ID", property = "productId"),
@Result(column = "BATCH_NO", property = "batchNo"),
@Result(column = "PRODUCT_QUANTITY", property = "productQuantity"),
@Result(column = "SALE_CHANNEL", property = "saleChannel"),
@Result(column = "STATE", property = "state"),
@Result(column = "CREATE_BY", property = "createBy"),
@Result(column = "UPDATE_BY", property = "updateBy")
})
List<PrdVoucherInfoDTO> findAll();
@Select("SELECT ID, VOUCHER_ID, VOUCHER_TYPE, VOUCHER_AMOUNT, VOUCHER_REAL_AMOUNT, INVOICE_DEMAND, INVOICE_RATE, INVOICE_AMOUNT, INVOICE_NO, TRANSACTION_TYPE, TRANSACTION_TIME, PRODUCT_ID, BATCH_NO, PRODUCT_QUANTITY, SALE_CHANNEL, STATE, CREATE_TIME, CREATE_BY, UPDATE_TIME, UPDATE_BY FROM PRD_VOUCHER_INFO LIMIT #{startNum},#{pageSize}")
@Results({
@Result(column = "ID", property = "id"),
@Result(column = "VOUCHER_ID", property = "voucherId"),
@Result(column = "VOUCHER_TYPE", property = "voucherType"),
@Result(column = "VOUCHER_AMOUNT", property = "voucherAmount"),
@Result(column = "VOUCHER_REAL_AMOUNT", property = "voucherRealAmount"),
@Result(column = "INVOICE_DEMAND", property = "invoiceDemand"),
@Result(column = "INVOICE_RATE", property = "invoiceRate"),
@Result(column = "INVOICE_AMOUNT", property = "invoiceAmount"),
@Result(column = "INVOICE_NO", property = "invoiceNo"),
@Result(column = "TRANSACTION_TYPE", property = "transactionType"),
@Result(column = "TRANSACTION_TIME", property = "transactionTime"),
@Result(column = "PRODUCT_ID", property = "productId"),
@Result(column = "BATCH_NO", property = "batchNo"),
@Result(column = "PRODUCT_QUANTITY", property = "productQuantity"),
@Result(column = "SALE_CHANNEL", property = "saleChannel"),
@Result(column = "STATE", property = "state"),
@Result(column = "CREATE_BY", property = "createBy"),
@Result(column = "UPDATE_BY", property = "updateBy")
})
List<PrdVoucherInfoDTO> findByPage(@Param("startNum") int startNum, @Param("pageSize") int pageSize);
@Insert("INSERT INTO PRD_VOUCHER_INFO( ID, VOUCHER_ID, VOUCHER_TYPE, VOUCHER_AMOUNT, VOUCHER_REAL_AMOUNT, INVOICE_DEMAND, INVOICE_RATE, INVOICE_AMOUNT, INVOICE_NO, TRANSACTION_TYPE, TRANSACTION_TIME, PRODUCT_ID, BATCH_NO, PRODUCT_QUANTITY, SALE_CHANNEL, STATE, CREATE_TIME, CREATE_BY, UPDATE_TIME, UPDATE_BY) " +
"VALUES(#{id}, #{voucherId}, #{voucherType}, #{voucherAmount}, #{voucherRealAmount}, #{invoiceDemand}, #{invoiceRate}, #{invoiceAmount}, #{invoiceNo}, #{transactionType}, #{transactionTime}, #{productId}, #{batchNo}, #{productQuantity}, #{saleChannel}, #{state}, #{createTime}, #{createBy}, #{updateTime}, #{updateBy})")
int insert(PrdVoucherInfoDTO prdVoucherInfoDTO);
}
| [
"[email protected]"
] | |
3627a5d1d7bd159bc323f333c7ebdd2e5b4cec6a | e1bd65ef3ea1b5a5b544a583887d1594ba0974d7 | /app/src/main/java/com/example/comptermsquiz/Quizcreatorofcomp.java | 752b5258febfb8e25e42fdf17a238f0cdf967b63 | [] | no_license | erickedquiban/CompTermsQuiz | 298ccaf134a45aac2ea869acecc8a019237bbb8f | 2d5a96fc96f16a10b93e9db381cf1ba9e7459667 | refs/heads/master | 2022-11-27T01:20:28.693588 | 2020-07-14T10:06:48 | 2020-07-14T10:06:48 | 279,547,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,206 | java | package com.example.comptermsquiz;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Quizcreatorofcomp extends AppCompatActivity {
private static final int REQUEST_CODE_QUIZ = 1;
public static final String SHARED_PREFS = "sharedPrefs";
public static final String KEY_HIGHSCORE = "keyHighscore";
public static final String KEY_SCORE = "keyScore";
TextView alert;
Button btn2;
Button btn3;
private TextView textViewHighscore;
private TextView textViewScore;
private int highscore, current_highscore;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quizcreatorofcomp);
btn2 = (Button) findViewById(R.id.btn2);
btn3 =(Button) findViewById(R.id.btn3);
alert = (TextView) findViewById(R.id.alert);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int1 = new Intent(Quizcreatorofcomp.this, CompActivity.class);
startActivity(int1);
// myMenu.findItem(R.id.nav_his)
// .setEnabled(true);
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int1 = new Intent(Quizcreatorofcomp.this, CompActivity.class);
startActivity(int1);
// myMenu.findItem(R.id.nav_his)
// .setEnabled(true);
}
});
//wag dito
textViewHighscore = findViewById(R.id.tv_highscore);
loadHighscore();
textViewScore = findViewById(R.id.recent);
loadScore();
Button buttonStartQuiz = findViewById(R.id.btn1);
buttonStartQuiz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startQuiz1();
}
});
}
private void startQuiz1() {
Intent intent = new Intent(Quizcreatorofcomp.this, Quiz5.class);
startActivityForResult(intent, REQUEST_CODE_QUIZ);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_QUIZ) {
if (resultCode == RESULT_OK) {
int score = data.getIntExtra(Quiz5.EXTRA_SCORE, 0);
if (score > highscore) {
updateHighscore(score);
}
int recent_score = data.getIntExtra(Quiz5.EXTRA_RECENT_SCORE, 0);
if (recent_score >= current_highscore || recent_score <= current_highscore) {
updateScore(recent_score);
}
}
}
}
private void loadHighscore() {
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
highscore = prefs.getInt(KEY_HIGHSCORE, 0);
textViewHighscore.setText("Highscore: " + highscore);
}
private void loadScore() {
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
current_highscore = prefs.getInt(KEY_SCORE, 0);
textViewScore.setText("Recent Score: " + current_highscore);
if (current_highscore <= 5) {
alert.setText("");
btn2.setEnabled(false);
}
}
private void updateHighscore(int highscoreNew) {
highscore = highscoreNew;
textViewHighscore.setText("Highscore: " + highscore);
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(KEY_HIGHSCORE, highscore);
editor.apply();
if (highscore <= 5) {
alert.setText("You have to Read more about the topic!");
btn2.setEnabled(false);
} else if (highscore >= 6 ){
alert.setText("Congratulations you meet the passing score");
btn2.setEnabled(true);
// quiz1.setEnabled(true);
}
}
private void updateScore (int highscoreNew) {
current_highscore = highscoreNew;
textViewScore.setText("Recent Score: " + current_highscore);
if (current_highscore <= 5) {
alert.setText("You have to Read more about the topic!");
btn2.setEnabled(false);
} else if (current_highscore >= 6 ){
alert.setText("Congratulations you meet the passing score");
btn2.setEnabled(true);
// quiz1.setEnabled(true);
}
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(KEY_SCORE, current_highscore);
editor.apply();
}
}
| [
"[email protected]"
] | |
c2adcf2da3c6b1378230a65ec3c0128224a7be79 | 59a4850e05d60e55c8e2de4d9ede61bd20e2cd8d | /src/main/java/com/kafkaexample/kafkaexample/services/Consumer.java | 303e185639152fb622c3100be62eda0bbcd199a6 | [] | no_license | darshan92kumar/springboot_kafka | 6b0d11cc945cb704c04dfa09b6cfb74553da41bc | b94ed4363ac83989d55a85823431e3d14ed5ed17 | refs/heads/master | 2020-07-01T08:14:47.153846 | 2019-08-07T18:20:54 | 2019-08-07T18:20:54 | 201,103,823 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 508 | java | package com.kafkaexample.kafkaexample.services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
@Service
public class Consumer {
private final Logger logger = LoggerFactory.getLogger(Consumer.class);
@KafkaListener(topics = "users", groupId = "group_id")
public void consume(String message){
logger.info(String.format("$$ -> Consumed Message -> %s",message));
}
}
| [
"[email protected]"
] | |
e35c1bfa202ecd6d59684f5a08fb0cc427d884f0 | 9ecf8b9e629920fc58a5e5e9fb218825449967ad | /app/src/main/java/com/idotools/browser/gp/minterface/OnItemClickListener.java | a58c180c61a28040e6199656bf6590fb4f87f2e4 | [] | no_license | wuxiaojun123/iDOToolsBrowser_gp | f421e23cf963195e7edd0fe4c5ab97cc071223eb | c98c592f835d09944c971b9de6c80b868af3f78d | refs/heads/master | 2021-01-13T15:17:32.751076 | 2016-12-14T11:47:36 | 2016-12-14T11:47:36 | 76,453,408 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 202 | java | package com.idotools.browser.gp.minterface;
/**
* Created by wuxiaojun on 16-11-11.
*/
public interface OnItemClickListener {
void onItemClickListener(String url,String imgUrl,String title);
}
| [
"[email protected]"
] | |
edd8579015f8e9ff271f2e899118f531edfebdab | a2a02eba49c6ffa1a788b18808a45c3fd0802487 | /reservations/src/main/java/com/alejandro/reservations/web/application/ReservationController.java | ffe732b108a27d827fd743cfdae0ade0a6ab66c5 | [] | no_license | ale517/SpringBoot | 9ce429aca8f735c9c5a34d68014f0369afa225db | ad0ce74c2a9d8bb74c44c30e91aaca804e739020 | refs/heads/master | 2021-09-04T13:07:34.524737 | 2018-01-19T01:52:14 | 2018-01-19T01:52:14 | 118,061,426 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,268 | java | package com.alejandro.reservations.web.application;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.alejandro.reservations.business.domain.RoomReservation;
import com.alejandro.reservations.business.service.ReservationService;
@Controller
@RequestMapping(value = "/reservations")
public class ReservationController {
@Autowired
private ReservationService reservationService;
@RequestMapping(method = RequestMethod.GET)
public String getReservations(@RequestParam(value = "date", required = false) String dataString, Model model) {
List<RoomReservation> roomReservationList = reservationService.getRoomReservationsForDate(dataString);
model.addAttribute("roomReservations", roomReservationList);
//reservationService.getRoomReservationsForDateDB(date);
return "reservations";
}
}
| [
"[email protected]"
] | |
0a24cdcb643003a1efe216e3fb3a4e73fd5be898 | 66581bc32744f3a30be77c7638a534f024daddb6 | /sakai-mini/2.8.0/sitestats/sitestats-api/src/java/org/sakaiproject/sitestats/api/Stat.java | 41e4b4836a05f7d05ebaa181a6c0d29f23289cf2 | [
"ECL-2.0"
] | permissive | lijiangt/sakai | 087be33a4f20fe199458fe6a4404f37c613f3fa2 | 2647ef7e93617e33d53b1756918e64502522636b | refs/heads/master | 2021-01-10T08:44:39.756518 | 2012-03-05T14:40:08 | 2012-03-05T14:40:08 | 36,716,620 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,857 | java | /**
* $URL: https://source.sakaiproject.org/svn/sitestats/tags/sitestats-2.2.0/sitestats-api/src/java/org/sakaiproject/sitestats/api/Stat.java $
* $Id: Stat.java 72172 2009-09-23 00:48:53Z [email protected] $
*
* Copyright (c) 2006-2009 The Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.osedu.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sakaiproject.sitestats.api;
import java.util.Date;
/**
* Represents common fields of records from the SST_EVENTS and SST_RESOURCES tables.
* @author Nuno Fernandes
*/
public interface Stat {
/** Get the db record id. */
public long getId();
/** Set the db record id. */
public void setId(long id);
/** Get the user Id this record refers to. */
public String getUserId();
/** Set the user Id this record refers to. */
public void setUserId(String userId);
/** Get the context (site Id) this record refers to. */
public String getSiteId();
/** Set the context (site Id) this record refers to. */
public void setSiteId(String siteId);
/** Get the total value. */
public long getCount();
/** Set the total value. */
public void setCount(long count);
/** Get the date this record refers to. Only year,month and day are important. */
public Date getDate();
/** Set the date this record refers to. Only year,month and day are important. */
public void setDate(Date date);
}
| [
"[email protected]"
] | |
66bea6dc6731ec934d4fc4ca883016111dbfb591 | 0b03bf625f9a604b2629d50e7ada93bfc7b96f80 | /src/by/htp/parcer/MainFamilySAX.java | 2eadeae37c399be3b8f1cc0e077fd89487e34f10 | [] | no_license | ZastenQ/Parcers | 00cb8b233629b372c74d861a73629f884e424e0d | 38fe6480ed7ed7f9bcc5e59e839a626188a51830 | refs/heads/master | 2021-01-23T12:33:55.380241 | 2017-06-05T13:12:10 | 2017-06-05T13:12:10 | 93,173,177 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 839 | java | package by.htp.parcer;
import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import by.htp.parcer.entity.Family;
public class MainFamilySAX {
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
XMLReader reader = XMLReaderFactory.createXMLReader();
FamilySAXHadler handler = new FamilySAXHadler();
reader.setContentHandler(handler);
reader.parse(new InputSource("resources/FamilyTree.xml"));
List<Family> familyList = handler.getFamilyXML();
for (Family familyEntity : familyList) {
System.out.println(familyEntity.getFamilyID());
}
}
}
| [
"[email protected]"
] | |
20092b3205524f62647a9af54fcf8b20ed77f5ed | afe318312fc586852375eac09ba57ae317403c46 | /src/main/java/com/pattern/behavioral/observer/ONewsChannel.java | 138e7222265f9199915fccc368a6e68d0b3aea4c | [] | no_license | ericlee83/leet-code-challenage | 337fd18353ff519784772cfef689da572ccd1f26 | 33a9a6ad501ce44abf9653683b6b4a922d73b728 | refs/heads/master | 2022-12-29T04:26:45.843676 | 2020-09-11T05:01:31 | 2020-09-11T05:01:31 | 283,921,648 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 308 | java | package com.pattern.behavioral.observer;
import lombok.Data;
import java.util.Observable;
import java.util.Observer;
@Data
public class ONewsChannel implements Observer {
private String news;
@Override
public void update(Observable o, Object arg) {
this.setNews((String) arg);
}
}
| [
"[email protected]"
] | |
dc2ce28f026da83a838471bf30680c8623d59e30 | 7992c5b62f823e4340312b56cfe59a72b6d83ea2 | /src/main/java/com/jaydip/urlshortner/entity/Url.java | 3340cfae2e8130bcd7ffa69843b70d567f8b026e | [] | no_license | jaydipkmn/url-shortner-social-login | f50cef9faa32a60dada522519a39cd68580b194c | 9105e988322d7b480323ae0310053a4e713ff545 | refs/heads/master | 2020-05-15T22:57:38.932288 | 2019-04-21T13:48:19 | 2019-04-21T13:48:19 | 182,539,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 673 | java | package com.jaydip.urlshortner.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "url")
public class Url {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "url_id")
private int id;
@Column(name = "ourl")
private String originalUrl;
@Column(name = "surl")
private String shortenedUrl;
}
| [
"[email protected]"
] | |
a9eb04a4d835fbadd7d32deb020a4132505cc8b9 | 8b1077057d5b2ec481c46b91e5f475f279660be9 | /src/main/java/cz/uhk/fim/ppro/validator/ReservationValidator.java | e05301f23402ae561729954bf5bc227570564faf | [] | no_license | ard0p8v/PPRO_TicketLon | b0a3f97d0fa0b11e5841d8650415d1f486c63c4c | 0fb535c14245a1b1151cd0354ffa9508c09ecb02 | refs/heads/master | 2018-09-16T08:03:55.685549 | 2018-06-05T17:26:33 | 2018-06-05T17:26:33 | 110,996,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,105 | java | package cz.uhk.fim.ppro.validator;
import cz.uhk.fim.ppro.model.Event;
import cz.uhk.fim.ppro.model.Reservation;
import cz.uhk.fim.ppro.service.IEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
public class ReservationValidator implements Validator {
@Autowired
private IEventService eventService;
@Override
public boolean supports(Class<?> clazz) {
return false;
}
@Override
public void validate(Object r, Errors errors) {
Reservation reservation = (Reservation) r;
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "numberOfTickets", "NotEmpty");
int id = reservation.getEvent().getIdEvent();
Event e = eventService.read(id);
int ticketsFree = e.getNumberOfFreeTickets();
if(reservation.getNumberOfTickets() > ticketsFree) {
errors.rejectValue("numberOfTickets", "Size.reservationForm.numberOfTickets");
}
}
}
| [
"[email protected]"
] | |
f5d33e322abe7618c676476ea9c5d421afc28c8c | 4300104be07b0d70abbffcfd10dd2bc2163deaa4 | /business-intelligence-suite/src/main/java/uninfz/ifrozet/ma/repository/Dim_categorieDao.java | c824511679173fe8cd7b4e6f3c44ac00c8a0dff3 | [] | no_license | Hasnaoui-Said/Gestion-projet-collaboratif | 8fd1f7d73f5a4d06b056f2eb4ed28b16ec6aae99 | 4b293d26cfe36eebeb67cfcd8f9960cf92d95a50 | refs/heads/master | 2023-07-12T03:08:47.005034 | 2021-08-15T10:18:23 | 2021-08-15T10:18:23 | 369,578,048 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 392 | java | package uninfz.ifrozet.ma.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import uninfz.ifrozet.ma.beans.Dim_categorie;
@Repository
public interface Dim_categorieDao extends JpaRepository<Dim_categorie, Long> {
public Dim_categorie findByName(String ref);
public int deleteByName(String ref);
}
| [
"[email protected]"
] | |
20cf6d7e28119312dcf0cee7776c875a3c8297f9 | 337b0fa86fbd56bc08fdc2830ba3caed54f2aa16 | /src/main/java/com/company/KWICException.java | fdbc4671f94eb9fb17d729b2e7054c30b9e43694 | [] | no_license | tomasjos/KWIC | f7027327662a69a7ca86e099e73733034fdc3fd3 | a3d2f6307ad2ba43647db7def035eb83fe2bb857 | refs/heads/master | 2021-02-04T03:42:18.738069 | 2020-03-09T22:59:52 | 2020-03-09T22:59:52 | 243,612,893 | 0 | 0 | null | 2020-10-13T19:54:55 | 2020-02-27T20:43:06 | Java | UTF-8 | Java | false | false | 390 | java | package com.company;
// generamos una clase KWICException derivada de RunTimeException, que se empleará en aquellas operaciones
// en las que haya que trabajar con elementos de la clase TituloKWIC
public class KWICException extends RuntimeException {
public KWICException(){
super("Error. ");
}
public KWICException(String msg){
super("Error. "+msg);
}
}
| [
"[email protected]"
] | |
8d85e4f7c8832ce3875494e1fb8fac73d21d4005 | dbf10a48149e028403eb8f5e3b9225464d045eb5 | /src/main/java/com/crud/demo/entity/Thuthu.java | cfdc4fc9eacafaf3223b4a83499a00db4536d1af | [] | no_license | vumanhducnd/DemoSpringboot-mysql | a4b46d15bfe56dbee38d8112cd01f1d6eeb3b78a | d659da118903b4072678b24ccb9a5185483db9e3 | refs/heads/master | 2022-12-20T01:10:55.958094 | 2020-07-29T07:15:12 | 2020-07-29T07:15:12 | 283,425,685 | 0 | 0 | null | 2022-12-10T06:06:35 | 2020-07-29T07:08:44 | Java | UTF-8 | Java | false | false | 563 | java | package com.crud.demo.entity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;
@Data
@Entity
public class Thuthu implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String hoten;
private String gioitinh;
private String email;
private String diachi;
private String sdt;
}
| [
"[email protected]"
] | |
c2354f72d3b14c87143e50a0f2d9305455cf6387 | 9f5a74ab2a271633bff36c6fc9be8d53dfe0a8ab | /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/hardware/minibot/Pusher.java | 1b52ad4e15a7b2a7eb5e3c177a226a69bb1e69c4 | [
"BSD-3-Clause"
] | permissive | kunhantsai/FtcRobotController | e8357b9f234a8426206197e03c125f1e099baff1 | 4ba802b4f51a74fe5dce77e935933fdd99bef53d | refs/heads/master | 2023-07-23T14:38:15.360660 | 2021-08-20T22:04:07 | 2021-08-20T22:04:07 | 389,491,292 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 820 | java | package org.firstinspires.ftc.teamcode.hardware.minibot;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
public class Pusher {
Servo pusher;
final Core core;
final static double PUSHER_INIT = 0.63;
final static double PUSHER_UP = 0.78;
final static double PUSHER_DOWN = 0.44;
public Pusher(Core c) {
core = c;
}
public void init(HardwareMap hwMap) {
pusher = hwMap.servo.get("sv_r_kicker"); // should be pusher, not sv_r_pusher
pusher.setPosition(PUSHER_INIT);
}
/***
* moves pusher up
*/
public void pusher_up() {
pusher.setPosition(PUSHER_UP);
}
/***
* moves pusher down
*/
public void pusher_down() {
pusher.setPosition(PUSHER_DOWN);
}
}
| [
"[email protected]"
] | |
1bb446df06f5b70cf92cd14ab6edbc759ce928af | 69040d2ad1b09341df198deb4822fde814eccd52 | /src/main/java/RingOfDestiny/summon/NullSummon.java | 8c76ed3ec97389879898d247a9024bc018286fef | [] | no_license | Rita-Bernstein/RingOfDestiny | 69feecf461541ed2c585c181c6dde6a16d39af52 | 788da2b2d11c2393288506b3e04e6d5da1a16949 | refs/heads/master | 2023-07-16T20:56:30.160192 | 2021-08-31T17:16:55 | 2021-08-31T17:16:55 | 343,334,965 | 3 | 3 | null | 2021-05-24T08:28:52 | 2021-03-01T08:01:25 | Java | UTF-8 | Java | false | false | 1,132 | java | package RingOfDestiny.summon;
import RingOfDestiny.RingOfDestiny;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.esotericsoftware.spine.*;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.Hitbox;
import com.megacrit.cardcrawl.vfx.TintEffect;
import static com.megacrit.cardcrawl.core.AbstractCreature.sr;
public class NullSummon extends AbstractSummon {
public static final String ID = RingOfDestiny.makeID("NullSummon");
public NullSummon() {
super(ID);
this.hb_x = 0.0f * Settings.scale;
this.hb_y = 0.0f * Settings.scale;
this.hb_w = 160.0f;
this.hb_h = 160.0f;
this.hb = new Hitbox(this.hb_w, this.hb_h);
}
@Override
public void attackAnimation() {
}
@Override
public void randomAttack(int amount) {
}
@Override
public void onSacrifice() {
}
}
| [
"[email protected]"
] | |
f7c611865842c7d111f97a66d876d93f651c59d6 | 920a44384fefb0af3c847607cb08de77b549cd3d | /chapter_002/src/main/java/ru/job4j/search/Task.java | 95565916dd8c9b85589a1cf3cae004262232f762 | [
"Apache-2.0"
] | permissive | Layton85/akordyukov | 2c1a9834986af026abd936472364cde5eeaccdce | 015ed8b0178d0e2416e45446f4096bc55ca6aae0 | refs/heads/master | 2021-05-11T14:26:08.162222 | 2020-04-30T04:16:00 | 2020-04-30T04:16:00 | 117,702,196 | 0 | 0 | Apache-2.0 | 2020-10-12T20:11:44 | 2018-01-16T15:32:01 | Java | UTF-8 | Java | false | false | 799 | java | package ru.job4j.search;
/**
* Task - class holds information about some task with some priority.
*
* @author Alexander Kordyukov ([email protected])
* @version $Id$
* @since 0.1
*/
public class Task {
/** Task description */
private String desc;
/** Task priority */
private int priority;
/**
* Constructor
* @param desc - Task description
* @param priority - Task priority
*/
public Task(String desc, int priority) {
this.desc = desc;
this.priority = priority;
}
/**
* Get-method
* @return - Task description
*/
public String getDesc() {
return desc;
}
/**
* Get-method
* @return - Task priority
*/
public int getPriority() {
return priority;
}
}
| [
"[email protected]"
] | |
b996c69cb31d31d0725f9b1497f3f086b6eb5108 | 7be89a287e793409da6df8f05571e6baee63e51f | /src/test/java/org/jitsi/jicofo/ParticipantTest.java | 78a752e357e8a6ff3ec2cf7f582d3bf0e8ecc5f5 | [
"Apache-2.0"
] | permissive | taotao0/jicofo | 6d6332b935f17e7e42e357d7bd881f8685d3609e | 237125bb170c55eeb7ff56202940778edf89182d | refs/heads/master | 2023-02-16T21:46:01.249971 | 2020-12-10T01:06:38 | 2020-12-10T01:06:38 | 294,305,977 | 0 | 0 | Apache-2.0 | 2020-09-10T04:49:32 | 2020-09-10T04:49:31 | null | UTF-8 | Java | false | false | 3,356 | java | /*
* Jicofo, the Jitsi Conference Focus.
*
* Copyright @ 2018 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.jicofo;
import mock.muc.*;
import org.junit.*;
import org.junit.runner.*;
import org.junit.runners.*;
import org.jxmpp.jid.impl.*;
import org.jxmpp.stringprep.*;
import java.time.*;
import static org.junit.Assert.*;
@RunWith(JUnit4.class)
public class ParticipantTest
{
@Test
public void testRestartReqRateLimiting()
throws XmppStringprepException
{
Participant p = new Participant(
new MockJitsiMeetConference(),
new MockRoomMember(JidCreate.entityFullFrom("[email protected]/1234"), null),
0);
p.setClock(Clock.fixed(Instant.now(), ZoneId.systemDefault()));
assertTrue("should allow 1st request", p.incrementAndCheckRestartRequests());
assertFalse("should not allow next request immediately", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(5)));
assertFalse("should not allow next request after 5 seconds", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(6)));
assertTrue("should allow 2nd request after 11 seconds", p.incrementAndCheckRestartRequests());
assertFalse("should not allow 3rd request after 11 seconds", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(10)));
assertTrue("should allow 3rd request after 21 seconds", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(11)));
assertFalse("should not allow more than 3 request within the last minute (31 second)", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(10)));
assertFalse("should not allow more than 3 request within the last minute (41 second)", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(10)));
assertFalse("should not allow more than 3 request within the last minute (51 second)", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(10)));
assertTrue("should allow the 4th request after 60 seconds have passed since the 1st (61 second)", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(5)));
assertFalse("should not allow the 5th request in 66th second", p.incrementAndCheckRestartRequests());
p.setClock(Clock.offset(p.getClock(), Duration.ofSeconds(5)));
assertTrue("should allow the 5th request in 71st second", p.incrementAndCheckRestartRequests());
}
}
| [
"[email protected]"
] | |
1447ba78337b5fec59672e9eb840e7e543d9d1af | 09eac36b250bd87e6e7ea1469836f09302b287d9 | /androidgauge/src/test/kotlin/com/lbbento/pitchuptunergauge/ExampleUnitTest.java | 25ae47493f833664b818c1c313a3bbd21e6a86b1 | [
"Apache-2.0"
] | permissive | foquanlin/pitchup | 3a2ee90a153c6119404ffa910eb050f780f5dc0e | 90dcd5af9b622baaf9f961c434096e2e9628661b | refs/heads/master | 2020-04-17T17:43:27.156896 | 2017-06-27T07:37:07 | 2017-06-27T07:37:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 418 | java | package com.lbbento.pitchuptunergauge;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
f0baaa32744e337c50702442a2f5ec1902a378c2 | ccb80fd76f16884ab6c3b28998a3526ac38ec321 | /ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/ae/DefaultJCasTermAnnotator.java | b8cfe837b0a329c597db23f2ffcbb8da22828b60 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | apache/ctakes | 5d5c35a7c8c906e21d52488396adeb40ebd7034e | def3dea5602945dfbec260d4faaabfbc0a2a2ad4 | refs/heads/main | 2023-07-02T18:28:53.754174 | 2023-05-18T00:00:51 | 2023-05-18T00:00:51 | 26,951,043 | 97 | 77 | Apache-2.0 | 2022-10-18T23:28:24 | 2014-11-21T08:00:09 | Java | UTF-8 | Java | false | false | 5,781 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ctakes.dictionary.lookup2.ae;
import org.apache.ctakes.core.config.ConfigParameterConstants;
import org.apache.ctakes.core.pipeline.PipeBitInfo;
import org.apache.ctakes.core.util.collection.CollectionMap;
import org.apache.ctakes.dictionary.lookup2.dictionary.RareWordDictionary;
import org.apache.ctakes.dictionary.lookup2.term.RareWordTerm;
import org.apache.ctakes.dictionary.lookup2.textspan.DefaultTextSpan;
import org.apache.ctakes.dictionary.lookup2.textspan.TextSpan;
import org.apache.ctakes.dictionary.lookup2.util.FastLookupToken;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.resource.ResourceInitializationException;
import java.util.Collection;
import java.util.List;
/**
* A direct string match using phrase permutations
* Author: SPF
* Affiliation: CHIP-NLP
* Date: 11/19/13
*/
@PipeBitInfo(
name = "Dictionary Lookup (Default)",
description = "Annotates clinically-relevant terms. Terms must match dictionary entries exactly.",
dependencies = { PipeBitInfo.TypeProduct.SENTENCE, PipeBitInfo.TypeProduct.BASE_TOKEN },
products = PipeBitInfo.TypeProduct.IDENTIFIED_ANNOTATION
)
public class DefaultJCasTermAnnotator extends AbstractJCasTermAnnotator {
/**
* {@inheritDoc}
*/
@Override
public void findTerms( final RareWordDictionary dictionary,
final List<FastLookupToken> allTokens,
final List<Integer> lookupTokenIndices,
final CollectionMap<TextSpan, Long, ? extends Collection<Long>> termsFromDictionary ) {
Collection<RareWordTerm> rareWordHits;
for ( Integer lookupTokenIndex : lookupTokenIndices ) {
final FastLookupToken lookupToken = allTokens.get( lookupTokenIndex );
rareWordHits = dictionary.getRareWordHits( lookupToken );
if ( rareWordHits == null || rareWordHits.isEmpty() ) {
continue;
}
for ( RareWordTerm rareWordHit : rareWordHits ) {
if ( rareWordHit.getText().length() < _minimumLookupSpan ) {
continue;
}
if ( rareWordHit.getTokenCount() == 1 ) {
// Single word term, add and move on
termsFromDictionary.placeValue( lookupToken.getTextSpan(), rareWordHit.getCuiCode() );
continue;
}
final int termStartIndex = lookupTokenIndex - rareWordHit.getRareWordIndex();
if ( termStartIndex < 0 || termStartIndex + rareWordHit.getTokenCount() > allTokens.size() ) {
// term will extend beyond window
continue;
}
final int termEndIndex = termStartIndex + rareWordHit.getTokenCount() - 1;
if ( isTermMatch( rareWordHit, allTokens, termStartIndex, termEndIndex ) ) {
final int spanStart = allTokens.get( termStartIndex ).getStart();
final int spanEnd = allTokens.get( termEndIndex ).getEnd();
termsFromDictionary.placeValue( new DefaultTextSpan( spanStart, spanEnd ), rareWordHit.getCuiCode() );
}
}
}
}
/**
* Hopefully the jit will inline this method
*
* @param rareWordHit rare word term to check for match
* @param allTokens all tokens in a window
* @param termStartIndex index of first token in allTokens to check
* @param termEndIndex index of last token in allTokens to check
* @return true if the rare word term exists in allTokens within the given indices
*/
public static boolean isTermMatch( final RareWordTerm rareWordHit, final List<FastLookupToken> allTokens,
final int termStartIndex, final int termEndIndex ) {
final String[] hitTokens = rareWordHit.getTokens();
int hit = 0;
for ( int i = termStartIndex; i < termEndIndex + 1; i++ ) {
if ( hitTokens[ hit ].equals( allTokens.get( i ).getText() )
|| hitTokens[ hit ].equals( allTokens.get( i ).getVariant() ) ) {
// the normal token or variant matched, move to the next token
hit++;
continue;
}
// the token normal didn't match and there is no matching variant
return false;
}
// some combination of token and variant matched
return true;
}
static public AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException {
return AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class );
}
static public AnalysisEngineDescription createAnnotatorDescription( final String descriptorPath )
throws ResourceInitializationException {
return AnalysisEngineFactory.createEngineDescription( DefaultJCasTermAnnotator.class,
ConfigParameterConstants.PARAM_LOOKUP_XML, descriptorPath );
}
}
| [
"[email protected]"
] | |
c1017525f80854b640dd32e21ac654dc04826974 | 31188bb11a663dad91d7e887fa2b9b38bef862bf | /SegundoSemestre2/MateriaLinguagemProgramação-Eclipse/1o etapa do segundo semestre/Ativ2/ProjetoDeTelefone/src/Ativ1/Adolescente.java | 1b2136819eeaf1c4ba9bb025179211583d1c8dc1 | [] | no_license | samuelmqi/AtividadesDaFacul | 03a64a13e86ca0296f758be39c44ab3d1d9f7a64 | d61657efbf5eb6cb3f83375829af32db699b87e1 | refs/heads/master | 2023-07-01T15:30:16.956697 | 2021-08-04T18:03:31 | 2021-08-04T18:03:31 | 392,784,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 530 | java | package Ativ1;
public class Adolescente {
public static void main(String[] args) {
//objetos tel 1 e tel 2:
Telefone tel1 = new Telefone();
Telefone tel2 = new Telefone();
//caracteristicas
tel1.marca = "YPhone";
tel1.cor = "Prata";
/*Segunda maneira para usar o parametro Ligar:
* String nome = "Matheus";
* tel1.Ligar(nome);
*/
tel1.Ligar("Matheus");//como eu vou ligar usando o parametro
tel1.TocarMusica();
tel2.marca = "S10";
tel2.cor = "Preta";
tel2.Ligar("Maria");
tel2.TocarMusica();
}
}
| [
"[email protected]"
] | |
c881c0be56fc46387d0f04ed72b7bdfbb1ca7eb5 | 4f5fba847b4b074b26a5ec071714d7f13ef110e0 | /JEE6/org.jeegen.jee6.util/src/test/java/org/jeegen/jee6/test/sorter/GermanSorter.java | af928236c7dddb7dd726ad4ace345ab8630860cb | [] | no_license | DominikPieper/JEE-Generator | e82650ae2285a45e769cdd88245328a51f8e11da | 1c1a8849b2fa0c75fe6ac7b435e8974624c7ff59 | refs/heads/master | 2021-06-17T14:04:56.577550 | 2017-06-11T11:43:16 | 2017-06-11T11:43:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 455 | java | /*
* $Id$
*/
package org.jeegen.jee6.test.sorter;
import java.text.Collator;
import java.util.Locale;
import org.jeegen.jee6.util.CollatingComparator;
public class GermanSorter extends CollatingComparator<String>
{
private static final long serialVersionUID = 1L;
public GermanSorter()
{
super(ASC, Locale.GERMAN, Collator.SECONDARY);
}
@Override
protected int compareLocale(String v1, String v2)
{
return collator.compare(v1, v2);
}
}
| [
"[email protected]"
] | |
dc3b63c375e08d2f10829481a4cade3d5e5c36da | 04b0086552fad6a6f207ccb3223962acffbd16cd | /expressui-core/src/main/java/com/expressui/core/util/MathUtil.java | 218a66e2b46dd2ae1cae18876b9920b498677432 | [] | no_license | iamsowmyan/expressui-framework | 1673664036569062109729b63a6e1ec6bb1c8864 | 354fce9d66b314fdaca75e1b1de3575721e812a4 | refs/heads/master | 2020-12-06T19:09:40.955212 | 2012-08-18T08:40:13 | 2012-08-18T08:40:13 | 43,866,663 | 1 | 0 | null | 2015-10-08T06:14:41 | 2015-10-08T06:14:41 | null | UTF-8 | Java | false | false | 3,327 | java | /*
* Copyright (c) 2012 Brown Bag Consulting.
* This file is part of the ExpressUI project.
* Author: Juan Osuna
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License Version 3
* as published by the Free Software Foundation with the addition of the
* following permission added to Section 15 as permitted in Section 7(a):
* FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
* Brown Bag Consulting, Brown Bag Consulting DISCLAIMS THE WARRANTY OF
* NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License.
*
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the ExpressUI software without
* disclosing the source code of your own applications. These activities
* include: offering paid services to customers as an ASP, providing
* services from a web application, shipping ExpressUI with a closed
* source product.
*
* For more information, please contact Brown Bag Consulting at this
* address: [email protected].
*/
package com.expressui.core.util;
/**
* Utility class for managing Math operations.
*/
public class MathUtil {
/**
* Gets the maximum integer, ignoring if one arg is null.
*
* @param a first integer
* @param b second integer
* @return maximum integer
*/
public static Integer maxIgnoreNull(Integer a, Integer b) {
if (a == null) return b;
if (b == null) return a;
return Math.max(a, b);
}
/**
* Gets the minimum integer, ignoring if one arg is null.
*
* @param a first integer
* @param b second integer
* @return minimum integer
*/
public static Integer minIgnoreNull(Integer a, Integer b) {
if (a == null) return b;
if (b == null) return a;
return Math.min(a, b);
}
/**
* Gets the maximum integer, returning null if any arg is null.
*
* @param a first integer
* @param b second integer
* @return maximum integer, or null if any arg is null
*/
public static Integer maxDisallowNull(Integer a, Integer b) {
if (a == null || b == null) return null;
return Math.max(a, b);
}
/**
* Get the minimum integer, returning null if any arg is null
*
* @param a first integer
* @param b second integer
* @return minimum integer, or null if any arg is null
*/
public static Integer minDisallowNull(Integer a, Integer b) {
if (a == null || b == null) return null;
return Math.min(a, b);
}
}
| [
"[email protected]"
] | |
0b9ebd041d4a3bf0af1b03d61d001570cb59c33f | 03bb847c85c8a2ef94606302fe28fde4182e21ae | /moduleCore/src/main/java/com/thanhhai/demo/dto/UserDto.java | 029126b9ef277aee0b72e05bad3cea3eb910487d | [] | no_license | thanhhaibkit/spring-boot-vuejs | 08ae0ab1a27f9351900a3ff7f4e2021ce0e34bc5 | 31b6def4e984ceb479d740a8e31946b8d91b242c | refs/heads/main | 2023-03-30T10:52:21.698941 | 2021-04-01T10:43:24 | 2021-04-01T10:43:24 | 353,288,830 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,485 | java | package com.thanhhai.demo.dto;
import com.thanhhai.demo.entity.User;
import com.thanhhai.demo.enums.ERole;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
private Long userId;
private String username;
private String password;
private String lastname;
private String firstname;
private String emailAddress;
private String phoneNumber;
private Long createdBy;
private Long updatedBy;
private ERole role;
public User toEntity() {
User entity = new User();
entity.setUsername(this.getUsername());
entity.setPassword(this.getPassword());
entity.setLastName(this.getLastname());
entity.setFirstName(this.getFirstname());
entity.setEmailAddress(this.getEmailAddress());
entity.setPhoneNumber(this.getPhoneNumber());
return entity;
}
public static UserDto from(final User user) {
if (user == null) {
return null;
}
return UserDto.builder()
.userId(user.getId())
.username(user.getUsername())
.lastname(user.getLastName())
.firstname(user.getFirstName())
.emailAddress(user.getEmailAddress())
.phoneNumber(user.getPhoneNumber())
.build();
}
}
| [
"[email protected]"
] | |
ed2286fd020cb624fcddf0478db09d23c6b0a7c0 | bc5e9310c5fe3752862d6ed91a4a2c4aa3e720ce | /core/src/main/java/com/dpwallet/core/network/AddressStatus.java | f8f48801010bee87543994cccdc67eb88d20065b | [] | no_license | dev2060/android_wallet_dpcurrency | 85ab6f27de1eccaf32e567757c7ed5199cfb1319 | 1ee8d3ca68d5bccb3d0b4da5ae5dbf555cf38592 | refs/heads/master | 2020-05-30T00:53:43.512783 | 2019-05-31T11:31:56 | 2019-05-31T11:31:56 | 189,466,631 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,364 | java | package com.dpwallet.core.network;
import com.dpwallet.core.network.ServerClient.HistoryTx;
import com.dpwallet.core.network.ServerClient.UnspentTx;
import com.dpwallet.core.wallet.AbstractAddress;
import com.google.common.collect.Sets;
import org.bitcoinj.core.Sha256Hash;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
/**
* @author John L. Jegutanis
*/
final public class AddressStatus {
final AbstractAddress address;
@Nullable final String status;
HashSet<HistoryTx> historyTransactions;
HashSet<UnspentTx> unspentTransactions;
HashSet<Sha256Hash> historyTxHashes = new HashSet<>();
HashSet<Sha256Hash> unspentTxHashes = new HashSet<>();
boolean stateMustBeApplied;
boolean historyTxStateApplied;
boolean unspentTxStateApplied;
public AddressStatus(AbstractAddress address, @Nullable String status) {
this.address = address;
this.status = status;
}
public AbstractAddress getAddress() {
return address;
}
@Nullable public String getStatus() {
return status;
}
/**
* Queue transactions that are going to be fetched
*/
public void queueHistoryTransactions(List<HistoryTx> txs) {
if (historyTransactions == null) {
historyTransactions = Sets.newHashSet(txs);
historyTxHashes = fillTransactions(txs);
stateMustBeApplied = true;
}
}
/**
* Queue transactions that are going to be fetched
*/
public void queueUnspentTransactions(List<UnspentTx> txs) {
if (unspentTransactions == null) {
unspentTransactions = Sets.newHashSet(txs);
unspentTxHashes = fillTransactions(txs);
stateMustBeApplied = true;
}
}
private HashSet<Sha256Hash> fillTransactions(Iterable<? extends HistoryTx> txs) {
HashSet<Sha256Hash> transactionHashes = new HashSet<>();
for (HistoryTx tx : txs) {
transactionHashes.add(tx.getTxHash());
}
return transactionHashes;
}
/**
* Return true if history transactions are queued
*/
public boolean isHistoryTxQueued() {
return historyTransactions != null;
}
/**
* Return true if unspent transactions are queued
*/
public boolean isUnspentTxQueued() {
return unspentTransactions != null;
}
/**
* Get queued history transactions
*/
public Set<Sha256Hash> getHistoryTxHashes() {
return historyTxHashes;
}
/**
* Get queued unspent transactions
*/
public Set<Sha256Hash> getUnspentTxHashes() {
return unspentTxHashes;
}
/**
* Get history transactions info
*/
public HashSet<HistoryTx> getHistoryTxs() {
return historyTransactions;
}
/**
* Get unspent transactions info
*/
public HashSet<UnspentTx> getUnspentTxs() {
return unspentTransactions;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AddressStatus status1 = (AddressStatus) o;
if (!address.equals(status1.address)) return false;
if (status != null ? !status.equals(status1.status) : status1.status != null) return false;
return true;
}
@Override
public int hashCode() {
int result = address.hashCode();
result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "{" +
"address=" + address +
", status='" + status + '\'' +
'}';
}
public boolean isHistoryTxStateApplied() {
return historyTxStateApplied;
}
public void setHistoryTxStateApplied(boolean historyTxStateApplied) {
this.historyTxStateApplied = historyTxStateApplied;
}
public boolean isUnspentTxStateApplied() {
return unspentTxStateApplied;
}
public void setUnspentTxStateApplied(boolean unspentTxStateApplied) {
this.unspentTxStateApplied = unspentTxStateApplied;
}
public boolean canCommitStatus() {
return !stateMustBeApplied || historyTxStateApplied && unspentTxStateApplied;
}
}
| [
"[email protected]"
] | |
b89af7b312cd89bc960a3d813aa62b59a28660cb | c69459418864e090a348c7c458f432009483fd8b | /org.xtext.univ.nantes.master.dsl/src-gen/org/xtext/univ/nantes/master/dsl/AbstractAgendaRuntimeModule.java | 114b6b2e94c3052f31ac6f1418974cf50f2233d1 | [] | no_license | PineauSullivan/DSL | 5a1ba6b0c5e4766448c60d5497331a498fc01220 | e1f4a175ed2da6d21aca8298a1706b5192c4142d | refs/heads/master | 2021-08-30T12:28:03.945969 | 2017-12-17T23:55:28 | 2017-12-17T23:55:28 | 114,465,044 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,744 | java | /*
* generated by Xtext 2.10.0
*/
package org.xtext.univ.nantes.master.dsl;
import com.google.inject.Binder;
import com.google.inject.Provider;
import com.google.inject.name.Names;
import java.util.Properties;
import org.eclipse.xtext.Constants;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.generator.IGenerator2;
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.parser.IParser;
import org.eclipse.xtext.parser.ITokenToStringConverter;
import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider;
import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter;
import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider;
import org.eclipse.xtext.parser.antlr.ITokenDefProvider;
import org.eclipse.xtext.parser.antlr.Lexer;
import org.eclipse.xtext.parser.antlr.LexerBindings;
import org.eclipse.xtext.parser.antlr.LexerProvider;
import org.eclipse.xtext.resource.IContainer;
import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.resource.containers.IAllContainersState;
import org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider;
import org.eclipse.xtext.resource.containers.StateBasedContainerManager;
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
import org.eclipse.xtext.scoping.IGlobalScopeProvider;
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.scoping.IgnoreCaseLinking;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider;
import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider;
import org.eclipse.xtext.serializer.ISerializer;
import org.eclipse.xtext.serializer.impl.Serializer;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer;
import org.eclipse.xtext.service.DefaultRuntimeModule;
import org.eclipse.xtext.service.SingletonBinding;
import org.xtext.univ.nantes.master.dsl.generator.AgendaGenerator;
import org.xtext.univ.nantes.master.dsl.parser.antlr.AgendaAntlrTokenFileProvider;
import org.xtext.univ.nantes.master.dsl.parser.antlr.AgendaParser;
import org.xtext.univ.nantes.master.dsl.parser.antlr.internal.InternalAgendaLexer;
import org.xtext.univ.nantes.master.dsl.scoping.AgendaScopeProvider;
import org.xtext.univ.nantes.master.dsl.serializer.AgendaSemanticSequencer;
import org.xtext.univ.nantes.master.dsl.serializer.AgendaSyntacticSequencer;
import org.xtext.univ.nantes.master.dsl.services.AgendaGrammarAccess;
import org.xtext.univ.nantes.master.dsl.validation.AgendaValidator;
/**
* Manual modifications go to {@link AgendaRuntimeModule}.
*/
@SuppressWarnings("all")
public abstract class AbstractAgendaRuntimeModule extends DefaultRuntimeModule {
protected Properties properties = null;
@Override
public void configure(Binder binder) {
properties = tryBindProperties(binder, "org/xtext/univ/nantes/master/dsl/Agenda.properties");
super.configure(binder);
}
public void configureLanguageName(Binder binder) {
binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.xtext.univ.nantes.master.dsl.Agenda");
}
public void configureFileExtensions(Binder binder) {
if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)
binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("agenda");
}
// contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2
public ClassLoader bindClassLoaderToInstance() {
return getClass().getClassLoader();
}
// contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2
public Class<? extends IGrammarAccess> bindIGrammarAccess() {
return AgendaGrammarAccess.class;
}
// contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2
public Class<? extends ISemanticSequencer> bindISemanticSequencer() {
return AgendaSemanticSequencer.class;
}
// contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2
public Class<? extends ISyntacticSequencer> bindISyntacticSequencer() {
return AgendaSyntacticSequencer.class;
}
// contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2
public Class<? extends ISerializer> bindISerializer() {
return Serializer.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Class<? extends IParser> bindIParser() {
return AgendaParser.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Class<? extends ITokenToStringConverter> bindITokenToStringConverter() {
return AntlrTokenToStringConverter.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Class<? extends IAntlrTokenFileProvider> bindIAntlrTokenFileProvider() {
return AgendaAntlrTokenFileProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Class<? extends Lexer> bindLexer() {
return InternalAgendaLexer.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Class<? extends ITokenDefProvider> bindITokenDefProvider() {
return AntlrTokenDefProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public Provider<InternalAgendaLexer> provideInternalAgendaLexer() {
return LexerProvider.create(InternalAgendaLexer.class);
}
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
public void configureRuntimeLexer(Binder binder) {
binder.bind(Lexer.class)
.annotatedWith(Names.named(LexerBindings.RUNTIME))
.to(InternalAgendaLexer.class);
}
// contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2
@SingletonBinding(eager=true)
public Class<? extends AgendaValidator> bindAgendaValidator() {
return AgendaValidator.class;
}
// contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2
public Class<? extends IScopeProvider> bindIScopeProvider() {
return AgendaScopeProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2
public void configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
// contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2
public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
return DefaultGlobalScopeProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2
public void configureIgnoreCaseLinking(Binder binder) {
binder.bindConstant().annotatedWith(IgnoreCaseLinking.class).to(false);
}
// contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return DefaultDeclarativeQualifiedNameProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2
public Class<? extends IContainer.Manager> bindIContainer$Manager() {
return StateBasedContainerManager.class;
}
// contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2
public Class<? extends IAllContainersState.Provider> bindIAllContainersState$Provider() {
return ResourceSetBasedAllContainersStateProvider.class;
}
// contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2
public void configureIResourceDescriptions(Binder binder) {
binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class);
}
// contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2
public void configureIResourceDescriptionsPersisted(Binder binder) {
binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class);
}
// contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2
public Class<? extends IGenerator2> bindIGenerator2() {
return AgendaGenerator.class;
}
}
| [
"[email protected]"
] | |
c5f86e43ea7d00da98e92c88e5b3b59ec397a478 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/23/23_1dd588a5711e2c9d53a10008b64ef29a30c125ec/Generate/23_1dd588a5711e2c9d53a10008b64ef29a30c125ec_Generate_t.java | 4518584cb6cffb2b88168fc8f90fdf674f7924e8 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 7,681 | java | /**
*
* Copyright 2010, Lawrence McAlpin.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package play.modules.scaffold;
import java.io.File;
import java.util.List;
import javax.persistence.GeneratedValue;
import play.Logger;
import play.Play;
import play.i18n.MessagesPlugin;
import play.modules.scaffold.entity.Entity;
import play.modules.scaffold.entity.PersistenceStrategy;
import play.modules.scaffold.generator.DatabaseAccessScaffolding;
import play.modules.scaffold.generator.ScaffoldingGenerator;
import play.modules.scaffold.utils.Fields;
/**
* Processes the scaffold:gen command. This command generates the scaffolding
* for a project, creating a rudimentary Application.index template, layout, and
* basic CRUD screens.
*
* @author Lawrence McAlpin
*/
public class Generate {
private static final String EXCLUDE = "--exclude";
private static final String INCLUDE = "--include";
private static final String OVERWRITE = "--overwrite";
private static final String WITH_LAYOUT = "--with-layout";
private static final String WITH_LOGIN = "--with-login";
private static final String ALL = "--all";
private static final String INVALID_MODELPATTERN = "Invalid pattern, provide a text string with optional '*' wildcard";
public static void main(String[] args) throws Exception {
// initialize Play!
File root = new File(System.getProperty("application.path"));
Play.init(root, System.getProperty("play.id", ""));
Thread.currentThread().setContextClassLoader(Play.classloader);
MessagesPlugin plugin = new MessagesPlugin();
plugin.onApplicationStart();
// default options
boolean forceOverwrite = false;
String includeRegEx = null;
String excludeRegEx = null;
boolean includeLayout = false;
boolean includeLogin = false;
// interpret command line arguments
String gettingArgumentsForCommand = null;
for (String arg : args) {
if (gettingArgumentsForCommand != null) {
if (gettingArgumentsForCommand.equalsIgnoreCase(INCLUDE)) {
gettingArgumentsForCommand = INCLUDE;
if (arg.isEmpty()) {
Logger.warn(INCLUDE + ": " + INVALID_MODELPATTERN);
System.exit(-1);
}
includeRegEx = arg;
Logger.info("--include: Including files that match: %s",
includeRegEx);
} else if (gettingArgumentsForCommand.equalsIgnoreCase(EXCLUDE)) {
gettingArgumentsForCommand = EXCLUDE;
if (arg.isEmpty()) {
Logger.warn(EXCLUDE + ": " + INVALID_MODELPATTERN);
System.exit(-1);
}
excludeRegEx = arg;
Logger.info("--exclude: Skipping files that match: %s",
excludeRegEx);
}
gettingArgumentsForCommand = null;
continue;
}
String lowerArg = arg.toLowerCase();
if (arg.startsWith("--")) {
if (lowerArg.equals(OVERWRITE)) {
forceOverwrite = true;
Logger.info("--overwrite: We will force overwrite target files");
} else if (lowerArg.equalsIgnoreCase(INCLUDE)) {
gettingArgumentsForCommand = INCLUDE;
} else if (lowerArg.equalsIgnoreCase(EXCLUDE)) {
gettingArgumentsForCommand = EXCLUDE;
} else if (lowerArg.equalsIgnoreCase(WITH_LAYOUT)) {
includeLayout = true;
} else if (lowerArg.equalsIgnoreCase(WITH_LOGIN)) {
includeLogin = true;
} else if (lowerArg.equalsIgnoreCase(ALL)) {
forceOverwrite = true;
includeLayout = true;
includeLogin = true;
} else {
Logger.warn("Invalid argument: %s", arg);
System.exit(-1);
}
}
}
// validate flags
if (includeLogin) {
try {
Class.forName("controllers.Secure", false, Play.classloader);
} catch (ClassNotFoundException e) {
Logger.warn(" ! controllers.Secure could not be found");
Logger.warn(" ! check application.conf to ensure module.secure is imported");
includeLogin = false;
}
}
// Locate domain model classes that we can process.
// Currently, we only support classes that extend the
// play.db.jpa.Model or siena.Model classes.
List<Class> classes = Play.classloader.getAllClasses();
ScaffoldingGenerator generator = new ScaffoldingGenerator();
generator.setForceOverwrite(forceOverwrite);
generator.setIncludeLayout(includeLayout);
generator.setIncludeLogin(includeLogin);
for (Class clazz : classes) {
// If this model is of a supported type, queue it up
// so the ScaffoldGenerator will create its controller
// and views.
PersistenceStrategy persistenceStrategy = PersistenceStrategy.forModel(clazz);
if (persistenceStrategy != null) {
String simpleName = clazz.getSimpleName();
boolean includeEntity = false;
// by default, include all entities if no --include= value is
// specified
if (includeRegEx == null) {
includeEntity = true;
}
// if an --include= value is specified, include only the models
// that match
if (includeRegEx != null && match(simpleName, includeRegEx)) {
includeEntity = true;
}
// always exclude models that match the --exclude= parameter
if (excludeRegEx != null && match(simpleName, excludeRegEx)) {
includeEntity = false;
}
if (includeEntity) {
Entity entity = new Entity(clazz);
// validate known limitations
if (persistenceStrategy == PersistenceStrategy.PURE_JPA) {
String idField = entity.getIdField();
if (idField == null) {
Logger.warn("Can not process %s because it needs an @Id annotated column", simpleName);
continue;
}
if (!Fields.annotations(clazz, idField).contains(GeneratedValue.class)) {
Logger.warn("Can not process %s because key must be auto-generated (use @GeneratedValue)", simpleName);
continue;
}
}
// we appear to be good to go!
generator.addEntity(entity);
} else {
Logger.info("Skipping %s", simpleName);
}
}
}
generator.generate();
}
// Does simple matching: you can add an asterisk to match "any"
// text. Matching is case insensitive.
public static boolean match(String text, String pattern) {
String normalizedText = text.toLowerCase();
String normalizedPattern = pattern.toLowerCase();
String[] subsections = normalizedPattern.split("[\\*~]");
int section = 0;
for (String subsection : subsections) {
int idx = normalizedText.indexOf(subsection);
if (idx == -1) {
return false;
}
// if we don't start with a wildcard, the first matched section must be at index 0
if (section == 0 && (!(normalizedPattern.startsWith("*") || normalizedPattern.startsWith("~")))) {
if (idx != 0) {
return false;
}
}
// if we don't end with a wildcard, the first matched section must be at index 0
if (section == subsections.length-1 && (!(normalizedPattern.endsWith("*") || normalizedPattern.endsWith("~")))) {
if (!normalizedText.endsWith(subsection)) {
return false;
}
}
normalizedText = normalizedText
.substring(idx + subsection.length());
section++;
}
return true;
}
}
| [
"[email protected]"
] | |
4dedd9bdd4e626285534299e72f00aeee5e71d35 | 1ea2a3c339899879a207cd880afb59668b9966e2 | /第九周上课/src/dome/Grandparent.java | 48ff5390d749aa5f2650282a0edc0285c9993a67 | [] | no_license | MaoSonglin/My-Java-Code | 7b00d4aa162bf9d524ff4e861f4eaf0be5fffa4b | f95f3532e33f5612c69f718f893c704d93d11c17 | refs/heads/master | 2021-01-21T11:19:29.747352 | 2017-03-01T13:23:23 | 2017-03-01T13:23:23 | 83,557,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 224 | java | package dome;
public class Grandparent {
// public Grandparent(){
// System.out.println("grandparent created.");
// };
public Grandparent(String string){
System.out.println("GrandParent Created.String:"+string);
}
}
| [
"[email protected]"
] | |
e504aa8e26c87d0273cd8ddf28bc261af57b5f29 | b8e1b701ab679d58832719f26b03846c298a37ea | /Rotation/src/Example.java | 0b805e99c0fd4bd4e3894258b19adc4a6a218fd3 | [] | no_license | tummykung/approx_inference | 79df35ec02d9169b53cfcf966111dd46ff3daf59 | d87f9de12b2f4c38e7a83d3604636d15e1fae600 | refs/heads/master | 2021-01-25T05:21:45.515042 | 2015-03-23T23:45:17 | 2015-03-23T23:45:17 | 28,884,902 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 773 | java | public class Example {
protected int[] x;
protected int[] y;
public Example(int[] x, int[] y) {
this.x = x;
this.y = y;
}
public int[] getInput() {
return x;
}
public int[] getOutput() {
return y;
}
public void setInput(int[] x) {
this.x = x;
}
public void setOutput(int[] y) {
this.y = y;
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("input ");
for (int i = 0; i < x.length; i++) {
b.append(x[i]);
if (i < x.length - 1)
b.append(" ");
}
b.append("\n");
b.append("output ");
for (int i = 0; i < y.length; i++) {
b.append(y[i]);
if (i < y.length - 1)
b.append(" ");
}
return b.toString();
}
}
| [
"[email protected]"
] | |
490e5efa89b692214f7a717e98cd3491a828d382 | 9b133cc145f81f05a22645676443c5b45a5529d3 | /som-common/som-common-core/src/main/java/com/ebig/som/common/core/config/RestTemplateConfig.java | 258bc59edb140393c4fe945702a1615c13603294 | [] | no_license | YYnegative/som1.0 | 738a0149d7b25761c8fc0011b03f08f582306746 | 12c76fd57d0f5803182fa29d687ca486bbe2355f | refs/heads/master | 2020-12-14T21:04:06.308156 | 2020-01-19T08:45:38 | 2020-01-19T08:45:38 | 234,867,692 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 629 | java | package com.ebig.som.common.core.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* 类功能说明:RestTemplate配置类<br/>
* 类修改者:<br/>
* 修改日期:<br/>
* 修改说明:<br/>
* 公司名称:广东以大供应链管理有限公司 <br/>
* 作者:luorx <br/>
* 创建时间:2020年1月6日 下午7:09:03 <br/>
* 版本:V1.0 <br/>
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
| [
"[email protected]"
] | |
456785124786f67ed38a0841c73c860d723ac886 | 0617cd020cc007713a9cfd918fe77af666ef4767 | /src/main/java/chess/ChessBoard.java | d88837ad0b931d6890a411d0779392622adde173 | [] | no_license | errachete/Board-games-platform | b89a0800da6159ee7b2c658631302b3d85ea0c04 | 67af4e9bebaaddb739ed77cbd16cf9cd7f477d88 | refs/heads/master | 2021-01-23T15:04:28.975598 | 2017-06-06T12:18:30 | 2017-06-06T12:18:30 | 93,268,717 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,206 | java | package chess;
/**
* Represents a chess board.
* This is not the full state, only the board component.
* Uses a somewhat-efficient internal representation
* to speed up move generation. Using bit-boards would be much faster,
* but also a lot more work.
*/
public class ChessBoard {
/*
* internal representation:
* 12x12 = 144 bytes, with 8x8 board starting at 2,2 with
* 1 ... 6 white pieces (1=pawn, 6=king)
* 9 ... 14 black pieces (9=pawn, 14=king)
* 16 = empty (0x10)
* 32 = outside (0x20)
* this allows many bit-wise tricks to test certain positions,
* and having a 2-width border avoids checking for bounds.
*/
private byte[] board;
protected final static int DIM = 8;
protected static int BORDER = 2;
protected static int DIM_WITH_BORDERS = 2 + 8 + 2;
protected static final byte COLOR_MASK = 0x08;
public static final byte EMPTY = 0x10;
public static final byte OUTSIDE = 0x20;
protected static final byte NON_PIECE_MASK = COLOR_MASK | EMPTY | OUTSIDE;
private static final int[][] DIAGONALS = new int[][]{
{1, 1}, {-1, 1}, {1, -1}, {-1, -1}};
private static final int[][] ROWS_N_COLS = new int[][]{
{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
private static final int[][] KNIGHT_JUMPS = new int[][]{
{1, 2}, {1,-2}, {-1, 2}, {-1,-2},
{2, 1}, {2,-1}, {-2, 1}, {-2,-1}};
private static final int[][] DIAGONALS_ROWS_N_COLS = new int[][]{
{1, 1}, {-1, 1}, {1, -1}, {-1, -1},
{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
public static boolean white(byte p) {
return (p & NON_PIECE_MASK) == 0;
}
public static boolean black(byte p) {
return (p & NON_PIECE_MASK) == COLOR_MASK;
}
/**
* checks if a piece has a given turn
* @param p board-piece
* @param turn (WHITE=0 or BLACK=1)
* @return true if and only if piece is of same turn as indicated
*/
public static boolean sameTurn(byte p, int turn) {
return (p & NON_PIECE_MASK) == (turn << 3);
}
public static boolean outside(byte p) {
return p == OUTSIDE;
}
public static boolean empty(byte p) {
return p == EMPTY;
}
public static boolean friend(byte a, byte b) {
// assumes that a or b is non-empty, non-outside
return ((a ^ b) & NON_PIECE_MASK) == 0;
}
public static boolean enemy(byte a, byte b) {
// assumes that a or b is non-empty, non-outside
return ((a ^ b) & NON_PIECE_MASK) == COLOR_MASK;
}
public byte get(int row, int col) {
return board[(row+BORDER) * DIM_WITH_BORDERS + (col+BORDER)];
}
public byte set(int row, int col, byte p) {
return board[(row+BORDER) * DIM_WITH_BORDERS + (col+BORDER)] = p;
}
/**
* Initializes a chess-board with the pieces at their start positions.
*/
public ChessBoard() {
board = new byte[DIM_WITH_BORDERS * DIM_WITH_BORDERS];
// initialize outside-border and empty-center
for (int i=0; i<DIM_WITH_BORDERS; i++) {
for (int j=0; j<DIM_WITH_BORDERS; j++) {
board[i*DIM_WITH_BORDERS + j] =
(i<BORDER || i>=DIM+BORDER || j<BORDER || j>=DIM+BORDER) ?
OUTSIDE : EMPTY;
}
}
// lines of pawns
for (int i=0; i<DIM; i++) {
set(1, i, Piece.Pawn.black());
set(6, i, Piece.Pawn.white());
}
set(0, 0, Piece.Rook.black());
set(0, 7, Piece.Rook.black());
set(7, 0, Piece.Rook.white());
set(7, 7, Piece.Rook.white());
set(0, 1, Piece.Knight.black());
set(0, 6, Piece.Knight.black());
set(7, 1, Piece.Knight.white());
set(7, 6, Piece.Knight.white());
set(0, 2, Piece.Bishop.black());
set(0, 5, Piece.Bishop.black());
set(7, 2, Piece.Bishop.white());
set(7, 5, Piece.Bishop.white());
set(0, 3, Piece.Queen.black());
set(7, 3, Piece.Queen.white());
set(0, 4, Piece.King.black());
set(7, 4, Piece.King.white());
}
public ChessBoard(ChessBoard other) {
board = other.board.clone();
}
/**
* Symbolic pieces. Encapsulates most piece operations.
*/
public enum Piece {
Pawn(1, 'p', 1, null, false),
Knight(2, 'n', 3.5, KNIGHT_JUMPS, false),
Bishop(3, 'b', 3.5, DIAGONALS, true),
Rook(4, 'r', 5, ROWS_N_COLS, true),
Queen(5, 'q', 9, DIAGONALS_ROWS_N_COLS, true),
King(6, 'k', 100, DIAGONALS_ROWS_N_COLS, false),
Empty(EMPTY, '.', 0, null, false),
Outside(OUTSIDE, '?', 0, null, false);
private final byte id;
private final char symbol;
private final double value;
private int[][] deltas;
private boolean linear;
/**
* Returns icon-names for each piece.
* @param p (as obtained by ChessBoard.get())
* @return icon names such as "p_b.png" for a pawn that is black
*/
public static String iconName(byte p) {
return "" + valueOf(p).getSymbol(false) + "_"
+ (ChessBoard.black(p) ? "b" : "w") + ".png";
}
public byte white() { return id; }
public byte black() { return (byte)(id | COLOR_MASK); }
public byte forTurn(int turn) {
return turn == ChessState.WHITE ? white() : black();
}
public static Piece valueOf(byte pieceCode) {
switch (pieceCode) {
case 1: case 8+1: return Pawn;
case 2: case 8+2: return Knight;
case 3: case 8+3: return Bishop;
case 4: case 8+4: return Rook;
case 5: case 8+5: return Queen;
case 6: case 8+6: return King;
case EMPTY: return Empty;
default: return Outside;
}
}
public char getSymbol(boolean black) {
return black ? Character.toUpperCase(symbol) : symbol;
}
public static char symbolOf(byte p) {
return valueOf(p).getSymbol(ChessBoard.black(p));
}
public double getValue(boolean negative) {
return negative ? -1 * value : value;
}
public int[][] getDeltas() {
return deltas;
}
public boolean hasLinearMotion() {
return linear;
}
Piece(int id, char symbol, double value, int[][] deltas, boolean linear) {
this.id = (byte)id;
this.symbol = symbol;
this.value = value;
this.deltas = deltas;
this.linear = linear;
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i=0; i<DIM; i++) {
sb.append(" "+i);
}
sb.append("\n");
for (int i=0; i<DIM; i++) {
for (int j=0; j<DIM; j++) {
sb.append(' ').append(Piece.symbolOf(get(i, j)));
}
sb.append(" - " + i + "\n");
}
return sb.toString();
}
}
| [
"[email protected]"
] | |
f79f3f84e622da90635198e793b5e03d8beae4eb | b9858bec63a29b3088e581d771a2307e20d5658e | /src/main/java/cn/mljia/ddd/common/port/adapter/persistence/hibernate/HibernateEventStore.java | f5cfef8ff176ae85aaae6833d87e8ca8b6e0e2e6 | [] | no_license | darknessitachi/ddd-common | 45ffbb6a9eebf810800e005ac934a1a3185c2d5c | 6b7bd396c73f5e968b2f7fa1e0caaed9f03ba744 | refs/heads/master | 2020-12-30T18:02:12.874261 | 2017-04-14T06:37:05 | 2017-04-14T06:37:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,696 | java | // Copyright 2012,2013 Vaughn Vernon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cn.mljia.ddd.common.port.adapter.persistence.hibernate;
import java.util.List;
import org.hibernate.Query;
import cn.mljia.ddd.common.domain.model.DomainEvent;
import cn.mljia.ddd.common.event.EventSerializer;
import cn.mljia.ddd.common.event.EventStore;
import cn.mljia.ddd.common.event.StoredEvent;
import cn.mljia.ddd.common.persistence.PersistenceManagerProvider;
public class HibernateEventStore extends AbstractHibernateSession implements EventStore
{
private static final Integer LIMIT = 100;
private String trackerName;
public HibernateEventStore(PersistenceManagerProvider aPersistenceManagerProvider)
{
this();
if (!aPersistenceManagerProvider.hasHibernateSession())
{
throw new IllegalArgumentException("The PersistenceManagerProvider must have a Hibernate Session.");
}
this.setSession(aPersistenceManagerProvider.hibernateSession());
}
public HibernateEventStore()
{
super();
}
@Override
@SuppressWarnings("unchecked")
public List<StoredEvent> allStoredEventsBetween(long aLowStoredEventId, long aHighStoredEventId)
{
Query query =
this.session().createQuery("from StoredEvent as _obj_ "
+ "where _obj_.trackerName=? and _obj_.eventId between ? and ? " + "order by _obj_.eventId");
query.setParameter(0, this.trackerName());
query.setParameter(1, aLowStoredEventId);
query.setParameter(2, aHighStoredEventId);
List<StoredEvent> storedEvents = query.list();
return storedEvents;
}
@Override
@SuppressWarnings("unchecked")
public List<StoredEvent> allStoredEventsSince(long aStoredEventId)
{
Query query =
this.session().createQuery("from StoredEvent as _obj_ "
+ "where _obj_.trackerName=? and _obj_.eventId > ? " + "order by _obj_.eventId");
query.setParameter(0, this.trackerName());
query.setParameter(1, aStoredEventId);
query.setMaxResults(LIMIT); // 相当于sql语句中的查询数量
query.setFirstResult(0); // 相当于sql语句中的开始索引
List<StoredEvent> storedEvents = query.list();
return storedEvents;
}
@Override
@SuppressWarnings("unchecked")
public List<StoredEvent> allStoredEventsSince(long aStoredEventId, String trackerName)
{
Query query =
this.session().createQuery("from StoredEvent as _obj_ "
+ "where _obj_.trackerName=? and _obj_.eventId > ? " + "order by _obj_.eventId");
query.setParameter(0, trackerName);
query.setParameter(1, aStoredEventId);
query.setMaxResults(LIMIT); // 相当于sql语句中的查询数量
query.setFirstResult(0); // 相当于sql语句中的开始索引
List<StoredEvent> storedEvents = query.list();
return storedEvents;
}
@Override
public StoredEvent append(DomainEvent aDomainEvent)
{
String eventSerialization = EventSerializer.instance().serialize(aDomainEvent);
StoredEvent storedEvent =
new StoredEvent(aDomainEvent.getClass().getName(), aDomainEvent.getClass().getName(),
aDomainEvent.occurredOn(), eventSerialization);
this.session().save(storedEvent);
return storedEvent;
}
@Override
public void close()
{
// no-op
}
@Override
public long countStoredEvents()
{
Query query = this.session().createQuery("select count(1) from StoredEvent");
long count = ((Long)query.uniqueResult()).longValue();
return count;
}
@Override
public String trackerName()
{
return trackerName;
}
}
| [
"[email protected]"
] | |
61697bac406d7b1ba3dbfd035ffa48b88fad4eba | 7a5c51b6093df3116cf70f0a698b5298d299a6fc | /Calculator/app/src/test/java/com/example/dmitry/calculator/ExampleUnitTest.java | a3fe31621613f655452f58aca6c0972f4ca60334 | [] | no_license | ElMaestro157/PMIVS_4 | 8ff31f66e22e502b83057600a33d0853c551d9d4 | 0e5d4f70adc33034a5ca94577f7471d9212a5204 | refs/heads/master | 2021-08-31T23:02:35.777902 | 2017-12-23T09:20:44 | 2017-12-23T09:20:44 | 115,184,280 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 407 | java | package com.example.dmitry.calculator;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
86f789719393c735ac34d32e4db4f0f3159e74eb | 32f0ca869e6bf78edc4743a221412302d4c9803b | /src/main/java/com/mmall/service/impl/CartServiceImpl.java | 3ceace6c42c6b088e5848d1408a6f8e3cb3acc6e | [
"Apache-2.0"
] | permissive | Leroy66/mmall_learning | 1fb35b4900b45e021d59df81eeb0060d82cbc08f | ced9a0baa71f3bbc01fcde85b2ebcec02714ca21 | refs/heads/master | 2021-05-07T00:03:54.697144 | 2018-07-23T01:28:08 | 2018-07-23T01:28:08 | 110,084,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,126 | java | package com.mmall.service.impl;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.mmall.common.Const;
import com.mmall.common.ResponsesCode;
import com.mmall.common.ServerResponse;
import com.mmall.dao.CartMapper;
import com.mmall.dao.ProductMapper;
import com.mmall.pojo.Cart;
import com.mmall.pojo.Product;
import com.mmall.service.ICartService;
import com.mmall.util.BigDecimalUtil;
import com.mmall.util.PropertiesUtil;
import com.mmall.vo.CartProductVo;
import com.mmall.vo.CartVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
@Service(value = "iCartService")
public class CartServiceImpl implements ICartService {
@Autowired
private CartMapper cartMapper;
@Autowired
private ProductMapper productMapper;
@Override
public ServerResponse<CartVo> add(Integer userId, Integer productId, Integer count) {
if (productId == null || count == null) {
return ServerResponse.createByErrorCodeMessage(ResponsesCode.ILLEGAL_AGUMENT.getCode(), ResponsesCode.ILLEGAL_AGUMENT.getDesc());
}
Cart cart = cartMapper.selectByUserIdAndProductId(userId, productId);
if (cart == null) {
//这个产品不在这个购物车里,需要增加一个购物车
Cart cartItem = new Cart();
cartItem.setUserId(userId);
cartItem.setProductId(productId);
cartItem.setQuantity(count);
cartItem.setChecked(Const.Cart.CHECKED);
cartMapper.insert(cartItem);
} else {
//这个产品已经在购物车里
//产品的数量要增加
count = cart.getQuantity() + count;
cart.setQuantity(count);
cartMapper.updateByPrimaryKeySelective(cart);
}
return this.list(userId);
}
@Override
public ServerResponse<CartVo> update(Integer userId, Integer productId, Integer count) {
if (productId == null || count == null) {
return ServerResponse.createByErrorCodeMessage(ResponsesCode.ILLEGAL_AGUMENT.getCode(), ResponsesCode.ILLEGAL_AGUMENT.getDesc());
}
Cart cart = cartMapper.selectByUserIdAndProductId(userId, productId);
if (cart != null) {
cart.setQuantity(count);
}
cartMapper.updateByPrimaryKeySelective(cart);
return this.list(userId);
}
@Override
public ServerResponse<CartVo> deleteProduct(Integer userId, String productIds) {
List<String> productIdList = Splitter.on(",").splitToList(productIds);
if (CollectionUtils.isEmpty(productIdList)) {
return ServerResponse.createByErrorCodeMessage(ResponsesCode.ILLEGAL_AGUMENT.getCode(), ResponsesCode.ILLEGAL_AGUMENT.getDesc());
}
cartMapper.deleteByUserIdAndProductIds(userId, productIdList);
return this.list(userId);
}
@Override
public ServerResponse<CartVo> list(Integer userId) {
CartVo cartVo = this.getCartVoLimit(userId);
return ServerResponse.createBySuccess(cartVo);
}
@Override
public ServerResponse<CartVo> selectOrUnSelectProduct(Integer userId, Integer productId, int checked) {
cartMapper.checkOrUnCheckProduct(userId, productId, checked);
return this.list(userId);
}
@Override
public ServerResponse<Integer> getCartProductCount(Integer userId) {
if (userId == null) {
return ServerResponse.createBySuccess(0);
}
return ServerResponse.createBySuccess(cartMapper.selectCartProductCountByUserId(userId));
}
private CartVo getCartVoLimit(Integer userId) {
CartVo cartVo = new CartVo();
List<Cart> cartList = cartMapper.selectByUserId(userId);
List<CartProductVo> cartProductVoList = Lists.newArrayList();
BigDecimal cartTotalPrice = new BigDecimal("0");
if (CollectionUtils.isNotEmpty(cartList)) {
for (Cart cartItem : cartList) { //for循环里面查询数据库???
CartProductVo cartProductVo = new CartProductVo();
cartProductVo.setId(cartItem.getId());
cartProductVo.setUserId(cartItem.getUserId());
cartProductVo.setProductId(cartItem.getProductId());
Product product = productMapper.selectByPrimaryKey(cartItem.getProductId());
if (product != null) {
cartProductVo.setProductMainImage(product.getMainImage());
cartProductVo.setProductName(product.getName());
cartProductVo.setProductSubTitle(product.getSubtitle());
cartProductVo.setProductStatus(product.getStatus());
cartProductVo.setProductStock(product.getStock());
cartProductVo.setProductPrice(product.getPrice());
//判断库存
int buyLimitCount = 0;
if (product.getStock() >= cartItem.getQuantity()) {
buyLimitCount = cartItem.getQuantity();
cartProductVo.setLimitQuantity(Const.Cart.LIMIT_NUM_SUCCESS);
} else {
buyLimitCount = product.getStock();
cartProductVo.setLimitQuantity(Const.Cart.LIMIT_NUM_FAIL);
//购物车中更新有效库存
Cart cartForQuantity = new Cart();
cartForQuantity.setId(cartItem.getId());
cartForQuantity.setQuantity(buyLimitCount);
cartMapper.updateByPrimaryKeySelective(cartForQuantity);
}
cartProductVo.setQuantity(buyLimitCount);
cartProductVo.setProductTotalPrice(BigDecimalUtil.mul(product.getPrice().doubleValue(), cartProductVo.getQuantity()));
cartProductVo.setProductChecked(cartItem.getChecked());
}
if (cartItem.getChecked() == Const.Cart.CHECKED) {
//如果已经勾选,增加到整个购物车总价中
cartTotalPrice = BigDecimalUtil.add(cartTotalPrice.doubleValue(), cartProductVo.getProductTotalPrice().doubleValue());
}
cartProductVoList.add(cartProductVo);
}
}
cartVo.setCartTotalPrice(cartTotalPrice);
cartVo.setCartProductVoList(cartProductVoList);
cartVo.setAllChecked(this.getAllCheckedStatus(userId));
cartVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix"));
return cartVo;
}
private boolean getAllCheckedStatus(Integer userId) {
if (userId == null) {
return false;
}
//查的是未选中的数量,0---表示全选了,非0表示没有全选
return cartMapper.selectCartProductCheckedByUserId(userId) == 0;
}
}
| [
"[email protected]"
] | |
cf6b5c0665f75fa97a32b75e00d9f68272e1ed47 | 36203259f2f0734a533d229684d93885220de6af | /Practica 7 LDOO/src/java/CONTROLADOR/COOKIEE.java | 1f8f63c231ef5ec6a2c5554b097d7d992b0d52da | [] | no_license | jaimehernandez99/LDOO6-8Miercoles | 58be7e43f2670df11f3d1f10b50b494a5db4c09e | 0668c2d5ba04c262f31c081169810b2d0cf33ec7 | refs/heads/master | 2020-03-27T14:44:53.493631 | 2018-11-08T04:44:35 | 2018-11-08T04:44:35 | 146,676,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,410 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controlador;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Halisson
*/
public class COOKIEE extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
Cookie[] cookie;
cookie = request.getCookies();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>COOKIES</title>");
out.println("</head>");
out.println("<body background=\"cookie.jpg\">");
out.println("<h1>COOKIES</h1>");
for(int i=0;i<cookie.length;i++){
out.println("<p><b> ¿Como se llama tu cookie? </b> "+cookie[i+1].getName()+"</p>");
out.println("<p><b> ¿Cuanto equivale tu cookie? </b> "+cookie[i+1].getValue()+"</p>");
out.println("<hr>");
}
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"[email protected]"
] | |
174951fddcf37add931123945897211c5c20723b | 31e3000f42fd0c77d7a6d44c667fde83eea574a6 | /src/main/java/com/accp/service/ISmbinvoicemainService.java | b30188160aeb30b3ae90878f89aca02601e07151 | [] | no_license | tanqitt/java26shb | f43dcf3f4a3d315bee34b196211c8ff089a1116f | 351d2385d035fef5145a5f8a176b140d3b49941d | refs/heads/master | 2023-08-21T18:09:43.892513 | 2019-08-30T01:59:17 | 2019-08-30T01:59:17 | 204,396,966 | 3 | 0 | null | 2023-07-22T14:31:03 | 2019-08-26T04:39:51 | Java | UTF-8 | Java | false | false | 299 | java | package com.accp.service;
import com.accp.entity.Smbinvoicemain;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 销售发票主表 服务类
* </p>
*
* @author lhp
* @since 2019-08-26
*/
public interface ISmbinvoicemainService extends IService<Smbinvoicemain> {
}
| [
"Administrator@SC-201904181800"
] | Administrator@SC-201904181800 |
0bb98bd00e5341bb9aea320ee31d1fcc5b38fc2b | dd8cf406948b8271b108506703edb0f6ed601f5d | /src/main/java/com/temp/domain/ReportRecord.java | c14ffb9887acfdf7c87f9055cdb240eaccaa04b7 | [] | no_license | Temp-Control-System/Temp-Control-Backend | f68b839291c6d8f4c597ce0113eb2e5e6494fb1b | 0faeca24deaf4fbc55bbfdacb8fcbfb6345d6841 | refs/heads/master | 2021-03-06T10:19:48.365782 | 2020-06-26T11:52:58 | 2020-06-26T11:52:58 | 246,194,594 | 0 | 2 | null | 2020-06-25T03:57:58 | 2020-03-10T02:59:14 | Java | UTF-8 | Java | false | false | 1,602 | java | package com.temp.domain;
import com.temp.enums.Wind;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDate;
/**
* 按天为粒度统计每间房间的数据,用于产生报表
*/
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ReportRecord {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
int roomId;
/**
* 日期,按天为粒度,格式: yyyy-MM-dd
*/
LocalDate date;
/**
* 该房间当日使用空调次数
*/
int use_times;
/**
* 该房间当日最常用目标温度(该房间使用时间最长的目标温度)
*/
float mostFreqTemp;
/**
* 该房间当日最常用风速(时间最长的风速)
*/
@Enumerated(EnumType.ORDINAL)
Wind mostFreqWind;
/**
* 达到目标温度次数
*/
int reachTargetTimes;
/**
* 被调度次数(详单记录数)
*/
int scheduledTimes;
/**
* 当日总费用
*/
int totalCost;
public ReportRecord(int roomId, LocalDate date, int use_times, float mostFreqTemp, Wind mostFreqWind, int reachTargetTimes, int scheduledTimes, int totalCost) {
this.roomId = roomId;
this.date = date;
this.use_times = use_times;
this.mostFreqTemp = mostFreqTemp;
this.mostFreqWind = mostFreqWind;
this.reachTargetTimes = reachTargetTimes;
this.scheduledTimes = scheduledTimes;
this.totalCost = totalCost;
}
}
| [
"[email protected]"
] | |
8bf3172757dce7d7aa924316957bdac1ac8c4f4c | 62470269e12a432ff73458a8e2910bbfc23efb53 | /YS_2/src/Utils.java | aab957cc62ff61e4925503b49e2b371a4dcc6089 | [] | no_license | Most601/Algo1 | ebcf5105531889ab360342f1f1f5407a51f06872 | b0874e2418c887cc3f649dddea196f698dbd8b44 | refs/heads/master | 2021-01-11T22:18:37.287177 | 2017-01-14T14:50:10 | 2017-01-14T14:50:10 | 78,945,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,060 | java |
//look at: http://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values-java
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Utils {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
public int compare( Map.Entry<K, V> o1, Map.Entry<K, V> o2 ) {
return (o2.getValue()).compareTo(o1.getValue());
}
});
Map<K, V> result = new LinkedHashMap<K, V>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
public static String getDigitPlusOne(int num) {
String dig = "";
if (num < 9) dig = "0"+(num+1);
else dig = ""+(num+1);
return dig;
}
} | [
"[email protected]"
] | |
8c6f2e1044c113602d65a6d49b65d372dd7a3cf7 | 522046bb7ab0cdfee3b40f557446f15625d632c9 | /feign/src/main/java/com/example/feign/HiController.java | 2c8418d44b19a34aa54e90e74aed8488c876cd40 | [] | no_license | jianchen98/springcloud | 9114bc2c1c403cac6377c18ea2c1be304705382c | 5053b933a0d9cef58f49e54bdfbc6466d47b5ff2 | refs/heads/master | 2023-06-08T02:31:27.717274 | 2019-08-03T13:13:07 | 2019-08-03T13:13:07 | 139,518,149 | 1 | 0 | null | 2023-05-26T22:13:56 | 2018-07-03T02:30:33 | Java | UTF-8 | Java | false | false | 624 | java | package com.example.feign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HiController {
@Autowired
SchedualServiceHi schedualServiceHi;
@RequestMapping(value = "/hi",method = RequestMethod.GET)
public String sayHi(@RequestParam String name){
return schedualServiceHi.sayHiFromClientOne(name);
}
}
| [
"[email protected]"
] | |
b92195cbb49c9568c5690bddc482bfd34232d7e2 | b79d99a494371a107f8c65d28149904d40c117b5 | /src/test/java/seedu/ezwatchlist/commons/util/CollectionUtilTest.java | d1f9ee17ccc4a06777514cb0ac591eba24ace572 | [
"MIT"
] | permissive | tswuxia/main | a038ed39972c2ac1340ca94e83c2f5d4a8d984ff | 936145b41747c7314f86108cb5b648d363569315 | refs/heads/master | 2022-03-20T04:49:51.471292 | 2019-10-22T03:11:18 | 2019-10-22T03:11:18 | 208,941,428 | 0 | 0 | NOASSERTION | 2019-10-22T03:11:21 | 2019-09-17T02:29:21 | Java | UTF-8 | Java | false | false | 4,528 | java | package seedu.ezwatchlist.commons.util;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.ezwatchlist.commons.util.CollectionUtil.requireAllNonNull;
import static seedu.ezwatchlist.testutil.Assert.assertThrows;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import seedu.ezwatchlist.commons.util.CollectionUtil;
public class CollectionUtilTest {
@Test
public void requireAllNonNullVarargs() {
// no arguments
assertNullPointerExceptionNotThrown();
// any non-empty argument list
assertNullPointerExceptionNotThrown(new Object(), new Object());
assertNullPointerExceptionNotThrown("test");
assertNullPointerExceptionNotThrown("");
// argument lists with just one null at the beginning
assertNullPointerExceptionThrown((Object) null);
assertNullPointerExceptionThrown(null, "", new Object());
assertNullPointerExceptionThrown(null, new Object(), new Object());
// argument lists with nulls in the middle
assertNullPointerExceptionThrown(new Object(), null, null, "test");
assertNullPointerExceptionThrown("", null, new Object());
// argument lists with one null as the last argument
assertNullPointerExceptionThrown("", new Object(), null);
assertNullPointerExceptionThrown(new Object(), new Object(), null);
// null reference
assertNullPointerExceptionThrown((Object[]) null);
// confirms nulls inside lists in the argument list are not considered
List<Object> containingNull = Arrays.asList((Object) null);
assertNullPointerExceptionNotThrown(containingNull, new Object());
}
@Test
public void requireAllNonNullCollection() {
// lists containing nulls in the front
assertNullPointerExceptionThrown(Arrays.asList((Object) null));
assertNullPointerExceptionThrown(Arrays.asList(null, new Object(), ""));
// lists containing nulls in the middle
assertNullPointerExceptionThrown(Arrays.asList("spam", null, new Object()));
assertNullPointerExceptionThrown(Arrays.asList("spam", null, "eggs", null, new Object()));
// lists containing nulls at the end
assertNullPointerExceptionThrown(Arrays.asList("spam", new Object(), null));
assertNullPointerExceptionThrown(Arrays.asList(new Object(), null));
// null reference
assertNullPointerExceptionThrown((Collection<Object>) null);
// empty list
assertNullPointerExceptionNotThrown(Collections.emptyList());
// list with all non-null elements
assertNullPointerExceptionNotThrown(Arrays.asList(new Object(), "ham", Integer.valueOf(1)));
assertNullPointerExceptionNotThrown(Arrays.asList(new Object()));
// confirms nulls inside nested lists are not considered
List<Object> containingNull = Arrays.asList((Object) null);
assertNullPointerExceptionNotThrown(Arrays.asList(containingNull, new Object()));
}
@Test
public void isAnyNonNull() {
assertFalse(CollectionUtil.isAnyNonNull());
assertFalse(CollectionUtil.isAnyNonNull((Object) null));
assertFalse(CollectionUtil.isAnyNonNull((Object[]) null));
assertTrue(CollectionUtil.isAnyNonNull(new Object()));
assertTrue(CollectionUtil.isAnyNonNull(new Object(), null));
}
/**
* Asserts that {@code CollectionUtil#requireAllNonNull(Object...)} throw {@code NullPointerException}
* if {@code objects} or any element of {@code objects} is null.
*/
private void assertNullPointerExceptionThrown(Object... objects) {
assertThrows(NullPointerException.class, () -> requireAllNonNull(objects));
}
/**
* Asserts that {@code CollectionUtil#requireAllNonNull(Collection<?>)} throw {@code NullPointerException}
* if {@code collection} or any element of {@code collection} is null.
*/
private void assertNullPointerExceptionThrown(Collection<?> collection) {
assertThrows(NullPointerException.class, () -> requireAllNonNull(collection));
}
private void assertNullPointerExceptionNotThrown(Object... objects) {
requireAllNonNull(objects);
}
private void assertNullPointerExceptionNotThrown(Collection<?> collection) {
requireAllNonNull(collection);
}
}
| [
"[email protected]"
] | |
bca19b035a92b5f86a40b70d4b5ad29b22fcdd20 | c9755b5d4bc88c2bfb49f07f1ac0eab3f3a0bb30 | /src/main/java/com/fivehl/tp2/factory/DemographyFactory.java | 2296b7531b177e47b547d38def98b6ae099cd42a | [] | no_license | Mystpot/TPExpanJune2018 | 860f42d6515f0c643677c1fef3512d4aff1e4087 | 747c3459e4d771b53f2b3034ef57def7a97362f4 | refs/heads/master | 2020-03-20T19:55:39.390386 | 2018-06-17T14:31:33 | 2018-06-17T14:31:33 | 137,661,310 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 574 | java | package com.fivehl.tp2.factory;
import com.fivehl.tp2.model.Demography;
import java.util.Date;
import java.util.Map;
/**
* Created by 213018500 on 6/1/2018.
*/
public class DemographyFactory {
public static Demography getDemography(Map<String, Object> values)
{
Demography factoryDemography = new Demography.Builder()
.gender((String)values.get("gender"))
.race((String)values.get("race"))
.dateOfBirth((Date)values.get("dateOfBirth"))
.build();
return factoryDemography;
}
}
| [
"[email protected]"
] | |
cea01cb1aae8fcef35b3e2c507893981fa4160a0 | 05fb1bb26ff72704504c91814adaf6de41faacdb | /Java8Ex/src/CollectionsEx/Country.java | 2433b756922a24446bdab3cd7b9033bc145d6a8d | [] | no_license | 0140/newJava | 49635d7c17022d1b61c0d3ed065f71fd25cfe02d | fc553b79146cc4a0993c194553de83bdbf0fc674 | refs/heads/master | 2022-01-12T22:15:15.324886 | 2019-07-01T03:22:02 | 2019-07-01T03:22:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,139 | java | package CollectionsEx;
public class Country { // POJO or Bean or ValueObject
private String name;
private long population;
public Country(String name, long population) {
super();
this.name = name;
this.population = population;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getPopulation() {
return population;
}
public void setPopulation(long population) {
this.population = population;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
/*private String item;
private int price;
public int hashCode(){
System.out.println("In hashcode");
int hashcode = 0;
hashcode = price*20;
hashcode += item.hashCode();
return hashcode;
}*/
@Override
public boolean equals(Object obj) {
Country other = (Country) obj;
if (name.equalsIgnoreCase((other.name)))
return true;
return false;
}
}
| [
"[email protected]"
] | |
27dda449364c8198168163c26b1eb67322efa8a7 | 5006234e71ecd7d5cd164cfef64f8617642ba11f | /src/test/java/net/fhirfactory/pegacorn/deployment/topology/map/archetypes/sample/BuildFHIRPlaceMap.java | db51e75130385598248fa71d4557bfdc3a57fcd2 | [] | no_license | fhirfactory/pegacorn-deployment-topology | 540f9beb60ce5e211b4a4c699e3f2e649ea8f5d7 | d150f3eaf2c295c05ee9b0821d67fb9a45c35e75 | refs/heads/master | 2023-01-23T04:24:59.964938 | 2020-12-11T06:32:35 | 2020-12-11T06:32:35 | 289,589,874 | 0 | 0 | null | 2020-12-11T06:32:36 | 2020-08-23T00:37:26 | Java | UTF-8 | Java | false | false | 3,654 | java | /*
* The MIT License
*
* Copyright 2020 Mark A. Hunter.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package net.fhirfactory.pegacorn.deployment.topology.map.archetypes.sample;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import net.fhirfactory.pegacorn.deployment.topology.map.archetypes.FHIRPlacePegacornSubsystem;
import net.fhirfactory.pegacorn.petasos.model.resilience.mode.ConcurrencyModeEnum;
import net.fhirfactory.pegacorn.petasos.model.resilience.mode.ResilienceModeEnum;
import net.fhirfactory.pegacorn.petasos.model.topology.NodeElementTypeEnum;
import net.fhirfactory.pegacorn.deployment.topology.map.model.DeploymentMapNodeElement;
/**
*
* @author Mark A. Hunter
*/
public class BuildFHIRPlaceMap extends FHIRPlacePegacornSubsystem {
String nodeFHIRPlaceText = "FHIRPlace";
String nodeFHIRPlaceGen0Text = "gen0-fhirplace";
@Override
public void buildSubsystemNode(DeploymentMapNodeElement solutionNode) {
DeploymentMapNodeElement fhirplaceNode = new DeploymentMapNodeElement();
fhirplaceNode.setConcurrencyMode(ConcurrencyModeEnum.CONCURRENCY_MODE_STANDALONE);
fhirplaceNode.setElementVersion("0.0.1");
fhirplaceNode.setInstanceName("FHIRPlace");
fhirplaceNode.setFunctionName("FHIRPlace");
fhirplaceNode.setResilienceMode(ResilienceModeEnum.RESILIENCE_MODE_STANDALONE);
fhirplaceNode.setTopologyElementType(NodeElementTypeEnum.EXTERNALISED_SERVICE);
fhirplaceNode.getContainedElements().add(fhirplaceNode);
buildExternalisedServiceNode(fhirplaceNode);
}
public void buildExternalisedServiceNode(DeploymentMapNodeElement fhirplaceNode) {
DeploymentMapNodeElement gen0FHIRPlaceServiceNode = new DeploymentMapNodeElement();
gen0FHIRPlaceServiceNode.setConcurrencyMode(ConcurrencyModeEnum.CONCURRENCY_MODE_STANDALONE);
gen0FHIRPlaceServiceNode.setElementVersion("0.0.1");
gen0FHIRPlaceServiceNode.setInstanceName(nodeFHIRPlaceGen0Text);
gen0FHIRPlaceServiceNode.setFunctionName(nodeFHIRPlaceGen0Text);
gen0FHIRPlaceServiceNode.setResilienceMode(ResilienceModeEnum.RESILIENCE_MODE_STANDALONE);
gen0FHIRPlaceServiceNode.setTopologyElementType(NodeElementTypeEnum.EXTERNALISED_SERVICE);
gen0FHIRPlaceServiceNode.setContainedElements(new ArrayList<DeploymentMapNodeElement>());
fhirplaceNode.getContainedElements().add(gen0FHIRPlaceServiceNode);
}
@Override
public Set<DeploymentMapNodeElement> buildConnectedSystemSet() {
return(new HashSet<DeploymentMapNodeElement>());
}
}
| [
"[email protected]"
] | |
e96213c6c282be51094378b3b897fa334f6264dc | 0e278ecb143588811177578ec6b83d84c5e16020 | /src/pboif2/pkg10119045/latihan47/nilaimahasiswa/Nilai.java | 0b67637f7dbb5d4e52eb0b33b21e834803bb2302 | [] | no_license | FahmaaMaulana/PBOIF2-10119045-Latihan47-NilaiMahasiswa | b4166f51cbf7b2019c28c3dd8c2afec48f1096ca | 66f04406f07c96193abba432565753c529bcc2bb | refs/heads/master | 2023-01-08T08:36:41.829112 | 2020-11-14T11:23:04 | 2020-11-14T11:23:04 | 312,802,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,989 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pboif2.pkg10119045.latihan47.nilaimahasiswa;
/**
*
* @author Legion
* NAMA : Fahma Maulana
* KELAS : PBOIF2
* NIM : 10119045
* Deskripsi: Nilai Mahasiswa
*/
public class Nilai {
private int quis,uts,uas;
private double nilaiAkhir;
public int getQuis() {
return quis;
}
public void setQuis(int quis) {
this.quis = quis;
}
public int getUts() {
return uts;
}
public void setUts(int uts) {
this.uts = uts;
}
public int getUas() {
return uas;
}
public void setUas(int uas) {
this.uas = uas;
}
public double getNilaiAkhir() {
return nilaiAkhir;
}
public void setNilaiAkhir(double nilaiAkhir) {
this.nilaiAkhir = nilaiAkhir;
}
public double hitungNilaiAkhir(int quis, int uts, int uas) {
return 0.2 * quis + 0.3 * uts + 0.5 * uas;
}
public String menentukanIndex(double na) {
String index;
if (na >= 80 && na <= 100) {
index = "A";
} else if (na >=68 && na <80) {
index = "B";
} else if (na >=56 && na <68) {
index = "C";
} else if (na >=45 && na <56) {
index = "D";
} else{
index = "E";
}
return index;
}
public String menentukanKeterangan(String index) {
String keterangan;
if (index == "A") {
keterangan = "Sangat Baik";
} else if (index == "B") {
keterangan = "Sangat Baik";
} else if (index == "C") {
keterangan = "Cukup";
} else if (index == "D") {
keterangan = "Kurang";
} else{
keterangan = "Sangat Kurang";
}
return keterangan;
}
}
| [
"Legion@LAPTOP-J4IBUFCV"
] | Legion@LAPTOP-J4IBUFCV |
50072ff406aa5a2c789db739e04d0dab1717f7b8 | 4bfedfe1ef1cd14f03cfaa2b76a54cc307cb75a3 | /cs179e/cs179e/Compiler/src/parsing/ast/visitor/IndentPrinter.java | cc65ed42f83eaa951aab6136cf3495fcfb4963f8 | [] | no_license | XiaoLi0614/Secure_Partition | ad2c2b57c2eeb876bbc76214af2b09fbcd41acd9 | 5e5c519b9a9f2e924d647507d0049a8b2a38b268 | refs/heads/master | 2023-08-22T01:06:59.272088 | 2021-09-21T19:06:27 | 2021-09-21T19:06:27 | 303,326,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,805 | java | package parsing.ast.visitor;
import parsing.ast.tree.CompilationUnit;
import parsing.ast.tree.List;
import parsing.ast.tree.Node;
import parsing.ast.tree.Token;
import java.util.Iterator;
/**
* User: Mohsen's Desktop
* Date: Aug 27, 2009
*/
public class IndentPrinter extends DepthFirstSearchVisitor {
private CompilationUnit compilationUnit;
private String out = "";
static class Counter {
private int c;
Counter(int c) { this.c = c; }
public int inc() { c++; return get(); }
public int dec() { c--; return get(); }
private int get() { return c; }
}
final Counter indentCount = new Counter(0);
public IndentPrinter(CompilationUnit compilationUnit) {
this.compilationUnit = compilationUnit;
setPre(
new Callable() {
public void run(Node node) {
print(node.getClass().getSimpleName() + "\n");
indentCount.inc();
}
}
);
setIn(new InCallable() {
public void run(Node node, int no) {
indentPrint(node.getClass().getFields()[no].getName() + ": ");
}
});
setPost(
new Callable() {
public void run(Node node) {
indentCount.dec();
}
}
);
}
private void print(String s) {
out += s;
}
private void indentPrint(String s) {
int c = indentCount.get();
for (int i = 0; i < c; i++) {
print("\t");
}
print(s);
}
public String print() {
compilationUnit.accept(this);
return out;
}
//------------------------------------------------------------
// Visits
public void visit(List list) {
pre.run(list);
Iterator iterator = list.iterator();
int i = 0;
while (iterator.hasNext()) {
Node node = (Node)iterator.next();
indentPrint("[" + i + "]: ");
node.accept(this);
i++;
}
post.run(list);
}
public void visit(Token token) {
print(" \"" + token.toString() + "\"\n");
}
}
| [
"[email protected]"
] | |
6f7e4a5eb75046499343da424bfda2e0d3055c6f | a2eb2ba623c5069617cb3e4e78ea98b806e087dd | /app/src/main/java/ir/maktabkhune/mycontacts/ContactDataModel.java | 85925bb747caf318fd616613ba07f26b566d2845 | [] | no_license | aliHosseinNezhad/MyContactApplication | 08bf32fd10c8ae81516a6b832f4bc77b10448f4d | 119800248eff64073b155f7370cf17357fb7c8d0 | refs/heads/main | 2023-05-09T06:00:00.714707 | 2021-05-18T01:10:36 | 2021-05-18T01:10:36 | 368,363,135 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 297 | java | package ir.maktabkhune.mycontacts;
import java.util.ArrayList;
public class ContactDataModel {
public String firstName;
public String lastName;
public long birthDateMilliSec;
public boolean hasBirthDate;
public ArrayList<String> phoneNumbers;
public int imageId;
}
| [
"[email protected]"
] | |
d0fbda4377e30d210c966f4d3a880f8978231925 | cb9796cbb14e8edf55a201614a18081c6b927ab3 | /owsproxyserver/src/org/deegree/io/datastore/sql/transaction/UpdateHandler.java | e9b46e780779b3cd8f2081b63bb159a911a14918 | [] | no_license | camptocamp/secureOWS | 40ebe40d9e51ee6ae471e2cb892de41d6cd9516a | 314dc306bdfd0726cd750359f0dcf746d9c87205 | refs/heads/master | 2021-01-23T12:05:15.578330 | 2011-07-21T13:50:05 | 2011-07-21T13:50:05 | 2,041,190 | 6 | 1 | null | null | null | null | UTF-8 | Java | false | false | 33,742 | java | //$Header: /home/deegree/jail/deegreerepository/deegree/src/org/deegree/io/datastore/sql/transaction/UpdateHandler.java,v 1.25 2006/09/20 11:35:41 mschneider Exp $
/*---------------- FILE HEADER ------------------------------------------
This file is part of deegree.
Copyright (C) 2001-2006 by:
EXSE, Department of Geography, University of Bonn
http://www.giub.uni-bonn.de/deegree/
lat/lon GmbH
http://www.lat-lon.de
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact:
Andreas Poth
lat/lon GmbH
Aennchenstraße 19
53177 Bonn
Germany
E-Mail: [email protected]
Prof. Dr. Klaus Greve
Department of Geography
University of Bonn
Meckenheimer Allee 166
53115 Bonn
Germany
E-Mail: [email protected]
---------------------------------------------------------------------------*/
package org.deegree.io.datastore.sql.transaction;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.deegree.datatypes.QualifiedName;
import org.deegree.datatypes.Types;
import org.deegree.framework.log.ILogger;
import org.deegree.framework.log.LoggerFactory;
import org.deegree.i18n.Messages;
import org.deegree.io.datastore.DatastoreException;
import org.deegree.io.datastore.FeatureId;
import org.deegree.io.datastore.idgenerator.FeatureIdAssigner;
import org.deegree.io.datastore.schema.MappedFeaturePropertyType;
import org.deegree.io.datastore.schema.MappedFeatureType;
import org.deegree.io.datastore.schema.MappedGeometryPropertyType;
import org.deegree.io.datastore.schema.MappedPropertyType;
import org.deegree.io.datastore.schema.MappedSimplePropertyType;
import org.deegree.io.datastore.schema.TableRelation;
import org.deegree.io.datastore.schema.TableRelation.FK_INFO;
import org.deegree.io.datastore.schema.content.MappingField;
import org.deegree.io.datastore.schema.content.MappingGeometryField;
import org.deegree.io.datastore.schema.content.SimpleContent;
import org.deegree.io.datastore.sql.AbstractRequestHandler;
import org.deegree.io.datastore.sql.StatementBuffer;
import org.deegree.io.datastore.sql.TableAliasGenerator;
import org.deegree.model.feature.Feature;
import org.deegree.model.feature.schema.FeaturePropertyType;
import org.deegree.model.filterencoding.Filter;
import org.deegree.model.spatialschema.Geometry;
import org.deegree.ogcbase.PropertyPath;
import org.deegree.ogcwebservices.wfs.operation.transaction.Insert;
import org.deegree.ogcwebservices.wfs.operation.transaction.Transaction;
import org.deegree.ogcwebservices.wfs.operation.transaction.Update;
/**
* Handler for {@link Update} operations (usually contained in {@link Transaction}
* requests).
*
* @author <a href="mailto:[email protected]">Markus Schneider</a>
* @author last edited by: $Author: mschneider $
*
* @version $Revision: 1.25 $, $Date: 2006/09/20 11:35:41 $
*/
public class UpdateHandler extends AbstractRequestHandler {
private static final ILogger LOG = LoggerFactory.getLogger( UpdateHandler.class );
private SQLTransaction dsTa;
/**
* Creates a new <code>UpdateHandler</code> from the given parameters.
*
* @param dsTa
* @param aliasGenerator
* @param conn
*/
public UpdateHandler( SQLTransaction dsTa, TableAliasGenerator aliasGenerator, Connection conn ) {
super( dsTa.getDatastore(), aliasGenerator, conn );
this.dsTa = dsTa;
}
/**
* Performs an update operation against the associated datastore.
*
* @param ft
* @param properties
* @param filter
* @return number of updated (root) feature instances
* @throws DatastoreException
*/
public int performUpdate( MappedFeatureType ft, Map<PropertyPath, Object> properties,
Filter filter )
throws DatastoreException {
List<FeatureId> fids = determineAffectedFIDs( ft, filter );
LOG.logDebug( "Updating: " + ft );
for ( PropertyPath property : properties.keySet() ) {
Object propertyValue = properties.get( property );
for ( FeatureId fid : fids ) {
LOG.logDebug( "Updating feature: " + fid );
performUpdate( fid, ft, property, propertyValue );
}
}
return fids.size();
}
/**
* Performs an update operation against the associated datastore.
* <p>
* The filter must match exactly one feature instance (or none) which is then replaced
* by the specified replacement feature.
*
* @param mappedFeatureType
* @param replacementFeature
* @param filter
* @return number of updated (root) feature instances (0 or 1)
* @throws DatastoreException
*/
public int performUpdate( MappedFeatureType mappedFeatureType, Feature replacementFeature,
Filter filter )
throws DatastoreException {
LOG.logDebug( "Updating (replace): " + mappedFeatureType );
if ( filter != null ) {
LOG.logDebug( " filter: " + filter.toXML() );
}
List<FeatureId> fids = determineAffectedFIDs( mappedFeatureType, filter );
if ( fids.size() > 1 ) {
String msg = Messages.getMessage( "DATASTORE_MORE_THAN_ONE_FEATURE" );
throw new DatastoreException( msg );
}
DeleteHandler deleteHandler = new DeleteHandler( this.dsTa, this.aliasGenerator, this.conn );
deleteHandler.performDelete( mappedFeatureType, filter );
// identify stored subfeatures / assign feature ids
FeatureIdAssigner fidAssigner = new FeatureIdAssigner( Insert.ID_GEN.GENERATE_NEW );
fidAssigner.assignFID( replacementFeature, this.dsTa );
// TODO remove this hack
fidAssigner.markStoredFeatures();
InsertHandler insertHandler = new InsertHandler( this.dsTa, this.aliasGenerator, this.conn );
List<Feature> features = new ArrayList<Feature>();
features.add( replacementFeature );
insertHandler.performInsert( features );
return fids.size();
}
/**
* Performs the update (replacing of a property) of the given feature instance.
* <p>
* If the selected property is a direct property of the feature, the root feature
* is updated, otherwise the targeted subfeatures have to be determined first.
*
* @param fid
* @param ft
* @param propertyName
* @param replacementValue
* @throws DatastoreException
*/
private void performUpdate( FeatureId fid, MappedFeatureType ft, PropertyPath propertyName,
Object replacementValue )
throws DatastoreException {
LOG.logDebug( "Updating fid: " + fid + ", propertyName: " + propertyName + " -> "
+ replacementValue );
int steps = propertyName.getSteps();
QualifiedName propName = propertyName.getStep( steps - 1 ).getPropertyName();
if ( steps > 2 ) {
QualifiedName subFtName = propertyName.getStep( steps - 2 ).getPropertyName();
MappedFeatureType subFt = this.datastore.getFeatureType( subFtName );
MappedPropertyType pt = (MappedPropertyType) subFt.getProperty( propName );
List<TableRelation> tablePath = getTablePath( ft, propertyName );
List<FeatureId> subFids = determineAffectedFIDs( fid, subFt, tablePath );
for ( FeatureId subFid : subFids ) {
updateProperty( subFid, subFt, pt, replacementValue );
}
} else {
MappedPropertyType pt = (MappedPropertyType) ft.getProperty( propName );
updateProperty( fid, ft, pt, replacementValue );
}
}
/**
* Determines the subfeature instances that are targeted by the given PropertyName.
*
* @param fid
* @param subFt
* @param propertyName
* @return the matched feature ids
* @throws DatastoreException
*/
private List<FeatureId> determineAffectedFIDs( FeatureId fid, MappedFeatureType subFt,
List<TableRelation> path )
throws DatastoreException {
List<FeatureId> subFids = new ArrayList<FeatureId>();
this.aliasGenerator.reset();
String[] tableAliases = this.aliasGenerator.generateUniqueAliases( path.size() + 1 );
String toTableAlias = tableAliases[tableAliases.length - 1];
StatementBuffer query = new StatementBuffer();
query.append( "SELECT " );
appendFeatureIdColumns( subFt, toTableAlias, query );
query.append( " FROM " );
query.append( path.get( 0 ).getFromTable() );
query.append( " " );
query.append( tableAliases[0] );
// append joins
for ( int i = 0; i < path.size(); i++ ) {
query.append( " JOIN " );
query.append( path.get( i ).getToTable() );
query.append( " " );
query.append( tableAliases[i + 1] );
query.append( " ON " );
MappingField[] fromFields = path.get( i ).getFromFields();
MappingField[] toFields = path.get( i ).getToFields();
for ( int j = 0; j < fromFields.length; j++ ) {
query.append( tableAliases[i] );
query.append( '.' );
query.append( fromFields[j].getField() );
query.append( '=' );
query.append( tableAliases[i + 1] );
query.append( '.' );
query.append( toFields[j].getField() );
}
}
query.append( " WHERE " );
MappingField[] fidFields = fid.getFidDefinition().getIdFields();
for ( int i = 0; i < fidFields.length; i++ ) {
query.append( tableAliases[0] );
query.append( '.' );
query.append( fidFields[i].getField() );
query.append( "=?" );
query.addArgument( fid.getValue( i ), fidFields[i].getType() );
if ( i != fidFields.length - 1 ) {
query.append( " AND " );
}
}
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = this.datastore.prepareStatement( conn, query );
rs = stmt.executeQuery();
subFids = extractFeatureIds( rs, subFt );
} catch ( SQLException e ) {
throw new DatastoreException( "Error in determineAffectedFIDs(): " + e.getMessage() );
} finally {
try {
if ( rs != null ) {
try {
rs.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing result set: '" + e.getMessage() + "'.", e );
}
}
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
}
return subFids;
}
/**
* Returns the relations (the "path") that lead from the feature type's table to the
* subfeature table which is targeted by the specified property name.
*
* @param ft source feature type
* @param path property name
* @return relations that lead from the feature type's table to the subfeature table
*/
private List<TableRelation> getTablePath( MappedFeatureType ft, PropertyPath path ) {
List<TableRelation> relations = new ArrayList<TableRelation>();
for ( int i = 1; i < path.getSteps() - 2; i += 2 ) {
QualifiedName propName = path.getStep( i ).getPropertyName();
MappedFeaturePropertyType pt = (MappedFeaturePropertyType) ft.getProperty( propName );
TableRelation[] tableRelations = pt.getTableRelations();
for ( int j = 0; j < tableRelations.length; j++ ) {
relations.add( tableRelations[j] );
}
ft = pt.getFeatureTypeReference().getFeatureType();
}
return relations;
}
/**
* Replaces the specified feature's property with the given value.
*
* @param fid
* @param ft
* @param pt
* @param replacementValue
* @throws DatastoreException
*/
private void updateProperty( FeatureId fid, MappedFeatureType ft, MappedPropertyType pt,
Object replacementValue )
throws DatastoreException {
LOG.logDebug( "Updating property '" + pt.getName() + "' of feature '" + fid + "'." );
if ( !ft.isUpdatable() ) {
String msg = Messages.getMessage( "DATASTORE_FT_NOT_UPDATABLE", ft.getName() );
throw new DatastoreException( msg );
}
TableRelation[] tablePath = pt.getTableRelations();
if ( pt instanceof MappedSimplePropertyType ) {
SimpleContent content = ( (MappedSimplePropertyType) pt ).getContent();
if ( content.isUpdateable() ) {
if ( content instanceof MappingField ) {
updateProperty( fid, tablePath, (MappingField) content, replacementValue );
}
} else {
LOG.logInfo( "Ignoring property '" + pt.getName() + "' in update - is virtual." );
}
} else if ( pt instanceof MappedGeometryPropertyType ) {
MappingGeometryField dbField = ( (MappedGeometryPropertyType) pt ).getMappingField();
Object dbGeometry = this.datastore.convertDeegreeToDBGeometry(
(Geometry) replacementValue,
dbField.getSRS(),
this.conn );
// TODO remove this Oracle hack
if ( this.datastore.getClass().getName().contains( "OracleDatastore" ) ) {
dbField = new MappingGeometryField( dbField.getTable(), dbField.getField(),
Types.STRUCT, dbField.getSRS() );
}
updateProperty( fid, tablePath, dbField, dbGeometry );
} else if ( pt instanceof FeaturePropertyType ) {
updateProperty( fid, ft, (MappedFeaturePropertyType) pt, (Feature) replacementValue );
} else {
throw new DatastoreException( "Internal error: Properties with type '" + pt.getClass()
+ "' are not handled in UpdateHandler." );
}
}
/**
* Updates a simple / geometry property of the specified feature.
* <p>
* Three cases have to be distinguished (which all have to be handled differently):
* <ol>
* <li>property value stored in feature table</li>
* <li>property value stored in property table, fk in property table</li>
* <li>property value stored in property table, fk in feature table</li>
* </ol>
*
* @param fid
* @param tablePath
* @param dbField
* @param replacementValue
* @throws DatastoreException
*/
private void updateProperty( FeatureId fid, TableRelation[] tablePath, MappingField dbField,
Object replacementValue )
throws DatastoreException {
if ( tablePath.length == 0 ) {
updateProperty( fid, dbField, replacementValue );
} else if ( tablePath.length == 1 ) {
TableRelation relation = tablePath[0];
if ( tablePath[0].getFKInfo() == FK_INFO.fkIsToField ) {
Object[] keyValues = determineKeyValues( fid, relation );
if ( keyValues != null ) {
deletePropertyRows( relation, keyValues );
}
insertPropertyRow( relation, keyValues, dbField, replacementValue );
} else {
Object[] oldKeyValues = determineKeyValues( fid, relation );
Object[] newKeyValues = findOrInsertPropertyRow( relation, dbField,
replacementValue );
updateFeatureRow( fid, relation, newKeyValues );
if ( oldKeyValues != null ) {
deleteOrphanedPropertyRows( relation, oldKeyValues );
}
}
} else {
throw new DatastoreException( "Updating of properties that are stored in "
+ "related tables using join tables is not "
+ "supported." );
}
}
private void updateFeatureRow( FeatureId fid, TableRelation relation, Object[] newKeyValues )
throws DatastoreException {
StatementBuffer query = new StatementBuffer();
query.append( "UPDATE " );
query.append( relation.getFromTable() );
query.append( " SET " );
MappingField[] fromFields = relation.getFromFields();
for ( int i = 0; i < newKeyValues.length; i++ ) {
query.append( fromFields[i].getField() );
query.append( "=?" );
query.addArgument( newKeyValues[i], fromFields[i].getType() );
}
query.append( " WHERE " );
appendFIDWhereCondition( query, fid );
LOG.logDebug( "Performing update: " + query.getQueryString() );
PreparedStatement stmt = null;
try {
stmt = this.datastore.prepareStatement( conn, query );
stmt.execute();
} catch ( SQLException e ) {
throw new DatastoreException( "Error in performUpdate(): " + e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
}
/**
* Updates a simple / geometry property of the specified feature.
* <p>
* This method handles the case where the property is stored in the feature table itself, so
* a single UPDATE statement is sufficient.
*
* @param fid
* @param dbField
* @param replacementValue
* @throws DatastoreException
*/
private void updateProperty( FeatureId fid, MappingField dbField, Object replacementValue )
throws DatastoreException {
StatementBuffer query = new StatementBuffer();
query.append( "UPDATE " );
query.append( dbField.getTable() );
query.append( " SET " );
query.append( dbField.getField() );
query.append( "=?" );
query.addArgument( replacementValue, dbField.getType() );
query.append( " WHERE " );
appendFIDWhereCondition( query, fid );
LOG.logDebug( "Performing update: " + query.getQueryString() );
PreparedStatement stmt = null;
try {
stmt = this.datastore.prepareStatement( conn, query );
stmt.execute();
} catch ( SQLException e ) {
throw new DatastoreException( "Error in performUpdate(): " + e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
}
/**
* Determines the values for the key columns that are referenced by the given table
* relation (as from fields).
*
* @param fid
* @param relation
* @return the values for the key columns
* @throws DatastoreException
*/
private Object[] determineKeyValues( FeatureId fid, TableRelation relation )
throws DatastoreException {
StatementBuffer query = new StatementBuffer();
query.append( "SELECT " );
MappingField[] fromFields = relation.getFromFields();
for ( int i = 0; i < fromFields.length; i++ ) {
query.append( fromFields[i].getField() );
if ( i != fromFields.length - 1 ) {
query.append( ',' );
}
}
query.append( " FROM " );
query.append( relation.getFromTable() );
query.append( " WHERE " );
appendFIDWhereCondition( query, fid );
Object[] keyValues = new Object[fromFields.length];
LOG.logDebug( "determineKeyValues: " + query.getQueryString() );
PreparedStatement stmt = null;
try {
stmt = this.datastore.prepareStatement( conn, query );
ResultSet rs = stmt.executeQuery();
if ( rs.next() ) {
for ( int i = 0; i < keyValues.length; i++ ) {
Object value = rs.getObject( i + 1 );
if ( value != null ) {
keyValues[i] = value;
} else {
keyValues = null;
break;
}
}
} else {
LOG.logError( "Internal error. Result is empty (no rows)." );
throw new SQLException();
}
} catch ( SQLException e ) {
throw new DatastoreException( "Error in performUpdate(): " + e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
return keyValues;
}
private void deletePropertyRows( TableRelation relation, Object[] keyValues )
throws DatastoreException {
StatementBuffer query = new StatementBuffer();
query.append( "DELETE FROM " );
query.append( relation.getToTable() );
query.append( " WHERE " );
MappingField[] toFields = relation.getToFields();
for ( int i = 0; i < toFields.length; i++ ) {
query.append( toFields[i].getField() );
query.append( "=?" );
query.addArgument( keyValues[i], toFields[i].getType() );
if ( i != toFields.length - 1 ) {
query.append( " AND " );
}
}
PreparedStatement stmt = null;
LOG.logDebug( "deletePropertyRows: " + query.getQueryString() );
try {
stmt = this.datastore.prepareStatement( conn, query );
stmt.execute();
} catch ( SQLException e ) {
throw new DatastoreException( "Error in performUpdate(): " + e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
}
private void insertPropertyRow( TableRelation relation, Object[] keyValues,
MappingField dbField, Object replacementValue )
throws DatastoreException {
if ( keyValues == null ) {
if ( relation.getFromFields().length > 1 ) {
throw new DatastoreException( "Key generation for compound keys is not supported." );
}
// generate new primary key
keyValues = new Object[1];
keyValues[0] = relation.getIdGenerator().getNewId( dsTa );
}
StatementBuffer query = new StatementBuffer();
query.append( "INSERT INTO " );
query.append( relation.getToTable() );
query.append( " (" );
MappingField[] toFields = relation.getToFields();
for ( int i = 0; i < toFields.length; i++ ) {
query.append( toFields[i].getField() );
query.append( ',' );
}
query.append( dbField.getField() );
query.append( ") VALUES (" );
for ( int i = 0; i < toFields.length; i++ ) {
query.append( '?' );
query.addArgument( keyValues[i], toFields[i].getType() );
query.append( ',' );
}
query.append( "?)" );
query.addArgument( replacementValue, dbField.getType() );
PreparedStatement stmt = null;
LOG.logDebug( "insertPropertyRow: " + query.getQueryString() );
try {
stmt = this.datastore.prepareStatement( conn, query );
stmt.execute();
} catch ( SQLException e ) {
throw new DatastoreException( "Error in performUpdate(): " + e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
}
/**
* Returns the foreign key value(s) for the row that stores the given property.
* <p>
* If the row already exists, the existing key is returned, otherwise a new row for the
* property is inserted first.
*
* @param relation
* @param dbField
* @param replacementValue
* @return foreign key value(s) for the row that stores the given property
* @throws DatastoreException
*/
private Object[] findOrInsertPropertyRow( TableRelation relation, MappingField dbField,
Object replacementValue )
throws DatastoreException {
Object[] keyValues = null;
if ( dbField.getType() != Types.GEOMETRY ) {
StatementBuffer query = new StatementBuffer();
query.append( "SELECT " );
MappingField[] toFields = relation.getToFields();
for ( int i = 0; i < toFields.length; i++ ) {
query.append( toFields[i].getField() );
if ( i != toFields.length - 1 ) {
query.append( ',' );
}
}
query.append( " FROM " );
query.append( relation.getToTable() );
query.append( " WHERE " );
query.append( dbField.getField() );
query.append( "=?" );
query.addArgument( replacementValue, dbField.getType() );
PreparedStatement stmt = null;
LOG.logDebug( "findOrInsertPropertyRow: " + query.getQueryString() );
try {
stmt = this.datastore.prepareStatement( conn, query );
ResultSet rs = stmt.executeQuery();
if ( rs.next() ) {
keyValues = new Object[toFields.length];
for ( int i = 0; i < toFields.length; i++ ) {
keyValues[i] = rs.getObject( i + 1 );
}
}
} catch ( SQLException e ) {
throw new DatastoreException( "Error in findOrInsertPropertyRow(): "
+ e.getMessage() );
} finally {
if ( stmt != null ) {
try {
stmt.close();
} catch ( SQLException e ) {
LOG.logError( "Error closing statement: '" + e.getMessage() + "'.", e );
}
}
}
if ( keyValues != null ) {
return keyValues;
}
}
if ( relation.getToFields().length > 1 ) {
throw new DatastoreException( "Key generation for compound keys is not supported." );
}
// property does not yet exist (or it's a geometry)
keyValues = new Object[1];
// generate new PK
keyValues[0] = relation.getNewPK( this.dsTa );
insertPropertyRow( relation, keyValues, dbField, replacementValue );
return keyValues;
}
private void deleteOrphanedPropertyRows( TableRelation relation, Object[] keyValues )
throws DatastoreException {
Map<String, Object> keyColumns = new HashMap<String, Object>();
for ( int i = 0; i < keyValues.length; i++ ) {
keyColumns.put( relation.getToFields()[i].getField(), keyValues[i] );
}
DeleteNode node = new DeleteNode( relation.getToTable(), keyColumns );
DeleteHandler deleteHandler = new DeleteHandler( this.dsTa, this.aliasGenerator, this.conn );
if ( deleteHandler.getReferencingRows( node ).size() == 0 ) {
try {
deleteHandler.performDelete( node );
} catch ( SQLException e ) {
throw new DatastoreException( e.getMessage() );
}
}
}
private void updateProperty( @SuppressWarnings("unused")
FeatureId fid, @SuppressWarnings("unused")
MappedFeatureType ft, @SuppressWarnings("unused")
MappedFeaturePropertyType pt, @SuppressWarnings("unused")
Feature replacementFeature ) {
throw new UnsupportedOperationException(
"Updating of feature properties is not implemented yet." );
}
private void appendFIDWhereCondition( StatementBuffer query, FeatureId fid ) {
MappingField[] fidFields = fid.getFidDefinition().getIdFields();
for ( int i = 0; i < fidFields.length; i++ ) {
query.append( fidFields[i].getField() );
query.append( "=?" );
query.addArgument( fid.getValue( i ), fidFields[i].getType() );
if ( i != fidFields.length - 1 ) {
query.append( " AND " );
}
}
}
}
/* ********************************************************************
Changes to this class. What the people have been up to:
$Log: UpdateHandler.java,v $
Revision 1.25 2006/09/20 11:35:41 mschneider
Merged datastore related messages with org.deegree.18n.
Revision 1.24 2006/09/19 14:57:01 mschneider
Fixed warnings, improved javadoc.
Revision 1.23 2006/09/05 14:43:24 mschneider
Adapted due to merging of messages.
Revision 1.22 2006/08/29 15:53:57 mschneider
Changed SimpleContent#isVirtual() to SimpleContent#isUpdateable().
Revision 1.21 2006/08/23 16:35:58 mschneider
Added handling of virtual properties. Virtual properties are skipped on update.
Revision 1.20 2006/08/22 18:14:42 mschneider
Refactored due to cleanup of org.deegree.io.datastore.schema package.
Revision 1.19 2006/08/21 16:42:36 mschneider
Refactored due to cleanup (and splitting) of org.deegree.io.datastore.schema package.
Revision 1.18 2006/08/21 15:46:53 mschneider
Refactored due to cleanup (and splitting) of org.deegree.io.datastore.schema package.
Revision 1.17 2006/08/06 20:49:30 poth
UnsupportedOperationException instead of datastoreException thrown
Revision 1.16 2006/07/26 18:57:29 mschneider
Fixed spelling in method name.
Revision 1.15 2006/06/29 10:26:20 mschneider
Moved identifying of stored features / assigning of feature ids from TransactionHandler here.
Revision 1.14 2006/06/28 08:53:35 poth
*** empty log message ***
Revision 1.13 2006/06/27 08:14:55 poth
bug fix - just log filter if available
Revision 1.12 2006/06/01 16:01:19 mschneider
Added exception that is thrown in case of FeatureProperty updates.
Revision 1.11 2006/05/30 17:04:06 mschneider
Update on geometry properties should work now.
Revision 1.10 2006/05/29 16:39:24 mschneider
Update on simple properties should work now.
Revision 1.9 2006/05/24 15:25:03 mschneider
Update for simple / geometry properties should work now (only when they are stored in the feature table).
Revision 1.8 2006/05/23 22:40:57 mschneider
"Standard" update throws Exception now (to let the user know that it is not fully implemented yet).
Revision 1.7 2006/05/23 16:06:34 mschneider
Changed signature of performUpdate().
Revision 1.6 2006/05/18 15:48:02 mschneider
Added handling of non-standard update (feature replace).
Revision 1.5 2006/05/17 18:28:49 mschneider
Initial work on Update.
Revision 1.4 2006/05/16 16:20:10 mschneider
Added update method for deegree specific update operation.
Revision 1.3 2006/04/18 12:47:40 mschneider
Improved javadoc.
Revision 1.2 2006/04/06 20:25:27 poth
*** empty log message ***
Revision 1.1 2006/02/13 17:54:55 mschneider
Initial version.
********************************************************************** */
| [
"sypasche@d2b8d2de-b12a-0410-86d9-8c904ad3c895"
] | sypasche@d2b8d2de-b12a-0410-86d9-8c904ad3c895 |
64d6b0c93a33dac273c9cbd06cf54f05bf87500e | f822300fb4f55d00d3fd34298b9d4c324b19705a | /src/main/java/cn/hinson/controller/SysUserController.java | 87a8eec170a7e6e8392f836cd21876622a327a45 | [] | no_license | jenkincstang/springboot_security5_oauth2.0 | e9eff1b0b45e519401c1c832f3c56d0f1799e2d8 | 844240cbb2f237d2277cb871a5ebd0c1734aceb6 | refs/heads/master | 2022-12-08T12:50:32.136443 | 2020-08-30T17:24:39 | 2020-08-30T17:24:39 | 289,246,985 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,821 | java | package cn.hinson.controller;
import cn.hinson.domain.SysRole;
import cn.hinson.domain.SysUser;
import cn.hinson.dto.UserDto;
import cn.hinson.service.SysRoleService;
import cn.hinson.service.SysUserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
@RestController
public class SysUserController {
protected final Log logger = LogFactory.getLog(this.getClass());
@Autowired
private final SysUserService sysUserService;
@Autowired
private final SysRoleService sysRoleService;
public SysUserController(SysUserService sysUserService, SysRoleService sysRoleService) {
this.sysUserService = sysUserService;
this.sysRoleService = sysRoleService;
}
@GetMapping("/test")
public String test() {
//访问这个url注册一个username:hinson1 password:password的用户
SysUser sysUser = sysUserService.getUserByName("admin");
if (sysUser == null) {
sysUser = new SysUser();
sysUser.setUsername("admin");
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String tmp = passwordEncoder.encode("password");
sysUser.setPassword(tmp);
SysRole adminRole = sysRoleService.getSysRoleByName("ROLE_ADMIN");
SysRole userRole = sysRoleService.getSysRoleByName("ROLE_USER");
List<SysRole> roles = new ArrayList<>();
roles.add(adminRole);
roles.add(userRole);
sysUser.setSysRoles(roles);
sysUserService.saveSysUser(sysUser);
}
return "success";
}
// @GetMapping("/login")
// public String login(){
// return ": login";
// }
@GetMapping("/user")
public Principal getUsers(@AuthenticationPrincipal Principal principal) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
System.out.println("AuthenticationPrincipal Name:>>" + authentication.getName());
return principal;
}
@GetMapping("/userManager")
public String getUserManagerInfo() {
return "User Manager Page";
}
@GetMapping("/sysManager")
public String getSystemManagerInfo() {
return "System Manager Page";
}
@GetMapping("/userInfo")
public String getUserInfo() {
return "User Information Page";
}
@PostMapping("/register")
public String register(@RequestBody UserDto userDto) {
System.out.println("Register User");
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
//访问这个url注册一个用户
SysUser existUser = sysUserService.getUserByName(userDto.getUsername());
if (existUser == null) {
SysUser sysUser = new SysUser();
sysUser.setUsername(userDto.getUsername());
sysUser.setPassword(passwordEncoder.encode(userDto.getPassword()));
sysUserService.saveSysUser(sysUser);
} else {
if (existUser.getPassword() == null) {
existUser.setPassword(passwordEncoder.encode(userDto.getPassword()));
sysUserService.saveSysUser(existUser);
} else {
return "User already Exists!";
}
}
return "Register User Success!";
}
}
| [
"[email protected]"
] | |
18902140da65f5d18c215518700d0ae9d34a9f78 | 10dd1c5ccc5de052a1a1b0b9d4789d5be30642db | /Underscore/src/java/com/underscore/Register.java | 8604174075d4f1e03dff52d60cdc3c8c89ae0916 | [] | no_license | jester628/WebtekLab | b0fa814afef2edd2116dbd44fdc10f1fca5588f3 | ab5d841a925c39b3e33115554280ef16b5c4bf43 | refs/heads/master | 2020-12-02T22:50:46.139342 | 2017-07-04T07:52:35 | 2017-07-04T07:52:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,375 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.underscore;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author s326lab
*/
@WebServlet(name = "Register", urlPatterns = {"/Register"})
public class Register extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"[email protected]"
] | |
84616fff5ec12369bfb166c86b5e251975728595 | 581d33ab87a2962ec0ae8765cac4078ad6c9f24b | /app/src/main/java/com/studytor/app/repositories/cache/AssistantScheduleCache.java | 8f9b6c782b2a75db8972103086488d0af6aa2b16 | [] | no_license | orzechdev/replacements-android | 3f8791a5e84e315b25a3d402fe4b6db8ec26ba43 | 2e7ebbcd9947c38f4e239c3e342a68db1c918a0c | refs/heads/master | 2023-04-30T06:07:40.431522 | 2018-09-14T18:53:09 | 2018-09-14T18:53:09 | 68,309,718 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 894 | java | package com.studytor.app.repositories.cache;
import android.arch.lifecycle.MutableLiveData;
import com.studytor.app.repositories.models.Schedule;
/**
* Created by Dawid on 25.07.2017.
*/
public class AssistantScheduleCache {
private MutableLiveData<Schedule> cachedScheduleList = new MutableLiveData<>();
private static AssistantScheduleCache instance;
private AssistantScheduleCache() {
this.cachedScheduleList = new MutableLiveData<>();
}
public static AssistantScheduleCache getInstance() {
if (instance == null){ //if there is no instance available... create new one
instance = new AssistantScheduleCache();
}
return instance;
}
public void putData(Schedule list){
cachedScheduleList.postValue(list);
}
public MutableLiveData<Schedule> getData(){
return cachedScheduleList;
}
}
| [
"[email protected]"
] | |
50852dce9dc6b48a78fe7c8e3073be81a859492e | f2164ba57c30de30c59712c8d80ee6aa0b795fa7 | /UIFramework/src/main/java/com/handmark/pulltorefresh/library/internal/RotateLoadingLayout.java | b3e2ae4b09ab8a0f076058593679905f0d76ee4f | [] | no_license | zhouweiyong/RecyclerViewDemo | a35b6bf448b68c344ca6899defeabf03d3522391 | c3b5e3001699b888912e21ce74e41c6099e282f4 | refs/heads/master | 2020-12-30T16:02:58.051687 | 2018-12-26T01:30:23 | 2018-12-26T01:30:23 | 90,957,621 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,516 | java | /*******************************************************************************
* Copyright 2011, 2012 Chris Banes.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.handmark.pulltorefresh.library.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView.ScaleType;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation;
import com.vstecs.android.uiframework.R;
public class RotateLoadingLayout extends LoadingLayout {
static final int ROTATION_ANIMATION_DURATION = 1200;
private final Animation mRotateAnimation;
private final Matrix mHeaderImageMatrix;
private float mRotationPivotX, mRotationPivotY;
private final boolean mRotateDrawableWhilePulling;
public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) {
super(context, mode, scrollDirection, attrs);
mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);
mHeaderImage.setScaleType(ScaleType.MATRIX);
mHeaderImageMatrix = new Matrix();
mHeaderImage.setImageMatrix(mHeaderImageMatrix);
mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
}
public void onLoadingDrawableSet(Drawable imageDrawable) {
if (null != imageDrawable) {
mRotationPivotX = Math.round(imageDrawable.getIntrinsicWidth() / 2f);
mRotationPivotY = Math.round(imageDrawable.getIntrinsicHeight() / 2f);
}
}
protected void onPullImpl(float scaleOfLayout) {
float angle;
if (mRotateDrawableWhilePulling) {
angle = scaleOfLayout * 90f;
} else {
angle = Math.max(0f, Math.min(180f, scaleOfLayout * 360f - 180f));
}
mHeaderImageMatrix.setRotate(angle, mRotationPivotX, mRotationPivotY);
mHeaderImage.setImageMatrix(mHeaderImageMatrix);
}
@Override
protected void refreshingImpl() {
mHeaderImage.startAnimation(mRotateAnimation);
}
@Override
protected void resetImpl() {
mHeaderImage.clearAnimation();
resetImageRotation();
}
private void resetImageRotation() {
if (null != mHeaderImageMatrix) {
mHeaderImageMatrix.reset();
mHeaderImage.setImageMatrix(mHeaderImageMatrix);
}
}
@Override
protected void pullToRefreshImpl() {
// NO-OP
}
@Override
protected void releaseToRefreshImpl() {
// NO-OP
}
@Override
protected int getDefaultDrawableResId() {
return R.mipmap.default_ptr_rotate;
}
}
| [
"[email protected]"
] | |
41d9056b8cb4e93485e0df7c2993352cfb2bf6dd | df67506b2776ed0786b7a787ddf3bb07854aad8a | /club/src/main/java/com/clubdemo/club/api/ClubAPI.java | 6c8286c27028626c8700ed52f2035bd1141fd752 | [] | no_license | ddjonline/wildfly-swarm-demo | 38d749e223d5c5190105ab2ce0b1756c269c7628 | 71061c77880eb7888c5701719dc9bc68808e93cc | refs/heads/master | 2020-03-07T06:02:39.388979 | 2018-04-17T14:29:53 | 2018-04-17T14:29:53 | 127,312,053 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,062 | java | package com.clubdemo.club.api;
import com.clubdemo.club.application.PersistenceHelper;
import com.clubdemo.club.entity.Club;
import javax.inject.Inject;
import javax.persistence.TypedQuery;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Collection;
@Path("/club")
public class ClubAPI {
@Inject
PersistenceHelper persistenceHelper;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAll() {
TypedQuery<Club> query = persistenceHelper.getEntityManager().createNamedQuery(Club.FIND_ALL, Club.class);
Collection<Club> allClubs = query.getResultList();
return Response.ok(allClubs).build();
}
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response findById(final @PathParam("id")Long id) {
Club club = persistenceHelper.getEntityManager().find(Club.class, id);
return Response.ok(club).build();
}
}
| [
"[email protected]"
] | |
2467edc25a32f7bdf14f448553f86080eaad7105 | 0ccf5aede655fa10099118f9494d7492e715b1d6 | /qyt_om/src/main/java/com/qyt/om/adapter/DeviceStateAdapter.java | 30b77b148cbb7eb0c2544f7cea9aaf28b5ad04bb | [] | no_license | wuxiflowing/operationmanager_android | 4a1560217eb0096f3b0712fbd3c5ca941154acf6 | ca488085ac83a65b181646162dec8793f3abf3fd | refs/heads/master | 2020-06-19T01:41:22.700198 | 2020-04-22T14:26:30 | 2020-04-22T14:26:30 | 196,521,472 | 0 | 0 | null | 2020-04-22T14:26:31 | 2019-07-12T06:26:32 | Java | UTF-8 | Java | false | false | 1,428 | java | package com.qyt.om.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bangqu.lib.base.BaseSimpleAdapter;
import com.qyt.om.R;
import com.qyt.om.model.InfoMap;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by 15052286501 on 2017/8/29.
*/
public class DeviceStateAdapter extends BaseSimpleAdapter<InfoMap> {
public DeviceStateAdapter(Context mContext, List<InfoMap> mData) {
super(mContext, mData);
}
@Override
protected View getViewAtPosition(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item_devicestate, null);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
InfoMap model = mData.get(position);
viewHolder.stateLabel.setText(model.label);
viewHolder.stateValue.setText(model.value);
return convertView;
}
class ViewHolder {
@BindView(R.id.state_value)
TextView stateValue;
@BindView(R.id.state_label)
TextView stateLabel;
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
}
| [
"[email protected]"
] | |
cf76f45e098f19d86f9beb677e1e0c7fe3eccaea | 6cd99145a125ef9de59cfe1a09891210d50839d5 | /Project/src/codigo/Hilo.java | d1d65b0a8b382c155a9170e846aeb263cb7d0d99 | [] | no_license | pdegioanni/tpFinalProgConcurrente | db29b2d922c4755b49dc4f52c13d46ef64d3737d | 717b3c3f6aef46b198f510f867f685ed0620d527 | refs/heads/main | 2023-06-16T20:02:39.874548 | 2021-06-11T18:34:23 | 2021-06-11T18:34:23 | 374,467,532 | 0 | 0 | null | 2021-06-11T16:43:17 | 2021-06-06T21:29:39 | HTML | UTF-8 | Java | false | false | 551 | java | package codigo;
public class Hilo implements Runnable {
private String nombre;
private Monitor monitor;
private int secuencia[];
private boolean continuar = true;
public Hilo(String nombre,Monitor monitor,int secuencia[]) {
this.nombre = nombre;
this.monitor = monitor;
this.secuencia = secuencia;
}
public void run() {
while(continuar) {
for(int i=0;i<secuencia.length;i++) {
//System.out.println("Hilo :"+nombre);
monitor.dispararTransicion(secuencia[i]);
}
}
}
public void set_Fin()
{
continuar = false;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.