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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
63102c2d744813d164e81f486568f790f7f81f63 | 16,724,602,657,148 | d7d598324a9f17012abc094fac03d8460995fa09 | /src/main/java/exercitii/OOP3exercises/CircleFirst.java | 989cd06b641563c5a06f06e35db0258bed5805cc | []
| no_license | Bogdan051979/demo_repo | https://github.com/Bogdan051979/demo_repo | de8d3391384f9fa5be76ff3c606656b3c15c0dd4 | 1cb96d886e604280e1fa5b665bdc96e8eae5888f | refs/heads/master | 2023-05-31T09:51:53.607000 | 2021-06-05T12:38:50 | 2021-06-05T12:38:50 | 374,086,323 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package exercitii.OOP3exercises;
public class CircleFirst {
// public constants
public static final double DEFAULT_RADIUS = 1.0;
public static final String DEFAULT_COLOR = "red";
// private instance variables
private double radius;
private String color;
// the overloaded constructors
// constructs a CircleFirst with default radius and color
public CircleFirst() {// 1st constructor
this.radius = DEFAULT_RADIUS;
this.color = DEFAULT_COLOR;
}
// constructs a CircleFirst with the given radius and default color
public CircleFirst(double radius) {// 2nd constructor
this.radius = radius;
this.color = DEFAULT_COLOR;
}
// construct a CircleFirst with the given radius and color
public CircleFirst(double radius, String color) { // 3rd constructor
this.radius = radius;
this.color = color;
}
// returns the radius - the public getter for private variable radius
public double getRadius() {
return this.radius;
}
// set the radius - the public setter for private variable radius
public void setRadius(double radius) {
this.radius = radius;
}
// returns the color - the public getter for private variable color
public String getColor() {
return this.color;
}
// set the color - the public setter for private variable color
public void setColor(String color) {
this.color = color;
}
// returns a self-descriptive string for this CircleFirst instance
@Override
public String toString() {
return "CircleFirst[radius=" + radius + " ,color=" + color + "]";
}
// returns the area of this CircleFirst
public double getArea() {
return radius * radius * Math.PI;
}
// return the circumference of this CircleFirst
public double getCircumference() {
return 2.0 * radius * Math.PI;
}
}
| UTF-8 | Java | 1,750 | java | CircleFirst.java | Java | []
| null | []
| package exercitii.OOP3exercises;
public class CircleFirst {
// public constants
public static final double DEFAULT_RADIUS = 1.0;
public static final String DEFAULT_COLOR = "red";
// private instance variables
private double radius;
private String color;
// the overloaded constructors
// constructs a CircleFirst with default radius and color
public CircleFirst() {// 1st constructor
this.radius = DEFAULT_RADIUS;
this.color = DEFAULT_COLOR;
}
// constructs a CircleFirst with the given radius and default color
public CircleFirst(double radius) {// 2nd constructor
this.radius = radius;
this.color = DEFAULT_COLOR;
}
// construct a CircleFirst with the given radius and color
public CircleFirst(double radius, String color) { // 3rd constructor
this.radius = radius;
this.color = color;
}
// returns the radius - the public getter for private variable radius
public double getRadius() {
return this.radius;
}
// set the radius - the public setter for private variable radius
public void setRadius(double radius) {
this.radius = radius;
}
// returns the color - the public getter for private variable color
public String getColor() {
return this.color;
}
// set the color - the public setter for private variable color
public void setColor(String color) {
this.color = color;
}
// returns a self-descriptive string for this CircleFirst instance
@Override
public String toString() {
return "CircleFirst[radius=" + radius + " ,color=" + color + "]";
}
// returns the area of this CircleFirst
public double getArea() {
return radius * radius * Math.PI;
}
// return the circumference of this CircleFirst
public double getCircumference() {
return 2.0 * radius * Math.PI;
}
}
| 1,750 | 0.725143 | 0.720571 | 70 | 24 | 22.871067 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 9 |
da8af0d18274e779f2dd90b163419eee0b9c4ecd | 21,251,498,189,453 | fc8472bf5920deefda2c5c85855d111d4d49727c | /0936-stamping-the-sequence.java | 7cffcf79bf4a17e77c7468476d0c47fcbb885ede | []
| no_license | leetcodepeasant/LeetCode_Solutions | https://github.com/leetcodepeasant/LeetCode_Solutions | 03944532495be0d33929758d7da95f8e99160651 | d011bbd376cf9b8261b45b80782a101f747696b5 | refs/heads/main | 2023-03-28T17:39:13.893000 | 2021-04-03T22:02:24 | 2021-04-03T22:02:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | class Solution {
public int[] movesToStamp(String stamp, String target) {
char[] S = stamp.toCharArray();
char[] T = target.toCharArray();
List<Integer> ans = new ArrayList<>();
boolean[] visited = new boolean[T.length - S.length + 1];
int questions = 0;
while (questions < T.length) {
boolean canSolve = false;
for (int i = 0; i <= T.length - S.length; i++) {
// i-th winwodw: starts at index i with length of S.length.
if (!visited[i] && canSolveWindow(S, T, i)) {
// visited[i] indicates whether i-th window has been replaced with all ?.
questions = solveWindow(S, T, i, questions);
ans.add(i);
visited[i] = true;
canSolve = true;
if (questions == T.length) {
break;
}
}
}
if (!canSolve) {
// If after checking all the windows and still find no solvable window,
// then the sequence is not possible to stamp. Early return, otherwise infinite loop.
return new int[0];
}
}
// Actual stamping sequence is the reverse of ans.
int[] ansArray = new int[ans.size()];
for (int i = 0; i < ans.size(); i++) {
ansArray[i] = ans.get(ans.size() - i - 1);
}
return ansArray;
}
private boolean canSolveWindow(char[] S, char[] T, int p) {
// Check if the p-th window of T can be replaced with all ?.
for (int i = 0; i < S.length; i++) {
if (T[i + p] != '?' && T[i + p] != S[i]) {
return false;
}
}
return true;
}
private int solveWindow(char[] S, char[] T, int p, int cnt) {
// Replace the p-th window of T with all ? and return the total number of ? in T now.
for (int i = 0; i < S.length; i++) {
if (T[i + p] != '?') {
T[i + p] = '?';
cnt++;
}
}
return cnt;
}
}
| UTF-8 | Java | 2,183 | java | 0936-stamping-the-sequence.java | Java | []
| null | []
| class Solution {
public int[] movesToStamp(String stamp, String target) {
char[] S = stamp.toCharArray();
char[] T = target.toCharArray();
List<Integer> ans = new ArrayList<>();
boolean[] visited = new boolean[T.length - S.length + 1];
int questions = 0;
while (questions < T.length) {
boolean canSolve = false;
for (int i = 0; i <= T.length - S.length; i++) {
// i-th winwodw: starts at index i with length of S.length.
if (!visited[i] && canSolveWindow(S, T, i)) {
// visited[i] indicates whether i-th window has been replaced with all ?.
questions = solveWindow(S, T, i, questions);
ans.add(i);
visited[i] = true;
canSolve = true;
if (questions == T.length) {
break;
}
}
}
if (!canSolve) {
// If after checking all the windows and still find no solvable window,
// then the sequence is not possible to stamp. Early return, otherwise infinite loop.
return new int[0];
}
}
// Actual stamping sequence is the reverse of ans.
int[] ansArray = new int[ans.size()];
for (int i = 0; i < ans.size(); i++) {
ansArray[i] = ans.get(ans.size() - i - 1);
}
return ansArray;
}
private boolean canSolveWindow(char[] S, char[] T, int p) {
// Check if the p-th window of T can be replaced with all ?.
for (int i = 0; i < S.length; i++) {
if (T[i + p] != '?' && T[i + p] != S[i]) {
return false;
}
}
return true;
}
private int solveWindow(char[] S, char[] T, int p, int cnt) {
// Replace the p-th window of T with all ? and return the total number of ? in T now.
for (int i = 0; i < S.length; i++) {
if (T[i + p] != '?') {
T[i + p] = '?';
cnt++;
}
}
return cnt;
}
}
| 2,183 | 0.452588 | 0.448923 | 58 | 36.637932 | 25.185312 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.706897 | false | false | 9 |
3750d0a98930b20fc6caa6b8a5b2c8fe2c3f6267 | 23,115,513,992,823 | 78bad9aadefb31fb967e5be20d44c3455b3c021c | /src/main/java/User.java | d0dcac814cec2de334833fd775829ab8e4ff540d | [
"MIT"
]
| permissive | bord81/Online-shop-on-MVC | https://github.com/bord81/Online-shop-on-MVC | d78bbc2bd63a9face98359d0bf468cdc2fe1e4d9 | 2109f9fe94a3cc52f529dae4fb750bbdedb41597 | refs/heads/master | 2021-01-21T14:58:25.174000 | 2017-05-19T17:16:47 | 2017-05-19T17:16:47 | 91,827,885 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pshopmvc;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class User implements Serializable{
@Id
private int id;
private String cookie;
private String basket;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getBasket() {
return basket;
}
public void setBasket(String basket) {
this.basket = basket;
}
public User() {
}
public User(int id, String cookie, String basket) {
this.id = id;
this.cookie = cookie;
this.basket = basket;
}
}
| UTF-8 | Java | 815 | java | User.java | Java | []
| null | []
| package pshopmvc;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class User implements Serializable{
@Id
private int id;
private String cookie;
private String basket;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getBasket() {
return basket;
}
public void setBasket(String basket) {
this.basket = basket;
}
public User() {
}
public User(int id, String cookie, String basket) {
this.id = id;
this.cookie = cookie;
this.basket = basket;
}
}
| 815 | 0.595092 | 0.595092 | 47 | 16.340425 | 14.600024 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.382979 | false | false | 9 |
0ec7ffc46903b5f1afbb18f3a8453fcc07e785c0 | 23,441,931,506,607 | dccf28692f23f877cc65d57f50017b64fd491cb5 | /src/com/example/bootcamp/GetImageTask.java | 3a6b4776ff85402cf8f496b8cabacf5c9df5b4a1 | []
| no_license | pivotal-lihao-luo/Bootcamp | https://github.com/pivotal-lihao-luo/Bootcamp | dd4db522358133764133aeec281dcdcd797c15b9 | 62d71e52debcf23aba38b92879a5bfbfa8a9a4cb | refs/heads/master | 2016-09-05T11:40:17.657000 | 2014-09-05T20:40:02 | 2014-09-05T20:40:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.bootcamp;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.util.Log;
public class GetImageTask {
private static GetImageTask instance;
private HashMap<String, Drawable> cache;
private static final String debug_tag = "getImageTask";
private UpdatableActivity temp;
public synchronized static GetImageTask getInstance() {
if (instance == null) {
instance = new GetImageTask();
}
return instance;
}
private GetImageTask() {
cache = new HashMap<String, Drawable>();
}
public Drawable getImage(String url, UpdatableActivity adapter) {
if (cache.containsKey(url))
return cache.get(url);
else {
temp = adapter;
new GetImage().execute(url);
return null;
}
}
private class GetImage extends AsyncTask<String, Integer, Drawable> {
@Override
protected Drawable doInBackground(String... url) {
try {
InputStream is = (InputStream) new URL(url[0]).getContent();
Drawable poster = Drawable.createFromStream(is, "src");
cache.put(url[0], poster);
return poster;
} catch (Exception e) {
Log.d(debug_tag, e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Drawable result) {
super.onPostExecute(result);
temp.updateImage();
}
}
} | UTF-8 | Java | 1,399 | java | GetImageTask.java | Java | []
| null | []
| package com.example.bootcamp;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.util.Log;
public class GetImageTask {
private static GetImageTask instance;
private HashMap<String, Drawable> cache;
private static final String debug_tag = "getImageTask";
private UpdatableActivity temp;
public synchronized static GetImageTask getInstance() {
if (instance == null) {
instance = new GetImageTask();
}
return instance;
}
private GetImageTask() {
cache = new HashMap<String, Drawable>();
}
public Drawable getImage(String url, UpdatableActivity adapter) {
if (cache.containsKey(url))
return cache.get(url);
else {
temp = adapter;
new GetImage().execute(url);
return null;
}
}
private class GetImage extends AsyncTask<String, Integer, Drawable> {
@Override
protected Drawable doInBackground(String... url) {
try {
InputStream is = (InputStream) new URL(url[0]).getContent();
Drawable poster = Drawable.createFromStream(is, "src");
cache.put(url[0], poster);
return poster;
} catch (Exception e) {
Log.d(debug_tag, e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Drawable result) {
super.onPostExecute(result);
temp.updateImage();
}
}
} | 1,399 | 0.694782 | 0.693352 | 62 | 21.580645 | 19.727619 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.112903 | false | false | 9 |
63c7a0c82fc49ed294bcfd40af303fb067d7fd89 | 26,723,286,522,308 | 2c82685308270e02066234e8c5db298bc20f14d4 | /src/com/atguigui/truck/truckTest.java | a79fa8c70ef21c6b74f667d50a7c096967d2d4f5 | []
| no_license | rockpm/lalala | https://github.com/rockpm/lalala | 4e350a7b973a65906e8d9e397e9c66f9d549f36d | 94078f89d43307ee4b9f065443688bf8f7555c06 | refs/heads/master | 2020-03-17T14:19:19.021000 | 2018-05-16T13:31:37 | 2018-05-16T13:31:37 | 133,667,100 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.atguigui.truck;
public class truckTest {
public static void main(String[] args) {
System.out.println("lalala");
System.out.println("123");
System.out.println("456");
System.out.println("789");
}
}
| UTF-8 | Java | 234 | java | truckTest.java | Java | []
| null | []
| package com.atguigui.truck;
public class truckTest {
public static void main(String[] args) {
System.out.println("lalala");
System.out.println("123");
System.out.println("456");
System.out.println("789");
}
}
| 234 | 0.649573 | 0.611111 | 12 | 17.5 | 14.801464 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false | 9 |
d329a8d27939a518e7585f152513613b7e236674 | 11,149,735,113,599 | 7f2e4e6f6cb7f38b18baeb72ff11646339e8f824 | /src/com/syntax/class14/MethodExamples.java | fa759a47e1825eb2034fc8fee6185b76436dd1d9 | []
| no_license | ChuyG1/JavaBasics | https://github.com/ChuyG1/JavaBasics | 6839a3bbd45d320a65b638bf2a0c36bfbdd531ba | 11241259cf2f314832e167f4f5e344dd3d9d5a29 | refs/heads/master | 2021-03-31T11:46:47.923000 | 2020-05-02T17:38:57 | 2020-05-02T17:38:57 | 248,104,547 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.syntax.class14;
public class MethodExamples {
//want to create a method that will be greeting a person
void greet(String name) {
System.out.println("Hello "+name);
}
public static void main(String[] args) {
//how do i call method greet?
//ClassName variableName=new ClassName();
MethodExamples object1=new MethodExamples();
object1.greet("Chuy");
object1.greet("Angel");
object1.greet("Pri");
object1.greet("Emilio");
}
}
| UTF-8 | Java | 461 | java | MethodExamples.java | Java | [
{
"context": "es object1=new MethodExamples();\n\t\tobject1.greet(\"Chuy\");\n\t\tobject1.greet(\"Angel\");\n\t\tobject1.greet(\"Pri",
"end": 375,
"score": 0.999312162399292,
"start": 371,
"tag": "NAME",
"value": "Chuy"
},
{
"context": "ples();\n\t\tobject1.greet(\"Chuy\");\n\t\tobject1.greet(\"Angel\");\n\t\tobject1.greet(\"Pri\");\n\t\tobject1.greet(\"Emili",
"end": 401,
"score": 0.9991716146469116,
"start": 396,
"tag": "NAME",
"value": "Angel"
},
{
"context": "huy\");\n\t\tobject1.greet(\"Angel\");\n\t\tobject1.greet(\"Pri\");\n\t\tobject1.greet(\"Emilio\");\n\t}\n}\n",
"end": 425,
"score": 0.999839186668396,
"start": 422,
"tag": "NAME",
"value": "Pri"
},
{
"context": "Angel\");\n\t\tobject1.greet(\"Pri\");\n\t\tobject1.greet(\"Emilio\");\n\t}\n}\n",
"end": 452,
"score": 0.9994561672210693,
"start": 446,
"tag": "NAME",
"value": "Emilio"
}
]
| null | []
| package com.syntax.class14;
public class MethodExamples {
//want to create a method that will be greeting a person
void greet(String name) {
System.out.println("Hello "+name);
}
public static void main(String[] args) {
//how do i call method greet?
//ClassName variableName=new ClassName();
MethodExamples object1=new MethodExamples();
object1.greet("Chuy");
object1.greet("Angel");
object1.greet("Pri");
object1.greet("Emilio");
}
}
| 461 | 0.70282 | 0.687636 | 20 | 22.049999 | 17.45129 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.55 | false | false | 9 |
cfe5266099cdc77b2ed89ae5add1d584014b38a5 | 29,008,209,125,774 | a7f104284e2565081e579c03807afee23f105121 | /src/main/java/com/zhenghao/dbmigration/entity/sqlserver/SQLServerToolCategory.java | 0bfd2b4f97e84e939521010f639fb4ac19b7a5ac | []
| no_license | ls1314loveni/DBMigration | https://github.com/ls1314loveni/DBMigration | 2deb0bec6d471040c67439ee8bbbcf8f893131de | 890c27fca8e8b1756a4bfd309889595a062fa0f7 | refs/heads/master | 2020-07-24T12:53:59.670000 | 2019-09-19T11:36:38 | 2019-09-19T11:36:38 | 207,935,195 | 0 | 0 | null | false | 2020-07-01T18:58:06 | 2019-09-12T01:03:25 | 2019-09-19T11:44:38 | 2020-07-01T18:58:04 | 89 | 0 | 0 | 1 | Java | false | false | package com.zhenghao.dbmigration.entity.sqlserver;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName(value = "tool_category")
public class SQLServerToolCategory {
private Integer categoryId;
private String categoryName;
private Integer fatherId;
private String categoryTag;
}
| UTF-8 | Java | 337 | java | SQLServerToolCategory.java | Java | []
| null | []
| package com.zhenghao.dbmigration.entity.sqlserver;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName(value = "tool_category")
public class SQLServerToolCategory {
private Integer categoryId;
private String categoryName;
private Integer fatherId;
private String categoryTag;
}
| 337 | 0.783383 | 0.783383 | 15 | 21.466667 | 18.424139 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 9 |
84f63e959ecf38ff2c553d6e11f6ffde2ddb1fb7 | 13,030,930,787,920 | 4d558449bd6a2f77e2cbbbba61a9d315fddf0c3e | /service/src/test/java/uk/gov/hmcts/reform/fpl/service/hearing/HearingServiceTest.java | e600939757e9836a6efe5c24b9b456c70dc9ae25 | [
"MIT"
]
| permissive | hmcts/fpl-ccd-configuration | https://github.com/hmcts/fpl-ccd-configuration | e55bab0556fe435cbcd525dceef7ae1191cb6773 | c821243f4a93f1634da8ce43f3135d0f21a46000 | refs/heads/master | 2023-09-01T19:23:30.620000 | 2023-09-01T10:07:28 | 2023-09-01T10:07:28 | 150,105,196 | 14 | 7 | MIT | false | 2023-09-14T15:25:57 | 2018-09-24T13:15:51 | 2023-08-23T08:26:13 | 2023-09-14T15:25:55 | 40,062 | 14 | 7 | 47 | Java | false | false | package uk.gov.hmcts.reform.fpl.service.hearing;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.NullSource;
import org.mockito.Mockito;
import uk.gov.hmcts.reform.fpl.enums.HearingStatus;
import uk.gov.hmcts.reform.fpl.model.CaseData;
import uk.gov.hmcts.reform.fpl.model.HearingBooking;
import uk.gov.hmcts.reform.fpl.model.common.Element;
import uk.gov.hmcts.reform.fpl.model.common.dynamic.DynamicList;
import uk.gov.hmcts.reform.fpl.model.common.dynamic.DynamicListElement;
import uk.gov.hmcts.reform.fpl.service.time.Time;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static uk.gov.hmcts.reform.fpl.utils.ElementUtils.element;
class HearingServiceTest {
private static final UUID FIELD_SELECTOR = UUID.randomUUID();
private static final HearingBooking HEARING_BOOKING = mock(HearingBooking.class);
private static final UUID ANOTHER_SELECTOR = UUID.randomUUID();
private static final LocalDateTime NOW = LocalDateTime.of(2020, 12, 10, 2, 3, 4);
private final Time time = mock(Time.class);
private final HearingService underTest = new HearingService(time);
@Nested
class FindHearing {
@Test
void noSelector() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder().build(), null);
assertThat(actual).isEmpty();
}
@Test
void noSelectorSelected() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder().build(),
selectedItem(null)
);
assertThat(actual).isEmpty();
}
@Test
void selectorWhenNoBookings() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(List.of())
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEmpty();
}
@Test
void selectorWithoutMatchingBooking() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(
List.of(
element(ANOTHER_SELECTOR, HEARING_BOOKING)
))
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEqualTo(Optional.empty());
}
@Test
void selectorMatchingBooking() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(List.of(
element(FIELD_SELECTOR, HEARING_BOOKING)
))
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEqualTo(Optional.of(element(FIELD_SELECTOR, HEARING_BOOKING)));
}
private DynamicList selectedItem(UUID fieldSelector) {
return DynamicList.builder().value(DynamicListElement.builder().code(fieldSelector).build()).build();
}
}
@Nested
class FindOnlyHearingsTodayOrInPastNonVacated {
@BeforeEach
void setUp() {
Mockito.when(time.now()).thenReturn(NOW);
}
@Test
void whenNoHearingDetails() {
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(null).cancelledHearingDetails(null).build());
assertThat(actual).isEqualTo(List.of());
}
@Test
void whenEmptyHearingDetails() {
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of()).cancelledHearingDetails(List.of()).build());
assertThat(actual).isEqualTo(List.of());
}
@Test
void returnInThePast() {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void returnInThePastCancelled() {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.cancelledHearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void returnNow() {
Element<HearingBooking> hearing = hearing(NOW);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@ParameterizedTest
@EnumSource(value = HearingStatus.class,
names = {"VACATED", "VACATED_AND_RE_LISTED", "VACATED_TO_BE_RE_LISTED"})
void doNotReturnIfStatus(HearingStatus hearingStatus) {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1), hearingStatus);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of());
}
@ParameterizedTest
@NullSource
@EnumSource(value = HearingStatus.class,
names = {"ADJOURNED", "ADJOURNED_TO_BE_RE_LISTED", "ADJOURNED_AND_RE_LISTED"})
void returnIfStatus(HearingStatus hearingStatus) {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1), hearingStatus);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void doReturnInFutureIfJustBeforeTodayMidnight() {
Element<HearingBooking> hearing = hearing(NOW.toLocalDate().plusDays(1).atStartOfDay().minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void doNotReturnInFutureIfAfterTodayMidnight() {
Element<HearingBooking> hearing = hearing(NOW.toLocalDate().plusDays(1).atStartOfDay());
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of());
}
private Element<HearingBooking> hearing(LocalDateTime localDateTime) {
return element(FIELD_SELECTOR, HearingBooking.builder().endDate(localDateTime).build());
}
private Element<HearingBooking> hearing(LocalDateTime localDateTime, HearingStatus status) {
return element(FIELD_SELECTOR, HearingBooking.builder().endDate(localDateTime).status(status).build());
}
}
}
| UTF-8 | Java | 8,125 | java | HearingServiceTest.java | Java | []
| null | []
| package uk.gov.hmcts.reform.fpl.service.hearing;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.NullSource;
import org.mockito.Mockito;
import uk.gov.hmcts.reform.fpl.enums.HearingStatus;
import uk.gov.hmcts.reform.fpl.model.CaseData;
import uk.gov.hmcts.reform.fpl.model.HearingBooking;
import uk.gov.hmcts.reform.fpl.model.common.Element;
import uk.gov.hmcts.reform.fpl.model.common.dynamic.DynamicList;
import uk.gov.hmcts.reform.fpl.model.common.dynamic.DynamicListElement;
import uk.gov.hmcts.reform.fpl.service.time.Time;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static uk.gov.hmcts.reform.fpl.utils.ElementUtils.element;
class HearingServiceTest {
private static final UUID FIELD_SELECTOR = UUID.randomUUID();
private static final HearingBooking HEARING_BOOKING = mock(HearingBooking.class);
private static final UUID ANOTHER_SELECTOR = UUID.randomUUID();
private static final LocalDateTime NOW = LocalDateTime.of(2020, 12, 10, 2, 3, 4);
private final Time time = mock(Time.class);
private final HearingService underTest = new HearingService(time);
@Nested
class FindHearing {
@Test
void noSelector() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder().build(), null);
assertThat(actual).isEmpty();
}
@Test
void noSelectorSelected() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder().build(),
selectedItem(null)
);
assertThat(actual).isEmpty();
}
@Test
void selectorWhenNoBookings() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(List.of())
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEmpty();
}
@Test
void selectorWithoutMatchingBooking() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(
List.of(
element(ANOTHER_SELECTOR, HEARING_BOOKING)
))
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEqualTo(Optional.empty());
}
@Test
void selectorMatchingBooking() {
Optional<Element<HearingBooking>> actual = underTest.findHearing(CaseData.builder()
.hearingDetails(List.of(
element(FIELD_SELECTOR, HEARING_BOOKING)
))
.build(),
selectedItem(FIELD_SELECTOR)
);
assertThat(actual).isEqualTo(Optional.of(element(FIELD_SELECTOR, HEARING_BOOKING)));
}
private DynamicList selectedItem(UUID fieldSelector) {
return DynamicList.builder().value(DynamicListElement.builder().code(fieldSelector).build()).build();
}
}
@Nested
class FindOnlyHearingsTodayOrInPastNonVacated {
@BeforeEach
void setUp() {
Mockito.when(time.now()).thenReturn(NOW);
}
@Test
void whenNoHearingDetails() {
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(null).cancelledHearingDetails(null).build());
assertThat(actual).isEqualTo(List.of());
}
@Test
void whenEmptyHearingDetails() {
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of()).cancelledHearingDetails(List.of()).build());
assertThat(actual).isEqualTo(List.of());
}
@Test
void returnInThePast() {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void returnInThePastCancelled() {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.cancelledHearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void returnNow() {
Element<HearingBooking> hearing = hearing(NOW);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@ParameterizedTest
@EnumSource(value = HearingStatus.class,
names = {"VACATED", "VACATED_AND_RE_LISTED", "VACATED_TO_BE_RE_LISTED"})
void doNotReturnIfStatus(HearingStatus hearingStatus) {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1), hearingStatus);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of());
}
@ParameterizedTest
@NullSource
@EnumSource(value = HearingStatus.class,
names = {"ADJOURNED", "ADJOURNED_TO_BE_RE_LISTED", "ADJOURNED_AND_RE_LISTED"})
void returnIfStatus(HearingStatus hearingStatus) {
Element<HearingBooking> hearing = hearing(NOW.minusSeconds(1), hearingStatus);
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void doReturnInFutureIfJustBeforeTodayMidnight() {
Element<HearingBooking> hearing = hearing(NOW.toLocalDate().plusDays(1).atStartOfDay().minusSeconds(1));
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of(hearing));
}
@Test
void doNotReturnInFutureIfAfterTodayMidnight() {
Element<HearingBooking> hearing = hearing(NOW.toLocalDate().plusDays(1).atStartOfDay());
List<Element<HearingBooking>> actual = underTest.findOnlyHearingsTodayOrInPastNonVacated(CaseData.builder()
.hearingDetails(List.of(
hearing
)).build());
assertThat(actual).isEqualTo(List.of());
}
private Element<HearingBooking> hearing(LocalDateTime localDateTime) {
return element(FIELD_SELECTOR, HearingBooking.builder().endDate(localDateTime).build());
}
private Element<HearingBooking> hearing(LocalDateTime localDateTime, HearingStatus status) {
return element(FIELD_SELECTOR, HearingBooking.builder().endDate(localDateTime).status(status).build());
}
}
}
| 8,125 | 0.626831 | 0.624615 | 223 | 35.434978 | 33.850422 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.408072 | false | false | 9 |
3693f5471bc934b766ec272466bfbe4c5f6c22b2 | 8,650,064,144,519 | 5409d9c3ea6b06d8c366dbbb0401b01292c761f5 | /egame.proxy.server.open.biz/src/cn/egame/proxy/server/open/biz/factory/AutoPurgeUrlThread.java | ef29bb69f8d19c5ee506247e913e15e0f7f9013c | []
| no_license | wendellup/varnish_egame | https://github.com/wendellup/varnish_egame | cacf7d9d26bd3cb7d3dc81755379c01fed27d8c3 | f90c2d6beddd3e287a414effe362e86d060e6b76 | refs/heads/master | 2018-12-28T15:36:28.592000 | 2015-05-11T10:35:05 | 2015-05-11T10:35:05 | 31,747,331 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.egame.proxy.server.open.biz.factory;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.ObjectMapper;
import cn.egame.common.util.Utils;
import cn.egame.proxy.server.open.biz.utils.ConstVar;
import cn.egame.proxy.server.open.biz.utils.HttpPurge;
import cn.egame.proxy.server.open.biz.utils.LocalUtils;
import cn.egame.proxy.server.open.biz.utils.Urls;
public class AutoPurgeUrlThread extends Thread{
private static final Logger LOG = Logger.getLogger(AutoPurgeUrlThread.class);
private static Logger varnishPurgeFetchLog = Logger.getLogger("varnishPurgeFetch");
//需要缓存的页面
private List<String> purgeUrlList = new ArrayList<String>();
//需要缓存的页面(拼接好host和参数)
private List<String> contactPurgeUrlList = new ArrayList<String>();
//varnish服务器地址
private List<String> proxyUrlList = new ArrayList<String>();
public AutoPurgeUrlThread(){
init();
}
public void init(){
Utils.initLog4j();
String proxyUrls = ConstVar.PROXY_URL_LIST;
if(proxyUrls==null){
throw new RuntimeException("proxyUrls is null");
}
String[] proxyUrlAry = proxyUrls.split(",");
for(String proxyUrl : proxyUrlAry){
if(null!=proxyUrl ){
proxyUrl = proxyUrl.trim();
if(!"".equals(proxyUrl)){
proxyUrlList.add(proxyUrl);
}
}
}
BufferedReader br = null;
try {
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(Utils.getConfigFile("purge_url.txt")), "utf-8"));
String line = null;
while((line = br.readLine())!=null){
line = line.trim();
if(line.equals("") || line.startsWith("#")){
continue;
}
purgeUrlList.add(line);
}
} catch (Exception e) {
LOG.error("", e);
} finally{
try {
if(br!=null){
br.close();
}
} catch (IOException e) {
LOG.error("", e);
}
}
}
@Override
public void run() {
varnishPurgeFetchLog.info("AutoPurgeUrlTimerTask begin exe log--->"+Utils.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss"));
long beginMillis = System.currentTimeMillis();
//1.先去爬取实际url返回的数据是否正确
boolean isPurge = firstTestAndContactUrl();
//2.实际url访问正常才进行purge和访问操作
if (isPurge) {
handlerUrls();
}
long endMillis = System.currentTimeMillis();
varnishPurgeFetchLog.info("AutoPurgeUrlTimerTask cost--->"+(endMillis - beginMillis));
}
private void handlerUrls() {
int rows_of_page = 20;
for (String url : contactPurgeUrlList) {
for (String proxyUrlHost : proxyUrlList) {
url = LocalUtils.replaceHost(url, proxyUrlHost);
if (url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)) {
// 版本广告接口
purgeFetchUrlAndSubUrl(url);
} else if (url.contains(Urls.MY_COIN_TASK_URL_BASE)) {
// 金币任务接口
purgeFetchUrlAndSubUrl(url);
} else {
// 频道列表, 搜索列表(小编推荐列表和老专题列表没做分页)
if(url.contains("channel_id=704")
|| url.contains("channel_id=712")){
purgeFetchUrlAndSubUrl(url);
}else{
for (int i = 0; i < ConstVar.PURGE_PAGE_NUM; i++) {
if (url.contains("channel_id=714")) {
//精选列表
rows_of_page = 15;
}else if (url.contains("channel_id=723")
|| url.contains("channel_id=1000")) {
//卡牌节点或者老版分类接口
rows_of_page = 10;
}else {
rows_of_page = 20;
}
String pageParam = "¤t_page=" + i + "&rows_of_page=" + rows_of_page;
url = url.replaceAll("¤t_page=\\d*&rows_of_page=\\d*", pageParam);
purgeFetchUrlAndSubUrl(url);
}
}
}
}
}
}
private boolean firstTestAndContactUrl(){
boolean isPurge = true;
for(String url : purgeUrlList){
String proxyRealUrl = "";
if(url.endsWith("?")){
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"terminal_id=1¤t_page=0&rows_of_page=20";
}else{
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"&terminal_id=1¤t_page=0&rows_of_page=20";
}
if(url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)){
//版本广告接口
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"&terminal_id=1&vc=749";
}else if(url.contains(Urls.MY_COIN_TASK_URL_BASE)){
//金币任务接口
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"terminal_id=1¤t_page=0&rows_of_page=100";
}
contactPurgeUrlList.add(proxyRealUrl);
varnishPurgeFetchLog.info("first validate url: "+proxyRealUrl);
try {
String jsonVal = httpGet(proxyRealUrl);
if(jsonVal!=null){
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(jsonVal);
if (jn.get("code") != null) {
int code = jn.get("code").getIntValue();
if(code!=0){
isPurge = false;
break;
}
}
}else{
varnishPurgeFetchLog.error(proxyRealUrl+"返回的结果为null");
isPurge = false;
break;
}
} catch (Exception e) {
varnishPurgeFetchLog.error("访问url:"+url+"报错", e);
isPurge = false;
break;
}
}
return isPurge;
}
/**
* purge当前的url和该url返回的子url,如推荐页和推荐下的游戏详情页
* @param url
*/
public void purgeFetchUrlAndSubUrl(String url){
// String testUrl = LocalUtils.replaceHost(url, ConstVar.PROXY_REAL_URL);
// String testJson = httpGet(testUrl);
// if(testJson==null || !testJson.contains("\"code\":0")){
// varnishPurgeFetchLog.error("test url error:"+testUrl+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("test url ok:"+testUrl);
//
// String returnStr = httpPurge(url);
// if(returnStr==null || !returnStr.contains("\"code\":0")){
// varnishPurgeFetchLog.error("purge url error:"+url+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("purge url ok:"+url);
//
// String returnStrNew = httpGet(url);
// if(returnStrNew==null || !returnStrNew.contains("\"code\":0")){
// varnishPurgeFetchLog.error("get url error:"+url+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("get url ok:"+url);
String returnStrNew = threeStepHandlerUrl(url, "url");
if(returnStrNew!=null){
//处理子频道
if(url.contains(Urls.CONTENT_URL_BASE)){
//如果是频道页
purgeFetchContentSubUrl(returnStrNew, url);
}else if(url.contains(Urls.SEARCH_URL_BASE)){
//如果是搜索频道
purgeFetchSearchSubUrl(returnStrNew, url);
}else if(url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)){
//版本广告接口不同广告类型对应的页面需要分别抓取
purgeFetchAdvSubUrl(returnStrNew, url);
}
}
}
private void purgeFetchAdvSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null){
Iterator<JsonNode> it = jn.get("ext").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
Iterator<JsonNode> detailListIt = jn2.get("detail_list").iterator();
while (detailListIt.hasNext()) {
JsonNode jn3 = detailListIt.next();
String linkUrl = jn3.get("link_url").getTextValue();
if(linkUrl.contains((Urls.GIFT_URL_BASE))){
linkUrl = linkUrl.replaceAll("current_page=\\d*&rows_of_page=\\d*&", "");
linkUrl = linkUrl.replaceAll("¤t_page=\\d*&rows_of_page=\\d*", "");
}
threeStepHandlerUrl(linkUrl, "广告详情");
}
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
private void purgeFetchSearchSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null
&& jn.get("ext").get("main") != null
&& jn.get("ext").get("main").get("content")!=null){
Iterator<JsonNode> it = jn.get("ext").get("main").get("content").get("game_list").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
String gameDetailUrl = jn2.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
/**
* @Description: purge和fetch子url
* @Create Date 2015年3月7日
* @Modified by none
* @Modified Date
*/
private void purgeFetchContentSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null
&& jn.get("ext").get("channel_page_type") != null
&& jn.get("ext").get("main") != null
&& jn.get("ext").get("main").get("content")!=null){
int channel_page_type = jn.get("ext").get("channel_page_type").getIntValue();
if(channel_page_type==14){
//解析精选列表页
handlerChoiceseSubChannel(jn);
}else if(channel_page_type==13){
//解析小编推荐列表页
handlerEditorChoiceSubChannel(jn);
}else if(channel_page_type==4){
//解析专题列表页
handlerTopicSubChannel(jn);
}else if(channel_page_type==20){
//解析卡牌列表页
handlerCardSubChannel(jn);
}else if(channel_page_type==5){
//解析分类列表页
handlerClassificationSubChannel(jn);
}else{
if (jn.get("ext").get("main").get("content").get("game_list") != null) {
Iterator<JsonNode> it = jn.get("ext").get("main").get("content").get("game_list").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
String gameDetailUrl = jn2.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
private void handlerClassificationSubChannel(JsonNode jn) {
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn1 = subChannelIt.next();
if (jn1!=null) {
String subChannelUrl = jn1.get("sub_channel_url").getTextValue();
if(subChannelUrl!=null){
subChannelUrl = subChannelUrl.replaceAll("rows_of_page=\\d*", "rows_of_page=20");
}
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "分类详情页");
}
}
}
}
private void handlerCardSubChannel(JsonNode jn) {
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn1 = subChannelIt.next();
if (jn1.get("game_list") != null) {
Iterator<JsonNode> gameListIt = jn1.get("game_list").iterator();
while (gameListIt.hasNext()) {
JsonNode jn2 = gameListIt.next();
JsonNode jnGameDetail = jn2.get("game_detail");
JsonNode jnImageDetail = jn2.get("image_detail");
int url_type = Utils.toInt(jn2.get("url_type").getTextValue(), 0);
if(url_type==9 && jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
//卡牌列表对应的5个游戏详情
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
if(url_type==10 && jnImageDetail!=null && jnImageDetail.get("link_url")!=null){
//跳转的游戏列表
String subChannelUrl = jnImageDetail.get("link_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "卡牌列表二层列表页");
}
}
}
}
}
}
private void handlerEditorChoiceSubChannel(JsonNode jn) throws JsonProcessingException, IOException {
// 小编推荐列表页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
//小编推荐列表页未分页, 强制设置拉取停止的页数
int cnt = 0;
while (subChannelIt.hasNext()) {
cnt++;
if(cnt>=ConstVar.PURGE_PAGE_NUM*20){
return;
}
JsonNode jn3 = subChannelIt.next();
if (jn3.get("sub_channel_url") != null) {
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "小编推荐详情页");
if(subChannelJson!=null){
// 小编推荐游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null
&& jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list")!=null){
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
JsonNode jnGameDetail = jn5.get("game_detail");
if(jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
private void handlerTopicSubChannel(JsonNode jn) throws IOException, JsonProcessingException {
// 专题列表页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
int cnt=0;
while (subChannelIt.hasNext()) {
cnt++;
if(cnt>=ConstVar.PURGE_PAGE_NUM*20){
return;
}
JsonNode jn3 = subChannelIt.next();
if (jn3.get("sub_channel_url") != null) {
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "专题详情页");
if (subChannelJson != null) {
// 专题详情页游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null && jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list") != null) {
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
if (jn5 != null && jn5.get("game_detail_url") != null) {
String gameDetailUrl = jn5.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
private void handlerChoiceseSubChannel(JsonNode jn) throws IOException, JsonProcessingException {
//精选详情页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn2 = subChannelIt.next();
if(jn2.get("channel_content_list")!=null){
Iterator<JsonNode> channelContentListIt = jn2.get("channel_content_list").iterator();
while (channelContentListIt.hasNext()) {
JsonNode jn3 = channelContentListIt.next();
if(jn3.get("sub_channel_url")!=null){
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "精选详情页");
if(subChannelJson!=null){
//精选列表详情页游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null
&& jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list")!=null){
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
JsonNode jnGameDetail = jn5.get("game_detail");
if(jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
}
}
private String threeStepHandlerUrl(String url, String logUrl) {
String retStr = null;
String testUrl = LocalUtils.replaceHost(url, ConstVar.PROXY_REAL_URL);
String testJson = httpGet(testUrl);
if (testJson == null
|| !testJson.contains("\"code\":0")) {
varnishPurgeFetchLog.error("test "+logUrl+" error:" + testUrl + "返回的结果不正确");
return null;
}
varnishPurgeFetchLog.info("test "+logUrl+" ok:" + testUrl);
for (String proxyUrl : proxyUrlList) {
url = LocalUtils.replaceHost(url, proxyUrl);
String purgeReturnStr = httpPurge(url);
if (purgeReturnStr == null
|| !purgeReturnStr.contains("\"code\":0")) {
varnishPurgeFetchLog.error("purge "+logUrl+" error:" + url + "返回的结果不正确");
break;
}
varnishPurgeFetchLog.info("purge "+logUrl+" ok:" + url);
String getReturnStr = httpGet(url);
if (getReturnStr == null
|| !getReturnStr.contains("\"code\":0")) {
varnishPurgeFetchLog.error("get "+logUrl+" error:" + url + "返回的结果不正确");
break;
}
varnishPurgeFetchLog.info("get "+logUrl+" ok:" + url);
retStr = getReturnStr;
}
return retStr;
}
public String httpPurge(String url) {
CloseableHttpClient httpclient = null;
HttpPurge httpPurge = null;
String returnStr = null;
try {
httpclient = HttpClients.createDefault();
httpPurge = new HttpPurge(url);
HttpResponse response = httpclient.execute(httpPurge);
HttpEntity entity = response.getEntity();
if (entity != null && entity.getContentType()!=null){
if(entity.getContentType().toString().trim().contains("application/json")){
returnStr = EntityUtils.toString(entity);;
EntityUtils.consume(entity);
return returnStr;
}else{
varnishPurgeFetchLog.info("httpPurge"+url+"content_type------>"+entity.getContentType().toString().trim());
LOG.error(url+"返回的ContentType不是json,为"+entity.getContentType().toString());
}
}
} catch (Exception ex) {
LOG.error("", ex);
} finally{
if(httpPurge!=null){
httpPurge.releaseConnection();
}
if(httpclient!=null){
try {
httpclient.close();
} catch (IOException e) {
LOG.error("", e);
}
}
}
return returnStr;
}
public String httpGet(String url) {
CloseableHttpClient httpclient = null;
HttpGet httpGet = null;
String returnStr = null;
try {
httpclient = HttpClients.createDefault();
httpGet = new HttpGet(url);
HttpResponse response = httpclient.execute(httpGet);
// System.out.println("-------------------------------------");
// System.out.println(response.getStatusLine());
// System.out.println("-------------------------------------");
HttpEntity entity = response.getEntity();
if (entity != null
&& entity.getContentType() != null
&& entity.getContentType().toString().trim()
.contains("application/json")) {
returnStr = EntityUtils.toString(entity);
;
EntityUtils.consume(entity);
} else {
varnishPurgeFetchLog.info("httpGet" + url + "content_type------>"
+ entity.getContentType().toString().trim());
LOG.error("httpGet" + url + "返回的ContentType不是json,为"
+ entity.getContentType().toString());
}
} catch (Exception ex) {
LOG.error("", ex);
} finally{
if(httpGet!=null){
httpGet.releaseConnection();
}
if(httpclient!=null){
try {
httpclient.close();
} catch (IOException e) {
LOG.error("", e);
}
}
}
return returnStr;
}
// public static void main(String[] args) {
// String url = "http://192.168.70.156/api/v2/mobile/channel/content.json?channel_id=702&terminal_id=1¤t_page=4&rows_of_page=20";
// new AutoPurgeUrlTimerTask().httpPurge(url);
// new AutoPurgeUrlTimerTask().httpGet(url);
// Utils.initLog4j();
// varnishPurgeFetchLog.info("varnishPurgeFetchLog");
// ObjectMapper jsonMapper = new ObjectMapper();
// try {
// JsonNode jn = jsonMapper.readTree("{}");
// } catch (JsonProcessingException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
}
| UTF-8 | Java | 24,252 | java | AutoPurgeUrlThread.java | Java | [
{
"context": "d main(String[] args) {\n//\t\tString url = \"http://192.168.70.156/api/v2/mobile/channel/content.json?channel_id=702",
"end": 22786,
"score": 0.7929772734642029,
"start": 22773,
"tag": "IP_ADDRESS",
"value": "92.168.70.156"
}
]
| null | []
| package cn.egame.proxy.server.open.biz.factory;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.ObjectMapper;
import cn.egame.common.util.Utils;
import cn.egame.proxy.server.open.biz.utils.ConstVar;
import cn.egame.proxy.server.open.biz.utils.HttpPurge;
import cn.egame.proxy.server.open.biz.utils.LocalUtils;
import cn.egame.proxy.server.open.biz.utils.Urls;
public class AutoPurgeUrlThread extends Thread{
private static final Logger LOG = Logger.getLogger(AutoPurgeUrlThread.class);
private static Logger varnishPurgeFetchLog = Logger.getLogger("varnishPurgeFetch");
//需要缓存的页面
private List<String> purgeUrlList = new ArrayList<String>();
//需要缓存的页面(拼接好host和参数)
private List<String> contactPurgeUrlList = new ArrayList<String>();
//varnish服务器地址
private List<String> proxyUrlList = new ArrayList<String>();
public AutoPurgeUrlThread(){
init();
}
public void init(){
Utils.initLog4j();
String proxyUrls = ConstVar.PROXY_URL_LIST;
if(proxyUrls==null){
throw new RuntimeException("proxyUrls is null");
}
String[] proxyUrlAry = proxyUrls.split(",");
for(String proxyUrl : proxyUrlAry){
if(null!=proxyUrl ){
proxyUrl = proxyUrl.trim();
if(!"".equals(proxyUrl)){
proxyUrlList.add(proxyUrl);
}
}
}
BufferedReader br = null;
try {
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(Utils.getConfigFile("purge_url.txt")), "utf-8"));
String line = null;
while((line = br.readLine())!=null){
line = line.trim();
if(line.equals("") || line.startsWith("#")){
continue;
}
purgeUrlList.add(line);
}
} catch (Exception e) {
LOG.error("", e);
} finally{
try {
if(br!=null){
br.close();
}
} catch (IOException e) {
LOG.error("", e);
}
}
}
@Override
public void run() {
varnishPurgeFetchLog.info("AutoPurgeUrlTimerTask begin exe log--->"+Utils.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss"));
long beginMillis = System.currentTimeMillis();
//1.先去爬取实际url返回的数据是否正确
boolean isPurge = firstTestAndContactUrl();
//2.实际url访问正常才进行purge和访问操作
if (isPurge) {
handlerUrls();
}
long endMillis = System.currentTimeMillis();
varnishPurgeFetchLog.info("AutoPurgeUrlTimerTask cost--->"+(endMillis - beginMillis));
}
private void handlerUrls() {
int rows_of_page = 20;
for (String url : contactPurgeUrlList) {
for (String proxyUrlHost : proxyUrlList) {
url = LocalUtils.replaceHost(url, proxyUrlHost);
if (url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)) {
// 版本广告接口
purgeFetchUrlAndSubUrl(url);
} else if (url.contains(Urls.MY_COIN_TASK_URL_BASE)) {
// 金币任务接口
purgeFetchUrlAndSubUrl(url);
} else {
// 频道列表, 搜索列表(小编推荐列表和老专题列表没做分页)
if(url.contains("channel_id=704")
|| url.contains("channel_id=712")){
purgeFetchUrlAndSubUrl(url);
}else{
for (int i = 0; i < ConstVar.PURGE_PAGE_NUM; i++) {
if (url.contains("channel_id=714")) {
//精选列表
rows_of_page = 15;
}else if (url.contains("channel_id=723")
|| url.contains("channel_id=1000")) {
//卡牌节点或者老版分类接口
rows_of_page = 10;
}else {
rows_of_page = 20;
}
String pageParam = "¤t_page=" + i + "&rows_of_page=" + rows_of_page;
url = url.replaceAll("¤t_page=\\d*&rows_of_page=\\d*", pageParam);
purgeFetchUrlAndSubUrl(url);
}
}
}
}
}
}
private boolean firstTestAndContactUrl(){
boolean isPurge = true;
for(String url : purgeUrlList){
String proxyRealUrl = "";
if(url.endsWith("?")){
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"terminal_id=1¤t_page=0&rows_of_page=20";
}else{
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"&terminal_id=1¤t_page=0&rows_of_page=20";
}
if(url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)){
//版本广告接口
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"&terminal_id=1&vc=749";
}else if(url.contains(Urls.MY_COIN_TASK_URL_BASE)){
//金币任务接口
proxyRealUrl = ConstVar.PROXY_REAL_URL+url+"terminal_id=1¤t_page=0&rows_of_page=100";
}
contactPurgeUrlList.add(proxyRealUrl);
varnishPurgeFetchLog.info("first validate url: "+proxyRealUrl);
try {
String jsonVal = httpGet(proxyRealUrl);
if(jsonVal!=null){
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(jsonVal);
if (jn.get("code") != null) {
int code = jn.get("code").getIntValue();
if(code!=0){
isPurge = false;
break;
}
}
}else{
varnishPurgeFetchLog.error(proxyRealUrl+"返回的结果为null");
isPurge = false;
break;
}
} catch (Exception e) {
varnishPurgeFetchLog.error("访问url:"+url+"报错", e);
isPurge = false;
break;
}
}
return isPurge;
}
/**
* purge当前的url和该url返回的子url,如推荐页和推荐下的游戏详情页
* @param url
*/
public void purgeFetchUrlAndSubUrl(String url){
// String testUrl = LocalUtils.replaceHost(url, ConstVar.PROXY_REAL_URL);
// String testJson = httpGet(testUrl);
// if(testJson==null || !testJson.contains("\"code\":0")){
// varnishPurgeFetchLog.error("test url error:"+testUrl+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("test url ok:"+testUrl);
//
// String returnStr = httpPurge(url);
// if(returnStr==null || !returnStr.contains("\"code\":0")){
// varnishPurgeFetchLog.error("purge url error:"+url+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("purge url ok:"+url);
//
// String returnStrNew = httpGet(url);
// if(returnStrNew==null || !returnStrNew.contains("\"code\":0")){
// varnishPurgeFetchLog.error("get url error:"+url+"返回的结果不正确");
// return;
// }
// varnishPurgeFetchLog.info("get url ok:"+url);
String returnStrNew = threeStepHandlerUrl(url, "url");
if(returnStrNew!=null){
//处理子频道
if(url.contains(Urls.CONTENT_URL_BASE)){
//如果是频道页
purgeFetchContentSubUrl(returnStrNew, url);
}else if(url.contains(Urls.SEARCH_URL_BASE)){
//如果是搜索频道
purgeFetchSearchSubUrl(returnStrNew, url);
}else if(url.contains(Urls.SHOW_VERSION_ADVS_URL_BASE)){
//版本广告接口不同广告类型对应的页面需要分别抓取
purgeFetchAdvSubUrl(returnStrNew, url);
}
}
}
private void purgeFetchAdvSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null){
Iterator<JsonNode> it = jn.get("ext").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
Iterator<JsonNode> detailListIt = jn2.get("detail_list").iterator();
while (detailListIt.hasNext()) {
JsonNode jn3 = detailListIt.next();
String linkUrl = jn3.get("link_url").getTextValue();
if(linkUrl.contains((Urls.GIFT_URL_BASE))){
linkUrl = linkUrl.replaceAll("current_page=\\d*&rows_of_page=\\d*&", "");
linkUrl = linkUrl.replaceAll("¤t_page=\\d*&rows_of_page=\\d*", "");
}
threeStepHandlerUrl(linkUrl, "广告详情");
}
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
private void purgeFetchSearchSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null
&& jn.get("ext").get("main") != null
&& jn.get("ext").get("main").get("content")!=null){
Iterator<JsonNode> it = jn.get("ext").get("main").get("content").get("game_list").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
String gameDetailUrl = jn2.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
/**
* @Description: purge和fetch子url
* @Create Date 2015年3月7日
* @Modified by none
* @Modified Date
*/
private void purgeFetchContentSubUrl(String returnStrNew, String url) {
try {
ObjectMapper jsonMapper = new ObjectMapper();
JsonNode jn = jsonMapper.readTree(returnStrNew);
if (jn.get("ext") != null
&& jn.get("ext").get("channel_page_type") != null
&& jn.get("ext").get("main") != null
&& jn.get("ext").get("main").get("content")!=null){
int channel_page_type = jn.get("ext").get("channel_page_type").getIntValue();
if(channel_page_type==14){
//解析精选列表页
handlerChoiceseSubChannel(jn);
}else if(channel_page_type==13){
//解析小编推荐列表页
handlerEditorChoiceSubChannel(jn);
}else if(channel_page_type==4){
//解析专题列表页
handlerTopicSubChannel(jn);
}else if(channel_page_type==20){
//解析卡牌列表页
handlerCardSubChannel(jn);
}else if(channel_page_type==5){
//解析分类列表页
handlerClassificationSubChannel(jn);
}else{
if (jn.get("ext").get("main").get("content").get("game_list") != null) {
Iterator<JsonNode> it = jn.get("ext").get("main").get("content").get("game_list").iterator();
while (it.hasNext()) {
JsonNode jn2 = it.next();
String gameDetailUrl = jn2.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
} catch (Exception e) {
LOG.error("", e);
}
}
private void handlerClassificationSubChannel(JsonNode jn) {
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn1 = subChannelIt.next();
if (jn1!=null) {
String subChannelUrl = jn1.get("sub_channel_url").getTextValue();
if(subChannelUrl!=null){
subChannelUrl = subChannelUrl.replaceAll("rows_of_page=\\d*", "rows_of_page=20");
}
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "分类详情页");
}
}
}
}
private void handlerCardSubChannel(JsonNode jn) {
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn1 = subChannelIt.next();
if (jn1.get("game_list") != null) {
Iterator<JsonNode> gameListIt = jn1.get("game_list").iterator();
while (gameListIt.hasNext()) {
JsonNode jn2 = gameListIt.next();
JsonNode jnGameDetail = jn2.get("game_detail");
JsonNode jnImageDetail = jn2.get("image_detail");
int url_type = Utils.toInt(jn2.get("url_type").getTextValue(), 0);
if(url_type==9 && jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
//卡牌列表对应的5个游戏详情
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
if(url_type==10 && jnImageDetail!=null && jnImageDetail.get("link_url")!=null){
//跳转的游戏列表
String subChannelUrl = jnImageDetail.get("link_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "卡牌列表二层列表页");
}
}
}
}
}
}
private void handlerEditorChoiceSubChannel(JsonNode jn) throws JsonProcessingException, IOException {
// 小编推荐列表页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
//小编推荐列表页未分页, 强制设置拉取停止的页数
int cnt = 0;
while (subChannelIt.hasNext()) {
cnt++;
if(cnt>=ConstVar.PURGE_PAGE_NUM*20){
return;
}
JsonNode jn3 = subChannelIt.next();
if (jn3.get("sub_channel_url") != null) {
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "小编推荐详情页");
if(subChannelJson!=null){
// 小编推荐游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null
&& jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list")!=null){
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
JsonNode jnGameDetail = jn5.get("game_detail");
if(jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
private void handlerTopicSubChannel(JsonNode jn) throws IOException, JsonProcessingException {
// 专题列表页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
int cnt=0;
while (subChannelIt.hasNext()) {
cnt++;
if(cnt>=ConstVar.PURGE_PAGE_NUM*20){
return;
}
JsonNode jn3 = subChannelIt.next();
if (jn3.get("sub_channel_url") != null) {
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "专题详情页");
if (subChannelJson != null) {
// 专题详情页游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null && jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list") != null) {
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
if (jn5 != null && jn5.get("game_detail_url") != null) {
String gameDetailUrl = jn5.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
private void handlerChoiceseSubChannel(JsonNode jn) throws IOException, JsonProcessingException {
//精选详情页(第二层)
if (jn.get("ext").get("main").get("content").get("sub_channel") != null) {
Iterator<JsonNode> subChannelIt = jn.get("ext").get("main").get("content").get("sub_channel").iterator();
while (subChannelIt.hasNext()) {
JsonNode jn2 = subChannelIt.next();
if(jn2.get("channel_content_list")!=null){
Iterator<JsonNode> channelContentListIt = jn2.get("channel_content_list").iterator();
while (channelContentListIt.hasNext()) {
JsonNode jn3 = channelContentListIt.next();
if(jn3.get("sub_channel_url")!=null){
String subChannelUrl = jn3.get("sub_channel_url").getTextValue();
String subChannelJson = threeStepHandlerUrl(subChannelUrl, "精选详情页");
if(subChannelJson!=null){
//精选列表详情页游戏详情页(第三层)
ObjectMapper jsonMapper2 = new ObjectMapper();
JsonNode jn4 = jsonMapper2.readTree(subChannelJson);
if (jn4.get("ext") != null
&& jn4.get("ext").get("main") != null
&& jn4.get("ext").get("main").get("content") != null
&& jn4.get("ext").get("main").get("content").get("game_list")!=null){
Iterator<JsonNode> gameDetailIt = jn4.get("ext").get("main").get("content").get("game_list").iterator();
while (gameDetailIt.hasNext()) {
JsonNode jn5 = gameDetailIt.next();
JsonNode jnGameDetail = jn5.get("game_detail");
if(jnGameDetail!=null && jnGameDetail.get("game_detail_url")!=null){
String gameDetailUrl = jnGameDetail.get("game_detail_url").getTextValue();
threeStepHandlerUrl(gameDetailUrl, "gameDetail");
}
}
}
}
}
}
}
}
}
}
private String threeStepHandlerUrl(String url, String logUrl) {
String retStr = null;
String testUrl = LocalUtils.replaceHost(url, ConstVar.PROXY_REAL_URL);
String testJson = httpGet(testUrl);
if (testJson == null
|| !testJson.contains("\"code\":0")) {
varnishPurgeFetchLog.error("test "+logUrl+" error:" + testUrl + "返回的结果不正确");
return null;
}
varnishPurgeFetchLog.info("test "+logUrl+" ok:" + testUrl);
for (String proxyUrl : proxyUrlList) {
url = LocalUtils.replaceHost(url, proxyUrl);
String purgeReturnStr = httpPurge(url);
if (purgeReturnStr == null
|| !purgeReturnStr.contains("\"code\":0")) {
varnishPurgeFetchLog.error("purge "+logUrl+" error:" + url + "返回的结果不正确");
break;
}
varnishPurgeFetchLog.info("purge "+logUrl+" ok:" + url);
String getReturnStr = httpGet(url);
if (getReturnStr == null
|| !getReturnStr.contains("\"code\":0")) {
varnishPurgeFetchLog.error("get "+logUrl+" error:" + url + "返回的结果不正确");
break;
}
varnishPurgeFetchLog.info("get "+logUrl+" ok:" + url);
retStr = getReturnStr;
}
return retStr;
}
public String httpPurge(String url) {
CloseableHttpClient httpclient = null;
HttpPurge httpPurge = null;
String returnStr = null;
try {
httpclient = HttpClients.createDefault();
httpPurge = new HttpPurge(url);
HttpResponse response = httpclient.execute(httpPurge);
HttpEntity entity = response.getEntity();
if (entity != null && entity.getContentType()!=null){
if(entity.getContentType().toString().trim().contains("application/json")){
returnStr = EntityUtils.toString(entity);;
EntityUtils.consume(entity);
return returnStr;
}else{
varnishPurgeFetchLog.info("httpPurge"+url+"content_type------>"+entity.getContentType().toString().trim());
LOG.error(url+"返回的ContentType不是json,为"+entity.getContentType().toString());
}
}
} catch (Exception ex) {
LOG.error("", ex);
} finally{
if(httpPurge!=null){
httpPurge.releaseConnection();
}
if(httpclient!=null){
try {
httpclient.close();
} catch (IOException e) {
LOG.error("", e);
}
}
}
return returnStr;
}
public String httpGet(String url) {
CloseableHttpClient httpclient = null;
HttpGet httpGet = null;
String returnStr = null;
try {
httpclient = HttpClients.createDefault();
httpGet = new HttpGet(url);
HttpResponse response = httpclient.execute(httpGet);
// System.out.println("-------------------------------------");
// System.out.println(response.getStatusLine());
// System.out.println("-------------------------------------");
HttpEntity entity = response.getEntity();
if (entity != null
&& entity.getContentType() != null
&& entity.getContentType().toString().trim()
.contains("application/json")) {
returnStr = EntityUtils.toString(entity);
;
EntityUtils.consume(entity);
} else {
varnishPurgeFetchLog.info("httpGet" + url + "content_type------>"
+ entity.getContentType().toString().trim());
LOG.error("httpGet" + url + "返回的ContentType不是json,为"
+ entity.getContentType().toString());
}
} catch (Exception ex) {
LOG.error("", ex);
} finally{
if(httpGet!=null){
httpGet.releaseConnection();
}
if(httpclient!=null){
try {
httpclient.close();
} catch (IOException e) {
LOG.error("", e);
}
}
}
return returnStr;
}
// public static void main(String[] args) {
// String url = "http://1192.168.3.11/api/v2/mobile/channel/content.json?channel_id=702&terminal_id=1¤t_page=4&rows_of_page=20";
// new AutoPurgeUrlTimerTask().httpPurge(url);
// new AutoPurgeUrlTimerTask().httpGet(url);
// Utils.initLog4j();
// varnishPurgeFetchLog.info("varnishPurgeFetchLog");
// ObjectMapper jsonMapper = new ObjectMapper();
// try {
// JsonNode jn = jsonMapper.readTree("{}");
// } catch (JsonProcessingException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
}
| 24,251 | 0.566889 | 0.559918 | 610 | 37.331146 | 28.954433 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.586885 | false | false | 9 |
16950aec7296af9ce8d36d00da105757c9f6927a | 25,159,918,429,666 | c8382a5e077c53617287d94eac196e2e6c99a860 | /DClick2.java | f6278b6b43c4a5cf443141a9080f8ad8dd960e18 | []
| no_license | aonatechnologies/SQL-Query-System | https://github.com/aonatechnologies/SQL-Query-System | c160d7e961141488dfac5edfe1b903ef5546822c | 546c826e650a2377a42cb7cb23f7d1d9629ccee4 | refs/heads/master | 2016-09-13T01:20:54.886000 | 2016-05-31T04:10:39 | 2016-05-31T04:10:39 | 58,554,054 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package initialClasses;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class DClick2 implements MouseListener {
private TextField t1;
private TextField t3;
private TextField t2;
private TGMenu f;
public DClick2(TextField tf1,TextField tf2,TextField tf3,TGMenu menu){
t1=tf1;
t2=tf2;
t3=tf3;
f=menu;
}
@Override
public void mouseClicked(MouseEvent arg0) {
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
t1.setEditable(f.Mult);
t2.setEditable(f.Mult);
t3.setEditable(f.Mult);
f.Uin=true;
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
| UTF-8 | Java | 990 | java | DClick2.java | Java | []
| null | []
| package initialClasses;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class DClick2 implements MouseListener {
private TextField t1;
private TextField t3;
private TextField t2;
private TGMenu f;
public DClick2(TextField tf1,TextField tf2,TextField tf3,TGMenu menu){
t1=tf1;
t2=tf2;
t3=tf3;
f=menu;
}
@Override
public void mouseClicked(MouseEvent arg0) {
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
t1.setEditable(f.Mult);
t2.setEditable(f.Mult);
t3.setEditable(f.Mult);
f.Uin=true;
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
| 990 | 0.69596 | 0.673737 | 54 | 16.333334 | 17.021772 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.240741 | false | false | 9 |
5d8f1fee374f59f64952a9c171da35a41e721f66 | 5,523,327,953,930 | b364b74ad664521b2418f98ad68f05cc71edb48a | /src/FaceTrack/FaceTrackPanel.java | 7cdb689402dfdc9ff9882a7a9d436f6294d39b1c | []
| no_license | ncontreras2018/OpenCV-Stuff | https://github.com/ncontreras2018/OpenCV-Stuff | c1ad5a3e158b7caaf509eeb81947c47ef071c76f | d3ba3a78813be9096f023f3f6a1e75768529cadd | refs/heads/master | 2020-02-26T15:04:01.437000 | 2016-07-26T02:36:52 | 2016-07-26T02:36:52 | 41,917,357 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package FaceTrack;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.opencv.core.Mat;
@SuppressWarnings("serial")
public class FaceTrackPanel extends JPanel {
Mat webcamFeed;
public FaceTrackPanel(int width, int height, String frameName) {
JFrame frame = new JFrame(frameName);
frame.add(this);
this.setPreferredSize(new Dimension(width, height));
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
System.out.println("Panel Ready");
}
}
| UTF-8 | Java | 582 | java | FaceTrackPanel.java | Java | []
| null | []
| package FaceTrack;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.opencv.core.Mat;
@SuppressWarnings("serial")
public class FaceTrackPanel extends JPanel {
Mat webcamFeed;
public FaceTrackPanel(int width, int height, String frameName) {
JFrame frame = new JFrame(frameName);
frame.add(this);
this.setPreferredSize(new Dimension(width, height));
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
System.out.println("Panel Ready");
}
}
| 582 | 0.709622 | 0.709622 | 30 | 17.4 | 19.222557 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.166667 | false | false | 9 |
589806a2c4a900f0065cc2f97df99a5dd04df533 | 28,484,223,118,170 | 3103db488150208ad3fa8778fad06f372e8657b7 | /src/main/resources/archetype-resources/src/main/java/config/WebappMvcConfig.java | 8d834ecfda36223a714df09e240a03bc786dd756 | []
| no_license | Shaika-Dzari/SpringWebMvc-Archetype | https://github.com/Shaika-Dzari/SpringWebMvc-Archetype | fb44a8266e7d6d0dd7d4205fde36009a6a6dc290 | d8a7058a2a9e6827103b327976f27ad7628fb8a9 | refs/heads/master | 2020-06-02T08:27:52.827000 | 2014-10-01T01:23:57 | 2014-10-01T01:23:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | #set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
/**
* Copyright © 2014 Remi Guillemette <rguillemette@n4dev.ca>
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
package ${package}.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author rguillemette
* @since Sep 30, 2014
*/
@EnableWebMvc
@Configuration
public class WebappMvcConfig {
}
| UTF-8 | Java | 651 | java | WebappMvcConfig.java | Java | [
{
"context": "et( $symbol_escape = '\\' )\n/**\n * Copyright © 2014 Remi Guillemette <rguillemette@n4dev.ca>\n * This work is free. You",
"end": 126,
"score": 0.9998936653137207,
"start": 110,
"tag": "NAME",
"value": "Remi Guillemette"
},
{
"context": "= '\\' )\n/**\n * Copyright © 2014 Remi Guillemette <rguillemette@n4dev.ca>\n * This work is free. You can redistribute it an",
"end": 149,
"score": 0.9999339580535889,
"start": 128,
"tag": "EMAIL",
"value": "rguillemette@n4dev.ca"
},
{
"context": "et.config.annotation.EnableWebMvc;\n\n/**\n * @author rguillemette\n * @since Sep 30, 2014\n */\n@EnableWebMvc\n@Configu",
"end": 559,
"score": 0.999620258808136,
"start": 547,
"tag": "USERNAME",
"value": "rguillemette"
}
]
| null | []
| #set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
/**
* Copyright © 2014 <NAME> <<EMAIL>>
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
package ${package}.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
/**
* @author rguillemette
* @since Sep 30, 2014
*/
@EnableWebMvc
@Configuration
public class WebappMvcConfig {
}
| 627 | 0.726154 | 0.707692 | 23 | 27.26087 | 25.89312 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.26087 | false | false | 9 |
02df680100bc3ee356fd3467fb400f70b3a98db1 | 33,285,996,548,823 | b38be5c5ba28cc43adc530c86d62b033e4fa819d | /src/springChapter/homework3/spring-core-study/src/proxy/MyPayGateWay.java | 10d1da8b20d7e9623f19a05f263bcf8d55413fdb | []
| no_license | chenhaiyan90/myJavaClass | https://github.com/chenhaiyan90/myJavaClass | 802187e822c9a8329c1e44d6feaf93c48d9e0a15 | 9266181d1f41f7cb5cff66794ead55046814dcd2 | refs/heads/master | 2021-01-12T06:43:16.640000 | 2017-12-14T04:27:39 | 2017-12-14T04:27:45 | 77,421,490 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package proxy;
public interface MyPayGateWay {
public boolean pay(int userId,long orderId,double money);
}
| UTF-8 | Java | 115 | java | MyPayGateWay.java | Java | []
| null | []
| package proxy;
public interface MyPayGateWay {
public boolean pay(int userId,long orderId,double money);
}
| 115 | 0.747826 | 0.747826 | 8 | 13.375 | 19.671919 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.875 | false | false | 9 |
d1032c9c3c9718e524fd5ba90c3c2225e2f227f5 | 3,032,246,924,142 | 468901ca7035d3bfc93d5c868707756351c76f8e | /src/main/java/com/learning/ds/educative/dp/knapsack_1/P5_MinSubsetSumDifference.java | a4071856304d229e30f81106db47887ac9ade0e8 | []
| no_license | nickahujaaol/DataStructures | https://github.com/nickahujaaol/DataStructures | 63fd88325ba0dc8a75b96e87f2813c02ff87320c | d6b2bf6694bcc6f955d895789c5fca700b6133da | refs/heads/master | 2023-03-11T23:34:39.766000 | 2021-02-25T06:27:21 | 2021-02-25T06:27:21 | 266,102,280 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.learning.ds.educative.dp.knapsack_1;
public class P5_MinSubsetSumDifference {
public static void main(String[] args) {
int[] inSet = {1, 2, 3, 9};
int minDiff = findMinDifference(inSet, 0, 0, 0);
System.out.println("Min Diff: " + minDiff);
}
private static int findMinDifference(int[] inSet, int index, int sum1, int sum2) {
if(index == inSet.length) {
return Math.abs(sum1 - sum2);
}
int leftMinSum = findMinDifference(inSet, index + 1, sum1 + inSet[index], sum2);
int rightMinSum = findMinDifference(inSet, index + 1, sum1, sum2 + inSet[index]);
return Math.min(leftMinSum, rightMinSum);
}
}
| UTF-8 | Java | 701 | java | P5_MinSubsetSumDifference.java | Java | []
| null | []
| package com.learning.ds.educative.dp.knapsack_1;
public class P5_MinSubsetSumDifference {
public static void main(String[] args) {
int[] inSet = {1, 2, 3, 9};
int minDiff = findMinDifference(inSet, 0, 0, 0);
System.out.println("Min Diff: " + minDiff);
}
private static int findMinDifference(int[] inSet, int index, int sum1, int sum2) {
if(index == inSet.length) {
return Math.abs(sum1 - sum2);
}
int leftMinSum = findMinDifference(inSet, index + 1, sum1 + inSet[index], sum2);
int rightMinSum = findMinDifference(inSet, index + 1, sum1, sum2 + inSet[index]);
return Math.min(leftMinSum, rightMinSum);
}
}
| 701 | 0.623395 | 0.596291 | 19 | 35.894737 | 29.754955 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.263158 | false | false | 9 |
e15f7d7f62138346edbc0e4f95ce7b8c7c804dde | 6,657,199,342,079 | c219f315067a6a21030c4fec8a39f1f99173a981 | /PropertyHeatMap/Server/src/net/zettroke/PropertyHeatMapServer/utils/IndexedThread.java | 6461b32ef5b2a4ad348af10dd5d70590c168e792 | []
| no_license | Zettroke/PropertyHeatMap | https://github.com/Zettroke/PropertyHeatMap | f16bb0821ce0ec6c79424e3e8987865cd21818ef | abe128554e404696e04f3c37d0e1f3f74f527eb4 | refs/heads/master | 2021-09-28T20:49:41.114000 | 2018-11-20T13:09:01 | 2018-11-20T13:09:01 | 106,757,374 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.zettroke.PropertyHeatMapServer.utils;
public class IndexedThread extends Thread{
public int index;
IndexedThread(Runnable r){
super(r);
}
}
| UTF-8 | Java | 173 | java | IndexedThread.java | Java | []
| null | []
| package net.zettroke.PropertyHeatMapServer.utils;
public class IndexedThread extends Thread{
public int index;
IndexedThread(Runnable r){
super(r);
}
}
| 173 | 0.710983 | 0.710983 | 8 | 20.625 | 17.38489 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 9 |
8f7446ff19da101894d85f4dc926cf432b6f8198 | 6,657,199,340,589 | 2c2af78417aac0e823973de9513209f27dabc16c | /src/main/java/com/demo/activiti/entity/Staff.java | cfa3b8db5eb21eae7d874b8b8480b70e02393126 | []
| no_license | jayz2017/testdemo | https://github.com/jayz2017/testdemo | 3fdc43beff25685097401091fd464aa18835a53d | 3c3b40019bde9d42511c2115bb81b3741c46834a | refs/heads/master | 2020-04-25T14:56:55.012000 | 2019-02-28T08:25:02 | 2019-02-28T08:25:02 | 172,860,426 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.demo.activiti.entity;
public class Staff {
private String staff_id;
private String staff_name;
private String department;
private String role;
public String getStaff_id() {
return staff_id;
}
public void setStaff_id(String staff_id) {
this.staff_id = staff_id;
}
public String getStaff_name() {
return staff_name;
}
public void setStaff_name(String staff_name) {
this.staff_name = staff_name;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
}
| UTF-8 | Java | 683 | java | Staff.java | Java | []
| null | []
| package com.demo.activiti.entity;
public class Staff {
private String staff_id;
private String staff_name;
private String department;
private String role;
public String getStaff_id() {
return staff_id;
}
public void setStaff_id(String staff_id) {
this.staff_id = staff_id;
}
public String getStaff_name() {
return staff_name;
}
public void setStaff_name(String staff_name) {
this.staff_name = staff_name;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
}
| 683 | 0.70571 | 0.70571 | 41 | 15.658537 | 15.17477 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.195122 | false | false | 9 |
6e813bbe428e5260c2bfd37aaea4b12b36848a5b | 3,367,254,380,678 | abf9c58adb57bce2472934fca7f058facb1f9bd2 | /String/ToUpperCase.java | d720a3ce745140249766b487a228b41a796c8321 | []
| no_license | tina-wuuuuu/Test2_Exercise | https://github.com/tina-wuuuuu/Test2_Exercise | 8c273ab44f27059907e06e418443d67207c383c4 | 6d572e299315786401aab67d503b8520c83a229a | refs/heads/master | 2022-12-26T12:46:38.185000 | 2020-10-13T07:55:43 | 2020-10-13T07:55:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package String;
public class ToUpperCase {
//Âà´«¦¨¤j¼g¦r¦ê
//String toUpperCase()
public static void main(String[] args) {
// TODO Auto-generated method stub
String strCom = "i like java";
System.out.println(strCom.toUpperCase());
}
}
| WINDOWS-1252 | Java | 260 | java | ToUpperCase.java | Java | []
| null | []
| package String;
public class ToUpperCase {
//Âà´«¦¨¤j¼g¦r¦ê
//String toUpperCase()
public static void main(String[] args) {
// TODO Auto-generated method stub
String strCom = "i like java";
System.out.println(strCom.toUpperCase());
}
}
| 260 | 0.682731 | 0.678715 | 13 | 18.153847 | 15.907648 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 9 |
d354155d48b74a93d8cabf5fba95cbdc00bcb974 | 4,870,492,935,920 | 4379e0b6f3c7cc75189243eebfc0f1fcc5c9f5ba | /ExposureTimeCalculator/test/alma/obsprep/services/etc/AtmosphereTableTest.java | f71879a22d17909e7403f943dfa8502f8d9fb7e8 | []
| no_license | CCATObservatory/alma-ot | https://github.com/CCATObservatory/alma-ot | bb1cb62bc5f6bd21cde88ac476a461f9b1bd2110 | d9db079e46cd47f3c0cae9ebbc5e426729dd2318 | refs/heads/master | 2016-09-06T18:44:01.550000 | 2014-12-19T17:11:57 | 2014-12-19T17:11:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*******************************************************************************
* ALMA - Atacama Large Millimeter Array
* Copyright (c) UKATC - UK Astronomy Technology Centre, Science and Technology Facilities Council, 2011
* (in the framework of the ALMA collaboration).
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package alma.obsprep.services.etc;
import java.io.File;
import junit.framework.TestSuite;
import alma.obsprep.ObsPrepTestCase;
import alma.obsprep.services.etc.AtmosphereTable.Data;
import alma.obsprep.util.FileUtilities;
/**
* AtmosphereTable test
*
* @author yatagai, 2006-07-21
*/
public class AtmosphereTableTest extends ObsPrepTestCase {
// SKY.SPE0001: 345.00000 0.42315E-01 0.27520E-01 0.50111E-03 0.29773E-04 0.13517E-02 0.19351E-01 0.54832E-05 0.14898E-03 0.00000E+00 0.91223E-01 0.216831E+02 0.291832E+02 -0.25541E-07 0.18242E+03 0.13693E+04 0.15517E+04
// SKY.SPE0002: 345.00000 0.58993E-01 0.38344E-01 0.97305E-03 0.41503E-04 0.13517E-02 0.19349E-01 0.54836E-05 0.14898E-03 0.00000E+00 0.11921E+00 0.280723E+02 0.357136E+02 -0.25541E-07 0.25420E+03 0.19080E+04 0.21622E+04
// SKY.SPE0003: 345.00000 0.81945E-01 0.53218E-01 0.18750E-02 0.57642E-04 0.13517E-02 0.19346E-01 0.54842E-05 0.14898E-03 0.00000E+00 0.15795E+00 0.366343E+02 0.443997E+02 -0.25541E-07 0.35286E+03 0.26486E+04 0.30015E+04
// SKY.SPE0004: 345.00000 0.11332E+00 0.73511E-01 0.35793E-02 0.79697E-04 0.13517E-02 0.19342E-01 0.54850E-05 0.14898E-03 0.00000E+00 0.21134E+00 0.479158E+02 0.557857E+02 -0.25541E-07 0.48753E+03 0.36595E+04 0.41470E+04
// SKY.SPE0005: 345.00000 0.16149E+00 0.10458E+00 0.72493E-02 0.11354E-03 0.13517E-02 0.19336E-01 0.54862E-05 0.14898E-03 0.00000E+00 0.29427E+00 0.643147E+02 0.722776E+02 -0.25541E-07 0.69383E+03 0.52079E+04 0.59017E+04
// SKY.SPE0006: 345.00000 0.24769E+00 0.15991E+00 0.16971E-01 0.17406E-03 0.13517E-02 0.19325E-01 0.54883E-05 0.14898E-03 0.00000E+00 0.44558E+00 0.910183E+02 0.990666E+02 -0.25541E-07 0.10616E+04 0.79685E+04 0.90301E+04
// SKY.SPE0007: 345.00000 0.47034E+00 0.30129E+00 0.60443E-01 0.33010E-03 0.13517E-02 0.19297E-01 0.54938E-05 0.14898E-03 0.00000E+00 0.85321E+00 0.146119E+03 0.154250E+03 -0.25541E-07 0.20034E+04 0.15038E+05 0.17041E+05
float freq345GHz = 345.0f; // [GHz]
double[] tauAt345GHz = {0.91223E-01, 0.11921E+00, 0.15795E+00, 0.21134E+00, 0.29427E+00, 0.44558E+00, 0.85321E+00};
double[] tatmAt345GHz = {0.291832E+02, 0.357136E+02, 0.443997E+02, 0.557857E+02, 0.722776E+02, 0.990666E+02, 0.154250E+03};
float freq = 345.05f; // [GHz]
int wvindex = 0; // WaterVaporColumnDencity = 0.4722mm [SKY.SPE00001]
float invalidSmallFreq = 19.0f;
float invalidLargeFreq = 2000.0f;
// from SKY.SPE00001.dat
// 345.00000 0.42315E-01 0.27520E-01 0.50111E-03 0.29773E-04 0.13517E-02 0.19351E-01 0.54832E-05 0.14898E-03 0.00000E+00 0.91223E-01 0.216831E+02 0.291832E+02 -0.25541E-07 0.18242E+03 0.13693E+04 0.15517E+04
// 345.10000 0.42374E-01 0.27536E-01 0.50143E-03 0.29732E-04 0.13604E-02 0.19360E-01 0.55037E-05 0.12579E-03 0.00000E+00 0.91293E-01 0.216997E+02 0.292022E+02 -0.23148E-07 0.18270E+03 0.13696E+04 0.15523E+04
double lfreq = 345.0;
double ufreq = 345.1;
double ltau = 0.91223E-01;
double utau = 0.91293E-01;
double ltatm = 0.291832E+02;
double utatm = 0.292022E+02;
public AtmosphereTableTest(String name) {
super(name);
}
@Override
public void setUp() throws Exception {
File aim = new File(getBaseDirectory(),"config/otData");
String otDataDir = FileUtilities.makeRelativePath(aim);
System.setProperty("otData.dir", otDataDir);
// alma.obsprep.ot.gui.toplevel.InitServices.initModelSupportClasses();
}
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(new TestSuite(AtmosphereTableTest.class));
return suite;
}
public void testRead() {
AtmosphereTable atbl = AtmosphereTable.getInstance();
Data atmData;
for (int i = 0; i < AtmosphereTable.NUM_WV_POINTS; i++) {
atmData = atbl.lookup(freq345GHz, i);
float m_tau;
float m_tatm;
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertEquals(tauAt345GHz[i], m_tau, 0.00001);
assertEquals(tatmAt345GHz[i], m_tatm, 0.000001E+02);
}
try {
atmData = atbl.lookup(freq345GHz, AtmosphereTable.NUM_WV_POINTS);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
//
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
public void testLookup() {
AtmosphereTable atbl = AtmosphereTable.getInstance();
Data atmData;
float m_tau;
float m_tatm;
atmData = atbl.lookup(freq, wvindex);
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertTrue((m_tau > ltau && m_tau < utau));
assertTrue((m_tatm > ltatm && m_tatm < utatm));
atmData = atbl.lookup((float)lfreq, wvindex);
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertEquals(ltau, m_tau, 1.0E-6);
assertEquals(ltatm, m_tatm, 1.0E-3);
atmData = atbl.lookup(invalidSmallFreq, wvindex);
assertNull(atmData);
atmData = atbl.lookup(invalidLargeFreq, wvindex);
assertNull(atmData);
}
/**
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
}
| UTF-8 | Java | 6,542 | java | AtmosphereTableTest.java | Java | [
{
"context": "ities;\n\n/**\n * AtmosphereTable test\n * \n * @author yatagai, 2006-07-21\n */\npublic class AtmosphereTableTest ",
"end": 1398,
"score": 0.9221920967102051,
"start": 1391,
"tag": "USERNAME",
"value": "yatagai"
}
]
| null | []
| /*******************************************************************************
* ALMA - Atacama Large Millimeter Array
* Copyright (c) UKATC - UK Astronomy Technology Centre, Science and Technology Facilities Council, 2011
* (in the framework of the ALMA collaboration).
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package alma.obsprep.services.etc;
import java.io.File;
import junit.framework.TestSuite;
import alma.obsprep.ObsPrepTestCase;
import alma.obsprep.services.etc.AtmosphereTable.Data;
import alma.obsprep.util.FileUtilities;
/**
* AtmosphereTable test
*
* @author yatagai, 2006-07-21
*/
public class AtmosphereTableTest extends ObsPrepTestCase {
// SKY.SPE0001: 345.00000 0.42315E-01 0.27520E-01 0.50111E-03 0.29773E-04 0.13517E-02 0.19351E-01 0.54832E-05 0.14898E-03 0.00000E+00 0.91223E-01 0.216831E+02 0.291832E+02 -0.25541E-07 0.18242E+03 0.13693E+04 0.15517E+04
// SKY.SPE0002: 345.00000 0.58993E-01 0.38344E-01 0.97305E-03 0.41503E-04 0.13517E-02 0.19349E-01 0.54836E-05 0.14898E-03 0.00000E+00 0.11921E+00 0.280723E+02 0.357136E+02 -0.25541E-07 0.25420E+03 0.19080E+04 0.21622E+04
// SKY.SPE0003: 345.00000 0.81945E-01 0.53218E-01 0.18750E-02 0.57642E-04 0.13517E-02 0.19346E-01 0.54842E-05 0.14898E-03 0.00000E+00 0.15795E+00 0.366343E+02 0.443997E+02 -0.25541E-07 0.35286E+03 0.26486E+04 0.30015E+04
// SKY.SPE0004: 345.00000 0.11332E+00 0.73511E-01 0.35793E-02 0.79697E-04 0.13517E-02 0.19342E-01 0.54850E-05 0.14898E-03 0.00000E+00 0.21134E+00 0.479158E+02 0.557857E+02 -0.25541E-07 0.48753E+03 0.36595E+04 0.41470E+04
// SKY.SPE0005: 345.00000 0.16149E+00 0.10458E+00 0.72493E-02 0.11354E-03 0.13517E-02 0.19336E-01 0.54862E-05 0.14898E-03 0.00000E+00 0.29427E+00 0.643147E+02 0.722776E+02 -0.25541E-07 0.69383E+03 0.52079E+04 0.59017E+04
// SKY.SPE0006: 345.00000 0.24769E+00 0.15991E+00 0.16971E-01 0.17406E-03 0.13517E-02 0.19325E-01 0.54883E-05 0.14898E-03 0.00000E+00 0.44558E+00 0.910183E+02 0.990666E+02 -0.25541E-07 0.10616E+04 0.79685E+04 0.90301E+04
// SKY.SPE0007: 345.00000 0.47034E+00 0.30129E+00 0.60443E-01 0.33010E-03 0.13517E-02 0.19297E-01 0.54938E-05 0.14898E-03 0.00000E+00 0.85321E+00 0.146119E+03 0.154250E+03 -0.25541E-07 0.20034E+04 0.15038E+05 0.17041E+05
float freq345GHz = 345.0f; // [GHz]
double[] tauAt345GHz = {0.91223E-01, 0.11921E+00, 0.15795E+00, 0.21134E+00, 0.29427E+00, 0.44558E+00, 0.85321E+00};
double[] tatmAt345GHz = {0.291832E+02, 0.357136E+02, 0.443997E+02, 0.557857E+02, 0.722776E+02, 0.990666E+02, 0.154250E+03};
float freq = 345.05f; // [GHz]
int wvindex = 0; // WaterVaporColumnDencity = 0.4722mm [SKY.SPE00001]
float invalidSmallFreq = 19.0f;
float invalidLargeFreq = 2000.0f;
// from SKY.SPE00001.dat
// 345.00000 0.42315E-01 0.27520E-01 0.50111E-03 0.29773E-04 0.13517E-02 0.19351E-01 0.54832E-05 0.14898E-03 0.00000E+00 0.91223E-01 0.216831E+02 0.291832E+02 -0.25541E-07 0.18242E+03 0.13693E+04 0.15517E+04
// 345.10000 0.42374E-01 0.27536E-01 0.50143E-03 0.29732E-04 0.13604E-02 0.19360E-01 0.55037E-05 0.12579E-03 0.00000E+00 0.91293E-01 0.216997E+02 0.292022E+02 -0.23148E-07 0.18270E+03 0.13696E+04 0.15523E+04
double lfreq = 345.0;
double ufreq = 345.1;
double ltau = 0.91223E-01;
double utau = 0.91293E-01;
double ltatm = 0.291832E+02;
double utatm = 0.292022E+02;
public AtmosphereTableTest(String name) {
super(name);
}
@Override
public void setUp() throws Exception {
File aim = new File(getBaseDirectory(),"config/otData");
String otDataDir = FileUtilities.makeRelativePath(aim);
System.setProperty("otData.dir", otDataDir);
// alma.obsprep.ot.gui.toplevel.InitServices.initModelSupportClasses();
}
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(new TestSuite(AtmosphereTableTest.class));
return suite;
}
public void testRead() {
AtmosphereTable atbl = AtmosphereTable.getInstance();
Data atmData;
for (int i = 0; i < AtmosphereTable.NUM_WV_POINTS; i++) {
atmData = atbl.lookup(freq345GHz, i);
float m_tau;
float m_tatm;
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertEquals(tauAt345GHz[i], m_tau, 0.00001);
assertEquals(tatmAt345GHz[i], m_tatm, 0.000001E+02);
}
try {
atmData = atbl.lookup(freq345GHz, AtmosphereTable.NUM_WV_POINTS);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
//
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
public void testLookup() {
AtmosphereTable atbl = AtmosphereTable.getInstance();
Data atmData;
float m_tau;
float m_tatm;
atmData = atbl.lookup(freq, wvindex);
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertTrue((m_tau > ltau && m_tau < utau));
assertTrue((m_tatm > ltatm && m_tatm < utatm));
atmData = atbl.lookup((float)lfreq, wvindex);
m_tau = atmData.getTau();
m_tatm = atmData.getTsky();
assertEquals(ltau, m_tau, 1.0E-6);
assertEquals(ltatm, m_tatm, 1.0E-3);
atmData = atbl.lookup(invalidSmallFreq, wvindex);
assertNull(atmData);
atmData = atbl.lookup(invalidLargeFreq, wvindex);
assertNull(atmData);
}
/**
* @see junit.framework.TestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
}
| 6,542 | 0.643993 | 0.409355 | 145 | 44.117241 | 58.26355 | 250 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.275862 | false | false | 9 |
1cb9890435cd85fd64997616fa574893c04acbb3 | 1,305,670,080,312 | 1a8484aec668ca4c93c58aa8ea49ed662ba0f1fb | /An TK's Beispiel angepasst/Java_eShop 1.0.0/src/persistance/PersistenceManager.java | c2db5f2f2dd8056953030f79dddd05e3b2ad5b2e | []
| no_license | Dawinartor/Java_eShop | https://github.com/Dawinartor/Java_eShop | d5770145b3c730036150201ee90263193254b855 | b196ff0e8fc6e3f4bce3d1ec4568b63148b94eb0 | refs/heads/master | 2020-05-18T12:12:16.804000 | 2019-06-10T07:23:22 | 2019-06-10T07:23:22 | 184,400,128 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package persistance;
import java.io.IOException;
import valueobjects.Artikel;
import valueobjects.Kunde;
import valueobjects.Mitarbeiter;
/**
* @author Dawinartor
*
*Allgemeine Schnittstelle für den Zugriff auf ein Speichermedium
* (z.B. Datei oder Datenbank) zum Ablegen von beispielsweise
* Artikel- oder Kundendaten.
*
* Das Interface muss von Klassen implementiert werden, die eine
* Persistenz-Schnittstelle realisieren wollen.
*/
public interface PersistenceManager {
public void openForReading(String datenquelle) throws IOException;
public void openForWriting(String datenquelle) throws IOException;
public boolean close();
// ---------- Artikel - Daten ----------
/**
* Methode zum Einlesen der Artikeldaten aus einer externen Datenquelle.
*
* @return Artikel-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Artikel ladeArtikel() throws IOException;
/**
* Methode zum schreiben der Artikeldaten in eine externe Datenquelle.
*
* @param a Artikel-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereArtikel(Artikel artikel) throws IOException;
// ---------- Kunden - Daten ----------
/**
* Methode zum Einlesen der Kunden aus einer externen Datenquelle.
*
* @return Kunden-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Kunde ladeKunden() throws IOException;
/**
* Methode zum schreiben der Kunden in eine externe Datenquelle.
*
* @param a Kunden-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereKunden(Kunde kunde) throws IOException;
// ---------- Mitarbeiter - Daten ----------
/**
* Methode zum Einlesen der Mitarbeiter aus einer externen Datenquelle.
*
* @return Mitarbeiter-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Mitarbeiter ladeMitarbeiter() throws IOException;
/**
* Methode zum schreiben der Mitarbeiter in eine externe Datenquelle.
*
* @param a Mitarbeiter-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereMitarbeiter(Mitarbeiter mitarbeiter) throws IOException;
//public boolean createNewFile() throws IOException;
//public Artikel ladeArtikelInZeile() throws IOException;
}
| ISO-8859-1 | Java | 2,500 | java | PersistenceManager.java | Java | [
{
"context": ";\nimport valueobjects.Mitarbeiter;\n\n/**\n * @author Dawinartor\n *\n *Allgemeine Schnittstelle für den Zugriff auf",
"end": 178,
"score": 0.9935189485549927,
"start": 168,
"tag": "NAME",
"value": "Dawinartor"
}
]
| null | []
| /**
*
*/
package persistance;
import java.io.IOException;
import valueobjects.Artikel;
import valueobjects.Kunde;
import valueobjects.Mitarbeiter;
/**
* @author Dawinartor
*
*Allgemeine Schnittstelle für den Zugriff auf ein Speichermedium
* (z.B. Datei oder Datenbank) zum Ablegen von beispielsweise
* Artikel- oder Kundendaten.
*
* Das Interface muss von Klassen implementiert werden, die eine
* Persistenz-Schnittstelle realisieren wollen.
*/
public interface PersistenceManager {
public void openForReading(String datenquelle) throws IOException;
public void openForWriting(String datenquelle) throws IOException;
public boolean close();
// ---------- Artikel - Daten ----------
/**
* Methode zum Einlesen der Artikeldaten aus einer externen Datenquelle.
*
* @return Artikel-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Artikel ladeArtikel() throws IOException;
/**
* Methode zum schreiben der Artikeldaten in eine externe Datenquelle.
*
* @param a Artikel-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereArtikel(Artikel artikel) throws IOException;
// ---------- Kunden - Daten ----------
/**
* Methode zum Einlesen der Kunden aus einer externen Datenquelle.
*
* @return Kunden-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Kunde ladeKunden() throws IOException;
/**
* Methode zum schreiben der Kunden in eine externe Datenquelle.
*
* @param a Kunden-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereKunden(Kunde kunde) throws IOException;
// ---------- Mitarbeiter - Daten ----------
/**
* Methode zum Einlesen der Mitarbeiter aus einer externen Datenquelle.
*
* @return Mitarbeiter-Objekte, wenn Einlesen erfolgreich, false
* @throws IOException
*/
public Mitarbeiter ladeMitarbeiter() throws IOException;
/**
* Methode zum schreiben der Mitarbeiter in eine externe Datenquelle.
*
* @param a Mitarbeiter-Objekt, das gespeichert werden soll
* @return true, wenn Schreibvorgang erfolgreich, false
* @throws IOException
*/
public boolean speichereMitarbeiter(Mitarbeiter mitarbeiter) throws IOException;
//public boolean createNewFile() throws IOException;
//public Artikel ladeArtikelInZeile() throws IOException;
}
| 2,500 | 0.726691 | 0.726691 | 92 | 26.163044 | 26.68507 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.054348 | false | false | 9 |
6a7ed2f6cdab2acb4cd6a606bc731d31a280071a | 962,072,682,291 | 59e4596f07b00a69feabb1fb119619aa58964dd4 | /StsTool.v.1.3.3/eu.aniketos.wp1.ststool.diagram/src/eu/aniketos/wp1/ststool/diagram/custom/utility/DescriptionDialog.java | 8d6d37e0a7920d77021a52a2e6097a65dc0bd3ca | []
| no_license | AniketosEU/Socio-technical-Security-Requirements | https://github.com/AniketosEU/Socio-technical-Security-Requirements | 895bac6785af1a40cb55afa9cb3dd73f83f8011f | 7ce04c023af6c3e77fa4741734da7edac103c875 | refs/heads/master | 2018-12-31T17:08:39.594000 | 2014-02-21T14:36:14 | 2014-02-21T14:36:14 | 15,801,803 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* DescriptionDialog.java
*
* This file is part of the STS-Tool project.
* Copyright (c) 2011-2012 "University of Trento - DISI" All rights reserved.
*
* Is strictly forbidden to remove this copyright notice from this source code.
*
* Disclaimer of Warranty:
* STS-Tool (this software) is provided "as-is" and without warranty of any kind,
* express, implied or otherwise, including without limitation, any warranty of
* merchantability or fitness for a particular purpose.
* In no event shall the copyright holder or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused and on
* any theory of liability, whether in contract, strict liability, or tort (including
* negligence or otherwise) arising in any way out of the use of this software, even
* if advised of the possibility of such damage.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3
* as published by the Free Software Foundation with the addition of the
* following permission added to Section 15 as permitted in Section 7(a):
* FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
* "University of Trento - DISI","University of Trento - DISI" DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA, 02110-1301 USA, or download the license from the following URL:
* http://www.sts-tool.eu/License.php
*
* For more information, please contact STS-Tool group at this
* address: ststool@disi.unitn.it
*
*/
package eu.aniketos.wp1.ststool.diagram.custom.utility;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class DescriptionDialog extends Dialog {
private Text text;
private String initialText = "";
private String result = null;
/**
* Create the dialog.
*
* @param parentShell
*/
public DescriptionDialog(Shell parentShell) {
this(parentShell, "");
}
/**
* Create the dialog.
*
* @param parentShell
* @wbp.parser.constructor
*/
public DescriptionDialog(Shell parentShell, String initialText) {
super(parentShell);
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
if (initialText != null) this.initialText = initialText;
}
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent){
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new FormLayout());
Label lblNewLabel = new Label(container, SWT.NONE);
FormData fd_lblNewLabel = new FormData();
fd_lblNewLabel.right = new FormAttachment(100, -10);
fd_lblNewLabel.top = new FormAttachment(0, 10);
fd_lblNewLabel.left = new FormAttachment(0, 10);
lblNewLabel.setLayoutData(fd_lblNewLabel);
lblNewLabel.setText("Enter a Description:");
text = new Text(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(100, -10);
fd_text.right = new FormAttachment(100, -10);
fd_text.top = new FormAttachment(lblNewLabel, 6);
fd_text.left = new FormAttachment(0, 10);
text.setLayoutData(fd_text);
text.setText(initialText);
return container;
}
/**
* Create contents of the button bar.
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent){
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
/**
* Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize(){
return new Point(450, 300);
}
@Override
protected void okPressed(){
result = text.getText().trim();
super.okPressed();
}
/**
* @return the text inserted by the user null if the dialog was closed
*/
public String getResult(){
return result;
}
}
| UTF-8 | Java | 4,926 | java | DescriptionDialog.java | Java | [
{
"context": " please contact STS-Tool group at this\r\n* address: ststool@disi.unitn.it\r\n*\r\n*/\r\npackage eu.aniketos.wp1.ststool.diagram.c",
"end": 2034,
"score": 0.9999294281005859,
"start": 2013,
"tag": "EMAIL",
"value": "ststool@disi.unitn.it"
}
]
| null | []
| /*
* DescriptionDialog.java
*
* This file is part of the STS-Tool project.
* Copyright (c) 2011-2012 "University of Trento - DISI" All rights reserved.
*
* Is strictly forbidden to remove this copyright notice from this source code.
*
* Disclaimer of Warranty:
* STS-Tool (this software) is provided "as-is" and without warranty of any kind,
* express, implied or otherwise, including without limitation, any warranty of
* merchantability or fitness for a particular purpose.
* In no event shall the copyright holder or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused and on
* any theory of liability, whether in contract, strict liability, or tort (including
* negligence or otherwise) arising in any way out of the use of this software, even
* if advised of the possibility of such damage.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3
* as published by the Free Software Foundation with the addition of the
* following permission added to Section 15 as permitted in Section 7(a):
* FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
* "University of Trento - DISI","University of Trento - DISI" DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA, 02110-1301 USA, or download the license from the following URL:
* http://www.sts-tool.eu/License.php
*
* For more information, please contact STS-Tool group at this
* address: <EMAIL>
*
*/
package eu.aniketos.wp1.ststool.diagram.custom.utility;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class DescriptionDialog extends Dialog {
private Text text;
private String initialText = "";
private String result = null;
/**
* Create the dialog.
*
* @param parentShell
*/
public DescriptionDialog(Shell parentShell) {
this(parentShell, "");
}
/**
* Create the dialog.
*
* @param parentShell
* @wbp.parser.constructor
*/
public DescriptionDialog(Shell parentShell, String initialText) {
super(parentShell);
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
if (initialText != null) this.initialText = initialText;
}
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent){
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new FormLayout());
Label lblNewLabel = new Label(container, SWT.NONE);
FormData fd_lblNewLabel = new FormData();
fd_lblNewLabel.right = new FormAttachment(100, -10);
fd_lblNewLabel.top = new FormAttachment(0, 10);
fd_lblNewLabel.left = new FormAttachment(0, 10);
lblNewLabel.setLayoutData(fd_lblNewLabel);
lblNewLabel.setText("Enter a Description:");
text = new Text(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(100, -10);
fd_text.right = new FormAttachment(100, -10);
fd_text.top = new FormAttachment(lblNewLabel, 6);
fd_text.left = new FormAttachment(0, 10);
text.setLayoutData(fd_text);
text.setText(initialText);
return container;
}
/**
* Create contents of the button bar.
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent){
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
/**
* Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize(){
return new Point(450, 300);
}
@Override
protected void okPressed(){
result = text.getText().trim();
super.okPressed();
}
/**
* @return the text inserted by the user null if the dialog was closed
*/
public String getResult(){
return result;
}
}
| 4,912 | 0.723508 | 0.712343 | 145 | 31.972414 | 27.40575 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.427586 | false | false | 9 |
2fb4ca0a39ef40babb4d108aa3aa6005e764046b | 19,396,072,377,085 | e61b5f97813e2afe758e1603e21b4c804ac1ad9a | /springmvc/src/main/java/com/liugw/learn/di/DITest.java | ba222ae1d6fb9de5e648be83ded758df1d294e0e | []
| no_license | liugaowei999/spring-mvc-learn | https://github.com/liugaowei999/spring-mvc-learn | 4036c9489230cf68b233d65ad568c1e292435b66 | 7da167bb8c2b63018dc7add6a6c192388480997d | refs/heads/master | 2021-09-13T13:22:19.785000 | 2018-04-30T14:55:49 | 2018-04-30T14:55:49 | 112,701,914 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.liugw.learn.di;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DITest {
public static void main(String[] args) {
// Women women = new Women();
// Man man = new Man();
//
// HuShi huShi = new HuShi(man);
// huShi.doWork();
//
// HuShi huShi1 = new HuShi(women);
// huShi1.doWork();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:spring-applicationcontext-DI.xml");
// Women women = (Women) context.getBean("woman");
// women.sayHello();
//HuShi huShi = (HuShi) context.getBean("nurse");
HuShi nurse = context.getBean(HuShi.class);
nurse.doWork();
}
}
| UTF-8 | Java | 719 | java | DITest.java | Java | []
| null | []
| package com.liugw.learn.di;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DITest {
public static void main(String[] args) {
// Women women = new Women();
// Man man = new Man();
//
// HuShi huShi = new HuShi(man);
// huShi.doWork();
//
// HuShi huShi1 = new HuShi(women);
// huShi1.doWork();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:spring-applicationcontext-DI.xml");
// Women women = (Women) context.getBean("woman");
// women.sayHello();
//HuShi huShi = (HuShi) context.getBean("nurse");
HuShi nurse = context.getBean(HuShi.class);
nurse.doWork();
}
}
| 719 | 0.652295 | 0.649513 | 27 | 24.629629 | 22.865383 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.37037 | false | false | 9 |
0043c0794a879e0730dd74f3ea782b4d0b49a723 | 29,343,216,571,211 | 9ac51ef6fe6dba4d47540e51eea479744a540aba | /Java.Homeworks.Stefan-Alexandru.Rentea/src/hells/Choice.java | 03e2ce0e4c6cd4bf566ac2e7ff71e59290119df3 | []
| no_license | stefan574/JavaHomeworksRenteaStefan-Alexandru | https://github.com/stefan574/JavaHomeworksRenteaStefan-Alexandru | 5f58364ce942a867b75e1b3ff793ede9b89b3776 | 90badf0fa4d1c3e6f42cf965b31d0ff240633279 | refs/heads/master | 2020-12-24T12:33:42.570000 | 2017-03-11T15:29:31 | 2017-03-11T15:29:31 | 72,980,581 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Choice Class
*/
package hells;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
/**
* @author Stefan-Alexandru Rentea
*/
public class Choice {
private final TheNineHellsOfBaator[] hells = new TheNineHellsOfBaator[4];
private String description;
/**
* Constructor for the Choice class, specifically for the player
*
* @param firstHell represents the first hell
* @param secondHell represents the second hell
* @param thirdHell represents the third hell
* @param forthHell represents the forth hell
*/
Choice(int firstHell, int secondHell, int thirdHell, int forthHell) {
this.hells[0] = TheNineHellsOfBaator.values()[firstHell - 1];
this.hells[1] = TheNineHellsOfBaator.values()[secondHell - 1];
this.hells[2] = TheNineHellsOfBaator.values()[thirdHell - 1];
this.hells[3] = TheNineHellsOfBaator.values()[forthHell - 1];
this.description = null;
}
/**
* Constructor for the Choice class, specifically for the dealer
*/
Choice() {
Random random = new Random();
List<TheNineHellsOfBaator> listOfHells = new ArrayList<>();
listOfHells.addAll(Arrays.asList(TheNineHellsOfBaator.values()));
Collections.shuffle(listOfHells);
this.hells[0] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[0]);
Collections.shuffle(listOfHells);
this.hells[1] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[1]);
Collections.shuffle(listOfHells);
this.hells[2] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[2]);
Collections.shuffle(listOfHells);
this.hells[3] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
this.description = null;
}
/**
* Getter for the hells field
*
* @return hells field
*/
public TheNineHellsOfBaator[] getHells() {
return hells;
}
/**
* Getter for the description field
*
* @return description field
*/
public String getDescription() {
return description;
}
/**
* Setter for the description field
*
* @param description represents the value for the description field
*/
public void setDescription(String description) {
this.description = description;
}
}
| UTF-8 | Java | 2,734 | java | Choice.java | Java | [
{
"context": "List;\r\nimport java.util.Random;\r\n\r\n/**\r\n * @author Stefan-Alexandru Rentea\r\n */\r\npublic class Choice {\r\n \r\n private fi",
"end": 221,
"score": 0.9998685121536255,
"start": 198,
"tag": "NAME",
"value": "Stefan-Alexandru Rentea"
}
]
| null | []
| /*
* Choice Class
*/
package hells;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
/**
* @author <NAME>
*/
public class Choice {
private final TheNineHellsOfBaator[] hells = new TheNineHellsOfBaator[4];
private String description;
/**
* Constructor for the Choice class, specifically for the player
*
* @param firstHell represents the first hell
* @param secondHell represents the second hell
* @param thirdHell represents the third hell
* @param forthHell represents the forth hell
*/
Choice(int firstHell, int secondHell, int thirdHell, int forthHell) {
this.hells[0] = TheNineHellsOfBaator.values()[firstHell - 1];
this.hells[1] = TheNineHellsOfBaator.values()[secondHell - 1];
this.hells[2] = TheNineHellsOfBaator.values()[thirdHell - 1];
this.hells[3] = TheNineHellsOfBaator.values()[forthHell - 1];
this.description = null;
}
/**
* Constructor for the Choice class, specifically for the dealer
*/
Choice() {
Random random = new Random();
List<TheNineHellsOfBaator> listOfHells = new ArrayList<>();
listOfHells.addAll(Arrays.asList(TheNineHellsOfBaator.values()));
Collections.shuffle(listOfHells);
this.hells[0] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[0]);
Collections.shuffle(listOfHells);
this.hells[1] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[1]);
Collections.shuffle(listOfHells);
this.hells[2] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
listOfHells.remove(this.hells[2]);
Collections.shuffle(listOfHells);
this.hells[3] = listOfHells.get(random.nextInt(listOfHells.size() - 1));
this.description = null;
}
/**
* Getter for the hells field
*
* @return hells field
*/
public TheNineHellsOfBaator[] getHells() {
return hells;
}
/**
* Getter for the description field
*
* @return description field
*/
public String getDescription() {
return description;
}
/**
* Setter for the description field
*
* @param description represents the value for the description field
*/
public void setDescription(String description) {
this.description = description;
}
}
| 2,717 | 0.603877 | 0.596562 | 93 | 27.39785 | 25.017044 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.387097 | false | false | 9 |
31a7f9db7cca93c2a5aba8639f85e753d30abd82 | 1,580,547,975,300 | faab5bccac31c54c753f7826ba3484f7cdd56c58 | /trunck/AP99/AP99-contract/AP99-contract-runtime/src/main/java/com/ebao/ap99/contract/entity/TRiContractAreaperil.java | 3d60e2e8a03a705d48558982e920268c86a96d48 | []
| no_license | semaxu/peakre | https://github.com/semaxu/peakre | 19e99d83e54ef815f8e2e480f29ad65569136fbd | c64ed4d4af93dc2015846a613f493e17b8c6d1e9 | refs/heads/master | 2021-01-23T12:11:50.815000 | 2016-07-13T05:55:47 | 2016-07-13T05:55:47 | 62,941,992 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ebao.ap99.contract.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
import org.restlet.engine.util.StringUtils;
import com.ebao.ap99.parent.BaseEntityImpl;
/**
* The persistent class for the T_RI_CONTRACT_AREAPERIL database table.
*/
@Entity
@Table(name = "T_RI_CONTRACT_AREAPERIL")
@NamedQuery(name = "TRiContractAreaperil.findAll", query = "SELECT t FROM TRiContractAreaperil t WHERE t.isActive != 'N'")
@XmlAccessorType(XmlAccessType.FIELD)
public class TRiContractAreaperil extends BaseEntityImpl implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// @SequenceGenerator(name="T_RI_CONTRACT_AREAPERIL_CONTCOMPID_GENERATOR" )
// @GeneratedValue(strategy=GenerationType.SEQUENCE,
// generator="T_RI_CONTRACT_AREAPERIL_CONTCOMPID_GENERATOR")
@Column(name = "CONT_COMP_ID")
@XmlTransient
private Long contCompId;
private String covered;
@Column(name = "COVERED_REMARK")
private String coveredRemark;
private String peril;
@Column(name = "PERIL_REMARK")
private String perilRemark;
// bi-directional one-to-one association to TRiContractInfo
@OneToOne
@JoinColumn(name = "CONT_COMP_ID")
@XmlTransient
private TRiContractInfo TRiContractInfo;
public TRiContractInfo getTRiContractInfo() {
return TRiContractInfo;
}
public void setTRiContractInfo(TRiContractInfo tRiContractInfo) {
TRiContractInfo = tRiContractInfo;
}
@Column(name = "IS_ACTIVE")
@XmlTransient
private String isActive;
public String getIsActive() {
return isActive;
}
public void setIsActive(String isActive) {
if (StringUtils.isNullOrEmpty(isActive)) {
this.isActive = "Y";
} else {
this.isActive = isActive;
}
}
public TRiContractAreaperil() {
// default Y
this.isActive = "Y";
}
public Long getContCompId() {
return this.contCompId;
}
public void setContCompId(Long contCompId) {
this.contCompId = contCompId;
}
public String getCovered() {
return this.covered;
}
public void setCovered(String covered) {
this.covered = covered;
}
public String getCoveredRemark() {
return this.coveredRemark;
}
public void setCoveredRemark(String coveredRemark) {
this.coveredRemark = coveredRemark;
}
public String getPeril() {
return this.peril;
}
public void setPeril(String peril) {
this.peril = peril;
}
public String getPerilRemark() {
return this.perilRemark;
}
public void setPerilRemark(String perilRemark) {
this.perilRemark = perilRemark;
}
@Override
public Long getPrimaryKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setPrimaryKey(Long paramLong) {
// TODO Auto-generated method stub
}
}
| UTF-8 | Java | 3,349 | java | TRiContractAreaperil.java | Java | []
| null | []
| package com.ebao.ap99.contract.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
import org.restlet.engine.util.StringUtils;
import com.ebao.ap99.parent.BaseEntityImpl;
/**
* The persistent class for the T_RI_CONTRACT_AREAPERIL database table.
*/
@Entity
@Table(name = "T_RI_CONTRACT_AREAPERIL")
@NamedQuery(name = "TRiContractAreaperil.findAll", query = "SELECT t FROM TRiContractAreaperil t WHERE t.isActive != 'N'")
@XmlAccessorType(XmlAccessType.FIELD)
public class TRiContractAreaperil extends BaseEntityImpl implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// @SequenceGenerator(name="T_RI_CONTRACT_AREAPERIL_CONTCOMPID_GENERATOR" )
// @GeneratedValue(strategy=GenerationType.SEQUENCE,
// generator="T_RI_CONTRACT_AREAPERIL_CONTCOMPID_GENERATOR")
@Column(name = "CONT_COMP_ID")
@XmlTransient
private Long contCompId;
private String covered;
@Column(name = "COVERED_REMARK")
private String coveredRemark;
private String peril;
@Column(name = "PERIL_REMARK")
private String perilRemark;
// bi-directional one-to-one association to TRiContractInfo
@OneToOne
@JoinColumn(name = "CONT_COMP_ID")
@XmlTransient
private TRiContractInfo TRiContractInfo;
public TRiContractInfo getTRiContractInfo() {
return TRiContractInfo;
}
public void setTRiContractInfo(TRiContractInfo tRiContractInfo) {
TRiContractInfo = tRiContractInfo;
}
@Column(name = "IS_ACTIVE")
@XmlTransient
private String isActive;
public String getIsActive() {
return isActive;
}
public void setIsActive(String isActive) {
if (StringUtils.isNullOrEmpty(isActive)) {
this.isActive = "Y";
} else {
this.isActive = isActive;
}
}
public TRiContractAreaperil() {
// default Y
this.isActive = "Y";
}
public Long getContCompId() {
return this.contCompId;
}
public void setContCompId(Long contCompId) {
this.contCompId = contCompId;
}
public String getCovered() {
return this.covered;
}
public void setCovered(String covered) {
this.covered = covered;
}
public String getCoveredRemark() {
return this.coveredRemark;
}
public void setCoveredRemark(String coveredRemark) {
this.coveredRemark = coveredRemark;
}
public String getPeril() {
return this.peril;
}
public void setPeril(String peril) {
this.peril = peril;
}
public String getPerilRemark() {
return this.perilRemark;
}
public void setPerilRemark(String perilRemark) {
this.perilRemark = perilRemark;
}
@Override
public Long getPrimaryKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setPrimaryKey(Long paramLong) {
// TODO Auto-generated method stub
}
}
| 3,349 | 0.685578 | 0.684085 | 133 | 24.18045 | 21.940739 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.308271 | false | false | 9 |
64e56265d1475696de47f05f7ce2884ad316e1fd | 24,592,982,752,792 | ef0ea8f7a83b3aa2de12b88c2b1bf6750ee0647e | /src/main/java/com/sargije/rest/hidmet/app/config/MvcConfig.java | ba1f7692c2e16cd6037305de887be9bf91bfb951 | []
| no_license | ivanristic/hidmet | https://github.com/ivanristic/hidmet | 478c935ded9796868f884bcdb12d79947f0ab913 | 9506365fac09fd03887816ad702ce233ffffe0fd | refs/heads/master | 2022-09-22T06:43:16.255000 | 2021-03-24T11:05:13 | 2021-03-24T11:05:13 | 101,793,346 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sargije.rest.hidmet.app.config;
import com.sargije.rest.hidmet.app.interceptors.CustomRequestLoggingInterceptor;
import com.sargije.rest.hidmet.app.model.Authorities;
import com.sargije.rest.hidmet.app.model.AuthoritiesId;
import graphql.kickstart.tools.SchemaParserDictionary;
import io.aexp.nodes.graphql.GraphQLTemplate;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.support.BasicAuthenticationInterceptor;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new CustomRequestLoggingInterceptor());
}
/*
@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter requestLoggingFilter = new CommonsRequestLoggingFilter();
requestLoggingFilter.setIncludeClientInfo(false);
requestLoggingFilter.setIncludeHeaders(false);
requestLoggingFilter.setIncludeQueryString(true);
requestLoggingFilter.setIncludePayload(true);
return requestLoggingFilter;
}
*/
@Bean
@CacheEvict(allEntries = true, cacheNames = {"currentActiveForecasts"})
public void currentForecastCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"description"})
public void descriptionCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"shortTermActiveForecasts"})
public void shortTearmForecastCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"fivedayActiveForecasts"})
public void fivedayForecastCacheEvict() {
}
@Bean
public GraphQLTemplate getGraphQLTemplate() {
//GraphQLTemplate graphQLTemplate = new GraphQLTemplate();
return new GraphQLTemplate();
}
@Bean
public RestTemplate getRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor("ivan", "123456"));
return restTemplate;
}
// workaround for Nested Input Types not Working for Mutations #216 https://github.com/graphql-java-kickstart/graphql-java-tools/issues/216
@Bean
public SchemaParserDictionary schemaParserDictionary() {
return new SchemaParserDictionary().add(Authorities.class).add(AuthoritiesId.class);
}
}
| UTF-8 | Java | 2,569 | java | MvcConfig.java | Java | [
{
"context": "ceptors().add(new BasicAuthenticationInterceptor(\"ivan\", \"123456\"));\n\t\treturn restTemplate;\n\t}\n\n\t// work",
"end": 2228,
"score": 0.8309071063995361,
"start": 2224,
"tag": "USERNAME",
"value": "ivan"
},
{
"context": "king for Mutations #216 https://github.com/graphql-java-kickstart/graphql-java-tools/issues/216\n\t@Bean\n\tpublic Sche",
"end": 2380,
"score": 0.6863999366760254,
"start": 2366,
"tag": "USERNAME",
"value": "java-kickstart"
}
]
| null | []
| package com.sargije.rest.hidmet.app.config;
import com.sargije.rest.hidmet.app.interceptors.CustomRequestLoggingInterceptor;
import com.sargije.rest.hidmet.app.model.Authorities;
import com.sargije.rest.hidmet.app.model.AuthoritiesId;
import graphql.kickstart.tools.SchemaParserDictionary;
import io.aexp.nodes.graphql.GraphQLTemplate;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.support.BasicAuthenticationInterceptor;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new CustomRequestLoggingInterceptor());
}
/*
@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter requestLoggingFilter = new CommonsRequestLoggingFilter();
requestLoggingFilter.setIncludeClientInfo(false);
requestLoggingFilter.setIncludeHeaders(false);
requestLoggingFilter.setIncludeQueryString(true);
requestLoggingFilter.setIncludePayload(true);
return requestLoggingFilter;
}
*/
@Bean
@CacheEvict(allEntries = true, cacheNames = {"currentActiveForecasts"})
public void currentForecastCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"description"})
public void descriptionCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"shortTermActiveForecasts"})
public void shortTearmForecastCacheEvict() {
}
@Bean
@CacheEvict(allEntries = true, cacheNames = {"fivedayActiveForecasts"})
public void fivedayForecastCacheEvict() {
}
@Bean
public GraphQLTemplate getGraphQLTemplate() {
//GraphQLTemplate graphQLTemplate = new GraphQLTemplate();
return new GraphQLTemplate();
}
@Bean
public RestTemplate getRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor("ivan", "123456"));
return restTemplate;
}
// workaround for Nested Input Types not Working for Mutations #216 https://github.com/graphql-java-kickstart/graphql-java-tools/issues/216
@Bean
public SchemaParserDictionary schemaParserDictionary() {
return new SchemaParserDictionary().add(Authorities.class).add(AuthoritiesId.class);
}
}
| 2,569 | 0.8116 | 0.806929 | 78 | 31.935898 | 31.631428 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.141026 | false | false | 9 |
bc5cefcbeedc7c6dd0e91c962b6b21a9f94063b2 | 26,139,170,981,306 | 5a5abfcbdad8bd7074b4e2ad92ce5e2cfb66a094 | /bole-server/bole-service/src/main/java/com/bin/bole/service/NationService.java | db823bbb1a481f6949e637c6e6f9dda3662aea92 | []
| no_license | leo-bin/bole | https://github.com/leo-bin/bole | 52b17bcf51ebfc0a0c995e8b0142d2b298915d68 | 315aae56cdf50678cbe7e03bab05c2bb27113e16 | refs/heads/master | 2023-05-04T18:47:31.326000 | 2021-05-23T11:21:31 | 2021-05-23T11:21:31 | 360,897,172 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bin.bole.service;
import com.bin.bole.dao.NationMapper;
import com.bin.bole.domain.emp.Nation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class NationService {
@Autowired
NationMapper nationMapper;
public List<Nation> getAllNations() {
return nationMapper.getAllNations();
}
}
| UTF-8 | Java | 424 | java | NationService.java | Java | []
| null | []
| package com.bin.bole.service;
import com.bin.bole.dao.NationMapper;
import com.bin.bole.domain.emp.Nation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class NationService {
@Autowired
NationMapper nationMapper;
public List<Nation> getAllNations() {
return nationMapper.getAllNations();
}
}
| 424 | 0.764151 | 0.764151 | 19 | 21.31579 | 19.265602 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false | 9 |
77011a3070a3806088f594b19c5f3cc7908bd356 | 19,550,691,147,766 | 2608dc190ea9d6616c473342502e26b0be041bc5 | /src/domain/ui/controller/handlers/basket/orderHandler.java | 3d4c3f31db0430b6cc4b9fc28dd8e428667afc53 | []
| no_license | Testing1819/webshop | https://github.com/Testing1819/webshop | d1ad27562b01329e935021e339d6f65633b02431 | e8048291aea7f6a586e48315ac202185f71595b7 | refs/heads/master | 2020-04-07T18:38:53.211000 | 2018-12-11T12:35:26 | 2018-12-11T12:35:26 | 156,883,530 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package domain.ui.controller.handlers.basket;
import domain.model.*;
import domain.ui.controller.HandlerFactory;
import domain.ui.controller.RequestHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.*;
public class orderHandler extends RequestHandler {
@Override
public String handlePost(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session = request.getSession();
ShoppingCart shoppingCart = (ShoppingCart) session.getAttribute("shoppingCart");
User user = (User) session.getAttribute("user");
if (shoppingCart != null) {
for (CartItem item: shoppingCart.getItems()) {
Order order = new Order(service.getNrOfOrders(), user.getUsername(), item.getTitle(), item.getArtist(), item.getPrice(), item.getAmount());
service.addOrder(order);
}
}
session.removeAttribute("shoppingCart");
return forwardRequest("order.history", request, response);
}
}
| UTF-8 | Java | 1,155 | java | orderHandler.java | Java | []
| null | []
| package domain.ui.controller.handlers.basket;
import domain.model.*;
import domain.ui.controller.HandlerFactory;
import domain.ui.controller.RequestHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.*;
public class orderHandler extends RequestHandler {
@Override
public String handlePost(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session = request.getSession();
ShoppingCart shoppingCart = (ShoppingCart) session.getAttribute("shoppingCart");
User user = (User) session.getAttribute("user");
if (shoppingCart != null) {
for (CartItem item: shoppingCart.getItems()) {
Order order = new Order(service.getNrOfOrders(), user.getUsername(), item.getTitle(), item.getArtist(), item.getPrice(), item.getAmount());
service.addOrder(order);
}
}
session.removeAttribute("shoppingCart");
return forwardRequest("order.history", request, response);
}
}
| 1,155 | 0.709957 | 0.709957 | 32 | 35.09375 | 34.560055 | 155 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 9 |
c4c2735b14719494d8112d8405cb897a7e2efe18 | 5,119,601,039,395 | 2f8c53426421070eb79188c12ad1c9307d626ccb | /core/src/view/EditorView.java | ecc9817678f7955033c03d97ca9de24b0798b857 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | DannyJo/OpenRTS | https://github.com/DannyJo/OpenRTS | 26242c692b246a0de42adb75a4f845d6aa222d4f | b8bb7ce553dece71b5a9a7ddfb37a76498532996 | refs/heads/master | 2017-10-31T15:09:18.627000 | 2015-05-21T12:54:20 | 2015-05-21T12:54:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package view;
import java.awt.event.ActionListener;
import model.ModelManager;
import view.mapDrawing.EditorRenderer;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
public class EditorView extends MapView implements ActionListener {
// Renderers
public EditorRenderer editorRend;
public EditorView(Node rootNode, Node gui, PhysicsSpace physicsSpace, AssetManager am, ViewPort vp) {
super(rootNode, gui, physicsSpace, am, vp);
editorRend = new EditorRenderer(this, materialManager);
rootNode.attachChild(editorRend.mainNode);
ModelManager.toolManager.addListener(editorRend);
}
@Override
public void reset() {
super.reset();
rootNode.detachChild(editorRend.mainNode);
ModelManager.toolManager.removeListener(editorRend);
editorRend = new EditorRenderer(this, materialManager);
rootNode.attachChild(editorRend.mainNode);
ModelManager.toolManager.addListener(editorRend);
}
}
| UTF-8 | Java | 1,036 | java | EditorView.java | Java | []
| null | []
| package view;
import java.awt.event.ActionListener;
import model.ModelManager;
import view.mapDrawing.EditorRenderer;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
public class EditorView extends MapView implements ActionListener {
// Renderers
public EditorRenderer editorRend;
public EditorView(Node rootNode, Node gui, PhysicsSpace physicsSpace, AssetManager am, ViewPort vp) {
super(rootNode, gui, physicsSpace, am, vp);
editorRend = new EditorRenderer(this, materialManager);
rootNode.attachChild(editorRend.mainNode);
ModelManager.toolManager.addListener(editorRend);
}
@Override
public void reset() {
super.reset();
rootNode.detachChild(editorRend.mainNode);
ModelManager.toolManager.removeListener(editorRend);
editorRend = new EditorRenderer(this, materialManager);
rootNode.attachChild(editorRend.mainNode);
ModelManager.toolManager.addListener(editorRend);
}
}
| 1,036 | 0.76834 | 0.764479 | 37 | 26 | 24.697084 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.513514 | false | false | 9 |
595a43cb9cef47dad2c181f16983139bc3645960 | 29,360,396,455,915 | 631afd8bb77a19ac0f0604c41176d11f63e90c7d | /kie-wb-common-stunner-client/kie-wb-common-stunner-widgets/src/main/java/org/kie/workbench/common/stunner/client/widgets/session/presenter/impl/CanvasSessionPresenterView.java | c58fc033c1c12de0e1faf1c416e1bf59a2dafbd1 | []
| no_license | tsurdilo/wirez | https://github.com/tsurdilo/wirez | 86aaf88fcf412cfa1b03a9cfa8e81503b52439bc | fd8963cdd0dd6ec916b051dc5759f23bd6fe2074 | refs/heads/master | 2020-12-29T03:07:36.637000 | 2016-10-04T01:44:36 | 2016-10-04T02:29:18 | 68,604,988 | 0 | 0 | null | true | 2016-09-19T12:46:45 | 2016-09-19T12:46:45 | 2016-01-17T18:41:42 | 2016-09-19T12:22:25 | 5,001 | 0 | 0 | 0 | null | null | null | package org.kie.workbench.common.stunner.client.widgets.session.presenter.impl;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import org.gwtbootstrap3.client.ui.gwt.FlowPanel;
import org.jboss.errai.ui.shared.api.annotations.DataField;
import org.jboss.errai.ui.shared.api.annotations.Templated;
import org.kie.workbench.common.stunner.client.widgets.session.presenter.CanvasSessionPresenter;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
@Dependent
@Templated
public class CanvasSessionPresenterView
extends Composite
implements CanvasSessionPresenter.View {
@Inject
@DataField
private Label loadingPanel;
@Inject
@DataField
private FlowPanel toolbarPanel;
@Inject
@DataField
private FlowPanel canvasPanel;
@Override
public CanvasSessionPresenter.View setToolbar(final IsWidget widget) {
toolbarPanel.clear();
toolbarPanel.add( widget );
return this;
}
@Override
public CanvasSessionPresenter.View setCanvas(final IsWidget widget) {
canvasPanel.clear();
canvasPanel.add( widget );
return this;
}
@Override
public CanvasSessionPresenter.View setLoading( final boolean loading ) {
loadingPanel.setVisible( loading );
return this;
}
@Override
public void destroy() {
this.removeFromParent();
}
}
| UTF-8 | Java | 1,495 | java | CanvasSessionPresenterView.java | Java | []
| null | []
| package org.kie.workbench.common.stunner.client.widgets.session.presenter.impl;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import org.gwtbootstrap3.client.ui.gwt.FlowPanel;
import org.jboss.errai.ui.shared.api.annotations.DataField;
import org.jboss.errai.ui.shared.api.annotations.Templated;
import org.kie.workbench.common.stunner.client.widgets.session.presenter.CanvasSessionPresenter;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
@Dependent
@Templated
public class CanvasSessionPresenterView
extends Composite
implements CanvasSessionPresenter.View {
@Inject
@DataField
private Label loadingPanel;
@Inject
@DataField
private FlowPanel toolbarPanel;
@Inject
@DataField
private FlowPanel canvasPanel;
@Override
public CanvasSessionPresenter.View setToolbar(final IsWidget widget) {
toolbarPanel.clear();
toolbarPanel.add( widget );
return this;
}
@Override
public CanvasSessionPresenter.View setCanvas(final IsWidget widget) {
canvasPanel.clear();
canvasPanel.add( widget );
return this;
}
@Override
public CanvasSessionPresenter.View setLoading( final boolean loading ) {
loadingPanel.setVisible( loading );
return this;
}
@Override
public void destroy() {
this.removeFromParent();
}
}
| 1,495 | 0.723746 | 0.723077 | 57 | 25.228069 | 23.811407 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.385965 | false | false | 9 |
ce22377e100079fece43e6feae0c51ff52c93fed | 13,159,779,817,524 | 18a66a9ebda178942ec7ba0289e09e709cd467b1 | /src/main/java/com/agoda/poc/utility/Helper.java | 5a1cd54661e5f244a06bf6438ff8296b687c09d8 | []
| no_license | harpzzz/RateLimiter | https://github.com/harpzzz/RateLimiter | 0920db8cdd68e28cd7bbe7fdf8975190a8f5b0d2 | dafe2d0e2a8d81362915ccfbc1ab550bd938106f | refs/heads/master | 2023-03-18T14:00:41.987000 | 2021-03-15T08:07:29 | 2021-03-15T08:07:29 | 347,898,799 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.agoda.poc.utility;
import static com.agoda.poc.contstant.Constant.BASE_URL;
public class Helper {
public static boolean isValidUrl(String uri) {
if(uri.contains(BASE_URL)){
String subUrl = uri.replace(BASE_URL,"");
if(!subUrl.isEmpty()){
return true;
}
}
return false;
}
public static String getSubPath(String uri) {
String[] split = uri.split("/");
return split[3];
}
}
| UTF-8 | Java | 497 | java | Helper.java | Java | []
| null | []
| package com.agoda.poc.utility;
import static com.agoda.poc.contstant.Constant.BASE_URL;
public class Helper {
public static boolean isValidUrl(String uri) {
if(uri.contains(BASE_URL)){
String subUrl = uri.replace(BASE_URL,"");
if(!subUrl.isEmpty()){
return true;
}
}
return false;
}
public static String getSubPath(String uri) {
String[] split = uri.split("/");
return split[3];
}
}
| 497 | 0.56338 | 0.561368 | 23 | 20.608696 | 19.22575 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.347826 | false | false | 9 |
7b66bfdd64ac34dad0d4dd862c66666c495c545a | 17,145,509,514,095 | ce09bd4982516bb5f048660810f8fc206cf0ce32 | /commandprocessor/src/main/java/me/deprilula28/gamesrob/data/Statistics.java | b7f1e221d648e30ee0550afafb1114a291c606aa | []
| no_license | GamesROB/Bot | https://github.com/GamesROB/Bot | e3a91458b6292fc7938af03d21ebcd0579c86236 | f5798586462d7a355fab5081b64ca0d09195f32b | refs/heads/master | 2018-12-27T00:18:03.230000 | 2018-11-11T03:17:01 | 2018-11-11T03:17:01 | 134,065,018 | 3 | 3 | null | false | 2019-03-13T23:44:46 | 2018-05-19T13:36:40 | 2019-03-02T15:06:11 | 2019-03-13T23:44:45 | 22,408 | 4 | 3 | 0 | Java | false | null | package me.deprilula28.gamesrob.data;
import me.deprilula28.gamesrob.GamesROB;
import lombok.AllArgsConstructor;
import lombok.Data;
import me.deprilula28.gamesrob.baseFramework.GamesInstance;
import me.deprilula28.gamesrob.utility.Cache;
import me.deprilula28.gamesrobshardcluster.utilities.Constants;
import me.deprilula28.gamesrobshardcluster.utilities.Log;
import me.deprilula28.gamesrob.utility.Utility;
import me.deprilula28.jdacmdframework.CommandContext;
import net.dv8tion.jda.core.entities.Message;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Consumer;
@Data
@AllArgsConstructor
public class Statistics {
private long gameCount;
private long totalTime;
private long firstBoot;
private String lastUpdateLogSent;
private long lastUpdateLogSentTime;
private Map<String, Integer> perGameCount;
private long commandCount;
private long upvotes;
private long monthUpvotes;
private long gameplayTime;
private long totConnections;
private Map<String, Long> perGameGameplayTime;
private Map<String, Integer> perCommandCount;
private double totalImageCommandGenTime;
private double totalImageCommandPostTime;
private long totalImageCommandBytes;
private long imageCommands;
public Consumer<Message> registerImageProcessor(long generateTimeNano, int byteAmount) {
imageCommands ++;
totalImageCommandBytes += byteAmount;
totalImageCommandGenTime += generateTimeNano / 1000000.0;
long postBegin = System.nanoTime();
return message -> totalImageCommandPostTime += (double) (System.nanoTime() - postBegin) / 1000000.0;
}
public void registerCommand(CommandContext context) {
String name = context.getCurrentCommand().getName();
perCommandCount.put(name, perCommandCount.containsKey(name) ? perCommandCount.get(name) + 1 : 1);
}
public void registerGameTime(long time, GamesInstance instance) {
gameplayTime += time;
perGameGameplayTime.put(instance.getLanguageCode(), perGameGameplayTime.containsKey(instance.getLanguageCode())
? perGameGameplayTime.get(instance.getLanguageCode()) + time : time);
}
public void registerGame(GamesInstance instance) {
gameCount ++;
perGameCount.put(instance.getLanguageCode(), perGameCount.containsKey(instance.getLanguageCode())
? perGameCount.get(instance.getLanguageCode()) + 1 : 1);
}
public void save() {
File file = Constants.STATS_FILE;
totalTime += System.currentTimeMillis() - GamesROB.UP_SINCE;
if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
if (file.exists()) file.delete();
Closeable toClose = null;
try {
file.createNewFile();
FileWriter writer = new FileWriter(file);
toClose = writer;
writer.write(Constants.GSON.toJson(this));
Log.info("Saved statistics.");
} catch (Exception e) {
Log.exception("Saving statistics", e, this);
} finally {
if (toClose != null) Utility.quietlyClose(toClose);
}
}
public static Statistics get() {
return Cache.get("statistics", n -> {
File file = Constants.STATS_FILE;
if (file.exists()) {
Scanner scann = null;
try {
file.createNewFile();
scann = new Scanner(new FileInputStream(file));
StringBuilder str = new StringBuilder();
while (scann.hasNextLine()) str.append(scann.nextLine());
scann.close();
Statistics stats = Constants.GSON.fromJson(str.toString(), Statistics.class);
if (stats.getPerGameCount() == null) stats.setPerGameCount(new HashMap<>());
if (stats.getPerCommandCount() == null) stats.setPerCommandCount(new HashMap<>());
if (stats.getPerGameGameplayTime() == null) stats.setPerGameGameplayTime(new HashMap<>());
return stats;
} catch (Exception e) {
Log.exception("Loading statistics", e);
} finally {
if (scann != null) Utility.quietlyClose(scann);
}
return null;
} else return new Statistics(
0L, 0L, System.currentTimeMillis(), null, 0,
new HashMap<>(), 0, 0L, 0L, 0L, 0L, new HashMap<>(),
new HashMap<>(), 0.0, 0.0, 0, 0
);
}, object -> ((Statistics) object).save());
}
}
| UTF-8 | Java | 4,819 | java | Statistics.java | Java | [
{
"context": "package me.deprilula28.gamesrob.data;\n\nimport me.deprilula28.gamesrob.Ga",
"end": 22,
"score": 0.6676022410392761,
"start": 13,
"tag": "USERNAME",
"value": "prilula28"
},
{
"context": "ackage me.deprilula28.gamesrob.data;\n\nimport me.deprilula28.gamesrob.GamesROB;\nimport lombok.AllArgsConstruct",
"end": 60,
"score": 0.7138664722442627,
"start": 51,
"tag": "USERNAME",
"value": "prilula28"
},
{
"context": "lArgsConstructor;\nimport lombok.Data;\nimport me.deprilula28.gamesrob.baseFramework.GamesInstance;\nimport me.",
"end": 154,
"score": 0.6352863311767578,
"start": 146,
"tag": "USERNAME",
"value": "prilula2"
},
{
"context": "prilula28.gamesrob.utility.Cache;\nimport me.deprilula28.gamesrobshardcluster.utilities.Constants;\nimpor",
"end": 259,
"score": 0.5841205716133118,
"start": 256,
"tag": "USERNAME",
"value": "ula"
},
{
"context": "srobshardcluster.utilities.Constants;\nimport me.deprilula28.gamesrobshardcluster.utilities.Log;\nimport me.dep",
"end": 325,
"score": 0.6785215735435486,
"start": 316,
"tag": "USERNAME",
"value": "prilula28"
},
{
"context": "8.gamesrobshardcluster.utilities.Log;\nimport me.deprilula28.gamesrob.utility.Utility;\nimport me.deprilula28.j",
"end": 383,
"score": 0.6121150255203247,
"start": 374,
"tag": "USERNAME",
"value": "prilula28"
}
]
| null | []
| package me.deprilula28.gamesrob.data;
import me.deprilula28.gamesrob.GamesROB;
import lombok.AllArgsConstructor;
import lombok.Data;
import me.deprilula28.gamesrob.baseFramework.GamesInstance;
import me.deprilula28.gamesrob.utility.Cache;
import me.deprilula28.gamesrobshardcluster.utilities.Constants;
import me.deprilula28.gamesrobshardcluster.utilities.Log;
import me.deprilula28.gamesrob.utility.Utility;
import me.deprilula28.jdacmdframework.CommandContext;
import net.dv8tion.jda.core.entities.Message;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Consumer;
@Data
@AllArgsConstructor
public class Statistics {
private long gameCount;
private long totalTime;
private long firstBoot;
private String lastUpdateLogSent;
private long lastUpdateLogSentTime;
private Map<String, Integer> perGameCount;
private long commandCount;
private long upvotes;
private long monthUpvotes;
private long gameplayTime;
private long totConnections;
private Map<String, Long> perGameGameplayTime;
private Map<String, Integer> perCommandCount;
private double totalImageCommandGenTime;
private double totalImageCommandPostTime;
private long totalImageCommandBytes;
private long imageCommands;
public Consumer<Message> registerImageProcessor(long generateTimeNano, int byteAmount) {
imageCommands ++;
totalImageCommandBytes += byteAmount;
totalImageCommandGenTime += generateTimeNano / 1000000.0;
long postBegin = System.nanoTime();
return message -> totalImageCommandPostTime += (double) (System.nanoTime() - postBegin) / 1000000.0;
}
public void registerCommand(CommandContext context) {
String name = context.getCurrentCommand().getName();
perCommandCount.put(name, perCommandCount.containsKey(name) ? perCommandCount.get(name) + 1 : 1);
}
public void registerGameTime(long time, GamesInstance instance) {
gameplayTime += time;
perGameGameplayTime.put(instance.getLanguageCode(), perGameGameplayTime.containsKey(instance.getLanguageCode())
? perGameGameplayTime.get(instance.getLanguageCode()) + time : time);
}
public void registerGame(GamesInstance instance) {
gameCount ++;
perGameCount.put(instance.getLanguageCode(), perGameCount.containsKey(instance.getLanguageCode())
? perGameCount.get(instance.getLanguageCode()) + 1 : 1);
}
public void save() {
File file = Constants.STATS_FILE;
totalTime += System.currentTimeMillis() - GamesROB.UP_SINCE;
if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
if (file.exists()) file.delete();
Closeable toClose = null;
try {
file.createNewFile();
FileWriter writer = new FileWriter(file);
toClose = writer;
writer.write(Constants.GSON.toJson(this));
Log.info("Saved statistics.");
} catch (Exception e) {
Log.exception("Saving statistics", e, this);
} finally {
if (toClose != null) Utility.quietlyClose(toClose);
}
}
public static Statistics get() {
return Cache.get("statistics", n -> {
File file = Constants.STATS_FILE;
if (file.exists()) {
Scanner scann = null;
try {
file.createNewFile();
scann = new Scanner(new FileInputStream(file));
StringBuilder str = new StringBuilder();
while (scann.hasNextLine()) str.append(scann.nextLine());
scann.close();
Statistics stats = Constants.GSON.fromJson(str.toString(), Statistics.class);
if (stats.getPerGameCount() == null) stats.setPerGameCount(new HashMap<>());
if (stats.getPerCommandCount() == null) stats.setPerCommandCount(new HashMap<>());
if (stats.getPerGameGameplayTime() == null) stats.setPerGameGameplayTime(new HashMap<>());
return stats;
} catch (Exception e) {
Log.exception("Loading statistics", e);
} finally {
if (scann != null) Utility.quietlyClose(scann);
}
return null;
} else return new Statistics(
0L, 0L, System.currentTimeMillis(), null, 0,
new HashMap<>(), 0, 0L, 0L, 0L, 0L, new HashMap<>(),
new HashMap<>(), 0.0, 0.0, 0, 0
);
}, object -> ((Statistics) object).save());
}
}
| 4,819 | 0.641419 | 0.630836 | 124 | 37.862904 | 28.045567 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.854839 | false | false | 9 |
5dd914a1ff062f142ec3c609b7c0f573b2e2d4a6 | 1,030,792,219,981 | 5085fe26fff67a73b18092eb4d3441f72120e00b | /app/src/main/java/com/android/messagebusexample/lib/MessageDataConstants.java | f74d119226014c9aba09b6d169f10ebaa99dd8b2 | []
| no_license | vishaljec/MessageBus | https://github.com/vishaljec/MessageBus | 2870366a465f23308a2ea15399cd2cfd1f523068 | 4bc04d5d1ae7b5f68451f1d99a4a0a4d7a712bf2 | refs/heads/master | 2022-11-06T04:51:36.019000 | 2020-06-23T09:50:47 | 2020-06-23T09:50:47 | 269,274,636 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.android.messagebusexample.lib;
public final class MessageDataConstants {
public static final String NO_CONNECTIVITY = "noConnectivity";
private MessageDataConstants() {
//Do nothing
}
}
| UTF-8 | Java | 221 | java | MessageDataConstants.java | Java | []
| null | []
| package com.android.messagebusexample.lib;
public final class MessageDataConstants {
public static final String NO_CONNECTIVITY = "noConnectivity";
private MessageDataConstants() {
//Do nothing
}
}
| 221 | 0.723982 | 0.723982 | 10 | 21.1 | 22.51866 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 9 |
56076c0bc99f77d350bed748da43d7f37b65ee8a | 37,271,726,196,025 | 78f1235efe79bf54a458b22508d9070b98fb761b | /design_patterns/src/com/ccy/proxy/DynamicProxyTest.java | c76ffa236a6bb510256dd05c586145cb9c2ac12a | []
| no_license | CCanyong/study | https://github.com/CCanyong/study | 805432cb59e20bd021d504c41c42530729ebd3c4 | bf75ec56f566aa39032e65bdebfdf79d00bce968 | refs/heads/master | 2022-12-07T02:32:00.778000 | 2020-09-03T06:15:53 | 2020-09-03T06:15:53 | 254,859,026 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ccy.proxy;
import java.lang.reflect.Proxy;
public class DynamicProxyTest {
public static void main(String[] args) {
Student student = new Student();
DynamicProxy dynamicProxy = new DynamicProxy(student);
Person person = (Person) Proxy.newProxyInstance(student.getClass().getClassLoader(),
student.getClass().getInterfaces(), dynamicProxy);
person.say();
}
}
| UTF-8 | Java | 430 | java | DynamicProxyTest.java | Java | []
| null | []
| package com.ccy.proxy;
import java.lang.reflect.Proxy;
public class DynamicProxyTest {
public static void main(String[] args) {
Student student = new Student();
DynamicProxy dynamicProxy = new DynamicProxy(student);
Person person = (Person) Proxy.newProxyInstance(student.getClass().getClassLoader(),
student.getClass().getInterfaces(), dynamicProxy);
person.say();
}
}
| 430 | 0.669767 | 0.669767 | 15 | 27.666666 | 27.798481 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false | 9 |
f08208e1029d0ba63407bd4ed994fde52107fca0 | 25,795,573,621,897 | af8f23765d1e6af3b88191a2129bb2d3909e9fbd | /src/org/bukkit/plugin/java/annotation/permission/ChildPermission.java | f2e2f1cfa7749eaf5b8ea513973f72cace2f197f | [
"BSD-3-Clause"
]
| permissive | Lakasabasz/Plugin-Annotation | https://github.com/Lakasabasz/Plugin-Annotation | f6919ed45a6dd015e399190b3e68e5db49bde4d2 | c1acd6a9ca0e02026a7f88344d3176de8578435a | refs/heads/main | 2023-03-08T00:13:49.863000 | 2021-02-18T16:54:41 | 2021-02-18T16:54:41 | 325,280,058 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.bukkit.plugin.java.annotation.permission;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ChildPermission {
boolean inherit() default true;
String name();
} | UTF-8 | Java | 420 | java | ChildPermission.java | Java | []
| null | []
| package org.bukkit.plugin.java.annotation.permission;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ChildPermission {
boolean inherit() default true;
String name();
} | 420 | 0.819048 | 0.819048 | 16 | 25.3125 | 17.380732 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 9 |
68d0bc5522bc318bef69783f3346e896a2d820ea | 28,621,662,062,376 | 47def904d7ed574278855bc779ff10911f1a85b4 | /src/main/java/com/progforce/BI_Interface/service/MailSenderService.java | 9eea3979bf4a43c12316c2f62bceb925797cb098 | []
| no_license | ElizavetaVinogradova/BI_Interface | https://github.com/ElizavetaVinogradova/BI_Interface | 457275fbe0f3ae00f2b32433934996a40738b4b1 | ba21c899b8d35a0d79580b2332bc2086838d0d4a | refs/heads/master | 2020-08-07T09:28:01.551000 | 2019-10-24T09:12:59 | 2019-10-24T09:12:59 | 213,391,912 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.progforce.BI_Interface.service;
import com.progforce.BI_Interface.config.EmailConfiguration;
import com.progforce.BI_Interface.domain.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class MailSenderService {
@Autowired
private JavaMailSender mailSender;
@Autowired
EmailConfiguration emailConfig;
@Autowired
public MailSenderService(JavaMailSender mailSender) {
this.mailSender = mailSender;
}
public void send(Message message){
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("BI_Interface");
mailMessage.setTo(emailConfig.getUsername());
mailMessage.setSubject("Export data process");
mailMessage.setText(message.toString());
mailSender.send(mailMessage);
}
}
| UTF-8 | Java | 997 | java | MailSenderService.java | Java | []
| null | []
| package com.progforce.BI_Interface.service;
import com.progforce.BI_Interface.config.EmailConfiguration;
import com.progforce.BI_Interface.domain.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class MailSenderService {
@Autowired
private JavaMailSender mailSender;
@Autowired
EmailConfiguration emailConfig;
@Autowired
public MailSenderService(JavaMailSender mailSender) {
this.mailSender = mailSender;
}
public void send(Message message){
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("BI_Interface");
mailMessage.setTo(emailConfig.getUsername());
mailMessage.setSubject("Export data process");
mailMessage.setText(message.toString());
mailSender.send(mailMessage);
}
}
| 997 | 0.757272 | 0.757272 | 33 | 29.212122 | 22.812487 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.484848 | false | false | 9 |
535c906518e426f21a73278b662f189e307feb6a | 22,505,628,682,939 | 05499a2b418fff2af68f6a53ecc68e8cd0e30920 | /LeapYear.java | b84ecaaca97ed4509a342ef027d31a227bfb6988 | []
| no_license | Nilkamal-m/java_practice_code | https://github.com/Nilkamal-m/java_practice_code | 06d4e1d2bd9f006a3429b475893706d321a802a0 | 1231a2b3dc599ec6b8a368c3b0b85b1f58159886 | refs/heads/master | 2023-07-17T10:18:38.121000 | 2021-09-09T17:02:21 | 2021-09-09T17:02:21 | 404,804,569 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
import java.lang.*;
public class LeapYear{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter the year ");
int year=scan.nextInt();
boolean isLeapYear=false;
if(year%400==0){
isLeapYear=true;
}
System.out.println(isLeapYear);
}
} | UTF-8 | Java | 328 | java | LeapYear.java | Java | []
| null | []
| import java.util.*;
import java.lang.*;
public class LeapYear{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter the year ");
int year=scan.nextInt();
boolean isLeapYear=false;
if(year%400==0){
isLeapYear=true;
}
System.out.println(isLeapYear);
}
} | 328 | 0.682927 | 0.670732 | 17 | 18.352942 | 14.303192 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.764706 | false | false | 9 |
13236f3b8be324857e28c3067b984a28ea968e97 | 34,832,184,776,112 | f4aec9162837f3d96ef98c15c0011f172a6147ff | /be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java | 244ff357175eb97400048f94e747b6eabb942355 | []
| no_license | 98rostom/BE-GRAPHES | https://github.com/98rostom/BE-GRAPHES | 61f0fefb202464eda639431ed6aaae8f66eb160f | b1969149511da2e0d605b352e04a0fae25a23982 | refs/heads/master | 2023-04-28T13:12:03.888000 | 2021-10-17T00:40:05 | 2021-10-17T00:40:05 | 351,597,834 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.insa.graphs.algorithm.shortestpath;
import org.insa.graphs.model.*;//pour reconnaître la classe arc (et autres)
public class Label implements Comparable<Label>{//pour la fonction compareTo
//le label de chaque noeud pourra nous donner toutes les infos dont on a besoin
//lors de l'écriture de l'algo de Dijkstra
//instances
private Node sommet_courant;
private boolean marque;
private double coût;
private Arc père; //il vaut mieux stocker l'arc que le sommet d'après le sujet
//constructeur
public Label (Node sommet_courant) { //pas besoin de spécifier les autres attributs, on connait déjà leur init
this.sommet_courant=sommet_courant;
this.marque=false; //init: le sommet n'est pas marqué quand il est créé
this.coût= Double.POSITIVE_INFINITY; //init: le coût initial d'un sommet est l'infini
this.père=null; //init: un sommet n'a initialement pas de père
}
//getters et setters générés automatiquement avec eclipse
public Node getSommet_courant() {
return this.sommet_courant;
}
public void setSommet_courant(Node sommet_courant) {
this.sommet_courant = sommet_courant;
}
public boolean getMarque() {
return this.marque;
}
public void setMarque_true() {
this.marque = true;
}
public double getCost() {
return this.coût;
}
public void setCost(double coût) {
this.coût = coût;
}
public Arc getPère() {
return this.père;
}
public void setPère(Arc père) {
this.père = père;
}
public double getTotalCost() {
return this.getCost();
}
@Override
public int compareTo(Label autre_label) {
return Double.compare(this.getTotalCost(), autre_label.getTotalCost());
}
}
| UTF-8 | Java | 1,697 | java | Label.java | Java | []
| null | []
| package org.insa.graphs.algorithm.shortestpath;
import org.insa.graphs.model.*;//pour reconnaître la classe arc (et autres)
public class Label implements Comparable<Label>{//pour la fonction compareTo
//le label de chaque noeud pourra nous donner toutes les infos dont on a besoin
//lors de l'écriture de l'algo de Dijkstra
//instances
private Node sommet_courant;
private boolean marque;
private double coût;
private Arc père; //il vaut mieux stocker l'arc que le sommet d'après le sujet
//constructeur
public Label (Node sommet_courant) { //pas besoin de spécifier les autres attributs, on connait déjà leur init
this.sommet_courant=sommet_courant;
this.marque=false; //init: le sommet n'est pas marqué quand il est créé
this.coût= Double.POSITIVE_INFINITY; //init: le coût initial d'un sommet est l'infini
this.père=null; //init: un sommet n'a initialement pas de père
}
//getters et setters générés automatiquement avec eclipse
public Node getSommet_courant() {
return this.sommet_courant;
}
public void setSommet_courant(Node sommet_courant) {
this.sommet_courant = sommet_courant;
}
public boolean getMarque() {
return this.marque;
}
public void setMarque_true() {
this.marque = true;
}
public double getCost() {
return this.coût;
}
public void setCost(double coût) {
this.coût = coût;
}
public Arc getPère() {
return this.père;
}
public void setPère(Arc père) {
this.père = père;
}
public double getTotalCost() {
return this.getCost();
}
@Override
public int compareTo(Label autre_label) {
return Double.compare(this.getTotalCost(), autre_label.getTotalCost());
}
}
| 1,697 | 0.723188 | 0.723188 | 68 | 23.544117 | 27.269049 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.235294 | false | false | 9 |
bc8bbfd3676a52cb8135e14c4a9c187d2281dec2 | 34,961,033,800,395 | bc41d4b5092e20a13d7f96f9a9d2a6a15ab6c9fb | /src/main/java/com/any/event/controller/EventController.java | eee93ce65338f2179fedebf3c86da25ba765b88b | []
| no_license | Lionhead93/event-kr | https://github.com/Lionhead93/event-kr | 8a7d5226e526120cd4fad9ebd52451ac96af34c3 | 869a1d431b1396ee4b88f3ba82326a608e3e1d82 | refs/heads/master | 2023-01-09T16:25:46.491000 | 2022-12-29T01:27:13 | 2022-12-29T01:27:13 | 228,572,329 | 1 | 0 | null | false | 2022-12-29T01:28:20 | 2019-12-17T08:45:16 | 2022-12-29T01:27:18 | 2022-12-29T01:28:18 | 4,424 | 1 | 0 | 0 | Java | false | false | package com.any.event.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class EventController {
@GetMapping("/api/hello")
public String hello() {
return "this is msg from controller";
}
}
| UTF-8 | Java | 320 | java | EventController.java | Java | []
| null | []
| package com.any.event.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class EventController {
@GetMapping("/api/hello")
public String hello() {
return "this is msg from controller";
}
}
| 320 | 0.74375 | 0.74375 | 15 | 20.333334 | 21.356237 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.266667 | false | false | 9 |
92e1b65d4896d0fb3fd7f1b5641120239835716f | 12,017,318,544,559 | 3cd49ab4b2da1b5b532dab926e76d0b8e1bd6622 | /hw01-0036514918/src/main/java/hr/fer/oprpp1/hw01/ComplexNumber.java | 7666510e1dfd9b525716a024beb20a290a93f6ab | []
| no_license | svenalmer/java-homeworks | https://github.com/svenalmer/java-homeworks | d2ccce4e38cc4faa55460588f2ea2e2dc250838c | 7bd1c4ee83749e4d4e580addee848c0b78e32a97 | refs/heads/master | 2023-05-05T22:19:33.295000 | 2021-05-22T10:39:31 | 2021-05-22T10:39:31 | 369,777,706 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hr.fer.oprpp1.hw01;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// TODO: Auto-generated Javadoc
/**
* The Class representing a complex number, allowing the user to perform various operations.
*/
public class ComplexNumber {
private double real;
private double imaginary;
/**
* Instantiates a new complex number.
*
* @param real value of the real component
* @param imaginary value of the imaginary component
*/
public ComplexNumber(double real, double imaginary) {
this.real = real;
this.imaginary = imaginary;
}
/**
* Returns a new instance of <code>ComplexNumber</code> with the given real value and imaginary value of 0.
*
* @param real the real value
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromReal(double real) {
return new ComplexNumber(real, 0);
}
/**
* Returns a new instance of <code>ComplexNumber</code> with the given imaginary value and real value of 0.
*
* @param imaginary the imaginary value
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromImaginary(double imaginary) {
return new ComplexNumber(0, imaginary);
}
/**
* Returns a new instance of <code>ComplexNumber</code> created from the given polar coordinates.
*
* @param magnitude the magnitude
* @param angle the angle
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromMagnitudeAndAngle(double magnitude, double angle) {
return new ComplexNumber(magnitude * Math.cos(angle), magnitude * Math.sin(angle));
}
/**
* Parses the given string and returns a new instance of <code>ComplexNumber</code>.
* Allowed formats are: "±a±bi", "±a", "±bi" (leading pluses are allowed, but not mandatory).
*
* @param s the string
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber parse(String s) {
double newReal = 0;
double newImaginary = 0;
String format1 = "[+-]?\\d+\\.?\\d*[+-]\\d+\\.?\\d*i";
String format2 = "[+-]?\\d+\\.?\\d*i";
String format3 = "[+-]?\\d+\\.?\\d*";
String format4 = "[+-]?i";
Pattern p1 = Pattern.compile(format1);
Matcher m1 = p1.matcher(s);
if (m1.find()) {
int i;
for (i = 1; i < s.length(); i++) {
if (s.charAt(i) == '+' || s.charAt(i) == '-') {
break;
}
}
newReal = Double.parseDouble(s.substring(0, i));
newImaginary = Double.parseDouble(s.substring(i, s.length() - 1));
return new ComplexNumber(newReal, newImaginary);
}
Pattern p2 = Pattern.compile(format2);
Matcher m2 = p2.matcher(s);
if (m2.find()) {
String s1 = s.substring(0, s.length() - 1);
newImaginary = Double.parseDouble(s1);
return fromImaginary(newImaginary);
}
Pattern p3 = Pattern.compile(format3);
Matcher m3 = p3.matcher(s);
if (m3.find()) {
newReal = Double.parseDouble(s);
return fromReal(newReal);
}
Pattern p4 = Pattern.compile(format4);
Matcher m4 = p4.matcher(s);
if (m4.find()) {
if (s.charAt(0) == '-') {
return fromImaginary(-1);
} else {
return fromImaginary(1);
}
}
throw new IllegalArgumentException("Invalid complex number format!");
}
/**
* Returns the real value.
*
* @return the real value
*/
public double getReal() {
return real;
}
/**
* Returns the imaginary value
*
* @return the imaginary value
*/
public double getImaginary() {
return imaginary;
}
/**
* Calculates the magnitude of the complex number.
*
* @return the magnitude
*/
public double getMagnitude() {
return Math.sqrt(Math.pow(this.real, 2) + Math.pow(this.imaginary, 2));
}
/**
* Calculates the angle of the complex number.
*
* @return the angle
*/
public double getAngle() {
double angle = Math.atan2(this.imaginary, this.real);
if (angle < 0) angle += 2 * Math.PI;
return angle;
}
/**
* Adds two complex numbers and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber add(ComplexNumber c) {
return new ComplexNumber(this.real + c.real, this.imaginary + c.imaginary);
}
/**
* Subtracts c from the <code>ComplexNumber</code> and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber sub(ComplexNumber c) {
return new ComplexNumber(this.real - c.real, this.imaginary - c.imaginary);
}
/**
* Multiplies two complex numbers and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber mul(ComplexNumber c) {
double newReal = this.real * c.real - this.imaginary * c.imaginary;
double newImaginary = this.real * c.imaginary + this.imaginary * c.real;
return new ComplexNumber(newReal, newImaginary);
}
/**
* Divides the <code>ComplexNumber</code> by the operand c and return the result as a new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber div(ComplexNumber c) {
double newRadius = this.getMagnitude() / c.getMagnitude();
double newReal = newRadius * Math.cos(this.getAngle() - c.getAngle());
double newImaginary = newRadius * Math.sin(this.getAngle() - c.getAngle());
return new ComplexNumber(newReal, newImaginary);
}
/**
* Raises the <code>ComplexNumber</code> to the power n and returns the result as a new instance of <code>ComplexNumber</code>.
*
* @param n the n
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber power(int n) {
double newReal = Math.pow(getMagnitude(), n) * Math.cos(getAngle() * n);
double newImaginary = Math.pow(getMagnitude(), n) * Math.sin(getAngle() * n);
return new ComplexNumber(newReal, newImaginary);
}
/**
* Calculates the n-th roots of the <code>ComplexNumber</code> and fills a new array with the results.
*
* @param n the n
* @return new array of <code>ComplexNumber</code>
*/
public ComplexNumber[] root(int n) {
ComplexNumber[] result = new ComplexNumber[n];
double arg;
double newReal;
double newImaginary;
for (int i = 0; i < n; i++) {
arg = (getAngle() + 2 * i * Math.PI) / n;
newReal = Math.pow(getMagnitude(), (double)1/n) * Math.cos(arg);
newImaginary = Math.pow(getMagnitude(), (double)1/n) * Math.sin(arg);
result[i] = new ComplexNumber(newReal, newImaginary);
}
return result;
}
/**
* Transforms the <code>ComplexNumber</code> into a new string.
*
* @return the string
*/
public String toString() {
StringBuilder sb = new StringBuilder();
if (real != 0) {
sb.append(real);
if (imaginary > 0) sb.append("+" + imaginary + "i");
else if (imaginary < 0) sb.append(imaginary + "i");
} else {
if (imaginary != 0 && imaginary != 1 && imaginary != -1) sb.append(imaginary + "i");
else if (imaginary == -1) sb.append("-i");
else if (imaginary == 1) sb.append("i");
else sb.append(0);
}
return sb.toString();
}
}
| UTF-8 | Java | 7,243 | java | ComplexNumber.java | Java | []
| null | []
| package hr.fer.oprpp1.hw01;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// TODO: Auto-generated Javadoc
/**
* The Class representing a complex number, allowing the user to perform various operations.
*/
public class ComplexNumber {
private double real;
private double imaginary;
/**
* Instantiates a new complex number.
*
* @param real value of the real component
* @param imaginary value of the imaginary component
*/
public ComplexNumber(double real, double imaginary) {
this.real = real;
this.imaginary = imaginary;
}
/**
* Returns a new instance of <code>ComplexNumber</code> with the given real value and imaginary value of 0.
*
* @param real the real value
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromReal(double real) {
return new ComplexNumber(real, 0);
}
/**
* Returns a new instance of <code>ComplexNumber</code> with the given imaginary value and real value of 0.
*
* @param imaginary the imaginary value
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromImaginary(double imaginary) {
return new ComplexNumber(0, imaginary);
}
/**
* Returns a new instance of <code>ComplexNumber</code> created from the given polar coordinates.
*
* @param magnitude the magnitude
* @param angle the angle
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber fromMagnitudeAndAngle(double magnitude, double angle) {
return new ComplexNumber(magnitude * Math.cos(angle), magnitude * Math.sin(angle));
}
/**
* Parses the given string and returns a new instance of <code>ComplexNumber</code>.
* Allowed formats are: "±a±bi", "±a", "±bi" (leading pluses are allowed, but not mandatory).
*
* @param s the string
* @return new instance of <code>ComplexNumber</code>
*/
public static ComplexNumber parse(String s) {
double newReal = 0;
double newImaginary = 0;
String format1 = "[+-]?\\d+\\.?\\d*[+-]\\d+\\.?\\d*i";
String format2 = "[+-]?\\d+\\.?\\d*i";
String format3 = "[+-]?\\d+\\.?\\d*";
String format4 = "[+-]?i";
Pattern p1 = Pattern.compile(format1);
Matcher m1 = p1.matcher(s);
if (m1.find()) {
int i;
for (i = 1; i < s.length(); i++) {
if (s.charAt(i) == '+' || s.charAt(i) == '-') {
break;
}
}
newReal = Double.parseDouble(s.substring(0, i));
newImaginary = Double.parseDouble(s.substring(i, s.length() - 1));
return new ComplexNumber(newReal, newImaginary);
}
Pattern p2 = Pattern.compile(format2);
Matcher m2 = p2.matcher(s);
if (m2.find()) {
String s1 = s.substring(0, s.length() - 1);
newImaginary = Double.parseDouble(s1);
return fromImaginary(newImaginary);
}
Pattern p3 = Pattern.compile(format3);
Matcher m3 = p3.matcher(s);
if (m3.find()) {
newReal = Double.parseDouble(s);
return fromReal(newReal);
}
Pattern p4 = Pattern.compile(format4);
Matcher m4 = p4.matcher(s);
if (m4.find()) {
if (s.charAt(0) == '-') {
return fromImaginary(-1);
} else {
return fromImaginary(1);
}
}
throw new IllegalArgumentException("Invalid complex number format!");
}
/**
* Returns the real value.
*
* @return the real value
*/
public double getReal() {
return real;
}
/**
* Returns the imaginary value
*
* @return the imaginary value
*/
public double getImaginary() {
return imaginary;
}
/**
* Calculates the magnitude of the complex number.
*
* @return the magnitude
*/
public double getMagnitude() {
return Math.sqrt(Math.pow(this.real, 2) + Math.pow(this.imaginary, 2));
}
/**
* Calculates the angle of the complex number.
*
* @return the angle
*/
public double getAngle() {
double angle = Math.atan2(this.imaginary, this.real);
if (angle < 0) angle += 2 * Math.PI;
return angle;
}
/**
* Adds two complex numbers and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber add(ComplexNumber c) {
return new ComplexNumber(this.real + c.real, this.imaginary + c.imaginary);
}
/**
* Subtracts c from the <code>ComplexNumber</code> and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber sub(ComplexNumber c) {
return new ComplexNumber(this.real - c.real, this.imaginary - c.imaginary);
}
/**
* Multiplies two complex numbers and returns a the new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber mul(ComplexNumber c) {
double newReal = this.real * c.real - this.imaginary * c.imaginary;
double newImaginary = this.real * c.imaginary + this.imaginary * c.real;
return new ComplexNumber(newReal, newImaginary);
}
/**
* Divides the <code>ComplexNumber</code> by the operand c and return the result as a new instance of <code>ComplexNumber</code>.
*
* @param c the other operand
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber div(ComplexNumber c) {
double newRadius = this.getMagnitude() / c.getMagnitude();
double newReal = newRadius * Math.cos(this.getAngle() - c.getAngle());
double newImaginary = newRadius * Math.sin(this.getAngle() - c.getAngle());
return new ComplexNumber(newReal, newImaginary);
}
/**
* Raises the <code>ComplexNumber</code> to the power n and returns the result as a new instance of <code>ComplexNumber</code>.
*
* @param n the n
* @return new instance of <code>ComplexNumber</code>
*/
public ComplexNumber power(int n) {
double newReal = Math.pow(getMagnitude(), n) * Math.cos(getAngle() * n);
double newImaginary = Math.pow(getMagnitude(), n) * Math.sin(getAngle() * n);
return new ComplexNumber(newReal, newImaginary);
}
/**
* Calculates the n-th roots of the <code>ComplexNumber</code> and fills a new array with the results.
*
* @param n the n
* @return new array of <code>ComplexNumber</code>
*/
public ComplexNumber[] root(int n) {
ComplexNumber[] result = new ComplexNumber[n];
double arg;
double newReal;
double newImaginary;
for (int i = 0; i < n; i++) {
arg = (getAngle() + 2 * i * Math.PI) / n;
newReal = Math.pow(getMagnitude(), (double)1/n) * Math.cos(arg);
newImaginary = Math.pow(getMagnitude(), (double)1/n) * Math.sin(arg);
result[i] = new ComplexNumber(newReal, newImaginary);
}
return result;
}
/**
* Transforms the <code>ComplexNumber</code> into a new string.
*
* @return the string
*/
public String toString() {
StringBuilder sb = new StringBuilder();
if (real != 0) {
sb.append(real);
if (imaginary > 0) sb.append("+" + imaginary + "i");
else if (imaginary < 0) sb.append(imaginary + "i");
} else {
if (imaginary != 0 && imaginary != 1 && imaginary != -1) sb.append(imaginary + "i");
else if (imaginary == -1) sb.append("-i");
else if (imaginary == 1) sb.append("i");
else sb.append(0);
}
return sb.toString();
}
}
| 7,243 | 0.659069 | 0.650642 | 259 | 26.949806 | 28.292347 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.907336 | false | false | 9 |
9b61b5136ce325638718b1cdec04cbf2af4ab25c | 30,013,231,490,843 | 43c55df055b59d7c426ed6e390633946e0afe805 | /lcm (1).java | d72116750d3da8a25632b6ba20a66b323483b16c | []
| no_license | Janani110798/java-program | https://github.com/Janani110798/java-program | 44c7c236a3dcc5b1e0a019673a8761a1c7b9e55a | 53c343eb1606c418f1b7bbee875280d1fa9717e0 | refs/heads/master | 2020-05-25T20:13:50.047000 | 2019-05-22T10:33:51 | 2019-05-22T10:33:51 | 187,970,620 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.*;
import java.util.*;
class lcm{
public static void main (String args[]){
int n1=24,n2=12,lcm;
lcm=(n1>n2)?n1:n2;
while(true){
if(lcm%n1==0 && lcm%n2==0){
System.out.printf("lcm of %d and %d is %d.",n1,n2,lcm);
break;
}
++lcm;
}
}
}
| UTF-8 | Java | 270 | java | lcm (1).java | Java | []
| null | []
| import java.io.*;
import java.util.*;
class lcm{
public static void main (String args[]){
int n1=24,n2=12,lcm;
lcm=(n1>n2)?n1:n2;
while(true){
if(lcm%n1==0 && lcm%n2==0){
System.out.printf("lcm of %d and %d is %d.",n1,n2,lcm);
break;
}
++lcm;
}
}
}
| 270 | 0.574074 | 0.514815 | 15 | 15.6 | 15.050138 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 9 |
3924cd3a5093afccab38a832dc605521dbd54c8b | 3,169,685,932,296 | 56beda9aa2961e9010ce32306cc1da39c2126399 | /src/main/java/com/fibermc/essentialcommands/commands/BackCommand.java | f4c75b1786ec5661b302e4202d071012beb361a4 | [
"MIT"
]
| permissive | John-Paul-R/Essential-Commands | https://github.com/John-Paul-R/Essential-Commands | 77f97544b4a60fc6bc30a68e05408e652b7252ad | 0d9740214a333c1a3a75103be9d992e833c329af | refs/heads/1.20.x | 2023-08-23T05:27:53.884000 | 2023-08-03T21:24:59 | 2023-08-03T21:24:59 | 196,686,025 | 90 | 43 | MIT | false | 2023-09-14T00:20:08 | 2019-07-13T06:18:08 | 2023-08-30T11:17:07 | 2023-09-14T00:20:07 | 1,375 | 86 | 26 | 50 | Java | false | false | package com.fibermc.essentialcommands.commands;
import com.fibermc.essentialcommands.access.ServerPlayerEntityAccess;
import com.fibermc.essentialcommands.playerdata.PlayerData;
import com.fibermc.essentialcommands.teleportation.PlayerTeleporter;
import com.fibermc.essentialcommands.text.ECText;
import com.fibermc.essentialcommands.types.MinecraftLocation;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
public class BackCommand implements Command<ServerCommandSource> {
public BackCommand() {}
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
//Store command sender
ServerPlayerEntity player = context.getSource().getPlayerOrThrow();
PlayerData playerData = ((ServerPlayerEntityAccess) player).ec$getPlayerData();
//Get previous location
MinecraftLocation loc = playerData.getPreviousLocation();
//chat message
if (loc == null) {
playerData.sendCommandError("cmd.back.error.no_prev_location");
return 0;
}
//Teleport player to home location
var prevLocationName = ECText.access(player).getText("cmd.back.location_name");
PlayerTeleporter.requestTeleport(playerData, loc, prevLocationName);
return 1;
}
}
| UTF-8 | Java | 1,524 | java | BackCommand.java | Java | []
| null | []
| package com.fibermc.essentialcommands.commands;
import com.fibermc.essentialcommands.access.ServerPlayerEntityAccess;
import com.fibermc.essentialcommands.playerdata.PlayerData;
import com.fibermc.essentialcommands.teleportation.PlayerTeleporter;
import com.fibermc.essentialcommands.text.ECText;
import com.fibermc.essentialcommands.types.MinecraftLocation;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
public class BackCommand implements Command<ServerCommandSource> {
public BackCommand() {}
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
//Store command sender
ServerPlayerEntity player = context.getSource().getPlayerOrThrow();
PlayerData playerData = ((ServerPlayerEntityAccess) player).ec$getPlayerData();
//Get previous location
MinecraftLocation loc = playerData.getPreviousLocation();
//chat message
if (loc == null) {
playerData.sendCommandError("cmd.back.error.no_prev_location");
return 0;
}
//Teleport player to home location
var prevLocationName = ECText.access(player).getText("cmd.back.location_name");
PlayerTeleporter.requestTeleport(playerData, loc, prevLocationName);
return 1;
}
}
| 1,524 | 0.75853 | 0.757218 | 41 | 36.170731 | 30.342678 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.512195 | false | false | 9 |
d6738a6a9f3468bab3efc287b70d9593c6731055 | 6,863,357,795,975 | 915d2ac6d2ff246ece0657ac6f777a1851fbd110 | /src/main/java/com/ufobuilders/branchlet/git/GitRepository.java | 2b852140ef7919b69fb38314ca2abdd482582afa | []
| no_license | ufobuilders/branchlet | https://github.com/ufobuilders/branchlet | e19893bf96cfbd10b28770b97749f2cf31cb4f5d | 877ea548676e1b1bc54e26c71ce7d52bcf6a655f | refs/heads/master | 2016-08-04T03:29:57.754000 | 2014-02-11T09:55:40 | 2014-02-11T09:55:40 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ufobuilders.branchlet.git;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
public class GitRepository {
private Repository repository;
public GitRepository(Repository repository) {
this.repository = repository;
}
public List<String> getBranchList() throws GitAPIException {
List<String> nameList = new ArrayList<String>();
List<Ref> call = new Git(this.repository).branchList().call();
for (Ref ref : call) {
nameList.add(ref.getName());
}
return nameList;
}
public boolean isBranchValid(String branchName) {
return false;
}
}
| UTF-8 | Java | 735 | java | GitRepository.java | Java | []
| null | []
| package com.ufobuilders.branchlet.git;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
public class GitRepository {
private Repository repository;
public GitRepository(Repository repository) {
this.repository = repository;
}
public List<String> getBranchList() throws GitAPIException {
List<String> nameList = new ArrayList<String>();
List<Ref> call = new Git(this.repository).branchList().call();
for (Ref ref : call) {
nameList.add(ref.getName());
}
return nameList;
}
public boolean isBranchValid(String branchName) {
return false;
}
}
| 735 | 0.746939 | 0.746939 | 30 | 23.5 | 20.248045 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.1 | false | false | 9 |
0cce57e284fd0f47b4efb0d1d11338db45c595d4 | 11,149,735,133,393 | 52727fb7d9123f3ae5fa25284b65d25f736fa4ac | /VerwaltenDatenbankBuch.java | 51274df0878bb03aa806489647f5a8c38d07364f | []
| no_license | EDVBeratung-Zimmermann/CHMV | https://github.com/EDVBeratung-Zimmermann/CHMV | b5b0e591a02a88b231679325ad9adfb0539d6a31 | b896eb9e74350f48a42f8066d92accba4fe8c72f | refs/heads/master | 2023-03-16T06:15:51.290000 | 2023-03-04T10:24:45 | 2023-03-04T10:24:45 | 163,578,554 | 2 | 2 | null | false | 2019-10-14T15:43:03 | 2018-12-30T10:19:16 | 2019-10-13T17:55:32 | 2019-10-14T15:43:02 | 1,309 | 1 | 2 | 0 | Java | false | false | /*
*
* Das JAVA-Programm Miles-Verlag Verlagsverwaltung stellt alle notwendigen
* Funktionen für die Verwaltung des Carola Hartman Miles-Verlags bereit.
*
* Copyright (C) 2017 EDV-Beratung und Betrieb, Entwicklung von SOftware
* Dipl.Inform Thomas Zimmermann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package milesVerlagMain;
import java.awt.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.List;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.*;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.plaf.ActionMapUIResource;
import static milesVerlagMain.ModulMyOwnFocusTraversalPolicy.newPolicy;
import java.io.File;
import java.io.IOException;
/**
*
* @author Thomas Zimmermann
*/
public class VerwaltenDatenbankBuch extends javax.swing.JDialog {
/**
* Creates new form VerwaltenDatenbankBuch
*
* @param parent
* @param modal
*/
private void IconAddActionPerformed(ActionEvent event) {
// TODO add your code here
String Dateiname = "";
if (chooser.showDialog(null, "Datei mit dem Icon wählen") == JFileChooser.APPROVE_OPTION) {
try {
Dateiname = chooser.getSelectedFile().getCanonicalPath();
System.out.println("Cover-Datei");
System.out.println("-> " + ModulHelferlein.pathUserDir);
System.out.println("-> " + ModulHelferlein.pathBuchprojekte);
System.out.println("-> " + Dateiname);
field_Cover.setText(Dateiname);
} catch (IOException ex) {
ModulHelferlein.Fehlermeldung("Exception: " + ex.getMessage());
}
}
}
private void FlyerActionPerformed(ActionEvent event) {
try {
// TODO add your code here
String ISBN = result.getString("BUCH_ISBN");
briefFlyer.bericht(ISBN, "PDF");
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch "
+ " WHERE BUCH_ID > '0' "
+ " ORDER BY BUCH_ISBN");
result.first();
while (!ISBN.equals(result.getString("BUCH_ISBN"))) {
result.next();
}
field_Flyer.setText(result.getString("BUCH_FLYER"));
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Flyer erstellen", "SQL-Exception", ex.getMessage());
}
}
public VerwaltenDatenbankBuch(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
buttonGroupBuchtyp.add(rbPB);
buttonGroupBuchtyp.add(rbHC);
buttonGroupBuchtyp.add(rbKindle);
Vector<Component> order = new Vector<>(38);
order.add(field_Titel);
order.add(cbHerausgeber);
order.add(field_ISBN);
order.add(field_Seiten);
order.add(field_Preis);
order.add(field_EK);
order.add(field_DruckNr);
order.add(field_Auflage);
order.add(field_Jahr);
order.add(field_Bestand);
order.add(cbDruckerei);
order.add(field_Cover_gross);
order.add(CoverAdd);
order.add(field_Text);
order.add(TextAdd);
order.add(field_Flyer);
order.add(FlyerAdd);
order.add(field_Vertrag);
order.add(VertragAdd);
order.add(field_VertragBOD);
order.add(VertragBODAdd);
order.add(field_Honorar);
order.add(field_Honorar_Anzahl);
order.add(field_Honorar_Prozent);
order.add(field_Aktiv);
order.add(Rezension);
order.add(field_VLB);
order.add(field_BLB);
order.add(btnBLB);
order.add(field_DNB);
order.add(btnDNB);
order.add(rbPB);
order.add(rbHC);
order.add(rbKindle);
order.add(Anfang);
order.add(Zurueck);
order.add(Vor);
order.add(Ende);
order.add(Update);
order.add(Einfuegen);
order.add(Loeschen);
order.add(Suchen);
order.add(WSuchen);
order.add(Drucken);
order.add(Schliessen);
newPolicy = new ModulMyOwnFocusTraversalPolicy(order);
setFocusTraversalPolicy(newPolicy);
lbAutor.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
ActionMap actionMap = new ActionMapUIResource();
actionMap.put("action_anfang", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
AnfangActionPerformed(e);
System.out.println("anfang action performed.");
}
});
actionMap.put("action_ende", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
EndeActionPerformed(e);
System.out.println("ende action performed.");
}
});
actionMap.put("action_vor", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
VorActionPerformed(e);
System.out.println("vor action performed.");
}
});
actionMap.put("action_zurueck", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
ZurueckActionPerformed(e);
System.out.println("zurueck action performed.");
}
});
actionMap.put("action_insert", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
EinfuegenActionPerformed(e);
System.out.println("insert action performed.");
}
});
actionMap.put("action_del", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
LoeschenActionPerformed(e);
System.out.println("del action performed.");
}
});
actionMap.put("action_save", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
UpdateActionPerformed(e);
System.out.println("Save action performed.");
}
});
actionMap.put("action_exit", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
SchliessenActionPerformed(e);
System.out.println("Exit action performed.");
}
});
actionMap.put("action_print", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
DruckenActionPerformed(e);
System.out.println("print action performed.");
}
});
InputMap keyMap = new ComponentInputMap(panel1);
//keyMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.Event.CTRL_MASK), "action_anfang");
//keyMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.Event.CTRL_MASK), "action_ende");
keyMap.put(KeyStroke.getKeyStroke("control alt A"), "action_anfang");
keyMap.put(KeyStroke.getKeyStroke("control alt E"), "action_ende");
keyMap.put(KeyStroke.getKeyStroke("control alt V"), "action_vor");
keyMap.put(KeyStroke.getKeyStroke("control alt Z"), "action_zurueck");
keyMap.put(KeyStroke.getKeyStroke("control alt I"), "action_insert");
keyMap.put(KeyStroke.getKeyStroke("control alt D"), "action_del");
keyMap.put(KeyStroke.getKeyStroke("control alt S"), "action_save");
keyMap.put(KeyStroke.getKeyStroke("control alt X"), "action_exit");
keyMap.put(KeyStroke.getKeyStroke("control alt P"), "action_print");
SwingUtilities.replaceUIActionMap(panel1, actionMap);
SwingUtilities.replaceUIInputMap(panel1, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
conn = null;
try { // Datenbank-Treiber laden
Class.forName(ModulHelferlein.dbDriver);
} catch (ClassNotFoundException exept) {
System.out.println("Treiber nicht gefunden: " + exept.getMessage());
System.exit(1);
} // Datenbank-Treiber laden
try { // Verbindung zur Datenbank ?ber die JDBC-Br?cke
conn = DriverManager.getConnection(ModulHelferlein.dbUrl, ModulHelferlein.dbUser, ModulHelferlein.dbPassword);
} catch (SQLException exept) {
System.out.println(
"Verbindung nicht moeglich: " + exept.getMessage());
System.exit(1);
} // try Verbindung zur Datenbank ?ber die JDBC-Br?cke
// final Connection conn2=conn;
if (conn != null) {
SQLAnfrage = null; // Anfrage erzeugen
SQLAnfrage2 = null; // Anfrage erzeugen
SQLAnfrage_a = null; // Anfrage erzeugen
try { // SQL-Anfragen an die Datenbank
SQLAnfrage = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
SQLAnfrage2 = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
SQLAnfrage_a = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
// String eintragAnrede = "";
String eintragAutor = "";
// Auswahlliste f?r Autoren erstellen
result_a = SQLAnfrage_a.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_Typ = 'Autor' ORDER BY ADRESSEN_NAME"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
while (result_a.next()) {
eintragAutor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_NAME") + ", "
+ result_a.getString("ADRESSEN_VORNAME");
// eintragAnrede = result_a.getString("ADRESSEN_ANREDE");
listModel.addElement(eintragAutor);
// cbAnrede.addItem(eintragAnrede);
} // while
// Auswahlliste f?r Druckereien erstellen
eintragAutor = "";
result_d = SQLAnfrage.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_Typ = 'Druckerei'"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
while (result_d.next()) {
eintragAutor = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_NAME") + ", "
+ result_d.getString("ADRESSEN_VORNAME");
cbDruckerei.addItem(eintragAutor);
} // while
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch ORDER BY BUCH_ID DESC"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
if (result.first()) {
maxID = result.getInt("Buch_ID");
} else {
maxID = 0;
}
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch "
+ " WHERE BUCH_ID > '0' "
+ " ORDER BY BUCH_ISBN");
// Anzahl der Datens?tze ermitteln
countMax = 0;
count = 0;
field_count.setText(Integer.toString(count));
while (result.next()) {
++countMax;
}
field_countMax.setText(Integer.toString(countMax));
// gehe zum ersten Datensatz - wenn nicht leer
if (result.first()) {
count = 1;
field_count.setText(Integer.toString(count));
resultIsEmpty = false;
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
//col_Autor = result.getInt("BUCH_AUTOR");
//result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
//result_a.next();
//field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
//cbAutor.setSelectedItem(field_Autor);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//LabelBild.setIcon(new ImageIcon(ModulHelferlein.pathUserDir + "/" + result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_Honorar"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
field_Gesamtbetrachtung.setSelected(result.getBoolean("BUCH_GESAMTBETRACHTUNG"));
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
// Schalterzust?nde setzen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
} else {
// Schalterzust?nde setzen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(false);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(false);
Suchen.setEnabled(false);
WSuchen.setEnabled(false);
Drucken.setEnabled(false);
Schliessen.setEnabled(true);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung(
"SQL-Exception: SQL-Anfrage nicht moeglich: "
+ exept.getMessage());
// System.exit(1);
} // try SQL-Anfragen an die Datenbank
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
panel1 = new JPanel();
jScrollPane1 = new JScrollPane();
field_Beschreibung = new JTextArea();
jLabel17 = new JLabel();
jScrollPane2 = new JScrollPane();
lbAutor = new JList<>();
cbHerausgeber = new JCheckBox();
jLabel5 = new JLabel();
jLabel1 = new JLabel();
jLabel2 = new JLabel();
field_count = new JTextField();
label1 = new JLabel();
field_countMax = new JTextField();
jLabel4 = new JLabel();
field_ID = new JTextField();
field_Aktiv = new JCheckBox();
field_Titel = new JTextField();
jbtnBelegexemplar = new JButton();
Rezension = new JButton();
label2 = new JLabel();
label3 = new JLabel();
jLabel9 = new JLabel();
jLabel14 = new JLabel();
field_VLB = new JCheckBox();
field_ISBN = new JTextField();
field_Seiten = new JTextField();
field_Auflage = new JTextField();
field_Jahr = new JTextField();
label4 = new JLabel();
label5 = new JLabel();
jLabel15 = new JLabel();
jLabel24 = new JLabel();
field_Preis = new JTextField();
field_EK = new JTextField();
field_Bestand = new JTextField();
field_BLB = new JCheckBox();
btnBLB = new JButton();
jLabel13 = new JLabel();
jLabel12 = new JLabel();
field_DNB = new JCheckBox();
btnDNB = new JButton();
field_DruckNr = new JTextField();
cbDruckerei = new JComboBox<>();
label6 = new JLabel();
rbPB = new JRadioButton();
rbHC = new JRadioButton();
rbKindle = new JRadioButton();
jLabel16 = new JLabel();
field_Cover = new JTextField();
CoverAdd = new JButton();
LabelBild = new JButton();
jLabel18 = new JLabel();
field_Text = new JTextField();
TextAdd = new JButton();
jLabel19 = new JLabel();
field_Flyer = new JTextField();
FlyerAdd = new JButton();
jLabel20 = new JLabel();
field_Vertrag = new JTextField();
VertragAdd = new JButton();
jLabel21 = new JLabel();
field_VertragBOD = new JTextField();
VertragBODAdd = new JButton();
field_Honorar = new JCheckBox();
field_Honorar_Anzahl = new JTextField();
jLabel22 = new JLabel();
field_Honorar_Prozent = new JTextField();
jLabel23 = new JLabel();
field_Honorar_2_Anzahl = new JTextField();
label8 = new JLabel();
field_Honorar_2_Prozent = new JTextField();
label7 = new JLabel();
Anfang = new JButton();
Zurueck = new JButton();
Vor = new JButton();
Ende = new JButton();
Update = new JButton();
Einfuegen = new JButton();
Loeschen = new JButton();
Suchen = new JButton();
WSuchen = new JButton();
Drucken = new JButton();
Schliessen = new JButton();
label9 = new JLabel();
field_Marge = new JTextField();
field_Gesamtbetrachtung = new JRadioButton();
field_BODgetrennt = new JRadioButton();
field_BoDFix = new JTextField();
field_BoDProzent = new JTextField();
label10 = new JLabel();
label11 = new JLabel();
field_Cover_gross = new JTextField();
Flyer = new JButton();
//======== this ========
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Carola Hartmann Miles Verlag");
setMinimumSize(new Dimension(970, 710));
setResizable(false);
setSize(new Dimension(750, 700));
setFont(new Font(Font.DIALOG, Font.BOLD, 12));
var contentPane = getContentPane();
contentPane.setLayout(null);
//======== panel1 ========
{
panel1.setPreferredSize(new Dimension(800, 658));
panel1.setLayout(null);
//======== jScrollPane1 ========
{
//---- field_Beschreibung ----
field_Beschreibung.setColumns(20);
field_Beschreibung.setLineWrap(true);
field_Beschreibung.setRows(5);
field_Beschreibung.setWrapStyleWord(true);
jScrollPane1.setViewportView(field_Beschreibung);
}
panel1.add(jScrollPane1);
jScrollPane1.setBounds(0, 282, 645, 104);
//---- jLabel17 ----
jLabel17.setText("Beschreibung");
panel1.add(jLabel17);
jLabel17.setBounds(0, 263, 141, jLabel17.getPreferredSize().height);
//======== jScrollPane2 ========
{
//---- lbAutor ----
lbAutor.setModel(listModel);
lbAutor.setValueIsAdjusting(true);
jScrollPane2.setViewportView(lbAutor);
}
panel1.add(jScrollPane2);
jScrollPane2.setBounds(0, 105, 325, 153);
//---- cbHerausgeber ----
cbHerausgeber.setText("Herausgeber");
panel1.add(cbHerausgeber);
cbHerausgeber.setBounds(0, 77, 195, cbHerausgeber.getPreferredSize().height);
//---- jLabel5 ----
jLabel5.setText("Titel");
panel1.add(jLabel5);
jLabel5.setBounds(0, 30, 49, jLabel5.getPreferredSize().height);
//---- jLabel1 ----
jLabel1.setFont(new Font("Tahoma", Font.BOLD, 12));
jLabel1.setText("Verwalten der Buchprojekte");
panel1.add(jLabel1);
jLabel1.setBounds(0, 0, 367, 25);
//---- jLabel2 ----
jLabel2.setText("Datensatz");
jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel2);
jLabel2.setBounds(423, 0, 57, 25);
//---- field_count ----
field_count.setEditable(false);
field_count.setHorizontalAlignment(SwingConstants.CENTER);
field_count.setText("000");
field_count.setEnabled(false);
field_count.setFocusable(false);
field_count.setMinimumSize(new Dimension(50, 25));
field_count.setPreferredSize(new Dimension(50, 25));
panel1.add(field_count);
field_count.setBounds(new Rectangle(new Point(485, 0), field_count.getPreferredSize()));
//---- label1 ----
label1.setText("von");
label1.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label1);
label1.setBounds(540, 0, 40, 25);
//---- field_countMax ----
field_countMax.setEditable(false);
field_countMax.setHorizontalAlignment(SwingConstants.CENTER);
field_countMax.setText("000");
field_countMax.setEnabled(false);
field_countMax.setFocusable(false);
field_countMax.setMinimumSize(new Dimension(50, 25));
field_countMax.setName("");
field_countMax.setPreferredSize(new Dimension(50, 25));
panel1.add(field_countMax);
field_countMax.setBounds(new Rectangle(new Point(595, 0), field_countMax.getPreferredSize()));
//---- jLabel4 ----
jLabel4.setText("ID");
jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel4);
jLabel4.setBounds(655, 0, 25, 25);
//---- field_ID ----
field_ID.setEditable(false);
field_ID.setText("000");
field_ID.setEnabled(false);
field_ID.setFocusable(false);
panel1.add(field_ID);
field_ID.setBounds(691, 0, 64, 25);
//---- field_Aktiv ----
field_Aktiv.setText("Aktiv");
field_Aktiv.addActionListener(e -> field_AktivActionPerformed(e));
panel1.add(field_Aktiv);
field_Aktiv.setBounds(775, 0, 56, 25);
panel1.add(field_Titel);
field_Titel.setBounds(0, 49, 645, 23);
//---- jbtnBelegexemplar ----
jbtnBelegexemplar.setText("Belegexemplare");
jbtnBelegexemplar.addActionListener(e -> jbtnBelegexemplarActionPerformed(e));
panel1.add(jbtnBelegexemplar);
jbtnBelegexemplar.setBounds(675, 49, 156, jbtnBelegexemplar.getPreferredSize().height);
//---- Rezension ----
Rezension.setText("Rezension veranlassen");
Rezension.setToolTipText("Veranlasse eine Rezension f\u00fcr das aktuelle Buch");
Rezension.addActionListener(e -> RezensionActionPerformed(e));
panel1.add(Rezension);
Rezension.setBounds(675, 77, 156, Rezension.getPreferredSize().height);
//---- label2 ----
label2.setText("ISBN");
panel1.add(label2);
label2.setBounds(372, 105, 46, 23);
//---- label3 ----
label3.setText("Seiten");
panel1.add(label3);
label3.setBounds(485, 105, 50, 23);
//---- jLabel9 ----
jLabel9.setText("Auflage");
panel1.add(jLabel9);
jLabel9.setBounds(540, 105, 50, 23);
//---- jLabel14 ----
jLabel14.setText("Jahr");
panel1.add(jLabel14);
jLabel14.setBounds(595, 105, 50, 23);
//---- field_VLB ----
field_VLB.setText("Datensatz VLB angelegt");
panel1.add(field_VLB);
field_VLB.setBounds(675, 105, 156, field_VLB.getPreferredSize().height);
//---- field_ISBN ----
field_ISBN.setText("jTextField1");
field_ISBN.setMinimumSize(new Dimension(108, 25));
field_ISBN.setPreferredSize(new Dimension(108, 25));
panel1.add(field_ISBN);
field_ISBN.setBounds(new Rectangle(new Point(372, 133), field_ISBN.getPreferredSize()));
//---- field_Seiten ----
field_Seiten.setText("jTextField2");
field_Seiten.setMaximumSize(new Dimension(42, 25));
field_Seiten.setMinimumSize(new Dimension(42, 25));
field_Seiten.setPreferredSize(new Dimension(42, 25));
field_Seiten.addActionListener(e -> field_SeitenActionPerformed(e));
panel1.add(field_Seiten);
field_Seiten.setBounds(485, 133, field_Seiten.getPreferredSize().width, 25);
//---- field_Auflage ----
field_Auflage.setText("jTextField3");
field_Auflage.setMaximumSize(new Dimension(50, 20));
field_Auflage.setMinimumSize(new Dimension(50, 20));
field_Auflage.setPreferredSize(new Dimension(50, 25));
field_Auflage.addActionListener(e -> field_AuflageActionPerformed(e));
panel1.add(field_Auflage);
field_Auflage.setBounds(540, 133, 35, 25);
panel1.add(field_Jahr);
field_Jahr.setBounds(595, 133, 50, 25);
//---- label4 ----
label4.setText("VK");
panel1.add(label4);
label4.setBounds(372, 165, 46, label4.getPreferredSize().height);
//---- label5 ----
label5.setText("EK");
panel1.add(label5);
label5.setBounds(423, 165, 57, label5.getPreferredSize().height);
//---- jLabel15 ----
jLabel15.setText("Bestand");
panel1.add(jLabel15);
jLabel15.setBounds(595, 165, 50, jLabel15.getPreferredSize().height);
//---- jLabel24 ----
jLabel24.setText("Pflichtexemplare");
jLabel24.setFont(jLabel24.getFont().deriveFont(jLabel24.getFont().getStyle() | Font.BOLD));
panel1.add(jLabel24);
jLabel24.setBounds(675, 163, 156, jLabel24.getPreferredSize().height);
panel1.add(field_Preis);
field_Preis.setBounds(375, 185, 46, field_Preis.getPreferredSize().height);
panel1.add(field_EK);
field_EK.setBounds(425, 185, 57, field_EK.getPreferredSize().height);
panel1.add(field_Bestand);
field_Bestand.setBounds(595, 185, 50, field_Bestand.getPreferredSize().height);
//---- field_BLB ----
field_BLB.setText("Berl.Land.Bibl.");
panel1.add(field_BLB);
field_BLB.setBounds(new Rectangle(new Point(675, 182), field_BLB.getPreferredSize()));
//---- btnBLB ----
btnBLB.setText("D");
btnBLB.setToolTipText("Drucke Brief an die Berliner Landesbibliothek");
btnBLB.addActionListener(e -> btnBLBActionPerformed(e));
panel1.add(btnBLB);
btnBLB.setBounds(775, 182, 56, btnBLB.getPreferredSize().height);
//---- jLabel13 ----
jLabel13.setText("Druck.Nr.");
jLabel13.setVerticalAlignment(SwingConstants.BOTTOM);
panel1.add(jLabel13);
jLabel13.setBounds(372, 210, jLabel13.getPreferredSize().width, 23);
//---- jLabel12 ----
jLabel12.setText("Druckerei");
jLabel12.setVerticalAlignment(SwingConstants.BOTTOM);
panel1.add(jLabel12);
jLabel12.setBounds(485, 210, 50, 23);
//---- field_DNB ----
field_DNB.setText("Dt.Nat.Bibl.");
panel1.add(field_DNB);
field_DNB.setBounds(675, 210, 95, field_DNB.getPreferredSize().height);
//---- btnDNB ----
btnDNB.setText("D");
btnDNB.setToolTipText("Drucke Brief an die Deutsche Nationalbibliothek");
btnDNB.addActionListener(e -> btnDNBActionPerformed(e));
panel1.add(btnDNB);
btnDNB.setBounds(775, 210, 56, btnDNB.getPreferredSize().height);
panel1.add(field_DruckNr);
field_DruckNr.setBounds(372, 238, 108, field_DruckNr.getPreferredSize().height);
//---- cbDruckerei ----
cbDruckerei.setModel(new DefaultComboBoxModel<>(new String[] {
"Item 1",
"Item 2",
"Item 3",
"Item 4"
}));
cbDruckerei.addActionListener(e -> cbDruckereiActionPerformed(e));
panel1.add(cbDruckerei);
cbDruckerei.setBounds(485, 238, 160, cbDruckerei.getPreferredSize().height);
//---- label6 ----
label6.setText("Ausgabeart");
label6.setFont(label6.getFont().deriveFont(label6.getFont().getStyle() | Font.BOLD));
panel1.add(label6);
label6.setBounds(691, 263, 79, label6.getPreferredSize().height);
//---- rbPB ----
rbPB.setSelected(true);
rbPB.setText("Paperback");
panel1.add(rbPB);
rbPB.setBounds(691, 282, 140, rbPB.getPreferredSize().height);
//---- rbHC ----
rbHC.setText("Hardcover");
panel1.add(rbHC);
rbHC.setBounds(691, 310, 140, rbHC.getPreferredSize().height);
//---- rbKindle ----
rbKindle.setText("Kindle");
panel1.add(rbKindle);
rbKindle.setBounds(691, 338, 140, rbKindle.getPreferredSize().height);
//---- jLabel16 ----
jLabel16.setText("Cover");
jLabel16.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel16);
jLabel16.setBounds(100, 391, 41, 25);
//---- field_Cover ----
field_Cover.setText("jTextField11");
field_Cover.setPreferredSize(new Dimension(65, 25));
panel1.add(field_Cover);
field_Cover.setBounds(695, 560, 115, field_Cover.getPreferredSize().height);
//---- CoverAdd ----
CoverAdd.setText("...");
CoverAdd.setToolTipText("Auswahl der Bilddatei f\u00fcr das Buchcover");
CoverAdd.addActionListener(e -> CoverAddActionPerformed(e));
panel1.add(CoverAdd);
CoverAdd.setBounds(595, 391, 50, 25);
//---- LabelBild ----
LabelBild.setFocusable(false);
LabelBild.setHorizontalTextPosition(SwingConstants.CENTER);
LabelBild.setIconTextGap(0);
LabelBild.setPreferredSize(new Dimension(120, 160));
LabelBild.setToolTipText("Icon f\u00fcr das Buchcover");
LabelBild.setMinimumSize(new Dimension(120, 160));
LabelBild.setMaximumSize(new Dimension(120, 160));
LabelBild.setMargin(new Insets(0, 0, 0, 0));
LabelBild.addActionListener(e -> IconAddActionPerformed(e));
panel1.add(LabelBild);
LabelBild.setBounds(691, 391, 120, 160);
//---- jLabel18 ----
jLabel18.setText("Text");
jLabel18.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel18);
jLabel18.setBounds(100, 421, 41, 23);
panel1.add(field_Text);
field_Text.setBounds(146, 421, 444, 23);
//---- TextAdd ----
TextAdd.setText("...");
TextAdd.setToolTipText("Auswahl des Quelltextes f\u00fcr den Buchblock");
TextAdd.addActionListener(e -> TextAddActionPerformed(e));
panel1.add(TextAdd);
TextAdd.setBounds(595, 421, 50, TextAdd.getPreferredSize().height);
//---- jLabel19 ----
jLabel19.setText("Flyer");
jLabel19.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel19);
jLabel19.setBounds(100, 449, 41, 23);
panel1.add(field_Flyer);
field_Flyer.setBounds(146, 449, 444, 23);
//---- FlyerAdd ----
FlyerAdd.setText("...");
FlyerAdd.setToolTipText("Auswahl des Werbeflyers");
FlyerAdd.addActionListener(e -> FlyerAddActionPerformed(e));
panel1.add(FlyerAdd);
FlyerAdd.setBounds(595, 449, 50, FlyerAdd.getPreferredSize().height);
//---- jLabel20 ----
jLabel20.setText("Vertrag Autor");
jLabel20.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel20);
jLabel20.setBounds(54, 477, 87, 23);
panel1.add(field_Vertrag);
field_Vertrag.setBounds(146, 477, 444, 23);
//---- VertragAdd ----
VertragAdd.setText("...");
VertragAdd.setToolTipText("Auswahl des Vertrages mit dem Autor");
VertragAdd.addActionListener(e -> VertragAddActionPerformed(e));
panel1.add(VertragAdd);
VertragAdd.setBounds(595, 477, 50, VertragAdd.getPreferredSize().height);
//---- jLabel21 ----
jLabel21.setText("Vertrag BOD");
jLabel21.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel21);
jLabel21.setBounds(54, 505, 87, 23);
panel1.add(field_VertragBOD);
field_VertragBOD.setBounds(146, 505, 444, 23);
//---- VertragBODAdd ----
VertragBODAdd.setText("...");
VertragBODAdd.setToolTipText("Auswahl des Vertrages mit BoD");
VertragBODAdd.addActionListener(e -> VertragBODAddActionPerformed(e));
panel1.add(VertragBODAdd);
VertragBODAdd.setBounds(595, 505, 50, VertragBODAdd.getPreferredSize().height);
//---- field_Honorar ----
field_Honorar.setText("Honorar auf der Basis");
field_Honorar.setActionCommand("Honorar");
panel1.add(field_Honorar);
field_Honorar.setBounds(0, 540, 155, 23);
//---- field_Honorar_Anzahl ----
field_Honorar_Anzahl.setMaximumSize(new Dimension(33, 25));
field_Honorar_Anzahl.setMinimumSize(new Dimension(33, 25));
field_Honorar_Anzahl.setPreferredSize(new Dimension(33, 25));
field_Honorar_Anzahl.addActionListener(e -> field_Honorar_AnzahlActionPerformed(e));
panel1.add(field_Honorar_Anzahl);
field_Honorar_Anzahl.setBounds(45, 570, field_Honorar_Anzahl.getPreferredSize().width, 20);
//---- jLabel22 ----
jLabel22.setText("St\u00fcck mit je");
panel1.add(jLabel22);
jLabel22.setBounds(90, 570, 83, 20);
//---- field_Honorar_Prozent ----
field_Honorar_Prozent.setMinimumSize(new Dimension(25, 30));
field_Honorar_Prozent.setPreferredSize(new Dimension(25, 25));
field_Honorar_Prozent.addActionListener(e -> field_Honorar_ProzentActionPerformed(e));
panel1.add(field_Honorar_Prozent);
field_Honorar_Prozent.setBounds(175, 570, 33, 20);
//---- jLabel23 ----
jLabel23.setText("% des Netto-VK pro St\u00fcck");
panel1.add(jLabel23);
jLabel23.setBounds(220, 570, 163, 20);
panel1.add(field_Honorar_2_Anzahl);
field_Honorar_2_Anzahl.setBounds(45, 600, 33, 20);
//---- label8 ----
label8.setText("St\u00fcck mit je");
panel1.add(label8);
label8.setBounds(90, 600, 83, 20);
panel1.add(field_Honorar_2_Prozent);
field_Honorar_2_Prozent.setBounds(175, 600, 33, 20);
//---- label7 ----
label7.setText("% des Netto-VK pro St\u00fcck");
panel1.add(label7);
label7.setBounds(220, 600, 163, 20);
//---- Anfang ----
Anfang.setText("<<");
Anfang.setToolTipText("gehe zum ersten Datensatz");
Anfang.addActionListener(e -> AnfangActionPerformed(e));
panel1.add(Anfang);
Anfang.setBounds(0, 635, 49, 23);
//---- Zurueck ----
Zurueck.setText("<");
Zurueck.setToolTipText("gehe zum vorherigen Datensatz");
Zurueck.addActionListener(e -> ZurueckActionPerformed(e));
panel1.add(Zurueck);
Zurueck.setBounds(50, 635, 49, Zurueck.getPreferredSize().height);
//---- Vor ----
Vor.setText(">");
Vor.setToolTipText("gehe zum n\u00e4chsten Datensatz");
Vor.addActionListener(e -> VorActionPerformed(e));
panel1.add(Vor);
Vor.setBounds(95, 635, 49, Vor.getPreferredSize().height);
//---- Ende ----
Ende.setText(">>");
Ende.setToolTipText("gehe zum letzten Datensatz");
Ende.addActionListener(e -> EndeActionPerformed(e));
panel1.add(Ende);
Ende.setBounds(145, 635, 49, Ende.getPreferredSize().height);
//---- Update ----
Update.setText("!");
Update.setToolTipText("Datensatz aktualisieren");
Update.addActionListener(e -> UpdateActionPerformed(e));
panel1.add(Update);
Update.setBounds(205, 635, 49, Update.getPreferredSize().height);
//---- Einfuegen ----
Einfuegen.setText("+");
Einfuegen.setToolTipText("Datensatz einf\u00fcgen");
Einfuegen.addActionListener(e -> EinfuegenActionPerformed(e));
panel1.add(Einfuegen);
Einfuegen.setBounds(255, 635, 49, Einfuegen.getPreferredSize().height);
//---- Loeschen ----
Loeschen.setText("-");
Loeschen.setToolTipText("Datensatz l\u00f6schen");
Loeschen.addActionListener(e -> LoeschenActionPerformed(e));
panel1.add(Loeschen);
Loeschen.setBounds(305, 635, 49, Loeschen.getPreferredSize().height);
//---- Suchen ----
Suchen.setText("?");
Suchen.setToolTipText("Suche nach Autor, Titel, ISBN oder Druckereinummer");
Suchen.addActionListener(e -> SuchenActionPerformed(e));
panel1.add(Suchen);
Suchen.setBounds(365, 635, 49, Suchen.getPreferredSize().height);
//---- WSuchen ----
WSuchen.setText("...");
WSuchen.setToolTipText("Weitersuchen");
WSuchen.addActionListener(e -> WSuchenActionPerformed(e));
panel1.add(WSuchen);
WSuchen.setBounds(415, 635, 49, WSuchen.getPreferredSize().height);
//---- Drucken ----
Drucken.setText("D");
Drucken.setToolTipText("Druckt das aktuelle Buchprojekt als PDF");
Drucken.addActionListener(e -> DruckenActionPerformed(e));
panel1.add(Drucken);
Drucken.setBounds(475, 635, 49, Drucken.getPreferredSize().height);
//---- Schliessen ----
Schliessen.setText("X");
Schliessen.setToolTipText("Schlie\u00dft den Dialog");
Schliessen.addActionListener(e -> SchliessenActionPerformed(e));
panel1.add(Schliessen);
Schliessen.setBounds(595, 635, 49, Schliessen.getPreferredSize().height);
//---- label9 ----
label9.setText("Marge");
panel1.add(label9);
label9.setBounds(new Rectangle(new Point(485, 165), label9.getPreferredSize()));
panel1.add(field_Marge);
field_Marge.setBounds(485, 185, 45, field_Marge.getPreferredSize().height);
//---- field_Gesamtbetrachtung ----
field_Gesamtbetrachtung.setText("Gesamtumfang");
field_Gesamtbetrachtung.setSelected(true);
panel1.add(field_Gesamtbetrachtung);
field_Gesamtbetrachtung.setBounds(155, 540, 225, field_Gesamtbetrachtung.getPreferredSize().height);
//---- field_BODgetrennt ----
field_BODgetrennt.setText("BoD getrennt betrachtet");
panel1.add(field_BODgetrennt);
field_BODgetrennt.setBounds(500, 540, 170, field_BODgetrennt.getPreferredSize().height);
panel1.add(field_BoDFix);
field_BoDFix.setBounds(390, 570, 30, 20);
panel1.add(field_BoDProzent);
field_BoDProzent.setBounds(390, 600, 30, field_BoDProzent.getPreferredSize().height);
//---- label10 ----
label10.setText("Fix-Betrag BoD");
panel1.add(label10);
label10.setBounds(430, 570, 100, 20);
//---- label11 ----
label11.setText("% Marge BoD");
panel1.add(label11);
label11.setBounds(430, 600, 80, 20);
panel1.add(field_Cover_gross);
field_Cover_gross.setBounds(145, 390, 444, 23);
//---- Flyer ----
Flyer.setText("F");
Flyer.setToolTipText("Werbeflyer erstellen");
Flyer.addActionListener(e -> FlyerActionPerformed(e));
panel1.add(Flyer);
Flyer.setBounds(535, 635, 49, Flyer.getPreferredSize().height);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel1.getComponentCount(); i++) {
Rectangle bounds = panel1.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel1.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel1.setMinimumSize(preferredSize);
panel1.setPreferredSize(preferredSize);
}
}
contentPane.add(panel1);
panel1.setBounds(10, 10, 970, 670);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
setSize(860, 720);
setLocationRelativeTo(getOwner());
//---- buttonGroup1 ----
var buttonGroup1 = new ButtonGroup();
buttonGroup1.add(field_Gesamtbetrachtung);
buttonGroup1.add(field_BODgetrennt);
}// </editor-fold>//GEN-END:initComponents
private void AnfangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AnfangActionPerformed
// TODO add your handling code here:
try {
result.first();
count = 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild);Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ","
// + result_a.getString("ADRESSEN_Name") + ","
// + result_a.getString("ADRESSEN_Vorname") + ","
// + result_a.getString("ADRESSEN_ANREDE");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
System.out.println("Anfang: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Anfang:");
}
}//GEN-LAST:event_AnfangActionPerformed
private void ZurueckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ZurueckActionPerformed
// TODO add your handling code here:
try {
if (result.previous()) {
count = count - 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
if (count > 1) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
} else {
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
}
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
result.next();
}
System.out.println("Zurück auf ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Zurück");
}
}//GEN-LAST:event_ZurueckActionPerformed
private void VorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VorActionPerformed
// TODO add your handling code here:
try {
if (result.next()) {
count = count + 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
if (count < countMax) {
Ende.setEnabled(true);
Vor.setEnabled(true);
} else {
Ende.setEnabled(false);
Vor.setEnabled(false);
}
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild);Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
result.previous();
}
System.out.println("Vor auf ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Vor");
}
}//GEN-LAST:event_VorActionPerformed
private void EndeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EndeActionPerformed
// TODO add your handling code here:
try {
result.last();
count = countMax;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
System.out.println("Ende: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Ende");
}
}//GEN-LAST:event_EndeActionPerformed
private void UpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UpdateActionPerformed
// TODO add your handling code here:
try {
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Anzahl der Seiten - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Jahr.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Erscheinungsjahres - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Bestand.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Buchbestandes - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Auflage.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Auflage- es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Preises - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_EK.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des EK-Preises - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_Marge.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Marge - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Anzahl.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Verkeuafsanzahl für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_2_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_2_Anzahl.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Verkeuafsanzahl für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_BoDFix.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Fix-Anteils der BoD-Marge - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes der BoD-Marge - es ist keine korrekte Ganzzahl");
} else {
result.updateString("Buch_Titel", field_Titel.getText());
result.updateFloat("Buch_EK", Float.parseFloat(field_EK.getText()));
result.updateFloat("Buch_Marge", Float.parseFloat(field_Marge.getText()));
result.updateFloat("Buch_Preis", Float.parseFloat(field_Preis.getText()));
result.updateString("Buch_ISBN", field_ISBN.getText());
result.updateInt("Buch_Seiten", Integer.parseInt(field_Seiten.getText()));
result.updateString("Buch_Beschreibung", field_Beschreibung.getText());
result.updateInt("Buch_Auflage", Integer.parseInt(field_Auflage.getText()));
result.updateString("BUCH_JAHR", field_Jahr.getText());
result.updateString("Buch_Druckereinummer", field_DruckNr.getText());
result.updateBoolean("Buch_DeuNatBibl", field_DNB.isSelected());
result.updateBoolean("Buch_BerlLBibl", field_BLB.isSelected());
result.updateBoolean("Buch_VLB", field_VLB.isSelected());
if (field_Gesamtbetrachtung.isSelected()) {
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", true);
} else {
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", false);
}
result.updateFloat("Buch_BODFIX", Float.parseFloat(field_BoDFix.getText()));
result.updateInt("Buch_Bestand", Integer.parseInt(field_Bestand.getText()));
result.updateInt("Buch_BODPROZENT", Integer.parseInt(field_BoDProzent.getText()));
result.updateString("Buch_Cover", field_Cover.getText());
result.updateString("Buch_Cover_gross", field_Cover_gross.getText());
result.updateString("Buch_Flyer", field_Flyer.getText());
result.updateString("Buch_Vertrag", field_Vertrag.getText());
result.updateString("Buch_BOD_Vertrag", field_VertragBOD.getText());
result.updateString("Buch_Text", field_Text.getText());
result.updateInt("Buch_Druckerei", Integer.parseInt(field_Druckerei.split(",")[0]));
result.updateBoolean("Buch_Honorar", field_Honorar.isSelected());
result.updateInt("Buch_Honorar_Prozent", Integer.parseInt(field_Honorar_Prozent.getText()));
result.updateInt("Buch_Honorar_Anzahl", Integer.parseInt(field_Honorar_Anzahl.getText()));
result.updateInt("Buch_Honorar_2_Prozent", Integer.parseInt(field_Honorar_2_Prozent.getText()));
result.updateInt("Buch_Honorar_2_Anzahl", Integer.parseInt(field_Honorar_2_Anzahl.getText()));
result.updateBoolean("BUCH_AKTIV", field_Aktiv.isSelected());
result.updateBoolean("Buch_HERAUSGEBER", cbHerausgeber.isSelected());
if (rbPB.isSelected()) {
result.updateInt("BUCH_HC", 0);
} else if (rbHC.isSelected()) {
result.updateInt("BUCH_HC", 1);
} else {
result.updateInt("BUCH_HC", 2);
}
List<String> ListeAutoren = lbAutor.getSelectedValuesList();
String EintragAutor = "";
String strAuswahl = "";
for (int i = 0, n = ListeAutoren.size(); i < n; i++) {
strAuswahl = ListeAutoren.get(i);
String[] splitAutor = strAuswahl.split(",");
EintragAutor = EintragAutor + splitAutor[0] + ",";
}
EintragAutor = EintragAutor.substring(0, EintragAutor.length() - 1);
result.updateString("Buch_Autor", EintragAutor);
result.updateRow();
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
System.out.println("Update: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
}
}
}
}
}
}
}
}
}
}
}
}
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}//GEN-LAST:event_UpdateActionPerformed
private void EinfuegenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EinfuegenActionPerformed
// TODO add your handling code here:
int ID;
String eingabeISBN = JOptionPane.showInputDialog(null, "Geben Sie die ISBN ein",
"Neues Buchprojekt",
JOptionPane.PLAIN_MESSAGE);
//helferlein.Infomeldung(helferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag BoD/");
if (!"".equals(eingabeISBN)) {
while (eingabeISBN.endsWith(" ")) {
eingabeISBN = eingabeISBN.substring(0, eingabeISBN.length() - 1);
}
File dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Schriftverkehr/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag Autor/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag BoD/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Belegexemplare/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Cover/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Pflichtexemplare/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Rezensionen/");
dir.mkdir();
try {
ID = maxID + 1;
maxID = maxID + 1;
result.moveToInsertRow();
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
result.updateInt("Buch_ID", ID);
result.updateString("Buch_Titel", "");
result.updateFloat("Buch_Preis", 0);
result.updateFloat("Buch_EK", 0);
result.updateFloat("Buch_Marge", 0);
result.updateString("Buch_ISBN", eingabeISBN);
result.updateInt("Buch_Seiten", 0);
result.updateString("Buch_Beschreibung", "");
result.updateString("BUCH_JAHR", "");
result.updateInt("Buch_Auflage", 1);
result.updateString("Buch_Druckereinummer", "");
result.updateBoolean("Buch_DeuNatBibl", false);
result.updateBoolean("Buch_DeuNatBibl", false);
result.updateInt("Buch_Bestand", 0);
result.updateString("Buch_Cover", "Buch.jpg");
result.updateString("Buch_Cover_GROSS", "Buch.jpg");
result.updateString("Buch_Flyer", "");
result.updateString("Buch_Vertrag", "");
result.updateString("Buch_BOD_Vertrag", "");
result.updateString("Buch_Text", "");
result.updateBoolean("Buch_Honorar", true);
result.updateBoolean("Buch_Herausgeber", false);
result.updateBoolean("Buch_VLB", false);
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", true);
result.updateInt("Buch_Honorar_Anzahl", 0);
result.updateInt("Buch_BODPROZENT", 0);
result.updateFloat("Buch_BODFIX", 0);
result.updateInt("Buch_Honorar_Prozent", 0);
result.updateInt("Buch_Honorar_2_Anzahl", 0);
result.updateInt("Buch_Honorar_2_Prozent", 0);
result.updateBoolean("BUCH_HC", false);
List<String> ListeAutoren = lbAutor.getSelectedValuesList();
String EintragAutor = "";
String strAuswahl = "";
for (int i = 0, n = ListeAutoren.size(); i < n; i++) {
strAuswahl = ListeAutoren.get(i);
String[] splitAutor = strAuswahl.split(",");
EintragAutor = EintragAutor + splitAutor[0] + ",";
}
EintragAutor = EintragAutor.substring(0, EintragAutor.length() - 1);
result.updateString("Buch_Autor", EintragAutor);
result.updateInt("Buch_Druckerei", Integer.parseInt(((String) cbDruckerei.getSelectedItem()).split(",")[0]));
result.updateInt("BUCH_HC", 0);
result.updateBoolean("BUCH_AKTIV", true);
result.updateBoolean("BUCH_HERAUSGEBER", false);
result.insertRow();
countMax = countMax + 1;
field_countMax.setText(Integer.toString(countMax));
count = countMax;
field_count.setText(Integer.toString(count));
resultIsEmpty = false;
result.last();
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background("Buch.jpg");this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: Einf?gen: " + exept.getMessage());
}
} else {
ModulHelferlein.Infomeldung("ohne ISBN kein Buchprojekt!");
} // if
}//GEN-LAST:event_EinfuegenActionPerformed
private void LoeschenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoeschenActionPerformed
// TODO add your handling code here:
if (JOptionPane.showConfirmDialog(null, "Soll der Datensatz wirklich gelöscht werden?") == JOptionPane.YES_OPTION) {
try {
result.deleteRow();
countMax = countMax - 1;
field_countMax.setText(Integer.toString(countMax));
count = 1;
field_count.setText(Integer.toString(count));
result.first();
if (result.getRow() > 0) {
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
resultIsEmpty = true;
field_ID.setText("");
field_Titel.setText("");
field_Preis.setText("");
field_EK.setText("");
field_ISBN.setText("");
field_Seiten.setText("");
field_Beschreibung.setText("");
field_Auflage.setText("");
field_DruckNr.setText("");
field_Jahr.setText("");
field_DNB.setSelected(false);
field_BLB.setSelected(false);
field_VLB.setSelected(false);
field_Bestand.setText("");
field_Cover.setText("");
field_Cover_gross.setText("");
field_Flyer.setText("");
field_Vertrag.setText("");
field_VertragBOD.setText("");
field_Text.setText("");
cbDruckerei.setSelectedItem("");
field_Honorar.setSelected(false);
field_Aktiv.setSelected(true);
cbHerausgeber.setSelected(false);
// Schalterzustand anpassen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(false);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(false);
Suchen.setEnabled(false);
WSuchen.setEnabled(false);
Drucken.setEnabled(false);
Schliessen.setEnabled(true);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}
}//GEN-LAST:event_LoeschenActionPerformed
private void SuchenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SuchenActionPerformed
// TODO add your handling code here:
boolean gefunden = false;
String[] Kriterien = {"Autor", "Titel", "ISBN", "BOD-Nummer", "Jahr"};
Kriterium = (String) JOptionPane.showInputDialog(null,
"Suchen",
"Nach was soll gesucht werden?",
JOptionPane.QUESTION_MESSAGE,
null, Kriterien,
Kriterien[2]);
if (Kriterium != null) {
try {
result.first();
count = 1;
switch (Kriterium) {
case "ISBN":
SuchString = field_ISBN.getText();
break;
case "Titel":
SuchString = field_Titel.getText();
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
break;
case "BOD-Nummer":
SuchString = field_DruckNr.getText();
break;
case "Jahr":
SuchString = field_Jahr.getText();
break;
}
do {
field_count.setText(Integer.toString(count));
switch (Kriterium) {
case "ISBN":
if (result.getString("BUCH_ISBN").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
if (lbAutor.getSelectedValue().contains(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Titel":
if (result.getString("BUCH_TITEL").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "BOD-Nummer":
if (result.getString("Buch_Druckereinummer").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Jahr":
if (result.getString("BUCH_JAHR").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
}
} while ((!gefunden) && result.next());
if (gefunden) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_count.setText(Integer.toString(count));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
ModulHelferlein.Infomeldung(Kriterium + " wurde nicht gefunden!");
AnfangActionPerformed(evt);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}
}//GEN-LAST:event_SuchenActionPerformed
private void WSuchenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WSuchenActionPerformed
// TODO add your handling code here:
boolean gefunden = false;
try {
result.next();
do {
switch (Kriterium) {
case "ISBN":
if (result.getString("BUCH_ISBN").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
if (lbAutor.getSelectedValue().contains(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Titel":
if (result.getString("BUCH_TITEL").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "BOD-Nummer":
if (result.getString("Buch_Druckereinummer").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Jahr":
if (result.getString("BUCH_JAHR").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
}
} while ((!gefunden) && result.next());
if (gefunden) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_count.setText(Integer.toString(count));
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
// col_Autor = result.getInt("BUCH_AUTOR");
// lbAutor.setSelectedValue(field_Autor, true);
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
ModulHelferlein.Infomeldung(Kriterium + " wurde nicht gefunden!");
AnfangActionPerformed(evt);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}//GEN-LAST:event_WSuchenActionPerformed
private void DruckenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DruckenActionPerformed
// TODO add your handling code here:
berBuch.Buch(field_ID.getText(), 1);
}//GEN-LAST:event_DruckenActionPerformed
private void SchliessenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SchliessenActionPerformed
// TODO add your handling code here:
try {
result.close();
SQLAnfrage.close();
conn.close();
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
this.dispose();
}//GEN-LAST:event_SchliessenActionPerformed
private void btnDNBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDNBActionPerformed
try {
// TODO add your handling code here:
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + ", ";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 2);
String Autor[] = field_Autor.split(", ");
field_Autor = "";
for (int i = 1; i < Autor.length; i = i + 3) {
field_Autor = field_Autor + Autor[i] + ", " + Autor[i + 1] + "; ";
}
field_Autor = field_Autor.substring(0, field_Autor.length() - 2) + ".";
String[] args = {"Pflichtexemplar", // 0
"DNB", // 1
field_Autor, // 2
field_Titel.getText(), // 3
field_ISBN.getText(), // 4
field_Jahr.getText(), // 5
result.getString("BUCH_ID")}; // 6
_DlgAusgabeFormat.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Drucke Pflichtexemplar Deutsche Nationalbibliothek", "SQL-Exception", ex.getMessage());
}
}//GEN-LAST:event_btnDNBActionPerformed
private void btnBLBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBLBActionPerformed
try {
// TODO add your handling code here:
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + ", ";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 2);
String Autor[] = field_Autor.split(", ");
field_Autor = "";
for (int i = 1; i < Autor.length; i = i + 3) {
field_Autor = field_Autor + Autor[i] + ", " + Autor[i + 1] + "; ";
}
field_Autor = field_Autor.substring(0, field_Autor.length() - 2) + ".";
String[] args = {"Pflichtexemplar", "BLB", field_Autor, field_Titel.getText(), field_ISBN.getText(), field_Jahr.getText(), result.getString("BUCH_ID")};
_DlgAusgabeFormat.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Drucke Pflichtexemplar Berliner Landesbibliothek", "SQL-Exception", ex.getMessage());
}
}//GEN-LAST:event_btnBLBActionPerformed
private void RezensionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RezensionActionPerformed
// dlgRezension fenster = new dlgRezension();
VerwaltenDatenbankRezensionAus.main(null);
/*
try {
// TODO add your handling code here:
String CmdLine;
String[] args;
field_Autor = "";
List selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + "#";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 1);
result_a = SQLAnfrage_a.executeQuery("SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = '"
+ field_Autor.split(",")[0]
+ "'");
result_a.next();
field_Anrede = result_a.getString("ADRESSEN_ANREDE");
CmdLine = field_Anrede + "!"
+ field_Autor + "!"
+ field_Titel.getText() + "!"
+ field_Beschreibung.getText() + "!"
+ field_ISBN.getText() + "!"
+ field_Preis.getText() + "!"
+ field_Seiten.getText() + "!"
+ result.getString("BUCH_ID") + "!"
+ "1" + "!"
+ "1";
//helferlein.Infomeldung(CmdLine);
args = CmdLine.split("!");
//helferlein.Infomeldung(args[1]);
_DlgRezensionErzeugen.main(args);
} catch (SQLException ex) {
Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
}
*/
}//GEN-LAST:event_RezensionActionPerformed
private void CoverAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CoverAddActionPerformed
// TODO add your handling code here:
String Dateiname = "";
if (chooser.showDialog(null, "Datei mit dem Cover wählen") == JFileChooser.APPROVE_OPTION) {
try {
Dateiname = chooser.getSelectedFile().getCanonicalPath();
System.out.println("Cover-Datei");
System.out.println("-> " + ModulHelferlein.pathUserDir);
System.out.println("-> " + ModulHelferlein.pathBuchprojekte);
System.out.println("-> " + Dateiname);
field_Cover_gross.setText(Dateiname);
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_CoverAddActionPerformed
private void TextAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Quelltext wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Text.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_TextAddActionPerformed
private void FlyerAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FlyerAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Flyer wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Flyer.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_FlyerAddActionPerformed
private void VertragAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VertragAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Autorenvertrag wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Vertrag.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_VertragAddActionPerformed
private void VertragBODAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VertragBODAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem BOD-Vertrag wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_VertragBOD.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_VertragBODAddActionPerformed
private void cbDruckereiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDruckereiActionPerformed
// TODO add your handling code here:
field_Druckerei = (String) cbDruckerei.getSelectedItem();
}//GEN-LAST:event_cbDruckereiActionPerformed
private void field_SeitenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_SeitenActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_SeitenActionPerformed
private void field_BestandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_BestandActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_BestandActionPerformed
private void field_Honorar_AnzahlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_Honorar_AnzahlActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_Honorar_AnzahlActionPerformed
private void field_Honorar_ProzentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_Honorar_ProzentActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_Honorar_ProzentActionPerformed
private void field_AuflageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_AuflageActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_AuflageActionPerformed
private void field_JahrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_JahrActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_JahrActionPerformed
private void field_PreisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_PreisActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Zahl");
}
}//GEN-LAST:event_field_PreisActionPerformed
private void field_EKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_EKActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Zahl");
}
}//GEN-LAST:event_field_EKActionPerformed
private void field_AktivActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_AktivActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_field_AktivActionPerformed
private void jbtnBelegexemplarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnBelegexemplarActionPerformed
// TODO add your handling code here:
try {
// TODO add your handling code here:
String CmdLine;
String[] args;
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + "#";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 1);
result_a = SQLAnfrage_a.executeQuery("SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = '"
+ field_Autor.split(",")[0]
+ "'");
result_a.next();
field_Anrede = result_a.getString("ADRESSEN_ANREDE");
CmdLine = field_Anrede + "!"
+ field_Autor + "!"
+ field_Titel.getText() + "!"
+ field_Beschreibung.getText() + "!"
+ field_ISBN.getText() + "!"
+ field_Preis.getText() + "!"
+ field_Seiten.getText() + "!"
+ result.getString("BUCH_ID") + "!"
+ "1" + "!"
+ "1";
//helferlein.Infomeldung(CmdLine);
args = CmdLine.split("!");
//helferlein.Infomeldung(args[1]);
_DlgBelegexemplareErzeugen.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Belegexemplar erzeugen", ex.getMessage());
//Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jbtnBelegexemplarActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
/**
* try { for (javax.swing.UIManager.LookAndFeelInfo info :
* javax.swing.UIManager.getInstalledLookAndFeels()) { if
* ("Nimbus".equals(info.getName())) {
* javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } }
* } catch (ClassNotFoundException | InstantiationException |
* IllegalAccessException | javax.swing.UnsupportedLookAndFeelException
* ex) {
* java.util.logging.Logger.getLogger(CarolaHartmannMilesVerlag.class.getName()).log(java.util.logging.Level.SEVERE,
* null, ex); }
*/
//</editor-fold>
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(() -> {
VerwaltenDatenbankBuch dialog = new VerwaltenDatenbankBuch(new javax.swing.JFrame(), true);
// try {
// javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
// Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
// }
// SwingUtilities.updateComponentTreeUI(dialog);
// updateComponentTreeUI(dialog);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dialog.setVisible(false);
}
});
dialog.setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private JPanel panel1;
private JScrollPane jScrollPane1;
private JTextArea field_Beschreibung;
private JLabel jLabel17;
private JScrollPane jScrollPane2;
private JList<String> lbAutor;
private JCheckBox cbHerausgeber;
private JLabel jLabel5;
private JLabel jLabel1;
private JLabel jLabel2;
private JTextField field_count;
private JLabel label1;
private JTextField field_countMax;
private JLabel jLabel4;
private JTextField field_ID;
private JCheckBox field_Aktiv;
private JTextField field_Titel;
private JButton jbtnBelegexemplar;
private JButton Rezension;
private JLabel label2;
private JLabel label3;
private JLabel jLabel9;
private JLabel jLabel14;
private JCheckBox field_VLB;
private JTextField field_ISBN;
private JTextField field_Seiten;
private JTextField field_Auflage;
private JTextField field_Jahr;
private JLabel label4;
private JLabel label5;
private JLabel jLabel15;
private JLabel jLabel24;
private JTextField field_Preis;
private JTextField field_EK;
private JTextField field_Bestand;
private JCheckBox field_BLB;
private JButton btnBLB;
private JLabel jLabel13;
private JLabel jLabel12;
private JCheckBox field_DNB;
private JButton btnDNB;
private JTextField field_DruckNr;
private JComboBox<String> cbDruckerei;
private JLabel label6;
private JRadioButton rbPB;
private JRadioButton rbHC;
private JRadioButton rbKindle;
private JLabel jLabel16;
private JTextField field_Cover;
private JButton CoverAdd;
private JButton LabelBild;
private JLabel jLabel18;
private JTextField field_Text;
private JButton TextAdd;
private JLabel jLabel19;
private JTextField field_Flyer;
private JButton FlyerAdd;
private JLabel jLabel20;
private JTextField field_Vertrag;
private JButton VertragAdd;
private JLabel jLabel21;
private JTextField field_VertragBOD;
private JButton VertragBODAdd;
private JCheckBox field_Honorar;
private JTextField field_Honorar_Anzahl;
private JLabel jLabel22;
private JTextField field_Honorar_Prozent;
private JLabel jLabel23;
private JTextField field_Honorar_2_Anzahl;
private JLabel label8;
private JTextField field_Honorar_2_Prozent;
private JLabel label7;
private JButton Anfang;
private JButton Zurueck;
private JButton Vor;
private JButton Ende;
private JButton Update;
private JButton Einfuegen;
private JButton Loeschen;
private JButton Suchen;
private JButton WSuchen;
private JButton Drucken;
private JButton Schliessen;
private JLabel label9;
private JTextField field_Marge;
private JRadioButton field_Gesamtbetrachtung;
private JRadioButton field_BODgetrennt;
private JTextField field_BoDFix;
private JTextField field_BoDProzent;
private JLabel label10;
private JLabel label11;
private JTextField field_Cover_gross;
private JButton Flyer;
// End of variables declaration//GEN-END:variables
private JFileChooser chooser = new JFileChooser(new File(System.getProperty("user.dir")));
private Integer count = 0;
private Integer countMax = 0;
private Connection conn;
private Statement SQLAnfrage;
private Statement SQLAnfrage2;
private Statement SQLAnfrage_a;
private ResultSet result;
private ResultSet result_a;
private ResultSet result_d;
private boolean resultIsEmpty = true;
private String col_Autor = "";
private int col_Druckerei = 0;
private int maxID = 0;
//private String sFilePathAndName = "";
private String field_Anrede = "";
private String field_Autor = "";
private String field_Druckerei = "";
private JComboBox<String> cbAnrede = new JComboBox<>();
private String Kriterium = "";
private String SuchString = "";
private DefaultListModel<String> listModel = new DefaultListModel<>();
private String[] col_Autorliste;
//private JPanel Bild = new Background("Buch.jpg");
ButtonGroup buttonGroupBuchtyp = new ButtonGroup();
}
| ISO-8859-1 | Java | 144,940 | java | VerwaltenDatenbankBuch.java | Java | [
{
"context": "e notwendigen\n * Funktionen für die Verwaltung des Carola Hartman Miles-Verlags bereit.\n *\n * Copyright (C) 2017 EDV-Bera",
"end": 139,
"score": 0.9955164790153503,
"start": 119,
"tag": "NAME",
"value": "Carola Hartman Miles"
},
{
"context": "ung von SOftware\n * Dipl.Inform Thomas Zimmermann\n *\n * This program is free software: you can redi",
"end": 283,
"score": 0.9998005628585815,
"start": 266,
"tag": "NAME",
"value": "Thomas Zimmermann"
},
{
"context": "le;\nimport java.io.IOException;\n\n/**\n *\n * @author Thomas Zimmermann\n */\npublic class VerwaltenDatenbankBuch extends j",
"end": 1663,
"score": 0.9998210072517395,
"start": 1646,
"tag": "NAME",
"value": "Thomas Zimmermann"
},
{
"context": "dowConstants.DISPOSE_ON_CLOSE);\n setTitle(\"Carola Hartmann Miles Verlag\");\n setMinimumSize(new Dimension(970, 710)",
"end": 24138,
"score": 0.999069333076477,
"start": 24110,
"tag": "NAME",
"value": "Carola Hartmann Miles Verlag"
},
{
"context": "/---- jLabel12 ----\n jLabel12.setText(\"Druckerei\");\n jLabel12.setVerticalAlignment(Swin",
"end": 33664,
"score": 0.994540810585022,
"start": 33655,
"tag": "NAME",
"value": "Druckerei"
},
{
"context": " //---- label9 ----\n label9.setText(\"Marge\");\n panel1.add(label9);\n la",
"end": 45506,
"score": 0.9915207624435425,
"start": 45501,
"tag": "NAME",
"value": "Marge"
},
{
"context": ".setText(Integer.toString(count));\n\n // Schalterzustand anpassen\n Anfang.setEnabled(false);\n ",
"end": 49477,
"score": 0.9996737241744995,
"start": 49462,
"tag": "NAME",
"value": "Schalterzustand"
},
{
"context": " result.moveToInsertRow();\n // Schalterzustand anpassen\n Anfang.setEnabled(true);",
"end": 89114,
"score": 0.9957830309867859,
"start": 89099,
"tag": "NAME",
"value": "Schalterzustand"
},
{
"context": "uflage\", 1);\n result.updateString(\"Buch_Druckereinummer\", \"\");\n result.updateBoolean(\"Buch",
"end": 90186,
"score": 0.7420552968978882,
"start": 90166,
"tag": "NAME",
"value": "Buch_Druckereinummer"
},
{
"context": " if (result.getRow() > 0) {\n // Schalterzustand anpassen\n Anfang.setEnabled(tr",
"end": 98828,
"score": 0.972303032875061,
"start": 98813,
"tag": "NAME",
"value": "Schalterzustand"
},
{
"context": "sgeber.setSelected(false);\n\n // Schalterzustand anpassen\n Anfang.setEnabled(fa",
"end": 105745,
"score": 0.9558998942375183,
"start": 105730,
"tag": "NAME",
"value": "Schalterzustand"
},
{
"context": ") {\n * java.util.logging.Logger.getLogger(CarolaHartmannMilesVerlag.class.getName()).log(java.util.logging.Level.SEVE",
"end": 139557,
"score": 0.91231369972229,
"start": 139532,
"tag": "NAME",
"value": "CarolaHartmannMilesVerlag"
}
]
| null | []
| /*
*
* Das JAVA-Programm Miles-Verlag Verlagsverwaltung stellt alle notwendigen
* Funktionen für die Verwaltung des <NAME>-Verlags bereit.
*
* Copyright (C) 2017 EDV-Beratung und Betrieb, Entwicklung von SOftware
* Dipl.Inform <NAME>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package milesVerlagMain;
import java.awt.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.List;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.*;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.plaf.ActionMapUIResource;
import static milesVerlagMain.ModulMyOwnFocusTraversalPolicy.newPolicy;
import java.io.File;
import java.io.IOException;
/**
*
* @author <NAME>
*/
public class VerwaltenDatenbankBuch extends javax.swing.JDialog {
/**
* Creates new form VerwaltenDatenbankBuch
*
* @param parent
* @param modal
*/
private void IconAddActionPerformed(ActionEvent event) {
// TODO add your code here
String Dateiname = "";
if (chooser.showDialog(null, "Datei mit dem Icon wählen") == JFileChooser.APPROVE_OPTION) {
try {
Dateiname = chooser.getSelectedFile().getCanonicalPath();
System.out.println("Cover-Datei");
System.out.println("-> " + ModulHelferlein.pathUserDir);
System.out.println("-> " + ModulHelferlein.pathBuchprojekte);
System.out.println("-> " + Dateiname);
field_Cover.setText(Dateiname);
} catch (IOException ex) {
ModulHelferlein.Fehlermeldung("Exception: " + ex.getMessage());
}
}
}
private void FlyerActionPerformed(ActionEvent event) {
try {
// TODO add your code here
String ISBN = result.getString("BUCH_ISBN");
briefFlyer.bericht(ISBN, "PDF");
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch "
+ " WHERE BUCH_ID > '0' "
+ " ORDER BY BUCH_ISBN");
result.first();
while (!ISBN.equals(result.getString("BUCH_ISBN"))) {
result.next();
}
field_Flyer.setText(result.getString("BUCH_FLYER"));
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Flyer erstellen", "SQL-Exception", ex.getMessage());
}
}
public VerwaltenDatenbankBuch(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
buttonGroupBuchtyp.add(rbPB);
buttonGroupBuchtyp.add(rbHC);
buttonGroupBuchtyp.add(rbKindle);
Vector<Component> order = new Vector<>(38);
order.add(field_Titel);
order.add(cbHerausgeber);
order.add(field_ISBN);
order.add(field_Seiten);
order.add(field_Preis);
order.add(field_EK);
order.add(field_DruckNr);
order.add(field_Auflage);
order.add(field_Jahr);
order.add(field_Bestand);
order.add(cbDruckerei);
order.add(field_Cover_gross);
order.add(CoverAdd);
order.add(field_Text);
order.add(TextAdd);
order.add(field_Flyer);
order.add(FlyerAdd);
order.add(field_Vertrag);
order.add(VertragAdd);
order.add(field_VertragBOD);
order.add(VertragBODAdd);
order.add(field_Honorar);
order.add(field_Honorar_Anzahl);
order.add(field_Honorar_Prozent);
order.add(field_Aktiv);
order.add(Rezension);
order.add(field_VLB);
order.add(field_BLB);
order.add(btnBLB);
order.add(field_DNB);
order.add(btnDNB);
order.add(rbPB);
order.add(rbHC);
order.add(rbKindle);
order.add(Anfang);
order.add(Zurueck);
order.add(Vor);
order.add(Ende);
order.add(Update);
order.add(Einfuegen);
order.add(Loeschen);
order.add(Suchen);
order.add(WSuchen);
order.add(Drucken);
order.add(Schliessen);
newPolicy = new ModulMyOwnFocusTraversalPolicy(order);
setFocusTraversalPolicy(newPolicy);
lbAutor.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
ActionMap actionMap = new ActionMapUIResource();
actionMap.put("action_anfang", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
AnfangActionPerformed(e);
System.out.println("anfang action performed.");
}
});
actionMap.put("action_ende", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
EndeActionPerformed(e);
System.out.println("ende action performed.");
}
});
actionMap.put("action_vor", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
VorActionPerformed(e);
System.out.println("vor action performed.");
}
});
actionMap.put("action_zurueck", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
ZurueckActionPerformed(e);
System.out.println("zurueck action performed.");
}
});
actionMap.put("action_insert", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
EinfuegenActionPerformed(e);
System.out.println("insert action performed.");
}
});
actionMap.put("action_del", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
LoeschenActionPerformed(e);
System.out.println("del action performed.");
}
});
actionMap.put("action_save", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
UpdateActionPerformed(e);
System.out.println("Save action performed.");
}
});
actionMap.put("action_exit", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
SchliessenActionPerformed(e);
System.out.println("Exit action performed.");
}
});
actionMap.put("action_print", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
DruckenActionPerformed(e);
System.out.println("print action performed.");
}
});
InputMap keyMap = new ComponentInputMap(panel1);
//keyMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.Event.CTRL_MASK), "action_anfang");
//keyMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.Event.CTRL_MASK), "action_ende");
keyMap.put(KeyStroke.getKeyStroke("control alt A"), "action_anfang");
keyMap.put(KeyStroke.getKeyStroke("control alt E"), "action_ende");
keyMap.put(KeyStroke.getKeyStroke("control alt V"), "action_vor");
keyMap.put(KeyStroke.getKeyStroke("control alt Z"), "action_zurueck");
keyMap.put(KeyStroke.getKeyStroke("control alt I"), "action_insert");
keyMap.put(KeyStroke.getKeyStroke("control alt D"), "action_del");
keyMap.put(KeyStroke.getKeyStroke("control alt S"), "action_save");
keyMap.put(KeyStroke.getKeyStroke("control alt X"), "action_exit");
keyMap.put(KeyStroke.getKeyStroke("control alt P"), "action_print");
SwingUtilities.replaceUIActionMap(panel1, actionMap);
SwingUtilities.replaceUIInputMap(panel1, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
conn = null;
try { // Datenbank-Treiber laden
Class.forName(ModulHelferlein.dbDriver);
} catch (ClassNotFoundException exept) {
System.out.println("Treiber nicht gefunden: " + exept.getMessage());
System.exit(1);
} // Datenbank-Treiber laden
try { // Verbindung zur Datenbank ?ber die JDBC-Br?cke
conn = DriverManager.getConnection(ModulHelferlein.dbUrl, ModulHelferlein.dbUser, ModulHelferlein.dbPassword);
} catch (SQLException exept) {
System.out.println(
"Verbindung nicht moeglich: " + exept.getMessage());
System.exit(1);
} // try Verbindung zur Datenbank ?ber die JDBC-Br?cke
// final Connection conn2=conn;
if (conn != null) {
SQLAnfrage = null; // Anfrage erzeugen
SQLAnfrage2 = null; // Anfrage erzeugen
SQLAnfrage_a = null; // Anfrage erzeugen
try { // SQL-Anfragen an die Datenbank
SQLAnfrage = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
SQLAnfrage2 = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
SQLAnfrage_a = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); // Anfrage der DB conn2 zuordnen
// String eintragAnrede = "";
String eintragAutor = "";
// Auswahlliste f?r Autoren erstellen
result_a = SQLAnfrage_a.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_Typ = 'Autor' ORDER BY ADRESSEN_NAME"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
while (result_a.next()) {
eintragAutor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_NAME") + ", "
+ result_a.getString("ADRESSEN_VORNAME");
// eintragAnrede = result_a.getString("ADRESSEN_ANREDE");
listModel.addElement(eintragAutor);
// cbAnrede.addItem(eintragAnrede);
} // while
// Auswahlliste f?r Druckereien erstellen
eintragAutor = "";
result_d = SQLAnfrage.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_Typ = 'Druckerei'"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
while (result_d.next()) {
eintragAutor = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_NAME") + ", "
+ result_d.getString("ADRESSEN_VORNAME");
cbDruckerei.addItem(eintragAutor);
} // while
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch ORDER BY BUCH_ID DESC"); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
if (result.first()) {
maxID = result.getInt("Buch_ID");
} else {
maxID = 0;
}
result = SQLAnfrage.executeQuery("SELECT * FROM tbl_buch "
+ " WHERE BUCH_ID > '0' "
+ " ORDER BY BUCH_ISBN");
// Anzahl der Datens?tze ermitteln
countMax = 0;
count = 0;
field_count.setText(Integer.toString(count));
while (result.next()) {
++countMax;
}
field_countMax.setText(Integer.toString(countMax));
// gehe zum ersten Datensatz - wenn nicht leer
if (result.first()) {
count = 1;
field_count.setText(Integer.toString(count));
resultIsEmpty = false;
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
//col_Autor = result.getInt("BUCH_AUTOR");
//result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
//result_a.next();
//field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
//cbAutor.setSelectedItem(field_Autor);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//LabelBild.setIcon(new ImageIcon(ModulHelferlein.pathUserDir + "/" + result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_Honorar"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
field_Gesamtbetrachtung.setSelected(result.getBoolean("BUCH_GESAMTBETRACHTUNG"));
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
// Schalterzust?nde setzen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
} else {
// Schalterzust?nde setzen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(false);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(false);
Suchen.setEnabled(false);
WSuchen.setEnabled(false);
Drucken.setEnabled(false);
Schliessen.setEnabled(true);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung(
"SQL-Exception: SQL-Anfrage nicht moeglich: "
+ exept.getMessage());
// System.exit(1);
} // try SQL-Anfragen an die Datenbank
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
panel1 = new JPanel();
jScrollPane1 = new JScrollPane();
field_Beschreibung = new JTextArea();
jLabel17 = new JLabel();
jScrollPane2 = new JScrollPane();
lbAutor = new JList<>();
cbHerausgeber = new JCheckBox();
jLabel5 = new JLabel();
jLabel1 = new JLabel();
jLabel2 = new JLabel();
field_count = new JTextField();
label1 = new JLabel();
field_countMax = new JTextField();
jLabel4 = new JLabel();
field_ID = new JTextField();
field_Aktiv = new JCheckBox();
field_Titel = new JTextField();
jbtnBelegexemplar = new JButton();
Rezension = new JButton();
label2 = new JLabel();
label3 = new JLabel();
jLabel9 = new JLabel();
jLabel14 = new JLabel();
field_VLB = new JCheckBox();
field_ISBN = new JTextField();
field_Seiten = new JTextField();
field_Auflage = new JTextField();
field_Jahr = new JTextField();
label4 = new JLabel();
label5 = new JLabel();
jLabel15 = new JLabel();
jLabel24 = new JLabel();
field_Preis = new JTextField();
field_EK = new JTextField();
field_Bestand = new JTextField();
field_BLB = new JCheckBox();
btnBLB = new JButton();
jLabel13 = new JLabel();
jLabel12 = new JLabel();
field_DNB = new JCheckBox();
btnDNB = new JButton();
field_DruckNr = new JTextField();
cbDruckerei = new JComboBox<>();
label6 = new JLabel();
rbPB = new JRadioButton();
rbHC = new JRadioButton();
rbKindle = new JRadioButton();
jLabel16 = new JLabel();
field_Cover = new JTextField();
CoverAdd = new JButton();
LabelBild = new JButton();
jLabel18 = new JLabel();
field_Text = new JTextField();
TextAdd = new JButton();
jLabel19 = new JLabel();
field_Flyer = new JTextField();
FlyerAdd = new JButton();
jLabel20 = new JLabel();
field_Vertrag = new JTextField();
VertragAdd = new JButton();
jLabel21 = new JLabel();
field_VertragBOD = new JTextField();
VertragBODAdd = new JButton();
field_Honorar = new JCheckBox();
field_Honorar_Anzahl = new JTextField();
jLabel22 = new JLabel();
field_Honorar_Prozent = new JTextField();
jLabel23 = new JLabel();
field_Honorar_2_Anzahl = new JTextField();
label8 = new JLabel();
field_Honorar_2_Prozent = new JTextField();
label7 = new JLabel();
Anfang = new JButton();
Zurueck = new JButton();
Vor = new JButton();
Ende = new JButton();
Update = new JButton();
Einfuegen = new JButton();
Loeschen = new JButton();
Suchen = new JButton();
WSuchen = new JButton();
Drucken = new JButton();
Schliessen = new JButton();
label9 = new JLabel();
field_Marge = new JTextField();
field_Gesamtbetrachtung = new JRadioButton();
field_BODgetrennt = new JRadioButton();
field_BoDFix = new JTextField();
field_BoDProzent = new JTextField();
label10 = new JLabel();
label11 = new JLabel();
field_Cover_gross = new JTextField();
Flyer = new JButton();
//======== this ========
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("<NAME>");
setMinimumSize(new Dimension(970, 710));
setResizable(false);
setSize(new Dimension(750, 700));
setFont(new Font(Font.DIALOG, Font.BOLD, 12));
var contentPane = getContentPane();
contentPane.setLayout(null);
//======== panel1 ========
{
panel1.setPreferredSize(new Dimension(800, 658));
panel1.setLayout(null);
//======== jScrollPane1 ========
{
//---- field_Beschreibung ----
field_Beschreibung.setColumns(20);
field_Beschreibung.setLineWrap(true);
field_Beschreibung.setRows(5);
field_Beschreibung.setWrapStyleWord(true);
jScrollPane1.setViewportView(field_Beschreibung);
}
panel1.add(jScrollPane1);
jScrollPane1.setBounds(0, 282, 645, 104);
//---- jLabel17 ----
jLabel17.setText("Beschreibung");
panel1.add(jLabel17);
jLabel17.setBounds(0, 263, 141, jLabel17.getPreferredSize().height);
//======== jScrollPane2 ========
{
//---- lbAutor ----
lbAutor.setModel(listModel);
lbAutor.setValueIsAdjusting(true);
jScrollPane2.setViewportView(lbAutor);
}
panel1.add(jScrollPane2);
jScrollPane2.setBounds(0, 105, 325, 153);
//---- cbHerausgeber ----
cbHerausgeber.setText("Herausgeber");
panel1.add(cbHerausgeber);
cbHerausgeber.setBounds(0, 77, 195, cbHerausgeber.getPreferredSize().height);
//---- jLabel5 ----
jLabel5.setText("Titel");
panel1.add(jLabel5);
jLabel5.setBounds(0, 30, 49, jLabel5.getPreferredSize().height);
//---- jLabel1 ----
jLabel1.setFont(new Font("Tahoma", Font.BOLD, 12));
jLabel1.setText("Verwalten der Buchprojekte");
panel1.add(jLabel1);
jLabel1.setBounds(0, 0, 367, 25);
//---- jLabel2 ----
jLabel2.setText("Datensatz");
jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel2);
jLabel2.setBounds(423, 0, 57, 25);
//---- field_count ----
field_count.setEditable(false);
field_count.setHorizontalAlignment(SwingConstants.CENTER);
field_count.setText("000");
field_count.setEnabled(false);
field_count.setFocusable(false);
field_count.setMinimumSize(new Dimension(50, 25));
field_count.setPreferredSize(new Dimension(50, 25));
panel1.add(field_count);
field_count.setBounds(new Rectangle(new Point(485, 0), field_count.getPreferredSize()));
//---- label1 ----
label1.setText("von");
label1.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(label1);
label1.setBounds(540, 0, 40, 25);
//---- field_countMax ----
field_countMax.setEditable(false);
field_countMax.setHorizontalAlignment(SwingConstants.CENTER);
field_countMax.setText("000");
field_countMax.setEnabled(false);
field_countMax.setFocusable(false);
field_countMax.setMinimumSize(new Dimension(50, 25));
field_countMax.setName("");
field_countMax.setPreferredSize(new Dimension(50, 25));
panel1.add(field_countMax);
field_countMax.setBounds(new Rectangle(new Point(595, 0), field_countMax.getPreferredSize()));
//---- jLabel4 ----
jLabel4.setText("ID");
jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel4);
jLabel4.setBounds(655, 0, 25, 25);
//---- field_ID ----
field_ID.setEditable(false);
field_ID.setText("000");
field_ID.setEnabled(false);
field_ID.setFocusable(false);
panel1.add(field_ID);
field_ID.setBounds(691, 0, 64, 25);
//---- field_Aktiv ----
field_Aktiv.setText("Aktiv");
field_Aktiv.addActionListener(e -> field_AktivActionPerformed(e));
panel1.add(field_Aktiv);
field_Aktiv.setBounds(775, 0, 56, 25);
panel1.add(field_Titel);
field_Titel.setBounds(0, 49, 645, 23);
//---- jbtnBelegexemplar ----
jbtnBelegexemplar.setText("Belegexemplare");
jbtnBelegexemplar.addActionListener(e -> jbtnBelegexemplarActionPerformed(e));
panel1.add(jbtnBelegexemplar);
jbtnBelegexemplar.setBounds(675, 49, 156, jbtnBelegexemplar.getPreferredSize().height);
//---- Rezension ----
Rezension.setText("Rezension veranlassen");
Rezension.setToolTipText("Veranlasse eine Rezension f\u00fcr das aktuelle Buch");
Rezension.addActionListener(e -> RezensionActionPerformed(e));
panel1.add(Rezension);
Rezension.setBounds(675, 77, 156, Rezension.getPreferredSize().height);
//---- label2 ----
label2.setText("ISBN");
panel1.add(label2);
label2.setBounds(372, 105, 46, 23);
//---- label3 ----
label3.setText("Seiten");
panel1.add(label3);
label3.setBounds(485, 105, 50, 23);
//---- jLabel9 ----
jLabel9.setText("Auflage");
panel1.add(jLabel9);
jLabel9.setBounds(540, 105, 50, 23);
//---- jLabel14 ----
jLabel14.setText("Jahr");
panel1.add(jLabel14);
jLabel14.setBounds(595, 105, 50, 23);
//---- field_VLB ----
field_VLB.setText("Datensatz VLB angelegt");
panel1.add(field_VLB);
field_VLB.setBounds(675, 105, 156, field_VLB.getPreferredSize().height);
//---- field_ISBN ----
field_ISBN.setText("jTextField1");
field_ISBN.setMinimumSize(new Dimension(108, 25));
field_ISBN.setPreferredSize(new Dimension(108, 25));
panel1.add(field_ISBN);
field_ISBN.setBounds(new Rectangle(new Point(372, 133), field_ISBN.getPreferredSize()));
//---- field_Seiten ----
field_Seiten.setText("jTextField2");
field_Seiten.setMaximumSize(new Dimension(42, 25));
field_Seiten.setMinimumSize(new Dimension(42, 25));
field_Seiten.setPreferredSize(new Dimension(42, 25));
field_Seiten.addActionListener(e -> field_SeitenActionPerformed(e));
panel1.add(field_Seiten);
field_Seiten.setBounds(485, 133, field_Seiten.getPreferredSize().width, 25);
//---- field_Auflage ----
field_Auflage.setText("jTextField3");
field_Auflage.setMaximumSize(new Dimension(50, 20));
field_Auflage.setMinimumSize(new Dimension(50, 20));
field_Auflage.setPreferredSize(new Dimension(50, 25));
field_Auflage.addActionListener(e -> field_AuflageActionPerformed(e));
panel1.add(field_Auflage);
field_Auflage.setBounds(540, 133, 35, 25);
panel1.add(field_Jahr);
field_Jahr.setBounds(595, 133, 50, 25);
//---- label4 ----
label4.setText("VK");
panel1.add(label4);
label4.setBounds(372, 165, 46, label4.getPreferredSize().height);
//---- label5 ----
label5.setText("EK");
panel1.add(label5);
label5.setBounds(423, 165, 57, label5.getPreferredSize().height);
//---- jLabel15 ----
jLabel15.setText("Bestand");
panel1.add(jLabel15);
jLabel15.setBounds(595, 165, 50, jLabel15.getPreferredSize().height);
//---- jLabel24 ----
jLabel24.setText("Pflichtexemplare");
jLabel24.setFont(jLabel24.getFont().deriveFont(jLabel24.getFont().getStyle() | Font.BOLD));
panel1.add(jLabel24);
jLabel24.setBounds(675, 163, 156, jLabel24.getPreferredSize().height);
panel1.add(field_Preis);
field_Preis.setBounds(375, 185, 46, field_Preis.getPreferredSize().height);
panel1.add(field_EK);
field_EK.setBounds(425, 185, 57, field_EK.getPreferredSize().height);
panel1.add(field_Bestand);
field_Bestand.setBounds(595, 185, 50, field_Bestand.getPreferredSize().height);
//---- field_BLB ----
field_BLB.setText("Berl.Land.Bibl.");
panel1.add(field_BLB);
field_BLB.setBounds(new Rectangle(new Point(675, 182), field_BLB.getPreferredSize()));
//---- btnBLB ----
btnBLB.setText("D");
btnBLB.setToolTipText("Drucke Brief an die Berliner Landesbibliothek");
btnBLB.addActionListener(e -> btnBLBActionPerformed(e));
panel1.add(btnBLB);
btnBLB.setBounds(775, 182, 56, btnBLB.getPreferredSize().height);
//---- jLabel13 ----
jLabel13.setText("Druck.Nr.");
jLabel13.setVerticalAlignment(SwingConstants.BOTTOM);
panel1.add(jLabel13);
jLabel13.setBounds(372, 210, jLabel13.getPreferredSize().width, 23);
//---- jLabel12 ----
jLabel12.setText("Druckerei");
jLabel12.setVerticalAlignment(SwingConstants.BOTTOM);
panel1.add(jLabel12);
jLabel12.setBounds(485, 210, 50, 23);
//---- field_DNB ----
field_DNB.setText("Dt.Nat.Bibl.");
panel1.add(field_DNB);
field_DNB.setBounds(675, 210, 95, field_DNB.getPreferredSize().height);
//---- btnDNB ----
btnDNB.setText("D");
btnDNB.setToolTipText("Drucke Brief an die Deutsche Nationalbibliothek");
btnDNB.addActionListener(e -> btnDNBActionPerformed(e));
panel1.add(btnDNB);
btnDNB.setBounds(775, 210, 56, btnDNB.getPreferredSize().height);
panel1.add(field_DruckNr);
field_DruckNr.setBounds(372, 238, 108, field_DruckNr.getPreferredSize().height);
//---- cbDruckerei ----
cbDruckerei.setModel(new DefaultComboBoxModel<>(new String[] {
"Item 1",
"Item 2",
"Item 3",
"Item 4"
}));
cbDruckerei.addActionListener(e -> cbDruckereiActionPerformed(e));
panel1.add(cbDruckerei);
cbDruckerei.setBounds(485, 238, 160, cbDruckerei.getPreferredSize().height);
//---- label6 ----
label6.setText("Ausgabeart");
label6.setFont(label6.getFont().deriveFont(label6.getFont().getStyle() | Font.BOLD));
panel1.add(label6);
label6.setBounds(691, 263, 79, label6.getPreferredSize().height);
//---- rbPB ----
rbPB.setSelected(true);
rbPB.setText("Paperback");
panel1.add(rbPB);
rbPB.setBounds(691, 282, 140, rbPB.getPreferredSize().height);
//---- rbHC ----
rbHC.setText("Hardcover");
panel1.add(rbHC);
rbHC.setBounds(691, 310, 140, rbHC.getPreferredSize().height);
//---- rbKindle ----
rbKindle.setText("Kindle");
panel1.add(rbKindle);
rbKindle.setBounds(691, 338, 140, rbKindle.getPreferredSize().height);
//---- jLabel16 ----
jLabel16.setText("Cover");
jLabel16.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel16);
jLabel16.setBounds(100, 391, 41, 25);
//---- field_Cover ----
field_Cover.setText("jTextField11");
field_Cover.setPreferredSize(new Dimension(65, 25));
panel1.add(field_Cover);
field_Cover.setBounds(695, 560, 115, field_Cover.getPreferredSize().height);
//---- CoverAdd ----
CoverAdd.setText("...");
CoverAdd.setToolTipText("Auswahl der Bilddatei f\u00fcr das Buchcover");
CoverAdd.addActionListener(e -> CoverAddActionPerformed(e));
panel1.add(CoverAdd);
CoverAdd.setBounds(595, 391, 50, 25);
//---- LabelBild ----
LabelBild.setFocusable(false);
LabelBild.setHorizontalTextPosition(SwingConstants.CENTER);
LabelBild.setIconTextGap(0);
LabelBild.setPreferredSize(new Dimension(120, 160));
LabelBild.setToolTipText("Icon f\u00fcr das Buchcover");
LabelBild.setMinimumSize(new Dimension(120, 160));
LabelBild.setMaximumSize(new Dimension(120, 160));
LabelBild.setMargin(new Insets(0, 0, 0, 0));
LabelBild.addActionListener(e -> IconAddActionPerformed(e));
panel1.add(LabelBild);
LabelBild.setBounds(691, 391, 120, 160);
//---- jLabel18 ----
jLabel18.setText("Text");
jLabel18.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel18);
jLabel18.setBounds(100, 421, 41, 23);
panel1.add(field_Text);
field_Text.setBounds(146, 421, 444, 23);
//---- TextAdd ----
TextAdd.setText("...");
TextAdd.setToolTipText("Auswahl des Quelltextes f\u00fcr den Buchblock");
TextAdd.addActionListener(e -> TextAddActionPerformed(e));
panel1.add(TextAdd);
TextAdd.setBounds(595, 421, 50, TextAdd.getPreferredSize().height);
//---- jLabel19 ----
jLabel19.setText("Flyer");
jLabel19.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel19);
jLabel19.setBounds(100, 449, 41, 23);
panel1.add(field_Flyer);
field_Flyer.setBounds(146, 449, 444, 23);
//---- FlyerAdd ----
FlyerAdd.setText("...");
FlyerAdd.setToolTipText("Auswahl des Werbeflyers");
FlyerAdd.addActionListener(e -> FlyerAddActionPerformed(e));
panel1.add(FlyerAdd);
FlyerAdd.setBounds(595, 449, 50, FlyerAdd.getPreferredSize().height);
//---- jLabel20 ----
jLabel20.setText("Vertrag Autor");
jLabel20.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel20);
jLabel20.setBounds(54, 477, 87, 23);
panel1.add(field_Vertrag);
field_Vertrag.setBounds(146, 477, 444, 23);
//---- VertragAdd ----
VertragAdd.setText("...");
VertragAdd.setToolTipText("Auswahl des Vertrages mit dem Autor");
VertragAdd.addActionListener(e -> VertragAddActionPerformed(e));
panel1.add(VertragAdd);
VertragAdd.setBounds(595, 477, 50, VertragAdd.getPreferredSize().height);
//---- jLabel21 ----
jLabel21.setText("Vertrag BOD");
jLabel21.setHorizontalAlignment(SwingConstants.RIGHT);
panel1.add(jLabel21);
jLabel21.setBounds(54, 505, 87, 23);
panel1.add(field_VertragBOD);
field_VertragBOD.setBounds(146, 505, 444, 23);
//---- VertragBODAdd ----
VertragBODAdd.setText("...");
VertragBODAdd.setToolTipText("Auswahl des Vertrages mit BoD");
VertragBODAdd.addActionListener(e -> VertragBODAddActionPerformed(e));
panel1.add(VertragBODAdd);
VertragBODAdd.setBounds(595, 505, 50, VertragBODAdd.getPreferredSize().height);
//---- field_Honorar ----
field_Honorar.setText("Honorar auf der Basis");
field_Honorar.setActionCommand("Honorar");
panel1.add(field_Honorar);
field_Honorar.setBounds(0, 540, 155, 23);
//---- field_Honorar_Anzahl ----
field_Honorar_Anzahl.setMaximumSize(new Dimension(33, 25));
field_Honorar_Anzahl.setMinimumSize(new Dimension(33, 25));
field_Honorar_Anzahl.setPreferredSize(new Dimension(33, 25));
field_Honorar_Anzahl.addActionListener(e -> field_Honorar_AnzahlActionPerformed(e));
panel1.add(field_Honorar_Anzahl);
field_Honorar_Anzahl.setBounds(45, 570, field_Honorar_Anzahl.getPreferredSize().width, 20);
//---- jLabel22 ----
jLabel22.setText("St\u00fcck mit je");
panel1.add(jLabel22);
jLabel22.setBounds(90, 570, 83, 20);
//---- field_Honorar_Prozent ----
field_Honorar_Prozent.setMinimumSize(new Dimension(25, 30));
field_Honorar_Prozent.setPreferredSize(new Dimension(25, 25));
field_Honorar_Prozent.addActionListener(e -> field_Honorar_ProzentActionPerformed(e));
panel1.add(field_Honorar_Prozent);
field_Honorar_Prozent.setBounds(175, 570, 33, 20);
//---- jLabel23 ----
jLabel23.setText("% des Netto-VK pro St\u00fcck");
panel1.add(jLabel23);
jLabel23.setBounds(220, 570, 163, 20);
panel1.add(field_Honorar_2_Anzahl);
field_Honorar_2_Anzahl.setBounds(45, 600, 33, 20);
//---- label8 ----
label8.setText("St\u00fcck mit je");
panel1.add(label8);
label8.setBounds(90, 600, 83, 20);
panel1.add(field_Honorar_2_Prozent);
field_Honorar_2_Prozent.setBounds(175, 600, 33, 20);
//---- label7 ----
label7.setText("% des Netto-VK pro St\u00fcck");
panel1.add(label7);
label7.setBounds(220, 600, 163, 20);
//---- Anfang ----
Anfang.setText("<<");
Anfang.setToolTipText("gehe zum ersten Datensatz");
Anfang.addActionListener(e -> AnfangActionPerformed(e));
panel1.add(Anfang);
Anfang.setBounds(0, 635, 49, 23);
//---- Zurueck ----
Zurueck.setText("<");
Zurueck.setToolTipText("gehe zum vorherigen Datensatz");
Zurueck.addActionListener(e -> ZurueckActionPerformed(e));
panel1.add(Zurueck);
Zurueck.setBounds(50, 635, 49, Zurueck.getPreferredSize().height);
//---- Vor ----
Vor.setText(">");
Vor.setToolTipText("gehe zum n\u00e4chsten Datensatz");
Vor.addActionListener(e -> VorActionPerformed(e));
panel1.add(Vor);
Vor.setBounds(95, 635, 49, Vor.getPreferredSize().height);
//---- Ende ----
Ende.setText(">>");
Ende.setToolTipText("gehe zum letzten Datensatz");
Ende.addActionListener(e -> EndeActionPerformed(e));
panel1.add(Ende);
Ende.setBounds(145, 635, 49, Ende.getPreferredSize().height);
//---- Update ----
Update.setText("!");
Update.setToolTipText("Datensatz aktualisieren");
Update.addActionListener(e -> UpdateActionPerformed(e));
panel1.add(Update);
Update.setBounds(205, 635, 49, Update.getPreferredSize().height);
//---- Einfuegen ----
Einfuegen.setText("+");
Einfuegen.setToolTipText("Datensatz einf\u00fcgen");
Einfuegen.addActionListener(e -> EinfuegenActionPerformed(e));
panel1.add(Einfuegen);
Einfuegen.setBounds(255, 635, 49, Einfuegen.getPreferredSize().height);
//---- Loeschen ----
Loeschen.setText("-");
Loeschen.setToolTipText("Datensatz l\u00f6schen");
Loeschen.addActionListener(e -> LoeschenActionPerformed(e));
panel1.add(Loeschen);
Loeschen.setBounds(305, 635, 49, Loeschen.getPreferredSize().height);
//---- Suchen ----
Suchen.setText("?");
Suchen.setToolTipText("Suche nach Autor, Titel, ISBN oder Druckereinummer");
Suchen.addActionListener(e -> SuchenActionPerformed(e));
panel1.add(Suchen);
Suchen.setBounds(365, 635, 49, Suchen.getPreferredSize().height);
//---- WSuchen ----
WSuchen.setText("...");
WSuchen.setToolTipText("Weitersuchen");
WSuchen.addActionListener(e -> WSuchenActionPerformed(e));
panel1.add(WSuchen);
WSuchen.setBounds(415, 635, 49, WSuchen.getPreferredSize().height);
//---- Drucken ----
Drucken.setText("D");
Drucken.setToolTipText("Druckt das aktuelle Buchprojekt als PDF");
Drucken.addActionListener(e -> DruckenActionPerformed(e));
panel1.add(Drucken);
Drucken.setBounds(475, 635, 49, Drucken.getPreferredSize().height);
//---- Schliessen ----
Schliessen.setText("X");
Schliessen.setToolTipText("Schlie\u00dft den Dialog");
Schliessen.addActionListener(e -> SchliessenActionPerformed(e));
panel1.add(Schliessen);
Schliessen.setBounds(595, 635, 49, Schliessen.getPreferredSize().height);
//---- label9 ----
label9.setText("Marge");
panel1.add(label9);
label9.setBounds(new Rectangle(new Point(485, 165), label9.getPreferredSize()));
panel1.add(field_Marge);
field_Marge.setBounds(485, 185, 45, field_Marge.getPreferredSize().height);
//---- field_Gesamtbetrachtung ----
field_Gesamtbetrachtung.setText("Gesamtumfang");
field_Gesamtbetrachtung.setSelected(true);
panel1.add(field_Gesamtbetrachtung);
field_Gesamtbetrachtung.setBounds(155, 540, 225, field_Gesamtbetrachtung.getPreferredSize().height);
//---- field_BODgetrennt ----
field_BODgetrennt.setText("BoD getrennt betrachtet");
panel1.add(field_BODgetrennt);
field_BODgetrennt.setBounds(500, 540, 170, field_BODgetrennt.getPreferredSize().height);
panel1.add(field_BoDFix);
field_BoDFix.setBounds(390, 570, 30, 20);
panel1.add(field_BoDProzent);
field_BoDProzent.setBounds(390, 600, 30, field_BoDProzent.getPreferredSize().height);
//---- label10 ----
label10.setText("Fix-Betrag BoD");
panel1.add(label10);
label10.setBounds(430, 570, 100, 20);
//---- label11 ----
label11.setText("% Marge BoD");
panel1.add(label11);
label11.setBounds(430, 600, 80, 20);
panel1.add(field_Cover_gross);
field_Cover_gross.setBounds(145, 390, 444, 23);
//---- Flyer ----
Flyer.setText("F");
Flyer.setToolTipText("Werbeflyer erstellen");
Flyer.addActionListener(e -> FlyerActionPerformed(e));
panel1.add(Flyer);
Flyer.setBounds(535, 635, 49, Flyer.getPreferredSize().height);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < panel1.getComponentCount(); i++) {
Rectangle bounds = panel1.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = panel1.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
panel1.setMinimumSize(preferredSize);
panel1.setPreferredSize(preferredSize);
}
}
contentPane.add(panel1);
panel1.setBounds(10, 10, 970, 670);
{
// compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
setSize(860, 720);
setLocationRelativeTo(getOwner());
//---- buttonGroup1 ----
var buttonGroup1 = new ButtonGroup();
buttonGroup1.add(field_Gesamtbetrachtung);
buttonGroup1.add(field_BODgetrennt);
}// </editor-fold>//GEN-END:initComponents
private void AnfangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AnfangActionPerformed
// TODO add your handling code here:
try {
result.first();
count = 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild);Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ","
// + result_a.getString("ADRESSEN_Name") + ","
// + result_a.getString("ADRESSEN_Vorname") + ","
// + result_a.getString("ADRESSEN_ANREDE");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
System.out.println("Anfang: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Anfang:");
}
}//GEN-LAST:event_AnfangActionPerformed
private void ZurueckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ZurueckActionPerformed
// TODO add your handling code here:
try {
if (result.previous()) {
count = count - 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
if (count > 1) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
} else {
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
}
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
result.next();
}
System.out.println("Zurück auf ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Zurück");
}
}//GEN-LAST:event_ZurueckActionPerformed
private void VorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VorActionPerformed
// TODO add your handling code here:
try {
if (result.next()) {
count = count + 1;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
if (count < countMax) {
Ende.setEnabled(true);
Vor.setEnabled(true);
} else {
Ende.setEnabled(false);
Vor.setEnabled(false);
}
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild);Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
result.previous();
}
System.out.println("Vor auf ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Vor");
}
}//GEN-LAST:event_VorActionPerformed
private void EndeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EndeActionPerformed
// TODO add your handling code here:
try {
result.last();
count = countMax;
field_count.setText(Integer.toString(count));
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("Buch_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
System.out.println("Ende: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
System.out.println("Ende");
}
}//GEN-LAST:event_EndeActionPerformed
private void UpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UpdateActionPerformed
// TODO add your handling code here:
try {
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Anzahl der Seiten - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Jahr.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Erscheinungsjahres - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Bestand.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Buchbestandes - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Auflage.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Auflage- es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Preises - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_EK.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des EK-Preises - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_Marge.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Marge - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Anzahl.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Verkeuafsanzahl für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_2_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_2_Anzahl.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe der Verkeuafsanzahl für Honorare - es ist keine korrekte Ganzzahl");
} else {
if (ModulHelferlein.checkNumberFormatFloat(field_BoDFix.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Fix-Anteils der BoD-Marge - es ist keine korrekte Zahl");
} else {
if (ModulHelferlein.checkNumberFormatInt(field_Honorar_Prozent.getText()) < 0) {
ModulHelferlein.Infomeldung("fehlerhafte Eingabe des Prozentwertes der BoD-Marge - es ist keine korrekte Ganzzahl");
} else {
result.updateString("Buch_Titel", field_Titel.getText());
result.updateFloat("Buch_EK", Float.parseFloat(field_EK.getText()));
result.updateFloat("Buch_Marge", Float.parseFloat(field_Marge.getText()));
result.updateFloat("Buch_Preis", Float.parseFloat(field_Preis.getText()));
result.updateString("Buch_ISBN", field_ISBN.getText());
result.updateInt("Buch_Seiten", Integer.parseInt(field_Seiten.getText()));
result.updateString("Buch_Beschreibung", field_Beschreibung.getText());
result.updateInt("Buch_Auflage", Integer.parseInt(field_Auflage.getText()));
result.updateString("BUCH_JAHR", field_Jahr.getText());
result.updateString("Buch_Druckereinummer", field_DruckNr.getText());
result.updateBoolean("Buch_DeuNatBibl", field_DNB.isSelected());
result.updateBoolean("Buch_BerlLBibl", field_BLB.isSelected());
result.updateBoolean("Buch_VLB", field_VLB.isSelected());
if (field_Gesamtbetrachtung.isSelected()) {
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", true);
} else {
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", false);
}
result.updateFloat("Buch_BODFIX", Float.parseFloat(field_BoDFix.getText()));
result.updateInt("Buch_Bestand", Integer.parseInt(field_Bestand.getText()));
result.updateInt("Buch_BODPROZENT", Integer.parseInt(field_BoDProzent.getText()));
result.updateString("Buch_Cover", field_Cover.getText());
result.updateString("Buch_Cover_gross", field_Cover_gross.getText());
result.updateString("Buch_Flyer", field_Flyer.getText());
result.updateString("Buch_Vertrag", field_Vertrag.getText());
result.updateString("Buch_BOD_Vertrag", field_VertragBOD.getText());
result.updateString("Buch_Text", field_Text.getText());
result.updateInt("Buch_Druckerei", Integer.parseInt(field_Druckerei.split(",")[0]));
result.updateBoolean("Buch_Honorar", field_Honorar.isSelected());
result.updateInt("Buch_Honorar_Prozent", Integer.parseInt(field_Honorar_Prozent.getText()));
result.updateInt("Buch_Honorar_Anzahl", Integer.parseInt(field_Honorar_Anzahl.getText()));
result.updateInt("Buch_Honorar_2_Prozent", Integer.parseInt(field_Honorar_2_Prozent.getText()));
result.updateInt("Buch_Honorar_2_Anzahl", Integer.parseInt(field_Honorar_2_Anzahl.getText()));
result.updateBoolean("BUCH_AKTIV", field_Aktiv.isSelected());
result.updateBoolean("Buch_HERAUSGEBER", cbHerausgeber.isSelected());
if (rbPB.isSelected()) {
result.updateInt("BUCH_HC", 0);
} else if (rbHC.isSelected()) {
result.updateInt("BUCH_HC", 1);
} else {
result.updateInt("BUCH_HC", 2);
}
List<String> ListeAutoren = lbAutor.getSelectedValuesList();
String EintragAutor = "";
String strAuswahl = "";
for (int i = 0, n = ListeAutoren.size(); i < n; i++) {
strAuswahl = ListeAutoren.get(i);
String[] splitAutor = strAuswahl.split(",");
EintragAutor = EintragAutor + splitAutor[0] + ",";
}
EintragAutor = EintragAutor.substring(0, EintragAutor.length() - 1);
result.updateString("Buch_Autor", EintragAutor);
result.updateRow();
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
System.out.println("Update: ID: " + field_ID.getText() + ", ISBN: " + field_ISBN.getText());
}
}
}
}
}
}
}
}
}
}
}
}
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}//GEN-LAST:event_UpdateActionPerformed
private void EinfuegenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EinfuegenActionPerformed
// TODO add your handling code here:
int ID;
String eingabeISBN = JOptionPane.showInputDialog(null, "Geben Sie die ISBN ein",
"Neues Buchprojekt",
JOptionPane.PLAIN_MESSAGE);
//helferlein.Infomeldung(helferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag BoD/");
if (!"".equals(eingabeISBN)) {
while (eingabeISBN.endsWith(" ")) {
eingabeISBN = eingabeISBN.substring(0, eingabeISBN.length() - 1);
}
File dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Schriftverkehr/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag Autor/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/1/Vertrag BoD/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Belegexemplare/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Cover/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Pflichtexemplare/");
dir.mkdir();
dir = new File(ModulHelferlein.pathBuchprojekte + "/" + eingabeISBN + "/Rezensionen/");
dir.mkdir();
try {
ID = maxID + 1;
maxID = maxID + 1;
result.moveToInsertRow();
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
result.updateInt("Buch_ID", ID);
result.updateString("Buch_Titel", "");
result.updateFloat("Buch_Preis", 0);
result.updateFloat("Buch_EK", 0);
result.updateFloat("Buch_Marge", 0);
result.updateString("Buch_ISBN", eingabeISBN);
result.updateInt("Buch_Seiten", 0);
result.updateString("Buch_Beschreibung", "");
result.updateString("BUCH_JAHR", "");
result.updateInt("Buch_Auflage", 1);
result.updateString("Buch_Druckereinummer", "");
result.updateBoolean("Buch_DeuNatBibl", false);
result.updateBoolean("Buch_DeuNatBibl", false);
result.updateInt("Buch_Bestand", 0);
result.updateString("Buch_Cover", "Buch.jpg");
result.updateString("Buch_Cover_GROSS", "Buch.jpg");
result.updateString("Buch_Flyer", "");
result.updateString("Buch_Vertrag", "");
result.updateString("Buch_BOD_Vertrag", "");
result.updateString("Buch_Text", "");
result.updateBoolean("Buch_Honorar", true);
result.updateBoolean("Buch_Herausgeber", false);
result.updateBoolean("Buch_VLB", false);
result.updateBoolean("BUCH_GESAMTBETRACHTUNG", true);
result.updateInt("Buch_Honorar_Anzahl", 0);
result.updateInt("Buch_BODPROZENT", 0);
result.updateFloat("Buch_BODFIX", 0);
result.updateInt("Buch_Honorar_Prozent", 0);
result.updateInt("Buch_Honorar_2_Anzahl", 0);
result.updateInt("Buch_Honorar_2_Prozent", 0);
result.updateBoolean("BUCH_HC", false);
List<String> ListeAutoren = lbAutor.getSelectedValuesList();
String EintragAutor = "";
String strAuswahl = "";
for (int i = 0, n = ListeAutoren.size(); i < n; i++) {
strAuswahl = ListeAutoren.get(i);
String[] splitAutor = strAuswahl.split(",");
EintragAutor = EintragAutor + splitAutor[0] + ",";
}
EintragAutor = EintragAutor.substring(0, EintragAutor.length() - 1);
result.updateString("Buch_Autor", EintragAutor);
result.updateInt("Buch_Druckerei", Integer.parseInt(((String) cbDruckerei.getSelectedItem()).split(",")[0]));
result.updateInt("BUCH_HC", 0);
result.updateBoolean("BUCH_AKTIV", true);
result.updateBoolean("BUCH_HERAUSGEBER", false);
result.insertRow();
countMax = countMax + 1;
field_countMax.setText(Integer.toString(countMax));
count = countMax;
field_count.setText(Integer.toString(count));
resultIsEmpty = false;
result.last();
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background("Buch.jpg");this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: Einf?gen: " + exept.getMessage());
}
} else {
ModulHelferlein.Infomeldung("ohne ISBN kein Buchprojekt!");
} // if
}//GEN-LAST:event_EinfuegenActionPerformed
private void LoeschenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoeschenActionPerformed
// TODO add your handling code here:
if (JOptionPane.showConfirmDialog(null, "Soll der Datensatz wirklich gelöscht werden?") == JOptionPane.YES_OPTION) {
try {
result.deleteRow();
countMax = countMax - 1;
field_countMax.setText(Integer.toString(countMax));
count = 1;
field_count.setText(Integer.toString(count));
result.first();
if (result.getRow() > 0) {
// Schalterzustand anpassen
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
//Bild = new Background(result.getString("Buch_COVER"));this.add(Bild); Bild.setBounds(520, 350, 120, 160);
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
resultIsEmpty = true;
field_ID.setText("");
field_Titel.setText("");
field_Preis.setText("");
field_EK.setText("");
field_ISBN.setText("");
field_Seiten.setText("");
field_Beschreibung.setText("");
field_Auflage.setText("");
field_DruckNr.setText("");
field_Jahr.setText("");
field_DNB.setSelected(false);
field_BLB.setSelected(false);
field_VLB.setSelected(false);
field_Bestand.setText("");
field_Cover.setText("");
field_Cover_gross.setText("");
field_Flyer.setText("");
field_Vertrag.setText("");
field_VertragBOD.setText("");
field_Text.setText("");
cbDruckerei.setSelectedItem("");
field_Honorar.setSelected(false);
field_Aktiv.setSelected(true);
cbHerausgeber.setSelected(false);
// Schalterzustand anpassen
Anfang.setEnabled(false);
Zurueck.setEnabled(false);
Vor.setEnabled(false);
Ende.setEnabled(false);
Update.setEnabled(false);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(false);
Suchen.setEnabled(false);
WSuchen.setEnabled(false);
Drucken.setEnabled(false);
Schliessen.setEnabled(true);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}
}//GEN-LAST:event_LoeschenActionPerformed
private void SuchenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SuchenActionPerformed
// TODO add your handling code here:
boolean gefunden = false;
String[] Kriterien = {"Autor", "Titel", "ISBN", "BOD-Nummer", "Jahr"};
Kriterium = (String) JOptionPane.showInputDialog(null,
"Suchen",
"Nach was soll gesucht werden?",
JOptionPane.QUESTION_MESSAGE,
null, Kriterien,
Kriterien[2]);
if (Kriterium != null) {
try {
result.first();
count = 1;
switch (Kriterium) {
case "ISBN":
SuchString = field_ISBN.getText();
break;
case "Titel":
SuchString = field_Titel.getText();
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
break;
case "BOD-Nummer":
SuchString = field_DruckNr.getText();
break;
case "Jahr":
SuchString = field_Jahr.getText();
break;
}
do {
field_count.setText(Integer.toString(count));
switch (Kriterium) {
case "ISBN":
if (result.getString("BUCH_ISBN").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
if (lbAutor.getSelectedValue().contains(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Titel":
if (result.getString("BUCH_TITEL").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "BOD-Nummer":
if (result.getString("Buch_Druckereinummer").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Jahr":
if (result.getString("BUCH_JAHR").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
}
} while ((!gefunden) && result.next());
if (gefunden) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_count.setText(Integer.toString(count));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
// col_Autor = result.getInt("BUCH_AUTOR");
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
// lbAutor.setSelectedValue(field_Autor, true);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
ModulHelferlein.Infomeldung(Kriterium + " wurde nicht gefunden!");
AnfangActionPerformed(evt);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}
}//GEN-LAST:event_SuchenActionPerformed
private void WSuchenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WSuchenActionPerformed
// TODO add your handling code here:
boolean gefunden = false;
try {
result.next();
do {
switch (Kriterium) {
case "ISBN":
if (result.getString("BUCH_ISBN").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Autor":
SuchString = result.getString("BUCH_Autor");
if (lbAutor.getSelectedValue().contains(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Titel":
if (result.getString("BUCH_TITEL").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "BOD-Nummer":
if (result.getString("Buch_Druckereinummer").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
case "Jahr":
if (result.getString("BUCH_JAHR").equals(SuchString)) {
gefunden = true;
} else {
count = count + 1;
}
break;
}
} while ((!gefunden) && result.next());
if (gefunden) {
Anfang.setEnabled(true);
Zurueck.setEnabled(true);
Vor.setEnabled(true);
Ende.setEnabled(true);
Update.setEnabled(true);
Einfuegen.setEnabled(true);
Loeschen.setEnabled(true);
Suchen.setEnabled(true);
WSuchen.setEnabled(true);
Drucken.setEnabled(true);
Schliessen.setEnabled(true);
field_count.setText(Integer.toString(count));
cbHerausgeber.setSelected(result.getBoolean("BUCH_HERAUSGEBER"));
field_ID.setText(Integer.toString(result.getInt("Buch_ID")));
field_Titel.setText(result.getString("Buch_Titel"));
field_Preis.setText(Float.toString(result.getFloat("Buch_Preis")));
field_EK.setText(Float.toString(result.getFloat("Buch_EK")));
field_Marge.setText(Float.toString(result.getFloat("Buch_Marge")));
field_ISBN.setText(result.getString("Buch_ISBN"));
field_Seiten.setText(Integer.toString(result.getInt("BUCH_SEITEN")));
field_Beschreibung.setText(result.getString("BUCH_BESCHREIBUNG"));
field_Auflage.setText(Integer.toString(result.getInt("BUCH_AUFLAGE")));
field_DruckNr.setText(result.getString("Buch_Druckereinummer"));
field_Jahr.setText(result.getString("Buch_JAHR"));
field_DNB.setSelected(result.getBoolean("Buch_DEUNATBIBL"));
field_BLB.setSelected(result.getBoolean("Buch_BERLLBIBL"));
field_VLB.setSelected(result.getBoolean("Buch_VLB"));
field_Bestand.setText(Integer.toString(result.getInt("Buch_Bestand")));
field_Cover.setText(result.getString("Buch_COVER"));
field_Cover_gross.setText(result.getString("Buch_COVER_GROSS"));
field_Flyer.setText(result.getString("Buch_FLYER"));
field_Vertrag.setText(result.getString("Buch_VERTRAG"));
field_VertragBOD.setText(result.getString("Buch_BOD_VERTRAG"));
field_Text.setText(result.getString("Buch_TEXT"));
field_Honorar.setSelected(result.getBoolean("Buch_HONORAR"));
field_Honorar_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_ANZAHL")));
field_Honorar_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_PROZENT")));
field_Honorar_2_Anzahl.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_ANZAHL")));
field_Honorar_2_Prozent.setText(Integer.toString(result.getInt("BUCH_HONORAR_2_PROZENT")));
field_Aktiv.setSelected(result.getBoolean("BUCH_AKTIV"));
if (result.getBoolean("BUCH_GESAMTBETRACHTUNG")) {
field_Gesamtbetrachtung.setSelected(true);
} else {
field_BODgetrennt.setSelected(true);
}
field_BoDProzent.setText(Integer.toString(result.getInt("BUCH_BODPROZENT")));
field_BoDFix.setText(Float.toString(result.getFloat("BUCH_BODFIX")));
switch (result.getInt("Buch_HC")) {
case 0:
rbPB.setSelected(true);
break;
case 1:
rbHC.setSelected(true);
break;
case 2:
rbKindle.setSelected(true);
break;
}
LabelBild.setIcon(new ImageIcon(result.getString("BUCH_COVER")));
// col_Autor = result.getInt("BUCH_AUTOR");
// lbAutor.setSelectedValue(field_Autor, true);
// result_a = SQLAnfrage2.executeQuery(
// "SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Autor)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
// result_a.next();
// field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
// + result_a.getString("ADRESSEN_Name") + ", "
// + result_a.getString("ADRESSEN_Vorname");
// cbAutor.setSelectedItem(field_Autor);
col_Autor = result.getString("BUCH_AUTOR");
col_Autorliste = col_Autor.split(",");
int[] select;
select = new int[col_Autorliste.length];
int selcount = 0;
for (String strAutor : col_Autorliste) {
result_a = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + strAutor);
result_a.next();
field_Autor = Integer.toString(result_a.getInt("ADRESSEN_ID")) + ", "
+ result_a.getString("ADRESSEN_Name") + ", "
+ result_a.getString("ADRESSEN_Vorname");
lbAutor.setSelectedValue(field_Autor, true);
select[selcount] = lbAutor.getSelectedIndex();
selcount = selcount + 1;
}
lbAutor.setSelectedIndices(select);
col_Druckerei = result.getInt("BUCH_DRUCKEREI");
result_d = SQLAnfrage2.executeQuery(
"SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = " + Integer.toString(col_Druckerei)); // schickt SQL an DB und erzeugt ergebnis -> wird in result gespeichert
result_d.next();
field_Druckerei = Integer.toString(result_d.getInt("ADRESSEN_ID")) + ", "
+ result_d.getString("ADRESSEN_Name") + ", "
+ result_d.getString("ADRESSEN_Vorname");
cbDruckerei.setSelectedItem(field_Druckerei);
} else {
ModulHelferlein.Infomeldung(Kriterium + " wurde nicht gefunden!");
AnfangActionPerformed(evt);
}
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
}//GEN-LAST:event_WSuchenActionPerformed
private void DruckenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DruckenActionPerformed
// TODO add your handling code here:
berBuch.Buch(field_ID.getText(), 1);
}//GEN-LAST:event_DruckenActionPerformed
private void SchliessenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SchliessenActionPerformed
// TODO add your handling code here:
try {
result.close();
SQLAnfrage.close();
conn.close();
} catch (SQLException exept) {
ModulHelferlein.Fehlermeldung("SQL-Exception: " + exept.getMessage());
}
this.dispose();
}//GEN-LAST:event_SchliessenActionPerformed
private void btnDNBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDNBActionPerformed
try {
// TODO add your handling code here:
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + ", ";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 2);
String Autor[] = field_Autor.split(", ");
field_Autor = "";
for (int i = 1; i < Autor.length; i = i + 3) {
field_Autor = field_Autor + Autor[i] + ", " + Autor[i + 1] + "; ";
}
field_Autor = field_Autor.substring(0, field_Autor.length() - 2) + ".";
String[] args = {"Pflichtexemplar", // 0
"DNB", // 1
field_Autor, // 2
field_Titel.getText(), // 3
field_ISBN.getText(), // 4
field_Jahr.getText(), // 5
result.getString("BUCH_ID")}; // 6
_DlgAusgabeFormat.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Drucke Pflichtexemplar Deutsche Nationalbibliothek", "SQL-Exception", ex.getMessage());
}
}//GEN-LAST:event_btnDNBActionPerformed
private void btnBLBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBLBActionPerformed
try {
// TODO add your handling code here:
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + ", ";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 2);
String Autor[] = field_Autor.split(", ");
field_Autor = "";
for (int i = 1; i < Autor.length; i = i + 3) {
field_Autor = field_Autor + Autor[i] + ", " + Autor[i + 1] + "; ";
}
field_Autor = field_Autor.substring(0, field_Autor.length() - 2) + ".";
String[] args = {"Pflichtexemplar", "BLB", field_Autor, field_Titel.getText(), field_ISBN.getText(), field_Jahr.getText(), result.getString("BUCH_ID")};
_DlgAusgabeFormat.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Drucke Pflichtexemplar Berliner Landesbibliothek", "SQL-Exception", ex.getMessage());
}
}//GEN-LAST:event_btnBLBActionPerformed
private void RezensionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RezensionActionPerformed
// dlgRezension fenster = new dlgRezension();
VerwaltenDatenbankRezensionAus.main(null);
/*
try {
// TODO add your handling code here:
String CmdLine;
String[] args;
field_Autor = "";
List selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + "#";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 1);
result_a = SQLAnfrage_a.executeQuery("SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = '"
+ field_Autor.split(",")[0]
+ "'");
result_a.next();
field_Anrede = result_a.getString("ADRESSEN_ANREDE");
CmdLine = field_Anrede + "!"
+ field_Autor + "!"
+ field_Titel.getText() + "!"
+ field_Beschreibung.getText() + "!"
+ field_ISBN.getText() + "!"
+ field_Preis.getText() + "!"
+ field_Seiten.getText() + "!"
+ result.getString("BUCH_ID") + "!"
+ "1" + "!"
+ "1";
//helferlein.Infomeldung(CmdLine);
args = CmdLine.split("!");
//helferlein.Infomeldung(args[1]);
_DlgRezensionErzeugen.main(args);
} catch (SQLException ex) {
Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
}
*/
}//GEN-LAST:event_RezensionActionPerformed
private void CoverAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CoverAddActionPerformed
// TODO add your handling code here:
String Dateiname = "";
if (chooser.showDialog(null, "Datei mit dem Cover wählen") == JFileChooser.APPROVE_OPTION) {
try {
Dateiname = chooser.getSelectedFile().getCanonicalPath();
System.out.println("Cover-Datei");
System.out.println("-> " + ModulHelferlein.pathUserDir);
System.out.println("-> " + ModulHelferlein.pathBuchprojekte);
System.out.println("-> " + Dateiname);
field_Cover_gross.setText(Dateiname);
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_CoverAddActionPerformed
private void TextAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Quelltext wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Text.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_TextAddActionPerformed
private void FlyerAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FlyerAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Flyer wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Flyer.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_FlyerAddActionPerformed
private void VertragAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VertragAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem Autorenvertrag wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_Vertrag.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_VertragAddActionPerformed
private void VertragBODAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VertragBODAddActionPerformed
// TODO add your handling code here:
if (chooser.showDialog(null, "Datei mit dem BOD-Vertrag wählen") == JFileChooser.APPROVE_OPTION) {
try {
field_VertragBOD.setText(chooser.getSelectedFile().getCanonicalPath());
} catch (IOException e) {
ModulHelferlein.Fehlermeldung("Exception: " + e.getMessage());
}
}
}//GEN-LAST:event_VertragBODAddActionPerformed
private void cbDruckereiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDruckereiActionPerformed
// TODO add your handling code here:
field_Druckerei = (String) cbDruckerei.getSelectedItem();
}//GEN-LAST:event_cbDruckereiActionPerformed
private void field_SeitenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_SeitenActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_SeitenActionPerformed
private void field_BestandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_BestandActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_BestandActionPerformed
private void field_Honorar_AnzahlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_Honorar_AnzahlActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_Honorar_AnzahlActionPerformed
private void field_Honorar_ProzentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_Honorar_ProzentActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_Honorar_ProzentActionPerformed
private void field_AuflageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_AuflageActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_AuflageActionPerformed
private void field_JahrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_JahrActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatInt(field_Seiten.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Ganzzahl");
}
}//GEN-LAST:event_field_JahrActionPerformed
private void field_PreisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_PreisActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Zahl");
}
}//GEN-LAST:event_field_PreisActionPerformed
private void field_EKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_EKActionPerformed
// TODO add your handling code here:
if (ModulHelferlein.checkNumberFormatFloat(field_Preis.getText()) < 0) {
ModulHelferlein.Fehlermeldung("fehlerhafte Eingabe - die ist keine korrekte Zahl");
}
}//GEN-LAST:event_field_EKActionPerformed
private void field_AktivActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_field_AktivActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_field_AktivActionPerformed
private void jbtnBelegexemplarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnBelegexemplarActionPerformed
// TODO add your handling code here:
try {
// TODO add your handling code here:
String CmdLine;
String[] args;
field_Autor = "";
List<String> selectedValues = lbAutor.getSelectedValuesList();
selectedValues.forEach((selectedValue) -> {
field_Autor = field_Autor + (String) selectedValue + "#";
});
field_Autor = field_Autor.substring(0, field_Autor.length() - 1);
result_a = SQLAnfrage_a.executeQuery("SELECT * FROM tbl_adresse WHERE ADRESSEN_ID = '"
+ field_Autor.split(",")[0]
+ "'");
result_a.next();
field_Anrede = result_a.getString("ADRESSEN_ANREDE");
CmdLine = field_Anrede + "!"
+ field_Autor + "!"
+ field_Titel.getText() + "!"
+ field_Beschreibung.getText() + "!"
+ field_ISBN.getText() + "!"
+ field_Preis.getText() + "!"
+ field_Seiten.getText() + "!"
+ result.getString("BUCH_ID") + "!"
+ "1" + "!"
+ "1";
//helferlein.Infomeldung(CmdLine);
args = CmdLine.split("!");
//helferlein.Infomeldung(args[1]);
_DlgBelegexemplareErzeugen.main(args);
} catch (SQLException ex) {
ModulHelferlein.Fehlermeldung("Belegexemplar erzeugen", ex.getMessage());
//Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jbtnBelegexemplarActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
/**
* try { for (javax.swing.UIManager.LookAndFeelInfo info :
* javax.swing.UIManager.getInstalledLookAndFeels()) { if
* ("Nimbus".equals(info.getName())) {
* javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } }
* } catch (ClassNotFoundException | InstantiationException |
* IllegalAccessException | javax.swing.UnsupportedLookAndFeelException
* ex) {
* java.util.logging.Logger.getLogger(CarolaHartmannMilesVerlag.class.getName()).log(java.util.logging.Level.SEVERE,
* null, ex); }
*/
//</editor-fold>
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(() -> {
VerwaltenDatenbankBuch dialog = new VerwaltenDatenbankBuch(new javax.swing.JFrame(), true);
// try {
// javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
// Logger.getLogger(VerwaltenDatenbankBuch.class.getName()).log(Level.SEVERE, null, ex);
// }
// SwingUtilities.updateComponentTreeUI(dialog);
// updateComponentTreeUI(dialog);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dialog.setVisible(false);
}
});
dialog.setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private JPanel panel1;
private JScrollPane jScrollPane1;
private JTextArea field_Beschreibung;
private JLabel jLabel17;
private JScrollPane jScrollPane2;
private JList<String> lbAutor;
private JCheckBox cbHerausgeber;
private JLabel jLabel5;
private JLabel jLabel1;
private JLabel jLabel2;
private JTextField field_count;
private JLabel label1;
private JTextField field_countMax;
private JLabel jLabel4;
private JTextField field_ID;
private JCheckBox field_Aktiv;
private JTextField field_Titel;
private JButton jbtnBelegexemplar;
private JButton Rezension;
private JLabel label2;
private JLabel label3;
private JLabel jLabel9;
private JLabel jLabel14;
private JCheckBox field_VLB;
private JTextField field_ISBN;
private JTextField field_Seiten;
private JTextField field_Auflage;
private JTextField field_Jahr;
private JLabel label4;
private JLabel label5;
private JLabel jLabel15;
private JLabel jLabel24;
private JTextField field_Preis;
private JTextField field_EK;
private JTextField field_Bestand;
private JCheckBox field_BLB;
private JButton btnBLB;
private JLabel jLabel13;
private JLabel jLabel12;
private JCheckBox field_DNB;
private JButton btnDNB;
private JTextField field_DruckNr;
private JComboBox<String> cbDruckerei;
private JLabel label6;
private JRadioButton rbPB;
private JRadioButton rbHC;
private JRadioButton rbKindle;
private JLabel jLabel16;
private JTextField field_Cover;
private JButton CoverAdd;
private JButton LabelBild;
private JLabel jLabel18;
private JTextField field_Text;
private JButton TextAdd;
private JLabel jLabel19;
private JTextField field_Flyer;
private JButton FlyerAdd;
private JLabel jLabel20;
private JTextField field_Vertrag;
private JButton VertragAdd;
private JLabel jLabel21;
private JTextField field_VertragBOD;
private JButton VertragBODAdd;
private JCheckBox field_Honorar;
private JTextField field_Honorar_Anzahl;
private JLabel jLabel22;
private JTextField field_Honorar_Prozent;
private JLabel jLabel23;
private JTextField field_Honorar_2_Anzahl;
private JLabel label8;
private JTextField field_Honorar_2_Prozent;
private JLabel label7;
private JButton Anfang;
private JButton Zurueck;
private JButton Vor;
private JButton Ende;
private JButton Update;
private JButton Einfuegen;
private JButton Loeschen;
private JButton Suchen;
private JButton WSuchen;
private JButton Drucken;
private JButton Schliessen;
private JLabel label9;
private JTextField field_Marge;
private JRadioButton field_Gesamtbetrachtung;
private JRadioButton field_BODgetrennt;
private JTextField field_BoDFix;
private JTextField field_BoDProzent;
private JLabel label10;
private JLabel label11;
private JTextField field_Cover_gross;
private JButton Flyer;
// End of variables declaration//GEN-END:variables
private JFileChooser chooser = new JFileChooser(new File(System.getProperty("user.dir")));
private Integer count = 0;
private Integer countMax = 0;
private Connection conn;
private Statement SQLAnfrage;
private Statement SQLAnfrage2;
private Statement SQLAnfrage_a;
private ResultSet result;
private ResultSet result_a;
private ResultSet result_d;
private boolean resultIsEmpty = true;
private String col_Autor = "";
private int col_Druckerei = 0;
private int maxID = 0;
//private String sFilePathAndName = "";
private String field_Anrede = "";
private String field_Autor = "";
private String field_Druckerei = "";
private JComboBox<String> cbAnrede = new JComboBox<>();
private String Kriterium = "";
private String SuchString = "";
private DefaultListModel<String> listModel = new DefaultListModel<>();
private String[] col_Autorliste;
//private JPanel Bild = new Background("Buch.jpg");
ButtonGroup buttonGroupBuchtyp = new ButtonGroup();
}
| 144,882 | 0.544844 | 0.532865 | 2,838 | 50.066242 | 32.018017 | 185 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.865751 | false | false | 9 |
c71ce3b7f1ebd2619b110bc17e49f93b50c066a0 | 23,338,852,318,285 | bf2ddb1279417276a3c5d2f38e8ad19ff9365087 | /src/main/java/com/fanbo/model/response/LoginResponse.java | b8cfe00cb4b213507528c9701c5d08f318297b39 | []
| no_license | ybfanbo/websvr-composite | https://github.com/ybfanbo/websvr-composite | d4b06edae6c221db6a3e5a55d034136401837f1c | ea79e20d7cfb0bd3b0ab7b6af6a607dab066dc28 | refs/heads/master | 2022-12-05T10:10:19.334000 | 2020-08-23T02:39:27 | 2020-08-23T02:39:27 | 280,291,025 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fanbo.model.response;
public class LoginResponse {
}
| UTF-8 | Java | 66 | java | LoginResponse.java | Java | []
| null | []
| package com.fanbo.model.response;
public class LoginResponse {
}
| 66 | 0.787879 | 0.787879 | 4 | 15.5 | 15.107944 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 9 |
584ff15b60a6768169e306706e754e0a7d9b6456 | 20,401,094,681,542 | af2b0e531d534e980c3680641d7a37d0a9c18aef | /src/exercise/chapter1/EX1416ClosestPair1D.java | 99bdb1ec339a3318d436fcaacbb3df45d29aad11 | []
| no_license | whuTangYue/Algorithm | https://github.com/whuTangYue/Algorithm | c8309ed4f42acaad3987f100b8a359cea44baeb5 | 1049f6534b7be6a76bba4349abfe023e11f66d37 | refs/heads/master | 2021-01-21T12:31:05.722000 | 2018-07-11T03:05:04 | 2018-07-11T03:05:04 | 102,078,086 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package exercise.chapter1;
import java.util.Arrays;
public class EX1416ClosestPair1D {
public static double[] closestPair(double[] nums){
if(nums==null||nums.length<2) return new double[0];
if(nums.length==2) return nums;
Arrays.sort(nums);//O(nlogn)
double[] m=new double[2];
double min=Double.POSITIVE_INFINITY;
double d=0;
for(int i =0;i<nums.length-1;i++){
d=Math.abs(nums[i+1]-nums[i]);
if(d==0) return new double[]{nums[i],nums[i+1]};
else if (d<min){m[0]=nums[i];m[1]=nums[i+1];min=d;}
} //O(n)
return m;
}
public static void main(String[] args) {
double[] nums = {1.1,2.2,3.2,4.3,3.4,2.5,9.4,1.5,3.6,4.9,10.0};
System.out.println(Arrays.toString(nums));
System.out.println(Arrays.toString(closestPair(nums)));
}
}
| UTF-8 | Java | 801 | java | EX1416ClosestPair1D.java | Java | []
| null | []
| package exercise.chapter1;
import java.util.Arrays;
public class EX1416ClosestPair1D {
public static double[] closestPair(double[] nums){
if(nums==null||nums.length<2) return new double[0];
if(nums.length==2) return nums;
Arrays.sort(nums);//O(nlogn)
double[] m=new double[2];
double min=Double.POSITIVE_INFINITY;
double d=0;
for(int i =0;i<nums.length-1;i++){
d=Math.abs(nums[i+1]-nums[i]);
if(d==0) return new double[]{nums[i],nums[i+1]};
else if (d<min){m[0]=nums[i];m[1]=nums[i+1];min=d;}
} //O(n)
return m;
}
public static void main(String[] args) {
double[] nums = {1.1,2.2,3.2,4.3,3.4,2.5,9.4,1.5,3.6,4.9,10.0};
System.out.println(Arrays.toString(nums));
System.out.println(Arrays.toString(closestPair(nums)));
}
}
| 801 | 0.621723 | 0.569288 | 31 | 23.838709 | 21.068394 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.322581 | false | false | 9 |
ab0447933390819ae300fa09bfe632d44f7cf884 | 17,549,236,403,006 | 5516cb4f94317c4bc13de1390b6ebac6a7ac9bd6 | /Test/src/main/java/stand/pcm/tx/CurrentVoltageSensor.java | 5490ea403d5b41d3a75ef2c71ee0a77d1bd45f22 | []
| no_license | SharyfIsmail/Stand-java | https://github.com/SharyfIsmail/Stand-java | 66b05d9f46490cf81ab60b067c10da36641b600b | ac78c88d15b26f6e1074a915146461e63570c3bf | refs/heads/master | 2023-02-12T03:27:44.708000 | 2021-01-14T09:33:43 | 2021-01-14T09:33:43 | 270,939,861 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package stand.pcm.tx;
import stand.can.CanCdr;
import stand.can.candata.DataFromCan;
import stand.util.BigEndByteParser;
public class CurrentVoltageSensor extends CanCdr implements DataFromCan {
private int current;
private int voltage;
private String error; // 65535(current) - Current_Voltage_Sensor not connected
private byte contactorsManagement; // 0 - Contractor OFF
// 1 - Contractor ON
// 3 - without changes
private byte powerDriverStatus; // 0 - Error
// 1 - Normal operation
@Override
public void parseDataFromCan(byte[] data) {
if (data.length == 8) {
byte[] b2 = new byte[2];
System.arraycopy(data, 0, b2, 0, b2.length);
int current = BigEndByteParser.unsignedIntToInt(b2);
if (current == 65535) {
error = "Current_Sensor not connected";
} else {
this.current = current;
error = null;
}
System.arraycopy(data, 2, b2, 0, b2.length);
voltage = BigEndByteParser.unsignedIntToInt(b2);
contactorsManagement = data[4];
powerDriverStatus = data[5];
} else {
throw new IndexOutOfBoundsException("длинна data не равна 8 байтам. data.length=" + data.length);
}
}
/**
* Get value in A
*/
public float getCurrent() {
return (float) ((current - 5000) * 0.1);
}
/**
* Get value in V
*/
public float getVoltage() {
return (float) (voltage * 0.1);
}
/**
* Get "Contractor OFF" if value 0 "Contractor ON" if value 1 "without changes"
* if value 3 "wrong value" if value is not 0,1,3
*/
public String getContactorsManagement() {
if (contactorsManagement == 0) {
return "contactor OFF";
} else if (contactorsManagement == 1) {
return "contactor ON";
} else if (contactorsManagement == 3) {
return "without changes";
} else {
return "wrong value: " + contactorsManagement;
}
}
/**
* Get "Normal operation" if value 1 "Error" if value 0 "wrong value" if value
* is not 0,1
*/
public String getPowerDriverStatus() {
if (powerDriverStatus == 1) {
return "Normal operation";
} else if (powerDriverStatus == 0) {
return "Error";
} else {
return "wrong value: " + powerDriverStatus;
}
}
public String getError() {
return error;
}
}
| UTF-8 | Java | 2,218 | java | CurrentVoltageSensor.java | Java | []
| null | []
| package stand.pcm.tx;
import stand.can.CanCdr;
import stand.can.candata.DataFromCan;
import stand.util.BigEndByteParser;
public class CurrentVoltageSensor extends CanCdr implements DataFromCan {
private int current;
private int voltage;
private String error; // 65535(current) - Current_Voltage_Sensor not connected
private byte contactorsManagement; // 0 - Contractor OFF
// 1 - Contractor ON
// 3 - without changes
private byte powerDriverStatus; // 0 - Error
// 1 - Normal operation
@Override
public void parseDataFromCan(byte[] data) {
if (data.length == 8) {
byte[] b2 = new byte[2];
System.arraycopy(data, 0, b2, 0, b2.length);
int current = BigEndByteParser.unsignedIntToInt(b2);
if (current == 65535) {
error = "Current_Sensor not connected";
} else {
this.current = current;
error = null;
}
System.arraycopy(data, 2, b2, 0, b2.length);
voltage = BigEndByteParser.unsignedIntToInt(b2);
contactorsManagement = data[4];
powerDriverStatus = data[5];
} else {
throw new IndexOutOfBoundsException("длинна data не равна 8 байтам. data.length=" + data.length);
}
}
/**
* Get value in A
*/
public float getCurrent() {
return (float) ((current - 5000) * 0.1);
}
/**
* Get value in V
*/
public float getVoltage() {
return (float) (voltage * 0.1);
}
/**
* Get "Contractor OFF" if value 0 "Contractor ON" if value 1 "without changes"
* if value 3 "wrong value" if value is not 0,1,3
*/
public String getContactorsManagement() {
if (contactorsManagement == 0) {
return "contactor OFF";
} else if (contactorsManagement == 1) {
return "contactor ON";
} else if (contactorsManagement == 3) {
return "without changes";
} else {
return "wrong value: " + contactorsManagement;
}
}
/**
* Get "Normal operation" if value 1 "Error" if value 0 "wrong value" if value
* is not 0,1
*/
public String getPowerDriverStatus() {
if (powerDriverStatus == 1) {
return "Normal operation";
} else if (powerDriverStatus == 0) {
return "Error";
} else {
return "wrong value: " + powerDriverStatus;
}
}
public String getError() {
return error;
}
}
| 2,218 | 0.658481 | 0.633924 | 90 | 23.433332 | 22.088232 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.2 | false | false | 9 |
fdfdc2cf0fd6cc462fbe64ee0881ca32b51cbd4b | 15,238,544,003,888 | 3f9f2250447ff64240eeafd20eeba0e9123d7831 | /src/main/java/org/ocsoft/flatlaf/extended/tree/WebExTree.java | 1ed5e811407537464820870393625a4eec748a58 | []
| no_license | tohhy/flatlaf | https://github.com/tohhy/flatlaf | 351f363a4b87f88040d735d484fac4240842a468 | ae9b87cae5e247c649eb15cd19cf56c3584710ce | refs/heads/master | 2016-09-05T12:48:19.708000 | 2016-01-20T12:55:59 | 2016-01-20T12:55:59 | 28,683,550 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/
package org.ocsoft.flatlaf.extended.tree;
import java.awt.Point;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import org.ocsoft.flatlaf.extended.tree.sample.SampleExDataProvider;
import org.ocsoft.flatlaf.extended.tree.sample.SampleTreeCellEditor;
import org.ocsoft.flatlaf.extended.tree.sample.SampleTreeCellRenderer;
import org.ocsoft.flatlaf.utils.collection.CollectionUtils;
import org.ocsoft.flatlaf.utils.general.Filter;
import org.ocsoft.flatlaf.weblaf.tree.UniqueNode;
import org.ocsoft.flatlaf.weblaf.tree.WebTree;
import org.ocsoft.flatlaf.weblaf.tree.WebTreeCellEditor;
import org.ocsoft.flatlaf.weblaf.tree.WebTreeCellRenderer;
/**
* WebTree extension that provides simple and convenient way to load tree data.
* Simply implement ExTreeDataProvider interface and pass it into the tree to
* create its structure.
*
* @author Mikle Garin
* @see org.ocsoft.flatlaf.extended.tree.ExTreeModel
* @see org.ocsoft.flatlaf.extended.tree.ExTreeDataProvider
*/
public class WebExTree<E extends UniqueNode> extends WebTree<E> {
/**
* Tree nodes comparator.
*/
protected Comparator<E> comparator;
/**
* Tree nodes filter.
*/
protected Filter<E> filter;
/**
* Constructs sample ex tree.
*/
public WebExTree() {
super();
// Installing sample data provider
setDataProvider(new SampleExDataProvider());
// Tree cell renderer & editor
setCellRenderer(new SampleTreeCellRenderer());
setCellEditor(new SampleTreeCellEditor());
}
/**
* Costructs ex tree using data from the custom data provider.
*
* @param dataProvider
* custom data provider
*/
public WebExTree(final ExTreeDataProvider dataProvider) {
super();
// Installing data provider
setDataProvider(dataProvider);
// Tree cell renderer & editor
setCellRenderer(new WebTreeCellRenderer());
setCellEditor(new WebTreeCellEditor());
}
/**
* Returns ex tree data provider.
*
* @return data provider
*/
public ExTreeDataProvider<E> getDataProvider() {
final TreeModel model = getModel();
return model != null && model instanceof ExTreeModel ? getExModel()
.getDataProvider() : null;
}
/**
* Changes data provider for this ex tree.
*
* @param dataProvider
* new data provider
*/
public void setDataProvider(final ExTreeDataProvider dataProvider) {
if (dataProvider != null) {
final ExTreeDataProvider<E> oldDataProvider = getDataProvider();
// Updating model
// Be aware that all the data will be loaded right away
setModel(new ExTreeModel<E>(this, dataProvider));
// Informing about data provider change
firePropertyChange(TREE_DATA_PROVIDER_PROPERTY, oldDataProvider,
dataProvider);
}
}
/**
* Returns tree nodes comparator.
*
* @return tree nodes comparator
*/
public Comparator<E> getComparator() {
return comparator;
}
/**
* Sets tree nodes comparator. Comparator replacement will automatically
* update all loaded nodes sorting.
*
* @param comparator
* tree nodes comparator
*/
public void setComparator(final Comparator<E> comparator) {
final Comparator<E> oldComparator = this.comparator;
this.comparator = comparator;
final ExTreeDataProvider dataProvider = getDataProvider();
if (dataProvider instanceof AbstractExTreeDataProvider) {
((AbstractExTreeDataProvider) dataProvider)
.setChildsComparator(comparator);
updateSortingAndFiltering();
}
firePropertyChange(TREE_COMPARATOR_PROPERTY, oldComparator, comparator);
}
/**
* Removes any applied tree nodes comparator.
*/
public void clearComparator() {
setComparator(null);
}
/**
* Returns tree nodes filter.
*
* @return tree nodes filter
*/
public Filter<E> getFilter() {
return filter;
}
/**
* Sets tree nodes filter. Comparator replacement will automatically
* re-filter all loaded nodes.
*
* @param filter
* tree nodes filter
*/
public void setFilter(final Filter<E> filter) {
final Filter<E> oldFilter = this.filter;
this.filter = filter;
final ExTreeDataProvider dataProvider = getDataProvider();
if (dataProvider instanceof AbstractExTreeDataProvider) {
((AbstractExTreeDataProvider) dataProvider).setChildsFilter(filter);
updateSortingAndFiltering();
}
firePropertyChange(TREE_FILTER_PROPERTY, oldFilter, filter);
}
/**
* Removes any applied tree nodes filter.
*/
public void clearFilter() {
setFilter(null);
}
/**
* Updates nodes sorting and filtering for all loaded nodes.
*/
public void updateSortingAndFiltering() {
getExModel().updateSortingAndFiltering();
}
/**
* Updates sorting and filtering for the specified node childs.
*/
public void updateSortingAndFiltering(final E node) {
getExModel().updateSortingAndFiltering(node);
}
/**
* Returns ex tree model.
*
* @return ex tree model
*/
public ExTreeModel<E> getExModel() {
return (ExTreeModel<E>) getModel();
}
/**
* Returns whether ex tree model is installed or not.
*
* @return true if ex tree model is installed, false otherwise
*/
public boolean isExModel() {
final TreeModel model = getModel();
return model != null && model instanceof ExTreeModel;
}
/**
* Sets child nodes for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param children
* new node children
*/
public void setChildNodes(final E parent, final List<E> children) {
getExModel().setChildNodes(parent, children);
}
/**
* Adds child node for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param child
* new node child
*/
public void addChildNode(final E parent, final E child) {
getExModel().addChildNodes(parent, Arrays.asList(child));
}
/**
* Adds child nodes for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param children
* new node children
*/
public void addChildNodes(final E parent, final List<E> children) {
getExModel().addChildNodes(parent, children);
}
/**
* Inserts a list of child nodes into parent node. This method might be used
* to manually change tree node childs without causing any structure
* corruptions.
*
* @param children
* list of new child nodes
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNodes(final List<E> children, final E parent,
final int index) {
getExModel().insertNodesInto(children, parent, index);
}
/**
* Inserts an array of child nodes into parent node. This method might be
* used to manually change tree node childs without causing any structure
* corruptions.
*
* @param children
* array of new child nodes
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNodes(final E[] children, final E parent,
final int index) {
getExModel().insertNodesInto(children, parent, index);
}
/**
* Inserts child node into parent node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param child
* new child node
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNode(final E child, final E parent, final int index) {
getExModel().insertNodeInto(child, parent, index);
}
/**
* Removes node with the specified ID from tree structure. This method will
* have effect only if node exists.
*
* @param nodeId
* ID of the node to remove
* @return true if tree structure was changed by the operation, false
* otherwise
*/
public boolean removeNode(final String nodeId) {
return removeNode(findNode(nodeId));
}
/**
* Removes node from tree structure. This method will have effect only if
* node exists.
*
* @param node
* node to remove
* @return true if tree structure was changed by the operation, false
* otherwise
*/
public boolean removeNode(final E node) {
final boolean exists = node != null && node.getParent() != null;
if (exists) {
getExModel().removeNodeFromParent(node);
}
return exists;
}
/**
* Removes nodes from tree structure. This method will have effect only if
* nodes exist.
*
* @param nodes
* list of nodes to remove
*/
public void removeNodes(final List<E> nodes) {
getExModel().removeNodesFromParent(nodes);
}
/**
* Removes nodes from tree structure. This method will have effect only if
* nodes exist.
*
* @param nodes
* array of nodes to remove
*/
public void removeNodes(final E[] nodes) {
getExModel().removeNodesFromParent(nodes);
}
/**
* Looks for the node with the specified ID in the tree model and returns it
* or null if it was not found.
*
* @param nodeId
* node ID
* @return node with the specified ID or null if it was not found
*/
public E findNode(final String nodeId) {
return getExModel().findNode(nodeId);
}
/**
* Forces tree node with the specified ID to be updated.
*
* @param nodeId
* ID of the tree node to be updated
*/
public void updateNode(final String nodeId) {
updateNode(findNode(nodeId));
}
/**
* Forces tree node to be updated.
*
* @param node
* tree node to be updated
*/
public void updateNode(final E node) {
getExModel().updateNode(node);
// todo Should actually perform this here (but need to improve filter
// interface methods - add cache clear methods)
// updateSortingAndFiltering ( ( E ) node.getParent () );
}
/**
* Forces tree node structure with the specified ID to be updated.
*
* @param nodeId
* ID of the tree node to be updated
*/
public void updateNodeStructure(final String nodeId) {
updateNodeStructure(findNode(nodeId));
}
/**
* Forces tree node structure with the specified ID to be updated.
*
* @param node
* tree node to be updated
*/
public void updateNodeStructure(final E node) {
getExModel().updateNodeStructure(node);
}
/**
* Reloads selected node childs.
*/
public void reloadSelectedNodes() {
// Checking that selection is not empty
final TreePath[] paths = getSelectionPaths();
if (paths != null) {
// Reloading all selected nodes
for (final TreePath path : paths) {
// Checking if node is not null and not busy yet
final E node = getNodeForPath(path);
if (node != null) {
// Reloading node childs
performReload(node, path, false);
}
}
}
}
/**
* Reloads node under the specified point.
*
* @param point
* point to look for node
* @return reloaded node or null if none reloaded
*/
public E reloadNodeUnderPoint(final Point point) {
return reloadNodeUnderPoint(point.x, point.y);
}
/**
* Reloads node under the specified point.
*
* @param x
* point X coordinate
* @param y
* point Y coordinate
* @return reloaded node or null if none reloaded
*/
public E reloadNodeUnderPoint(final int x, final int y) {
return reloadPath(getPathForLocation(x, y));
}
/**
* Reloads root node childs.
*
* @return reloaded root node
*/
public E reloadRootNode() {
return reloadNode(getRootNode());
}
/**
* Reloads node with the specified ID.
*
* @param nodeId
* ID of the node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final String nodeId) {
return reloadNode(findNode(nodeId));
}
/**
* Reloads specified node childs.
*
* @param node
* node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final E node) {
return reloadNode(node, false);
}
/**
* Reloads specified node childs and selects it if requested.
*
* @param node
* node to reload
* @param select
* whether select the node or not
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final E node, final boolean select) {
// Checking that node is not null
if (node != null) {
// Reloading node childs
performReload(node, getPathForNode(node), select);
return node;
}
return null;
}
/**
* Reloads node childs at the specified path.
*
* @param path
* path of the node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadPath(final TreePath path) {
return reloadPath(path, false);
}
/**
* Reloads node childs at the specified path and selects it if needed.
*
* @param path
* path of the node to reload
* @param select
* whether select the node or not
* @return reloaded node or null if none reloaded
*/
public E reloadPath(final TreePath path, final boolean select) {
// Checking that path is not null
if (path != null) {
// Checking if node is not null and not busy yet
final E node = getNodeForPath(path);
if (node != null) {
// Reloading node childs
performReload(node, path, select);
return node;
}
}
return null;
}
/**
* Performs the actual reload call.
*
* @param node
* node to reload
* @param path
* path to node
* @param select
* whether select the node or not
*/
protected void performReload(final E node, final TreePath path,
final boolean select) {
// Select node under the mouse
if (select && !isPathSelected(path)) {
setSelectionPath(path);
}
// Expand the selected node since the collapsed node will ignore reload
// call
// In case the node childs were not loaded yet this call will cause it
// to load childs
if (!isExpanded(path)) {
expandPath(path);
}
// Reload selected node childs
// This won't be called if node was not loaded yet since expand would
// call load before
if (node != null) {
getExModel().reload(node);
}
}
/**
* Expands node with the specified ID.
*
* @param nodeId
* ID of the node to expand
*/
public void expandNode(final String nodeId) {
expandNode(findNode(nodeId));
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
*/
public void expandPath(final List<String> pathNodeIds) {
expandPath(pathNodeIds, true, true);
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
* @param expandLastNode
* whether should expand last found path node or not
*/
public void expandPath(final List<String> pathNodeIds,
final boolean expandLastNode) {
expandPath(pathNodeIds, expandLastNode, true);
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
public void expandPath(final List<String> pathNodeIds,
final boolean expandLastNode, final boolean selectLastNode) {
final List<String> ids = CollectionUtils.copy(pathNodeIds);
for (int initial = 0; initial < ids.size(); initial++) {
final E initialNode = findNode(ids.get(initial));
if (initialNode != null) {
for (int i = 0; i <= initial; i++) {
ids.remove(i);
}
if (ids.size() > 0) {
expandPathImpl(initialNode, ids, expandLastNode,
selectLastNode);
}
return;
}
}
}
/**
* Performs a single path node expansion. Be aware that operation might stop
* even before reaching the end of the path if something unexpected
* happened.
*
* @param currentNode
* last reached node
* @param leftToExpand
* node path IDs left for expansion
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
protected void expandPathImpl(final E currentNode,
final List<String> leftToExpand, final boolean expandLastNode,
final boolean selectLastNode) {
// There is still more to load
if (leftToExpand.size() > 0) {
// Expanding already loaded node
expandNode(currentNode);
// Retrieving next node
final E nextNode = findNode(leftToExpand.get(0));
leftToExpand.remove(0);
// If node exists continue expanding path
if (nextNode != null) {
expandPathImpl(nextNode, leftToExpand, expandLastNode,
selectLastNode);
} else {
expandPathEndImpl(currentNode, expandLastNode, selectLastNode);
}
} else {
expandPathEndImpl(currentNode, expandLastNode, selectLastNode);
}
}
/**
* Finishes async tree path expansion.
*
* @param lastFoundNode
* last found path node
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
protected void expandPathEndImpl(final E lastFoundNode,
final boolean expandLastNode, final boolean selectLastNode) {
if (selectLastNode) {
setSelectedNode(lastFoundNode);
}
if (expandLastNode) {
expandNode(lastFoundNode);
}
}
} | UTF-8 | Java | 21,974 | java | WebExTree.java | Java | [
{
"context": "the tree to\n * create its structure.\n *\n * @author Mikle Garin\n * @see org.ocsoft.flatlaf.extended.tree.ExTreeMo",
"end": 1692,
"score": 0.9998432397842407,
"start": 1681,
"tag": "NAME",
"value": "Mikle Garin"
}
]
| null | []
| /*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/
package org.ocsoft.flatlaf.extended.tree;
import java.awt.Point;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import org.ocsoft.flatlaf.extended.tree.sample.SampleExDataProvider;
import org.ocsoft.flatlaf.extended.tree.sample.SampleTreeCellEditor;
import org.ocsoft.flatlaf.extended.tree.sample.SampleTreeCellRenderer;
import org.ocsoft.flatlaf.utils.collection.CollectionUtils;
import org.ocsoft.flatlaf.utils.general.Filter;
import org.ocsoft.flatlaf.weblaf.tree.UniqueNode;
import org.ocsoft.flatlaf.weblaf.tree.WebTree;
import org.ocsoft.flatlaf.weblaf.tree.WebTreeCellEditor;
import org.ocsoft.flatlaf.weblaf.tree.WebTreeCellRenderer;
/**
* WebTree extension that provides simple and convenient way to load tree data.
* Simply implement ExTreeDataProvider interface and pass it into the tree to
* create its structure.
*
* @author <NAME>
* @see org.ocsoft.flatlaf.extended.tree.ExTreeModel
* @see org.ocsoft.flatlaf.extended.tree.ExTreeDataProvider
*/
public class WebExTree<E extends UniqueNode> extends WebTree<E> {
/**
* Tree nodes comparator.
*/
protected Comparator<E> comparator;
/**
* Tree nodes filter.
*/
protected Filter<E> filter;
/**
* Constructs sample ex tree.
*/
public WebExTree() {
super();
// Installing sample data provider
setDataProvider(new SampleExDataProvider());
// Tree cell renderer & editor
setCellRenderer(new SampleTreeCellRenderer());
setCellEditor(new SampleTreeCellEditor());
}
/**
* Costructs ex tree using data from the custom data provider.
*
* @param dataProvider
* custom data provider
*/
public WebExTree(final ExTreeDataProvider dataProvider) {
super();
// Installing data provider
setDataProvider(dataProvider);
// Tree cell renderer & editor
setCellRenderer(new WebTreeCellRenderer());
setCellEditor(new WebTreeCellEditor());
}
/**
* Returns ex tree data provider.
*
* @return data provider
*/
public ExTreeDataProvider<E> getDataProvider() {
final TreeModel model = getModel();
return model != null && model instanceof ExTreeModel ? getExModel()
.getDataProvider() : null;
}
/**
* Changes data provider for this ex tree.
*
* @param dataProvider
* new data provider
*/
public void setDataProvider(final ExTreeDataProvider dataProvider) {
if (dataProvider != null) {
final ExTreeDataProvider<E> oldDataProvider = getDataProvider();
// Updating model
// Be aware that all the data will be loaded right away
setModel(new ExTreeModel<E>(this, dataProvider));
// Informing about data provider change
firePropertyChange(TREE_DATA_PROVIDER_PROPERTY, oldDataProvider,
dataProvider);
}
}
/**
* Returns tree nodes comparator.
*
* @return tree nodes comparator
*/
public Comparator<E> getComparator() {
return comparator;
}
/**
* Sets tree nodes comparator. Comparator replacement will automatically
* update all loaded nodes sorting.
*
* @param comparator
* tree nodes comparator
*/
public void setComparator(final Comparator<E> comparator) {
final Comparator<E> oldComparator = this.comparator;
this.comparator = comparator;
final ExTreeDataProvider dataProvider = getDataProvider();
if (dataProvider instanceof AbstractExTreeDataProvider) {
((AbstractExTreeDataProvider) dataProvider)
.setChildsComparator(comparator);
updateSortingAndFiltering();
}
firePropertyChange(TREE_COMPARATOR_PROPERTY, oldComparator, comparator);
}
/**
* Removes any applied tree nodes comparator.
*/
public void clearComparator() {
setComparator(null);
}
/**
* Returns tree nodes filter.
*
* @return tree nodes filter
*/
public Filter<E> getFilter() {
return filter;
}
/**
* Sets tree nodes filter. Comparator replacement will automatically
* re-filter all loaded nodes.
*
* @param filter
* tree nodes filter
*/
public void setFilter(final Filter<E> filter) {
final Filter<E> oldFilter = this.filter;
this.filter = filter;
final ExTreeDataProvider dataProvider = getDataProvider();
if (dataProvider instanceof AbstractExTreeDataProvider) {
((AbstractExTreeDataProvider) dataProvider).setChildsFilter(filter);
updateSortingAndFiltering();
}
firePropertyChange(TREE_FILTER_PROPERTY, oldFilter, filter);
}
/**
* Removes any applied tree nodes filter.
*/
public void clearFilter() {
setFilter(null);
}
/**
* Updates nodes sorting and filtering for all loaded nodes.
*/
public void updateSortingAndFiltering() {
getExModel().updateSortingAndFiltering();
}
/**
* Updates sorting and filtering for the specified node childs.
*/
public void updateSortingAndFiltering(final E node) {
getExModel().updateSortingAndFiltering(node);
}
/**
* Returns ex tree model.
*
* @return ex tree model
*/
public ExTreeModel<E> getExModel() {
return (ExTreeModel<E>) getModel();
}
/**
* Returns whether ex tree model is installed or not.
*
* @return true if ex tree model is installed, false otherwise
*/
public boolean isExModel() {
final TreeModel model = getModel();
return model != null && model instanceof ExTreeModel;
}
/**
* Sets child nodes for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param children
* new node children
*/
public void setChildNodes(final E parent, final List<E> children) {
getExModel().setChildNodes(parent, children);
}
/**
* Adds child node for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param child
* new node child
*/
public void addChildNode(final E parent, final E child) {
getExModel().addChildNodes(parent, Arrays.asList(child));
}
/**
* Adds child nodes for the specified node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param parent
* node to process
* @param children
* new node children
*/
public void addChildNodes(final E parent, final List<E> children) {
getExModel().addChildNodes(parent, children);
}
/**
* Inserts a list of child nodes into parent node. This method might be used
* to manually change tree node childs without causing any structure
* corruptions.
*
* @param children
* list of new child nodes
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNodes(final List<E> children, final E parent,
final int index) {
getExModel().insertNodesInto(children, parent, index);
}
/**
* Inserts an array of child nodes into parent node. This method might be
* used to manually change tree node childs without causing any structure
* corruptions.
*
* @param children
* array of new child nodes
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNodes(final E[] children, final E parent,
final int index) {
getExModel().insertNodesInto(children, parent, index);
}
/**
* Inserts child node into parent node. This method might be used to
* manually change tree node childs without causing any structure
* corruptions.
*
* @param child
* new child node
* @param parent
* parent node
* @param index
* insert index
*/
public void insertChildNode(final E child, final E parent, final int index) {
getExModel().insertNodeInto(child, parent, index);
}
/**
* Removes node with the specified ID from tree structure. This method will
* have effect only if node exists.
*
* @param nodeId
* ID of the node to remove
* @return true if tree structure was changed by the operation, false
* otherwise
*/
public boolean removeNode(final String nodeId) {
return removeNode(findNode(nodeId));
}
/**
* Removes node from tree structure. This method will have effect only if
* node exists.
*
* @param node
* node to remove
* @return true if tree structure was changed by the operation, false
* otherwise
*/
public boolean removeNode(final E node) {
final boolean exists = node != null && node.getParent() != null;
if (exists) {
getExModel().removeNodeFromParent(node);
}
return exists;
}
/**
* Removes nodes from tree structure. This method will have effect only if
* nodes exist.
*
* @param nodes
* list of nodes to remove
*/
public void removeNodes(final List<E> nodes) {
getExModel().removeNodesFromParent(nodes);
}
/**
* Removes nodes from tree structure. This method will have effect only if
* nodes exist.
*
* @param nodes
* array of nodes to remove
*/
public void removeNodes(final E[] nodes) {
getExModel().removeNodesFromParent(nodes);
}
/**
* Looks for the node with the specified ID in the tree model and returns it
* or null if it was not found.
*
* @param nodeId
* node ID
* @return node with the specified ID or null if it was not found
*/
public E findNode(final String nodeId) {
return getExModel().findNode(nodeId);
}
/**
* Forces tree node with the specified ID to be updated.
*
* @param nodeId
* ID of the tree node to be updated
*/
public void updateNode(final String nodeId) {
updateNode(findNode(nodeId));
}
/**
* Forces tree node to be updated.
*
* @param node
* tree node to be updated
*/
public void updateNode(final E node) {
getExModel().updateNode(node);
// todo Should actually perform this here (but need to improve filter
// interface methods - add cache clear methods)
// updateSortingAndFiltering ( ( E ) node.getParent () );
}
/**
* Forces tree node structure with the specified ID to be updated.
*
* @param nodeId
* ID of the tree node to be updated
*/
public void updateNodeStructure(final String nodeId) {
updateNodeStructure(findNode(nodeId));
}
/**
* Forces tree node structure with the specified ID to be updated.
*
* @param node
* tree node to be updated
*/
public void updateNodeStructure(final E node) {
getExModel().updateNodeStructure(node);
}
/**
* Reloads selected node childs.
*/
public void reloadSelectedNodes() {
// Checking that selection is not empty
final TreePath[] paths = getSelectionPaths();
if (paths != null) {
// Reloading all selected nodes
for (final TreePath path : paths) {
// Checking if node is not null and not busy yet
final E node = getNodeForPath(path);
if (node != null) {
// Reloading node childs
performReload(node, path, false);
}
}
}
}
/**
* Reloads node under the specified point.
*
* @param point
* point to look for node
* @return reloaded node or null if none reloaded
*/
public E reloadNodeUnderPoint(final Point point) {
return reloadNodeUnderPoint(point.x, point.y);
}
/**
* Reloads node under the specified point.
*
* @param x
* point X coordinate
* @param y
* point Y coordinate
* @return reloaded node or null if none reloaded
*/
public E reloadNodeUnderPoint(final int x, final int y) {
return reloadPath(getPathForLocation(x, y));
}
/**
* Reloads root node childs.
*
* @return reloaded root node
*/
public E reloadRootNode() {
return reloadNode(getRootNode());
}
/**
* Reloads node with the specified ID.
*
* @param nodeId
* ID of the node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final String nodeId) {
return reloadNode(findNode(nodeId));
}
/**
* Reloads specified node childs.
*
* @param node
* node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final E node) {
return reloadNode(node, false);
}
/**
* Reloads specified node childs and selects it if requested.
*
* @param node
* node to reload
* @param select
* whether select the node or not
* @return reloaded node or null if none reloaded
*/
public E reloadNode(final E node, final boolean select) {
// Checking that node is not null
if (node != null) {
// Reloading node childs
performReload(node, getPathForNode(node), select);
return node;
}
return null;
}
/**
* Reloads node childs at the specified path.
*
* @param path
* path of the node to reload
* @return reloaded node or null if none reloaded
*/
public E reloadPath(final TreePath path) {
return reloadPath(path, false);
}
/**
* Reloads node childs at the specified path and selects it if needed.
*
* @param path
* path of the node to reload
* @param select
* whether select the node or not
* @return reloaded node or null if none reloaded
*/
public E reloadPath(final TreePath path, final boolean select) {
// Checking that path is not null
if (path != null) {
// Checking if node is not null and not busy yet
final E node = getNodeForPath(path);
if (node != null) {
// Reloading node childs
performReload(node, path, select);
return node;
}
}
return null;
}
/**
* Performs the actual reload call.
*
* @param node
* node to reload
* @param path
* path to node
* @param select
* whether select the node or not
*/
protected void performReload(final E node, final TreePath path,
final boolean select) {
// Select node under the mouse
if (select && !isPathSelected(path)) {
setSelectionPath(path);
}
// Expand the selected node since the collapsed node will ignore reload
// call
// In case the node childs were not loaded yet this call will cause it
// to load childs
if (!isExpanded(path)) {
expandPath(path);
}
// Reload selected node childs
// This won't be called if node was not loaded yet since expand would
// call load before
if (node != null) {
getExModel().reload(node);
}
}
/**
* Expands node with the specified ID.
*
* @param nodeId
* ID of the node to expand
*/
public void expandNode(final String nodeId) {
expandNode(findNode(nodeId));
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
*/
public void expandPath(final List<String> pathNodeIds) {
expandPath(pathNodeIds, true, true);
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
* @param expandLastNode
* whether should expand last found path node or not
*/
public void expandPath(final List<String> pathNodeIds,
final boolean expandLastNode) {
expandPath(pathNodeIds, expandLastNode, true);
}
/**
* Expands path using the specified node path IDs. IDs are used to find real
* nodes within the expanded roots. Be aware that operation might stop even
* before reaching the end of the path if something unexpected happened.
*
* @param pathNodeIds
* node path IDs
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
public void expandPath(final List<String> pathNodeIds,
final boolean expandLastNode, final boolean selectLastNode) {
final List<String> ids = CollectionUtils.copy(pathNodeIds);
for (int initial = 0; initial < ids.size(); initial++) {
final E initialNode = findNode(ids.get(initial));
if (initialNode != null) {
for (int i = 0; i <= initial; i++) {
ids.remove(i);
}
if (ids.size() > 0) {
expandPathImpl(initialNode, ids, expandLastNode,
selectLastNode);
}
return;
}
}
}
/**
* Performs a single path node expansion. Be aware that operation might stop
* even before reaching the end of the path if something unexpected
* happened.
*
* @param currentNode
* last reached node
* @param leftToExpand
* node path IDs left for expansion
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
protected void expandPathImpl(final E currentNode,
final List<String> leftToExpand, final boolean expandLastNode,
final boolean selectLastNode) {
// There is still more to load
if (leftToExpand.size() > 0) {
// Expanding already loaded node
expandNode(currentNode);
// Retrieving next node
final E nextNode = findNode(leftToExpand.get(0));
leftToExpand.remove(0);
// If node exists continue expanding path
if (nextNode != null) {
expandPathImpl(nextNode, leftToExpand, expandLastNode,
selectLastNode);
} else {
expandPathEndImpl(currentNode, expandLastNode, selectLastNode);
}
} else {
expandPathEndImpl(currentNode, expandLastNode, selectLastNode);
}
}
/**
* Finishes async tree path expansion.
*
* @param lastFoundNode
* last found path node
* @param expandLastNode
* whether should expand last found path node or not
* @param selectLastNode
* whether should select last found path node or not
*/
protected void expandPathEndImpl(final E lastFoundNode,
final boolean expandLastNode, final boolean selectLastNode) {
if (selectLastNode) {
setSelectedNode(lastFoundNode);
}
if (expandLastNode) {
expandNode(lastFoundNode);
}
}
} | 21,969 | 0.588104 | 0.587786 | 711 | 29.907173 | 23.907459 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.251758 | false | false | 9 |
c20749c51c4085f2b2d51108bb095242387ff3bd | 8,040,178,796,987 | 8a4d5f8f38977d1ed489a802d628b243afebdbee | /src/main/java/com/hcl/bankingapp/repository/BeneficiaryStatusRepository.java | f2077f6813ffd21a98a7f570f8a63a38c4f371e7 | []
| no_license | shadowkate/Banking1 | https://github.com/shadowkate/Banking1 | 26e97698391c11505c1fb47702b58a930691e3df | a497aa50d4ecd9977755296df9177960d0a45c9d | refs/heads/master | 2020-07-19T03:44:01.632000 | 2019-09-04T16:52:39 | 2019-09-04T16:52:39 | 206,368,254 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hcl.bankingapp.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.hcl.bankingapp.entity.BeneficiaryStatus;
public interface BeneficiaryStatusRepository extends JpaRepository<BeneficiaryStatus, Integer> {
}
| UTF-8 | Java | 256 | java | BeneficiaryStatusRepository.java | Java | []
| null | []
| package com.hcl.bankingapp.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.hcl.bankingapp.entity.BeneficiaryStatus;
public interface BeneficiaryStatusRepository extends JpaRepository<BeneficiaryStatus, Integer> {
}
| 256 | 0.851563 | 0.851563 | 9 | 27.444445 | 33.671982 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 9 |
f85bbd9f54f25048ee1b256c9683708dd13321ba | 8,040,178,797,980 | f7167b6f416b7e75c4a5965e198d1628f5d61fb0 | /mad-graphs-master/mad-graphs-master/mad-graphs-master@e3528182ef3/src/main/java/com/jda/mad/GraphAllProbesFromSupportZip.java | 2ba2e6ba5a6352fb74143d196075f3b1d6e4028e | []
| no_license | SamNiBoy/Knowledge | https://github.com/SamNiBoy/Knowledge | cacceba18ccbe7ca61b9c2b27e15d1fd1ef8f9c1 | cf3497888e9ea05a6695f76f5d7c24f61d624701 | refs/heads/master | 2020-02-29T11:50:21.278000 | 2020-02-07T02:50:33 | 2020-02-07T02:50:33 | 88,963,053 | 0 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jda.mad;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.TimeZone;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.jda.mad.graphs.ChartType;
import com.jda.mad.graphs.Grapher;
import com.jda.mad.graphs.Utils;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
/**
* Application to create graphs from MOCA support zip files. This application works solely on command line arguments
* to be able to filter down the number of graphs. Each graph is opened in a new window.
* <p/>
* Copyright (c) 2016 JDA Software All Rights Reserved
*
* @author mdobrinin
*/
public class GraphAllProbesFromSupportZip {
public static void main(String[] args) throws IOException, ParseException {
final CommandLine options = getOptions(args);
String supportZip = "";
try {
supportZip = getSupportZipArg(options);
}
catch (IllegalStateException e) {
printUsage();
System.exit(0);
}
final ZipFile zipFile = new ZipFile(supportZip);
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
// figure out the timezone from the support zip so that we can display dates
// in the same way as they appear on the instance -- this is needed to make them match the logs
String timeZone = Utils.determineTimeZone(zipFile);
if (timeZone != null) {
System.out.println("Setting time zone... " + timeZone);
Grapher.setTimeZone(timeZone);
}
else {
System.out.println("Defaulting to time zone... " + TimeZone.getDefault());
Grapher.setTimeZone(TimeZone.getDefault().getDisplayName());
}
while(entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final String name = entry.getName();
String separatorRegex = "/";
if (name.startsWith("csv_probe_data")) {
final String separator;
if (name.contains("/")) {
separator = "/";
}
else if (name.contains("\\")) {
separator = "\\";
separatorRegex = "\\\\";
}
else {
throw new RuntimeException("Unknown separator in entry {" + name + "}");
}
final String pkg = name.substring(name.indexOf(separator) + 1);
final String[] strings = pkg.split(separatorRegex);
final List<ChartType> chartTypes = findChartTypes(options);
// only graph this probe if it was requested
if (Utils.filter(strings[0], strings[1], chartTypes)) {
final List<String> data = Utils.readEntry(zipFile, entry);
if (data.size() >= 2) {
Grapher.chartSingleFile(strings[0], strings[1], data);
}
}
}
}
}
private static List<ChartType> findChartTypes(CommandLine options) {
List<ChartType> chartTypes = new ArrayList<ChartType>();
if (options.hasOption('o')) chartTypes.add(ChartType.JVM);
if (options.hasOption('m')) chartTypes.add(ChartType.MOCA);
if (options.hasOption('w')) chartTypes.add(ChartType.WS);
if (options.hasOption('j')) chartTypes.add(ChartType.JOBS);
if (options.hasOption('t')) chartTypes.add(ChartType.TASKS);
if (options.hasOption('i')) chartTypes.add(ChartType.INTEGRATOR);
if (options.hasOption('d')) chartTypes.add(ChartType.WM);
if (options.hasOption('e')) chartTypes.add(ChartType.OTHER);
return chartTypes;
}
/**
* Parse the options from
* @param args
* @return
* @throws ParseException
*/
static CommandLine getOptions(String[] args) throws ParseException {
Options options = defaultOptions();
CommandLineParser parser = new DefaultParser();
try {
CommandLine cmd = parser.parse(options, args);
if (cmd.hasOption("h") || cmd.getOptions().length == 0) {
printUsage();
System.exit(0);
}
return cmd;
}
catch (Exception e) {
printUsage();
System.exit(0);
}
return null;
}
/**
* Get the actual support zip file path from the arguments.
* @param c command line options
* @return support zip arg
*/
static String getSupportZipArg(CommandLine c) {
List<String> argList = c.getArgList();
if (argList.size() != 1 || argList.get(0).isEmpty()) {
throw new IllegalStateException("Invalid arguments");
}
return argList.get(0);
}
private static Options defaultOptions() {
Options options = new Options();
options.addOption("o", "jvm-overview", false, "Graph JVM and OS overview");
options.addOption("m", "moca-overview ", false, "Graph MOCA overview");
options.addOption("w", "ws", false, "Graph all web services (dynamic)");
options.addOption("j", "jobs", false, "Graph all jobs (dynamic)");
options.addOption("t", "tasks", false, "Graph all tasks (dynamic)");
options.addOption("i", "integrator", false, "Graph all integrator probes (dynamic)");
options.addOption("d", "wm", false, "Graph all WM probes");
options.addOption("e", "everything-else", false, "Graph all other probes (not captured by other categories)");
options.addOption("h", "help", false, "Print usage");
return options;
}
private static void printUsage() {
HelpFormatter formatter = new HelpFormatter();
// set comparator as null to preserve declaration order
formatter.setOptionComparator(null);
formatter.printHelp( "java -jar mad-graphs.jar <support-zip> [options]", null, defaultOptions(), "Note that dynamic items may produce a large number of graphs. The actual number of graphs will depend on products installed, customizations, etc.");
}
} | UTF-8 | Java | 6,438 | java | GraphAllProbesFromSupportZip.java | Java | [
{
"context": "016 JDA Software All Rights Reserved\n *\n * @author mdobrinin\n */\npublic class GraphAllProbesFromSupportZip {\n\n",
"end": 890,
"score": 0.9955969452857971,
"start": 881,
"tag": "USERNAME",
"value": "mdobrinin"
}
]
| null | []
| package com.jda.mad;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.TimeZone;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.jda.mad.graphs.ChartType;
import com.jda.mad.graphs.Grapher;
import com.jda.mad.graphs.Utils;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
/**
* Application to create graphs from MOCA support zip files. This application works solely on command line arguments
* to be able to filter down the number of graphs. Each graph is opened in a new window.
* <p/>
* Copyright (c) 2016 JDA Software All Rights Reserved
*
* @author mdobrinin
*/
public class GraphAllProbesFromSupportZip {
public static void main(String[] args) throws IOException, ParseException {
final CommandLine options = getOptions(args);
String supportZip = "";
try {
supportZip = getSupportZipArg(options);
}
catch (IllegalStateException e) {
printUsage();
System.exit(0);
}
final ZipFile zipFile = new ZipFile(supportZip);
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
// figure out the timezone from the support zip so that we can display dates
// in the same way as they appear on the instance -- this is needed to make them match the logs
String timeZone = Utils.determineTimeZone(zipFile);
if (timeZone != null) {
System.out.println("Setting time zone... " + timeZone);
Grapher.setTimeZone(timeZone);
}
else {
System.out.println("Defaulting to time zone... " + TimeZone.getDefault());
Grapher.setTimeZone(TimeZone.getDefault().getDisplayName());
}
while(entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final String name = entry.getName();
String separatorRegex = "/";
if (name.startsWith("csv_probe_data")) {
final String separator;
if (name.contains("/")) {
separator = "/";
}
else if (name.contains("\\")) {
separator = "\\";
separatorRegex = "\\\\";
}
else {
throw new RuntimeException("Unknown separator in entry {" + name + "}");
}
final String pkg = name.substring(name.indexOf(separator) + 1);
final String[] strings = pkg.split(separatorRegex);
final List<ChartType> chartTypes = findChartTypes(options);
// only graph this probe if it was requested
if (Utils.filter(strings[0], strings[1], chartTypes)) {
final List<String> data = Utils.readEntry(zipFile, entry);
if (data.size() >= 2) {
Grapher.chartSingleFile(strings[0], strings[1], data);
}
}
}
}
}
private static List<ChartType> findChartTypes(CommandLine options) {
List<ChartType> chartTypes = new ArrayList<ChartType>();
if (options.hasOption('o')) chartTypes.add(ChartType.JVM);
if (options.hasOption('m')) chartTypes.add(ChartType.MOCA);
if (options.hasOption('w')) chartTypes.add(ChartType.WS);
if (options.hasOption('j')) chartTypes.add(ChartType.JOBS);
if (options.hasOption('t')) chartTypes.add(ChartType.TASKS);
if (options.hasOption('i')) chartTypes.add(ChartType.INTEGRATOR);
if (options.hasOption('d')) chartTypes.add(ChartType.WM);
if (options.hasOption('e')) chartTypes.add(ChartType.OTHER);
return chartTypes;
}
/**
* Parse the options from
* @param args
* @return
* @throws ParseException
*/
static CommandLine getOptions(String[] args) throws ParseException {
Options options = defaultOptions();
CommandLineParser parser = new DefaultParser();
try {
CommandLine cmd = parser.parse(options, args);
if (cmd.hasOption("h") || cmd.getOptions().length == 0) {
printUsage();
System.exit(0);
}
return cmd;
}
catch (Exception e) {
printUsage();
System.exit(0);
}
return null;
}
/**
* Get the actual support zip file path from the arguments.
* @param c command line options
* @return support zip arg
*/
static String getSupportZipArg(CommandLine c) {
List<String> argList = c.getArgList();
if (argList.size() != 1 || argList.get(0).isEmpty()) {
throw new IllegalStateException("Invalid arguments");
}
return argList.get(0);
}
private static Options defaultOptions() {
Options options = new Options();
options.addOption("o", "jvm-overview", false, "Graph JVM and OS overview");
options.addOption("m", "moca-overview ", false, "Graph MOCA overview");
options.addOption("w", "ws", false, "Graph all web services (dynamic)");
options.addOption("j", "jobs", false, "Graph all jobs (dynamic)");
options.addOption("t", "tasks", false, "Graph all tasks (dynamic)");
options.addOption("i", "integrator", false, "Graph all integrator probes (dynamic)");
options.addOption("d", "wm", false, "Graph all WM probes");
options.addOption("e", "everything-else", false, "Graph all other probes (not captured by other categories)");
options.addOption("h", "help", false, "Print usage");
return options;
}
private static void printUsage() {
HelpFormatter formatter = new HelpFormatter();
// set comparator as null to preserve declaration order
formatter.setOptionComparator(null);
formatter.printHelp( "java -jar mad-graphs.jar <support-zip> [options]", null, defaultOptions(), "Note that dynamic items may produce a large number of graphs. The actual number of graphs will depend on products installed, customizations, etc.");
}
} | 6,438 | 0.607642 | 0.605002 | 163 | 38.503067 | 32.827187 | 254 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.742331 | false | false | 9 |
79b15651a1b7b2d6ce6555453890766c1b8bd04b | 29,394,756,176,048 | 2800bee378af90c7ad736743e37ba40c0745275e | /GeneticKnapsack/src/org/knapsack/KnapsackItem.java | db03790525f6cab85c46db0ec969c0078e37c627 | []
| no_license | fractalDimension/knapsack-problem-genetic-algo | https://github.com/fractalDimension/knapsack-problem-genetic-algo | 0a8bec7a25df558c91671640cb3ec9aff4695cd2 | bfabdcaca4760654a312b244f88160195d845868 | refs/heads/master | 2016-09-06T01:28:50.268000 | 2015-07-10T03:28:53 | 2015-07-10T03:28:53 | 38,797,459 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.knapsack;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.uncommons.maths.random.MersenneTwisterRNG;
//git staging test delete this comment when done
public class KnapsackItem {
//still need to create a factory to create objects of this dude
private List<List<String>> items = new ArrayList<List<String>>();
private Random rng = new MersenneTwisterRNG();
public KnapsackItem(int numItems, int weightRange, int valueRange) {
for (int i = 0; i < numItems; i++) {
List<String> temp = new ArrayList<String>();
temp.add(Integer.toString(rng.nextInt(weightRange + 1)));
temp.add(Integer.toString(rng.nextInt(valueRange + 1)));
items.add(temp);
}
}
public List<List<String>> getItem() {
return items;
}
public void printItems() {
for (int i = 0; i < items.size(); i++) {
List<String> sub = items.get(i);
System.out.format("item %d: %n", i);
System.out.println("weight: " + sub.get(0));
System.out.println("value: " + sub.get(1));
System.out.println();
}
}
public String[][] toMultiDimString() {
final int size = items.size();
String[][] multiDimString = new String[size][2];
for (int i = 0; i < size; i++) {
List<String> sub = items.get(i);
multiDimString[i][0] = sub.get(0);
multiDimString[i][1] = sub.get(1);
}
return multiDimString;
}
}
| UTF-8 | Java | 1,370 | java | KnapsackItem.java | Java | []
| null | []
| package org.knapsack;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.uncommons.maths.random.MersenneTwisterRNG;
//git staging test delete this comment when done
public class KnapsackItem {
//still need to create a factory to create objects of this dude
private List<List<String>> items = new ArrayList<List<String>>();
private Random rng = new MersenneTwisterRNG();
public KnapsackItem(int numItems, int weightRange, int valueRange) {
for (int i = 0; i < numItems; i++) {
List<String> temp = new ArrayList<String>();
temp.add(Integer.toString(rng.nextInt(weightRange + 1)));
temp.add(Integer.toString(rng.nextInt(valueRange + 1)));
items.add(temp);
}
}
public List<List<String>> getItem() {
return items;
}
public void printItems() {
for (int i = 0; i < items.size(); i++) {
List<String> sub = items.get(i);
System.out.format("item %d: %n", i);
System.out.println("weight: " + sub.get(0));
System.out.println("value: " + sub.get(1));
System.out.println();
}
}
public String[][] toMultiDimString() {
final int size = items.size();
String[][] multiDimString = new String[size][2];
for (int i = 0; i < size; i++) {
List<String> sub = items.get(i);
multiDimString[i][0] = sub.get(0);
multiDimString[i][1] = sub.get(1);
}
return multiDimString;
}
}
| 1,370 | 0.662044 | 0.653285 | 51 | 25.862745 | 21.274139 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.117647 | false | false | 9 |
639ea54762b5a22adcacc5adbe44562f7bbeb362 | 6,442,450,974,637 | b75d958cf00bf19bffaf9d74d8b7754fbe35ea39 | /springboot-rabbitmq/src/test/java/com/example/rabbitmq/mq/MQTest.java | ed695477907083ef79c4ac565db870ffd0cd97ea | [
"Apache-2.0"
]
| permissive | pcshao/springboot-example | https://github.com/pcshao/springboot-example | bb56c739a1a3ac9907f5dc7fa5ffd904424bb60d | 21a4d0974789ecd65b16152de98b7c3dbc154a45 | refs/heads/master | 2020-04-05T06:57:05.383000 | 2018-11-09T03:23:58 | 2018-11-09T03:23:58 | 156,657,946 | 0 | 0 | Apache-2.0 | true | 2018-11-08T06:04:23 | 2018-11-08T06:04:23 | 2018-11-05T14:48:35 | 2018-09-12T03:40:10 | 69 | 0 | 0 | 0 | null | false | null | package com.example.rabbitmq.mq;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.SimpleDateFormat;
import java.util.Date;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MQTest {
// @Autowired
// private Sender sender;
//
// @Test
// public void driectTest() {
// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
// sender.driectSend("Driect Data:" + sf.format(new Date()));
// }
} | UTF-8 | Java | 680 | java | MQTest.java | Java | []
| null | []
| package com.example.rabbitmq.mq;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.SimpleDateFormat;
import java.util.Date;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MQTest {
// @Autowired
// private Sender sender;
//
// @Test
// public void driectTest() {
// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
// sender.driectSend("Driect Data:" + sf.format(new Date()));
// }
} | 680 | 0.737463 | 0.735988 | 26 | 25.115385 | 22.106955 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 9 |
a9c0c1ecbfc0f9d5cce4bdcd7402f20192ac6def | 29,523,605,219,185 | df1ade52dec2914bbea095e1e7a639ddbf4e3a15 | /src/main/java/input/MySQLConnectionInfo.java | 75823a635421f8187d9a136793a2ce13b1d52582 | []
| no_license | lhermannGit/RDFAnalyzer | https://github.com/lhermannGit/RDFAnalyzer | 8ccb4c9278e4997031d6da1d1074eab515c6c74b | c09cb99f579a412c37d8c42c98b0c28742dd12cc | refs/heads/master | 2021-01-10T08:43:32.487000 | 2016-03-03T17:41:14 | 2016-03-03T17:41:14 | 50,346,733 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package input;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class MySQLConnectionInfo {
String password = "";
String username = "";
String database = "";
String server = "";
InputStream inputStream;
public MySQLConnectionInfo() {
Properties prop = new Properties();
try {
inputStream = new FileInputStream(new File("config.properties"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (inputStream != null) {
try {
prop.load(inputStream);
username = prop.getProperty("username");
password = prop.getProperty("password");
database = prop.getProperty("database");
server = prop.getProperty("server");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
throw new FileNotFoundException("property file not found in the classpath");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public String getUser() {
return username;
}
public String getPassword() {
return password;
}
public String getDatabaseName() {
return database;
}
public String getServer() {
return server;
}
}
| UTF-8 | Java | 1,372 | java | MySQLConnectionInfo.java | Java | [
{
"context": "ad(inputStream);\n\t\t\t\tusername = prop.getProperty(\"username\");\n\t\t\t\tpassword = prop.getProperty(\"password\");\n\t",
"end": 708,
"score": 0.9978632926940918,
"start": 700,
"tag": "USERNAME",
"value": "username"
},
{
"context": "rty(\"username\");\n\t\t\t\tpassword = prop.getProperty(\"password\");\n\t\t\t\tdatabase = prop.getProperty(\"database\");\n\t",
"end": 753,
"score": 0.6123863458633423,
"start": 745,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "\n\t\t\t}\n\t\t}\n\n\t}\n\n\tpublic String getUser() {\n\t\treturn username;\n\t}\n\n\tpublic String getPassword() {\n\t\treturn pass",
"end": 1203,
"score": 0.6390831470489502,
"start": 1195,
"tag": "USERNAME",
"value": "username"
},
{
"context": "rname;\n\t}\n\n\tpublic String getPassword() {\n\t\treturn password;\n\t}\n\n\tpublic String getDatabaseName() {\n\t\treturn ",
"end": 1257,
"score": 0.9822543263435364,
"start": 1249,
"tag": "PASSWORD",
"value": "password"
}
]
| null | []
| package input;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class MySQLConnectionInfo {
String password = "";
String username = "";
String database = "";
String server = "";
InputStream inputStream;
public MySQLConnectionInfo() {
Properties prop = new Properties();
try {
inputStream = new FileInputStream(new File("config.properties"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (inputStream != null) {
try {
prop.load(inputStream);
username = prop.getProperty("username");
password = prop.getProperty("<PASSWORD>");
database = prop.getProperty("database");
server = prop.getProperty("server");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
try {
throw new FileNotFoundException("property file not found in the classpath");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public String getUser() {
return username;
}
public String getPassword() {
return <PASSWORD>;
}
public String getDatabaseName() {
return database;
}
public String getServer() {
return server;
}
}
| 1,376 | 0.689504 | 0.688047 | 65 | 20.107693 | 17.340147 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.015385 | false | false | 9 |
392d6e65c50dff065232a04d8bda368557623310 | 26,285,199,876,604 | be6edaedcb611b094335677fdd829a62786e50fd | /src/test/java/com/labkit/test/personapi/patch/jax/rs/PatchingTest.java | eeac02ee17a5fb8fc9703226c1ffdb2441d55906 | [
"MIT"
]
| permissive | vidhya03/http-patch-jax-rs | https://github.com/vidhya03/http-patch-jax-rs | 4936330cfd590e370ff43288e9dd7d9a43e4a3f6 | 6806e679618fb22906e1f01c333cfb251314dde5 | refs/heads/master | 2021-01-17T17:55:55.540000 | 2018-10-23T07:46:15 | 2018-10-23T07:46:15 | 53,337,719 | 1 | 6 | MIT | false | 2018-10-23T07:46:17 | 2016-03-07T15:50:20 | 2018-03-30T16:03:14 | 2018-10-23T07:46:16 | 8,643 | 1 | 5 | 8 | Java | false | null | package com.labkit.test.personapi.patch.jax.rs;
import static org.mockito.Mockito.when;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.ReaderInterceptorContext;
import org.junit.Test;
import org.mockito.Mock;
import com.vidhya.java.http.patch.jax.rs.Patching;
public class PatchingTest {
Patching patch;
@Mock
ReaderInterceptorContext interceptorContext;
@Mock
UriInfo uriInfo;
@Test
public void patchTest() throws Exception{
patch = new Patching();
//when(patch.aroundReadFrom(interceptorContext)).thenReturn(patch);
}
}
| UTF-8 | Java | 561 | java | PatchingTest.java | Java | []
| null | []
| package com.labkit.test.personapi.patch.jax.rs;
import static org.mockito.Mockito.when;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.ReaderInterceptorContext;
import org.junit.Test;
import org.mockito.Mock;
import com.vidhya.java.http.patch.jax.rs.Patching;
public class PatchingTest {
Patching patch;
@Mock
ReaderInterceptorContext interceptorContext;
@Mock
UriInfo uriInfo;
@Test
public void patchTest() throws Exception{
patch = new Patching();
//when(patch.aroundReadFrom(interceptorContext)).thenReturn(patch);
}
}
| 561 | 0.764706 | 0.764706 | 31 | 17.096775 | 19.776745 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.967742 | false | false | 9 |
4b64c042a7740b406185e6a2302d94757a22d2a2 | 19,396,072,330,146 | 8c920fa1f68f32ba7d872f73925b24eb0c5a4c4c | /Pertemuan11/src/pratikum11/bangundatar/Resizeable.java | 8a8817a15901a161546c80de92e01248cc12d27a | []
| no_license | alfendors/PBO_4423 | https://github.com/alfendors/PBO_4423 | 4d187ca3178eb3e35831fa45f05b9783298233b9 | 53bafe4d65c239e73274002927331909e0a48063 | refs/heads/main | 2023-06-12T02:07:59.727000 | 2021-07-12T10:31:45 | 2021-07-12T10:31:45 | 344,752,861 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pratikum11.bangundatar;
public interface Resizeable {
public void resize(double x);
}
| UTF-8 | Java | 99 | java | Resizeable.java | Java | []
| null | []
| package pratikum11.bangundatar;
public interface Resizeable {
public void resize(double x);
}
| 99 | 0.767677 | 0.747475 | 5 | 18.799999 | 14.998667 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 9 |
edf5d9f07df2babef25ffd7ba45972b2e87cb723 | 27,831,388,105,834 | 53653737855af76622b782b9050463ebb6e11c45 | /src/model/SalesOrder.java | d8112ce83df78b22267b68c020546b81bca26a8f | []
| no_license | inforkgodara/automate-manual-repetitive-data-entry-tasks | https://github.com/inforkgodara/automate-manual-repetitive-data-entry-tasks | d29214d30f5fd2eeeac8529f6ec10b66c04cebb4 | 452a3e432313493e1f67e03ebf10bb511e1b076c | refs/heads/master | 2023-05-13T04:52:51.542000 | 2021-06-06T20:14:31 | 2021-06-06T20:14:31 | 304,935,478 | 8 | 2 | 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 model;
/**
*
* @author Ramesh Godara
*/
public class SalesOrder {
}
| UTF-8 | Java | 270 | java | SalesOrder.java | Java | [
{
"context": " the editor.\n */\npackage model;\n\n/**\n *\n * @author Ramesh Godara\n */\npublic class SalesOrder {\n \n}\n",
"end": 232,
"score": 0.9998818635940552,
"start": 219,
"tag": "NAME",
"value": "Ramesh Godara"
}
]
| 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 model;
/**
*
* @author <NAME>
*/
public class SalesOrder {
}
| 263 | 0.696296 | 0.696296 | 14 | 18.285715 | 23.571861 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 9 |
efe8cdd855119615aa18b18d10513dc01fceb6c5 | 19,808,389,201,894 | 944da74138e0b0efde96b5fe731bbfdbe4520c5c | /Starterbot/src/gos/bot/Engine.java | 87ab64381a5b91b87f2c41bc1e59f35fcd637f53 | [
"Apache-2.0"
]
| permissive | Oduig/swoc2014 | https://github.com/Oduig/swoc2014 | d9d62b1799c3c4a4ad15fd0eb0ccca341c298f72 | 9459163c0df76d64da54dd0f02d0b6634da95055 | refs/heads/master | 2021-01-10T21:08:57.192000 | 2014-10-12T18:46:18 | 2014-10-12T18:46:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gos.bot;
import gos.bot.protocol.InitiateRequest;
import gos.bot.protocol.Move;
import gos.bot.protocol.MoveRequest;
import gos.bot.protocol.Player;
import gos.bot.protocol.ProcessedMove;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import com.google.gson.Gson;
public class Engine implements AutoCloseable
{
private final IBot bot;
private final InputStreamReader inStreamReader;
private final BufferedReader inReader;
private final Gson gson;
private Player botColor;
public Engine(IBot bot)
{
this.bot = bot;
inStreamReader = new InputStreamReader(System.in);
inReader = new BufferedReader(inStreamReader);
gson = new Gson();
}
public void run()
{
try
{
DoInitiateRequest();
Player winner = DoFirstRound();
while (winner == Player.None)
{
winner = DoNormalRound();
}
}
catch (Exception ex)
{
System.err.println("Exception. Bailing out.");
ex.printStackTrace(System.err);
}
}
private void DoInitiateRequest() throws InvalidMessageException
{
InitiateRequest initRequest = readMessage(InitiateRequest.class);
if (initRequest == null)
{
throw new InvalidMessageException("Unexpected message received. Expected InitiateRequest.");
}
botColor = initRequest.Color;
bot.HandleInitiate(initRequest);
}
private Player DoFirstRound() throws InvalidMessageException
{
Player winner;
if (botColor == Player.White)
{
// Do the first move
HandleMoveRequest();
// and wait for the engine to acknowledge
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
// Wait for first two moves of black
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
}
else
{
// Wait for first white move
winner = HandleProcessedMove();
}
return winner;
}
private Player DoNormalRound() throws InvalidMessageException
{
Player winner;
HandleMoveRequest();
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
HandleMoveRequest();
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
return winner;
}
private void HandleMoveRequest() throws InvalidMessageException
{
// process first move
MoveRequest moveRequest = readMessage(MoveRequest.class);
if (moveRequest == null)
{
throw new InvalidMessageException("Unexpected message received. Expected MoveRequest.");
}
Move move = bot.HandleMove(moveRequest);
writeMessage(move);
}
private Player HandleProcessedMove() throws InvalidMessageException
{
ProcessedMove processedMove = readMessage(ProcessedMove.class);
if (processedMove == null)
{
throw new InvalidMessageException("Unexpected message received. Expected ProcessedMove.");
}
bot.HandleProcessedMove(processedMove);
return processedMove.Winner;
}
@Override
public void close() throws Exception
{
try
{
inReader.close();
inStreamReader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
private <T> T readMessage(Class<T> classOfT)
{
String messageStr = null;
try
{
messageStr = inReader.readLine();
}
catch (IOException e)
{
return null;
}
if (messageStr == null || messageStr.isEmpty())
{
return null;
}
return gson.fromJson(messageStr, classOfT);
}
private <T> void writeMessage(T message)
{
String messageStr = gson.toJson(message);
System.out.println(messageStr);
}
}
| UTF-8 | Java | 4,567 | java | Engine.java | Java | []
| null | []
| package gos.bot;
import gos.bot.protocol.InitiateRequest;
import gos.bot.protocol.Move;
import gos.bot.protocol.MoveRequest;
import gos.bot.protocol.Player;
import gos.bot.protocol.ProcessedMove;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import com.google.gson.Gson;
public class Engine implements AutoCloseable
{
private final IBot bot;
private final InputStreamReader inStreamReader;
private final BufferedReader inReader;
private final Gson gson;
private Player botColor;
public Engine(IBot bot)
{
this.bot = bot;
inStreamReader = new InputStreamReader(System.in);
inReader = new BufferedReader(inStreamReader);
gson = new Gson();
}
public void run()
{
try
{
DoInitiateRequest();
Player winner = DoFirstRound();
while (winner == Player.None)
{
winner = DoNormalRound();
}
}
catch (Exception ex)
{
System.err.println("Exception. Bailing out.");
ex.printStackTrace(System.err);
}
}
private void DoInitiateRequest() throws InvalidMessageException
{
InitiateRequest initRequest = readMessage(InitiateRequest.class);
if (initRequest == null)
{
throw new InvalidMessageException("Unexpected message received. Expected InitiateRequest.");
}
botColor = initRequest.Color;
bot.HandleInitiate(initRequest);
}
private Player DoFirstRound() throws InvalidMessageException
{
Player winner;
if (botColor == Player.White)
{
// Do the first move
HandleMoveRequest();
// and wait for the engine to acknowledge
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
// Wait for first two moves of black
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
}
else
{
// Wait for first white move
winner = HandleProcessedMove();
}
return winner;
}
private Player DoNormalRound() throws InvalidMessageException
{
Player winner;
HandleMoveRequest();
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
HandleMoveRequest();
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
if (winner != Player.None)
{
return winner;
}
winner = HandleProcessedMove();
return winner;
}
private void HandleMoveRequest() throws InvalidMessageException
{
// process first move
MoveRequest moveRequest = readMessage(MoveRequest.class);
if (moveRequest == null)
{
throw new InvalidMessageException("Unexpected message received. Expected MoveRequest.");
}
Move move = bot.HandleMove(moveRequest);
writeMessage(move);
}
private Player HandleProcessedMove() throws InvalidMessageException
{
ProcessedMove processedMove = readMessage(ProcessedMove.class);
if (processedMove == null)
{
throw new InvalidMessageException("Unexpected message received. Expected ProcessedMove.");
}
bot.HandleProcessedMove(processedMove);
return processedMove.Winner;
}
@Override
public void close() throws Exception
{
try
{
inReader.close();
inStreamReader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
private <T> T readMessage(Class<T> classOfT)
{
String messageStr = null;
try
{
messageStr = inReader.readLine();
}
catch (IOException e)
{
return null;
}
if (messageStr == null || messageStr.isEmpty())
{
return null;
}
return gson.fromJson(messageStr, classOfT);
}
private <T> void writeMessage(T message)
{
String messageStr = gson.toJson(message);
System.out.println(messageStr);
}
}
| 4,567 | 0.567988 | 0.567988 | 189 | 23.164021 | 21.334562 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.365079 | false | false | 9 |
70fd11f7580599b0ebe8b406b4e9ae7ff3d29659 | 2,147,483,670,178 | d97188826b74798317d1d0213f81df1a908a7854 | /src/main/java/com/equipment/management/handler/JwtAccessDeniedHandler.java | 324c71b27169daf4613692ce0fa5dd40c7f105e2 | []
| no_license | alllostser/equipment-management-system | https://github.com/alllostser/equipment-management-system | d17843e3397f0f00103f105a1a356edbea861455 | a5a8cce8e725654f270d91f6244ae36f1806b11a | refs/heads/master | 2023-03-17T02:45:42.604000 | 2021-03-07T17:25:35 | 2021-03-07T17:25:35 | 328,713,301 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.equipment.management.handler;
import com.equipment.management.utils.ResultUtil;
import lombok.SneakyThrows;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* @description: AccessDeineHandler 用来解决认证过的用户访问无权限资源时的异常
* @author: Guxinyu
* @created: 2020/09/18 17:30
*/
public class JwtAccessDeniedHandler implements AccessDeniedHandler {
/**
* 当用户尝试访问需要权限才能的REST资源而权限不足的时候,
* 将调用此方法发送403响应以及错误信息
*/
@SneakyThrows
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
Map<String,Object> result = new HashMap();
result.put("errCode",HttpServletResponse.SC_FORBIDDEN);
result.put("errMsg","权限不足");
result.put("status","failed");
ResultUtil.responseJson(response,result);
}
}
| UTF-8 | Java | 1,251 | java | JwtAccessDeniedHandler.java | Java | [
{
"context": "cessDeineHandler 用来解决认证过的用户访问无权限资源时的异常\n * @author: Guxinyu\n * @created: 2020/09/18 17:30\n */\npublic class Jw",
"end": 507,
"score": 0.9995051622390747,
"start": 500,
"tag": "USERNAME",
"value": "Guxinyu"
}
]
| null | []
| package com.equipment.management.handler;
import com.equipment.management.utils.ResultUtil;
import lombok.SneakyThrows;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* @description: AccessDeineHandler 用来解决认证过的用户访问无权限资源时的异常
* @author: Guxinyu
* @created: 2020/09/18 17:30
*/
public class JwtAccessDeniedHandler implements AccessDeniedHandler {
/**
* 当用户尝试访问需要权限才能的REST资源而权限不足的时候,
* 将调用此方法发送403响应以及错误信息
*/
@SneakyThrows
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
Map<String,Object> result = new HashMap();
result.put("errCode",HttpServletResponse.SC_FORBIDDEN);
result.put("errMsg","权限不足");
result.put("status","failed");
ResultUtil.responseJson(response,result);
}
}
| 1,251 | 0.764075 | 0.75067 | 33 | 32.909092 | 29.281666 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 9 |
9f5ea13e3297e50e831c1135da81975a1fa23fb9 | 2,594,160,268,355 | d04318f0a01b10d4f9e9415873178c99697b637d | /src/main/java/repository/ServicoRepositoryList.java | 591e885b81340bc9d8cf73df190edd6f79313c1a | []
| no_license | UCDB/sistema_financeiro_2017_A2 | https://github.com/UCDB/sistema_financeiro_2017_A2 | cbc9327f48fadb98762e1f8e28a4b995e26adbd4 | 5911a5cab4450c4d9f4d3ff3100d323966b96cbe | refs/heads/master | 2021-01-21T22:05:52.044000 | 2017-06-23T01:55:21 | 2017-06-23T01:55:21 | 95,165,069 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package repository;
import java.util.ArrayList;
import java.util.List;
import model.Servico;
public class ServicoRepositoryList implements ServicoRepository{
private int id=0;
private List<Servico> lista = new ArrayList<>();
@Override
public void cadastrar(Servico serv) {
serv.setId_funcionario(id++);
lista.add(serv);
}
@Override
public Servico buscarPorId(Integer id) {
for (int i = 0; i < lista.size(); i++){
if (lista.get(i).getId_funcionario().equals(id)){
return lista.get(i);
}
}
return null;
}
}
| UTF-8 | Java | 544 | java | ServicoRepositoryList.java | Java | []
| null | []
| package repository;
import java.util.ArrayList;
import java.util.List;
import model.Servico;
public class ServicoRepositoryList implements ServicoRepository{
private int id=0;
private List<Servico> lista = new ArrayList<>();
@Override
public void cadastrar(Servico serv) {
serv.setId_funcionario(id++);
lista.add(serv);
}
@Override
public Servico buscarPorId(Integer id) {
for (int i = 0; i < lista.size(); i++){
if (lista.get(i).getId_funcionario().equals(id)){
return lista.get(i);
}
}
return null;
}
}
| 544 | 0.689338 | 0.685662 | 29 | 17.758621 | 18.214537 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.517241 | false | false | 15 |
6d00c577d5722e3a55238ab3735bf396377c8063 | 19,198,503,815,119 | bc481ba079430cf1c271126d91ec287524e5ad69 | /Tutorial34/src/SerializeArray/WriteObjects.java | 5f3dda423eaaf092e43c5de438452ce93ca33798 | []
| no_license | gg-akaghzi/java | https://github.com/gg-akaghzi/java | 2038dde676213c8f201a31d5120e81c7f0354349 | 353eea953dbedbf1dcbaae7dd4d4a32bd6f5525a | refs/heads/master | 2016-08-06T14:24:26.274000 | 2014-11-14T16:46:23 | 2014-11-14T16:46:23 | 26,131,715 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package SerializeArray;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
public class WriteObjects {
public static void main(String[] args) {
System.out.println("Writing objects");
Person[] people = { new Person(1, "mike"), new Person(2, "sue"),
new Person(3, "bob") };
ArrayList<Person> peopleList = new ArrayList<Person>(Arrays.asList(people));
try (FileOutputStream fs = new FileOutputStream("./src/array.txt")) {
try (ObjectOutputStream os = new ObjectOutputStream(fs)) {
os.writeObject(people);
os.writeObject(peopleList);
} catch (FileNotFoundException e) {
System.out.println("File not found exception for: ");
} catch (IOException e) {
System.out.println("IO exception for:");
}
} catch (FileNotFoundException e) {
System.out.println("FNFE");
} catch (IOException e) {
System.out.println("IOE");
}
}
}
| UTF-8 | Java | 1,008 | java | WriteObjects.java | Java | [
{
"context": "g objects\");\n\t\tPerson[] people = { new Person(1, \"mike\"), new Person(2, \"sue\"),\n\t\t\t\tnew Person(3, \"bob\")",
"end": 366,
"score": 0.9998189806938171,
"start": 362,
"tag": "NAME",
"value": "mike"
},
{
"context": " people = { new Person(1, \"mike\"), new Person(2, \"sue\"),\n\t\t\t\tnew Person(3, \"bob\") };\n\t\tArrayList<Person",
"end": 388,
"score": 0.9994409084320068,
"start": 385,
"tag": "NAME",
"value": "sue"
},
{
"context": "\"mike\"), new Person(2, \"sue\"),\n\t\t\t\tnew Person(3, \"bob\") };\n\t\tArrayList<Person> peopleList = new ArrayLi",
"end": 414,
"score": 0.9997713565826416,
"start": 411,
"tag": "NAME",
"value": "bob"
}
]
| null | []
| package SerializeArray;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
public class WriteObjects {
public static void main(String[] args) {
System.out.println("Writing objects");
Person[] people = { new Person(1, "mike"), new Person(2, "sue"),
new Person(3, "bob") };
ArrayList<Person> peopleList = new ArrayList<Person>(Arrays.asList(people));
try (FileOutputStream fs = new FileOutputStream("./src/array.txt")) {
try (ObjectOutputStream os = new ObjectOutputStream(fs)) {
os.writeObject(people);
os.writeObject(peopleList);
} catch (FileNotFoundException e) {
System.out.println("File not found exception for: ");
} catch (IOException e) {
System.out.println("IO exception for:");
}
} catch (FileNotFoundException e) {
System.out.println("FNFE");
} catch (IOException e) {
System.out.println("IOE");
}
}
}
| 1,008 | 0.704365 | 0.701389 | 35 | 27.799999 | 21.36459 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.142857 | false | false | 15 |
dd2248ef8de51e16e061f63bca5da04b895dc417 | 1,013,612,305,071 | 12762497d537c34c977b85ec6875157ae9131ed1 | /app/src/main/java/com/yundong/milk/api/service/IPCAService.java | 3a5025ac5fbf76fdadd94e8838da09da886a994a | []
| no_license | 415192022/Milk | https://github.com/415192022/Milk | 42fc2bf6298f5f626c9154842fe8fe8f33123053 | c43e8b96d7b2ab95c3b17860110917e55c37e14a | refs/heads/master | 2021-01-16T23:16:37.189000 | 2017-03-20T09:58:21 | 2017-03-20T09:58:21 | 82,780,130 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yundong.milk.api.service;
import com.yundong.milk.model.BuyNowBean;
import com.yundong.milk.model.PCABean;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;
/**
* Created by MingweiLi on 2017/3/3.
*/
public interface IPCAService {
@FormUrlEncoded
@POST("area/area_list")
Observable<PCABean> getPCA(
@Field("area_parent_id") String area_parent_id
);
}
| UTF-8 | Java | 464 | java | IPCAService.java | Java | [
{
"context": "ttp.POST;\nimport rx.Observable;\n\n/**\n * Created by MingweiLi on 2017/3/3.\n */\n\npublic interface IPCAService {\n",
"end": 266,
"score": 0.8820414543151855,
"start": 257,
"tag": "USERNAME",
"value": "MingweiLi"
}
]
| null | []
| package com.yundong.milk.api.service;
import com.yundong.milk.model.BuyNowBean;
import com.yundong.milk.model.PCABean;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;
/**
* Created by MingweiLi on 2017/3/3.
*/
public interface IPCAService {
@FormUrlEncoded
@POST("area/area_list")
Observable<PCABean> getPCA(
@Field("area_parent_id") String area_parent_id
);
}
| 464 | 0.724138 | 0.704741 | 21 | 21.095238 | 17.0961 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.380952 | false | false | 15 |
7b9a417cdc51f5d7640af34b991fe990d1361660 | 26,199,300,530,280 | 5a17f2137e1b29edcbf268dd3c2de3150a78ec43 | /ZipCodeRange/src/main/java/com/williamssonoma/zipcode/model/ZipCodeRange.java | 11d235298d94e5922d7845ccff3c01dd7823f647 | []
| no_license | asajjad1234/JavaMisc | https://github.com/asajjad1234/JavaMisc | 7c737a363831b82e866b0933fcff356d104444a1 | e63846f8a0681e35cd80bbab0ab5a0768254941b | refs/heads/master | 2020-04-11T02:13:54.606000 | 2019-01-22T09:36:03 | 2019-01-22T09:36:03 | 161,438,874 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package com.williamssonoma.zipcode.model;
/**
* @author ahmedsajjad
* A class to hold the lower and upper bound Zip Code ranges.
*/
public final class ZipCodeRange implements Comparable <ZipCodeRange> {
private String lowerBound;
private String upperBound;
/**
* Constructor to create ZipCodeRange
* @param lowerBound
* @param upperBound
*/
public ZipCodeRange(String lowerBound, String upperBound) {
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
/**
* Compare method to compare 2 different ZipCodeRanges
*/
public int compareTo(ZipCodeRange zipRange) {
return (this.lowerBound.compareTo(zipRange.lowerBound));
}
/**
* @return the lowerBound
*/
public String getLowerBound() {
return lowerBound;
}
/**
* @return the upperBound
*/
public String getUpperBound() {
return upperBound;
}
/**
* @param upperBound the upperBound to set
*/
public void setUpperBound(String upperBound) {
this.upperBound = upperBound;
}
@Override
/**
* toString method for ZipCodeRange
*/
public String toString() {
return "["+this.lowerBound + "," + this.upperBound+"] ";
}
}
| UTF-8 | Java | 1,216 | java | ZipCodeRange.java | Java | [
{
"context": "m.williamssonoma.zipcode.model;\r\n\r\n/**\r\n * @author ahmedsajjad\r\n * A class to hold the lower and upper bound Zip",
"end": 87,
"score": 0.9990501403808594,
"start": 76,
"tag": "USERNAME",
"value": "ahmedsajjad"
}
]
| null | []
| /**
*
*/
package com.williamssonoma.zipcode.model;
/**
* @author ahmedsajjad
* A class to hold the lower and upper bound Zip Code ranges.
*/
public final class ZipCodeRange implements Comparable <ZipCodeRange> {
private String lowerBound;
private String upperBound;
/**
* Constructor to create ZipCodeRange
* @param lowerBound
* @param upperBound
*/
public ZipCodeRange(String lowerBound, String upperBound) {
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
/**
* Compare method to compare 2 different ZipCodeRanges
*/
public int compareTo(ZipCodeRange zipRange) {
return (this.lowerBound.compareTo(zipRange.lowerBound));
}
/**
* @return the lowerBound
*/
public String getLowerBound() {
return lowerBound;
}
/**
* @return the upperBound
*/
public String getUpperBound() {
return upperBound;
}
/**
* @param upperBound the upperBound to set
*/
public void setUpperBound(String upperBound) {
this.upperBound = upperBound;
}
@Override
/**
* toString method for ZipCodeRange
*/
public String toString() {
return "["+this.lowerBound + "," + this.upperBound+"] ";
}
}
| 1,216 | 0.658717 | 0.657895 | 60 | 18.266666 | 19.811501 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.066667 | false | false | 15 |
c8d1f68786e31f87f87f04f461d4d40a601a6937 | 18,665,927,911,151 | 7f0c43b9d8914e856ccc30fe27ea8e11f4dd06be | /src/main/java/com/guonl/car/factory/CSSupplier.java | dea611fd63e01d9f216e33e54d8d89409cb02f2b | [
"Apache-2.0"
]
| permissive | guonl/DesignPattern | https://github.com/guonl/DesignPattern | 8a95e59887b4eac15311c27b5a9db1821283b4d1 | e8a5be9185eca7afe8d355e6f2c80d84ec8f9e9a | refs/heads/master | 2020-12-02T18:12:27.364000 | 2017-11-21T02:58:41 | 2017-11-21T02:58:41 | 96,303,749 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.guonl.car.factory;
/**
*
* @ClassName: JSSupplier
* @Description: 捷顺供应商
* @author guonl
* @date 2017年8月3日 上午10:46:32
* @version V1.0
*
*/
public class CSSupplier implements ParkingSupplier {
@Override
public Boolean checkIsExist() {
return true;
}
@Override
public String getParkingInfo(String carNo) {
return "get parking car info **测试** " + carNo;
}
@Override
public String notifySupplier(String carNo) {
return "notify to supplier **测试** " + carNo;
}
}
| UTF-8 | Java | 564 | java | CSSupplier.java | Java | [
{
"context": "e: JSSupplier \r\n * @Description: 捷顺供应商\r\n * @author guonl\r\n * @date 2017年8月3日 上午10:46:32 \r\n * @version V1.0",
"end": 112,
"score": 0.9993324875831604,
"start": 107,
"tag": "USERNAME",
"value": "guonl"
}
]
| null | []
| package com.guonl.car.factory;
/**
*
* @ClassName: JSSupplier
* @Description: 捷顺供应商
* @author guonl
* @date 2017年8月3日 上午10:46:32
* @version V1.0
*
*/
public class CSSupplier implements ParkingSupplier {
@Override
public Boolean checkIsExist() {
return true;
}
@Override
public String getParkingInfo(String carNo) {
return "get parking car info **测试** " + carNo;
}
@Override
public String notifySupplier(String carNo) {
return "notify to supplier **测试** " + carNo;
}
}
| 564 | 0.634328 | 0.608209 | 30 | 15.866667 | 17.188627 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.7 | false | false | 15 |
d09a5576d7000e227f0709c8ab1227f9aa8025be | 35,622,458,761,894 | d835e9623b5f83c18a21407bd6cf0ab7d2f26895 | /src/org/AttackTheFortress/views/MenuView.java | 3ade18cfd99cf4706eed28c1b70bbfa50bf04898 | []
| no_license | panda926/AttackTheFortness | https://github.com/panda926/AttackTheFortness | 400633c32246e93bc2565dd2176bf50679305370 | f5bdc44b18a6f2cb8118bc8c8135ad6d005ca534 | refs/heads/master | 2021-01-10T05:24:28.545000 | 2016-03-17T13:59:33 | 2016-03-17T13:59:33 | 54,122,168 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.AttackTheFortress.views;
import org.AttackTheFortress.DataManager;
import org.AttackTheFortress.Global;
import org.cocos2d.layers.Layer;
import org.cocos2d.menus.Menu;
import org.cocos2d.menus.MenuItem;
import org.cocos2d.menus.MenuItemImage;
import org.cocos2d.nodes.Director;
import org.cocos2d.nodes.Scene;
import org.cocos2d.nodes.Sprite;
import org.cocos2d.transitions.FadeTransition;
public class MenuView extends Layer {
private String bgPath, btnPath;
private float rScale_width = 0.0f;
private float rScale_height = 0.0f;
public MenuView() {
// TODO Auto-generated constructor stub
bgPath = "gfx/menuview/";
btnPath = "gfx/buttons/";
rScale_width = Global.g_rScale_x;
rScale_height = Global.g_rScale_y;
DataManager.shared().playMusic(0);
loadResource();
}
private void loadResource()
{
// background
Sprite bgSprite = Sprite.sprite(bgPath + "menuviewback.png");
bgSprite.setScaleX(rScale_width); bgSprite.setScaleY(rScale_height);
bgSprite.setPosition(getWidth()/2, getHeight()/2);
addChild(bgSprite, -1);
// play button
MenuItem item = MenuItemImage.item(btnPath + "BtnPlay1.png", btnPath + "BtnPlay2.png", this, "showMapView");
Menu menu = Menu.menu(item);
menu.setPosition(0, 0);
item.setScaleX(rScale_width); item.setScaleY(rScale_height);
item.setPosition(235*rScale_width, 97*rScale_height);
addChild(menu);
}
public void showMapView()
{
Scene scene = Scene.node();
scene.addChild(new MapView(), 0);
Director.sharedDirector().replaceScene(new FadeTransition(1.0f, scene));
}
}
| UTF-8 | Java | 1,685 | java | MenuView.java | Java | []
| null | []
| package org.AttackTheFortress.views;
import org.AttackTheFortress.DataManager;
import org.AttackTheFortress.Global;
import org.cocos2d.layers.Layer;
import org.cocos2d.menus.Menu;
import org.cocos2d.menus.MenuItem;
import org.cocos2d.menus.MenuItemImage;
import org.cocos2d.nodes.Director;
import org.cocos2d.nodes.Scene;
import org.cocos2d.nodes.Sprite;
import org.cocos2d.transitions.FadeTransition;
public class MenuView extends Layer {
private String bgPath, btnPath;
private float rScale_width = 0.0f;
private float rScale_height = 0.0f;
public MenuView() {
// TODO Auto-generated constructor stub
bgPath = "gfx/menuview/";
btnPath = "gfx/buttons/";
rScale_width = Global.g_rScale_x;
rScale_height = Global.g_rScale_y;
DataManager.shared().playMusic(0);
loadResource();
}
private void loadResource()
{
// background
Sprite bgSprite = Sprite.sprite(bgPath + "menuviewback.png");
bgSprite.setScaleX(rScale_width); bgSprite.setScaleY(rScale_height);
bgSprite.setPosition(getWidth()/2, getHeight()/2);
addChild(bgSprite, -1);
// play button
MenuItem item = MenuItemImage.item(btnPath + "BtnPlay1.png", btnPath + "BtnPlay2.png", this, "showMapView");
Menu menu = Menu.menu(item);
menu.setPosition(0, 0);
item.setScaleX(rScale_width); item.setScaleY(rScale_height);
item.setPosition(235*rScale_width, 97*rScale_height);
addChild(menu);
}
public void showMapView()
{
Scene scene = Scene.node();
scene.addChild(new MapView(), 0);
Director.sharedDirector().replaceScene(new FadeTransition(1.0f, scene));
}
}
| 1,685 | 0.691395 | 0.674777 | 57 | 27.561403 | 23.241688 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.649123 | false | false | 15 |
6c3d6812be88ba31d8292234918cd575ad4eb6aa | 11,785,390,323,933 | 2d76beab605a966bf26a86a26e510b9ec127e698 | /src/main/java/com/lysong/friday/service/PermissionService.java | babd477530f7e1390d0b96595ff52348731cc0df | []
| no_license | LySong000/SpringBootRBAC | https://github.com/LySong000/SpringBootRBAC | dae545cd8fac2075da277e3231d41482568b6385 | 879345b9f13b37b8f57f7d5e695347d7d35dbfdb | refs/heads/master | 2022-06-21T11:49:59.502000 | 2020-03-22T04:57:32 | 2020-03-22T04:57:32 | 248,483,495 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lysong.friday.service;
import com.lysong.friday.base.result.Results;
import com.lysong.friday.model.SysPermission;
/**
* @Author: LySong
* @Date: 2020/3/17 23:13
*/
public interface PermissionService {
Results listAllPermission();
Results<SysPermission> listAllPermissionByRoleId(int intValue);
Results<SysPermission> getAllMenu();
Results<SysPermission> save(SysPermission sysPermission);
SysPermission getPermissionById(Integer id);
Results<SysPermission> update(SysPermission sysPermission);
Results<SysPermission> deleteById(Integer id);
Results getMenu(Long userId);
}
| UTF-8 | Java | 658 | java | PermissionService.java | Java | [
{
"context": "ng.friday.model.SysPermission;\r\n\r\n/**\r\n * @Author: LySong\r\n * @Date: 2020/3/17 23:13\r\n */\r\npublic interface",
"end": 157,
"score": 0.999122142791748,
"start": 151,
"tag": "USERNAME",
"value": "LySong"
}
]
| null | []
| package com.lysong.friday.service;
import com.lysong.friday.base.result.Results;
import com.lysong.friday.model.SysPermission;
/**
* @Author: LySong
* @Date: 2020/3/17 23:13
*/
public interface PermissionService {
Results listAllPermission();
Results<SysPermission> listAllPermissionByRoleId(int intValue);
Results<SysPermission> getAllMenu();
Results<SysPermission> save(SysPermission sysPermission);
SysPermission getPermissionById(Integer id);
Results<SysPermission> update(SysPermission sysPermission);
Results<SysPermission> deleteById(Integer id);
Results getMenu(Long userId);
}
| 658 | 0.727964 | 0.711246 | 27 | 22.370371 | 23.297031 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.407407 | false | false | 15 |
4e527a5537446c326bb383b4539651602f28684f | 27,530,740,391,658 | 67b01200460a5ee7d143a400c37cf1244dc30a5c | /springockito-annotations/src/test/java/org/kubek2k/springockito/annotations/it/SpringockitoAnnotationsSpiesIntegrationTest.java | 34fd5416355ea8c1ee5185a42fde64d7ebc4c684 | []
| no_license | kmoens/springockito | https://github.com/kmoens/springockito | 17b3234027026f5b427f14ed5f1002dbed8ee35b | 108d86705d34ac8e75fca190f85a8e517b0da9fa | refs/heads/master | 2022-12-21T13:21:53.282000 | 2020-02-25T12:53:45 | 2020-02-25T12:53:45 | 40,006,287 | 5 | 4 | null | false | 2022-12-16T00:47:31 | 2015-07-31T13:21:26 | 2020-02-25T12:53:49 | 2022-12-16T00:47:28 | 94 | 6 | 3 | 11 | Java | false | false | package org.kubek2k.springockito.annotations.it;
import org.kubek2k.springockito.annotations.SpringockitoContextLoader;
import org.kubek2k.springockito.annotations.WrapWithSpy;
import org.kubek2k.springockito.annotations.it.beans.InnerBean;
import org.kubek2k.springockito.annotations.it.beans.OuterBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
import static org.mockito.Mockito.verify;
@ContextConfiguration(loader = SpringockitoContextLoader.class,
locations = "classpath:/mockContext.xml")
public class SpringockitoAnnotationsSpiesIntegrationTest extends AbstractTestNGSpringContextTests {
@WrapWithSpy
@Autowired
private InnerBean innerBean;
@Autowired
private OuterBean outerBean;
@Test
@DirtiesContext
public void shouldUseSpyInsteadOfOriginalBean() {
int result = outerBean.doSomething();
// the actual returned value is real and we can verify interaction
Assert.assertEquals(result, InnerBean.VALUE_RETURNED_BY_INNER);
verify(innerBean).doSomething();
}
} | UTF-8 | Java | 1,334 | java | SpringockitoAnnotationsSpiesIntegrationTest.java | Java | []
| null | []
| package org.kubek2k.springockito.annotations.it;
import org.kubek2k.springockito.annotations.SpringockitoContextLoader;
import org.kubek2k.springockito.annotations.WrapWithSpy;
import org.kubek2k.springockito.annotations.it.beans.InnerBean;
import org.kubek2k.springockito.annotations.it.beans.OuterBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
import static org.mockito.Mockito.verify;
@ContextConfiguration(loader = SpringockitoContextLoader.class,
locations = "classpath:/mockContext.xml")
public class SpringockitoAnnotationsSpiesIntegrationTest extends AbstractTestNGSpringContextTests {
@WrapWithSpy
@Autowired
private InnerBean innerBean;
@Autowired
private OuterBean outerBean;
@Test
@DirtiesContext
public void shouldUseSpyInsteadOfOriginalBean() {
int result = outerBean.doSomething();
// the actual returned value is real and we can verify interaction
Assert.assertEquals(result, InnerBean.VALUE_RETURNED_BY_INNER);
verify(innerBean).doSomething();
}
} | 1,334 | 0.801349 | 0.797601 | 37 | 35.081081 | 28.421898 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.513514 | false | false | 15 |
71d172e539c112c8cd1214b0a5f85314904d9ba6 | 30,150,670,477,894 | c99e3e1d7f0f5f47b6b186b79685a17bd8d12f51 | /sif3-naplan-provider/src/main/java/sif3/au/naplan/provider/service/NAPCodeFrameService.java | 180299404b412b1bb20aeda7d6894c04a801d44c | [
"Apache-2.0"
]
| permissive | nsip/sif3-naplan-adapter | https://github.com/nsip/sif3-naplan-adapter | 146ec746523513ee2c9974662ce077e340b624c7 | ee34c4c7b2e4584b99c81bd5da4f46cae347e3f8 | refs/heads/master | 2020-03-31T19:55:24.532000 | 2018-10-23T03:45:25 | 2018-10-23T03:45:25 | 152,518,308 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sif3.au.naplan.provider.service;
import sif.dd.au30.model.NAPCodeFrameCollectionType;
public interface NAPCodeFrameService extends NaplanService<NAPCodeFrameCollectionType> {
}
| UTF-8 | Java | 188 | java | NAPCodeFrameService.java | Java | []
| null | []
| package sif3.au.naplan.provider.service;
import sif.dd.au30.model.NAPCodeFrameCollectionType;
public interface NAPCodeFrameService extends NaplanService<NAPCodeFrameCollectionType> {
}
| 188 | 0.851064 | 0.835106 | 7 | 25.857143 | 32.445244 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 15 |
21859e8f946938f33cca7c8fbfbc0b70ed52ad4f | 4,475,355,981,803 | d70956121e9d644baba3e1ad311b550c941a6688 | /app/src/main/java/com/sahara/melanie/fortify_android/metrics/surveys/SurveyResponseActivity.java | 51d981867c3f2941ad2553129d9b3fd06c453bb6 | []
| no_license | melanie38/sandbox | https://github.com/melanie38/sandbox | 4222dfa416e93a10e69fbb4c95671d02b80c40e7 | 70895aedec1f189715c36e42d3bce861d4291219 | refs/heads/master | 2018-04-20T11:49:07.946000 | 2018-04-06T16:55:12 | 2018-04-06T16:55:12 | 90,777,222 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sahara.melanie.fortify_android.metrics.surveys;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.sahara.melanie.fortify_android.R;
import com.sahara.melanie.fortify_android.base_activity.MasterActivity;
import com.sahara.melanie.fortify_android.start.LaunchActivity;
import org.w3c.dom.Text;
public class SurveyResponseActivity extends MasterActivity {
private int numberOfSurveys;
private int allyeeId;
private ViewPager mViewPager;
private TabLayout mTabLayout;
private TextView surveyTitle;
private SurveyTabAdapter mSurveyTabAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!checkInit()) {
finish();
}
else {
setContentView(R.layout.activity_survey_response);
//Get intents
numberOfSurveys = getIntent().getIntExtra("numberOfSurveys", 0);
allyeeId = getIntent().getIntExtra("allyeeId", -1);
surveyTitle = (TextView) findViewById(R.id.survey_number_title);
surveyTitle.setText("Survey #1");
//Set up adapters
mTabLayout = (TabLayout) findViewById(R.id.tabs);
mSurveyTabAdapter = new SurveyResponseActivity.SurveyTabAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.response_view_Pager);
mViewPager.setAdapter(mSurveyTabAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
int s = position + 1;
surveyTitle.setText("Survey #" + s);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mTabLayout.setupWithViewPager(mViewPager, true);
}
}
private boolean checkInit() {
if (!LaunchActivity.initialized) {
Intent intent = new Intent(this, LaunchActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
return false;
}
return true;
}
public class SurveyTabAdapter extends FragmentStatePagerAdapter{
public SurveyTabAdapter(FragmentManager fm) {super(fm);}
@Override
public Fragment getItem(int position) {
int surveyNumber = position + 1;
SurveyResponseFragment fragment = SurveyResponseFragment.newInstance(surveyNumber, allyeeId);
return fragment;
}
@Override
public int getCount() {
return numberOfSurveys;
}
}
}
| UTF-8 | Java | 3,243 | java | SurveyResponseActivity.java | Java | []
| null | []
| package com.sahara.melanie.fortify_android.metrics.surveys;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.sahara.melanie.fortify_android.R;
import com.sahara.melanie.fortify_android.base_activity.MasterActivity;
import com.sahara.melanie.fortify_android.start.LaunchActivity;
import org.w3c.dom.Text;
public class SurveyResponseActivity extends MasterActivity {
private int numberOfSurveys;
private int allyeeId;
private ViewPager mViewPager;
private TabLayout mTabLayout;
private TextView surveyTitle;
private SurveyTabAdapter mSurveyTabAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!checkInit()) {
finish();
}
else {
setContentView(R.layout.activity_survey_response);
//Get intents
numberOfSurveys = getIntent().getIntExtra("numberOfSurveys", 0);
allyeeId = getIntent().getIntExtra("allyeeId", -1);
surveyTitle = (TextView) findViewById(R.id.survey_number_title);
surveyTitle.setText("Survey #1");
//Set up adapters
mTabLayout = (TabLayout) findViewById(R.id.tabs);
mSurveyTabAdapter = new SurveyResponseActivity.SurveyTabAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.response_view_Pager);
mViewPager.setAdapter(mSurveyTabAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
int s = position + 1;
surveyTitle.setText("Survey #" + s);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mTabLayout.setupWithViewPager(mViewPager, true);
}
}
private boolean checkInit() {
if (!LaunchActivity.initialized) {
Intent intent = new Intent(this, LaunchActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
return false;
}
return true;
}
public class SurveyTabAdapter extends FragmentStatePagerAdapter{
public SurveyTabAdapter(FragmentManager fm) {super(fm);}
@Override
public Fragment getItem(int position) {
int surveyNumber = position + 1;
SurveyResponseFragment fragment = SurveyResponseFragment.newInstance(surveyNumber, allyeeId);
return fragment;
}
@Override
public int getCount() {
return numberOfSurveys;
}
}
}
| 3,243 | 0.650015 | 0.646623 | 100 | 31.43 | 27.147839 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52 | false | false | 15 |
c61f1ccd82f27e8ebe8c31638ac8791857850cb0 | 8,126,078,159,424 | 66146e2d2c12c9d2f1e43ab494340f07fd52bdbd | /src/main/java/ua/kozak/service/UserService.java | 48a9834c1baffe54cb720f211453788afa43cd37 | []
| no_license | OrysiaKozak/Online_Shop | https://github.com/OrysiaKozak/Online_Shop | 37b8def64418976dd0ef2e4e525dd96f731cf278 | b29500f823d13fea0048900cbf2256cd7b5cbdb7 | refs/heads/master | 2016-09-13T00:05:23.911000 | 2016-05-17T15:03:32 | 2016-05-17T15:03:32 | 58,444,841 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ua.kozak.service;
import java.util.List;
import ua.kozak.entity.User;
public interface UserService {
public void add(String firstName, String secondName, String email,
String phoneNumber, String roleName);
public List<User> getAllUsers();
public void update(int id,String firstName, String secondName, String email,
String phoneNumber, String roleName);
public void remove(int id);
}
| UTF-8 | Java | 427 | java | UserService.java | Java | []
| null | []
| package ua.kozak.service;
import java.util.List;
import ua.kozak.entity.User;
public interface UserService {
public void add(String firstName, String secondName, String email,
String phoneNumber, String roleName);
public List<User> getAllUsers();
public void update(int id,String firstName, String secondName, String email,
String phoneNumber, String roleName);
public void remove(int id);
}
| 427 | 0.735363 | 0.735363 | 18 | 21.722221 | 23.323345 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.444444 | false | false | 15 |
108e12cc44d0d4285aa5ad7f88f0074ea4fb9d93 | 35,871,566,865,514 | 986fb035dbf2f82be8c1b991dfc2751e18885adf | /ms-general/src/main/java/com/flores/controller/UbigeoDepartamentoController.java | d17cdc32ae4c0815dc63ac5bf7b15dbf0a9bc741 | []
| no_license | Wil1999/aeg-unasam | https://github.com/Wil1999/aeg-unasam | 7192cfc086141504b20fd764c9a7c2d99b2aeffd | 7f424681ea3010475ab6a6f483bb99425963b555 | refs/heads/main | 2023-04-16T20:00:53.763000 | 2021-04-10T21:47:21 | 2021-04-10T21:47:21 | 354,992,279 | 0 | 0 | null | false | 2021-04-10T21:47:22 | 2021-04-05T22:44:14 | 2021-04-05T23:22:10 | 2021-04-10T21:47:22 | 131 | 0 | 0 | 0 | Java | false | false | package com.flores.controller;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flores.model.UbigeoDepartamento;
import com.flores.model.dto.UbigeoDepartamentoDto;
import com.flores.repository.UbigeoDepartamentoRespository;
@RestController
@RequestMapping("/ubigeodepartamento")
public class UbigeoDepartamentoController {
@Autowired
private UbigeoDepartamentoRespository departamentoRepository;
@GetMapping(path = "/listar")
private List<UbigeoDepartamento> listar() {
return departamentoRepository.findAll();
}
@GetMapping(path = "/{id}")
private Optional<UbigeoDepartamento> show(@PathVariable int id) {
return departamentoRepository.findById(id);
}
@PostMapping(path="/nuevo")
private UbigeoDepartamento create(@RequestBody UbigeoDepartamentoDto ubigeoDepartamentoDto) {
UbigeoDepartamento ubigeDep = new UbigeoDepartamento();
ubigeDep.setNombre(ubigeoDepartamentoDto.getNombre());
return departamentoRepository.save(ubigeDep);
}
@PutMapping(path ="/{id}")
private UbigeoDepartamento update(@RequestBody UbigeoDepartamentoDto ubigeoDepartamento,@PathVariable int id) {
UbigeoDepartamento ubigeoDepartamentoNow = departamentoRepository.findById(id).orElse(null);
ubigeoDepartamentoNow.setNombre(ubigeoDepartamento.getNombre());
return departamentoRepository.save(ubigeoDepartamentoNow);
}
@DeleteMapping("/{id}")
private void delete(@PathVariable int id) {
departamentoRepository.deleteById(id);
}
}
| UTF-8 | Java | 2,020 | java | UbigeoDepartamentoController.java | Java | []
| null | []
| package com.flores.controller;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flores.model.UbigeoDepartamento;
import com.flores.model.dto.UbigeoDepartamentoDto;
import com.flores.repository.UbigeoDepartamentoRespository;
@RestController
@RequestMapping("/ubigeodepartamento")
public class UbigeoDepartamentoController {
@Autowired
private UbigeoDepartamentoRespository departamentoRepository;
@GetMapping(path = "/listar")
private List<UbigeoDepartamento> listar() {
return departamentoRepository.findAll();
}
@GetMapping(path = "/{id}")
private Optional<UbigeoDepartamento> show(@PathVariable int id) {
return departamentoRepository.findById(id);
}
@PostMapping(path="/nuevo")
private UbigeoDepartamento create(@RequestBody UbigeoDepartamentoDto ubigeoDepartamentoDto) {
UbigeoDepartamento ubigeDep = new UbigeoDepartamento();
ubigeDep.setNombre(ubigeoDepartamentoDto.getNombre());
return departamentoRepository.save(ubigeDep);
}
@PutMapping(path ="/{id}")
private UbigeoDepartamento update(@RequestBody UbigeoDepartamentoDto ubigeoDepartamento,@PathVariable int id) {
UbigeoDepartamento ubigeoDepartamentoNow = departamentoRepository.findById(id).orElse(null);
ubigeoDepartamentoNow.setNombre(ubigeoDepartamento.getNombre());
return departamentoRepository.save(ubigeoDepartamentoNow);
}
@DeleteMapping("/{id}")
private void delete(@PathVariable int id) {
departamentoRepository.deleteById(id);
}
}
| 2,020 | 0.819802 | 0.819802 | 57 | 34.438595 | 28.562038 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.210526 | false | false | 15 |
ecd571dd64b803cdd0eb986dc056f95776a27db1 | 1,717,986,924,502 | dd4a224e8d4b5355163fa4a3d80ad81d9a79b25d | /src/main/java/com/hzl/demo/pojo/User.java | 6a9c2e03f708f1122e39df6b38ee6bb23850ab17 | []
| no_license | baimuchengling/springboot | https://github.com/baimuchengling/springboot | c76c765172203e2655c22ba9e4531130d5b86733 | 163de3dd782f3b38316bee01a2164f0a94a6c103 | refs/heads/master | 2020-05-18T00:58:40.417000 | 2019-04-30T16:31:02 | 2019-04-30T16:31:02 | 184,077,380 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hzl.demo.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @Auther:
* @Date: 2018/12/20 21:15
* @Description:
*//*
* @program: springboot
* @description:
* @author:
* @create: 2018-12-20-21-15
*/
public class User {
@NotBlank(message = "姓名不允许为空!")
private String username;
@NotNull(message = "password not null")
private String password;
private Date birthday;
@Min(value = 18,message = "未成年人不可以添加!")
private Integer age;
@JsonInclude(JsonInclude.Include.NON_NULL)
private double income;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss ",locale="zh",timezone = "GMT+8")
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public double getIncome() {
return income;
}
public void setIncome(double income) {
this.income = income;
}
@Override
public String toString() {
return "User{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", birthday=" + birthday +
", age=" + age +
", income=" + income +
'}';
}
}
| UTF-8 | Java | 1,932 | java | User.java | Java | [
{
"context": "\n\n public String getUsername() {\n return username;\n }\n\n public void setUsername(String userna",
"end": 830,
"score": 0.8001244068145752,
"start": 822,
"tag": "USERNAME",
"value": "username"
},
{
"context": "sername(String username) {\n this.username = username;\n }\n\n public String getPassword() {\n ",
"end": 918,
"score": 0.7850244641304016,
"start": 910,
"tag": "USERNAME",
"value": "username"
},
{
"context": "\n\n public String getPassword() {\n return password;\n }\n\n public void setPassword(String passwo",
"end": 984,
"score": 0.5137935280799866,
"start": 976,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "assword(String password) {\n this.password = password;\n }\n @JsonFormat(pattern = \"yyyy-MM-dd hh:m",
"end": 1072,
"score": 0.9622828960418701,
"start": 1064,
"tag": "PASSWORD",
"value": "password"
},
{
"context": " return \"User{\" +\n \"username='\" + username + '\\'' +\n \", password='\" + passwor",
"end": 1691,
"score": 0.9285433888435364,
"start": 1683,
"tag": "USERNAME",
"value": "username"
},
{
"context": "username + '\\'' +\n \", password='\" + password + '\\'' +\n \", birthday=\" + birthday",
"end": 1742,
"score": 0.9806538820266724,
"start": 1734,
"tag": "PASSWORD",
"value": "password"
}
]
| null | []
| package com.hzl.demo.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @Auther:
* @Date: 2018/12/20 21:15
* @Description:
*//*
* @program: springboot
* @description:
* @author:
* @create: 2018-12-20-21-15
*/
public class User {
@NotBlank(message = "姓名不允许为空!")
private String username;
@NotNull(message = "password not null")
private String password;
private Date birthday;
@Min(value = 18,message = "未成年人不可以添加!")
private Integer age;
@JsonInclude(JsonInclude.Include.NON_NULL)
private double income;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return <PASSWORD>;
}
public void setPassword(String password) {
this.password = <PASSWORD>;
}
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss ",locale="zh",timezone = "GMT+8")
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public double getIncome() {
return income;
}
public void setIncome(double income) {
this.income = income;
}
@Override
public String toString() {
return "User{" +
"username='" + username + '\'' +
", password='" + <PASSWORD> + '\'' +
", birthday=" + birthday +
", age=" + age +
", income=" + income +
'}';
}
}
| 1,938 | 0.593354 | 0.579114 | 87 | 20.793104 | 17.714945 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.344828 | false | false | 15 |
76b1f86e1c18003ead90a5d4970b8821569d46b2 | 31,774,168,110,860 | 151e65ef89ddb8b3adb881a098a1534fc8297661 | /se-web/.svn/pristine/76/76b1f86e1c18003ead90a5d4970b8821569d46b2.svn-base | 74d0e974803ad89d07843c7c0ab462b96e171705 | []
| no_license | Ox0400/test | https://github.com/Ox0400/test | 94adc938bf6f1b75c2798e1abd2d4e348e0907aa | 116b6927ee9acf56188e1bdad6bd7224d017035a | refs/heads/master | 2023-03-17T17:58:20.746000 | 2020-02-08T07:16:12 | 2020-02-08T07:16:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xjw.utility;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
/***
* MD5加密 生成32位md5码
*
* @param 待加密字符串
* @return 返回32位md5码
*/
public static String md5Encode(String inStr) throws Exception {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
return "";
}
byte[] byteArray = inStr.getBytes("UTF-8");
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16) {
hexValue.append("0");
}
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
/**
* 乐付 第三方
* 功能:MD5加密
* @param strSrc 加密的源字符串
* @return 加密串 长度32位(hex串)
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static String getMessageDigest(String strSrc) throws NoSuchAlgorithmException, UnsupportedEncodingException {
final String ALGO_MD5 = "MD5";
byte[] bt = strSrc.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance(ALGO_MD5);
md.update(bt);
String strDes = StringUtil.byte2hex(md.digest());
return strDes;
}
/**
* 乐付 第三方
* 将字节数组转为HEX字符串(16进制串)
* @param bts 要转换的字节数组
* @return 转换后的HEX串
*/
public static String bytes2Hex(byte[] bts) {
String des = "";
String tmp = null;
for (int i = 0; i < bts.length; i++) {
tmp = (Integer.toHexString(bts[i] & 0xFF));
if (tmp.length() == 1) {
des += "0";
}
des += tmp;
}
return des;
}
/**
* 测试主函数
*
* @param args
* @throws Exception
*/
// <?xml version="1.0" encoding="utf-8"?>
// <request action="client_loginVerf">
// <element id="20160711203056963">
// <properties name="pcode">J22</properties>
// <properties name="gcode">J22300</properties>
// <properties name="userid">kofren22</properties>
// <properties name="password">9bc5587ad3</properties>
// <properties name="token">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>
// <properties name="cagent">TST_AGIN</properties>
// <properties name="gametype">547</properties>
// <properties name="flashid"></properties>
// <properties name="mobile">1</properties>
// <properties name="lang">zh</properties>
// <properties name="session_token">67febb3dff74502653f5acd6c085d715</properties>
// <properties name="gameCategory">0</properties><
// properties name="custom"></properties></element></request>
public static void main(String args[]) throws Exception {
// String str = new String("amigoxiexiexingxing");
// System.out.println("原始:" + str);
//token:c9c692143eb05dd7084549eefc14252e
System.out.println();
DESEncrypt a = new DESEncrypt("d3Mz7wk9");
String pwd = a.decrypt("nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0");
pwd = "669ddfdfd071769";
pwd = pwd.substring(4, pwd.length());
System.out.println(pwd.substring(0, pwd.length() - 6));
System.out.println("MD5后:" + md5Encode("J22"+"J22300"+"kofren22"+"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0"+"123123"));
// System.out.println(MD5Util.getMessageDigest("123123"));
}
}
| UTF-8 | Java | 3,500 | 76b1f86e1c18003ead90a5d4970b8821569d46b2.svn-base | Java | [
{
"context": "en22</properties>\r\n//\t<properties name=\"password\">9bc5587ad3</properties>\r\n//\t<properties name=\"token\">d4a96ce",
"end": 2174,
"score": 0.993407130241394,
"start": 2164,
"tag": "PASSWORD",
"value": "9bc5587ad3"
},
{
"context": "5587ad3</properties>\r\n//\t<properties name=\"token\">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>\r\n//\t<",
"end": 2218,
"score": 0.5369340181350708,
"start": 2217,
"tag": "PASSWORD",
"value": "d"
},
{
"context": "587ad3</properties>\r\n//\t<properties name=\"token\">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>\r\n//\t<propertie",
"end": 2227,
"score": 0.518161416053772,
"start": 2218,
"tag": "KEY",
"value": "4a96cebaf"
},
{
"context": "roperties>\r\n//\t<properties name=\"token\">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>\r\n//\t<properties n",
"end": 2230,
"score": 0.5259634256362915,
"start": 2227,
"tag": "PASSWORD",
"value": "db0"
},
{
"context": "erties>\r\n//\t<properties name=\"token\">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>\r\n//\t<properties nam",
"end": 2232,
"score": 0.4987431764602661,
"start": 2230,
"tag": "KEY",
"value": "34"
},
{
"context": "ties>\r\n//\t<properties name=\"token\">d4a96cebafdb034a1d9b0dd97e3d3c4d</properties>\r\n//\t<properties name=\"cagent\">TST_AG",
"end": 2249,
"score": 0.5322420597076416,
"start": 2232,
"tag": "PASSWORD",
"value": "a1d9b0dd97e3d3c4d"
},
{
"context": "/properties>\r\n//\t<properties name=\"session_token\">67febb3dff74502653f5acd6c085d715</properties>\r\n//\t<properties name=\"gameCategory\">",
"end": 2567,
"score": 0.9440886974334717,
"start": 2535,
"tag": "KEY",
"value": "67febb3dff74502653f5acd6c085d715"
},
{
"context": "\r\n//\t\tSystem.out.println(\"原始:\" + str);\r\n\t\t//token:c9c692143eb05dd7084549eefc14252e\r\n\t\tSystem.out.println();\r\n\t\tDESEn",
"end": 2874,
"score": 0.6327521204948425,
"start": 2858,
"tag": "KEY",
"value": "c9c692143eb05dd7"
},
{
"context": "ln(\"原始:\" + str);\r\n\t\t//token:c9c692143eb05dd7084549eefc14252e\r\n\t\tSystem.out.println();\r\n\t\tDESEncrypt a ",
"end": 2882,
"score": 0.5673974752426147,
"start": 2880,
"tag": "PASSWORD",
"value": "ee"
},
{
"context": "原始:\" + str);\r\n\t\t//token:c9c692143eb05dd7084549eefc14252e\r\n\t\tSystem.out.println();\r\n\t\tDESEncrypt a = new",
"end": 2888,
"score": 0.5632715225219727,
"start": 2884,
"tag": "PASSWORD",
"value": "1425"
},
{
"context": "ESEncrypt(\"d3Mz7wk9\");\r\n\t\tString pwd = a.decrypt(\"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0\");\r\n\t\tpwd = \"669ddfdfd07",
"end": 2997,
"score": 0.5680546760559082,
"start": 2990,
"tag": "PASSWORD",
"value": "nxysN20"
},
{
"context": "pt(\"d3Mz7wk9\");\r\n\t\tString pwd = a.decrypt(\"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0\");\r\n\t\tpwd = \"669ddfdfd071769\";\r\n\t",
"end": 3006,
"score": 0.4801332652568817,
"start": 2997,
"tag": "KEY",
"value": "uYDF1KIG0"
},
{
"context": "String pwd = a.decrypt(\"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0\");\r\n\t\tpwd = \"669ddfdfd071769\";\r\n\t\tpwd = pwd.",
"end": 3017,
"score": 0.4982210695743561,
"start": 3016,
"tag": "KEY",
"value": "x"
},
{
"context": "ng pwd = a.decrypt(\"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0\");\r\n\t\tpwd = \"669ddfdfd071769\";\r\n\t\tpwd = pwd.subst",
"end": 3022,
"score": 0.4450952410697937,
"start": 3020,
"tag": "KEY",
"value": "r0"
},
{
"context": "pt(\"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0\");\r\n\t\tpwd = \"669ddfdfd071769\";\r\n\t\tpwd = pwd.substring(4, pwd.length());\r\n\t\tSys",
"end": 3051,
"score": 0.9994263052940369,
"start": 3036,
"tag": "PASSWORD",
"value": "669ddfdfd071769"
}
]
| null | []
| package com.xjw.utility;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
/***
* MD5加密 生成32位md5码
*
* @param 待加密字符串
* @return 返回32位md5码
*/
public static String md5Encode(String inStr) throws Exception {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
return "";
}
byte[] byteArray = inStr.getBytes("UTF-8");
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16) {
hexValue.append("0");
}
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
/**
* 乐付 第三方
* 功能:MD5加密
* @param strSrc 加密的源字符串
* @return 加密串 长度32位(hex串)
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static String getMessageDigest(String strSrc) throws NoSuchAlgorithmException, UnsupportedEncodingException {
final String ALGO_MD5 = "MD5";
byte[] bt = strSrc.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance(ALGO_MD5);
md.update(bt);
String strDes = StringUtil.byte2hex(md.digest());
return strDes;
}
/**
* 乐付 第三方
* 将字节数组转为HEX字符串(16进制串)
* @param bts 要转换的字节数组
* @return 转换后的HEX串
*/
public static String bytes2Hex(byte[] bts) {
String des = "";
String tmp = null;
for (int i = 0; i < bts.length; i++) {
tmp = (Integer.toHexString(bts[i] & 0xFF));
if (tmp.length() == 1) {
des += "0";
}
des += tmp;
}
return des;
}
/**
* 测试主函数
*
* @param args
* @throws Exception
*/
// <?xml version="1.0" encoding="utf-8"?>
// <request action="client_loginVerf">
// <element id="20160711203056963">
// <properties name="pcode">J22</properties>
// <properties name="gcode">J22300</properties>
// <properties name="userid">kofren22</properties>
// <properties name="password"><PASSWORD></properties>
// <properties name="token">d4a96cebafdb034<PASSWORD></properties>
// <properties name="cagent">TST_AGIN</properties>
// <properties name="gametype">547</properties>
// <properties name="flashid"></properties>
// <properties name="mobile">1</properties>
// <properties name="lang">zh</properties>
// <properties name="session_token"><KEY></properties>
// <properties name="gameCategory">0</properties><
// properties name="custom"></properties></element></request>
public static void main(String args[]) throws Exception {
// String str = new String("amigoxiexiexingxing");
// System.out.println("原始:" + str);
//token:c9c692143eb05dd7084549eefc<PASSWORD>2e
System.out.println();
DESEncrypt a = new DESEncrypt("d3Mz7wk9");
String pwd = a.decrypt("<PASSWORD> <KEY>EtBYZbVCsvxHCNr0");
pwd = "<PASSWORD>";
pwd = pwd.substring(4, pwd.length());
System.out.println(pwd.substring(0, pwd.length() - 6));
System.out.println("MD5后:" + md5Encode("J22"+"J22300"+"kofren22"+"nxysN20uYDF1KIG0EtBYZbVCsvxHCNr0"+"123123"));
// System.out.println(MD5Util.getMessageDigest("123123"));
}
}
| 3,467 | 0.662073 | 0.608149 | 109 | 28.623854 | 22.966185 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.889908 | false | false | 15 |
|
415aac00f27896789c1ec794f32a03a071e955d3 | 13,975,823,611,232 | 1907cbc9105a0ac30a61e191530e1b87a4a7ce1c | /src/com/bright/amp/authc/model/TsysModule.java | 0d68d6ba1738beec315c25c24a52835388151391 | []
| no_license | brightsw/amp | https://github.com/brightsw/amp | 4fa8a299bd3edfa302afb00b30c3439f1ade4db6 | 62a2219d5b68834e494d3958682045c6d0004b1e | refs/heads/master | 2021-05-04T04:11:06.403000 | 2016-10-24T08:25:21 | 2016-10-24T08:25:21 | 70,866,702 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bright.amp.authc.model;
import java.util.List;
import org.apache.ibatis.type.Alias;
@Alias("TsysModule")
public class TsysModule {
private String modid;
private String modname;
private String modlevel;
private String parentid;
private String url;
private String modCode;
private String iconName;
private String subModuleFlag;
private List<TsysModule> subModule;
public String getModid() {
return modid;
}
public void setModid(String modid) {
this.modid = modid;
}
public String getModname() {
return modname;
}
public void setModname(String modname) {
this.modname = modname;
}
public String getModlevel() {
return modlevel;
}
public void setModlevel(String modlevel) {
this.modlevel = modlevel;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getModCode() {
return modCode;
}
public void setModCode(String modCode) {
this.modCode = modCode;
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
}
public List<TsysModule> getSubModule() {
return subModule;
}
public void setSubModule(List<TsysModule> subModule) {
this.subModule = subModule;
}
public String getSubModuleFlag() {
return subModuleFlag;
}
public void setSubModuleFlag(String subModuleFlag) {
this.subModuleFlag = subModuleFlag;
}
} | UTF-8 | Java | 1,622 | java | TsysModule.java | Java | []
| null | []
| package com.bright.amp.authc.model;
import java.util.List;
import org.apache.ibatis.type.Alias;
@Alias("TsysModule")
public class TsysModule {
private String modid;
private String modname;
private String modlevel;
private String parentid;
private String url;
private String modCode;
private String iconName;
private String subModuleFlag;
private List<TsysModule> subModule;
public String getModid() {
return modid;
}
public void setModid(String modid) {
this.modid = modid;
}
public String getModname() {
return modname;
}
public void setModname(String modname) {
this.modname = modname;
}
public String getModlevel() {
return modlevel;
}
public void setModlevel(String modlevel) {
this.modlevel = modlevel;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getModCode() {
return modCode;
}
public void setModCode(String modCode) {
this.modCode = modCode;
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
}
public List<TsysModule> getSubModule() {
return subModule;
}
public void setSubModule(List<TsysModule> subModule) {
this.subModule = subModule;
}
public String getSubModuleFlag() {
return subModuleFlag;
}
public void setSubModuleFlag(String subModuleFlag) {
this.subModuleFlag = subModuleFlag;
}
} | 1,622 | 0.694205 | 0.694205 | 99 | 15.393939 | 15.790176 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.959596 | false | false | 15 |
4a045a4e90b7111b1996dd5cac8249905e0b7c82 | 7,499,012,943,793 | 2963d07727d66c2d571ae04ae14fc11e25cdcd00 | /T11.java | 7bd2d4614748a1c6e0ba1dc9474125d340acee09 | []
| no_license | Qianheorgan/siyuetian | https://github.com/Qianheorgan/siyuetian | d1913fd15b61b9a2e13910592facb80b79c270b3 | 8e73174d1751578ce88efefdc669781140449ad3 | refs/heads/master | 2021-07-08T05:53:12.953000 | 2020-10-24T06:25:35 | 2020-10-24T06:25:35 | 197,773,562 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import com.sun.corba.se.impl.orbutil.CacheTable;
public class T11 {
public static void main(String[] args) {
int x=20;
int y=5;
System.out.println(x+y+""+(x+y)+y);
int a=1234;
System.out.println(a%10);
}
}
| UTF-8 | Java | 255 | java | T11.java | Java | []
| null | []
| import com.sun.corba.se.impl.orbutil.CacheTable;
public class T11 {
public static void main(String[] args) {
int x=20;
int y=5;
System.out.println(x+y+""+(x+y)+y);
int a=1234;
System.out.println(a%10);
}
}
| 255 | 0.560784 | 0.517647 | 11 | 22.181818 | 16.573902 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 15 |
c7bdee7c1eac8be99a7825e94b42e89a41b31c3d | 2,379,411,918,005 | 78b7db9fade7e66fc621b698e4739fac862f603b | /demo/zhuyuan/com/dao/IThDao.java | cff6842c09959b99423863e1042072dc6463be7f | []
| no_license | Amaindex/HP_Exercitation | https://github.com/Amaindex/HP_Exercitation | c9b3610c8660b89bc96fc1c5971dd4469a4b4fc6 | 4589cb11a12923cd87302fdb6201fcbb6c29e6fe | refs/heads/master | 2020-04-14T18:55:50.910000 | 2019-03-08T03:06:27 | 2019-03-08T03:06:27 | 164,038,283 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dao;
import com.pojo.Th;
public interface IThDao {
public Th getbyid(String id);
}
| UTF-8 | Java | 101 | java | IThDao.java | Java | []
| null | []
| package com.dao;
import com.pojo.Th;
public interface IThDao {
public Th getbyid(String id);
}
| 101 | 0.712871 | 0.712871 | 9 | 10.222222 | 11.564099 | 30 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 15 |
549a657a4597541678a90590a372cb7a89e65d0f | 18,339,510,378,274 | 3c721c91e615189ca2aa486d580374a6b670d4da | /src/main/java/com/elane/learning/annotations/ClassA.java | 63ab670b91a3ea21226a2ae76bfa5295989e2437 | []
| no_license | lixin2302007/jenkins-demo-springboot | https://github.com/lixin2302007/jenkins-demo-springboot | 83d8652b989e09c3f4ba94f4471468dbf580bef0 | f370015a336f53e0b0de2f5f14af426e03c42763 | refs/heads/master | 2023-05-28T01:49:02.871000 | 2021-06-17T06:40:25 | 2021-06-17T06:40:25 | 319,208,530 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.elane.learning.annotations;
public class ClassA implements ScanClassInterface {
}
| UTF-8 | Java | 95 | java | ClassA.java | Java | []
| null | []
| package com.elane.learning.annotations;
public class ClassA implements ScanClassInterface {
}
| 95 | 0.831579 | 0.831579 | 4 | 22.75 | 22.653643 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 15 |
14bb3e99ae6f12dca64ea3a9091e210a9c0ae25c | 30,640,296,714,815 | 8e19c3b5fb7fffc67b8a5c34660d1b15cea92761 | /src/main/java/com/java/springaop/pointcut/PointCutDefinition.java | 9a29bffb48af0b93bac87ae3946f335e8b105d02 | []
| no_license | Spring-Projects-org/SpringAOP | https://github.com/Spring-Projects-org/SpringAOP | 4e19da22e98c078bd5135193f157ffaeab89acaf | dead9cc697bc9187f530fa0fdde378e2cdd0855b | refs/heads/master | 2020-03-31T18:29:14.255000 | 2018-10-14T08:45:44 | 2018-10-14T08:45:44 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.java.springaop.pointcut;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class PointCutDefinition {
@Pointcut("within(com.java.springaop.service..*)")
public void serviceLayer() {
}
}
| UTF-8 | Java | 322 | java | PointCutDefinition.java | Java | []
| null | []
| package com.java.springaop.pointcut;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class PointCutDefinition {
@Pointcut("within(com.java.springaop.service..*)")
public void serviceLayer() {
}
}
| 322 | 0.779503 | 0.779503 | 15 | 20.466667 | 19.720942 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 15 |
4ba308e197a9f9187226d1304154dcdf485af4d3 | 19,232,863,581,640 | 549275146dc8ecdba9144a6aed2796baa1639eb3 | /Codes/yore/medium/Number319.java | 9f5e5ce8ce4d9ec055ad313a28d6119af371812b | [
"Apache-2.0"
]
| permissive | asdf2014/algorithm | https://github.com/asdf2014/algorithm | fdb07986746a3e5c36bfc66f4b6b7cb60850ff84 | b0ed7a36f47b66c04b908eb67f2146843a9c71a3 | refs/heads/master | 2023-09-05T22:35:12.922000 | 2023-09-01T12:04:03 | 2023-09-01T12:04:03 | 108,250,452 | 270 | 87 | Apache-2.0 | false | 2021-09-24T16:12:08 | 2017-10-25T09:45:27 | 2021-09-24T12:03:46 | 2021-09-24T16:12:08 | 13,172 | 199 | 58 | 1 | Java | false | false | package com.yore.medium;
/**
* @author Yore
* @date 2021/11/15 14:37
* @description
*/
public class Number319 {
public int bulbSwitch(int n) {
return (int) Math.sqrt(n + 0.5);
}
}
| UTF-8 | Java | 201 | java | Number319.java | Java | [
{
"context": "package com.yore.medium;\n\n/**\n * @author Yore\n * @date 2021/11/15 14:37\n * @description\n */\npub",
"end": 45,
"score": 0.8482517004013062,
"start": 41,
"tag": "USERNAME",
"value": "Yore"
}
]
| null | []
| package com.yore.medium;
/**
* @author Yore
* @date 2021/11/15 14:37
* @description
*/
public class Number319 {
public int bulbSwitch(int n) {
return (int) Math.sqrt(n + 0.5);
}
}
| 201 | 0.597015 | 0.512438 | 12 | 15.75 | 13.071119 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 15 |
ef7a37a09d6c48983278fce4be693b7886ca66af | 24,498,493,512,619 | fbc7305ee7cc359689b6e3ff4aba9cf758995de9 | /Trapping_Rain_Water.java | d57c77f079a88c746e591c428b9d82855f3c1817 | []
| no_license | deepakrkole/leetcode-Java | https://github.com/deepakrkole/leetcode-Java | dedde69e695c095075e3ba43fa4c27b1ed84ec4b | 99dcd5127568f956ec4ec36d8e88d5949ba519d9 | refs/heads/master | 2021-01-15T20:53:22.539000 | 2015-01-31T21:40:38 | 2015-01-31T21:40:38 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Solution {
public int trap(int[] A) {
if( A.length <= 2 )
return 0;
int[] leftHighest = new int[A.length];
int[] rightHighest = new int[A.length];
int leftHigh = A[0];
leftHighest[0] = 0;
for( int i = 1; i < A.length; ++i ) {
leftHighest[i] = leftHigh;
if( A[i] > leftHigh ) {
leftHigh = A[i];
}
}
int rightHigh = A[A.length-1];
rightHighest[A.length-1] = 0;
for( int i = A.length - 2; i >= 0; --i ) {
rightHighest[i] = rightHigh;
if( A[i] > rightHigh ) {
rightHigh = A[i];
}
}
int ans = 0;
for( int i = 0; i < A.length; ++i ) {
if( Math.min( leftHighest[i], rightHighest[i] ) > A[i] )
ans += Math.min( leftHighest[i], rightHighest[i] ) - A[i];
}
return ans;
}
}
| UTF-8 | Java | 948 | java | Trapping_Rain_Water.java | Java | []
| null | []
| public class Solution {
public int trap(int[] A) {
if( A.length <= 2 )
return 0;
int[] leftHighest = new int[A.length];
int[] rightHighest = new int[A.length];
int leftHigh = A[0];
leftHighest[0] = 0;
for( int i = 1; i < A.length; ++i ) {
leftHighest[i] = leftHigh;
if( A[i] > leftHigh ) {
leftHigh = A[i];
}
}
int rightHigh = A[A.length-1];
rightHighest[A.length-1] = 0;
for( int i = A.length - 2; i >= 0; --i ) {
rightHighest[i] = rightHigh;
if( A[i] > rightHigh ) {
rightHigh = A[i];
}
}
int ans = 0;
for( int i = 0; i < A.length; ++i ) {
if( Math.min( leftHighest[i], rightHighest[i] ) > A[i] )
ans += Math.min( leftHighest[i], rightHighest[i] ) - A[i];
}
return ans;
}
}
| 948 | 0.427215 | 0.413502 | 30 | 30.6 | 17.180609 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false | 15 |
09e50341647b7519a9fcee696d6a8667f9fdefd9 | 31,997,506,396,936 | 7820fbc18fd86119fafa64316d30a27995609e80 | /CivitasJava/civitas/Casilla_Impuesto.java | aa7f187fa7b10e6cfa298412cdbbc31286ce3686 | []
| no_license | KamiJuanmi/Civitas | https://github.com/KamiJuanmi/Civitas | 54105668496963043c67987ff8997741bc5118c3 | 5bec2e106ea89f32b09152abbcce851e854c525e | refs/heads/main | 2023-05-06T23:04:31.892000 | 2021-05-23T17:37:32 | 2021-05-23T17:37:32 | 370,108,704 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package civitas;
import java.util.ArrayList;
public class Casilla_Impuesto extends Casilla
{
private float importe;
Casilla_Impuesto(String nombre, float cantidad)
{
super(nombre);
this.importe=cantidad;
}
public float getImporte()
{
return this.importe;
}
@Override
void recibeJugador(int iactual, ArrayList<Jugador> todos)
{
if (super.jugadorCorrecto(iactual, todos)) {
super.informe(iactual, todos);
todos.get(iactual).pagaImpuesto(this.importe);
}
}
@Override
public String toString()
{
String ret=super.getNombre();
ret += " de tipo impuesto con precio: \n" + this.importe;
return ret;
}
}
| UTF-8 | Java | 755 | java | Casilla_Impuesto.java | Java | []
| null | []
|
package civitas;
import java.util.ArrayList;
public class Casilla_Impuesto extends Casilla
{
private float importe;
Casilla_Impuesto(String nombre, float cantidad)
{
super(nombre);
this.importe=cantidad;
}
public float getImporte()
{
return this.importe;
}
@Override
void recibeJugador(int iactual, ArrayList<Jugador> todos)
{
if (super.jugadorCorrecto(iactual, todos)) {
super.informe(iactual, todos);
todos.get(iactual).pagaImpuesto(this.importe);
}
}
@Override
public String toString()
{
String ret=super.getNombre();
ret += " de tipo impuesto con precio: \n" + this.importe;
return ret;
}
}
| 755 | 0.601324 | 0.601324 | 34 | 21.117647 | 19.682426 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.441176 | false | false | 15 |
04b08f4c4a26d244be84ec034e808a9feca6fd74 | 33,500,744,956,594 | fad4ec927af16fb64f21dc63a10e917f926c0325 | /first/src/main/java/cn/zero/main/Main.java | 694d4456a2d8cd0495ac1bd5d531167868ce3a92 | []
| no_license | Linhangyang/list | https://github.com/Linhangyang/list | 83e67d628572a200a0bcb3da3407794e28ae657e | 8cd1534d04d382acba5f31b92bbfc3a4adca52fc | refs/heads/master | 2022-04-28T11:17:21.858000 | 2019-07-15T03:15:11 | 2019-07-15T03:15:11 | 192,641,195 | 0 | 0 | null | false | 2022-03-31T18:50:03 | 2019-06-19T02:06:02 | 2019-07-15T03:15:45 | 2022-03-31T18:50:03 | 64 | 0 | 0 | 1 | Java | false | false | package cn.zero.main;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Main {
private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public static void main(String[] args) throws Exception {
String first = "2019-04-14";
String second = "2019-06-26";
Date firstdate = format.parse(first);
Date seconddate = format.parse(second);
int cnt = longOfTwoDate(firstdate, seconddate);
System.out.println(cnt);
}
public static int longOfTwoDate(Date first, Date second) throws ParseException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(first);
int cnt = 0;
while (calendar.getTime().compareTo(second) != 0) {
calendar.add(Calendar.DATE, 1);
cnt++;
}
return cnt;
}
}
| UTF-8 | Java | 924 | java | Main.java | Java | []
| null | []
| package cn.zero.main;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Main {
private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public static void main(String[] args) throws Exception {
String first = "2019-04-14";
String second = "2019-06-26";
Date firstdate = format.parse(first);
Date seconddate = format.parse(second);
int cnt = longOfTwoDate(firstdate, seconddate);
System.out.println(cnt);
}
public static int longOfTwoDate(Date first, Date second) throws ParseException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(first);
int cnt = 0;
while (calendar.getTime().compareTo(second) != 0) {
calendar.add(Calendar.DATE, 1);
cnt++;
}
return cnt;
}
}
| 924 | 0.642857 | 0.622294 | 31 | 28.806452 | 23.22043 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.677419 | false | false | 15 |
15057a36722c9d42590bc5b6e547ef89366cb953 | 22,514,218,566,032 | 61a7dbad353b40c569fb4b0e8637608fe39d3d4d | /heranca2/exercicio1/Assistente.java | 779f9d8f3d7d07e20984439f28eb6aa18c37f0a5 | []
| no_license | callboydev/heranca | https://github.com/callboydev/heranca | 2f83fa9d8a791af6f752fed9981f32a98589d521 | cc06e2eccb3bca9b33bc9574019e7506e6cc9fbc | refs/heads/main | 2023-01-03T08:06:14.916000 | 2020-10-31T18:44:29 | 2020-10-31T18:44:29 | 300,623,948 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Assistente extends Funcionario {
protected String matricula;
public String getMatricula() {
return matricula;
}
public Assistente(String nome, String setor, double salario, String matricula) {
super(nome, setor, salario);
this.matricula = matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
@Override
public void exibirDados() {
System.out.println("Matricula: " + this.matricula + "\nNome: " + this.nome + "\nSetor: " + this.setor + "\nSalário: " + this.salario);
}
}
| UTF-8 | Java | 612 | java | Assistente.java | Java | []
| null | []
| public class Assistente extends Funcionario {
protected String matricula;
public String getMatricula() {
return matricula;
}
public Assistente(String nome, String setor, double salario, String matricula) {
super(nome, setor, salario);
this.matricula = matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
@Override
public void exibirDados() {
System.out.println("Matricula: " + this.matricula + "\nNome: " + this.nome + "\nSetor: " + this.setor + "\nSalário: " + this.salario);
}
}
| 612 | 0.626841 | 0.626841 | 22 | 26.772728 | 32.901966 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
74133215c3632ec86817b84ac067924ae820da91 | 3,831,110,863,370 | 47a8cd3e3042b9231a9daf45d60292e9b2f9746c | /src/pmh_system/controller/RegPayment.java | 91e047dac7d92d0aafff76d11f994fd8bc9e484c | []
| no_license | Elisvobs/mortage_system | https://github.com/Elisvobs/mortage_system | ac6a81576d43b06f0e356b36785d72976f686541 | 10cd041dd4a02e66ca05c7876dac39d151a716ea | refs/heads/master | 2020-07-28T05:04:34.167000 | 2019-09-18T13:39:14 | 2019-09-18T13:39:14 | 209,317,537 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pmh_system.controller;
import com.itextpdf.text.DocumentException;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.validation.NumberValidator;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import pmh_system.Main;
import pmh_system.database.DatabaseHandler;
import pmh_system.pdf.ReceiptCreator;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import static pmh_system.Main.exchangeRate;
import static pmh_system.Main.initialAmount;
public class RegPayment implements Initializable {
private Status status = new Status();
private ObservableList<String> methods = FXCollections.observableArrayList();
private ObservableList<String> currencies = FXCollections.observableArrayList();
@FXML
private JFXComboBox method, currency;
@FXML
private JFXTextField accountHolder, apId, rate, account, amount;
@FXML
private Label equivalent;
@FXML
private AnchorPane anc;
private void filling() {
methods.add("Cash");
methods.add("Ecocash");
methods.add("Transfer");
currencies.add("GBP");
currencies.add("US$");
currencies.add("ZAR");
currencies.add("ZWL");
method.setItems(methods);
currency.setItems(currencies);
}
public void save(ActionEvent event) throws IOException, DocumentException {
if (String.valueOf(method.getValue()) == "" || String.valueOf(currency.getValue()) == ""
|| amount.getText().isEmpty() || account.getText().isEmpty()
|| rate.getText().isEmpty() || accountHolder.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING, "You must fill the required fields !");
alert.showAndWait();
} else {
Main.paymentMethod = String.valueOf(this.method.getValue());
Main.currencyUsed = String.valueOf(this.currency.getValue());
Main.client = this.accountHolder.getText();
Main.accountNo = Integer.parseInt(this.apId.getText());
Main.exchangeRate = Double.parseDouble(this.rate.getText());
Main.sortedAccNo = this.account.getText();
Main.initialAmount = Double.parseDouble(this.amount.getText());
double answer = Math.abs(initialAmount/exchangeRate);
equivalent.setText(String.valueOf(answer));
Main.equivalency = Double.parseDouble(this.equivalent.getText());
DatabaseHandler dbHandler = new DatabaseHandler();
dbHandler.makePayment();
ReceiptCreator receiptCreator = new ReceiptCreator();
receiptCreator.receiptBuild();
status.stepCompleted();
dashboard(event);
}
}
public void dashboard(ActionEvent e) throws IOException {
AnchorPane pane = FXMLLoader.load(getClass().getResource("/pmh_system/views/dashboard.fxml"));
anc.getChildren().setAll(pane);
}
public void addApplicant(ActionEvent e) throws IOException {
AnchorPane pane = FXMLLoader.load(getClass().getResource("/pmh_system/views/personal.fxml"));
anc.getChildren().setAll(pane);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
filling();
NumberValidator numberValidator = new NumberValidator();
numberValidator.setMessage("Please enter a valid number");
amount.getValidators().add(numberValidator);
numberValidator.setMessage("Please enter a valid number");
}
} | UTF-8 | Java | 3,856 | java | RegPayment.java | Java | []
| null | []
| package pmh_system.controller;
import com.itextpdf.text.DocumentException;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.validation.NumberValidator;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import pmh_system.Main;
import pmh_system.database.DatabaseHandler;
import pmh_system.pdf.ReceiptCreator;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import static pmh_system.Main.exchangeRate;
import static pmh_system.Main.initialAmount;
public class RegPayment implements Initializable {
private Status status = new Status();
private ObservableList<String> methods = FXCollections.observableArrayList();
private ObservableList<String> currencies = FXCollections.observableArrayList();
@FXML
private JFXComboBox method, currency;
@FXML
private JFXTextField accountHolder, apId, rate, account, amount;
@FXML
private Label equivalent;
@FXML
private AnchorPane anc;
private void filling() {
methods.add("Cash");
methods.add("Ecocash");
methods.add("Transfer");
currencies.add("GBP");
currencies.add("US$");
currencies.add("ZAR");
currencies.add("ZWL");
method.setItems(methods);
currency.setItems(currencies);
}
public void save(ActionEvent event) throws IOException, DocumentException {
if (String.valueOf(method.getValue()) == "" || String.valueOf(currency.getValue()) == ""
|| amount.getText().isEmpty() || account.getText().isEmpty()
|| rate.getText().isEmpty() || accountHolder.getText().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING, "You must fill the required fields !");
alert.showAndWait();
} else {
Main.paymentMethod = String.valueOf(this.method.getValue());
Main.currencyUsed = String.valueOf(this.currency.getValue());
Main.client = this.accountHolder.getText();
Main.accountNo = Integer.parseInt(this.apId.getText());
Main.exchangeRate = Double.parseDouble(this.rate.getText());
Main.sortedAccNo = this.account.getText();
Main.initialAmount = Double.parseDouble(this.amount.getText());
double answer = Math.abs(initialAmount/exchangeRate);
equivalent.setText(String.valueOf(answer));
Main.equivalency = Double.parseDouble(this.equivalent.getText());
DatabaseHandler dbHandler = new DatabaseHandler();
dbHandler.makePayment();
ReceiptCreator receiptCreator = new ReceiptCreator();
receiptCreator.receiptBuild();
status.stepCompleted();
dashboard(event);
}
}
public void dashboard(ActionEvent e) throws IOException {
AnchorPane pane = FXMLLoader.load(getClass().getResource("/pmh_system/views/dashboard.fxml"));
anc.getChildren().setAll(pane);
}
public void addApplicant(ActionEvent e) throws IOException {
AnchorPane pane = FXMLLoader.load(getClass().getResource("/pmh_system/views/personal.fxml"));
anc.getChildren().setAll(pane);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
filling();
NumberValidator numberValidator = new NumberValidator();
numberValidator.setMessage("Please enter a valid number");
amount.getValidators().add(numberValidator);
numberValidator.setMessage("Please enter a valid number");
}
} | 3,856 | 0.685944 | 0.685944 | 103 | 36.446602 | 27.571524 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.805825 | false | false | 15 |
a7cdfc8f6d00a2eff8954c4d4c591eda2cdde45d | 18,090,402,292,500 | 89611acca839b26de3fe9c77fa065bf15f42aad1 | /api/src/main/java/pl/dawid/kaszyca/dto/CategoryDTO.java | c224ffec2d57843630796a5185898f2ea0d1c8a0 | []
| no_license | dawidkaszyca/Auction-application | https://github.com/dawidkaszyca/Auction-application | 1046cd7920454b2ccc583487a6b7f89fa34c5058 | 6e5c9a7d3abef4f473e16128516eb97a21c6058b | refs/heads/master | 2023-03-08T10:00:59.282000 | 2021-02-27T16:09:42 | 2021-02-27T16:09:42 | 254,859,735 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.dawid.kaszyca.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
public class CategoryDTO {
private String name;
private List<CategoryAttributesDTO> categoryAttributes;
}
| UTF-8 | Java | 284 | java | CategoryDTO.java | Java | []
| null | []
| package pl.dawid.kaszyca.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
public class CategoryDTO {
private String name;
private List<CategoryAttributesDTO> categoryAttributes;
}
| 284 | 0.792253 | 0.792253 | 17 | 15.705882 | 15.705993 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 15 |
e69f5d0252b54487b9529da225509e372c394f20 | 15,247,133,964,174 | 6b3ba91109f4ea919ad27518e47ec556a264384b | /cs180/lab09/src/edu/purdue/zmai/lab/Listener.java | 4f3cf491d9883bc1715ccee35bf6293f8da4ebed | []
| no_license | SpeedBird-C/CourseProjects | https://github.com/SpeedBird-C/CourseProjects | 8d9d60536b31dda5dc0db75e5fcb6704c8cb1144 | 6aad595fabe99f140c0c31accfa7aa078039a4cd | refs/heads/master | 2021-01-01T21:52:02.309000 | 2015-10-20T18:08:39 | 2015-10-20T18:08:39 | 239,356,973 | 1 | 0 | null | true | 2020-02-09T18:56:47 | 2020-02-09T18:56:46 | 2020-02-09T18:56:44 | 2015-10-20T18:09:05 | 67,140 | 0 | 0 | 0 | null | false | false | // package edu.purdue.zmai.lab;
import android.view.View.*;
import android.view.View;
import java.util.*;
import android.os.*;
import android.widget.*;
public class Listener implements OnClickListener {
@Override
public void onClick(View arg) {
Button b = (Button) arg;
String c = b.getText().toString();
if (c.equals("Reset") || c.equals("Time") || c.equals("Serial"))
StartActivity.logIt(c);
}
} | UTF-8 | Java | 423 | java | Listener.java | Java | []
| null | []
| // package edu.purdue.zmai.lab;
import android.view.View.*;
import android.view.View;
import java.util.*;
import android.os.*;
import android.widget.*;
public class Listener implements OnClickListener {
@Override
public void onClick(View arg) {
Button b = (Button) arg;
String c = b.getText().toString();
if (c.equals("Reset") || c.equals("Time") || c.equals("Serial"))
StartActivity.logIt(c);
}
} | 423 | 0.673759 | 0.673759 | 17 | 23.941177 | 17.691708 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.764706 | false | false | 15 |
7f702e2690ecfeb6ea53dbea9edc56c70c192c26 | 15,247,133,962,302 | b3a21256acff0d6346c9cff598fba927244f9831 | /src/main/java/com/qdone/common/mq/JMSConfig.java | 06fc9dcf750e28f0b58de36e6deee672f14a9522 | [
"Apache-2.0"
]
| permissive | yhb19930707/boot-master | https://github.com/yhb19930707/boot-master | d95a16c19ba51218d025e86c92ea7ff7931bb8e3 | b19e9b701cf4384ac951db474f6041d33e6377f1 | refs/heads/master | 2023-01-22T18:00:21.402000 | 2020-11-23T08:38:48 | 2020-11-23T08:38:48 | 315,250,194 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.qdone.common.mq;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.MessageType;
/**
* @author 付为地
* 配置jms 同时支持queue和topic消息
* 参考资料:https://spring.io/guides/gs/messaging-jms/
*/
@Configuration
public class JMSConfig {
/**
* 队列类型的queue对应JmsListenerContainer
* @param activeMQConnectionFactory
* ActiveMQ连接配置
* @return
* 队列JmsListenerContainer
*/
@Bean(name = "queueListenerContainerFactory")
public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setPubSubDomain(false);//true开启topic,false开启queue
factory.setConnectionFactory(activeMQConnectionFactory);
factory.setMessageConverter(jacksonJmsMessageConverter());
return factory;
}
/**
* 消息体序列化
* @return
* 信息解析器
*/
@Bean
public MessageConverter jacksonJmsMessageConverter() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
/**
* 发布订阅类型的topic对应JmsListenerContainer
* @param activeMQConnectionFactory
* ActiveMQ连接配置
* @return
* 订阅JmsListenerContainer
*/
@Bean(name="topicListenerContainerFactory")
public JmsListenerContainerFactory<?> jmsListenerContainerTopic(ConnectionFactory activeMQConnectionFactory) {
DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();
bean.setPubSubDomain(true);//true开启topic,false开启queue
bean.setConnectionFactory(activeMQConnectionFactory);
return bean;
}
/**
* @param activeMQConnectionFactory 连接工厂
* @return 通用队列消息监听器
*/
@Bean
public DefaultMessageListenerContainer listenerContainer(ConnectionFactory activeMQConnectionFactory){
DefaultMessageListenerContainer m =new DefaultMessageListenerContainer();
m.setConnectionFactory(activeMQConnectionFactory);
Destination d = new ActiveMQQueue("*");//*表示通配所有队列名称,目前针对单个名字有效,比如:qghappy,针对qghappy.name无效
m.setDestination(d);
m.setMessageListener(new QueueMessageListener());
return m;
}
}
| UTF-8 | Java | 3,125 | java | JMSConfig.java | Java | [
{
"context": "support.converter.MessageType;\r\n\r\n/**\r\n * @author 付为地 \r\n * 配置jms 同时支持queue和topic消息\r\n * 参考资料:https://spr",
"end": 720,
"score": 0.999596893787384,
"start": 717,
"tag": "NAME",
"value": "付为地"
}
]
| null | []
| package com.qdone.common.mq;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.MessageType;
/**
* @author 付为地
* 配置jms 同时支持queue和topic消息
* 参考资料:https://spring.io/guides/gs/messaging-jms/
*/
@Configuration
public class JMSConfig {
/**
* 队列类型的queue对应JmsListenerContainer
* @param activeMQConnectionFactory
* ActiveMQ连接配置
* @return
* 队列JmsListenerContainer
*/
@Bean(name = "queueListenerContainerFactory")
public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setPubSubDomain(false);//true开启topic,false开启queue
factory.setConnectionFactory(activeMQConnectionFactory);
factory.setMessageConverter(jacksonJmsMessageConverter());
return factory;
}
/**
* 消息体序列化
* @return
* 信息解析器
*/
@Bean
public MessageConverter jacksonJmsMessageConverter() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
/**
* 发布订阅类型的topic对应JmsListenerContainer
* @param activeMQConnectionFactory
* ActiveMQ连接配置
* @return
* 订阅JmsListenerContainer
*/
@Bean(name="topicListenerContainerFactory")
public JmsListenerContainerFactory<?> jmsListenerContainerTopic(ConnectionFactory activeMQConnectionFactory) {
DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();
bean.setPubSubDomain(true);//true开启topic,false开启queue
bean.setConnectionFactory(activeMQConnectionFactory);
return bean;
}
/**
* @param activeMQConnectionFactory 连接工厂
* @return 通用队列消息监听器
*/
@Bean
public DefaultMessageListenerContainer listenerContainer(ConnectionFactory activeMQConnectionFactory){
DefaultMessageListenerContainer m =new DefaultMessageListenerContainer();
m.setConnectionFactory(activeMQConnectionFactory);
Destination d = new ActiveMQQueue("*");//*表示通配所有队列名称,目前针对单个名字有效,比如:qghappy,针对qghappy.name无效
m.setDestination(d);
m.setMessageListener(new QueueMessageListener());
return m;
}
}
| 3,125 | 0.764807 | 0.76378 | 82 | 33.621952 | 30.106979 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.170732 | false | false | 15 |
dad24d57f1db36a7244610f2ce4c6d4bfd5a806f | 30,571,577,278,987 | d5b6be3dd3f60c511fc72b4e23eaf55a44662f5b | /src/com/project/pojo/BankCard.java | d716c6728961086d4d4a42c174fd721d60a64993 | []
| no_license | jeluck/tennis | https://github.com/jeluck/tennis | 897bc0f54f4349a7d45cdcf6555bb9147df3a1f8 | 2e20ed1edfa135c9cfb750dfa1c46a8172f86261 | refs/heads/master | 2020-03-21T13:22:09.946000 | 2018-06-25T16:12:45 | 2018-06-25T16:12:45 | 138,602,276 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.project.pojo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "bank_card")
public class BankCard{
private int id;
private String account_name;// 开户名
private int card_status;// 银行卡审核状态:1:待审核 2:通过 3:未通过
private int bank_province;// 开户行所在省
private int bank_city;// 开户行所在市
private int bank_area;// 开户行所在区
private String bank_address;// 开户行地址
private String card_num;// 卡号
private String card_remark;// 审核意见
private BankInfo bank;
private String card_num_show;
private Weuser weuser;
/**
* 更新时间
*/
private String update_time;
/**
* 创建时间
*/
private String create_time;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "bank_info_id")
public BankInfo getBank() {
return bank;
}
public void setBank(BankInfo bank) {
this.bank = bank;
}
public void setCard_num_show(String card_num_show) {
this.card_num_show = card_num_show;
}
public String getCard_num_show() {
return card_num_show;
}
@Id
@GeneratedValue
@Column(name = "id" )
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "account_name")
public String getAccount_name() {
return account_name;
}
public void setAccount_name(String account_name) {
this.account_name = account_name;
}
@Column(name = "bank_province" )
public int getBank_province() {
return bank_province;
}
public void setBank_province(int bank_province) {
this.bank_province = bank_province;
}
@Column(name = "bank_city" )
public int getBank_city() {
return bank_city;
}
public void setBank_city(int bank_city) {
this.bank_city = bank_city;
}
@Column(name = "bank_address")
public String getBank_address() {
return bank_address;
}
public void setBank_address(String bank_address) {
this.bank_address = bank_address;
}
@Column(name = "card_num")
public String getCard_num() {
return card_num;
}
public void setCard_num(String card_num) {
this.card_num = card_num;
this.card_num_show = card_num != null && !card_num.trim().equals("") ? card_num
.substring(0, 4)
+ "***********"
+ card_num.substring(card_num.length() - 4, card_num.length())
: card_num;
}
@Column(name = "card_status" )
public int getCard_status() {
return card_status;
}
public void setCard_status(int card_status) {
this.card_status = card_status;
}
@Column(name = "card_remark")
public String getCard_remark() {
return card_remark;
}
public void setCard_remark(String card_remark) {
this.card_remark = card_remark;
}
@Column(name = "update_time")
public String getUpdate_time() {
return update_time;
}
public void setUpdate_time(String update_time) {
this.update_time = update_time;
}
@Column(name = "create_time")
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
@Column(name = "bank_area")
public int getBank_area() {
return bank_area;
}
public void setBank_area(int bank_area) {
this.bank_area = bank_area;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "weuser_id")
public Weuser getWeuser() {
return weuser;
}
public void setWeuser(Weuser weuser) {
this.weuser = weuser;
}
}
| UTF-8 | Java | 3,686 | java | BankCard.java | Java | []
| null | []
| package com.project.pojo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "bank_card")
public class BankCard{
private int id;
private String account_name;// 开户名
private int card_status;// 银行卡审核状态:1:待审核 2:通过 3:未通过
private int bank_province;// 开户行所在省
private int bank_city;// 开户行所在市
private int bank_area;// 开户行所在区
private String bank_address;// 开户行地址
private String card_num;// 卡号
private String card_remark;// 审核意见
private BankInfo bank;
private String card_num_show;
private Weuser weuser;
/**
* 更新时间
*/
private String update_time;
/**
* 创建时间
*/
private String create_time;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "bank_info_id")
public BankInfo getBank() {
return bank;
}
public void setBank(BankInfo bank) {
this.bank = bank;
}
public void setCard_num_show(String card_num_show) {
this.card_num_show = card_num_show;
}
public String getCard_num_show() {
return card_num_show;
}
@Id
@GeneratedValue
@Column(name = "id" )
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "account_name")
public String getAccount_name() {
return account_name;
}
public void setAccount_name(String account_name) {
this.account_name = account_name;
}
@Column(name = "bank_province" )
public int getBank_province() {
return bank_province;
}
public void setBank_province(int bank_province) {
this.bank_province = bank_province;
}
@Column(name = "bank_city" )
public int getBank_city() {
return bank_city;
}
public void setBank_city(int bank_city) {
this.bank_city = bank_city;
}
@Column(name = "bank_address")
public String getBank_address() {
return bank_address;
}
public void setBank_address(String bank_address) {
this.bank_address = bank_address;
}
@Column(name = "card_num")
public String getCard_num() {
return card_num;
}
public void setCard_num(String card_num) {
this.card_num = card_num;
this.card_num_show = card_num != null && !card_num.trim().equals("") ? card_num
.substring(0, 4)
+ "***********"
+ card_num.substring(card_num.length() - 4, card_num.length())
: card_num;
}
@Column(name = "card_status" )
public int getCard_status() {
return card_status;
}
public void setCard_status(int card_status) {
this.card_status = card_status;
}
@Column(name = "card_remark")
public String getCard_remark() {
return card_remark;
}
public void setCard_remark(String card_remark) {
this.card_remark = card_remark;
}
@Column(name = "update_time")
public String getUpdate_time() {
return update_time;
}
public void setUpdate_time(String update_time) {
this.update_time = update_time;
}
@Column(name = "create_time")
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
@Column(name = "bank_area")
public int getBank_area() {
return bank_area;
}
public void setBank_area(int bank_area) {
this.bank_area = bank_area;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "weuser_id")
public Weuser getWeuser() {
return weuser;
}
public void setWeuser(Weuser weuser) {
this.weuser = weuser;
}
}
| 3,686 | 0.669933 | 0.668253 | 171 | 19.888889 | 17.074465 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.105263 | false | false | 15 |
8de2744b557091f51c614f0ca0d78f24198da33a | 20,736,102,140,768 | cc3ffdc65faca0c78031128b1d6cb416236a161a | /SKS-Web/src/java/interfaces/PacketRepository.java | c61f1b716c02c6489b4909f2c95d451b77405057 | []
| no_license | arbego/SKS | https://github.com/arbego/SKS | 8131225c682c5f9da85019a2fad6d697240461bd | 4ba17cc1337b802ba34e977661c08abc5d991220 | refs/heads/master | 2016-09-08T02:21:45.951000 | 2014-01-21T23:59:16 | 2014-01-21T23:59:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interfaces;
import entities.DeliveryWarehouse;
import entities.Packet;
import entities.ReceiverPerson;
import java.util.List;
public interface PacketRepository extends Repository<Packet> {
List<Packet> getByReceiver(ReceiverPerson receiver);
List<Packet> getByDeliveryWarehouse(DeliveryWarehouse deliveryWarehouse);
}
| UTF-8 | Java | 336 | java | PacketRepository.java | Java | []
| null | []
| package interfaces;
import entities.DeliveryWarehouse;
import entities.Packet;
import entities.ReceiverPerson;
import java.util.List;
public interface PacketRepository extends Repository<Packet> {
List<Packet> getByReceiver(ReceiverPerson receiver);
List<Packet> getByDeliveryWarehouse(DeliveryWarehouse deliveryWarehouse);
}
| 336 | 0.830357 | 0.830357 | 11 | 29.545454 | 24.860935 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 15 |
9c735f426f40811f78f4d88b42be4e36bb23fc4c | 15,358,803,115,617 | a947a21357b7b4712cc2b1e828e57dc7fc959f81 | /src/main/java/demo/bedoreH/demo0927/demo2.java | 6d22be8ce625c7d4df311cdb7b771b02c7fe0279 | []
| no_license | zzw-echo/DailyLearning | https://github.com/zzw-echo/DailyLearning | c103f0a2d43148a89fc6a36a4904cb89a33bca8c | 50f2a72aafe929cfe41558ac0dad8c665dd665ec | refs/heads/master | 2021-12-27T09:03:59.418000 | 2021-09-12T09:11:03 | 2021-09-12T09:11:03 | 243,429,154 | 0 | 0 | null | false | 2020-10-14T00:06:07 | 2020-02-27T04:19:11 | 2020-10-13T05:58:01 | 2020-10-14T00:06:05 | 152,019 | 0 | 0 | 1 | Java | false | false | package demo.bedoreH.demo0927;
import java.util.Scanner;
/**
* 作者 : 张泽文
* 邮箱 : zzw.me@qq.com
* 时间 : 2020/9/27 20:26
*/
public class demo2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt() % 4;
int y = sc.nextInt() % 2;
int z = sc.nextInt() % 4;
int m = sc.nextInt();
int n = sc.nextInt();
int len = sc.nextInt();
int[][] arr = new int[len][2];
for (int i = 0; i < len; i++) {
for (int j = 0; j < 2; j++) {
arr[i][j] = sc.nextInt();
}
}
int step = 0;
if (y == 0) {
step = (z - x) % 4;
} else if (y == 1) {
if (x == 0) {
z += 3;
} else if (x == 2) {
z++;
} else if (x == 3) {
z += 2;
}
step = z % 4;
}
for (int i = 0; i < len; i++) {
int tempX = arr[i][0];
int tempY = arr[i][1];
if (step == 1) {
tempX = m - tempX + 1;
} else if (step == 2) {
tempX = m - tempX + 1;
tempY = n - tempY + 1;
} else if (step == 3) {
tempY = n - tempY + 1;
}
System.out.print(tempX + " ");
System.out.print(tempY);
System.out.println();
}
}
}
| UTF-8 | Java | 1,476 | java | demo2.java | Java | [
{
"context": "demo0927;\n\nimport java.util.Scanner;\n\n/**\n * 作者 : 张泽文\n * 邮箱 : zzw.me@qq.com\n * 时间 : 2020/9/27 20:26\n */",
"end": 74,
"score": 0.9998102188110352,
"start": 71,
"tag": "NAME",
"value": "张泽文"
},
{
"context": "import java.util.Scanner;\n\n/**\n * 作者 : 张泽文\n * 邮箱 : zzw.me@qq.com\n * 时间 : 2020/9/27 20:26\n */\npublic class demo2 {\n",
"end": 96,
"score": 0.9999264478683472,
"start": 83,
"tag": "EMAIL",
"value": "zzw.me@qq.com"
}
]
| null | []
| package demo.bedoreH.demo0927;
import java.util.Scanner;
/**
* 作者 : 张泽文
* 邮箱 : <EMAIL>
* 时间 : 2020/9/27 20:26
*/
public class demo2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt() % 4;
int y = sc.nextInt() % 2;
int z = sc.nextInt() % 4;
int m = sc.nextInt();
int n = sc.nextInt();
int len = sc.nextInt();
int[][] arr = new int[len][2];
for (int i = 0; i < len; i++) {
for (int j = 0; j < 2; j++) {
arr[i][j] = sc.nextInt();
}
}
int step = 0;
if (y == 0) {
step = (z - x) % 4;
} else if (y == 1) {
if (x == 0) {
z += 3;
} else if (x == 2) {
z++;
} else if (x == 3) {
z += 2;
}
step = z % 4;
}
for (int i = 0; i < len; i++) {
int tempX = arr[i][0];
int tempY = arr[i][1];
if (step == 1) {
tempX = m - tempX + 1;
} else if (step == 2) {
tempX = m - tempX + 1;
tempY = n - tempY + 1;
} else if (step == 3) {
tempY = n - tempY + 1;
}
System.out.print(tempX + " ");
System.out.print(tempY);
System.out.println();
}
}
}
| 1,470 | 0.354683 | 0.325069 | 60 | 23.200001 | 14.1419 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false | 15 |
f6a74e17d86b400579871a5986ef533aa4d13732 | 18,665,927,931,195 | 77e25c2197fd69eb3716744c5d383e80a2760112 | /src/main/java/com/lerx/portal/obj/GlobalTagsAnalyzeReturn.java | 2d6963f66162f98231c1e54ec0b153abf99f9172 | []
| no_license | LWHTarena/lerx20190613 | https://github.com/LWHTarena/lerx20190613 | 51f6a1ebfb05a2af0d66656d0e694564070224b9 | 604c9914f4ce4f513c2a9f60a781c35329711d98 | refs/heads/master | 2022-12-24T03:51:10.507000 | 2019-06-13T05:39:30 | 2019-06-13T05:39:30 | 191,605,783 | 0 | 0 | null | false | 2022-12-16T11:17:24 | 2019-06-12T16:16:04 | 2019-06-13T05:44:11 | 2022-12-16T11:17:21 | 31,295 | 0 | 0 | 16 | JavaScript | false | false | package com.lerx.portal.obj;
public class GlobalTagsAnalyzeReturn {
private EnvirSet es;
private String html;
public EnvirSet getEs() {
return es;
}
public void setEs(EnvirSet es) {
this.es = es;
}
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
}
| UTF-8 | Java | 320 | java | GlobalTagsAnalyzeReturn.java | Java | []
| null | []
| package com.lerx.portal.obj;
public class GlobalTagsAnalyzeReturn {
private EnvirSet es;
private String html;
public EnvirSet getEs() {
return es;
}
public void setEs(EnvirSet es) {
this.es = es;
}
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
}
| 320 | 0.684375 | 0.684375 | 21 | 14.238095 | 12.843026 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.285714 | false | false | 15 |
f4e915e41edc62c010bc6a677835ef91af7e7b24 | 10,505,490,049,706 | 813ba0f584c3f59674e428977582cdba196e2268 | /src/main/java/org/reflection/model/com/AbstractTransactableAmount.java | 1795de71f08ad603019f01aceafd94865d18bfdd | []
| no_license | oith/r_pos | https://github.com/oith/r_pos | 6fce9db40407576d8c7fd6e7749fc2dd5f617e5c | 41fd5d9b59e5a086103a45fb85ef25fe11d03c52 | refs/heads/master | 2021-01-23T01:35:08.425000 | 2017-04-08T05:20:23 | 2017-04-08T05:20:23 | 85,919,919 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.reflection.model.com;
import com.oith.annotation.MacCodable;
import org.reflection.model.auth.AuthUser;
import javax.persistence.*;
import javax.validation.constraints.Size;
import java.util.Date;
@Entity
@Table(name = "ADM_TRANSACTION_AMOUNT")
@MacCodable(id = "id", code = "code", caption = "remarks")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractTransactableAmount extends AbstractCodeable implements ITransactableAmount {
@Embedded
public EmbdAuditable embdAuditable;
@Size(min = 2, max = 10)
@Column(name = "CODE", unique = true, nullable = false, length = 10)
private String code;
@Temporal(TemporalType.DATE)
@Column(name = "TRANS_DATE", nullable = false)
private Date transDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "ORIGIN_DATE", nullable = false)
private Date originDate = new Date();
@Column(name = "AMOUNT", nullable = false)
private Double amount;
@Column(name = "REMARKS", length = 500)
private String remarks;
@ManyToOne(optional = false)
@JoinColumn(name = "AUTH_USER_TRANS_BY_ID", nullable = false)
private AuthUser authUserTransBy;
public AbstractTransactableAmount() {
}
public AbstractTransactableAmount(Date transDate, Double amount, AuthUser authUserTransBy) {
this(transDate, amount, authUserTransBy, transDate);
}
public AbstractTransactableAmount(Date transDate, Double amount, AuthUser authUserTransBy, Date originDate) {
this.transDate = transDate;
this.amount = amount;
this.authUserTransBy = authUserTransBy;
this.originDate = originDate;
}
public AbstractTransactableAmount(AbstractTransactableAmount abstractTransactableAmount) {
this.transDate = abstractTransactableAmount.transDate;
this.amount = abstractTransactableAmount.amount;
this.authUserTransBy = abstractTransactableAmount.authUserTransBy;
this.originDate = abstractTransactableAmount.originDate;
}
public Date getTransDate() {
return transDate;
}
public void setTransDate(Date transDate) {
this.transDate = transDate;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public AuthUser getAuthUserTransBy() {
return authUserTransBy;
}
public void setAuthUserTransBy(AuthUser authUserTransBy) {
this.authUserTransBy = authUserTransBy;
}
public Date getOriginDate() {
return originDate;
}
public void setOriginDate(Date originDate) {
this.originDate = originDate;
}
@Override
public String getCode() {
return code;
}
@Override
public void setCode(String code) {
this.code = code;
}
@Override
public EmbdAuditable getEmbdAuditable() {
return embdAuditable;
}
@Override
public void setEmbdAuditable(EmbdAuditable embdAuditable) {
this.embdAuditable = embdAuditable;
}
}
| UTF-8 | Java | 3,237 | java | AbstractTransactableAmount.java | Java | []
| null | []
| package org.reflection.model.com;
import com.oith.annotation.MacCodable;
import org.reflection.model.auth.AuthUser;
import javax.persistence.*;
import javax.validation.constraints.Size;
import java.util.Date;
@Entity
@Table(name = "ADM_TRANSACTION_AMOUNT")
@MacCodable(id = "id", code = "code", caption = "remarks")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractTransactableAmount extends AbstractCodeable implements ITransactableAmount {
@Embedded
public EmbdAuditable embdAuditable;
@Size(min = 2, max = 10)
@Column(name = "CODE", unique = true, nullable = false, length = 10)
private String code;
@Temporal(TemporalType.DATE)
@Column(name = "TRANS_DATE", nullable = false)
private Date transDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "ORIGIN_DATE", nullable = false)
private Date originDate = new Date();
@Column(name = "AMOUNT", nullable = false)
private Double amount;
@Column(name = "REMARKS", length = 500)
private String remarks;
@ManyToOne(optional = false)
@JoinColumn(name = "AUTH_USER_TRANS_BY_ID", nullable = false)
private AuthUser authUserTransBy;
public AbstractTransactableAmount() {
}
public AbstractTransactableAmount(Date transDate, Double amount, AuthUser authUserTransBy) {
this(transDate, amount, authUserTransBy, transDate);
}
public AbstractTransactableAmount(Date transDate, Double amount, AuthUser authUserTransBy, Date originDate) {
this.transDate = transDate;
this.amount = amount;
this.authUserTransBy = authUserTransBy;
this.originDate = originDate;
}
public AbstractTransactableAmount(AbstractTransactableAmount abstractTransactableAmount) {
this.transDate = abstractTransactableAmount.transDate;
this.amount = abstractTransactableAmount.amount;
this.authUserTransBy = abstractTransactableAmount.authUserTransBy;
this.originDate = abstractTransactableAmount.originDate;
}
public Date getTransDate() {
return transDate;
}
public void setTransDate(Date transDate) {
this.transDate = transDate;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public AuthUser getAuthUserTransBy() {
return authUserTransBy;
}
public void setAuthUserTransBy(AuthUser authUserTransBy) {
this.authUserTransBy = authUserTransBy;
}
public Date getOriginDate() {
return originDate;
}
public void setOriginDate(Date originDate) {
this.originDate = originDate;
}
@Override
public String getCode() {
return code;
}
@Override
public void setCode(String code) {
this.code = code;
}
@Override
public EmbdAuditable getEmbdAuditable() {
return embdAuditable;
}
@Override
public void setEmbdAuditable(EmbdAuditable embdAuditable) {
this.embdAuditable = embdAuditable;
}
}
| 3,237 | 0.686438 | 0.683967 | 117 | 26.666666 | 24.901173 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470085 | false | false | 15 |
72443472a086ebbfb6345474239034c2fe9b2a83 | 35,467,839,946,995 | d5f09c7b0e954cd20dd613af600afd91b039c48a | /sources/androidx/databinding/adapters/TableLayoutBindingAdapter.java | 16367bde310bb9830ef91475f65ca3f15b3b5ab3 | []
| no_license | t0HiiBwn/CoolapkRelease | https://github.com/t0HiiBwn/CoolapkRelease | af5e00c701bf82c4e90b1033f5c5f9dc8526f4b3 | a6a2b03e32cde0e5163016e0078391271a8d33ab | refs/heads/main | 2022-07-29T23:28:35.867000 | 2021-03-26T11:41:18 | 2021-03-26T11:41:18 | 345,290,891 | 5 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package androidx.databinding.adapters;
import android.util.SparseBooleanArray;
import android.widget.TableLayout;
import java.util.regex.Pattern;
public class TableLayoutBindingAdapter {
private static final int MAX_COLUMNS = 20;
private static Pattern sColumnPattern = Pattern.compile("\\s*,\\s*");
public static void setCollapseColumns(TableLayout tableLayout, CharSequence charSequence) {
SparseBooleanArray parseColumns = parseColumns(charSequence);
for (int i = 0; i < 20; i++) {
boolean z = parseColumns.get(i, false);
if (z != tableLayout.isColumnCollapsed(i)) {
tableLayout.setColumnCollapsed(i, z);
}
}
}
public static void setShrinkColumns(TableLayout tableLayout, CharSequence charSequence) {
if (charSequence == null || charSequence.length() <= 0 || charSequence.charAt(0) != '*') {
tableLayout.setShrinkAllColumns(false);
SparseBooleanArray parseColumns = parseColumns(charSequence);
int size = parseColumns.size();
for (int i = 0; i < size; i++) {
int keyAt = parseColumns.keyAt(i);
boolean valueAt = parseColumns.valueAt(i);
if (valueAt) {
tableLayout.setColumnShrinkable(keyAt, valueAt);
}
}
return;
}
tableLayout.setShrinkAllColumns(true);
}
public static void setStretchColumns(TableLayout tableLayout, CharSequence charSequence) {
if (charSequence == null || charSequence.length() <= 0 || charSequence.charAt(0) != '*') {
tableLayout.setStretchAllColumns(false);
SparseBooleanArray parseColumns = parseColumns(charSequence);
int size = parseColumns.size();
for (int i = 0; i < size; i++) {
int keyAt = parseColumns.keyAt(i);
boolean valueAt = parseColumns.valueAt(i);
if (valueAt) {
tableLayout.setColumnStretchable(keyAt, valueAt);
}
}
return;
}
tableLayout.setStretchAllColumns(true);
}
private static SparseBooleanArray parseColumns(CharSequence charSequence) {
SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
if (charSequence == null) {
return sparseBooleanArray;
}
for (String str : sColumnPattern.split(charSequence)) {
try {
int parseInt = Integer.parseInt(str);
if (parseInt >= 0) {
sparseBooleanArray.put(parseInt, true);
}
} catch (NumberFormatException unused) {
}
}
return sparseBooleanArray;
}
}
| UTF-8 | Java | 2,792 | java | TableLayoutBindingAdapter.java | Java | []
| null | []
| package androidx.databinding.adapters;
import android.util.SparseBooleanArray;
import android.widget.TableLayout;
import java.util.regex.Pattern;
public class TableLayoutBindingAdapter {
private static final int MAX_COLUMNS = 20;
private static Pattern sColumnPattern = Pattern.compile("\\s*,\\s*");
public static void setCollapseColumns(TableLayout tableLayout, CharSequence charSequence) {
SparseBooleanArray parseColumns = parseColumns(charSequence);
for (int i = 0; i < 20; i++) {
boolean z = parseColumns.get(i, false);
if (z != tableLayout.isColumnCollapsed(i)) {
tableLayout.setColumnCollapsed(i, z);
}
}
}
public static void setShrinkColumns(TableLayout tableLayout, CharSequence charSequence) {
if (charSequence == null || charSequence.length() <= 0 || charSequence.charAt(0) != '*') {
tableLayout.setShrinkAllColumns(false);
SparseBooleanArray parseColumns = parseColumns(charSequence);
int size = parseColumns.size();
for (int i = 0; i < size; i++) {
int keyAt = parseColumns.keyAt(i);
boolean valueAt = parseColumns.valueAt(i);
if (valueAt) {
tableLayout.setColumnShrinkable(keyAt, valueAt);
}
}
return;
}
tableLayout.setShrinkAllColumns(true);
}
public static void setStretchColumns(TableLayout tableLayout, CharSequence charSequence) {
if (charSequence == null || charSequence.length() <= 0 || charSequence.charAt(0) != '*') {
tableLayout.setStretchAllColumns(false);
SparseBooleanArray parseColumns = parseColumns(charSequence);
int size = parseColumns.size();
for (int i = 0; i < size; i++) {
int keyAt = parseColumns.keyAt(i);
boolean valueAt = parseColumns.valueAt(i);
if (valueAt) {
tableLayout.setColumnStretchable(keyAt, valueAt);
}
}
return;
}
tableLayout.setStretchAllColumns(true);
}
private static SparseBooleanArray parseColumns(CharSequence charSequence) {
SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
if (charSequence == null) {
return sparseBooleanArray;
}
for (String str : sColumnPattern.split(charSequence)) {
try {
int parseInt = Integer.parseInt(str);
if (parseInt >= 0) {
sparseBooleanArray.put(parseInt, true);
}
} catch (NumberFormatException unused) {
}
}
return sparseBooleanArray;
}
}
| 2,792 | 0.590616 | 0.586318 | 71 | 38.323944 | 27.527592 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.746479 | false | false | 15 |
47e1d5870212d6c70938fced237ccf1b6e24c317 | 35,467,839,946,265 | b0bbcedf6312b3e426f9bd71329448e762b23326 | /recrutamento-teste-carrinho-compras-joaosouz/src/main/java/br/com/improving/carrinho/CarrinhoComprasFactory.java | 1288d822919a3003ba86192f08d7b1cbf388f8f2 | []
| no_license | joaosouz91/teste-improving-solucao | https://github.com/joaosouz91/teste-improving-solucao | 8813e1e9c18f37d332cf304dd5a958485fc94b3d | d86a041d9118409d48c8462cb5e9adede9bae895 | refs/heads/master | 2020-03-28T21:47:51.837000 | 2018-09-17T23:24:14 | 2018-09-17T23:24:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.improving.carrinho;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* Classe responsável pela criação e recuperação dos carrinhos de compras.
*/
public class CarrinhoComprasFactory {
private List<CarrinhoCompras> carrinhoList = new ArrayList<>();
public List<CarrinhoCompras> getCarrinhoList() {
return carrinhoList;
}
/**
* Cria e retorna um novo carrinho de compras para o cliente passado como parâmetro.
*
* Caso já exista um carrinho de compras para o cliente passado como parâmetro, este carrinho deverá ser retornado.
*
* @param identificacaoCliente
* @return CarrinhoCompras
*/
public CarrinhoCompras criar(String identificacaoCliente) {
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
if(carrinhoCompras.getIdentificacaoCliente().equals(identificacaoCliente)) {
return carrinhoCompras;
}
}
CarrinhoCompras c = new CarrinhoCompras();
c.setIdentificacaoCliente(identificacaoCliente);
carrinhoList.add(c);
return c;
}
/**
* Retorna o valor do ticket médio no momento da chamada ao método.
* O valor do ticket médio é a soma do valor total de todos os carrinhos de compra dividido
* pela quantidade de carrinhos de compra.
* O valor retornado deverá ser arredondado com duas casas decimais, seguindo a regra:
* 0-4 deve ser arredondado para baixo e 5-9 deve ser arredondado para cima.
*
* @return BigDecimal
*/
public BigDecimal getValorTicketMedio() {
BigDecimal valorTotalCarrinhos = new BigDecimal(0);
BigDecimal ticketMedio = new BigDecimal(0);
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
valorTotalCarrinhos = valorTotalCarrinhos.add(carrinhoCompras.getValorTotal());
}
ticketMedio = valorTotalCarrinhos.divide(new BigDecimal(carrinhoList.size()));
return Util.arredondar(ticketMedio);
}
/**
* Invalida um carrinho de compras quando o cliente faz um checkout ou sua sessão expirar.
* Deve ser efetuada a remoção do carrinho do cliente passado como parâmetro da listagem de carrinhos de compras.
*
* @param identificacaoCliente
* @return Retorna um boolean, tendo o valor true caso o cliente passado como parämetro tenha um carrinho de compras e
* e false caso o cliente não possua um carrinho.
*/
public boolean invalidar(String identificacaoCliente) {
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
if(carrinhoCompras.getIdentificacaoCliente().equals(identificacaoCliente)) {
carrinhoList.remove(carrinhoCompras);
return true;
}
}
return false;
}
}
| UTF-8 | Java | 2,743 | java | CarrinhoComprasFactory.java | Java | []
| null | []
| package br.com.improving.carrinho;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* Classe responsável pela criação e recuperação dos carrinhos de compras.
*/
public class CarrinhoComprasFactory {
private List<CarrinhoCompras> carrinhoList = new ArrayList<>();
public List<CarrinhoCompras> getCarrinhoList() {
return carrinhoList;
}
/**
* Cria e retorna um novo carrinho de compras para o cliente passado como parâmetro.
*
* Caso já exista um carrinho de compras para o cliente passado como parâmetro, este carrinho deverá ser retornado.
*
* @param identificacaoCliente
* @return CarrinhoCompras
*/
public CarrinhoCompras criar(String identificacaoCliente) {
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
if(carrinhoCompras.getIdentificacaoCliente().equals(identificacaoCliente)) {
return carrinhoCompras;
}
}
CarrinhoCompras c = new CarrinhoCompras();
c.setIdentificacaoCliente(identificacaoCliente);
carrinhoList.add(c);
return c;
}
/**
* Retorna o valor do ticket médio no momento da chamada ao método.
* O valor do ticket médio é a soma do valor total de todos os carrinhos de compra dividido
* pela quantidade de carrinhos de compra.
* O valor retornado deverá ser arredondado com duas casas decimais, seguindo a regra:
* 0-4 deve ser arredondado para baixo e 5-9 deve ser arredondado para cima.
*
* @return BigDecimal
*/
public BigDecimal getValorTicketMedio() {
BigDecimal valorTotalCarrinhos = new BigDecimal(0);
BigDecimal ticketMedio = new BigDecimal(0);
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
valorTotalCarrinhos = valorTotalCarrinhos.add(carrinhoCompras.getValorTotal());
}
ticketMedio = valorTotalCarrinhos.divide(new BigDecimal(carrinhoList.size()));
return Util.arredondar(ticketMedio);
}
/**
* Invalida um carrinho de compras quando o cliente faz um checkout ou sua sessão expirar.
* Deve ser efetuada a remoção do carrinho do cliente passado como parâmetro da listagem de carrinhos de compras.
*
* @param identificacaoCliente
* @return Retorna um boolean, tendo o valor true caso o cliente passado como parämetro tenha um carrinho de compras e
* e false caso o cliente não possua um carrinho.
*/
public boolean invalidar(String identificacaoCliente) {
for (CarrinhoCompras carrinhoCompras : carrinhoList) {
if(carrinhoCompras.getIdentificacaoCliente().equals(identificacaoCliente)) {
carrinhoList.remove(carrinhoCompras);
return true;
}
}
return false;
}
}
| 2,743 | 0.713184 | 0.710981 | 81 | 32.617283 | 33.431915 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.975309 | false | false | 15 |
452a3b917c238dd80bc0c2e4ab07160d2b0f634b | 22,737,556,934,546 | 939cfc256a6e11ff318504700c0b88f6e30f87e4 | /bubble sort/bubble.java | 3e33e0f7a5b69e1241fdde4733164ce8dd86ab81 | []
| no_license | joeant1989/prom1 | https://github.com/joeant1989/prom1 | e190b6585365fc4a2a4e19c35558b0d8930a8c2c | 95a4a7024cea9bab8185b2396c590ed956b7bc5b | refs/heads/master | 2021-01-01T17:29:19.393000 | 2017-08-12T10:12:04 | 2017-08-12T10:12:04 | 98,083,135 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sort;
import java.util.Scanner;
public class Bubble {
public static void main(String[] args) throws InterruptedException {
int i, j, temp = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of elements: ");
int n = sc.nextInt();
int a[] = new int[50];
System.out.println("Enter the elements : ");
for (i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
System.out.println("Before sorting...");
for (i = 0; i < n; i++) {
System.out.println(a[i]);
}
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
Thread.sleep(5000);
System.out.println("After sorting....");
for (i = 0; i < n; i++) {
System.out.println(a[i]);
}
}
}
| UTF-8 | Java | 828 | java | bubble.java | Java | []
| null | []
| package sort;
import java.util.Scanner;
public class Bubble {
public static void main(String[] args) throws InterruptedException {
int i, j, temp = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of elements: ");
int n = sc.nextInt();
int a[] = new int[50];
System.out.println("Enter the elements : ");
for (i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
System.out.println("Before sorting...");
for (i = 0; i < n; i++) {
System.out.println(a[i]);
}
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
Thread.sleep(5000);
System.out.println("After sorting....");
for (i = 0; i < n; i++) {
System.out.println(a[i]);
}
}
}
| 828 | 0.508454 | 0.493961 | 36 | 21 | 16.4063 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.861111 | false | false | 15 |
d000b534a5f19b97102adb479af23bfb62ed31c7 | 33,895,881,916,508 | 6dcb2fd11c7d2a43ee5309727861d2ad47355c4c | /app/src/main/java/com/example/android/musicalstructure/MainActivity.java | 4f9304d7fd8cbde6f65ffb04ad2ea721e90196c2 | []
| no_license | pigscanfly/MusicalStructure2 | https://github.com/pigscanfly/MusicalStructure2 | 7b0f3f2f8f27ce3febc6149cf83a5e8103fbc53b | 54c74643b711305a7df8fc4cb2e913f2e9e2af89 | refs/heads/master | 2021-01-20T13:43:32.555000 | 2017-05-07T14:01:24 | 2017-05-07T14:01:24 | 90,521,136 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.android.musicalstructure;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Duck activity
// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);
// Find the View that shows the duck image
ImageView ducks = (ImageView) findViewById(R.id.duck_activity);
// Set a click listener on that View
ducks.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the duck image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the Duck activity
Intent ducksIntent = new Intent(MainActivity.this, DuckActivity.class);
// Start the Duck activity
startActivity(ducksIntent);
}
});
//Cow activity
// Find the View that shows the cow image
ImageView cows = (ImageView) findViewById(R.id.cow_activity);
// Set a click listener on that View
cows.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the cow image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the cow activity.
Intent cowsIntent = new Intent(MainActivity.this, CowActivity.class);
// Start the cow activity
startActivity(cowsIntent);
}
});
//pig activity
// Find the View that shows the pig image
ImageView pigs = (ImageView) findViewById(R.id.pig_activity);
// Set a click listener on that View
pigs.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the pig image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the pig activity
Intent pigsIntent = new Intent(MainActivity.this, PigActivity.class);
// Start the new activity
startActivity(pigsIntent);
}
});
//dog activity
// Find the View that shows the dog image.
ImageView dogs = (ImageView) findViewById(R.id.dog_activity);
// Set a click listener on that View
dogs.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the dog image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the dog activity.
Intent dogsIntent = new Intent(MainActivity.this, DogActivity.class);
// Start the dog activity
startActivity(dogsIntent);
}
});
}
}
| UTF-8 | Java | 3,276 | java | MainActivity.java | Java | []
| null | []
| package com.example.android.musicalstructure;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Duck activity
// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);
// Find the View that shows the duck image
ImageView ducks = (ImageView) findViewById(R.id.duck_activity);
// Set a click listener on that View
ducks.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the duck image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the Duck activity
Intent ducksIntent = new Intent(MainActivity.this, DuckActivity.class);
// Start the Duck activity
startActivity(ducksIntent);
}
});
//Cow activity
// Find the View that shows the cow image
ImageView cows = (ImageView) findViewById(R.id.cow_activity);
// Set a click listener on that View
cows.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the cow image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the cow activity.
Intent cowsIntent = new Intent(MainActivity.this, CowActivity.class);
// Start the cow activity
startActivity(cowsIntent);
}
});
//pig activity
// Find the View that shows the pig image
ImageView pigs = (ImageView) findViewById(R.id.pig_activity);
// Set a click listener on that View
pigs.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the pig image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the pig activity
Intent pigsIntent = new Intent(MainActivity.this, PigActivity.class);
// Start the new activity
startActivity(pigsIntent);
}
});
//dog activity
// Find the View that shows the dog image.
ImageView dogs = (ImageView) findViewById(R.id.dog_activity);
// Set a click listener on that View
dogs.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the dog image is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the dog activity.
Intent dogsIntent = new Intent(MainActivity.this, DogActivity.class);
// Start the dog activity
startActivity(dogsIntent);
}
});
}
}
| 3,276 | 0.609585 | 0.60928 | 97 | 32.773197 | 28.350714 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.298969 | false | false | 15 |
58bd8d2d830554e0d6f8fa1b80d2af1357cca298 | 18,013,092,880,356 | 50d849210daf514035086497f960c2c17f13efdd | /src/main/java/com/xwj/util/TestJdbc.java | 867e0ff18776141afc804c2a3de48ace3709170b | []
| no_license | xuwenjin/springJdbc | https://github.com/xuwenjin/springJdbc | f1395b3d1f2e69cd9ac3b15b2a02ab4503a87f4c | 3ac11d5551ba3435654166db24c5012a1606839b | refs/heads/master | 2020-03-25T08:03:21.014000 | 2018-08-05T08:18:06 | 2018-08-05T08:18:06 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xwj.util;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.util.CollectionUtils;
import com.xwj.bean.User;
public class TestJdbc {
private ApplicationContext ctx = null;
private JdbcTemplate jdbcTemplate = null;
{
ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
jdbcTemplate = (JdbcTemplate) ctx.getBean("jdbcTemplate");
}
/**
* 执行 INSERT
*/
@Test
public void testInsert() {
String sql = "INSERT INTO xwj_user(id, last_name, age) VALUES(?, ?, ?)";
jdbcTemplate.update(sql, "1", "a-xwj", 0);
}
/**
* 执行UPDATE
*/
@Test
public void testUpdate() {
String sql = "UPDATE xwj_user SET last_name = ? WHERE id = ?";
jdbcTemplate.update(sql, "b-xwj", 1);
}
/**
* 执行 DELETE
*/
@Test
public void testDelete() {
String sql = "DELETE from xwj_user WHERE id = ?";
jdbcTemplate.update(sql, 1);
}
/**
* 测试批量更新操作 最后一个参数是 Object[] 的 List 类型:因为修改一条记录需要一个 Object 数组,修改多条记录就需要一个
* List 来存放多个数组。
*/
@Test
public void testBatchUpdate() {
String sql = "INSERT INTO xwj_user(id, last_name, email) VALUES(?, ?, ?)";
List<Object[]> batchArgs = new ArrayList<>();
batchArgs.add(new Object[] { "2", "AA", "aa@atguigu.com" });
batchArgs.add(new Object[] { "3", "BB", "bb@atguigu.com" });
batchArgs.add(new Object[] { "4", "CC", "cc@atguigu.com" });
batchArgs.add(new Object[] { "5", "DD", "dd@atguigu.com" });
jdbcTemplate.batchUpdate(sql, batchArgs);
}
/**
* 从数据库中获取一条记录,实际得到对应的一个对象 注意:不是调用 queryForObject(String sql,Class<Employee> requiredType, Object... args) 方法!
* 而需要调用queryForObject(String sql, RowMapper<Employee> rowMapper, Object... args)
* 1、其中的 RowMapper 指定如何去映射结果集的行,常用的实现类为 BeanPropertyRowMapper
* 2、使用SQL中的列的别名完成列名和类的属性名的映射,例如 last_name lastName
* 3、不支持级联属性。 JdbcTemplate只能作为一个 JDBC 的小工具, 而不是 ORM 框架
*/
@Test
public void testQueryForObject() {
String sql = "SELECT id, last_name lastName, email FROM xwj_user WHERE ID = ?";
RowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class);
// 在将数据装入对象时需要调用set方法。
User user = jdbcTemplate.queryForObject(sql, rowMapper, 2);
System.out.println(user);
}
/**
* 一次查询多个对象
* 注意:调用的不是 queryForList 方法
*/
@Test
public void testQueryForList() {
String sql = "SELECT id, name, email FROM xwj_user WHERE id > ?";
RowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class);
List<User> userList = jdbcTemplate.query(sql, rowMapper, 1);
if (!CollectionUtils.isEmpty(userList)) {
userList.forEach(user -> {
System.out.println(user);
});
}
}
/**
* 获取单个列的值或做统计查询
* 使用 queryForObject(String sql, Class<Long> requiredType)
*/
@Test
public void testQueryForCount() {
String sql = "SELECT count(id) FROM xwj_user";
long count = jdbcTemplate.queryForObject(sql, Long.class);
System.out.println(count);
}
}
| GB18030 | Java | 3,756 | java | TestJdbc.java | Java | [
{
"context": "t<>();\n\t\tbatchArgs.add(new Object[] { \"2\", \"AA\", \"aa@atguigu.com\" });\n\t\tbatchArgs.add(new Object[] { \"3\", \"BB\", \"b",
"end": 1533,
"score": 0.9999290108680725,
"start": 1519,
"tag": "EMAIL",
"value": "aa@atguigu.com"
},
{
"context": "m\" });\n\t\tbatchArgs.add(new Object[] { \"3\", \"BB\", \"bb@atguigu.com\" });\n\t\tbatchArgs.add(new Object[] { \"4\", \"CC\", \"c",
"end": 1596,
"score": 0.999925971031189,
"start": 1582,
"tag": "EMAIL",
"value": "bb@atguigu.com"
},
{
"context": "m\" });\n\t\tbatchArgs.add(new Object[] { \"4\", \"CC\", \"cc@atguigu.com\" });\n\t\tbatchArgs.add(new Object[] { \"5\", \"DD\", \"d",
"end": 1659,
"score": 0.9999265074729919,
"start": 1645,
"tag": "EMAIL",
"value": "cc@atguigu.com"
},
{
"context": "m\" });\n\t\tbatchArgs.add(new Object[] { \"5\", \"DD\", \"dd@atguigu.com\" });\n\n\t\tjdbcTemplate.batchUpdate(sql, batchArgs);",
"end": 1722,
"score": 0.9999276399612427,
"start": 1708,
"tag": "EMAIL",
"value": "dd@atguigu.com"
}
]
| null | []
| package com.xwj.util;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.util.CollectionUtils;
import com.xwj.bean.User;
public class TestJdbc {
private ApplicationContext ctx = null;
private JdbcTemplate jdbcTemplate = null;
{
ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
jdbcTemplate = (JdbcTemplate) ctx.getBean("jdbcTemplate");
}
/**
* 执行 INSERT
*/
@Test
public void testInsert() {
String sql = "INSERT INTO xwj_user(id, last_name, age) VALUES(?, ?, ?)";
jdbcTemplate.update(sql, "1", "a-xwj", 0);
}
/**
* 执行UPDATE
*/
@Test
public void testUpdate() {
String sql = "UPDATE xwj_user SET last_name = ? WHERE id = ?";
jdbcTemplate.update(sql, "b-xwj", 1);
}
/**
* 执行 DELETE
*/
@Test
public void testDelete() {
String sql = "DELETE from xwj_user WHERE id = ?";
jdbcTemplate.update(sql, 1);
}
/**
* 测试批量更新操作 最后一个参数是 Object[] 的 List 类型:因为修改一条记录需要一个 Object 数组,修改多条记录就需要一个
* List 来存放多个数组。
*/
@Test
public void testBatchUpdate() {
String sql = "INSERT INTO xwj_user(id, last_name, email) VALUES(?, ?, ?)";
List<Object[]> batchArgs = new ArrayList<>();
batchArgs.add(new Object[] { "2", "AA", "<EMAIL>" });
batchArgs.add(new Object[] { "3", "BB", "<EMAIL>" });
batchArgs.add(new Object[] { "4", "CC", "<EMAIL>" });
batchArgs.add(new Object[] { "5", "DD", "<EMAIL>" });
jdbcTemplate.batchUpdate(sql, batchArgs);
}
/**
* 从数据库中获取一条记录,实际得到对应的一个对象 注意:不是调用 queryForObject(String sql,Class<Employee> requiredType, Object... args) 方法!
* 而需要调用queryForObject(String sql, RowMapper<Employee> rowMapper, Object... args)
* 1、其中的 RowMapper 指定如何去映射结果集的行,常用的实现类为 BeanPropertyRowMapper
* 2、使用SQL中的列的别名完成列名和类的属性名的映射,例如 last_name lastName
* 3、不支持级联属性。 JdbcTemplate只能作为一个 JDBC 的小工具, 而不是 ORM 框架
*/
@Test
public void testQueryForObject() {
String sql = "SELECT id, last_name lastName, email FROM xwj_user WHERE ID = ?";
RowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class);
// 在将数据装入对象时需要调用set方法。
User user = jdbcTemplate.queryForObject(sql, rowMapper, 2);
System.out.println(user);
}
/**
* 一次查询多个对象
* 注意:调用的不是 queryForList 方法
*/
@Test
public void testQueryForList() {
String sql = "SELECT id, name, email FROM xwj_user WHERE id > ?";
RowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class);
List<User> userList = jdbcTemplate.query(sql, rowMapper, 1);
if (!CollectionUtils.isEmpty(userList)) {
userList.forEach(user -> {
System.out.println(user);
});
}
}
/**
* 获取单个列的值或做统计查询
* 使用 queryForObject(String sql, Class<Long> requiredType)
*/
@Test
public void testQueryForCount() {
String sql = "SELECT count(id) FROM xwj_user";
long count = jdbcTemplate.queryForObject(sql, Long.class);
System.out.println(count);
}
}
| 3,728 | 0.666265 | 0.662349 | 114 | 28.122807 | 26.867819 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.429825 | false | false | 15 |
f1cd76dd9f4cc37f44614729f612ca650efd254e | 29,807,073,099,971 | 3a09a1c7292df560566b9c18a997b0e785695fb7 | /src/mastermind_calc/Calculations.java | fddad0136adc3a61b1ac0f07f1d4f99b192921d9 | []
| no_license | joannastecura97/Mastermind | https://github.com/joannastecura97/Mastermind | 01c89f1fe5cb9ce350e170c33f4c39ee17d68522 | 549db4b082343f10e8d420e43c9b215412965033 | refs/heads/master | 2022-08-11T20:03:04.248000 | 2020-05-19T19:27:48 | 2020-05-19T19:27:48 | 265,343,113 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mastermind_calc;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Class used for finding a win in the game.
*/
public class Calculations {
/**
* Method used for calculating how many number of colors in<code>guess</code>
* are the same and how many colors in<code>guess</code> are in the same position as in <code>candidate</code>.
* @param guess guess
* @param candidate one of number from possibleNumbers
* @return new instance of the class <code>Counter</code>
*/
public static Counter calcPositionAndColor(String guess, String candidate) {
int positionCounter=0;
int colorCounter=0;
for (int i = 0; i < candidate.length(); i++) {
if (guess.charAt(i) == candidate.charAt(i)) {
positionCounter++;
} else if (guess.contains(String.valueOf(candidate.charAt(i)))) {
colorCounter++;
}
}
return new Counter(positionCounter, colorCounter);
}
/**
* Method used for generate all possible numbers from 0123 to 5433
* without 6,7,8,9 and there is only one same digit in each number
* @return <code>Set</code> list of numbers that meet the requirements
*/
public static Set<String> generatePossibleNumbers() {
Set<String> set = new HashSet<>();
for (int i = 123; i < 5433; i++) {
if(i<1000){
set.add(String.valueOf("0"+i));
}
else set.add(String.valueOf(i));
}
Iterator<String> iterator = set.iterator();
while (iterator.hasNext()) {
String str = iterator.next();
Set<Character> characters = new HashSet<>();
for (char c : str.toCharArray()) {
if (characters.contains(c)) {
iterator.remove();
break;
}
if(c=='6'||c=='7'||c=='8'||c=='9'){
iterator.remove();
break;
}
characters.add(c);
}
}
return set;
}
/**
* Method used for calculating how many number of colors in<code>guess</code>
* are the same and how many colors in<code>guess</code> are in the same position as in one of <code>possibleNumbers</code>
* (using method calcPositionAndColor()) and removing all numbers from possibleNumbers, which
* after calculating and comparing with<code>guess</code> don't have the same number of colors which
* are the same and don't have the same number of colors in the same position as in <code>guessCount</code>.
* @param guessCount Instance of class <code>Counter</code> with number of colors which are the same and number of colors in the same position from comparing guess in game and key
* @param guess guess from game
* @param possibleNumbers numbers that can give the victory
*/
public static void removeWrongNumbers(Counter guessCount, String guess,
Set<String> possibleNumbers) {
//possibleNums.removeIf(str -> !calcPositionAndColor(guess, str).equals(guessCount));
Iterator<String> iterator = possibleNumbers.iterator();
while (iterator.hasNext()) {
String str = iterator.next();
if (!calcPositionAndColor(guess, str).equals(guessCount)) {
iterator.remove();
}
}
}
} | UTF-8 | Java | 3,493 | java | Calculations.java | Java | []
| null | []
| package mastermind_calc;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Class used for finding a win in the game.
*/
public class Calculations {
/**
* Method used for calculating how many number of colors in<code>guess</code>
* are the same and how many colors in<code>guess</code> are in the same position as in <code>candidate</code>.
* @param guess guess
* @param candidate one of number from possibleNumbers
* @return new instance of the class <code>Counter</code>
*/
public static Counter calcPositionAndColor(String guess, String candidate) {
int positionCounter=0;
int colorCounter=0;
for (int i = 0; i < candidate.length(); i++) {
if (guess.charAt(i) == candidate.charAt(i)) {
positionCounter++;
} else if (guess.contains(String.valueOf(candidate.charAt(i)))) {
colorCounter++;
}
}
return new Counter(positionCounter, colorCounter);
}
/**
* Method used for generate all possible numbers from 0123 to 5433
* without 6,7,8,9 and there is only one same digit in each number
* @return <code>Set</code> list of numbers that meet the requirements
*/
public static Set<String> generatePossibleNumbers() {
Set<String> set = new HashSet<>();
for (int i = 123; i < 5433; i++) {
if(i<1000){
set.add(String.valueOf("0"+i));
}
else set.add(String.valueOf(i));
}
Iterator<String> iterator = set.iterator();
while (iterator.hasNext()) {
String str = iterator.next();
Set<Character> characters = new HashSet<>();
for (char c : str.toCharArray()) {
if (characters.contains(c)) {
iterator.remove();
break;
}
if(c=='6'||c=='7'||c=='8'||c=='9'){
iterator.remove();
break;
}
characters.add(c);
}
}
return set;
}
/**
* Method used for calculating how many number of colors in<code>guess</code>
* are the same and how many colors in<code>guess</code> are in the same position as in one of <code>possibleNumbers</code>
* (using method calcPositionAndColor()) and removing all numbers from possibleNumbers, which
* after calculating and comparing with<code>guess</code> don't have the same number of colors which
* are the same and don't have the same number of colors in the same position as in <code>guessCount</code>.
* @param guessCount Instance of class <code>Counter</code> with number of colors which are the same and number of colors in the same position from comparing guess in game and key
* @param guess guess from game
* @param possibleNumbers numbers that can give the victory
*/
public static void removeWrongNumbers(Counter guessCount, String guess,
Set<String> possibleNumbers) {
//possibleNums.removeIf(str -> !calcPositionAndColor(guess, str).equals(guessCount));
Iterator<String> iterator = possibleNumbers.iterator();
while (iterator.hasNext()) {
String str = iterator.next();
if (!calcPositionAndColor(guess, str).equals(guessCount)) {
iterator.remove();
}
}
}
} | 3,493 | 0.590324 | 0.581449 | 90 | 37.822224 | 34.316364 | 183 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
61cefb23956aeb13184272f76e585354b642849a | 15,324,443,367,578 | ea75256408143f7915c3d514d359d0e01193d324 | /eses-client/src/main/java/de/osrg/eses/client/select/LocatedLableableSelector.java | 274f6ed8dd01f847174b0c69dd91fdfed7e0adf9 | []
| no_license | mediahype/de.osrg.eses | https://github.com/mediahype/de.osrg.eses | 50d1799db5471c6955886f89ef9338fd7143ad00 | f793d500029bebf5516cb28b43ebddcdb824eb3e | refs/heads/master | 2016-09-14T16:04:47.399000 | 2016-05-26T20:44:30 | 2016-05-26T20:44:30 | 32,334,349 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.osrg.eses.client.select;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.osrg.eses.client.select.functional.FunctionalSelectionChanged;
import de.osrg.eses.model.Node;
import de.osrg.eses.types.ValueHolder;
import de.osrg.eses.view.types.ValueSelector;
/**
* Composite that selects an object. It is called located because the object is defined somewhere
* (but that is not yet implemented) and can be assigned a label (which is also NYI)
*
* @author saatsch
*
*/
public abstract class LocatedLableableSelector extends ValueSelector {
private static final Logger LOG = LoggerFactory.getLogger(LocatedLableableSelector.class);
private Text txtFilter;
private Table tblObjects;
private Text txtHint;
private TableViewer tableViewer;
public LocatedLableableSelector(Composite parent, Resulting client) {
super(parent);
setLayout(new GridLayout(1, false));
SashForm sashForm = new SashForm(this, SWT.NONE);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
@SuppressWarnings("unused")
Composite cmpLeft = new Composite(sashForm, SWT.NONE);
Composite cmpRight = new Composite(sashForm, SWT.NONE);
cmpRight.setLayout(new GridLayout(2, false));
Label lblFilter = new Label(cmpRight, SWT.NONE);
lblFilter.setBounds(0, 0, 49, 13);
lblFilter.setText("Filter");
txtFilter = new Text(cmpRight, SWT.BORDER);
txtFilter.setText("TODO: implement Filter");
txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtFilter.setBounds(0, 0, 76, 19);
tableViewer = new TableViewer(cmpRight, SWT.BORDER | SWT.FULL_SELECTION);
tblObjects = tableViewer.getTable();
tblObjects.setHeaderVisible(true);
GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_table.heightHint = 280;
tblObjects.setLayoutData(gd_table);
tblObjects.setBounds(0, 0, 84, 84);
TableViewerColumn colName = new TableViewerColumn(tableViewer, SWT.NONE);
colName.getColumn().setWidth(215);
colName.getColumn().setText("Name");
colName.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
String disp = null;
try {
disp = ((Node) element).getDisplayName();
} catch (Exception e) {
LOG.error("error: ", e);
}
return disp;
}
});
TableViewerColumn colSource = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnNewColumn = colSource.getColumn();
tblclmnNewColumn.setWidth(100);
tblclmnNewColumn.setText("Source");
colSource.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return "implement me.";
}
});
txtHint = new Text(cmpRight, SWT.BORDER);
GridData gd_txtHint = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd_txtHint.heightHint = 61;
getTxtHint().setLayoutData(gd_txtHint);
getTxtHint().setBounds(0, 0, 76, 19);
sashForm.setWeights(new int[] {1, 4});
tblObjects.addSelectionListener(new FunctionalSelectionChanged(this));
tableViewer.addDoubleClickListener(new LocatedLableableSelected(client));
}
protected void postInit() {
tableViewer.setContentProvider(getContentProvider());
// it does not matter what we set here but setting this to null causes
// the viewer to not be refreshed
tableViewer.setInput("");
tableViewer.refresh();
}
public Object getSelection() {
TableItem[] selection = tableViewer.getTable().getSelection();
if (selection.length == 0) {
return null;
}
return selection[0].getData();
}
public Text getTxtHint() {
return txtHint;
}
public abstract IContentProvider getContentProvider();
@Override
public ValueHolder getSelectedValue() {
// TODO Auto-generated method stub
return null;
}
}
| UTF-8 | Java | 4,711 | java | LocatedLableableSelector.java | Java | [
{
"context": "igned a label (which is also NYI)\r\n * \r\n * @author saatsch\r\n *\r\n */\r\npublic abstract class LocatedLableableS",
"end": 1119,
"score": 0.9978294372558594,
"start": 1112,
"tag": "USERNAME",
"value": "saatsch"
}
]
| null | []
| package de.osrg.eses.client.select;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.osrg.eses.client.select.functional.FunctionalSelectionChanged;
import de.osrg.eses.model.Node;
import de.osrg.eses.types.ValueHolder;
import de.osrg.eses.view.types.ValueSelector;
/**
* Composite that selects an object. It is called located because the object is defined somewhere
* (but that is not yet implemented) and can be assigned a label (which is also NYI)
*
* @author saatsch
*
*/
public abstract class LocatedLableableSelector extends ValueSelector {
private static final Logger LOG = LoggerFactory.getLogger(LocatedLableableSelector.class);
private Text txtFilter;
private Table tblObjects;
private Text txtHint;
private TableViewer tableViewer;
public LocatedLableableSelector(Composite parent, Resulting client) {
super(parent);
setLayout(new GridLayout(1, false));
SashForm sashForm = new SashForm(this, SWT.NONE);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
@SuppressWarnings("unused")
Composite cmpLeft = new Composite(sashForm, SWT.NONE);
Composite cmpRight = new Composite(sashForm, SWT.NONE);
cmpRight.setLayout(new GridLayout(2, false));
Label lblFilter = new Label(cmpRight, SWT.NONE);
lblFilter.setBounds(0, 0, 49, 13);
lblFilter.setText("Filter");
txtFilter = new Text(cmpRight, SWT.BORDER);
txtFilter.setText("TODO: implement Filter");
txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtFilter.setBounds(0, 0, 76, 19);
tableViewer = new TableViewer(cmpRight, SWT.BORDER | SWT.FULL_SELECTION);
tblObjects = tableViewer.getTable();
tblObjects.setHeaderVisible(true);
GridData gd_table = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
gd_table.heightHint = 280;
tblObjects.setLayoutData(gd_table);
tblObjects.setBounds(0, 0, 84, 84);
TableViewerColumn colName = new TableViewerColumn(tableViewer, SWT.NONE);
colName.getColumn().setWidth(215);
colName.getColumn().setText("Name");
colName.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
String disp = null;
try {
disp = ((Node) element).getDisplayName();
} catch (Exception e) {
LOG.error("error: ", e);
}
return disp;
}
});
TableViewerColumn colSource = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnNewColumn = colSource.getColumn();
tblclmnNewColumn.setWidth(100);
tblclmnNewColumn.setText("Source");
colSource.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return "implement me.";
}
});
txtHint = new Text(cmpRight, SWT.BORDER);
GridData gd_txtHint = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd_txtHint.heightHint = 61;
getTxtHint().setLayoutData(gd_txtHint);
getTxtHint().setBounds(0, 0, 76, 19);
sashForm.setWeights(new int[] {1, 4});
tblObjects.addSelectionListener(new FunctionalSelectionChanged(this));
tableViewer.addDoubleClickListener(new LocatedLableableSelected(client));
}
protected void postInit() {
tableViewer.setContentProvider(getContentProvider());
// it does not matter what we set here but setting this to null causes
// the viewer to not be refreshed
tableViewer.setInput("");
tableViewer.refresh();
}
public Object getSelection() {
TableItem[] selection = tableViewer.getTable().getSelection();
if (selection.length == 0) {
return null;
}
return selection[0].getData();
}
public Text getTxtHint() {
return txtHint;
}
public abstract IContentProvider getContentProvider();
@Override
public ValueHolder getSelectedValue() {
// TODO Auto-generated method stub
return null;
}
}
| 4,711 | 0.694545 | 0.683719 | 150 | 29.406666 | 25.432812 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false | 15 |
22a729bb9f4bbe2ef3efd2026c2a6ff98635ff2e | 18,631,568,184,259 | 380b8e3ee1c4b753e2c94b58d8f0b05ad0abd534 | /tutorial-java-basic/src/main/java/com/example/javabasic/sample/exception/multilevel/CatchException1.java | bab1156606b0f243029ee9e8fd0403c8beb4e938 | [
"Apache-2.0"
]
| permissive | chenpenghui93/tutorial | https://github.com/chenpenghui93/tutorial | 836048f02bfaae78b0eb93c1b7039dc4cc416dcd | a75700dca0a62ee68816d4ea51ba0d77841e10de | refs/heads/main | 2023-08-22T12:05:03.631000 | 2021-09-25T13:10:46 | 2021-09-25T13:10:46 | 356,541,517 | 0 | 0 | Apache-2.0 | false | 2021-04-10T10:31:38 | 2021-04-10T10:02:49 | 2021-04-10T10:03:01 | 2021-04-10T10:31:37 | 0 | 0 | 0 | 0 | null | false | false | package com.example.javabasic.sample.exception.multilevel;
/**
* @author: cph
* @date: 2021/9/2 12:10
*/
public class CatchException1 {
public static void main(String[] args) {
try {
try {
// 该异常被内层catch捕获
throw new ArrayIndexOutOfBoundsException();
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("内层发生异常ArrayIndexOutOfBoundsException " + e);
}
// 该异常被外层对应catch捕获
throw new ArithmeticException();
} catch (ArithmeticException e) {
System.out.println("外层发生异常ArithmeticException " + e);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("外层发生异常ArrayIndexOutOfBoundsException " + e);
}
}
}
| UTF-8 | Java | 866 | java | CatchException1.java | Java | [
{
"context": "asic.sample.exception.multilevel;\n\n/**\n * @author: cph\n * @date: 2021/9/2 12:10\n */\npublic class CatchEx",
"end": 79,
"score": 0.9996746778488159,
"start": 76,
"tag": "USERNAME",
"value": "cph"
}
]
| null | []
| package com.example.javabasic.sample.exception.multilevel;
/**
* @author: cph
* @date: 2021/9/2 12:10
*/
public class CatchException1 {
public static void main(String[] args) {
try {
try {
// 该异常被内层catch捕获
throw new ArrayIndexOutOfBoundsException();
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("内层发生异常ArrayIndexOutOfBoundsException " + e);
}
// 该异常被外层对应catch捕获
throw new ArithmeticException();
} catch (ArithmeticException e) {
System.out.println("外层发生异常ArithmeticException " + e);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("外层发生异常ArrayIndexOutOfBoundsException " + e);
}
}
}
| 866 | 0.596977 | 0.583123 | 24 | 32.083332 | 24.419794 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 15 |
0f98de2772dc2d2cc418c4a245a293cc642fa24c | 18,631,568,183,887 | 68a706fa2034763d1ec28aa314e7744975974a65 | /src/main/java/com/company/transportmanagementadmin/configs/DataSourceConfig.java | d9340cdc28d3de25690c61882ae5c0af09e0d79a | []
| no_license | deepaksureshs/transport-management-admin | https://github.com/deepaksureshs/transport-management-admin | cc878d92b73dbc197516ba0f7f31132a3085140b | d3ab4ec5ff25e7e3f083e4760d5a9fafe43cc2a8 | refs/heads/main | 2023-04-29T07:03:30.885000 | 2021-05-23T07:19:33 | 2021-05-23T07:19:33 | 369,552,632 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company.transportmanagementadmin.configs;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@Configuration
public class DataSourceConfig {
@Value("${datasource.url}")
private String url;
@Value("${datasource.username}")
private String userName;
@Value("${datasource.password}")
private String password;
@Primary
@Bean(name = "dataSource")
public DriverManagerDataSource setdDataSource() {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setUrl(url);
driverManagerDataSource.setUsername(userName);
driverManagerDataSource.setPassword(password);
return driverManagerDataSource;
}
@Primary
@Bean(name = "namedParameterJdbcTemplate")
public NamedParameterJdbcTemplate setNamedParameterJdbcTemplate(DriverManagerDataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
}
| UTF-8 | Java | 1,211 | java | DataSourceConfig.java | Java | [
{
"context": "etUrl(url);\n\t\tdriverManagerDataSource.setUsername(userName);\n\t\tdriverManagerDataSource.setPassword(password)",
"end": 905,
"score": 0.9988664388656616,
"start": 897,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "(userName);\n\t\tdriverManagerDataSource.setPassword(password);\n\t\treturn driverManagerDataSource;\n\t}\n\n\t@Primary",
"end": 954,
"score": 0.9993728995323181,
"start": 946,
"tag": "PASSWORD",
"value": "password"
}
]
| null | []
| package com.company.transportmanagementadmin.configs;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@Configuration
public class DataSourceConfig {
@Value("${datasource.url}")
private String url;
@Value("${datasource.username}")
private String userName;
@Value("${datasource.password}")
private String password;
@Primary
@Bean(name = "dataSource")
public DriverManagerDataSource setdDataSource() {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setUrl(url);
driverManagerDataSource.setUsername(userName);
driverManagerDataSource.setPassword(<PASSWORD>);
return driverManagerDataSource;
}
@Primary
@Bean(name = "namedParameterJdbcTemplate")
public NamedParameterJdbcTemplate setNamedParameterJdbcTemplate(DriverManagerDataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
}
| 1,213 | 0.827415 | 0.827415 | 38 | 30.868422 | 26.747524 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.105263 | false | false | 15 |
560228f73378ea45a326d3d6497ab849d3be2106 | 36,335,423,348,754 | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /java/elasticsearch/2015/4/PeriodThrottler.java | 9a2aa761433c23b99936360c683dcb077410963a | []
| no_license | rosoareslv/SED99 | https://github.com/rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703000 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | false | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | 2020-11-24T20:46:14 | 2020-11-24T20:56:17 | 744,608 | 0 | 0 | 0 | null | false | false | /*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.watcher.throttle;
import org.elasticsearch.watcher.watch.Watch;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
import org.elasticsearch.watcher.support.clock.Clock;
import org.elasticsearch.common.joda.time.PeriodType;
import org.elasticsearch.common.unit.TimeValue;
/**
*
*/
public class PeriodThrottler implements Throttler {
private final TimeValue period;
private final PeriodType periodType;
private final Clock clock;
public PeriodThrottler(Clock clock, TimeValue period) {
this(clock, period, PeriodType.minutes());
}
public PeriodThrottler(Clock clock, TimeValue period, PeriodType periodType) {
this.period = period;
this.periodType = periodType;
this.clock = clock;
}
public TimeValue interval() {
return period;
}
@Override
public Result throttle(WatchExecutionContext ctx) {
Watch.Status status = ctx.watch().status();
if (status.lastExecuted() != null) {
TimeValue timeElapsed = clock.timeElapsedSince(status.lastExecuted());
if (timeElapsed.getMillis() <= period.getMillis()) {
return Result.throttle("throttling interval is set to [" + period.format(periodType) +
"] but time elapsed since last execution is [" + timeElapsed.format(periodType) + "]");
}
}
return Result.NO;
}
}
| UTF-8 | Java | 1,685 | java | PeriodThrottler.java | Java | []
| null | []
| /*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.watcher.throttle;
import org.elasticsearch.watcher.watch.Watch;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
import org.elasticsearch.watcher.support.clock.Clock;
import org.elasticsearch.common.joda.time.PeriodType;
import org.elasticsearch.common.unit.TimeValue;
/**
*
*/
public class PeriodThrottler implements Throttler {
private final TimeValue period;
private final PeriodType periodType;
private final Clock clock;
public PeriodThrottler(Clock clock, TimeValue period) {
this(clock, period, PeriodType.minutes());
}
public PeriodThrottler(Clock clock, TimeValue period, PeriodType periodType) {
this.period = period;
this.periodType = periodType;
this.clock = clock;
}
public TimeValue interval() {
return period;
}
@Override
public Result throttle(WatchExecutionContext ctx) {
Watch.Status status = ctx.watch().status();
if (status.lastExecuted() != null) {
TimeValue timeElapsed = clock.timeElapsedSince(status.lastExecuted());
if (timeElapsed.getMillis() <= period.getMillis()) {
return Result.throttle("throttling interval is set to [" + period.format(periodType) +
"] but time elapsed since last execution is [" + timeElapsed.format(periodType) + "]");
}
}
return Result.NO;
}
}
| 1,685 | 0.68724 | 0.68724 | 49 | 33.387756 | 30.332724 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.489796 | false | false | 15 |
07c15282dbc9c0c2b92924db8307fd80cbd38dde | 3,118,146,310,408 | 0b47c44e9f860cb820e1db22420b9359ddf885fc | /Week_07/G20200343030592/LeetCode_1122_592.java | d18b71fa0184ad45f8a1cdd3fe10f8aab63476f0 | []
| no_license | maxminute/algorithm006-class02 | https://github.com/maxminute/algorithm006-class02 | f71f9e8d2f59b1f7bbde434182a29c09792795d2 | 320d978f3a18751ebbac0c2c9a45462cdcc4cbc6 | refs/heads/master | 2021-01-02T03:17:20.549000 | 2020-04-05T14:54:22 | 2020-04-05T14:54:22 | 239,468,160 | 0 | 2 | null | true | 2020-04-05T14:54:23 | 2020-02-10T09:01:46 | 2020-04-05T14:53:34 | 2020-04-05T14:54:22 | 10,215 | 0 | 0 | 0 | Java | false | false | package com.gsf.geekbang_demo.arithmetic.leetCode.week07;
import java.util.Arrays;
/**
* 1122. 数组的相对排序
*/
public class Demo1122 {
public int[] relativeSortArray(int[] arr1, int[] arr2) {
int k = 0;
for (int i = 0; i < arr2.length; i++) {
for (int j = 0; j < arr1.length; j++) {
if (arr1[j] == arr2[i]) {
int temp = arr1[k]; arr1[k++] = arr1[j]; arr1[j] = temp;
}
}
}
if (k != arr1.length - 1) {
insertionSort(arr1, k);
}
return arr1;
}
private void insertionSort(int[] arr1, int k) {
for (int i = k + 1; i < arr1.length; i++) {
int value = arr1[i];
int j = i - 1;
for (; j >= k; j--) {
if (arr1[j] > value) {
arr1[j + 1] = arr1[j];
} else {
break;
}
}
arr1[j + 1] = value;
}
}
public static void main(String[] args) {
System.err.println(Arrays.toString(new Demo1122().relativeSortArray(new int[]{26,21,11,20,50,34,1,18}, new int[]{21,11,26,20})));
}
}
| UTF-8 | Java | 1,205 | java | LeetCode_1122_592.java | Java | []
| null | []
| package com.gsf.geekbang_demo.arithmetic.leetCode.week07;
import java.util.Arrays;
/**
* 1122. 数组的相对排序
*/
public class Demo1122 {
public int[] relativeSortArray(int[] arr1, int[] arr2) {
int k = 0;
for (int i = 0; i < arr2.length; i++) {
for (int j = 0; j < arr1.length; j++) {
if (arr1[j] == arr2[i]) {
int temp = arr1[k]; arr1[k++] = arr1[j]; arr1[j] = temp;
}
}
}
if (k != arr1.length - 1) {
insertionSort(arr1, k);
}
return arr1;
}
private void insertionSort(int[] arr1, int k) {
for (int i = k + 1; i < arr1.length; i++) {
int value = arr1[i];
int j = i - 1;
for (; j >= k; j--) {
if (arr1[j] > value) {
arr1[j + 1] = arr1[j];
} else {
break;
}
}
arr1[j + 1] = value;
}
}
public static void main(String[] args) {
System.err.println(Arrays.toString(new Demo1122().relativeSortArray(new int[]{26,21,11,20,50,34,1,18}, new int[]{21,11,26,20})));
}
}
| 1,205 | 0.433249 | 0.378673 | 43 | 26.697674 | 25.715378 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.837209 | false | false | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.