blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
863d404afdb38e189a67374398c7afd921727974
| 27,307,402,070,530 |
a16c9baf104491a8d583c7e11d4a8dd5319f96f7
|
/src/main/java/com/noto0648/stations/nameplate/NamePlateAonamiLine.java
|
8561540ccc305d9668cbc891e15b27a70ce65ba5
|
[] |
no_license
|
noto0648/StationsMod
|
https://github.com/noto0648/StationsMod
|
cc6588051549927bf1888a0f3b1f468eb4ecd71f
|
eaff3a6197a182bc65ca948e228f195f1f1a6114
|
refs/heads/master
| 2021-01-21T21:48:13.194000 | 2020-06-10T03:51:04 | 2020-06-10T03:51:04 | 23,016,250 | 3 | 3 | null | false | 2020-08-20T11:55:28 | 2014-08-16T11:02:13 | 2020-08-17T03:24:39 | 2020-08-20T11:55:27 | 488 | 3 | 3 | 0 |
Java
| false | false |
package com.noto0648.stations.nameplate;
import com.noto0648.stations.client.render.TileEntityNamePlateRender;
import com.noto0648.stations.client.texture.NewFontRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import java.util.List;
import java.util.Map;
/**
* Created by Noto on 14/08/25.
*/
@NamePlateAnnotation
public class NamePlateAonamiLine extends NamePlateBase
{
@SideOnly(Side.CLIENT)
@Override
public void render(Map<String, String> map, boolean rotate, int plateFace)
{
String nowStation = map.get("stationName");
String nowEnglish = map.get("englishName");
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
GL11.glNormal3f(-1.0F, 0.0F, 0.0F);
if(plateFace == 1) GL11.glTranslatef(0F, 0.25F, 0F);
if(plateFace == 2) GL11.glTranslatef(0F, -0.25F, 0F);
GL11.glTranslated(-0, 0, 0.07);
GL11.glScalef(0.01F, 0.01F, 0.01F);
GL11.glColor3f(0.9999999999F, 0.9999999999F, 0.9999999999F);
GL11.glPushMatrix();
GL11.glScaled(0.4D, 0.4D, 0.4D);
int width = NewFontRenderer.INSTANCE.drawString(nowStation, false);
GL11.glTranslated(-width / 2, 10, 0);
NewFontRenderer.INSTANCE.drawString(nowStation);
GL11.glTranslated(width / 2, -10, 0);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, -20, 0);
GL11.glScaled(0.4D, 0.4D, 0.4D);
int engW = NewFontRenderer.INSTANCE.drawString(nowEnglish, false);
GL11.glTranslated(-engW / 2, 10, 0);
NewFontRenderer.INSTANCE.drawString(nowEnglish);
GL11.glTranslated(width / 2, -10, 0);
GL11.glPopMatrix();
String nextStation = !rotate ? map.get("prevStation"): map.get("nextStation");
String nextEnglish = !rotate ? map.get("prevEnglish"): map.get("nextEnglish");
{
GL11.glPushMatrix();
GL11.glTranslated(-80, 10, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextStation, false);
NewFontRenderer.INSTANCE.drawString(nextStation);
GL11.glPopMatrix();
}
{
GL11.glPushMatrix();
GL11.glTranslated(-80, 5, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextEnglish, false);
NewFontRenderer.INSTANCE.drawString(nextEnglish);
GL11.glPopMatrix();
}
nextStation = rotate ? map.get("prevStation"): map.get("nextStation");
nextEnglish = rotate ? map.get("prevEnglish"): map.get("nextEnglish");
{
GL11.glPushMatrix();
GL11.glTranslated(70, 10, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextStation, false);
GL11.glTranslatef(-strW, 0, 0);
NewFontRenderer.INSTANCE.drawString(nextStation);
GL11.glPopMatrix();
}
{
GL11.glPushMatrix();
GL11.glTranslated(70, 5, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextEnglish, false);
GL11.glTranslatef(-strW, 0, 0);
NewFontRenderer.INSTANCE.drawString(nextEnglish);
GL11.glPopMatrix();
}
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor3f(1F, 1F, 1F);
}
@Override
public void init(List<String> list)
{
list.add("stationName");
list.add("englishName");
list.add("nextStation");
list.add("nextEnglish");
list.add("prevStation");
list.add("prevEnglish");
}
@Override
public String getName()
{
return "Aonami Line";
}
@Override
public boolean isUserRender()
{
return true;
}
@Override
public void userRender(int plateFace)
{
if(plateFace == 1) GL11.glTranslatef(0F, 0.5F, 0F);
if(plateFace == 2) GL11.glTranslatef(0F, -0.5F, 0F);
TileEntityNamePlateRender.subwayModel.renderAll();
}
}
|
UTF-8
|
Java
| 4,476 |
java
|
NamePlateAonamiLine.java
|
Java
|
[
{
"context": "til.List;\nimport java.util.Map;\n\n/**\n * Created by Noto on 14/08/25.\n */\n@NamePlateAnnotation\npublic c",
"end": 504,
"score": 0.624172031879425,
"start": 503,
"tag": "NAME",
"value": "N"
},
{
"context": "l.List;\nimport java.util.Map;\n\n/**\n * Created by Noto on 14/08/25.\n */\n@NamePlateAnnotation\npublic clas",
"end": 507,
"score": 0.5658961534500122,
"start": 504,
"tag": "USERNAME",
"value": "oto"
}
] | null |
[] |
package com.noto0648.stations.nameplate;
import com.noto0648.stations.client.render.TileEntityNamePlateRender;
import com.noto0648.stations.client.texture.NewFontRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import java.util.List;
import java.util.Map;
/**
* Created by Noto on 14/08/25.
*/
@NamePlateAnnotation
public class NamePlateAonamiLine extends NamePlateBase
{
@SideOnly(Side.CLIENT)
@Override
public void render(Map<String, String> map, boolean rotate, int plateFace)
{
String nowStation = map.get("stationName");
String nowEnglish = map.get("englishName");
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
GL11.glNormal3f(-1.0F, 0.0F, 0.0F);
if(plateFace == 1) GL11.glTranslatef(0F, 0.25F, 0F);
if(plateFace == 2) GL11.glTranslatef(0F, -0.25F, 0F);
GL11.glTranslated(-0, 0, 0.07);
GL11.glScalef(0.01F, 0.01F, 0.01F);
GL11.glColor3f(0.9999999999F, 0.9999999999F, 0.9999999999F);
GL11.glPushMatrix();
GL11.glScaled(0.4D, 0.4D, 0.4D);
int width = NewFontRenderer.INSTANCE.drawString(nowStation, false);
GL11.glTranslated(-width / 2, 10, 0);
NewFontRenderer.INSTANCE.drawString(nowStation);
GL11.glTranslated(width / 2, -10, 0);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, -20, 0);
GL11.glScaled(0.4D, 0.4D, 0.4D);
int engW = NewFontRenderer.INSTANCE.drawString(nowEnglish, false);
GL11.glTranslated(-engW / 2, 10, 0);
NewFontRenderer.INSTANCE.drawString(nowEnglish);
GL11.glTranslated(width / 2, -10, 0);
GL11.glPopMatrix();
String nextStation = !rotate ? map.get("prevStation"): map.get("nextStation");
String nextEnglish = !rotate ? map.get("prevEnglish"): map.get("nextEnglish");
{
GL11.glPushMatrix();
GL11.glTranslated(-80, 10, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextStation, false);
NewFontRenderer.INSTANCE.drawString(nextStation);
GL11.glPopMatrix();
}
{
GL11.glPushMatrix();
GL11.glTranslated(-80, 5, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextEnglish, false);
NewFontRenderer.INSTANCE.drawString(nextEnglish);
GL11.glPopMatrix();
}
nextStation = rotate ? map.get("prevStation"): map.get("nextStation");
nextEnglish = rotate ? map.get("prevEnglish"): map.get("nextEnglish");
{
GL11.glPushMatrix();
GL11.glTranslated(70, 10, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextStation, false);
GL11.glTranslatef(-strW, 0, 0);
NewFontRenderer.INSTANCE.drawString(nextStation);
GL11.glPopMatrix();
}
{
GL11.glPushMatrix();
GL11.glTranslated(70, 5, 0);
GL11.glScaled(0.15D, 0.15D, 0.15D);
int strW = NewFontRenderer.INSTANCE.drawString(nextEnglish, false);
GL11.glTranslatef(-strW, 0, 0);
NewFontRenderer.INSTANCE.drawString(nextEnglish);
GL11.glPopMatrix();
}
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor3f(1F, 1F, 1F);
}
@Override
public void init(List<String> list)
{
list.add("stationName");
list.add("englishName");
list.add("nextStation");
list.add("nextEnglish");
list.add("prevStation");
list.add("prevEnglish");
}
@Override
public String getName()
{
return "Aonami Line";
}
@Override
public boolean isUserRender()
{
return true;
}
@Override
public void userRender(int plateFace)
{
if(plateFace == 1) GL11.glTranslatef(0F, 0.5F, 0F);
if(plateFace == 2) GL11.glTranslatef(0F, -0.5F, 0F);
TileEntityNamePlateRender.subwayModel.renderAll();
}
}
| 4,476 | 0.616175 | 0.552502 | 142 | 30.521128 | 24.594376 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.007042 | false | false |
13
|
87cbed91fe0bd0580f0bcbc1cde01679db75e4d3
| 21,002,390,080,026 |
25657440951581f8d8ec4e57cfc0a363dcb50be0
|
/MonthMoNi/src/main/java/com/example/search_shopcart/presenter/AddCartPresenter.java
|
bd1d798014c2d93bb08d1a52d467040c53121169
|
[] |
no_license
|
1657895829/ThreePractice
|
https://github.com/1657895829/ThreePractice
|
2fa00a5be8d9eb2fa1762c8be85e87b1b3ab9dec
|
422f5ed100839fb9dfc283e966741eb2a9b3958e
|
refs/heads/master
| 2020-03-18T20:35:01.609000 | 2018-06-01T09:05:49 | 2018-06-01T09:05:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.search_shopcart.presenter;
import com.example.search_shopcart.base.BasePresenter;
import com.example.search_shopcart.bean.AddCartBean;
import com.example.search_shopcart.model.AddCartModel;
import com.example.search_shopcart.model.AddCartModelCallBack;
import com.example.search_shopcart.view.AddCartViewListener;
/**
* 加入购物车 p 层
*/
public class AddCartPresenter extends BasePresenter<AddCartViewListener> {
private AddCartModel model;
public AddCartPresenter() {
this.model = new AddCartModel();
}
public void getData(String pid){
model.getData(pid, new AddCartModelCallBack() {
@Override
public void success(AddCartBean addCartBean) {
view.success(addCartBean);
}
@Override
public void failure(Exception e) {
view.failure(e);
}
});
}
}
|
UTF-8
|
Java
| 926 |
java
|
AddCartPresenter.java
|
Java
|
[] | null |
[] |
package com.example.search_shopcart.presenter;
import com.example.search_shopcart.base.BasePresenter;
import com.example.search_shopcart.bean.AddCartBean;
import com.example.search_shopcart.model.AddCartModel;
import com.example.search_shopcart.model.AddCartModelCallBack;
import com.example.search_shopcart.view.AddCartViewListener;
/**
* 加入购物车 p 层
*/
public class AddCartPresenter extends BasePresenter<AddCartViewListener> {
private AddCartModel model;
public AddCartPresenter() {
this.model = new AddCartModel();
}
public void getData(String pid){
model.getData(pid, new AddCartModelCallBack() {
@Override
public void success(AddCartBean addCartBean) {
view.success(addCartBean);
}
@Override
public void failure(Exception e) {
view.failure(e);
}
});
}
}
| 926 | 0.667396 | 0.667396 | 33 | 26.69697 | 23.170626 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false |
13
|
9a3ebf514dcb0f247e1aaf369a7073889483fd54
| 27,693,949,128,007 |
cc510a22d6ea59ff7660e579a179e131e72c5ae5
|
/commodity-service/server/src/main/java/com/zzz/smo/commodityservice/server/enums/CommodityStatusEnum.java
|
890dc8692662dc24f5736841dec16eae34d79999
|
[] |
no_license
|
Zero9811/Supermarket-Online
|
https://github.com/Zero9811/Supermarket-Online
|
5b1196e49816fc5336287ded22f4a8895648d96a
|
300b1c8da67d4b7c29091a1bfebaa45535053b63
|
refs/heads/master
| 2020-04-13T09:50:15.502000 | 2019-03-21T13:55:12 | 2019-03-21T13:55:12 | 163,092,987 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.zzz.smo.commodityservice.server.enums;
import lombok.Getter;
/**
* 商品上下架状态
* @Author: Sean
* @Date: 2019/1/1 22:41
*/
@Getter
public enum CommodityStatusEnum {
UP(0,"在架"),
DOWN(1,"下架"),
;
private int code;
private String message;
CommodityStatusEnum(int code,String message){
this.code = code;
this.message = message;
}
}
|
UTF-8
|
Java
| 407 |
java
|
CommodityStatusEnum.java
|
Java
|
[
{
"context": "\nimport lombok.Getter;\n\n/**\n * 商品上下架状态\n * @Author: Sean\n * @Date: 2019/1/1 22:41\n */\n@Getter\npublic enum ",
"end": 106,
"score": 0.9984902143478394,
"start": 102,
"tag": "NAME",
"value": "Sean"
}
] | null |
[] |
package com.zzz.smo.commodityservice.server.enums;
import lombok.Getter;
/**
* 商品上下架状态
* @Author: Sean
* @Date: 2019/1/1 22:41
*/
@Getter
public enum CommodityStatusEnum {
UP(0,"在架"),
DOWN(1,"下架"),
;
private int code;
private String message;
CommodityStatusEnum(int code,String message){
this.code = code;
this.message = message;
}
}
| 407 | 0.628571 | 0.597403 | 22 | 16.5 | 14.711622 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false |
13
|
49c04168907df513a509344794a368aa41d4bfe5
| 27,745,488,799,253 |
d478e9b50f05d2bcddddfb929654c5507eee6752
|
/src/test/java/com/moandjiezana/toml/TableArrayTest.java
|
dd2d42c5f83bd53e22917e1efde47b1dba323f90
|
[
"MIT"
] |
permissive
|
mwanji/toml4j
|
https://github.com/mwanji/toml4j
|
0ff73ef603b67e2fd479b4b4b7321f9906f2b4ae
|
1f32acc5976b69b80f7307449dc47791d235885a
|
refs/heads/master
| 2023-08-29T18:28:50.638000 | 2021-07-27T05:04:38 | 2021-07-27T05:04:38 | 8,440,284 | 315 | 69 |
MIT
| false | 2023-05-09T16:32:04 | 2013-02-26T19:40:17 | 2023-04-06T10:27:50 | 2023-05-05T18:45:28 | 480 | 275 | 56 | 54 |
Java
| false | false |
package com.moandjiezana.toml;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
public class TableArrayTest {
@Test
public void should_parse_table_array() throws Exception {
Toml toml = new Toml().read(file("products_table_array"));
List<Toml> products = toml.getTables("products");
assertEquals(3, products.size());
assertEquals("Hammer", products.get(0).getString("name"));
assertEquals(738594937L, products.get(0).getLong("sku").longValue());
Assert.assertNull(products.get(1).getString("name"));
assertNull(products.get(1).getLong("sku"));
assertEquals("Nail", products.get(2).getString("name"));
assertEquals(284758393L, products.get(2).getLong("sku").longValue());
assertEquals("gray", products.get(2).getString("color"));
}
@Test
public void should_parse_table_array_out_of_order() throws Exception {
Toml toml = new Toml().read(file("should_parse_table_array_out_of_order"));
List<Toml> tables = toml.getTables("product");
List<Toml> employees = toml.getTables("employee");
assertThat(tables, hasSize(2));
assertThat(tables.get(0).getDouble("price"), equalTo(9.99));
assertThat(tables.get(1).getString("type"), equalTo("ZX80"));
assertThat(employees, hasSize(1));
assertThat(employees.get(0).getString("name"), equalTo("Marinus van der Lubbe"));
}
@Test
public void should_parse_nested_table_arrays() throws Exception {
Toml toml = new Toml().read(file("fruit_table_array"));
List<Toml> fruits = toml.getTables("fruit");
assertEquals(2, fruits.size());
Toml apple = fruits.get(0);
assertEquals("apple", apple.getString("name"));
assertEquals("red", apple.getTable("physical").getString("color"));
assertEquals("round", apple.getTable("physical").getString("shape"));
assertEquals(2, apple.getTables("variety").size());
Toml banana = fruits.get(1);
assertEquals("banana", banana.getString("name"));
assertEquals(1, banana.getTables("variety").size());
assertEquals("plantain", banana.getTables("variety").get(0).getString("name"));
}
@Test
public void should_create_array_ancestors_as_tables() throws Exception {
Toml toml = new Toml().read("[[a.b.c]]\n id=3");
assertEquals(3, toml.getTable("a").getTable("b").getTables("c").get(0).getLong("id").intValue());
}
@Test
public void should_navigate_array_with_compound_key() throws Exception {
Toml toml = new Toml().read(file("fruit_table_array"));
List<Toml> appleVarieties = toml.getTables("fruit[0].variety");
Toml appleVariety = toml.getTable("fruit[0].variety[1]");
String bananaVariety = toml.getString("fruit[1].variety[0].name");
assertEquals(2, appleVarieties.size());
assertEquals("red delicious", appleVarieties.get(0).getString("name"));
assertEquals("granny smith", appleVariety.getString("name"));
assertEquals("plantain", bananaVariety);
}
@Test
public void should_return_null_for_missing_table_array() throws Exception {
Toml toml = new Toml().read("[a]");
assertNull(toml.getTables("b"));
}
@Test
public void should_return_null_for_missing_table_array_with_index() throws Exception {
Toml toml = new Toml();
assertNull(toml.getTable("a[0]"));
assertNull(toml.getString("a[0].c"));
}
@Test
public void should_return_null_for_index_out_of_bounds() throws Exception {
Toml toml = new Toml().read("[[a]]\n c = 1");
assertNull(toml.getTable("a[1]"));
}
@Test
public void should_handle_repeated_tables() {
new Toml().read("[[a]]\n [a.b]\n [[a]]\n [a.b]");
}
@Test(expected = IllegalStateException.class)
public void should_fail_on_empty_table_array_name() {
new Toml().read("[[]]");
}
private File file(String fileName) {
return new File(getClass().getResource(fileName + ".toml").getFile());
}
}
|
UTF-8
|
Java
| 4,153 |
java
|
TableArrayTest.java
|
Java
|
[
{
"context": "That(employees.get(0).getString(\"name\"), equalTo(\"Marinus van der Lubbe\"));\n }\n\n @Test\n public void should_parse_neste",
"end": 1618,
"score": 0.9998705983161926,
"start": 1597,
"tag": "NAME",
"value": "Marinus van der Lubbe"
}
] | null |
[] |
package com.moandjiezana.toml;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
public class TableArrayTest {
@Test
public void should_parse_table_array() throws Exception {
Toml toml = new Toml().read(file("products_table_array"));
List<Toml> products = toml.getTables("products");
assertEquals(3, products.size());
assertEquals("Hammer", products.get(0).getString("name"));
assertEquals(738594937L, products.get(0).getLong("sku").longValue());
Assert.assertNull(products.get(1).getString("name"));
assertNull(products.get(1).getLong("sku"));
assertEquals("Nail", products.get(2).getString("name"));
assertEquals(284758393L, products.get(2).getLong("sku").longValue());
assertEquals("gray", products.get(2).getString("color"));
}
@Test
public void should_parse_table_array_out_of_order() throws Exception {
Toml toml = new Toml().read(file("should_parse_table_array_out_of_order"));
List<Toml> tables = toml.getTables("product");
List<Toml> employees = toml.getTables("employee");
assertThat(tables, hasSize(2));
assertThat(tables.get(0).getDouble("price"), equalTo(9.99));
assertThat(tables.get(1).getString("type"), equalTo("ZX80"));
assertThat(employees, hasSize(1));
assertThat(employees.get(0).getString("name"), equalTo("<NAME>"));
}
@Test
public void should_parse_nested_table_arrays() throws Exception {
Toml toml = new Toml().read(file("fruit_table_array"));
List<Toml> fruits = toml.getTables("fruit");
assertEquals(2, fruits.size());
Toml apple = fruits.get(0);
assertEquals("apple", apple.getString("name"));
assertEquals("red", apple.getTable("physical").getString("color"));
assertEquals("round", apple.getTable("physical").getString("shape"));
assertEquals(2, apple.getTables("variety").size());
Toml banana = fruits.get(1);
assertEquals("banana", banana.getString("name"));
assertEquals(1, banana.getTables("variety").size());
assertEquals("plantain", banana.getTables("variety").get(0).getString("name"));
}
@Test
public void should_create_array_ancestors_as_tables() throws Exception {
Toml toml = new Toml().read("[[a.b.c]]\n id=3");
assertEquals(3, toml.getTable("a").getTable("b").getTables("c").get(0).getLong("id").intValue());
}
@Test
public void should_navigate_array_with_compound_key() throws Exception {
Toml toml = new Toml().read(file("fruit_table_array"));
List<Toml> appleVarieties = toml.getTables("fruit[0].variety");
Toml appleVariety = toml.getTable("fruit[0].variety[1]");
String bananaVariety = toml.getString("fruit[1].variety[0].name");
assertEquals(2, appleVarieties.size());
assertEquals("red delicious", appleVarieties.get(0).getString("name"));
assertEquals("granny smith", appleVariety.getString("name"));
assertEquals("plantain", bananaVariety);
}
@Test
public void should_return_null_for_missing_table_array() throws Exception {
Toml toml = new Toml().read("[a]");
assertNull(toml.getTables("b"));
}
@Test
public void should_return_null_for_missing_table_array_with_index() throws Exception {
Toml toml = new Toml();
assertNull(toml.getTable("a[0]"));
assertNull(toml.getString("a[0].c"));
}
@Test
public void should_return_null_for_index_out_of_bounds() throws Exception {
Toml toml = new Toml().read("[[a]]\n c = 1");
assertNull(toml.getTable("a[1]"));
}
@Test
public void should_handle_repeated_tables() {
new Toml().read("[[a]]\n [a.b]\n [[a]]\n [a.b]");
}
@Test(expected = IllegalStateException.class)
public void should_fail_on_empty_table_array_name() {
new Toml().read("[[]]");
}
private File file(String fileName) {
return new File(getClass().getResource(fileName + ".toml").getFile());
}
}
| 4,138 | 0.675175 | 0.66169 | 127 | 31.700787 | 28.676945 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.661417 | false | false |
13
|
32920e85fec8cc4f9412b0bb442335d8240fb79f
| 27,341,761,811,716 |
cb325ce46dfe7b889222a000fe8f3e8e92883a84
|
/lac-service/src/main/java/top/lac/core/pojo/PhotoAlbum.java
|
9b3e738381ed4398c0fcd4aa1c9969ef7d5c42dc
|
[] |
no_license
|
zcjcsl/lac
|
https://github.com/zcjcsl/lac
|
f6dea60fb3a221385185196bf4c8c2914776366d
|
da6d976e4a91eaecdc48ee92f99f25817f01f1c0
|
refs/heads/master
| 2018-03-22T03:00:17.583000 | 2016-08-10T05:23:56 | 2016-08-10T05:23:56 | 55,567,197 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package top.lac.core.pojo;
import java.io.Serializable;
import java.util.Date;
import top.lac.core.enums.PhotoAlbumType;
public class PhotoAlbum implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
/**
* 姓名
*/
private String name;
/**
* 图片数量
*/
private Integer photoCount;
/**
* 相册类型
*/
private PhotoAlbumType type;
/**
* 封面图
*/
private String coverPhoto;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后一次更新时间
*/
private Date lastUpdateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getPhotoCount() {
return photoCount;
}
public void setPhotoCount(Integer photoCount) {
this.photoCount = photoCount;
}
public PhotoAlbumType getType() {
return type;
}
public void setType(PhotoAlbumType type) {
this.type = type;
}
public String getCoverPhoto() {
return coverPhoto;
}
public void setCoverPhoto(String coverPhoto) {
this.coverPhoto = coverPhoto;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
}
|
UTF-8
|
Java
| 1,788 |
java
|
PhotoAlbum.java
|
Java
|
[] | null |
[] |
package top.lac.core.pojo;
import java.io.Serializable;
import java.util.Date;
import top.lac.core.enums.PhotoAlbumType;
public class PhotoAlbum implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
/**
* 姓名
*/
private String name;
/**
* 图片数量
*/
private Integer photoCount;
/**
* 相册类型
*/
private PhotoAlbumType type;
/**
* 封面图
*/
private String coverPhoto;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后一次更新时间
*/
private Date lastUpdateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getPhotoCount() {
return photoCount;
}
public void setPhotoCount(Integer photoCount) {
this.photoCount = photoCount;
}
public PhotoAlbumType getType() {
return type;
}
public void setType(PhotoAlbumType type) {
this.type = type;
}
public String getCoverPhoto() {
return coverPhoto;
}
public void setCoverPhoto(String coverPhoto) {
this.coverPhoto = coverPhoto;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
}
| 1,788 | 0.644919 | 0.644342 | 112 | 13.464286 | 15.149216 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.098214 | false | false |
13
|
cd11a0e6f7c2cb7b52666ee973fbd5c03951c7f4
| 5,437,428,615,441 |
b1bb3e66898f51693d6902f7e0dfa67e808c3a0e
|
/src/ch11/CallableAndFuture.java
|
5a8f103a049897dd57f93d3fb5d1136e6e93a845
|
[] |
no_license
|
liuyangzzu/JavaZZU
|
https://github.com/liuyangzzu/JavaZZU
|
114cb25a20c4473d26e37737b5a8d4da543a5b8c
|
47738b42137e52a6838c98d1ea7c56920e52f37b
|
refs/heads/master
| 2021-01-01T05:19:56.798000 | 2016-06-04T09:04:19 | 2016-06-04T09:04:19 | 58,599,185 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ch11;
import java.util.Random;
import java.util.concurrent.*;
public class CallableAndFuture {
public static void main(String[] args) throws ExecutionException {
ExecutorService threadPool = Executors.newCachedThreadPool();
CompletionService<Integer> cs = new ExecutorCompletionService<Integer>(threadPool);
for (int i = 0; i < 5; i++) {
final int taskID = i;
cs.submit(new Callable<Integer>() {
public Integer call() throws Exception {
Random random = new Random();
Thread.sleep(random.nextInt(3000));
return taskID;
}
});
}
threadPool.shutdown();
for (int i = 0; i < 5; i++) {
try {
System.out.println(cs.take().get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
}
|
UTF-8
|
Java
| 1,039 |
java
|
CallableAndFuture.java
|
Java
|
[] | null |
[] |
package ch11;
import java.util.Random;
import java.util.concurrent.*;
public class CallableAndFuture {
public static void main(String[] args) throws ExecutionException {
ExecutorService threadPool = Executors.newCachedThreadPool();
CompletionService<Integer> cs = new ExecutorCompletionService<Integer>(threadPool);
for (int i = 0; i < 5; i++) {
final int taskID = i;
cs.submit(new Callable<Integer>() {
public Integer call() throws Exception {
Random random = new Random();
Thread.sleep(random.nextInt(3000));
return taskID;
}
});
}
threadPool.shutdown();
for (int i = 0; i < 5; i++) {
try {
System.out.println(cs.take().get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
}
| 1,039 | 0.524543 | 0.514918 | 33 | 30.515152 | 22.726465 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false |
13
|
6b3c172fa91d321a68720d616fb18339e8aa0896
| 1,451,698,978,904 |
866af3bde354e92f8c0bee06ce29407bd8ccc264
|
/villager/csp-api/src/main/java/com/cmig/future/csportal/api/open/message/controllers/PushController.java
|
86cda36c329b2409604f11f968f8138b899294f1
|
[] |
no_license
|
ZMTraobin/ZMTraobin
|
https://github.com/ZMTraobin/ZMTraobin
|
663bd0d40641213bb842a296ff79de7144087420
|
deda16aad14f0da9a5e3b5974393793fda301c26
|
refs/heads/master
| 2020-03-29T01:23:00.929000 | 2018-11-13T03:37:45 | 2018-11-13T03:37:45 | 149,385,921 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cmig.future.csportal.api.open.message.controllers;
import com.cmig.future.csportal.common.exception.DataWarnningException;
import com.cmig.future.csportal.common.oauth2.OAuthConstants;
import com.cmig.future.csportal.common.oauth2.exceptions.OAuth2Exception;
import com.cmig.future.csportal.common.oauth2.utils.OAuthUtils;
import com.cmig.future.csportal.common.utils.Constants;
import com.cmig.future.csportal.common.utils.Jpush.JPushPmCloundUtils;
import com.cmig.future.csportal.common.utils.Jpush.JPushUtils;
import com.cmig.future.csportal.common.utils.SmsUtil;
import com.cmig.future.csportal.common.utils.StringUtils;
import com.cmig.future.csportal.common.utils.sign.CspSignUtil;
import com.cmig.future.csportal.module.base.controllers.BaseExtendController;
import com.cmig.future.csportal.module.base.enums.NotifyCategoryEnum;
import com.cmig.future.csportal.module.base.entity.RetApp;
import com.cmig.future.csportal.module.properties.community.dto.BaseCommunity;
import com.cmig.future.csportal.module.properties.community.service.IBaseCommunityService;
import com.cmig.future.csportal.module.properties.mgtuser.dto.MgtUser;
import com.cmig.future.csportal.module.properties.mgtuser.service.IMgtUserService;
import com.cmig.future.csportal.module.sys.notifyrecord.constants.NotifyMessageTypeEnum;
import com.cmig.future.csportal.module.sys.notifyrecord.dto.SysNotifyRecord;
import com.cmig.future.csportal.module.sys.notifyrecord.service.ISysNotifyRecordService;
import com.cmig.future.csportal.module.sys.openinfo.dto.OpenAppInfo;
import com.cmig.future.csportal.module.user.appuser.dto.AppUser;
import com.cmig.future.csportal.module.user.appuser.service.IAppUserService;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@Controller
@ResponseBody
@RequestMapping(value = "${commonPath}")
public class PushController extends BaseExtendController {
@Autowired
private ISysNotifyRecordService sysNotifyRecordService;
@Autowired
private IBaseCommunityService BaseCommunityService;
@Autowired
private IMgtUserService mgtUserService;
@Autowired
private IAppUserService appUserService;
// 业主端push
@RequestMapping(value = "/push/user", produces = { "application/json" }, method = RequestMethod.POST)
public RetApp user(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String alert = getParam(request, "content", "");
String mobiles = getParam(request, "mobile", "");
String contentExt = getParam(request, "message", "");
String category = getParam(request, "type", "");
String sourceSystemCommunityId=getParam(request, "sourceSystemCommunityId", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobiles)) {
throw new DataWarnningException("手机号不能为空");
}
if (StringUtils.isEmpty(alert)) {
throw new DataWarnningException("消息内容不能为空");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
BaseCommunity communityQuery = new BaseCommunity();
if(!StringUtils.isEmpty(sourceSystemCommunityId)){
communityQuery.setSourceSystem(openAppInfo.getAppName());
communityQuery.setSourceSystemId(sourceSystemCommunityId);
communityQuery = BaseCommunityService.getBySourceSystemId(communityQuery);
if(null==communityQuery){
throw new DataWarnningException("该小区未同步");
}
}
logger.debug("mobile:{} alert:{} message:{} type:{} sourceSystemCommunityId:{}",mobiles,alert,contentExt,category,sourceSystemCommunityId);
for(String mobile:mobiles.split(";")){
SysNotifyRecord sysNotifyRecord = new SysNotifyRecord();
sysNotifyRecord.setMessageType(NotifyMessageTypeEnum.PUSH.getCode());
if (!StringUtils.isEmpty(category)) {
sysNotifyRecord.setCategory(category);
}
sysNotifyRecord.setCmsNotifyId(null);
sysNotifyRecord.setSubject(null);
sysNotifyRecord.setContent(alert);
sysNotifyRecord.setContentExt(URLDecoder.decode(contentExt,"UTF-8"));
sysNotifyRecord.setReceiverInfo(mobile);
sysNotifyRecord.setCommunityId(communityQuery.getId());
sysNotifyRecord.setSourceSystem(openAppInfo.getAppName());
AppUser appUser= appUserService.getByMobile(mobile);
if(null!=appUser){
sysNotifyRecord.setAppUserId(appUser.getId());
sysNotifyRecordService.save(sysNotifyRecord);
JPushUtils.pushAlertWithMessage(sysNotifyRecord);
}else{
sysNotifyRecord.setStatus(Constants.NOTIFY_STATUS_FAIL);
sysNotifyRecord.setRemark("未能匹配用户别名:"+mobile);
sysNotifyRecordService.save(sysNotifyRecord);
}
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
} catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch (OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
// 物管云-物业端push
@RequestMapping(value = "/push/propertyClound", produces = { "application/json" }, method = RequestMethod.POST)
public RetApp propertyClound(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String alert = getParam(request, "content", "");
String mobiles = getParam(request, "mobile", "");
String contentExt = getParam(request, "message", "");
String category = getParam(request, "type", "");
String sourceSystemCommunityId=getParam(request, "sourceSystemCommunityId", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobiles)) {
throw new DataWarnningException("手机号不能为空");
}
if (StringUtils.isEmpty(alert)) {
throw new DataWarnningException("消息内容不能为空");
}
if (StringUtils.isEmpty(category)) {
throw new DataWarnningException("消息分类不能为空");
}
if (StringUtils.isEmpty(sourceSystemCommunityId)) {
throw new DataWarnningException("小区id不能为空");
}
if(!NotifyCategoryEnum.contains(category)){
throw new DataWarnningException("消息分类参数错误");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
BaseCommunity communityQuery = new BaseCommunity();
communityQuery.setSourceSystem(openAppInfo.getAppName());
communityQuery.setSourceSystemId(sourceSystemCommunityId);
communityQuery = BaseCommunityService.getBySourceSystemId(communityQuery);
if(null==communityQuery){
throw new DataWarnningException("该小区未同步");
}
logger.debug("mobile:{} alert:{} message:{} type:{} sourceSystemCommunityId:{}",mobiles,alert,contentExt,category,sourceSystemCommunityId);
for(String mobile:mobiles.split(";")){
SysNotifyRecord sysNotifyRecord = new SysNotifyRecord();
sysNotifyRecord.setMessageType(NotifyMessageTypeEnum.PUSH.getCode());
sysNotifyRecord.setCategory(category);
sysNotifyRecord.setCmsNotifyId(null);
sysNotifyRecord.setSubject(null);
sysNotifyRecord.setContent(alert);
contentExt = StringEscapeUtils.unescapeHtml4(contentExt);
sysNotifyRecord.setContentExt(URLDecoder.decode(contentExt,"UTF-8"));
sysNotifyRecord.setReceiverInfo(mobile);
sysNotifyRecord.setCommunityId(communityQuery.getId());
sysNotifyRecord.setSourceSystem(openAppInfo.getAppName());
MgtUser mgtUser= mgtUserService.getUserByMobile(mobile);
if(null!=mgtUser){
sysNotifyRecord.setMgtUserId(mgtUser.getId());
sysNotifyRecordService.save(sysNotifyRecord);
JPushPmCloundUtils.pushAlertWithMessage(sysNotifyRecord);
}else{
sysNotifyRecord.setStatus(Constants.NOTIFY_STATUS_FAIL);
sysNotifyRecord.setRemark("未能匹配员工别名:"+mobile);
sysNotifyRecordService.save(sysNotifyRecord);
}
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
}catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
// 短信公共接口
@RequestMapping(value = "/sms/message", produces = { "application/json" }, method = RequestMethod.POST)
@ResponseBody
public RetApp sendSmsToAppUser(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String content = getParam(request, "content", "");
String mobile = getParam(request, "mobile", "");
String sign = getParam(request, "sign", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobile)) {
throw new DataWarnningException("手机号不能为空");
}else if(mobile.split(";").length>50){
throw new DataWarnningException("超过单次人数上限");
}
if (StringUtils.isEmpty(content)) {
throw new DataWarnningException("消息内容不能为空");
}
if (StringUtils.isEmpty(sign)) {
throw new DataWarnningException("签名信息不能为空");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
Map<String, String> map = new HashMap();
map.put("appid", appId);
map.put("mobile", mobile);
map.put("content", content);
if (!CspSignUtil.checkSign(map, openAppInfo.getAppSecret(), sign)) {
throw new DataWarnningException("签名验证未通过");
} else {
//logger.debug("手机号:{} 短信内容:{}", mobile, content);
SmsUtil.send(openAppInfo, content, mobile.split(";"));
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
}catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch(OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
}
|
UTF-8
|
Java
| 11,971 |
java
|
PushController.java
|
Java
|
[] | null |
[] |
package com.cmig.future.csportal.api.open.message.controllers;
import com.cmig.future.csportal.common.exception.DataWarnningException;
import com.cmig.future.csportal.common.oauth2.OAuthConstants;
import com.cmig.future.csportal.common.oauth2.exceptions.OAuth2Exception;
import com.cmig.future.csportal.common.oauth2.utils.OAuthUtils;
import com.cmig.future.csportal.common.utils.Constants;
import com.cmig.future.csportal.common.utils.Jpush.JPushPmCloundUtils;
import com.cmig.future.csportal.common.utils.Jpush.JPushUtils;
import com.cmig.future.csportal.common.utils.SmsUtil;
import com.cmig.future.csportal.common.utils.StringUtils;
import com.cmig.future.csportal.common.utils.sign.CspSignUtil;
import com.cmig.future.csportal.module.base.controllers.BaseExtendController;
import com.cmig.future.csportal.module.base.enums.NotifyCategoryEnum;
import com.cmig.future.csportal.module.base.entity.RetApp;
import com.cmig.future.csportal.module.properties.community.dto.BaseCommunity;
import com.cmig.future.csportal.module.properties.community.service.IBaseCommunityService;
import com.cmig.future.csportal.module.properties.mgtuser.dto.MgtUser;
import com.cmig.future.csportal.module.properties.mgtuser.service.IMgtUserService;
import com.cmig.future.csportal.module.sys.notifyrecord.constants.NotifyMessageTypeEnum;
import com.cmig.future.csportal.module.sys.notifyrecord.dto.SysNotifyRecord;
import com.cmig.future.csportal.module.sys.notifyrecord.service.ISysNotifyRecordService;
import com.cmig.future.csportal.module.sys.openinfo.dto.OpenAppInfo;
import com.cmig.future.csportal.module.user.appuser.dto.AppUser;
import com.cmig.future.csportal.module.user.appuser.service.IAppUserService;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@Controller
@ResponseBody
@RequestMapping(value = "${commonPath}")
public class PushController extends BaseExtendController {
@Autowired
private ISysNotifyRecordService sysNotifyRecordService;
@Autowired
private IBaseCommunityService BaseCommunityService;
@Autowired
private IMgtUserService mgtUserService;
@Autowired
private IAppUserService appUserService;
// 业主端push
@RequestMapping(value = "/push/user", produces = { "application/json" }, method = RequestMethod.POST)
public RetApp user(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String alert = getParam(request, "content", "");
String mobiles = getParam(request, "mobile", "");
String contentExt = getParam(request, "message", "");
String category = getParam(request, "type", "");
String sourceSystemCommunityId=getParam(request, "sourceSystemCommunityId", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobiles)) {
throw new DataWarnningException("手机号不能为空");
}
if (StringUtils.isEmpty(alert)) {
throw new DataWarnningException("消息内容不能为空");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
BaseCommunity communityQuery = new BaseCommunity();
if(!StringUtils.isEmpty(sourceSystemCommunityId)){
communityQuery.setSourceSystem(openAppInfo.getAppName());
communityQuery.setSourceSystemId(sourceSystemCommunityId);
communityQuery = BaseCommunityService.getBySourceSystemId(communityQuery);
if(null==communityQuery){
throw new DataWarnningException("该小区未同步");
}
}
logger.debug("mobile:{} alert:{} message:{} type:{} sourceSystemCommunityId:{}",mobiles,alert,contentExt,category,sourceSystemCommunityId);
for(String mobile:mobiles.split(";")){
SysNotifyRecord sysNotifyRecord = new SysNotifyRecord();
sysNotifyRecord.setMessageType(NotifyMessageTypeEnum.PUSH.getCode());
if (!StringUtils.isEmpty(category)) {
sysNotifyRecord.setCategory(category);
}
sysNotifyRecord.setCmsNotifyId(null);
sysNotifyRecord.setSubject(null);
sysNotifyRecord.setContent(alert);
sysNotifyRecord.setContentExt(URLDecoder.decode(contentExt,"UTF-8"));
sysNotifyRecord.setReceiverInfo(mobile);
sysNotifyRecord.setCommunityId(communityQuery.getId());
sysNotifyRecord.setSourceSystem(openAppInfo.getAppName());
AppUser appUser= appUserService.getByMobile(mobile);
if(null!=appUser){
sysNotifyRecord.setAppUserId(appUser.getId());
sysNotifyRecordService.save(sysNotifyRecord);
JPushUtils.pushAlertWithMessage(sysNotifyRecord);
}else{
sysNotifyRecord.setStatus(Constants.NOTIFY_STATUS_FAIL);
sysNotifyRecord.setRemark("未能匹配用户别名:"+mobile);
sysNotifyRecordService.save(sysNotifyRecord);
}
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
} catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch (OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
// 物管云-物业端push
@RequestMapping(value = "/push/propertyClound", produces = { "application/json" }, method = RequestMethod.POST)
public RetApp propertyClound(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String alert = getParam(request, "content", "");
String mobiles = getParam(request, "mobile", "");
String contentExt = getParam(request, "message", "");
String category = getParam(request, "type", "");
String sourceSystemCommunityId=getParam(request, "sourceSystemCommunityId", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobiles)) {
throw new DataWarnningException("手机号不能为空");
}
if (StringUtils.isEmpty(alert)) {
throw new DataWarnningException("消息内容不能为空");
}
if (StringUtils.isEmpty(category)) {
throw new DataWarnningException("消息分类不能为空");
}
if (StringUtils.isEmpty(sourceSystemCommunityId)) {
throw new DataWarnningException("小区id不能为空");
}
if(!NotifyCategoryEnum.contains(category)){
throw new DataWarnningException("消息分类参数错误");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
BaseCommunity communityQuery = new BaseCommunity();
communityQuery.setSourceSystem(openAppInfo.getAppName());
communityQuery.setSourceSystemId(sourceSystemCommunityId);
communityQuery = BaseCommunityService.getBySourceSystemId(communityQuery);
if(null==communityQuery){
throw new DataWarnningException("该小区未同步");
}
logger.debug("mobile:{} alert:{} message:{} type:{} sourceSystemCommunityId:{}",mobiles,alert,contentExt,category,sourceSystemCommunityId);
for(String mobile:mobiles.split(";")){
SysNotifyRecord sysNotifyRecord = new SysNotifyRecord();
sysNotifyRecord.setMessageType(NotifyMessageTypeEnum.PUSH.getCode());
sysNotifyRecord.setCategory(category);
sysNotifyRecord.setCmsNotifyId(null);
sysNotifyRecord.setSubject(null);
sysNotifyRecord.setContent(alert);
contentExt = StringEscapeUtils.unescapeHtml4(contentExt);
sysNotifyRecord.setContentExt(URLDecoder.decode(contentExt,"UTF-8"));
sysNotifyRecord.setReceiverInfo(mobile);
sysNotifyRecord.setCommunityId(communityQuery.getId());
sysNotifyRecord.setSourceSystem(openAppInfo.getAppName());
MgtUser mgtUser= mgtUserService.getUserByMobile(mobile);
if(null!=mgtUser){
sysNotifyRecord.setMgtUserId(mgtUser.getId());
sysNotifyRecordService.save(sysNotifyRecord);
JPushPmCloundUtils.pushAlertWithMessage(sysNotifyRecord);
}else{
sysNotifyRecord.setStatus(Constants.NOTIFY_STATUS_FAIL);
sysNotifyRecord.setRemark("未能匹配员工别名:"+mobile);
sysNotifyRecordService.save(sysNotifyRecord);
}
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
}catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
// 短信公共接口
@RequestMapping(value = "/sms/message", produces = { "application/json" }, method = RequestMethod.POST)
@ResponseBody
public RetApp sendSmsToAppUser(HttpServletRequest request, HttpServletResponse response) {
RetApp retApp = new RetApp();
String content = getParam(request, "content", "");
String mobile = getParam(request, "mobile", "");
String sign = getParam(request, "sign", "");
final String appId = getParam(request, OAuthConstants.OAUTH_APP_ID, "");
try {
if (StringUtils.isEmpty(mobile)) {
throw new DataWarnningException("手机号不能为空");
}else if(mobile.split(";").length>50){
throw new DataWarnningException("超过单次人数上限");
}
if (StringUtils.isEmpty(content)) {
throw new DataWarnningException("消息内容不能为空");
}
if (StringUtils.isEmpty(sign)) {
throw new DataWarnningException("签名信息不能为空");
}
// 校验appid
OpenAppInfo openAppInfo = OAuthUtils.getOpenAppInfo(appId);
Map<String, String> map = new HashMap();
map.put("appid", appId);
map.put("mobile", mobile);
map.put("content", content);
if (!CspSignUtil.checkSign(map, openAppInfo.getAppSecret(), sign)) {
throw new DataWarnningException("签名验证未通过");
} else {
//logger.debug("手机号:{} 短信内容:{}", mobile, content);
SmsUtil.send(openAppInfo, content, mobile.split(";"));
}
retApp.setStatus(OK);
retApp.setMessage("发送成功");
}catch (DataWarnningException e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch(OAuth2Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage(e.getMessage());
}catch (Exception e) {
e.printStackTrace();
retApp.setStatus(FAIL);
retApp.setMessage("发送失败");
}
return retApp;
}
}
| 11,971 | 0.67796 | 0.676842 | 269 | 42.230484 | 28.316303 | 151 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.643123 | false | false |
13
|
19cc7aff7e32210d161bc8643206ecf313ec528c
| 16,183,436,804,617 |
eaa057992c95150ba3c6312028f0fffd8a3f325b
|
/2/DataPoint.java
|
1e5f4fc6292d80e24315540d7c967c642f5159f8
|
[] |
no_license
|
wavebeem/sim
|
https://github.com/wavebeem/sim
|
3198c9f4cbefe19b3e28896b2bc1147869022ff6
|
537230d0e93b9a4290f709046c9423e12948d2b3
|
refs/heads/master
| 2020-04-16T01:32:56.269000 | 2012-04-02T09:19:05 | 2012-04-02T09:19:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class DataPoint {
public final int h;
public final int p;
public DataPoint(int h, int p) {
this.h = h;
this.p = p;
}
}
|
UTF-8
|
Java
| 159 |
java
|
DataPoint.java
|
Java
|
[] | null |
[] |
public class DataPoint {
public final int h;
public final int p;
public DataPoint(int h, int p) {
this.h = h;
this.p = p;
}
}
| 159 | 0.534591 | 0.534591 | 9 | 16.666666 | 11.440668 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
13
|
56c391e41e9d807787cb8a3030401e4fef0870fd
| 9,766,755,677,825 |
617564e22272d5b04da8ba2db95882bd4ceacec2
|
/java-base-examples-guides/src/main/java/com/github/ljmatlight/demo/alipay/AlipayPayRequest.java
|
2449e50c037f24beb17ad5e4707cb1905d0d3465
|
[] |
no_license
|
ljmatlight/java-best-practices
|
https://github.com/ljmatlight/java-best-practices
|
70e311b5a0def8830dd1489968a75845b7803429
|
e26bae33da89ba5cc9c3722744fd55ff41159757
|
refs/heads/master
| 2021-05-10T18:55:10.928000 | 2018-07-31T16:42:32 | 2018-07-31T16:42:32 | 118,139,650 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.github.ljmatlight.demo.alipay;
import com.github.ljmatlight.demo.PayRequest;
/**
* 支付宝支付请求参数定义
*
* @author tengpeng.gao
* @since 2018/7/31
*/
public class AlipayPayRequest implements PayRequest {
private String alipayId;
public String getAlipayId() {
return alipayId;
}
@Override
public String toString() {
return "AlipayPayRequest{" + "alipayId='" + alipayId + '\'' + '}';
}
public void setAlipayId(String alipayId) {
this.alipayId = alipayId;
}
}
|
UTF-8
|
Java
| 550 |
java
|
AlipayPayRequest.java
|
Java
|
[
{
"context": "demo.PayRequest;\n\n/**\n * 支付宝支付请求参数定义\n *\n * @author tengpeng.gao\n * @since 2018/7/31\n */\npublic class AlipayPayReq",
"end": 136,
"score": 0.9969317317008972,
"start": 124,
"tag": "NAME",
"value": "tengpeng.gao"
}
] | null |
[] |
package com.github.ljmatlight.demo.alipay;
import com.github.ljmatlight.demo.PayRequest;
/**
* 支付宝支付请求参数定义
*
* @author tengpeng.gao
* @since 2018/7/31
*/
public class AlipayPayRequest implements PayRequest {
private String alipayId;
public String getAlipayId() {
return alipayId;
}
@Override
public String toString() {
return "AlipayPayRequest{" + "alipayId='" + alipayId + '\'' + '}';
}
public void setAlipayId(String alipayId) {
this.alipayId = alipayId;
}
}
| 550 | 0.645833 | 0.632576 | 27 | 18.555555 | 19.892923 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false |
13
|
3eaccf065db3de6a72078690f059d5156dcc9baf
| 18,665,927,894,431 |
2ebca69e016eeb9e218b3172930e8b80ed86ca40
|
/spring-functionaltest-domain/src/main/java/jp/co/ntt/fw/spring/functionaltest/domain/repository/dmly/DeliveryOrderCriteria.java
|
053c6527c86de9e8606a5fb9a259563cac32e4e3
|
[] |
no_license
|
btkatoutmj/spring-functionaltest
|
https://github.com/btkatoutmj/spring-functionaltest
|
ca1dd65dac88ca16e7fd436e731d05ee8fd931fa
|
7dd1337592dbc2482d33d48d900122f967ce47a3
|
refs/heads/master
| 2021-01-24T05:05:28.438000 | 2017-05-30T09:31:20 | 2017-06-12T00:57:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright(c) 2014-2017 NTT Corporation.
*/
package jp.co.ntt.fw.spring.functionaltest.domain.repository.dmly;
import java.io.Serializable;
import java.util.Date;
public class DeliveryOrderCriteria implements Serializable {
private static final long serialVersionUID = 1L;
private Date fromAcceptDatetime;
private Date toAcceptDatetime;
private Date updateCompletionDatetime;
public Date getFromAcceptDatetime() {
return fromAcceptDatetime;
}
public void setFromAcceptDatetime(Date fromAcceptDatetime) {
this.fromAcceptDatetime = fromAcceptDatetime;
}
public Date getToAcceptDatetime() {
return toAcceptDatetime;
}
public void setToAcceptDatetime(Date toAcceptDatetime) {
this.toAcceptDatetime = toAcceptDatetime;
}
public Date getUpdateCompletionDatetime() {
return updateCompletionDatetime;
}
public void setUpdateCompletionDatetime(Date updateCompletionDatetime) {
this.updateCompletionDatetime = updateCompletionDatetime;
}
}
|
UTF-8
|
Java
| 1,061 |
java
|
DeliveryOrderCriteria.java
|
Java
|
[] | null |
[] |
/*
* Copyright(c) 2014-2017 NTT Corporation.
*/
package jp.co.ntt.fw.spring.functionaltest.domain.repository.dmly;
import java.io.Serializable;
import java.util.Date;
public class DeliveryOrderCriteria implements Serializable {
private static final long serialVersionUID = 1L;
private Date fromAcceptDatetime;
private Date toAcceptDatetime;
private Date updateCompletionDatetime;
public Date getFromAcceptDatetime() {
return fromAcceptDatetime;
}
public void setFromAcceptDatetime(Date fromAcceptDatetime) {
this.fromAcceptDatetime = fromAcceptDatetime;
}
public Date getToAcceptDatetime() {
return toAcceptDatetime;
}
public void setToAcceptDatetime(Date toAcceptDatetime) {
this.toAcceptDatetime = toAcceptDatetime;
}
public Date getUpdateCompletionDatetime() {
return updateCompletionDatetime;
}
public void setUpdateCompletionDatetime(Date updateCompletionDatetime) {
this.updateCompletionDatetime = updateCompletionDatetime;
}
}
| 1,061 | 0.737983 | 0.7295 | 43 | 23.674419 | 24.622471 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.302326 | false | false |
13
|
b87d874c2708eb4cf8e62463ea1873871fec55b5
| 18,665,927,896,702 |
ae0a1a7703cb506b1f8b0c544aa761fecb7e1ae1
|
/src/com/sai/model/spring/dao/LikesDAOMybatis.java
|
a758fc788208e0c913fd52c9127d3e71f4fd706a
|
[] |
no_license
|
GyusLee/sai_test
|
https://github.com/GyusLee/sai_test
|
d10e37ddd1a2db3d7263c2083f2bbf72556475f2
|
51cc075bb024aa4e3f1766ea18e435b15addae42
|
refs/heads/master
| 2021-01-10T18:11:26.842000 | 2016-12-12T07:16:23 | 2016-12-12T07:16:23 | 71,980,223 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sai.model.spring.dao;
import java.util.List;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.sai.model.domain.Likes;
@Repository
public class LikesDAOMybatis implements LikesDAO{
@Autowired
private SqlSessionTemplate sqlSessionTemplate;
public List selectAll(int l_num) {
List list=sqlSessionTemplate.selectList("Likes.selectAll", l_num);
return list;
}
public Likes select(Likes likes) {
Likes likesTemp=new Likes();
likesTemp=sqlSessionTemplate.selectOne("Likes.selectOne", likes);
System.out.println(likesTemp);
return likesTemp;
}
public int insert(Likes likes) {
int result=sqlSessionTemplate.insert("Likes.insert", likes);
return result;
}
public int delete(Likes likes) {
int result=sqlSessionTemplate.delete("Likes.delete", likes);
return result;
}
}
|
UTF-8
|
Java
| 935 |
java
|
LikesDAOMybatis.java
|
Java
|
[] | null |
[] |
package com.sai.model.spring.dao;
import java.util.List;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.sai.model.domain.Likes;
@Repository
public class LikesDAOMybatis implements LikesDAO{
@Autowired
private SqlSessionTemplate sqlSessionTemplate;
public List selectAll(int l_num) {
List list=sqlSessionTemplate.selectList("Likes.selectAll", l_num);
return list;
}
public Likes select(Likes likes) {
Likes likesTemp=new Likes();
likesTemp=sqlSessionTemplate.selectOne("Likes.selectOne", likes);
System.out.println(likesTemp);
return likesTemp;
}
public int insert(Likes likes) {
int result=sqlSessionTemplate.insert("Likes.insert", likes);
return result;
}
public int delete(Likes likes) {
int result=sqlSessionTemplate.delete("Likes.delete", likes);
return result;
}
}
| 935 | 0.774332 | 0.774332 | 40 | 22.375 | 22.508539 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.3 | false | false |
13
|
ea44dc6dde111eb345b9bbdffc1f9e618fcf888c
| 4,088,808,922,709 |
6a8ab2b5d257691a4dd8ef211eddeb8c2324e91c
|
/src/it/nextre/academy/pr130120/pattern/visitor/TotaleCarrelloPromoRomanzi30.java
|
7bd679b9e3fe34472d42843668f7984cd8f80b76
|
[] |
no_license
|
valix85/ac130120
|
https://github.com/valix85/ac130120
|
f32cfec96f776c287125c29dc8b26e7c63582bff
|
75099e7c8ac4fcd3c9976344c55d49740f2c32c8
|
refs/heads/master
| 2020-12-18T23:55:35.683000 | 2020-03-04T10:46:35 | 2020-03-04T10:46:35 | 235,560,803 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package it.nextre.academy.pr130120.pattern.visitor;
public class TotaleCarrelloPromoRomanzi30 implements ProdottoVisitor{
private double totale;
private Carrello cart;
public TotaleCarrelloPromoRomanzi30(Carrello cart) {
this.cart=cart;
}
@Override
public void visit(Gadget prodotto) {
totale+=prodotto.getPrezzo();
}
@Override
public void visit(Libro prodotto) {
System.out.println("prezzo libro: "+prodotto.getTitolo()+" "+prodotto.getPrezzo());
if (prodotto instanceof Romanzo){
visit((Romanzo)prodotto);
}else {
totale += prodotto.getPrezzo();
}
}
public void visit(Romanzo prodotto) {
System.out.println("Sconto promo romanzo 30%");
totale+=(prodotto.getPrezzo()-(prodotto.getPrezzo()*0.3));
}
public double getTotale(){
for(Acquistabile item : cart.getItems()){
item.accept(this);
}
return totale;
}
}//end class
|
UTF-8
|
Java
| 1,006 |
java
|
TotaleCarrelloPromoRomanzi30.java
|
Java
|
[] | null |
[] |
package it.nextre.academy.pr130120.pattern.visitor;
public class TotaleCarrelloPromoRomanzi30 implements ProdottoVisitor{
private double totale;
private Carrello cart;
public TotaleCarrelloPromoRomanzi30(Carrello cart) {
this.cart=cart;
}
@Override
public void visit(Gadget prodotto) {
totale+=prodotto.getPrezzo();
}
@Override
public void visit(Libro prodotto) {
System.out.println("prezzo libro: "+prodotto.getTitolo()+" "+prodotto.getPrezzo());
if (prodotto instanceof Romanzo){
visit((Romanzo)prodotto);
}else {
totale += prodotto.getPrezzo();
}
}
public void visit(Romanzo prodotto) {
System.out.println("Sconto promo romanzo 30%");
totale+=(prodotto.getPrezzo()-(prodotto.getPrezzo()*0.3));
}
public double getTotale(){
for(Acquistabile item : cart.getItems()){
item.accept(this);
}
return totale;
}
}//end class
| 1,006 | 0.625248 | 0.611332 | 38 | 25.473684 | 23.016855 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.315789 | false | false |
13
|
13cc3798b5f3e8cc86c712050c23f97208570626
| 21,981,642,650,253 |
1f712e261bb9d4ff798f52088a44bf085a32b182
|
/app/src/main/java/com/p000/brt.java
|
892907f794d7fcd7cf9f99023265919a4430e040
|
[] |
no_license
|
XuanTung95/demoApp
|
https://github.com/XuanTung95/demoApp
|
884bedde516dfb514dc1351624b3b89d3f5ea1bc
|
671201658af50253f56d1fcb7c0c8cb78be512ec
|
refs/heads/master
| 2021-09-21T12:51:01.612000 | 2018-08-27T00:47:54 | 2018-08-27T00:47:54 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.p000;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import p000.att.C0806a;
import p000.awe.C0858a;
import p000.awe.C0859b;
/* renamed from: brt */
class brt {
/* renamed from: a */
private static final brm<C0806a> f7462a = new brm(brz.m10584a(), true);
/* renamed from: b */
private final bqw f7463b;
/* renamed from: c */
private final Map<String, bqx> f7464c;
/* renamed from: d */
private final Map<String, bqx> f7465d;
/* renamed from: e */
private final Map<String, bqx> f7466e;
/* renamed from: f */
private final bsc<C0858a, brm<C0806a>> f7467f;
/* renamed from: g */
private final bsc<String, C1431b> f7468g;
/* renamed from: h */
private final Set<C0859b> f7469h;
/* renamed from: i */
private final bqs f7470i;
/* renamed from: j */
private final Map<String, C1432c> f7471j;
/* renamed from: k */
private volatile String f7472k;
/* renamed from: l */
private int f7473l;
/* renamed from: brt$a */
interface C1428a {
/* renamed from: a */
void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr);
}
/* renamed from: brt$2 */
class C14302 implements C1428a {
C14302(brt brt) {
}
/* renamed from: a */
public void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr) {
set.addAll(c0859b.m6132c());
set2.addAll(c0859b.m6133d());
brr.mo1414e();
brr.mo1415f();
}
}
/* renamed from: brt$b */
static class C1431b {
/* renamed from: a */
private brm<C0806a> f7454a;
/* renamed from: b */
private C0806a f7455b;
public C1431b(brm<C0806a> brm, C0806a c0806a) {
this.f7454a = brm;
this.f7455b = c0806a;
}
/* renamed from: a */
public brm<C0806a> m10550a() {
return this.f7454a;
}
/* renamed from: b */
public C0806a m10551b() {
return this.f7455b;
}
}
/* renamed from: brt$c */
static class C1432c {
/* renamed from: a */
private final Set<C0859b> f7456a = new HashSet();
/* renamed from: b */
private final Map<C0859b, List<C0858a>> f7457b = new HashMap();
/* renamed from: c */
private final Map<C0859b, List<C0858a>> f7458c = new HashMap();
/* renamed from: d */
private final Map<C0859b, List<String>> f7459d = new HashMap();
/* renamed from: e */
private final Map<C0859b, List<String>> f7460e = new HashMap();
/* renamed from: f */
private C0858a f7461f;
/* renamed from: a */
public Set<C0859b> m10552a() {
return this.f7456a;
}
/* renamed from: b */
public Map<C0859b, List<C0858a>> m10553b() {
return this.f7457b;
}
/* renamed from: c */
public Map<C0859b, List<String>> m10554c() {
return this.f7459d;
}
/* renamed from: d */
public Map<C0859b, List<String>> m10555d() {
return this.f7460e;
}
/* renamed from: e */
public Map<C0859b, List<C0858a>> m10556e() {
return this.f7458c;
}
/* renamed from: f */
public C0858a m10557f() {
return this.f7461f;
}
}
/* renamed from: a */
private brm<C0806a> m10558a(C0806a c0806a, Set<String> set, bsa bsa) {
if (!c0806a.f4509l) {
return new brm(c0806a, true);
}
C0806a a;
int i;
brm a2;
String str;
String valueOf;
switch (c0806a.f4498a) {
case 2:
a = awe.m6136a(c0806a);
a.f4500c = new C0806a[c0806a.f4500c.length];
for (i = 0; i < c0806a.f4500c.length; i++) {
a2 = m10558a(c0806a.f4500c[i], (Set) set, bsa.mo1418a(i));
if (a2 == f7462a) {
return f7462a;
}
a.f4500c[i] = (C0806a) a2.m10537a();
}
return new brm(a, false);
case 3:
a = awe.m6136a(c0806a);
if (c0806a.f4501d.length != c0806a.f4502e.length) {
str = "Invalid serving value: ";
valueOf = String.valueOf(c0806a.toString());
brd.m10493a(valueOf.length() != 0 ? str.concat(valueOf) : new String(str));
return f7462a;
}
a.f4501d = new C0806a[c0806a.f4501d.length];
a.f4502e = new C0806a[c0806a.f4501d.length];
for (i = 0; i < c0806a.f4501d.length; i++) {
a2 = m10558a(c0806a.f4501d[i], (Set) set, bsa.mo1419b(i));
brm a3 = m10558a(c0806a.f4502e[i], (Set) set, bsa.mo1420c(i));
if (a2 == f7462a || a3 == f7462a) {
return f7462a;
}
a.f4501d[i] = (C0806a) a2.m10537a();
a.f4502e[i] = (C0806a) a3.m10537a();
}
return new brm(a, false);
case 4:
if (set.contains(c0806a.f4503f)) {
valueOf = String.valueOf(c0806a.f4503f);
str = String.valueOf(set.toString());
brd.m10493a(new StringBuilder((String.valueOf(valueOf).length() + 79) + String.valueOf(str).length()).append("Macro cycle detected. Current macro reference: ").append(valueOf).append(". Previous macro references: ").append(str).append(".").toString());
return f7462a;
}
set.add(c0806a.f4503f);
brm<C0806a> a4 = bsb.m10597a(m10559a(c0806a.f4503f, (Set) set, bsa.mo1417a()), c0806a.f4508k);
set.remove(c0806a.f4503f);
return a4;
case 7:
a = awe.m6136a(c0806a);
a.f4507j = new C0806a[c0806a.f4507j.length];
for (i = 0; i < c0806a.f4507j.length; i++) {
a2 = m10558a(c0806a.f4507j[i], (Set) set, bsa.mo1421d(i));
if (a2 == f7462a) {
return f7462a;
}
a.f4507j[i] = (C0806a) a2.m10537a();
}
return new brm(a, false);
default:
brd.m10493a("Unknown type: " + c0806a.f4498a);
return f7462a;
}
}
/* renamed from: a */
private brm<C0806a> m10559a(String str, Set<String> set, brf brf) {
this.f7473l++;
C1431b c1431b = (C1431b) this.f7468g.m10600a(str);
if (c1431b != null) {
m10563a(c1431b.m10551b(), (Set) set);
this.f7473l--;
return c1431b.m10550a();
}
C1432c c1432c = (C1432c) this.f7471j.get(str);
if (c1432c == null) {
String valueOf = String.valueOf(m10562a());
brd.m10493a(new StringBuilder((String.valueOf(valueOf).length() + 15) + String.valueOf(str).length()).append(valueOf).append("Invalid macro: ").append(str).toString());
this.f7473l--;
return f7462a;
}
C0858a f;
brm a = m10566a(str, c1432c.m10552a(), c1432c.m10553b(), c1432c.m10554c(), c1432c.m10556e(), c1432c.m10555d(), set, brf.mo1407b());
if (((Set) a.m10537a()).isEmpty()) {
f = c1432c.m10557f();
} else {
if (((Set) a.m10537a()).size() > 1) {
valueOf = String.valueOf(m10562a());
brd.m10495b(new StringBuilder((String.valueOf(valueOf).length() + 37) + String.valueOf(str).length()).append(valueOf).append("Multiple macros active for macroName ").append(str).toString());
}
f = (C0858a) ((Set) a.m10537a()).iterator().next();
}
if (f == null) {
this.f7473l--;
return f7462a;
}
brm a2 = m10560a(this.f7466e, f, (Set) set, brf.mo1406a());
boolean z = a.m10538b() && a2.m10538b();
brm<C0806a> brm = a2 == f7462a ? f7462a : new brm((C0806a) a2.m10537a(), z);
C0806a b = f.m6129b();
if (brm.m10538b()) {
this.f7468g.m10601a(str, new C1431b(brm, b));
}
m10563a(b, (Set) set);
this.f7473l--;
return brm;
}
/* renamed from: a */
private brm<C0806a> m10560a(Map<String, bqx> map, C0858a c0858a, Set<String> set, bro bro) {
boolean z = true;
C0806a c0806a = (C0806a) c0858a.m6127a().get(ats.FUNCTION.toString());
if (c0806a == null) {
brd.m10493a("No function id in properties");
return f7462a;
}
String str = c0806a.f4504g;
bqx bqx = (bqx) map.get(str);
if (bqx == null) {
brd.m10493a(String.valueOf(str).concat(" has no backing implementation."));
return f7462a;
}
brm<C0806a> brm = (brm) this.f7467f.m10600a(c0858a);
if (brm != null) {
return brm;
}
Map hashMap = new HashMap();
boolean z2 = true;
for (Entry entry : c0858a.m6127a().entrySet()) {
brm a = m10558a((C0806a) entry.getValue(), (Set) set, bro.mo1408a((String) entry.getKey()).mo1409a((C0806a) entry.getValue()));
if (a == f7462a) {
return f7462a;
}
boolean z3;
if (a.m10538b()) {
c0858a.m6128a((String) entry.getKey(), (C0806a) a.m10537a());
z3 = z2;
} else {
z3 = false;
}
hashMap.put((String) entry.getKey(), (C0806a) a.m10537a());
z2 = z3;
}
if (bqx.m10480a(hashMap.keySet())) {
if (!(z2 && bqx.m10479a())) {
z = false;
}
brm = new brm(bqx.m10478a(hashMap), z);
if (!z) {
return brm;
}
this.f7467f.m10601a(c0858a, brm);
return brm;
}
String valueOf = String.valueOf(bqx.m10481b());
String valueOf2 = String.valueOf(hashMap.keySet());
brd.m10493a(new StringBuilder(((String.valueOf(str).length() + 43) + String.valueOf(valueOf).length()) + String.valueOf(valueOf2).length()).append("Incorrect keys for function ").append(str).append(" required ").append(valueOf).append(" had ").append(valueOf2).toString());
return f7462a;
}
/* renamed from: a */
private brm<Set<C0858a>> m10561a(Set<C0859b> set, Set<String> set2, C1428a c1428a, brs brs) {
Set hashSet = new HashSet();
Collection hashSet2 = new HashSet();
boolean z = true;
for (C0859b c0859b : set) {
brr a = brs.mo1416a();
brm a2 = m10565a(c0859b, (Set) set2, a);
if (((Boolean) a2.m10537a()).booleanValue()) {
c1428a.mo1422a(c0859b, hashSet, hashSet2, a);
}
boolean z2 = z && a2.m10538b();
z = z2;
}
hashSet.removeAll(hashSet2);
return new brm(hashSet, z);
}
/* renamed from: a */
private String m10562a() {
if (this.f7473l <= 1) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Integer.toString(this.f7473l));
for (int i = 2; i < this.f7473l; i++) {
stringBuilder.append(' ');
}
stringBuilder.append(": ");
return stringBuilder.toString();
}
/* renamed from: a */
private void m10563a(C0806a c0806a, Set<String> set) {
if (c0806a != null) {
brm a = m10558a(c0806a, (Set) set, new brl());
if (a != f7462a) {
Object c = brz.m10591c((C0806a) a.m10537a());
if (c instanceof Map) {
this.f7470i.m10458a((Map) c);
} else if (c instanceof List) {
for (Object c2 : (List) c2) {
if (c2 instanceof Map) {
this.f7470i.m10458a((Map) c2);
} else {
brd.m10495b("pushAfterEvaluate: value not a Map");
}
}
} else {
brd.m10495b("pushAfterEvaluate: value not a Map or List");
}
}
}
}
/* renamed from: a */
brm<Boolean> m10564a(C0858a c0858a, Set<String> set, bro bro) {
brm a = m10560a(this.f7465d, c0858a, (Set) set, bro);
Object b = brz.m10588b((C0806a) a.m10537a());
brz.m10590c(b);
return new brm(b, a.m10538b());
}
/* renamed from: a */
brm<Boolean> m10565a(C0859b c0859b, Set<String> set, brr brr) {
boolean z = true;
for (C0858a a : c0859b.m6131b()) {
brm a2 = m10564a(a, (Set) set, brr.mo1410a());
if (((Boolean) a2.m10537a()).booleanValue()) {
brz.m10590c(Boolean.valueOf(false));
return new brm(Boolean.valueOf(false), a2.m10538b());
}
boolean z2 = z && a2.m10538b();
z = z2;
}
for (C0858a a3 : c0859b.m6130a()) {
a2 = m10564a(a3, (Set) set, brr.mo1411b());
if (((Boolean) a2.m10537a()).booleanValue()) {
z = z && a2.m10538b();
} else {
brz.m10590c(Boolean.valueOf(false));
return new brm(Boolean.valueOf(false), a2.m10538b());
}
}
brz.m10590c(Boolean.valueOf(true));
return new brm(Boolean.valueOf(true), z);
}
/* renamed from: a */
brm<Set<C0858a>> m10566a(String str, Set<C0859b> set, Map<C0859b, List<C0858a>> map, Map<C0859b, List<String>> map2, Map<C0859b, List<C0858a>> map3, Map<C0859b, List<String>> map4, Set<String> set2, brs brs) {
final Map<C0859b, List<C0858a>> map5 = map;
final Map<C0859b, List<String>> map6 = map2;
final Map<C0859b, List<C0858a>> map7 = map3;
final Map<C0859b, List<String>> map8 = map4;
return m10561a((Set) set, (Set) set2, new C1428a(this) {
/* renamed from: a */
public void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr) {
List list = (List) map5.get(c0859b);
map6.get(c0859b);
if (list != null) {
set.addAll(list);
brr.mo1412c();
}
list = (List) map7.get(c0859b);
map8.get(c0859b);
if (list != null) {
set2.addAll(list);
brr.mo1413d();
}
}
}, brs);
}
/* renamed from: a */
brm<Set<C0858a>> m10567a(Set<C0859b> set, brs brs) {
return m10561a((Set) set, new HashSet(), new C14302(this), brs);
}
/* renamed from: a */
public synchronized void m10568a(String str) {
m10569b(str);
bsf a = this.f7463b.m10477a(str).m10476a();
for (C0858a a2 : (Set) m10567a(this.f7469h, a.m10614b()).m10537a()) {
m10560a(this.f7464c, a2, new HashSet(), a.m10613a());
}
m10569b(null);
}
/* renamed from: b */
synchronized void m10569b(String str) {
this.f7472k = str;
}
}
|
UTF-8
|
Java
| 15,601 |
java
|
brt.java
|
Java
|
[] | null |
[] |
package com.p000;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import p000.att.C0806a;
import p000.awe.C0858a;
import p000.awe.C0859b;
/* renamed from: brt */
class brt {
/* renamed from: a */
private static final brm<C0806a> f7462a = new brm(brz.m10584a(), true);
/* renamed from: b */
private final bqw f7463b;
/* renamed from: c */
private final Map<String, bqx> f7464c;
/* renamed from: d */
private final Map<String, bqx> f7465d;
/* renamed from: e */
private final Map<String, bqx> f7466e;
/* renamed from: f */
private final bsc<C0858a, brm<C0806a>> f7467f;
/* renamed from: g */
private final bsc<String, C1431b> f7468g;
/* renamed from: h */
private final Set<C0859b> f7469h;
/* renamed from: i */
private final bqs f7470i;
/* renamed from: j */
private final Map<String, C1432c> f7471j;
/* renamed from: k */
private volatile String f7472k;
/* renamed from: l */
private int f7473l;
/* renamed from: brt$a */
interface C1428a {
/* renamed from: a */
void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr);
}
/* renamed from: brt$2 */
class C14302 implements C1428a {
C14302(brt brt) {
}
/* renamed from: a */
public void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr) {
set.addAll(c0859b.m6132c());
set2.addAll(c0859b.m6133d());
brr.mo1414e();
brr.mo1415f();
}
}
/* renamed from: brt$b */
static class C1431b {
/* renamed from: a */
private brm<C0806a> f7454a;
/* renamed from: b */
private C0806a f7455b;
public C1431b(brm<C0806a> brm, C0806a c0806a) {
this.f7454a = brm;
this.f7455b = c0806a;
}
/* renamed from: a */
public brm<C0806a> m10550a() {
return this.f7454a;
}
/* renamed from: b */
public C0806a m10551b() {
return this.f7455b;
}
}
/* renamed from: brt$c */
static class C1432c {
/* renamed from: a */
private final Set<C0859b> f7456a = new HashSet();
/* renamed from: b */
private final Map<C0859b, List<C0858a>> f7457b = new HashMap();
/* renamed from: c */
private final Map<C0859b, List<C0858a>> f7458c = new HashMap();
/* renamed from: d */
private final Map<C0859b, List<String>> f7459d = new HashMap();
/* renamed from: e */
private final Map<C0859b, List<String>> f7460e = new HashMap();
/* renamed from: f */
private C0858a f7461f;
/* renamed from: a */
public Set<C0859b> m10552a() {
return this.f7456a;
}
/* renamed from: b */
public Map<C0859b, List<C0858a>> m10553b() {
return this.f7457b;
}
/* renamed from: c */
public Map<C0859b, List<String>> m10554c() {
return this.f7459d;
}
/* renamed from: d */
public Map<C0859b, List<String>> m10555d() {
return this.f7460e;
}
/* renamed from: e */
public Map<C0859b, List<C0858a>> m10556e() {
return this.f7458c;
}
/* renamed from: f */
public C0858a m10557f() {
return this.f7461f;
}
}
/* renamed from: a */
private brm<C0806a> m10558a(C0806a c0806a, Set<String> set, bsa bsa) {
if (!c0806a.f4509l) {
return new brm(c0806a, true);
}
C0806a a;
int i;
brm a2;
String str;
String valueOf;
switch (c0806a.f4498a) {
case 2:
a = awe.m6136a(c0806a);
a.f4500c = new C0806a[c0806a.f4500c.length];
for (i = 0; i < c0806a.f4500c.length; i++) {
a2 = m10558a(c0806a.f4500c[i], (Set) set, bsa.mo1418a(i));
if (a2 == f7462a) {
return f7462a;
}
a.f4500c[i] = (C0806a) a2.m10537a();
}
return new brm(a, false);
case 3:
a = awe.m6136a(c0806a);
if (c0806a.f4501d.length != c0806a.f4502e.length) {
str = "Invalid serving value: ";
valueOf = String.valueOf(c0806a.toString());
brd.m10493a(valueOf.length() != 0 ? str.concat(valueOf) : new String(str));
return f7462a;
}
a.f4501d = new C0806a[c0806a.f4501d.length];
a.f4502e = new C0806a[c0806a.f4501d.length];
for (i = 0; i < c0806a.f4501d.length; i++) {
a2 = m10558a(c0806a.f4501d[i], (Set) set, bsa.mo1419b(i));
brm a3 = m10558a(c0806a.f4502e[i], (Set) set, bsa.mo1420c(i));
if (a2 == f7462a || a3 == f7462a) {
return f7462a;
}
a.f4501d[i] = (C0806a) a2.m10537a();
a.f4502e[i] = (C0806a) a3.m10537a();
}
return new brm(a, false);
case 4:
if (set.contains(c0806a.f4503f)) {
valueOf = String.valueOf(c0806a.f4503f);
str = String.valueOf(set.toString());
brd.m10493a(new StringBuilder((String.valueOf(valueOf).length() + 79) + String.valueOf(str).length()).append("Macro cycle detected. Current macro reference: ").append(valueOf).append(". Previous macro references: ").append(str).append(".").toString());
return f7462a;
}
set.add(c0806a.f4503f);
brm<C0806a> a4 = bsb.m10597a(m10559a(c0806a.f4503f, (Set) set, bsa.mo1417a()), c0806a.f4508k);
set.remove(c0806a.f4503f);
return a4;
case 7:
a = awe.m6136a(c0806a);
a.f4507j = new C0806a[c0806a.f4507j.length];
for (i = 0; i < c0806a.f4507j.length; i++) {
a2 = m10558a(c0806a.f4507j[i], (Set) set, bsa.mo1421d(i));
if (a2 == f7462a) {
return f7462a;
}
a.f4507j[i] = (C0806a) a2.m10537a();
}
return new brm(a, false);
default:
brd.m10493a("Unknown type: " + c0806a.f4498a);
return f7462a;
}
}
/* renamed from: a */
private brm<C0806a> m10559a(String str, Set<String> set, brf brf) {
this.f7473l++;
C1431b c1431b = (C1431b) this.f7468g.m10600a(str);
if (c1431b != null) {
m10563a(c1431b.m10551b(), (Set) set);
this.f7473l--;
return c1431b.m10550a();
}
C1432c c1432c = (C1432c) this.f7471j.get(str);
if (c1432c == null) {
String valueOf = String.valueOf(m10562a());
brd.m10493a(new StringBuilder((String.valueOf(valueOf).length() + 15) + String.valueOf(str).length()).append(valueOf).append("Invalid macro: ").append(str).toString());
this.f7473l--;
return f7462a;
}
C0858a f;
brm a = m10566a(str, c1432c.m10552a(), c1432c.m10553b(), c1432c.m10554c(), c1432c.m10556e(), c1432c.m10555d(), set, brf.mo1407b());
if (((Set) a.m10537a()).isEmpty()) {
f = c1432c.m10557f();
} else {
if (((Set) a.m10537a()).size() > 1) {
valueOf = String.valueOf(m10562a());
brd.m10495b(new StringBuilder((String.valueOf(valueOf).length() + 37) + String.valueOf(str).length()).append(valueOf).append("Multiple macros active for macroName ").append(str).toString());
}
f = (C0858a) ((Set) a.m10537a()).iterator().next();
}
if (f == null) {
this.f7473l--;
return f7462a;
}
brm a2 = m10560a(this.f7466e, f, (Set) set, brf.mo1406a());
boolean z = a.m10538b() && a2.m10538b();
brm<C0806a> brm = a2 == f7462a ? f7462a : new brm((C0806a) a2.m10537a(), z);
C0806a b = f.m6129b();
if (brm.m10538b()) {
this.f7468g.m10601a(str, new C1431b(brm, b));
}
m10563a(b, (Set) set);
this.f7473l--;
return brm;
}
/* renamed from: a */
private brm<C0806a> m10560a(Map<String, bqx> map, C0858a c0858a, Set<String> set, bro bro) {
boolean z = true;
C0806a c0806a = (C0806a) c0858a.m6127a().get(ats.FUNCTION.toString());
if (c0806a == null) {
brd.m10493a("No function id in properties");
return f7462a;
}
String str = c0806a.f4504g;
bqx bqx = (bqx) map.get(str);
if (bqx == null) {
brd.m10493a(String.valueOf(str).concat(" has no backing implementation."));
return f7462a;
}
brm<C0806a> brm = (brm) this.f7467f.m10600a(c0858a);
if (brm != null) {
return brm;
}
Map hashMap = new HashMap();
boolean z2 = true;
for (Entry entry : c0858a.m6127a().entrySet()) {
brm a = m10558a((C0806a) entry.getValue(), (Set) set, bro.mo1408a((String) entry.getKey()).mo1409a((C0806a) entry.getValue()));
if (a == f7462a) {
return f7462a;
}
boolean z3;
if (a.m10538b()) {
c0858a.m6128a((String) entry.getKey(), (C0806a) a.m10537a());
z3 = z2;
} else {
z3 = false;
}
hashMap.put((String) entry.getKey(), (C0806a) a.m10537a());
z2 = z3;
}
if (bqx.m10480a(hashMap.keySet())) {
if (!(z2 && bqx.m10479a())) {
z = false;
}
brm = new brm(bqx.m10478a(hashMap), z);
if (!z) {
return brm;
}
this.f7467f.m10601a(c0858a, brm);
return brm;
}
String valueOf = String.valueOf(bqx.m10481b());
String valueOf2 = String.valueOf(hashMap.keySet());
brd.m10493a(new StringBuilder(((String.valueOf(str).length() + 43) + String.valueOf(valueOf).length()) + String.valueOf(valueOf2).length()).append("Incorrect keys for function ").append(str).append(" required ").append(valueOf).append(" had ").append(valueOf2).toString());
return f7462a;
}
/* renamed from: a */
private brm<Set<C0858a>> m10561a(Set<C0859b> set, Set<String> set2, C1428a c1428a, brs brs) {
Set hashSet = new HashSet();
Collection hashSet2 = new HashSet();
boolean z = true;
for (C0859b c0859b : set) {
brr a = brs.mo1416a();
brm a2 = m10565a(c0859b, (Set) set2, a);
if (((Boolean) a2.m10537a()).booleanValue()) {
c1428a.mo1422a(c0859b, hashSet, hashSet2, a);
}
boolean z2 = z && a2.m10538b();
z = z2;
}
hashSet.removeAll(hashSet2);
return new brm(hashSet, z);
}
/* renamed from: a */
private String m10562a() {
if (this.f7473l <= 1) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Integer.toString(this.f7473l));
for (int i = 2; i < this.f7473l; i++) {
stringBuilder.append(' ');
}
stringBuilder.append(": ");
return stringBuilder.toString();
}
/* renamed from: a */
private void m10563a(C0806a c0806a, Set<String> set) {
if (c0806a != null) {
brm a = m10558a(c0806a, (Set) set, new brl());
if (a != f7462a) {
Object c = brz.m10591c((C0806a) a.m10537a());
if (c instanceof Map) {
this.f7470i.m10458a((Map) c);
} else if (c instanceof List) {
for (Object c2 : (List) c2) {
if (c2 instanceof Map) {
this.f7470i.m10458a((Map) c2);
} else {
brd.m10495b("pushAfterEvaluate: value not a Map");
}
}
} else {
brd.m10495b("pushAfterEvaluate: value not a Map or List");
}
}
}
}
/* renamed from: a */
brm<Boolean> m10564a(C0858a c0858a, Set<String> set, bro bro) {
brm a = m10560a(this.f7465d, c0858a, (Set) set, bro);
Object b = brz.m10588b((C0806a) a.m10537a());
brz.m10590c(b);
return new brm(b, a.m10538b());
}
/* renamed from: a */
brm<Boolean> m10565a(C0859b c0859b, Set<String> set, brr brr) {
boolean z = true;
for (C0858a a : c0859b.m6131b()) {
brm a2 = m10564a(a, (Set) set, brr.mo1410a());
if (((Boolean) a2.m10537a()).booleanValue()) {
brz.m10590c(Boolean.valueOf(false));
return new brm(Boolean.valueOf(false), a2.m10538b());
}
boolean z2 = z && a2.m10538b();
z = z2;
}
for (C0858a a3 : c0859b.m6130a()) {
a2 = m10564a(a3, (Set) set, brr.mo1411b());
if (((Boolean) a2.m10537a()).booleanValue()) {
z = z && a2.m10538b();
} else {
brz.m10590c(Boolean.valueOf(false));
return new brm(Boolean.valueOf(false), a2.m10538b());
}
}
brz.m10590c(Boolean.valueOf(true));
return new brm(Boolean.valueOf(true), z);
}
/* renamed from: a */
brm<Set<C0858a>> m10566a(String str, Set<C0859b> set, Map<C0859b, List<C0858a>> map, Map<C0859b, List<String>> map2, Map<C0859b, List<C0858a>> map3, Map<C0859b, List<String>> map4, Set<String> set2, brs brs) {
final Map<C0859b, List<C0858a>> map5 = map;
final Map<C0859b, List<String>> map6 = map2;
final Map<C0859b, List<C0858a>> map7 = map3;
final Map<C0859b, List<String>> map8 = map4;
return m10561a((Set) set, (Set) set2, new C1428a(this) {
/* renamed from: a */
public void mo1422a(C0859b c0859b, Set<C0858a> set, Set<C0858a> set2, brr brr) {
List list = (List) map5.get(c0859b);
map6.get(c0859b);
if (list != null) {
set.addAll(list);
brr.mo1412c();
}
list = (List) map7.get(c0859b);
map8.get(c0859b);
if (list != null) {
set2.addAll(list);
brr.mo1413d();
}
}
}, brs);
}
/* renamed from: a */
brm<Set<C0858a>> m10567a(Set<C0859b> set, brs brs) {
return m10561a((Set) set, new HashSet(), new C14302(this), brs);
}
/* renamed from: a */
public synchronized void m10568a(String str) {
m10569b(str);
bsf a = this.f7463b.m10477a(str).m10476a();
for (C0858a a2 : (Set) m10567a(this.f7469h, a.m10614b()).m10537a()) {
m10560a(this.f7464c, a2, new HashSet(), a.m10613a());
}
m10569b(null);
}
/* renamed from: b */
synchronized void m10569b(String str) {
this.f7472k = str;
}
}
| 15,601 | 0.503301 | 0.380296 | 427 | 35.536301 | 31.158512 | 281 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.775176 | false | false |
13
|
c080b5b35504c3ea727098b6130952a7cc42f56b
| 21,981,642,653,408 |
44cb9ce694a01df6e5d95c4501f47df872503941
|
/InventoryReportView.java
|
eda0f60f984112a931dc0b4cb6c3124e4e44f956
|
[] |
no_license
|
aliisrat/SampleDemo
|
https://github.com/aliisrat/SampleDemo
|
458f16bc27497fefcf746830294af9f8a8d09639
|
b6e754ee542f281c07ef9d19be888dedcbb93357
|
refs/heads/master
| 2021-08-28T12:25:29.484000 | 2017-12-12T08:10:34 | 2017-12-12T08:10:34 | 113,957,475 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.bluesquare.models;
import java.util.Date;
import com.bluesquare.entities.Supplier;
public class InventoryReportView {
private long srno;
private String transactionId;
private Supplier supplier;
private double totalQuantity;
private double totalAmount;
private double totalAmountTax;
private double amountPaid;
private double amountUnPaid;
private Date paymentDate;
private String payStatus;
public InventoryReportView(long srno, String transactionId, Supplier supplier, double totalQuantity,
double totalAmount, double totalAmountTax, double amountPaid, double amountUnPaid, Date paymentDate,
String payStatus) {
super();
this.srno = srno;
this.transactionId = transactionId;
this.supplier = supplier;
this.totalQuantity = totalQuantity;
this.totalAmount = totalAmount;
this.totalAmountTax = totalAmountTax;
this.amountPaid = amountPaid;
this.amountUnPaid = amountUnPaid;
this.paymentDate = paymentDate;
this.payStatus = payStatus;
}
public long getSrno() {
return srno;
}
public void setSrno(long srno) {
this.srno = srno;
}
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public Supplier getSupplier() {
return supplier;
}
public void setSupplier(Supplier supplier) {
this.supplier = supplier;
}
public double getTotalQuantity() {
return totalQuantity;
}
public void setTotalQuantity(double totalQuantity) {
this.totalQuantity = totalQuantity;
}
public double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(double totalAmount) {
this.totalAmount = totalAmount;
}
public double getTotalAmountTax() {
return totalAmountTax;
}
public void setTotalAmountTax(double totalAmountTax) {
this.totalAmountTax = totalAmountTax;
}
public double getAmountPaid() {
return amountPaid;
}
public void setAmountPaid(double amountPaid) {
this.amountPaid = amountPaid;
}
public double getAmountUnPaid() {
return amountUnPaid;
}
public void setAmountUnPaid(double amountUnPaid) {
this.amountUnPaid = amountUnPaid;
}
public Date getPaymentDate() {
return paymentDate;
}
public void setPaymentDate(Date paymentDate) {
this.paymentDate = paymentDate;
}
public String getPayStatus() {
return payStatus;
}
public void setPayStatus(String payStatus) {
this.payStatus = payStatus;
}
@Override
public String toString() {
return "InventoryReportView [srno=" + srno + ", transactionId=" + transactionId + ", supplier=" + supplier
+ ", totalQuantity=" + totalQuantity + ", totalAmount=" + totalAmount + ", totalAmountTax="
+ totalAmountTax + ", amountPaid=" + amountPaid + ", amountUnPaid=" + amountUnPaid + ", paymentDate="
+ paymentDate + ", payStatus=" + payStatus + "]";
}
}
|
UTF-8
|
Java
| 2,825 |
java
|
InventoryReportView.java
|
Java
|
[] | null |
[] |
package com.bluesquare.models;
import java.util.Date;
import com.bluesquare.entities.Supplier;
public class InventoryReportView {
private long srno;
private String transactionId;
private Supplier supplier;
private double totalQuantity;
private double totalAmount;
private double totalAmountTax;
private double amountPaid;
private double amountUnPaid;
private Date paymentDate;
private String payStatus;
public InventoryReportView(long srno, String transactionId, Supplier supplier, double totalQuantity,
double totalAmount, double totalAmountTax, double amountPaid, double amountUnPaid, Date paymentDate,
String payStatus) {
super();
this.srno = srno;
this.transactionId = transactionId;
this.supplier = supplier;
this.totalQuantity = totalQuantity;
this.totalAmount = totalAmount;
this.totalAmountTax = totalAmountTax;
this.amountPaid = amountPaid;
this.amountUnPaid = amountUnPaid;
this.paymentDate = paymentDate;
this.payStatus = payStatus;
}
public long getSrno() {
return srno;
}
public void setSrno(long srno) {
this.srno = srno;
}
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
public Supplier getSupplier() {
return supplier;
}
public void setSupplier(Supplier supplier) {
this.supplier = supplier;
}
public double getTotalQuantity() {
return totalQuantity;
}
public void setTotalQuantity(double totalQuantity) {
this.totalQuantity = totalQuantity;
}
public double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(double totalAmount) {
this.totalAmount = totalAmount;
}
public double getTotalAmountTax() {
return totalAmountTax;
}
public void setTotalAmountTax(double totalAmountTax) {
this.totalAmountTax = totalAmountTax;
}
public double getAmountPaid() {
return amountPaid;
}
public void setAmountPaid(double amountPaid) {
this.amountPaid = amountPaid;
}
public double getAmountUnPaid() {
return amountUnPaid;
}
public void setAmountUnPaid(double amountUnPaid) {
this.amountUnPaid = amountUnPaid;
}
public Date getPaymentDate() {
return paymentDate;
}
public void setPaymentDate(Date paymentDate) {
this.paymentDate = paymentDate;
}
public String getPayStatus() {
return payStatus;
}
public void setPayStatus(String payStatus) {
this.payStatus = payStatus;
}
@Override
public String toString() {
return "InventoryReportView [srno=" + srno + ", transactionId=" + transactionId + ", supplier=" + supplier
+ ", totalQuantity=" + totalQuantity + ", totalAmount=" + totalAmount + ", totalAmountTax="
+ totalAmountTax + ", amountPaid=" + amountPaid + ", amountUnPaid=" + amountUnPaid + ", paymentDate="
+ paymentDate + ", payStatus=" + payStatus + "]";
}
}
| 2,825 | 0.748319 | 0.748319 | 101 | 26.970297 | 23.163839 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.980198 | false | false |
13
|
d6b546663157bcdf9c70b4f15b1b3a47bc289de0
| 15,315,853,388,027 |
368b0aad6fea946ad9a15c466754f1ad3470a859
|
/CS2/Final Project/Key.java
|
c70c1e74bbc5aad1063ed220d8ab38eb9a7e9915
|
[] |
no_license
|
jessecarter111/School-Work
|
https://github.com/jessecarter111/School-Work
|
73f99a604be789dbc8a70b0a4e2e07fa5e520e51
|
2b8c54be4284b0aa5ff997ddf8663662d899ad09
|
refs/heads/master
| 2022-11-28T03:20:03.218000 | 2020-08-07T01:35:33 | 2020-08-07T01:35:33 | 278,173,033 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package contacteditor;
/*
* 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.
*/
/**
*
* @author mcjes
*/
public class Key {
private String key;
public Key(String i){
key=i.toUpperCase();
}
public Key(){
}
public void setUnlock(String i){
if(i==null){
i=" ";
return;
}
key=i;
}
public String getUnlock(){
return key;
}
}
|
UTF-8
|
Java
| 605 |
java
|
Key.java
|
Java
|
[
{
"context": "emplate in the editor.\r\n */\r\n\r\n/**\r\n *\r\n * @author mcjes\r\n */\r\npublic class Key {\r\n private String key;",
"end": 243,
"score": 0.999558687210083,
"start": 238,
"tag": "USERNAME",
"value": "mcjes"
}
] | null |
[] |
package contacteditor;
/*
* 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.
*/
/**
*
* @author mcjes
*/
public class Key {
private String key;
public Key(String i){
key=i.toUpperCase();
}
public Key(){
}
public void setUnlock(String i){
if(i==null){
i=" ";
return;
}
key=i;
}
public String getUnlock(){
return key;
}
}
| 605 | 0.515702 | 0.515702 | 34 | 15.794118 | 16.980576 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.647059 | false | false |
13
|
7163d6f3e8faff5782dd95e558c67bb32c1c8178
| 27,479,200,786,219 |
80bbf648689e6aead59d763783c24de9689962d8
|
/CodeUp/src/q_095/Main.java
|
687635f83c0d4b3cf135ee618239e34bc83c0483
|
[] |
no_license
|
superbono/Algorithm_Study
|
https://github.com/superbono/Algorithm_Study
|
e428ebf606c55ecd8720f144414b1c929fb87a67
|
f317457e9ae907a7e818a0e001bf2b4666371e17
|
refs/heads/master
| 2023-02-17T18:52:41.515000 | 2021-01-02T09:40:10 | 2021-01-02T09:40:10 | 324,052,642 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package q_095;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
// 번호를 부른 횟수(n, 1 ~ 10000)가 첫 줄에 입력된다.
// n개의 랜덤 번호(k, 1 ~ 23)가 두 번째 줄에 공백을 사이에 두고 순서대로 입력된다.
// 출석을 부른 번호 중에 가장 빠른 번호를 1개만 출력한다.
// 10
// 10 4 2 3 6 6 7 9 8 5
// 2 출력
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i,n,num;
ArrayList<Integer> a = new ArrayList<>();
n = sc.nextInt();
for(i=0;i<n;i++) {
num = sc.nextInt();
a.add(num);
}
Collections.sort(a);
for(i=0;i<n;i++) {
}
System.out.printf("%d ",a.get(0));
}
}
|
UTF-8
|
Java
| 776 |
java
|
Main.java
|
Java
|
[] | null |
[] |
package q_095;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
// 번호를 부른 횟수(n, 1 ~ 10000)가 첫 줄에 입력된다.
// n개의 랜덤 번호(k, 1 ~ 23)가 두 번째 줄에 공백을 사이에 두고 순서대로 입력된다.
// 출석을 부른 번호 중에 가장 빠른 번호를 1개만 출력한다.
// 10
// 10 4 2 3 6 6 7 9 8 5
// 2 출력
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i,n,num;
ArrayList<Integer> a = new ArrayList<>();
n = sc.nextInt();
for(i=0;i<n;i++) {
num = sc.nextInt();
a.add(num);
}
Collections.sort(a);
for(i=0;i<n;i++) {
}
System.out.printf("%d ",a.get(0));
}
}
| 776 | 0.568536 | 0.521807 | 41 | 14.658537 | 15.08611 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.829268 | false | false |
13
|
d364db951150e113fa614703b65126da82ee4115
| 14,001,593,446,655 |
3efa417c5668b2e7d1c377c41d976ed31fd26fdc
|
/src/br/com/mind5/business/materialCatalogue/model/MatogueModelSelect.java
|
52f07773f58096518e36dffdb040f1167555c2de
|
[] |
no_license
|
grazianiborcai/Agenda_WS
|
https://github.com/grazianiborcai/Agenda_WS
|
4b2656716cc49a413636933665d6ad8b821394ef
|
e8815a951f76d498eb3379394a54d2aa1655f779
|
refs/heads/master
| 2023-05-24T19:39:22.215000 | 2023-05-15T15:15:15 | 2023-05-15T15:15:15 | 109,902,084 | 0 | 0 | null | false | 2022-06-29T19:44:56 | 2017-11-07T23:14:21 | 2022-01-18T22:22:20 | 2022-06-29T19:44:55 | 25,285 | 0 | 0 | 7 |
Java
| false | false |
package br.com.mind5.business.materialCatalogue.model;
import javax.servlet.http.HttpServletRequest;
import br.com.mind5.business.materialCatalogue.info.MatogueInfo;
import br.com.mind5.business.materialCatalogue.model.decisionTree.MatogueRootSelect;
import br.com.mind5.model.ModelTemplate;
import br.com.mind5.model.decisionTree.DeciTree;
import br.com.mind5.model.decisionTree.DeciTreeOption;
public final class MatogueModelSelect extends ModelTemplate<MatogueInfo> {
public MatogueModelSelect(String incomingData, HttpServletRequest request) {
super(incomingData, request, MatogueInfo.class);
}
@Override protected DeciTree<MatogueInfo> getDecisionTreeHook(DeciTreeOption<MatogueInfo> option) {
return new MatogueRootSelect(option);
}
}
|
UTF-8
|
Java
| 781 |
java
|
MatogueModelSelect.java
|
Java
|
[] | null |
[] |
package br.com.mind5.business.materialCatalogue.model;
import javax.servlet.http.HttpServletRequest;
import br.com.mind5.business.materialCatalogue.info.MatogueInfo;
import br.com.mind5.business.materialCatalogue.model.decisionTree.MatogueRootSelect;
import br.com.mind5.model.ModelTemplate;
import br.com.mind5.model.decisionTree.DeciTree;
import br.com.mind5.model.decisionTree.DeciTreeOption;
public final class MatogueModelSelect extends ModelTemplate<MatogueInfo> {
public MatogueModelSelect(String incomingData, HttpServletRequest request) {
super(incomingData, request, MatogueInfo.class);
}
@Override protected DeciTree<MatogueInfo> getDecisionTreeHook(DeciTreeOption<MatogueInfo> option) {
return new MatogueRootSelect(option);
}
}
| 781 | 0.806658 | 0.798976 | 22 | 33.5 | 32.795162 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.045455 | false | false |
13
|
48897fba270642324fda7e66f8ab28c972246be7
| 23,922,967,897,009 |
e390cf112053b9fc72c56c95bd4ad2795d571d33
|
/testing/implementation/source/eclasstool/model/login/.svn/text-base/LoginModel.java.svn-base
|
f70803760e43b48a1bdb983fb2ffefca84e5738f
|
[] |
no_license
|
SilentGaia/eclass
|
https://github.com/SilentGaia/eclass
|
62cc756c74d126df332ff80282d30f3dad69bd24
|
fce73ef19e696203921252a38188d08e098a4b9a
|
refs/heads/master
| 2021-01-19T08:00:38.245000 | 2015-03-28T08:44:00 | 2015-03-28T08:44:00 | 28,836,315 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package eclasstool.model.login;
import eclasstool.model.roster.*;
import eclasstool.view.roster.*;
import java.util.*;
/**
* LoginModel represents the class where all student and user
* authentication takes place.
*
* @author Eric Tran (etran04@calpoly.edu)
*/
public class LoginModel extends Observable
{
// Contains the name and password of all valid users
private HashMap<String, String> users;
// Whether or not login is successful.
private boolean loginSuccessful;
// Whether or not register is successful
private boolean registerSuccessful;
// Contains the name of the last user who logged in
private String lastLoginUser;
/**
* Default constructor for the login model.
* @param roster roster to pull names from
*/
public LoginModel(RosterModel roster)
{
users = new HashMap<String, String>();
RosterModel model = roster;
for (Student currStudent: model.getListStudents())
{
users.put(currStudent.getName(), "password");
}
loginSuccessful = false;
registerSuccessful = false;
lastLoginUser = "";
}
/**
* Registers a user, taking their name and password and adding to database
* @param name name of registered user
* @param password password of registered user
* @return whether or not login was successful
*/
public boolean registerUser(String name, String password)
{
users.put(name, password);
registerSuccessful = true;
return registerSuccessful;
}
/**
* Attempts to validate the user
* @param name name of user who tried to log in.
* @param password attempted password
* @return whether or not it was successful
*/
public boolean confirmUser(String name, String password)
{
if (users.get(name) != null && users.get(name).equals(password))
{
// User is valid, put them through
loginSuccessful = true;
lastLoginUser = name;
setChanged();
notifyObservers(lastLoginUser);
}
return loginSuccessful;
}
/**
* Allows one to register as a guest.
*/
public void guestLogin()
{
loginSuccessful = true;
setChanged();
notifyObservers("Guest");
}
/**
* Gets whether or not login was successful.
* @return whether or not login was successful
*/
public boolean getLoginSuccessful()
{
return loginSuccessful;
}
/**
* Resetst the succesful values.
*/
public void resetSuccess()
{
loginSuccessful = false;
registerSuccessful = false;
}
/**
* Gets the entire map of users and passwords.
* @return entire map of users and passwords
*/
public HashMap<String, String> getUsers()
{
return users;
}
/**
* Gets the last user who logged in
* @return name of last user who logged in
*/
public String getLoginUser()
{
return lastLoginUser;
}
}
|
UTF-8
|
Java
| 3,279 |
LoginModel.java.svn-base
|
Java
|
[
{
"context": "\r\n * authentication takes place. \r\n * \r\n * @author Eric Tran (etran04@calpoly.edu)\r\n */\r\npublic class LoginMod",
"end": 254,
"score": 0.9998103380203247,
"start": 245,
"tag": "NAME",
"value": "Eric Tran"
},
{
"context": "ication takes place. \r\n * \r\n * @author Eric Tran (etran04@calpoly.edu)\r\n */\r\npublic class LoginModel extends Observable",
"end": 275,
"score": 0.9999330043792725,
"start": 256,
"tag": "EMAIL",
"value": "etran04@calpoly.edu"
}
] | null |
[] |
package eclasstool.model.login;
import eclasstool.model.roster.*;
import eclasstool.view.roster.*;
import java.util.*;
/**
* LoginModel represents the class where all student and user
* authentication takes place.
*
* @author <NAME> (<EMAIL>)
*/
public class LoginModel extends Observable
{
// Contains the name and password of all valid users
private HashMap<String, String> users;
// Whether or not login is successful.
private boolean loginSuccessful;
// Whether or not register is successful
private boolean registerSuccessful;
// Contains the name of the last user who logged in
private String lastLoginUser;
/**
* Default constructor for the login model.
* @param roster roster to pull names from
*/
public LoginModel(RosterModel roster)
{
users = new HashMap<String, String>();
RosterModel model = roster;
for (Student currStudent: model.getListStudents())
{
users.put(currStudent.getName(), "password");
}
loginSuccessful = false;
registerSuccessful = false;
lastLoginUser = "";
}
/**
* Registers a user, taking their name and password and adding to database
* @param name name of registered user
* @param password password of registered user
* @return whether or not login was successful
*/
public boolean registerUser(String name, String password)
{
users.put(name, password);
registerSuccessful = true;
return registerSuccessful;
}
/**
* Attempts to validate the user
* @param name name of user who tried to log in.
* @param password attempted password
* @return whether or not it was successful
*/
public boolean confirmUser(String name, String password)
{
if (users.get(name) != null && users.get(name).equals(password))
{
// User is valid, put them through
loginSuccessful = true;
lastLoginUser = name;
setChanged();
notifyObservers(lastLoginUser);
}
return loginSuccessful;
}
/**
* Allows one to register as a guest.
*/
public void guestLogin()
{
loginSuccessful = true;
setChanged();
notifyObservers("Guest");
}
/**
* Gets whether or not login was successful.
* @return whether or not login was successful
*/
public boolean getLoginSuccessful()
{
return loginSuccessful;
}
/**
* Resetst the succesful values.
*/
public void resetSuccess()
{
loginSuccessful = false;
registerSuccessful = false;
}
/**
* Gets the entire map of users and passwords.
* @return entire map of users and passwords
*/
public HashMap<String, String> getUsers()
{
return users;
}
/**
* Gets the last user who logged in
* @return name of last user who logged in
*/
public String getLoginUser()
{
return lastLoginUser;
}
}
| 3,264 | 0.581275 | 0.580665 | 124 | 24.443548 | 19.975107 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.314516 | false | false |
13
|
|
d102a3c8ffffcce69a010ca66fc1170876161cd8
| 10,256,381,974,296 |
c3e9e510d1f8c23284e009569a16f349da91ed24
|
/src/main/java/com/javaapi/test/application/log/log/log4j/Loader.java
|
7829af50cc72c23734d11c2572e0031c5bc3479f
|
[] |
no_license
|
incoding/api-usage
|
https://github.com/incoding/api-usage
|
ab661b3b97df8e482d1c509f65476114718f757e
|
c3c8ab209e21547c313252c84479e26212e0739c
|
refs/heads/master
| 2023-07-23T05:39:23.554000 | 2023-07-17T05:49:19 | 2023-07-17T05:49:19 | 140,235,999 | 0 | 2 | null | false | 2022-11-16T06:58:55 | 2018-07-09T05:35:56 | 2022-03-07T14:32:12 | 2022-11-16T06:58:52 | 2,012 | 0 | 2 | 21 |
Java
| false | false |
package com.javaapi.test.application.log.log.log4j;
/**
* https://github.com/liweinan/java-snippets.git
*/
public class Loader {
// public static void main(String args[]) throws Exception {
// // load by code
// {
// Logger myLogger = Logger.getLogger("net.bluedash.log4j");
// SimpleLayout simpleLayout = new SimpleLayout();
// myLogger.setLevel(Level.DEBUG);
// // FileAppender fileAppender = new FileAppender(simpleLayout,
// // "play.out");
// // myLogger.addAppender(fileAppender);
//
// ConsoleAppender consoleAppender = new ConsoleAppender(simpleLayout);
// myLogger.addAppender(consoleAppender);
//
// myLogger.debug("eating apple...");
// myLogger.fatal("bad apple");
// }
//
// // load by configuration file
// {
// InputStream config = Loader.class.getClassLoader()
// .getResourceAsStream("META-INF/log4j.properties");
// PropertyConfigurator.configure(config);
// Logger propLogger = Logger.getLogger("propLogger");
// propLogger.info("I'm dancing!");
// }
// }
}
|
UTF-8
|
Java
| 1,007 |
java
|
Loader.java
|
Java
|
[
{
"context": "cation.log.log.log4j;\n\n\n/**\n * https://github.com/liweinan/java-snippets.git\n */\npublic class Loader {\n\t// p",
"end": 88,
"score": 0.9996439814567566,
"start": 80,
"tag": "USERNAME",
"value": "liweinan"
}
] | null |
[] |
package com.javaapi.test.application.log.log.log4j;
/**
* https://github.com/liweinan/java-snippets.git
*/
public class Loader {
// public static void main(String args[]) throws Exception {
// // load by code
// {
// Logger myLogger = Logger.getLogger("net.bluedash.log4j");
// SimpleLayout simpleLayout = new SimpleLayout();
// myLogger.setLevel(Level.DEBUG);
// // FileAppender fileAppender = new FileAppender(simpleLayout,
// // "play.out");
// // myLogger.addAppender(fileAppender);
//
// ConsoleAppender consoleAppender = new ConsoleAppender(simpleLayout);
// myLogger.addAppender(consoleAppender);
//
// myLogger.debug("eating apple...");
// myLogger.fatal("bad apple");
// }
//
// // load by configuration file
// {
// InputStream config = Loader.class.getClassLoader()
// .getResourceAsStream("META-INF/log4j.properties");
// PropertyConfigurator.configure(config);
// Logger propLogger = Logger.getLogger("propLogger");
// propLogger.info("I'm dancing!");
// }
// }
}
| 1,007 | 0.690169 | 0.68719 | 34 | 28.617647 | 23.109732 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.205882 | false | false |
13
|
6a69802ea96fad98c487e371bf5f1eb35b200d54
| 10,118,942,983,250 |
e75c0384c278502ec6a8351d22feec39875d5bd4
|
/Flipkart_Group5/src/edu/iiitb/flipkart/dao/admin/advertisement_management/deleteAdvertisementDao.java
|
b91e9fdde9980a142ff58a382df082a59be268d0
|
[] |
no_license
|
tanushreevinayak/flipkart
|
https://github.com/tanushreevinayak/flipkart
|
37125349bf0f6ec40b1c50bac457f465e387df39
|
85253017db3437f9c732bfad22931e1234c6d0eb
|
refs/heads/master
| 2016-09-06T11:13:46.543000 | 2015-03-30T17:01:12 | 2015-03-30T17:01:12 | 33,135,298 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package edu.iiitb.flipkart.dao.admin.advertisement_management;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import edu.iiitb.flipkart.dbUtil.ConnectionPool;
import edu.iiitb.flipkart.model.admin.deleteAdvertisementForSelectedAdHeadingMOdel;
import edu.iiitb.flipkart.model.admin.selectAdvertisementHeadingModel;
public class deleteAdvertisementDao {
public List<String> SelectAdHeadingToDeleteAdvertisement(selectAdvertisementHeadingModel model) {
List<String> adheadinglist=new ArrayList<String>();
Connection con=ConnectionPool.getConnection();
try {
Statement stmt=con.createStatement();
String queryTOGEtAdHeading="select * from advertisement";
ResultSet coursenameResutSet=stmt.executeQuery(queryTOGEtAdHeading);
while(coursenameResutSet.next())
{
adheadinglist.add(coursenameResutSet.getString("advertisement_name"));
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
return adheadinglist;
// TODO Auto-generated method stub
}
public String deleteAdverisementForSelectedAdHeading(deleteAdvertisementForSelectedAdHeadingMOdel model) {
//List<String> productlist=new ArrayList<String>();
Connection con=ConnectionPool.getConnection();
try {
Statement stmt=con.createStatement();
String GetAdId="select advertisement_id from advertisement where advertisement_name='"+model.getAdvertisement_name()+"'";
ResultSet deletead=stmt.executeQuery(GetAdId);
if(deletead.next())
{
model.setAdvertisement_id(deletead.getString("advertisement_id"));
}
PreparedStatement prestmt=null;
String query="delete from Flipkart.advertisement where advertisement_id='"+model.getAdvertisement_id()+"'";
prestmt=con.prepareStatement(query);
//prestmt.setString(1, model.getAdvertisement_id());
prestmt.executeUpdate();
return "success";
//}
} catch (Exception e) {
e.printStackTrace();
return "failure";
// TODO: handle exception
}
// TODO Auto-generated method stub
}
}
|
UTF-8
|
Java
| 2,157 |
java
|
deleteAdvertisementDao.java
|
Java
|
[] | null |
[] |
package edu.iiitb.flipkart.dao.admin.advertisement_management;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import edu.iiitb.flipkart.dbUtil.ConnectionPool;
import edu.iiitb.flipkart.model.admin.deleteAdvertisementForSelectedAdHeadingMOdel;
import edu.iiitb.flipkart.model.admin.selectAdvertisementHeadingModel;
public class deleteAdvertisementDao {
public List<String> SelectAdHeadingToDeleteAdvertisement(selectAdvertisementHeadingModel model) {
List<String> adheadinglist=new ArrayList<String>();
Connection con=ConnectionPool.getConnection();
try {
Statement stmt=con.createStatement();
String queryTOGEtAdHeading="select * from advertisement";
ResultSet coursenameResutSet=stmt.executeQuery(queryTOGEtAdHeading);
while(coursenameResutSet.next())
{
adheadinglist.add(coursenameResutSet.getString("advertisement_name"));
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
return adheadinglist;
// TODO Auto-generated method stub
}
public String deleteAdverisementForSelectedAdHeading(deleteAdvertisementForSelectedAdHeadingMOdel model) {
//List<String> productlist=new ArrayList<String>();
Connection con=ConnectionPool.getConnection();
try {
Statement stmt=con.createStatement();
String GetAdId="select advertisement_id from advertisement where advertisement_name='"+model.getAdvertisement_name()+"'";
ResultSet deletead=stmt.executeQuery(GetAdId);
if(deletead.next())
{
model.setAdvertisement_id(deletead.getString("advertisement_id"));
}
PreparedStatement prestmt=null;
String query="delete from Flipkart.advertisement where advertisement_id='"+model.getAdvertisement_id()+"'";
prestmt=con.prepareStatement(query);
//prestmt.setString(1, model.getAdvertisement_id());
prestmt.executeUpdate();
return "success";
//}
} catch (Exception e) {
e.printStackTrace();
return "failure";
// TODO: handle exception
}
// TODO Auto-generated method stub
}
}
| 2,157 | 0.754752 | 0.754288 | 95 | 21.705263 | 28.236919 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.6 | false | false |
13
|
3d0bb392c4ba6264bafa1d16a1269391ca6fd3f7
| 32,547,262,199,827 |
63a8f192bf3fc6bdd4a805f0ee176b27074b51d7
|
/src/easy/hashtable/intersectionoftwoarrays/IntersectionOfTwoArrays.java
|
ecedea46aa6011a09f1c9f43564e5f8df1e4ff31
|
[
"MIT"
] |
permissive
|
john-h3/nothing-to-do
|
https://github.com/john-h3/nothing-to-do
|
e85637e118c0e36bf8a6b4da1d70ab1e517ebcbb
|
837ab4a228b8f591f4d7cba533261395ccc641c6
|
refs/heads/master
| 2021-05-24T17:23:33.110000 | 2021-04-06T15:50:16 | 2021-04-06T15:50:16 | 253,674,898 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package easy.hashtable.intersectionoftwoarrays;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
/**
* IntersectionOfTwoArrays
*
* @author john 2021/2/8
*/
public class IntersectionOfTwoArrays {
class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
var set1 = new HashSet<Integer>();
var set2 = new HashSet<Integer>();
Arrays.stream(nums1).forEach(set1::add);
Arrays.stream(nums2).forEach(set2::add);
set1.retainAll(set2);
return set1.stream().mapToInt(Integer::intValue).toArray();
}
}
}
|
UTF-8
|
Java
| 588 |
java
|
IntersectionOfTwoArrays.java
|
Java
|
[
{
"context": "Set;\n\n/**\n * IntersectionOfTwoArrays\n *\n * @author john 2021/2/8\n */\npublic class IntersectionOfTwoArrays",
"end": 176,
"score": 0.9984166622161865,
"start": 172,
"tag": "USERNAME",
"value": "john"
}
] | null |
[] |
package easy.hashtable.intersectionoftwoarrays;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
/**
* IntersectionOfTwoArrays
*
* @author john 2021/2/8
*/
public class IntersectionOfTwoArrays {
class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
var set1 = new HashSet<Integer>();
var set2 = new HashSet<Integer>();
Arrays.stream(nums1).forEach(set1::add);
Arrays.stream(nums2).forEach(set2::add);
set1.retainAll(set2);
return set1.stream().mapToInt(Integer::intValue).toArray();
}
}
}
| 588 | 0.681973 | 0.653061 | 23 | 24.565218 | 19.635429 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.478261 | false | false |
13
|
3eb79ddb0910aff0ecba10fb7f25adb85ef0911a
| 30,399,778,526,356 |
38f62616ee9e78fbd00a9b6417acc054d028e10c
|
/haksaProjectBackup/src/main/java/com/cafe24/iumium/personnel/appoint/dto/PersonnelTemporaryAppointment.java
|
bee7e09c1c47e0390e3b6e682e2d21e4c8fe839c
|
[] |
no_license
|
wonmin123/haksaBackup
|
https://github.com/wonmin123/haksaBackup
|
883c0e702d98545dd1723082ffd48b7d391a2045
|
aaccfd695308d997ed57a6e114157d7187cb6fc7
|
refs/heads/master
| 2020-03-30T12:22:59.893000 | 2019-03-18T08:57:05 | 2019-03-18T08:57:05 | 151,221,964 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cafe24.iumium.personnel.appoint.dto;
public class PersonnelTemporaryAppointment {
private String appointmentSchoolPersonnelNumber;
private String appointmentTemporaryCareerDivision;
private String appointmentTemporaryContractStartTerm;
private String appointmentTemporaryContractEndTerm;
private String appointmentTemporaryAppointmentStartTerm;
private String appointmentTemporaryAppointmentEndTerm;
private String appointmentTemporaryAppointReason;
private String appointmentTemporaryRegistrationDate;
private String appointmentTemporaryModificationDate;
public String getAppointmentSchoolPersonnelNumber() {
return appointmentSchoolPersonnelNumber;
}
public void setAppointmentSchoolPersonnelNumber(String appointmentSchoolPersonnelNumber) {
this.appointmentSchoolPersonnelNumber = appointmentSchoolPersonnelNumber;
}
public String getAppointmentTemporaryCareerDivision() {
return appointmentTemporaryCareerDivision;
}
public void setAppointmentTemporaryCareerDivision(String appointmentTemporaryCareerDivision) {
this.appointmentTemporaryCareerDivision = appointmentTemporaryCareerDivision;
}
public String getAppointmentTemporaryContractStartTerm() {
return appointmentTemporaryContractStartTerm;
}
public void setAppointmentTemporaryContractStartTerm(String appointmentTemporaryContractStartTerm) {
this.appointmentTemporaryContractStartTerm = appointmentTemporaryContractStartTerm;
}
public String getAppointmentTemporaryContractEndTerm() {
return appointmentTemporaryContractEndTerm;
}
public void setAppointmentTemporaryContractEndTerm(String appointmentTemporaryContractEndTerm) {
this.appointmentTemporaryContractEndTerm = appointmentTemporaryContractEndTerm;
}
public String getAppointmentTemporaryAppointmentStartTerm() {
return appointmentTemporaryAppointmentStartTerm;
}
public void setAppointmentTemporaryAppointmentStartTerm(String appointmentTemporaryAppointmentStartTerm) {
this.appointmentTemporaryAppointmentStartTerm = appointmentTemporaryAppointmentStartTerm;
}
public String getAppointmentTemporaryAppointmentEndTerm() {
return appointmentTemporaryAppointmentEndTerm;
}
public void setAppointmentTemporaryAppointmentEndTerm(String appointmentTemporaryAppointmentEndTerm) {
this.appointmentTemporaryAppointmentEndTerm = appointmentTemporaryAppointmentEndTerm;
}
public String getAppointmentTemporaryAppointReason() {
return appointmentTemporaryAppointReason;
}
public void setAppointmentTemporaryAppointReason(String appointmentTemporaryAppointReason) {
this.appointmentTemporaryAppointReason = appointmentTemporaryAppointReason;
}
public String getAppointmentTemporaryRegistrationDate() {
return appointmentTemporaryRegistrationDate;
}
public void setAppointmentTemporaryRegistrationDate(String appointmentTemporaryRegistrationDate) {
this.appointmentTemporaryRegistrationDate = appointmentTemporaryRegistrationDate;
}
public String getAppointmentTemporaryModificationDate() {
return appointmentTemporaryModificationDate;
}
public void setAppointmentTemporaryModificationDate(String appointmentTemporaryModificationDate) {
this.appointmentTemporaryModificationDate = appointmentTemporaryModificationDate;
}
@Override
public String toString() {
return "PersonnelTemporaryAppointment [appointmentSchoolPersonnelNumber=" + appointmentSchoolPersonnelNumber
+ ", appointmentTemporaryCareerDivision=" + appointmentTemporaryCareerDivision
+ ", appointmentTemporaryContractStartTerm=" + appointmentTemporaryContractStartTerm
+ ", appointmentTemporaryContractEndTerm=" + appointmentTemporaryContractEndTerm
+ ", appointmentTemporaryAppointmentStartTerm=" + appointmentTemporaryAppointmentStartTerm
+ ", appointmentTemporaryAppointmentEndTerm=" + appointmentTemporaryAppointmentEndTerm
+ ", appointmentTemporaryAppointReason=" + appointmentTemporaryAppointReason
+ ", appointmentTemporaryRegistrationDate=" + appointmentTemporaryRegistrationDate
+ ", appointmentTemporaryModificationDate=" + appointmentTemporaryModificationDate + "]";
}
}
|
UTF-8
|
Java
| 4,169 |
java
|
PersonnelTemporaryAppointment.java
|
Java
|
[] | null |
[] |
package com.cafe24.iumium.personnel.appoint.dto;
public class PersonnelTemporaryAppointment {
private String appointmentSchoolPersonnelNumber;
private String appointmentTemporaryCareerDivision;
private String appointmentTemporaryContractStartTerm;
private String appointmentTemporaryContractEndTerm;
private String appointmentTemporaryAppointmentStartTerm;
private String appointmentTemporaryAppointmentEndTerm;
private String appointmentTemporaryAppointReason;
private String appointmentTemporaryRegistrationDate;
private String appointmentTemporaryModificationDate;
public String getAppointmentSchoolPersonnelNumber() {
return appointmentSchoolPersonnelNumber;
}
public void setAppointmentSchoolPersonnelNumber(String appointmentSchoolPersonnelNumber) {
this.appointmentSchoolPersonnelNumber = appointmentSchoolPersonnelNumber;
}
public String getAppointmentTemporaryCareerDivision() {
return appointmentTemporaryCareerDivision;
}
public void setAppointmentTemporaryCareerDivision(String appointmentTemporaryCareerDivision) {
this.appointmentTemporaryCareerDivision = appointmentTemporaryCareerDivision;
}
public String getAppointmentTemporaryContractStartTerm() {
return appointmentTemporaryContractStartTerm;
}
public void setAppointmentTemporaryContractStartTerm(String appointmentTemporaryContractStartTerm) {
this.appointmentTemporaryContractStartTerm = appointmentTemporaryContractStartTerm;
}
public String getAppointmentTemporaryContractEndTerm() {
return appointmentTemporaryContractEndTerm;
}
public void setAppointmentTemporaryContractEndTerm(String appointmentTemporaryContractEndTerm) {
this.appointmentTemporaryContractEndTerm = appointmentTemporaryContractEndTerm;
}
public String getAppointmentTemporaryAppointmentStartTerm() {
return appointmentTemporaryAppointmentStartTerm;
}
public void setAppointmentTemporaryAppointmentStartTerm(String appointmentTemporaryAppointmentStartTerm) {
this.appointmentTemporaryAppointmentStartTerm = appointmentTemporaryAppointmentStartTerm;
}
public String getAppointmentTemporaryAppointmentEndTerm() {
return appointmentTemporaryAppointmentEndTerm;
}
public void setAppointmentTemporaryAppointmentEndTerm(String appointmentTemporaryAppointmentEndTerm) {
this.appointmentTemporaryAppointmentEndTerm = appointmentTemporaryAppointmentEndTerm;
}
public String getAppointmentTemporaryAppointReason() {
return appointmentTemporaryAppointReason;
}
public void setAppointmentTemporaryAppointReason(String appointmentTemporaryAppointReason) {
this.appointmentTemporaryAppointReason = appointmentTemporaryAppointReason;
}
public String getAppointmentTemporaryRegistrationDate() {
return appointmentTemporaryRegistrationDate;
}
public void setAppointmentTemporaryRegistrationDate(String appointmentTemporaryRegistrationDate) {
this.appointmentTemporaryRegistrationDate = appointmentTemporaryRegistrationDate;
}
public String getAppointmentTemporaryModificationDate() {
return appointmentTemporaryModificationDate;
}
public void setAppointmentTemporaryModificationDate(String appointmentTemporaryModificationDate) {
this.appointmentTemporaryModificationDate = appointmentTemporaryModificationDate;
}
@Override
public String toString() {
return "PersonnelTemporaryAppointment [appointmentSchoolPersonnelNumber=" + appointmentSchoolPersonnelNumber
+ ", appointmentTemporaryCareerDivision=" + appointmentTemporaryCareerDivision
+ ", appointmentTemporaryContractStartTerm=" + appointmentTemporaryContractStartTerm
+ ", appointmentTemporaryContractEndTerm=" + appointmentTemporaryContractEndTerm
+ ", appointmentTemporaryAppointmentStartTerm=" + appointmentTemporaryAppointmentStartTerm
+ ", appointmentTemporaryAppointmentEndTerm=" + appointmentTemporaryAppointmentEndTerm
+ ", appointmentTemporaryAppointReason=" + appointmentTemporaryAppointReason
+ ", appointmentTemporaryRegistrationDate=" + appointmentTemporaryRegistrationDate
+ ", appointmentTemporaryModificationDate=" + appointmentTemporaryModificationDate + "]";
}
}
| 4,169 | 0.850564 | 0.850084 | 81 | 49.469135 | 35.516674 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.938272 | false | false |
13
|
376fb861ed9d7e814647c1013cb0e37d63f60202
| 3,238,405,361,249 |
25bfbd11b18f967932dbf4f170521edfe58d54f2
|
/src/test/java/fr/lernejo/navy_battle/StartServeurTest.java
|
568d34abb7d37920570443adf79eb77855b09814
|
[] |
no_license
|
Sazard/java_api_training
|
https://github.com/Sazard/java_api_training
|
af6c7c30646e41cb0ef1b20df34da0ccd9f5ad61
|
32a27435721efbc60689cc1fa7c5cd8f28a2cfc3
|
refs/heads/main
| 2023-06-21T23:59:22.471000 | 2021-07-10T15:51:48 | 2021-07-10T15:51:48 | 370,987,059 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package fr.lernejo.navy_battle;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
class StartServeurTest {
@Test
void tStartServ() throws IOException, InterruptedException {
StartServer st = new StartServer(5678);
Assertions.assertNotEquals(st, "IOException");
st.serv.stop(0);
}
}
|
UTF-8
|
Java
| 500 |
java
|
StartServeurTest.java
|
Java
|
[] | null |
[] |
package fr.lernejo.navy_battle;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
class StartServeurTest {
@Test
void tStartServ() throws IOException, InterruptedException {
StartServer st = new StartServer(5678);
Assertions.assertNotEquals(st, "IOException");
st.serv.stop(0);
}
}
| 500 | 0.734 | 0.724 | 21 | 22.809525 | 19.110254 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.619048 | false | false |
13
|
a0fa2f3f08d1648cac00ab1d9f3c103ba49cba13
| 5,738,076,330,170 |
c23f472d17065c183fdbf8006a93550bb3a3e03c
|
/src/zadaci_18_01_2016/BrojKnjige.java
|
7c8abc67785946d8717ac9f77546c023fe781ab3
|
[] |
no_license
|
AnaJozicAgic/BILD-IT-zadaci
|
https://github.com/AnaJozicAgic/BILD-IT-zadaci
|
7304f7ca91792ac72508d738d7702ef3dd263db9
|
62c29d874741da35aab1aa872530619e3e41af7f
|
refs/heads/master
| 2020-12-11T07:33:14.638000 | 2016-03-07T08:47:50 | 2016-03-07T08:47:50 | 49,741,730 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package zadaci_18_01_2016;
import java.util.InputMismatchException;
public class BrojKnjige {
public static void main(String[] args) throws InputMismatchException {
java.util.Scanner input = new java.util.Scanner(System.in);
// Handling the exception
try {
// Prompting the user to enter values to be processed
System.out.println("Unesite devet brojeva za izracunavanje ISBN ");
// Placing the values in an array
int[] brojevi = new int[9];
for (int i = 0; i < brojevi.length; i++) {
brojevi[i] = input.nextInt();
}
int checksum = 0; // Variable to store value of the 10. number
int up = 0;// position counter needed for ISBN calculation
// loop for summing the values
for (int i = 0; i < brojevi.length; i++) {
up++;
checksum += brojevi[i] * up;
}
checksum %= 11;
// conditions for outputting the ISBN
if (checksum == 10) {
for (int i = 0; i < brojevi.length; i++) {
System.out.print(brojevi[i] + " ");
}
System.out.print("X");
} else {
for (int i = 0; i < brojevi.length; i++) {
System.out.print(brojevi[i] + " ");
}
System.out.print(checksum);
}
} catch (Exception e) {
System.out.println(" Doslo je do greske ");
}
input.close();
}
}
|
UTF-8
|
Java
| 1,318 |
java
|
BrojKnjige.java
|
Java
|
[] | null |
[] |
package zadaci_18_01_2016;
import java.util.InputMismatchException;
public class BrojKnjige {
public static void main(String[] args) throws InputMismatchException {
java.util.Scanner input = new java.util.Scanner(System.in);
// Handling the exception
try {
// Prompting the user to enter values to be processed
System.out.println("Unesite devet brojeva za izracunavanje ISBN ");
// Placing the values in an array
int[] brojevi = new int[9];
for (int i = 0; i < brojevi.length; i++) {
brojevi[i] = input.nextInt();
}
int checksum = 0; // Variable to store value of the 10. number
int up = 0;// position counter needed for ISBN calculation
// loop for summing the values
for (int i = 0; i < brojevi.length; i++) {
up++;
checksum += brojevi[i] * up;
}
checksum %= 11;
// conditions for outputting the ISBN
if (checksum == 10) {
for (int i = 0; i < brojevi.length; i++) {
System.out.print(brojevi[i] + " ");
}
System.out.print("X");
} else {
for (int i = 0; i < brojevi.length; i++) {
System.out.print(brojevi[i] + " ");
}
System.out.print(checksum);
}
} catch (Exception e) {
System.out.println(" Doslo je do greske ");
}
input.close();
}
}
| 1,318 | 0.592564 | 0.576631 | 53 | 22.867924 | 21.737749 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.622642 | false | false |
13
|
71cbf53ebc0c0e3785dc80707fc7a5ffcea2a6a3
| 3,813,930,988,251 |
386392a0b910c55fdfc9c6f9f7798793404e6a8e
|
/src/com/android/messaging/mmslib/pdu/PduBody.java
|
8cbb2e683964c2926123c80985ea7f79cf1f9b21
|
[] |
no_license
|
CyanogenMod/android_packages_apps_Messaging
|
https://github.com/CyanogenMod/android_packages_apps_Messaging
|
c7ecdb8f6999b612bf1066014e641ec9c569f53b
|
d5fc4ce8c407e94dce2c013d94f643289b7a1a5c
|
refs/heads/cm-13.0
| 2021-01-17T01:48:47.750000 | 2016-12-22T01:19:35 | 2016-12-22T01:19:35 | 45,417,877 | 14 | 74 | null | false | 2016-11-27T12:08:08 | 2015-11-02T19:46:08 | 2016-11-11T11:42:29 | 2016-11-27T11:55:03 | 9,243 | 9 | 47 | 0 |
Java
| null | null |
/*
* Copyright (C) 2007 Esmertec AG.
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.messaging.mmslib.pdu;
import java.util.Vector;
public class PduBody {
private Vector<PduPart> mParts = null;
/**
* Constructor.
*/
public PduBody() {
mParts = new Vector<PduPart>();
}
/**
* Appends the specified part to the end of this body.
*
* @param part part to be appended
* @return true when success, false when fail
* @throws NullPointerException when part is null
*/
public boolean addPart(PduPart part) {
if (null == part) {
throw new NullPointerException();
}
return mParts.add(part);
}
/**
* Inserts the specified part at the specified position.
*
* @param index index at which the specified part is to be inserted
* @param part part to be inserted
* @throws NullPointerException when part is null
*/
public void addPart(int index, PduPart part) {
if (null == part) {
throw new NullPointerException();
}
mParts.add(index, part);
}
/**
* Remove all of the parts.
*/
public void removeAll() {
mParts.clear();
}
/**
* Get the part at the specified position.
*
* @param index index of the part to return
* @return part at the specified index
*/
public PduPart getPart(int index) {
return mParts.get(index);
}
/**
* Get the number of parts.
*
* @return the number of parts
*/
public int getPartsNum() {
return mParts.size();
}
}
|
UTF-8
|
Java
| 2,227 |
java
|
PduBody.java
|
Java
|
[] | null |
[] |
/*
* Copyright (C) 2007 Esmertec AG.
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.messaging.mmslib.pdu;
import java.util.Vector;
public class PduBody {
private Vector<PduPart> mParts = null;
/**
* Constructor.
*/
public PduBody() {
mParts = new Vector<PduPart>();
}
/**
* Appends the specified part to the end of this body.
*
* @param part part to be appended
* @return true when success, false when fail
* @throws NullPointerException when part is null
*/
public boolean addPart(PduPart part) {
if (null == part) {
throw new NullPointerException();
}
return mParts.add(part);
}
/**
* Inserts the specified part at the specified position.
*
* @param index index at which the specified part is to be inserted
* @param part part to be inserted
* @throws NullPointerException when part is null
*/
public void addPart(int index, PduPart part) {
if (null == part) {
throw new NullPointerException();
}
mParts.add(index, part);
}
/**
* Remove all of the parts.
*/
public void removeAll() {
mParts.clear();
}
/**
* Get the part at the specified position.
*
* @param index index of the part to return
* @return part at the specified index
*/
public PduPart getPart(int index) {
return mParts.get(index);
}
/**
* Get the number of parts.
*
* @return the number of parts
*/
public int getPartsNum() {
return mParts.size();
}
}
| 2,227 | 0.619219 | 0.61383 | 87 | 24.597702 | 22.286257 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.218391 | false | false |
13
|
cbc16c5726964bbfd020ba04276b11e4bd838ba1
| 28,613,072,134,451 |
44aebe6741982484faa00057bb725a61495408f4
|
/DemoBoxWeight.java
|
fb906871d9fb2c1500f750ee4fde865dbd39bed9
|
[] |
no_license
|
advanceddatastructures2020/Najmal_java
|
https://github.com/advanceddatastructures2020/Najmal_java
|
db703090ae9973d8b8aaad7b708c15bb4ed082e3
|
375626703d434b1d311383b127c23227e88de55a
|
refs/heads/main
| 2023-08-03T00:12:43.178000 | 2021-09-14T07:47:50 | 2021-09-14T07:47:50 | 366,315,083 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
class Box
{
double width,height,depth;
Box(Box ob)
{
width= ob.width;
height=ob.height;
depth= ob.depth;
}
Box(double w,double h,double d)
{
width=w;
height=h;
depth=d;
}
Box()
{
width=-1;
height=-1;
depth=-1;
}
Box(double len)
{
width=height=depth=len;
}
double volume()
{
return width*height*depth;
}
}
class BoxWeight extends Box
{
double weight;
BoxWeight(double w,double h, double d, double m)
{
width=w;
height=h;
depth=d;
weight=m;
}
}
class DemoBoxWeight
{
public static void main(String args[])
{
BoxWeight mybox1= new BoxWeight(10,20,15,34.3);
BoxWeight mybox2= new BoxWeight(2,3,4,0.076);
double vol;
vol=mybox1.volume();
System.out.println("Vol of mybox1="+vol);
System.out.println("Wt of mybox1="+mybox1.weight);
vol=mybox2.volume();
System.out.println("Vol of mybox2="+vol);
System.out.println("Wt of mybox2="+mybox2.weight);
}
}
|
UTF-8
|
Java
| 952 |
java
|
DemoBoxWeight.java
|
Java
|
[] | null |
[] |
class Box
{
double width,height,depth;
Box(Box ob)
{
width= ob.width;
height=ob.height;
depth= ob.depth;
}
Box(double w,double h,double d)
{
width=w;
height=h;
depth=d;
}
Box()
{
width=-1;
height=-1;
depth=-1;
}
Box(double len)
{
width=height=depth=len;
}
double volume()
{
return width*height*depth;
}
}
class BoxWeight extends Box
{
double weight;
BoxWeight(double w,double h, double d, double m)
{
width=w;
height=h;
depth=d;
weight=m;
}
}
class DemoBoxWeight
{
public static void main(String args[])
{
BoxWeight mybox1= new BoxWeight(10,20,15,34.3);
BoxWeight mybox2= new BoxWeight(2,3,4,0.076);
double vol;
vol=mybox1.volume();
System.out.println("Vol of mybox1="+vol);
System.out.println("Wt of mybox1="+mybox1.weight);
vol=mybox2.volume();
System.out.println("Vol of mybox2="+vol);
System.out.println("Wt of mybox2="+mybox2.weight);
}
}
| 952 | 0.628151 | 0.597689 | 59 | 14.169492 | 15.037977 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.474576 | false | false |
13
|
caa732969c71898b074ff25966afd5515aa0ff64
| 19,567,871,067,233 |
eb9f655206c43c12b497c667ba56a0d358b6bc3a
|
/RegExpSupport/src/org/intellij/lang/regexp/inspection/RegExpSimplifiableInspection.java
|
9257cb106623fea983e96ad82d9160888c6c3ca5
|
[
"Apache-2.0"
] |
permissive
|
JetBrains/intellij-community
|
https://github.com/JetBrains/intellij-community
|
2ed226e200ecc17c037dcddd4a006de56cd43941
|
05dbd4575d01a213f3f4d69aa4968473f2536142
|
refs/heads/master
| 2023-09-03T17:06:37.560000 | 2023-09-03T11:51:00 | 2023-09-03T12:12:27 | 2,489,216 | 16,288 | 6,635 |
Apache-2.0
| false | 2023-09-12T07:41:58 | 2011-09-30T13:33:05 | 2023-09-12T03:37:30 | 2023-09-12T06:46:46 | 4,523,919 | 15,754 | 4,972 | 237 | null | false | false |
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.intellij.lang.regexp.inspection;
import com.intellij.codeInspection.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.lang.regexp.RegExpBundle;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.*;
import org.jetbrains.annotations.NotNull;
/**
* @author Bas Leijdekkers
*/
public class RegExpSimplifiableInspection extends LocalInspectionTool {
@Override
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new RegExpSimplifiableVisitor(holder);
}
private static class RegExpSimplifiableVisitor extends RegExpElementVisitor {
private final ProblemsHolder myHolder;
RegExpSimplifiableVisitor(@NotNull ProblemsHolder holder) {
myHolder = holder;
}
@Override
public void visitRegExpClass(RegExpClass regExpClass) {
super.visitRegExpClass(regExpClass);
final RegExpClassElement[] elements = regExpClass.getElements();
for (RegExpClassElement element : elements) {
if (element instanceof RegExpCharRange range) {
final int from = range.getFrom().getValue();
final RegExpChar to = range.getTo();
if (from != -1 && to != null && from == to.getValue()) {
// [a-abc] -> [abc]
registerProblem(range, to.getUnescapedText());
}
}
}
if (regExpClass.isNegated()) {
if (elements.length == 1) {
final RegExpClassElement element = elements[0];
if (element instanceof RegExpSimpleClass simpleClass) {
final String text = getInverseSimpleClassText(simpleClass);
if (text != null) {
// [^\d] -> \D
registerProblem(regExpClass, text);
}
}
}
}
else {
if (elements.length == 1) {
final RegExpClassElement element = elements[0];
if (element instanceof RegExpPosixBracketExpression) return;
if (!(element instanceof RegExpCharRange)) {
if (!(element instanceof RegExpChar) || !"{}().*+?|$".contains(element.getText())) {
// [a] -> a
registerProblem(regExpClass, element.getUnescapedText());
}
}
}
}
}
@Override
public void visitRegExpClosure(RegExpClosure closure) {
super.visitRegExpClosure(closure);
ASTNode token = closure.getQuantifier().getToken();
if (token == null || token.getElementType() != RegExpTT.STAR) {
return;
}
PsiElement sibling = closure.getPrevSibling();
RegExpAtom atom = closure.getAtom();
if (sibling instanceof RegExpElement && atom.getClass() == sibling.getClass() && sibling.textMatches(atom) && !containsGroup(atom)) {
final String text = atom.getUnescapedText() + '+';
myHolder.registerProblem(closure.getParent(),
TextRange.from(sibling.getStartOffsetInParent(), sibling.getTextLength() + closure.getTextLength()),
RegExpBundle.message("inspection.warning.can.be.simplified", text),
new RegExpSimplifiableFix(text));
}
}
@Override
public void visitRegExpProperty(RegExpProperty property) {
super.visitRegExpProperty(property);
final ASTNode categoryNode = property.getCategoryNode();
if (categoryNode == null) {
return;
}
final String category = categoryNode.getText();
switch (category) {
case "Digit", "IsDigit" -> registerProblem(property, property.isNegated() ? "\\D" : "\\d");
case "Blank", "IsBlank" -> registerProblem(property, property.isNegated() ? "[^ \\t]" : "[ \\t]");
case "Space", "IsSpace", "IsWhite_Space", "IsWhiteSpace" -> registerProblem(property, property.isNegated() ? "\\S" : "\\s");
}
}
@Override
public void visitRegExpQuantifier(RegExpQuantifier quantifier) {
if (!quantifier.isCounted()) {
return;
}
final RegExpNumber minElement = quantifier.getMin();
final String min = minElement == null ? "" : minElement.getText();
final RegExpNumber maxElement = quantifier.getMax();
final String max = maxElement == null ? "" : maxElement.getText();
if (!max.isEmpty() && max.equals(min)) {
if ("1".equals(max)) {
myHolder.registerProblem(quantifier,
RegExpBundle.message("inspection.warning.can.be.removed"),
new RegExpSimplifiableFix(quantifier.getText(), true));
}
else {
final ASTNode node = quantifier.getNode();
if (node.findChildByType(RegExpTT.COMMA) != null) {
registerProblem(quantifier, "{" + max + "}");
}
}
}
else if (("0".equals(min) || min.isEmpty()) && "1".equals(max)) {
registerProblem(quantifier, "?");
}
else if (("0".equals(min) || min.isEmpty()) && max.isEmpty()) {
registerProblem(quantifier, "*");
}
else if ("1".equals(min) && max.isEmpty()) {
registerProblem(quantifier, "+");
}
}
private void registerProblem(RegExpElement element, String replacement) {
myHolder.registerProblem(element,
RegExpBundle.message("inspection.warning.can.be.simplified", replacement),
new RegExpSimplifiableFix(replacement));
}
private static boolean containsGroup(RegExpAtom atom) {
return atom instanceof RegExpGroup || PsiTreeUtil.findChildOfType(atom, RegExpGroup.class) != null;
}
private static String getInverseSimpleClassText(RegExpSimpleClass simpleClass) {
return switch (simpleClass.getKind()) {
case DIGIT -> "\\D";
case NON_DIGIT -> "\\d";
case WORD -> "\\W";
case NON_WORD -> "\\w";
case SPACE -> "\\S";
case NON_SPACE -> "\\s";
case HORIZONTAL_SPACE -> "\\H";
case NON_HORIZONTAL_SPACE -> "\\h";
case VERTICAL_SPACE -> "\\V";
case NON_VERTICAL_SPACE -> "\\v";
case XML_NAME_START -> "\\I";
case NON_XML_NAME_START -> "\\i";
case XML_NAME_PART -> "\\C";
case NON_XML_NAME_PART -> "\\c";
default -> null;
};
}
private static class RegExpSimplifiableFix implements LocalQuickFix {
private final String myExpression;
private final boolean myDelete;
RegExpSimplifiableFix(String newExpression) {
this(newExpression, false);
}
RegExpSimplifiableFix(String expression, boolean delete) {
myExpression = expression;
myDelete = delete;
}
@Override
public @NotNull String getFamilyName() {
return CommonQuickFixBundle.message("fix.simplify");
}
@Override
public @NotNull String getName() {
return myDelete
? CommonQuickFixBundle.message("fix.remove", myExpression)
: CommonQuickFixBundle.message("fix.replace.with.x", myExpression);
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
if (!(element instanceof RegExpElement)) {
return;
}
RegExpReplacementUtil.replaceInContext(element, myDelete ? "" : myExpression, descriptor.getTextRangeInElement());
}
}
}
}
|
UTF-8
|
Java
| 7,829 |
java
|
RegExpSimplifiableInspection.java
|
Java
|
[
{
"context": "org.jetbrains.annotations.NotNull;\n\n/**\n * @author Bas Leijdekkers\n */\npublic class RegExpSimplifiableInspection ext",
"end": 649,
"score": 0.9998393654823303,
"start": 634,
"tag": "NAME",
"value": "Bas Leijdekkers"
}
] | null |
[] |
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.intellij.lang.regexp.inspection;
import com.intellij.codeInspection.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.lang.regexp.RegExpBundle;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.*;
import org.jetbrains.annotations.NotNull;
/**
* @author <NAME>
*/
public class RegExpSimplifiableInspection extends LocalInspectionTool {
@Override
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
return new RegExpSimplifiableVisitor(holder);
}
private static class RegExpSimplifiableVisitor extends RegExpElementVisitor {
private final ProblemsHolder myHolder;
RegExpSimplifiableVisitor(@NotNull ProblemsHolder holder) {
myHolder = holder;
}
@Override
public void visitRegExpClass(RegExpClass regExpClass) {
super.visitRegExpClass(regExpClass);
final RegExpClassElement[] elements = regExpClass.getElements();
for (RegExpClassElement element : elements) {
if (element instanceof RegExpCharRange range) {
final int from = range.getFrom().getValue();
final RegExpChar to = range.getTo();
if (from != -1 && to != null && from == to.getValue()) {
// [a-abc] -> [abc]
registerProblem(range, to.getUnescapedText());
}
}
}
if (regExpClass.isNegated()) {
if (elements.length == 1) {
final RegExpClassElement element = elements[0];
if (element instanceof RegExpSimpleClass simpleClass) {
final String text = getInverseSimpleClassText(simpleClass);
if (text != null) {
// [^\d] -> \D
registerProblem(regExpClass, text);
}
}
}
}
else {
if (elements.length == 1) {
final RegExpClassElement element = elements[0];
if (element instanceof RegExpPosixBracketExpression) return;
if (!(element instanceof RegExpCharRange)) {
if (!(element instanceof RegExpChar) || !"{}().*+?|$".contains(element.getText())) {
// [a] -> a
registerProblem(regExpClass, element.getUnescapedText());
}
}
}
}
}
@Override
public void visitRegExpClosure(RegExpClosure closure) {
super.visitRegExpClosure(closure);
ASTNode token = closure.getQuantifier().getToken();
if (token == null || token.getElementType() != RegExpTT.STAR) {
return;
}
PsiElement sibling = closure.getPrevSibling();
RegExpAtom atom = closure.getAtom();
if (sibling instanceof RegExpElement && atom.getClass() == sibling.getClass() && sibling.textMatches(atom) && !containsGroup(atom)) {
final String text = atom.getUnescapedText() + '+';
myHolder.registerProblem(closure.getParent(),
TextRange.from(sibling.getStartOffsetInParent(), sibling.getTextLength() + closure.getTextLength()),
RegExpBundle.message("inspection.warning.can.be.simplified", text),
new RegExpSimplifiableFix(text));
}
}
@Override
public void visitRegExpProperty(RegExpProperty property) {
super.visitRegExpProperty(property);
final ASTNode categoryNode = property.getCategoryNode();
if (categoryNode == null) {
return;
}
final String category = categoryNode.getText();
switch (category) {
case "Digit", "IsDigit" -> registerProblem(property, property.isNegated() ? "\\D" : "\\d");
case "Blank", "IsBlank" -> registerProblem(property, property.isNegated() ? "[^ \\t]" : "[ \\t]");
case "Space", "IsSpace", "IsWhite_Space", "IsWhiteSpace" -> registerProblem(property, property.isNegated() ? "\\S" : "\\s");
}
}
@Override
public void visitRegExpQuantifier(RegExpQuantifier quantifier) {
if (!quantifier.isCounted()) {
return;
}
final RegExpNumber minElement = quantifier.getMin();
final String min = minElement == null ? "" : minElement.getText();
final RegExpNumber maxElement = quantifier.getMax();
final String max = maxElement == null ? "" : maxElement.getText();
if (!max.isEmpty() && max.equals(min)) {
if ("1".equals(max)) {
myHolder.registerProblem(quantifier,
RegExpBundle.message("inspection.warning.can.be.removed"),
new RegExpSimplifiableFix(quantifier.getText(), true));
}
else {
final ASTNode node = quantifier.getNode();
if (node.findChildByType(RegExpTT.COMMA) != null) {
registerProblem(quantifier, "{" + max + "}");
}
}
}
else if (("0".equals(min) || min.isEmpty()) && "1".equals(max)) {
registerProblem(quantifier, "?");
}
else if (("0".equals(min) || min.isEmpty()) && max.isEmpty()) {
registerProblem(quantifier, "*");
}
else if ("1".equals(min) && max.isEmpty()) {
registerProblem(quantifier, "+");
}
}
private void registerProblem(RegExpElement element, String replacement) {
myHolder.registerProblem(element,
RegExpBundle.message("inspection.warning.can.be.simplified", replacement),
new RegExpSimplifiableFix(replacement));
}
private static boolean containsGroup(RegExpAtom atom) {
return atom instanceof RegExpGroup || PsiTreeUtil.findChildOfType(atom, RegExpGroup.class) != null;
}
private static String getInverseSimpleClassText(RegExpSimpleClass simpleClass) {
return switch (simpleClass.getKind()) {
case DIGIT -> "\\D";
case NON_DIGIT -> "\\d";
case WORD -> "\\W";
case NON_WORD -> "\\w";
case SPACE -> "\\S";
case NON_SPACE -> "\\s";
case HORIZONTAL_SPACE -> "\\H";
case NON_HORIZONTAL_SPACE -> "\\h";
case VERTICAL_SPACE -> "\\V";
case NON_VERTICAL_SPACE -> "\\v";
case XML_NAME_START -> "\\I";
case NON_XML_NAME_START -> "\\i";
case XML_NAME_PART -> "\\C";
case NON_XML_NAME_PART -> "\\c";
default -> null;
};
}
private static class RegExpSimplifiableFix implements LocalQuickFix {
private final String myExpression;
private final boolean myDelete;
RegExpSimplifiableFix(String newExpression) {
this(newExpression, false);
}
RegExpSimplifiableFix(String expression, boolean delete) {
myExpression = expression;
myDelete = delete;
}
@Override
public @NotNull String getFamilyName() {
return CommonQuickFixBundle.message("fix.simplify");
}
@Override
public @NotNull String getName() {
return myDelete
? CommonQuickFixBundle.message("fix.remove", myExpression)
: CommonQuickFixBundle.message("fix.replace.with.x", myExpression);
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
if (!(element instanceof RegExpElement)) {
return;
}
RegExpReplacementUtil.replaceInContext(element, myDelete ? "" : myExpression, descriptor.getTextRangeInElement());
}
}
}
}
| 7,820 | 0.615277 | 0.612722 | 204 | 37.377453 | 30.87117 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.617647 | false | false |
13
|
5fbd4ab285185baa610fe0e46e69344f40bede7b
| 4,269,197,493,259 |
4b62068cd2a971d8398c1641dcad9ea51485e300
|
/src/main/java/Utils/ValidatorUtil.java
|
b631514fe4a71c076641f5dae1efc5d784009343
|
[] |
no_license
|
YCP0627/EclipseWorkspaces
|
https://github.com/YCP0627/EclipseWorkspaces
|
5f3f499d5d251e47f697c5dc5c29bc9bd7700cc2
|
d226ade8965d86c8c43074729e2332b559048017
|
refs/heads/master
| 2020-04-14T10:24:51.528000 | 2018-12-17T07:31:39 | 2018-12-17T07:31:39 | 163,786,129 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Utils;
import Entity.GlobalException;
import com.mysql.cj.util.StringUtils;
import org.hibernate.validator.HibernateValidator;
import javax.el.Expression;
import javax.el.ExpressionFactory;
import javax.swing.*;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.groups.Default;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ValidatorUtil {
private static Validator validator = Validation
.byProvider(HibernateValidator.class).configure().failFast(true).buildValidatorFactory().getValidator();
public static <T> void validate(JFrame jFrame,T obj){
Set<ConstraintViolation<T>> set = validator.validate(obj,Default.class);
if(set != null && set.size() >0 ){
System.out.println(set.size());
throw new GlobalException(jFrame,set.iterator().next().getMessage());
}
}
}
|
UTF-8
|
Java
| 1,041 |
java
|
ValidatorUtil.java
|
Java
|
[] | null |
[] |
package Utils;
import Entity.GlobalException;
import com.mysql.cj.util.StringUtils;
import org.hibernate.validator.HibernateValidator;
import javax.el.Expression;
import javax.el.ExpressionFactory;
import javax.swing.*;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.groups.Default;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ValidatorUtil {
private static Validator validator = Validation
.byProvider(HibernateValidator.class).configure().failFast(true).buildValidatorFactory().getValidator();
public static <T> void validate(JFrame jFrame,T obj){
Set<ConstraintViolation<T>> set = validator.validate(obj,Default.class);
if(set != null && set.size() >0 ){
System.out.println(set.size());
throw new GlobalException(jFrame,set.iterator().next().getMessage());
}
}
}
| 1,041 | 0.740634 | 0.739673 | 34 | 29.617647 | 26.29249 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.676471 | false | false |
13
|
3c7f9293bff2d5d98f459747c64800fe5bda3b1e
| 17,291,538,361,940 |
875c5abc53844feed26c7e61981bc958178d505f
|
/spring-databinding-validation/src/main/java/com/panlingxiao/spring/validation/domain/Point.java
|
a15040d588a47baf38e0180ae2e3f4f090639ab4
|
[] |
no_license
|
plx927/MyRepository
|
https://github.com/plx927/MyRepository
|
9e72d34b0f157dde369b0ea28168213287699484
|
465efd7305ccb7c3f65c76ea5373227f35210cf3
|
refs/heads/master
| 2022-12-22T17:12:41.622000 | 2020-02-23T16:42:50 | 2020-02-23T16:42:50 | 48,499,441 | 4 | 3 | null | false | 2022-12-16T09:44:07 | 2015-12-23T16:10:40 | 2020-10-16T08:55:31 | 2022-12-16T09:44:07 | 305 | 3 | 1 | 6 |
Java
| false | false |
package com.panlingxiao.spring.validation.domain;
import lombok.Data;
@Data
public class Point {
int x, y;
}
|
UTF-8
|
Java
| 115 |
java
|
Point.java
|
Java
|
[] | null |
[] |
package com.panlingxiao.spring.validation.domain;
import lombok.Data;
@Data
public class Point {
int x, y;
}
| 115 | 0.730435 | 0.730435 | 9 | 11.888889 | 15.220195 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false |
13
|
5d96b58d618114800912052dcfd491e6042390bc
| 17,291,538,362,505 |
69735e4777a859a998244526c345e9b3b686fedd
|
/src/main/java/com/emse/spring/faircorp/dto/RoomDto.java
|
3d1d54f3f60dda2ac529f0d85d9da4d9a21e7e95
|
[] |
no_license
|
dhayanth-dharma/spring-good-practice
|
https://github.com/dhayanth-dharma/spring-good-practice
|
e50108dfceceac1251b5c8ddde363c7e20263ec3
|
33babb8e9c341a82d17bc69d6d0b8eb1a60afd23
|
refs/heads/master
| 2023-01-22T08:33:27.510000 | 2020-11-25T08:22:45 | 2020-11-25T08:22:45 | 315,624,934 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.emse.spring.faircorp.dto;
public class RoomDto {
}
|
UTF-8
|
Java
| 64 |
java
|
RoomDto.java
|
Java
|
[] | null |
[] |
package com.emse.spring.faircorp.dto;
public class RoomDto {
}
| 64 | 0.765625 | 0.765625 | 4 | 15 | 15.443445 | 37 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false |
13
|
b5f8f87dafaf19d28998b475f18839a3d68f0c4f
| 25,374,666,835,226 |
c343e471cdf5c22fe807a03bdcbb462bf5dffb6a
|
/webapp/src/main/java/net/mashrur/tryouts/servlets/filters/TestServletFilter.java
|
5f37187ab46f7dba134bde095b202d19f7c367d7
|
[] |
no_license
|
saadlu/Notes
|
https://github.com/saadlu/Notes
|
f01f53d8b0a75ecfe4590cbaff371a4638f8ad52
|
0985f1daa34f87f877373034abd84f28b4c6ec91
|
refs/heads/master
| 2020-04-27T14:18:34.754000 | 2011-10-16T21:30:30 | 2011-10-16T21:30:30 | 2,587,388 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package net.mashrur.tryouts.servlets.filters;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpServletResponse;
/**
* @web.filter name="TestServletFilter"
*
* @web.filter-mapping servlet-name="FirstServlet"
*/
public class TestServletFilter
implements Filter{
public void init(FilterConfig config){
System.out.println("Filter initialized yeah!!!");
}
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
throws IOException, ServletException{
System.out.println("doFilter called");
CharResponseWrapper crw =
new CharResponseWrapper((HttpServletResponse)response);
filterChain.doFilter(request,crw);
PrintWriter out = ((HttpServletResponse)response).getWriter();
out.println(crw.toString());
out.println("Stuff from filter");
out.close();
}
private static class CharResponseWrapper
extends HttpServletResponseWrapper{
private CharArrayWriter output;
public CharResponseWrapper(HttpServletResponse response){
super(response);
output = new CharArrayWriter();
}
public String toString(){
return output.toString();
}
public PrintWriter getWriter(){
return new PrintWriter(output);
}
}
public void destroy(){
System.out.println("Filter destroyed");
}
}
|
UTF-8
|
Java
| 1,706 |
java
|
TestServletFilter.java
|
Java
|
[] | null |
[] |
package net.mashrur.tryouts.servlets.filters;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpServletResponse;
/**
* @web.filter name="TestServletFilter"
*
* @web.filter-mapping servlet-name="FirstServlet"
*/
public class TestServletFilter
implements Filter{
public void init(FilterConfig config){
System.out.println("Filter initialized yeah!!!");
}
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain filterChain)
throws IOException, ServletException{
System.out.println("doFilter called");
CharResponseWrapper crw =
new CharResponseWrapper((HttpServletResponse)response);
filterChain.doFilter(request,crw);
PrintWriter out = ((HttpServletResponse)response).getWriter();
out.println(crw.toString());
out.println("Stuff from filter");
out.close();
}
private static class CharResponseWrapper
extends HttpServletResponseWrapper{
private CharArrayWriter output;
public CharResponseWrapper(HttpServletResponse response){
super(response);
output = new CharArrayWriter();
}
public String toString(){
return output.toString();
}
public PrintWriter getWriter(){
return new PrintWriter(output);
}
}
public void destroy(){
System.out.println("Filter destroyed");
}
}
| 1,706 | 0.728605 | 0.728605 | 69 | 22.753624 | 18.928856 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.884058 | false | false |
13
|
4b3bac855b6fffe22fd784c11211c64b9b855135
| 30,657,476,612,066 |
84643c21e9d0aecd54fe8db8a9d91c8df04dd1a3
|
/library/src/test/java/gold/me/clear/library/XorTest.java
|
9f23eddf25d31b4594100e5a47845625d6c1da51
|
[] |
no_license
|
privacy-unknown/app-manager-v1
|
https://github.com/privacy-unknown/app-manager-v1
|
c6acf90fded4050d1c6e2bfff2f184f44d6aeda9
|
91e8f67e7a6ec86c562fc1e115f7583649669198
|
refs/heads/master
| 2018-09-30T18:53:22.889000 | 2018-06-11T20:05:44 | 2018-06-11T20:05:44 | 126,873,403 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package gold.me.clear.library;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class XorTest {
@Test
public void printDecodedString() {
assertDecoding("settings");
assertDecoding("hide_icon");
assertDecoding("Android");
assertDecoding(".clear.provider");
assertDecoding("file://");
assertDecoding("US");
assertDecoding("Google");
assertDecoding("http://ip-api.com/json");
assertDecoding("device");
assertDecoding("country");
assertDecoding("countryCode");
assertDecoding("org");
assertDecoding("region");
assertDecoding("push_token");
assertDecoding("os_version");
assertDecoding("tag");
assertDecoding("device/check");
assertDecoding("Authorization");
assertDecoding("type");
assertDecoding("android.intent.action.BOOT_COMPLETED");
assertDecoding("android.intent.action.PACKAGE_ADDED");
}
private void assertDecoding(String input) {
String encoded = CommonUtils.wrapConstant(input);
String decoded = CommonUtils.wrapConstant(encoded);
System.out.print("\n");
System.out.println("original: " + input);
System.out.println("encoded: END-" + encoded + "-END");
System.out.println("decoded: " + decoded);
System.out.println("-----------------");
assertEquals(input, decoded);
}
}
|
UTF-8
|
Java
| 1,464 |
java
|
XorTest.java
|
Java
|
[] | null |
[] |
package gold.me.clear.library;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class XorTest {
@Test
public void printDecodedString() {
assertDecoding("settings");
assertDecoding("hide_icon");
assertDecoding("Android");
assertDecoding(".clear.provider");
assertDecoding("file://");
assertDecoding("US");
assertDecoding("Google");
assertDecoding("http://ip-api.com/json");
assertDecoding("device");
assertDecoding("country");
assertDecoding("countryCode");
assertDecoding("org");
assertDecoding("region");
assertDecoding("push_token");
assertDecoding("os_version");
assertDecoding("tag");
assertDecoding("device/check");
assertDecoding("Authorization");
assertDecoding("type");
assertDecoding("android.intent.action.BOOT_COMPLETED");
assertDecoding("android.intent.action.PACKAGE_ADDED");
}
private void assertDecoding(String input) {
String encoded = CommonUtils.wrapConstant(input);
String decoded = CommonUtils.wrapConstant(encoded);
System.out.print("\n");
System.out.println("original: " + input);
System.out.println("encoded: END-" + encoded + "-END");
System.out.println("decoded: " + decoded);
System.out.println("-----------------");
assertEquals(input, decoded);
}
}
| 1,464 | 0.617486 | 0.617486 | 49 | 28.897959 | 19.713505 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.673469 | false | false |
13
|
f6ae66a444d705d32997cbd76ac88c6c38e405e4
| 32,126,355,430,540 |
69a4f2d51ebeea36c4d8192e25cfb5f3f77bef5e
|
/methods/Method_50480.java
|
00fb1c80698d40b5409d5ef8f6fd711d7785cf7c
|
[] |
no_license
|
P79N6A/icse_20_user_study
|
https://github.com/P79N6A/icse_20_user_study
|
5b9c42c6384502fdc9588430899f257761f1f506
|
8a3676bc96059ea2c4f6d209016f5088a5628f3c
|
refs/heads/master
| 2020-06-24T08:25:22.606000 | 2019-07-25T15:31:16 | 2019-07-25T15:31:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
@Override public List<HmilyTransaction> listAll(){
List<HmilyTransaction> transactionRecovers=Lists.newArrayList();
List<String> zNodePaths;
try {
zNodePaths=zooKeeper.getChildren(rootPathPrefix,false);
}
catch ( Exception e) {
throw new HmilyRuntimeException(e);
}
if (CollectionUtils.isNotEmpty(zNodePaths)) {
transactionRecovers=zNodePaths.stream().filter(StringUtils::isNoneBlank).map(zNodePath -> {
try {
byte[] content=zooKeeper.getData(buildRootPath(zNodePath),false,new Stat());
return RepositoryConvertUtils.transformBean(content,objectSerializer);
}
catch ( KeeperException|InterruptedException|HmilyException e) {
e.printStackTrace();
}
return null;
}
).collect(Collectors.toList());
}
return transactionRecovers;
}
|
UTF-8
|
Java
| 815 |
java
|
Method_50480.java
|
Java
|
[] | null |
[] |
@Override public List<HmilyTransaction> listAll(){
List<HmilyTransaction> transactionRecovers=Lists.newArrayList();
List<String> zNodePaths;
try {
zNodePaths=zooKeeper.getChildren(rootPathPrefix,false);
}
catch ( Exception e) {
throw new HmilyRuntimeException(e);
}
if (CollectionUtils.isNotEmpty(zNodePaths)) {
transactionRecovers=zNodePaths.stream().filter(StringUtils::isNoneBlank).map(zNodePath -> {
try {
byte[] content=zooKeeper.getData(buildRootPath(zNodePath),false,new Stat());
return RepositoryConvertUtils.transformBean(content,objectSerializer);
}
catch ( KeeperException|InterruptedException|HmilyException e) {
e.printStackTrace();
}
return null;
}
).collect(Collectors.toList());
}
return transactionRecovers;
}
| 815 | 0.715337 | 0.715337 | 24 | 32.958332 | 28.537226 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
13
|
11061b46351ba2ce40ef1d9190a912a9603f08af
| 11,699,490,976,142 |
0d1d37e25aae8ffeba3516d00e34cd046bfafcda
|
/dealer/src/test/java/cn/lmjia/market/dealer/controller/AgentControllerTest.java
|
5f13272f8818a125e7dc0ea80080a7d617c86ed1
|
[] |
no_license
|
JoleneOL/market-manage
|
https://github.com/JoleneOL/market-manage
|
c14897904b206e90b7435cde5c38e739fe094ca7
|
0f3baa4ffaf5d87cf61d288ff1a8cdde5e939617
|
refs/heads/production
| 2022-07-09T15:31:06.980000 | 2019-12-17T20:46:53 | 2019-12-17T20:46:53 | 89,607,184 | 88 | 40 | null | false | 2022-06-20T23:38:47 | 2017-04-27T14:34:09 | 2022-04-29T11:00:46 | 2022-06-20T23:38:44 | 9,286 | 72 | 39 | 31 |
Java
| false | false |
package cn.lmjia.market.dealer.controller;
import cn.lmjia.market.core.entity.Login;
import cn.lmjia.market.core.entity.Manager;
import cn.lmjia.market.core.entity.support.ManageLevel;
import cn.lmjia.market.dealer.DealerServiceTest;
import me.jiangcai.jpa.entity.support.Address;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Test;
import org.springframework.http.MediaType;
import java.time.LocalDate;
import java.util.UUID;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* @author CJ
*/
public class AgentControllerTest extends DealerServiceTest {
//curl 'http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Cookie: Idea-390470b1=20f86e89-5fd1-46f7-b19e-172f714e3451; __utma=111872281.1550433883.1463023041.1468930698.1468956142.15; Idea-390470b3=a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc' -H 'Origin: http://localhost:55555' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Connection: keep-alive'
// --data 'rank=%E6%B5%99%E6%B1%9F%E7%9C%81%E4%BB%A3%E7%90%86&agentName=%E5%BE%90%E5%8C%97%E6%96%B9&firstPayment=30000&agencyFee=30000&beginDate=2017-5-1&endDate=2018-5-1&mobile=18829901010&password=123456&guideUser=1&address=%E6%B2%B3%E5%8C%97%E7%9C%81%2F%E7%A7%A6%E7%9A%87%E5%B2%9B%E5%B8%82%2F%E5%8C%97%E6%88%B4%E6%B2%B3%E5%8C%BA&fullAddress=111111&cardFrontPath=filePath&cardBackPath=filePath&cardFront=&cardBack=' --compressed
//curl 'http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Cookie: Idea-390470b1=20f86e89-5fd1-46f7-b19e-172f714e3451; __utma=111872281.1550433883.1463023041.1468930698.1468956142.15; Idea-390470b3=a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc' -H 'Origin: http://localhost:55555' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Connection: keep-alive'
// --data 'superiorId=1&rank=%E6%B5%99%E6%B1%9F%E7%9C%81%E4%BB%A3%E7%90%86&agentName=%E5%BE%90%E5%8C%97%E6%96%B9&firstPayment=30000&agencyFee=30000&beginDate=2017-5-1&endDate=2018-5-1&mobile=18829901010&password=123456&guideUser=1&address=%E5%8C%97%E4%BA%AC%E5%B8%82%2F%E5%8C%97%E4%BA%AC%E5%B8%82%2F%E4%B8%9C%E5%9F%8E%E5%8C%BA&fullAddress=111111111&cardFrontPath=filePath&cardBackPath=filePath&cardFront=&cardBack=' --compressed
@Test
public void indexForAdd() throws Exception {
// 此处分2种情况
Manager manager = newRandomManager("", ManageLevel.customerManager);
runWith(manager, () -> {
mockMvc.perform(get("/addAgent"))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML))
.andExpect(view().name("addAgent.html"));
String rank = "某代理商" + RandomStringUtils.randomAlphabetic(10);
String agentName = "某人" + RandomStringUtils.randomAlphabetic(10);
int firstPayment = 1000 + random.nextInt(10000);
int agencyFee = 500 + random.nextInt(600);
LocalDate beginDate = LocalDate.now().minusMonths(2);
LocalDate endDate = LocalDate.now().plusMonths(2);
String mobile = randomMobile();
String password = UUID.randomUUID().toString();
Login guideUser = randomLogin(false);
Address address = randomAddress();
String cardFrontPath = newRandomImagePath();
String cardBackPath = newRandomImagePath();
String businessLicensePath = newRandomImagePath();
mockMvc.perform(post("/addAgent")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("rank", rank)
.param("agentName", agentName)
.param("firstPayment", String.valueOf(firstPayment))
.param("agencyFee", String.valueOf(agencyFee))
.param("beginDate", toText(beginDate))
.param("endDate", toText(endDate))
.param("mobile", mobile)
.param("password", password)
.param("guideUser", String.valueOf(guideUser.getId()))
.param("address", address.getStandardWithoutOther())
.param("fullAddress", address.getOtherAddress())
.param("cardFrontPath", cardFrontPath)
.param("cardBackPath", cardBackPath)
.param("businessLicensePath", businessLicensePath)
)
.andDo(print())
.andExpect(status().isFound())
;
// TODO 数据校验,以及因为手机号码的排他性,所以需要在页面上做远程校验 同时检查登录名以及联系表的手机号码
return null;
});
}
}
|
UTF-8
|
Java
| 5,860 |
java
|
AgentControllerTest.java
|
Java
|
[
{
"context": "et.result.MockMvcResultMatchers.*;\n\n/**\n * @author CJ\n */\npublic class AgentControllerTest extends Deal",
"end": 552,
"score": 0.9994525909423828,
"start": 550,
"tag": "USERNAME",
"value": "CJ"
},
{
"context": "a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc' -H 'Origin: http://localhost:55555' -H 'Accept-E",
"end": 954,
"score": 0.942328155040741,
"start": 914,
"tag": "KEY",
"value": "Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc"
},
{
"context": "-5-1&endDate=2018-5-1&mobile=18829901010&password=123456&guideUser=1&address=%E6%B2%B3%E5%8C%97%E7%9C%81%2",
"end": 1752,
"score": 0.9988234043121338,
"start": 1746,
"tag": "PASSWORD",
"value": "123456"
},
{
"context": "a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc' -H 'Origin: http://localhost:55555' -H 'Accept-E",
"end": 2313,
"score": 0.9160462617874146,
"start": 2273,
"tag": "KEY",
"value": "Ydn9jsKu29bd5lMf1M9ScSwfNIqhOuYSbswlq7Cc"
},
{
"context": "-5-1&endDate=2018-5-1&mobile=18829901010&password=123456&guideUser=1&address=%E5%8C%97%E4%BA%AC%E5%B8%82%2",
"end": 3124,
"score": 0.9993970394134521,
"start": 3118,
"tag": "PASSWORD",
"value": "123456"
},
{
"context": "omAlphabetic(10);\n String agentName = \"某人\" + RandomStringUtils.randomAlphabetic(10);\n ",
"end": 3879,
"score": 0.984410285949707,
"start": 3877,
"tag": "NAME",
"value": "某人"
},
{
"context": "le = randomMobile();\n String password = UUID.randomUUID().toString();\n Login guideUser = randomLogin(fals",
"end": 4268,
"score": 0.973476767539978,
"start": 4242,
"tag": "PASSWORD",
"value": "UUID.randomUUID().toString"
},
{
"context": "nk\", rank)\n .param(\"agentName\", agentName)\n .param(\"firstPayment\", Strin",
"end": 4754,
"score": 0.7743618488311768,
"start": 4745,
"tag": "NAME",
"value": "agentName"
},
{
"context": "e\", mobile)\n .param(\"password\", password)\n .param(\"guideUser\", String.v",
"end": 5102,
"score": 0.9974103569984436,
"start": 5094,
"tag": "PASSWORD",
"value": "password"
}
] | null |
[] |
package cn.lmjia.market.dealer.controller;
import cn.lmjia.market.core.entity.Login;
import cn.lmjia.market.core.entity.Manager;
import cn.lmjia.market.core.entity.support.ManageLevel;
import cn.lmjia.market.dealer.DealerServiceTest;
import me.jiangcai.jpa.entity.support.Address;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Test;
import org.springframework.http.MediaType;
import java.time.LocalDate;
import java.util.UUID;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* @author CJ
*/
public class AgentControllerTest extends DealerServiceTest {
//curl 'http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Cookie: Idea-390470b1=20f86e89-5fd1-46f7-b19e-172f714e3451; __utma=111872281.1550433883.1463023041.1468930698.1468956142.15; Idea-390470b3=a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=<KEY>' -H 'Origin: http://localhost:55555' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Connection: keep-alive'
// --data 'rank=%E6%B5%99%E6%B1%9F%E7%9C%81%E4%BB%A3%E7%90%86&agentName=%E5%BE%90%E5%8C%97%E6%96%B9&firstPayment=30000&agencyFee=30000&beginDate=2017-5-1&endDate=2018-5-1&mobile=18829901010&password=<PASSWORD>&guideUser=1&address=%E6%B2%B3%E5%8C%97%E7%9C%81%2F%E7%A7%A6%E7%9A%87%E5%B2%9B%E5%B8%82%2F%E5%8C%97%E6%88%B4%E6%B2%B3%E5%8C%BA&fullAddress=111111&cardFrontPath=filePath&cardBackPath=filePath&cardFront=&cardBack=' --compressed
//curl 'http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Cookie: Idea-390470b1=20f86e89-5fd1-46f7-b19e-172f714e3451; __utma=111872281.1550433883.1463023041.1468930698.1468956142.15; Idea-390470b3=a1f71123-38e9-4790-8993-1b4f55050f10; ckCsrfToken=<KEY>' -H 'Origin: http://localhost:55555' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://localhost:55555/market-manage/dealer/src/main/resources/dealer-view/addAgent.html' -H 'Connection: keep-alive'
// --data 'superiorId=1&rank=%E6%B5%99%E6%B1%9F%E7%9C%81%E4%BB%A3%E7%90%86&agentName=%E5%BE%90%E5%8C%97%E6%96%B9&firstPayment=30000&agencyFee=30000&beginDate=2017-5-1&endDate=2018-5-1&mobile=18829901010&password=<PASSWORD>&guideUser=1&address=%E5%8C%97%E4%BA%AC%E5%B8%82%2F%E5%8C%97%E4%BA%AC%E5%B8%82%2F%E4%B8%9C%E5%9F%8E%E5%8C%BA&fullAddress=111111111&cardFrontPath=filePath&cardBackPath=filePath&cardFront=&cardBack=' --compressed
@Test
public void indexForAdd() throws Exception {
// 此处分2种情况
Manager manager = newRandomManager("", ManageLevel.customerManager);
runWith(manager, () -> {
mockMvc.perform(get("/addAgent"))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML))
.andExpect(view().name("addAgent.html"));
String rank = "某代理商" + RandomStringUtils.randomAlphabetic(10);
String agentName = "某人" + RandomStringUtils.randomAlphabetic(10);
int firstPayment = 1000 + random.nextInt(10000);
int agencyFee = 500 + random.nextInt(600);
LocalDate beginDate = LocalDate.now().minusMonths(2);
LocalDate endDate = LocalDate.now().plusMonths(2);
String mobile = randomMobile();
String password = <PASSWORD>();
Login guideUser = randomLogin(false);
Address address = randomAddress();
String cardFrontPath = newRandomImagePath();
String cardBackPath = newRandomImagePath();
String businessLicensePath = newRandomImagePath();
mockMvc.perform(post("/addAgent")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("rank", rank)
.param("agentName", agentName)
.param("firstPayment", String.valueOf(firstPayment))
.param("agencyFee", String.valueOf(agencyFee))
.param("beginDate", toText(beginDate))
.param("endDate", toText(endDate))
.param("mobile", mobile)
.param("password", <PASSWORD>)
.param("guideUser", String.valueOf(guideUser.getId()))
.param("address", address.getStandardWithoutOther())
.param("fullAddress", address.getOtherAddress())
.param("cardFrontPath", cardFrontPath)
.param("cardBackPath", cardBackPath)
.param("businessLicensePath", businessLicensePath)
)
.andDo(print())
.andExpect(status().isFound())
;
// TODO 数据校验,以及因为手机号码的排他性,所以需要在页面上做远程校验 同时检查登录名以及联系表的手机号码
return null;
});
}
}
| 5,784 | 0.679443 | 0.5777 | 78 | 72.602562 | 153.3936 | 923 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.974359 | false | false |
13
|
d8e8f268823e102473f7a6729fd060fc7527cfa6
| 28,698,971,523,092 |
6f16fb995b357f274eaa3550411f2b21f34df4ac
|
/5.19-5.25/src/chapter08/Homework05/CheckingAccount.java
|
5fd3a7fed084b88400855345b8a686ec1df89102
|
[] |
no_license
|
zxc404/zhouxucheng
|
https://github.com/zxc404/zhouxucheng
|
04a853944419df64e6d7d081c0f262b2d48e09a8
|
1a47927bca4ba222d4a7a5be6b3a5fbcc590c5c1
|
refs/heads/master
| 2023-06-27T08:08:08.678000 | 2021-08-01T09:47:32 | 2021-08-01T09:47:32 | 359,463,552 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package chapter08.Homework05;
public class CheckingAccount extends BankAccount{
public CheckingAccount(double balance) {
super(balance);
}
@Override
public void deposit(double amount) {
super.deposit(amount-1);
}
@Override
public void withdraw(double amount) {
this.setBalance(this.getBalance()-1-amount);
}
}
|
UTF-8
|
Java
| 370 |
java
|
CheckingAccount.java
|
Java
|
[] | null |
[] |
package chapter08.Homework05;
public class CheckingAccount extends BankAccount{
public CheckingAccount(double balance) {
super(balance);
}
@Override
public void deposit(double amount) {
super.deposit(amount-1);
}
@Override
public void withdraw(double amount) {
this.setBalance(this.getBalance()-1-amount);
}
}
| 370 | 0.662162 | 0.645946 | 18 | 19.555555 | 18.628599 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false |
13
|
9bd4cec9d46d9723c1414b0570e3948b756a51f8
| 24,927,990,240,767 |
b2ff64dc14f782b93a2f40c53ab8606266b227f5
|
/PackageDemo/src/com/test/Student.java
|
a3d63a759d7e5f8391e4321ad2c9ad9c34fa3094
|
[] |
no_license
|
manohar427/B8_CoreJava
|
https://github.com/manohar427/B8_CoreJava
|
373c4cc622f170a93b7d4aa54f96185eafec847d
|
a26832b3bf6e37312eebaeff67057bab6c7f81cd
|
refs/heads/master
| 2021-01-19T11:48:32.782000 | 2017-04-20T03:22:08 | 2017-04-20T03:22:08 | 87,996,764 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.test;
public class Student {
public int age = 20;
public String name = "Abc";
String address = "India";
protected String offideAddress = "US";
}
|
UTF-8
|
Java
| 174 |
java
|
Student.java
|
Java
|
[
{
"context": " public int age = 20;\n public String name = \"Abc\";\n String address = \"India\";\n protected Str",
"end": 96,
"score": 0.9997531771659851,
"start": 93,
"tag": "NAME",
"value": "Abc"
}
] | null |
[] |
package com.test;
public class Student {
public int age = 20;
public String name = "Abc";
String address = "India";
protected String offideAddress = "US";
}
| 174 | 0.649425 | 0.637931 | 8 | 20.75 | 13.562356 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false |
13
|
cfe2de2e707e3ead1a9fff01b84596436122592d
| 7,593,502,244,602 |
39c9476219e88519a282f222fa8e4f793679ec9f
|
/src/ZongJian.java
|
2b24dd0efc95978a783b9bfc878d5b92f4108e45
|
[] |
no_license
|
az2893/Proxy
|
https://github.com/az2893/Proxy
|
9f66c11f7d215bffb69ac1c0863e786fd74be6b2
|
47c09c963b93106701b577b54bbfe69ca9d32070
|
refs/heads/master
| 2020-03-19T10:57:18.331000 | 2018-06-07T03:16:52 | 2018-06-07T03:16:52 | 136,415,863 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class ZongJian extends Manager {
@Override
public void RequestApplications(Request request) {
if(request.getRequestType().equals("请假") && request.getNumber()<= 5){
System.out.println(name+"批准"+request.getRequestContent());
}
else{
if(superior!=null)
superior.RequestApplications(request);
}
}
public ZongJian(String name) {
super(name);
}
}
|
UTF-8
|
Java
| 457 |
java
|
ZongJian.java
|
Java
|
[] | null |
[] |
public class ZongJian extends Manager {
@Override
public void RequestApplications(Request request) {
if(request.getRequestType().equals("请假") && request.getNumber()<= 5){
System.out.println(name+"批准"+request.getRequestContent());
}
else{
if(superior!=null)
superior.RequestApplications(request);
}
}
public ZongJian(String name) {
super(name);
}
}
| 457 | 0.585746 | 0.583519 | 16 | 27.0625 | 24.329685 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.1875 | false | false |
13
|
1836fa5731970db047525f24f98f3eb48999f833
| 20,263,655,711,892 |
bdd32f82265cc06e9b10ab0c7e5c1effaaf59792
|
/src/com/tfs/crm/workbench/clue/service/impl/ClueActivityRelationServiceImpl.java
|
7e51a7c5b5ab7848c0031790bccccc7dc94ef327
|
[] |
no_license
|
linhao123lh/crm
|
https://github.com/linhao123lh/crm
|
8eb234aaf4b260c30b2969829ae8cca2a6a3ac47
|
998b41a98b094a93d26084605aff868841e19062
|
refs/heads/master
| 2020-04-18T06:53:00.834000 | 2019-04-30T05:50:12 | 2019-04-30T05:50:12 | 167,340,577 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.tfs.crm.workbench.clue.service.impl;
import com.tfs.crm.workbench.clue.dao.ClueActivityRelationDao;
import com.tfs.crm.workbench.clue.domain.ClueActivityRelation;
import com.tfs.crm.workbench.clue.service.ClueActivityRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class ClueActivityRelationServiceImpl implements ClueActivityRelationService {
@Autowired
private ClueActivityRelationDao clueActivityRelationDao;
/**
* 批量添加线索和市场活动关联关系
* @param relationList
* @return
*/
@Override
public int relationActivityByActivityIdClueId(List<ClueActivityRelation> relationList) {
return clueActivityRelationDao.insertBatchRelationActivityClue(relationList);
}
/**
* 删除线索和市场活动关联关系
* @param paramMap
* @return
*/
@Override
public int saveUnbundActivityByActivityIdClueId(Map<String, Object> paramMap) {
return clueActivityRelationDao.deleteRelationByActivityIdClueId(paramMap);
}
}
|
UTF-8
|
Java
| 1,178 |
java
|
ClueActivityRelationServiceImpl.java
|
Java
|
[] | null |
[] |
package com.tfs.crm.workbench.clue.service.impl;
import com.tfs.crm.workbench.clue.dao.ClueActivityRelationDao;
import com.tfs.crm.workbench.clue.domain.ClueActivityRelation;
import com.tfs.crm.workbench.clue.service.ClueActivityRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class ClueActivityRelationServiceImpl implements ClueActivityRelationService {
@Autowired
private ClueActivityRelationDao clueActivityRelationDao;
/**
* 批量添加线索和市场活动关联关系
* @param relationList
* @return
*/
@Override
public int relationActivityByActivityIdClueId(List<ClueActivityRelation> relationList) {
return clueActivityRelationDao.insertBatchRelationActivityClue(relationList);
}
/**
* 删除线索和市场活动关联关系
* @param paramMap
* @return
*/
@Override
public int saveUnbundActivityByActivityIdClueId(Map<String, Object> paramMap) {
return clueActivityRelationDao.deleteRelationByActivityIdClueId(paramMap);
}
}
| 1,178 | 0.769162 | 0.769162 | 37 | 29.324324 | 30.030664 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.324324 | false | false |
13
|
0358bcc4d3ea5377c38897db633a8ad3cfa5cdb5
| 20,263,655,711,503 |
647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4
|
/com.tencent.token/classes.jar/com/tencent/token/ov.java
|
e2a2c843a8dcab9c6b81e8283a884b1af4d339cc
|
[] |
no_license
|
tsuzcx/qq_apk
|
https://github.com/tsuzcx/qq_apk
|
0d5e792c3c7351ab781957bac465c55c505caf61
|
afe46ef5640d0ba6850cdefd3c11badbd725a3f6
|
refs/heads/main
| 2022-07-02T10:32:11.651000 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | false | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | 2022-01-31T06:56:43 | 2022-01-31T09:46:26 | 167,304 | 0 | 1 | 1 |
Java
| false | false |
package com.tencent.token;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public final class ov
{
private static String a = "";
private static String b = "";
public static String a(Context paramContext)
{
if (paramContext == null) {
return null;
}
try
{
String str = a;
i = 1;
if (str != null) {
if (str.trim().length() != 0) {
break label65;
}
}
}
catch (Exception paramContext)
{
for (;;)
{
continue;
int i = 0;
}
}
if (i != 0)
{
paramContext = (TelephonyManager)paramContext.getSystemService("phone");
if (paramContext != null) {
a = paramContext.getDeviceId();
}
}
return a;
}
public static String a(Exception paramException)
{
String str = Log.getStackTraceString(paramException);
if (str != null)
{
if ((str.indexOf("\n") != -1) && (str.indexOf("\n") < 100)) {
return str.substring(0, str.indexOf("\n"));
}
paramException = str;
if (str.length() > 100) {
paramException = str.substring(0, 100);
}
return paramException;
}
return "";
}
public static boolean a(String paramString)
{
if (paramString == null) {
return true;
}
return paramString.trim().length() == 0;
}
public static String b(Context paramContext)
{
if (paramContext == null) {
return null;
}
try
{
String str = b;
i = 1;
if (str != null) {
if (str.trim().length() != 0) {
break label74;
}
}
}
catch (Exception paramContext)
{
for (;;)
{
continue;
int i = 0;
}
}
if (i != 0)
{
paramContext = (WifiManager)paramContext.getSystemService("wifi");
if (paramContext != null)
{
paramContext = paramContext.getConnectionInfo();
if (paramContext != null) {
b = paramContext.getMacAddress();
}
}
}
return b;
}
public static String b(String paramString)
{
Object localObject = mj.a();
try
{
StringBuilder localStringBuilder = new StringBuilder("");
String str = a((Context)localObject);
if (!TextUtils.isEmpty(str)) {
localStringBuilder.append(str);
}
localObject = b((Context)localObject);
if (!TextUtils.isEmpty((CharSequence)localObject)) {
localStringBuilder.append((String)localObject);
}
localStringBuilder.append(System.currentTimeMillis());
localStringBuilder.append(paramString);
localStringBuilder.append((int)(Math.random() * 2147483647.0D));
paramString = c(localStringBuilder.toString());
return paramString;
}
catch (Exception paramString) {}
return "";
}
private static String c(String paramString)
{
if (paramString != null)
{
if (paramString.length() == 0) {
return null;
}
try
{
Object localObject = MessageDigest.getInstance("MD5");
((MessageDigest)localObject).update(paramString.getBytes());
paramString = ((MessageDigest)localObject).digest();
if (paramString == null) {
return "";
}
localObject = new StringBuffer();
int i = 0;
while (i < paramString.length)
{
String str = Integer.toHexString(paramString[i] & 0xFF);
if (str.length() == 1) {
((StringBuffer)localObject).append("0");
}
((StringBuffer)localObject).append(str);
i += 1;
}
return ((StringBuffer)localObject).toString().toUpperCase();
}
catch (NoSuchAlgorithmException paramString)
{
paramString.printStackTrace();
}
}
return null;
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.token\classes.jar
* Qualified Name: com.tencent.token.ov
* JD-Core Version: 0.7.0.1
*/
|
UTF-8
|
Java
| 4,424 |
java
|
ov.java
|
Java
|
[] | null |
[] |
package com.tencent.token;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public final class ov
{
private static String a = "";
private static String b = "";
public static String a(Context paramContext)
{
if (paramContext == null) {
return null;
}
try
{
String str = a;
i = 1;
if (str != null) {
if (str.trim().length() != 0) {
break label65;
}
}
}
catch (Exception paramContext)
{
for (;;)
{
continue;
int i = 0;
}
}
if (i != 0)
{
paramContext = (TelephonyManager)paramContext.getSystemService("phone");
if (paramContext != null) {
a = paramContext.getDeviceId();
}
}
return a;
}
public static String a(Exception paramException)
{
String str = Log.getStackTraceString(paramException);
if (str != null)
{
if ((str.indexOf("\n") != -1) && (str.indexOf("\n") < 100)) {
return str.substring(0, str.indexOf("\n"));
}
paramException = str;
if (str.length() > 100) {
paramException = str.substring(0, 100);
}
return paramException;
}
return "";
}
public static boolean a(String paramString)
{
if (paramString == null) {
return true;
}
return paramString.trim().length() == 0;
}
public static String b(Context paramContext)
{
if (paramContext == null) {
return null;
}
try
{
String str = b;
i = 1;
if (str != null) {
if (str.trim().length() != 0) {
break label74;
}
}
}
catch (Exception paramContext)
{
for (;;)
{
continue;
int i = 0;
}
}
if (i != 0)
{
paramContext = (WifiManager)paramContext.getSystemService("wifi");
if (paramContext != null)
{
paramContext = paramContext.getConnectionInfo();
if (paramContext != null) {
b = paramContext.getMacAddress();
}
}
}
return b;
}
public static String b(String paramString)
{
Object localObject = mj.a();
try
{
StringBuilder localStringBuilder = new StringBuilder("");
String str = a((Context)localObject);
if (!TextUtils.isEmpty(str)) {
localStringBuilder.append(str);
}
localObject = b((Context)localObject);
if (!TextUtils.isEmpty((CharSequence)localObject)) {
localStringBuilder.append((String)localObject);
}
localStringBuilder.append(System.currentTimeMillis());
localStringBuilder.append(paramString);
localStringBuilder.append((int)(Math.random() * 2147483647.0D));
paramString = c(localStringBuilder.toString());
return paramString;
}
catch (Exception paramString) {}
return "";
}
private static String c(String paramString)
{
if (paramString != null)
{
if (paramString.length() == 0) {
return null;
}
try
{
Object localObject = MessageDigest.getInstance("MD5");
((MessageDigest)localObject).update(paramString.getBytes());
paramString = ((MessageDigest)localObject).digest();
if (paramString == null) {
return "";
}
localObject = new StringBuffer();
int i = 0;
while (i < paramString.length)
{
String str = Integer.toHexString(paramString[i] & 0xFF);
if (str.length() == 1) {
((StringBuffer)localObject).append("0");
}
((StringBuffer)localObject).append(str);
i += 1;
}
return ((StringBuffer)localObject).toString().toUpperCase();
}
catch (NoSuchAlgorithmException paramString)
{
paramString.printStackTrace();
}
}
return null;
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.token\classes.jar
* Qualified Name: com.tencent.token.ov
* JD-Core Version: 0.7.0.1
*/
| 4,424 | 0.54566 | 0.535036 | 181 | 22.475138 | 20.042654 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.38674 | false | false |
13
|
eee30c908add9feda32bf24fa2be8fd9fdb9f3c4
| 2,851,858,292,610 |
d376924996b2c1a007aff30a9f8186d15704f973
|
/EIS_WSHOP/src/logic/modelCalculators/WeatherCalculator.java
|
de280a33bb8133e586794e56cda0a079fbee4197
|
[] |
no_license
|
GvardianDLVII/AwareRuleMining
|
https://github.com/GvardianDLVII/AwareRuleMining
|
d3f218c6fa0a65b8202ea190e98ac16f1f8abfda
|
3731389f85dca50ae404723d7bf89b617da3c0ca
|
refs/heads/master
| 2021-05-29T17:44:38.875000 | 2015-06-18T21:12:31 | 2015-06-18T21:12:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package logic.modelCalculators;
import logic.DataContainer;
import model.HumidityLevel;
import model.PressureLevel;
import model.RainValue;
import model.TemperatureLevel;
import model.WeatherModel;
import model.WindDirection;
import model.WindStrength;
import dataAccess.entities.WeatherCurrent;
public class WeatherCalculator implements ModelCalculator<WeatherCurrent, WeatherModel> {
@Override
public WeatherModel calculate(DataContainer<WeatherCurrent> dataContainer) {
double sampleCount = dataContainer.getElements().size();
if(sampleCount == 0)
return null;
double totalHumidity = 0.0;
double totalTemperature = 0.0;
double totalPressure = 0.0;
double totalWindSpeed = 0.0;
double totalWindAngle = 0.0;
double totalRain = 0.0;
for (WeatherCurrent weatherCurrent : dataContainer.getElements()) {
totalHumidity += weatherCurrent.getHumidity();
totalTemperature += fahrenheitToCelsius(weatherCurrent.getTemperatureValueCurrent());
totalPressure += weatherCurrent.getPressure();
totalWindSpeed += weatherCurrent.getWindSpeed();
totalWindAngle += weatherCurrent.getWindAngle();
totalRain += weatherCurrent.getRain();
}
totalHumidity /= sampleCount;
totalTemperature /= sampleCount;
totalPressure /= sampleCount;
totalWindSpeed /= sampleCount;
totalWindAngle /= sampleCount;
totalRain /= sampleCount;
HumidityLevel humidityLevel = HumidityLevel.getbyPercentage(totalHumidity/100.0);
TemperatureLevel temperatureLevel = TemperatureLevel.getByValue(totalTemperature);
PressureLevel pressureLevel = PressureLevel.getByValue(totalPressure);
WindStrength windStrength = WindStrength.getByValue(totalWindSpeed);
WindDirection windDirection = WindDirection.getByValue(totalWindAngle);
RainValue rainValue = RainValue.getByValue(totalRain);
return new WeatherModel(dataContainer.getDate(), temperatureLevel, humidityLevel, pressureLevel, windStrength, windDirection, rainValue);
}
private static double fahrenheitToCelsius(double f) {
return (f-32.0)/1.8;
}
}
|
UTF-8
|
Java
| 2,098 |
java
|
WeatherCalculator.java
|
Java
|
[] | null |
[] |
package logic.modelCalculators;
import logic.DataContainer;
import model.HumidityLevel;
import model.PressureLevel;
import model.RainValue;
import model.TemperatureLevel;
import model.WeatherModel;
import model.WindDirection;
import model.WindStrength;
import dataAccess.entities.WeatherCurrent;
public class WeatherCalculator implements ModelCalculator<WeatherCurrent, WeatherModel> {
@Override
public WeatherModel calculate(DataContainer<WeatherCurrent> dataContainer) {
double sampleCount = dataContainer.getElements().size();
if(sampleCount == 0)
return null;
double totalHumidity = 0.0;
double totalTemperature = 0.0;
double totalPressure = 0.0;
double totalWindSpeed = 0.0;
double totalWindAngle = 0.0;
double totalRain = 0.0;
for (WeatherCurrent weatherCurrent : dataContainer.getElements()) {
totalHumidity += weatherCurrent.getHumidity();
totalTemperature += fahrenheitToCelsius(weatherCurrent.getTemperatureValueCurrent());
totalPressure += weatherCurrent.getPressure();
totalWindSpeed += weatherCurrent.getWindSpeed();
totalWindAngle += weatherCurrent.getWindAngle();
totalRain += weatherCurrent.getRain();
}
totalHumidity /= sampleCount;
totalTemperature /= sampleCount;
totalPressure /= sampleCount;
totalWindSpeed /= sampleCount;
totalWindAngle /= sampleCount;
totalRain /= sampleCount;
HumidityLevel humidityLevel = HumidityLevel.getbyPercentage(totalHumidity/100.0);
TemperatureLevel temperatureLevel = TemperatureLevel.getByValue(totalTemperature);
PressureLevel pressureLevel = PressureLevel.getByValue(totalPressure);
WindStrength windStrength = WindStrength.getByValue(totalWindSpeed);
WindDirection windDirection = WindDirection.getByValue(totalWindAngle);
RainValue rainValue = RainValue.getByValue(totalRain);
return new WeatherModel(dataContainer.getDate(), temperatureLevel, humidityLevel, pressureLevel, windStrength, windDirection, rainValue);
}
private static double fahrenheitToCelsius(double f) {
return (f-32.0)/1.8;
}
}
| 2,098 | 0.770257 | 0.759771 | 56 | 35.464287 | 28.796679 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.267857 | false | false |
13
|
93a6bcb147160694e1c205930f52680a5613bb0b
| 6,880,537,625,028 |
e3eecfce5fc2258c95c3205d04d8e2ae8a9875f5
|
/rl4j/rl4j-doom/src/main/java/org/deeplearning4j/rl4j/mdp/vizdoom/DeadlyCorridor.java
|
912cf6926b6b925c4848e7685b05b2366b2b596a
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-free-unknown"
] |
permissive
|
farizrahman4u/deeplearning4j
|
https://github.com/farizrahman4u/deeplearning4j
|
585bdec78e7e8252ca63a0691102b15774e7a6dc
|
e0555358db5a55823ea1af78ae98a546ad64baab
|
refs/heads/master
| 2021-06-28T19:20:38.204000 | 2019-10-02T10:16:12 | 2019-10-02T10:16:12 | 134,716,860 | 1 | 1 |
Apache-2.0
| true | 2019-10-02T10:14:08 | 2018-05-24T13:08:06 | 2019-06-12T15:41:57 | 2019-10-02T10:14:08 | 558,892 | 0 | 1 | 0 |
Java
| false | false |
package org.deeplearning4j.rl4j.mdp.vizdoom;
import vizdoom.Button;
import java.util.Arrays;
import java.util.List;
/**
* @author rubenfiszel (ruben.fiszel@epfl.ch) on 8/1/16.
*/
public class DeadlyCorridor extends VizDoom {
public DeadlyCorridor(boolean render) {
super(render);
}
public Configuration getConfiguration() {
setScaleFactor(1.0);
List<Button> buttons = Arrays.asList(Button.ATTACK, Button.MOVE_LEFT, Button.MOVE_RIGHT, Button.MOVE_FORWARD,
Button.TURN_LEFT, Button.TURN_RIGHT);
return new Configuration("deadly_corridor", 0.0, 5, 100, 2100, 0, buttons);
}
public DeadlyCorridor newInstance() {
return new DeadlyCorridor(isRender());
}
}
|
UTF-8
|
Java
| 752 |
java
|
DeadlyCorridor.java
|
Java
|
[
{
"context": "til.Arrays;\nimport java.util.List;\n\n/**\n * @author rubenfiszel (ruben.fiszel@epfl.ch) on 8/1/16.\n */\npublic clas",
"end": 145,
"score": 0.9992361068725586,
"start": 134,
"tag": "USERNAME",
"value": "rubenfiszel"
},
{
"context": "port java.util.List;\n\n/**\n * @author rubenfiszel (ruben.fiszel@epfl.ch) on 8/1/16.\n */\npublic class DeadlyCorridor exten",
"end": 167,
"score": 0.9999334216117859,
"start": 147,
"tag": "EMAIL",
"value": "ruben.fiszel@epfl.ch"
}
] | null |
[] |
package org.deeplearning4j.rl4j.mdp.vizdoom;
import vizdoom.Button;
import java.util.Arrays;
import java.util.List;
/**
* @author rubenfiszel (<EMAIL>) on 8/1/16.
*/
public class DeadlyCorridor extends VizDoom {
public DeadlyCorridor(boolean render) {
super(render);
}
public Configuration getConfiguration() {
setScaleFactor(1.0);
List<Button> buttons = Arrays.asList(Button.ATTACK, Button.MOVE_LEFT, Button.MOVE_RIGHT, Button.MOVE_FORWARD,
Button.TURN_LEFT, Button.TURN_RIGHT);
return new Configuration("deadly_corridor", 0.0, 5, 100, 2100, 0, buttons);
}
public DeadlyCorridor newInstance() {
return new DeadlyCorridor(isRender());
}
}
| 739 | 0.666223 | 0.640957 | 30 | 24.033333 | 28.661802 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
13
|
7fd39ab48d046a08e6837ff13c25d2676ceef660
| 16,733,192,593,525 |
00d3609d5091f4bdd5a5c3039a87f0d31dfcf247
|
/jsp-initialization/servletinit/src/main/java/servletinit/AppContextListener.java
|
54a99e5f13909b91b932a52afb3834ab19eff434
|
[] |
no_license
|
rpsinghc/maven-projects
|
https://github.com/rpsinghc/maven-projects
|
7168fc28d1259e0bd46c2c4821a53e98f2890511
|
e296c8e752d22b26ec2c70760896123b6660a995
|
refs/heads/master
| 2022-12-15T09:37:52.813000 | 2019-06-22T23:53:47 | 2019-06-22T23:53:47 | 193,223,011 | 0 | 0 | null | false | 2022-12-09T22:53:19 | 2019-06-22T10:48:56 | 2019-06-22T23:53:57 | 2022-12-09T22:53:15 | 20,344 | 0 | 0 | 14 |
Java
| false | false |
package servletinit;
import java.util.Locale;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;
@WebListener
public class AppContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
Locale locale = Locale.getDefault();
ServletRegistration.Dynamic registration = event.getServletContext()
.addServlet("appController", locale.getISO3Country().equals("USA") ?
DefaultAppController.class : OffshoreAppController.class);
registration.addMapping("/app/");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
|
UTF-8
|
Java
| 805 |
java
|
AppContextListener.java
|
Java
|
[] | null |
[] |
package servletinit;
import java.util.Locale;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;
@WebListener
public class AppContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
Locale locale = Locale.getDefault();
ServletRegistration.Dynamic registration = event.getServletContext()
.addServlet("appController", locale.getISO3Country().equals("USA") ?
DefaultAppController.class : OffshoreAppController.class);
registration.addMapping("/app/");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
| 805 | 0.73913 | 0.737888 | 26 | 29.961538 | 28.089802 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false |
13
|
8eddd5c8fe3d69f0d81197b77ea419e7ce7de488
| 11,871,289,623,385 |
1ec9ae7ea611b64ac44a7181ad7397590a7bc3df
|
/wf_data_service/src/main/java/com/wf/data/dao/mycattrans/entity/TransDeal.java
|
529ab2757d75fbeea22f3948f6b0ca5a257fcb15
|
[] |
no_license
|
joeystuck/data
|
https://github.com/joeystuck/data
|
8f4550a5a83631c1397f6f685e8fbf268815bccb
|
37dcd5d1138f231ffa69f042b13664718506fd2e
|
refs/heads/master
| 2020-03-28T12:06:40.129000 | 2018-08-31T19:27:19 | 2018-08-31T19:27:19 | 148,270,272 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.wf.data.dao.mycattrans.entity;
import com.wf.core.persistence.DataEntity;
public class TransDeal extends DataEntity {
private static final long serialVersionUID = -1;
private Long userId;
private Long gameId;
private String businessId;
private Long changeNoteId;
private Long amount;
private Integer businessType;
private String phase;
private Integer callbackCount;
private Integer callbackStatus;
private Long channelId;
private String remark;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getGameId() {
return gameId;
}
public void setGameId(Long gameId) {
this.gameId = gameId;
}
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public Long getChangeNoteId() {
return changeNoteId;
}
public void setChangeNoteId(Long changeNoteId) {
this.changeNoteId = changeNoteId;
}
public Long getAmount() {
return amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public Integer getBusinessType() {
return businessType;
}
public void setBusinessType(Integer businessType) {
this.businessType = businessType;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public Integer getCallbackCount() {
return callbackCount;
}
public void setCallbackCount(Integer callbackCount) {
this.callbackCount = callbackCount;
}
public Integer getCallbackStatus() {
return callbackStatus;
}
public void setCallbackStatus(Integer callbackStatus) {
this.callbackStatus = callbackStatus;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
|
UTF-8
|
Java
| 1,956 |
java
|
TransDeal.java
|
Java
|
[] | null |
[] |
package com.wf.data.dao.mycattrans.entity;
import com.wf.core.persistence.DataEntity;
public class TransDeal extends DataEntity {
private static final long serialVersionUID = -1;
private Long userId;
private Long gameId;
private String businessId;
private Long changeNoteId;
private Long amount;
private Integer businessType;
private String phase;
private Integer callbackCount;
private Integer callbackStatus;
private Long channelId;
private String remark;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getGameId() {
return gameId;
}
public void setGameId(Long gameId) {
this.gameId = gameId;
}
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public Long getChangeNoteId() {
return changeNoteId;
}
public void setChangeNoteId(Long changeNoteId) {
this.changeNoteId = changeNoteId;
}
public Long getAmount() {
return amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public Integer getBusinessType() {
return businessType;
}
public void setBusinessType(Integer businessType) {
this.businessType = businessType;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public Integer getCallbackCount() {
return callbackCount;
}
public void setCallbackCount(Integer callbackCount) {
this.callbackCount = callbackCount;
}
public Integer getCallbackStatus() {
return callbackStatus;
}
public void setCallbackStatus(Integer callbackStatus) {
this.callbackStatus = callbackStatus;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
| 1,956 | 0.739264 | 0.738753 | 107 | 17.289721 | 16.590172 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.271028 | false | false |
13
|
ede60103b68c352c344634b30d0a3066287267de
| 15,307,263,462,462 |
29913b4293619f9a6541ddf72ea0a593e9aa5400
|
/src/com/epam/jamp/behavior/impl/Drinking.java
|
15a23e7e3e33351b331d170a8e744ca8ac333ea6
|
[] |
no_license
|
4060741400005352234/jamp.first.arch.princ
|
https://github.com/4060741400005352234/jamp.first.arch.princ
|
4a5074b0bf6f60bdc2c867b66c550db956133b78
|
d89d46c55e0860b9d5e2736425ccce56d17324e9
|
refs/heads/master
| 2021-01-13T00:37:59.176000 | 2015-12-03T03:43:24 | 2015-12-03T03:43:24 | 47,094,198 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.epam.jamp.behavior.impl;
import com.epam.jamp.behavior.DrinkBehavior;
import org.apache.log4j.Logger;
public class Drinking implements DrinkBehavior {
private static Logger log = Logger.getLogger(Drinking.class);
@Override
public void drink() {
//System.out.println("Duck's drinking now.");
log.info("Duck's drinking now.");
}
}
|
UTF-8
|
Java
| 377 |
java
|
Drinking.java
|
Java
|
[] | null |
[] |
package com.epam.jamp.behavior.impl;
import com.epam.jamp.behavior.DrinkBehavior;
import org.apache.log4j.Logger;
public class Drinking implements DrinkBehavior {
private static Logger log = Logger.getLogger(Drinking.class);
@Override
public void drink() {
//System.out.println("Duck's drinking now.");
log.info("Duck's drinking now.");
}
}
| 377 | 0.700265 | 0.697613 | 15 | 24.133333 | 22.054075 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false |
13
|
b263530d30a9afe6656df318a052f345ea108e1d
| 19,086,834,676,864 |
05c1da0af9c423b54f623edd6ee543e2f4b297c2
|
/src/main/java/com/tel/pathfinder/exception/MapDetailsNotFoundException.java
|
875d87196aa87d11d53b908293fca32c4aa7f59b
|
[] |
no_license
|
stylesmangalasseri/pathfinder
|
https://github.com/stylesmangalasseri/pathfinder
|
61a840ac3777797e77ef0b2b947c2174c64d20e4
|
042bfd8ae1c274ae624affac59805e9a409bba69
|
refs/heads/master
| 2021-01-23T14:35:22.459000 | 2017-09-07T10:56:07 | 2017-09-07T10:56:07 | 102,692,918 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.tel.pathfinder.exception;
import java.io.FileNotFoundException;
/**
* Exception to throw if map file details not found
*
* @author styles mangalasseri
*
*/
public class MapDetailsNotFoundException extends FileNotFoundException {
private static final long serialVersionUID = 1L;
public MapDetailsNotFoundException(String message) {
super(message);
}
}
|
UTF-8
|
Java
| 379 |
java
|
MapDetailsNotFoundException.java
|
Java
|
[
{
"context": "f map file details not found\n * \n * @author styles mangalasseri\n * \n */\npublic class MapDetailsNotFoundException ",
"end": 168,
"score": 0.8137688636779785,
"start": 156,
"tag": "NAME",
"value": "mangalasseri"
}
] | null |
[] |
package com.tel.pathfinder.exception;
import java.io.FileNotFoundException;
/**
* Exception to throw if map file details not found
*
* @author styles mangalasseri
*
*/
public class MapDetailsNotFoundException extends FileNotFoundException {
private static final long serialVersionUID = 1L;
public MapDetailsNotFoundException(String message) {
super(message);
}
}
| 379 | 0.773087 | 0.770449 | 18 | 20.055555 | 23.241419 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
13
|
909787f4a28500c9099974553bb5a5a8d8d83423
| 2,534,030,721,051 |
e72c3c625273dd5ef531832a2acd737aaf2afcad
|
/src/main/java/org/recap/batch/job/CheckAndNotifyPendingRequestTasklet.java
|
e42e1688fd59befd8bf0f82f7fb918abebad0df7
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
ResearchCollectionsAndPreservation/scsb-batch-scheduler
|
https://github.com/ResearchCollectionsAndPreservation/scsb-batch-scheduler
|
d5b4e27c0f335312beb4268c6081a103910497ed
|
1eb9e6b14bd842986c199165ebce81ec026d0c42
|
refs/heads/v7-dev
| 2023-07-22T22:54:36.871000 | 2023-05-10T06:17:28 | 2023-05-10T06:17:28 | 88,159,244 | 1 | 17 |
NOASSERTION
| false | 2019-08-05T14:10:07 | 2017-04-13T11:46:42 | 2019-06-22T09:46:53 | 2019-08-05T14:10:07 | 217 | 1 | 12 | 0 |
Java
| false | false |
package org.recap.batch.job;
import lombok.extern.slf4j.Slf4j;
import org.recap.ScsbConstants;
import org.recap.batch.service.CheckAndNotifyPendingRequestService;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by angelind on 14/9/17.
*/
@Slf4j
public class CheckAndNotifyPendingRequestTasklet extends JobCommonTasklet implements Tasklet {
@Autowired
private CheckAndNotifyPendingRequestService checkAndNotifyPendingRequestService;
/**
* This method starts the execution for checking pending request in the lasOutgoingQ and notifying through sending email.
*
* @param contribution StepContribution
* @param chunkContext ChunkContext
* @return RepeatStatus
* @throws Exception Exception Class
*/
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
log.info("Executing CheckAndNotifyPendingRequestTasklet");
StepExecution stepExecution = chunkContext.getStepContext().getStepExecution();
JobExecution jobExecution = stepExecution.getJobExecution();
ExecutionContext executionContext = jobExecution.getExecutionContext();
try {
updateJob(jobExecution, "CheckAndNotifyPendingRequestTasklet", Boolean.FALSE);
checkAndNotifyPendingRequestService.checkPendingMessagesInQueue(scsbCircUrl);
} catch (Exception ex) {
updateExecutionExceptionStatus(stepExecution, executionContext, ex, ScsbConstants.CHECK_AND_NOTIFY_PENDING_REQUEST_STATUS_NAME);
}
return RepeatStatus.FINISHED;
}
}
|
UTF-8
|
Java
| 2,026 |
java
|
CheckAndNotifyPendingRequestTasklet.java
|
Java
|
[
{
"context": "s.factory.annotation.Autowired;\n\n/**\n * Created by angelind on 14/9/17.\n */\n@Slf4j\npublic class CheckAndNotif",
"end": 651,
"score": 0.9996092319488525,
"start": 643,
"tag": "USERNAME",
"value": "angelind"
}
] | null |
[] |
package org.recap.batch.job;
import lombok.extern.slf4j.Slf4j;
import org.recap.ScsbConstants;
import org.recap.batch.service.CheckAndNotifyPendingRequestService;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by angelind on 14/9/17.
*/
@Slf4j
public class CheckAndNotifyPendingRequestTasklet extends JobCommonTasklet implements Tasklet {
@Autowired
private CheckAndNotifyPendingRequestService checkAndNotifyPendingRequestService;
/**
* This method starts the execution for checking pending request in the lasOutgoingQ and notifying through sending email.
*
* @param contribution StepContribution
* @param chunkContext ChunkContext
* @return RepeatStatus
* @throws Exception Exception Class
*/
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
log.info("Executing CheckAndNotifyPendingRequestTasklet");
StepExecution stepExecution = chunkContext.getStepContext().getStepExecution();
JobExecution jobExecution = stepExecution.getJobExecution();
ExecutionContext executionContext = jobExecution.getExecutionContext();
try {
updateJob(jobExecution, "CheckAndNotifyPendingRequestTasklet", Boolean.FALSE);
checkAndNotifyPendingRequestService.checkPendingMessagesInQueue(scsbCircUrl);
} catch (Exception ex) {
updateExecutionExceptionStatus(stepExecution, executionContext, ex, ScsbConstants.CHECK_AND_NOTIFY_PENDING_REQUEST_STATUS_NAME);
}
return RepeatStatus.FINISHED;
}
}
| 2,026 | 0.780355 | 0.776407 | 46 | 43.04348 | 35.958889 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.586957 | false | false |
13
|
709cd2a252b6cdecc611b2b4fbf4ba704ac3cf08
| 4,483,945,920,306 |
a93c4256888d66de3acbc9e052be6837d2476e57
|
/app/src/main/java/org/fundacionparaguaya/adviserplatform/ui/survey/priorities/EditPriorityViewModel.java
|
83ba167e30822e33fc2710c7cc7061fa39ace685
|
[
"MIT"
] |
permissive
|
alefq/ps-advisor-app
|
https://github.com/alefq/ps-advisor-app
|
802a11d1fd5db7992cb5d59c35eb5627ab00c77c
|
7c49e294f2a08c9929d5d7111f8ad76a2d9a6b27
|
refs/heads/develop
| 2021-04-30T06:09:54.663000 | 2018-09-04T15:18:23 | 2018-09-04T15:18:23 | 121,436,458 | 1 | 4 |
MIT
| false | 2023-08-19T01:41:00 | 2018-02-13T21:03:52 | 2019-11-23T10:44:32 | 2023-08-19T01:40:59 | 4,518 | 0 | 9 | 2 |
Java
| false | false |
package org.fundacionparaguaya.adviserplatform.ui.survey.priorities;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.Transformations;
import android.arch.lifecycle.ViewModel;
import org.fundacionparaguaya.adviserplatform.data.model.IndicatorOption;
import org.fundacionparaguaya.adviserplatform.data.model.IndicatorQuestion;
import org.fundacionparaguaya.adviserplatform.data.repositories.SurveyRepository;
import org.jcodec.common.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.Months;
import java.util.Calendar;
import java.util.Date;
public final class EditPriorityViewModel extends ViewModel {
private SurveyRepository repo;
private LiveData<IndicatorQuestion> mIndicator = null;
private String mReason;
private String mAction;
private Date mCompletionDate = null;
private int numberOfMonths = 0;
private final MutableLiveData<Integer> mQuestionsUnanswered = new MutableLiveData<>();
private IndicatorOption.Level mPovertyLevel;
public EditPriorityViewModel(SurveyRepository repository) {
this.repo = repository;
updateUnansweredCount();
}
final String getReason() {
return this.mReason;
}
final void setReason(String mReason) {
this.mReason = mReason;
updateUnansweredCount();
}
String getAction() {
return this.mAction;
}
void setAction(String value) {
this.mAction = value;
updateUnansweredCount();
}
Date getCompletionDate() {
return this.mCompletionDate;
}
final void setCompletionDate(Date value) {
this.mCompletionDate = value;
updateUnansweredCount();
}
final void setIndicator(int surveyId, int indicatorIndex) {
mIndicator = Transformations.map(repo.getSurvey(surveyId), value -> value.getIndicatorQuestions().get(indicatorIndex));
}
final boolean isAchievement() {
return mPovertyLevel == IndicatorOption.Level.Green;
}
final LiveData<IndicatorQuestion> getIndicator() {
if(mIndicator != null)
{
return mIndicator;
}
throw new IllegalStateException("getIndicator called before surveyId and IndicatorIndex set");
}
boolean areRequirementsMet()
{
return getNumUnanswered() == 0;
}
void setLevel(IndicatorOption.Level level)
{
mPovertyLevel = level;
updateUnansweredCount();
}
IndicatorOption.Level getLevel()
{
return mPovertyLevel;
}
private void updateUnansweredCount()
{
int unanswered = 0;
if(mPovertyLevel != IndicatorOption.Level.Green && (numberOfMonths == 0 || mCompletionDate==null)) unanswered++;
if(StringUtils.isEmpty(mReason)) unanswered++;
if(StringUtils.isEmpty(mAction)) unanswered++;
mQuestionsUnanswered.setValue(unanswered);
}
LiveData<Integer> NumberOfQuestionsUnanswered()
{
return mQuestionsUnanswered;
}
int getNumUnanswered()
{
Integer value = mQuestionsUnanswered.getValue();
return value!=null ? value : 0;
}
void setNumMonths(int i) {
numberOfMonths = i;
if(i>0) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, numberOfMonths);
this.mCompletionDate = cal.getTime();
}
updateUnansweredCount();
}
int getMonthsUntilCompletion()
{
if(mCompletionDate==null) return 0;
else {
DateTime start = new DateTime();
DateTime end = new DateTime(mCompletionDate);
return Months.monthsBetween(start, end).getMonths() + 1;
}
}
}
|
UTF-8
|
Java
| 3,768 |
java
|
EditPriorityViewModel.java
|
Java
|
[] | null |
[] |
package org.fundacionparaguaya.adviserplatform.ui.survey.priorities;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.Transformations;
import android.arch.lifecycle.ViewModel;
import org.fundacionparaguaya.adviserplatform.data.model.IndicatorOption;
import org.fundacionparaguaya.adviserplatform.data.model.IndicatorQuestion;
import org.fundacionparaguaya.adviserplatform.data.repositories.SurveyRepository;
import org.jcodec.common.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.Months;
import java.util.Calendar;
import java.util.Date;
public final class EditPriorityViewModel extends ViewModel {
private SurveyRepository repo;
private LiveData<IndicatorQuestion> mIndicator = null;
private String mReason;
private String mAction;
private Date mCompletionDate = null;
private int numberOfMonths = 0;
private final MutableLiveData<Integer> mQuestionsUnanswered = new MutableLiveData<>();
private IndicatorOption.Level mPovertyLevel;
public EditPriorityViewModel(SurveyRepository repository) {
this.repo = repository;
updateUnansweredCount();
}
final String getReason() {
return this.mReason;
}
final void setReason(String mReason) {
this.mReason = mReason;
updateUnansweredCount();
}
String getAction() {
return this.mAction;
}
void setAction(String value) {
this.mAction = value;
updateUnansweredCount();
}
Date getCompletionDate() {
return this.mCompletionDate;
}
final void setCompletionDate(Date value) {
this.mCompletionDate = value;
updateUnansweredCount();
}
final void setIndicator(int surveyId, int indicatorIndex) {
mIndicator = Transformations.map(repo.getSurvey(surveyId), value -> value.getIndicatorQuestions().get(indicatorIndex));
}
final boolean isAchievement() {
return mPovertyLevel == IndicatorOption.Level.Green;
}
final LiveData<IndicatorQuestion> getIndicator() {
if(mIndicator != null)
{
return mIndicator;
}
throw new IllegalStateException("getIndicator called before surveyId and IndicatorIndex set");
}
boolean areRequirementsMet()
{
return getNumUnanswered() == 0;
}
void setLevel(IndicatorOption.Level level)
{
mPovertyLevel = level;
updateUnansweredCount();
}
IndicatorOption.Level getLevel()
{
return mPovertyLevel;
}
private void updateUnansweredCount()
{
int unanswered = 0;
if(mPovertyLevel != IndicatorOption.Level.Green && (numberOfMonths == 0 || mCompletionDate==null)) unanswered++;
if(StringUtils.isEmpty(mReason)) unanswered++;
if(StringUtils.isEmpty(mAction)) unanswered++;
mQuestionsUnanswered.setValue(unanswered);
}
LiveData<Integer> NumberOfQuestionsUnanswered()
{
return mQuestionsUnanswered;
}
int getNumUnanswered()
{
Integer value = mQuestionsUnanswered.getValue();
return value!=null ? value : 0;
}
void setNumMonths(int i) {
numberOfMonths = i;
if(i>0) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, numberOfMonths);
this.mCompletionDate = cal.getTime();
}
updateUnansweredCount();
}
int getMonthsUntilCompletion()
{
if(mCompletionDate==null) return 0;
else {
DateTime start = new DateTime();
DateTime end = new DateTime(mCompletionDate);
return Months.monthsBetween(start, end).getMonths() + 1;
}
}
}
| 3,768 | 0.673301 | 0.671178 | 144 | 25.166666 | 25.73152 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4375 | false | false |
13
|
01bb20118073bb192b96262bbda3e46c5b9c2119
| 17,892,833,816,520 |
70b8456f3a0ab569b1ae9dd177bdc095b32e202b
|
/src/main/java/task1/part1/Solution3.java
|
d0f9b4d9bb77f02b1693f8a6c4254642a1854a0f
|
[] |
no_license
|
JJammer/EpamCourse
|
https://github.com/JJammer/EpamCourse
|
da24418f2c8822ac4e2757245de8391f77cf7c78
|
910753a9d53e28401baa4cbddc7422bb5eeadb4b
|
refs/heads/master
| 2019-01-26T20:38:47.794000 | 2017-09-05T15:45:23 | 2017-09-05T15:45:23 | 98,034,796 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package task1.part1;
public class Solution3 {
public static void main(String[] args) {
int height = 12;
System.out.print(makePyramid(height));
}
public static String makePyramid(int height) {
StringBuilder pyramidBuilder = new StringBuilder();
for (int currHeight = 1; currHeight <= height; ++currHeight) {
int countOfSpaces = height - currHeight;
fillWithWhiteSpace(pyramidBuilder, countOfSpaces);
fillWithNumbers(pyramidBuilder, currHeight);
fillWithWhiteSpace(pyramidBuilder, countOfSpaces);
pyramidBuilder.append('\n');
}
return pyramidBuilder.toString();
}
private static void fillWithNumbers(StringBuilder sb, int maxNumber) {
for (int number = 1; number <= maxNumber; ++number) {
sb.append(number);
}
for (int number = maxNumber - 1; number > 0; --number) {
sb.append(number);
}
}
private static void fillWithWhiteSpace(StringBuilder sb, int count) {
for (int i = 0; i < count; ++i) {
sb.append(' ');
}
}
}
|
UTF-8
|
Java
| 1,146 |
java
|
Solution3.java
|
Java
|
[] | null |
[] |
package task1.part1;
public class Solution3 {
public static void main(String[] args) {
int height = 12;
System.out.print(makePyramid(height));
}
public static String makePyramid(int height) {
StringBuilder pyramidBuilder = new StringBuilder();
for (int currHeight = 1; currHeight <= height; ++currHeight) {
int countOfSpaces = height - currHeight;
fillWithWhiteSpace(pyramidBuilder, countOfSpaces);
fillWithNumbers(pyramidBuilder, currHeight);
fillWithWhiteSpace(pyramidBuilder, countOfSpaces);
pyramidBuilder.append('\n');
}
return pyramidBuilder.toString();
}
private static void fillWithNumbers(StringBuilder sb, int maxNumber) {
for (int number = 1; number <= maxNumber; ++number) {
sb.append(number);
}
for (int number = maxNumber - 1; number > 0; --number) {
sb.append(number);
}
}
private static void fillWithWhiteSpace(StringBuilder sb, int count) {
for (int i = 0; i < count; ++i) {
sb.append(' ');
}
}
}
| 1,146 | 0.593368 | 0.584642 | 39 | 28.384615 | 25.383839 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
13
|
a277bab9f2b911d634dff2a096763e32de9bb06e
| 16,655,883,238,215 |
78e2f7144c8deaeda5964e747edd0557960433fa
|
/src/main/java/io/github/rockitconsulting/test/rockitizer/payload/model/MqPayload.java
|
36dcc77660e83b4ba96cfa638a93af127581de9d
|
[
"GPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-3.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
rockitconsulting/test.rockitizer
|
https://github.com/rockitconsulting/test.rockitizer
|
512b4e1e5ab4698acb2d5bc8621d68b5dc056bb7
|
83e79f9663ce2071a588ff9c6ca41857c955f3bd
|
refs/heads/master
| 2023-06-22T06:44:30.649000 | 2023-06-07T12:34:02 | 2023-06-07T12:34:02 | 88,857,625 | 15 | 23 |
MIT
| false | 2018-04-11T11:25:32 | 2017-04-20T11:23:21 | 2018-04-10T19:29:27 | 2018-04-11T11:25:32 | 402 | 2 | 11 | 0 |
Java
| false | null |
package io.github.rockitconsulting.test.rockitizer.payload.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement
@XmlType(propOrder = { "header", "body" })
public class MqPayload {
MqHeader header = new MqHeader();
String body;
public MqHeader getHeader() {
return header;
}
@XmlElement
public void setHeader(MqHeader header) {
this.header = header;
}
public String getBody() {
return body;
}
@XmlElement
public void setBody(String body) {
this.body = body;
}
}
|
UTF-8
|
Java
| 596 |
java
|
MqPayload.java
|
Java
|
[
{
"context": "package io.github.rockitconsulting.test.rockitizer.payload.model;\n\nimport ",
"end": 24,
"score": 0.5061425566673279,
"start": 22,
"tag": "USERNAME",
"value": "it"
}
] | null |
[] |
package io.github.rockitconsulting.test.rockitizer.payload.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement
@XmlType(propOrder = { "header", "body" })
public class MqPayload {
MqHeader header = new MqHeader();
String body;
public MqHeader getHeader() {
return header;
}
@XmlElement
public void setHeader(MqHeader header) {
this.header = header;
}
public String getBody() {
return body;
}
@XmlElement
public void setBody(String body) {
this.body = body;
}
}
| 596 | 0.736577 | 0.736577 | 33 | 17.060606 | 17.888441 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.939394 | false | false |
13
|
52931ba1c9aa54d2908530fb9e8e6901b5b620ad
| 27,573,690,103,523 |
13a9f51562621d021b5da9d1f6b9a938b0651189
|
/src/com/atae/ecipc/network/Queue.java
|
2d286bc525a4a8464565aa4ecdd41c29b0d25f55
|
[] |
no_license
|
adefarge/atae-ecipc
|
https://github.com/adefarge/atae-ecipc
|
238fee720911de183d7def85226022eabbbc9be5
|
b94895e889000c0ce78d28426e19ffc0335ca871
|
HEAD
| 2019-04-19T03:32:55.125000 | 2015-06-02T19:02:56 | 2015-06-02T19:02:56 | 27,655,995 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.atae.ecipc.network;
import java.util.ArrayList;
import java.util.HashMap;
import com.atae.ecipc.query.Query;
import com.atae.ecipc.util.DateUtils;
public class Queue {
ArrayList<Query> queries;
HashMap<Long, Query> passed;
// On ne peux pas exécuter une même requête plus de toute les millisecondes;
final long timeBetweenQueries = 1;
int i;
int n;
public Queue() {
this.queries = new ArrayList<Query>();
passed = new HashMap<Long, Query>();
this.i = 0;
this.n = 0;
}
public boolean next() {
if(this.i < this.n) {
this.i++;
return true;
}
else return false;
}
public Query get() {
passed.put(DateUtils.getCurrentTime(), this.queries.get(this.i - 1));
return this.queries.get(this.i - 1);
}
public void add(Query q) {
// Il s'agit d'une queue intélligente !
//if(!queries.contains(q)) {
// A faire ici !!
// On vérifie qu'une requête similaires n'a pas déjà été appelée
this.queries.add(q);
this.n++;
//}
}
// On crée les méthodes qui permettent d'accèder à la queue et de la gérer
public HashMap<Integer, String> getQueue() {
HashMap<Integer, String> r = new HashMap<Integer, String>();
for(int u = i; u < n; u++) {
r.put(u, queries.get(u).getName());
}
return r;
}
public void cancel(int u) {
if(u >= i && u < n)
queries.remove(u);
}
public void clear() {
i = n;
}
}
|
ISO-8859-1
|
Java
| 1,487 |
java
|
Queue.java
|
Java
|
[] | null |
[] |
package com.atae.ecipc.network;
import java.util.ArrayList;
import java.util.HashMap;
import com.atae.ecipc.query.Query;
import com.atae.ecipc.util.DateUtils;
public class Queue {
ArrayList<Query> queries;
HashMap<Long, Query> passed;
// On ne peux pas exécuter une même requête plus de toute les millisecondes;
final long timeBetweenQueries = 1;
int i;
int n;
public Queue() {
this.queries = new ArrayList<Query>();
passed = new HashMap<Long, Query>();
this.i = 0;
this.n = 0;
}
public boolean next() {
if(this.i < this.n) {
this.i++;
return true;
}
else return false;
}
public Query get() {
passed.put(DateUtils.getCurrentTime(), this.queries.get(this.i - 1));
return this.queries.get(this.i - 1);
}
public void add(Query q) {
// Il s'agit d'une queue intélligente !
//if(!queries.contains(q)) {
// A faire ici !!
// On vérifie qu'une requête similaires n'a pas déjà été appelée
this.queries.add(q);
this.n++;
//}
}
// On crée les méthodes qui permettent d'accèder à la queue et de la gérer
public HashMap<Integer, String> getQueue() {
HashMap<Integer, String> r = new HashMap<Integer, String>();
for(int u = i; u < n; u++) {
r.put(u, queries.get(u).getName());
}
return r;
}
public void cancel(int u) {
if(u >= i && u < n)
queries.remove(u);
}
public void clear() {
i = n;
}
}
| 1,487 | 0.603671 | 0.600272 | 72 | 18.430555 | 19.426376 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.902778 | false | false |
13
|
b54e207322922698079ca9df8d462d463438a5bf
| 1,614,907,709,233 |
85a51c7447b8c11f6cdd1932f10cc1f29add9d8d
|
/FordLab/src/ucLinkedList/LinkListOperations.java
|
70b9cc324a2cc5fb4601824ba15a68b24647d262
|
[] |
no_license
|
jarumugan/FordLab-Java-Training
|
https://github.com/jarumugan/FordLab-Java-Training
|
e1508f8ff3fd65d2dd6b4f85b9ead5f25215ccfc
|
3cb6f3366c224dcbf2e7e50263bc52163cc67451
|
refs/heads/master
| 2020-04-30T09:06:02.813000 | 2019-03-27T13:34:08 | 2019-03-27T13:34:08 | 176,737,078 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ucLinkedList;
import java.util.Scanner;
public class LinkListOperations
{
List studRegistry;
List firstList = new List();
int listCount=0;
Scanner scan = new Scanner(System.in);
String listName;
//
void createLinkList()
{
System.out.println();System.out.println();
System.out.println("<-------- Add Data ---------->");
System.out.println("<---------------------------->");
//
studRegistry = new List();
studRegistry.name = "Start";
studRegistry.link = null;
//
firstList = studRegistry;
do
{
listCount++;
System.out.println(" Enter name for list < " + listCount + " > : ");
listName = scan.next();
//
studRegistry.link = new List();
(studRegistry.link).name = listName;
(studRegistry.link).link = null;
studRegistry = studRegistry.link;
//
} while (!(listName.equalsIgnoreCase("end")));
}
//
void printLinkList()
{
List temp;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Print List -------->");
System.out.println("<---------------------------->");
System.out.println();System.out.println();
do
{
System.out.print(temp.name + " >> ");
temp=temp.link;
}while(temp.link != null);
}
//
void searchLinkList()
{
List temp;
int count=0;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Search List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name you want to search : ");
listName = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
System.out.println(" Match found .. Success < " + count + " > list element ");
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void deleteLinkList()
{
List temp,prev;
int count=0;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Delete List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name you want to delete : ");
listName = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
prev.link=temp.link;
System.out.println(" Match found .. Success < " + count + " > list element deleted.. ");
System.gc();
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void insertLinkList()
{
List temp,prev;
int count=0;
temp=firstList;
String newList;
System.out.println();System.out.println();
System.out.println("<-------- Insert List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name before you want to insert : ");
listName = scan.next();
System.out.println(" Enter name you want to insert : ");
newList = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
prev.link = new List();
prev = prev.link;
prev.name = newList;
prev.link = temp;
System.out.println(" Match found .. Success < " + newList + " > list element inserted.. ");
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void swapLinkList()
{
List temp,prev,swap1_prev = null, swap1_next=null,swap2_prev = null, swap2_next=null, swap1 = null,swap2 = null,swap_temp;
swap_temp = new List();
int count=0;
boolean swap1_found=false, swap2_found=false;
temp=firstList;
String newList,swap_1,swap_2;
//
System.out.println();System.out.println();
System.out.println("<-------- Swap List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter the list (#1) you want to swap : ");
swap_1 = scan.next();
System.out.println(" Enter the list (#2) you want to swap : ");
swap_2 = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
//
if( (temp.name.equalsIgnoreCase(swap_1)) || (temp.name.equalsIgnoreCase(swap_2)) )
{
if ( (temp.name.equalsIgnoreCase(swap_1)) && (swap1_found == false) )
{
System.out.println( " Inside Swap 1 found ..");
swap1_prev = prev;
swap1 = temp;
swap1_next = temp.link;
swap1_found=true;
}
if ( (temp.name.equalsIgnoreCase(swap_2)) && (swap2_found == false) )
{
System.out.println( " Inside Swap 2 found ..");
swap2_prev = prev;
swap2 = temp;
swap2_next = temp.link;
swap2_found=true;
}
}
//
if( (swap1_found == true) && (swap2_found == true) )
{
System.out.println( " Inside Swaping ..");
//
swap1_prev.link=swap2;
swap2.link=swap1_next;
//
swap2_prev.link=swap1;
swap1.link=swap2_next;
//
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
}
|
UTF-8
|
Java
| 5,520 |
java
|
LinkListOperations.java
|
Java
|
[] | null |
[] |
package ucLinkedList;
import java.util.Scanner;
public class LinkListOperations
{
List studRegistry;
List firstList = new List();
int listCount=0;
Scanner scan = new Scanner(System.in);
String listName;
//
void createLinkList()
{
System.out.println();System.out.println();
System.out.println("<-------- Add Data ---------->");
System.out.println("<---------------------------->");
//
studRegistry = new List();
studRegistry.name = "Start";
studRegistry.link = null;
//
firstList = studRegistry;
do
{
listCount++;
System.out.println(" Enter name for list < " + listCount + " > : ");
listName = scan.next();
//
studRegistry.link = new List();
(studRegistry.link).name = listName;
(studRegistry.link).link = null;
studRegistry = studRegistry.link;
//
} while (!(listName.equalsIgnoreCase("end")));
}
//
void printLinkList()
{
List temp;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Print List -------->");
System.out.println("<---------------------------->");
System.out.println();System.out.println();
do
{
System.out.print(temp.name + " >> ");
temp=temp.link;
}while(temp.link != null);
}
//
void searchLinkList()
{
List temp;
int count=0;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Search List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name you want to search : ");
listName = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
System.out.println(" Match found .. Success < " + count + " > list element ");
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void deleteLinkList()
{
List temp,prev;
int count=0;
temp=firstList;
System.out.println();System.out.println();
System.out.println("<-------- Delete List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name you want to delete : ");
listName = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
prev.link=temp.link;
System.out.println(" Match found .. Success < " + count + " > list element deleted.. ");
System.gc();
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void insertLinkList()
{
List temp,prev;
int count=0;
temp=firstList;
String newList;
System.out.println();System.out.println();
System.out.println("<-------- Insert List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter name before you want to insert : ");
listName = scan.next();
System.out.println(" Enter name you want to insert : ");
newList = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
if(temp.name.equalsIgnoreCase(listName))
{
prev.link = new List();
prev = prev.link;
prev.name = newList;
prev.link = temp;
System.out.println(" Match found .. Success < " + newList + " > list element inserted.. ");
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
//
void swapLinkList()
{
List temp,prev,swap1_prev = null, swap1_next=null,swap2_prev = null, swap2_next=null, swap1 = null,swap2 = null,swap_temp;
swap_temp = new List();
int count=0;
boolean swap1_found=false, swap2_found=false;
temp=firstList;
String newList,swap_1,swap_2;
//
System.out.println();System.out.println();
System.out.println("<-------- Swap List -------->");
System.out.println("<---------------------------->");
//
System.out.println(" Enter the list (#1) you want to swap : ");
swap_1 = scan.next();
System.out.println(" Enter the list (#2) you want to swap : ");
swap_2 = scan.next();
//
do
{
//System.out.print(temp.name + " >> ");
prev=temp;
temp=temp.link;
count++;
//
if( (temp.name.equalsIgnoreCase(swap_1)) || (temp.name.equalsIgnoreCase(swap_2)) )
{
if ( (temp.name.equalsIgnoreCase(swap_1)) && (swap1_found == false) )
{
System.out.println( " Inside Swap 1 found ..");
swap1_prev = prev;
swap1 = temp;
swap1_next = temp.link;
swap1_found=true;
}
if ( (temp.name.equalsIgnoreCase(swap_2)) && (swap2_found == false) )
{
System.out.println( " Inside Swap 2 found ..");
swap2_prev = prev;
swap2 = temp;
swap2_next = temp.link;
swap2_found=true;
}
}
//
if( (swap1_found == true) && (swap2_found == true) )
{
System.out.println( " Inside Swaping ..");
//
swap1_prev.link=swap2;
swap2.link=swap1_next;
//
swap2_prev.link=swap1;
swap1.link=swap2_next;
//
printLinkList();
return;
}
}while(temp.link != null);
System.out.println(" Match not found ");
}
}
| 5,520 | 0.536775 | 0.528623 | 223 | 22.753363 | 21.842632 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.475336 | false | false |
13
|
ca272319a430a7533b551cb580dcdf5b1080fbd8
| 33,629,593,992,834 |
fb39e6db582375a1182a85d4941fdafbf83e249d
|
/MySniffer/pcap4j-distribution-1.7.0-src/pcap4j-core/src/main/java/org/pcap4j/packet/Dot11FrameControl.java
|
0b0e1f562be69fa76d0c41825741fffe5b936372
|
[
"MIT"
] |
permissive
|
DongXiangzhi/Sniffer
|
https://github.com/DongXiangzhi/Sniffer
|
bf10873cfcd0f3b242c236693f78993275df8985
|
51d1a703b7a00696d02937b490721e9bfcafc13f
|
refs/heads/master
| 2021-01-19T21:51:12.254000 | 2017-04-19T07:38:04 | 2017-04-19T07:38:04 | 88,715,252 | 5 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*_##########################################################################
_##
_## Copyright (C) 2016 Pcap4J.org
_##
_##########################################################################
*/
package org.pcap4j.packet;
import java.io.Serializable;
import org.pcap4j.packet.namednumber.Dot11FrameType;
import org.pcap4j.util.ByteArrays;
/**
* Frame control field of an IEEE802.11 frame.
* <pre style="white-space: pre;">
* 0 1 2 3 4 5 6 7
* +----------+----------+----------+----------+----------+----------+----------+----------+
* | Protocol | Type | Subtype |
* | Version | | |
* +----------+----------+----------+----------+----------+----------+----------+----------+
* | To DS | From DS |More | Retry |Power | More |Protected | Order |
* | | |Fragments | |Management| Data |Frame | |
* +----------+----------+----------+----------+----------+----------+----------+----------+
* <pre>
*
* @see <a href="http://standards.ieee.org/getieee802/download/802.11-2012.pdf">IEEE802.11</a>
* @author Kaito Yamada
* @since pcap4j 1.7.0
*/
public final class Dot11FrameControl implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5402534865955179413L;
private final ProtocolVersion protocolVersion;
private final Dot11FrameType type;
private final boolean toDs;
private final boolean fromDs;
private final boolean moreFragments;
private final boolean retry;
private final boolean powerManagement;
private final boolean moreData;
private final boolean protectedFrame;
private final boolean order;
/**
* A static factory method.
* This method validates the arguments by {@link ByteArrays#validateBounds(byte[], int, int)},
* which may throw exceptions undocumented here.
*
* @param rawData rawData
* @param offset offset
* @param length length
* @return a new Dot11FrameControl object.
* @throws IllegalRawDataException if parsing the raw data fails.
*/
public static Dot11FrameControl newInstance(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
return new Dot11FrameControl(rawData, offset, length);
}
private Dot11FrameControl(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
if (length < 2) {
StringBuilder sb = new StringBuilder(200);
sb.append("The data is too short to build a Dot11FrameControl (")
.append(2)
.append(" bytes). data: ")
.append(ByteArrays.toHexString(rawData, " "))
.append(", offset: ")
.append(offset)
.append(", length: ")
.append(length);
throw new IllegalRawDataException(sb.toString());
}
byte firstByte = rawData[offset];
switch (firstByte & 0x03) {
case 0:
this.protocolVersion = ProtocolVersion.V0;
break;
case 1:
this.protocolVersion = ProtocolVersion.V1;
break;
case 2:
this.protocolVersion = ProtocolVersion.V2;
break;
case 3:
this.protocolVersion = ProtocolVersion.V3;
break;
default:
throw new AssertionError("Never get here.");
}
this.type
= Dot11FrameType.getInstance(
(byte) (((firstByte << 2) & 0x30) | ((firstByte >> 4) & 0x0F))
);
byte secondByte = rawData[offset + 1];
this.toDs = (secondByte & 0x01) != 0;
this.fromDs = (secondByte & 0x02) != 0;
this.moreFragments = (secondByte & 0x04) != 0;
this.retry = (secondByte & 0x08) != 0;
this.powerManagement = (secondByte & 0x10) != 0;
this.moreData = (secondByte & 0x20) != 0;
this.protectedFrame = (secondByte & 0x40) != 0;
this.order = (secondByte & 0x80) != 0;
}
private Dot11FrameControl(Builder builder) {
if (
builder == null
|| builder.protocolVersion == null
|| builder.type == null
) {
StringBuilder sb = new StringBuilder();
sb.append("builder").append(builder)
.append(" builder.protocolVersion: ").append(builder.protocolVersion)
.append(" builder.type: ").append(builder.type);
throw new NullPointerException(sb.toString());
}
this.protocolVersion = builder.protocolVersion;
this.type = builder.type;
this.toDs = builder.toDs;
this.fromDs = builder.fromDs;
this.moreFragments = builder.moreFragments;
this.retry = builder.retry;
this.powerManagement = builder.powerManagement;
this.moreData = builder.moreData;
this.protectedFrame = builder.protectedFrame;
this.order = builder.order;
}
/**
* @return protocolVersion
*/
public ProtocolVersion getProtocolVersion() {
return protocolVersion;
}
/**
* @return type
*/
public Dot11FrameType getType() {
return type;
}
/**
* @return toDs
*/
public boolean isToDs() {
return toDs;
}
/**
* @return fromDs
*/
public boolean isFromDs() {
return fromDs;
}
/**
* @return moreFragments
*/
public boolean isMoreFragments() {
return moreFragments;
}
/**
* @return retry
*/
public boolean isRetry() {
return retry;
}
/**
* @return powerManagement
*/
public boolean isPowerManagement() {
return powerManagement;
}
/**
* @return moreData
*/
public boolean isMoreData() {
return moreData;
}
/**
* @return protectedFrame
*/
public boolean isProtectedFrame() {
return protectedFrame;
}
/**
* @return order
*/
public boolean isOrder() {
return order;
}
/**
*
* @return a new Builder object populated with this object's fields.
*/
public Builder getBuilder() {
return new Builder(this);
}
/**
* @return the raw data.
*/
public byte[] getRawData() {
byte[] data = new byte[2];
data[0] |= protocolVersion.value;
data[0] |= type.getType().getValue() << 2;
data[0] |= type.value() << 4;
if (toDs) { data[1] |= 0x01; }
if (fromDs) { data[1] |= 0x02; }
if (moreFragments) { data[1] |= 0x04; }
if (retry) { data[1] |= 0x08; }
if (powerManagement) { data[1] |= 0x10; }
if (moreData) { data[1] |= 0x20; }
if (protectedFrame) { data[1] |= 0x40; }
if (order) { data[1] |= 0x80; }
return data;
}
/**
* @return length
*/
public int length() {
return 2;
}
@Override
public String toString() {
return toString("");
}
/**
* @param indent indent
* @return String represantation of this object.
*/
public String toString(String indent) {
StringBuilder sb = new StringBuilder();
String ls = System.getProperty("line.separator");
sb.append(indent).append("Protocol Version: ")
.append(protocolVersion).append(ls)
.append(indent).append("Type/Subtype: ")
.append(type).append(ls)
.append(indent).append("To DS: ")
.append(toDs).append(ls)
.append(indent).append("From DS: ")
.append(fromDs).append(ls)
.append(indent).append("More Fragments: ")
.append(moreFragments).append(ls)
.append(indent).append("Retry: ")
.append(retry).append(ls)
.append(indent).append("Power Management: ")
.append(powerManagement).append(ls)
.append(indent).append("More Data: ")
.append(moreData).append(ls)
.append(indent).append("Protected Frame: ")
.append(protectedFrame).append(ls)
.append(indent).append("Order: ")
.append(order).append(ls);
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (fromDs ? 1231 : 1237);
result = prime * result + (moreData ? 1231 : 1237);
result = prime * result + (moreFragments ? 1231 : 1237);
result = prime * result + (order ? 1231 : 1237);
result = prime * result + (powerManagement ? 1231 : 1237);
result = prime * result + (protectedFrame ? 1231 : 1237);
result = prime * result + ((protocolVersion == null) ? 0 : protocolVersion.hashCode());
result = prime * result + (retry ? 1231 : 1237);
result = prime * result + (toDs ? 1231 : 1237);
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Dot11FrameControl other = (Dot11FrameControl) obj;
if (fromDs != other.fromDs)
return false;
if (moreData != other.moreData)
return false;
if (moreFragments != other.moreFragments)
return false;
if (order != other.order)
return false;
if (powerManagement != other.powerManagement)
return false;
if (protectedFrame != other.protectedFrame)
return false;
if (protocolVersion != other.protocolVersion)
return false;
if (retry != other.retry)
return false;
if (toDs != other.toDs)
return false;
if (!type.equals(other.type))
return false;
return true;
}
/**
* @author Kaito Yamada
* @since pcap4j 1.7.0
*/
public static final class Builder {
private ProtocolVersion protocolVersion;
private Dot11FrameType type;
private boolean toDs;
private boolean fromDs;
private boolean moreFragments;
private boolean retry;
private boolean powerManagement;
private boolean moreData;
private boolean protectedFrame;
private boolean order;
/**
*
*/
public Builder() {}
private Builder(Dot11FrameControl obj) {
this.protocolVersion = obj.protocolVersion;
this.type = obj.type;
this.toDs = obj.toDs;
this.fromDs = obj.fromDs;
this.moreFragments = obj.moreFragments;
this.retry = obj.retry;
this.powerManagement = obj.powerManagement;
this.moreData = obj.moreData;
this.protectedFrame = obj.protectedFrame;
this.order = obj.order;
}
/**
* @param protocolVersion protocolVersion
* @return this Builder object for method chaining.
*/
public Builder protocolVersion(ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion;
return this;
}
/**
* @param type type
* @return this Builder object for method chaining.
*/
public Builder type(Dot11FrameType type) {
this.type = type;
return this;
}
/**
* @param toDs toDs
* @return this Builder object for method chaining.
*/
public Builder toDs(boolean toDs) {
this.toDs = toDs;
return this;
}
/**
* @param fromDs fromDs
* @return this Builder object for method chaining.
*/
public Builder fromDs(boolean fromDs) {
this.fromDs = fromDs;
return this;
}
/**
* @param moreFragments moreFragments
* @return this Builder object for method chaining.
*/
public Builder moreFragments(boolean moreFragments) {
this.moreFragments = moreFragments;
return this;
}
/**
* @param retry retry
* @return this Builder object for method chaining.
*/
public Builder retry(boolean retry) {
this.retry = retry;
return this;
}
/**
* @param powerManagement powerManagement
* @return this Builder object for method chaining.
*/
public Builder powerManagement(boolean powerManagement) {
this.powerManagement = powerManagement;
return this;
}
/**
* @param moreData moreData
* @return this Builder object for method chaining.
*/
public Builder moreData(boolean moreData) {
this.moreData = moreData;
return this;
}
/**
* @param protectedFrame protectedFrame
* @return this Builder object for method chaining.
*/
public Builder protectedFrame(boolean protectedFrame) {
this.protectedFrame = protectedFrame;
return this;
}
/**
* @param order order
* @return this Builder object for method chaining.
*/
public Builder order(boolean order) {
this.order = order;
return this;
}
/**
*
* @return a new Dot11FrameControl object.
*/
public Dot11FrameControl build() {
return new Dot11FrameControl(this);
}
}
/**
* Protocol version of IEEE802.11 frame
*
* @see <a href="http://standards.ieee.org/getieee802/download/802.11-2012.pdf">IEEE802.11</a>
* @author Kaito Yamada
* @since pcap4j 1.7.0
*/
public static enum ProtocolVersion {
/**
* v0 (00)
*/
V0(0),
/**
* v1 (01)
*/
V1(1),
/**
* v2 (10)
*/
V2(2),
/**
* v3 (11)
*/
V3(3);
private final int value;
private ProtocolVersion(int value) {
this.value = value;
}
/**
* @return value
*/
public int getValue() {
return value;
}
}
}
|
UTF-8
|
Java
| 13,225 |
java
|
Dot11FrameControl.java
|
Java
|
[
{
"context": "ownload/802.11-2012.pdf\">IEEE802.11</a>\n * @author Kaito Yamada\n * @since pcap4j 1.7.0\n */\npublic final class Dot",
"end": 1311,
"score": 0.999852180480957,
"start": 1299,
"tag": "NAME",
"value": "Kaito Yamada"
},
{
"context": "rn false;\n return true;\n }\n\n /**\n * @author Kaito Yamada\n * @since pcap4j 1.7.0\n */\n public static fi",
"end": 9397,
"score": 0.9998629093170166,
"start": 9385,
"tag": "NAME",
"value": "Kaito Yamada"
},
{
"context": "nload/802.11-2012.pdf\">IEEE802.11</a>\n * @author Kaito Yamada\n * @since pcap4j 1.7.0\n */\n public static en",
"end": 12778,
"score": 0.9998567700386047,
"start": 12766,
"tag": "NAME",
"value": "Kaito Yamada"
}
] | null |
[] |
/*_##########################################################################
_##
_## Copyright (C) 2016 Pcap4J.org
_##
_##########################################################################
*/
package org.pcap4j.packet;
import java.io.Serializable;
import org.pcap4j.packet.namednumber.Dot11FrameType;
import org.pcap4j.util.ByteArrays;
/**
* Frame control field of an IEEE802.11 frame.
* <pre style="white-space: pre;">
* 0 1 2 3 4 5 6 7
* +----------+----------+----------+----------+----------+----------+----------+----------+
* | Protocol | Type | Subtype |
* | Version | | |
* +----------+----------+----------+----------+----------+----------+----------+----------+
* | To DS | From DS |More | Retry |Power | More |Protected | Order |
* | | |Fragments | |Management| Data |Frame | |
* +----------+----------+----------+----------+----------+----------+----------+----------+
* <pre>
*
* @see <a href="http://standards.ieee.org/getieee802/download/802.11-2012.pdf">IEEE802.11</a>
* @author <NAME>
* @since pcap4j 1.7.0
*/
public final class Dot11FrameControl implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5402534865955179413L;
private final ProtocolVersion protocolVersion;
private final Dot11FrameType type;
private final boolean toDs;
private final boolean fromDs;
private final boolean moreFragments;
private final boolean retry;
private final boolean powerManagement;
private final boolean moreData;
private final boolean protectedFrame;
private final boolean order;
/**
* A static factory method.
* This method validates the arguments by {@link ByteArrays#validateBounds(byte[], int, int)},
* which may throw exceptions undocumented here.
*
* @param rawData rawData
* @param offset offset
* @param length length
* @return a new Dot11FrameControl object.
* @throws IllegalRawDataException if parsing the raw data fails.
*/
public static Dot11FrameControl newInstance(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
return new Dot11FrameControl(rawData, offset, length);
}
private Dot11FrameControl(
byte[] rawData, int offset, int length
) throws IllegalRawDataException {
if (length < 2) {
StringBuilder sb = new StringBuilder(200);
sb.append("The data is too short to build a Dot11FrameControl (")
.append(2)
.append(" bytes). data: ")
.append(ByteArrays.toHexString(rawData, " "))
.append(", offset: ")
.append(offset)
.append(", length: ")
.append(length);
throw new IllegalRawDataException(sb.toString());
}
byte firstByte = rawData[offset];
switch (firstByte & 0x03) {
case 0:
this.protocolVersion = ProtocolVersion.V0;
break;
case 1:
this.protocolVersion = ProtocolVersion.V1;
break;
case 2:
this.protocolVersion = ProtocolVersion.V2;
break;
case 3:
this.protocolVersion = ProtocolVersion.V3;
break;
default:
throw new AssertionError("Never get here.");
}
this.type
= Dot11FrameType.getInstance(
(byte) (((firstByte << 2) & 0x30) | ((firstByte >> 4) & 0x0F))
);
byte secondByte = rawData[offset + 1];
this.toDs = (secondByte & 0x01) != 0;
this.fromDs = (secondByte & 0x02) != 0;
this.moreFragments = (secondByte & 0x04) != 0;
this.retry = (secondByte & 0x08) != 0;
this.powerManagement = (secondByte & 0x10) != 0;
this.moreData = (secondByte & 0x20) != 0;
this.protectedFrame = (secondByte & 0x40) != 0;
this.order = (secondByte & 0x80) != 0;
}
private Dot11FrameControl(Builder builder) {
if (
builder == null
|| builder.protocolVersion == null
|| builder.type == null
) {
StringBuilder sb = new StringBuilder();
sb.append("builder").append(builder)
.append(" builder.protocolVersion: ").append(builder.protocolVersion)
.append(" builder.type: ").append(builder.type);
throw new NullPointerException(sb.toString());
}
this.protocolVersion = builder.protocolVersion;
this.type = builder.type;
this.toDs = builder.toDs;
this.fromDs = builder.fromDs;
this.moreFragments = builder.moreFragments;
this.retry = builder.retry;
this.powerManagement = builder.powerManagement;
this.moreData = builder.moreData;
this.protectedFrame = builder.protectedFrame;
this.order = builder.order;
}
/**
* @return protocolVersion
*/
public ProtocolVersion getProtocolVersion() {
return protocolVersion;
}
/**
* @return type
*/
public Dot11FrameType getType() {
return type;
}
/**
* @return toDs
*/
public boolean isToDs() {
return toDs;
}
/**
* @return fromDs
*/
public boolean isFromDs() {
return fromDs;
}
/**
* @return moreFragments
*/
public boolean isMoreFragments() {
return moreFragments;
}
/**
* @return retry
*/
public boolean isRetry() {
return retry;
}
/**
* @return powerManagement
*/
public boolean isPowerManagement() {
return powerManagement;
}
/**
* @return moreData
*/
public boolean isMoreData() {
return moreData;
}
/**
* @return protectedFrame
*/
public boolean isProtectedFrame() {
return protectedFrame;
}
/**
* @return order
*/
public boolean isOrder() {
return order;
}
/**
*
* @return a new Builder object populated with this object's fields.
*/
public Builder getBuilder() {
return new Builder(this);
}
/**
* @return the raw data.
*/
public byte[] getRawData() {
byte[] data = new byte[2];
data[0] |= protocolVersion.value;
data[0] |= type.getType().getValue() << 2;
data[0] |= type.value() << 4;
if (toDs) { data[1] |= 0x01; }
if (fromDs) { data[1] |= 0x02; }
if (moreFragments) { data[1] |= 0x04; }
if (retry) { data[1] |= 0x08; }
if (powerManagement) { data[1] |= 0x10; }
if (moreData) { data[1] |= 0x20; }
if (protectedFrame) { data[1] |= 0x40; }
if (order) { data[1] |= 0x80; }
return data;
}
/**
* @return length
*/
public int length() {
return 2;
}
@Override
public String toString() {
return toString("");
}
/**
* @param indent indent
* @return String represantation of this object.
*/
public String toString(String indent) {
StringBuilder sb = new StringBuilder();
String ls = System.getProperty("line.separator");
sb.append(indent).append("Protocol Version: ")
.append(protocolVersion).append(ls)
.append(indent).append("Type/Subtype: ")
.append(type).append(ls)
.append(indent).append("To DS: ")
.append(toDs).append(ls)
.append(indent).append("From DS: ")
.append(fromDs).append(ls)
.append(indent).append("More Fragments: ")
.append(moreFragments).append(ls)
.append(indent).append("Retry: ")
.append(retry).append(ls)
.append(indent).append("Power Management: ")
.append(powerManagement).append(ls)
.append(indent).append("More Data: ")
.append(moreData).append(ls)
.append(indent).append("Protected Frame: ")
.append(protectedFrame).append(ls)
.append(indent).append("Order: ")
.append(order).append(ls);
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (fromDs ? 1231 : 1237);
result = prime * result + (moreData ? 1231 : 1237);
result = prime * result + (moreFragments ? 1231 : 1237);
result = prime * result + (order ? 1231 : 1237);
result = prime * result + (powerManagement ? 1231 : 1237);
result = prime * result + (protectedFrame ? 1231 : 1237);
result = prime * result + ((protocolVersion == null) ? 0 : protocolVersion.hashCode());
result = prime * result + (retry ? 1231 : 1237);
result = prime * result + (toDs ? 1231 : 1237);
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Dot11FrameControl other = (Dot11FrameControl) obj;
if (fromDs != other.fromDs)
return false;
if (moreData != other.moreData)
return false;
if (moreFragments != other.moreFragments)
return false;
if (order != other.order)
return false;
if (powerManagement != other.powerManagement)
return false;
if (protectedFrame != other.protectedFrame)
return false;
if (protocolVersion != other.protocolVersion)
return false;
if (retry != other.retry)
return false;
if (toDs != other.toDs)
return false;
if (!type.equals(other.type))
return false;
return true;
}
/**
* @author <NAME>
* @since pcap4j 1.7.0
*/
public static final class Builder {
private ProtocolVersion protocolVersion;
private Dot11FrameType type;
private boolean toDs;
private boolean fromDs;
private boolean moreFragments;
private boolean retry;
private boolean powerManagement;
private boolean moreData;
private boolean protectedFrame;
private boolean order;
/**
*
*/
public Builder() {}
private Builder(Dot11FrameControl obj) {
this.protocolVersion = obj.protocolVersion;
this.type = obj.type;
this.toDs = obj.toDs;
this.fromDs = obj.fromDs;
this.moreFragments = obj.moreFragments;
this.retry = obj.retry;
this.powerManagement = obj.powerManagement;
this.moreData = obj.moreData;
this.protectedFrame = obj.protectedFrame;
this.order = obj.order;
}
/**
* @param protocolVersion protocolVersion
* @return this Builder object for method chaining.
*/
public Builder protocolVersion(ProtocolVersion protocolVersion) {
this.protocolVersion = protocolVersion;
return this;
}
/**
* @param type type
* @return this Builder object for method chaining.
*/
public Builder type(Dot11FrameType type) {
this.type = type;
return this;
}
/**
* @param toDs toDs
* @return this Builder object for method chaining.
*/
public Builder toDs(boolean toDs) {
this.toDs = toDs;
return this;
}
/**
* @param fromDs fromDs
* @return this Builder object for method chaining.
*/
public Builder fromDs(boolean fromDs) {
this.fromDs = fromDs;
return this;
}
/**
* @param moreFragments moreFragments
* @return this Builder object for method chaining.
*/
public Builder moreFragments(boolean moreFragments) {
this.moreFragments = moreFragments;
return this;
}
/**
* @param retry retry
* @return this Builder object for method chaining.
*/
public Builder retry(boolean retry) {
this.retry = retry;
return this;
}
/**
* @param powerManagement powerManagement
* @return this Builder object for method chaining.
*/
public Builder powerManagement(boolean powerManagement) {
this.powerManagement = powerManagement;
return this;
}
/**
* @param moreData moreData
* @return this Builder object for method chaining.
*/
public Builder moreData(boolean moreData) {
this.moreData = moreData;
return this;
}
/**
* @param protectedFrame protectedFrame
* @return this Builder object for method chaining.
*/
public Builder protectedFrame(boolean protectedFrame) {
this.protectedFrame = protectedFrame;
return this;
}
/**
* @param order order
* @return this Builder object for method chaining.
*/
public Builder order(boolean order) {
this.order = order;
return this;
}
/**
*
* @return a new Dot11FrameControl object.
*/
public Dot11FrameControl build() {
return new Dot11FrameControl(this);
}
}
/**
* Protocol version of IEEE802.11 frame
*
* @see <a href="http://standards.ieee.org/getieee802/download/802.11-2012.pdf">IEEE802.11</a>
* @author <NAME>
* @since pcap4j 1.7.0
*/
public static enum ProtocolVersion {
/**
* v0 (00)
*/
V0(0),
/**
* v1 (01)
*/
V1(1),
/**
* v2 (10)
*/
V2(2),
/**
* v3 (11)
*/
V3(3);
private final int value;
private ProtocolVersion(int value) {
this.value = value;
}
/**
* @return value
*/
public int getValue() {
return value;
}
}
}
| 13,207 | 0.582533 | 0.558866 | 511 | 24.880627 | 21.468117 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.422701 | false | false |
13
|
58d95a274a94247aa4b506c47639338cb95f0917
| 25,374,666,847,610 |
38f24cb578e18fe296eea0311a77cb6ac732578a
|
/commonserverlib/src/main/java/com/isay/commonserverlib/bean/CalendarInfo.java
|
b4a456d79a54f3017f5786ea2e442ff3e1231b8e
|
[] |
no_license
|
isayWu/ComponentizationSample
|
https://github.com/isayWu/ComponentizationSample
|
2941214d8e3b48963690732d53f8ff6a5cbba662
|
1f5e540bcfa8d9459859eab0462e4f11a4f1c2d2
|
refs/heads/master
| 2023-05-30T02:46:11.249000 | 2021-06-11T07:39:16 | 2021-06-11T07:39:16 | 260,128,499 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.isay.commonserverlib.bean;
/**
* Desc:
* <p>
* Author: WuCongYi
* Date: 2020/5/14
* Copyright: Copyright (c) 2016-2020
* Company: @小牛科技
* Update Comments:
* 构建配置参见:
*
* @author wucongyi
*/
public class CalendarInfo {
private int year;
private int month;
private int day;
private int week;
/**
* 公历节日
*/
private String holiday;
private int lunaYear;
private int lunaMonth;
private int lunaDay;
private String lunaDayStr;
/**
* 农历节日
*/
private String lunaHoliday;
/**
* 24节气
*/
private String solarItem;
public int getYear() {
return year;
}
public CalendarInfo setYear(int year) {
this.year = year;
return this;
}
public int getMonth() {
return month;
}
public CalendarInfo setMonth(int month) {
this.month = month;
return this;
}
public int getDay() {
return day;
}
public CalendarInfo setDay(int day) {
this.day = day;
return this;
}
public String getHoliday() {
return holiday;
}
public CalendarInfo setHoliday(String holiday) {
this.holiday = holiday;
return this;
}
public int getLunaYear() {
return lunaYear;
}
public CalendarInfo setLunaYear(int lunaYear) {
this.lunaYear = lunaYear;
return this;
}
public int getLunaMonth() {
return lunaMonth;
}
public CalendarInfo setLunaMonth(int lunaMonth) {
this.lunaMonth = lunaMonth;
return this;
}
public int getLunaDay() {
return lunaDay;
}
public CalendarInfo setLunaDay(int lunaDay) {
this.lunaDay = lunaDay;
return this;
}
public String getLunaHoliday() {
return lunaHoliday;
}
public CalendarInfo setLunaHoliday(String lunaHoliday) {
this.lunaHoliday = lunaHoliday;
return this;
}
public String getLunaDayStr() {
return lunaDayStr;
}
public CalendarInfo setLunaDayStr(String lunaDayStr) {
this.lunaDayStr = lunaDayStr;
return this;
}
public int getWeek() {
return week;
}
public CalendarInfo setWeek(int week) {
this.week = week;
return this;
}
public String getSolarItem() {
return solarItem;
}
public CalendarInfo setSolarItem(String solarItem) {
this.solarItem = solarItem;
return this;
}
}
|
UTF-8
|
Java
| 2,560 |
java
|
CalendarInfo.java
|
Java
|
[
{
"context": "monserverlib.bean;\n\n/**\n * Desc:\n * <p>\n * Author: WuCongYi\n * Date: 2020/5/14\n * Copyright: Copyright (c) 20",
"end": 79,
"score": 0.9995204210281372,
"start": 71,
"tag": "NAME",
"value": "WuCongYi"
},
{
"context": "@小牛科技\n * Update Comments:\n * 构建配置参见:\n *\n * @author wucongyi\n */\npublic class CalendarInfo {\n\n private int ",
"end": 208,
"score": 0.9996680021286011,
"start": 200,
"tag": "USERNAME",
"value": "wucongyi"
}
] | null |
[] |
package com.isay.commonserverlib.bean;
/**
* Desc:
* <p>
* Author: WuCongYi
* Date: 2020/5/14
* Copyright: Copyright (c) 2016-2020
* Company: @小牛科技
* Update Comments:
* 构建配置参见:
*
* @author wucongyi
*/
public class CalendarInfo {
private int year;
private int month;
private int day;
private int week;
/**
* 公历节日
*/
private String holiday;
private int lunaYear;
private int lunaMonth;
private int lunaDay;
private String lunaDayStr;
/**
* 农历节日
*/
private String lunaHoliday;
/**
* 24节气
*/
private String solarItem;
public int getYear() {
return year;
}
public CalendarInfo setYear(int year) {
this.year = year;
return this;
}
public int getMonth() {
return month;
}
public CalendarInfo setMonth(int month) {
this.month = month;
return this;
}
public int getDay() {
return day;
}
public CalendarInfo setDay(int day) {
this.day = day;
return this;
}
public String getHoliday() {
return holiday;
}
public CalendarInfo setHoliday(String holiday) {
this.holiday = holiday;
return this;
}
public int getLunaYear() {
return lunaYear;
}
public CalendarInfo setLunaYear(int lunaYear) {
this.lunaYear = lunaYear;
return this;
}
public int getLunaMonth() {
return lunaMonth;
}
public CalendarInfo setLunaMonth(int lunaMonth) {
this.lunaMonth = lunaMonth;
return this;
}
public int getLunaDay() {
return lunaDay;
}
public CalendarInfo setLunaDay(int lunaDay) {
this.lunaDay = lunaDay;
return this;
}
public String getLunaHoliday() {
return lunaHoliday;
}
public CalendarInfo setLunaHoliday(String lunaHoliday) {
this.lunaHoliday = lunaHoliday;
return this;
}
public String getLunaDayStr() {
return lunaDayStr;
}
public CalendarInfo setLunaDayStr(String lunaDayStr) {
this.lunaDayStr = lunaDayStr;
return this;
}
public int getWeek() {
return week;
}
public CalendarInfo setWeek(int week) {
this.week = week;
return this;
}
public String getSolarItem() {
return solarItem;
}
public CalendarInfo setSolarItem(String solarItem) {
this.solarItem = solarItem;
return this;
}
}
| 2,560 | 0.58373 | 0.576984 | 136 | 17.529411 | 15.153597 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.330882 | false | false |
13
|
d776b9e93154e58c32e0ba8e4295ed1ca57e47e0
| 32,435,593,034,474 |
0e2f89b765fc95c3b83bc370dacd1f03f413f638
|
/armada-apiserver/src/main/java/net/twerion/armada/api/node/NodeRedisSchema.java
|
353062999c26b9c0857f4d8da86a30f7b6122a30
|
[
"MIT"
] |
permissive
|
behind-the-blocks/armada
|
https://github.com/behind-the-blocks/armada
|
cfd16253e275c3b0b426f162064043a5e1adbdf5
|
4e9d2fe866793314c7aa68d35a0d69be3fc3cd16
|
refs/heads/master
| 2020-06-11T10:42:01.638000 | 2019-06-26T16:12:38 | 2019-06-26T16:12:38 | 193,934,710 | 2 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package net.twerion.armada.api.node;
import com.google.common.base.Charsets;
import com.google.common.base.MoreObjects;
import net.twerion.armada.Node;
import net.twerion.armada.LabelSet;
import net.twerion.armada.Address;
import net.twerion.armada.Resources;
import net.twerion.armada.LabelSelectorSet;
import net.twerion.armada.NodeAppStarterSet;
import net.twerion.armada.api.redis.RedisObjectSchema;
public final class NodeRedisSchema {
private NodeRedisSchema() {
}
public RedisObjectSchema<Node.Builder> create() {
RedisObjectSchema.Builder<Node.Builder> builder =
RedisObjectSchema.newBuilder(Node.Builder.class);
builder.addField(
builder.field(String.class, "cluster_id")
.withMutator(Node.Builder::setClusterId)
.withAccessor(Node.Builder::getClusterId)
.withEncoder(NodeRedisSchema::toUtf8)
.withDecoder(NodeRedisSchema::fromUtf8)
.create());
builder.addField(
builder.field(Node.Status.class, "status")
.withMutator(Node.Builder::setStatus)
.withAccessor(Node.Builder::getStatus)
.withEncoder(NodeRedisSchema::encodeStatus)
.withDecoder(NodeRedisSchema::decodeStatus)
.create());
builder.addField(
builder.field(LabelSet.class, "labels")
.withMutator(Node.Builder::setLabels)
.withAccessor(Node.Builder::getLabels)
.withEncoder(LabelSet::toByteArray)
.withDecoder(LabelSet::parseFrom)
.create());
builder.addField(
builder.field(Address.class, "address")
.withMutator(Node.Builder::setAddress)
.withAccessor(Node.Builder::getAddress)
.withEncoder(Address::toByteArray)
.withDecoder(Address::parseFrom)
.create());
builder.addField(
builder.field(LabelSelectorSet.class, "ship_selectors")
.withMutator(Node.Builder::setShipSelectors)
.withAccessor(Node.Builder::getShipSelectors)
.withEncoder(LabelSelectorSet::toByteArray)
.withDecoder(LabelSelectorSet::parseFrom)
.create());
builder.addField(
builder.field(Resources.class, "resources")
.withMutator(Node.Builder::setResources)
.withAccessor(Node.Builder::getResources)
.withEncoder(Resources::toByteArray)
.withDecoder(Resources::parseFrom)
.create());
builder.addField(
builder.field(NodeAppStarterSet.class, "app_starters")
.withMutator(Node.Builder::setAppStarters)
.withAccessor(Node.Builder::getAppStarters)
.withEncoder(NodeAppStarterSet::toByteArray)
.withDecoder(NodeAppStarterSet::parseFrom)
.create()
);
return builder.create();
}
private static Node.Status decodeStatus(byte[] encoded) {
if (encoded.length != 1) {
return Node.Status.UNKNOWN;
}
Node.Status decoded = Node.Status.valueOf(encoded[0]);
return MoreObjects.firstNonNull(decoded, Node.Status.UNKNOWN);
}
private static byte[] encodeStatus(Node.Status status) {
return new byte[]{(byte) status.ordinal()};
}
private static byte[] toUtf8(String value) {
return value.getBytes(Charsets.UTF_8);
}
private static String fromUtf8(byte[] bytes) {
return new String(bytes, Charsets.UTF_8);
}
}
|
UTF-8
|
Java
| 3,265 |
java
|
NodeRedisSchema.java
|
Java
|
[] | null |
[] |
package net.twerion.armada.api.node;
import com.google.common.base.Charsets;
import com.google.common.base.MoreObjects;
import net.twerion.armada.Node;
import net.twerion.armada.LabelSet;
import net.twerion.armada.Address;
import net.twerion.armada.Resources;
import net.twerion.armada.LabelSelectorSet;
import net.twerion.armada.NodeAppStarterSet;
import net.twerion.armada.api.redis.RedisObjectSchema;
public final class NodeRedisSchema {
private NodeRedisSchema() {
}
public RedisObjectSchema<Node.Builder> create() {
RedisObjectSchema.Builder<Node.Builder> builder =
RedisObjectSchema.newBuilder(Node.Builder.class);
builder.addField(
builder.field(String.class, "cluster_id")
.withMutator(Node.Builder::setClusterId)
.withAccessor(Node.Builder::getClusterId)
.withEncoder(NodeRedisSchema::toUtf8)
.withDecoder(NodeRedisSchema::fromUtf8)
.create());
builder.addField(
builder.field(Node.Status.class, "status")
.withMutator(Node.Builder::setStatus)
.withAccessor(Node.Builder::getStatus)
.withEncoder(NodeRedisSchema::encodeStatus)
.withDecoder(NodeRedisSchema::decodeStatus)
.create());
builder.addField(
builder.field(LabelSet.class, "labels")
.withMutator(Node.Builder::setLabels)
.withAccessor(Node.Builder::getLabels)
.withEncoder(LabelSet::toByteArray)
.withDecoder(LabelSet::parseFrom)
.create());
builder.addField(
builder.field(Address.class, "address")
.withMutator(Node.Builder::setAddress)
.withAccessor(Node.Builder::getAddress)
.withEncoder(Address::toByteArray)
.withDecoder(Address::parseFrom)
.create());
builder.addField(
builder.field(LabelSelectorSet.class, "ship_selectors")
.withMutator(Node.Builder::setShipSelectors)
.withAccessor(Node.Builder::getShipSelectors)
.withEncoder(LabelSelectorSet::toByteArray)
.withDecoder(LabelSelectorSet::parseFrom)
.create());
builder.addField(
builder.field(Resources.class, "resources")
.withMutator(Node.Builder::setResources)
.withAccessor(Node.Builder::getResources)
.withEncoder(Resources::toByteArray)
.withDecoder(Resources::parseFrom)
.create());
builder.addField(
builder.field(NodeAppStarterSet.class, "app_starters")
.withMutator(Node.Builder::setAppStarters)
.withAccessor(Node.Builder::getAppStarters)
.withEncoder(NodeAppStarterSet::toByteArray)
.withDecoder(NodeAppStarterSet::parseFrom)
.create()
);
return builder.create();
}
private static Node.Status decodeStatus(byte[] encoded) {
if (encoded.length != 1) {
return Node.Status.UNKNOWN;
}
Node.Status decoded = Node.Status.valueOf(encoded[0]);
return MoreObjects.firstNonNull(decoded, Node.Status.UNKNOWN);
}
private static byte[] encodeStatus(Node.Status status) {
return new byte[]{(byte) status.ordinal()};
}
private static byte[] toUtf8(String value) {
return value.getBytes(Charsets.UTF_8);
}
private static String fromUtf8(byte[] bytes) {
return new String(bytes, Charsets.UTF_8);
}
}
| 3,265 | 0.694946 | 0.692496 | 101 | 31.326733 | 20.377676 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.336634 | false | false |
13
|
4a42866ff91ed9f23fc8fb0b31d0d5e472ff0860
| 34,205,119,565,592 |
693cfc1a3fe9355e5c75f3532c84031c29277a44
|
/core/src/main/java/org/parchmentmc/feather/metadata/SourceMetadataBuilder.java
|
fffddb742bce6af7f06ef1a0b0412f9ff5b09cc8
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
SizableShrimp/Feather
|
https://github.com/SizableShrimp/Feather
|
3e80cdb9bfdf18c7cfa92d4b48720b96274367e0
|
59d5d8b3cbddb94b118153a27227accb3e30ba23
|
refs/heads/main
| 2023-06-29T18:06:00.096000 | 2021-06-19T16:52:24 | 2021-06-19T16:52:24 | 394,806,598 | 0 | 0 |
MIT
| true | 2021-08-10T23:36:50 | 2021-08-10T23:36:50 | 2021-07-29T09:09:41 | 2021-06-26T04:03:06 | 416 | 0 | 0 | 0 | null | false | false |
package org.parchmentmc.feather.metadata;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.parchmentmc.feather.named.Named;
import org.parchmentmc.feather.named.NamedBuilder;
import org.parchmentmc.feather.util.SimpleVersion;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public final class SourceMetadataBuilder implements SourceMetadata {
private SimpleVersion specVersion = SimpleVersion.of(1, 0, 0);
private String minecraftVersion = "0.0.0";
private LinkedHashSet<ClassMetadata> classes = new LinkedHashSet<>();
private SourceMetadataBuilder() {
}
public static SourceMetadataBuilder create() {
return new SourceMetadataBuilder();
}
public static SourceMetadataBuilder create(final SourceMetadata target) {
if (target == null)
return create();
return create()
.withSpecVersion(target.getSpecificationVersion())
.withMinecraftVersion(target.getMinecraftVersion())
.withClasses(target.getClasses());
}
public SourceMetadataBuilder withSpecVersion(SimpleVersion specVersion) {
this.specVersion = specVersion;
return this;
}
public SourceMetadataBuilder withMinecraftVersion(String minecraftVersion) {
this.minecraftVersion = minecraftVersion;
return this;
}
public SourceMetadataBuilder withClasses(LinkedHashSet<ClassMetadata> classes) {
this.classes = classes;
return this;
}
public SourceMetadataBuilder merge(final SourceMetadata source, final String mergingSchema) {
if (source == null)
return this;
final Map<Named, ClassMetadata> schemadLocalInnerClasses = this.classes
.stream().collect(Collectors.toMap(
fm -> NamedBuilder.create()
.with(mergingSchema, fm.getName().getName(mergingSchema).orElse(""))
.build(),
Function.identity()
));
final Map<Named, ClassMetadata> schemadSourceInnerClasses = source.getClasses()
.stream().collect(Collectors.toMap(
fm -> NamedBuilder.create()
.with(mergingSchema, fm.getName().getName(mergingSchema).orElse(""))
.build(),
Function.identity()
));
this.classes = new LinkedHashSet<>();
for (final Named keyReference : schemadLocalInnerClasses.keySet()) {
if (!schemadSourceInnerClasses.containsKey(keyReference)) {
this.classes.add(schemadLocalInnerClasses.get(keyReference));
} else {
this.classes.add(
ClassMetadataBuilder.create(schemadLocalInnerClasses.get(keyReference))
.merge(schemadSourceInnerClasses.get(keyReference), mergingSchema)
.build()
);
}
}
schemadSourceInnerClasses.keySet().stream()
.filter(mr -> !schemadLocalInnerClasses.containsKey(mr))
.forEach(mr -> this.classes.add(schemadSourceInnerClasses.get(mr)));
return this;
}
@Override
public SimpleVersion getSpecificationVersion() {
return specVersion;
}
@Override
public String getMinecraftVersion() {
return minecraftVersion;
}
@Override
public LinkedHashSet<ClassMetadata> getClasses() {
return classes;
}
public ImmutableSourceMetadata build() {
return new ImmutableSourceMetadata(
specVersion,
minecraftVersion,
classes.stream().map(ClassMetadata::toImmutable).collect(Collectors.toCollection(LinkedHashSet::new))
);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SourceMetadata)) return false;
SourceMetadata that = (SourceMetadata) o;
return getSpecificationVersion().equals(that.getSpecificationVersion())
&& getMinecraftVersion().equals(that.getMinecraftVersion())
&& getClasses().equals(that.getClasses());
}
@Override
public int hashCode() {
return Objects.hash(getSpecificationVersion(), getMinecraftVersion(), getClasses());
}
public SourceMetadataBuilder addClass(final ClassMetadata build) {
this.classes.add(build);
return this;
}
@Override
public @NonNull SourceMetadata toImmutable() {
return build();
}
}
|
UTF-8
|
Java
| 4,773 |
java
|
SourceMetadataBuilder.java
|
Java
|
[] | null |
[] |
package org.parchmentmc.feather.metadata;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.parchmentmc.feather.named.Named;
import org.parchmentmc.feather.named.NamedBuilder;
import org.parchmentmc.feather.util.SimpleVersion;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public final class SourceMetadataBuilder implements SourceMetadata {
private SimpleVersion specVersion = SimpleVersion.of(1, 0, 0);
private String minecraftVersion = "0.0.0";
private LinkedHashSet<ClassMetadata> classes = new LinkedHashSet<>();
private SourceMetadataBuilder() {
}
public static SourceMetadataBuilder create() {
return new SourceMetadataBuilder();
}
public static SourceMetadataBuilder create(final SourceMetadata target) {
if (target == null)
return create();
return create()
.withSpecVersion(target.getSpecificationVersion())
.withMinecraftVersion(target.getMinecraftVersion())
.withClasses(target.getClasses());
}
public SourceMetadataBuilder withSpecVersion(SimpleVersion specVersion) {
this.specVersion = specVersion;
return this;
}
public SourceMetadataBuilder withMinecraftVersion(String minecraftVersion) {
this.minecraftVersion = minecraftVersion;
return this;
}
public SourceMetadataBuilder withClasses(LinkedHashSet<ClassMetadata> classes) {
this.classes = classes;
return this;
}
public SourceMetadataBuilder merge(final SourceMetadata source, final String mergingSchema) {
if (source == null)
return this;
final Map<Named, ClassMetadata> schemadLocalInnerClasses = this.classes
.stream().collect(Collectors.toMap(
fm -> NamedBuilder.create()
.with(mergingSchema, fm.getName().getName(mergingSchema).orElse(""))
.build(),
Function.identity()
));
final Map<Named, ClassMetadata> schemadSourceInnerClasses = source.getClasses()
.stream().collect(Collectors.toMap(
fm -> NamedBuilder.create()
.with(mergingSchema, fm.getName().getName(mergingSchema).orElse(""))
.build(),
Function.identity()
));
this.classes = new LinkedHashSet<>();
for (final Named keyReference : schemadLocalInnerClasses.keySet()) {
if (!schemadSourceInnerClasses.containsKey(keyReference)) {
this.classes.add(schemadLocalInnerClasses.get(keyReference));
} else {
this.classes.add(
ClassMetadataBuilder.create(schemadLocalInnerClasses.get(keyReference))
.merge(schemadSourceInnerClasses.get(keyReference), mergingSchema)
.build()
);
}
}
schemadSourceInnerClasses.keySet().stream()
.filter(mr -> !schemadLocalInnerClasses.containsKey(mr))
.forEach(mr -> this.classes.add(schemadSourceInnerClasses.get(mr)));
return this;
}
@Override
public SimpleVersion getSpecificationVersion() {
return specVersion;
}
@Override
public String getMinecraftVersion() {
return minecraftVersion;
}
@Override
public LinkedHashSet<ClassMetadata> getClasses() {
return classes;
}
public ImmutableSourceMetadata build() {
return new ImmutableSourceMetadata(
specVersion,
minecraftVersion,
classes.stream().map(ClassMetadata::toImmutable).collect(Collectors.toCollection(LinkedHashSet::new))
);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SourceMetadata)) return false;
SourceMetadata that = (SourceMetadata) o;
return getSpecificationVersion().equals(that.getSpecificationVersion())
&& getMinecraftVersion().equals(that.getMinecraftVersion())
&& getClasses().equals(that.getClasses());
}
@Override
public int hashCode() {
return Objects.hash(getSpecificationVersion(), getMinecraftVersion(), getClasses());
}
public SourceMetadataBuilder addClass(final ClassMetadata build) {
this.classes.add(build);
return this;
}
@Override
public @NonNull SourceMetadata toImmutable() {
return build();
}
}
| 4,773 | 0.624764 | 0.623507 | 135 | 34.355556 | 29.238602 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.414815 | false | false |
13
|
4c81e2cfa0d007a4ab199e80eff901d69886ae08
| 6,700,149,034,968 |
17b9b32bd2f974b65d055cd8eda87c1aa7b55e1b
|
/MeditationTracker/meditationTracker/src/main/java/com/meditationtracker/sync/backup/RealBackupManager.java
|
37fa93a384f6c763c742e6f30cd410bdb95231cd
|
[] |
no_license
|
phdApp/MeditationTracker
|
https://github.com/phdApp/MeditationTracker
|
4a70944b10a35822a1d977f4a80b98f9b83deaa1
|
c4cd1a8852bfd49cde47c94a7c587b5c09c60b79
|
refs/heads/master
| 2023-03-16T23:07:56.705000 | 2017-01-15T11:03:26 | 2017-01-15T11:03:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.meditationtracker.sync.backup;
import android.app.backup.BackupManager;
import android.app.backup.RestoreObserver;
import android.content.Context;
import android.util.Log;
import com.meditationtracker.util.Util;
public class RealBackupManager implements IBackupManager {
private final BackupManager instance;
private final Context context;
public RealBackupManager(Context context) {
instance = new BackupManager(context);
this.context = context;
}
@Override
public void dataChanged() {
instance.dataChanged();
Log.d("MTRK", "Asked backup ops");
}
@Override
public int requestRestore(RestoreObserver observer) {
return instance.requestRestore(observer);
}
}
|
UTF-8
|
Java
| 714 |
java
|
RealBackupManager.java
|
Java
|
[] | null |
[] |
package com.meditationtracker.sync.backup;
import android.app.backup.BackupManager;
import android.app.backup.RestoreObserver;
import android.content.Context;
import android.util.Log;
import com.meditationtracker.util.Util;
public class RealBackupManager implements IBackupManager {
private final BackupManager instance;
private final Context context;
public RealBackupManager(Context context) {
instance = new BackupManager(context);
this.context = context;
}
@Override
public void dataChanged() {
instance.dataChanged();
Log.d("MTRK", "Asked backup ops");
}
@Override
public int requestRestore(RestoreObserver observer) {
return instance.requestRestore(observer);
}
}
| 714 | 0.766106 | 0.766106 | 31 | 22.032259 | 19.324869 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.967742 | false | false |
13
|
7fda7a497ffa630204a2bc5d84ed35dbf2818807
| 6,700,149,035,869 |
e12ccabe95b9b598afc2496663a05eda0140e1e6
|
/src/main/java/POJOS/Captcha.java
|
fe2d3214c6070e5ee0dbb3840e96799eb1b568a1
|
[] |
no_license
|
WilliansAlb/GCIC
|
https://github.com/WilliansAlb/GCIC
|
9c6aff4f9d843c137a23c1d0121a8e68aac83252
|
57a6894c3e32ea25abe5b8cc1ef8c8e50583c6d6
|
refs/heads/master
| 2023-05-03T01:15:12.027000 | 2021-05-18T19:52:45 | 2021-05-18T19:52:45 | 367,196,811 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package POJOS;
/**
*
* @author willi
*/
public class Captcha {
private String id;
private String nombre;
private int veces;
private int aciertos;
private int fallos;
private String fecha;
private String url;
private String titulo;
public Captcha(String id, String nombre, int veces, int aciertos, int fallos, String fecha, String url, String titulo) {
this.id = id;
this.nombre = nombre;
this.veces = veces;
this.aciertos = aciertos;
this.fallos = fallos;
this.fecha = fecha;
this.url = url;
this.titulo = titulo;
}
public Captcha() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public int getVeces() {
return veces;
}
public void setVeces(int veces) {
this.veces = veces;
}
public int getAciertos() {
return aciertos;
}
public void setAciertos(int aciertos) {
this.aciertos = aciertos;
}
public int getFallos() {
return fallos;
}
public void setFallos(int fallos) {
this.fallos = fallos;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
}
|
UTF-8
|
Java
| 1,942 |
java
|
Captcha.java
|
Java
|
[
{
"context": " the editor.\n */\npackage POJOS;\n\n/**\n *\n * @author willi\n */\npublic class Captcha {\n private String id;",
"end": 224,
"score": 0.9863555431365967,
"start": 219,
"tag": "USERNAME",
"value": "willi"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package POJOS;
/**
*
* @author willi
*/
public class Captcha {
private String id;
private String nombre;
private int veces;
private int aciertos;
private int fallos;
private String fecha;
private String url;
private String titulo;
public Captcha(String id, String nombre, int veces, int aciertos, int fallos, String fecha, String url, String titulo) {
this.id = id;
this.nombre = nombre;
this.veces = veces;
this.aciertos = aciertos;
this.fallos = fallos;
this.fecha = fecha;
this.url = url;
this.titulo = titulo;
}
public Captcha() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public int getVeces() {
return veces;
}
public void setVeces(int veces) {
this.veces = veces;
}
public int getAciertos() {
return aciertos;
}
public void setAciertos(int aciertos) {
this.aciertos = aciertos;
}
public int getFallos() {
return fallos;
}
public void setFallos(int fallos) {
this.fallos = fallos;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
}
| 1,942 | 0.573635 | 0.573635 | 103 | 17.854368 | 18.409794 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.417476 | false | false |
13
|
ce970b8c7576e1d39b3e32366753f9884304fcf2
| 34,677,565,972,328 |
50fc2e72eb30756d7a361f5a322ae19442b73804
|
/edu.uoc.ictflag.web/src/edu/uoc/ictflag/web/IctflagExceptionHandlerFactory.java
|
0782314e45da36cbd2141e3253e383f9b7990658
|
[] |
no_license
|
dganan/ict-flag
|
https://github.com/dganan/ict-flag
|
a6bf360789d1c536d2d14849a0229c2f30d1cd93
|
e05970e8a437ac9ac06cd036e507ee4daa7fe9da
|
refs/heads/master
| 2023-08-09T16:37:21.580000 | 2022-02-10T10:42:54 | 2022-02-10T10:42:54 | 244,713,853 | 0 | 0 | null | false | 2023-07-23T07:36:47 | 2020-03-03T18:40:55 | 2022-02-10T10:37:37 | 2023-07-23T07:36:44 | 125,010 | 0 | 0 | 13 |
CSS
| false | false |
package edu.uoc.ictflag.web;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;
public class IctflagExceptionHandlerFactory extends ExceptionHandlerFactory
{
private ExceptionHandlerFactory parent;
// this injection handles jsf
public IctflagExceptionHandlerFactory(ExceptionHandlerFactory parent)
{
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler()
{
ExceptionHandler result = new IctflagExceptionHandler(parent.getExceptionHandler());
return result;
}
}
|
UTF-8
|
Java
| 562 |
java
|
IctflagExceptionHandlerFactory.java
|
Java
|
[] | null |
[] |
package edu.uoc.ictflag.web;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;
public class IctflagExceptionHandlerFactory extends ExceptionHandlerFactory
{
private ExceptionHandlerFactory parent;
// this injection handles jsf
public IctflagExceptionHandlerFactory(ExceptionHandlerFactory parent)
{
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler()
{
ExceptionHandler result = new IctflagExceptionHandler(parent.getExceptionHandler());
return result;
}
}
| 562 | 0.80605 | 0.80605 | 22 | 24.545454 | 26.834047 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.954545 | false | false |
13
|
ef11e86d1aea4d2844d8856f7881744b35365200
| 34,677,565,972,960 |
bef58a3be22d7234bdc9ec325708d307575d5235
|
/apm-commons/apm-datacarrier/src/main/java/com/google/code/fqueue/FBlockingQueue.java
|
1798a522425df659b483c40da2624d3446f8c041
|
[
"BSD-3-Clause",
"Apache-2.0"
] |
permissive
|
shusl/skywalking
|
https://github.com/shusl/skywalking
|
81e9d22487b63240da1907404282b4e72eaa9da4
|
07e5308f1c24f7d59a9a9b6cf7a212e518ef4cc7
|
refs/heads/master
| 2023-09-01T00:03:57.215000 | 2020-07-16T03:30:18 | 2020-07-16T03:30:18 | 244,008,003 | 0 | 1 |
Apache-2.0
| true | 2020-07-16T03:32:04 | 2020-02-29T17:06:35 | 2020-07-16T03:30:36 | 2020-07-16T03:31:31 | 284,693 | 0 | 0 | 1 |
Java
| false | false |
package com.google.code.fqueue;
import com.google.code.fqueue.exception.FileEOFException;
import com.google.code.fqueue.exception.FileFormatException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.AbstractQueue;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
/**
* Author: shushenglin
* Date: 2017/12/11 17:05
*/
public class FBlockingQueue extends AbstractQueue<byte[]> implements BlockingQueue<byte[]> {
public static final int LOG_FILE_SIZE = 1024 * 1024 * 300;
private FSQueue fsQueue = null;
private static final Logger log = LoggerFactory.getLogger(FBlockingQueue.class);
private ReentrantLock lock = new ReentrantLock();
private Condition notEmpty = lock.newCondition();
public FBlockingQueue(String path, ScheduledExecutorService executorService) throws Exception {
fsQueue = new FSQueue(path, LOG_FILE_SIZE, executorService);
}
public FBlockingQueue(String path, int logSize, ScheduledExecutorService executorService) throws Exception {
fsQueue = new FSQueue(path, logSize, executorService);
}
@Override
public Iterator<byte[]> iterator() {
throw new UnsupportedOperationException("iterator Unsupported now");
}
@Override
public int size() {
return fsQueue.getQueueSize();
}
@Override
public boolean offer(byte[] e) {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lock();
try {
return enqueue(e);
} finally {
lock.unlock();
}
}
private boolean enqueue(byte[] e) {
try {
fsQueue.add(e);
notEmpty.signal();
return true;
} catch (IOException ex) {
log.error("enqueue element error", ex);
} catch (FileFormatException ex) {
log.error("enqueue element error", ex);
}
return false;
}
@Override
public byte[] peek() {
try {
lock.lock();
return fsQueue.peek();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
} finally {
lock.unlock();
}
}
@Override
public byte[] poll() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
return dequeue();
} finally {
lock.unlock();
}
}
private byte[] dequeue(){
try {
return fsQueue.readNextAndRemove();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
}
}
public void close() {
if (fsQueue != null) {
fsQueue.close();
}
}
@Override
public void put(byte[] e) throws InterruptedException {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
enqueue(e);
} finally {
lock.unlock();
}
}
/**
* remove the first element and return null
*
* @return always return null
*/
public byte[] remove() {
try {
lock.lock();
fsQueue.remove();
} catch (FileEOFException e) {
log.error(e.getMessage(), e);
} finally {
lock.unlock();
}
return null;
}
@Override
public boolean offer(byte[] e, long timeout, TimeUnit unit) throws InterruptedException {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
return enqueue(e);
} finally {
lock.unlock();
}
}
public byte[] peekOrWait() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0)
notEmpty.await();
return fsQueue.peek();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
} finally {
lock.unlock();
}
}
@Override
public byte[] take() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0)
notEmpty.await();
return dequeue();
} finally {
lock.unlock();
}
}
@Override
public byte[] poll(long timeout, TimeUnit unit) throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
return dequeue();
} finally {
lock.unlock();
}
}
@Override
public int remainingCapacity() {
return size();
}
@Override
public int drainTo(Collection<? super byte[]> c) {
return drainTo(c,Integer.MAX_VALUE);
}
@Override
public int drainTo(Collection<? super byte[]> c, int maxElements) {
checkNotNull(c);
if (maxElements <= 0)
return 0;
final ReentrantLock lock = this.lock;
lock.lock();
try{
int n = Math.min(maxElements, size());
int i = 0;
while (i < n) {
byte[] bytes = dequeue();
if (bytes != null) {
c.add(bytes);
}else {
break;
}
i++;
}
return i;
}finally {
lock.unlock();
}
}
private static void checkNotNull(Object v) {
if (v == null)
throw new NullPointerException();
}
}
|
UTF-8
|
Java
| 5,252 |
java
|
FBlockingQueue.java
|
Java
|
[
{
"context": "il.concurrent.locks.ReentrantLock;\n\n/**\n * Author: shushenglin\n * Date: 2017/12/11 17:05\n */\npublic class FBlo",
"end": 582,
"score": 0.9996882677078247,
"start": 571,
"tag": "USERNAME",
"value": "shushenglin"
}
] | null |
[] |
package com.google.code.fqueue;
import com.google.code.fqueue.exception.FileEOFException;
import com.google.code.fqueue.exception.FileFormatException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.AbstractQueue;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
/**
* Author: shushenglin
* Date: 2017/12/11 17:05
*/
public class FBlockingQueue extends AbstractQueue<byte[]> implements BlockingQueue<byte[]> {
public static final int LOG_FILE_SIZE = 1024 * 1024 * 300;
private FSQueue fsQueue = null;
private static final Logger log = LoggerFactory.getLogger(FBlockingQueue.class);
private ReentrantLock lock = new ReentrantLock();
private Condition notEmpty = lock.newCondition();
public FBlockingQueue(String path, ScheduledExecutorService executorService) throws Exception {
fsQueue = new FSQueue(path, LOG_FILE_SIZE, executorService);
}
public FBlockingQueue(String path, int logSize, ScheduledExecutorService executorService) throws Exception {
fsQueue = new FSQueue(path, logSize, executorService);
}
@Override
public Iterator<byte[]> iterator() {
throw new UnsupportedOperationException("iterator Unsupported now");
}
@Override
public int size() {
return fsQueue.getQueueSize();
}
@Override
public boolean offer(byte[] e) {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lock();
try {
return enqueue(e);
} finally {
lock.unlock();
}
}
private boolean enqueue(byte[] e) {
try {
fsQueue.add(e);
notEmpty.signal();
return true;
} catch (IOException ex) {
log.error("enqueue element error", ex);
} catch (FileFormatException ex) {
log.error("enqueue element error", ex);
}
return false;
}
@Override
public byte[] peek() {
try {
lock.lock();
return fsQueue.peek();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
} finally {
lock.unlock();
}
}
@Override
public byte[] poll() {
final ReentrantLock lock = this.lock;
lock.lock();
try {
return dequeue();
} finally {
lock.unlock();
}
}
private byte[] dequeue(){
try {
return fsQueue.readNextAndRemove();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
}
}
public void close() {
if (fsQueue != null) {
fsQueue.close();
}
}
@Override
public void put(byte[] e) throws InterruptedException {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
enqueue(e);
} finally {
lock.unlock();
}
}
/**
* remove the first element and return null
*
* @return always return null
*/
public byte[] remove() {
try {
lock.lock();
fsQueue.remove();
} catch (FileEOFException e) {
log.error(e.getMessage(), e);
} finally {
lock.unlock();
}
return null;
}
@Override
public boolean offer(byte[] e, long timeout, TimeUnit unit) throws InterruptedException {
checkNotNull(e);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
return enqueue(e);
} finally {
lock.unlock();
}
}
public byte[] peekOrWait() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0)
notEmpty.await();
return fsQueue.peek();
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
} catch (FileFormatException e) {
log.error(e.getMessage(), e);
return null;
} finally {
lock.unlock();
}
}
@Override
public byte[] take() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0)
notEmpty.await();
return dequeue();
} finally {
lock.unlock();
}
}
@Override
public byte[] poll(long timeout, TimeUnit unit) throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
while (size() == 0) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
return dequeue();
} finally {
lock.unlock();
}
}
@Override
public int remainingCapacity() {
return size();
}
@Override
public int drainTo(Collection<? super byte[]> c) {
return drainTo(c,Integer.MAX_VALUE);
}
@Override
public int drainTo(Collection<? super byte[]> c, int maxElements) {
checkNotNull(c);
if (maxElements <= 0)
return 0;
final ReentrantLock lock = this.lock;
lock.lock();
try{
int n = Math.min(maxElements, size());
int i = 0;
while (i < n) {
byte[] bytes = dequeue();
if (bytes != null) {
c.add(bytes);
}else {
break;
}
i++;
}
return i;
}finally {
lock.unlock();
}
}
private static void checkNotNull(Object v) {
if (v == null)
throw new NullPointerException();
}
}
| 5,252 | 0.669459 | 0.663366 | 245 | 20.436735 | 19.295582 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.228571 | false | false |
13
|
ce4c2587cf7016b9ae804f7f610ec59e32ed0bea
| 38,079,180,051,324 |
f59b530efe83042a31d74b294ef20af9f4354a37
|
/d5manlegacyexport/ma/tools2/io/EndRecognizingInputStream.java
|
59e989d644083281b57755176ce3d6cf0e6fa968
|
[] |
no_license
|
m7a/bp-d5man-legacy
|
https://github.com/m7a/bp-d5man-legacy
|
ff93ab3aef7480cf55d779b6df61918e898e547e
|
80c02648e5e2fcba20fca83925b24c40dcedc9bb
|
refs/heads/master
| 2021-07-06T14:36:31.325000 | 2021-02-05T21:42:41 | 2021-02-05T21:42:41 | 225,728,193 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ma.tools2.io;
import java.util.Arrays;
import java.io.InputStream;
import java.io.IOException;
/**
* Allows you to create a filter stream which ends once the underlying stream
* has sent a specific terminator byte string.
*
* @since Tools 2.1, 2015/10/03
* @author Linux-Fan, Ma_Sys.ma
* @version 1.0.0.0
*/
public class EndRecognizingInputStream extends InputStream {
private final InputStream src;
private final byte[] terminator;
private IOException failure;
private int bpos;
private byte[] last;
public EndRecognizingInputStream(InputStream src, byte[] terminator) {
this.src = src;
this.terminator = terminator;
last = new byte[terminator.length];
failure = null;
bpos = -1;
Arrays.fill(last, (byte)0);
}
@Override
public int read() throws IOException {
if(failure != null)
throw failure;
if(last == null)
return -1; // end of stream
int next = src.read();
if(next == -1) {
try {
src.close();
} catch(IOException ex) {
failure = ex;
throw failure;
}
failure = new IOException("Unexpected end of stream.");
throw failure;
}
last[bpos = ((bpos + 1) % last.length)] = (byte)next;
if(isEnd()) {
last = null;
return -1;
}
return next;
}
private boolean isEnd() {
// the start is one behind me
// consider the pattern to be TEST and the input to be XTEST
// v v v v v v (cursor)
// 0000 -> X000 -> XT00 -> XTE0 -> XTES -> TTES (data)
int j = (bpos + 1) % last.length;
for(int i = 0; i < last.length; i++) {
if(last[j] != terminator[i])
return false;
j = (j + 1) % last.length;
}
return true;
}
@Override
public void close() throws IOException {
if(last != null) {
try {
while(read() != -1)
;
} catch(IOException ex) {
// Ignore errors which occur if the output is
// not wanted anyway.
}
}
// src deliberately not closed!
super.close();
}
}
|
UTF-8
|
Java
| 1,990 |
java
|
EndRecognizingInputStream.java
|
Java
|
[
{
"context": "ing.\n *\n * @since Tools 2.1, 2015/10/03\n * @author Linux-Fan, Ma_Sys.ma\n * @version 1.0.0.0\n */\npublic class E",
"end": 289,
"score": 0.8436418175697327,
"start": 280,
"tag": "NAME",
"value": "Linux-Fan"
},
{
"context": "@since Tools 2.1, 2015/10/03\n * @author Linux-Fan, Ma_Sys.ma\n * @version 1.0.0.0\n */\npublic class EndRecognizi",
"end": 300,
"score": 0.9966924786567688,
"start": 291,
"tag": "USERNAME",
"value": "Ma_Sys.ma"
}
] | null |
[] |
package ma.tools2.io;
import java.util.Arrays;
import java.io.InputStream;
import java.io.IOException;
/**
* Allows you to create a filter stream which ends once the underlying stream
* has sent a specific terminator byte string.
*
* @since Tools 2.1, 2015/10/03
* @author Linux-Fan, Ma_Sys.ma
* @version 1.0.0.0
*/
public class EndRecognizingInputStream extends InputStream {
private final InputStream src;
private final byte[] terminator;
private IOException failure;
private int bpos;
private byte[] last;
public EndRecognizingInputStream(InputStream src, byte[] terminator) {
this.src = src;
this.terminator = terminator;
last = new byte[terminator.length];
failure = null;
bpos = -1;
Arrays.fill(last, (byte)0);
}
@Override
public int read() throws IOException {
if(failure != null)
throw failure;
if(last == null)
return -1; // end of stream
int next = src.read();
if(next == -1) {
try {
src.close();
} catch(IOException ex) {
failure = ex;
throw failure;
}
failure = new IOException("Unexpected end of stream.");
throw failure;
}
last[bpos = ((bpos + 1) % last.length)] = (byte)next;
if(isEnd()) {
last = null;
return -1;
}
return next;
}
private boolean isEnd() {
// the start is one behind me
// consider the pattern to be TEST and the input to be XTEST
// v v v v v v (cursor)
// 0000 -> X000 -> XT00 -> XTE0 -> XTES -> TTES (data)
int j = (bpos + 1) % last.length;
for(int i = 0; i < last.length; i++) {
if(last[j] != terminator[i])
return false;
j = (j + 1) % last.length;
}
return true;
}
@Override
public void close() throws IOException {
if(last != null) {
try {
while(read() != -1)
;
} catch(IOException ex) {
// Ignore errors which occur if the output is
// not wanted anyway.
}
}
// src deliberately not closed!
super.close();
}
}
| 1,990 | 0.607538 | 0.58995 | 92 | 20.630434 | 18.454243 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.98913 | false | false |
13
|
ba738f4ea39ae5d2c62006806a189cbe0e5a8ddf
| 32,358,283,611,314 |
63672504035ac3c9984950b4e8a9acd813783922
|
/MapReduce/java/mapper/Job_Context_implemented.java
|
cecadcc1911a0034ee5ec127bdf5adfa6fc56d2b
|
[] |
no_license
|
ameet20/MapReduce
|
https://github.com/ameet20/MapReduce
|
aa68b12fba4483216364de24bf16517cf6c403c0
|
3553bfd965f51668dbeeb3d71efa4f5f21887c8b
|
refs/heads/master
| 2021-07-20T21:09:19.852000 | 2021-07-09T11:31:47 | 2021-07-09T11:31:47 | 162,818,675 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.apache.hadoop.mapred;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.util.Progressable;
/**
* @deprecated Use {@link org.apache.hadoop.mapreduce.JobContext} instead.
*/
@Deprecated
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class JobContextImpl
extends org.apache.hadoop.mapreduce.task.JobContextImpl
implements JobContext {
private JobConf job;
private Progressable progress;
JobContextImpl(JobConf conf, org.apache.hadoop.mapreduce.JobID jobId,
Progressable progress) {
super(conf, jobId);
this.job = conf;
this.progress = progress;
}
JobContextImpl(JobConf conf, org.apache.hadoop.mapreduce.JobID jobId) {
this(conf, jobId, Reporter.NULL);
}
/**
* Get the job Configuration
*
* @return JobConf
*/
public JobConf getJobConf() {
return job;
}
/**
* Get the progress mechanism for reporting progress.
*
* @return progress mechanism
*/
public Progressable getProgressible() {
return progress;
}
}
|
UTF-8
|
Java
| 1,140 |
java
|
Job_Context_implemented.java
|
Java
|
[] | null |
[] |
package org.apache.hadoop.mapred;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.util.Progressable;
/**
* @deprecated Use {@link org.apache.hadoop.mapreduce.JobContext} instead.
*/
@Deprecated
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class JobContextImpl
extends org.apache.hadoop.mapreduce.task.JobContextImpl
implements JobContext {
private JobConf job;
private Progressable progress;
JobContextImpl(JobConf conf, org.apache.hadoop.mapreduce.JobID jobId,
Progressable progress) {
super(conf, jobId);
this.job = conf;
this.progress = progress;
}
JobContextImpl(JobConf conf, org.apache.hadoop.mapreduce.JobID jobId) {
this(conf, jobId, Reporter.NULL);
}
/**
* Get the job Configuration
*
* @return JobConf
*/
public JobConf getJobConf() {
return job;
}
/**
* Get the progress mechanism for reporting progress.
*
* @return progress mechanism
*/
public Progressable getProgressible() {
return progress;
}
}
| 1,140 | 0.714035 | 0.714035 | 47 | 23.25532 | 21.735811 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.382979 | false | false |
13
|
d68940c74eaa77a5314a45dc77b13ed764503210
| 38,362,647,889,591 |
2cc7bc814a0a58f9ecc82cb5852b2783cc09246a
|
/src/server/Resources.java
|
fa2a7f27f38c4552914b58b98460f2abf199ad75
|
[] |
no_license
|
mahdirezaie336/MTankTrouble
|
https://github.com/mahdirezaie336/MTankTrouble
|
e290f78e60383647668c1c8e02093eb42baf0515
|
8d6f7058810a1593565bb44eba490fa39f8a2818
|
refs/heads/master
| 2022-11-30T23:22:34.371000 | 2020-08-11T18:08:09 | 2020-08-11T18:08:09 | 286,459,125 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.LinkedList;
import server.command.CommandException;
/**
* Using Bill Pugh Singleton design pattern, i've created this class.
*
* This class keeps all resources of the server like sessions, games and .... It alse has some
* public static fields which are some resources directory in system. like USERS_PATH.
*
* @author Mahdi
*
*/
public class Resources
{
public static final String USERS_PATH = "./data/server/users/";
public static final String MAPS_PATH = "./maps/";
public static final String IMAGES_PATH = "./images/";
private HashMap<String, Game> games;
private LinkedList<Session> sessions;
/**
* Initializes the collections.
*/
private Resources()
{
games = new HashMap<>();
sessions = new LinkedList<>();
}
/**
* The helper class that keeps the unique instance of the Resources class.
*
* @author Mahdi Rezaie 9728040
*
*/
private static class Helper
{
private static final Resources INSTANCE = new Resources();
}
/**
* Gets the unique instance of this class
* @return The unique instance
*/
public static Resources getInstance()
{
return Helper.INSTANCE;
}
/**
* Checks whether a game is exists.
* @param s The game name
* @return If found returns true.
*/
public boolean gameExists(String s)
{
return games.containsKey(s);
}
/**
* Adds a new game to the game collection.
* @param name The game name
* @param game Tha game
*/
public void addGame(String name, Game game)
{
games.put(name, game);
}
/**
* Gets a game by its name.
* @param gameName The game name
* @return The desired game
*/
public Game getGame(String gameName)
{
return games.get(gameName);
}
/**
* Gets all games names.
* @return The games names array
*/
public String[] getGamesArray()
{
return games.keySet().toArray(new String[games.size()]);
}
/**
* Removes a game from games list.
* @param gameName The game name to remove
*/
public void removeGame(String gameName)
{
games.remove(gameName);
}
/**
* Starts a new session with the connection.
*
* @param connection The session connection
*/
public void startNewSession(Socket connection)
{
Session s = new Session(connection);
sessions.add(s);
Thread t = new Thread(s);
t.start();
}
/**
* Removes a session from sessions list.
* @param s The session to remove.
*/
public void removeSession(Session s)
{
sessions.remove(s);
}
/**
* Checks whether a user is registered.
* @param user The user to be checked
* @return If found returns true.
*/
public boolean userIsRegistered(User user)
{
if(user == null) return false;
return userIsRegistered(user.getUsername());
}
/**
* Checks whether a user is registered.
* @param username Username of the user to be checked
* @return If found returns true.
*/
public boolean userIsRegistered(String username)
{
File file = new File(USERS_PATH + username + ".bin");
return file.exists();
}
/**
* Adds a new users to the users list.
* @param user The new user
* @throws CommandException If user already exists throws this type of exception
* @throws ServerException On any other exceptions throws this type of exception
*/
public void addUser(User user) throws CommandException,ServerException
{
File file = new File(USERS_PATH + user.getUsername() + ".bin");
if(!new File(USERS_PATH).exists()) // Checking existance of users path
new File(USERS_PATH).mkdirs();
if(userIsRegistered(user.getUsername())) // Checking existance of user
throw new CommandException("User is already exists.");
try // Create new file
{
file.createNewFile();
} catch (IOException e1)
{
throw new ServerException(e1.getMessage());
}
try( // Writing user to file
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
)
{
oos.writeObject(user);
}
catch(IOException e)
{
throw new ServerException(e.getMessage());
}
}
/**
* Gets a user specified with username.
* @param username The user name
* @return The desired user
* @throws ServerException On any problems excpet user not found, throws this.
* @throws CommandException If user not found throws this type of exception.
*/
public User getUser(String username) throws ServerException, CommandException
{
try(
FileInputStream fis = new FileInputStream(Resources.USERS_PATH + username + ".bin");
ObjectInputStream ois = new ObjectInputStream(fis);
)
{
return (User) ois.readObject();
}
catch (FileNotFoundException e1)
{
throw new CommandException("User not found!");
}
catch (ClassNotFoundException|IOException e)
{
throw new ServerException(e.getMessage());
}
}
public void removeUser(String username) throws ServerException
{
try
{
Files.delete(new File(USERS_PATH + username + ".bin").toPath());
} catch (IOException e)
{
throw new ServerException(e.getMessage());
}
}
}
|
UTF-8
|
Java
| 5,384 |
java
|
Resources.java
|
Java
|
[
{
"context": "rectory in system. like USERS_PATH.\n * \n * @author Mahdi\n *\n */\npublic class Resources\n{\n\tpublic static fi",
"end": 667,
"score": 0.9986209869384766,
"start": 662,
"tag": "NAME",
"value": "Mahdi"
},
{
"context": " instance of the Resources class.\n\t * \n\t * @author Mahdi Rezaie 9728040\n\t *\n\t */\n\tprivate static class Helper\n\t{\n",
"end": 1192,
"score": 0.9998342394828796,
"start": 1180,
"tag": "NAME",
"value": "Mahdi Rezaie"
},
{
"context": "r specified with username.\n\t * @param username The user name\n\t * @return The desired user\n\t * @throws Ser",
"end": 4468,
"score": 0.8025804758071899,
"start": 4464,
"tag": "NAME",
"value": "user"
},
{
"context": "cified with username.\n\t * @param username The user name\n\t * @return The desired user\n\t * @throws ServerEx",
"end": 4473,
"score": 0.40636077523231506,
"start": 4469,
"tag": "USERNAME",
"value": "name"
}
] | null |
[] |
package server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.LinkedList;
import server.command.CommandException;
/**
* Using Bill Pugh Singleton design pattern, i've created this class.
*
* This class keeps all resources of the server like sessions, games and .... It alse has some
* public static fields which are some resources directory in system. like USERS_PATH.
*
* @author Mahdi
*
*/
public class Resources
{
public static final String USERS_PATH = "./data/server/users/";
public static final String MAPS_PATH = "./maps/";
public static final String IMAGES_PATH = "./images/";
private HashMap<String, Game> games;
private LinkedList<Session> sessions;
/**
* Initializes the collections.
*/
private Resources()
{
games = new HashMap<>();
sessions = new LinkedList<>();
}
/**
* The helper class that keeps the unique instance of the Resources class.
*
* @author <NAME> 9728040
*
*/
private static class Helper
{
private static final Resources INSTANCE = new Resources();
}
/**
* Gets the unique instance of this class
* @return The unique instance
*/
public static Resources getInstance()
{
return Helper.INSTANCE;
}
/**
* Checks whether a game is exists.
* @param s The game name
* @return If found returns true.
*/
public boolean gameExists(String s)
{
return games.containsKey(s);
}
/**
* Adds a new game to the game collection.
* @param name The game name
* @param game Tha game
*/
public void addGame(String name, Game game)
{
games.put(name, game);
}
/**
* Gets a game by its name.
* @param gameName The game name
* @return The desired game
*/
public Game getGame(String gameName)
{
return games.get(gameName);
}
/**
* Gets all games names.
* @return The games names array
*/
public String[] getGamesArray()
{
return games.keySet().toArray(new String[games.size()]);
}
/**
* Removes a game from games list.
* @param gameName The game name to remove
*/
public void removeGame(String gameName)
{
games.remove(gameName);
}
/**
* Starts a new session with the connection.
*
* @param connection The session connection
*/
public void startNewSession(Socket connection)
{
Session s = new Session(connection);
sessions.add(s);
Thread t = new Thread(s);
t.start();
}
/**
* Removes a session from sessions list.
* @param s The session to remove.
*/
public void removeSession(Session s)
{
sessions.remove(s);
}
/**
* Checks whether a user is registered.
* @param user The user to be checked
* @return If found returns true.
*/
public boolean userIsRegistered(User user)
{
if(user == null) return false;
return userIsRegistered(user.getUsername());
}
/**
* Checks whether a user is registered.
* @param username Username of the user to be checked
* @return If found returns true.
*/
public boolean userIsRegistered(String username)
{
File file = new File(USERS_PATH + username + ".bin");
return file.exists();
}
/**
* Adds a new users to the users list.
* @param user The new user
* @throws CommandException If user already exists throws this type of exception
* @throws ServerException On any other exceptions throws this type of exception
*/
public void addUser(User user) throws CommandException,ServerException
{
File file = new File(USERS_PATH + user.getUsername() + ".bin");
if(!new File(USERS_PATH).exists()) // Checking existance of users path
new File(USERS_PATH).mkdirs();
if(userIsRegistered(user.getUsername())) // Checking existance of user
throw new CommandException("User is already exists.");
try // Create new file
{
file.createNewFile();
} catch (IOException e1)
{
throw new ServerException(e1.getMessage());
}
try( // Writing user to file
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
)
{
oos.writeObject(user);
}
catch(IOException e)
{
throw new ServerException(e.getMessage());
}
}
/**
* Gets a user specified with username.
* @param username The user name
* @return The desired user
* @throws ServerException On any problems excpet user not found, throws this.
* @throws CommandException If user not found throws this type of exception.
*/
public User getUser(String username) throws ServerException, CommandException
{
try(
FileInputStream fis = new FileInputStream(Resources.USERS_PATH + username + ".bin");
ObjectInputStream ois = new ObjectInputStream(fis);
)
{
return (User) ois.readObject();
}
catch (FileNotFoundException e1)
{
throw new CommandException("User not found!");
}
catch (ClassNotFoundException|IOException e)
{
throw new ServerException(e.getMessage());
}
}
public void removeUser(String username) throws ServerException
{
try
{
Files.delete(new File(USERS_PATH + username + ".bin").toPath());
} catch (IOException e)
{
throw new ServerException(e.getMessage());
}
}
}
| 5,378 | 0.683507 | 0.681649 | 229 | 22.510918 | 23.099672 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.790393 | false | false |
13
|
9b576077b952bef8d39348e0ecbcf0653fa9053a
| 6,734,508,782,746 |
4417886f50f85f3348a44b417e57c1ecac9930a4
|
/src/main/java/com/sliu/framework/app/cache/service/CacheService.java
|
e7f7f55e519fbc74fa1357295dbbeb79a7d3b736
|
[] |
no_license
|
itxiaojian/wechatpf
|
https://github.com/itxiaojian/wechatpf
|
1fcf2ecc783c36c5c84d8408d78639de22263bde
|
bdf2b36c9733b1125feabb5d078e84f51034f718
|
refs/heads/master
| 2021-01-19T20:55:50.196000 | 2017-04-19T02:20:35 | 2017-04-19T02:20:35 | 88,578,665 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sliu.framework.app.cache.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;
import com.sliu.framework.app.support.weixin.WeixinCacheUtils;
@Service
public class CacheService {
private Logger logger = LoggerFactory.getLogger(CacheService.class);
@Autowired
private CacheManager cacheManager;
@SuppressWarnings("unchecked")
public List<Map<String, Object>> getWxCacheList() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Cache cache = cacheManager.getCache(WeixinCacheUtils.WX_CACHE_NAME);
ConcurrentMap<String, Map<String, String>> store = (ConcurrentMap<String, Map<String, String>>)cache.getNativeCache();
Set<String> keySet = store.keySet();
Iterator<String> iterator=keySet.iterator();
while(iterator.hasNext()){
Map<String, Object> map = new HashMap<String, Object>();
String key=(String)iterator.next();
ValueWrapper valueWrapper = cache.get(key);
map.put("key", key);
map.put("value", valueWrapper.get());
list.add(map);
}
return list;
}
/**
* 清除缓存
* @param keys
* @return
*/
public void evictCache(String[] keys) {
Cache cache = cacheManager.getCache(WeixinCacheUtils.WX_CACHE_NAME);
for(int i =0; i<keys.length; i++) {
String key = keys[i];
cache.evict(key);
logger.info("成功清除KEY--【{}】的缓存", key);
}
}
}
|
UTF-8
|
Java
| 1,875 |
java
|
CacheService.java
|
Java
|
[] | null |
[] |
package com.sliu.framework.app.cache.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;
import com.sliu.framework.app.support.weixin.WeixinCacheUtils;
@Service
public class CacheService {
private Logger logger = LoggerFactory.getLogger(CacheService.class);
@Autowired
private CacheManager cacheManager;
@SuppressWarnings("unchecked")
public List<Map<String, Object>> getWxCacheList() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Cache cache = cacheManager.getCache(WeixinCacheUtils.WX_CACHE_NAME);
ConcurrentMap<String, Map<String, String>> store = (ConcurrentMap<String, Map<String, String>>)cache.getNativeCache();
Set<String> keySet = store.keySet();
Iterator<String> iterator=keySet.iterator();
while(iterator.hasNext()){
Map<String, Object> map = new HashMap<String, Object>();
String key=(String)iterator.next();
ValueWrapper valueWrapper = cache.get(key);
map.put("key", key);
map.put("value", valueWrapper.get());
list.add(map);
}
return list;
}
/**
* 清除缓存
* @param keys
* @return
*/
public void evictCache(String[] keys) {
Cache cache = cacheManager.getCache(WeixinCacheUtils.WX_CACHE_NAME);
for(int i =0; i<keys.length; i++) {
String key = keys[i];
cache.evict(key);
logger.info("成功清除KEY--【{}】的缓存", key);
}
}
}
| 1,875 | 0.713899 | 0.712277 | 61 | 28.311476 | 24.417503 | 120 | true | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.918033 | false | false |
13
|
ae10d499845be929843b837fc5c1c2bb66a1c1fb
| 27,221,502,729,077 |
6409996a6813b40c9c2e4b561108790386a4e9dc
|
/Documentação-PI/ProjetoMulaCar/src/br/com/pi/dal/MarcasDal.java
|
c33f30dd9c985609274de49b363d9f2e8661c93e
|
[
"MIT"
] |
permissive
|
MiguellNeto/Projeto-Locacao-Veiculo
|
https://github.com/MiguellNeto/Projeto-Locacao-Veiculo
|
7bb643c67395cb1044a85fc547e972356457f0a8
|
34de3c7d3150a47fae79aab4efaa3f229bd72f72
|
refs/heads/main
| 2023-03-26T11:35:17.690000 | 2021-03-19T16:45:53 | 2021-03-19T16:45:53 | 349,489,091 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* -------------------------------------------------------------------------------------------------->
* Licença : MIT - Copyright 2019 Jhonathan, Gustavo e Miguel
* Criado em : 23/11/2020 19:39:24
* Instituição: FACULDADE SENAI FATESG
* Curso : Análise e Desenvolvimento de sistemas - Módulo 3 - 2020/11
* Disciplina : Projeto Integrador
* Alunos : Jhonathan dos Reis, Gustavo Gabriel e Miguel Neto
* Projeto : Projeto Locação de Veículos
* Exercício : Mula Car
* ---------------------------------------------------------------------------------------------------
* Propósito do arquivo:
* ---------------------------------------------------------------------------------------------------|
*/
package br.com.pi.dal;
import br.com.pi.model.Marcas;
import br.com.pi.util.Conexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
/**
*
* @author jhonlinux
*/
public class MarcasDal {
//--- ATRIBUTOS ----------------------------------------------------------------------------------->
//
private Connection conexao;
//--- FIM ATRIBUTOS -------------------------------------------------------------------------------|
//
//--- CONSTRUTORES -------------------------------------------------------------------------------->
//
public MarcasDal() throws Exception {
conexao = Conexao.getConexao();
}
//--- FIM CONSTRUTORES ----------------------------------------------------------------------------|
//
//--- CREATE -------------------------------------------------------------------------------------->
//
public void addMarcas(Marcas marca) throws Exception {
String sql = "INSERT INTO marcas (mar_nome) VALUES (?)";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, marca.getNome());
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM CREATE ----------------------------------------------------------------------------------|
//
//--- UPDATE -------------------------------------------------------------------------------------->
//
public void updateMarcas(Marcas marca) throws Exception {
String sql = "UPDATE marcas SET mar_nome=? WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, marca.getNome());
preparedStatement.setInt(2, marca.getIden());
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM UPDATE ----------------------------------------------------------------------------------|
//
//--- DELETE -------------------------------------------------------------------------------------->
//
public void deleteMarcas(int mar_iden) throws Exception {
String sql = "DELETE FROM marcas WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setInt(1, mar_iden);
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM DELETE ----------------------------------------------------------------------------------|
//
//--- READ ---------------------------------------------------------------------------------------->
//
public ArrayList<Marcas> getAllMarcas() throws Exception {
ArrayList<Marcas> lista = new ArrayList<Marcas>();
String sql = "SELECT * FROM marcas";
try {
Statement statement = conexao.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
Marcas marca = new Marcas();
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
lista.add(marca);
}
} catch (Exception error) {
throw error;
}
return lista;
}
public Marcas getMarcasById(int mar_iden) throws Exception {
Marcas marca = new Marcas();
String sql = "SELECT * FROM marcas WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setInt(1, mar_iden);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
}
} catch (Exception error) {
throw error;
}
return marca;
}
public Marcas getMarcarByNome(String nome) throws Exception {
Marcas marca = new Marcas();
String sql = "SELECT * FROM marcas WHERE mar_nome=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, nome);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
}
} catch (Exception error) {
throw error;
}
return marca;
}
//--- FIM READ ------------------------------------------------------------------------------------|
//
}
|
UTF-8
|
Java
| 5,821 |
java
|
MarcasDal.java
|
Java
|
[
{
"context": "----------->\n * Licença : MIT - Copyright 2019 Jhonathan, Gustavo e Miguel \n * Criado em : 23/11/2020 19",
"end": 154,
"score": 0.9998909831047058,
"start": 145,
"tag": "NAME",
"value": "Jhonathan"
},
{
"context": ">\n * Licença : MIT - Copyright 2019 Jhonathan, Gustavo e Miguel \n * Criado em : 23/11/2020 19:39:24 \n ",
"end": 163,
"score": 0.9985799193382263,
"start": 156,
"tag": "NAME",
"value": "Gustavo"
},
{
"context": "nça : MIT - Copyright 2019 Jhonathan, Gustavo e Miguel \n * Criado em : 23/11/2020 19:39:24 \n * Instit",
"end": 172,
"score": 0.9981119632720947,
"start": 166,
"tag": "NAME",
"value": "Miguel"
},
{
"context": " Disciplina : Projeto Integrador\n * Alunos : Jhonathan dos Reis, Gustavo Gabriel e Miguel Neto\n * Projeto : P",
"end": 399,
"score": 0.9998958110809326,
"start": 381,
"tag": "NAME",
"value": "Jhonathan dos Reis"
},
{
"context": "to Integrador\n * Alunos : Jhonathan dos Reis, Gustavo Gabriel e Miguel Neto\n * Projeto : Projeto Locação de",
"end": 416,
"score": 0.9998828768730164,
"start": 401,
"tag": "NAME",
"value": "Gustavo Gabriel"
},
{
"context": "Alunos : Jhonathan dos Reis, Gustavo Gabriel e Miguel Neto\n * Projeto : Projeto Locação de Veículos\n * ",
"end": 430,
"score": 0.9998376965522766,
"start": 419,
"tag": "NAME",
"value": "Miguel Neto"
},
{
"context": " : Projeto Locação de Veículos\n * Exercício : Mula Car\n * ---------------------------------------------",
"end": 501,
"score": 0.9995360970497131,
"start": 493,
"tag": "NAME",
"value": "Mula Car"
},
{
"context": "nt;\nimport java.util.ArrayList;\n\n/**\n *\n * @author jhonlinux\n */\npublic class MarcasDal {\n\n //--- ATRIBUTOS",
"end": 1002,
"score": 0.9996097087860107,
"start": 993,
"tag": "USERNAME",
"value": "jhonlinux"
}
] | null |
[] |
/*
* -------------------------------------------------------------------------------------------------->
* Licença : MIT - Copyright 2019 Jhonathan, Gustavo e Miguel
* Criado em : 23/11/2020 19:39:24
* Instituição: FACULDADE SENAI FATESG
* Curso : Análise e Desenvolvimento de sistemas - Módulo 3 - 2020/11
* Disciplina : Projeto Integrador
* Alunos : <NAME>, <NAME> e <NAME>
* Projeto : Projeto Locação de Veículos
* Exercício : <NAME>
* ---------------------------------------------------------------------------------------------------
* Propósito do arquivo:
* ---------------------------------------------------------------------------------------------------|
*/
package br.com.pi.dal;
import br.com.pi.model.Marcas;
import br.com.pi.util.Conexao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
/**
*
* @author jhonlinux
*/
public class MarcasDal {
//--- ATRIBUTOS ----------------------------------------------------------------------------------->
//
private Connection conexao;
//--- FIM ATRIBUTOS -------------------------------------------------------------------------------|
//
//--- CONSTRUTORES -------------------------------------------------------------------------------->
//
public MarcasDal() throws Exception {
conexao = Conexao.getConexao();
}
//--- FIM CONSTRUTORES ----------------------------------------------------------------------------|
//
//--- CREATE -------------------------------------------------------------------------------------->
//
public void addMarcas(Marcas marca) throws Exception {
String sql = "INSERT INTO marcas (mar_nome) VALUES (?)";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, marca.getNome());
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM CREATE ----------------------------------------------------------------------------------|
//
//--- UPDATE -------------------------------------------------------------------------------------->
//
public void updateMarcas(Marcas marca) throws Exception {
String sql = "UPDATE marcas SET mar_nome=? WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, marca.getNome());
preparedStatement.setInt(2, marca.getIden());
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM UPDATE ----------------------------------------------------------------------------------|
//
//--- DELETE -------------------------------------------------------------------------------------->
//
public void deleteMarcas(int mar_iden) throws Exception {
String sql = "DELETE FROM marcas WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setInt(1, mar_iden);
preparedStatement.executeUpdate();
} catch (Exception error) {
throw error;
}
}
//--- FIM DELETE ----------------------------------------------------------------------------------|
//
//--- READ ---------------------------------------------------------------------------------------->
//
public ArrayList<Marcas> getAllMarcas() throws Exception {
ArrayList<Marcas> lista = new ArrayList<Marcas>();
String sql = "SELECT * FROM marcas";
try {
Statement statement = conexao.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
Marcas marca = new Marcas();
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
lista.add(marca);
}
} catch (Exception error) {
throw error;
}
return lista;
}
public Marcas getMarcasById(int mar_iden) throws Exception {
Marcas marca = new Marcas();
String sql = "SELECT * FROM marcas WHERE mar_iden=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setInt(1, mar_iden);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
}
} catch (Exception error) {
throw error;
}
return marca;
}
public Marcas getMarcarByNome(String nome) throws Exception {
Marcas marca = new Marcas();
String sql = "SELECT * FROM marcas WHERE mar_nome=?";
try {
PreparedStatement preparedStatement = conexao.prepareStatement(sql);
preparedStatement.setString(1, nome);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
marca.setIden(rs.getInt("mar_iden"));
marca.setNome(rs.getString("mar_nome"));
}
} catch (Exception error) {
throw error;
}
return marca;
}
//--- FIM READ ------------------------------------------------------------------------------------|
//
}
| 5,793 | 0.427465 | 0.42213 | 163 | 34.650307 | 31.303293 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.423313 | false | false |
13
|
0d75bef4ad3cb7a6778e58fbbe9d62092ea7a17b
| 31,078,383,411,140 |
e9b56cba0c99ccaa7ffd885a55c75868062734ed
|
/src/Execution/Matrix.java
|
a061895abb6e31b223864fc93f03ae3342b89c74
|
[] |
no_license
|
SamirBoulil/pred_experimentation
|
https://github.com/SamirBoulil/pred_experimentation
|
21828a767ecf7a002fe9bac4e7edf3fa80f18406
|
808e52e5fc8d986ccf66bee876fc187465cf28a2
|
refs/heads/master
| 2020-08-28T00:31:56.491000 | 2013-01-05T18:45:11 | 2013-01-05T18:45:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package Execution;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import Csv.DaoConcept;
import Csv.Format;
import Csv.FormatFactory;
import Dissimilarity.Dissimilarity;
import Dissimilarity.DissimilarityFactory;
import Dissimilarity.Jaccard;
public class Matrix {
// TODO : corriger les phrases
/**
* @param args
* args[0] is the name of the dissimilarity selected. It could be "jaccard" or "cosinus".
* args[1] is the format of output. It could be "orange" or "R".
* args[2] is the column where is the concept. It's based on 0-index (0 equals "the first column is the concept). Following words are the context. Previous words are ignored.
* args[3] is a boolean to specify whether or not it considers "null" words in the context.
*
*/
public static void main(String[] args) {
// load arguments
Dissimilarity dissimilarity = null;
Format fileFormat = null;
try {
dissimilarity = DissimilarityFactory.create(args[0]);
fileFormat = FormatFactory.create(args[1]);
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
int columnConcept = Integer.parseInt(args[2]);
boolean nullWord = Boolean.parseBoolean(args[3]);
// load matrix (concatenation)
long before = System.currentTimeMillis();
List<List<Word>> datas = DaoConcept.loadConcepts('|', columnConcept, nullWord );
System.out.println("load done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
// compute the matrix dissimilarity
Matrix conceptMatrix = new Matrix(dissimilarity);
List<String[]> dissMatrix = conceptMatrix.getMatrix(datas);
System.out.println("matrix done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
// write concepts depending on the format file specified in argument
if(fileFormat != null){
List<String[]> result = fileFormat.transform(dissMatrix);
DaoConcept.writeConcepts("matrix", result);
}
System.out.println("write done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
}
private Dissimilarity dissimilarity;
public Matrix(Dissimilarity dissimilarity) {
this.dissimilarity = dissimilarity;
}
public List<String[]> getMatrix(List<List<Word>> datas){
String[][] dissimilarities = new String[datas.size()+1][datas.size()+1];
dissimilarities[0][0] = "";
for(int i=0 ; i < datas.size() ; i++)
dissimilarities[0][i+1] = datas.get(i).get(0).getValue();
for(int i=0 ; i < datas.size() ; i++){
dissimilarities[i+1][0] = datas.get(i).get(0).getValue();
for(int j=0 ; j<i+1 ; j++){
Double dissValue = new Double(dissimilarity.getValue(datas.get(i), datas.get(j)));
dissimilarities[i+1][j+1] = dissValue.toString();
dissimilarities[j+1][i+1] = dissValue.toString();
}
}
return new ArrayList<String[]>(Arrays.asList(dissimilarities));
}
public Dissimilarity getDissimilarity() {
return dissimilarity;
}
public void setDissimilarity(Dissimilarity dissimilarity) {
this.dissimilarity = dissimilarity;
}
}
|
UTF-8
|
Java
| 3,043 |
java
|
Matrix.java
|
Java
|
[] | null |
[] |
package Execution;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import Csv.DaoConcept;
import Csv.Format;
import Csv.FormatFactory;
import Dissimilarity.Dissimilarity;
import Dissimilarity.DissimilarityFactory;
import Dissimilarity.Jaccard;
public class Matrix {
// TODO : corriger les phrases
/**
* @param args
* args[0] is the name of the dissimilarity selected. It could be "jaccard" or "cosinus".
* args[1] is the format of output. It could be "orange" or "R".
* args[2] is the column where is the concept. It's based on 0-index (0 equals "the first column is the concept). Following words are the context. Previous words are ignored.
* args[3] is a boolean to specify whether or not it considers "null" words in the context.
*
*/
public static void main(String[] args) {
// load arguments
Dissimilarity dissimilarity = null;
Format fileFormat = null;
try {
dissimilarity = DissimilarityFactory.create(args[0]);
fileFormat = FormatFactory.create(args[1]);
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
int columnConcept = Integer.parseInt(args[2]);
boolean nullWord = Boolean.parseBoolean(args[3]);
// load matrix (concatenation)
long before = System.currentTimeMillis();
List<List<Word>> datas = DaoConcept.loadConcepts('|', columnConcept, nullWord );
System.out.println("load done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
// compute the matrix dissimilarity
Matrix conceptMatrix = new Matrix(dissimilarity);
List<String[]> dissMatrix = conceptMatrix.getMatrix(datas);
System.out.println("matrix done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
// write concepts depending on the format file specified in argument
if(fileFormat != null){
List<String[]> result = fileFormat.transform(dissMatrix);
DaoConcept.writeConcepts("matrix", result);
}
System.out.println("write done");
System.out.println((System.currentTimeMillis() - before) / 1000.0);
}
private Dissimilarity dissimilarity;
public Matrix(Dissimilarity dissimilarity) {
this.dissimilarity = dissimilarity;
}
public List<String[]> getMatrix(List<List<Word>> datas){
String[][] dissimilarities = new String[datas.size()+1][datas.size()+1];
dissimilarities[0][0] = "";
for(int i=0 ; i < datas.size() ; i++)
dissimilarities[0][i+1] = datas.get(i).get(0).getValue();
for(int i=0 ; i < datas.size() ; i++){
dissimilarities[i+1][0] = datas.get(i).get(0).getValue();
for(int j=0 ; j<i+1 ; j++){
Double dissValue = new Double(dissimilarity.getValue(datas.get(i), datas.get(j)));
dissimilarities[i+1][j+1] = dissValue.toString();
dissimilarities[j+1][i+1] = dissValue.toString();
}
}
return new ArrayList<String[]>(Arrays.asList(dissimilarities));
}
public Dissimilarity getDissimilarity() {
return dissimilarity;
}
public void setDissimilarity(Dissimilarity dissimilarity) {
this.dissimilarity = dissimilarity;
}
}
| 3,043 | 0.705225 | 0.690766 | 109 | 26.917431 | 29.397038 | 175 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.642202 | false | false |
13
|
5a54da1a633fb24ede896805de8a385486ddb657
| 2,405,181,754,154 |
525f18f80f0a1df6598629f606432568681bd9b1
|
/src/main/java/com/shootbot/mtgmonkey/model/DeckFinish.java
|
611e15ff35dfa5265ddd6eb53504314678c54551
|
[] |
no_license
|
shootbot/MTG-Monkey
|
https://github.com/shootbot/MTG-Monkey
|
27a9a2adac063413d43706996d4ca82295e3d8b4
|
f0174eba65ada4361158f24e8552df6543c6a44a
|
refs/heads/master
| 2018-12-04T17:17:29.963000 | 2018-11-18T19:05:41 | 2018-11-18T19:05:41 | 11,025,877 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.shootbot.mtgmonkey.model;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class DeckFinish {
private Decklist decklist;
private String archetype;
private LocalDate date;
private String tourneyName;
private String player;
private String result;
private String format;
private String name;
private String url;
private static final DateTimeFormatter formatter;
static {
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
}
public DeckFinish(String result, Decklist decklist, String name, String player) {
this.result = result;
this.decklist = decklist;
this.name = name;
this.player = player;
}
public LocalDate getDate() {
return date;
}
public String getPlacing() {
return result;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public void setDate(String date) {
this.date = LocalDate.parse(date, formatter);
}
public String getTourneyName() {
return tourneyName;
}
public void setTourneyName(String tourneyName) {
this.tourneyName = tourneyName;
}
public Decklist getDecklist() {
return decklist;
}
public String getName() {
return name;
}
}
|
UTF-8
|
Java
| 1,206 |
java
|
DeckFinish.java
|
Java
|
[] | null |
[] |
package com.shootbot.mtgmonkey.model;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class DeckFinish {
private Decklist decklist;
private String archetype;
private LocalDate date;
private String tourneyName;
private String player;
private String result;
private String format;
private String name;
private String url;
private static final DateTimeFormatter formatter;
static {
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
}
public DeckFinish(String result, Decklist decklist, String name, String player) {
this.result = result;
this.decklist = decklist;
this.name = name;
this.player = player;
}
public LocalDate getDate() {
return date;
}
public String getPlacing() {
return result;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public void setDate(String date) {
this.date = LocalDate.parse(date, formatter);
}
public String getTourneyName() {
return tourneyName;
}
public void setTourneyName(String tourneyName) {
this.tourneyName = tourneyName;
}
public Decklist getDecklist() {
return decklist;
}
public String getName() {
return name;
}
}
| 1,206 | 0.732172 | 0.732172 | 64 | 17.84375 | 17.192129 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.421875 | false | false |
13
|
0bbf3f340ab3984d76f1ed8d49df2245b0fda65f
| 14,594,298,933,257 |
4162595179cdd3a5fab6b04cf49611ef516ddabd
|
/java/DesignPattern/src/interpreter/Tester.java
|
cc25ffbfc6db415d6a431660c8dbde2cd932d129
|
[] |
no_license
|
huapuyu/huapuyu
|
https://github.com/huapuyu/huapuyu
|
a3ea2917ac00d2d778aa7151c6826664dff23b9a
|
97939ec19b3ecc953d9de9f7aa7cdeea468b7c33
|
refs/heads/master
| 2020-02-26T20:04:25.083000 | 2019-12-29T07:53:14 | 2019-12-29T07:53:14 | 34,595,945 | 3 | 12 | null | false | 2019-12-27T07:10:51 | 2015-04-26T03:13:35 | 2019-12-27T07:10:37 | 2019-12-27T07:10:50 | 695,456 | 3 | 11 | 13 |
Java
| false | false |
package interpreter;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class Tester
{
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
}
@AfterClass
public static void tearDownAfterClass() throws Exception
{
}
@Before
public void setUp() throws Exception
{
}
@After
public void tearDown() throws Exception
{
}
@Test
public void test()
{
Context context = new Context();
List<AbstractExpression> list = new ArrayList<AbstractExpression>();
list.add(new TerminalExpression());
list.add(new NonterminalExpression());
list.add(new TerminalExpression());
list.add(new TerminalExpression());
for (AbstractExpression abstractExpression : list)
{
abstractExpression.interpret(context);
}
}
}
|
UTF-8
|
Java
| 940 |
java
|
Tester.java
|
Java
|
[] | null |
[] |
package interpreter;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class Tester
{
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
}
@AfterClass
public static void tearDownAfterClass() throws Exception
{
}
@Before
public void setUp() throws Exception
{
}
@After
public void tearDown() throws Exception
{
}
@Test
public void test()
{
Context context = new Context();
List<AbstractExpression> list = new ArrayList<AbstractExpression>();
list.add(new TerminalExpression());
list.add(new NonterminalExpression());
list.add(new TerminalExpression());
list.add(new TerminalExpression());
for (AbstractExpression abstractExpression : list)
{
abstractExpression.interpret(context);
}
}
}
| 940 | 0.705319 | 0.705319 | 49 | 17.224489 | 18.584902 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.142857 | false | false |
13
|
ef454f2df7555a7e4881b05c7ed3555f0a90ed91
| 32,908,039,478,747 |
5b28d7dd37957aeb77ef5a9cc513fe23a2ede3d3
|
/src/com/rvsharma/Hackerrank/ReverseMergeSortB.java
|
5a9ae463e063b6754dc1721105156b8e450d6ad1
|
[] |
no_license
|
rvsharma-cmu/ctci-and-hackerrank-problems
|
https://github.com/rvsharma-cmu/ctci-and-hackerrank-problems
|
266daf038da5385a9c99f2585ca4bb6c9f8f525d
|
2df70e79bebeaa0315d00fd8d2af3a3747bcdcfa
|
refs/heads/master
| 2023-05-27T23:55:58.424000 | 2021-06-09T17:30:05 | 2021-06-09T17:30:05 | 216,147,859 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.rvsharma.Hackerrank;
import java.util.Arrays;
/**
* Merge sort tried in reverse order
* TODO: fix the bug, currently fails on this input array = [1, 3, 2, 7]
* TODO: Output in this case is [7, 7, 7, 7]
*/
public class ReverseMergeSortB {
static int[] MergeSort(int[] values) {
int[] traverseArray = new int[values.length];
mergeSortHelper(values, traverseArray, 0, values.length - 1);
System.out.println(Arrays.toString(values));
return values;
}
static void mergeSortHelper(int[] values, int[] traverseArray, int first, int last){
if(first < last){
int middle = (first + last) / 2;
mergeSortHelper(values, traverseArray, first, middle);
mergeSortHelper(values, traverseArray, middle + 1, last);
mergeSortHelper(values, traverseArray, first, middle, last);
}
}
static void mergeSortHelper(int[] values, int[] traverseArray, int first, int middle, int last){
for(int i = first; i <= last; i++){
traverseArray[i] = values[i];
}
int left = first;
int right = middle + 1;
int currentIndex = first;
while(left <= middle && right <= last){
if(traverseArray[right] >= traverseArray[left]){
values[currentIndex] = traverseArray[right];
right++;
} else {
values[currentIndex] = traverseArray[left];
left++;
}
currentIndex++;
}
int remaining = last - right;
for(int i = 0; i <= remaining; i++){
values[currentIndex+i] = traverseArray[right+i];
}
}
}
|
UTF-8
|
Java
| 1,703 |
java
|
ReverseMergeSortB.java
|
Java
|
[] | null |
[] |
package com.rvsharma.Hackerrank;
import java.util.Arrays;
/**
* Merge sort tried in reverse order
* TODO: fix the bug, currently fails on this input array = [1, 3, 2, 7]
* TODO: Output in this case is [7, 7, 7, 7]
*/
public class ReverseMergeSortB {
static int[] MergeSort(int[] values) {
int[] traverseArray = new int[values.length];
mergeSortHelper(values, traverseArray, 0, values.length - 1);
System.out.println(Arrays.toString(values));
return values;
}
static void mergeSortHelper(int[] values, int[] traverseArray, int first, int last){
if(first < last){
int middle = (first + last) / 2;
mergeSortHelper(values, traverseArray, first, middle);
mergeSortHelper(values, traverseArray, middle + 1, last);
mergeSortHelper(values, traverseArray, first, middle, last);
}
}
static void mergeSortHelper(int[] values, int[] traverseArray, int first, int middle, int last){
for(int i = first; i <= last; i++){
traverseArray[i] = values[i];
}
int left = first;
int right = middle + 1;
int currentIndex = first;
while(left <= middle && right <= last){
if(traverseArray[right] >= traverseArray[left]){
values[currentIndex] = traverseArray[right];
right++;
} else {
values[currentIndex] = traverseArray[left];
left++;
}
currentIndex++;
}
int remaining = last - right;
for(int i = 0; i <= remaining; i++){
values[currentIndex+i] = traverseArray[right+i];
}
}
}
| 1,703 | 0.565473 | 0.557252 | 56 | 29.410715 | 26.237089 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.928571 | false | false |
13
|
f70f2731633a9af6344864c0b72d9653248cb1a8
| 13,125,420,074,127 |
9b151da4e82d17d10e2c18c9f53511dbcd423273
|
/src/test/java/pl/edu/agh/ki/to2/crawler/it/CrawlTest.java
|
c06760d61f578c1e524eeb13d7f39caa78f8d4f8
|
[] |
no_license
|
nachteil/frazeusz
|
https://github.com/nachteil/frazeusz
|
7336355fe1ddd4721645ecafffbaf0219b5c8a34
|
ce8274eed4f020146388f103c6c70800a43af063
|
refs/heads/master
| 2021-01-10T07:00:27.178000 | 2016-01-06T09:05:18 | 2016-01-06T09:05:18 | 47,341,538 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pl.edu.agh.ki.to2.crawler.it;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import pl.edu.agh.ki.to2.crawler.downloader.Counter;
import pl.edu.agh.ki.to2.crawler.downloader.Crawler;
import pl.edu.agh.ki.to2.crawler.downloader.DownloadTask;
import pl.edu.agh.ki.to2.crawler.downloader.TaskQueue;
import pl.edu.agh.ki.to2.parser.parsingControl.ParserFile;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* Created by Rav on 2015-12-16.
*/
public class CrawlTest {
Crawler crawler;
DownloadTask downloadTaskMock;
TaskQueue taskQueueMock;
BlockingQueue <DownloadTask> queue = new LinkedBlockingQueue<>();
int counter;
int tasksNum;
int workersPool;
int maxPages;
int maxDepth;
@Before
public void setUpBefore() throws InterruptedException {
counter = 0;
tasksNum = 10;
workersPool = 1;
maxPages = tasksNum;
maxDepth = 10;
List<String> urls = Arrays.asList("http://www.onet.pl");
crawler = new TaskQueueTakingTestCrawler(workersPool, maxPages, maxDepth, urls);
downloadTaskMock = mock(DownloadTask.class);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
synchronized (this) {
System.out.println("IN thread");
counter++;
}
return null;
}
}).when(downloadTaskMock).run();
for(int i = 0; i<tasksNum; i++)
queue.put(downloadTaskMock);
taskQueueMock = crawler.getTaskQueue();
when(taskQueueMock.get()).thenReturn(queue.take());
}
@Test
public void queueTakingTest() throws InterruptedException {
System.out.println("Starting test");
//TODO fix test
// crawler.startCrawling();
// assert(counter == tasksNum);
}
private class TaskQueueTakingTestCrawler extends Crawler{
public TaskQueueTakingTestCrawler(int workersPool, int maxSites, int maxDepth, List<String> urls) {
super(workersPool, maxSites, maxDepth, urls);
}
private TaskQueue makeTaskQueue(BlockingQueue<ParserFile> fileQueue, int maxDepth,
Counter counter, int maxStreamSize){
return mock(TaskQueue.class);
}
public TaskQueue getTaskQueue(){
return mock(TaskQueue.class);
}
}
}
|
UTF-8
|
Java
| 2,731 |
java
|
CrawlTest.java
|
Java
|
[
{
"context": "tatic org.mockito.Mockito.when;\n\n/**\n * Created by Rav on 2015-12-16.\n */\npublic class CrawlTest {\n\n ",
"end": 737,
"score": 0.9924426674842834,
"start": 734,
"tag": "NAME",
"value": "Rav"
}
] | null |
[] |
package pl.edu.agh.ki.to2.crawler.it;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import pl.edu.agh.ki.to2.crawler.downloader.Counter;
import pl.edu.agh.ki.to2.crawler.downloader.Crawler;
import pl.edu.agh.ki.to2.crawler.downloader.DownloadTask;
import pl.edu.agh.ki.to2.crawler.downloader.TaskQueue;
import pl.edu.agh.ki.to2.parser.parsingControl.ParserFile;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* Created by Rav on 2015-12-16.
*/
public class CrawlTest {
Crawler crawler;
DownloadTask downloadTaskMock;
TaskQueue taskQueueMock;
BlockingQueue <DownloadTask> queue = new LinkedBlockingQueue<>();
int counter;
int tasksNum;
int workersPool;
int maxPages;
int maxDepth;
@Before
public void setUpBefore() throws InterruptedException {
counter = 0;
tasksNum = 10;
workersPool = 1;
maxPages = tasksNum;
maxDepth = 10;
List<String> urls = Arrays.asList("http://www.onet.pl");
crawler = new TaskQueueTakingTestCrawler(workersPool, maxPages, maxDepth, urls);
downloadTaskMock = mock(DownloadTask.class);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
synchronized (this) {
System.out.println("IN thread");
counter++;
}
return null;
}
}).when(downloadTaskMock).run();
for(int i = 0; i<tasksNum; i++)
queue.put(downloadTaskMock);
taskQueueMock = crawler.getTaskQueue();
when(taskQueueMock.get()).thenReturn(queue.take());
}
@Test
public void queueTakingTest() throws InterruptedException {
System.out.println("Starting test");
//TODO fix test
// crawler.startCrawling();
// assert(counter == tasksNum);
}
private class TaskQueueTakingTestCrawler extends Crawler{
public TaskQueueTakingTestCrawler(int workersPool, int maxSites, int maxDepth, List<String> urls) {
super(workersPool, maxSites, maxDepth, urls);
}
private TaskQueue makeTaskQueue(BlockingQueue<ParserFile> fileQueue, int maxDepth,
Counter counter, int maxStreamSize){
return mock(TaskQueue.class);
}
public TaskQueue getTaskQueue(){
return mock(TaskQueue.class);
}
}
}
| 2,731 | 0.656536 | 0.648847 | 87 | 30.390804 | 23.897461 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.701149 | false | false |
13
|
f3a66107df28c4c8fd4da573cded3db1c2ca0ee1
| 14,688,788,222,960 |
f5073488baa9b55b7eb586e8535f6a88cfa6dd9c
|
/zhks_exam/src/main/java/com/cd/zj/repository/TblScoreRepository.java
|
fd5570fff36ae24a694cdcae5ea1c1240b37870b
|
[] |
no_license
|
lmy1/zhks
|
https://github.com/lmy1/zhks
|
4e96c25c14066423df660f3d798cc8944051e982
|
c4ff8d6c7cdf6dbbc65a7e32e703339975905cb0
|
refs/heads/master
| 2020-03-22T04:58:28.521000 | 2018-07-03T05:36:29 | 2018-07-03T05:36:29 | 139,533,284 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cd.zj.repository;
import org.springframework.data.repository.CrudRepository;
import com.cd.zj.entity.TblScore;
public interface TblScoreRepository extends CrudRepository<TblScore, Long> {
}
|
UTF-8
|
Java
| 204 |
java
|
TblScoreRepository.java
|
Java
|
[] | null |
[] |
package com.cd.zj.repository;
import org.springframework.data.repository.CrudRepository;
import com.cd.zj.entity.TblScore;
public interface TblScoreRepository extends CrudRepository<TblScore, Long> {
}
| 204 | 0.828431 | 0.828431 | 7 | 28.142857 | 28.098951 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false |
13
|
5c7ac81391131399cb71df02dfb1fb5af5d7000e
| 1,614,907,712,256 |
15716697535f9dec0cd75784f0676dec3087ad39
|
/src/main/java/pl/bogus/hibernate/modul5/App20MultiJoinCartesianAvoid.java
|
78a0b8fde0d504b89b9a20dd7751f6a18fd22c77
|
[] |
no_license
|
jablonskiboguslaw1/HibRepeatSec
|
https://github.com/jablonskiboguslaw1/HibRepeatSec
|
4faf50d76978424d9be70b69a041392ec879f531
|
50362c864c4407d4119c4f235f2a91819f989c83
|
refs/heads/main
| 2023-04-18T21:17:01.683000 | 2021-05-07T12:56:52 | 2021-05-07T12:56:52 | 362,050,339 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pl.bogus.hibernate.modul5;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.QueryHints;
import pl.bogus.hibernate.entity.Category;
import pl.bogus.hibernate.entity.Product;
import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class App20MultiJoinCartesianAvoid {
private static Logger logger = LogManager.getLogger();
private static EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("unit");
public static void main(String[] args) {
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
List<Product> resultList = entityManager.createQuery(
"select distinct p from Product p " +
"left join fetch p.attributes",
Product.class).setHint(QueryHints.PASS_DISTINCT_THROUGH,false).getResultList();
resultList = entityManager.createQuery(
"select distinct p from Product p " +
"left join fetch p.reviews",
Product.class).setHint(QueryHints.PASS_DISTINCT_THROUGH,false).getResultList();
logger.info("size: "+ resultList.size());
for (Product product : resultList) {
logger.info(product);
logger.info(product.getAttributes());
logger.info(product.getReviews());
}
entityManager.getTransaction().commit();
entityManager.close();
}
}
|
UTF-8
|
Java
| 1,593 |
java
|
App20MultiJoinCartesianAvoid.java
|
Java
|
[] | null |
[] |
package pl.bogus.hibernate.modul5;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.QueryHints;
import pl.bogus.hibernate.entity.Category;
import pl.bogus.hibernate.entity.Product;
import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class App20MultiJoinCartesianAvoid {
private static Logger logger = LogManager.getLogger();
private static EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("unit");
public static void main(String[] args) {
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
List<Product> resultList = entityManager.createQuery(
"select distinct p from Product p " +
"left join fetch p.attributes",
Product.class).setHint(QueryHints.PASS_DISTINCT_THROUGH,false).getResultList();
resultList = entityManager.createQuery(
"select distinct p from Product p " +
"left join fetch p.reviews",
Product.class).setHint(QueryHints.PASS_DISTINCT_THROUGH,false).getResultList();
logger.info("size: "+ resultList.size());
for (Product product : resultList) {
logger.info(product);
logger.info(product.getAttributes());
logger.info(product.getReviews());
}
entityManager.getTransaction().commit();
entityManager.close();
}
}
| 1,593 | 0.678594 | 0.675455 | 47 | 32.893616 | 28.409044 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.553191 | false | false |
13
|
0f75680041645922444b70acf02406f5c302cb3f
| 32,753,420,660,774 |
713748aa415d6c351f557ac3e0f68aaa364dfec8
|
/src/com/ruijie/product/log/plugin/IdlePlugin.java
|
52fac385c88e3bcfd82eaed640188fe55b22970a
|
[] |
no_license
|
hellozhuzhuye/elog
|
https://github.com/hellozhuzhuye/elog
|
fbcf4a5f3cea3cc275d853fb7cc8e656bb8a5c6f
|
906688a57cb10f694f7ef387738c2eb36d6827c7
|
refs/heads/master
| 2023-01-02T01:03:28.230000 | 2020-10-27T01:46:57 | 2020-10-27T01:46:57 | 307,553,046 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ruijie.product.log.plugin;
public interface IdlePlugin {
public boolean init();
public boolean start();
public boolean stop();
// @Deprecated
// public boolean destory();
}
|
UTF-8
|
Java
| 196 |
java
|
IdlePlugin.java
|
Java
|
[] | null |
[] |
package com.ruijie.product.log.plugin;
public interface IdlePlugin {
public boolean init();
public boolean start();
public boolean stop();
// @Deprecated
// public boolean destory();
}
| 196 | 0.709184 | 0.709184 | 12 | 15.333333 | 13.356231 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.083333 | false | false |
13
|
a9cde83de6ee42a8227115c61b9bb0adff778fc9
| 32,753,420,663,708 |
88d44d002acdaf618edcefa96f9c147f6f5aaf5f
|
/src/main/java/com/example/S3ReplicationLambdaHandler.java
|
989661e400751faba0f55d35304df088f621edac
|
[
"Apache-2.0"
] |
permissive
|
Laxenade/S3Replicator
|
https://github.com/Laxenade/S3Replicator
|
bf60faba7cd9835ef6f1236c8908ad456ef36838
|
1659a3d063073066244867b316bd1730724c902a
|
refs/heads/master
| 2021-08-17T11:27:30.391000 | 2017-11-21T05:25:08 | 2017-11-21T05:25:08 | 109,354,370 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.event.S3EventNotification;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.CopyObjectRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class S3ReplicationLambdaHandler implements RequestHandler<S3EventNotification, String> {
@Override
public String handleRequest(final S3EventNotification s3Event, final Context context) {
// Logger
final LambdaLogger logger = context.getLogger();
// Parameters
final boolean allowOverwrite = Boolean.valueOf(System.getenv("ALLOW_OVERWRITE"));
final boolean useSSE = Boolean.valueOf(System.getenv("USE_SSE"));
final String destinationBuckets = System.getenv("DESTINATION_BUCKETS");
final String destinationRegion = System.getenv("DESTINATION_REGION");
// Client
final AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withRegion(destinationRegion).build();
// Format Bucket name
final List<String> buckets =
Arrays.stream(destinationBuckets.split(","))
.map(String::trim).filter(bucket -> !bucket.isEmpty()).collect(Collectors.toList());
for (S3EventNotification.S3EventNotificationRecord record : s3Event.getRecords()) {
final String sourceKey = record.getS3().getObject().getKey();
final String sourceBucket = record.getS3().getBucket().getName();
String decodedSourceKey;
// Decode Object Key
try {
decodedSourceKey = java.net.URLDecoder.decode(sourceKey, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(String.format("Failed to decode the key %s.", sourceKey), e);
}
for (String destinationBucket : buckets) {
// Check object existence
if (s3Client.doesObjectExist(destinationBucket, decodedSourceKey) && !allowOverwrite) {
logger.log(
String.format("Object with the key %s already exists in the destination bucket %s, overwrite is not allowed.",
decodedSourceKey, destinationBucket));
} else {
CopyObjectRequest copyObjectRequest =
new CopyObjectRequest(sourceBucket, decodedSourceKey, destinationBucket, decodedSourceKey);
ObjectMetadata objectMetadata = new ObjectMetadata();
// Set SSE if enabled
if (useSSE) {
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
copyObjectRequest.setNewObjectMetadata(objectMetadata);
}
s3Client.copyObject(copyObjectRequest);
}
s3Client.setObjectAcl(destinationBucket, decodedSourceKey, CannedAccessControlList.BucketOwnerFullControl);
}
}
return "success";
}
}
|
UTF-8
|
Java
| 3,510 |
java
|
S3ReplicationLambdaHandler.java
|
Java
|
[] | null |
[] |
package com.example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.event.S3EventNotification;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.CopyObjectRequest;
import com.amazonaws.services.s3.model.ObjectMetadata;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class S3ReplicationLambdaHandler implements RequestHandler<S3EventNotification, String> {
@Override
public String handleRequest(final S3EventNotification s3Event, final Context context) {
// Logger
final LambdaLogger logger = context.getLogger();
// Parameters
final boolean allowOverwrite = Boolean.valueOf(System.getenv("ALLOW_OVERWRITE"));
final boolean useSSE = Boolean.valueOf(System.getenv("USE_SSE"));
final String destinationBuckets = System.getenv("DESTINATION_BUCKETS");
final String destinationRegion = System.getenv("DESTINATION_REGION");
// Client
final AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withRegion(destinationRegion).build();
// Format Bucket name
final List<String> buckets =
Arrays.stream(destinationBuckets.split(","))
.map(String::trim).filter(bucket -> !bucket.isEmpty()).collect(Collectors.toList());
for (S3EventNotification.S3EventNotificationRecord record : s3Event.getRecords()) {
final String sourceKey = record.getS3().getObject().getKey();
final String sourceBucket = record.getS3().getBucket().getName();
String decodedSourceKey;
// Decode Object Key
try {
decodedSourceKey = java.net.URLDecoder.decode(sourceKey, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(String.format("Failed to decode the key %s.", sourceKey), e);
}
for (String destinationBucket : buckets) {
// Check object existence
if (s3Client.doesObjectExist(destinationBucket, decodedSourceKey) && !allowOverwrite) {
logger.log(
String.format("Object with the key %s already exists in the destination bucket %s, overwrite is not allowed.",
decodedSourceKey, destinationBucket));
} else {
CopyObjectRequest copyObjectRequest =
new CopyObjectRequest(sourceBucket, decodedSourceKey, destinationBucket, decodedSourceKey);
ObjectMetadata objectMetadata = new ObjectMetadata();
// Set SSE if enabled
if (useSSE) {
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
copyObjectRequest.setNewObjectMetadata(objectMetadata);
}
s3Client.copyObject(copyObjectRequest);
}
s3Client.setObjectAcl(destinationBucket, decodedSourceKey, CannedAccessControlList.BucketOwnerFullControl);
}
}
return "success";
}
}
| 3,510 | 0.65755 | 0.649573 | 76 | 45.184212 | 36.22543 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.644737 | false | false |
13
|
0e6d64b006c026fbde2382d3ffd18ea392f38a2d
| 9,818,295,244,167 |
6ff3876d901fc1f405f369619058953741733e41
|
/currency-broker-server/src/main/java/app/BrokerConfiguration.java
|
e65fc007802af5f15fd0eaf8e5611c195027c64d
|
[] |
no_license
|
xiaomaixiaomai/spring-currency-broker
|
https://github.com/xiaomaixiaomai/spring-currency-broker
|
4f8517c1fb96d26123649e6501a51ac03b6f6aca
|
444b60d4250b8bfbafe39805a8a107b89f0cbf57
|
refs/heads/master
| 2021-05-27T17:40:07.625000 | 2014-05-23T09:58:53 | 2014-05-23T09:58:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package app;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import service.CurrencyExchangeImpl;
import java.util.Arrays;
@Configuration
@ComponentScan(basePackageClasses = {CurrencyExchangeImpl.class})
@ImportResource({"classpath:app-context.xml"})
@EnableAutoConfiguration
@EnableWebMvc
public class BrokerConfiguration {
@Bean
MetricRegistry metricsRegistry() {
return new MetricRegistry();
}
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(BrokerConfiguration.class);
ConfigurableApplicationContext applicationContext = springApplication.run(args);
JmxReporter.forRegistry(applicationContext.getBean(MetricRegistry.class))
.build()
.start();
}
@Bean
ServletRegistrationBean cxfServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/ws/*");
}
}
|
UTF-8
|
Java
| 1,693 |
java
|
BrokerConfiguration.java
|
Java
|
[] | null |
[] |
package app;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import service.CurrencyExchangeImpl;
import java.util.Arrays;
@Configuration
@ComponentScan(basePackageClasses = {CurrencyExchangeImpl.class})
@ImportResource({"classpath:app-context.xml"})
@EnableAutoConfiguration
@EnableWebMvc
public class BrokerConfiguration {
@Bean
MetricRegistry metricsRegistry() {
return new MetricRegistry();
}
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(BrokerConfiguration.class);
ConfigurableApplicationContext applicationContext = springApplication.run(args);
JmxReporter.forRegistry(applicationContext.getBean(MetricRegistry.class))
.build()
.start();
}
@Bean
ServletRegistrationBean cxfServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/ws/*");
}
}
| 1,693 | 0.795038 | 0.795038 | 48 | 34.270832 | 27.861816 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.479167 | false | false |
13
|
cbe9cf55310044c07e4f37777ae914e4ac0bf515
| 8,452,495,708,578 |
45d40114e3e2513a2dc9ebce6f357282953ef80e
|
/src/main/java/cn/nextop/guava/widgets/datetime/action/actor/text/impl/ShowTextActor.java
|
30b550c6652976eebe7317d1f332d5f5214e78ed
|
[] |
no_license
|
jonnychu/guava
|
https://github.com/jonnychu/guava
|
439f28d5420d5c7c18f4b368ad2fc7a6b92254a2
|
d4d7f1d8bb255780a7e8c6754b564b8568686cb8
|
refs/heads/master
| 2021-01-05T15:02:07.865000 | 2020-05-20T10:44:29 | 2020-05-20T10:44:29 | 241,055,616 | 0 | 0 | null | false | 2020-10-13T21:08:19 | 2020-02-17T08:27:54 | 2020-05-20T10:44:43 | 2020-10-13T21:08:18 | 3,243 | 0 | 0 | 1 |
Java
| false | false |
package cn.nextop.guava.widgets.datetime.action.actor.text.impl;
import org.eclipse.draw2d.IFigure;
import cn.nextop.guava.widgets.datetime.action.actor.text.AbstractTextActor;
/**
* @author jonny
*/
public class ShowTextActor extends AbstractTextActor {
@Override
protected boolean updateData(IFigure container, IFigure widget) {
return true;
}
}
|
UTF-8
|
Java
| 359 |
java
|
ShowTextActor.java
|
Java
|
[
{
"context": "tion.actor.text.AbstractTextActor;\n\n/**\n * @author jonny\n */\npublic class ShowTextActor extends AbstractTe",
"end": 200,
"score": 0.9988651871681213,
"start": 195,
"tag": "USERNAME",
"value": "jonny"
}
] | null |
[] |
package cn.nextop.guava.widgets.datetime.action.actor.text.impl;
import org.eclipse.draw2d.IFigure;
import cn.nextop.guava.widgets.datetime.action.actor.text.AbstractTextActor;
/**
* @author jonny
*/
public class ShowTextActor extends AbstractTextActor {
@Override
protected boolean updateData(IFigure container, IFigure widget) {
return true;
}
}
| 359 | 0.78273 | 0.779944 | 16 | 21.4375 | 26.835072 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false |
13
|
eb6e9251613ec87eb0d8f4c40ce48b43f90d231f
| 15,616,501,156,697 |
87e2b907f7a360d0837130eca0c062f7aaf626d9
|
/calendar/src/calendar/Calendar.java
|
b4c95a728567c4739f6daa2da9f0e8112d7e6b39
|
[] |
no_license
|
ace810408/calendar_V2
|
https://github.com/ace810408/calendar_V2
|
0588a59c41040c7d705f1031718fa87dabdac599
|
99dd820f96047fcbf6ed31925dfe45a81a90781b
|
refs/heads/master
| 2021-01-13T02:03:58.188000 | 2014-07-29T06:34:18 | 2014-07-29T06:34:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*******************************************************************
FileName [ Calendar.java ]
PackageName [ calendar ]
JavaProjectName [ Calendar ]
Synopsis
[
1.Check leap year.
2.Check days in a month.
3.Check what day is that day.
4.Find a whole month.
5.Check holidays.
]
Author [ Chi-Hsuan Hsu ]
Copyright [ Copyleft(c) 2014 MITLAB, GIEE, NTUST, Taiwan ]
*********************************************************************/
/*
* 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 calendar;
/**
*
* @author asus
*/
import java.io.*;
public class Calendar {
static void print_month_v0(int days, int first_day) { // 將日曆印出來
int d, i;
System.out.println(" Sun Mon Tue Wed Thr Fri Sat");
for (i = 0; i < first_day; i++) {
System.out.print(" ");
}
for (d = 1; d <= days; d++) {
System.out.printf("%4d", d);
if ((d + first_day) % 7 == 0) {
System.out.println("");
}
}
System.out.println("");
System.out.println("");
}
static int is_leap(int year) //0 not leap year,1 leap year
{
if (year % 4 != 0) {
return 0;
}
if (year % 100 != 0) {
return 1;
}
if (year % 400 != 0) {
return 0;
}
return 1;
}
static void Check_leap_year()throws IOException //判斷閏年
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int i=1;
System.out.println(" Please enter a year.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
if(year>1899)
break;
else
System.out.println("Please enter a year.");
}
if (is_leap(year) == 1)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
static void Check_days() throws IOException //判斷一個月有幾天
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int Keyinmonth = 0; int i=1;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
String month[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
System.out.println(" Please enter a year and a month.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 )
break;
else
System.out.println("Please enter a year and a month.");
}
if (is_leap(year) == 1) {
System.out.println("In " + year + " there is " + leap_days[Keyinmonth - 1] + " days in " + month[Keyinmonth - 1]);
} else {
System.out.println("In " + year + " there is " + days[Keyinmonth - 1] + " days in " + month[Keyinmonth - 1]);
}
}
static void Check_what_day() throws IOException //找星期幾
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int Keyinmonth = 0; int date=0; int i=1;
int k; int j; int first_day = 1;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
String month[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
System.out.println(" Please enter a year and a month and a date.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
String dayy = keyin.readLine();
date = Integer.parseInt(dayy);
if(is_leap(year)==1)
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 && date <=leap_days[Keyinmonth-1] && date > 0)
break;
else
System.out.println("Please enter a year and a month and a date.");
else
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 && date <=days[Keyinmonth-1] && date > 0 )
break;
else
System.out.println("Please enter a year and a month and a date.");
}
String week[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
for (k = 1900; k <= (year); k++)
{
for (j = 0; j <= 11; j++)
{
if (k == year) {
if (j == (Keyinmonth - 1))
{
System.out.printf(" " + month[j] + " " + date + " is on " + week[(date-1 + first_day) % 7] + " in " + year);
System.out.printf("\n");
}
}
if (is_leap(k) == 1) //算出First_day
{
first_day = (first_day + leap_days[j]) % 7;
}
else
{
first_day = (first_day + days[j]) % 7;
}
}
}
}
static void Find_Month() throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0,Keyinmonth=0; int k; int i=1;
int first_day=1; int j;
int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
int leap_days[]={31,29,31,30,31,30,31,31,30,31,30,31};
String month[]={"January","Febuary","March","April","May","June","July","August","September","October","November","December"};
System.out.println(" Please enter a year and a month.");
while(i ==1)
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 )
break;
else
System.out.println("Please enter a year and a month.");
}
is_leap(year);
for(k=1900;k<=(year);k++)
{
for(j=0;j<=11;j++)
{
if(k==year)
{
if(j==(Keyinmonth-1))
{
System.out.printf("\n");
System.out.printf(" %s",month[j]);
System.out.printf("\n");
if (is_leap(year)==1)
print_month_v0(leap_days[j],first_day);
else
print_month_v0(days[j],first_day);
}
}
if (is_leap(k)==1)
first_day=(first_day+leap_days[j])%7;
else
first_day=(first_day+days[j])%7;
}
}
}
static void Check_holiday() throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int i=1; int first_day = 1 ; int k; int j;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
System.out.println(" Please enter a year.");
while(i==1)
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
if(year>1899)
break;
else
System.out.println("Please enter a year.");
}
for (k = 1900; k <= (year); k++) {
for (j = 0; j <= 11; j++) {
if (k == year)
{
if (j == 0)
{
if (is_leap(year) == 1)
{
switch (first_day)
{
case (0):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (5):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (6):
System.out.println(" There are " + 106 + " holidays in this year.");
break;
default:
System.out.println(" There are " + 104 + " holidays in this year.");
break;
}
}
if (is_leap(year) == 0)
{
switch (first_day)
{
case (0):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (6):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
default:
System.out.println(" There are " + 104 + " holidays in this year.");
break;
}
}
}
}
if (is_leap(k) == 1)
{
first_day = (first_day + leap_days[j]) % 7;
}
else
{
first_day = (first_day + days[j]) % 7;
}
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int i = 1;
int choice;
int did = 0;
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
while(i==1)
{
String cho = keyin.readLine(); //選項
choice = Integer.parseInt(cho);
if(choice>0 && choice<6) //防呆
switch(choice)
{
case(1):
Check_leap_year();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String d = keyin.readLine();
did = Integer.parseInt(d);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(2):
Check_days();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String e = keyin.readLine();
did = Integer.parseInt(e);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(3):
Check_what_day();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String f = keyin.readLine();
did = Integer.parseInt(f);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(4):
Find_Month();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String g = keyin.readLine();
did = Integer.parseInt(g);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(5):
Check_holiday();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String h = keyin.readLine();
did = Integer.parseInt(h);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
default :
System.out.println("error");
break;
}
else
{
System.out.println("Please make sure your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
}
}
}
|
BIG5
|
Java
| 17,727 |
java
|
Calendar.java
|
Java
|
[
{
"context": "\n 5.Check holidays.\n ]\n Author [ Chi-Hsuan Hsu ]\n Copyright [ Copyleft(c) 2014 MITLAB, GIEE",
"end": 379,
"score": 0.9998089671134949,
"start": 366,
"tag": "NAME",
"value": "Chi-Hsuan Hsu"
},
{
"context": "e editor.\n */\npackage calendar;\n\n/**\n *\n * @author asus\n */\nimport java.io.*;\n\npublic class Calendar {\n\n ",
"end": 747,
"score": 0.9891210794448853,
"start": 743,
"tag": "USERNAME",
"value": "asus"
}
] | null |
[] |
/*******************************************************************
FileName [ Calendar.java ]
PackageName [ calendar ]
JavaProjectName [ Calendar ]
Synopsis
[
1.Check leap year.
2.Check days in a month.
3.Check what day is that day.
4.Find a whole month.
5.Check holidays.
]
Author [ <NAME> ]
Copyright [ Copyleft(c) 2014 MITLAB, GIEE, NTUST, Taiwan ]
*********************************************************************/
/*
* 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 calendar;
/**
*
* @author asus
*/
import java.io.*;
public class Calendar {
static void print_month_v0(int days, int first_day) { // 將日曆印出來
int d, i;
System.out.println(" Sun Mon Tue Wed Thr Fri Sat");
for (i = 0; i < first_day; i++) {
System.out.print(" ");
}
for (d = 1; d <= days; d++) {
System.out.printf("%4d", d);
if ((d + first_day) % 7 == 0) {
System.out.println("");
}
}
System.out.println("");
System.out.println("");
}
static int is_leap(int year) //0 not leap year,1 leap year
{
if (year % 4 != 0) {
return 0;
}
if (year % 100 != 0) {
return 1;
}
if (year % 400 != 0) {
return 0;
}
return 1;
}
static void Check_leap_year()throws IOException //判斷閏年
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int i=1;
System.out.println(" Please enter a year.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
if(year>1899)
break;
else
System.out.println("Please enter a year.");
}
if (is_leap(year) == 1)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
static void Check_days() throws IOException //判斷一個月有幾天
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int Keyinmonth = 0; int i=1;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
String month[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
System.out.println(" Please enter a year and a month.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 )
break;
else
System.out.println("Please enter a year and a month.");
}
if (is_leap(year) == 1) {
System.out.println("In " + year + " there is " + leap_days[Keyinmonth - 1] + " days in " + month[Keyinmonth - 1]);
} else {
System.out.println("In " + year + " there is " + days[Keyinmonth - 1] + " days in " + month[Keyinmonth - 1]);
}
}
static void Check_what_day() throws IOException //找星期幾
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int Keyinmonth = 0; int date=0; int i=1;
int k; int j; int first_day = 1;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
String month[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
System.out.println(" Please enter a year and a month and a date.");
while(i==1) //防呆
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
String dayy = keyin.readLine();
date = Integer.parseInt(dayy);
if(is_leap(year)==1)
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 && date <=leap_days[Keyinmonth-1] && date > 0)
break;
else
System.out.println("Please enter a year and a month and a date.");
else
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 && date <=days[Keyinmonth-1] && date > 0 )
break;
else
System.out.println("Please enter a year and a month and a date.");
}
String week[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
for (k = 1900; k <= (year); k++)
{
for (j = 0; j <= 11; j++)
{
if (k == year) {
if (j == (Keyinmonth - 1))
{
System.out.printf(" " + month[j] + " " + date + " is on " + week[(date-1 + first_day) % 7] + " in " + year);
System.out.printf("\n");
}
}
if (is_leap(k) == 1) //算出First_day
{
first_day = (first_day + leap_days[j]) % 7;
}
else
{
first_day = (first_day + days[j]) % 7;
}
}
}
}
static void Find_Month() throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0,Keyinmonth=0; int k; int i=1;
int first_day=1; int j;
int days[]={31,28,31,30,31,30,31,31,30,31,30,31};
int leap_days[]={31,29,31,30,31,30,31,31,30,31,30,31};
String month[]={"January","Febuary","March","April","May","June","July","August","September","October","November","December"};
System.out.println(" Please enter a year and a month.");
while(i ==1)
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
String mon = keyin.readLine();
Keyinmonth = Integer.parseInt(mon);
if(year>1899 && Keyinmonth<13 && Keyinmonth>0 )
break;
else
System.out.println("Please enter a year and a month.");
}
is_leap(year);
for(k=1900;k<=(year);k++)
{
for(j=0;j<=11;j++)
{
if(k==year)
{
if(j==(Keyinmonth-1))
{
System.out.printf("\n");
System.out.printf(" %s",month[j]);
System.out.printf("\n");
if (is_leap(year)==1)
print_month_v0(leap_days[j],first_day);
else
print_month_v0(days[j],first_day);
}
}
if (is_leap(k)==1)
first_day=(first_day+leap_days[j])%7;
else
first_day=(first_day+days[j])%7;
}
}
}
static void Check_holiday() throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int year=0; int i=1; int first_day = 1 ; int k; int j;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
System.out.println(" Please enter a year.");
while(i==1)
{
String yea = keyin.readLine();
year = Integer.parseInt(yea);
if(year>1899)
break;
else
System.out.println("Please enter a year.");
}
for (k = 1900; k <= (year); k++) {
for (j = 0; j <= 11; j++) {
if (k == year)
{
if (j == 0)
{
if (is_leap(year) == 1)
{
switch (first_day)
{
case (0):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (5):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (6):
System.out.println(" There are " + 106 + " holidays in this year.");
break;
default:
System.out.println(" There are " + 104 + " holidays in this year.");
break;
}
}
if (is_leap(year) == 0)
{
switch (first_day)
{
case (0):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
case (6):
System.out.println(" There are " + 105 + " holidays in this year.");
break;
default:
System.out.println(" There are " + 104 + " holidays in this year.");
break;
}
}
}
}
if (is_leap(k) == 1)
{
first_day = (first_day + leap_days[j]) % 7;
}
else
{
first_day = (first_day + days[j]) % 7;
}
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
throws IOException
{
java.util.Scanner scanner = new java.util.Scanner(System.in);
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
int i = 1;
int choice;
int did = 0;
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
while(i==1)
{
String cho = keyin.readLine(); //選項
choice = Integer.parseInt(cho);
if(choice>0 && choice<6) //防呆
switch(choice)
{
case(1):
Check_leap_year();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String d = keyin.readLine();
did = Integer.parseInt(d);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(2):
Check_days();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String e = keyin.readLine();
did = Integer.parseInt(e);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(3):
Check_what_day();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String f = keyin.readLine();
did = Integer.parseInt(f);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(4):
Find_Month();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String g = keyin.readLine();
did = Integer.parseInt(g);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
case(5):
Check_holiday();
System.out.println(" ");
System.out.println("Do you want to continue?");
System.out.println(" 0. Yes");
System.out.println("Else No");
String h = keyin.readLine();
did = Integer.parseInt(h);
if(did!=0)
{
i++;
break;
}
else
{
System.out.println("Please enter your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
break;
default :
System.out.println("error");
break;
}
else
{
System.out.println("Please make sure your choice.");
System.out.println(" 1.Is this year a leap year? ");
System.out.println(" 2.How many days in this month? ");
System.out.println(" 3.See what day is this day. ");
System.out.println(" 4.Find a whole month. ");
System.out.println(" 5.Check how many holidays in this year. ");
}
}
}
}
| 17,720 | 0.417294 | 0.393907 | 438 | 39.317352 | 27.951397 | 147 | false | false | 35 | 0.003964 | 0 | 0 | 0 | 0 | 0.872146 | false | false |
13
|
2f5f913754f253f71ef6b1684cefd5e6c5bd2801
| 12,008,728,588,711 |
e1950d4ac9067ada98631569275d9ac421378233
|
/src/java/watij/elements/Radio.java
|
f709cc5418b6d6daa6cda48e82516f8432830429
|
[] |
no_license
|
Amsoft-Systems/watij_release_3.2.1
|
https://github.com/Amsoft-Systems/watij_release_3.2.1
|
cd3493658631420d0acf9be9f57db83321fa7add
|
568622c787b5f84c7d4863d0059bd81e0c7fcfab
|
refs/heads/master
| 2018-01-07T11:44:14.426000 | 2013-05-01T08:32:04 | 2013-05-01T08:32:04 | 9,788,135 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package watij.elements;
/**
* Created by IntelliJ IDEA.
* User:
* Date: Apr 20, 2006
* Time: 8:25:44 PM
* To change this template use File | Settings | File Templates.
*/
public interface Radio extends RadioCheckCommon {
}
|
UTF-8
|
Java
| 230 |
java
|
Radio.java
|
Java
|
[] | null |
[] |
package watij.elements;
/**
* Created by IntelliJ IDEA.
* User:
* Date: Apr 20, 2006
* Time: 8:25:44 PM
* To change this template use File | Settings | File Templates.
*/
public interface Radio extends RadioCheckCommon {
}
| 230 | 0.695652 | 0.647826 | 11 | 19.90909 | 19.851515 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false |
13
|
5867d1e564588fcaa8462d1b2188344285c1dc60
| 18,184,891,595,751 |
1c9d1d6910b3ef2e62c523a4974c9fda4d0c8d25
|
/CBEC/src/main/java/com/rainbowsix/cbec/dao/IAreaDao.java
|
a34ee91ca9b5b8e9417bb1dc9622a6f3f698f42f
|
[] |
no_license
|
RainbowSix66666/Lion
|
https://github.com/RainbowSix66666/Lion
|
78a7e1136045e4d9e7a018d9af6e08376aca7c2a
|
daa77769bd33e8f96c94f800e3e6c025d05877e8
|
refs/heads/master
| 2020-03-25T17:25:30.227000 | 2018-09-01T04:30:51 | 2018-09-01T04:30:51 | 143,976,967 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.rainbowsix.cbec.dao;
import java.util.List;
import com.rainbowsix.cbec.model.AreaModel;
public interface IAreaDao {
//基础方法
public void add(AreaModel area) throws Exception;
public void delete(AreaModel area) throws Exception;
public List<AreaModel> selectAll() throws Exception;
public void modify(AreaModel area) throws Exception;
public AreaModel selectById(int id) throws Exception;
}
|
UTF-8
|
Java
| 431 |
java
|
IAreaDao.java
|
Java
|
[] | null |
[] |
package com.rainbowsix.cbec.dao;
import java.util.List;
import com.rainbowsix.cbec.model.AreaModel;
public interface IAreaDao {
//基础方法
public void add(AreaModel area) throws Exception;
public void delete(AreaModel area) throws Exception;
public List<AreaModel> selectAll() throws Exception;
public void modify(AreaModel area) throws Exception;
public AreaModel selectById(int id) throws Exception;
}
| 431 | 0.770686 | 0.770686 | 14 | 28.214285 | 22.094532 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false |
13
|
6aad9f6407f9fc37ad5285ca7c457faafa97fb04
| 21,053,929,701,379 |
05b7ff6631c8f54ae6d7137bf578bfea0e1ef18a
|
/vimana source code/crypto-lib/Java/cryptolib/src/test/java/io/vimana/cryptolib/SymFBCryptoTest.java
|
6d51d3d483aba40e7194c5cd32ca35ebc02a1ffe
|
[] |
no_license
|
VIMANAGLOBAL/VIMANA-GLOBAL
|
https://github.com/VIMANAGLOBAL/VIMANA-GLOBAL
|
9c297af0bd96954011e6c6719f4eef9bb1d124f5
|
604ff1d434b6fa24256fb0fa99cec617f7fd8f26
|
refs/heads/master
| 2023-02-01T22:08:17.280000 | 2019-11-01T15:48:33 | 2019-11-01T15:48:33 | 219,011,811 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package io.vimana.cryptolib;
import io.vimana.cryptolib.dataformat.AEAD;
import io.vimana.cryptolib.dataformat.AEADMessage;
import io.vimana.cryptolib.impl.SymJCEImpl;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.security.SecureRandom;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
*
* @author al
*/
public class SymvimryptoTest {
private static final String PLAIN_FILE = "../../testdata/encrypt_sym_test_plain.bin";
private static final String KEY_FILE = "../../testdata/encrypt_sym_test_key.bin";
private static final String OUT_FILE_ENCRYPT_SYM = "../../testdata/encrypt_sym_test.bin";
private static final String OUT_FILE_ENCRYPT_SYM_AEAD = "../../testdata/encrypt_sym_aead_test.bin";
private static final String OPEN_TEXT = "This is test open text. Should be visisble as is";
private static final SecureRandom srand = new SecureRandom();
private static final int RANDOM_BYTES_NUMBER = 4096;
private static vimryptoParams params = vimryptoParams.createDefault();
public SymvimryptoTest() {
}
private static void writeToFile(ByteBuffer data, String fileName) throws IOException {
FileChannel out = new FileOutputStream(fileName).getChannel();
data.rewind();
out.write(data);
out.close();
}
private static ByteBuffer readFromFile(String fileName) throws IOException {
FileChannel fChan;
Long fSize;
ByteBuffer mBuf;
fChan = new FileInputStream(fileName).getChannel();
fSize = fChan.size();
mBuf = ByteBuffer.allocate(fSize.intValue());
fChan.read(mBuf);
fChan.close();
mBuf.rewind();
return mBuf;
}
@BeforeAll
public static void setUpClass() {
System.out.println("Preparing random plain file and random salt+key");
//write random file of plain text
byte[] rt = new byte[RANDOM_BYTES_NUMBER];
srand.nextBytes(rt);
try {
writeToFile(ByteBuffer.wrap(rt), PLAIN_FILE);
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
srand.nextBytes(key);
srand.nextBytes(salt);
//write salt+key to file
ByteBuffer skb = ByteBuffer.allocate(salt.length + key.length);
skb.put(salt);
skb.put(key);
writeToFile(skb, KEY_FILE);
} catch (IOException ex) {
fail("Can not write: " + PLAIN_FILE);
}
}
@AfterAll
public static void tearDownClass() {
}
@Test
public void testEncryptToFile() {
System.out.println("Testing symmetric encryptio-decryption fith files");
try {
//read plain text file
byte[] plain = readFromFile(PLAIN_FILE).array();
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
//read key file: salt+key
ByteBuffer skb = readFromFile(KEY_FILE);
skb.get(salt);
skb.get(key);
vimryptoSym instance_e = new SymJCEImpl(params);
instance_e.setSymmetricSalt(salt);
instance_e.setSymmetricNonce(null); //generate random nonce
instance_e.setSymmetricKey(key);
byte[] encrypted = instance_e.encryptSymmetric(plain);
//write encrypted to file prefixed with explicitNounce
writeToFile(ByteBuffer.wrap(encrypted), OUT_FILE_ENCRYPT_SYM);
//read encrypted data file into "encrypted" byte array
encrypted = readFromFile(OUT_FILE_ENCRYPT_SYM).array();
//prepare instance for decription.
vimryptoSym instance_d = new SymJCEImpl(params);
instance_d.setSymmetricSalt(salt);
instance_d.setSymmetricKey(key);
//There is no need to call setSymmetricNounce() because nounce
// is part of encrypted data (prefix of 8 bytes legnth)
byte[] plain_decrypted = instance_d.decryptSymmetric(encrypted);
//check that decrypted and plain arrays match
assertArrayEquals(plain, plain_decrypted);
} catch (IOException ex) {
fail("Can not read: " + PLAIN_FILE);
} catch (CryptoNotValidException ex) {
fail("Can not encrypt:" + ex.getMessage());
}
}
@Test
public void testEncryptAEADToFile() {
System.out.println("Testing symmetric AEAD encryption-decryption fith files");
try {
//read plain text file
byte[] plain = readFromFile(PLAIN_FILE).array();
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
//read key file
//read key file: salt+key
ByteBuffer skb = readFromFile(KEY_FILE);
skb.get(salt);
skb.get(key);
//encrypt
vimryptoSym instance_e = new SymJCEImpl(params);
instance_e.setSymmetricSalt(salt);
instance_e.setSymmetricNonce(null); //generate random nonce
byte[] _nonce = instance_e.getSymmetricNounce();
instance_e.setSymmetricKey(key);
AEADMessage encrypted = instance_e.encryptSymmetricWithAEAData(plain, OPEN_TEXT.getBytes());
//write encrypted to file prefixed with explicitNounce
ByteBuffer wrb = ByteBuffer.wrap(encrypted.toBytes());
writeToFile(wrb, OUT_FILE_ENCRYPT_SYM_AEAD);
//read encrypted
byte[] encrypted_buf = readFromFile(OUT_FILE_ENCRYPT_SYM_AEAD).array();
vimryptoSym instance_d = new SymJCEImpl(params);
instance_d.setSymmetricSalt(salt);
instance_d.setSymmetricKey(key);
AEAD decrypted = instance_d.decryptSymmetricWithAEAData(encrypted_buf);
//check
assertTrue(decrypted.hmac_ok);
assertArrayEquals(decrypted.decrypted, plain);
assertArrayEquals(decrypted.plain, OPEN_TEXT.getBytes())
;
} catch (IOException ex) {
fail("Can not read: " + PLAIN_FILE);
} catch (CryptoNotValidException ex) {
fail("Can not encrypt:" + ex.getMessage());
}
}
}
|
UTF-8
|
Java
| 6,643 |
java
|
SymFBCryptoTest.java
|
Java
|
[
{
"context": "ort org.junit.jupiter.api.Test;\n\n/**\n *\n * @author al\n */\npublic class SymvimryptoTest {\n\n private s",
"end": 676,
"score": 0.9624057412147522,
"start": 674,
"tag": "USERNAME",
"value": "al"
}
] | null |
[] |
package io.vimana.cryptolib;
import io.vimana.cryptolib.dataformat.AEAD;
import io.vimana.cryptolib.dataformat.AEADMessage;
import io.vimana.cryptolib.impl.SymJCEImpl;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.security.SecureRandom;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
*
* @author al
*/
public class SymvimryptoTest {
private static final String PLAIN_FILE = "../../testdata/encrypt_sym_test_plain.bin";
private static final String KEY_FILE = "../../testdata/encrypt_sym_test_key.bin";
private static final String OUT_FILE_ENCRYPT_SYM = "../../testdata/encrypt_sym_test.bin";
private static final String OUT_FILE_ENCRYPT_SYM_AEAD = "../../testdata/encrypt_sym_aead_test.bin";
private static final String OPEN_TEXT = "This is test open text. Should be visisble as is";
private static final SecureRandom srand = new SecureRandom();
private static final int RANDOM_BYTES_NUMBER = 4096;
private static vimryptoParams params = vimryptoParams.createDefault();
public SymvimryptoTest() {
}
private static void writeToFile(ByteBuffer data, String fileName) throws IOException {
FileChannel out = new FileOutputStream(fileName).getChannel();
data.rewind();
out.write(data);
out.close();
}
private static ByteBuffer readFromFile(String fileName) throws IOException {
FileChannel fChan;
Long fSize;
ByteBuffer mBuf;
fChan = new FileInputStream(fileName).getChannel();
fSize = fChan.size();
mBuf = ByteBuffer.allocate(fSize.intValue());
fChan.read(mBuf);
fChan.close();
mBuf.rewind();
return mBuf;
}
@BeforeAll
public static void setUpClass() {
System.out.println("Preparing random plain file and random salt+key");
//write random file of plain text
byte[] rt = new byte[RANDOM_BYTES_NUMBER];
srand.nextBytes(rt);
try {
writeToFile(ByteBuffer.wrap(rt), PLAIN_FILE);
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
srand.nextBytes(key);
srand.nextBytes(salt);
//write salt+key to file
ByteBuffer skb = ByteBuffer.allocate(salt.length + key.length);
skb.put(salt);
skb.put(key);
writeToFile(skb, KEY_FILE);
} catch (IOException ex) {
fail("Can not write: " + PLAIN_FILE);
}
}
@AfterAll
public static void tearDownClass() {
}
@Test
public void testEncryptToFile() {
System.out.println("Testing symmetric encryptio-decryption fith files");
try {
//read plain text file
byte[] plain = readFromFile(PLAIN_FILE).array();
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
//read key file: salt+key
ByteBuffer skb = readFromFile(KEY_FILE);
skb.get(salt);
skb.get(key);
vimryptoSym instance_e = new SymJCEImpl(params);
instance_e.setSymmetricSalt(salt);
instance_e.setSymmetricNonce(null); //generate random nonce
instance_e.setSymmetricKey(key);
byte[] encrypted = instance_e.encryptSymmetric(plain);
//write encrypted to file prefixed with explicitNounce
writeToFile(ByteBuffer.wrap(encrypted), OUT_FILE_ENCRYPT_SYM);
//read encrypted data file into "encrypted" byte array
encrypted = readFromFile(OUT_FILE_ENCRYPT_SYM).array();
//prepare instance for decription.
vimryptoSym instance_d = new SymJCEImpl(params);
instance_d.setSymmetricSalt(salt);
instance_d.setSymmetricKey(key);
//There is no need to call setSymmetricNounce() because nounce
// is part of encrypted data (prefix of 8 bytes legnth)
byte[] plain_decrypted = instance_d.decryptSymmetric(encrypted);
//check that decrypted and plain arrays match
assertArrayEquals(plain, plain_decrypted);
} catch (IOException ex) {
fail("Can not read: " + PLAIN_FILE);
} catch (CryptoNotValidException ex) {
fail("Can not encrypt:" + ex.getMessage());
}
}
@Test
public void testEncryptAEADToFile() {
System.out.println("Testing symmetric AEAD encryption-decryption fith files");
try {
//read plain text file
byte[] plain = readFromFile(PLAIN_FILE).array();
byte[] key = new byte[256 / 8];
byte[] salt = new byte[4];
//read key file
//read key file: salt+key
ByteBuffer skb = readFromFile(KEY_FILE);
skb.get(salt);
skb.get(key);
//encrypt
vimryptoSym instance_e = new SymJCEImpl(params);
instance_e.setSymmetricSalt(salt);
instance_e.setSymmetricNonce(null); //generate random nonce
byte[] _nonce = instance_e.getSymmetricNounce();
instance_e.setSymmetricKey(key);
AEADMessage encrypted = instance_e.encryptSymmetricWithAEAData(plain, OPEN_TEXT.getBytes());
//write encrypted to file prefixed with explicitNounce
ByteBuffer wrb = ByteBuffer.wrap(encrypted.toBytes());
writeToFile(wrb, OUT_FILE_ENCRYPT_SYM_AEAD);
//read encrypted
byte[] encrypted_buf = readFromFile(OUT_FILE_ENCRYPT_SYM_AEAD).array();
vimryptoSym instance_d = new SymJCEImpl(params);
instance_d.setSymmetricSalt(salt);
instance_d.setSymmetricKey(key);
AEAD decrypted = instance_d.decryptSymmetricWithAEAData(encrypted_buf);
//check
assertTrue(decrypted.hmac_ok);
assertArrayEquals(decrypted.decrypted, plain);
assertArrayEquals(decrypted.plain, OPEN_TEXT.getBytes())
;
} catch (IOException ex) {
fail("Can not read: " + PLAIN_FILE);
} catch (CryptoNotValidException ex) {
fail("Can not encrypt:" + ex.getMessage());
}
}
}
| 6,643 | 0.616137 | 0.613127 | 177 | 36.531075 | 26.252369 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.59887 | false | false |
13
|
19233b8ed8970128a8fd4695307e1295784ea45c
| 5,781,025,996,870 |
c853401bcf2186b844a7491e86b085d7a2718168
|
/src/ProcessControl/ProcessControlFactory.java
|
b6576be996148763b38b345e0ba42d94fef3bbb1
|
[] |
no_license
|
fantoli/NWSTCRPI
|
https://github.com/fantoli/NWSTCRPI
|
5fadce26735a09dfa3a285f5144047883936792a
|
490c481bcd8fa100bf80f20c2f703620fc168a8c
|
refs/heads/master
| 2023-08-03T18:46:16.542000 | 2021-09-10T11:54:50 | 2021-09-10T11:54:50 | 404,267,943 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ProcessControl;
/**
*
* @author JOliver
*/
public class ProcessControlFactory {
private static iProcessMgr _processMgr;
public static iProcessMgr ProcessMgr() throws Exception {
if (_processMgr == null) {
String _OS = System.getProperty("os.name");
if (_OS.toLowerCase().contains("windows")) {
_processMgr = new WindowsProcessMgr();
} else {
if (_OS.toLowerCase().contains("mac")) {
throw new Exception("Sistema operativo no soportado: " + _OS);
} else {
if (_OS.toLowerCase().contains("linux")) {
_processMgr = new LinuxProcessMgr();
} else {
throw new Exception("Sistema operativo no soportado: " + _OS);
}
}
}
}
return _processMgr;
}
}
|
UTF-8
|
Java
| 1,151 |
java
|
ProcessControlFactory.java
|
Java
|
[
{
"context": "*/\r\npackage ProcessControl;\r\n\r\n/**\r\n *\r\n * @author JOliver\r\n */\r\npublic class ProcessControlFactory {\r\n p",
"end": 244,
"score": 0.7695288062095642,
"start": 237,
"tag": "NAME",
"value": "JOliver"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ProcessControl;
/**
*
* @author JOliver
*/
public class ProcessControlFactory {
private static iProcessMgr _processMgr;
public static iProcessMgr ProcessMgr() throws Exception {
if (_processMgr == null) {
String _OS = System.getProperty("os.name");
if (_OS.toLowerCase().contains("windows")) {
_processMgr = new WindowsProcessMgr();
} else {
if (_OS.toLowerCase().contains("mac")) {
throw new Exception("Sistema operativo no soportado: " + _OS);
} else {
if (_OS.toLowerCase().contains("linux")) {
_processMgr = new LinuxProcessMgr();
} else {
throw new Exception("Sistema operativo no soportado: " + _OS);
}
}
}
}
return _processMgr;
}
}
| 1,151 | 0.516073 | 0.516073 | 34 | 31.852942 | 25.845846 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.323529 | false | false |
13
|
7b3607c8d80b0e662a5127590d1f52629af935d8
| 14,860,586,865,982 |
e66ee067b07a1c5538218655544aaf17508bf151
|
/src/io/Comparator.java
|
95453ffe464d5eb233f71785626a9209cb1ee621
|
[] |
no_license
|
poke53280/Andux
|
https://github.com/poke53280/Andux
|
8d697b37c234ce7f4a6e3c037a6dcaaf0a6c49d8
|
fdba4436b03854925c6d239d0a8c7ba8d1f11368
|
refs/heads/master
| 2021-07-05T06:57:48.900000 | 2017-09-29T07:18:23 | 2017-09-29T07:18:23 | 105,121,718 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package io;
import world.Engine;
import world.ItemArray;
import world.Item;
import world.RotSet;
import world.ItemState;
import world.Focus;
import root.Command;
import root.Factory;
import root.ParseUtil;
import java.awt.Point;
public class Comparator {
private Engine main;
private Engine aux;
private int THRESHOLD = 4;
public Comparator(Engine main, Engine aux) {
this.main = main;
this.aux = aux;
}
public Item findSay() {
//looks up *any* in aux. finds main, checks for newer
//(other) message in main. returns main item if so is found.
Item j = getAnyAux();
if (j == null) {
//Aux is empty
return null;
}
ItemArray a = main.getData();
Item i = a.search(j.ID);
if (i == null) {
//System.out.println("Comperator.findSay:Item"
// + " in aux, but not in main, id=" + j.ID);
return null;
}
String auxMessage = j.getMessage();
String mainMessage = i.getMessage();
if (auxMessage.equals(mainMessage)) {
return null;
} else {
return i;
}
}
public Item makeAuxSpec(int id) {
return aux.makeSpec(id);
}
public Item getOutside() {
ItemArray auxData = aux.getData();
ItemArray mainData= main.getData();
Focus f = aux.getFocus();
int out = mainData.sort(f.getRect() );
Item[] a = mainData.getArray();
for (int pos=0;pos < out;pos++) {
Item k = a[pos];
ItemState s = k.getState();
if (s.isControlled() ) {
Item j = auxData.search(k.ID);
if(isOutside(j,k) ) {
return k;
} else {
//Aux item is properly describing position in main engine.
//headCheck(j,k);
if (!isHeaded(j,k) ) {
return k;
}
}
}
}
return null;
}
public Item exileObsolete() {
ItemArray auxData = aux.getData();
ItemArray mainData= main.getData();
Focus f = aux.getFocus();
int out = mainData.sort(f.getRect() );
Item[] a = auxData.getArray();
int index = auxData.size();
for (int pos=0;pos < index;pos++) {
int id = a[pos].ID;
Item i = mainData.search(id);
if (i == null || !i.getState().isControlled() ) {
//Item is in aux engine, but not in main engine. It should not be in
//aux engine, but mother host should also be informed.
//Send a new dummy position, far way from anywhere.
//Recheck; XXXFor now, just delete immediately. Old items may be stuck.
ItemState s = a[pos].getState();
s.destroy();
auxData.removeAt(pos);
pos--;
index--;
} else if (!isOutside(a[pos], i) ){
//Aux item is proplery describing main engine item.
//headCheck(a[pos],i);
if (!isHeaded(a[pos],i) ) {
return i;
}
} else {
//Aux item is not close enough to main engine item. Aux engine needs to
//be updated, whether main item is within focus or not.
return i;
}
}
return null;
}
public Item getTransfer() {
Focus f = aux.getFocus();
Item i = main.getTransfer(f);
return i; //null if none found.
}
public Item getAnyAux() {
return aux.getAny();
}
private String showDiff(int id) {
Item l = aux.getItem(id);
Item m = main.getItem(id);
if (l == null || m == null) {
return "Item id=" + id + " not found in main and/or aux engine";
} else {
Point p = m.getDiff(l);
return "Item id=" + id + ": dx = " + p.x + ", dy = " + p.y;
}
}
private boolean isOutside(Item auxItem, Item mainItem) {
if (mainItem == null) {
return false;
}
if (auxItem == null) {
return true;
}
Point p = Item.getDiff(auxItem, mainItem);
if (p.x > THRESHOLD || p.y > THRESHOLD) {
return true;
} else {
return false;
}
}
private void headCheck(Item auxItem, Item mainItem) {
boolean isHeaded = isHeaded(auxItem, mainItem);
if (!isHeaded) {
System.out.println("Comparator: Head update needed on " + auxItem.ID);
} else {
System.out.println("Heading OK");
}
}
private boolean isHeaded(Item auxItem, Item mainItem) {
if (mainItem == null) {
return false;
}
if (auxItem == null) {
return true;
}
if (mainItem == auxItem) {
System.out.println("WARN: Comparator: aux and main items are identical");
} else {
//System.out.println("Comparator: aux and main items are NOT identical");
}
RotSet jr = auxItem.getRotation();
RotSet ir = mainItem.getRotation();
if (jr == ir) {
System.out.println("WARN: Comparator: aux and main items have identical rotation object");
}
return jr.isHeaded(ir);
}
public void registerCommands(Factory f, String prefix) {
f.add(prefix + "c/diff" , new Diff() );
f.add(prefix + "c/update", new Update() );
f.add(prefix + "c/transferscan", new TransferScan() );
f.add(prefix + "c/obsolete", new Obsolete() );
}
public void deregisterCommands(Factory f, String prefix) {
f.remove(prefix + "c/diff");
f.remove(prefix + "c/update");
f.remove(prefix + "c/transferscan");
f.remove(prefix + "c/obsolete");
}
class Obsolete extends Command {
public Obsolete() {
setUsage("obsolete");
}
public Command create(String[] args) {
Command c = new Obsolete();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
exileObsolete();
setResult("Obsolete finished.");
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
class TransferScan extends Command {
public TransferScan() {
setUsage("transferscan");
}
public Command create(String[] args) {
Command c = new TransferScan();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
Item i = getTransfer();
if (i != null) {
setResult("Item ID " + i.getID() + " on TRANSFER and in focus zone.");
} else {
setResult("No TRANSFER items in focus zone.");
}
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
class Diff extends Command {
private int itemID = -1;
public Diff() {
setUsage("diff <itemID>");
}
public Command create(String[] args) {
Command c = new Diff();
c.setArgs(args);
return c;
}
public void init() {
super.init();
itemID = -1;
}
public void execute() {
if (isValid ) {
setResult(showDiff(itemID) );
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
if (args.length != PAR1 +1) {
isValid = false;
} else {
itemID = ParseUtil.parseInt(args[PAR1] );
if (itemID== -1 ) {
isValid = false;
} else {
isValid = true;
}
}
}
}
class Update extends Command {
public Update() {
setUsage("update");
}
public Command create(String[] args) {
Command c = new Update();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
getOutside();
setResult("");
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
}
|
UTF-8
|
Java
| 7,124 |
java
|
Comparator.java
|
Java
|
[] | null |
[] |
package io;
import world.Engine;
import world.ItemArray;
import world.Item;
import world.RotSet;
import world.ItemState;
import world.Focus;
import root.Command;
import root.Factory;
import root.ParseUtil;
import java.awt.Point;
public class Comparator {
private Engine main;
private Engine aux;
private int THRESHOLD = 4;
public Comparator(Engine main, Engine aux) {
this.main = main;
this.aux = aux;
}
public Item findSay() {
//looks up *any* in aux. finds main, checks for newer
//(other) message in main. returns main item if so is found.
Item j = getAnyAux();
if (j == null) {
//Aux is empty
return null;
}
ItemArray a = main.getData();
Item i = a.search(j.ID);
if (i == null) {
//System.out.println("Comperator.findSay:Item"
// + " in aux, but not in main, id=" + j.ID);
return null;
}
String auxMessage = j.getMessage();
String mainMessage = i.getMessage();
if (auxMessage.equals(mainMessage)) {
return null;
} else {
return i;
}
}
public Item makeAuxSpec(int id) {
return aux.makeSpec(id);
}
public Item getOutside() {
ItemArray auxData = aux.getData();
ItemArray mainData= main.getData();
Focus f = aux.getFocus();
int out = mainData.sort(f.getRect() );
Item[] a = mainData.getArray();
for (int pos=0;pos < out;pos++) {
Item k = a[pos];
ItemState s = k.getState();
if (s.isControlled() ) {
Item j = auxData.search(k.ID);
if(isOutside(j,k) ) {
return k;
} else {
//Aux item is properly describing position in main engine.
//headCheck(j,k);
if (!isHeaded(j,k) ) {
return k;
}
}
}
}
return null;
}
public Item exileObsolete() {
ItemArray auxData = aux.getData();
ItemArray mainData= main.getData();
Focus f = aux.getFocus();
int out = mainData.sort(f.getRect() );
Item[] a = auxData.getArray();
int index = auxData.size();
for (int pos=0;pos < index;pos++) {
int id = a[pos].ID;
Item i = mainData.search(id);
if (i == null || !i.getState().isControlled() ) {
//Item is in aux engine, but not in main engine. It should not be in
//aux engine, but mother host should also be informed.
//Send a new dummy position, far way from anywhere.
//Recheck; XXXFor now, just delete immediately. Old items may be stuck.
ItemState s = a[pos].getState();
s.destroy();
auxData.removeAt(pos);
pos--;
index--;
} else if (!isOutside(a[pos], i) ){
//Aux item is proplery describing main engine item.
//headCheck(a[pos],i);
if (!isHeaded(a[pos],i) ) {
return i;
}
} else {
//Aux item is not close enough to main engine item. Aux engine needs to
//be updated, whether main item is within focus or not.
return i;
}
}
return null;
}
public Item getTransfer() {
Focus f = aux.getFocus();
Item i = main.getTransfer(f);
return i; //null if none found.
}
public Item getAnyAux() {
return aux.getAny();
}
private String showDiff(int id) {
Item l = aux.getItem(id);
Item m = main.getItem(id);
if (l == null || m == null) {
return "Item id=" + id + " not found in main and/or aux engine";
} else {
Point p = m.getDiff(l);
return "Item id=" + id + ": dx = " + p.x + ", dy = " + p.y;
}
}
private boolean isOutside(Item auxItem, Item mainItem) {
if (mainItem == null) {
return false;
}
if (auxItem == null) {
return true;
}
Point p = Item.getDiff(auxItem, mainItem);
if (p.x > THRESHOLD || p.y > THRESHOLD) {
return true;
} else {
return false;
}
}
private void headCheck(Item auxItem, Item mainItem) {
boolean isHeaded = isHeaded(auxItem, mainItem);
if (!isHeaded) {
System.out.println("Comparator: Head update needed on " + auxItem.ID);
} else {
System.out.println("Heading OK");
}
}
private boolean isHeaded(Item auxItem, Item mainItem) {
if (mainItem == null) {
return false;
}
if (auxItem == null) {
return true;
}
if (mainItem == auxItem) {
System.out.println("WARN: Comparator: aux and main items are identical");
} else {
//System.out.println("Comparator: aux and main items are NOT identical");
}
RotSet jr = auxItem.getRotation();
RotSet ir = mainItem.getRotation();
if (jr == ir) {
System.out.println("WARN: Comparator: aux and main items have identical rotation object");
}
return jr.isHeaded(ir);
}
public void registerCommands(Factory f, String prefix) {
f.add(prefix + "c/diff" , new Diff() );
f.add(prefix + "c/update", new Update() );
f.add(prefix + "c/transferscan", new TransferScan() );
f.add(prefix + "c/obsolete", new Obsolete() );
}
public void deregisterCommands(Factory f, String prefix) {
f.remove(prefix + "c/diff");
f.remove(prefix + "c/update");
f.remove(prefix + "c/transferscan");
f.remove(prefix + "c/obsolete");
}
class Obsolete extends Command {
public Obsolete() {
setUsage("obsolete");
}
public Command create(String[] args) {
Command c = new Obsolete();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
exileObsolete();
setResult("Obsolete finished.");
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
class TransferScan extends Command {
public TransferScan() {
setUsage("transferscan");
}
public Command create(String[] args) {
Command c = new TransferScan();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
Item i = getTransfer();
if (i != null) {
setResult("Item ID " + i.getID() + " on TRANSFER and in focus zone.");
} else {
setResult("No TRANSFER items in focus zone.");
}
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
class Diff extends Command {
private int itemID = -1;
public Diff() {
setUsage("diff <itemID>");
}
public Command create(String[] args) {
Command c = new Diff();
c.setArgs(args);
return c;
}
public void init() {
super.init();
itemID = -1;
}
public void execute() {
if (isValid ) {
setResult(showDiff(itemID) );
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
if (args.length != PAR1 +1) {
isValid = false;
} else {
itemID = ParseUtil.parseInt(args[PAR1] );
if (itemID== -1 ) {
isValid = false;
} else {
isValid = true;
}
}
}
}
class Update extends Command {
public Update() {
setUsage("update");
}
public Command create(String[] args) {
Command c = new Update();
c.setArgs(args);
return c;
}
public void init() {
super.init();
}
public void execute() {
if (isValid ) {
getOutside();
setResult("");
} else {
setResult(showUsage() );
}
}
public void setArgs(String[] args) {
init();
isValid = true;
}
}
}
| 7,124 | 0.601348 | 0.600084 | 392 | 17.17602 | 18.314907 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.244898 | false | false |
13
|
85963ab56b2d25275e4c42870dbac8dfc6a8e6a7
| 14,697,378,121,942 |
1433c68414748d72d79deb34003c20d72e715da2
|
/src/ch06/_01_Fish.java
|
2911df774b57d2df2a098a59692cc91a7f3ded3d
|
[] |
no_license
|
KimJeongnam/JAVA
|
https://github.com/KimJeongnam/JAVA
|
c8fa9194f22122b89d1873284171fff3eef14c19
|
fc2f4d46483ee05b4b3f1986d5d287c0b0bf8723
|
refs/heads/master
| 2020-03-30T12:34:49.383000 | 2018-10-05T09:20:19 | 2018-10-05T09:20:19 | 151,230,542 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ch06;
public class _01_Fish extends _01_Animal{
@Override
public void move() {
// TODO Auto-generated method stub
System.out.println("헤엄치다.");
}
@Override
public void eat() {
// TODO Auto-generated method stub
System.out.println("먹이를 먹다.");
}
}
|
UTF-8
|
Java
| 290 |
java
|
_01_Fish.java
|
Java
|
[] | null |
[] |
package ch06;
public class _01_Fish extends _01_Animal{
@Override
public void move() {
// TODO Auto-generated method stub
System.out.println("헤엄치다.");
}
@Override
public void eat() {
// TODO Auto-generated method stub
System.out.println("먹이를 먹다.");
}
}
| 290 | 0.665441 | 0.643382 | 17 | 15 | 14.535959 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.058824 | false | false |
13
|
6bd858a91da3e5659119625d785acac1f3368df0
| 26,577,257,683,162 |
b5f4c0dee1484e55503ce63a08ede3d831c6b64a
|
/src/main/java/com/lastminute/taxesquiz/sale/tax/service/TaxService.java
|
a07ddd5ffd1184f37289eeb94b9a42aadcf8e6e6
|
[] |
no_license
|
LidianGit/SalesTaxesQuiz
|
https://github.com/LidianGit/SalesTaxesQuiz
|
8596d71839f124708399390c02871c9094cc8344
|
1f3efce8d21baa98eabfb0ff4db357e2da445ea7
|
refs/heads/master
| 2021-07-02T12:56:55.341000 | 2017-09-24T18:52:55 | 2017-09-24T18:52:55 | 104,410,176 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.lastminute.taxesquiz.sale.tax.service;
import com.lastminute.taxesquiz.sale.basket.model.Basket;
public interface TaxService {
Basket applyTaxes(Basket basket);
}
|
UTF-8
|
Java
| 183 |
java
|
TaxService.java
|
Java
|
[] | null |
[] |
package com.lastminute.taxesquiz.sale.tax.service;
import com.lastminute.taxesquiz.sale.basket.model.Basket;
public interface TaxService {
Basket applyTaxes(Basket basket);
}
| 183 | 0.79235 | 0.79235 | 9 | 19.333334 | 22.597935 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
13
|
65efe628405464af49edaa3dc59f6ce10dd3336f
| 31,086,973,308,962 |
c813e7bf34b0d19bf98fac1e0ff924a94a8f18e2
|
/src/com/eby/mhs/MhsTableModel.java
|
93799e493c783b71b07e9797bca540c5974bbebd
|
[] |
no_license
|
kevinmel2000/BasicCRUDHibernateGenericDAO
|
https://github.com/kevinmel2000/BasicCRUDHibernateGenericDAO
|
1789dc31f1e0f35e2a836bee8bc6e84d599cac7c
|
3f67f8eb1d2d9a30730dc2d0f485a96924f4ef76
|
refs/heads/master
| 2020-04-12T12:23:25.172000 | 2015-08-24T11:55:43 | 2015-08-24T11:55:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.eby.mhs;
import com.eby.orm.entity.Dosen;
import com.eby.orm.entity.Mahasiswa;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.util.Callback;
import javax.swing.table.AbstractTableModel;
/**
*
* @author 3b1
*/
public final class MhsTableModel {
private final List<Mahasiswa> list;
private final ObservableList<Mahasiswa> row;
private final Collection<TableColumn<Mahasiswa, String>> column;
public MhsTableModel() {
list = new ArrayList<>();
row = FXCollections.observableArrayList(list);
column = new ArrayList<>();
this.initColumn();
}
public void initColumn() {
column.add(this.addTableColumn1("NIM", "nim"));
column.add(this.addTableColumn2("NAMA", "nama"));
column.add(this.addTableColumn3("KELAS", "kelas"));
column.add(this.addTableColumn4("ALAMAT", "alamat"));
column.add(this.addTableColumn5("Tgl. LAHIR", "tglLahir"));
column.add(this.getDosen());
// column.add(this.getMahasiswa());
}
public void removeAllColumn() {
while (column.iterator().hasNext()) {
column.remove(column.iterator().next());
}
}
private TableColumn addTableColumn1(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn2(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(125);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn3(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(60);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn4(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn5(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn getDosen() {
TableColumn t = this.addTableColumn2("DOSEN", "dosen");
t.setCellFactory(new Callback< TableColumn<Dosen, Dosen>, TableCell<Dosen, Dosen>>() {
@Override
public TableCell<Dosen, Dosen> call(TableColumn<Dosen, Dosen> param) {
TableCell<Dosen, Dosen> parentCell = new TableCell<Dosen, Dosen>() {
@Override
protected void updateItem(Dosen cat, boolean empty) {
super.updateItem(cat, empty);
if (cat != null) {
Label label = new Label(cat.getNama());
setGraphic(label);
}else{
setGraphic(null);
}
}
};
return parentCell;
}
;
});
return t;
}
public Collection<TableColumn<Mahasiswa, String>> getAllColumn() {
return column;
}
public ObservableList<Mahasiswa> getItem() {
return row;
}
public void remove(int index) {
row.remove(index);
this.removeAllColumn();
this.initColumn();
}
public void removeAllElement() {
int size = list.size();
for (int i = 0; i < size; i++) {
list.remove(i);
}
this.removeAllColumn();
}
}
|
UTF-8
|
Java
| 4,614 |
java
|
MhsTableModel.java
|
Java
|
[
{
"context": "wing.table.AbstractTableModel;\n\n/**\n *\n * @author 3b1\n */\npublic final class MhsTableModel {\n \n pr",
"end": 742,
"score": 0.8945804834365845,
"start": 739,
"tag": "USERNAME",
"value": "3b1"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.eby.mhs;
import com.eby.orm.entity.Dosen;
import com.eby.orm.entity.Mahasiswa;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.util.Callback;
import javax.swing.table.AbstractTableModel;
/**
*
* @author 3b1
*/
public final class MhsTableModel {
private final List<Mahasiswa> list;
private final ObservableList<Mahasiswa> row;
private final Collection<TableColumn<Mahasiswa, String>> column;
public MhsTableModel() {
list = new ArrayList<>();
row = FXCollections.observableArrayList(list);
column = new ArrayList<>();
this.initColumn();
}
public void initColumn() {
column.add(this.addTableColumn1("NIM", "nim"));
column.add(this.addTableColumn2("NAMA", "nama"));
column.add(this.addTableColumn3("KELAS", "kelas"));
column.add(this.addTableColumn4("ALAMAT", "alamat"));
column.add(this.addTableColumn5("Tgl. LAHIR", "tglLahir"));
column.add(this.getDosen());
// column.add(this.getMahasiswa());
}
public void removeAllColumn() {
while (column.iterator().hasNext()) {
column.remove(column.iterator().next());
}
}
private TableColumn addTableColumn1(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn2(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(125);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn3(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(60);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn4(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn addTableColumn5(String tableHeader, String entityAttribute) {
TableColumn t = new TableColumn(tableHeader);
t.setPrefWidth(100);
t.setCellValueFactory(new PropertyValueFactory<>(entityAttribute));
return t;
}
private TableColumn getDosen() {
TableColumn t = this.addTableColumn2("DOSEN", "dosen");
t.setCellFactory(new Callback< TableColumn<Dosen, Dosen>, TableCell<Dosen, Dosen>>() {
@Override
public TableCell<Dosen, Dosen> call(TableColumn<Dosen, Dosen> param) {
TableCell<Dosen, Dosen> parentCell = new TableCell<Dosen, Dosen>() {
@Override
protected void updateItem(Dosen cat, boolean empty) {
super.updateItem(cat, empty);
if (cat != null) {
Label label = new Label(cat.getNama());
setGraphic(label);
}else{
setGraphic(null);
}
}
};
return parentCell;
}
;
});
return t;
}
public Collection<TableColumn<Mahasiswa, String>> getAllColumn() {
return column;
}
public ObservableList<Mahasiswa> getItem() {
return row;
}
public void remove(int index) {
row.remove(index);
this.removeAllColumn();
this.initColumn();
}
public void removeAllElement() {
int size = list.size();
for (int i = 0; i < size; i++) {
list.remove(i);
}
this.removeAllColumn();
}
}
| 4,614 | 0.609883 | 0.603814 | 143 | 31.265734 | 24.911297 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.664336 | false | false |
13
|
292f929d247c6d10fbfe61d8da9907b502d506fa
| 28,595,892,294,610 |
6518dbafacaa8ad88437ef1a61743cdaead62539
|
/src/test/java/com/app/downloader/transfer/HttpFileTransferClientTest.java
|
7487deb8af890551fd78bf34486e1d96b00065b9
|
[] |
no_license
|
shivasr/DownloadManager
|
https://github.com/shivasr/DownloadManager
|
4ee90d647580b1e1bc3f81dca360a8c6679853b5
|
addabd7853a573b32b3a5370fd4ab1a961b4140a
|
refs/heads/master
| 2021-08-31T04:28:56.234000 | 2017-12-20T10:49:45 | 2017-12-20T10:49:45 | 114,446,726 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package com.app.downloader.transfer;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import com.app.downloader.api.exception.DownloaderException;
/**
* @author shiva
*
*/
public class HttpFileTransferClientTest {
HTTPFileTransferClient httpTransferClient;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
httpTransferClient = new HTTPFileTransferClient("test.rebex.net");
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link com.app.downloader.transfer.HTTPFileTransferClient#downloadFrom(java.lang.String, java.lang.String)}.
* @throws DownloaderException
*/
@Test
public final void testDownloadFrom() throws DownloaderException {
String remoteFile = "https://vignette.wikia.nocookie.net/geosworld/images/0/09/Toon_link.jpg";
String localFile = "/Users/shiva/Downloads/";
HTTPFileTransferClient httpTransferClient = mock(HTTPFileTransferClient.class);
doNothing().when(httpTransferClient).downloadFrom(remoteFile, localFile);
httpTransferClient.downloadFrom(remoteFile, localFile);
}
}
|
UTF-8
|
Java
| 1,336 |
java
|
HttpFileTransferClientTest.java
|
Java
|
[
{
"context": "api.exception.DownloaderException;\n\n/**\n * @author shiva\n *\n */\npublic class HttpFileTransferClientTest {\n",
"end": 365,
"score": 0.9982379674911499,
"start": 360,
"tag": "USERNAME",
"value": "shiva"
}
] | null |
[] |
/**
*
*/
package com.app.downloader.transfer;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import com.app.downloader.api.exception.DownloaderException;
/**
* @author shiva
*
*/
public class HttpFileTransferClientTest {
HTTPFileTransferClient httpTransferClient;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
httpTransferClient = new HTTPFileTransferClient("test.rebex.net");
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link com.app.downloader.transfer.HTTPFileTransferClient#downloadFrom(java.lang.String, java.lang.String)}.
* @throws DownloaderException
*/
@Test
public final void testDownloadFrom() throws DownloaderException {
String remoteFile = "https://vignette.wikia.nocookie.net/geosworld/images/0/09/Toon_link.jpg";
String localFile = "/Users/shiva/Downloads/";
HTTPFileTransferClient httpTransferClient = mock(HTTPFileTransferClient.class);
doNothing().when(httpTransferClient).downloadFrom(remoteFile, localFile);
httpTransferClient.downloadFrom(remoteFile, localFile);
}
}
| 1,336 | 0.757485 | 0.75524 | 53 | 24.207546 | 28.826979 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.981132 | false | false |
13
|
0401a0b6aa2eb4947b91768a673ad03fc0bcc324
| 32,882,269,637,770 |
1cfcd4fd6b075a574eaafcb3b86830de032b90bc
|
/common/src/common/java/info/u_team/music_player/gui/playlist/GuiMusicPlaylistListEntryFunctions.java
|
f945c46b1fc8603c5a06d3d3365ce655a8d7dc32
|
[
"Apache-2.0"
] |
permissive
|
MC-U-Team/Music-Player
|
https://github.com/MC-U-Team/Music-Player
|
7180c21022e9588b90bfc7819f39b83de6a9ed4e
|
e3f8a2f5fefae899e6afa15e7077d755004446c5
|
refs/heads/1.20.1
| 2023-08-31T18:26:47.129000 | 2023-08-28T23:30:54 | 2023-08-28T23:30:54 | 128,273,344 | 71 | 35 |
Apache-2.0
| false | 2023-09-13T04:55:33 | 2018-04-05T22:57:26 | 2023-08-20T03:33:17 | 2023-09-13T04:55:33 | 3,445 | 51 | 18 | 32 |
Java
| false | false |
package info.u_team.music_player.gui.playlist;
import info.u_team.music_player.init.MusicPlayerResources;
import info.u_team.music_player.lavaplayer.api.audio.IAudioTrack;
import info.u_team.music_player.musicplayer.playlist.LoadedTracks;
import info.u_team.music_player.musicplayer.playlist.Playlist;
import info.u_team.music_player.musicplayer.playlist.Playlists;
import info.u_team.music_player.util.WrappedObject;
import info.u_team.u_team_core.gui.elements.ImageButton;
import net.minecraft.client.gui.GuiGraphics;
abstract class GuiMusicPlaylistListEntryFunctions extends GuiMusicPlaylistListEntryPlayable {
protected final Playlist playlist;
protected final WrappedObject<String> uri;
protected final ImageButton deleteTrackButton;
protected final ImageButton upButton, downButton;
GuiMusicPlaylistListEntryFunctions(GuiMusicPlaylistList guilist, Playlists playlists, Playlist playlist, LoadedTracks loadedTrack, IAudioTrack track) {
super(playlists, playlist, loadedTrack, track);
this.playlist = playlist;
uri = loadedTrack.getUri();
deleteTrackButton = addChildren(new ImageButton(0, 0, 20, 20, MusicPlayerResources.TEXTURE_CLEAR));
upButton = addChildren(new ImageButton(0, 0, 20, 10, MusicPlayerResources.TEXTURE_UP));
downButton = addChildren(new ImageButton(0, 0, 20, 10, MusicPlayerResources.TEXTURE_DOWN));
deleteTrackButton.setPressable(() -> {
playlist.remove(uri);
guilist.updateAllEntries();
});
upButton.setPressable(() -> {
playlist.move(uri, 1);
guilist.setSelectedEntryWhenMove(this, -1);
guilist.updateAllEntries();
});
downButton.setPressable(() -> {
playlist.move(uri, -1);
guilist.setSelectedEntryWhenMove(this, 1);
guilist.updateAllEntries();
});
}
@Override
public void render(GuiGraphics guiGraphics, int slotIndex, int entryY, int entryX, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float partialTicks) {
super.render(guiGraphics, slotIndex, entryY, entryX, entryWidth, entryHeight, mouseX, mouseY, hovered, partialTicks);
drawEntryExtended(guiGraphics, entryX, entryY, entryWidth, entryHeight, mouseX, mouseY, hovered, partialTicks);
deleteTrackButton.setX(entryWidth - 15);
deleteTrackButton.setY(entryY + 8);
deleteTrackButton.render(guiGraphics, mouseX, mouseY, partialTicks);
upButton.setX(entryWidth - 40);
upButton.setY(entryY + 8);
upButton.render(guiGraphics, mouseX, mouseY, partialTicks);
downButton.setX(entryWidth - 40);
downButton.setY(entryY + 18);
downButton.render(guiGraphics, mouseX, mouseY, partialTicks);
}
public abstract void drawEntryExtended(GuiGraphics guiGraphics, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean mouseInList, float partialTicks);
}
|
UTF-8
|
Java
| 2,789 |
java
|
GuiMusicPlaylistListEntryFunctions.java
|
Java
|
[] | null |
[] |
package info.u_team.music_player.gui.playlist;
import info.u_team.music_player.init.MusicPlayerResources;
import info.u_team.music_player.lavaplayer.api.audio.IAudioTrack;
import info.u_team.music_player.musicplayer.playlist.LoadedTracks;
import info.u_team.music_player.musicplayer.playlist.Playlist;
import info.u_team.music_player.musicplayer.playlist.Playlists;
import info.u_team.music_player.util.WrappedObject;
import info.u_team.u_team_core.gui.elements.ImageButton;
import net.minecraft.client.gui.GuiGraphics;
abstract class GuiMusicPlaylistListEntryFunctions extends GuiMusicPlaylistListEntryPlayable {
protected final Playlist playlist;
protected final WrappedObject<String> uri;
protected final ImageButton deleteTrackButton;
protected final ImageButton upButton, downButton;
GuiMusicPlaylistListEntryFunctions(GuiMusicPlaylistList guilist, Playlists playlists, Playlist playlist, LoadedTracks loadedTrack, IAudioTrack track) {
super(playlists, playlist, loadedTrack, track);
this.playlist = playlist;
uri = loadedTrack.getUri();
deleteTrackButton = addChildren(new ImageButton(0, 0, 20, 20, MusicPlayerResources.TEXTURE_CLEAR));
upButton = addChildren(new ImageButton(0, 0, 20, 10, MusicPlayerResources.TEXTURE_UP));
downButton = addChildren(new ImageButton(0, 0, 20, 10, MusicPlayerResources.TEXTURE_DOWN));
deleteTrackButton.setPressable(() -> {
playlist.remove(uri);
guilist.updateAllEntries();
});
upButton.setPressable(() -> {
playlist.move(uri, 1);
guilist.setSelectedEntryWhenMove(this, -1);
guilist.updateAllEntries();
});
downButton.setPressable(() -> {
playlist.move(uri, -1);
guilist.setSelectedEntryWhenMove(this, 1);
guilist.updateAllEntries();
});
}
@Override
public void render(GuiGraphics guiGraphics, int slotIndex, int entryY, int entryX, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float partialTicks) {
super.render(guiGraphics, slotIndex, entryY, entryX, entryWidth, entryHeight, mouseX, mouseY, hovered, partialTicks);
drawEntryExtended(guiGraphics, entryX, entryY, entryWidth, entryHeight, mouseX, mouseY, hovered, partialTicks);
deleteTrackButton.setX(entryWidth - 15);
deleteTrackButton.setY(entryY + 8);
deleteTrackButton.render(guiGraphics, mouseX, mouseY, partialTicks);
upButton.setX(entryWidth - 40);
upButton.setY(entryY + 8);
upButton.render(guiGraphics, mouseX, mouseY, partialTicks);
downButton.setX(entryWidth - 40);
downButton.setY(entryY + 18);
downButton.render(guiGraphics, mouseX, mouseY, partialTicks);
}
public abstract void drawEntryExtended(GuiGraphics guiGraphics, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean mouseInList, float partialTicks);
}
| 2,789 | 0.777698 | 0.766224 | 65 | 41.907692 | 41.505039 | 187 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.169231 | false | false |
13
|
01a0e8c6fd66dc3cc7cb780e50456276d4cfbcec
| 32,882,269,637,713 |
00815c2a5975941d1d5b4bfaa0b6e1855b43256b
|
/CloudMarket_Common/src/main/java/com/iza/common/config/UserStatus.java
|
ef568a6a4d0d3cc3ab52a11e64eb4cb2b4cf86a2
|
[] |
no_license
|
izayaha/Cloud_Market
|
https://github.com/izayaha/Cloud_Market
|
bb592d84e619143b375a41be4469b684fd62dc0a
|
040888e12a88845b2ca3a72bddd4e137e2c0d83b
|
refs/heads/master
| 2023-01-07T14:44:31.370000 | 2020-11-07T12:37:28 | 2020-11-07T12:37:28 | 309,928,842 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.iza.common.config;
public enum UserStatus {
已登录(1),锁定(2),已解锁(3);
private int val;
private UserStatus(int v){
val = v;
}
public int getVal(){
return val;
}
}
|
UTF-8
|
Java
| 228 |
java
|
UserStatus.java
|
Java
|
[] | null |
[] |
package com.iza.common.config;
public enum UserStatus {
已登录(1),锁定(2),已解锁(3);
private int val;
private UserStatus(int v){
val = v;
}
public int getVal(){
return val;
}
}
| 228 | 0.556604 | 0.542453 | 12 | 16.666666 | 10.749677 | 32 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false |
13
|
58134c4189552fb8a2338129b2ab60e554aef5ec
| 15,470,472,225,896 |
d94aafe2d4727bc60ff4b91d8a6b296bb6126840
|
/src/test/java/lesson07/a_refactoring_for_page_factory/BaseTest.java
|
9fba805f884902182f3a963d1f469a8e684a9917
|
[] |
no_license
|
QA-automation-engineer/tests-automation
|
https://github.com/QA-automation-engineer/tests-automation
|
af8325fb959209bf8822e617baba81f9fbdc804c
|
402397d0cc93271deaaebfa22f97730d37d915b4
|
refs/heads/master
| 2021-08-31T13:10:37.157000 | 2017-12-21T11:46:04 | 2017-12-21T11:46:04 | 112,730,882 | 0 | 0 | null | false | 2017-12-21T11:46:05 | 2017-12-01T11:08:02 | 2017-12-01T11:10:23 | 2017-12-21T11:46:05 | 41 | 0 | 0 | 0 |
Java
| false | null |
package lesson07.a_refactoring_for_page_factory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class BaseTest extends SimpleAPI{
static WebDriver webDriver;
@BeforeClass
public static void setUp(){
webDriver = new ChromeDriver();
//webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webDriver.manage().window().maximize();
}
@AfterClass
public static void tearDown(){
webDriver.quit();
webDriver = null;
}
@Override
public WebDriver getWebDriver() {
return webDriver;
}
}
|
UTF-8
|
Java
| 689 |
java
|
BaseTest.java
|
Java
|
[] | null |
[] |
package lesson07.a_refactoring_for_page_factory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class BaseTest extends SimpleAPI{
static WebDriver webDriver;
@BeforeClass
public static void setUp(){
webDriver = new ChromeDriver();
//webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webDriver.manage().window().maximize();
}
@AfterClass
public static void tearDown(){
webDriver.quit();
webDriver = null;
}
@Override
public WebDriver getWebDriver() {
return webDriver;
}
}
| 689 | 0.683599 | 0.677794 | 29 | 22.758621 | 19.292048 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.448276 | false | false |
13
|
b899b44f2455ac0df6a8f645b3c4f223e7e63fe1
| 7,078,106,122,206 |
9bd34cf1d42ca1a73a364986f285e3c9be908b3a
|
/Week_04/search2dMatrix.java
|
95fa96afc5b32311f782ed616e779e48153d6cae
|
[] |
no_license
|
531651225/algorithm016
|
https://github.com/531651225/algorithm016
|
6ff311bea0c5bc0d3a659a62408675cb4c541cdf
|
8cd65061fcc07c0d6675dadc81944e07f6db61b5
|
refs/heads/master
| 2023-04-04T05:56:10.648000 | 2021-04-18T08:57:54 | 2021-04-18T08:57:54 | 293,420,392 | 0 | 0 | null | true | 2020-09-07T04:18:48 | 2020-09-07T04:18:48 | 2020-09-07T01:42:14 | 2020-08-31T10:12:12 | 4 | 0 | 0 | 0 | null | false | false |
//编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性:
//
//
// 每行中的整数从左到右按升序排列。
// 每行的第一个整数大于前一行的最后一个整数。
//
//
// 示例 1:
//
// 输入:
//matrix = [
// [1, 3, 5, 7],
// [10, 11, 16, 20],
// [23, 30, 34, 50]
//]
//target = 3
//输出: true
//
//
// 示例 2:
//
// 输入:
//matrix = [
// [1, 3, 5, 7],
// [10, 11, 16, 20],
// [23, 30, 34, 50]
//]
//target = 13
//输出: false
// Related Topics 数组 二分查找
// 👍 251 👎 0
//leetcode submit region begin(Prohibit modification and deletion)
class search2dMatrix {
时间复杂度 : 由于是标准的二分查找,时间复杂度为O(log(mn))
空间复杂度 : O(1)
//将二维处当做一维处理
public boolean searchMatrix(int[][] matrix, int target) {
if (matrix.length == 0 || matrix[0].length == 0) {
return false;
}
int rowl = matrix.length;
int coll = matrix[0].length;
int len = rowl * coll;
int left = 0, right = len - 1;
while (right >= left) {
int mid = left + (right - left) / 2;
int row = mid / coll;
int col = mid % coll;
if (target > matrix[row][col]) {
left = mid + 1;
} else if (target < matrix[row][col]) {
right = mid - 1;
} else {
return true;
}
}
return false;
}
}
时间复杂度 : 由于是标准的二分查找,时间复杂度为O(log(n) + log(m))
空间复杂度 : O(1)
//两个二分
public boolean searchMatrix(int[][] matrix, int target) {
int colStart = 0, colEnd = matrix.length - 1;
if (matrix.length == 0 || matrix[0].length == 0) {
return false;
}
// 1 10 23 mid = 1,target = 11
// left = 1 right = 2 mid = 1
// left = 2 right = 2
int col = matrix[0].length - 1;
while (colEnd > colStart) {
int mid = colStart + (colEnd - colStart) / 2;
if (matrix[mid][col] < target) {
colStart = mid + 1;
} else if (matrix[mid][col] > target){
colEnd = mid;
}else {
return true;
}
}
colStart = colStart;
int left = 0, right = matrix[colStart].length - 1;
while (left <= right) {
int mid= left + (right - left) / 2;
if (matrix[colStart][mid] > target) {
right = mid - 1;
} else if (matrix[colStart][mid] < target) {
left = mid + 1;
}else {
return true;
}
}
return false;
}
//leetcode submit region end(Prohibit modification and deletion)
|
UTF-8
|
Java
| 2,548 |
java
|
search2dMatrix.java
|
Java
|
[] | null |
[] |
//编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性:
//
//
// 每行中的整数从左到右按升序排列。
// 每行的第一个整数大于前一行的最后一个整数。
//
//
// 示例 1:
//
// 输入:
//matrix = [
// [1, 3, 5, 7],
// [10, 11, 16, 20],
// [23, 30, 34, 50]
//]
//target = 3
//输出: true
//
//
// 示例 2:
//
// 输入:
//matrix = [
// [1, 3, 5, 7],
// [10, 11, 16, 20],
// [23, 30, 34, 50]
//]
//target = 13
//输出: false
// Related Topics 数组 二分查找
// 👍 251 👎 0
//leetcode submit region begin(Prohibit modification and deletion)
class search2dMatrix {
时间复杂度 : 由于是标准的二分查找,时间复杂度为O(log(mn))
空间复杂度 : O(1)
//将二维处当做一维处理
public boolean searchMatrix(int[][] matrix, int target) {
if (matrix.length == 0 || matrix[0].length == 0) {
return false;
}
int rowl = matrix.length;
int coll = matrix[0].length;
int len = rowl * coll;
int left = 0, right = len - 1;
while (right >= left) {
int mid = left + (right - left) / 2;
int row = mid / coll;
int col = mid % coll;
if (target > matrix[row][col]) {
left = mid + 1;
} else if (target < matrix[row][col]) {
right = mid - 1;
} else {
return true;
}
}
return false;
}
}
时间复杂度 : 由于是标准的二分查找,时间复杂度为O(log(n) + log(m))
空间复杂度 : O(1)
//两个二分
public boolean searchMatrix(int[][] matrix, int target) {
int colStart = 0, colEnd = matrix.length - 1;
if (matrix.length == 0 || matrix[0].length == 0) {
return false;
}
// 1 10 23 mid = 1,target = 11
// left = 1 right = 2 mid = 1
// left = 2 right = 2
int col = matrix[0].length - 1;
while (colEnd > colStart) {
int mid = colStart + (colEnd - colStart) / 2;
if (matrix[mid][col] < target) {
colStart = mid + 1;
} else if (matrix[mid][col] > target){
colEnd = mid;
}else {
return true;
}
}
colStart = colStart;
int left = 0, right = matrix[colStart].length - 1;
while (left <= right) {
int mid= left + (right - left) / 2;
if (matrix[colStart][mid] > target) {
right = mid - 1;
} else if (matrix[colStart][mid] < target) {
left = mid + 1;
}else {
return true;
}
}
return false;
}
//leetcode submit region end(Prohibit modification and deletion)
| 2,548 | 0.531025 | 0.491457 | 103 | 20.563107 | 16.903305 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.582524 | false | false |
13
|
c91d2867a805da20125b3e6286a15656492c9630
| 26,044,681,691,455 |
028e5e25a15ffadeba0f967c02f133398ffd7fa8
|
/app/src/main/java/solutions/clairthoughts/jlptn4study/domain/KunyoumiReading.java
|
9e96d6b08f42fec3e65a8c3413133e7a2c10a12e
|
[] |
no_license
|
TheImplementer/JLPTN4Study
|
https://github.com/TheImplementer/JLPTN4Study
|
3e99bb4548b36b27e93a43e7831a8619c50b356b
|
c3d3eccf0b92ccf37bf332c9ed28d5ec6ff424c9
|
refs/heads/master
| 2021-01-20T10:29:07.334000 | 2017-03-04T23:55:33 | 2017-03-04T23:55:33 | 83,932,827 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package solutions.clairthoughts.jlptn4study.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
public class KunyoumiReading extends KanjiReading {
private final String reading;
public KunyoumiReading(
@JsonProperty("reading") String reading
) {
this.reading = reading;
}
@Override
public String getReading() {
return reading;
}
}
|
UTF-8
|
Java
| 402 |
java
|
KunyoumiReading.java
|
Java
|
[] | null |
[] |
package solutions.clairthoughts.jlptn4study.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
public class KunyoumiReading extends KanjiReading {
private final String reading;
public KunyoumiReading(
@JsonProperty("reading") String reading
) {
this.reading = reading;
}
@Override
public String getReading() {
return reading;
}
}
| 402 | 0.689055 | 0.686567 | 19 | 20.157894 | 19.858084 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.263158 | false | false |
13
|
c4aafa82954dad92feaa2147daa64f8a32259548
| 21,930,103,066,420 |
e08e7baaa909e6f87781f499d3651768c66001c3
|
/src/game/net/PacketBattleUpdate.java
|
5dab003098e9bb895b081ea24d6df66c70f2ecb2
|
[] |
no_license
|
zakiisak/Java-Quest
|
https://github.com/zakiisak/Java-Quest
|
6d27f0f5a29cc06460c02d174b84ac308def9590
|
f2bebc0b1946e8b0eea75111fc3bfc8988e0edd0
|
refs/heads/master
| 2023-04-30T04:34:15.704000 | 2021-05-13T00:54:57 | 2021-05-13T00:54:57 | 327,353,059 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package game.net;
public class PacketBattleUpdate {
public int[] players;
public Object data;
public PacketBattleUpdate()
{
}
public PacketBattleUpdate(Object data)
{
this.data = data;
}
}
|
UTF-8
|
Java
| 207 |
java
|
PacketBattleUpdate.java
|
Java
|
[] | null |
[] |
package game.net;
public class PacketBattleUpdate {
public int[] players;
public Object data;
public PacketBattleUpdate()
{
}
public PacketBattleUpdate(Object data)
{
this.data = data;
}
}
| 207 | 0.700483 | 0.700483 | 16 | 11.9375 | 12.920279 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.125 | false | false |
13
|
cc20bf199e0bffeb44d3cb52e4e9df19853d8a69
| 30,880,814,876,785 |
00b7c94a66f43f6c8b671d6371509c9a1a69cf79
|
/Dolvomee/src/main/java/co/yedam/dolvomee/command/users/UsersSelect.java
|
57b304ab263b09b9163200efad572ee41e4ecdce
|
[] |
no_license
|
ToDoJacob/Dolvomee
|
https://github.com/ToDoJacob/Dolvomee
|
5722cee4f0879a8372269493aa580dbb03c7d52a
|
1801437e69cb823861516b8571ad90a62a3be204
|
refs/heads/master
| 2023-09-02T05:17:47.221000 | 2021-11-18T12:41:38 | 2021-11-18T12:41:38 | 424,103,559 | 1 | 0 | null | false | 2021-11-18T12:41:39 | 2021-11-03T05:35:02 | 2021-11-18T03:45:32 | 2021-11-18T12:41:39 | 6,748 | 0 | 0 | 1 |
Java
| false | false |
package co.yedam.dolvomee.command.users;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import co.yedam.dolvomee.comm.Command;
import co.yedam.dolvomee.service.users.UsersService;
import co.yedam.dolvomee.service.users.UsersServiceImpl;
import co.yedam.dolvomee.service.users.UsersVO;
public class UsersSelect implements Command {
@Override
public String run(HttpServletRequest request, HttpServletResponse response) {
//회원 리스트에서 회원 조회
UsersService usersDao = new UsersServiceImpl();
UsersVO vo = new UsersVO();
vo.setUsersEmail(request.getParameter("usersEmail"));
vo = usersDao.selectUser(vo);
request.setAttribute("users", vo);
return "users/usersSelect";
}
}
|
UTF-8
|
Java
| 837 |
java
|
UsersSelect.java
|
Java
|
[] | null |
[] |
package co.yedam.dolvomee.command.users;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import co.yedam.dolvomee.comm.Command;
import co.yedam.dolvomee.service.users.UsersService;
import co.yedam.dolvomee.service.users.UsersServiceImpl;
import co.yedam.dolvomee.service.users.UsersVO;
public class UsersSelect implements Command {
@Override
public String run(HttpServletRequest request, HttpServletResponse response) {
//회원 리스트에서 회원 조회
UsersService usersDao = new UsersServiceImpl();
UsersVO vo = new UsersVO();
vo.setUsersEmail(request.getParameter("usersEmail"));
vo = usersDao.selectUser(vo);
request.setAttribute("users", vo);
return "users/usersSelect";
}
}
| 837 | 0.749693 | 0.749693 | 29 | 26.103449 | 22.637085 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.551724 | false | false |
13
|
19ba74d1e7910e13f61cc876f471bd1eff5ff083
| 14,508,399,542,161 |
1d6d43ff87b66794a8faf46f9a3009d189f6c1e4
|
/MyApplication12/app/src/main/java/com/example/administrator/myapplication/BlankFragment2.java
|
81d21ddd634986d5726df7a95c7387eb15751e47
|
[] |
no_license
|
nhoc10mc/Ung-dung-quang-cao-phim
|
https://github.com/nhoc10mc/Ung-dung-quang-cao-phim
|
bb8458200dca626cba5fd3e74e9c9ab0e89401d1
|
bb30d34bc8235c0da2b3b49e037d93471d623ad8
|
refs/heads/master
| 2020-04-10T07:05:02.614000 | 2018-12-07T20:33:23 | 2018-12-07T20:33:23 | 160,872,362 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.administrator.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
/**
* A simple {@link Fragment} subclass.
*/
public class BlankFragment2 extends Fragment {
/**
* Example URL:
* http://i1.ytimg.com/vi/TDFAYRtrYuk/hqdefault.jpg
* For more info:
* http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
*/
String trailerImageUrl = "http://i1.ytimg.com/vi/";
String youtube = "https://www.youtube.com/watch?v=";
ArrayList<Trailer> arrayTrailer;
TrailerAdapter adapterTrailer;
RecyclerView mRecyclerViewTrailer;
RecyclerView.LayoutManager mLayoutManagerTrailer;
public BlankFragment2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank_fragment2, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mRecyclerViewTrailer = (RecyclerView) getActivity().findViewById(R.id.recyclerViewTrailer);
mLayoutManagerTrailer = new LinearLayoutManager(getActivity());
mRecyclerViewTrailer.setLayoutManager(mLayoutManagerTrailer);
arrayTrailer = new ArrayList<>();
adapterTrailer = new TrailerAdapter(getActivity(),R.layout.trailer_item,arrayTrailer);
mRecyclerViewTrailer.setAdapter(adapterTrailer);
getJsonTrailer("https://api.themoviedb.org/3/movie/" + Main3Activity.id + "/videos?api_key=a04329d567415d2371a88fa497271e10");
adapterTrailer.setItemClickListener(new TrailerAdapter.ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick) {
Intent intent = new Intent(getActivity(),PlayVideoTrailerActivity.class);
intent.putExtra("keyVideoTrailer", arrayTrailer.get(position).getKeyTrailer());
startActivity(intent);
}
});
}
private void getJsonTrailer (String url){
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonresults = response.getJSONArray("results");
String trailer_image = "";
String trailer_key = "";
for (int i = 0; i<jsonresults.length(); i++) {
JSONObject jsonresult = jsonresults.getJSONObject(i);
trailer_key = jsonresult.getString("key");
trailer_image = trailerImageUrl + trailer_key + "/hqdefault.jpg";
arrayTrailer.add(new Trailer(trailer_image,trailer_key));
}
adapterTrailer.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity(), "Loi!", Toast.LENGTH_SHORT).show();
}
}
);
requestQueue.add(jsonObjectRequest);
}
}
|
UTF-8
|
Java
| 4,376 |
java
|
BlankFragment2.java
|
Java
|
[
{
"context": "g/3/movie/\" + Main3Activity.id + \"/videos?api_key=a04329d567415d2371a88fa497271e10\");\n adapterTrailer.setItemClickListener(ne",
"end": 2456,
"score": 0.9997219443321228,
"start": 2424,
"tag": "KEY",
"value": "a04329d567415d2371a88fa497271e10"
}
] | null |
[] |
package com.example.administrator.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
/**
* A simple {@link Fragment} subclass.
*/
public class BlankFragment2 extends Fragment {
/**
* Example URL:
* http://i1.ytimg.com/vi/TDFAYRtrYuk/hqdefault.jpg
* For more info:
* http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
*/
String trailerImageUrl = "http://i1.ytimg.com/vi/";
String youtube = "https://www.youtube.com/watch?v=";
ArrayList<Trailer> arrayTrailer;
TrailerAdapter adapterTrailer;
RecyclerView mRecyclerViewTrailer;
RecyclerView.LayoutManager mLayoutManagerTrailer;
public BlankFragment2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank_fragment2, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mRecyclerViewTrailer = (RecyclerView) getActivity().findViewById(R.id.recyclerViewTrailer);
mLayoutManagerTrailer = new LinearLayoutManager(getActivity());
mRecyclerViewTrailer.setLayoutManager(mLayoutManagerTrailer);
arrayTrailer = new ArrayList<>();
adapterTrailer = new TrailerAdapter(getActivity(),R.layout.trailer_item,arrayTrailer);
mRecyclerViewTrailer.setAdapter(adapterTrailer);
getJsonTrailer("https://api.themoviedb.org/3/movie/" + Main3Activity.id + "/videos?api_key=a04329d567415d2371a88fa497271e10");
adapterTrailer.setItemClickListener(new TrailerAdapter.ItemClickListener() {
@Override
public void onClick(View view, int position, boolean isLongClick) {
Intent intent = new Intent(getActivity(),PlayVideoTrailerActivity.class);
intent.putExtra("keyVideoTrailer", arrayTrailer.get(position).getKeyTrailer());
startActivity(intent);
}
});
}
private void getJsonTrailer (String url){
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonresults = response.getJSONArray("results");
String trailer_image = "";
String trailer_key = "";
for (int i = 0; i<jsonresults.length(); i++) {
JSONObject jsonresult = jsonresults.getJSONObject(i);
trailer_key = jsonresult.getString("key");
trailer_image = trailerImageUrl + trailer_key + "/hqdefault.jpg";
arrayTrailer.add(new Trailer(trailer_image,trailer_key));
}
adapterTrailer.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity(), "Loi!", Toast.LENGTH_SHORT).show();
}
}
);
requestQueue.add(jsonObjectRequest);
}
}
| 4,376 | 0.654936 | 0.64511 | 118 | 36.084747 | 31.249292 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.610169 | false | false |
13
|
fcf48d5a750e30434b93b5a9f5bfc13a1c3800f6
| 10,213,432,253,977 |
7a532f7098d402f0aac795853ff321aeaa6961f9
|
/src/main/java/com/quapt/myf4h/product/rest/resources/StatusResource.java
|
e0de3716eebdf812e8f0ba6a1bf1b3c53320c36a
|
[] |
no_license
|
logeshvardhan/chatapp
|
https://github.com/logeshvardhan/chatapp
|
84e671f159f6f064bd268eaff3882d124f32efea
|
658f05d2474da2d2169c87c77702f137683fabd3
|
refs/heads/master
| 2021-07-10T19:49:57.886000 | 2017-10-13T17:48:07 | 2017-10-13T17:48:07 | 106,855,449 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.quapt.myf4h.product.rest.resources;
import java.util.List;
import java.util.Properties;
import javax.inject.Inject;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
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 com.quapt.myf4h.product.core.utill.MailServices;
import com.quapt.myf4h.product.domain.Status;
import com.quapt.myf4h.product.repository.StatusRepository;
@RestController
@RequestMapping("/api/status")
public class StatusResource {
@Inject
private StatusRepository statusRepository;
@Autowired
public JavaMailSender javaMailSender;
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<Status> query() {
List<Status> userStatus = statusRepository.findAll();
return userStatus;
}
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public Status addItem(@RequestBody Status status) {
/*String host = "smtp.gmail.com";
String from = "user";
String pass = "Quapt@123";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("like2eatinfo@gmail.com");
mailMessage.setTo("testing77@mailinator.com");
mailMessage.setSubject("Welcome...!!!");
mailMessage.setText("Hello " +"Mailinator" +"\n Your registration is successfull");
javaMailSender.send(mailMessage);
try {
Session session = Session.getDefaultInstance(props, new MailServices(from, pass));
MimeMessage message = new MimeMessage(session);
Address fromAddress = new InternetAddress(from);
Address toAddress;
toAddress = new InternetAddress("testing77@mailinator.com");
message.setFrom(fromAddress);
message.setRecipient(Message.RecipientType.TO, toAddress);
message.setSubject("Testing JavaMail");
message.setText("Welcome to JavaMail");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
message.saveChanges();
Transport.send(message);
transport.close();
} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
return statusRepository.save(status);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public Status updateStatus(@RequestBody Status updatedStatus, @PathVariable Integer id) {
return statusRepository.save(updatedStatus);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public void deleteItem(@PathVariable Long id) {
Status status = statusRepository.findOne((Long)id);
statusRepository.delete(status);
}
}
|
UTF-8
|
Java
| 4,034 |
java
|
StatusResource.java
|
Java
|
[
{
"context": " String from = \"user\";\r\n String pass = \"Quapt@123\";\r\n\t Properties props = System.getProperties()",
"end": 1778,
"score": 0.9993076920509338,
"start": 1769,
"tag": "PASSWORD",
"value": "Quapt@123"
},
{
"context": "\", from);\r\n props.put(\"mail.smtp.password\", pass);\r\n props.put(\"mail.smtp.port\", \"587\");\r\n ",
"end": 2020,
"score": 0.9990102052688599,
"start": 2016,
"tag": "PASSWORD",
"value": "pass"
},
{
"context": " new SimpleMailMessage();\r\n\t\tmailMessage.setFrom(\"like2eatinfo@gmail.com\");\r\n mailMessage.setTo(\"testing77@mailinat",
"end": 2269,
"score": 0.9999298453330994,
"start": 2247,
"tag": "EMAIL",
"value": "like2eatinfo@gmail.com"
},
{
"context": "2eatinfo@gmail.com\");\r\n mailMessage.setTo(\"testing77@mailinator.com\");\r\n mailMessage.setSubject(\"Welcome...!!!",
"end": 2325,
"score": 0.9999301433563232,
"start": 2301,
"tag": "EMAIL",
"value": "testing77@mailinator.com"
},
{
"context": "s toAddress;\r\n\t\t\ttoAddress = new InternetAddress(\"testing77@mailinator.com\");\r\n\t\t\tmessage.setFrom(fromAddress);\r\n\t me",
"end": 2836,
"score": 0.9999311566352844,
"start": 2812,
"tag": "EMAIL",
"value": "testing77@mailinator.com"
}
] | null |
[] |
package com.quapt.myf4h.product.rest.resources;
import java.util.List;
import java.util.Properties;
import javax.inject.Inject;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
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 com.quapt.myf4h.product.core.utill.MailServices;
import com.quapt.myf4h.product.domain.Status;
import com.quapt.myf4h.product.repository.StatusRepository;
@RestController
@RequestMapping("/api/status")
public class StatusResource {
@Inject
private StatusRepository statusRepository;
@Autowired
public JavaMailSender javaMailSender;
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<Status> query() {
List<Status> userStatus = statusRepository.findAll();
return userStatus;
}
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public Status addItem(@RequestBody Status status) {
/*String host = "smtp.gmail.com";
String from = "user";
String pass = "<PASSWORD>";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", <PASSWORD>);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("<EMAIL>");
mailMessage.setTo("<EMAIL>");
mailMessage.setSubject("Welcome...!!!");
mailMessage.setText("Hello " +"Mailinator" +"\n Your registration is successfull");
javaMailSender.send(mailMessage);
try {
Session session = Session.getDefaultInstance(props, new MailServices(from, pass));
MimeMessage message = new MimeMessage(session);
Address fromAddress = new InternetAddress(from);
Address toAddress;
toAddress = new InternetAddress("<EMAIL>");
message.setFrom(fromAddress);
message.setRecipient(Message.RecipientType.TO, toAddress);
message.setSubject("Testing JavaMail");
message.setText("Welcome to JavaMail");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
message.saveChanges();
Transport.send(message);
transport.close();
} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
return statusRepository.save(status);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public Status updateStatus(@RequestBody Status updatedStatus, @PathVariable Integer id) {
return statusRepository.save(updatedStatus);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public void deleteItem(@PathVariable Long id) {
Status status = statusRepository.findOne((Long)id);
statusRepository.delete(status);
}
}
| 3,992 | 0.714427 | 0.710709 | 108 | 35.351852 | 25.602486 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.518519 | false | false |
13
|
10ff49e46759a576753f2619140b67a27e21a772
| 19,172,734,044,008 |
a7d7bf24961f9b7388717a15512945fa45f84106
|
/sample/src/main/java/com/sdk/dyq/sample/dyq_test/adapter/RecyclerViewTestAdapter.java
|
ec2c199f129e4c5a67bfb3398fa2da5a93cc914f
|
[] |
no_license
|
could-deng/MultiTypeModel
|
https://github.com/could-deng/MultiTypeModel
|
90ff4029de3f31aac9d3c1270008225e7cbfe196
|
1ac07828e66f24da2af6575e492928c1d4deaa3d
|
refs/heads/master
| 2020-12-30T18:02:49.089000 | 2017-05-11T07:14:31 | 2017-05-11T07:14:31 | 90,945,652 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sdk.dyq.sample.dyq_test.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.sdk.dyq.multitypemodel.R;
import com.sdk.dyq.sample.dyq_test.Bean.MessageBean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yuanqiang on 2017/5/9.
*/
public class RecyclerViewTestAdapter extends RecyclerView.Adapter<RecyclerViewTestAdapter.ViewHolder>{
private static final int ME = 11;//自己
private static final int OTHER = 12;//他人
private List<MessageBean> beanList;
public RecyclerViewTestAdapter() {
beanList = null;
}
public void setBeanList(List<MessageBean> msgList){
if((beanList!=null)&& beanList!=msgList){
beanList.clear();
}
beanList = msgList;
notifyDataSetChanged();
}
private List<MessageBean> getBeanList(){
if(beanList == null) beanList = new ArrayList<>();
return beanList;
}
@Override
public int getItemViewType(int position) {
int viewType;
MessageBean bean = getBeanList().get(position);
if(bean.getId() == 0){
viewType = ME;
}else {
viewType = OTHER;
}
return viewType;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
ViewGroup view;
switch (viewType){
case ME:
view = (ViewGroup) mInflater.inflate(R.layout.listview_message_mine_item,parent,false);
//不能写成:ViewGroup member = mInflater.inflate(R.layout.listview_message_item,null);
return new MineViewHolder(view);
case OTHER:
view = (ViewGroup) mInflater.inflate(R.layout.listview_message_item,parent,false);
return new MemberViewHolder(view);
}
return null;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
MessageBean bean = getBeanList().get(position);
switch (holder.getItemViewType()){
case ME:
((MineViewHolder)holder).tv_member_name.setText("我");
((MineViewHolder)holder).tv_message.setText(bean.getMsgContent());
break;
case OTHER:
((MemberViewHolder)holder).tv_member_name.setText(bean.getName());
((MemberViewHolder)holder).tv_message.setText(bean.getMsgContent());
break;
}
}
@Override
public int getItemCount() {
return beanList.size();
}
/**
* 基类
*/
public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View itemView) {
super(itemView);
}
}
public class MemberViewHolder extends ViewHolder{
public ImageView img_member_avatar;
public TextView tv_member_name;
public TextView tv_message;
public TextView tv_message_time;
public MemberViewHolder(View itemView) {
super(itemView);
img_member_avatar = (ImageView) itemView.findViewById(R.id.img_member_avatar);
tv_member_name = (TextView) itemView.findViewById(R.id.tv_member_name);
tv_message = (TextView) itemView.findViewById(R.id.tv_message);
tv_message_time = (TextView) itemView.findViewById(R.id.tv_message_time);
}
}
public class MineViewHolder extends ViewHolder {
public ImageView img_member_avatar;
public TextView tv_member_name;
public TextView tv_message;
public TextView tv_message_time;
public MineViewHolder(View itemView) {
super(itemView);
img_member_avatar = (ImageView) itemView.findViewById(R.id.img_member_avatar);
tv_member_name = (TextView) itemView.findViewById(R.id.tv_member_name);
tv_message = (TextView) itemView.findViewById(R.id.tv_message);
tv_message_time = (TextView) itemView.findViewById(R.id.tv_message_time);
}
}
}
|
UTF-8
|
Java
| 4,266 |
java
|
RecyclerViewTestAdapter.java
|
Java
|
[
{
"context": "rayList;\nimport java.util.List;\n\n/**\n * Created by yuanqiang on 2017/5/9.\n */\n\npublic class RecyclerViewTestAd",
"end": 422,
"score": 0.9994563460350037,
"start": 413,
"tag": "USERNAME",
"value": "yuanqiang"
}
] | null |
[] |
package com.sdk.dyq.sample.dyq_test.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.sdk.dyq.multitypemodel.R;
import com.sdk.dyq.sample.dyq_test.Bean.MessageBean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yuanqiang on 2017/5/9.
*/
public class RecyclerViewTestAdapter extends RecyclerView.Adapter<RecyclerViewTestAdapter.ViewHolder>{
private static final int ME = 11;//自己
private static final int OTHER = 12;//他人
private List<MessageBean> beanList;
public RecyclerViewTestAdapter() {
beanList = null;
}
public void setBeanList(List<MessageBean> msgList){
if((beanList!=null)&& beanList!=msgList){
beanList.clear();
}
beanList = msgList;
notifyDataSetChanged();
}
private List<MessageBean> getBeanList(){
if(beanList == null) beanList = new ArrayList<>();
return beanList;
}
@Override
public int getItemViewType(int position) {
int viewType;
MessageBean bean = getBeanList().get(position);
if(bean.getId() == 0){
viewType = ME;
}else {
viewType = OTHER;
}
return viewType;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
ViewGroup view;
switch (viewType){
case ME:
view = (ViewGroup) mInflater.inflate(R.layout.listview_message_mine_item,parent,false);
//不能写成:ViewGroup member = mInflater.inflate(R.layout.listview_message_item,null);
return new MineViewHolder(view);
case OTHER:
view = (ViewGroup) mInflater.inflate(R.layout.listview_message_item,parent,false);
return new MemberViewHolder(view);
}
return null;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
MessageBean bean = getBeanList().get(position);
switch (holder.getItemViewType()){
case ME:
((MineViewHolder)holder).tv_member_name.setText("我");
((MineViewHolder)holder).tv_message.setText(bean.getMsgContent());
break;
case OTHER:
((MemberViewHolder)holder).tv_member_name.setText(bean.getName());
((MemberViewHolder)holder).tv_message.setText(bean.getMsgContent());
break;
}
}
@Override
public int getItemCount() {
return beanList.size();
}
/**
* 基类
*/
public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View itemView) {
super(itemView);
}
}
public class MemberViewHolder extends ViewHolder{
public ImageView img_member_avatar;
public TextView tv_member_name;
public TextView tv_message;
public TextView tv_message_time;
public MemberViewHolder(View itemView) {
super(itemView);
img_member_avatar = (ImageView) itemView.findViewById(R.id.img_member_avatar);
tv_member_name = (TextView) itemView.findViewById(R.id.tv_member_name);
tv_message = (TextView) itemView.findViewById(R.id.tv_message);
tv_message_time = (TextView) itemView.findViewById(R.id.tv_message_time);
}
}
public class MineViewHolder extends ViewHolder {
public ImageView img_member_avatar;
public TextView tv_member_name;
public TextView tv_message;
public TextView tv_message_time;
public MineViewHolder(View itemView) {
super(itemView);
img_member_avatar = (ImageView) itemView.findViewById(R.id.img_member_avatar);
tv_member_name = (TextView) itemView.findViewById(R.id.tv_member_name);
tv_message = (TextView) itemView.findViewById(R.id.tv_message);
tv_message_time = (TextView) itemView.findViewById(R.id.tv_message_time);
}
}
}
| 4,266 | 0.630302 | 0.627474 | 128 | 32.15625 | 27.562269 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.523438 | false | false |
13
|
3dc67f909fa99838437be54770babe206b5fd21d
| 24,386,824,313,990 |
b471f95ac0b354246d2f93211dbbccf4b5583d1e
|
/src/main/java/ua/com/novopacksv/production/converter/datetime/LocalDateToStringConverter.java
|
3fc4243b21c4d83360efb064ce89534d8354c398
|
[] |
no_license
|
RyzhkovAndrii/javaproject
|
https://github.com/RyzhkovAndrii/javaproject
|
d4fd22cbcd57375ce9e79118e8da6b9ca8af8f2b
|
f9642d06937c800705272c80507117c279a36851
|
HEAD
| 2018-07-28T23:49:07.554000 | 2018-06-02T15:31:09 | 2018-06-02T15:31:09 | 129,460,390 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ua.com.novopacksv.production.converter.datetime;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@Component
public class LocalDateToStringConverter implements Converter<LocalDate, String> {
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
@Nullable
@Override
public String convert(@Nullable LocalDate localDate) {
return localDate == null ? null : localDate.format(formatter);
}
}
|
UTF-8
|
Java
| 635 |
java
|
LocalDateToStringConverter.java
|
Java
|
[] | null |
[] |
package ua.com.novopacksv.production.converter.datetime;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@Component
public class LocalDateToStringConverter implements Converter<LocalDate, String> {
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
@Nullable
@Override
public String convert(@Nullable LocalDate localDate) {
return localDate == null ? null : localDate.format(formatter);
}
}
| 635 | 0.788976 | 0.788976 | 21 | 29.285715 | 29.75478 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false |
13
|
1b1a3d67db85d9ea1325fe514a3858e4eed93f55
| 1,511,828,551,642 |
39a58812ca3773c0ff7549d6a03e5480c7cce648
|
/WithErrorMessageNim.java
|
4a4102723f6b13543fe5399a63c1a14070cae421
|
[] |
no_license
|
lizmao9/Unit2_practice1
|
https://github.com/lizmao9/Unit2_practice1
|
c7b1aed95a3f686ff06346049ceefb438c8c4e61
|
23b7fddd42cd259c27c882e26475a7adf9d5ac97
|
refs/heads/master
| 2020-04-03T11:25:51.464000 | 2018-10-29T14:58:16 | 2018-10-29T14:58:16 | 155,221,427 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Scanner;
import java.util.Random;
/**
* Nim is a game that proceeds as following:
* 1.An assigned number of sticks (>= 1) are placed in a row.
* 2.Two players alternate turns picking up one or two sticks.
* 3.The player who picks up the last stick loses.
*
* The user can choose to play with another player or AI.
*
* @author Liz and Amy
* @version 10/29/17
*/
public class WithErrorMessageNim{
static Scanner in = new Scanner(System.in);
static int countStick;
static int roundCount = 0;
static int mode = 0;
public static void main (String[] args) {
System.out.println("\nWelcome to NIM!");
System.out.println("Here are the rules:\n 1.An assigned number of sticks (>= 1) are placed in a row.\n 2.Two players alternate turns picking up one or two sticks.\n 3.The player who picks up the last stick loses.");
System.out.println("Enter number to select mode:\n 1. Two players\n 2. Play with AI");
//User chooses to play with another player or AI
mode = in.nextInt();
if (mode != 1 && mode != 2){
System.err.print("Error: Invalid mode selection");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
} else if (mode == 2) {
System.out.println("You will be player 1 while the AI will be player 2");
}
//Asks user for intial output
System.out.println("How many sticks do you want to start with?");
countStick = in.nextInt();
//If user puts in 0 or 1 initially (which blocks the game from proceeding),
//the system prints an error message and restart the whole game.
if (countStick == 0 || countStick == 1) {
System.err.println("Error: Invalid initial input\n");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
} else {
removeStick(0); //print out the number of sticks chosen
while (countStick != 1){
roundCount++;
if (roundCount % 2 == 1) {//Player 1's round
System.out.print("Player 1 removes how many sticks? ");
int playerRemove = in.nextInt();
inputVerify(playerRemove);
if (countStick == 1){//Determines winner
System.out.println("Player 1 wins!");
break;
}
} else {//Player 2's round
if (mode == 1) {//Two players
System.out.print("Player 2 removes how many sticks? ");
int playerRemove = in.nextInt();
inputVerify(playerRemove);
} else {//Play with AI (random generates number)
Random random = new Random();
int playerRemove = (int)(Math.random()*2 + 1);
System.out.println("AI removes " + playerRemove);
inputVerify(playerRemove);
}
if (countStick == 1){//Determines winner
System.out.println("Player2 wins!");
break;
}
}
}
}
}
//Method to remove input number of sticks
public static void removeStick(int input) {
if (input < countStick) {//make sure the input is smaller than current number of sticks
int count = 0;
for (int i = 0; i <(countStick - input); i++){
System.out.print("|");
count++;
}
System.out.println(" ");
countStick = count;
} else {//error message
System.err.print("Error: Input equals current stick count.");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
}
}
//Verifies if user only put in 1 or 2 sticks to remove
public static void inputVerify(int input) {
if (input == 1 || input == 2) {//removes stick
removeStick(input);
} else {//error message
System.err.println("Error: You should only be removing 1 or 2 sticks at a time.");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
}
}
}
|
UTF-8
|
Java
| 4,425 |
java
|
WithErrorMessageNim.java
|
Java
|
[
{
"context": "e to play with another player or AI.\n *\n * @author Liz and Amy\n * @version 10/29/17\n */\npublic class WithErr",
"end": 359,
"score": 0.9989421367645264,
"start": 352,
"tag": "NAME",
"value": "Liz and"
},
{
"context": "y with another player or AI.\n *\n * @author Liz and Amy\n * @version 10/29/17\n */\npublic class WithErrorMe",
"end": 363,
"score": 0.9899499416351318,
"start": 360,
"tag": "NAME",
"value": "Amy"
},
{
"context": ");\n String[] arguments = new String[]{\"Liz and Amy\"};\n WithErrorMessageNim.main(arguments",
"end": 3902,
"score": 0.8205693960189819,
"start": 3891,
"tag": "NAME",
"value": "Liz and Amy"
}
] | null |
[] |
import java.util.Scanner;
import java.util.Random;
/**
* Nim is a game that proceeds as following:
* 1.An assigned number of sticks (>= 1) are placed in a row.
* 2.Two players alternate turns picking up one or two sticks.
* 3.The player who picks up the last stick loses.
*
* The user can choose to play with another player or AI.
*
* @author <NAME> Amy
* @version 10/29/17
*/
public class WithErrorMessageNim{
static Scanner in = new Scanner(System.in);
static int countStick;
static int roundCount = 0;
static int mode = 0;
public static void main (String[] args) {
System.out.println("\nWelcome to NIM!");
System.out.println("Here are the rules:\n 1.An assigned number of sticks (>= 1) are placed in a row.\n 2.Two players alternate turns picking up one or two sticks.\n 3.The player who picks up the last stick loses.");
System.out.println("Enter number to select mode:\n 1. Two players\n 2. Play with AI");
//User chooses to play with another player or AI
mode = in.nextInt();
if (mode != 1 && mode != 2){
System.err.print("Error: Invalid mode selection");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
} else if (mode == 2) {
System.out.println("You will be player 1 while the AI will be player 2");
}
//Asks user for intial output
System.out.println("How many sticks do you want to start with?");
countStick = in.nextInt();
//If user puts in 0 or 1 initially (which blocks the game from proceeding),
//the system prints an error message and restart the whole game.
if (countStick == 0 || countStick == 1) {
System.err.println("Error: Invalid initial input\n");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
} else {
removeStick(0); //print out the number of sticks chosen
while (countStick != 1){
roundCount++;
if (roundCount % 2 == 1) {//Player 1's round
System.out.print("Player 1 removes how many sticks? ");
int playerRemove = in.nextInt();
inputVerify(playerRemove);
if (countStick == 1){//Determines winner
System.out.println("Player 1 wins!");
break;
}
} else {//Player 2's round
if (mode == 1) {//Two players
System.out.print("Player 2 removes how many sticks? ");
int playerRemove = in.nextInt();
inputVerify(playerRemove);
} else {//Play with AI (random generates number)
Random random = new Random();
int playerRemove = (int)(Math.random()*2 + 1);
System.out.println("AI removes " + playerRemove);
inputVerify(playerRemove);
}
if (countStick == 1){//Determines winner
System.out.println("Player2 wins!");
break;
}
}
}
}
}
//Method to remove input number of sticks
public static void removeStick(int input) {
if (input < countStick) {//make sure the input is smaller than current number of sticks
int count = 0;
for (int i = 0; i <(countStick - input); i++){
System.out.print("|");
count++;
}
System.out.println(" ");
countStick = count;
} else {//error message
System.err.print("Error: Input equals current stick count.");
String[] arguments = new String[]{"<NAME>"};
WithErrorMessageNim.main(arguments);
}
}
//Verifies if user only put in 1 or 2 sticks to remove
public static void inputVerify(int input) {
if (input == 1 || input == 2) {//removes stick
removeStick(input);
} else {//error message
System.err.println("Error: You should only be removing 1 or 2 sticks at a time.");
String[] arguments = new String[]{"Liz and Amy"};
WithErrorMessageNim.main(arguments);
}
}
}
| 4,419 | 0.545989 | 0.534689 | 101 | 42.821781 | 30.054867 | 228 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.544554 | false | false |
13
|
a41b56fef5c01c901cd80a45aa036f687a17c145
| 4,011,499,477,574 |
c82f89b0e6d1547c2829422e7de7664b378c1039
|
/src/com/hongyu/controller/HyTicketSceneController.java
|
cfbbbdbf9e2362a18fcd8fb9b05613b8e9e91deb
|
[] |
no_license
|
chenxiaoyin3/shetuan_backend
|
https://github.com/chenxiaoyin3/shetuan_backend
|
1bab5327cafd42c8086c25ade7e8ce08fda6a1ac
|
e21a0b14a2427c9ad52ed00f68d5cce2689fdaeb
|
refs/heads/master
| 2022-05-15T14:52:07.137000 | 2022-04-07T03:30:57 | 2022-04-07T03:30:57 | 250,762,749 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.hongyu.controller;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import com.hongyu.CommonAttributes;
import com.hongyu.Filter;
import com.hongyu.Json;
import com.hongyu.Order;
import com.hongyu.Page;
import com.hongyu.Pageable;
import com.hongyu.controller.HyTicketHotelandsceneController.WrapInbound;
import com.hongyu.entity.CommonSequence.SequenceTypeEnum;
import com.hongyu.entity.CommonSequence;
import com.hongyu.entity.HyAdmin;
import com.hongyu.entity.HyArea;
import com.hongyu.entity.HyTicketInbound;
import com.hongyu.entity.HyTicketScene;
import com.hongyu.entity.HyTicketSceneTicketManagement;
import com.hongyu.entity.HyRoleAuthority.CheckedOperation;
import com.hongyu.entity.HySupplierContract.ContractStatus;
import com.hongyu.entity.HySupplierElement.SupplierType;
import com.hongyu.entity.HySupplier;
import com.hongyu.entity.HySupplierContract;
import com.hongyu.entity.HySupplierElement;
import com.hongyu.entity.HyTicketHotelRoom;
import com.hongyu.entity.HyTicketPriceInbound;
import com.hongyu.service.CommonSequenceService;
import com.hongyu.service.HyAdminService;
import com.hongyu.service.HyAreaService;
import com.hongyu.service.HySupplierContractService;
import com.hongyu.service.HySupplierElementService;
import com.hongyu.service.HySupplierService;
import com.hongyu.service.HyTicketInboundService;
import com.hongyu.service.HyTicketPriceInboundService;
import com.hongyu.service.HyTicketSceneService;
import com.hongyu.service.HyTicketSceneTicketManagementService;
import com.hongyu.util.AuthorityUtils;
@Controller
@RequestMapping("/admin/internTicket/scenic/")
public class HyTicketSceneController {
@Resource
private TaskService taskService;
@Resource
private HistoryService historyService;
@Resource
private RuntimeService runtimeService;
@Resource(name="hyAdminServiceImpl")
private HyAdminService hyAdminService;
@Resource(name="hySupplierServiceImpl")
private HySupplierService hySupplierService;
@Resource(name="hyTicketSceneServiceImpl")
private HyTicketSceneService hyTicketSceneService;
@Resource(name="hyAreaServiceImpl")
private HyAreaService hyAreaService;
@Resource(name="hyTicketSceneTicketManagementServiceImpl")
private HyTicketSceneTicketManagementService hyTicketSceneTicketManagementService;
@Resource(name="commonSequenceServiceImp")
private CommonSequenceService commonSequenceService;
@Resource(name="hyTicketPriceInboundServiceImpl")
private HyTicketPriceInboundService hyTicketPriceInboundService;
@Resource(name="hySupplierElementServiceImpl")
private HySupplierElementService hySupplierElementService;
@Resource(name="hySupplierContractServiceImpl")
private HySupplierContractService hySupplierContractService;
@Resource(name="hyTicketInboundServiceImpl")
private HyTicketInboundService hyTicketInboundService;
@RequestMapping(value="list/view")
@ResponseBody
public Json list(Pageable pageable,String sceneName,String creatorName,HttpSession session,HttpServletRequest request)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=new HyTicketScene();
Map<String,Object> map=new HashMap<String,Object>();
List<HashMap<String, Object>> list = new ArrayList<>();
/**
* 获取当前用户
*/
String username = (String) session.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
/**
* 获取用户权限范围
*/
CheckedOperation co=(CheckedOperation) request.getAttribute("co");
/** 所有符合条件的账号 ,默认可以看到自己创建的数据 */
Set<HyAdmin> hyAdmins = AuthorityUtils.getAdmins(session, request);
List<Filter> sceneFilter=new ArrayList<Filter>();
sceneFilter.add(Filter.in("creator",hyAdmins));
if(sceneName!=null&&!sceneName.equals(""))
{
sceneFilter.add(Filter.like("sceneName", sceneName));
}
List<Filter> filter=new ArrayList<Filter>();
if(creatorName!=null&&!creatorName.equals(""))
{
filter.add(Filter.like("name",creatorName));
List<HyAdmin> adminList=hyAdminService.findList(null,filter,null);
if(adminList.size()==0){
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(new Page<HyTicketScene>());
}
else{
sceneFilter.add(Filter.in("creator", adminList));
List<Filter> supplierFilter=new ArrayList<Filter>();
supplierFilter.add(Filter.eq("liable", findPAdmin(admin))); //帅选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,supplierFilter,null); //根据合同找到供应商
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
sceneFilter.add(Filter.eq("ticketSupplier", hySupplier));
}
pageable.setFilters(sceneFilter);
List<Order> orders = new ArrayList<Order>();
orders.add(Order.desc("createTime"));
pageable.setOrders(orders);
Page<HyTicketScene> page=hyTicketSceneService.findPage(pageable,hyTicketScene);
if(page.getTotal()>0){
for(HyTicketScene scene:page.getRows()){
HashMap<String,Object> sceneMap=new HashMap<String,Object>();
HyAdmin creator=scene.getCreator();
sceneMap.put("id", scene.getId());
sceneMap.put("sceneName", scene.getSceneName());
List<HyTicketSceneTicketManagement> ticketList =new ArrayList<>(scene.getHyTicketSceneTickets());
//算出最近价格日期和最低价格
if(ticketList.size()>0){
List<Date> dateList=new ArrayList<>();
List<BigDecimal> priceList=new ArrayList<>();
for(HyTicketSceneTicketManagement ticket:ticketList){
List<HyTicketPriceInbound> inboundPrices=new ArrayList<>(ticket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound inboundPrice:inboundPrices) {
dateList.add(inboundPrice.getEndDate());
//时间过滤时分秒
Date date=DateUtils.truncate(new Date(), Calendar.DATE);
if(inboundPrice.getEndDate().compareTo(date)>=0){
priceList.add(inboundPrice.getSettlementPrice());
}
}
}
if(!dateList.isEmpty()) {
Date latestPriceDate=Collections.max(dateList);
sceneMap.put("latestPriceDate",latestPriceDate);
}
if(!priceList.isEmpty()) {
BigDecimal lowestPrice=Collections.min(priceList);
sceneMap.put("lowestPrice",lowestPrice);
}
}
sceneMap.put("createTime", scene.getCreateTime());
sceneMap.put("creatorName", scene.getCreator().getName());
//查找是否有上架产品,判断是否可编辑
List<HyTicketSceneTicketManagement> sceneTickets=new ArrayList<>(scene.getHyTicketSceneTickets());
int flag=1; //标志位
for(HyTicketSceneTicketManagement sceneTicket:sceneTickets) {
//如果有已上架产品
if(sceneTicket.getSaleStatus()==2) {
flag=0;
break;
}
}
sceneMap.put("isEdit",flag); //是否可编辑,1-可编辑,0-不可编辑
/** 当前用户对本条数据的操作权限 */
if(creator.equals(admin)){
if(co==CheckedOperation.view){
sceneMap.put("privilege", "view");
}
else{
sceneMap.put("privilege", "edit");
}
}
else{
if(co==CheckedOperation.edit){
sceneMap.put("privilege", "edit");
}
else{
sceneMap.put("privilege", "view");
}
}
list.add(sceneMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
}
//creatorName!=null
else{
List<Filter> supplierFilter=new ArrayList<Filter>();
supplierFilter.add(Filter.eq("liable", admin)); //帅选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,supplierFilter,null); //根据合同找到供应商
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
sceneFilter.add(Filter.eq("ticketSupplier", hySupplier));
}
pageable.setFilters(sceneFilter);
List<Order> orders = new ArrayList<Order>();
orders.add(Order.desc("createTime"));
pageable.setOrders(orders);
Page<HyTicketScene> page=hyTicketSceneService.findPage(pageable,hyTicketScene);
if(page.getTotal()>0){
for(HyTicketScene scene:page.getRows()){
HashMap<String,Object> sceneMap=new HashMap<String,Object>();
HyAdmin creator=scene.getCreator();
sceneMap.put("id", scene.getId());
sceneMap.put("sceneName", scene.getSceneName());
List<HyTicketSceneTicketManagement> ticketList =new ArrayList<>(scene.getHyTicketSceneTickets());
//算出最近价格日期和最低价格
if(ticketList.size()>0){
List<Date> dateList=new ArrayList<>();
List<BigDecimal> priceList=new ArrayList<>();
for(HyTicketSceneTicketManagement ticket:ticketList){
List<HyTicketPriceInbound> inboundPrices=new ArrayList<>(ticket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound inboundPrice:inboundPrices) {
dateList.add(inboundPrice.getEndDate());
//时间过滤时分秒
Date date=DateUtils.truncate(new Date(), Calendar.DATE);
if(inboundPrice.getEndDate().compareTo(date)>=0){
priceList.add(inboundPrice.getSettlementPrice());
}
}
}
if(!dateList.isEmpty()) {
Date latestPriceDate=Collections.max(dateList);
sceneMap.put("latestPriceDate",latestPriceDate);
}
if(!priceList.isEmpty()) {
BigDecimal lowestPrice=Collections.min(priceList);
sceneMap.put("lowestPrice",lowestPrice);
}
}
sceneMap.put("createTime", scene.getCreateTime());
sceneMap.put("creatorName", scene.getCreator().getName());
//查找是否有上架产品,判断是否可编辑
List<HyTicketSceneTicketManagement> sceneTickets=new ArrayList<>(scene.getHyTicketSceneTickets());
int flag=1; //标志位
for(HyTicketSceneTicketManagement sceneTicket:sceneTickets) {
//如果有已上架产品
if(sceneTicket.getSaleStatus()==1) {
flag=0;
break;
}
}
sceneMap.put("isEdit",flag); //是否可编辑,1-可编辑,0-不可编辑
/** 当前用户对本条数据的操作权限 */
if(creator.equals(admin)){
if(co==CheckedOperation.view){
sceneMap.put("privilege", "view");
}
else{
sceneMap.put("privilege", "edit");
}
}
else{
if(co==CheckedOperation.edit){
sceneMap.put("privilege", "edit");
}
else{
sceneMap.put("privilege", "view");
}
}
list.add(sceneMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
e.printStackTrace();
}
return json;
}
@RequestMapping(value="add", method = RequestMethod.POST)
@ResponseBody
public Json add(HyTicketScene hyTicketScene,Long areaId,Long supplierId,HttpSession session)
{
Json json=new Json();
try{
HyArea hyArea=hyAreaService.find(areaId);
hyTicketScene.setArea(hyArea);
if(supplierId!=null) {
HySupplierElement piaowubuGongyingshang=hySupplierElementService.find(supplierId);
hyTicketScene.setHySupplierElement(piaowubuGongyingshang);
}
hyTicketScene.setCreateTime(new Date());
/**
* 获取当前用户
*/
String username = (String) session.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
Boolean flag = false;
//新增只有供应商合同为正常才可以新建门票
if(admin.getHyAdmin() != null) {
HyAdmin parent = admin.getHyAdmin();
Set<HySupplierContract> supplierContracts = parent.getLiableContracts();
for(HySupplierContract c : supplierContracts) {
if(c.getContractStatus() == ContractStatus.zhengchang) {
flag = true;
break;
}
}
} else {
Set<HySupplierContract> supplierContracts1 = admin.getLiableContracts();
for(HySupplierContract c : supplierContracts1) {
if(c.getContractStatus() == ContractStatus.zhengchang) {
flag = true;
break;
}
}
}
if(flag == false) {
json.setMsg("供应商合同状态错误");
json.setSuccess(false);
return json;
}
hyTicketScene.setCreator(admin);
List<Filter> filters=new ArrayList<Filter>();
filters.add(Filter.eq("liable", findPAdmin(admin))); //筛选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,filters,null); //根据合同找到供应商
filters.clear();
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
hyTicketScene.setTicketSupplier(hySupplier);
}
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
filters.add(Filter.eq("type", SequenceTypeEnum.piaowujingquPn));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
filters.clear();
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="JQ-" + dateStr + "-" + String.format("%04d", value);
}
hyTicketScene.setPn(produc);
hyTicketScene.setMhState(0); //将门户完善状态设为未完善
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());//初始化门户推广文件
hyTicketSceneService.save(hyTicketScene);
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="edit")
@ResponseBody
public Json edit(HyTicketScene hyTicketScene,Long areaId,Long supplierId)
{
Json json=new Json();
try{
HyArea hyArea=hyAreaService.find(areaId);
hyTicketScene.setArea(hyArea);
HyTicketScene preScene=hyTicketSceneService.find(hyTicketScene.getId());
if(preScene.getMhState()!=null) {
if(preScene.getMhState()==0) {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());
}
else if(preScene.getMhState()==1) {
hyTicketScene.setMhState(2); //将门户完善状态改为供应商修改,待完善
hyTicketScene.setMhIntroduction(preScene.getMhIntroduction());
}
else {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(preScene.getMhIntroduction());
}
}
else {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());
}
if(supplierId!=null) {
HySupplierElement piaowubuGongyingshang=hySupplierElementService.find(supplierId);
hyTicketScene.setHySupplierElement(piaowubuGongyingshang);
}
hyTicketScene.setModifyTime(new Date());
hyTicketSceneService.update(hyTicketScene,"ticketSupplier","createTime","creator","pn","mhReserveReq",
"mhSceneName","mhSceneAddress","mhBriefIntroduction","mhCreateTime","mhUpdateTime",
"mhOperator");
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="detail/view",method = RequestMethod.GET)
@ResponseBody
public Json detail(Long id)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=hyTicketSceneService.find(id);
Map<String,Object> map=new HashMap<String,Object>();
map.put("sceneName",hyTicketScene.getSceneName());
map.put("area", hyTicketScene.getArea().getFullName());
map.put("areaId", hyTicketScene.getArea().getId());
if(hyTicketScene.getTicketSupplier().getIsInner()==true) {
map.put("supplierName", hyTicketScene.getHySupplierElement().getName());
map.put("supplierId", hyTicketScene.getHySupplierElement().getId());
}
map.put("sceneAddress", hyTicketScene.getSceneAddress());
map.put("star", hyTicketScene.getStar());
map.put("openTime", hyTicketScene.getOpenTime());
map.put("closeTime", hyTicketScene.getCloseTime());
map.put("ticketExchangeAddress", hyTicketScene.getTicketExchangeAddress());
map.put("introduction", hyTicketScene.getIntroduction()); //产品介绍
map.put("ticketFile",hyTicketScene.getTicketFile()); //票务推广文件
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("supplierList/view")
@ResponseBody
public Json supplierList()
{
Json json=new Json();
try{
List<HashMap<String, Object>> list = new ArrayList<>();
List<Filter> filters=new ArrayList<Filter>();
filters.add(Filter.eq("supplierType", SupplierType.piaowuTicket)); //筛选旅游元素供应商
List<HySupplierElement> piaowubuGongyingshangList=hySupplierElementService.findList(null,filters,null);
for(HySupplierElement gongyingshang:piaowubuGongyingshangList){
HashMap<String,Object> map=new HashMap<String,Object>();
map.put("supplierId", gongyingshang.getId());
map.put("supplierName", gongyingshang.getName());
list.add(map);
}
json.setMsg("列表成功");
json.setSuccess(true);
json.setObj(list);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
/**
* 由父区域的ID得到全部的子区域
* @param id
* @return
*/
@RequestMapping(value="areacomboxlist/view", method = RequestMethod.GET)
@ResponseBody
public Json getSubAreas(Long id) {
Json j = new Json();
try {
HashMap<String, Object> hashMap = new HashMap<>();
HyArea parent = hyAreaService.find(id);
List<HashMap<String, Object>> obj = new ArrayList<>();
if(parent != null && parent.getHyAreas().size() > 0) {
for (HyArea child : parent.getHyAreas()) {
if(child.getStatus()) {
HashMap<String, Object> hm = new HashMap<>();
hm.put("value", child.getId());
hm.put("label", child.getName());
hm.put("isLeaf", child.getHyAreas().size() == 0);
obj.add(hm);
}
}
}
hashMap.put("total", parent.getHyAreas().size());
hashMap.put("data", obj);
j.setSuccess(true);
j.setMsg("查找成功!");
j.setObj(obj);
} catch(Exception e) {
// TODO Auto-generated catch block
j.setSuccess(false);
j.setMsg(e.getMessage());
}
return j;
}
@RequestMapping(value="ticketList/view")
@ResponseBody
public Json ticketList(HyTicketSceneTicketManagement queryParam,Long sceneId,Pageable pageable)
{
Json json=new Json();
try{
Map<String,Object> map=new HashMap<String,Object>();
List<HashMap<String, Object>> list = new ArrayList<>();
HyTicketScene hyTicketScene=hyTicketSceneService.find(sceneId);
List<Filter> filter=new ArrayList<Filter>();
filter.add(Filter.eq("hyTicketScene", hyTicketScene));
pageable.setFilters(filter);
Page<HyTicketSceneTicketManagement> page=hyTicketSceneTicketManagementService.findPage(pageable,queryParam);
if(page.getTotal()>0){
for(HyTicketSceneTicketManagement sceneTicket:page.getRows()){
HashMap<String,Object> ticketMap=new HashMap<String,Object>();
ticketMap.put("id", sceneTicket.getId());
ticketMap.put("productId", sceneTicket.getProductId());
ticketMap.put("productName", sceneTicket.getProductName());
ticketMap.put("auditStatus", sceneTicket.getAuditStatus());
ticketMap.put("saleStatus", sceneTicket.getSaleStatus());
ticketMap.put("status", sceneTicket.getStatus());
list.add(ticketMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
/*新建一个内部类,传递参数*/
static class WrapHyTicketScene{
private Long sceneId;
private HyTicketSceneTicketManagement sceneTicket;
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public HyTicketSceneTicketManagement getSceneTicket() {
return sceneTicket;
}
public void setSceneTicket(HyTicketSceneTicketManagement sceneTicket) {
this.sceneTicket = sceneTicket;
}
}
@RequestMapping(value="addTicket", method = RequestMethod.POST)
@ResponseBody
public Json addTicket(@RequestBody WrapHyTicketScene wrapHyTicketScene,HttpSession httpSession)
{
Json json=new Json();
try{
Long sceneId=wrapHyTicketScene.getSceneId();
HyTicketScene hyTicketScene=hyTicketSceneService.find(sceneId);
HyTicketSceneTicketManagement sceneTicket=wrapHyTicketScene.getSceneTicket();
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
sceneTicket.setHyTicketScene(hyTicketScene);
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
List<Filter> filters = new ArrayList<Filter>();
filters.add(Filter.eq("type", SequenceTypeEnum.piaowubump));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="MP-" + dateStr + "-" + String.format("%04d", value);
}
sceneTicket.setProductId(produc);
sceneTicket.setStatus(true);
sceneTicket.setSaleStatus(1); //未上架
sceneTicket.setAuditStatus(2); //提交审核
sceneTicket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
sceneTicket.setOperator(admin);
sceneTicket.setSubmitTime(new Date());
//如果预约时间为空,则设为0
if(sceneTicket.getDays()==null) {
sceneTicket.setDays(0);
}
if(sceneTicket.getTimes()==null) {
sceneTicket.setTimes(0);
}
hyTicketSceneTicketManagementService.save(sceneTicket);
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(sceneTicket);
hyTicketPriceInboundService.save(price);
}
}
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="saveTicket", method = RequestMethod.POST)
@ResponseBody
public Json saveTicket(@RequestBody WrapHyTicketScene wrapHyTicketScene,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=hyTicketSceneService.find(wrapHyTicketScene.getSceneId());
HyTicketSceneTicketManagement sceneTicket=wrapHyTicketScene.getSceneTicket();
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
sceneTicket.setHyTicketScene(hyTicketScene);
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
List<Filter> filters = new ArrayList<Filter>();
filters.add(Filter.eq("type", SequenceTypeEnum.piaowubump));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="MP-" + dateStr + "-" + String.format("%04d", value);
}
sceneTicket.setProductId(produc);
sceneTicket.setStatus(true);
sceneTicket.setSaleStatus(1); //未上架
sceneTicket.setAuditStatus(1); //保存未提交
//如果预约时间为空,则设为0
if(sceneTicket.getDays()==null) {
sceneTicket.setDays(0);
}
if(sceneTicket.getTimes()==null) {
sceneTicket.setTimes(0);
}
hyTicketSceneTicketManagementService.save(sceneTicket);
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(sceneTicket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("submitPrice")
@ResponseBody
public Json submitPrice(Long ticketId,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement hyTicketSceneTicket=hyTicketSceneTicketManagementService.find(ticketId);
hyTicketSceneTicket.setAuditStatus(2); //提交审核
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
hyTicketSceneTicket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
hyTicketSceneTicket.setOperator(admin);
hyTicketSceneTicket.setSubmitTime(new Date());
hyTicketSceneTicket.setStatus(true);
hyTicketSceneTicketManagementService.update(hyTicketSceneTicket);
json.setMsg("提交成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editTicket/submit")
@ResponseBody
public Json editsubmitTicket(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
ticket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
ticket.setAuditStatus(2); //提交审核
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
ticket.setOperator(admin);
ticket.setSubmitTime(new Date());
//如果预约时间为空,则设为0
if(ticket.getDays()==null) {
ticket.setDays(0);
}
if(ticket.getTimes()==null) {
ticket.setTimes(0);
}
hyTicketSceneTicketManagementService.update(ticket,"productId","hyTicketScene","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editTicket/save")
@ResponseBody
public Json editsaveTicket(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ticket.setAuditStatus(1); //未提交
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
//如果预约时间为空,则设为0
if(ticket.getDays()==null) {
ticket.setDays(0);
}
if(ticket.getTimes()==null) {
ticket.setTimes(0);
}
hyTicketSceneTicketManagementService.update(ticket,"productId","hyTicketScene","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editPrice/submit")
@ResponseBody
public Json editsumitPrice(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
ticket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
ticket.setAuditStatus(2); //提交审核
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
ticket.setOperator(admin);
ticket.setSubmitTime(new Date());
hyTicketSceneTicketManagementService.update(ticket,"productId","productName","hyTicketScene","ticketType","isReserve",
"days","times","isRealName","refundReq","realNameRemark","reserveReq","productType","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticket.getHyTicketPriceInbounds());
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("价格编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editPrice/save")
@ResponseBody
public Json editsavePrice(@RequestBody HyTicketSceneTicketManagement ticket)
{
Json json=new Json();
try{
ticket.setAuditStatus(1); //未提交
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
hyTicketSceneTicketManagementService.update(ticket,"productId","productName","hyTicketScene","ticketType","isReserve",
"days","times","isRealName","refundReq","realNameRemark","reserveReq","productType","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticket.getHyTicketPriceInbounds());
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("价格编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("price/detail/view")
@ResponseBody
public Json priceDetail(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticketScene=hyTicketSceneTicketManagementService.find(ticketId);
String processInstanceId = ticketScene.getProcessInstanceId();
List<Comment> commentList = taskService.getProcessInstanceComments(processInstanceId);
Collections.reverse(commentList);
List<Map<String, Object>> list = new LinkedList<>();
for (Comment comment : commentList) {
Map<String, Object> obj = new HashMap<>();
String taskId = comment.getTaskId();
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId)
.singleResult();
String step = "";
if (task != null) {
step = task.getName();
}
obj.put("step", step);
String username = comment.getUserId();
HyAdmin hyAdmin = hyAdminService.find(username);
String name = "";
if (hyAdmin != null) {
name = hyAdmin.getName();
}
obj.put("name", name);
String str = comment.getFullMessage();
int index = str.lastIndexOf(":");
if (index < 0) {
obj.put("comment", " ");
obj.put("result", 1);
} else {
obj.put("comment", str.substring(0, index));
obj.put("result", Integer.parseInt(str.substring(index + 1)));
}
obj.put("time", comment.getTime());
list.add(obj);
}
HashMap<String,Object> map=new HashMap<String,Object>();
map.put("auditList", list);
map.put("productId", ticketScene.getProductId());
map.put("productName", ticketScene.getProductName());
map.put("ticketType", ticketScene.getTicketType());
map.put("isReserve", ticketScene.getIsReserve());
if(ticketScene.getIsReserve()==true){
map.put("days", ticketScene.getDays());
map.put("times", ticketScene.getTimes());
}
map.put("isRealName", ticketScene.getIsRealName());
if(ticketScene.getIsRealName()==true){
map.put("realNameRemark", ticketScene.getRealNameRemark());
}
map.put("refundReq", ticketScene.getRefundReq());
map.put("reserveReq", ticketScene.getReserveReq());
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticketScene.getHyTicketPriceInbounds());
map.put("priceList", priceList);
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("cancel")
@ResponseBody
public Json cancel(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setStatus(false);
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("取消成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("restore")
@ResponseBody
public Json restore(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setStatus(true);
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("恢复成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("oncarriage")
@ResponseBody
public Json oncarriage(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setSaleStatus(2); //上架
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("上架成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("undercarriage")
@ResponseBody
public Json undercarriage(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setSaleStatus(3); //下架
ticket.setMhIsSale(0); //门户同步显下架
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("下架成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
//查看实时库存
@RequestMapping("inbound/view")
@ResponseBody
public Json inboundView(Long priceId)
{
Json json=new Json();
try {
List<Filter> filters=new ArrayList<>();
if(priceId==null) {
json.setSuccess(false);
json.setMsg("传出参数有误");
return json;
}
filters.add(Filter.eq("priceInboundId", priceId));
filters.add(Filter.eq("type", 1)); //1-酒店,门票,酒加景
List<HyTicketInbound> ticketInbounds=hyTicketInboundService.findList(null,filters,null);
List<Map<String,Object>> list=new ArrayList<>();
for(HyTicketInbound inbound:ticketInbounds) {
Map<String,Object> map=new HashMap<>();
map.put("day", inbound.getDay());
map.put("inventory", inbound.getInventory());
list.add(map);
}
json.setObj(list);
json.setSuccess(true);
json.setMsg("查询成功");
}
catch(Exception e) {
json.setMsg(e.getMessage());
json.setSuccess(false);
}
return json;
}
//内部类,用于修改库存传递参数
static class WrapInbound{
Long priceId;
List<HyTicketInbound> hyTicketInbounds;
public Long getPriceId() {
return priceId;
}
public void setPriceId(Long priceId) {
this.priceId = priceId;
}
public List<HyTicketInbound> getHyTicketInbounds() {
return hyTicketInbounds;
}
public void setHyTicketInbounds(List<HyTicketInbound> hyTicketInbounds) {
this.hyTicketInbounds = hyTicketInbounds;
}
}
//只修改库存
@RequestMapping("editInbound")
@ResponseBody
public Json editInbound(@RequestBody WrapInbound wrapInbound)
{
Json json=new Json();
try {
Long priceId=wrapInbound.getPriceId();
List<HyTicketInbound> hyTicketInbounds=wrapInbound.getHyTicketInbounds();
//将库存表针对每天的库存都修改
for(HyTicketInbound inbound:hyTicketInbounds) {
List<Filter> filters=new ArrayList<>();
filters.add(Filter.eq("type", 1));
filters.add(Filter.eq("priceInboundId", priceId));
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
String dateString=formatter.format(inbound.getDay());
Date inboundDay=formatter.parse(dateString);
filters.add(Filter.eq("day", inboundDay));
List<HyTicketInbound> ticketInbounds=hyTicketInboundService.findList(null,filters,null);
HyTicketInbound ticketInbound=ticketInbounds.get(0);
ticketInbound.setInventory(inbound.getInventory());
hyTicketInboundService.update(ticketInbound);
}
json.setSuccess(true);
json.setMsg("修改成功");
}
catch(Exception e) {
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
public HyAdmin findPAdmin(HyAdmin admin) {
HyAdmin hyAdmin=new HyAdmin();
try {
//如果是父帐号,即合同负责人
if(admin.getHyAdmin()==null) {
hyAdmin=admin;
}
//如果是子账号,查找其父帐号
else {
while(admin.getHyAdmin()!=null) {
admin=admin.getHyAdmin();
}
hyAdmin=admin;
}
}
catch(Exception e) {
e.printStackTrace();
}
return hyAdmin;
}
}
|
UTF-8
|
Java
| 48,276 |
java
|
HyTicketSceneController.java
|
Java
|
[
{
"context": "门票价格提交申请\n\t\t\tAuthentication.setAuthenticatedUserId(username);\n\t\t\ttaskService.addComment(task.getId(), pi.getP",
"end": 31603,
"score": 0.7295888066291809,
"start": 31595,
"tag": "USERNAME",
"value": "username"
}
] | null |
[] |
package com.hongyu.controller;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import com.hongyu.CommonAttributes;
import com.hongyu.Filter;
import com.hongyu.Json;
import com.hongyu.Order;
import com.hongyu.Page;
import com.hongyu.Pageable;
import com.hongyu.controller.HyTicketHotelandsceneController.WrapInbound;
import com.hongyu.entity.CommonSequence.SequenceTypeEnum;
import com.hongyu.entity.CommonSequence;
import com.hongyu.entity.HyAdmin;
import com.hongyu.entity.HyArea;
import com.hongyu.entity.HyTicketInbound;
import com.hongyu.entity.HyTicketScene;
import com.hongyu.entity.HyTicketSceneTicketManagement;
import com.hongyu.entity.HyRoleAuthority.CheckedOperation;
import com.hongyu.entity.HySupplierContract.ContractStatus;
import com.hongyu.entity.HySupplierElement.SupplierType;
import com.hongyu.entity.HySupplier;
import com.hongyu.entity.HySupplierContract;
import com.hongyu.entity.HySupplierElement;
import com.hongyu.entity.HyTicketHotelRoom;
import com.hongyu.entity.HyTicketPriceInbound;
import com.hongyu.service.CommonSequenceService;
import com.hongyu.service.HyAdminService;
import com.hongyu.service.HyAreaService;
import com.hongyu.service.HySupplierContractService;
import com.hongyu.service.HySupplierElementService;
import com.hongyu.service.HySupplierService;
import com.hongyu.service.HyTicketInboundService;
import com.hongyu.service.HyTicketPriceInboundService;
import com.hongyu.service.HyTicketSceneService;
import com.hongyu.service.HyTicketSceneTicketManagementService;
import com.hongyu.util.AuthorityUtils;
@Controller
@RequestMapping("/admin/internTicket/scenic/")
public class HyTicketSceneController {
@Resource
private TaskService taskService;
@Resource
private HistoryService historyService;
@Resource
private RuntimeService runtimeService;
@Resource(name="hyAdminServiceImpl")
private HyAdminService hyAdminService;
@Resource(name="hySupplierServiceImpl")
private HySupplierService hySupplierService;
@Resource(name="hyTicketSceneServiceImpl")
private HyTicketSceneService hyTicketSceneService;
@Resource(name="hyAreaServiceImpl")
private HyAreaService hyAreaService;
@Resource(name="hyTicketSceneTicketManagementServiceImpl")
private HyTicketSceneTicketManagementService hyTicketSceneTicketManagementService;
@Resource(name="commonSequenceServiceImp")
private CommonSequenceService commonSequenceService;
@Resource(name="hyTicketPriceInboundServiceImpl")
private HyTicketPriceInboundService hyTicketPriceInboundService;
@Resource(name="hySupplierElementServiceImpl")
private HySupplierElementService hySupplierElementService;
@Resource(name="hySupplierContractServiceImpl")
private HySupplierContractService hySupplierContractService;
@Resource(name="hyTicketInboundServiceImpl")
private HyTicketInboundService hyTicketInboundService;
@RequestMapping(value="list/view")
@ResponseBody
public Json list(Pageable pageable,String sceneName,String creatorName,HttpSession session,HttpServletRequest request)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=new HyTicketScene();
Map<String,Object> map=new HashMap<String,Object>();
List<HashMap<String, Object>> list = new ArrayList<>();
/**
* 获取当前用户
*/
String username = (String) session.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
/**
* 获取用户权限范围
*/
CheckedOperation co=(CheckedOperation) request.getAttribute("co");
/** 所有符合条件的账号 ,默认可以看到自己创建的数据 */
Set<HyAdmin> hyAdmins = AuthorityUtils.getAdmins(session, request);
List<Filter> sceneFilter=new ArrayList<Filter>();
sceneFilter.add(Filter.in("creator",hyAdmins));
if(sceneName!=null&&!sceneName.equals(""))
{
sceneFilter.add(Filter.like("sceneName", sceneName));
}
List<Filter> filter=new ArrayList<Filter>();
if(creatorName!=null&&!creatorName.equals(""))
{
filter.add(Filter.like("name",creatorName));
List<HyAdmin> adminList=hyAdminService.findList(null,filter,null);
if(adminList.size()==0){
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(new Page<HyTicketScene>());
}
else{
sceneFilter.add(Filter.in("creator", adminList));
List<Filter> supplierFilter=new ArrayList<Filter>();
supplierFilter.add(Filter.eq("liable", findPAdmin(admin))); //帅选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,supplierFilter,null); //根据合同找到供应商
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
sceneFilter.add(Filter.eq("ticketSupplier", hySupplier));
}
pageable.setFilters(sceneFilter);
List<Order> orders = new ArrayList<Order>();
orders.add(Order.desc("createTime"));
pageable.setOrders(orders);
Page<HyTicketScene> page=hyTicketSceneService.findPage(pageable,hyTicketScene);
if(page.getTotal()>0){
for(HyTicketScene scene:page.getRows()){
HashMap<String,Object> sceneMap=new HashMap<String,Object>();
HyAdmin creator=scene.getCreator();
sceneMap.put("id", scene.getId());
sceneMap.put("sceneName", scene.getSceneName());
List<HyTicketSceneTicketManagement> ticketList =new ArrayList<>(scene.getHyTicketSceneTickets());
//算出最近价格日期和最低价格
if(ticketList.size()>0){
List<Date> dateList=new ArrayList<>();
List<BigDecimal> priceList=new ArrayList<>();
for(HyTicketSceneTicketManagement ticket:ticketList){
List<HyTicketPriceInbound> inboundPrices=new ArrayList<>(ticket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound inboundPrice:inboundPrices) {
dateList.add(inboundPrice.getEndDate());
//时间过滤时分秒
Date date=DateUtils.truncate(new Date(), Calendar.DATE);
if(inboundPrice.getEndDate().compareTo(date)>=0){
priceList.add(inboundPrice.getSettlementPrice());
}
}
}
if(!dateList.isEmpty()) {
Date latestPriceDate=Collections.max(dateList);
sceneMap.put("latestPriceDate",latestPriceDate);
}
if(!priceList.isEmpty()) {
BigDecimal lowestPrice=Collections.min(priceList);
sceneMap.put("lowestPrice",lowestPrice);
}
}
sceneMap.put("createTime", scene.getCreateTime());
sceneMap.put("creatorName", scene.getCreator().getName());
//查找是否有上架产品,判断是否可编辑
List<HyTicketSceneTicketManagement> sceneTickets=new ArrayList<>(scene.getHyTicketSceneTickets());
int flag=1; //标志位
for(HyTicketSceneTicketManagement sceneTicket:sceneTickets) {
//如果有已上架产品
if(sceneTicket.getSaleStatus()==2) {
flag=0;
break;
}
}
sceneMap.put("isEdit",flag); //是否可编辑,1-可编辑,0-不可编辑
/** 当前用户对本条数据的操作权限 */
if(creator.equals(admin)){
if(co==CheckedOperation.view){
sceneMap.put("privilege", "view");
}
else{
sceneMap.put("privilege", "edit");
}
}
else{
if(co==CheckedOperation.edit){
sceneMap.put("privilege", "edit");
}
else{
sceneMap.put("privilege", "view");
}
}
list.add(sceneMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
}
//creatorName!=null
else{
List<Filter> supplierFilter=new ArrayList<Filter>();
supplierFilter.add(Filter.eq("liable", admin)); //帅选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,supplierFilter,null); //根据合同找到供应商
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
sceneFilter.add(Filter.eq("ticketSupplier", hySupplier));
}
pageable.setFilters(sceneFilter);
List<Order> orders = new ArrayList<Order>();
orders.add(Order.desc("createTime"));
pageable.setOrders(orders);
Page<HyTicketScene> page=hyTicketSceneService.findPage(pageable,hyTicketScene);
if(page.getTotal()>0){
for(HyTicketScene scene:page.getRows()){
HashMap<String,Object> sceneMap=new HashMap<String,Object>();
HyAdmin creator=scene.getCreator();
sceneMap.put("id", scene.getId());
sceneMap.put("sceneName", scene.getSceneName());
List<HyTicketSceneTicketManagement> ticketList =new ArrayList<>(scene.getHyTicketSceneTickets());
//算出最近价格日期和最低价格
if(ticketList.size()>0){
List<Date> dateList=new ArrayList<>();
List<BigDecimal> priceList=new ArrayList<>();
for(HyTicketSceneTicketManagement ticket:ticketList){
List<HyTicketPriceInbound> inboundPrices=new ArrayList<>(ticket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound inboundPrice:inboundPrices) {
dateList.add(inboundPrice.getEndDate());
//时间过滤时分秒
Date date=DateUtils.truncate(new Date(), Calendar.DATE);
if(inboundPrice.getEndDate().compareTo(date)>=0){
priceList.add(inboundPrice.getSettlementPrice());
}
}
}
if(!dateList.isEmpty()) {
Date latestPriceDate=Collections.max(dateList);
sceneMap.put("latestPriceDate",latestPriceDate);
}
if(!priceList.isEmpty()) {
BigDecimal lowestPrice=Collections.min(priceList);
sceneMap.put("lowestPrice",lowestPrice);
}
}
sceneMap.put("createTime", scene.getCreateTime());
sceneMap.put("creatorName", scene.getCreator().getName());
//查找是否有上架产品,判断是否可编辑
List<HyTicketSceneTicketManagement> sceneTickets=new ArrayList<>(scene.getHyTicketSceneTickets());
int flag=1; //标志位
for(HyTicketSceneTicketManagement sceneTicket:sceneTickets) {
//如果有已上架产品
if(sceneTicket.getSaleStatus()==1) {
flag=0;
break;
}
}
sceneMap.put("isEdit",flag); //是否可编辑,1-可编辑,0-不可编辑
/** 当前用户对本条数据的操作权限 */
if(creator.equals(admin)){
if(co==CheckedOperation.view){
sceneMap.put("privilege", "view");
}
else{
sceneMap.put("privilege", "edit");
}
}
else{
if(co==CheckedOperation.edit){
sceneMap.put("privilege", "edit");
}
else{
sceneMap.put("privilege", "view");
}
}
list.add(sceneMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
e.printStackTrace();
}
return json;
}
@RequestMapping(value="add", method = RequestMethod.POST)
@ResponseBody
public Json add(HyTicketScene hyTicketScene,Long areaId,Long supplierId,HttpSession session)
{
Json json=new Json();
try{
HyArea hyArea=hyAreaService.find(areaId);
hyTicketScene.setArea(hyArea);
if(supplierId!=null) {
HySupplierElement piaowubuGongyingshang=hySupplierElementService.find(supplierId);
hyTicketScene.setHySupplierElement(piaowubuGongyingshang);
}
hyTicketScene.setCreateTime(new Date());
/**
* 获取当前用户
*/
String username = (String) session.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
Boolean flag = false;
//新增只有供应商合同为正常才可以新建门票
if(admin.getHyAdmin() != null) {
HyAdmin parent = admin.getHyAdmin();
Set<HySupplierContract> supplierContracts = parent.getLiableContracts();
for(HySupplierContract c : supplierContracts) {
if(c.getContractStatus() == ContractStatus.zhengchang) {
flag = true;
break;
}
}
} else {
Set<HySupplierContract> supplierContracts1 = admin.getLiableContracts();
for(HySupplierContract c : supplierContracts1) {
if(c.getContractStatus() == ContractStatus.zhengchang) {
flag = true;
break;
}
}
}
if(flag == false) {
json.setMsg("供应商合同状态错误");
json.setSuccess(false);
return json;
}
hyTicketScene.setCreator(admin);
List<Filter> filters=new ArrayList<Filter>();
filters.add(Filter.eq("liable", findPAdmin(admin))); //筛选该登录账号负责的合同
List<HySupplierContract> hySupplierContracts=hySupplierContractService.findList(null,filters,null); //根据合同找到供应商
filters.clear();
if(!hySupplierContracts.isEmpty()) {
HySupplier hySupplier=hySupplierContracts.get(0).getHySupplier(); //找出供应商
hyTicketScene.setTicketSupplier(hySupplier);
}
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
filters.add(Filter.eq("type", SequenceTypeEnum.piaowujingquPn));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
filters.clear();
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="JQ-" + dateStr + "-" + String.format("%04d", value);
}
hyTicketScene.setPn(produc);
hyTicketScene.setMhState(0); //将门户完善状态设为未完善
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());//初始化门户推广文件
hyTicketSceneService.save(hyTicketScene);
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="edit")
@ResponseBody
public Json edit(HyTicketScene hyTicketScene,Long areaId,Long supplierId)
{
Json json=new Json();
try{
HyArea hyArea=hyAreaService.find(areaId);
hyTicketScene.setArea(hyArea);
HyTicketScene preScene=hyTicketSceneService.find(hyTicketScene.getId());
if(preScene.getMhState()!=null) {
if(preScene.getMhState()==0) {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());
}
else if(preScene.getMhState()==1) {
hyTicketScene.setMhState(2); //将门户完善状态改为供应商修改,待完善
hyTicketScene.setMhIntroduction(preScene.getMhIntroduction());
}
else {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(preScene.getMhIntroduction());
}
}
else {
hyTicketScene.setMhState(preScene.getMhState());
hyTicketScene.setMhIntroduction(hyTicketScene.getIntroduction());
}
if(supplierId!=null) {
HySupplierElement piaowubuGongyingshang=hySupplierElementService.find(supplierId);
hyTicketScene.setHySupplierElement(piaowubuGongyingshang);
}
hyTicketScene.setModifyTime(new Date());
hyTicketSceneService.update(hyTicketScene,"ticketSupplier","createTime","creator","pn","mhReserveReq",
"mhSceneName","mhSceneAddress","mhBriefIntroduction","mhCreateTime","mhUpdateTime",
"mhOperator");
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="detail/view",method = RequestMethod.GET)
@ResponseBody
public Json detail(Long id)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=hyTicketSceneService.find(id);
Map<String,Object> map=new HashMap<String,Object>();
map.put("sceneName",hyTicketScene.getSceneName());
map.put("area", hyTicketScene.getArea().getFullName());
map.put("areaId", hyTicketScene.getArea().getId());
if(hyTicketScene.getTicketSupplier().getIsInner()==true) {
map.put("supplierName", hyTicketScene.getHySupplierElement().getName());
map.put("supplierId", hyTicketScene.getHySupplierElement().getId());
}
map.put("sceneAddress", hyTicketScene.getSceneAddress());
map.put("star", hyTicketScene.getStar());
map.put("openTime", hyTicketScene.getOpenTime());
map.put("closeTime", hyTicketScene.getCloseTime());
map.put("ticketExchangeAddress", hyTicketScene.getTicketExchangeAddress());
map.put("introduction", hyTicketScene.getIntroduction()); //产品介绍
map.put("ticketFile",hyTicketScene.getTicketFile()); //票务推广文件
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("supplierList/view")
@ResponseBody
public Json supplierList()
{
Json json=new Json();
try{
List<HashMap<String, Object>> list = new ArrayList<>();
List<Filter> filters=new ArrayList<Filter>();
filters.add(Filter.eq("supplierType", SupplierType.piaowuTicket)); //筛选旅游元素供应商
List<HySupplierElement> piaowubuGongyingshangList=hySupplierElementService.findList(null,filters,null);
for(HySupplierElement gongyingshang:piaowubuGongyingshangList){
HashMap<String,Object> map=new HashMap<String,Object>();
map.put("supplierId", gongyingshang.getId());
map.put("supplierName", gongyingshang.getName());
list.add(map);
}
json.setMsg("列表成功");
json.setSuccess(true);
json.setObj(list);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
/**
* 由父区域的ID得到全部的子区域
* @param id
* @return
*/
@RequestMapping(value="areacomboxlist/view", method = RequestMethod.GET)
@ResponseBody
public Json getSubAreas(Long id) {
Json j = new Json();
try {
HashMap<String, Object> hashMap = new HashMap<>();
HyArea parent = hyAreaService.find(id);
List<HashMap<String, Object>> obj = new ArrayList<>();
if(parent != null && parent.getHyAreas().size() > 0) {
for (HyArea child : parent.getHyAreas()) {
if(child.getStatus()) {
HashMap<String, Object> hm = new HashMap<>();
hm.put("value", child.getId());
hm.put("label", child.getName());
hm.put("isLeaf", child.getHyAreas().size() == 0);
obj.add(hm);
}
}
}
hashMap.put("total", parent.getHyAreas().size());
hashMap.put("data", obj);
j.setSuccess(true);
j.setMsg("查找成功!");
j.setObj(obj);
} catch(Exception e) {
// TODO Auto-generated catch block
j.setSuccess(false);
j.setMsg(e.getMessage());
}
return j;
}
@RequestMapping(value="ticketList/view")
@ResponseBody
public Json ticketList(HyTicketSceneTicketManagement queryParam,Long sceneId,Pageable pageable)
{
Json json=new Json();
try{
Map<String,Object> map=new HashMap<String,Object>();
List<HashMap<String, Object>> list = new ArrayList<>();
HyTicketScene hyTicketScene=hyTicketSceneService.find(sceneId);
List<Filter> filter=new ArrayList<Filter>();
filter.add(Filter.eq("hyTicketScene", hyTicketScene));
pageable.setFilters(filter);
Page<HyTicketSceneTicketManagement> page=hyTicketSceneTicketManagementService.findPage(pageable,queryParam);
if(page.getTotal()>0){
for(HyTicketSceneTicketManagement sceneTicket:page.getRows()){
HashMap<String,Object> ticketMap=new HashMap<String,Object>();
ticketMap.put("id", sceneTicket.getId());
ticketMap.put("productId", sceneTicket.getProductId());
ticketMap.put("productName", sceneTicket.getProductName());
ticketMap.put("auditStatus", sceneTicket.getAuditStatus());
ticketMap.put("saleStatus", sceneTicket.getSaleStatus());
ticketMap.put("status", sceneTicket.getStatus());
list.add(ticketMap);
}
}
map.put("rows", list);
map.put("pageNumber", Integer.valueOf(pageable.getPage()));
map.put("pageSize", Integer.valueOf(pageable.getRows()));
map.put("total",Long.valueOf(page.getTotal()));
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
/*新建一个内部类,传递参数*/
static class WrapHyTicketScene{
private Long sceneId;
private HyTicketSceneTicketManagement sceneTicket;
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public HyTicketSceneTicketManagement getSceneTicket() {
return sceneTicket;
}
public void setSceneTicket(HyTicketSceneTicketManagement sceneTicket) {
this.sceneTicket = sceneTicket;
}
}
@RequestMapping(value="addTicket", method = RequestMethod.POST)
@ResponseBody
public Json addTicket(@RequestBody WrapHyTicketScene wrapHyTicketScene,HttpSession httpSession)
{
Json json=new Json();
try{
Long sceneId=wrapHyTicketScene.getSceneId();
HyTicketScene hyTicketScene=hyTicketSceneService.find(sceneId);
HyTicketSceneTicketManagement sceneTicket=wrapHyTicketScene.getSceneTicket();
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
sceneTicket.setHyTicketScene(hyTicketScene);
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
List<Filter> filters = new ArrayList<Filter>();
filters.add(Filter.eq("type", SequenceTypeEnum.piaowubump));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="MP-" + dateStr + "-" + String.format("%04d", value);
}
sceneTicket.setProductId(produc);
sceneTicket.setStatus(true);
sceneTicket.setSaleStatus(1); //未上架
sceneTicket.setAuditStatus(2); //提交审核
sceneTicket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
sceneTicket.setOperator(admin);
sceneTicket.setSubmitTime(new Date());
//如果预约时间为空,则设为0
if(sceneTicket.getDays()==null) {
sceneTicket.setDays(0);
}
if(sceneTicket.getTimes()==null) {
sceneTicket.setTimes(0);
}
hyTicketSceneTicketManagementService.save(sceneTicket);
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(sceneTicket);
hyTicketPriceInboundService.save(price);
}
}
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping(value="saveTicket", method = RequestMethod.POST)
@ResponseBody
public Json saveTicket(@RequestBody WrapHyTicketScene wrapHyTicketScene,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketScene hyTicketScene=hyTicketSceneService.find(wrapHyTicketScene.getSceneId());
HyTicketSceneTicketManagement sceneTicket=wrapHyTicketScene.getSceneTicket();
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
sceneTicket.setHyTicketScene(hyTicketScene);
String produc="";
Date cur = new Date();
DateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(cur);
List<Filter> filters = new ArrayList<Filter>();
filters.add(Filter.eq("type", SequenceTypeEnum.piaowubump));
synchronized(CommonSequence.class) {
List<CommonSequence> ss = commonSequenceService.findList(null, filters, null);
CommonSequence c = ss.get(0);
Long value = c.getValue() + 1;
c.setValue(value);
commonSequenceService.update(c);
produc="MP-" + dateStr + "-" + String.format("%04d", value);
}
sceneTicket.setProductId(produc);
sceneTicket.setStatus(true);
sceneTicket.setSaleStatus(1); //未上架
sceneTicket.setAuditStatus(1); //保存未提交
//如果预约时间为空,则设为0
if(sceneTicket.getDays()==null) {
sceneTicket.setDays(0);
}
if(sceneTicket.getTimes()==null) {
sceneTicket.setTimes(0);
}
hyTicketSceneTicketManagementService.save(sceneTicket);
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(sceneTicket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("添加成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("submitPrice")
@ResponseBody
public Json submitPrice(Long ticketId,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement hyTicketSceneTicket=hyTicketSceneTicketManagementService.find(ticketId);
hyTicketSceneTicket.setAuditStatus(2); //提交审核
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
hyTicketSceneTicket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
hyTicketSceneTicket.setOperator(admin);
hyTicketSceneTicket.setSubmitTime(new Date());
hyTicketSceneTicket.setStatus(true);
hyTicketSceneTicketManagementService.update(hyTicketSceneTicket);
json.setMsg("提交成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editTicket/submit")
@ResponseBody
public Json editsubmitTicket(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
ticket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
ticket.setAuditStatus(2); //提交审核
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
ticket.setOperator(admin);
ticket.setSubmitTime(new Date());
//如果预约时间为空,则设为0
if(ticket.getDays()==null) {
ticket.setDays(0);
}
if(ticket.getTimes()==null) {
ticket.setTimes(0);
}
hyTicketSceneTicketManagementService.update(ticket,"productId","hyTicketScene","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editTicket/save")
@ResponseBody
public Json editsaveTicket(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
List<HyTicketPriceInbound> priceList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
//增加判断合同期限与上产品日期的比较,产品日期不能超出合同期限
HyAdmin contractLiable=new HyAdmin();//合同负责人
if(admin.getHyAdmin() != null) {
contractLiable = admin.getHyAdmin();
} else {
contractLiable = admin;
}
List<Filter> contractList=new ArrayList<>();
contractList.add(Filter.eq("liable", contractLiable)); //该负责人的合同
contractList.add(Filter.eq("contractStatus", ContractStatus.zhengchang)); //状态正常
List<HySupplierContract> supplierContractList=hySupplierContractService.findList(null,contractList,null);
//如果该供应商没有正常状态的合同
if(supplierContractList.isEmpty()) {
json.setSuccess(false);
json.setMsg("没有正常状态的合同");
return json;
}
//原则上一个合同负责人只有个正常状态的合同
HySupplierContract supplierContract=supplierContractList.get(0);
Date expiration=supplierContract.getDeadDate(); //找过合同到期日期
for(HyTicketPriceInbound priceInbound:priceList) {
//如果上产品的结束日期比合同到期日大,抛异常
if(priceInbound.getEndDate().compareTo(expiration)>0) {
json.setSuccess(false);
json.setMsg("产品日期超出合同期限");
return json;
}
}
ticket.setAuditStatus(1); //未提交
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
//如果预约时间为空,则设为0
if(ticket.getDays()==null) {
ticket.setDays(0);
}
if(ticket.getTimes()==null) {
ticket.setTimes(0);
}
hyTicketSceneTicketManagementService.update(ticket,"productId","hyTicketScene","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editPrice/submit")
@ResponseBody
public Json editsumitPrice(@RequestBody HyTicketSceneTicketManagement ticket,HttpSession httpSession)
{
Json json=new Json();
try{
String username = (String) httpSession.getAttribute(CommonAttributes.Principal);
HyAdmin admin = hyAdminService.find(username);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("sceneticketPriceProcess");
Task task = taskService.createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult();
// 完成 门票价格提交申请
Authentication.setAuthenticatedUserId(username);
taskService.addComment(task.getId(), pi.getProcessInstanceId(), " :1");
taskService.complete(task.getId());
ticket.setProcessInstanceId(pi.getProcessInstanceId()); //保存流程id
ticket.setAuditStatus(2); //提交审核
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
ticket.setOperator(admin);
ticket.setSubmitTime(new Date());
hyTicketSceneTicketManagementService.update(ticket,"productId","productName","hyTicketScene","ticketType","isReserve",
"days","times","isRealName","refundReq","realNameRemark","reserveReq","productType","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticket.getHyTicketPriceInbounds());
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("价格编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("editPrice/save")
@ResponseBody
public Json editsavePrice(@RequestBody HyTicketSceneTicketManagement ticket)
{
Json json=new Json();
try{
ticket.setAuditStatus(1); //未提交
ticket.setSaleStatus(1); //未上架
ticket.setStatus(true);
hyTicketSceneTicketManagementService.update(ticket,"productId","productName","hyTicketScene","ticketType","isReserve",
"days","times","isRealName","refundReq","realNameRemark","reserveReq","productType","mhProductName","mhReserveReq",
"mhRefundReq","mhIsSale");
HyTicketSceneTicketManagement sceneTicket=hyTicketSceneTicketManagementService.find(ticket.getId());
List<HyTicketPriceInbound> inboundList=new ArrayList<>(sceneTicket.getHyTicketPriceInbounds());
for(HyTicketPriceInbound priceInbound:inboundList){
hyTicketPriceInboundService.delete(priceInbound);
}
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticket.getHyTicketPriceInbounds());
if(priceList.size()>0){
for(HyTicketPriceInbound price:priceList){
price.setHyTicketSceneTicketManagement(ticket);
hyTicketPriceInboundService.save(price);
}
}
json.setMsg("价格编辑成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("price/detail/view")
@ResponseBody
public Json priceDetail(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticketScene=hyTicketSceneTicketManagementService.find(ticketId);
String processInstanceId = ticketScene.getProcessInstanceId();
List<Comment> commentList = taskService.getProcessInstanceComments(processInstanceId);
Collections.reverse(commentList);
List<Map<String, Object>> list = new LinkedList<>();
for (Comment comment : commentList) {
Map<String, Object> obj = new HashMap<>();
String taskId = comment.getTaskId();
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId)
.singleResult();
String step = "";
if (task != null) {
step = task.getName();
}
obj.put("step", step);
String username = comment.getUserId();
HyAdmin hyAdmin = hyAdminService.find(username);
String name = "";
if (hyAdmin != null) {
name = hyAdmin.getName();
}
obj.put("name", name);
String str = comment.getFullMessage();
int index = str.lastIndexOf(":");
if (index < 0) {
obj.put("comment", " ");
obj.put("result", 1);
} else {
obj.put("comment", str.substring(0, index));
obj.put("result", Integer.parseInt(str.substring(index + 1)));
}
obj.put("time", comment.getTime());
list.add(obj);
}
HashMap<String,Object> map=new HashMap<String,Object>();
map.put("auditList", list);
map.put("productId", ticketScene.getProductId());
map.put("productName", ticketScene.getProductName());
map.put("ticketType", ticketScene.getTicketType());
map.put("isReserve", ticketScene.getIsReserve());
if(ticketScene.getIsReserve()==true){
map.put("days", ticketScene.getDays());
map.put("times", ticketScene.getTimes());
}
map.put("isRealName", ticketScene.getIsRealName());
if(ticketScene.getIsRealName()==true){
map.put("realNameRemark", ticketScene.getRealNameRemark());
}
map.put("refundReq", ticketScene.getRefundReq());
map.put("reserveReq", ticketScene.getReserveReq());
List<HyTicketPriceInbound> priceList=new ArrayList<>(ticketScene.getHyTicketPriceInbounds());
map.put("priceList", priceList);
json.setMsg("查询成功");
json.setSuccess(true);
json.setObj(map);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("cancel")
@ResponseBody
public Json cancel(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setStatus(false);
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("取消成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("restore")
@ResponseBody
public Json restore(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setStatus(true);
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("恢复成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("oncarriage")
@ResponseBody
public Json oncarriage(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setSaleStatus(2); //上架
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("上架成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
@RequestMapping("undercarriage")
@ResponseBody
public Json undercarriage(Long ticketId)
{
Json json=new Json();
try{
HyTicketSceneTicketManagement ticket=hyTicketSceneTicketManagementService.find(ticketId);
ticket.setSaleStatus(3); //下架
ticket.setMhIsSale(0); //门户同步显下架
hyTicketSceneTicketManagementService.update(ticket);
json.setMsg("下架成功");
json.setSuccess(true);
}
catch(Exception e){
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
//查看实时库存
@RequestMapping("inbound/view")
@ResponseBody
public Json inboundView(Long priceId)
{
Json json=new Json();
try {
List<Filter> filters=new ArrayList<>();
if(priceId==null) {
json.setSuccess(false);
json.setMsg("传出参数有误");
return json;
}
filters.add(Filter.eq("priceInboundId", priceId));
filters.add(Filter.eq("type", 1)); //1-酒店,门票,酒加景
List<HyTicketInbound> ticketInbounds=hyTicketInboundService.findList(null,filters,null);
List<Map<String,Object>> list=new ArrayList<>();
for(HyTicketInbound inbound:ticketInbounds) {
Map<String,Object> map=new HashMap<>();
map.put("day", inbound.getDay());
map.put("inventory", inbound.getInventory());
list.add(map);
}
json.setObj(list);
json.setSuccess(true);
json.setMsg("查询成功");
}
catch(Exception e) {
json.setMsg(e.getMessage());
json.setSuccess(false);
}
return json;
}
//内部类,用于修改库存传递参数
static class WrapInbound{
Long priceId;
List<HyTicketInbound> hyTicketInbounds;
public Long getPriceId() {
return priceId;
}
public void setPriceId(Long priceId) {
this.priceId = priceId;
}
public List<HyTicketInbound> getHyTicketInbounds() {
return hyTicketInbounds;
}
public void setHyTicketInbounds(List<HyTicketInbound> hyTicketInbounds) {
this.hyTicketInbounds = hyTicketInbounds;
}
}
//只修改库存
@RequestMapping("editInbound")
@ResponseBody
public Json editInbound(@RequestBody WrapInbound wrapInbound)
{
Json json=new Json();
try {
Long priceId=wrapInbound.getPriceId();
List<HyTicketInbound> hyTicketInbounds=wrapInbound.getHyTicketInbounds();
//将库存表针对每天的库存都修改
for(HyTicketInbound inbound:hyTicketInbounds) {
List<Filter> filters=new ArrayList<>();
filters.add(Filter.eq("type", 1));
filters.add(Filter.eq("priceInboundId", priceId));
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
String dateString=formatter.format(inbound.getDay());
Date inboundDay=formatter.parse(dateString);
filters.add(Filter.eq("day", inboundDay));
List<HyTicketInbound> ticketInbounds=hyTicketInboundService.findList(null,filters,null);
HyTicketInbound ticketInbound=ticketInbounds.get(0);
ticketInbound.setInventory(inbound.getInventory());
hyTicketInboundService.update(ticketInbound);
}
json.setSuccess(true);
json.setMsg("修改成功");
}
catch(Exception e) {
json.setSuccess(false);
json.setMsg(e.getMessage());
}
return json;
}
public HyAdmin findPAdmin(HyAdmin admin) {
HyAdmin hyAdmin=new HyAdmin();
try {
//如果是父帐号,即合同负责人
if(admin.getHyAdmin()==null) {
hyAdmin=admin;
}
//如果是子账号,查找其父帐号
else {
while(admin.getHyAdmin()!=null) {
admin=admin.getHyAdmin();
}
hyAdmin=admin;
}
}
catch(Exception e) {
e.printStackTrace();
}
return hyAdmin;
}
}
| 48,276 | 0.713943 | 0.711871 | 1,315 | 33.862358 | 26.17836 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.98327 | false | false |
13
|
ec60d187ba2ca9aa1a019ce8a3a6e403de46d88e
| 16,913,581,241,492 |
4e53b348ecdc3f37850debea15e66b1419497cc0
|
/src/engine/Selection.java
|
3302bcc7e2d4ddab1db93cb7788ac9628107eeb3
|
[] |
no_license
|
blole/TRIPPN-BALLS
|
https://github.com/blole/TRIPPN-BALLS
|
f59089f915245039c57f024335b9ed2215a13fd5
|
09b67523e999d64a49262f24e89c06a4406b2ae2
|
refs/heads/master
| 2016-09-05T16:10:52.003000 | 2011-05-06T00:13:20 | 2011-05-06T00:13:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package engine;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.util.List;
import javax.media.opengl.GL2;
import collision.CollisionData;
import collision.tests.RaySphereIntersectTest;
import structures.Entity;
import structures.Vector;
/**
* System for selecting objects while in game.
* @author Björn Holm and Jacob Norlin Andersson
*
*/
public class Selection {
/**
* Throws a ray which is checked for intersection against each
* object in the world to see if the mouse is on top of an
* object.
* @param pitch
* @param yaw
*/
public void findTarget(float pitch, float yaw){
pitch += Camera.pitch;
yaw += Camera.yaw;
Vector lookPos = Vector.newTurnedUnitVector(pitch, yaw);
lookPos = new Vector(1,-1,-1).turn(pitch, yaw);
System.out.println(lookPos.abs());
lookPos.multiplySelf(300);
Vector offset = new Vector(5,5,5);
lookPos.addSelf(Camera.pos);
Engine.gl.glPointSize(10);
Engine.gl.glLoadIdentity();
Engine.gl.glBegin(GL2.GL_POINTS);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(lookPos.x, lookPos.y, lookPos.z);
Engine.gl.glEnd();
Engine.gl.glBegin(GL2.GL_LINES);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(lookPos.x, lookPos.y, lookPos.z);
Engine.gl.glColor3f(1, 0, 0);
Engine.gl.glVertex3f(offset.x, offset.y, offset.z);
Engine.gl.glEnd();
Engine.gl.glLoadIdentity();
Engine.gl.glRotatef(pitch, 1, 0, 0);
Engine.gl.glRotatef(yaw, 0, 1, 0);
Engine.gl.glBegin(GL2.GL_LINES);
Engine.gl.glColor3f(0, 1, 0);
Engine.gl.glVertex3f(0,0,0);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(0,0,3);
Engine.gl.glEnd();
System.out.println(lookPos);
RaySphereIntersectTest test = new RaySphereIntersectTest();
for (Entity entity : Entity.all) {
if(test.TestRaySphere(Camera.pos, lookPos, entity)){
onOver(entity);
break;
}
}
}
/**
* If the mouse is on an object this method is called.
* @param entity
*/
public void onOver(Entity entity){
System.out.println(" COOLT GRABBEN");
// Camera.setTarget(smek.pos);
}
/**
* Converts the mouse position to be able to find a target.
*/
public void findMouseTarget(){
Point mousePos = Input.getRelativeMousePos();
Rectangle bounds = Engine.getAbsoluteCanvasBounds();
float bw = bounds.width/2f;
float bh = bounds.height/2f;
Point2D.Float lol = new Point2D.Float(mousePos.x/bw-1, mousePos.y/bh-1);
System.out.println("WWEEEEEEEE mouseCoords: "+lol);
float FOV = Camera.getFOV()/2;
float yaw = lol.x*FOV;
float pitch = lol.y*FOV;
// System.out.println("-----------");
// System.out.println("mouseX: "+mouseX+" mouseY: "+mouseY+"\n"+
// "pitch: "+pitch+" yaw: "+yaw+"\n"+
// "xAspect: "+xAspect+" yAspect: "+yAspect);
System.out.println("===========");
findTarget(pitch, yaw);
}
}
|
ISO-8859-1
|
Java
| 2,906 |
java
|
Selection.java
|
Java
|
[
{
"context": "em for selecting objects while in game.\n * @author Björn Holm and Jacob Norlin Andersson\n *\n */\npublic class Se",
"end": 357,
"score": 0.9998677372932434,
"start": 347,
"tag": "NAME",
"value": "Björn Holm"
},
{
"context": "g objects while in game.\n * @author Björn Holm and Jacob Norlin Andersson\n *\n */\npublic class Selection {\n\n\t/**\n\t * Throws ",
"end": 384,
"score": 0.999833881855011,
"start": 362,
"tag": "NAME",
"value": "Jacob Norlin Andersson"
}
] | null |
[] |
package engine;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.util.List;
import javax.media.opengl.GL2;
import collision.CollisionData;
import collision.tests.RaySphereIntersectTest;
import structures.Entity;
import structures.Vector;
/**
* System for selecting objects while in game.
* @author <NAME> and <NAME>
*
*/
public class Selection {
/**
* Throws a ray which is checked for intersection against each
* object in the world to see if the mouse is on top of an
* object.
* @param pitch
* @param yaw
*/
public void findTarget(float pitch, float yaw){
pitch += Camera.pitch;
yaw += Camera.yaw;
Vector lookPos = Vector.newTurnedUnitVector(pitch, yaw);
lookPos = new Vector(1,-1,-1).turn(pitch, yaw);
System.out.println(lookPos.abs());
lookPos.multiplySelf(300);
Vector offset = new Vector(5,5,5);
lookPos.addSelf(Camera.pos);
Engine.gl.glPointSize(10);
Engine.gl.glLoadIdentity();
Engine.gl.glBegin(GL2.GL_POINTS);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(lookPos.x, lookPos.y, lookPos.z);
Engine.gl.glEnd();
Engine.gl.glBegin(GL2.GL_LINES);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(lookPos.x, lookPos.y, lookPos.z);
Engine.gl.glColor3f(1, 0, 0);
Engine.gl.glVertex3f(offset.x, offset.y, offset.z);
Engine.gl.glEnd();
Engine.gl.glLoadIdentity();
Engine.gl.glRotatef(pitch, 1, 0, 0);
Engine.gl.glRotatef(yaw, 0, 1, 0);
Engine.gl.glBegin(GL2.GL_LINES);
Engine.gl.glColor3f(0, 1, 0);
Engine.gl.glVertex3f(0,0,0);
Engine.gl.glColor3f(1, 1, 1);
Engine.gl.glVertex3f(0,0,3);
Engine.gl.glEnd();
System.out.println(lookPos);
RaySphereIntersectTest test = new RaySphereIntersectTest();
for (Entity entity : Entity.all) {
if(test.TestRaySphere(Camera.pos, lookPos, entity)){
onOver(entity);
break;
}
}
}
/**
* If the mouse is on an object this method is called.
* @param entity
*/
public void onOver(Entity entity){
System.out.println(" COOLT GRABBEN");
// Camera.setTarget(smek.pos);
}
/**
* Converts the mouse position to be able to find a target.
*/
public void findMouseTarget(){
Point mousePos = Input.getRelativeMousePos();
Rectangle bounds = Engine.getAbsoluteCanvasBounds();
float bw = bounds.width/2f;
float bh = bounds.height/2f;
Point2D.Float lol = new Point2D.Float(mousePos.x/bw-1, mousePos.y/bh-1);
System.out.println("WWEEEEEEEE mouseCoords: "+lol);
float FOV = Camera.getFOV()/2;
float yaw = lol.x*FOV;
float pitch = lol.y*FOV;
// System.out.println("-----------");
// System.out.println("mouseX: "+mouseX+" mouseY: "+mouseY+"\n"+
// "pitch: "+pitch+" yaw: "+yaw+"\n"+
// "xAspect: "+xAspect+" yAspect: "+yAspect);
System.out.println("===========");
findTarget(pitch, yaw);
}
}
| 2,885 | 0.666093 | 0.645439 | 113 | 24.707964 | 19.815378 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.442478 | false | false |
13
|
59cf3a3a6f9ab1495a82e242517465dd3c5e7cbb
| 25,812,753,484,383 |
c094d92209cfa3181f842799341a18b271ca6f28
|
/src/com/neuedu/test/work.java
|
34d7efcec9cb4a44980522b90739a680867ea668
|
[] |
no_license
|
Firetryant/jdbcTest
|
https://github.com/Firetryant/jdbcTest
|
d284fde7fcaf188a49bc36a589073877cde94e96
|
5819ae61858e24b6b8207e33e4b013593dcb3809
|
refs/heads/master
| 2020-06-13T06:35:33.008000 | 2019-07-01T00:12:22 | 2019-07-01T00:12:22 | 194,573,415 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.neuedu.test;
public class work {
//混元霹雳手 08:09:55
// package com.neuedu.pojo;
public class Tests {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Tests(int id, String name) {
this.id = id;
this.name = name;
}
public Tests() {
}
@Override
public String toString() {
return "Tests{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
// 混元霹雳手 08:10:06
// package com.neuedu.test;
import com.neuedu.pojo.Tests;
import com.neuedu.util.JdbcTest;
import java.util.List;
public class Test {
public static void main(String[] args) {
// Tests tests= new Tests(20,"qwer");
// JdbcTest.executeUpdate("insert into Tests(id,name) values(?,?)",tests.getId(),tests.getName());
JdbcTest.selectMethod();
List<Tests> ts= JdbcTest.selectMethod();
for (Tests s:ts
) {
System.out.println(s);
}
}
}
//混元霹雳手 08:10:16
// package com.neuedu.util;
import com.mysql.jdbc.Driver;
import com.neuedu.pojo.Tests;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
//增删改查 2重复代码 3 结果存储 拿到结果 怎么存储
public class JdbcTest {
public static final String URL ="jdbc:mysql://127.0.0.1:3306/test1?useUnicode=true&characterEncoding=utf8";
public static final String user="root";
public static final String prd="root";
static{
//加载驱动
try {
new Driver();
} catch (SQLException e) {
e.printStackTrace();
}
}
// 动态参数
// public static void move(int... ints){
// for(int i=0;i<ints.length;i++){
// System.out.println(i);
// }
//
// }
// public static void main(String[] args) {
// move(1,2,3,4);
// insertMethod();
// selectMethod();
// updateMethod();
// deleteMethod();
// insertMethod("insert into Tests(id,name) values(?,?)",13,"封装测试");
// }
// 查询的方法
public static List<Tests> selectMethod(){
List<Tests> ts= new ArrayList<>();
Connection conn=null;
PreparedStatement pstm=null;
ResultSet rs=null;
try {
conn=DriverManager.getConnection(URL,user,prd);
String sql ="select * from Tests";
// where name=?";
pstm=conn.prepareStatement(sql);
// pstm.setString(1,"qqqq");
rs=pstm.executeQuery();
// 创建查询窗口
// ? 占位
// statement 和 PreparedStatement 的区别
// state=conn.createStatement();
// 如果条件是字符串 要加引号
// sql 注入 加入 横成立的 or 1=1
// sql 相对安全 (相对)
// String sql = "select * from Tests";
// rs= state.executeQuery(sql);
while(rs.next()){
// int a=rs.getInt(1);
//// String a=rs.getString("name");
//// int a=rs.getInt("id");
// System.out.println(a);
int id=rs.getInt("id");
String name =rs.getString("name");
Tests tests = new Tests(id,name);
ts.add(tests);
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
// try {
// rs.close();
// state.close();
// conn.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
close(rs,pstm,conn);
}
return ts;
}
// 动态参数一定要放在参数列表的最后位置
// 插入的方法 英文 中文
// 对增删 封装的一个方法 对任意数据进行 操作 ------对数据库操作的根据类
public static int executeUpdate(String sql,Object... objs){
Connection conn=null;
PreparedStatement pstm =null;
int result=0;
try {
conn=DriverManager.getConnection(URL,user,prd);
pstm=conn.prepareStatement(sql);
if(objs!=null){
for(int i=0;i<objs.length;i++){
pstm.setObject(i+1,objs[i]);
}
}
result= pstm.executeUpdate();
// System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,pstm,conn);
}
return result;
}
// public static void insertMethod(){
// Connection conn=null;
// Statement state=null;
/* try {
conn=DriverManager.getConnection(URL,user,prd);
state=conn.createStatement();
String sql = "insert into Tests(name) values('中文')";
int result=state.executeUpdate(sql);
System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,state,conn);
}*/
// }
// 改的方法
// public static void updateMethod(){
// Connection conn= null;
// Statement state=null;
/* try {
conn = DriverManager.getConnection(URL,user,prd);
state =conn.createStatement();
String sql="update Tests set name='b' where id=1 ";
int result=state.executeUpdate(sql);
System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,state,conn);
}*/
// }
// 删的方法
//public static void deleteMethod(){
// Connection conn= null;
// PreparedStatement pstm=null;
/* try {
conn = DriverManager.getConnection(URL,user,prd);
String sql="delete from Tests where id=4";
pstm=conn.prepareStatement(sql);
// state =conn.createStatement();
// String sql="delete from Tests where id=4";
// int result=state.executeUpdate(sql);
// System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,pstm,conn);
}*/
//}
//关闭的方法
public static void close( ResultSet rs,PreparedStatement pstm,Connection conn){
if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(pstm!=null){
try {
pstm.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
//修改 删除
//当前方法 不足 缺点
}
|
UTF-8
|
Java
| 7,723 |
java
|
work.java
|
Java
|
[
{
"context": " public static final String URL =\"jdbc:mysql://127.0.0.1:3306/test1?useUnicode=true&characterEncoding=utf8",
"end": 1726,
"score": 0.9997062683105469,
"start": 1717,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
},
{
"context": "=utf8\";\n public static final String user=\"root\";\n public static final String prd=\"root\";",
"end": 1825,
"score": 0.9762720465660095,
"start": 1821,
"tag": "USERNAME",
"value": "root"
}
] | null |
[] |
package com.neuedu.test;
public class work {
//混元霹雳手 08:09:55
// package com.neuedu.pojo;
public class Tests {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Tests(int id, String name) {
this.id = id;
this.name = name;
}
public Tests() {
}
@Override
public String toString() {
return "Tests{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
// 混元霹雳手 08:10:06
// package com.neuedu.test;
import com.neuedu.pojo.Tests;
import com.neuedu.util.JdbcTest;
import java.util.List;
public class Test {
public static void main(String[] args) {
// Tests tests= new Tests(20,"qwer");
// JdbcTest.executeUpdate("insert into Tests(id,name) values(?,?)",tests.getId(),tests.getName());
JdbcTest.selectMethod();
List<Tests> ts= JdbcTest.selectMethod();
for (Tests s:ts
) {
System.out.println(s);
}
}
}
//混元霹雳手 08:10:16
// package com.neuedu.util;
import com.mysql.jdbc.Driver;
import com.neuedu.pojo.Tests;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
//增删改查 2重复代码 3 结果存储 拿到结果 怎么存储
public class JdbcTest {
public static final String URL ="jdbc:mysql://127.0.0.1:3306/test1?useUnicode=true&characterEncoding=utf8";
public static final String user="root";
public static final String prd="root";
static{
//加载驱动
try {
new Driver();
} catch (SQLException e) {
e.printStackTrace();
}
}
// 动态参数
// public static void move(int... ints){
// for(int i=0;i<ints.length;i++){
// System.out.println(i);
// }
//
// }
// public static void main(String[] args) {
// move(1,2,3,4);
// insertMethod();
// selectMethod();
// updateMethod();
// deleteMethod();
// insertMethod("insert into Tests(id,name) values(?,?)",13,"封装测试");
// }
// 查询的方法
public static List<Tests> selectMethod(){
List<Tests> ts= new ArrayList<>();
Connection conn=null;
PreparedStatement pstm=null;
ResultSet rs=null;
try {
conn=DriverManager.getConnection(URL,user,prd);
String sql ="select * from Tests";
// where name=?";
pstm=conn.prepareStatement(sql);
// pstm.setString(1,"qqqq");
rs=pstm.executeQuery();
// 创建查询窗口
// ? 占位
// statement 和 PreparedStatement 的区别
// state=conn.createStatement();
// 如果条件是字符串 要加引号
// sql 注入 加入 横成立的 or 1=1
// sql 相对安全 (相对)
// String sql = "select * from Tests";
// rs= state.executeQuery(sql);
while(rs.next()){
// int a=rs.getInt(1);
//// String a=rs.getString("name");
//// int a=rs.getInt("id");
// System.out.println(a);
int id=rs.getInt("id");
String name =rs.getString("name");
Tests tests = new Tests(id,name);
ts.add(tests);
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
// try {
// rs.close();
// state.close();
// conn.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
close(rs,pstm,conn);
}
return ts;
}
// 动态参数一定要放在参数列表的最后位置
// 插入的方法 英文 中文
// 对增删 封装的一个方法 对任意数据进行 操作 ------对数据库操作的根据类
public static int executeUpdate(String sql,Object... objs){
Connection conn=null;
PreparedStatement pstm =null;
int result=0;
try {
conn=DriverManager.getConnection(URL,user,prd);
pstm=conn.prepareStatement(sql);
if(objs!=null){
for(int i=0;i<objs.length;i++){
pstm.setObject(i+1,objs[i]);
}
}
result= pstm.executeUpdate();
// System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,pstm,conn);
}
return result;
}
// public static void insertMethod(){
// Connection conn=null;
// Statement state=null;
/* try {
conn=DriverManager.getConnection(URL,user,prd);
state=conn.createStatement();
String sql = "insert into Tests(name) values('中文')";
int result=state.executeUpdate(sql);
System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,state,conn);
}*/
// }
// 改的方法
// public static void updateMethod(){
// Connection conn= null;
// Statement state=null;
/* try {
conn = DriverManager.getConnection(URL,user,prd);
state =conn.createStatement();
String sql="update Tests set name='b' where id=1 ";
int result=state.executeUpdate(sql);
System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,state,conn);
}*/
// }
// 删的方法
//public static void deleteMethod(){
// Connection conn= null;
// PreparedStatement pstm=null;
/* try {
conn = DriverManager.getConnection(URL,user,prd);
String sql="delete from Tests where id=4";
pstm=conn.prepareStatement(sql);
// state =conn.createStatement();
// String sql="delete from Tests where id=4";
// int result=state.executeUpdate(sql);
// System.out.println(result);
} catch (SQLException e) {
e.printStackTrace();
}finally {
close(null,pstm,conn);
}*/
//}
//关闭的方法
public static void close( ResultSet rs,PreparedStatement pstm,Connection conn){
if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(pstm!=null){
try {
pstm.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
//修改 删除
//当前方法 不足 缺点
}
| 7,723 | 0.468195 | 0.461278 | 262 | 27.141222 | 18.561203 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.59542 | false | false |
13
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.