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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
91b40b1accc3fe91434c01c0fdf4e62fc044b7dc | 30,863,635,031,817 | 1415496f94592ba4412407b71dc18722598163dd | /doc/jitsi-bundles-dex/sources/org/jivesoftware/smack/provider/PrivacyProvider.java | cda69a94982a9ad0a7974a2775b8f25587e13c64 | [
"Apache-2.0"
] | permissive | lhzheng880828/VOIPCall | https://github.com/lhzheng880828/VOIPCall | ad534535869c47b5fc17405b154bdc651b52651b | a7ba25debd4bd2086bae2a48306d28c614ce0d4a | refs/heads/master | 2021-07-04T17:25:21.953000 | 2020-09-29T07:29:42 | 2020-09-29T07:29:42 | 183,576,020 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.jivesoftware.smack.provider;
import java.util.ArrayList;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ParameterPacketExtension;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingleinfo.JingleInfoQueryIQ;
import org.jitsi.org.xmlpull.v1.XmlPullParser;
import org.jivesoftware.smack.packet.DefaultPacketExtension;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Privacy;
import org.jivesoftware.smack.packet.PrivacyItem;
public class PrivacyProvider implements IQProvider {
public IQ parseIQ(XmlPullParser parser) throws Exception {
Privacy privacy = new Privacy();
privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace()));
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("active")) {
String activeName = parser.getAttributeValue("", "name");
if (activeName == null) {
privacy.setDeclineActiveList(true);
} else {
privacy.setActiveName(activeName);
}
} else if (parser.getName().equals("default")) {
String defaultName = parser.getAttributeValue("", "name");
if (defaultName == null) {
privacy.setDeclineDefaultList(true);
} else {
privacy.setDefaultName(defaultName);
}
} else if (parser.getName().equals("list")) {
parseList(parser, privacy);
}
} else if (eventType == 3 && parser.getName().equals(JingleInfoQueryIQ.ELEMENT_NAME)) {
done = true;
}
}
return privacy;
}
public void parseList(XmlPullParser parser, Privacy privacy) throws Exception {
boolean done = false;
String listName = parser.getAttributeValue("", "name");
ArrayList<PrivacyItem> items = new ArrayList();
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("item")) {
items.add(parseItem(parser));
}
} else if (eventType == 3 && parser.getName().equals("list")) {
done = true;
}
}
privacy.setPrivacyList(listName, items);
}
public PrivacyItem parseItem(XmlPullParser parser) throws Exception {
boolean done = false;
String actionValue = parser.getAttributeValue("", "action");
String orderValue = parser.getAttributeValue("", "order");
String type = parser.getAttributeValue("", "type");
boolean allow = true;
if ("allow".equalsIgnoreCase(actionValue)) {
allow = true;
} else if ("deny".equalsIgnoreCase(actionValue)) {
allow = false;
}
PrivacyItem item = new PrivacyItem(type, allow, Integer.parseInt(orderValue));
item.setValue(parser.getAttributeValue("", ParameterPacketExtension.VALUE_ATTR_NAME));
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("iq")) {
item.setFilterIQ(true);
}
if (parser.getName().equals("message")) {
item.setFilterMessage(true);
}
if (parser.getName().equals("presence-in")) {
item.setFilterPresence_in(true);
}
if (parser.getName().equals("presence-out")) {
item.setFilterPresence_out(true);
}
} else if (eventType == 3 && parser.getName().equals("item")) {
done = true;
}
}
return item;
}
}
| UTF-8 | Java | 4,020 | java | PrivacyProvider.java | Java | [] | null | [] | package org.jivesoftware.smack.provider;
import java.util.ArrayList;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ParameterPacketExtension;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingleinfo.JingleInfoQueryIQ;
import org.jitsi.org.xmlpull.v1.XmlPullParser;
import org.jivesoftware.smack.packet.DefaultPacketExtension;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Privacy;
import org.jivesoftware.smack.packet.PrivacyItem;
public class PrivacyProvider implements IQProvider {
public IQ parseIQ(XmlPullParser parser) throws Exception {
Privacy privacy = new Privacy();
privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace()));
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("active")) {
String activeName = parser.getAttributeValue("", "name");
if (activeName == null) {
privacy.setDeclineActiveList(true);
} else {
privacy.setActiveName(activeName);
}
} else if (parser.getName().equals("default")) {
String defaultName = parser.getAttributeValue("", "name");
if (defaultName == null) {
privacy.setDeclineDefaultList(true);
} else {
privacy.setDefaultName(defaultName);
}
} else if (parser.getName().equals("list")) {
parseList(parser, privacy);
}
} else if (eventType == 3 && parser.getName().equals(JingleInfoQueryIQ.ELEMENT_NAME)) {
done = true;
}
}
return privacy;
}
public void parseList(XmlPullParser parser, Privacy privacy) throws Exception {
boolean done = false;
String listName = parser.getAttributeValue("", "name");
ArrayList<PrivacyItem> items = new ArrayList();
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("item")) {
items.add(parseItem(parser));
}
} else if (eventType == 3 && parser.getName().equals("list")) {
done = true;
}
}
privacy.setPrivacyList(listName, items);
}
public PrivacyItem parseItem(XmlPullParser parser) throws Exception {
boolean done = false;
String actionValue = parser.getAttributeValue("", "action");
String orderValue = parser.getAttributeValue("", "order");
String type = parser.getAttributeValue("", "type");
boolean allow = true;
if ("allow".equalsIgnoreCase(actionValue)) {
allow = true;
} else if ("deny".equalsIgnoreCase(actionValue)) {
allow = false;
}
PrivacyItem item = new PrivacyItem(type, allow, Integer.parseInt(orderValue));
item.setValue(parser.getAttributeValue("", ParameterPacketExtension.VALUE_ATTR_NAME));
while (!done) {
int eventType = parser.next();
if (eventType == 2) {
if (parser.getName().equals("iq")) {
item.setFilterIQ(true);
}
if (parser.getName().equals("message")) {
item.setFilterMessage(true);
}
if (parser.getName().equals("presence-in")) {
item.setFilterPresence_in(true);
}
if (parser.getName().equals("presence-out")) {
item.setFilterPresence_out(true);
}
} else if (eventType == 3 && parser.getName().equals("item")) {
done = true;
}
}
return item;
}
}
| 4,020 | 0.553483 | 0.551741 | 95 | 41.315788 | 25.189079 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.610526 | false | false | 13 |
22df1e0e5f0a8e7b37f4dd7d66384bc3e2b7d176 | 8,272,107,043,242 | 636275575dac17dfbc7c3672c333d9405950589c | /src/main/java/org/mitallast/queue/raft/resource/NodeInfo.java | 600021ed8c968f9ec28309c31b7d5bd67bac31c3 | [
"MIT"
] | permissive | manfredma/netty-queue | https://github.com/manfredma/netty-queue | b6af7126e9ad3a5b1da6e41871ec3aa50078d662 | 0945d7fc352d70ef4c477fba128d0c0a72b690e4 | refs/heads/master | 2021-01-24T04:43:11.762000 | 2015-09-08T09:18:22 | 2015-09-08T09:18:22 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.mitallast.queue.raft.resource;
public interface NodeInfo {
long version();
long timestamp();
}
| UTF-8 | Java | 118 | java | NodeInfo.java | Java | [] | null | [] | package org.mitallast.queue.raft.resource;
public interface NodeInfo {
long version();
long timestamp();
}
| 118 | 0.70339 | 0.70339 | 8 | 13.75 | 14.931091 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 13 |
51a51dbaa39f4dd460a338f21a4bd2c082ca7f42 | 16,183,436,819,672 | 4f5a3034d91b71837104ceb6512d635ff7e9ae34 | /sortArraybyParity.java | 60ec3889bac3fb61c96bf39492b6f5a77388c97a | [] | no_license | Sowmyashish/leetcode-playground | https://github.com/Sowmyashish/leetcode-playground | 48d2636d24dc723d7fecc312b18b8e171c40e43a | fb28bd78ba182235e8cf9bfaf8f8c466cd31dab0 | refs/heads/master | 2020-04-04T22:58:01.084000 | 2019-08-01T00:40:30 | 2019-08-01T00:40:30 | 156,341,132 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package general;
/**
* Created by ashishsowmya on 10/4/18.
*/
public class sortArraybyParity {
public int[] sort(int[] A)
{
int[] B = new int[A.length];
int even=0;
int odd = A.length-1;
for(int i=0;i<A.length;i++)
{
if(A[i]%2 == 0)
{
B[even] = A[i];
even++;
}
else
{
B[odd] = A[i];
odd--;
}
}
return B;
}
public static void main(String args[])
{
sortArraybyParity obj = new sortArraybyParity();
int[] c = {1,2,4,3,7,5,6};
int[] D = obj.sort(c);
for(int i=0;i<D.length;i++)
{
System.out.println(D[i]);
}
}
}
| UTF-8 | Java | 790 | java | sortArraybyParity.java | Java | [
{
"context": "package general;\n\n/**\n * Created by ashishsowmya on 10/4/18.\n */\npublic class sortArraybyParity {\n",
"end": 48,
"score": 0.5777239203453064,
"start": 36,
"tag": "USERNAME",
"value": "ashishsowmya"
}
] | null | [] | package general;
/**
* Created by ashishsowmya on 10/4/18.
*/
public class sortArraybyParity {
public int[] sort(int[] A)
{
int[] B = new int[A.length];
int even=0;
int odd = A.length-1;
for(int i=0;i<A.length;i++)
{
if(A[i]%2 == 0)
{
B[even] = A[i];
even++;
}
else
{
B[odd] = A[i];
odd--;
}
}
return B;
}
public static void main(String args[])
{
sortArraybyParity obj = new sortArraybyParity();
int[] c = {1,2,4,3,7,5,6};
int[] D = obj.sort(c);
for(int i=0;i<D.length;i++)
{
System.out.println(D[i]);
}
}
}
| 790 | 0.389873 | 0.367089 | 40 | 18.75 | 14.231567 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575 | false | false | 13 |
3343e34faea96420cec0412578546c100eb29f66 | 7,997,229,123,502 | 6f624b0c3bde6035b8e5c71de9496c01680e7807 | /src/test/java/week11/d01/PairFinderTest.java | ecc340ccfb7edef7d5ebaa4d564721b555f9c34e | [] | no_license | jfulop99/training-solutions | https://github.com/jfulop99/training-solutions | 6c96e20169c666a2dbaad8c8fffa968a5dea2472 | 16aec578fd6954962f1772c9a75ecbbe87e042b9 | refs/heads/master | 2023-04-13T19:33:15.903000 | 2021-04-24T01:16:37 | 2021-04-24T01:16:37 | 308,003,982 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package week11.d01;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PairFinderTest {
@Test
void testPairs() {
PairFinder pairFinder = new PairFinder();
assertEquals(3, pairFinder.findPairs(new int[]{7, 1, 5, 7, 3, 3, 9, 7, 6, 7}));
assertEquals(3, pairFinder.findPairs2(new int[]{7, 1, 5, 7, 3, 3, 9, 7, 6, 7}));
}
} | UTF-8 | Java | 402 | java | PairFinderTest.java | Java | [] | null | [] | package week11.d01;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PairFinderTest {
@Test
void testPairs() {
PairFinder pairFinder = new PairFinder();
assertEquals(3, pairFinder.findPairs(new int[]{7, 1, 5, 7, 3, 3, 9, 7, 6, 7}));
assertEquals(3, pairFinder.findPairs2(new int[]{7, 1, 5, 7, 3, 3, 9, 7, 6, 7}));
}
} | 402 | 0.621891 | 0.554726 | 18 | 21.388889 | 28.355165 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.444444 | false | false | 13 |
73526b26175286f8e0102c9fdf58f74cf60434dc | 29,764,123,421,187 | ed0731e2b30e5f5ab019ebb4952bdfae33d13835 | /Excepsion/ex2/Main.java | 30d52979ae80360b7ddbde353ca36e9768f302ae | [] | no_license | Screem2020/git-course | https://github.com/Screem2020/git-course | be002997537f0e535aadd1084dbc64838b24107c | 40d3ee19080b9adb9d0b81ad7ffc72a4d4458960 | refs/heads/master | 2023-08-26T22:07:41.950000 | 2022-09-29T14:07:12 | 2022-09-29T14:07:12 | 372,443,843 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Excepsion.ex2;
import java.util.Scanner;
public class Main {
//3. Пользователь вводит с консоли строку вида: Иван, Java разработчик, Росси, Oracle
//Программа выводит на консоль информацию о пользователе:
//Имя: Иван
//Должность: Java разработчик
//Страна: Россия
//Компания: Oracle
public static void main(String[] args) {
method();
}
public static void method() {
Scanner scn = new Scanner(System.in);
System.out.println("Введите свои данные:");
String line = scn.nextLine();
String[] split = line.split(",");
for (int i = 0; i < split.length; i++) {
split[i] = split[i].trim();
}
String name = split[0];
String position = split[1];
String country = split[2];
String company = split[3];
System.out.println("Имя: " + name);
System.out.println("Должность: " + position);
System.out.println("Страна: " + country);
System.out.println("Компания: " + company);
}
}
// public static void method(String text) {
// char[] chars = text.toCharArray();
// int i = 0;
// while (i < chars.length){
// System.out.print(chars[i++]);
// if (chars[i] == ',') {
// System.out.print("\n");
// }
// }
// }
| UTF-8 | Java | 1,621 | java | Main.java | Java | [
{
"context": " //3. Пользователь вводит с консоли строку вида: Иван, Java разработчик, Росси, Oracle\n //Программа ",
"end": 127,
"score": 0.9997046589851379,
"start": 123,
"tag": "NAME",
"value": "Иван"
},
{
"context": "т на консоль информацию о пользователе:\n //Имя: Иван\n... | null | [] | package Excepsion.ex2;
import java.util.Scanner;
public class Main {
//3. Пользователь вводит с консоли строку вида: Иван, Java разработчик, Росси, Oracle
//Программа выводит на консоль информацию о пользователе:
//Имя: Иван
//Должность: Java разработчик
//Страна: Россия
//Компания: Oracle
public static void main(String[] args) {
method();
}
public static void method() {
Scanner scn = new Scanner(System.in);
System.out.println("Введите свои данные:");
String line = scn.nextLine();
String[] split = line.split(",");
for (int i = 0; i < split.length; i++) {
split[i] = split[i].trim();
}
String name = split[0];
String position = split[1];
String country = split[2];
String company = split[3];
System.out.println("Имя: " + name);
System.out.println("Должность: " + position);
System.out.println("Страна: " + country);
System.out.println("Компания: " + company);
}
}
// public static void method(String text) {
// char[] chars = text.toCharArray();
// int i = 0;
// while (i < chars.length){
// System.out.print(chars[i++]);
// if (chars[i] == ',') {
// System.out.print("\n");
// }
// }
// }
| 1,621 | 0.515067 | 0.50946 | 47 | 29.361702 | 20.684484 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.574468 | false | false | 13 |
98eb7bd1fddbe8fdc54d8dd145d9fadd10a5e0d3 | 29,764,123,421,888 | c2fa402fd6575a5f4eb6037cd67c4605a383afd1 | /Provider/src/main/java/com/pdsu/csc/dao/FileDownloadMapper.java | 902995f0c03f6d005c712c7daab217ce00e90c4f | [] | no_license | pyb1430501241/pdsu_csc_cloud | https://github.com/pyb1430501241/pdsu_csc_cloud | a6d7b7e23d93582fa72901f6b87608a8bf92d2d8 | 1d746b5e4406e5010dc1e6253732784ccd9f4d85 | refs/heads/master | 2023-05-31T23:58:44.063000 | 2021-06-03T06:24:57 | 2021-06-03T06:24:57 | 312,222,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pdsu.csc.dao;
import java.util.List;
import com.pdsu.csc.bean.FileDownload;
import com.pdsu.csc.bean.FileDownloadExample;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface FileDownloadMapper {
long countByExample(FileDownloadExample example);
int deleteByExample(FileDownloadExample example);
int deleteByPrimaryKey(Integer id);
int insert(FileDownload record);
int insertSelective(FileDownload record);
List<FileDownload> selectByExample(FileDownloadExample example);
FileDownload selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") FileDownload record, @Param("example") FileDownloadExample example);
int updateByExample(@Param("record") FileDownload record, @Param("example") FileDownloadExample example);
int updateByPrimaryKeySelective(FileDownload record);
int updateByPrimaryKey(FileDownload record);
} | UTF-8 | Java | 977 | java | FileDownloadMapper.java | Java | [] | null | [] | package com.pdsu.csc.dao;
import java.util.List;
import com.pdsu.csc.bean.FileDownload;
import com.pdsu.csc.bean.FileDownloadExample;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface FileDownloadMapper {
long countByExample(FileDownloadExample example);
int deleteByExample(FileDownloadExample example);
int deleteByPrimaryKey(Integer id);
int insert(FileDownload record);
int insertSelective(FileDownload record);
List<FileDownload> selectByExample(FileDownloadExample example);
FileDownload selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") FileDownload record, @Param("example") FileDownloadExample example);
int updateByExample(@Param("record") FileDownload record, @Param("example") FileDownloadExample example);
int updateByPrimaryKeySelective(FileDownload record);
int updateByPrimaryKey(FileDownload record);
} | 977 | 0.794268 | 0.794268 | 33 | 28.636364 | 31.141727 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575758 | false | false | 13 |
897be506ae81e1b39c96241c32c8ffa99161829e | 32,109,175,565,765 | 742dfb22206598d0c34b0852fa517ec145b5f3b9 | /Sources/tekwave-portlets/src/main/java/com/tekwave/dao/impl/TcDeviceTypeDaoImpl.java | 92a36b3b5cfccf0ba6a028ea70985c7d661b30ad | [] | no_license | mccrindlealex/Temp-Transfer | https://github.com/mccrindlealex/Temp-Transfer | 962f1f6fc6fb6877aae0b0de055a7d7d68fc97a4 | fe7b6c870b96cdbca1c2e6049a65a89ce08bbfb4 | refs/heads/master | 2016-07-26T11:37:00.398000 | 2015-07-26T21:34:08 | 2015-07-26T21:34:08 | 39,733,533 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tekwave.dao.impl;
import com.tekwave.dao.TcDeviceTypeDao;
import com.tekwave.entity.tekcontrol.TcDeviceType;
import com.tekwave.util.DaoParametersHolder;
import org.hibernate.ejb.QueryHints;
import org.springframework.stereotype.Repository;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.util.List;
@Repository
public class TcDeviceTypeDaoImpl extends BaseDaoImpl<TcDeviceType> implements TcDeviceTypeDao {
@Override
public int count(DaoParametersHolder daoParametersHolder) {
return 0;
}
@Override
public List<TcDeviceType> load(int startIndex, int count, DaoParametersHolder daoParametersHolder) {
return null;
}
@Override
public List<TcDeviceType> getAll() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(TcDeviceType.class);
Root from = cq.from(TcDeviceType.class);
cq.select(from);
return (List<TcDeviceType>) getEm().createQuery(cq).setHint(QueryHints.HINT_CACHEABLE, true).getResultList();
}
}
| UTF-8 | Java | 1,157 | java | TcDeviceTypeDaoImpl.java | Java | [] | null | [] | package com.tekwave.dao.impl;
import com.tekwave.dao.TcDeviceTypeDao;
import com.tekwave.entity.tekcontrol.TcDeviceType;
import com.tekwave.util.DaoParametersHolder;
import org.hibernate.ejb.QueryHints;
import org.springframework.stereotype.Repository;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.util.List;
@Repository
public class TcDeviceTypeDaoImpl extends BaseDaoImpl<TcDeviceType> implements TcDeviceTypeDao {
@Override
public int count(DaoParametersHolder daoParametersHolder) {
return 0;
}
@Override
public List<TcDeviceType> load(int startIndex, int count, DaoParametersHolder daoParametersHolder) {
return null;
}
@Override
public List<TcDeviceType> getAll() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(TcDeviceType.class);
Root from = cq.from(TcDeviceType.class);
cq.select(from);
return (List<TcDeviceType>) getEm().createQuery(cq).setHint(QueryHints.HINT_CACHEABLE, true).getResultList();
}
}
| 1,157 | 0.753673 | 0.752809 | 36 | 31.111111 | 30.294643 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 13 |
17f1bc1fac1b740c8f2778fd95771269320152bb | 29,532,195,160,063 | 50246995c75ca7cfcf16a85c41b83fd7e99a34ae | /src/main/java/br/com/imasoft/rh/repository/PontoRepository.java | 52ef404f6e3e103477b67845401b613ddbff3679 | [] | no_license | brunocarneiro312/rh | https://github.com/brunocarneiro312/rh | 5bbcfb3e8963fcb3fd0b57d9db15d9759c4ee994 | e82df6717e381b5f6ff75e59d143f38e30cc8552 | refs/heads/master | 2023-01-11T12:55:47.439000 | 2020-11-05T00:59:58 | 2020-11-05T00:59:58 | 309,842,715 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.imasoft.rh.repository;
import br.com.imasoft.rh.model.Ponto;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PontoRepository extends JpaRepository<Ponto, Integer> {
}
| UTF-8 | Java | 216 | java | PontoRepository.java | Java | [] | null | [] | package br.com.imasoft.rh.repository;
import br.com.imasoft.rh.model.Ponto;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PontoRepository extends JpaRepository<Ponto, Integer> {
}
| 216 | 0.819444 | 0.819444 | 8 | 26 | 27.919527 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 13 |
99d92b05252e55e938c6931b088e4a8a0b6bb5b4 | 14,181,982,061,239 | d75952cd8f99826a6b7b7b59cafebb8e96db81b8 | /app/src/main/java/com/vaynefond/zhihudaily/base/widget/HeaderRecyclerViewAdapter.java | b1a94d15594f3050e33df513b876647503c77560 | [] | no_license | brycefond/ZhihuDaily | https://github.com/brycefond/ZhihuDaily | b446e410e3bebedc0347dae94e10c5c4bd83c438 | 7f930b377b067bfd709eac43b1374e0009f3555e | refs/heads/master | 2020-04-09T20:36:09.306000 | 2018-12-06T15:52:31 | 2018-12-06T15:52:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vaynefond.zhihudaily.base.widget;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.vaynefond.zhihudaily.base.adapter.BaseViewHolder;
class HeaderRecyclerViewAdapter<VH> extends WrapperRecyclerViewAdapter {
private RecyclerView.Adapter mAdapter;
private View mEmptyView;
private SparseArray<ViewInfo> mHeaderViewInfos;
private SparseArray<ViewInfo> mFooterViewInfos;
private View mLoadMoreView;
public HeaderRecyclerViewAdapter(@NonNull RecyclerView.Adapter adapter, @NonNull View emptyView,
@NonNull SparseArray<ViewInfo> headerViewInfos, @NonNull SparseArray<ViewInfo> footerViewInfos,
@NonNull View loadMoreView) {
mAdapter = adapter;
mEmptyView = emptyView;
mHeaderViewInfos = headerViewInfos;
mFooterViewInfos = footerViewInfos;
mLoadMoreView = loadMoreView;
}
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewAttachedToWindow(holder);
int viewType = getItemViewType(holder.getLayoutPosition());
if (isDecorType(viewType)) {
ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
if (params instanceof StaggeredGridLayoutManager.LayoutParams) {
((StaggeredGridLayoutManager.LayoutParams) params).setFullSpan(true);
}
}
if (mAdapter != null) {
mAdapter.onViewAttachedToWindow(holder);
}
}
private boolean isDecorType(int type) {
return isEmtpyView(type) || isHeader(type) ||
isFooter(type) || isLoadMoreView(type);
}
private boolean isEmtpyView(int type) {
return type == AdapterType.TYPE_EMPTY_VIEW;
}
private boolean isHeader(int type) {
return type >= AdapterType.TYPE_HEADER_BASE &&
type < AdapterType.TYPE_HEADER_BASE + mHeaderViewInfos.size();
}
private boolean isFooter(int type) {
return type <= AdapterType.TYPE_FOOTER_BASE &&
type > AdapterType.TYPE_FOOTER_BASE - mFooterViewInfos.size();
}
private boolean isLoadMoreView(int type) {
return type == AdapterType.TYPE_LOAD_MORE;
}
public int getHeaderCount() {
return mHeaderViewInfos.size();
}
public int getFooterCount() {
return mFooterViewInfos.size();
}
private View getHeaderView(int type) {
return mHeaderViewInfos.get(type).view;
}
private View getFooterView(int type) {
return mFooterViewInfos.get(type).view;
}
public boolean removeHeader(@NonNull View view) {
for (int i = 0; i < mHeaderViewInfos.size(); i++) {
final View header = mHeaderViewInfos.valueAt(i).view;
if (view == header) {
mHeaderViewInfos.removeAt(i);
return true;
}
}
return false;
}
public boolean removeFooter(@NonNull View view) {
for (int i = 0; i < mFooterViewInfos.size(); i++) {
final View footer = mFooterViewInfos.valueAt(i).view;
if (view == footer) {
mFooterViewInfos.removeAt(i);
return true;
}
}
return false;
}
@Override
RecyclerView.Adapter getWrappedAdapter() {
return mAdapter;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (isEmtpyView(viewType)) {
return BaseViewHolder.create(mEmptyView);
} else if (isHeader(viewType)) {
return BaseViewHolder.create(getHeaderView(viewType));
} else if (isFooter(viewType)) {
return BaseViewHolder.create(getFooterView(viewType));
} else if (isLoadMoreView(viewType)) {
return BaseViewHolder.create(mLoadMoreView);
}
return mAdapter.onCreateViewHolder(parent, viewType);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
final int type = getItemViewType(position);
if (isDecorType(type)) {
return;
}
int headerCount = getHeaderCount();
final int adjPosition = position - headerCount;
if (mAdapter != null) {
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
mAdapter.onBindViewHolder(holder, adjPosition);
}
}
}
@Override
public int getItemViewType(int position) {
int headerCount = getHeaderCount();
int footerCount = getFooterCount();
if (mAdapter == null || mAdapter.getItemCount() == 0) {
if (headerCount == 0 && footerCount == 0) {
return AdapterType.TYPE_EMPTY_VIEW;
}
}
if (position < headerCount) {
return AdapterType.TYPE_HEADER_BASE + position;
}
final int adjPosition = position - headerCount;
if (mAdapter != null) {
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemViewType(adjPosition);
}
}
if (position == getItemCount() - 1) {
return AdapterType.TYPE_LOAD_MORE;
}
return AdapterType.TYPE_FOOTER_BASE - (getItemCount() - position - 2);
}
@Override
public int getItemCount() {
int itemCount = getHeaderCount() + getFooterCount() + 1;
if (mAdapter != null) {
itemCount += mAdapter.getItemCount();
}
if (itemCount == 0) {
itemCount = 1;
}
return itemCount;
}
@Override
public long getItemId(int position) {
int headerCount = getHeaderCount();
if (mAdapter != null && position > headerCount) {
int adjPosition = position - headerCount;
if (hasStableIds()) {
adjPosition--;
}
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemId(adjPosition);
}
}
return -1;
}
@Override
public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewDetachedFromWindow(holder);
if (mAdapter != null) {
mAdapter.onViewDetachedFromWindow(holder);
}
}
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
if (mAdapter != null) {
mAdapter.onDetachedFromRecyclerView(recyclerView);
}
}
}
| UTF-8 | Java | 6,973 | java | HeaderRecyclerViewAdapter.java | Java | [] | null | [] | package com.vaynefond.zhihudaily.base.widget;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.vaynefond.zhihudaily.base.adapter.BaseViewHolder;
class HeaderRecyclerViewAdapter<VH> extends WrapperRecyclerViewAdapter {
private RecyclerView.Adapter mAdapter;
private View mEmptyView;
private SparseArray<ViewInfo> mHeaderViewInfos;
private SparseArray<ViewInfo> mFooterViewInfos;
private View mLoadMoreView;
public HeaderRecyclerViewAdapter(@NonNull RecyclerView.Adapter adapter, @NonNull View emptyView,
@NonNull SparseArray<ViewInfo> headerViewInfos, @NonNull SparseArray<ViewInfo> footerViewInfos,
@NonNull View loadMoreView) {
mAdapter = adapter;
mEmptyView = emptyView;
mHeaderViewInfos = headerViewInfos;
mFooterViewInfos = footerViewInfos;
mLoadMoreView = loadMoreView;
}
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewAttachedToWindow(holder);
int viewType = getItemViewType(holder.getLayoutPosition());
if (isDecorType(viewType)) {
ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
if (params instanceof StaggeredGridLayoutManager.LayoutParams) {
((StaggeredGridLayoutManager.LayoutParams) params).setFullSpan(true);
}
}
if (mAdapter != null) {
mAdapter.onViewAttachedToWindow(holder);
}
}
private boolean isDecorType(int type) {
return isEmtpyView(type) || isHeader(type) ||
isFooter(type) || isLoadMoreView(type);
}
private boolean isEmtpyView(int type) {
return type == AdapterType.TYPE_EMPTY_VIEW;
}
private boolean isHeader(int type) {
return type >= AdapterType.TYPE_HEADER_BASE &&
type < AdapterType.TYPE_HEADER_BASE + mHeaderViewInfos.size();
}
private boolean isFooter(int type) {
return type <= AdapterType.TYPE_FOOTER_BASE &&
type > AdapterType.TYPE_FOOTER_BASE - mFooterViewInfos.size();
}
private boolean isLoadMoreView(int type) {
return type == AdapterType.TYPE_LOAD_MORE;
}
public int getHeaderCount() {
return mHeaderViewInfos.size();
}
public int getFooterCount() {
return mFooterViewInfos.size();
}
private View getHeaderView(int type) {
return mHeaderViewInfos.get(type).view;
}
private View getFooterView(int type) {
return mFooterViewInfos.get(type).view;
}
public boolean removeHeader(@NonNull View view) {
for (int i = 0; i < mHeaderViewInfos.size(); i++) {
final View header = mHeaderViewInfos.valueAt(i).view;
if (view == header) {
mHeaderViewInfos.removeAt(i);
return true;
}
}
return false;
}
public boolean removeFooter(@NonNull View view) {
for (int i = 0; i < mFooterViewInfos.size(); i++) {
final View footer = mFooterViewInfos.valueAt(i).view;
if (view == footer) {
mFooterViewInfos.removeAt(i);
return true;
}
}
return false;
}
@Override
RecyclerView.Adapter getWrappedAdapter() {
return mAdapter;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (isEmtpyView(viewType)) {
return BaseViewHolder.create(mEmptyView);
} else if (isHeader(viewType)) {
return BaseViewHolder.create(getHeaderView(viewType));
} else if (isFooter(viewType)) {
return BaseViewHolder.create(getFooterView(viewType));
} else if (isLoadMoreView(viewType)) {
return BaseViewHolder.create(mLoadMoreView);
}
return mAdapter.onCreateViewHolder(parent, viewType);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
final int type = getItemViewType(position);
if (isDecorType(type)) {
return;
}
int headerCount = getHeaderCount();
final int adjPosition = position - headerCount;
if (mAdapter != null) {
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
mAdapter.onBindViewHolder(holder, adjPosition);
}
}
}
@Override
public int getItemViewType(int position) {
int headerCount = getHeaderCount();
int footerCount = getFooterCount();
if (mAdapter == null || mAdapter.getItemCount() == 0) {
if (headerCount == 0 && footerCount == 0) {
return AdapterType.TYPE_EMPTY_VIEW;
}
}
if (position < headerCount) {
return AdapterType.TYPE_HEADER_BASE + position;
}
final int adjPosition = position - headerCount;
if (mAdapter != null) {
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemViewType(adjPosition);
}
}
if (position == getItemCount() - 1) {
return AdapterType.TYPE_LOAD_MORE;
}
return AdapterType.TYPE_FOOTER_BASE - (getItemCount() - position - 2);
}
@Override
public int getItemCount() {
int itemCount = getHeaderCount() + getFooterCount() + 1;
if (mAdapter != null) {
itemCount += mAdapter.getItemCount();
}
if (itemCount == 0) {
itemCount = 1;
}
return itemCount;
}
@Override
public long getItemId(int position) {
int headerCount = getHeaderCount();
if (mAdapter != null && position > headerCount) {
int adjPosition = position - headerCount;
if (hasStableIds()) {
adjPosition--;
}
int adapterCount = mAdapter.getItemCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemId(adjPosition);
}
}
return -1;
}
@Override
public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewDetachedFromWindow(holder);
if (mAdapter != null) {
mAdapter.onViewDetachedFromWindow(holder);
}
}
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
if (mAdapter != null) {
mAdapter.onDetachedFromRecyclerView(recyclerView);
}
}
}
| 6,973 | 0.61566 | 0.613796 | 224 | 30.129465 | 25.338358 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.424107 | false | false | 13 |
b96e7d5158a12267626d7ad8827ddee3241c7011 | 11,716,670,847,392 | 7a1c3e37b70220cc06300316786aee95a081cc6b | /src/test/java/biz/tugay/ctci/ch04/TreesAndGraphsTest.java | 357a70332b055fa8e512f2b7ca9502297bc4277c | [] | no_license | koraytugay/cracking-the-coding-interview | https://github.com/koraytugay/cracking-the-coding-interview | fce3e0caf55c0e0626e74ba78322cc7f264d81f0 | 52f3d312bbf6f1a018f7f2cc203683f7427dfc89 | refs/heads/master | 2021-07-15T04:43:00.095000 | 2021-07-09T01:41:50 | 2021-07-09T01:41:50 | 199,335,828 | 2 | 0 | null | false | 2019-08-11T18:41:51 | 2019-07-28T20:50:01 | 2019-08-11T11:54:44 | 2019-08-11T18:41:50 | 35 | 0 | 0 | 0 | Java | false | false | package biz.tugay.ctci.ch04;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.joining;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class TreesAndGraphsTest {
TreesAndGraphs treesAndGraphs = new TreesAndGraphs();
Node a, b, c, d, e, f, g;
@Before
public void before() {
a = new Node("0");
b = new Node("1");
c = new Node("2");
d = new Node("3");
e = new Node("4");
f = new Node("5");
g = new Node("6");
}
@Test
public void depthFirstSearch() {
sampleGraph();
assertThat(asString(treesAndGraphs.depthFirstSearch(a)), equalTo("013245"));
}
@Test
public void depthFirstSearch_Cyclic() {
a.children.add(b);
b.children.add(c);
c.children.add(d);
d.children.add(a);
assertThat(asString(treesAndGraphs.depthFirstSearch(a)), equalTo("0123"));
}
@Test
public void breathFirstSearch() {
sampleGraph();
assertThat(asString(treesAndGraphs.breadthFirstSearch(a)), equalTo("014532"));
}
@Test
public void breathFirstSearch_Linear() {
a.children.addAll(asList(b, c));
b.children.add(d);
c.children.add(d);
d.children.addAll(asList((e), f));
assertThat(asString(treesAndGraphs.breadthFirstSearch(a)), equalTo("012345"));
}
@Test
public void pathExists() {
sampleGraph();
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(d), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(c), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(f), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(b).contains(a), is(false));
assertThat(treesAndGraphs.breadthFirstSearch(c).contains(d), is(true));
}
@Test
public void minimalTreeSingleElement() {
Node node = treesAndGraphs.minimalTree(asList("a"));
assertThat(node.val, equalTo("a"));
assertThat(node.children.size(), is(0));
}
@Test
public void minimalTreeTwoElement() {
Node node = treesAndGraphs.minimalTree(asList("a", "b"));
assertThat(node.val, equalTo("b"));
assertThat(node.children.get(0).val, equalTo("a"));
assertThat(node.children.size(), is(1));
}
@Test
public void minimalTreeThreeElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c"));
assertThat(node.val, equalTo("b"));
assertThat(node.children.get(0).val, equalTo("a"));
assertThat(node.children.get(1).val, equalTo("c"));
}
@Test
public void minimalTreeFourElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c", "d"));
assertThat(node.val, equalTo("c"));
assertThat(node.children.get(0).val, equalTo("b"));
assertThat(node.children.get(1).val, equalTo("d"));
assertThat(node.children.get(0).children.get(0).val, equalTo("a"));
}
@Test
public void minimalTreeSevenElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c", "d", "e", "f", "g"));
assertThat(node.val, equalTo("d"));
assertThat(node.children.get(0).val, equalTo("b"));
assertThat(node.children.get(1).val, equalTo("f"));
assertThat(node.children.get(0).children.get(0).val, equalTo("a"));
assertThat(node.children.get(0).children.get(1).val, equalTo("c"));
assertThat(node.children.get(1).children.get(0).val, equalTo("e"));
assertThat(node.children.get(1).children.get(1).val, equalTo("g"));
}
@Test
public void listOfDepths() {
sampleBinaryTree();
List<List<Node>> listOfDepths = treesAndGraphs.listOfDepths(d);
assertThat(listOfDepths.size(), is(3));
assertThat(listOfDepths.get(0).size(), is(1));
assertThat(listOfDepths.get(1).size(), is(2));
assertThat(listOfDepths.get(2).size(), is(4));
}
@Test
public void checkBalanced() {
sampleBinaryTree();
assertThat(treesAndGraphs.checkBalanced(d), is(true));
}
@Test
public void checkBalanced_Unbalanced() {
d.children.add(b);
b.children.add(a);
assertThat(treesAndGraphs.checkBalanced(d), is(false));
}
@Test
public void isBinarySearchTree() {
sampleBinaryTree();
assertThat(treesAndGraphs.isBinarySearchTree(d), is(true));
}
@Test
public void isBinarySearchTreeLeftFalse() {
sampleBinaryTree();
a.val = "9";
assertThat(treesAndGraphs.isBinarySearchTree(d), is(false));
}
@Test
public void isBinarySearchTreeRightFalse() {
sampleBinaryTree();
g.val = "1";
assertThat(treesAndGraphs.isBinarySearchTree(d), is(false));
}
@Test
public void sumPaths1Node() {
assertThat(treesAndGraphs.sumPaths(b, 1), is(1L));
}
@Test
public void sumPaths1NodeNoSums() {
assertThat(treesAndGraphs.sumPaths(b, 2), is(0L));
}
@Test
public void sumPaths2Nodes() {
b.children.add(c);
assertThat(treesAndGraphs.sumPaths(b, 3), is(1L));
}
@Test
public void sumPaths2NodesNoSums() {
b.children.add(c);
assertThat(treesAndGraphs.sumPaths(b, 4), is(0L));
}
@Test
public void sumPaths3Nodes() {
Node d = new Node("2");
b.children.addAll(Arrays.asList(c, d));
assertThat(treesAndGraphs.sumPaths(b, 3), is(2L));
}
@Test
public void sumPathsBinaryTree() {
sampleBinaryTree();
a.val = b.val = c.val = d.val = e.val = f.val = g.val = "0";
d.val = "5";
b.val = "2";
a.val = "3";
c.val = "10";
f.val = "-2";
e.val = "12";
g.val = "7";
assertThat(treesAndGraphs.sumPaths(d, 10), is(4L));
}
@Test
public void isSubtreeSingleNode() {
Node t1 = new Node("a");
Node t2 = new Node("a");
assertThat(treesAndGraphs.isSubtree(t1, t2), is(true));
}
@Test
public void isSubtreeExactTrees() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, d), is(true));
}
@Test
public void isSubtreeLeftNodeIs() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, b), is(true));
}
@Test
public void isSubtreeRightNodeIs() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, f), is(true));
}
@Test
public void testStackOverflow() {
Node oneOne = new Node("1");
Node oneTwo = new Node("2");
Node oneThree = new Node("3");
Node oneFour = new Node("4");
Node twoOne = new Node("1");
Node twoTwo = new Node("2");
Node twoThree = new Node("3");
oneOne.children.add(oneTwo);
oneOne.children.add(oneThree);
oneThree.children.add(oneFour);
oneFour.children.add(null);
oneFour.children.add(twoOne);
twoOne.children.add(twoTwo);
twoTwo.children.add(twoThree);
Node subOne = new Node("1");
Node subTwo = new Node("2");
Node subThree = new Node("3");
subOne.children.add(subTwo);
subTwo.children.add(subThree);
System.out.println(treesAndGraphs.isSubtree(oneOne, subOne));
}
@Test
public void isSubtreeFalse() {
a = new Node("0");
b = new Node("1");
c = new Node("2");
d = new Node("0");
e = new Node("1");
f = new Node("3");
a.children.add(b);
b.children.add(c);
d.children.add(e);
e.children.add(f);
assertThat(treesAndGraphs.isSubtree(a, d), is(false));
}
@Test
public void isSubtreeFalseTricky() {
Node t1_a = new Node("a");
Node t1_b = new Node("b");
Node t1_c = new Node("c");
Node t1_d = new Node("d");
Node t1_e = new Node("e");
Node t1_f = new Node("f");
t1_a.children.add(t1_b);
t1_b.children.add(t1_c);
t1_c.children.add(t1_d);
t1_d.children.add(t1_e);
t1_e.children.add(t1_f);
Node t2_a = new Node("a");
Node t2_f = new Node("f");
t2_a.children.add(t2_f);
assertThat(treesAndGraphs.isSubtree(t1_a, t2_a), is(true));
}
@Test
public void isSubtree_2() {
Node t1_1 = new Node("a");
Node t1_2 = new Node("b");
Node t1_3 = new Node("a");
Node t1_4 = new Node("d");
t1_1.children.add(t1_2);
t1_2.children.add(t1_3);
t1_3.children.add(t1_4);
Node t2_1 = new Node("a");
Node t2_2 = new Node("d");
t2_1.children.add(t2_2);
assertThat(treesAndGraphs.isSubtree(t1_1, t2_1), is(true));
}
private void sampleGraph() {
a.children.addAll(asList(b, e, f));
b.children.addAll(asList(d, e));
c.children.addAll(asList(b));
d.children.addAll(asList(c, e));
}
private void sampleBinaryTree() {
d.children.add(b);
d.children.add(f);
b.children.add(a);
b.children.add(c);
f.children.add(e);
f.children.add(g);
}
private String asString(List<Node> nodes) {
return nodes.stream().map(node -> node.val).collect(joining(""));
}
}
| UTF-8 | Java | 9,598 | java | TreesAndGraphsTest.java | Java | [] | null | [] | package biz.tugay.ctci.ch04;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.joining;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class TreesAndGraphsTest {
TreesAndGraphs treesAndGraphs = new TreesAndGraphs();
Node a, b, c, d, e, f, g;
@Before
public void before() {
a = new Node("0");
b = new Node("1");
c = new Node("2");
d = new Node("3");
e = new Node("4");
f = new Node("5");
g = new Node("6");
}
@Test
public void depthFirstSearch() {
sampleGraph();
assertThat(asString(treesAndGraphs.depthFirstSearch(a)), equalTo("013245"));
}
@Test
public void depthFirstSearch_Cyclic() {
a.children.add(b);
b.children.add(c);
c.children.add(d);
d.children.add(a);
assertThat(asString(treesAndGraphs.depthFirstSearch(a)), equalTo("0123"));
}
@Test
public void breathFirstSearch() {
sampleGraph();
assertThat(asString(treesAndGraphs.breadthFirstSearch(a)), equalTo("014532"));
}
@Test
public void breathFirstSearch_Linear() {
a.children.addAll(asList(b, c));
b.children.add(d);
c.children.add(d);
d.children.addAll(asList((e), f));
assertThat(asString(treesAndGraphs.breadthFirstSearch(a)), equalTo("012345"));
}
@Test
public void pathExists() {
sampleGraph();
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(d), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(c), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(a).contains(f), is(true));
assertThat(treesAndGraphs.breadthFirstSearch(b).contains(a), is(false));
assertThat(treesAndGraphs.breadthFirstSearch(c).contains(d), is(true));
}
@Test
public void minimalTreeSingleElement() {
Node node = treesAndGraphs.minimalTree(asList("a"));
assertThat(node.val, equalTo("a"));
assertThat(node.children.size(), is(0));
}
@Test
public void minimalTreeTwoElement() {
Node node = treesAndGraphs.minimalTree(asList("a", "b"));
assertThat(node.val, equalTo("b"));
assertThat(node.children.get(0).val, equalTo("a"));
assertThat(node.children.size(), is(1));
}
@Test
public void minimalTreeThreeElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c"));
assertThat(node.val, equalTo("b"));
assertThat(node.children.get(0).val, equalTo("a"));
assertThat(node.children.get(1).val, equalTo("c"));
}
@Test
public void minimalTreeFourElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c", "d"));
assertThat(node.val, equalTo("c"));
assertThat(node.children.get(0).val, equalTo("b"));
assertThat(node.children.get(1).val, equalTo("d"));
assertThat(node.children.get(0).children.get(0).val, equalTo("a"));
}
@Test
public void minimalTreeSevenElements() {
Node node = treesAndGraphs.minimalTree(asList("a", "b", "c", "d", "e", "f", "g"));
assertThat(node.val, equalTo("d"));
assertThat(node.children.get(0).val, equalTo("b"));
assertThat(node.children.get(1).val, equalTo("f"));
assertThat(node.children.get(0).children.get(0).val, equalTo("a"));
assertThat(node.children.get(0).children.get(1).val, equalTo("c"));
assertThat(node.children.get(1).children.get(0).val, equalTo("e"));
assertThat(node.children.get(1).children.get(1).val, equalTo("g"));
}
@Test
public void listOfDepths() {
sampleBinaryTree();
List<List<Node>> listOfDepths = treesAndGraphs.listOfDepths(d);
assertThat(listOfDepths.size(), is(3));
assertThat(listOfDepths.get(0).size(), is(1));
assertThat(listOfDepths.get(1).size(), is(2));
assertThat(listOfDepths.get(2).size(), is(4));
}
@Test
public void checkBalanced() {
sampleBinaryTree();
assertThat(treesAndGraphs.checkBalanced(d), is(true));
}
@Test
public void checkBalanced_Unbalanced() {
d.children.add(b);
b.children.add(a);
assertThat(treesAndGraphs.checkBalanced(d), is(false));
}
@Test
public void isBinarySearchTree() {
sampleBinaryTree();
assertThat(treesAndGraphs.isBinarySearchTree(d), is(true));
}
@Test
public void isBinarySearchTreeLeftFalse() {
sampleBinaryTree();
a.val = "9";
assertThat(treesAndGraphs.isBinarySearchTree(d), is(false));
}
@Test
public void isBinarySearchTreeRightFalse() {
sampleBinaryTree();
g.val = "1";
assertThat(treesAndGraphs.isBinarySearchTree(d), is(false));
}
@Test
public void sumPaths1Node() {
assertThat(treesAndGraphs.sumPaths(b, 1), is(1L));
}
@Test
public void sumPaths1NodeNoSums() {
assertThat(treesAndGraphs.sumPaths(b, 2), is(0L));
}
@Test
public void sumPaths2Nodes() {
b.children.add(c);
assertThat(treesAndGraphs.sumPaths(b, 3), is(1L));
}
@Test
public void sumPaths2NodesNoSums() {
b.children.add(c);
assertThat(treesAndGraphs.sumPaths(b, 4), is(0L));
}
@Test
public void sumPaths3Nodes() {
Node d = new Node("2");
b.children.addAll(Arrays.asList(c, d));
assertThat(treesAndGraphs.sumPaths(b, 3), is(2L));
}
@Test
public void sumPathsBinaryTree() {
sampleBinaryTree();
a.val = b.val = c.val = d.val = e.val = f.val = g.val = "0";
d.val = "5";
b.val = "2";
a.val = "3";
c.val = "10";
f.val = "-2";
e.val = "12";
g.val = "7";
assertThat(treesAndGraphs.sumPaths(d, 10), is(4L));
}
@Test
public void isSubtreeSingleNode() {
Node t1 = new Node("a");
Node t2 = new Node("a");
assertThat(treesAndGraphs.isSubtree(t1, t2), is(true));
}
@Test
public void isSubtreeExactTrees() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, d), is(true));
}
@Test
public void isSubtreeLeftNodeIs() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, b), is(true));
}
@Test
public void isSubtreeRightNodeIs() {
sampleBinaryTree();
assertThat(treesAndGraphs.isSubtree(d, f), is(true));
}
@Test
public void testStackOverflow() {
Node oneOne = new Node("1");
Node oneTwo = new Node("2");
Node oneThree = new Node("3");
Node oneFour = new Node("4");
Node twoOne = new Node("1");
Node twoTwo = new Node("2");
Node twoThree = new Node("3");
oneOne.children.add(oneTwo);
oneOne.children.add(oneThree);
oneThree.children.add(oneFour);
oneFour.children.add(null);
oneFour.children.add(twoOne);
twoOne.children.add(twoTwo);
twoTwo.children.add(twoThree);
Node subOne = new Node("1");
Node subTwo = new Node("2");
Node subThree = new Node("3");
subOne.children.add(subTwo);
subTwo.children.add(subThree);
System.out.println(treesAndGraphs.isSubtree(oneOne, subOne));
}
@Test
public void isSubtreeFalse() {
a = new Node("0");
b = new Node("1");
c = new Node("2");
d = new Node("0");
e = new Node("1");
f = new Node("3");
a.children.add(b);
b.children.add(c);
d.children.add(e);
e.children.add(f);
assertThat(treesAndGraphs.isSubtree(a, d), is(false));
}
@Test
public void isSubtreeFalseTricky() {
Node t1_a = new Node("a");
Node t1_b = new Node("b");
Node t1_c = new Node("c");
Node t1_d = new Node("d");
Node t1_e = new Node("e");
Node t1_f = new Node("f");
t1_a.children.add(t1_b);
t1_b.children.add(t1_c);
t1_c.children.add(t1_d);
t1_d.children.add(t1_e);
t1_e.children.add(t1_f);
Node t2_a = new Node("a");
Node t2_f = new Node("f");
t2_a.children.add(t2_f);
assertThat(treesAndGraphs.isSubtree(t1_a, t2_a), is(true));
}
@Test
public void isSubtree_2() {
Node t1_1 = new Node("a");
Node t1_2 = new Node("b");
Node t1_3 = new Node("a");
Node t1_4 = new Node("d");
t1_1.children.add(t1_2);
t1_2.children.add(t1_3);
t1_3.children.add(t1_4);
Node t2_1 = new Node("a");
Node t2_2 = new Node("d");
t2_1.children.add(t2_2);
assertThat(treesAndGraphs.isSubtree(t1_1, t2_1), is(true));
}
private void sampleGraph() {
a.children.addAll(asList(b, e, f));
b.children.addAll(asList(d, e));
c.children.addAll(asList(b));
d.children.addAll(asList(c, e));
}
private void sampleBinaryTree() {
d.children.add(b);
d.children.add(f);
b.children.add(a);
b.children.add(c);
f.children.add(e);
f.children.add(g);
}
private String asString(List<Node> nodes) {
return nodes.stream().map(node -> node.val).collect(joining(""));
}
}
| 9,598 | 0.580433 | 0.563451 | 337 | 27.480713 | 22.690155 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.792285 | false | false | 13 |
dd0675a43b5d814e87b5652ac1e47d21d6a80adb | 12,592,844,154,196 | bf16d44211946e202ec6f6071dc4438c051362dd | /app/src/main/java/com/example/marcin/projectv1/Result.java | 37d19f16a8271e0700e04e6fd1102365e09c870b | [] | no_license | marcinconn/Android | https://github.com/marcinconn/Android | b333a16c6f29bf55eb6cf74cb46e81573e904edd | 0f7b192429cff87caed8007edf843ecbb0d23e86 | refs/heads/master | 2020-05-04T13:10:13.312000 | 2019-04-02T20:04:29 | 2019-04-02T20:04:29 | 179,149,074 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.marcin.projectv1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.List;
public class Result extends AppCompatActivity {
List<Record> listRec;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Connect c = new Connect(this);
if(Find.sScpecific==true) {listRec = c.getSpecific(); Find.sScpecific = false;} else
if(Find.sAll==true) {listRec = c.getAll(); Find.sAll = false;}
ListView lV = findViewById(R.id.resList);
RecordAdapter recAd = new RecordAdapter(this,R.layout.adapter_view_layout, listRec);
lV.setAdapter(recAd);
}
}
| UTF-8 | Java | 798 | java | Result.java | Java | [
{
"context": "package com.example.marcin.projectv1;\n\nimport android.support.v7.app.AppComp",
"end": 26,
"score": 0.7614139914512634,
"start": 20,
"tag": "USERNAME",
"value": "marcin"
}
] | null | [] | package com.example.marcin.projectv1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.List;
public class Result extends AppCompatActivity {
List<Record> listRec;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Connect c = new Connect(this);
if(Find.sScpecific==true) {listRec = c.getSpecific(); Find.sScpecific = false;} else
if(Find.sAll==true) {listRec = c.getAll(); Find.sAll = false;}
ListView lV = findViewById(R.id.resList);
RecordAdapter recAd = new RecordAdapter(this,R.layout.adapter_view_layout, listRec);
lV.setAdapter(recAd);
}
}
| 798 | 0.701754 | 0.699248 | 26 | 29.692308 | 27.560799 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 13 |
470a4ee558269cd9c04f2dde3b163d31cd749a1f | 14,302,241,149,136 | 6170d095e94cf9eadac32d2bc1d0de65847886c3 | /app/src/main/java/com/fanglin/fenhong/microbuyer/common/HomeFragment.java | ff373ef3c7bda5fd27d53a1e5c97c5c0749f64d8 | [] | no_license | oblivion0001/fenhongshop | https://github.com/oblivion0001/fenhongshop | 726f9e7227b3e2b7cc8cf64d45df70e5efc6853d | 47bf5666ddc104af4f0edaa4153f4a8eb2728feb | refs/heads/master | 2020-12-14T07:40:24.517000 | 2017-06-27T15:32:51 | 2017-06-27T15:32:51 | 95,571,190 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fanglin.fenhong.microbuyer.common;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.fanglin.fenhong.microbuyer.R;
import com.fanglin.fenhong.microbuyer.base.baselib.BaseFunc;
import com.fanglin.fenhong.microbuyer.base.baselib.BaseVar;
import com.fanglin.fenhong.microbuyer.base.baseui.BaseFragment;
import com.fanglin.fenhong.microbuyer.base.event.HomeBtnDoubleClickEvent;
import com.fanglin.fenhong.microbuyer.base.event.WifiUnconnectHintAfter;
import com.fanglin.fenhong.microbuyer.base.model.HomeNavigation;
import com.fanglin.fenhong.microbuyer.base.model.ShareData;
import com.fanglin.fenhong.microbuyer.base.model.WSDefaultSearchText;
import com.fanglin.fenhong.microbuyer.base.model.WSHomeNavigation;
import com.fanglin.fenhong.microbuyer.buyer.SearchActivity;
import com.fanglin.fenhong.microbuyer.common.adapter.HomeTopNavigationAdapter;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.viewpagerindicator.TabPageIndicator;
import java.util.ArrayList;
import java.util.List;
import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;
/**
* 作者: Created by Plucky on 2015/8/17.
* ModifyBy Plucky 2016-3-23 10:00
* modify by lizhixin on 2016/04/22
* 添加EventBus接收事件
*/
public class HomeFragment extends BaseFragment implements WSHomeNavigation.HomeNavigationModelCallBack, WSDefaultSearchText.WSDefaultSearchTextModelCallBack {
View view;
@ViewInject(R.id.tvTitleSearchIcon)
TextView tvTitleSearchIcon;
@ViewInject(R.id.tvIconShare)
TextView tvIconShare;
@ViewInject(R.id.tvTitleText)
TextView tvTitleText;
@ViewInject(R.id.tvMsgNum)
TextView tvMsgNum;
@ViewInject(R.id.indicator)
TabPageIndicator indicator;
@ViewInject(R.id.pager)
ViewPager pager;
WSHomeNavigation wsHomeNavigation;
private WSDefaultSearchText wsDefaultSearchText;
HomeTopNavigationAdapter adapter;
@ViewInject(R.id.LDoing)
LinearLayout LDoing;
@ViewInject(R.id.progressBar)
ProgressBar progressBar;
@ViewInject(R.id.ivRefresh)
ImageView ivRefresh;
@ViewInject(R.id.tvRefresh)
TextView tvRefresh;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
}
@Override
public void onResume() {
super.onResume();
if (msgnum != null && msgnum.getTotalNum() > 0) {
tvMsgNum.setText(String.valueOf(msgnum.getTotalNum()));
tvMsgNum.setVisibility(View.VISIBLE);
} else {
tvMsgNum.setText("0");
tvMsgNum.setVisibility(View.INVISIBLE);
}
}
private void initView() {
BaseFunc.setFont(tvTitleSearchIcon);
BaseFunc.setFont(tvIconShare);
adapter = new HomeTopNavigationAdapter(act, act.getSupportFragmentManager());
pager.setAdapter(adapter);
indicator.setViewPager(pager);
pager.setOffscreenPageLimit(6);
wsHomeNavigation = new WSHomeNavigation();
wsHomeNavigation.setNavigationModelCallBack(this);
//首页头部搜索文字提示
wsDefaultSearchText = new WSDefaultSearchText();
wsDefaultSearchText.setWSDefaultSearchText(this);
beginRefresh();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_home, container, false);
ViewUtils.inject(this, view);
initView();
return view;
}
@Override
public void onNavigationSuccess(List<HomeNavigation> list) {
adapter.setList(list);
adapter.notifyDataSetChanged();
indicator.notifyDataSetChanged();
endRefresh(true);
}
@Override
public void onNavigationError(String errcode) {
endRefresh(false);
}
@Override
public void onDefaultSearchText(String str) {
tvTitleText.setText(str);
}
private void beginRefresh() {
LDoing.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
tvRefresh.setVisibility(View.GONE);
ivRefresh.setVisibility(View.GONE);
pager.setVisibility(View.GONE);
wsHomeNavigation.getList(0, 0);
wsDefaultSearchText.getDefaultSearchText();
}
private void endRefresh(boolean isSuccess) {
progressBar.setVisibility(View.GONE);
if (isSuccess) {
pager.setVisibility(View.VISIBLE);
LDoing.setVisibility(View.GONE);
ivRefresh.setVisibility(View.GONE);
tvRefresh.setVisibility(View.GONE);
} else {
pager.setVisibility(View.GONE);
LDoing.setVisibility(View.VISIBLE);
ivRefresh.setVisibility(View.VISIBLE);
tvRefresh.setVisibility(View.VISIBLE);
}
}
@OnClick(value = {R.id.ivRefresh, R.id.tvRefresh, R.id.LShare, R.id.LMsg, R.id.LSearch})
public void onViewClick(View view) {
switch (view.getId()) {
case R.id.ivRefresh:
case R.id.tvRefresh:
beginRefresh();
break;
case R.id.LShare:
ShareData.fhShare(act, getShareData(), null);
break;
case R.id.LMsg:
BaseFunc.gotoActivity(act, MsgCenterActivity.class, null);
break;
case R.id.LSearch:
BaseFunc.gotoActivity(act, SearchActivity.class, tvTitleText.getText().toString());
break;
}
}
@Subscribe(threadMode = ThreadMode.MainThread)
public void onHomeBtnDoubleClick(HomeBtnDoubleClickEvent event) {
if (pager != null) {
pager.setCurrentItem(0);//回到第一个频道 -- lizhixin
}
}
private ShareData getShareData() {
ShareData shareData = new ShareData();
shareData.title = act.getString(R.string.share_home_title);
shareData.content = act.getString(R.string.share_home_content);
shareData.imgs = BaseVar.APP_SHARE_HOME_LOGO;
List<String> list_image = new ArrayList<>();
list_image.add(BaseVar.APP_SHARE_HOME_LOGO);
shareData.mul_img = list_image;
shareData.url = BaseVar.APP_SHARE_HOME_URL;
return shareData;
}
@Subscribe(threadMode = ThreadMode.MainThread)
public void handleNoWfi(WifiUnconnectHintAfter wifiUnconnectHintEntity) {
if (adapter.list == null || adapter.list.size() == 0) {
beginRefresh();
}
}
@Override
public void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
}
| UTF-8 | Java | 7,167 | java | HomeFragment.java | Java | [
{
"context": "reenrobot.event.ThreadMode;\n\n/**\n * 作者: Created by Plucky on 2015/8/17.\n * ModifyBy Plucky 2016-3-23 10:00\n",
"end": 1553,
"score": 0.886406421661377,
"start": 1547,
"tag": "USERNAME",
"value": "Plucky"
},
{
"context": " * 作者: Created by Plucky on 2015/8/17.\n * Mo... | null | [] | package com.fanglin.fenhong.microbuyer.common;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.fanglin.fenhong.microbuyer.R;
import com.fanglin.fenhong.microbuyer.base.baselib.BaseFunc;
import com.fanglin.fenhong.microbuyer.base.baselib.BaseVar;
import com.fanglin.fenhong.microbuyer.base.baseui.BaseFragment;
import com.fanglin.fenhong.microbuyer.base.event.HomeBtnDoubleClickEvent;
import com.fanglin.fenhong.microbuyer.base.event.WifiUnconnectHintAfter;
import com.fanglin.fenhong.microbuyer.base.model.HomeNavigation;
import com.fanglin.fenhong.microbuyer.base.model.ShareData;
import com.fanglin.fenhong.microbuyer.base.model.WSDefaultSearchText;
import com.fanglin.fenhong.microbuyer.base.model.WSHomeNavigation;
import com.fanglin.fenhong.microbuyer.buyer.SearchActivity;
import com.fanglin.fenhong.microbuyer.common.adapter.HomeTopNavigationAdapter;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.viewpagerindicator.TabPageIndicator;
import java.util.ArrayList;
import java.util.List;
import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;
/**
* 作者: Created by Plucky on 2015/8/17.
* ModifyBy Plucky 2016-3-23 10:00
* modify by lizhixin on 2016/04/22
* 添加EventBus接收事件
*/
public class HomeFragment extends BaseFragment implements WSHomeNavigation.HomeNavigationModelCallBack, WSDefaultSearchText.WSDefaultSearchTextModelCallBack {
View view;
@ViewInject(R.id.tvTitleSearchIcon)
TextView tvTitleSearchIcon;
@ViewInject(R.id.tvIconShare)
TextView tvIconShare;
@ViewInject(R.id.tvTitleText)
TextView tvTitleText;
@ViewInject(R.id.tvMsgNum)
TextView tvMsgNum;
@ViewInject(R.id.indicator)
TabPageIndicator indicator;
@ViewInject(R.id.pager)
ViewPager pager;
WSHomeNavigation wsHomeNavigation;
private WSDefaultSearchText wsDefaultSearchText;
HomeTopNavigationAdapter adapter;
@ViewInject(R.id.LDoing)
LinearLayout LDoing;
@ViewInject(R.id.progressBar)
ProgressBar progressBar;
@ViewInject(R.id.ivRefresh)
ImageView ivRefresh;
@ViewInject(R.id.tvRefresh)
TextView tvRefresh;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
}
@Override
public void onResume() {
super.onResume();
if (msgnum != null && msgnum.getTotalNum() > 0) {
tvMsgNum.setText(String.valueOf(msgnum.getTotalNum()));
tvMsgNum.setVisibility(View.VISIBLE);
} else {
tvMsgNum.setText("0");
tvMsgNum.setVisibility(View.INVISIBLE);
}
}
private void initView() {
BaseFunc.setFont(tvTitleSearchIcon);
BaseFunc.setFont(tvIconShare);
adapter = new HomeTopNavigationAdapter(act, act.getSupportFragmentManager());
pager.setAdapter(adapter);
indicator.setViewPager(pager);
pager.setOffscreenPageLimit(6);
wsHomeNavigation = new WSHomeNavigation();
wsHomeNavigation.setNavigationModelCallBack(this);
//首页头部搜索文字提示
wsDefaultSearchText = new WSDefaultSearchText();
wsDefaultSearchText.setWSDefaultSearchText(this);
beginRefresh();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_home, container, false);
ViewUtils.inject(this, view);
initView();
return view;
}
@Override
public void onNavigationSuccess(List<HomeNavigation> list) {
adapter.setList(list);
adapter.notifyDataSetChanged();
indicator.notifyDataSetChanged();
endRefresh(true);
}
@Override
public void onNavigationError(String errcode) {
endRefresh(false);
}
@Override
public void onDefaultSearchText(String str) {
tvTitleText.setText(str);
}
private void beginRefresh() {
LDoing.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
tvRefresh.setVisibility(View.GONE);
ivRefresh.setVisibility(View.GONE);
pager.setVisibility(View.GONE);
wsHomeNavigation.getList(0, 0);
wsDefaultSearchText.getDefaultSearchText();
}
private void endRefresh(boolean isSuccess) {
progressBar.setVisibility(View.GONE);
if (isSuccess) {
pager.setVisibility(View.VISIBLE);
LDoing.setVisibility(View.GONE);
ivRefresh.setVisibility(View.GONE);
tvRefresh.setVisibility(View.GONE);
} else {
pager.setVisibility(View.GONE);
LDoing.setVisibility(View.VISIBLE);
ivRefresh.setVisibility(View.VISIBLE);
tvRefresh.setVisibility(View.VISIBLE);
}
}
@OnClick(value = {R.id.ivRefresh, R.id.tvRefresh, R.id.LShare, R.id.LMsg, R.id.LSearch})
public void onViewClick(View view) {
switch (view.getId()) {
case R.id.ivRefresh:
case R.id.tvRefresh:
beginRefresh();
break;
case R.id.LShare:
ShareData.fhShare(act, getShareData(), null);
break;
case R.id.LMsg:
BaseFunc.gotoActivity(act, MsgCenterActivity.class, null);
break;
case R.id.LSearch:
BaseFunc.gotoActivity(act, SearchActivity.class, tvTitleText.getText().toString());
break;
}
}
@Subscribe(threadMode = ThreadMode.MainThread)
public void onHomeBtnDoubleClick(HomeBtnDoubleClickEvent event) {
if (pager != null) {
pager.setCurrentItem(0);//回到第一个频道 -- lizhixin
}
}
private ShareData getShareData() {
ShareData shareData = new ShareData();
shareData.title = act.getString(R.string.share_home_title);
shareData.content = act.getString(R.string.share_home_content);
shareData.imgs = BaseVar.APP_SHARE_HOME_LOGO;
List<String> list_image = new ArrayList<>();
list_image.add(BaseVar.APP_SHARE_HOME_LOGO);
shareData.mul_img = list_image;
shareData.url = BaseVar.APP_SHARE_HOME_URL;
return shareData;
}
@Subscribe(threadMode = ThreadMode.MainThread)
public void handleNoWfi(WifiUnconnectHintAfter wifiUnconnectHintEntity) {
if (adapter.list == null || adapter.list.size() == 0) {
beginRefresh();
}
}
@Override
public void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
}
| 7,167 | 0.686999 | 0.682221 | 217 | 31.788019 | 24.162874 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.603687 | false | false | 13 |
e0e8e85ca7b7fda3582cafec33655c8a68505cee | 11,175,504,939,079 | 23fa7a3cf7fb7216667430c59fdf62067278397c | /OffDroid/src/main/java/br/com/guerethes/offdroid/query/order/OrderByDesc.java | f241285342a02dca4eeac254c4ba3d825f60c0c0 | [
"MIT"
] | permissive | guerethes/offdroid2 | https://github.com/guerethes/offdroid2 | 9036ee4b0c6585222dd3fc61764e2b84ed176717 | 28962954cfc4bcff69dfb2f8f86bfa5e53c9f8f7 | refs/heads/master | 2021-09-14T07:32:52.981000 | 2018-05-09T21:12:33 | 2018-05-09T21:12:33 | 106,003,394 | 0 | 2 | null | false | 2018-05-09T21:12:34 | 2017-10-06T12:42:34 | 2018-05-09T17:47:42 | 2018-05-09T21:12:34 | 111 | 0 | 2 | 0 | Java | false | null | package br.com.guerethes.offdroid.query.order;
import com.db4o.query.Query;
import br.com.guerethes.offdroid.query.ElementsRestrictionQuery;
/**
* Created by jean on 26/12/16.
*/
public class OrderByDesc extends ElementsRestrictionQuery {
public static OrderByDesc create(String field) {
OrderByDesc orderByDesc = new OrderByDesc();
orderByDesc.field = field;
return orderByDesc;
}
@Override
public void toDDL(Query q) {
q.descend(field).orderDescending();
}
} | UTF-8 | Java | 520 | java | OrderByDesc.java | Java | [
{
"context": "query.ElementsRestrictionQuery;\n\n/**\n * Created by jean on 26/12/16.\n */\npublic class OrderByDesc extends",
"end": 166,
"score": 0.949137806892395,
"start": 162,
"tag": "USERNAME",
"value": "jean"
}
] | null | [] | package br.com.guerethes.offdroid.query.order;
import com.db4o.query.Query;
import br.com.guerethes.offdroid.query.ElementsRestrictionQuery;
/**
* Created by jean on 26/12/16.
*/
public class OrderByDesc extends ElementsRestrictionQuery {
public static OrderByDesc create(String field) {
OrderByDesc orderByDesc = new OrderByDesc();
orderByDesc.field = field;
return orderByDesc;
}
@Override
public void toDDL(Query q) {
q.descend(field).orderDescending();
}
} | 520 | 0.7 | 0.686538 | 23 | 21.652174 | 21.927963 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304348 | false | false | 13 |
ca187dc5dde3d93a8f6495e225ad389a054c3fa9 | 14,147,622,319,860 | 4e0a0265764a690b155da6b98c79c2eb5b59da18 | /src/main/java/com/yp/service/ApiServer.java | 8859e9ac416ffee3ef27b2b1cd520712b74c07c4 | [] | no_license | zhuifengzheng/webfluxclient | https://github.com/zhuifengzheng/webfluxclient | 5db0111bbc20e08d21ffededefad3ddb61510369 | afa0690858c51715544dcf1a4da0807476801f24 | refs/heads/master | 2020-03-29T04:52:11.540000 | 2018-09-20T04:51:09 | 2018-09-20T04:51:09 | 149,553,061 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yp.service;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author fengzheng
* @create 2018-09-15 9:53
* @desc
**/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiServer {
String value() default "";
}
| UTF-8 | Java | 379 | java | ApiServer.java | Java | [
{
"context": "mport java.lang.annotation.Target;\n\n/**\n * @author fengzheng\n * @create 2018-09-15 9:53\n * @desc\n **/\n@Target(",
"end": 211,
"score": 0.997053861618042,
"start": 202,
"tag": "USERNAME",
"value": "fengzheng"
}
] | null | [] | package com.yp.service;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author fengzheng
* @create 2018-09-15 9:53
* @desc
**/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiServer {
String value() default "";
}
| 379 | 0.754617 | 0.725594 | 18 | 20.055555 | 15.367615 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
73df6e65af5603547e9a0acd5fbdc341949074c3 | 32,796,370,326,852 | 70234b0f1b3dd9a1b6324e421d1a82adfbdc0838 | /src/com/shop/test/SpringHibernateTest.java | e6681ed80eb61fc35749f56115df8882267fe388 | [] | no_license | IveyLv/OnlineShop | https://github.com/IveyLv/OnlineShop | 590708859685c07f9903be20019245e9ce37a2d2 | 2d41a45f5ad99d151eff05c8e922253695aaf29d | refs/heads/master | 2022-09-18T21:31:03.163000 | 2020-02-17T12:05:36 | 2020-02-17T12:05:36 | 241,097,779 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.shop.test;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.sql.DataSource;
import java.sql.SQLException;
public class SpringHibernateTest {
private ApplicationContext ctx = null;
{
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
@Test
public void dataSourceTest() throws SQLException {
DataSource dataSource = ctx.getBean(DataSource.class);
System.out.println(dataSource.getConnection());
}
}
| UTF-8 | Java | 599 | java | SpringHibernateTest.java | Java | [] | null | [] | package com.shop.test;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.sql.DataSource;
import java.sql.SQLException;
public class SpringHibernateTest {
private ApplicationContext ctx = null;
{
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
@Test
public void dataSourceTest() throws SQLException {
DataSource dataSource = ctx.getBean(DataSource.class);
System.out.println(dataSource.getConnection());
}
}
| 599 | 0.752922 | 0.752922 | 23 | 25.043478 | 25.577637 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.434783 | false | false | 13 |
8043174eea1912b39905beefea3377a1ffaedbda | 3,539,053,115,647 | 0ffb484dbfcfb625647c9c9afe6cc87224d33520 | /src/main/java/com/mitocode/jwd/examen/patient/application/PatientCreateService.java | c4378429ab30391a6aec0b076af8bc74fc3c4d19 | [] | no_license | emiliocaldas/curso-javaweb-examen | https://github.com/emiliocaldas/curso-javaweb-examen | b633d033e8dec83ea42783a8226ff919967cca1a | c4f78e0a5636fa55ef32bcc6554c5e1c5a5d34a8 | refs/heads/main | 2023-07-06T23:46:40.069000 | 2021-08-15T16:31:12 | 2021-08-15T16:31:12 | 328,726,313 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mitocode.jwd.examen.patient.application;
import org.springframework.stereotype.Service;
import com.mitocode.jwd.examen.patient.domain.Patient;
import com.mitocode.jwd.examen.patient.domain.PatientRepository;
@Service
public class PatientCreateService {
private PatientRepository patientRepository;
public PatientCreateService(PatientRepository patientRepository) {
this.patientRepository = patientRepository;
}
public int save(Patient patient) {
int rows = patientRepository.save(patient);
return rows;
}
}
| UTF-8 | Java | 538 | java | PatientCreateService.java | Java | [] | null | [] | package com.mitocode.jwd.examen.patient.application;
import org.springframework.stereotype.Service;
import com.mitocode.jwd.examen.patient.domain.Patient;
import com.mitocode.jwd.examen.patient.domain.PatientRepository;
@Service
public class PatientCreateService {
private PatientRepository patientRepository;
public PatientCreateService(PatientRepository patientRepository) {
this.patientRepository = patientRepository;
}
public int save(Patient patient) {
int rows = patientRepository.save(patient);
return rows;
}
}
| 538 | 0.812268 | 0.812268 | 23 | 22.391304 | 24.301975 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.826087 | false | false | 13 |
d690b7a7c3ad9a1ce7857ce157a46bc8d8bd91f4 | 7,928,509,690,535 | 7c8d2d2791b63d49edaf464129849a585460c880 | /6清算系统/AccSettleRealTime_latest/src/com/goldsign/settle/realtime/app/io/FileWriter19.java | e159d91b7719f71426de7f5c974fb1fcd576dd4e | [] | no_license | wuqq-20191129/wlmq | https://github.com/wuqq-20191129/wlmq | 5cd3ebc50945bde41d0fd615ba93ca95ab1a2235 | ae26d439af09097b65c90cad8d22954cd91fe5f5 | refs/heads/master | 2023-01-14T03:19:23.226000 | 2020-11-24T01:43:22 | 2020-11-24T02:09:41 | 315,494,185 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.goldsign.settle.realtime.app.io;
import com.goldsign.settle.realtime.app.vo.FileRecord18;
import com.goldsign.settle.realtime.frame.exception.FileWriteException;
import com.goldsign.settle.realtime.frame.io.FileWriterBase;
import com.goldsign.settle.realtime.frame.vo.FileRecordBase;
import java.util.Vector;
/**
*
* @author hejj
*/
public class FileWriter19 extends FileWriterBase{
@Override
public void writeFile(String pathBcp, String fileName, String tradType, Vector records) throws FileWriteException {
this.writeFileForCommon(pathBcp, fileName, tradType, records);
}
@Override
public String getLine(FileRecordBase vob) {
FileRecord18 vo =(FileRecord18)vob;
StringBuffer sb = new StringBuffer();
sb.append(vo.getLineId() + FileWriterBase.FIELD_DELIM);//2线路代码
sb.append(vo.getStationId() + FileWriterBase.FIELD_DELIM);//2站点代码
sb.append(vo.getDevTypeId() + FileWriterBase.FIELD_DELIM);//2设备类型
sb.append(vo.getDeviceId() + FileWriterBase.FIELD_DELIM);//2设备代码
sb.append(vo.getAutoBalDatetimeBegein() + FileWriterBase.FIELD_DELIM);//自动结存周期开始时间
sb.append(vo.getAutoBalDatetimeEnd() + FileWriterBase.FIELD_DELIM);//自动结存周期结束时间
sb.append(vo.getSjtNumSaleTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1发售数量
sb.append(vo.getSjtNumSaleTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2发售数量
sb.append(this.convertFenToYuan(vo.getSjtSaleFeeTotal1()) + FileWriterBase.FIELD_DELIM);//单程票箱1发售总金额
sb.append(this.convertFenToYuan(vo.getSjtSaleFeeTotal2()) + FileWriterBase.FIELD_DELIM);//单程票箱2发售总金额
sb.append(this.convertFenToYuan(vo.getChargeFeeTotal()) + FileWriterBase.FIELD_DELIM);//充值总金额
sb.append(vo.getSjtNumPutTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1存入总数量
sb.append(vo.getSjtNumPutTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2存入总数量
sb.append(vo.getSjtNumClearTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1清空数量
sb.append(vo.getSjtNumClearTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2清空数量
sb.append(vo.getSjtNumBalTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1结存数量
sb.append(vo.getSjtNumBalTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2结存数量
sb.append(vo.getSjtNumWasteTotal() + FileWriterBase.FIELD_DELIM);//单程票废票数量
sb.append(this.convertFenToYuan(vo.getTvmBalFeeTotal()) + FileWriterBase.FIELD_DELIM);//TVM结存金额
this.addCommonToBuff(sb, vo);
sb.append(FileWriterBase.getLineDelimter());
return sb.toString();
}
}
| UTF-8 | Java | 3,099 | java | FileWriter19.java | Java | [
{
"context": ";\r\nimport java.util.Vector;\r\n\r\n/**\r\n *\r\n * @author hejj\r\n */\r\npublic class FileWriter19 extends FileWrite",
"end": 545,
"score": 0.9996310472488403,
"start": 541,
"tag": "USERNAME",
"value": "hejj"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.goldsign.settle.realtime.app.io;
import com.goldsign.settle.realtime.app.vo.FileRecord18;
import com.goldsign.settle.realtime.frame.exception.FileWriteException;
import com.goldsign.settle.realtime.frame.io.FileWriterBase;
import com.goldsign.settle.realtime.frame.vo.FileRecordBase;
import java.util.Vector;
/**
*
* @author hejj
*/
public class FileWriter19 extends FileWriterBase{
@Override
public void writeFile(String pathBcp, String fileName, String tradType, Vector records) throws FileWriteException {
this.writeFileForCommon(pathBcp, fileName, tradType, records);
}
@Override
public String getLine(FileRecordBase vob) {
FileRecord18 vo =(FileRecord18)vob;
StringBuffer sb = new StringBuffer();
sb.append(vo.getLineId() + FileWriterBase.FIELD_DELIM);//2线路代码
sb.append(vo.getStationId() + FileWriterBase.FIELD_DELIM);//2站点代码
sb.append(vo.getDevTypeId() + FileWriterBase.FIELD_DELIM);//2设备类型
sb.append(vo.getDeviceId() + FileWriterBase.FIELD_DELIM);//2设备代码
sb.append(vo.getAutoBalDatetimeBegein() + FileWriterBase.FIELD_DELIM);//自动结存周期开始时间
sb.append(vo.getAutoBalDatetimeEnd() + FileWriterBase.FIELD_DELIM);//自动结存周期结束时间
sb.append(vo.getSjtNumSaleTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1发售数量
sb.append(vo.getSjtNumSaleTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2发售数量
sb.append(this.convertFenToYuan(vo.getSjtSaleFeeTotal1()) + FileWriterBase.FIELD_DELIM);//单程票箱1发售总金额
sb.append(this.convertFenToYuan(vo.getSjtSaleFeeTotal2()) + FileWriterBase.FIELD_DELIM);//单程票箱2发售总金额
sb.append(this.convertFenToYuan(vo.getChargeFeeTotal()) + FileWriterBase.FIELD_DELIM);//充值总金额
sb.append(vo.getSjtNumPutTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1存入总数量
sb.append(vo.getSjtNumPutTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2存入总数量
sb.append(vo.getSjtNumClearTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1清空数量
sb.append(vo.getSjtNumClearTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2清空数量
sb.append(vo.getSjtNumBalTotal1() + FileWriterBase.FIELD_DELIM);//单程票箱1结存数量
sb.append(vo.getSjtNumBalTotal2() + FileWriterBase.FIELD_DELIM);//单程票箱2结存数量
sb.append(vo.getSjtNumWasteTotal() + FileWriterBase.FIELD_DELIM);//单程票废票数量
sb.append(this.convertFenToYuan(vo.getTvmBalFeeTotal()) + FileWriterBase.FIELD_DELIM);//TVM结存金额
this.addCommonToBuff(sb, vo);
sb.append(FileWriterBase.getLineDelimter());
return sb.toString();
}
}
| 3,099 | 0.70994 | 0.69862 | 60 | 45.116665 | 37.385422 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.683333 | false | false | 13 |
72f631b9733c6fd00e64cc7d0c3cc7ed0c6bbeeb | 8,959,301,827,432 | 4f273b27591782ec1be5c6762d19fe232a3b46c7 | /src/test/java/com/vortexalex/shoppingbasket/taxes/DefaultTaxPolicyTest.java | b8c12adf35cf1818e8179cbeab29d532d1b29955 | [
"Apache-2.0"
] | permissive | vortexalex/shopping-basket | https://github.com/vortexalex/shopping-basket | 0c023c0e995ec5d2ec39ac10cda8c8569dd31155 | 9351e9a30a3ed59b10f2fc7961ba4cbf4091a9fa | refs/heads/main | 2023-01-28T19:23:34.143000 | 2020-12-11T11:15:38 | 2020-12-11T11:15:38 | 319,966,497 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vortexalex.shoppingbasket.taxes;
import com.vortexalex.shoppingbasket.ShoppingItem;
import com.vortexalex.shoppingbasket.ShoppingCategory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultTaxPolicyTest {
private static ExemptionPolicy exemptionPolicy;
@BeforeAll
public static void init() {
exemptionPolicy = new ExemptionPolicy();
}
@Test
public void testPolicyAppliesNoTaxesForBook() {
ShoppingItem item = new ShoppingItem("book", ShoppingCategory.BOOK, new BigDecimal(12.49));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesNoTaxesForFood() {
ShoppingItem item = new ShoppingItem("food", ShoppingCategory.FOOD, new BigDecimal(3));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesNoTaxesForMedical() {
ShoppingItem item = new ShoppingItem("medical", ShoppingCategory.MEDICAL, new BigDecimal(30));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesTaxesForImportedPerfume() {
ShoppingItem item = new ShoppingItem("perfume", ShoppingCategory.OTHER, true, new BigDecimal("47.50"));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("7.15"), tax);
}
@Test
public void testPolicyAppliesTaxesForImportedBook() {
ShoppingItem importBook = new ShoppingItem("importBook", ShoppingCategory.BOOK, true, new BigDecimal(10));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(importBook);
assertEquals(new BigDecimal("0.50"), tax);
}
}
| UTF-8 | Java | 2,296 | java | DefaultTaxPolicyTest.java | Java | [] | null | [] | package com.vortexalex.shoppingbasket.taxes;
import com.vortexalex.shoppingbasket.ShoppingItem;
import com.vortexalex.shoppingbasket.ShoppingCategory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultTaxPolicyTest {
private static ExemptionPolicy exemptionPolicy;
@BeforeAll
public static void init() {
exemptionPolicy = new ExemptionPolicy();
}
@Test
public void testPolicyAppliesNoTaxesForBook() {
ShoppingItem item = new ShoppingItem("book", ShoppingCategory.BOOK, new BigDecimal(12.49));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesNoTaxesForFood() {
ShoppingItem item = new ShoppingItem("food", ShoppingCategory.FOOD, new BigDecimal(3));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesNoTaxesForMedical() {
ShoppingItem item = new ShoppingItem("medical", ShoppingCategory.MEDICAL, new BigDecimal(30));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("0.00"), tax);
}
@Test
public void testPolicyAppliesTaxesForImportedPerfume() {
ShoppingItem item = new ShoppingItem("perfume", ShoppingCategory.OTHER, true, new BigDecimal("47.50"));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(item);
assertEquals(new BigDecimal("7.15"), tax);
}
@Test
public void testPolicyAppliesTaxesForImportedBook() {
ShoppingItem importBook = new ShoppingItem("importBook", ShoppingCategory.BOOK, true, new BigDecimal(10));
DefaultTaxPolicy taxPolicy = new DefaultTaxPolicy(exemptionPolicy);
BigDecimal tax = taxPolicy.apply(importBook);
assertEquals(new BigDecimal("0.50"), tax);
}
}
| 2,296 | 0.715592 | 0.703397 | 72 | 30.888889 | 32.348602 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.638889 | false | false | 13 |
9c968332db291fe033dbece82766dfc224e13293 | 25,769,871,839 | a98ee3c87379f23dee39ffea279107c5bcb66cec | /Week_03/edu/geek/study/combinations/Permutation.java | 873ff4953f7092253ba8dbd1d4639e539198542a | [] | no_license | JinCheng-Huang/algorithm013 | https://github.com/JinCheng-Huang/algorithm013 | 0a7c8cbb11894392090ee433bcb7d5bd9b688204 | 1ad64867303746d1e6eaf8fe574e878021eac5fc | refs/heads/master | 2022-11-30T09:33:51.314000 | 2020-08-19T17:29:39 | 2020-08-19T17:29:39 | 283,829,723 | 0 | 0 | null | true | 2020-07-30T16:54:09 | 2020-07-30T16:54:08 | 2020-07-27T07:02:30 | 2020-07-22T11:09:54 | 2 | 0 | 0 | 0 | null | false | false | package edu.geek.study.combinations;
import java.util.ArrayList;
import java.util.List;
/**
* 给定一个 没有重复 数字的序列,返回其所有可能的全排列。
* 示例:
* 输入: [1,2,3]
* 输出:
* [
* [1,2,3],
* [1,3,2],
* [2,1,3],
* [2,3,1],
* [3,1,2],
* [3,2,1]
* ]
* 来源:力扣(LeetCode)
* 链接:https://leetcode-cn.com/problems/permutations
* 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
public class Permutation {
public static void main(String[] args) {
List<List<Integer>> result = permute(new int[]{1,2,3});
System.out.println(1111);
}
public static List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<List<Integer>>();
List<Integer> numList = new ArrayList<Integer>();
for (int i : nums) {
numList.add(i);
}
fillPermute(numList, new ArrayList<Integer>(), result);
return result;
}
private static void fillPermute(List<Integer> numList, ArrayList<Integer> list, List<List<Integer>> result) {
if(numList.size() == 0) {
result.add(new ArrayList<Integer>(list));
return;
}
for (int i = 0; i < numList.size(); i++) {
list.add(numList.get(i));
List<Integer> newList = new ArrayList<Integer>(numList);
newList.remove(i);
fillPermute(newList, list, result);
list.remove(list.size() - 1);
}
}
}
| UTF-8 | Java | 1,440 | java | Permutation.java | Java | [] | null | [] | package edu.geek.study.combinations;
import java.util.ArrayList;
import java.util.List;
/**
* 给定一个 没有重复 数字的序列,返回其所有可能的全排列。
* 示例:
* 输入: [1,2,3]
* 输出:
* [
* [1,2,3],
* [1,3,2],
* [2,1,3],
* [2,3,1],
* [3,1,2],
* [3,2,1]
* ]
* 来源:力扣(LeetCode)
* 链接:https://leetcode-cn.com/problems/permutations
* 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
public class Permutation {
public static void main(String[] args) {
List<List<Integer>> result = permute(new int[]{1,2,3});
System.out.println(1111);
}
public static List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<List<Integer>>();
List<Integer> numList = new ArrayList<Integer>();
for (int i : nums) {
numList.add(i);
}
fillPermute(numList, new ArrayList<Integer>(), result);
return result;
}
private static void fillPermute(List<Integer> numList, ArrayList<Integer> list, List<List<Integer>> result) {
if(numList.size() == 0) {
result.add(new ArrayList<Integer>(list));
return;
}
for (int i = 0; i < numList.size(); i++) {
list.add(numList.get(i));
List<Integer> newList = new ArrayList<Integer>(numList);
newList.remove(i);
fillPermute(newList, list, result);
list.remove(list.size() - 1);
}
}
}
| 1,440 | 0.618789 | 0.59472 | 53 | 23.301888 | 22.711966 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.660377 | false | false | 13 |
ad0c42c2a2b3da71abf10d5c8e1ae7a8b9d9c49d | 28,647,431,913,705 | 1d6a1249325b1538043bbf4618782681b1b7e3ba | /src/main/java/org/niit/DAO/JobDAOImpl.java | 03039b547b7af96a6bb0eda2a9fd715208fcb716 | [] | no_license | swapna55/project | https://github.com/swapna55/project | 9d7fe07a1fe6d304bdc031ef791fea55832e1e28 | 5a4469ac780e5fd3f5b80e8dd3389d48b4f07e82 | refs/heads/master | 2020-05-21T08:41:13.096000 | 2016-11-25T05:05:19 | 2016-11-25T05:05:19 | 63,700,975 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*package org.niit.DAO;
import java.util.List;
import javax.transaction.Transactional;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.niit.model.Job;
import org.niit.model.User;
import org.springframework.stereotype.Repository;
@Repository("jobDAO")
public class JobDAOImpl {
private SessionFactory sessionFactory;
public JobDAOImpl(SessionFactory sessionFactory)
{
this.sessionFactory=sessionFactory;
}
@Transactional
public boolean postJob(Job job)
{
try {
job.setId(getMaxId()+1);
sessionFactory.getCurrentSession().save(job);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
public boolean updateJob(Job jobApplication)
{
try {
sessionFactory.getCurrentSession().update(jobApplication);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
private Integer getMaxId()
{
Integer maxID = 100;
try {
String hql="select max(id) from job";
Query query =sessionFactory.getCurrentSession().createQuery(hql);
maxID=(Integer) query .uniqueResult();
}
catch(Exception e)
{
maxID = 100;
e.printStackTrace();
}
return maxID+1;
}
@Transactional
public boolean save(JobApplication jobApplied)
{
try {
sessionFactory.getCurrentSession().save(jobApplied);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
public List<Job> getAllVacantJobs() {
String hql="from job where status='v'";
Query query =sessionFactory.getCurrentSession().createQuery(hql);
return query.list();
}
@Transactional
public boolean applyForJob(JobApplication jobApplication) {
try{
sessionFactory.getCurrentSession().save(jobApplication);
}catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
}
*/ | UTF-8 | Java | 1,933 | java | JobDAOImpl.java | Java | [] | null | [] | /*package org.niit.DAO;
import java.util.List;
import javax.transaction.Transactional;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.niit.model.Job;
import org.niit.model.User;
import org.springframework.stereotype.Repository;
@Repository("jobDAO")
public class JobDAOImpl {
private SessionFactory sessionFactory;
public JobDAOImpl(SessionFactory sessionFactory)
{
this.sessionFactory=sessionFactory;
}
@Transactional
public boolean postJob(Job job)
{
try {
job.setId(getMaxId()+1);
sessionFactory.getCurrentSession().save(job);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
public boolean updateJob(Job jobApplication)
{
try {
sessionFactory.getCurrentSession().update(jobApplication);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
private Integer getMaxId()
{
Integer maxID = 100;
try {
String hql="select max(id) from job";
Query query =sessionFactory.getCurrentSession().createQuery(hql);
maxID=(Integer) query .uniqueResult();
}
catch(Exception e)
{
maxID = 100;
e.printStackTrace();
}
return maxID+1;
}
@Transactional
public boolean save(JobApplication jobApplied)
{
try {
sessionFactory.getCurrentSession().save(jobApplied);
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@Transactional
public List<Job> getAllVacantJobs() {
String hql="from job where status='v'";
Query query =sessionFactory.getCurrentSession().createQuery(hql);
return query.list();
}
@Transactional
public boolean applyForJob(JobApplication jobApplication) {
try{
sessionFactory.getCurrentSession().save(jobApplication);
}catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
}
*/ | 1,933 | 0.69581 | 0.691671 | 138 | 13.014493 | 16.621527 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.442029 | false | false | 13 |
d1d64815a6c0f8ee58446ce08df6c1bed8ec7eeb | 35,588,099,042,776 | e0b2610d3d9632b25c28c7c5c27db95a728096e2 | /app/src/main/java/koohi/koohi/Main2Activity.java | b964e0f4143ab60009b2e3294a0ee8d8d3c25b3b | [] | no_license | royalHM/royalProject | https://github.com/royalHM/royalProject | 462d4f394d56922dd27d34b9663feb03a03acd39 | 6a1b1e005153452a045d27e37b6ddf4f51d6c83a | refs/heads/master | 2020-03-27T00:56:52.235000 | 2018-08-22T07:04:55 | 2018-08-22T07:05:33 | 145,668,976 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package koohi.koohi;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Main2Activity extends AppCompatActivity {
Toolbar toolbar1;
Button button12, button2323;
TextView VR_Name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
button12 = (Button) findViewById(R.id.Button_gmali);
button12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SendEmail();
}
});
button2323 = (Button) findViewById(R.id.Button_report);
button2323.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent Button_sd = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/joinchat/AAAAAE46F2eQwRB9pLdGwA"));
startActivity(Button_sd);
}
});
Versionshwocode();
toolbar1 = (Toolbar) findViewById(R.id.toolbar1);
setSupportActionBar(toolbar1);
getSupportActionBar().setDisplayShowTitleEnabled(false);
{
}
}
void Versionshwocode() {
VR_Name = (TextView) findViewById(R.id.VR_code);
PackageManager packageManager = getPackageManager();
PackageInfo info = null;
try {
info = packageManager.getPackageInfo(getPackageName(), 0);
VR_Name.setText(info.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
private void SendEmail() {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "koohi6739@gmail.com", null));
intent.putExtra("android.intent.extra.SUBJECT", "Send From Application Android");
startActivity(Intent.createChooser(intent, "لطفا انتخاب کنید"));
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
{
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.aboutus_2, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.about_ns:
case R.id.flsh:
Intent i = new Intent(Main2Activity.this, MainActivity.class);
startActivity(i);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
| UTF-8 | Java | 3,172 | java | Main2Activity.java | Java | [
{
"context": "Intent.ACTION_SENDTO, Uri.fromParts(\"mailto\", \"koohi6739@gmail.com\", null));\n intent.putExtra(\"android.intent",
"end": 2139,
"score": 0.9995250701904297,
"start": 2123,
"tag": "EMAIL",
"value": "hi6739@gmail.com"
}
] | null | [] | package koohi.koohi;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Main2Activity extends AppCompatActivity {
Toolbar toolbar1;
Button button12, button2323;
TextView VR_Name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
button12 = (Button) findViewById(R.id.Button_gmali);
button12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SendEmail();
}
});
button2323 = (Button) findViewById(R.id.Button_report);
button2323.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent Button_sd = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/joinchat/AAAAAE46F2eQwRB9pLdGwA"));
startActivity(Button_sd);
}
});
Versionshwocode();
toolbar1 = (Toolbar) findViewById(R.id.toolbar1);
setSupportActionBar(toolbar1);
getSupportActionBar().setDisplayShowTitleEnabled(false);
{
}
}
void Versionshwocode() {
VR_Name = (TextView) findViewById(R.id.VR_code);
PackageManager packageManager = getPackageManager();
PackageInfo info = null;
try {
info = packageManager.getPackageInfo(getPackageName(), 0);
VR_Name.setText(info.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
private void SendEmail() {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "koo<EMAIL>", null));
intent.putExtra("android.intent.extra.SUBJECT", "Send From Application Android");
startActivity(Intent.createChooser(intent, "لطفا انتخاب کنید"));
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
{
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.aboutus_2, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.about_ns:
case R.id.flsh:
Intent i = new Intent(Main2Activity.this, MainActivity.class);
startActivity(i);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
| 3,163 | 0.635845 | 0.624129 | 107 | 28.495327 | 26.309578 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.560748 | false | false | 13 |
d28dd8550f7e85d4f8cca22c4a31e8d5fbbb7374 | 35,347,580,865,015 | a09ffeb6bea88cc6ee1a06aca1b60583128a33e3 | /src/other/Nine.java | ae683e2fd87e1b3e77fa5f3c8fb89fe02ae42980 | [] | no_license | qlxazm/leetcode-offer | https://github.com/qlxazm/leetcode-offer | 06b489e0ecee4abcae14be338226b9fbcb097fed | f83186faaad4308c2fc81912d8413a48164837b4 | refs/heads/master | 2022-12-11T15:53:59.237000 | 2020-09-11T13:34:43 | 2020-09-11T13:34:43 | 272,159,736 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package other;
import java.util.Scanner;
/**
* @author yd
* @date 2020/4/11 19:08
*/
public class Nine {
/**
* 接收两个表示9进制数的字符串,返回表示它们相加后的9进制数的字符串
* @param num1 string字符串 第一个加数
* @param num2 string字符串 第二个加数
* @return string字符串
*/
public String add (String num1, String num2) {
int i1 = num1.indexOf(".");
int i2 = num2.indexOf(".");
int len1 = num1.length();
int len2 = num2.length();
// 没有小数部分
if (i1 == -1 && i2 == -1) {
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2, 9);
return Integer.toString(a + b, 9);
} else if (i1 == -1) {
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2.substring(0, i2), 9);
return Integer.toString(a + b, 9) + "." + num2.substring(i2 + 1);
} else if (i2 == -1) {
int a = Integer.parseInt(num1.substring(0, i1), 9);
int b = Integer.parseInt(num2, 9);
return Integer.toString(a + b, 9) + "." + num1.substring(i1 + 1);
} else {
// 小数点的长度
int size = Math.max(len1 - i1, len2 - i2) - 1;
int k = len1 - i1 - 1;
while (k < size) {
num1 += "0";
k++;
}
k = len2 - i2 - 1;
while (k < size) {
num2 += "0";
}
num1 = num1.replace(".", "");
num2 = num2.replace(".", "");
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2, 9);
String ans = Integer.toString(a + b, 9);
return ans.substring(0, ans.length() - size) + "." + ans.substring(ans.length() - size);
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] num = scanner.nextLine().split(",");
Nine nine = new Nine();
System.out.println(nine.add(num[0], num[1]));
}
}
| UTF-8 | Java | 2,141 | java | Nine.java | Java | [
{
"context": " other;\n\nimport java.util.Scanner;\n\n/**\n * @author yd\n * @date 2020/4/11 19:08\n */\npublic class Nine {\n",
"end": 60,
"score": 0.9996083974838257,
"start": 58,
"tag": "USERNAME",
"value": "yd"
}
] | null | [] | package other;
import java.util.Scanner;
/**
* @author yd
* @date 2020/4/11 19:08
*/
public class Nine {
/**
* 接收两个表示9进制数的字符串,返回表示它们相加后的9进制数的字符串
* @param num1 string字符串 第一个加数
* @param num2 string字符串 第二个加数
* @return string字符串
*/
public String add (String num1, String num2) {
int i1 = num1.indexOf(".");
int i2 = num2.indexOf(".");
int len1 = num1.length();
int len2 = num2.length();
// 没有小数部分
if (i1 == -1 && i2 == -1) {
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2, 9);
return Integer.toString(a + b, 9);
} else if (i1 == -1) {
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2.substring(0, i2), 9);
return Integer.toString(a + b, 9) + "." + num2.substring(i2 + 1);
} else if (i2 == -1) {
int a = Integer.parseInt(num1.substring(0, i1), 9);
int b = Integer.parseInt(num2, 9);
return Integer.toString(a + b, 9) + "." + num1.substring(i1 + 1);
} else {
// 小数点的长度
int size = Math.max(len1 - i1, len2 - i2) - 1;
int k = len1 - i1 - 1;
while (k < size) {
num1 += "0";
k++;
}
k = len2 - i2 - 1;
while (k < size) {
num2 += "0";
}
num1 = num1.replace(".", "");
num2 = num2.replace(".", "");
int a = Integer.parseInt(num1, 9);
int b = Integer.parseInt(num2, 9);
String ans = Integer.toString(a + b, 9);
return ans.substring(0, ans.length() - size) + "." + ans.substring(ans.length() - size);
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] num = scanner.nextLine().split(",");
Nine nine = new Nine();
System.out.println(nine.add(num[0], num[1]));
}
}
| 2,141 | 0.473475 | 0.431334 | 65 | 30.030769 | 21.589861 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 13 |
ba379f44047c49d39215bfb96a385feeeb2c5141 | 31,301,721,704,301 | df5e629b5fd66b06610735b6513f740bf3e2029c | /src/main/java/com/niit_team/student_management/Repository/StudentRepository.java | 049b383f9ca76a853495c1ebc6816fe978852c57 | [] | no_license | ChouTreeMan/student_management | https://github.com/ChouTreeMan/student_management | 65d8da7e50ef25b783807fa5381e63bb7319c1f1 | 79b54d31354de4395a81fae6a06f4dc755d03e42 | refs/heads/master | 2023-02-18T21:26:33.694000 | 2021-01-13T13:55:53 | 2021-01-13T13:55:53 | 328,933,003 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.niit_team.student_management.Repository;
import com.niit_team.student_management.Entity.StudentInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
@EnableJpaRepositories
public interface StudentRepository extends JpaRepository<StudentInfo,Integer> {
/*根据与login_id(登录表)对应的name(学生信息表)查询stu_id*/
@Query(value = "select stu_id from student_details where name = :name", nativeQuery = true)
int dispatch(@Param("name")String login_id);
/*学生更新自己个人信息*/
@Query(value = "update student_details set age=:age," +
"date_of_birth=:date,blood_group=:bg,address=:addr," +
"phone_number=:phone,email=:email where stu_id=:stu_id",
nativeQuery = true)
@Modifying
void updateStu(@Param("stu_id")int stu_id,
@Param("age")int age,
@Param("date")String date,
@Param("bg")String bg,
@Param("addr")String addr,
@Param("phone")String phone,
@Param("email")String email);
}
| UTF-8 | Java | 1,440 | java | StudentRepository.java | Java | [] | null | [] | package com.niit_team.student_management.Repository;
import com.niit_team.student_management.Entity.StudentInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
@EnableJpaRepositories
public interface StudentRepository extends JpaRepository<StudentInfo,Integer> {
/*根据与login_id(登录表)对应的name(学生信息表)查询stu_id*/
@Query(value = "select stu_id from student_details where name = :name", nativeQuery = true)
int dispatch(@Param("name")String login_id);
/*学生更新自己个人信息*/
@Query(value = "update student_details set age=:age," +
"date_of_birth=:date,blood_group=:bg,address=:addr," +
"phone_number=:phone,email=:email where stu_id=:stu_id",
nativeQuery = true)
@Modifying
void updateStu(@Param("stu_id")int stu_id,
@Param("age")int age,
@Param("date")String date,
@Param("bg")String bg,
@Param("addr")String addr,
@Param("phone")String phone,
@Param("email")String email);
}
| 1,440 | 0.674638 | 0.674638 | 30 | 45 | 23.280893 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 13 |
e40a5f8eecf4dd29ec90aa5856f042df99396bec | 35,785,667,530,221 | 34b96d362aeb261dcd6b37fcd534c1340c799663 | /src/test/java/com/Aviana/test/Avianca/page/Comprar.java | 31a0130c9fe0620eaab9fbc170471255fb8829b9 | [] | no_license | Castel2/Avianca | https://github.com/Castel2/Avianca | 7b5c3a07a1abb2fe3c0da39a0afab8c17d8fcb9c | b4b7d2ebee0b2f716df1e8545b6e2fed2d671053 | refs/heads/main | 2023-03-28T13:24:03.140000 | 2021-03-29T06:35:08 | 2021-03-29T06:35:08 | 352,517,984 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.Aviana.test.Avianca.page;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import com.Aviana.test.Avianca.BasePOM.BasePOM;
public class Comprar extends BasePOM{
By desde = By.xpath("//span[text()='Explora destinos']");
By hacia = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[1]/fieldset/div/div[3]/div[2]/label/div/input[1]");
By destino = By.xpath("//div[text()='África']");
By destino2 = By.xpath("//div[text()='Marruecos']");
By destino3 = By.xpath("//div[@data-id='CMN']");
By ida = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[2]/fieldset/div/div/div[1]/label/div/input[1]");
By soloIDa = By.xpath("//a[text()='Solo ida']");
By buscar = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[3]/fieldset/div/div[4]/button");
public Comprar(WebDriver driver) {
super(driver);
// TODO Auto-generated constructor stub
}
public void diligenciar() {
wait(7, soloIDa);
click(soloIDa);
click(hacia);
wait(7, desde);
click(desde);
wait(7, destino);
click(destino);
wait(7, destino2);
click(destino2);
wait(7, destino3);
click(destino3);
wait(7, ida);
write("Jue, 1 abr.", ida);
wait(7, buscar);
click(buscar);
}
}
| UTF-8 | Java | 1,538 | java | Comprar.java | Java | [
{
"context": "no3);\n\t\tclick(destino3);\n\t\twait(7, ida);\n\t\twrite(\"Jue, 1 abr.\", ida);\n\t\twait(7, buscar);\n\t\tclick(busc",
"end": 1474,
"score": 0.7745648622512817,
"start": 1473,
"tag": "NAME",
"value": "J"
}
] | null | [] | package com.Aviana.test.Avianca.page;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import com.Aviana.test.Avianca.BasePOM.BasePOM;
public class Comprar extends BasePOM{
By desde = By.xpath("//span[text()='Explora destinos']");
By hacia = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[1]/fieldset/div/div[3]/div[2]/label/div/input[1]");
By destino = By.xpath("//div[text()='África']");
By destino2 = By.xpath("//div[text()='Marruecos']");
By destino3 = By.xpath("//div[@data-id='CMN']");
By ida = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[2]/fieldset/div/div/div[1]/label/div/input[1]");
By soloIDa = By.xpath("//a[text()='Solo ida']");
By buscar = By.xpath("/html/body/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div[1]/div/div[2]/div/div/section/div[3]/div[3]/div[2]/div/form/div/div[2]/div/div/div[3]/fieldset/div/div[4]/button");
public Comprar(WebDriver driver) {
super(driver);
// TODO Auto-generated constructor stub
}
public void diligenciar() {
wait(7, soloIDa);
click(soloIDa);
click(hacia);
wait(7, desde);
click(desde);
wait(7, destino);
click(destino);
wait(7, destino2);
click(destino2);
wait(7, destino3);
click(destino3);
wait(7, ida);
write("Jue, 1 abr.", ida);
wait(7, buscar);
click(buscar);
}
}
| 1,538 | 0.657124 | 0.62069 | 44 | 33.93182 | 51.597393 | 222 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.022727 | false | false | 13 |
13be49c6b31239176ff00afdb8231fbfb43dc41d | 8,443,905,749,393 | 2bfc33589c5d0f4436a5c133e954d024f321b9bd | /src/com/proxy/HelloWorldHandler.java | 5371eb113eca404083a70b2b0e124e167ca4ea71 | [
"Apache-2.0"
] | permissive | judedmsx/java | https://github.com/judedmsx/java | 710dfc34b28d16b2d885a8f68214430858c61369 | 282c09ce2588b80e1f4ee8a5ac8ee2f0f62971bd | refs/heads/master | 2021-01-11T06:33:21.646000 | 2017-05-21T06:50:38 | 2017-05-21T06:50:38 | 69,222,332 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
public class HelloWorldHandler implements InvocationHandler{
private Object target;
public HelloWorldHandler(Object obj){
super();
target = obj;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Object result = null;
doBefore();
result = method.invoke(target, args);
doAfter();
return result;
}
public void doBefore(){
System.out.println("before method invoke");
}
public void doAfter(){
System.out.println("after method invoke");
}
}
| UTF-8 | Java | 621 | java | HelloWorldHandler.java | Java | [] | null | [] | package com.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
public class HelloWorldHandler implements InvocationHandler{
private Object target;
public HelloWorldHandler(Object obj){
super();
target = obj;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Object result = null;
doBefore();
result = method.invoke(target, args);
doAfter();
return result;
}
public void doBefore(){
System.out.println("before method invoke");
}
public void doAfter(){
System.out.println("after method invoke");
}
}
| 621 | 0.719807 | 0.719807 | 33 | 17.818182 | 18.332706 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.575758 | false | false | 13 |
435052b571e1da488e798f278b011309bc3123b5 | 8,443,905,750,247 | d241bdac077d963a7147c4aa22e167644e0886a6 | /src/main/java/fr/piroxxi/factorygame/core/exceptions/IllegalGameAction.java | b7caa44e7d119ff6bc1b8281c252618cb896d200 | [] | no_license | piroxxi/FactoryGame | https://github.com/piroxxi/FactoryGame | a12cefc37f85ae6b10a7b9b3c48c4b8331952fc3 | 5b2cadac5932973e65a12284c13721ef279d7353 | refs/heads/master | 2021-01-19T00:17:59.462000 | 2016-11-12T06:20:08 | 2016-11-12T06:20:08 | 72,997,970 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fr.piroxxi.factorygame.core.exceptions;
public class IllegalGameAction extends Throwable {
public IllegalGameAction(String message) {
super(message);
}
}
| UTF-8 | Java | 179 | java | IllegalGameAction.java | Java | [] | null | [] | package fr.piroxxi.factorygame.core.exceptions;
public class IllegalGameAction extends Throwable {
public IllegalGameAction(String message) {
super(message);
}
}
| 179 | 0.743017 | 0.743017 | 7 | 24.571428 | 21.225706 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 13 |
3454376308cdd7b08a99d8cd2782f7f4620eb7c6 | 23,656,679,910,459 | 9d4b037b0e4ed1e3ccd70d261c23fea055fe056d | /demo_selenium_advanced/src/main/java/Day1/Basic_annodations.java | 073e42ad748d4463e250c662711f3703ee4f5ed7 | [] | no_license | Princy3194/Selenium | https://github.com/Princy3194/Selenium | 32272781dd7c904a989b67788f619c11683c1d57 | c178d8947c6ebf26b0a48d192a1088dd31d82080 | refs/heads/master | 2020-03-29T01:40:19.894000 | 2018-09-19T07:40:13 | 2018-09-19T07:40:13 | 149,400,587 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Basic_annodations {
@Test
public void testcase1() throws InterruptedException {
// step 1: Set the system property
System.setProperty("webdriver.chrome.driver","C:\\Users\\A07208trng_B4a.04.28\\Desktop\\chromedriver.exe");
//step 2: Launch the browser
WebDriver driver= new ChromeDriver();
//Step: Launch the URL
driver.get("https://www.google.com/");
Thread.sleep(2000);
driver.close();
}
}
| UTF-8 | Java | 623 | java | Basic_annodations.java | Java | [] | null | [] | package Day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Basic_annodations {
@Test
public void testcase1() throws InterruptedException {
// step 1: Set the system property
System.setProperty("webdriver.chrome.driver","C:\\Users\\A07208trng_B4a.04.28\\Desktop\\chromedriver.exe");
//step 2: Launch the browser
WebDriver driver= new ChromeDriver();
//Step: Launch the URL
driver.get("https://www.google.com/");
Thread.sleep(2000);
driver.close();
}
}
| 623 | 0.669342 | 0.640449 | 31 | 18.096775 | 23.657986 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.516129 | false | false | 13 |
d7e9a9643334966a13369402e71a6c1c5e3eb262 | 36,807,869,744,110 | f063863fd3a1db8a4506f6fd0c795834171cfe1a | /src/main/java/io/github/nhannht/webquizzangular/repository/QuizRepository.java | 45b872b0160790dbb49a5d4cdeffa005dd323dde | [] | no_license | nhanclassroom/web-quizz-angular-backend | https://github.com/nhanclassroom/web-quizz-angular-backend | 9c7ce661910744bf5a21d1fb85e20bb6abfced94 | 50cc3e0b08f110da98b90f8e1610ecb8a52a9820 | refs/heads/master | 2023-08-16T23:43:57.852000 | 2021-09-21T11:50:21 | 2021-09-21T11:50:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.nhannht.webquizzangular.repository;
import io.github.nhannht.webquizzangular.entity.Quiz;
import io.github.nhannht.webquizzangular.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface QuizRepository extends JpaRepository<Quiz, Long> {
Page<Quiz> findAllBy(Pageable pageable);
Page<Quiz> findAllByUser(User user, Pageable pageable);
@Query(value = "select * from quiz where user_answered contains ?1 and completed_at is not null",nativeQuery = true)
Page<Quiz> findAllQuizThatAnswerByUser(User user,Pageable pageable);
@Query(value = "select * from quiz where completed_at is not null",nativeQuery = true)
Page<Quiz> findAllByAndCompletedAtIsNotNull(Pageable pageable);
}
| UTF-8 | Java | 965 | java | QuizRepository.java | Java | [
{
"context": "package io.github.nhannht.webquizzangular.repository;\n\nimport io.github.nha",
"end": 25,
"score": 0.9977028369903564,
"start": 18,
"tag": "USERNAME",
"value": "nhannht"
},
{
"context": "nht.webquizzangular.repository;\n\nimport io.github.nhannht.webquizzangular.entity... | null | [] | package io.github.nhannht.webquizzangular.repository;
import io.github.nhannht.webquizzangular.entity.Quiz;
import io.github.nhannht.webquizzangular.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface QuizRepository extends JpaRepository<Quiz, Long> {
Page<Quiz> findAllBy(Pageable pageable);
Page<Quiz> findAllByUser(User user, Pageable pageable);
@Query(value = "select * from quiz where user_answered contains ?1 and completed_at is not null",nativeQuery = true)
Page<Quiz> findAllQuizThatAnswerByUser(User user,Pageable pageable);
@Query(value = "select * from quiz where completed_at is not null",nativeQuery = true)
Page<Quiz> findAllByAndCompletedAtIsNotNull(Pageable pageable);
}
| 965 | 0.803109 | 0.802073 | 19 | 49.736843 | 29.733627 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.894737 | false | false | 13 |
842cbaf151e829752079df2eb344c96074e16cc1 | 36,721,970,396,626 | 67b6565904c2895daae1570131430367b34ddfbd | /src/main/java/cn/org/chtf/card/manage/ReportManagement/dao/CertificateStatisticsTableMapper.java | 23a5341da6cc3635fb462ccd57d9695997acdd95 | [] | no_license | bellmit/exhibition | https://github.com/bellmit/exhibition | 0035c20fe0412e89980924f9df284c3e9afc3e57 | 50c101a35afb5d5d402dcb464344ef79713005de | refs/heads/master | 2023-07-09T13:56:58.603000 | 2021-08-17T14:31:17 | 2021-08-17T14:31:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.org.chtf.card.manage.ReportManagement.dao;
import java.util.Map;
public interface CertificateStatisticsTableMapper {
Map<String, Object> getStatisticalInfo(Map<String, Object> map);
}
| UTF-8 | Java | 198 | java | CertificateStatisticsTableMapper.java | Java | [] | null | [] | package cn.org.chtf.card.manage.ReportManagement.dao;
import java.util.Map;
public interface CertificateStatisticsTableMapper {
Map<String, Object> getStatisticalInfo(Map<String, Object> map);
}
| 198 | 0.808081 | 0.808081 | 7 | 27.285715 | 26.364014 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false | 13 |
d7b269101515901916e550115f9e652fb3535498 | 19,439,022,048,782 | db2ca48fffaf6689c9db439abaf9d98729548e0b | /minsu-service/minsu-service-cms/minsu-service-cms-provider/src/main/java/com/ziroom/minsu/services/cms/dao/ActivityApplyDao.java | c8fae68863e5d4d9a4ab17c499183d6acc062455 | [] | no_license | majinwen/sojourn | https://github.com/majinwen/sojourn | 46a950dbd64442e4ef333c512eb956be9faef50d | ab98247790b1951017fc7dd340e1941d5b76dc39 | refs/heads/master | 2020-03-22T07:07:05.299000 | 2018-03-18T13:45:23 | 2018-03-18T13:45:23 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ziroom.minsu.services.cms.dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.asura.framework.base.exception.BusinessException;
import com.asura.framework.base.paging.PagingResult;
import com.asura.framework.base.util.Check;
import com.asura.framework.base.util.UUIDGenerator;
import com.asura.framework.dao.mybatis.base.MybatisDaoContext;
import com.asura.framework.dao.mybatis.paginator.domain.PageBounds;
import com.asura.framework.utils.LogUtil;
import com.ziroom.minsu.entity.cms.ActivityApplyEntity;
import com.ziroom.minsu.services.cms.dto.LanApplayRequest;
import com.ziroom.minsu.services.cms.entity.ActivityApplyVo;
/**
* <p>活动申请Dao</p>
*
* <PRE>
* <BR> 修改记录
* <BR>-----------------------------------------------
* <BR> 修改日期 修改人 修改内容
* </PRE>
* @author lishaochuan on 2016年6月29日
* @since 1.0
* @version 1.0
*/
@Repository("cms.activityApplyDao")
public class ActivityApplyDao {
/**
* 日志对象
*/
private static Logger LOGGER = LoggerFactory.getLogger(ActivityApplyDao.class);
private String SQLID = "cms.activityApplyDao.";
@Autowired
@Qualifier("cms.MybatisDaoContext")
private MybatisDaoContext mybatisDaoContext;
/**
* 根据手机号查询申请信息
* @author lishaochuan
* @create 2016年6月30日上午10:12:25
* @param mobile
* @return
*/
public ActivityApplyEntity getApplyByMobile(String mobile){
if (Check.NuNStr(mobile)) {
LogUtil.error(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
return mybatisDaoContext.findOne(SQLID + "selectByMoblie", ActivityApplyEntity.class, mobile);
}
/**
* 保存活动申请信息
* @author lishaochuan
* @create 2016年6月29日下午3:24:48
* @param apply
* @return
*/
public int save(ActivityApplyEntity apply) {
if (Check.NuNObj(apply)) {
LogUtil.error(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
if (Check.NuNStr(apply.getFid())) {
apply.setFid(UUIDGenerator.hexUUID());
}
return mybatisDaoContext.save(SQLID + "save", apply);
}
/**
*
* 获取申请列表
* @author liyingjie
* @created 2016年6月25日 下午6:47:58
* @param request
* @return
*/
public PagingResult<ActivityApplyVo> getApplayList(LanApplayRequest request){
if(Check.NuNObj(request)){
LogUtil.info(LOGGER, "getApplayList 参数对象为空");
throw new BusinessException("getApplayList 参数对象为空");
}
PageBounds pageBounds = new PageBounds();
pageBounds.setLimit(request.getLimit());
pageBounds.setPage(request.getPage());
return mybatisDaoContext.findForPage(SQLID + "findApplayExtVo", ActivityApplyVo.class, request, pageBounds);
}
/**
* 查询申请详情
* @author zl
* @param applyFid
* @return
*/
public ActivityApplyVo getApplyDetailWithBLOBs(String applyFid){
if (Check.NuNStr(applyFid)) {
LogUtil.info(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
return mybatisDaoContext.findOne(SQLID + "getApplyDetailWithBLOBs", ActivityApplyVo.class, applyFid);
}
}
| UTF-8 | Java | 3,464 | java | ActivityApplyDao.java | Java | [
{
"context": "---\n * <BR>\t修改日期\t\t\t修改人\t\t\t修改内容\n * </PRE>\n * @author lishaochuan on 2016年6月29日\n * @since 1.0\n * @version 1.0\n */\n@",
"end": 999,
"score": 0.9931470155715942,
"start": 988,
"tag": "USERNAME",
"value": "lishaochuan"
},
{
"context": " \n \n /**\n * ... | null | [] | package com.ziroom.minsu.services.cms.dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.asura.framework.base.exception.BusinessException;
import com.asura.framework.base.paging.PagingResult;
import com.asura.framework.base.util.Check;
import com.asura.framework.base.util.UUIDGenerator;
import com.asura.framework.dao.mybatis.base.MybatisDaoContext;
import com.asura.framework.dao.mybatis.paginator.domain.PageBounds;
import com.asura.framework.utils.LogUtil;
import com.ziroom.minsu.entity.cms.ActivityApplyEntity;
import com.ziroom.minsu.services.cms.dto.LanApplayRequest;
import com.ziroom.minsu.services.cms.entity.ActivityApplyVo;
/**
* <p>活动申请Dao</p>
*
* <PRE>
* <BR> 修改记录
* <BR>-----------------------------------------------
* <BR> 修改日期 修改人 修改内容
* </PRE>
* @author lishaochuan on 2016年6月29日
* @since 1.0
* @version 1.0
*/
@Repository("cms.activityApplyDao")
public class ActivityApplyDao {
/**
* 日志对象
*/
private static Logger LOGGER = LoggerFactory.getLogger(ActivityApplyDao.class);
private String SQLID = "cms.activityApplyDao.";
@Autowired
@Qualifier("cms.MybatisDaoContext")
private MybatisDaoContext mybatisDaoContext;
/**
* 根据手机号查询申请信息
* @author lishaochuan
* @create 2016年6月30日上午10:12:25
* @param mobile
* @return
*/
public ActivityApplyEntity getApplyByMobile(String mobile){
if (Check.NuNStr(mobile)) {
LogUtil.error(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
return mybatisDaoContext.findOne(SQLID + "selectByMoblie", ActivityApplyEntity.class, mobile);
}
/**
* 保存活动申请信息
* @author lishaochuan
* @create 2016年6月29日下午3:24:48
* @param apply
* @return
*/
public int save(ActivityApplyEntity apply) {
if (Check.NuNObj(apply)) {
LogUtil.error(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
if (Check.NuNStr(apply.getFid())) {
apply.setFid(UUIDGenerator.hexUUID());
}
return mybatisDaoContext.save(SQLID + "save", apply);
}
/**
*
* 获取申请列表
* @author liyingjie
* @created 2016年6月25日 下午6:47:58
* @param request
* @return
*/
public PagingResult<ActivityApplyVo> getApplayList(LanApplayRequest request){
if(Check.NuNObj(request)){
LogUtil.info(LOGGER, "getApplayList 参数对象为空");
throw new BusinessException("getApplayList 参数对象为空");
}
PageBounds pageBounds = new PageBounds();
pageBounds.setLimit(request.getLimit());
pageBounds.setPage(request.getPage());
return mybatisDaoContext.findForPage(SQLID + "findApplayExtVo", ActivityApplyVo.class, request, pageBounds);
}
/**
* 查询申请详情
* @author zl
* @param applyFid
* @return
*/
public ActivityApplyVo getApplyDetailWithBLOBs(String applyFid){
if (Check.NuNStr(applyFid)) {
LogUtil.info(LOGGER, "参数为空");
throw new BusinessException("参数为空");
}
return mybatisDaoContext.findOne(SQLID + "getApplyDetailWithBLOBs", ActivityApplyVo.class, applyFid);
}
}
| 3,464 | 0.689963 | 0.674569 | 118 | 26.525423 | 24.693962 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.016949 | false | false | 13 |
6e45680424071796e39ace3cfc01e3a2f4684dda | 33,655,363,794,130 | a3aa889ab51ee6cdc772967798ada36d2f66cb4e | /src/bots/runeCrafting/Graahk/resources/pouches/Pouches.java | f94e0aec9325e0cf971a18f35353e1a4e55742c9 | [] | no_license | Skype-calls/Graahk | https://github.com/Skype-calls/Graahk | a6e60d00aa7ae275c6b0b0a9b57cc32ba215f030 | 901bb2f23ee871b275bbf7455964e38e65d94437 | refs/heads/master | 2016-09-11T04:52:38.225000 | 2012-08-24T18:39:00 | 2012-08-24T18:39:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package src.bots.runeCrafting.Graahk.resources.pouches;
import org.powerbot.game.api.methods.Settings;
/**
* Settings for Pouches, I do not take credit, credit goes to xMunch
*/
public class Pouches {
public static boolean allEmpty() {
return Settings.get(486) == 1073741824 && Settings.get(720) == 0;
}
public static boolean smallEmpty() {
return smallCount() == 0 && smallEssType() == null;
}
public static boolean medEmpty() {
return medCount() == 0 && medEssType() == null;
}
public static boolean largeEmpty() {
return largeCount() == 0 && largeEssType() == null;
}
public static boolean giantEmpty() {
return Settings.get(720) < 64 && giantCount() == 0 && giantEssType() == null;
}
public static int smallCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
if (count >= 48) {
count %= 512;
}
if (count > 3) {
count %= 8;
}
return count;
}
public static int medCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
if (count > 48) {
count %= 512;
}
return count / 8;
}
public static int largeCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
return count / 512;
}
public static int giantCount() {
return (Settings.get(486) - 1073741824) / 262144;
}
public static String smallEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
if (type >= 16) {
type %= 16;
}
if (type >= 4) {
if (type < 9) {
type %= 4;
} else {
type %= 9;
}
}
return type == 1 ? " Rune " : type == 2 ? " Pure " : null;
}
public static String medEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
if (type >= 16) {
type %= 16;
}
return type >= 4 && type < 9 ? " Rune " : type >= 9 ? " Pure " : null;
}
public static String largeEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
return type >= 16 && type < 32 ? " Rune " : type >= 32 ? " Pure " : null;
}
public static String giantEssType() {
return Settings.get(720) >= 64 && Settings.get(720) < 128 ? " Rune " : Settings.get(720) >= 128 ? " Pure " : null;
}
}
| UTF-8 | Java | 2,842 | java | Pouches.java | Java | [
{
"context": " for Pouches, I do not take credit, credit goes to xMunch\n */\npublic class Pouches {\n\n public static boo",
"end": 277,
"score": 0.9993386268615723,
"start": 271,
"tag": "USERNAME",
"value": "xMunch"
}
] | null | [] | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package src.bots.runeCrafting.Graahk.resources.pouches;
import org.powerbot.game.api.methods.Settings;
/**
* Settings for Pouches, I do not take credit, credit goes to xMunch
*/
public class Pouches {
public static boolean allEmpty() {
return Settings.get(486) == 1073741824 && Settings.get(720) == 0;
}
public static boolean smallEmpty() {
return smallCount() == 0 && smallEssType() == null;
}
public static boolean medEmpty() {
return medCount() == 0 && medEssType() == null;
}
public static boolean largeEmpty() {
return largeCount() == 0 && largeEssType() == null;
}
public static boolean giantEmpty() {
return Settings.get(720) < 64 && giantCount() == 0 && giantEssType() == null;
}
public static int smallCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
if (count >= 48) {
count %= 512;
}
if (count > 3) {
count %= 8;
}
return count;
}
public static int medCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
if (count > 48) {
count %= 512;
}
return count / 8;
}
public static int largeCount() {
int count = Settings.get(486) - 1073741824;
if (count >= 4608) {
count %= 262144;
}
return count / 512;
}
public static int giantCount() {
return (Settings.get(486) - 1073741824) / 262144;
}
public static String smallEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
if (type >= 16) {
type %= 16;
}
if (type >= 4) {
if (type < 9) {
type %= 4;
} else {
type %= 9;
}
}
return type == 1 ? " Rune " : type == 2 ? " Pure " : null;
}
public static String medEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
if (type >= 16) {
type %= 16;
}
return type >= 4 && type < 9 ? " Rune " : type >= 9 ? " Pure " : null;
}
public static String largeEssType() {
int type = Settings.get(720);
if (type >= 64) {
type %= 64;
}
return type >= 16 && type < 32 ? " Rune " : type >= 32 ? " Pure " : null;
}
public static String giantEssType() {
return Settings.get(720) >= 64 && Settings.get(720) < 128 ? " Rune " : Settings.get(720) >= 128 ? " Pure " : null;
}
}
| 2,842 | 0.485925 | 0.418719 | 111 | 24.603603 | 22.589672 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342342 | false | false | 13 |
bcf174ecd4832ef23fdfaa87c95ff9af2e6f5e18 | 33,655,363,795,625 | 12d3f02ef7e5c840dd50414c582321040eca5f66 | /src/main/java/DataAn/jfreechart/thread/CreateTimeSeriesDataTask2.java | 7fab28fe6da2d286348281ff4e01bad3caae3b9b | [] | no_license | snailhu/RemoteData | https://github.com/snailhu/RemoteData | e89e89143616809b28c5777afb3818228ab6b8ba | 90e24445d5d22021fcb42991aab46cd69ad28c77 | refs/heads/master | 2020-04-12T05:32:04.788000 | 2017-03-20T06:46:39 | 2017-03-20T06:46:39 | 62,614,365 | 0 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package DataAn.jfreechart.thread;
import java.util.Date;
import java.util.concurrent.RecursiveTask;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.Second;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesDataItem;
import DataAn.jfreechart.chart.ChartUtils;
import DataAn.jfreechart.dto.LineTimeSeriesDto2;
/**
* 多线程生成:TimeSeries
*
*/
public class CreateTimeSeriesDataTask2 extends RecursiveTask<TimeSeries>{
private static final long serialVersionUID = 1L;
private TimeSeriesDataItem[] arrayData;
private String paramCode;
private String paramName;
public CreateTimeSeriesDataTask2(TimeSeriesDataItem[] arrayData,
String paramCode, String paramName) {
super();
this.arrayData = arrayData;
this.paramCode = paramCode;
this.paramName = paramName;
}
@Override
protected TimeSeries compute() {
TimeSeries timeseries = ChartUtils.createTimeseries(paramName);
for (TimeSeriesDataItem item : arrayData) {
if(item != null){
// 往序列里面添加数据
// timeseries.addOrUpdate(new Millisecond(lineTimeSeriesDto.getDatetime()), lineTimeSeriesDto.getParamValue());
timeseries.addOrUpdate(item);
}
}
return timeseries;
}
}
| UTF-8 | Java | 1,292 | java | CreateTimeSeriesDataTask2.java | Java | [] | null | [] | package DataAn.jfreechart.thread;
import java.util.Date;
import java.util.concurrent.RecursiveTask;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.Second;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesDataItem;
import DataAn.jfreechart.chart.ChartUtils;
import DataAn.jfreechart.dto.LineTimeSeriesDto2;
/**
* 多线程生成:TimeSeries
*
*/
public class CreateTimeSeriesDataTask2 extends RecursiveTask<TimeSeries>{
private static final long serialVersionUID = 1L;
private TimeSeriesDataItem[] arrayData;
private String paramCode;
private String paramName;
public CreateTimeSeriesDataTask2(TimeSeriesDataItem[] arrayData,
String paramCode, String paramName) {
super();
this.arrayData = arrayData;
this.paramCode = paramCode;
this.paramName = paramName;
}
@Override
protected TimeSeries compute() {
TimeSeries timeseries = ChartUtils.createTimeseries(paramName);
for (TimeSeriesDataItem item : arrayData) {
if(item != null){
// 往序列里面添加数据
// timeseries.addOrUpdate(new Millisecond(lineTimeSeriesDto.getDatetime()), lineTimeSeriesDto.getParamValue());
timeseries.addOrUpdate(item);
}
}
return timeseries;
}
}
| 1,292 | 0.737718 | 0.734548 | 50 | 23.24 | 23.992966 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.54 | false | false | 13 |
cf723f75d54ada7e1e7203ebec5db7b34adb1ed5 | 22,660,247,453,751 | 07cf2402e75319fdd4686c51f9522036f5c20be3 | /cloud-stream-rabbitmq-provider9401/src/main/java/cn/coderblue/springcloud/StreamMqApplication9401.java | cc18c58d4f148aee30cd202fd97f8cbaa58ab50f | [] | no_license | CoderBleu/study-springcloud | https://github.com/CoderBleu/study-springcloud | 09f2f0616b633688568bb19f705e98fded23d04a | 79ce4b1ea6cac208023b41e4e583452f9aeacf75 | refs/heads/main | 2023-03-27T07:38:16.888000 | 2021-04-02T05:57:08 | 2021-04-02T05:57:08 | 329,262,212 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.coderblue.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author coderblue
* @create 2020-02-22 10:54
*/
@SpringBootApplication
public class StreamMqApplication9401 {
public static void main(String[] args) {
SpringApplication.run(StreamMqApplication9401.class, args);
}
}
| UTF-8 | Java | 396 | java | StreamMqApplication9401.java | Java | [
{
"context": "toconfigure.SpringBootApplication;\n\n/**\n * @author coderblue\n * @create 2020-02-22 10:54\n */\n@SpringBootApplic",
"end": 180,
"score": 0.9995549321174622,
"start": 171,
"tag": "USERNAME",
"value": "coderblue"
}
] | null | [] | package cn.coderblue.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author coderblue
* @create 2020-02-22 10:54
*/
@SpringBootApplication
public class StreamMqApplication9401 {
public static void main(String[] args) {
SpringApplication.run(StreamMqApplication9401.class, args);
}
}
| 396 | 0.772727 | 0.722222 | 15 | 25.4 | 23.182753 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
09dc0b3c49ef7ffee8a5e300d76cf9f5ed9d0721 | 25,804,163,580,639 | 1225e59f757cb218ef68cf44701a88264562ac09 | /src/main/java/com/afkl/cases/df/WebConfiguration.java | 4a25793534a2a5da35efe71b5f30dc328ce07177 | [] | no_license | krunalshahbeit2006/original-case | https://github.com/krunalshahbeit2006/original-case | 34d6281912b6157cb83ba3136fff7d138c9f2063 | 22afc29dc7f6a52874204246095c4d2e0ecf4613 | refs/heads/master | 2020-03-27T16:46:32.223000 | 2018-09-02T18:14:36 | 2018-09-02T18:14:36 | 146,805,489 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.afkl.cases.df;
import com.afkl.cases.df.inceptors.StatisticsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Created by KRUNAL SHAH on 09/02/18.
*/
@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {
@Autowired
StatisticsInterceptor statisticsInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(statisticsInterceptor).addPathPatterns("/search");
}
} | UTF-8 | Java | 731 | java | WebConfiguration.java | Java | [
{
"context": "tation.WebMvcConfigurerAdapter;\n\n/**\n * Created by KRUNAL SHAH on 09/02/18.\n */\n@Configuration\npublic class WebC",
"end": 400,
"score": 0.9997995495796204,
"start": 389,
"tag": "NAME",
"value": "KRUNAL SHAH"
}
] | null | [] | package com.afkl.cases.df;
import com.afkl.cases.df.inceptors.StatisticsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Created by <NAME> on 09/02/18.
*/
@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {
@Autowired
StatisticsInterceptor statisticsInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(statisticsInterceptor).addPathPatterns("/search");
}
} | 726 | 0.812585 | 0.804378 | 22 | 32.272728 | 30.121243 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 13 |
32a647b98c421015be055d1c418b5ba646ed71e2 | 33,354,716,087,791 | 6d1f7ee871b3d6b5fea5f30301dd6ca319e077b4 | /upp/src/main/java/upp/backend/handlers/publishing/SaveAndSelectEditor.java | 2f2c669bd4aa052dc490804769693eb3b5061932 | [] | no_license | sankovicivana/LiteralnoUdruzenje | https://github.com/sankovicivana/LiteralnoUdruzenje | 89bba63867114a2c6823d1e15a6c49c5e430e50f | 5034ef664890ec459e18af959d2a497318009501 | refs/heads/main | 2023-03-07T18:11:28.323000 | 2021-02-07T22:16:34 | 2021-02-07T22:16:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package upp.backend.handlers.publishing;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.jvnet.hk2.annotations.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import upp.backend.model.*;
import upp.backend.repository.BookRepository;
import upp.backend.repository.GenreRepository;
import upp.backend.repository.UserRepository;
import java.util.*;
@Service
@Component
public class SaveAndSelectEditor implements JavaDelegate {
@Autowired
UserRepository userRepository;
@Autowired
GenreRepository genreRepository;
@Autowired
BookRepository bookRepository;
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
Map<String,Object> formVariables = delegateExecution.getVariables();
List<User> editors = userRepository.findAllByUserRole(UserRole.EDITOR);
Book book = new Book();
Genre genre = new Genre();
book.setName(formVariables.get("name").toString());
book.setSynopsis(formVariables.get("synopsis").toString());
if (formVariables.get("genres") != null) {
String genres = formVariables.get("genres").toString();
String str[] = genres.split(",");
List<String> genresListIds = new ArrayList<String>();
genresListIds = Arrays.asList(str);
if (genresListIds.isEmpty()) {
System.out.println("ovdeee2");
}
System.out.println(genresListIds);
}
Random rand = new Random();
int randomNumber = rand.nextInt(editors.size());
System.out.println("Random broj je " + randomNumber);
User editor = editors.get(randomNumber);
book.setEditor(editor);
delegateExecution.setVariable("editor", editor.getUsername());
bookRepository.save(book);
genreRepository.save(genre);
//email fali
}
}
| UTF-8 | Java | 2,030 | java | SaveAndSelectEditor.java | Java | [] | null | [] | package upp.backend.handlers.publishing;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.jvnet.hk2.annotations.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import upp.backend.model.*;
import upp.backend.repository.BookRepository;
import upp.backend.repository.GenreRepository;
import upp.backend.repository.UserRepository;
import java.util.*;
@Service
@Component
public class SaveAndSelectEditor implements JavaDelegate {
@Autowired
UserRepository userRepository;
@Autowired
GenreRepository genreRepository;
@Autowired
BookRepository bookRepository;
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
Map<String,Object> formVariables = delegateExecution.getVariables();
List<User> editors = userRepository.findAllByUserRole(UserRole.EDITOR);
Book book = new Book();
Genre genre = new Genre();
book.setName(formVariables.get("name").toString());
book.setSynopsis(formVariables.get("synopsis").toString());
if (formVariables.get("genres") != null) {
String genres = formVariables.get("genres").toString();
String str[] = genres.split(",");
List<String> genresListIds = new ArrayList<String>();
genresListIds = Arrays.asList(str);
if (genresListIds.isEmpty()) {
System.out.println("ovdeee2");
}
System.out.println(genresListIds);
}
Random rand = new Random();
int randomNumber = rand.nextInt(editors.size());
System.out.println("Random broj je " + randomNumber);
User editor = editors.get(randomNumber);
book.setEditor(editor);
delegateExecution.setVariable("editor", editor.getUsername());
bookRepository.save(book);
genreRepository.save(genre);
//email fali
}
}
| 2,030 | 0.687685 | 0.6867 | 61 | 32.27869 | 24.339895 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606557 | false | false | 13 |
e4b565f528ed7ceb29f4a2dde07bd2979df8eb13 | 33,363,305,955,814 | 5403261872bfd5f166ab305567da4a18d3c4ea33 | /modules/lang-expression/src/main/java/org/opensearch/script/expression/GeoField.java | 35be5e25bb0a407adb21c1c82aa69172fe6805aa | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown",
"SSPL-1.0"
] | permissive | opensearch-project/OpenSearch | https://github.com/opensearch-project/OpenSearch | 1f1ec7be4bc949937fbc2156c5bdbcd6f50a7372 | e98ded62d4b672a03acb4beb02bd047d7d4e1c69 | refs/heads/main | 2023-09-03T15:28:02.756000 | 2023-09-02T18:55:09 | 2023-09-02T18:55:09 | 334,274,271 | 7,644 | 1,321 | Apache-2.0 | false | 2023-09-14T21:53:11 | 2021-01-29T22:10:00 | 2023-09-14T20:09:00 | 2023-09-14T21:53:10 | 558,185 | 7,536 | 1,182 | 1,403 | Java | false | false | /*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.script.expression;
import org.apache.lucene.search.DoubleValuesSource;
import org.opensearch.index.fielddata.IndexFieldData;
/**
* Expressions API for geo_point fields.
*/
final class GeoField {
// no instance
private GeoField() {}
// supported variables
static final String EMPTY_VARIABLE = "empty";
static final String LAT_VARIABLE = "lat";
static final String LON_VARIABLE = "lon";
// supported methods
static final String ISEMPTY_METHOD = "isEmpty";
static final String GETLAT_METHOD = "getLat";
static final String GETLON_METHOD = "getLon";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case EMPTY_VARIABLE:
return new GeoEmptyValueSource(fieldData);
case LAT_VARIABLE:
return new GeoLatitudeValueSource(fieldData);
case LON_VARIABLE:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for geo field [" + fieldName + "].");
}
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case ISEMPTY_METHOD:
return new GeoEmptyValueSource(fieldData);
case GETLAT_METHOD:
return new GeoLatitudeValueSource(fieldData);
case GETLON_METHOD:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member method [" + method + "] does not exist for geo field [" + fieldName + "].");
}
}
}
| UTF-8 | Java | 2,885 | java | GeoField.java | Java | [] | null | [] | /*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.script.expression;
import org.apache.lucene.search.DoubleValuesSource;
import org.opensearch.index.fielddata.IndexFieldData;
/**
* Expressions API for geo_point fields.
*/
final class GeoField {
// no instance
private GeoField() {}
// supported variables
static final String EMPTY_VARIABLE = "empty";
static final String LAT_VARIABLE = "lat";
static final String LON_VARIABLE = "lon";
// supported methods
static final String ISEMPTY_METHOD = "isEmpty";
static final String GETLAT_METHOD = "getLat";
static final String GETLON_METHOD = "getLon";
static DoubleValuesSource getVariable(IndexFieldData<?> fieldData, String fieldName, String variable) {
switch (variable) {
case EMPTY_VARIABLE:
return new GeoEmptyValueSource(fieldData);
case LAT_VARIABLE:
return new GeoLatitudeValueSource(fieldData);
case LON_VARIABLE:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member variable [" + variable + "] does not exist for geo field [" + fieldName + "].");
}
}
static DoubleValuesSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
switch (method) {
case ISEMPTY_METHOD:
return new GeoEmptyValueSource(fieldData);
case GETLAT_METHOD:
return new GeoLatitudeValueSource(fieldData);
case GETLON_METHOD:
return new GeoLongitudeValueSource(fieldData);
default:
throw new IllegalArgumentException("Member method [" + method + "] does not exist for geo field [" + fieldName + "].");
}
}
}
| 2,885 | 0.682149 | 0.679376 | 80 | 35.0625 | 30.226786 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.325 | false | false | 13 |
e4f1ea3b969f1c74715b8c932517667ec2f257de | 7,876,970,046,827 | da611a84dc58b1004443edeb0b4b3ab23582e115 | /src/com/deepwelldevelopment/dungeonrun/engine/physics/Hitbox.java | 2779c650b3b6701c26b6ed41edbed69426fd45e6 | [] | no_license | cjs07/Dungeon_Run | https://github.com/cjs07/Dungeon_Run | 292c8f93e94107954fe2ebc67147cd912a4afa88 | 9c56328e4fb828a65e87c3c0abc7274266851259 | refs/heads/master | 2021-01-17T02:49:47.812000 | 2016-10-17T02:31:51 | 2016-10-17T02:31:51 | 59,522,702 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.deepwelldevelopment.dungeonrun.engine.physics;
import java.awt.*;
public class Hitbox extends Rectangle {
public Hitbox(int x, int y, int width, int height) {
super(x, y, width, height);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Hitbox(Rectangle r) {
super(r);
x = (int) r.getX();
y = (int) r.getY();
width = (int) r.getWidth();
height = (int) r.getHeight();
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public Rectangle toRect() {
return new Rectangle(x, y, width, height);
}
}
| UTF-8 | Java | 713 | java | Hitbox.java | Java | [
{
"context": "package com.deepwelldevelopment.dungeonrun.engine.physics;\n\nimport java.awt.*;\n\np",
"end": 31,
"score": 0.6296606063842773,
"start": 16,
"tag": "USERNAME",
"value": "welldevelopment"
}
] | null | [] | package com.deepwelldevelopment.dungeonrun.engine.physics;
import java.awt.*;
public class Hitbox extends Rectangle {
public Hitbox(int x, int y, int width, int height) {
super(x, y, width, height);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Hitbox(Rectangle r) {
super(r);
x = (int) r.getX();
y = (int) r.getY();
width = (int) r.getWidth();
height = (int) r.getHeight();
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public Rectangle toRect() {
return new Rectangle(x, y, width, height);
}
}
| 713 | 0.528752 | 0.528752 | 35 | 19.371429 | 16.974073 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.685714 | false | false | 13 |
92029b8bfc81b91d93dbfc60550818344ca9898e | 9,955,734,213,972 | 875aa02e1ae031bc319cb3d3c48e971e9262b6d0 | /src/main/java/lk/ijse/dep/rcrmoto/business/custom/impl/CustomerBOImpl.java | 3dfea96b40a8ef82893e1626569b2e219507aac1 | [
"MIT"
] | permissive | yohan71/MotorbikeShop-Management-SpringDataJPA-Maven | https://github.com/yohan71/MotorbikeShop-Management-SpringDataJPA-Maven | b0322c71e84e06f96c2979103e8f944c03f2dc5a | 636f2a8d7fa202fe35742ace56083625b2973e57 | refs/heads/master | 2022-11-10T04:56:37.621000 | 2019-12-02T15:26:24 | 2019-12-02T15:26:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package lk.ijse.dep.rcrmoto.business.custom.impl;
import lk.ijse.dep.rcrmoto.business.custom.CustomerBO;
import lk.ijse.dep.rcrmoto.dao.custom.CustomerDAO;
import lk.ijse.dep.rcrmoto.dto.CustomerDTO;
import lk.ijse.dep.rcrmoto.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.List;
@Component
@Transactional
public class CustomerBOImpl implements CustomerBO {
@Autowired
CustomerDAO customerDAO;
@Override
public void saveCustomer(CustomerDTO customer) throws Exception {
customerDAO.save(new Customer(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
@Override
public void updateCustomer(CustomerDTO customer) throws Exception {
customerDAO.save(new Customer(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
@Override
public void deleteCustomer(String id) throws Exception {
customerDAO.deleteById(id);
}
@Override
@Transactional(readOnly = true)
public List<CustomerDTO> findAllCustomers() throws Exception {
List<Customer> all = customerDAO.findAll();
List<CustomerDTO> customerDTOS = new ArrayList<>();
for (Customer customer : all) {
customerDTOS.add(new CustomerDTO(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
return customerDTOS;
}
@Override
@Transactional(readOnly = true)
public String getLastCustomerId() throws Exception {
String lastCustomerId = customerDAO.getLastCustomerId();
return lastCustomerId;
}
@Override
@Transactional(readOnly = true)
public List<CustomerDTO> searchCustomer(String text) throws Exception {
List<Customer> search = customerDAO.searchCustomers(text);
List<CustomerDTO> customers = new ArrayList<>();
for (Customer customer : search) {
customers.add(new CustomerDTO(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
return customers;
}
}
| UTF-8 | Java | 2,286 | java | CustomerBOImpl.java | Java | [] | null | [] | package lk.ijse.dep.rcrmoto.business.custom.impl;
import lk.ijse.dep.rcrmoto.business.custom.CustomerBO;
import lk.ijse.dep.rcrmoto.dao.custom.CustomerDAO;
import lk.ijse.dep.rcrmoto.dto.CustomerDTO;
import lk.ijse.dep.rcrmoto.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.List;
@Component
@Transactional
public class CustomerBOImpl implements CustomerBO {
@Autowired
CustomerDAO customerDAO;
@Override
public void saveCustomer(CustomerDTO customer) throws Exception {
customerDAO.save(new Customer(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
@Override
public void updateCustomer(CustomerDTO customer) throws Exception {
customerDAO.save(new Customer(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
@Override
public void deleteCustomer(String id) throws Exception {
customerDAO.deleteById(id);
}
@Override
@Transactional(readOnly = true)
public List<CustomerDTO> findAllCustomers() throws Exception {
List<Customer> all = customerDAO.findAll();
List<CustomerDTO> customerDTOS = new ArrayList<>();
for (Customer customer : all) {
customerDTOS.add(new CustomerDTO(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
return customerDTOS;
}
@Override
@Transactional(readOnly = true)
public String getLastCustomerId() throws Exception {
String lastCustomerId = customerDAO.getLastCustomerId();
return lastCustomerId;
}
@Override
@Transactional(readOnly = true)
public List<CustomerDTO> searchCustomer(String text) throws Exception {
List<Customer> search = customerDAO.searchCustomers(text);
List<CustomerDTO> customers = new ArrayList<>();
for (Customer customer : search) {
customers.add(new CustomerDTO(customer.getCustomerId(),customer.getName(),customer.getContact()));
}
return customers;
}
}
| 2,286 | 0.709099 | 0.709099 | 65 | 34.169231 | 30.549616 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.507692 | false | false | 13 |
cc432bc3fefa99b8beb334fda7ec3005577e4ff7 | 13,365,938,251,116 | dbb36b8ca79d9c990be16961b8fb08c5746f12e4 | /src/roguelike/creature/creatures/GoblinAI.java | 9bcd4306c6bafb7db182bc144fc10332cbf2da69 | [] | no_license | fiftyfivebells/roguelike-project | https://github.com/fiftyfivebells/roguelike-project | 28dbb7a0350316898cfad0007fb96cd9609f5988 | 5d425937a5a7b004c4a5c56873f8f746cecc32e0 | refs/heads/master | 2020-03-23T18:50:42.716000 | 2018-08-19T02:22:08 | 2018-08-19T02:22:08 | 141,934,319 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package roguelike.creature.creatures;
import roguelike.creature.Creature;
import roguelike.creature.CreatureAI;
import roguelike.creature.Path;
import roguelike.items.Item;
import roguelike.world.Point;
import java.util.List;
public class GoblinAI extends CreatureAI {
private Creature player;
public GoblinAI(Creature creature, Creature player) {
super(creature);
this.player = player;
}
public void onUpdate() {
if (canRangedWeaponAttack(player)) {
creature.rangedWeaponAttack(player);
} else if (canThrowAttack(player)) {
creature.throwItem(getWeaponToThrow(), player.getX(), player.getY(), player.getZ());
} else if (creature.canSee(player.getX(), player.getY(), player.getZ())) {
hunt(player);
} else if (canPickUp()) {
creature.pickup();
if (canUseBetterEquipment()) {
useBetterEquipment();
}
} else {
wander();
}
}
private boolean canRangedWeaponAttack(Creature player) {
return creature.getWeapon() != null
&& creature.getWeapon().getRangedAttackValue() > 0
&& creature.canSee(player.getX(), player.getY(), player.getZ());
}
private boolean canThrowAttack(Creature player) {
return creature.canSee(player.getX(), player.getY(), player.getZ())
&& getWeaponToThrow() != null;
}
private Item getWeaponToThrow() {
Item toThrow = null;
for (Item item : creature.getInventory().getItems()) {
if (item == null || creature.getWeapon() == item || creature.getArmor() == item) {
continue;
}
if (toThrow == null || item.getThrownAttackValue() > toThrow.getAttackValue()) {
toThrow = item;
}
}
return toThrow;
}
private boolean canPickUp() {
return creature.item(creature.getX(), creature.getY(), creature.getZ()) != null
&& !creature.getInventory().isFull();
}
protected boolean canUseBetterEquipment() {
int currentWeaponRating = creature.getWeapon() == null ? 0 : creature.getWeapon().getAttackValue() + creature.getWeapon().getRangedAttackValue();
int currentArmorRating = creature.getArmor() == null ? 0 : creature.getArmor().getDefenseValue() + creature.getWeapon().getDefenseValue();
for (Item item : creature.getInventory().getItems()) {
if (item == null) { continue; }
boolean isArmor = item.getAttackValue() + item.getRangedAttackValue() < item.getDefenseValue();
if (item.getAttackValue() + item.getRangedAttackValue() > currentWeaponRating
|| isArmor && item.getDefenseValue() > currentArmorRating) {
return true;
}
}
return false;
}
protected void useBetterEquipment() {
int currentWeaponRating = creature.getWeapon() == null ? 0 : creature.getWeapon().getAttackValue() + creature.getWeapon().getRangedAttackValue();
int currentArmorRating = creature.getArmor() == null ? 0 : creature.getArmor().getDefenseValue() + creature.getWeapon().getDefenseValue();
for (Item item : creature.getInventory().getItems()) {
if (item == null) { continue; }
boolean isArmor = item.getAttackValue() + item.getRangedAttackValue() < item.getDefenseValue();
if (item.getAttackValue() + item.getRangedAttackValue() > currentWeaponRating
|| isArmor && item.getDefenseValue() > currentArmorRating) {
creature.equip(item);
}
}
}
public void hunt(Creature target) {
List<Point> points = new Path(creature, target.getX(), target.getY()).getPoints();
int mx = points.get(0).getX() - creature.getX();
int my = points.get(0).getY() - creature.getY();
creature.moveBy(mx, my, 0);
}
}
| UTF-8 | Java | 3,995 | java | GoblinAI.java | Java | [] | null | [] | package roguelike.creature.creatures;
import roguelike.creature.Creature;
import roguelike.creature.CreatureAI;
import roguelike.creature.Path;
import roguelike.items.Item;
import roguelike.world.Point;
import java.util.List;
public class GoblinAI extends CreatureAI {
private Creature player;
public GoblinAI(Creature creature, Creature player) {
super(creature);
this.player = player;
}
public void onUpdate() {
if (canRangedWeaponAttack(player)) {
creature.rangedWeaponAttack(player);
} else if (canThrowAttack(player)) {
creature.throwItem(getWeaponToThrow(), player.getX(), player.getY(), player.getZ());
} else if (creature.canSee(player.getX(), player.getY(), player.getZ())) {
hunt(player);
} else if (canPickUp()) {
creature.pickup();
if (canUseBetterEquipment()) {
useBetterEquipment();
}
} else {
wander();
}
}
private boolean canRangedWeaponAttack(Creature player) {
return creature.getWeapon() != null
&& creature.getWeapon().getRangedAttackValue() > 0
&& creature.canSee(player.getX(), player.getY(), player.getZ());
}
private boolean canThrowAttack(Creature player) {
return creature.canSee(player.getX(), player.getY(), player.getZ())
&& getWeaponToThrow() != null;
}
private Item getWeaponToThrow() {
Item toThrow = null;
for (Item item : creature.getInventory().getItems()) {
if (item == null || creature.getWeapon() == item || creature.getArmor() == item) {
continue;
}
if (toThrow == null || item.getThrownAttackValue() > toThrow.getAttackValue()) {
toThrow = item;
}
}
return toThrow;
}
private boolean canPickUp() {
return creature.item(creature.getX(), creature.getY(), creature.getZ()) != null
&& !creature.getInventory().isFull();
}
protected boolean canUseBetterEquipment() {
int currentWeaponRating = creature.getWeapon() == null ? 0 : creature.getWeapon().getAttackValue() + creature.getWeapon().getRangedAttackValue();
int currentArmorRating = creature.getArmor() == null ? 0 : creature.getArmor().getDefenseValue() + creature.getWeapon().getDefenseValue();
for (Item item : creature.getInventory().getItems()) {
if (item == null) { continue; }
boolean isArmor = item.getAttackValue() + item.getRangedAttackValue() < item.getDefenseValue();
if (item.getAttackValue() + item.getRangedAttackValue() > currentWeaponRating
|| isArmor && item.getDefenseValue() > currentArmorRating) {
return true;
}
}
return false;
}
protected void useBetterEquipment() {
int currentWeaponRating = creature.getWeapon() == null ? 0 : creature.getWeapon().getAttackValue() + creature.getWeapon().getRangedAttackValue();
int currentArmorRating = creature.getArmor() == null ? 0 : creature.getArmor().getDefenseValue() + creature.getWeapon().getDefenseValue();
for (Item item : creature.getInventory().getItems()) {
if (item == null) { continue; }
boolean isArmor = item.getAttackValue() + item.getRangedAttackValue() < item.getDefenseValue();
if (item.getAttackValue() + item.getRangedAttackValue() > currentWeaponRating
|| isArmor && item.getDefenseValue() > currentArmorRating) {
creature.equip(item);
}
}
}
public void hunt(Creature target) {
List<Point> points = new Path(creature, target.getX(), target.getY()).getPoints();
int mx = points.get(0).getX() - creature.getX();
int my = points.get(0).getY() - creature.getY();
creature.moveBy(mx, my, 0);
}
}
| 3,995 | 0.604255 | 0.602253 | 109 | 35.651375 | 36.527325 | 153 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.587156 | false | false | 13 |
5daf66490f6bf129cb4d128fa86b272c93c1b184 | 7,756,710,944,474 | 48d7b9dfa3eafc159c21127dc9bcc08d659c7083 | /src/ast/expressions/UnaryMinus.java | 69a46319fbd959a8eab84b14a06505dd524904a8 | [] | no_license | Diecaal/DLP | https://github.com/Diecaal/DLP | e42d1c805f6f194694d95dbe0c420e4c2238b807 | aa6f33ab15bfdfd92d918a4a452446a288a5848b | refs/heads/master | 2023-06-06T20:00:02.278000 | 2021-07-06T00:02:33 | 2021-07-06T00:02:33 | 345,994,669 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ast.expressions;
import ast.Expression;
import semantic.Visitor;
public class UnaryMinus extends AbstractExpression {
private Expression expression;
public UnaryMinus(int line, int column, Expression expression) {
super(line, column);
this.expression = expression;
}
public Expression getExpression() {
return expression;
}
@Override
public <TP, TR> TR accept(Visitor<TP, TR> v, TP param) {
return v.visit(this, param);
}
@Override
public String toString() {
return "-" + getExpression();
}
}
| UTF-8 | Java | 591 | java | UnaryMinus.java | Java | [] | null | [] | package ast.expressions;
import ast.Expression;
import semantic.Visitor;
public class UnaryMinus extends AbstractExpression {
private Expression expression;
public UnaryMinus(int line, int column, Expression expression) {
super(line, column);
this.expression = expression;
}
public Expression getExpression() {
return expression;
}
@Override
public <TP, TR> TR accept(Visitor<TP, TR> v, TP param) {
return v.visit(this, param);
}
@Override
public String toString() {
return "-" + getExpression();
}
}
| 591 | 0.648054 | 0.648054 | 27 | 20.888889 | 19.524597 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.592593 | false | false | 13 |
c9055dc0cacea3e19972dba6f5f7f277e384673b | 32,856,499,874,638 | 983d8d01fee002e685e43b2dd2d01510cf23abe6 | /qvcse-server/src/main/java/com/qumasoft/server/clientrequest/ClientRequestListClientBranches.java | 5aee464730a0ea118056246537ff5c2d9baf9d1a | [
"Apache-2.0"
] | permissive | jimv39/qvcsos | https://github.com/jimv39/qvcsos | 5b509ef957761efc63f10b56e4573b72d5f4da44 | f40337fb4d2a8f63c81df4c946c6c21adfcb27bd | refs/heads/develop | 2023-08-31T09:15:20.388000 | 2023-08-29T20:11:16 | 2023-08-29T20:11:16 | 17,339,971 | 5 | 5 | Apache-2.0 | false | 2023-06-28T23:55:42 | 2014-03-02T15:08:49 | 2022-10-04T01:26:48 | 2023-06-28T23:55:41 | 14,499 | 6 | 2 | 2 | Java | false | false | /* Copyright 2004-2023 Jim Voris
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qumasoft.server.clientrequest;
import com.qumasoft.qvcslib.ClientBranchInfo;
import com.qumasoft.qvcslib.QVCSConstants;
import com.qumasoft.qvcslib.RemotePropertiesBaseClass;
import com.qumasoft.qvcslib.ServerResponseFactoryInterface;
import com.qumasoft.qvcslib.requestdata.ClientRequestListClientBranchesData;
import com.qumasoft.qvcslib.response.AbstractServerManagementResponse;
import com.qumasoft.qvcslib.response.ServerResponseListBranches;
import com.qvcsos.server.DatabaseManager;
import com.qvcsos.server.dataaccess.BranchDAO;
import com.qvcsos.server.dataaccess.CommitDAO;
import com.qvcsos.server.dataaccess.FunctionalQueriesDAO;
import com.qvcsos.server.dataaccess.TagDAO;
import com.qvcsos.server.dataaccess.impl.BranchDAOImpl;
import com.qvcsos.server.dataaccess.impl.CommitDAOImpl;
import com.qvcsos.server.dataaccess.impl.FunctionalQueriesDAOImpl;
import com.qvcsos.server.dataaccess.impl.TagDAOImpl;
import com.qvcsos.server.datamodel.Branch;
import com.qvcsos.server.datamodel.Commit;
import com.qvcsos.server.datamodel.Tag;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* List client branches.
* @author Jim Voris
*/
public class ClientRequestListClientBranches extends AbstractClientRequest {
/**
* Creates a new instance of ClientRequestListClientBranches.
*
* @param data the request data.
*/
public ClientRequestListClientBranches(ClientRequestListClientBranchesData data) {
setRequest(data);
}
@Override
public AbstractServerManagementResponse execute(String userName, ServerResponseFactoryInterface response) {
ServerResponseListBranches listBranchesResponse = new ServerResponseListBranches();
listBranchesResponse.setServerName(getRequest().getServerName());
listBranchesResponse.setProjectName(getRequest().getProjectName());
buildBranchInfo(listBranchesResponse, getRequest().getProjectName());
listBranchesResponse.setSyncToken(getRequest().getSyncToken());
return listBranchesResponse;
}
/**
* Build the list of branches for a given project.
* @param listBranchesResponse the response object into which we populate the list of branches.
* @param projectName the project name.
*/
public static void buildBranchInfo(ServerResponseListBranches listBranchesResponse, String projectName) {
// Get the branches for this project...
FunctionalQueriesDAO functionalQueriesDAO = new FunctionalQueriesDAOImpl(DatabaseManager.getInstance().getSchemaName());
TagDAO tagDAO = new TagDAOImpl(DatabaseManager.getInstance().getSchemaName());
List<Branch> branches = functionalQueriesDAO.findBranchesForProjectName(projectName);
if (branches != null && !branches.isEmpty()) {
List<ClientBranchInfo> clientBranchInfoList = new ArrayList<>();
for (Branch branch : branches) {
ClientBranchInfo branchInfo = new ClientBranchInfo();
branchInfo.setProjectId(branch.getProjectId());
branchInfo.setBranchName(branch.getBranchName());
branchInfo.setBranchId(branch.getId());
Properties branchProperties = new Properties();
// Figure out the name of the branch's parent branch.
String parentBranchName = getParentBranchName(branch);
if (branch.getBranchTypeId() == QVCSConstants.QVCS_TRUNK_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_FEATURE_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsFeatureBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_TAG_BASED_BRANCH_TYPE) {
Tag tag = tagDAO.findById(branch.getTagId());
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsTagBasedBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticTagBasedBranchTag(), tag.getTagText());
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
if (tag.getMoveableFlag()) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticMoveableTagTag(), QVCSConstants.QVCS_YES);
} else {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticMoveableTagTag(), QVCSConstants.QVCS_NO);
}
CommitDAO commitDAO = new CommitDAOImpl(DatabaseManager.getInstance().getSchemaName());
Commit commit = commitDAO.findById(tag.getCommitId());
Long commitTime = commit.getCommitDate().getTime();
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchAnchorDateTag(), String.valueOf(commitTime));
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_RELEASE_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReleaseBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
CommitDAO commitDAO = new CommitDAOImpl(DatabaseManager.getInstance().getSchemaName());
Commit commit = commitDAO.findById(branch.getCommitId());
Long commitTime = commit.getCommitDate().getTime();
branchProperties.setProperty(RemotePropertiesBaseClass.getBranchAnchorDateTag(projectName, branch.getBranchName()), commitTime.toString());
}
branchInfo.setBranchProperties(branchProperties);
clientBranchInfoList.add(branchInfo);
}
listBranchesResponse.setClientBranchInfoList(clientBranchInfoList);
}
}
private static String getParentBranchName(Branch branch) {
String parentBranchName = "";
if (branch.getParentBranchId() != null) {
BranchDAO branchDAO = new BranchDAOImpl(DatabaseManager.getInstance().getSchemaName());
Branch parentBranch = branchDAO.findById(branch.getParentBranchId());
parentBranchName = parentBranch.getBranchName();
}
return parentBranchName;
}
}
| UTF-8 | Java | 7,768 | java | ClientRequestListClientBranches.java | Java | [
{
"context": "/* Copyright 2004-2023 Jim Voris\n *\n * Licensed under the Apache License, Versio",
"end": 34,
"score": 0.9998279213905334,
"start": 25,
"tag": "NAME",
"value": "Jim Voris"
},
{
"context": "operties;\n\n/**\n * List client branches.\n * @author Jim Voris\n */\npubl... | null | [] | /* Copyright 2004-2023 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qumasoft.server.clientrequest;
import com.qumasoft.qvcslib.ClientBranchInfo;
import com.qumasoft.qvcslib.QVCSConstants;
import com.qumasoft.qvcslib.RemotePropertiesBaseClass;
import com.qumasoft.qvcslib.ServerResponseFactoryInterface;
import com.qumasoft.qvcslib.requestdata.ClientRequestListClientBranchesData;
import com.qumasoft.qvcslib.response.AbstractServerManagementResponse;
import com.qumasoft.qvcslib.response.ServerResponseListBranches;
import com.qvcsos.server.DatabaseManager;
import com.qvcsos.server.dataaccess.BranchDAO;
import com.qvcsos.server.dataaccess.CommitDAO;
import com.qvcsos.server.dataaccess.FunctionalQueriesDAO;
import com.qvcsos.server.dataaccess.TagDAO;
import com.qvcsos.server.dataaccess.impl.BranchDAOImpl;
import com.qvcsos.server.dataaccess.impl.CommitDAOImpl;
import com.qvcsos.server.dataaccess.impl.FunctionalQueriesDAOImpl;
import com.qvcsos.server.dataaccess.impl.TagDAOImpl;
import com.qvcsos.server.datamodel.Branch;
import com.qvcsos.server.datamodel.Commit;
import com.qvcsos.server.datamodel.Tag;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* List client branches.
* @author <NAME>
*/
public class ClientRequestListClientBranches extends AbstractClientRequest {
/**
* Creates a new instance of ClientRequestListClientBranches.
*
* @param data the request data.
*/
public ClientRequestListClientBranches(ClientRequestListClientBranchesData data) {
setRequest(data);
}
@Override
public AbstractServerManagementResponse execute(String userName, ServerResponseFactoryInterface response) {
ServerResponseListBranches listBranchesResponse = new ServerResponseListBranches();
listBranchesResponse.setServerName(getRequest().getServerName());
listBranchesResponse.setProjectName(getRequest().getProjectName());
buildBranchInfo(listBranchesResponse, getRequest().getProjectName());
listBranchesResponse.setSyncToken(getRequest().getSyncToken());
return listBranchesResponse;
}
/**
* Build the list of branches for a given project.
* @param listBranchesResponse the response object into which we populate the list of branches.
* @param projectName the project name.
*/
public static void buildBranchInfo(ServerResponseListBranches listBranchesResponse, String projectName) {
// Get the branches for this project...
FunctionalQueriesDAO functionalQueriesDAO = new FunctionalQueriesDAOImpl(DatabaseManager.getInstance().getSchemaName());
TagDAO tagDAO = new TagDAOImpl(DatabaseManager.getInstance().getSchemaName());
List<Branch> branches = functionalQueriesDAO.findBranchesForProjectName(projectName);
if (branches != null && !branches.isEmpty()) {
List<ClientBranchInfo> clientBranchInfoList = new ArrayList<>();
for (Branch branch : branches) {
ClientBranchInfo branchInfo = new ClientBranchInfo();
branchInfo.setProjectId(branch.getProjectId());
branchInfo.setBranchName(branch.getBranchName());
branchInfo.setBranchId(branch.getId());
Properties branchProperties = new Properties();
// Figure out the name of the branch's parent branch.
String parentBranchName = getParentBranchName(branch);
if (branch.getBranchTypeId() == QVCSConstants.QVCS_TRUNK_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_FEATURE_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsFeatureBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_TAG_BASED_BRANCH_TYPE) {
Tag tag = tagDAO.findById(branch.getTagId());
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsTagBasedBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticTagBasedBranchTag(), tag.getTagText());
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
if (tag.getMoveableFlag()) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticMoveableTagTag(), QVCSConstants.QVCS_YES);
} else {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticMoveableTagTag(), QVCSConstants.QVCS_NO);
}
CommitDAO commitDAO = new CommitDAOImpl(DatabaseManager.getInstance().getSchemaName());
Commit commit = commitDAO.findById(tag.getCommitId());
Long commitTime = commit.getCommitDate().getTime();
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchAnchorDateTag(), String.valueOf(commitTime));
} else if (branch.getBranchTypeId() == QVCSConstants.QVCS_RELEASE_BRANCH_TYPE) {
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReleaseBranchFlagTag(), QVCSConstants.QVCS_YES);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticBranchParentTag(), parentBranchName);
branchProperties.setProperty(RemotePropertiesBaseClass.getStaticIsReadOnlyBranchFlagTag(), QVCSConstants.QVCS_NO);
CommitDAO commitDAO = new CommitDAOImpl(DatabaseManager.getInstance().getSchemaName());
Commit commit = commitDAO.findById(branch.getCommitId());
Long commitTime = commit.getCommitDate().getTime();
branchProperties.setProperty(RemotePropertiesBaseClass.getBranchAnchorDateTag(projectName, branch.getBranchName()), commitTime.toString());
}
branchInfo.setBranchProperties(branchProperties);
clientBranchInfoList.add(branchInfo);
}
listBranchesResponse.setClientBranchInfoList(clientBranchInfoList);
}
}
private static String getParentBranchName(Branch branch) {
String parentBranchName = "";
if (branch.getParentBranchId() != null) {
BranchDAO branchDAO = new BranchDAOImpl(DatabaseManager.getInstance().getSchemaName());
Branch parentBranch = branchDAO.findById(branch.getParentBranchId());
parentBranchName = parentBranch.getBranchName();
}
return parentBranchName;
}
}
| 7,762 | 0.718074 | 0.716529 | 137 | 55.700729 | 40.874092 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.686131 | false | false | 13 |
6fb505d5eb6fbafa49304a9ce0f82ad80f0b99b8 | 13,580,686,610,202 | cb016e9e3ff7ad7c21151e62554535ed04a6dd77 | /src/ca/kscheme/primitives/Procedures.java | da2a769078f621123e262e2ccdca9c0a04224e36 | [] | no_license | kdvolder/kscheme | https://github.com/kdvolder/kscheme | 2e40c1d9e8b7162c75a3e9e06df83133f0299888 | aa418d55bafdc1ebee48d5f78d90b1fb9985d939 | refs/heads/master | 2022-12-12T14:39:37.758000 | 2020-09-19T18:19:47 | 2020-09-19T18:19:47 | 296,909,174 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ca.kscheme.primitives;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import ca.kscheme.data.KSchemeException;
import ca.kscheme.data.SProcedure;
import ca.kscheme.interp.Cont;
import ca.kscheme.interp.ErrorWithCont;
import ca.kscheme.interp.KSchemeAssert;
import ca.kscheme.interp.Trampoline;
import ca.kscheme.namespace.ClassFrame;
import ca.kscheme.namespace.SchemeName;
public class Procedures extends ClassFrame {
public Procedures() throws KSchemeException {
super();
}
public final SProcedure apply = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertEquals("number of argumens",2, length(rands));
return apply(car(rands),cadr(rands), k);
} catch (KSchemeException e) {
throw new ErrorWithCont("Applying primitive #apply with rands "+rands,k,e);
}
}
};
public final SProcedure remainder = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 2, length(rands));
return k.applyCont(asInt(car(rands))%asInt(cadr(rands)));
} catch (Exception e) {
return k.raise("apply remainder "+rands, e);
}
}
};
public final SProcedure method = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertTrue("Number of args", length(rands)>=2);
Class<?> cls = asClass(car(rands));
String methodName = asSymbol(cadr(rands)).getName();
Object argTypeList = cddr(rands);
int numArgs = length(argTypeList); // number of arguments, not including receiver
Class<?>[] parameterTypes = new Class<?>[numArgs];
for (int i = 0; i < numArgs; i++) {
parameterTypes[i] = asClass(car(argTypeList));
argTypeList = cdr(argTypeList);
}
Method method = cls.getMethod(methodName, parameterTypes);
if (Modifier.isStatic(method.getModifiers()))
return k.applyCont(new StaticMethodInvoker(method));
else
return k.applyCont(new InstanceMethodInvoker(method));
} catch (Exception e) {
throw new ErrorWithCont("apply #method "+rands, k, e);
}
}
};
public final SProcedure constructor = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
Constructor<?> method;
try {
KSchemeAssert.assertTrue("Need at least one rand",length(rands)>=1);
Class<?> cls = asClass(car(rands));
Object argTypeList = cdr(rands);
int numArgs = length(argTypeList); // number of arguments, not including receiver
Class<?>[] parameterTypes = new Class<?>[numArgs];
for (int i = 0; i < numArgs; i++) {
parameterTypes[i] = asClass(car(argTypeList));
argTypeList = cdr(argTypeList);
}
method = cls.getConstructor(parameterTypes);
} catch (Exception e) {
throw new ErrorWithCont("constructor "+rands, k, e);
}
return k.applyCont(new ConstructorInvoker(method));
}
};
@SchemeName("call-with-current-continuation")
public final SProcedure callCC = new SProcedure() {
@Override
public Trampoline apply(Object rands, final Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 1, length(rands));
return apply(car(rands), list(k), k);
} catch (KSchemeException e) {
throw new ErrorWithCont("apply call/cc "+rands, k, e);
}
}
};
@SchemeName("call-with-handler")
public final SProcedure tryIt = new SProcedure() {
@Override
public Trampoline apply(Object rands, final Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 2, length(rands));
SProcedure body = asProcedure(car(rands));
final SProcedure handler = asProcedure(cadr(rands));
return body.apply(makeNull(), new Cont(null, k) {
// This continuation is is the one that handles exceptions.
@Override
protected Trampoline applyNow(Object value) {
//In non exceptional situation skip over this cont.
return parent.applyCont(value);
}
@Override
public Trampoline raise(Cont origin, Object info, Exception e) {
// In exceptional situations... call the handler
return handler.apply(list(e,origin),parent);
}
});
} catch (KSchemeException e) {
return k.raise("try: "+rands, e);
}
}
};
public final SProcedure error = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
return k.raise(cons(error,rands),new KSchemeException("error"));
}
};
}
| UTF-8 | Java | 4,513 | java | Procedures.java | Java | [] | null | [] | package ca.kscheme.primitives;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import ca.kscheme.data.KSchemeException;
import ca.kscheme.data.SProcedure;
import ca.kscheme.interp.Cont;
import ca.kscheme.interp.ErrorWithCont;
import ca.kscheme.interp.KSchemeAssert;
import ca.kscheme.interp.Trampoline;
import ca.kscheme.namespace.ClassFrame;
import ca.kscheme.namespace.SchemeName;
public class Procedures extends ClassFrame {
public Procedures() throws KSchemeException {
super();
}
public final SProcedure apply = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertEquals("number of argumens",2, length(rands));
return apply(car(rands),cadr(rands), k);
} catch (KSchemeException e) {
throw new ErrorWithCont("Applying primitive #apply with rands "+rands,k,e);
}
}
};
public final SProcedure remainder = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 2, length(rands));
return k.applyCont(asInt(car(rands))%asInt(cadr(rands)));
} catch (Exception e) {
return k.raise("apply remainder "+rands, e);
}
}
};
public final SProcedure method = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
try {
KSchemeAssert.assertTrue("Number of args", length(rands)>=2);
Class<?> cls = asClass(car(rands));
String methodName = asSymbol(cadr(rands)).getName();
Object argTypeList = cddr(rands);
int numArgs = length(argTypeList); // number of arguments, not including receiver
Class<?>[] parameterTypes = new Class<?>[numArgs];
for (int i = 0; i < numArgs; i++) {
parameterTypes[i] = asClass(car(argTypeList));
argTypeList = cdr(argTypeList);
}
Method method = cls.getMethod(methodName, parameterTypes);
if (Modifier.isStatic(method.getModifiers()))
return k.applyCont(new StaticMethodInvoker(method));
else
return k.applyCont(new InstanceMethodInvoker(method));
} catch (Exception e) {
throw new ErrorWithCont("apply #method "+rands, k, e);
}
}
};
public final SProcedure constructor = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
Constructor<?> method;
try {
KSchemeAssert.assertTrue("Need at least one rand",length(rands)>=1);
Class<?> cls = asClass(car(rands));
Object argTypeList = cdr(rands);
int numArgs = length(argTypeList); // number of arguments, not including receiver
Class<?>[] parameterTypes = new Class<?>[numArgs];
for (int i = 0; i < numArgs; i++) {
parameterTypes[i] = asClass(car(argTypeList));
argTypeList = cdr(argTypeList);
}
method = cls.getConstructor(parameterTypes);
} catch (Exception e) {
throw new ErrorWithCont("constructor "+rands, k, e);
}
return k.applyCont(new ConstructorInvoker(method));
}
};
@SchemeName("call-with-current-continuation")
public final SProcedure callCC = new SProcedure() {
@Override
public Trampoline apply(Object rands, final Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 1, length(rands));
return apply(car(rands), list(k), k);
} catch (KSchemeException e) {
throw new ErrorWithCont("apply call/cc "+rands, k, e);
}
}
};
@SchemeName("call-with-handler")
public final SProcedure tryIt = new SProcedure() {
@Override
public Trampoline apply(Object rands, final Cont k) {
try {
KSchemeAssert.assertEquals("Number of rands", 2, length(rands));
SProcedure body = asProcedure(car(rands));
final SProcedure handler = asProcedure(cadr(rands));
return body.apply(makeNull(), new Cont(null, k) {
// This continuation is is the one that handles exceptions.
@Override
protected Trampoline applyNow(Object value) {
//In non exceptional situation skip over this cont.
return parent.applyCont(value);
}
@Override
public Trampoline raise(Cont origin, Object info, Exception e) {
// In exceptional situations... call the handler
return handler.apply(list(e,origin),parent);
}
});
} catch (KSchemeException e) {
return k.raise("try: "+rands, e);
}
}
};
public final SProcedure error = new SProcedure() {
@Override
public Trampoline apply(Object rands, Cont k) {
return k.raise(cons(error,rands),new KSchemeException("error"));
}
};
}
| 4,513 | 0.686018 | 0.684246 | 143 | 30.559441 | 23.988523 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.342657 | false | false | 13 |
e33fc5a87ecc2ce175c45ad3f3ceef55c54dc051 | 28,991,029,258,319 | 2962d1eb4164c7cd2aecad636c87226d6cdfea3d | /app/src/main/java/com/nmp90/hearmythoughts/providers/speech/ISpeechRecognitionProvider.java | 53f4ada8a3f272d01e542a5fcb901b8b4028560d | [] | no_license | n0m0r3pa1n/hear_my_thoughts | https://github.com/n0m0r3pa1n/hear_my_thoughts | b20af149746f47bdb3a6a34472286143587fa6f1 | 8fc18f88a99e271c200f026d8470050d319cb5c2 | refs/heads/master | 2021-05-15T01:31:06.804000 | 2017-02-25T08:31:19 | 2017-02-25T08:31:19 | 31,137,754 | 6 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nmp90.hearmythoughts.providers.speech;
import android.content.Context;
/**
* Created by nmp on 15-3-12.
*/
public interface ISpeechRecognitionProvider {
void startRecognition(Context context, ISpeechRecognitionListener listener);
boolean isStarted();
void stopRecognition();
}
| UTF-8 | Java | 305 | java | ISpeechRecognitionProvider.java | Java | [
{
"context": "import android.content.Context;\n\n/**\n * Created by nmp on 15-3-12.\n */\npublic interface ISpeechRecogniti",
"end": 106,
"score": 0.9994732737541199,
"start": 103,
"tag": "USERNAME",
"value": "nmp"
}
] | null | [] | package com.nmp90.hearmythoughts.providers.speech;
import android.content.Context;
/**
* Created by nmp on 15-3-12.
*/
public interface ISpeechRecognitionProvider {
void startRecognition(Context context, ISpeechRecognitionListener listener);
boolean isStarted();
void stopRecognition();
}
| 305 | 0.767213 | 0.744262 | 12 | 24.416666 | 23.973799 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 13 |
5bfca8ba25854f304156fd7bfe0ded9fecf1ecc8 | 27,444,841,035,223 | 1e3727beecef376d54524669691e3e0522f0b7e1 | /web/src/main/java/com/alibaba/webx/web/module/pipeline/shiro/verifer/impl/Md5UserVeriferImpl.java | c11783e2f49f3beae64678d8d1d21a4b5095d365 | [] | no_license | FranksZhang/webxdemo | https://github.com/FranksZhang/webxdemo | 2ad55e0bd267d023f22b0a58eda6708817a18220 | d9ea37c83f14dd4e53a6597d578dcdf48ca614c8 | refs/heads/master | 2020-12-27T09:44:18.789000 | 2016-05-17T10:46:19 | 2016-05-17T10:46:19 | 55,525,648 | 0 | 0 | null | true | 2016-05-17T10:31:44 | 2016-04-05T16:52:27 | 2016-04-05T16:52:28 | 2016-05-17T10:31:43 | 1,461 | 0 | 0 | 0 | Java | null | null | package com.alibaba.webx.web.module.pipeline.shiro.verifer.impl;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.webx.common.po.authority.User;
import com.alibaba.webx.service.authority.UserService;
import com.alibaba.webx.web.module.pipeline.shiro.verifer.UserVerifer;
/**
*
* @author xiaoMzjm
*
*/
@Component("Md5UserVeriferImpl")
public class Md5UserVeriferImpl implements UserVerifer{
@Autowired
private UserService userService;
@Override
public User getUser(String userName, String password) {
User user = userService.selectByNameFromCache(userName);
if(user != null) {
String md5Password = new Md5Hash(password,user.getSalt(),2).toString();
if(md5Password.equals(user.getPassword())) {
return user;
}
else {
return null;
}
}
return null;
}
}
| UTF-8 | Java | 924 | java | Md5UserVeriferImpl.java | Java | [
{
"context": "ine.shiro.verifer.UserVerifer;\n\n/**\n * \n * @author xiaoMzjm\n *\n */\n@Component(\"Md5UserVeriferImpl\")\npublic cl",
"end": 428,
"score": 0.9995551109313965,
"start": 420,
"tag": "USERNAME",
"value": "xiaoMzjm"
}
] | null | [] | package com.alibaba.webx.web.module.pipeline.shiro.verifer.impl;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.webx.common.po.authority.User;
import com.alibaba.webx.service.authority.UserService;
import com.alibaba.webx.web.module.pipeline.shiro.verifer.UserVerifer;
/**
*
* @author xiaoMzjm
*
*/
@Component("Md5UserVeriferImpl")
public class Md5UserVeriferImpl implements UserVerifer{
@Autowired
private UserService userService;
@Override
public User getUser(String userName, String password) {
User user = userService.selectByNameFromCache(userName);
if(user != null) {
String md5Password = new Md5Hash(password,user.getSalt(),2).toString();
if(md5Password.equals(user.getPassword())) {
return user;
}
else {
return null;
}
}
return null;
}
}
| 924 | 0.757576 | 0.75 | 37 | 23.972973 | 24.552742 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.432432 | false | false | 13 |
1e7ebb5306cbe4f1649f03e87af77abf18fcbd21 | 6,485,400,684,136 | db59e4b56658c4e57a608944b718d3b58a1182f0 | /src/main/java/com/iic/Repository/LoginRepository.java | 736296297ba7ecf2a91332e6a72aeec7dceb44f6 | [] | no_license | mounika2525/projectmgmt | https://github.com/mounika2525/projectmgmt | ecf87ee7f7a9c3e1c6e36ae78d4cfaa2c5b957f4 | ec8116b2af0e1ea6d3bd7b342ec824326043e4c5 | refs/heads/master | 2020-12-03T08:25:42.665000 | 2016-08-17T13:17:50 | 2016-08-17T13:17:50 | 67,692,125 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.iic.Repository;
import com.iic.model.Login;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by mounika on 09/08/16.
*/
@Repository
public interface LoginRepository extends JpaRepository<Login,Long> {
@Query("select l from Login l where l.username = ?1 and l.password = ?2")
public List<Login> findByusernameAndPassword(String username, String password);
}
| UTF-8 | Java | 538 | java | LoginRepository.java | Java | [
{
"context": "sitory;\n\nimport java.util.List;\n\n/**\n * Created by mounika on 09/08/16.\n */\n@Repository\npublic interface Log",
"end": 273,
"score": 0.9996333122253418,
"start": 266,
"tag": "USERNAME",
"value": "mounika"
}
] | null | [] | package com.iic.Repository;
import com.iic.model.Login;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by mounika on 09/08/16.
*/
@Repository
public interface LoginRepository extends JpaRepository<Login,Long> {
@Query("select l from Login l where l.username = ?1 and l.password = ?2")
public List<Login> findByusernameAndPassword(String username, String password);
}
| 538 | 0.776952 | 0.762082 | 18 | 28.888889 | 28.631546 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 13 |
9db9dc4cb673ad02171aeaa989122071252343d6 | 31,086,973,347,623 | c7411da579ca1c2b95a375e4cc8ce64ad164d574 | /src/com/ahmed/tinystartapp/utils/DataUtil.java | ccc19ba0542801bbe4ca9e0851273f2a1b8a3620 | [] | no_license | Ahmedfir/TinyStartApp | https://github.com/Ahmedfir/TinyStartApp | d0279c786b176339889ad9b0606fcd813412da7a | a0b876263bc6268d45addbd02f4423ebc585521e | refs/heads/master | 2016-09-06T02:45:00.964000 | 2014-04-24T19:49:29 | 2014-04-24T19:49:29 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ahmed.tinystartapp.utils;
import java.util.Collection;
import java.util.List;
/**
* Utility class provides methods for data processing.
*
* @see http
* ://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/CryptoSpec
* .html#Cipher
*
* @author Ahmed
*/
public final class DataUtil {
/**
* Internal constructor; not to be called as this class provides static
* utilities only.
*/
private DataUtil() {
throw new UnsupportedOperationException("No instances permitted");
}
/**
* Test if a given string is empty.
*
* @param s
* the string to test
* @return <code> true </code> string is empty, otherwise
* <code> false </code>.
*/
public static boolean isEmpty(final String s) {
return (s == null || s.length() == 0);
}
/**
* Test if a given string is not empty.
*
* @param s
* the string to test
* @return <code> true </code> string is not empty, otherwise
* <code> false </code>.
*/
public static boolean isNotEmpty(final String s) {
return (s != null && s.length() != 0);
}
/**
* Test if a given collection is not empty.
*
* @param <T>
* the type of the collection.
* @param collection
* to test
* @return <code> true </code> collection is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final Collection<T> collection) {
return (collection != null && !collection.isEmpty());
}
/**
* Test if a given collection is empty.
*
* @param <T>
* the type of the collection.
* @param collection
* to test
* @return <code> true </code> collection is empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final Collection<T> collection) {
return (collection == null || collection.isEmpty());
}
/**
* Test if a given arguments is not empty.
*
* @param <T>
* the type of the arguments.
* @param args
* to test
* @return <code> true </code> arguments is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final T... args) {
return (args != null && args.length != 0);
}
/**
* Test if a given arguments is empty.
*
* @param <T>
* the type of the arguments.
* @param args
* to test
* @return <code> true </code> arguments is empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final T... args) {
return (args == null || args.length == 0);
}
/**
* Test if a given argument is not empty.
*
* @param <T>
* the type of the argument.
* @param t
* to test
* @return <code> true </code> argument is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final T t) {
return (t != null);
}
/**
* Test if a given argument is not empty.
*
* @param <T>
* the type of the argument.
* @param t
* to test
* @return <code> true </code> argument is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final T t) {
return (t == null);
}
/**
* Test if a given list is not empty.
*
* @param <T>
* the type of the list.
* @param list
* to test
* @return <code> true </code> list is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final List<T> list) {
return (list != null && !list.isEmpty());
}
/**
* Test if a given list is empty.
*
* @param <T>
* the type of the list.
* @param list
* to test
* @return <code> true </code> list is empty, otherwise <code> false </code>
*/
public static <T> boolean isEmpty(final List<T> list) {
return (list == null || list.isEmpty());
}
/**
* Get the number of elements.
*
* @param args
* @return the number of elements.
*/
public static <T> int sizeOf(T... args) {
return args != null ? args.length : 0;
}
/**
* Get the number of characters.
*
* @param s
* @return
*/
public static <T> int sizeOf(String s) {
return s != null ? s.length() : 0;
}
/**
* Get the number of elements.
*
* @param list
* @return the number of elements.
*/
public static <T> int sizeOf(List<T> list) {
return list != null ? list.size() : 0;
}
/**
* Get the number of elements.
*
* @param collection
* @return the number of elements.
*/
public static <T> int sizeOf(Collection<T> collection) {
return collection != null ? collection.size() : 0;
}
}
| UTF-8 | Java | 4,679 | java | DataUtil.java | Java | [
{
"context": "pto/CryptoSpec\n * .html#Cipher\n * \n * @author Ahmed\n */\npublic final class DataUtil {\n\n\t/**\n\t * Inter",
"end": 295,
"score": 0.999655544757843,
"start": 290,
"tag": "NAME",
"value": "Ahmed"
}
] | null | [] | package com.ahmed.tinystartapp.utils;
import java.util.Collection;
import java.util.List;
/**
* Utility class provides methods for data processing.
*
* @see http
* ://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/CryptoSpec
* .html#Cipher
*
* @author Ahmed
*/
public final class DataUtil {
/**
* Internal constructor; not to be called as this class provides static
* utilities only.
*/
private DataUtil() {
throw new UnsupportedOperationException("No instances permitted");
}
/**
* Test if a given string is empty.
*
* @param s
* the string to test
* @return <code> true </code> string is empty, otherwise
* <code> false </code>.
*/
public static boolean isEmpty(final String s) {
return (s == null || s.length() == 0);
}
/**
* Test if a given string is not empty.
*
* @param s
* the string to test
* @return <code> true </code> string is not empty, otherwise
* <code> false </code>.
*/
public static boolean isNotEmpty(final String s) {
return (s != null && s.length() != 0);
}
/**
* Test if a given collection is not empty.
*
* @param <T>
* the type of the collection.
* @param collection
* to test
* @return <code> true </code> collection is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final Collection<T> collection) {
return (collection != null && !collection.isEmpty());
}
/**
* Test if a given collection is empty.
*
* @param <T>
* the type of the collection.
* @param collection
* to test
* @return <code> true </code> collection is empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final Collection<T> collection) {
return (collection == null || collection.isEmpty());
}
/**
* Test if a given arguments is not empty.
*
* @param <T>
* the type of the arguments.
* @param args
* to test
* @return <code> true </code> arguments is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final T... args) {
return (args != null && args.length != 0);
}
/**
* Test if a given arguments is empty.
*
* @param <T>
* the type of the arguments.
* @param args
* to test
* @return <code> true </code> arguments is empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final T... args) {
return (args == null || args.length == 0);
}
/**
* Test if a given argument is not empty.
*
* @param <T>
* the type of the argument.
* @param t
* to test
* @return <code> true </code> argument is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final T t) {
return (t != null);
}
/**
* Test if a given argument is not empty.
*
* @param <T>
* the type of the argument.
* @param t
* to test
* @return <code> true </code> argument is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isEmpty(final T t) {
return (t == null);
}
/**
* Test if a given list is not empty.
*
* @param <T>
* the type of the list.
* @param list
* to test
* @return <code> true </code> list is not empty, otherwise
* <code> false </code>.
*/
public static <T> boolean isNotEmpty(final List<T> list) {
return (list != null && !list.isEmpty());
}
/**
* Test if a given list is empty.
*
* @param <T>
* the type of the list.
* @param list
* to test
* @return <code> true </code> list is empty, otherwise <code> false </code>
*/
public static <T> boolean isEmpty(final List<T> list) {
return (list == null || list.isEmpty());
}
/**
* Get the number of elements.
*
* @param args
* @return the number of elements.
*/
public static <T> int sizeOf(T... args) {
return args != null ? args.length : 0;
}
/**
* Get the number of characters.
*
* @param s
* @return
*/
public static <T> int sizeOf(String s) {
return s != null ? s.length() : 0;
}
/**
* Get the number of elements.
*
* @param list
* @return the number of elements.
*/
public static <T> int sizeOf(List<T> list) {
return list != null ? list.size() : 0;
}
/**
* Get the number of elements.
*
* @param collection
* @return the number of elements.
*/
public static <T> int sizeOf(Collection<T> collection) {
return collection != null ? collection.size() : 0;
}
}
| 4,679 | 0.574909 | 0.572986 | 200 | 22.395 | 21.084805 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.1 | false | false | 13 |
e0fff71f22ba520c1a587bf465d442feb99c4657 | 1,262,720,454,308 | 68e0bebe891c316997ed7591481d1a755769d13b | /src/BuddyController.java | e86e9d8b1916105a0493f2ccc97d4c61b0443675 | [] | no_license | JoshuaGerwing/sysc3110 | https://github.com/JoshuaGerwing/sysc3110 | 11e185ace2ebc64c1475faf11e80b5d257f32d05 | cc10b45c9700df3f0fb138d19f6e5f3b8c28747f | refs/heads/master | 2021-08-19T22:20:43.571000 | 2017-11-27T15:30:21 | 2017-11-27T15:30:21 | 105,532,680 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class BuddyController implements ActionListener {
private UserInterface gui;
private AddressBook addrBook;
public BuddyController() {
addrBook = new AddressBook();
gui = new UserInterface(this);
}
public static void main(String[] args){
new BuddyController();
}
@Override
public void actionPerformed(ActionEvent arg0) {
String command = arg0.getActionCommand();
if(command.equals(UserInterface.ADD_BUDDY)) {
String buddyName = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's name?");
String buddyAddr = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's address?");
String buddyPhone = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's phone number?");
BuddyInfo newBuddy = new BuddyInfo(buddyName, buddyAddr, buddyPhone);
addrBook.addBuddy(newBuddy);
gui.getListModel().addElement(newBuddy);
}
else if(command.equals(UserInterface.EDIT_BUDDY)) {
if(gui.getSelectedBuddy() != null) {
String buddyName = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's name?", gui.getSelectedBuddy().getName());
String buddyAddr = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's address?", gui.getSelectedBuddy().getAddress());
String buddyPhone = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's phone number?", gui.getSelectedBuddy().getPhone());
BuddyInfo newBuddy = new BuddyInfo(buddyName, buddyAddr, buddyPhone);
addrBook.removeBuddy(gui.getSelectedBuddy());
addrBook.addBuddy(newBuddy);
gui.getListModel().removeElement(gui.getSelectedBuddy());
gui.getListModel().addElement(newBuddy);
}
}
else if(command.equals(UserInterface.REMOVE_BUDDY)) {
addrBook.removeBuddy(gui.getSelectedBuddy());
gui.getListModel().removeElement(gui.getSelectedBuddy());
gui.getRemove().setEnabled(false);
gui.getEdit().setEnabled(false);
}
else if(command.equals(UserInterface.SAVE_ADDR)) {
String s = addrBook.toString();
BufferedWriter out;
try {
out = new BufferedWriter(new FileWriter("savedAddr.txt"));
out.write(s);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
else if(command.equals(UserInterface.READ_ADDR)) {
BufferedReader in = null;
String line;
addrBook.clear();
try {
in = new BufferedReader(new FileReader("savedAddr.txt"));
while ((line = in.readLine()) != null) {
addrBook.addBuddy(BuddyInfo.importBuddy(line));
}
in.close();
} catch (IOException e) {
e.printStackTrace();
};
JLabel label = new JLabel(addrBook.toString());
gui.getListScroll().setViewportView(label);
System.out.println(addrBook.toString());
}
else if(command.equals(UserInterface.DISP_ADDR)) {
/*JLabel label = new JLabel(addrBook.toString());
gui.getListScroll().removeAll();
gui.getListScroll().add(label);*/
}
else if(command.equals(UserInterface.CREATE_ADDR)){
gui.getCreate().setEnabled(false);
gui.getSave().setEnabled(true);
gui.getDisp().setEnabled(true);
gui.getAdd().setEnabled(true);
}
}
}
| UTF-8 | Java | 3,468 | java | BuddyController.java | Java | [] | null | [] | import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class BuddyController implements ActionListener {
private UserInterface gui;
private AddressBook addrBook;
public BuddyController() {
addrBook = new AddressBook();
gui = new UserInterface(this);
}
public static void main(String[] args){
new BuddyController();
}
@Override
public void actionPerformed(ActionEvent arg0) {
String command = arg0.getActionCommand();
if(command.equals(UserInterface.ADD_BUDDY)) {
String buddyName = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's name?");
String buddyAddr = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's address?");
String buddyPhone = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's phone number?");
BuddyInfo newBuddy = new BuddyInfo(buddyName, buddyAddr, buddyPhone);
addrBook.addBuddy(newBuddy);
gui.getListModel().addElement(newBuddy);
}
else if(command.equals(UserInterface.EDIT_BUDDY)) {
if(gui.getSelectedBuddy() != null) {
String buddyName = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's name?", gui.getSelectedBuddy().getName());
String buddyAddr = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's address?", gui.getSelectedBuddy().getAddress());
String buddyPhone = JOptionPane.showInputDialog(gui.getFrame(), "What's your buddy's phone number?", gui.getSelectedBuddy().getPhone());
BuddyInfo newBuddy = new BuddyInfo(buddyName, buddyAddr, buddyPhone);
addrBook.removeBuddy(gui.getSelectedBuddy());
addrBook.addBuddy(newBuddy);
gui.getListModel().removeElement(gui.getSelectedBuddy());
gui.getListModel().addElement(newBuddy);
}
}
else if(command.equals(UserInterface.REMOVE_BUDDY)) {
addrBook.removeBuddy(gui.getSelectedBuddy());
gui.getListModel().removeElement(gui.getSelectedBuddy());
gui.getRemove().setEnabled(false);
gui.getEdit().setEnabled(false);
}
else if(command.equals(UserInterface.SAVE_ADDR)) {
String s = addrBook.toString();
BufferedWriter out;
try {
out = new BufferedWriter(new FileWriter("savedAddr.txt"));
out.write(s);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
else if(command.equals(UserInterface.READ_ADDR)) {
BufferedReader in = null;
String line;
addrBook.clear();
try {
in = new BufferedReader(new FileReader("savedAddr.txt"));
while ((line = in.readLine()) != null) {
addrBook.addBuddy(BuddyInfo.importBuddy(line));
}
in.close();
} catch (IOException e) {
e.printStackTrace();
};
JLabel label = new JLabel(addrBook.toString());
gui.getListScroll().setViewportView(label);
System.out.println(addrBook.toString());
}
else if(command.equals(UserInterface.DISP_ADDR)) {
/*JLabel label = new JLabel(addrBook.toString());
gui.getListScroll().removeAll();
gui.getListScroll().add(label);*/
}
else if(command.equals(UserInterface.CREATE_ADDR)){
gui.getCreate().setEnabled(false);
gui.getSave().setEnabled(true);
gui.getDisp().setEnabled(true);
gui.getAdd().setEnabled(true);
}
}
}
| 3,468 | 0.700115 | 0.699539 | 94 | 34.893616 | 28.95722 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.074468 | false | false | 13 |
417f70f57bdfbdafc9c20a0c17d9af2b3a81baf7 | 12,618,613,959,171 | 154287196588d8db71a170439056f0ad3855569d | /oa/src/main/java/com/hnguigu/oa/service/impl/OaPrivilegeServiceImpl.java | 6c65751325a464f4b591585f7e5cc7d22476b1f0 | [] | no_license | oneboat/oa- | https://github.com/oneboat/oa- | ff803a55caacce6090ed837dbb4591729ccd009c | 90567f8fd0ea5ced9554364d3cf4ac10780583ff | refs/heads/master | 2020-05-02T12:35:16.232000 | 2018-10-18T00:59:19 | 2018-10-18T00:59:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hnguigu.oa.service.impl;
import com.hnguigu.oa.dao.OaPrivilegeMapper;
import com.hnguigu.oa.domain.OaPrivilege;
import com.hnguigu.oa.domain.OaRole;
import com.hnguigu.oa.service.OaPrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @program: oa
* @description: ${description}
* @author: 徐子楼
* @create: 2018-08-28 16:22
**/
@Service
@Transactional
public class OaPrivilegeServiceImpl implements OaPrivilegeService {
@Autowired
private OaPrivilegeMapper oaPrivilegeMapper;
@Override
public List<OaPrivilege> findPricilegeByRole(OaRole role) {
return this.oaPrivilegeMapper.findPricilegeByRole(role);
}
}
| UTF-8 | Java | 828 | java | OaPrivilegeServiceImpl.java | Java | [
{
"context": "m: oa\n * @description: ${description}\n * @author: 徐子楼\n * @create: 2018-08-28 16:22\n **/\n@Service\n@Trans",
"end": 479,
"score": 0.999846339225769,
"start": 476,
"tag": "NAME",
"value": "徐子楼"
}
] | null | [] | package com.hnguigu.oa.service.impl;
import com.hnguigu.oa.dao.OaPrivilegeMapper;
import com.hnguigu.oa.domain.OaPrivilege;
import com.hnguigu.oa.domain.OaRole;
import com.hnguigu.oa.service.OaPrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @program: oa
* @description: ${description}
* @author: 徐子楼
* @create: 2018-08-28 16:22
**/
@Service
@Transactional
public class OaPrivilegeServiceImpl implements OaPrivilegeService {
@Autowired
private OaPrivilegeMapper oaPrivilegeMapper;
@Override
public List<OaPrivilege> findPricilegeByRole(OaRole role) {
return this.oaPrivilegeMapper.findPricilegeByRole(role);
}
}
| 828 | 0.784672 | 0.770073 | 29 | 27.344828 | 22.889956 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.37931 | false | false | 13 |
c12eb4b32683ed2dbae8a5e93cafdd033efc6750 | 8,916,352,151,964 | 65a09e9f4450c6133e6de337dbba373a5510160f | /naifg24/src/main/java/co/simasoft/fileupload/UploadedFile.java | 30f241d6a3c059baea1cd5ba331ae669f6e3acdf | [] | no_license | nelsonjava/simasoft | https://github.com/nelsonjava/simasoft | c0136cdf0c208a5e8d01ab72080330e4a15b1261 | be83eb8ef67758be82bbd811b672572eff1910ee | refs/heads/master | 2021-01-23T15:21:01.981000 | 2017-04-27T12:46:16 | 2017-04-27T12:46:16 | 27,980,384 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package by.creepid.jsf.fileupload;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import org.apache.commons.fileupload.FileItem;
/**
*
* @author rusakovich
*/
public class UploadedFile implements Serializable {
private static final long serialVersionUID = 3932877942216518622L;
private String fileName;
private String contentType;
private long fileSize;
private String longFileName;
private String fileContent;
private InputStream inputStream = null;
private String shortFileName;
public UploadedFile() {
}
public UploadedFile(FileItem fileItem, String longFileName, String shortFileName) {
fileName = fileItem.getName();
contentType = fileItem.getContentType();
fileSize = fileItem.getSize();
fileContent = fileItem.getString();
this.shortFileName = shortFileName;
this.longFileName = longFileName;
try {
inputStream = fileItem.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Deletes the file
*
* @return
*/
public boolean delete() {
File file = new File(longFileName);
return file.delete();
}
public InputStream getInputStream() {
return inputStream;
}
/**
* @return Returns the orginal name of the uploaded file
*/
public String getFileName() {
return fileName;
}
/**
* Returns the content type for the uploaded file
*
* @return
*/
public String getContentType() {
return contentType;
}
/**
* Returns the size of the file in bytes
*
* @return
*/
public long getFileSize() {
return fileSize;
}
/**
* Returns the abosulute path of the uploaded file
*
* @return
*/
public String getLongFileName() {
return longFileName;
}
/**
* Returns the contents of the file in string form
*
* @return
*/
public String getFileContent() {
return fileContent;
}
/**
* Returns the relative path of the uploaded file
*
* @return
*/
public String getShortFileName() {
return shortFileName;
}
}
| UTF-8 | Java | 2,501 | java | UploadedFile.java | Java | [
{
"context": "he.commons.fileupload.FileItem;\n\n/**\n *\n * @author rusakovich\n */\npublic class UploadedFile implements Serializ",
"end": 403,
"score": 0.9960418939590454,
"start": 393,
"tag": "USERNAME",
"value": "rusakovich"
}
] | 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 by.creepid.jsf.fileupload;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import org.apache.commons.fileupload.FileItem;
/**
*
* @author rusakovich
*/
public class UploadedFile implements Serializable {
private static final long serialVersionUID = 3932877942216518622L;
private String fileName;
private String contentType;
private long fileSize;
private String longFileName;
private String fileContent;
private InputStream inputStream = null;
private String shortFileName;
public UploadedFile() {
}
public UploadedFile(FileItem fileItem, String longFileName, String shortFileName) {
fileName = fileItem.getName();
contentType = fileItem.getContentType();
fileSize = fileItem.getSize();
fileContent = fileItem.getString();
this.shortFileName = shortFileName;
this.longFileName = longFileName;
try {
inputStream = fileItem.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Deletes the file
*
* @return
*/
public boolean delete() {
File file = new File(longFileName);
return file.delete();
}
public InputStream getInputStream() {
return inputStream;
}
/**
* @return Returns the orginal name of the uploaded file
*/
public String getFileName() {
return fileName;
}
/**
* Returns the content type for the uploaded file
*
* @return
*/
public String getContentType() {
return contentType;
}
/**
* Returns the size of the file in bytes
*
* @return
*/
public long getFileSize() {
return fileSize;
}
/**
* Returns the abosulute path of the uploaded file
*
* @return
*/
public String getLongFileName() {
return longFileName;
}
/**
* Returns the contents of the file in string form
*
* @return
*/
public String getFileContent() {
return fileContent;
}
/**
* Returns the relative path of the uploaded file
*
* @return
*/
public String getShortFileName() {
return shortFileName;
}
}
| 2,501 | 0.618553 | 0.610956 | 112 | 21.330357 | 19.525345 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.321429 | false | false | 13 |
4086e6ea2a0bcbc31e5bcd5cb2593eab660dbae8 | 8,916,352,149,526 | 7ec60129e443c8f84829f3ac628aaf7a3456a55e | /src/main/java/com/dinor913/workService/model/security/UserRoles.java | a968641a533e69024b3e0b93b6f5cadca4053225 | [] | no_license | dinor913/WorkServices | https://github.com/dinor913/WorkServices | 8682c1593aada71500bbafb16d2d73eb91efe48c | 9eac6788693dbe86a79405e0cc1d9a9dd109cbd7 | refs/heads/master | 2016-09-18T22:26:33.402000 | 2016-09-04T22:56:22 | 2016-09-04T22:56:22 | 67,228,428 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dinor913.workService.model.security;
import javax.persistence.*;
@Entity
@Table(name = "user_roles")
public class UserRoles {
@Id
@SequenceGenerator(name = "user_roles_user_role_id_seq",
sequenceName = "user_roles_user_role_id_seq",
allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_roles_user_role_id_seq")
private int id;
@Column(name = "role", nullable = false)
private String role = UserRole.USER.getUserRole();
@ManyToOne
@JoinColumn(name = "user_id")
private UserAuthorization userAuthorization;
public int getId() {
return id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public UserAuthorization getUserAuthorization() {
return userAuthorization;
}
public void setUserAuthorization(UserAuthorization userAuthorization) {
this.userAuthorization = userAuthorization;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof UserRole)) return false;
UserRoles userRoles = (UserRoles) o;
if (getId() != userRoles.getId()) return false;
return getRole().equals(userRoles.getRole());
}
@Override
public int hashCode() {
int result = getId();
result = 31 * result + getRole().hashCode();
return result;
}
}
| UTF-8 | Java | 1,506 | java | UserRoles.java | Java | [] | null | [] | package com.dinor913.workService.model.security;
import javax.persistence.*;
@Entity
@Table(name = "user_roles")
public class UserRoles {
@Id
@SequenceGenerator(name = "user_roles_user_role_id_seq",
sequenceName = "user_roles_user_role_id_seq",
allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_roles_user_role_id_seq")
private int id;
@Column(name = "role", nullable = false)
private String role = UserRole.USER.getUserRole();
@ManyToOne
@JoinColumn(name = "user_id")
private UserAuthorization userAuthorization;
public int getId() {
return id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public UserAuthorization getUserAuthorization() {
return userAuthorization;
}
public void setUserAuthorization(UserAuthorization userAuthorization) {
this.userAuthorization = userAuthorization;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof UserRole)) return false;
UserRoles userRoles = (UserRoles) o;
if (getId() != userRoles.getId()) return false;
return getRole().equals(userRoles.getRole());
}
@Override
public int hashCode() {
int result = getId();
result = 31 * result + getRole().hashCode();
return result;
}
}
| 1,506 | 0.628818 | 0.624834 | 62 | 23.290323 | 23.101032 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.387097 | false | false | 13 |
81fdb5164723bc24092a7d2ecf1cf83851d0fd29 | 22,016,002,403,731 | c54b22e45a47ae2bad01283c42a779dda5e57bbc | /ToMail/src/main/java/com/tmail/board/Dao/AddressDao.java | 163f197e1816a20d1997f8cd58dcd3fa8e18e9cf | [] | no_license | yunjae830/project_ToMail | https://github.com/yunjae830/project_ToMail | f76a349d79df79f5cd7bd02694d1df78c712a527 | 99e511d0294512acef98d9e918ad2e8aabca25aa | refs/heads/master | 2020-04-17T22:35:33.424000 | 2019-02-08T03:39:42 | 2019-02-08T03:39:42 | 167,000,295 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tmail.board.Dao;
import java.util.List;
import com.tmail.board.Dto.AddressDto;
import com.tmail.board.Dto.Address_GroupDto;
public interface AddressDao {
String namespace = "email.";
public List<AddressDto> selectList(AddressDto dto);
public AddressDto selectOne_email_chk(String name);
public int insert(AddressDto dto);
public int update(AddressDto dto);
public int delete(String name);
public int address_check(AddressDto dto);
public int group_insert(Address_GroupDto dto);
public List<Address_GroupDto> selectList_Group(int members_seq);
public int group_admin_size(int group_seq);
public int delete_group(Address_GroupDto dto);
public int update_group(Address_GroupDto dto);
public int group_cnt(Address_GroupDto dto);
public int delete_addr(AddressDto dto);
public String selectOne_email(AddressDto dto);
public List<String> selectOne_cus_seq(AddressDto dto);
} | UTF-8 | Java | 964 | java | AddressDao.java | Java | [] | null | [] | package com.tmail.board.Dao;
import java.util.List;
import com.tmail.board.Dto.AddressDto;
import com.tmail.board.Dto.Address_GroupDto;
public interface AddressDao {
String namespace = "email.";
public List<AddressDto> selectList(AddressDto dto);
public AddressDto selectOne_email_chk(String name);
public int insert(AddressDto dto);
public int update(AddressDto dto);
public int delete(String name);
public int address_check(AddressDto dto);
public int group_insert(Address_GroupDto dto);
public List<Address_GroupDto> selectList_Group(int members_seq);
public int group_admin_size(int group_seq);
public int delete_group(Address_GroupDto dto);
public int update_group(Address_GroupDto dto);
public int group_cnt(Address_GroupDto dto);
public int delete_addr(AddressDto dto);
public String selectOne_email(AddressDto dto);
public List<String> selectOne_cus_seq(AddressDto dto);
} | 964 | 0.733402 | 0.733402 | 28 | 32.5 | 20.602531 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 13 |
06bde01e929d93a11cb5ce203f4b0c6a8a9cacf7 | 18,794,776,887,689 | 4c11620041635cff7f021481c2aa8240fdf5e7ad | /MoveMePOJO/src/com/cl/moveme/entities/Persona.java | 1e20df42cd367ff72df0e2b0b3a693d71158bac1 | [] | no_license | ChrystianDuarte/MoveMeRemote | https://github.com/ChrystianDuarte/MoveMeRemote | 92af38b3b99b2dc4625b91881e802c05770ab976 | 6b22c4f29beca2e320d74be51c89e05c356bf59a | refs/heads/master | 2021-01-01T03:43:51.539000 | 2016-05-15T21:39:06 | 2016-05-15T21:39:06 | 58,423,048 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.cl.moveme.entities;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Chrystian Duarte
*/
@Entity
@Table(name = "persona", catalog = "Moveme", schema = "")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
@NamedQuery(name = "Persona.findById", query = "SELECT p FROM Persona p WHERE p.id = :id"),
@NamedQuery(name = "Persona.findByNombre", query = "SELECT p FROM Persona p WHERE p.nombre = :nombre"),
@NamedQuery(name = "Persona.findByApellido", query = "SELECT p FROM Persona p WHERE p.apellido = :apellido"),
@NamedQuery(name = "Persona.findByEdad", query = "SELECT p FROM Persona p WHERE p.edad = :edad"),
@NamedQuery(name = "Persona.findByCargo", query = "SELECT p FROM Persona p WHERE p.cargo = :cargo"),
@NamedQuery(name = "Persona.findByRun", query = "SELECT p FROM Persona p WHERE p.run = :run")})
public class Persona implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "NOMBRE")
private String nombre;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "APELLIDO")
private String apellido;
@Basic(optional = false)
@NotNull
@Column(name = "EDAD")
private int edad;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "CARGO")
private String cargo;
@Basic(optional = false)
@NotNull
@Column(name = "RUN")
private int run;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "persona")
private Collection<Oportunidad> oportunidadCollection;
public Persona() {
}
public Persona(Integer id) {
this.id = id;
}
public Persona(Integer id, String nombre, String apellido, int edad, String cargo, int run) {
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
this.edad = edad;
this.cargo = cargo;
this.run = run;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
public String getCargo() {
return cargo;
}
public void setCargo(String cargo) {
this.cargo = cargo;
}
public int getRun() {
return run;
}
public void setRun(int run) {
this.run = run;
}
@XmlTransient
public Collection<Oportunidad> getOportunidadCollection() {
return oportunidadCollection;
}
public void setOportunidadCollection(Collection<Oportunidad> oportunidadCollection) {
this.oportunidadCollection = oportunidadCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Persona)) {
return false;
}
Persona other = (Persona) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.cl.moveme.entities.Persona[ id=" + id + " ]";
}
}
| UTF-8 | Java | 4,933 | java | Persona.java | Java | [
{
"context": "nd.annotation.XmlTransient;\r\n\r\n/**\r\n *\r\n * @author Chrystian Duarte\r\n */\r\n@Entity\r\n@Table(name = \"persona\", catalog =",
"end": 912,
"score": 0.9998770952224731,
"start": 896,
"tag": "NAME",
"value": "Chrystian Duarte"
},
{
"context": " @Size(min = 1, ... | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.cl.moveme.entities;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author <NAME>
*/
@Entity
@Table(name = "persona", catalog = "Moveme", schema = "")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
@NamedQuery(name = "Persona.findById", query = "SELECT p FROM Persona p WHERE p.id = :id"),
@NamedQuery(name = "Persona.findByNombre", query = "SELECT p FROM Persona p WHERE p.nombre = :nombre"),
@NamedQuery(name = "Persona.findByApellido", query = "SELECT p FROM Persona p WHERE p.apellido = :apellido"),
@NamedQuery(name = "Persona.findByEdad", query = "SELECT p FROM Persona p WHERE p.edad = :edad"),
@NamedQuery(name = "Persona.findByCargo", query = "SELECT p FROM Persona p WHERE p.cargo = :cargo"),
@NamedQuery(name = "Persona.findByRun", query = "SELECT p FROM Persona p WHERE p.run = :run")})
public class Persona implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "NOMBRE")
private String nombre;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "APELLIDO")
private String apellido;
@Basic(optional = false)
@NotNull
@Column(name = "EDAD")
private int edad;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "CARGO")
private String cargo;
@Basic(optional = false)
@NotNull
@Column(name = "RUN")
private int run;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "persona")
private Collection<Oportunidad> oportunidadCollection;
public Persona() {
}
public Persona(Integer id) {
this.id = id;
}
public Persona(Integer id, String nombre, String apellido, int edad, String cargo, int run) {
this.id = id;
this.nombre = nombre;
this.apellido = apellido;
this.edad = edad;
this.cargo = cargo;
this.run = run;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
public String getCargo() {
return cargo;
}
public void setCargo(String cargo) {
this.cargo = cargo;
}
public int getRun() {
return run;
}
public void setRun(int run) {
this.run = run;
}
@XmlTransient
public Collection<Oportunidad> getOportunidadCollection() {
return oportunidadCollection;
}
public void setOportunidadCollection(Collection<Oportunidad> oportunidadCollection) {
this.oportunidadCollection = oportunidadCollection;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Persona)) {
return false;
}
Persona other = (Persona) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.cl.moveme.entities.Persona[ id=" + id + " ]";
}
}
| 4,923 | 0.618082 | 0.61565 | 173 | 26.51445 | 24.895994 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.485549 | false | false | 13 |
6364fb94d52da07205a71f0198a3847a2d74ac56 | 11,407,433,145,949 | 68eae657f9180772c81a26607a4c5f52c4700cc0 | /src/leetcode/easy/ValidParentheses.java | d2b11b3018c3f927fae2718dfc0b4466b8b6a251 | [] | no_license | h-hub/algorithm-practice | https://github.com/h-hub/algorithm-practice | 434564975845f99ca107467ecbb3e061be5b057f | bdce96160db00c561fe8910dec307424bfbff93c | refs/heads/master | 2021-10-15T14:57:44.045000 | 2021-10-15T06:37:40 | 2021-10-15T06:37:40 | 145,707,063 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package leetcode.easy;
import java.util.LinkedList;
import java.util.Stack;
//https://leetcode.com/problems/valid-parentheses/
public class ValidParentheses {
public static void main(String[] args) {
System.out.println(isValid("([)]"));
}
public static boolean isValid(String s) {
Stack<Character> paraStack = new Stack<>();
for(int i=0; i < s.length(); i++){
if(!paraStack.isEmpty() && paraStack.peek()=='(' && s.charAt(i)==')'){
paraStack.pop();
} else if(!paraStack.isEmpty() && paraStack.peek()=='{' && s.charAt(i)=='}'){
paraStack.pop();
} else if(!paraStack.isEmpty() && paraStack.peek()=='[' && s.charAt(i)==']'){
paraStack.pop();
} else {
paraStack.add(s.charAt(i));
}
}
if(paraStack.isEmpty()){
return true;
}
return false;
}
}
| UTF-8 | Java | 955 | java | ValidParentheses.java | Java | [] | null | [] | package leetcode.easy;
import java.util.LinkedList;
import java.util.Stack;
//https://leetcode.com/problems/valid-parentheses/
public class ValidParentheses {
public static void main(String[] args) {
System.out.println(isValid("([)]"));
}
public static boolean isValid(String s) {
Stack<Character> paraStack = new Stack<>();
for(int i=0; i < s.length(); i++){
if(!paraStack.isEmpty() && paraStack.peek()=='(' && s.charAt(i)==')'){
paraStack.pop();
} else if(!paraStack.isEmpty() && paraStack.peek()=='{' && s.charAt(i)=='}'){
paraStack.pop();
} else if(!paraStack.isEmpty() && paraStack.peek()=='[' && s.charAt(i)==']'){
paraStack.pop();
} else {
paraStack.add(s.charAt(i));
}
}
if(paraStack.isEmpty()){
return true;
}
return false;
}
}
| 955 | 0.509948 | 0.508901 | 37 | 24.81081 | 24.961416 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.351351 | false | false | 13 |
11cf936d17b1658fe77ade47cccb784155f55c36 | 27,187,143,041,286 | 86942fb4114d59c84e94387cdf6c620be1ea9633 | /src/main/java/com/infra/domain/file/FileAttributesComparator.java | ac2667ca6ccaf840e65800f01df7362f93f2a641 | [] | no_license | koolanuj/file-service | https://github.com/koolanuj/file-service | a9d5f67ece96bdb9d3f9588dd6174b60efeb03bd | 47c37a28a5771ba53f08223f6bcdb6292a1bdd3e | refs/heads/master | 2023-03-07T02:22:16.319000 | 2020-08-26T20:03:20 | 2020-08-26T20:03:20 | 277,322,848 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.infra.domain.file;
import org.thymeleaf.util.StringUtils;
import java.util.Comparator;
/**
* Excluding datetime related attributes
*/
public class FileAttributesComparator implements Comparator<FileAttributes> {
@Override
public int compare(FileAttributes fileAttr1, FileAttributes fileAttr2) {
if (fileAttr1 == null || fileAttr2 == null) {
return -1;
}
boolean result = (StringUtils.equals(fileAttr1.getName(), fileAttr2.getName()) &&
StringUtils.equals(fileAttr1.getPath(), fileAttr2.getPath()) &&
StringUtils.equals(replaceFileSeparator(fileAttr1.getFileType()), replaceFileSeparator(fileAttr2.getFileType())) &&
(fileAttr1.getSize() == fileAttr2.getSize()));
return result ? 0 : -1;
}
private String replaceFileSeparator (String fileStr) {
return fileStr.replace("/" , "").replace("\\", "");
}
}
| UTF-8 | Java | 940 | java | FileAttributesComparator.java | Java | [] | null | [] | package com.infra.domain.file;
import org.thymeleaf.util.StringUtils;
import java.util.Comparator;
/**
* Excluding datetime related attributes
*/
public class FileAttributesComparator implements Comparator<FileAttributes> {
@Override
public int compare(FileAttributes fileAttr1, FileAttributes fileAttr2) {
if (fileAttr1 == null || fileAttr2 == null) {
return -1;
}
boolean result = (StringUtils.equals(fileAttr1.getName(), fileAttr2.getName()) &&
StringUtils.equals(fileAttr1.getPath(), fileAttr2.getPath()) &&
StringUtils.equals(replaceFileSeparator(fileAttr1.getFileType()), replaceFileSeparator(fileAttr2.getFileType())) &&
(fileAttr1.getSize() == fileAttr2.getSize()));
return result ? 0 : -1;
}
private String replaceFileSeparator (String fileStr) {
return fileStr.replace("/" , "").replace("\\", "");
}
}
| 940 | 0.656383 | 0.640426 | 27 | 33.814816 | 34.600403 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 13 |
2ac0cdb5ceb823255c6baa3dba7264eb426b1c19 | 6,270,652,266,672 | a428c3a364eda78b376cf989d6c3d8155e38ae5f | /HotelManagement/src/com/gmail/queenskeleton/hotel/service/BuildingService.java | 4b8e8b8a2abad86227a05792a1fa8a23afbefdd7 | [] | no_license | QueenSkeleton/Hotel-Reservation-and-Management-System-Spring-MVC | https://github.com/QueenSkeleton/Hotel-Reservation-and-Management-System-Spring-MVC | 0b34610c2c6331347e0ea7093efaf34b038e391f | a375c4cdb7ef6dbceb79c10206f226c9453dd048 | refs/heads/master | 2020-05-30T12:03:31.255000 | 2019-06-01T13:58:06 | 2019-06-01T13:58:06 | 189,722,080 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gmail.queenskeleton.hotel.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gmail.queenskeleton.hotel.entity.Building;
import com.gmail.queenskeleton.hotel.repository.BuildingRepository;
@Service
public class BuildingService {
@Autowired
private BuildingRepository buildingRepository;
public void setBuildingRepository(BuildingRepository buildingRepository) {
this.buildingRepository = buildingRepository;
}
@Transactional
public List<Building> getList() {
return buildingRepository.findAll();
}
@Transactional
public Building getByID(long id) {
return buildingRepository.findById(id).get();
}
@Transactional
public boolean save(Building building) {
return buildingRepository.save(building) != null;
}
@Transactional
public boolean deleteByID(long id) {
buildingRepository.deleteById(id);
return true;
}
}
| UTF-8 | Java | 1,031 | java | BuildingService.java | Java | [] | null | [] | package com.gmail.queenskeleton.hotel.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gmail.queenskeleton.hotel.entity.Building;
import com.gmail.queenskeleton.hotel.repository.BuildingRepository;
@Service
public class BuildingService {
@Autowired
private BuildingRepository buildingRepository;
public void setBuildingRepository(BuildingRepository buildingRepository) {
this.buildingRepository = buildingRepository;
}
@Transactional
public List<Building> getList() {
return buildingRepository.findAll();
}
@Transactional
public Building getByID(long id) {
return buildingRepository.findById(id).get();
}
@Transactional
public boolean save(Building building) {
return buildingRepository.save(building) != null;
}
@Transactional
public boolean deleteByID(long id) {
buildingRepository.deleteById(id);
return true;
}
}
| 1,031 | 0.799224 | 0.799224 | 43 | 22.976744 | 22.867147 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.116279 | false | false | 13 |
bf16a00771bcad35987e9b0520fcadc418435285 | 3,942,779,999,436 | 4948eb471f8e1d0979516be54e302a72212eaa77 | /src/Multithreading/McDonald/McDon.java | 7391b1ce179109278270d5bfd84e202d7f7dee0c | [] | no_license | obriy77/kursy.by | https://github.com/obriy77/kursy.by | a2a36f1c6bd1fdb3200a11a1b19a4b4fef8a2b20 | 4c6da5a85f1128ed402cdbca0407d205b47932a2 | refs/heads/master | 2020-04-02T21:01:30.771000 | 2016-07-13T19:28:02 | 2016-07-13T19:28:02 | 62,881,588 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Multithreading.McDonald;
import java.util.ArrayList;
import java.util.List;
/**
* Свободная касса. В ресторане быстрого обслуживания есть несколько касс. Посетители стоят в очереди
* в конкретную кассу, но могут перейти в другую очередь при уменьшении или исчезновении там очереди.
* д/з №9
* Created by А on 16.11.14.
*/
public class McDon {
private volatile List<Cashtable> cashtableList;
public McDon() {
cashtableList = new ArrayList<>();
Cashtable c1 = new Cashtable(1);
Cashtable c2 = new Cashtable(2);
Cashtable c3 = new Cashtable(3);
cashtableList.add(c1);
cashtableList.add(c2);
cashtableList.add(c3);
c1.start();
c2.start();
c3.start();
}
public List<Cashtable> getCashtableList() {
return cashtableList;
}
public static void main(String[] args) throws InterruptedException {
McDon mcDon = new McDon();
List<Cashtable> cashtableList = mcDon.getCashtableList();
Customer c1 = new Customer(cashtableList, "Anna");
Customer c2 = new Customer(cashtableList, "Sam");
Customer c3 = new Customer(cashtableList, "Chandler");
Customer c4 = new Customer(cashtableList, "Alex");
Customer c5 = new Customer(cashtableList, "Monica");
Customer c6 = new Customer(cashtableList, "John");
Customer c7 = new Customer(cashtableList, "Kathy");
c1.start();
c2.start();
c2.sleep(2000);
c3.start();
c4.start();
c4.sleep(4000);
c5.start();
c6.start();
c7.start();
}
}
| UTF-8 | Java | 1,804 | java | McDon.java | Java | [
{
"context": " исчезновении там очереди.\n * д/з №9\n * Created by А on 16.11.14.\n */\npublic class McDon {\n private",
"end": 319,
"score": 0.940133273601532,
"start": 318,
"tag": "NAME",
"value": "А"
},
{
"context": " Customer c1 = new Customer(cashtableList, \"Anna\");\n... | null | [] | package Multithreading.McDonald;
import java.util.ArrayList;
import java.util.List;
/**
* Свободная касса. В ресторане быстрого обслуживания есть несколько касс. Посетители стоят в очереди
* в конкретную кассу, но могут перейти в другую очередь при уменьшении или исчезновении там очереди.
* д/з №9
* Created by А on 16.11.14.
*/
public class McDon {
private volatile List<Cashtable> cashtableList;
public McDon() {
cashtableList = new ArrayList<>();
Cashtable c1 = new Cashtable(1);
Cashtable c2 = new Cashtable(2);
Cashtable c3 = new Cashtable(3);
cashtableList.add(c1);
cashtableList.add(c2);
cashtableList.add(c3);
c1.start();
c2.start();
c3.start();
}
public List<Cashtable> getCashtableList() {
return cashtableList;
}
public static void main(String[] args) throws InterruptedException {
McDon mcDon = new McDon();
List<Cashtable> cashtableList = mcDon.getCashtableList();
Customer c1 = new Customer(cashtableList, "Anna");
Customer c2 = new Customer(cashtableList, "Sam");
Customer c3 = new Customer(cashtableList, "Chandler");
Customer c4 = new Customer(cashtableList, "Alex");
Customer c5 = new Customer(cashtableList, "Monica");
Customer c6 = new Customer(cashtableList, "John");
Customer c7 = new Customer(cashtableList, "Kathy");
c1.start();
c2.start();
c2.sleep(2000);
c3.start();
c4.start();
c4.sleep(4000);
c5.start();
c6.start();
c7.start();
}
}
| 1,804 | 0.621555 | 0.595223 | 53 | 29.811321 | 24.460255 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.773585 | false | false | 13 |
897beaca7e5fefdfee6368b8f08b65add3bfea2f | 13,666,585,946,200 | 504dabbfe7c8a026e819fb824e0e40448ba38a84 | /module16/src/main/java/by/rudko/oop/menu/view/ConsoleView.java | 6ab2579db9258e9f3f677908e16342c108f04b32 | [] | no_license | hezkvectory/jmp2015 | https://github.com/hezkvectory/jmp2015 | c94dfa31cc308a9e18ef6197bbf298e775adbec3 | 245efa1e70c6c5555d3c442c3f60a894d35916e6 | refs/heads/master | 2020-11-26T23:53:48.973000 | 2015-09-16T08:13:15 | 2015-09-16T08:13:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package by.rudko.oop.menu.view;
/**
* Created by rudkodm on 9/7/15.
*/
public abstract class ConsoleView {
protected abstract String getStringRepresentation();
public void print() {
String s = this.getStringRepresentation();
System.out.print(s);
}
}
| UTF-8 | Java | 282 | java | ConsoleView.java | Java | [
{
"context": "package by.rudko.oop.menu.view;\n\n/**\n * Created by rudkodm on 9/7/15.\n */\npublic abstract class ConsoleView ",
"end": 58,
"score": 0.9996002912521362,
"start": 51,
"tag": "USERNAME",
"value": "rudkodm"
}
] | null | [] | package by.rudko.oop.menu.view;
/**
* Created by rudkodm on 9/7/15.
*/
public abstract class ConsoleView {
protected abstract String getStringRepresentation();
public void print() {
String s = this.getStringRepresentation();
System.out.print(s);
}
}
| 282 | 0.663121 | 0.648936 | 13 | 20.692308 | 19.080336 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 13 |
2f13e6568ebaab525dbb505de03490c18edeeabb | 18,906,446,057,397 | bfe9e0f239b55eaf748ccf8ba2ecec0d33924c8c | /src/main/java/io/github/s8a/javacipher/VigenereCipher.java | e7b9c65d640ae0314c9812a30705a4a27889ce9e | [
"MIT"
] | permissive | S8A/javacipher | https://github.com/S8A/javacipher | 189cc8f46593f679ecf03476db8820bcf5595d8c | d87b99657f8cc77e570b033b0294e51e792ee515 | refs/heads/master | 2021-05-09T05:01:51.392000 | 2018-03-06T21:30:24 | 2018-03-06T21:30:24 | 119,295,600 | 0 | 0 | null | false | 2018-01-31T01:24:27 | 2018-01-28T20:36:32 | 2018-01-28T22:19:50 | 2018-01-31T01:24:26 | 9 | 0 | 0 | 0 | Java | false | null | package io.github.s8a.javacipher;
/**
* The Vigenere cipher is type of polyalphabetic substitution cipher
* that encrypts plaintext using a series of interwoven Caesar
* ciphers based on the letters of a keyword.
*/
public class VigenereCipher {
private enum CipherMode {ENCRYPT, DECRYPT}
/**
* Encrypts text using the Vigenere cipher with a given keyword.
*
* @param text Text to encrypt.
* @param keyword Keyword used to encrypt the text.
* @return Decrypted text.
*/
public static String encrypt(String text, String keyword) {
return cipher(text, keyword, CipherMode.ENCRYPT);
}
/**
* Decrypts text using the Vigenere cipher with a given keyword.
*
* @param text Text to encrypt.
* @param keyword Keyword used to encrypt the text.
* @return Decrypted text.
*/
public static String decrypt(String text, String keyword) {
return cipher(text, keyword, CipherMode.DECRYPT);
}
/**
* Applies the Vigenere cipher algorithm to encrypt or decrypt.
*/
private static String cipher(String text, String keyword, CipherMode m) {
StringBuilder sb = new StringBuilder();
int count = 0; // Index of current keyword character
for (char c : text.toCharArray()) {
char currentKey = keyword.toLowerCase().charAt(
count++ % keyword.length()); // Handle wrap around keyword
if (Character.isLetter(c)) {
int shift = (int) currentKey - 'a'; // Current key ordinal
char shifted = m.equals(CipherMode.ENCRYPT)
? CaesarCipher.shift(c, shift)
: CaesarCipher.shift(c, -shift);
sb.append(shifted);
} else {
sb.append(c);
}
}
return sb.toString();
}
} | UTF-8 | Java | 1,896 | java | VigenereCipher.java | Java | [
{
"context": "package io.github.s8a.javacipher;\n\n\n/**\n * The Vigenere cipher is type ",
"end": 21,
"score": 0.9823751449584961,
"start": 18,
"tag": "USERNAME",
"value": "s8a"
}
] | null | [] | package io.github.s8a.javacipher;
/**
* The Vigenere cipher is type of polyalphabetic substitution cipher
* that encrypts plaintext using a series of interwoven Caesar
* ciphers based on the letters of a keyword.
*/
public class VigenereCipher {
private enum CipherMode {ENCRYPT, DECRYPT}
/**
* Encrypts text using the Vigenere cipher with a given keyword.
*
* @param text Text to encrypt.
* @param keyword Keyword used to encrypt the text.
* @return Decrypted text.
*/
public static String encrypt(String text, String keyword) {
return cipher(text, keyword, CipherMode.ENCRYPT);
}
/**
* Decrypts text using the Vigenere cipher with a given keyword.
*
* @param text Text to encrypt.
* @param keyword Keyword used to encrypt the text.
* @return Decrypted text.
*/
public static String decrypt(String text, String keyword) {
return cipher(text, keyword, CipherMode.DECRYPT);
}
/**
* Applies the Vigenere cipher algorithm to encrypt or decrypt.
*/
private static String cipher(String text, String keyword, CipherMode m) {
StringBuilder sb = new StringBuilder();
int count = 0; // Index of current keyword character
for (char c : text.toCharArray()) {
char currentKey = keyword.toLowerCase().charAt(
count++ % keyword.length()); // Handle wrap around keyword
if (Character.isLetter(c)) {
int shift = (int) currentKey - 'a'; // Current key ordinal
char shifted = m.equals(CipherMode.ENCRYPT)
? CaesarCipher.shift(c, shift)
: CaesarCipher.shift(c, -shift);
sb.append(shifted);
} else {
sb.append(c);
}
}
return sb.toString();
}
} | 1,896 | 0.598101 | 0.597046 | 57 | 32.280701 | 26.255663 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.385965 | false | false | 13 |
c90dc19a2405037b45c3e6c1bc8400b57c1d7cb4 | 18,150,531,811,239 | 94fafb458dd461f7443a52d82052999a95af20fb | /src/main/java/com/pointlion/mvc/common/model/SchJobExecute.java | ea90fdf22ac375f657ea264ff6d8045ade14a8cc | [
"Apache-2.0"
] | permissive | LiuGuoxin/JFinalOA | https://github.com/LiuGuoxin/JFinalOA | 6f45cf87c24333df32082e8540325ed304f09a93 | 77e760135778a7944c4100bfd5008396ab83891a | refs/heads/master | 2023-07-16T11:35:06.662000 | 2020-05-08T13:51:10 | 2020-05-08T13:51:10 | 262,062,231 | 0 | 0 | Apache-2.0 | false | 2020-05-07T13:49:03 | 2020-05-07T13:45:50 | 2020-05-07T13:48:21 | 2020-05-07T13:49:01 | 0 | 0 | 0 | 1 | HTML | false | false | package com.pointlion.mvc.common.model;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.pointlion.mvc.common.model.base.BaseSchJobExecute;
@SuppressWarnings("serial")
public class SchJobExecute extends BaseSchJobExecute<SchJobExecute> {
public static final SchJobExecute dao = new SchJobExecute();
public static final String tableName = "sch_job_execute";
/***
* 根据主键查询
*/
public SchJobExecute getById(String id){
return SchJobExecute.dao.findById(id);
}
/***
* 删除
* @param ids
*/
@Before(Tx.class)
public void deleteByIds(String ids){
String idarr[] = ids.split(",");
for(String id : idarr){
SchJobExecute o = SchJobExecute.dao.getById(id);
o.delete();
}
}
} | UTF-8 | Java | 768 | java | SchJobExecute.java | Java | [] | null | [] | package com.pointlion.mvc.common.model;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.pointlion.mvc.common.model.base.BaseSchJobExecute;
@SuppressWarnings("serial")
public class SchJobExecute extends BaseSchJobExecute<SchJobExecute> {
public static final SchJobExecute dao = new SchJobExecute();
public static final String tableName = "sch_job_execute";
/***
* 根据主键查询
*/
public SchJobExecute getById(String id){
return SchJobExecute.dao.findById(id);
}
/***
* 删除
* @param ids
*/
@Before(Tx.class)
public void deleteByIds(String ids){
String idarr[] = ids.split(",");
for(String id : idarr){
SchJobExecute o = SchJobExecute.dao.getById(id);
o.delete();
}
}
} | 768 | 0.704787 | 0.704787 | 31 | 23.290323 | 21.681259 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.193548 | false | false | 13 |
f7c2c4112985ff71b8619f1224633c62cd528742 | 30,571,577,246,515 | 915ca70e32f60b377db0f35e8b01fbe7a32feea1 | /Leetcode/src/problems/queue/ShortestSubarray.java | 707169ea3e294f9d4a2224f846b920266f44b7d8 | [] | no_license | hundanLi/Algorithm | https://github.com/hundanLi/Algorithm | c097c398088c98426a5e1601f40b324fd48e162b | 6edcda76f6ce58e55001a92dfdbf609012582e92 | refs/heads/master | 2022-12-03T08:03:04.800000 | 2020-08-15T02:26:33 | 2020-08-15T02:26:33 | 287,663,134 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package problems.queue;
import java.util.ArrayDeque;
import java.util.Deque;
/**
* @author li
* @version 1.0
* @date 2020-01-16 15:52
**/
public class ShortestSubarray {
public int shortestSubarray(int[] arr, int k) {
int[] prefixSum = new int[arr.length + 1];
for (int i = 0; i < arr.length; i++) {
prefixSum[i + 1] = prefixSum[i] + arr[i];
}
Deque<Integer> deque = new ArrayDeque<>();
deque.addFirst(0);
int ans = Integer.MAX_VALUE;
for (int i = 1; i < prefixSum.length; i++) {
while (!deque.isEmpty() && prefixSum[deque.getLast()] >= prefixSum[i]) {
deque.removeLast();
}
deque.addLast(i);
int diff = prefixSum[i] - k;
while (deque.size() > 1 && diff >= prefixSum[deque.getFirst()]) {
ans = Math.min(ans, i - deque.getFirst());
deque.removeFirst();
}
}
return ans == Integer.MAX_VALUE ? -1 : ans;
}
}
| UTF-8 | Java | 1,022 | java | ShortestSubarray.java | Java | [
{
"context": "rrayDeque;\nimport java.util.Deque;\n\n/**\n * @author li\n * @version 1.0\n * @date 2020-01-16 15:52\n **/\npu",
"end": 96,
"score": 0.9747498035430908,
"start": 94,
"tag": "NAME",
"value": "li"
}
] | null | [] | package problems.queue;
import java.util.ArrayDeque;
import java.util.Deque;
/**
* @author li
* @version 1.0
* @date 2020-01-16 15:52
**/
public class ShortestSubarray {
public int shortestSubarray(int[] arr, int k) {
int[] prefixSum = new int[arr.length + 1];
for (int i = 0; i < arr.length; i++) {
prefixSum[i + 1] = prefixSum[i] + arr[i];
}
Deque<Integer> deque = new ArrayDeque<>();
deque.addFirst(0);
int ans = Integer.MAX_VALUE;
for (int i = 1; i < prefixSum.length; i++) {
while (!deque.isEmpty() && prefixSum[deque.getLast()] >= prefixSum[i]) {
deque.removeLast();
}
deque.addLast(i);
int diff = prefixSum[i] - k;
while (deque.size() > 1 && diff >= prefixSum[deque.getFirst()]) {
ans = Math.min(ans, i - deque.getFirst());
deque.removeFirst();
}
}
return ans == Integer.MAX_VALUE ? -1 : ans;
}
}
| 1,022 | 0.514677 | 0.494129 | 33 | 29.969696 | 21.913721 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606061 | false | false | 13 |
4956d59d23c36717eb7c24d37b5d68c39255efdf | 16,587,163,744,698 | 707faf9498b106f93305321b2f1ee9c31784506f | /java/ema/src/shared/EMALogger.java | 8029f1c55b81ed7e0759d9809c7c7c133cfa7c4f | [] | no_license | bdumitriu/playground | https://github.com/bdumitriu/playground | 489479996fd3c8a83f456d08c01de5e09acb18d8 | 22a67f59832f0367806e50c84f2aec1ebba18150 | refs/heads/master | 2023-07-31T13:53:37.833000 | 2023-07-18T23:06:28 | 2023-07-18T23:07:24 | 2,675,737 | 1 | 0 | null | false | 2022-11-24T03:00:56 | 2011-10-30T15:39:47 | 2022-11-03T11:09:40 | 2022-11-24T03:00:53 | 17,467 | 2 | 0 | 13 | Java | false | false | /**
* This class provides the system with an simple means of logging all types of
* messages to a file.
*
* Author: Bogdan Dumitriu
* Version: 0.1
* Date: Dec 6, 2003
*/
package shared;
import java.util.logging.FileHandler;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import java.util.logging.SimpleFormatter;
import java.io.IOException;
import java.sql.SQLException;
import java.rmi.RemoteException;
public class EMALogger
{
public synchronized static EMALogger getInstance()
{
if (logger == null)
{
logger = new EMALogger();
}
return logger;
}
/**
* Logs a configuration message.
*
* @param message the message text
*/
public void logConfigMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.CONFIG, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs an informational message.
*
* @param message the message text
*/
public void logInfoMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.INFO, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs an error message.
*
* @param message the message text
*/
public void logErrorMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.SEVERE, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs any other type of message than the ones defined above.
*
* @param message the message text
*/
public void logOtherMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.FINEST, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs a default error message for SQL exceptions. This method is provided
* because the system makes heavy use of methods throwing this exception and
* a uniform error message for all these exceptions is preferred.
*
* @param e the SQLException
*/
public void logDefaultSQLExceptionMessage(SQLException e)
{
logErrorMessage("An error occured while using the database. The exact error message given by the " +
"system was: \"" + e.getMessage() + "\".");
}
/**
* Logs a default error message for remote exceptions. This method is provided
* because the system makes heavy use of methods throwing this exception and
* a uniform error message for all these exceptions is preferred.
*
* @param e the RemoteException
*/
public void logDefaultRemoteExceptionMessage(RemoteException e)
{
logErrorMessage("An error occured while using the RMI mechanism. The exact error message given by " +
"the system was: \"" + e.getMessage() + "\".");
}
private EMALogger()
{
try
{
// create the FileHandler which will write to the log file
EMAProperties props = EMAProperties.getInstance();
fileHandler = new FileHandler(props.getProperty("log.file"), true);
// set the log level
String logLevel = props.getProperty("log.level");
if (logLevel.equalsIgnoreCase("none"))
{
fileHandler.setLevel(Level.OFF);
}
else if (logLevel.equalsIgnoreCase("config"))
{
fileHandler.setLevel(Level.CONFIG);
}
else if (logLevel.equalsIgnoreCase("info"))
{
fileHandler.setLevel(Level.INFO);
}
else if (logLevel.equalsIgnoreCase("error"))
{
fileHandler.setLevel(Level.SEVERE);
}
else if (logLevel.equalsIgnoreCase("all"))
{
fileHandler.setLevel(Level.ALL);
}
fileHandler.setFormatter(new SimpleFormatter());
}
catch (IOException e)
{
fileHandler = null;
}
catch (SecurityException e)
{
fileHandler = null;
}
}
/**
* The FileHandler used to log messages.
*/
FileHandler fileHandler;
/**
* An instance of this class.
*/
private static EMALogger logger;
}
| UTF-8 | Java | 3,909 | java | EMALogger.java | Java | [
{
"context": " all types of\n * messages to a file.\n *\n * Author: Bogdan Dumitriu\n * Version: 0.1\n * Date: Dec 6, 2003\n */\npackage ",
"end": 135,
"score": 0.9998736381530762,
"start": 120,
"tag": "NAME",
"value": "Bogdan Dumitriu"
}
] | null | [] | /**
* This class provides the system with an simple means of logging all types of
* messages to a file.
*
* Author: <NAME>
* Version: 0.1
* Date: Dec 6, 2003
*/
package shared;
import java.util.logging.FileHandler;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import java.util.logging.SimpleFormatter;
import java.io.IOException;
import java.sql.SQLException;
import java.rmi.RemoteException;
public class EMALogger
{
public synchronized static EMALogger getInstance()
{
if (logger == null)
{
logger = new EMALogger();
}
return logger;
}
/**
* Logs a configuration message.
*
* @param message the message text
*/
public void logConfigMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.CONFIG, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs an informational message.
*
* @param message the message text
*/
public void logInfoMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.INFO, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs an error message.
*
* @param message the message text
*/
public void logErrorMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.SEVERE, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs any other type of message than the ones defined above.
*
* @param message the message text
*/
public void logOtherMessage(String message)
{
if (fileHandler == null)
{
return;
}
LogRecord record = new LogRecord(Level.FINEST, message);
record.setLoggerName("");
fileHandler.publish(record);
}
/**
* Logs a default error message for SQL exceptions. This method is provided
* because the system makes heavy use of methods throwing this exception and
* a uniform error message for all these exceptions is preferred.
*
* @param e the SQLException
*/
public void logDefaultSQLExceptionMessage(SQLException e)
{
logErrorMessage("An error occured while using the database. The exact error message given by the " +
"system was: \"" + e.getMessage() + "\".");
}
/**
* Logs a default error message for remote exceptions. This method is provided
* because the system makes heavy use of methods throwing this exception and
* a uniform error message for all these exceptions is preferred.
*
* @param e the RemoteException
*/
public void logDefaultRemoteExceptionMessage(RemoteException e)
{
logErrorMessage("An error occured while using the RMI mechanism. The exact error message given by " +
"the system was: \"" + e.getMessage() + "\".");
}
private EMALogger()
{
try
{
// create the FileHandler which will write to the log file
EMAProperties props = EMAProperties.getInstance();
fileHandler = new FileHandler(props.getProperty("log.file"), true);
// set the log level
String logLevel = props.getProperty("log.level");
if (logLevel.equalsIgnoreCase("none"))
{
fileHandler.setLevel(Level.OFF);
}
else if (logLevel.equalsIgnoreCase("config"))
{
fileHandler.setLevel(Level.CONFIG);
}
else if (logLevel.equalsIgnoreCase("info"))
{
fileHandler.setLevel(Level.INFO);
}
else if (logLevel.equalsIgnoreCase("error"))
{
fileHandler.setLevel(Level.SEVERE);
}
else if (logLevel.equalsIgnoreCase("all"))
{
fileHandler.setLevel(Level.ALL);
}
fileHandler.setFormatter(new SimpleFormatter());
}
catch (IOException e)
{
fileHandler = null;
}
catch (SecurityException e)
{
fileHandler = null;
}
}
/**
* The FileHandler used to log messages.
*/
FileHandler fileHandler;
/**
* An instance of this class.
*/
private static EMALogger logger;
}
| 3,900 | 0.68969 | 0.6879 | 177 | 21.079096 | 23.061069 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.700565 | false | false | 13 |
1ed49a6553186dbdc65ecd431760e02389299f53 | 14,173,392,100,971 | d233bd8ff67b4b53fd6ed696033ddbb9d05097d7 | /src/main/java/com/epoolex/flightservices/repos/PassengerRespository.java | 3cd90fc4d2e2da180cee985c0c24caa13b559c29 | [] | no_license | kershadi/SpingBoot-FlightServices | https://github.com/kershadi/SpingBoot-FlightServices | ae5ae3f7853c0b50e9b5f2a2fdbc0b96ccf55990 | 301c48496b07e88b3fd18cc48ccd967a1198f37f | refs/heads/master | 2022-04-25T07:31:40.010000 | 2020-04-26T03:31:02 | 2020-04-26T03:31:02 | 255,010,196 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.epoolex.flightservices.repos;
import org.springframework.data.jpa.repository.JpaRepository;
import com.epoolex.flightservices.entities.Passenger;
public interface PassengerRespository extends JpaRepository<Passenger, Integer> {
}
| UTF-8 | Java | 248 | java | PassengerRespository.java | Java | [] | null | [] | package com.epoolex.flightservices.repos;
import org.springframework.data.jpa.repository.JpaRepository;
import com.epoolex.flightservices.entities.Passenger;
public interface PassengerRespository extends JpaRepository<Passenger, Integer> {
}
| 248 | 0.83871 | 0.83871 | 9 | 26.333334 | 30.789608 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 13 |
56454f008d091dc3f572f09d7bc40651dc3c9c85 | 13,331,578,526,938 | ef81a3ed712c8ac2e1b29261c31a15b69ba34c1c | /programs/Oddno.java | 9389efb0d96d589a7b3b40ad537e160c2b5d3667 | [] | no_license | athifaayesha-25/Athifa-Ayesha | https://github.com/athifaayesha-25/Athifa-Ayesha | 69ea4e7a53f35c3cb84a1eee3362243d366ad9d1 | e1a43c4617cb9f1473b28ed27915cfd78947964e | refs/heads/master | 2020-12-03T21:51:42.052000 | 2020-04-04T05:50:50 | 2020-04-04T05:50:50 | 231,497,077 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
class Oddno
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,i;
double b=0;
for(i=1;i<=3;i++)
{
a=sc.nextInt();
while(a%2!=0);
{
if(a%2==0)
{
b=b-0.5;
}
if(a<0)
{
b--;
}
else if(a%2!=0)
{
b++;
}
System.out.println(" the score is: "+b);
}
break;
}
}
} | UTF-8 | Java | 595 | java | Oddno.java | Java | [] | null | [] | import java.util.Scanner;
class Oddno
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,i;
double b=0;
for(i=1;i<=3;i++)
{
a=sc.nextInt();
while(a%2!=0);
{
if(a%2==0)
{
b=b-0.5;
}
if(a<0)
{
b--;
}
else if(a%2!=0)
{
b++;
}
System.out.println(" the score is: "+b);
}
break;
}
}
} | 595 | 0.307563 | 0.287395 | 34 | 15.558824 | 11.446014 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 13 |
60ae6868cf245afe138166a1fabe1e333bb7bbce | 24,833,500,921,373 | e4000afea12588966a92940ca0315b3fcc30d7f2 | /src/main/java/project/model/factory/issue/IssueFactoryImpl.java | 63c3452feabd6dd0615452f68da72158c8523633 | [] | no_license | EgorShumskikh/bug-tracker | https://github.com/EgorShumskikh/bug-tracker | 58ce65b99ef074585d6f5bcd4b887d7c63175b63 | 9d69b471e526176dbd8073a26bfd14f88bc5c302 | refs/heads/master | 2022-12-18T08:12:18.269000 | 2020-09-13T17:00:01 | 2020-09-13T17:00:01 | 293,758,064 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package project.model.factory.issue;
import project.model.issue.Issue;
import project.model.issue.IssueType;
import project.model.issue.projectissue.BugIssue;
import project.model.issue.projectissue.EpicIssue;
import project.model.issue.projectissue.StoryIssue;
import project.model.issue.projectissue.TaskIssue;
public class IssueFactoryImpl implements IssueFactory {
private static IssueFactoryImpl factory = new IssueFactoryImpl();
public static IssueFactoryImpl getInstance() {
return factory;
}
@Override
public Issue createIssue(IssueType issueType) {
Issue issue;
switch (issueType) {
case BUG:
issue = new BugIssue();
break;
case EPIC:
issue = new EpicIssue();
break;
case STORY:
issue = new StoryIssue();
break;
case TASK:
issue = new TaskIssue();
break;
default:
throw new IllegalStateException("Unexpected value: " + issueType);
}
return issue;
}
}
| UTF-8 | Java | 1,135 | java | IssueFactoryImpl.java | Java | [] | null | [] | package project.model.factory.issue;
import project.model.issue.Issue;
import project.model.issue.IssueType;
import project.model.issue.projectissue.BugIssue;
import project.model.issue.projectissue.EpicIssue;
import project.model.issue.projectissue.StoryIssue;
import project.model.issue.projectissue.TaskIssue;
public class IssueFactoryImpl implements IssueFactory {
private static IssueFactoryImpl factory = new IssueFactoryImpl();
public static IssueFactoryImpl getInstance() {
return factory;
}
@Override
public Issue createIssue(IssueType issueType) {
Issue issue;
switch (issueType) {
case BUG:
issue = new BugIssue();
break;
case EPIC:
issue = new EpicIssue();
break;
case STORY:
issue = new StoryIssue();
break;
case TASK:
issue = new TaskIssue();
break;
default:
throw new IllegalStateException("Unexpected value: " + issueType);
}
return issue;
}
}
| 1,135 | 0.605286 | 0.605286 | 41 | 26.682926 | 20.545534 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.487805 | false | false | 13 |
9f13623d749109274d824f996910e67f97345983 | 14,353,780,742,996 | 4655377bba84a552cfe128d74008956567eaabc7 | /JavaTestNishu/src/test0702/first/JavaScannertest.java | 5d6915a322047f9d40a27c1eaf4174132f620534 | [] | no_license | NishuGamage/Sachi | https://github.com/NishuGamage/Sachi | 109542e5e9b8cc8bff2df2bc8cf2e18a175cde19 | 3e5104bd3e5528d284849509a836065474cc6daa | refs/heads/master | 2022-11-16T00:05:49.607000 | 2020-07-07T01:06:53 | 2020-07-07T01:06:53 | 277,467,529 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package test0702.first;
import java.util.Scanner;
public class JavaScannertest {
public static void main(String[] args) {
//Create Scanner object
Scanner scanner = new Scanner (System.in);
//read user input as string
System.out.println("Enter string input:");
scanner.nextLine();
//read user input as integer
System.out.println("Enter integer input");
scanner.nextInt();
//read user input as long
System.out.println("Enter long input");
scanner.nextLong();
//read user input as float
System.out.println("Enter float input");
scanner.nextFloat();
//read user input as byte
System.out.println("Enter byte input");
scanner.nextByte();
//read user input as short
System.out.println("Enter shoir Input");
scanner.nextShort();
//read user input as boolean
System.out.println("Enter boolean input");
scanner.nextBoolean();
//read user input BigDecimal
System.out.println("Enter BIgDecimal input");
scanner.nextBigDecimal();
//read user input as BigInteger
System.out.println("Enter BigInteger input");
scanner.nextBigInteger();
scanner.close();
}
}
| UTF-8 | Java | 1,298 | java | JavaScannertest.java | Java | [] | null | [] | package test0702.first;
import java.util.Scanner;
public class JavaScannertest {
public static void main(String[] args) {
//Create Scanner object
Scanner scanner = new Scanner (System.in);
//read user input as string
System.out.println("Enter string input:");
scanner.nextLine();
//read user input as integer
System.out.println("Enter integer input");
scanner.nextInt();
//read user input as long
System.out.println("Enter long input");
scanner.nextLong();
//read user input as float
System.out.println("Enter float input");
scanner.nextFloat();
//read user input as byte
System.out.println("Enter byte input");
scanner.nextByte();
//read user input as short
System.out.println("Enter shoir Input");
scanner.nextShort();
//read user input as boolean
System.out.println("Enter boolean input");
scanner.nextBoolean();
//read user input BigDecimal
System.out.println("Enter BIgDecimal input");
scanner.nextBigDecimal();
//read user input as BigInteger
System.out.println("Enter BigInteger input");
scanner.nextBigInteger();
scanner.close();
}
}
| 1,298 | 0.61171 | 0.608629 | 77 | 14.857142 | 15.822649 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.077922 | false | false | 13 |
9f21ec7d8db5f8899ee34f11d69481745dd78120 | 38,233,798,873,796 | 056fe6f8c30a54b07fec80e66ede1ac5fcd3ad1d | /src/com/ns/neo/utils/simulationHttpClient/toHttpBinary/StringToHttpBinaryForForm.java | 5d0e3d7f188e819b218eb2a033ddd36d7482ed5c | [] | no_license | githubQQ/wzcx | https://github.com/githubQQ/wzcx | c6930bb6f1ba894d045030a745b8ff9588fda262 | 947f470276e097447d8ef06cdde6d91e430ffbcd | refs/heads/master | 2019-01-02T01:56:41.077000 | 2015-06-24T01:19:21 | 2015-06-24T01:19:21 | 37,698,048 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ns.neo.utils.simulationHttpClient.toHttpBinary;
import com.ns.neo.utils.container.Idnm;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 针对Form的消息体
* */
public class StringToHttpBinaryForForm extends StringToHttpBinary{
/**
* Url参数对象,增加到Url的参数
* */
protected ArrayList<Idnm> formParamLt;
/**
* 得到字符串信息
* */
public String getStringContent(){
return createURLParamsString(this.getFormParamLt());
}
/**
* 创建URL的参数部分,将中文部分格式化为UTF-8
* */
public static String createURLParamsString(List<Idnm> getParam){
StringBuilder sb = new StringBuilder();
if(getParam!=null&&getParam.size()>0){
Iterator<Idnm> it = getParam.iterator();
while (it.hasNext()) {
Idnm im = it.next();
sb.append(im.getId());
sb.append("=");
sb.append(im.getName());
sb.append("&");
}
}
//
if(sb.length()>0){
sb.deleteCharAt(sb.length()-1);
}
return sb.toString();
}
/**
* 增加新的URL参数,增加新的url但是系统保证不重复
* */
public void addFormParamLt(Idnm im){
//删除重复的参数
/*for(Iterator<Idnm> imit=this.getFormParamLt().iterator();imit.hasNext();){
Idnm tim = imit.next();
if(tim.getId().equals(im.getId())){
imit.remove();
}
}*/
this.getFormParamLt().add(im);
}
public void addFormParamLt(String name,String value){
this.addFormParamLt(new Idnm(name,value));
}
/**
* 清空所有的Form参数
* */
public void cleanFormParamLt(){
this.getFormParamLt().clear();
}
public ArrayList<Idnm> getFormParamLt() {
if (this.formParamLt == null) {
this.formParamLt = new ArrayList<Idnm>();
}
return formParamLt;
}
public void setFormParamLt(ArrayList<Idnm> paramLt) {
this.formParamLt = paramLt;
}
}
| UTF-8 | Java | 2,138 | java | StringToHttpBinaryForForm.java | Java | [] | null | [] | package com.ns.neo.utils.simulationHttpClient.toHttpBinary;
import com.ns.neo.utils.container.Idnm;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 针对Form的消息体
* */
public class StringToHttpBinaryForForm extends StringToHttpBinary{
/**
* Url参数对象,增加到Url的参数
* */
protected ArrayList<Idnm> formParamLt;
/**
* 得到字符串信息
* */
public String getStringContent(){
return createURLParamsString(this.getFormParamLt());
}
/**
* 创建URL的参数部分,将中文部分格式化为UTF-8
* */
public static String createURLParamsString(List<Idnm> getParam){
StringBuilder sb = new StringBuilder();
if(getParam!=null&&getParam.size()>0){
Iterator<Idnm> it = getParam.iterator();
while (it.hasNext()) {
Idnm im = it.next();
sb.append(im.getId());
sb.append("=");
sb.append(im.getName());
sb.append("&");
}
}
//
if(sb.length()>0){
sb.deleteCharAt(sb.length()-1);
}
return sb.toString();
}
/**
* 增加新的URL参数,增加新的url但是系统保证不重复
* */
public void addFormParamLt(Idnm im){
//删除重复的参数
/*for(Iterator<Idnm> imit=this.getFormParamLt().iterator();imit.hasNext();){
Idnm tim = imit.next();
if(tim.getId().equals(im.getId())){
imit.remove();
}
}*/
this.getFormParamLt().add(im);
}
public void addFormParamLt(String name,String value){
this.addFormParamLt(new Idnm(name,value));
}
/**
* 清空所有的Form参数
* */
public void cleanFormParamLt(){
this.getFormParamLt().clear();
}
public ArrayList<Idnm> getFormParamLt() {
if (this.formParamLt == null) {
this.formParamLt = new ArrayList<Idnm>();
}
return formParamLt;
}
public void setFormParamLt(ArrayList<Idnm> paramLt) {
this.formParamLt = paramLt;
}
}
| 2,138 | 0.568205 | 0.566199 | 87 | 21.91954 | 20.127306 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.551724 | false | false | 13 |
3e514c8b0c391456479d35165b56ba6ad0da999e | 26,164,940,821,831 | 787f53b8d07fe9f118ba8482801458db64f77237 | /app/src/main/java/google/com/uberclone/activity/MapActivity.java | 0cc0c2a4ec13900865bc9c1a24f47e8a9506cdcf | [] | no_license | GohelAshok701/UberClone | https://github.com/GohelAshok701/UberClone | 05585d2c2c9a4aec805abba4db68716062726125 | e303ffd6ed6b00bf2b824648b9af0169d0625ac6 | refs/heads/master | 2020-04-11T18:38:40.202000 | 2019-01-10T03:08:23 | 2019-01-10T03:08:23 | 162,006,253 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package google.com.uberclone.activity;
import android.Manifest;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.arch.persistence.room.Room;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import java.text.DecimalFormat;
import google.com.uberclone.R;
import google.com.uberclone.database.AppDatabase;
import google.com.uberclone.database.LocatioModel;
import google.com.uberclone.util.PreferenceData;
import google.com.uberclone.util.Util;
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener, GpsStatus.Listener {
private AppDatabase database;
private static final String TAG = MapActivity.class.getCanonicalName();
private GoogleMap mMap;
private GoogleApiClient googleApiClient;
private Location location;
private LocationRequest locationRequest;
private LocationManager locationManager;
private int TIME = 30000;
final Handler handler = new Handler();
private boolean isHendler = false;
private LatLng mCenterLatLong;
private TextView txt_latlng;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
database = Room.databaseBuilder(this, AppDatabase.class, "db-contacts")
.allowMainThreadQueries() //Allows room to do operation on main thread
.build();
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.addGpsStatusListener(this);
txt_latlng=findViewById(R.id.txt_latlng);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
Log.d("Camera postion change" + "", cameraPosition + "");
mCenterLatLong = cameraPosition.target;
mMap.clear();
try {
Location mLocation = new Location("");
mLocation.setLatitude(mCenterLatLong.latitude);
mLocation.setLongitude(mCenterLatLong.longitude);
txt_latlng.setText("Lat : " + mCenterLatLong.latitude + "," + "\nLong : " + mCenterLatLong.longitude);
} catch (Exception e) {
e.printStackTrace();
}
}
});
buildApiClient();
}
protected synchronized void buildApiClient() {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
googleApiClient.connect();
}
@Override
public void onLocationChanged(final Location location) {
this.location = location;
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
Log.e("lat", "" + location.getLatitude());
Log.e("lat", "" + location.getLongitude());
if (location != null) {
if (!isHendler) {
isHendler = true;
PreferenceData.setPrvLat("" + location.getLatitude());
PreferenceData.setPrvLong("" + location.getLongitude());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
handler.postDelayed(this, TIME);
locationDestance();
}
}, TIME);
}
}
}
private void locationDestance() {
if (PreferenceData.getPrvlat().length() > 0 && PreferenceData.getPrvlong().length() > 0 && location != null) {
Location startPoint = new Location("locationA");
startPoint.setLatitude(Double.parseDouble(PreferenceData.getPrvlat()));
startPoint.setLongitude(Double.parseDouble(PreferenceData.getPrvlong()));
Location endPoint = new Location("locationB");
endPoint.setLatitude(location.getLatitude());
endPoint.setLongitude(location.getLongitude());
double distance = startPoint.distanceTo(endPoint);
Log.d("DETAIL DISTNCE", "" + distance);
LocatioModel locatioModel = new LocatioModel();
locatioModel.setMeter("" + new DecimalFormat("##.##").format(distance));
database.locationDAO().insert(locatioModel);
database.locationDAO().getLocationDetails();
Log.d("DETAIL", database.locationDAO().getLocationDetails().toString());
Log.d("DETAIL SUM", "" + new DecimalFormat("##.##").format(Double.parseDouble(database.locationDAO().getSum()) / 1000));
if (Double.parseDouble(new DecimalFormat("##.##").format(Double.parseDouble(database.locationDAO().getSum()) / 1000)) > 0.7) {
addNotification();
}
PreferenceData.setPrvLat("" + location.getLatitude());
PreferenceData.setPrvLong("" + location.getLongitude());
}
}
private void addNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_map_icon)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, MapActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
// Add as notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, builder.build());
}
@Override
public void onConnected(@Nullable Bundle bundle) {
locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
try {
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onGpsStatusChanged(int event) {
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
Log.e(TAG, "onGpsStatusChanged started");
break;
case GpsStatus.GPS_EVENT_STOPPED:
Log.e(TAG, "onGpsStatusChanged stopped");
if (Util.isGpsEnable(this)) {
} else {
Intent intent = new Intent(this, LocationServiceActivity.class);
startActivity(intent);
finish();
}
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
Log.e(TAG, "onGpsStatusChanged first fix");
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
Log.e(TAG, "onGpsStatusChanged status");
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
database.locationDAO().deleteTable();
}
}
| UTF-8 | Java | 9,962 | java | MapActivity.java | Java | [] | null | [] | package google.com.uberclone.activity;
import android.Manifest;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.arch.persistence.room.Room;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import java.text.DecimalFormat;
import google.com.uberclone.R;
import google.com.uberclone.database.AppDatabase;
import google.com.uberclone.database.LocatioModel;
import google.com.uberclone.util.PreferenceData;
import google.com.uberclone.util.Util;
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener, GpsStatus.Listener {
private AppDatabase database;
private static final String TAG = MapActivity.class.getCanonicalName();
private GoogleMap mMap;
private GoogleApiClient googleApiClient;
private Location location;
private LocationRequest locationRequest;
private LocationManager locationManager;
private int TIME = 30000;
final Handler handler = new Handler();
private boolean isHendler = false;
private LatLng mCenterLatLong;
private TextView txt_latlng;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
database = Room.databaseBuilder(this, AppDatabase.class, "db-contacts")
.allowMainThreadQueries() //Allows room to do operation on main thread
.build();
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.addGpsStatusListener(this);
txt_latlng=findViewById(R.id.txt_latlng);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
Log.d("Camera postion change" + "", cameraPosition + "");
mCenterLatLong = cameraPosition.target;
mMap.clear();
try {
Location mLocation = new Location("");
mLocation.setLatitude(mCenterLatLong.latitude);
mLocation.setLongitude(mCenterLatLong.longitude);
txt_latlng.setText("Lat : " + mCenterLatLong.latitude + "," + "\nLong : " + mCenterLatLong.longitude);
} catch (Exception e) {
e.printStackTrace();
}
}
});
buildApiClient();
}
protected synchronized void buildApiClient() {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
googleApiClient.connect();
}
@Override
public void onLocationChanged(final Location location) {
this.location = location;
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
Log.e("lat", "" + location.getLatitude());
Log.e("lat", "" + location.getLongitude());
if (location != null) {
if (!isHendler) {
isHendler = true;
PreferenceData.setPrvLat("" + location.getLatitude());
PreferenceData.setPrvLong("" + location.getLongitude());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
handler.postDelayed(this, TIME);
locationDestance();
}
}, TIME);
}
}
}
private void locationDestance() {
if (PreferenceData.getPrvlat().length() > 0 && PreferenceData.getPrvlong().length() > 0 && location != null) {
Location startPoint = new Location("locationA");
startPoint.setLatitude(Double.parseDouble(PreferenceData.getPrvlat()));
startPoint.setLongitude(Double.parseDouble(PreferenceData.getPrvlong()));
Location endPoint = new Location("locationB");
endPoint.setLatitude(location.getLatitude());
endPoint.setLongitude(location.getLongitude());
double distance = startPoint.distanceTo(endPoint);
Log.d("DETAIL DISTNCE", "" + distance);
LocatioModel locatioModel = new LocatioModel();
locatioModel.setMeter("" + new DecimalFormat("##.##").format(distance));
database.locationDAO().insert(locatioModel);
database.locationDAO().getLocationDetails();
Log.d("DETAIL", database.locationDAO().getLocationDetails().toString());
Log.d("DETAIL SUM", "" + new DecimalFormat("##.##").format(Double.parseDouble(database.locationDAO().getSum()) / 1000));
if (Double.parseDouble(new DecimalFormat("##.##").format(Double.parseDouble(database.locationDAO().getSum()) / 1000)) > 0.7) {
addNotification();
}
PreferenceData.setPrvLat("" + location.getLatitude());
PreferenceData.setPrvLong("" + location.getLongitude());
}
}
private void addNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_map_icon)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, MapActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
// Add as notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, builder.build());
}
@Override
public void onConnected(@Nullable Bundle bundle) {
locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
try {
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onGpsStatusChanged(int event) {
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
Log.e(TAG, "onGpsStatusChanged started");
break;
case GpsStatus.GPS_EVENT_STOPPED:
Log.e(TAG, "onGpsStatusChanged stopped");
if (Util.isGpsEnable(this)) {
} else {
Intent intent = new Intent(this, LocationServiceActivity.class);
startActivity(intent);
finish();
}
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
Log.e(TAG, "onGpsStatusChanged first fix");
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
Log.e(TAG, "onGpsStatusChanged status");
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
database.locationDAO().deleteTable();
}
}
| 9,962 | 0.651074 | 0.647761 | 259 | 37.463322 | 34.939903 | 259 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606178 | false | false | 13 |
861b8687622e7284392e62c5f797bb121898392a | 14,645,838,547,991 | 1a44adb7926c82d534df89c189485d6f4c4c4fb5 | /nideshop-server/src/main/java/com/newland/nideshopserver/model/NideshopAttributeCategory.java | 0579a546969798a5efbb933c350e4bc8221b3ec3 | [] | no_license | berrythinking/nideshop-springboot | https://github.com/berrythinking/nideshop-springboot | f09c6c3257c59cb472d15451744865e4390597cb | 51068ab6a7f239a3ec2ec87655244a0091a773dc | refs/heads/master | 2022-12-27T06:06:03.952000 | 2020-04-04T11:29:03 | 2020-04-04T11:29:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.newland.nideshopserver.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tk.mybatis.mapper.annotation.KeySql;
import javax.persistence.*;
/**
* @author xzt
* @CREATE2019-09-29 12:23
*/
@Getter
@Setter
@ToString
@Table(name = "nideshop_attribute_category")
public class NideshopAttributeCategory {
@Id
@KeySql(useGeneratedKeys = true)
private Integer id;
private String name;
private Integer enabled;
}
| UTF-8 | Java | 472 | java | NideshopAttributeCategory.java | Java | [
{
"context": "ySql;\n\nimport javax.persistence.*;\n\n/**\n * @author xzt\n * @CREATE2019-09-29 12:23\n */\n@Getter\n@Setter\n@T",
"end": 203,
"score": 0.9996750354766846,
"start": 200,
"tag": "USERNAME",
"value": "xzt"
}
] | null | [] | package com.newland.nideshopserver.model;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tk.mybatis.mapper.annotation.KeySql;
import javax.persistence.*;
/**
* @author xzt
* @CREATE2019-09-29 12:23
*/
@Getter
@Setter
@ToString
@Table(name = "nideshop_attribute_category")
public class NideshopAttributeCategory {
@Id
@KeySql(useGeneratedKeys = true)
private Integer id;
private String name;
private Integer enabled;
}
| 472 | 0.741525 | 0.716102 | 24 | 18.666666 | 14.64487 | 44 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 13 |
eb6ca578211581e60a9422fdc766803f7b7ae4d3 | 37,357,625,556,482 | ba3e600f479a9bdbd156a8a01b7b263894951daa | /app/src/main/java/com/chengxiang/pay/model/CommonPostModel.java | 712fd792713f28746119aeeb99f9de23a1c574f8 | [] | no_license | liujinrui94/WalletRefactor | https://github.com/liujinrui94/WalletRefactor | 3b4794f1b2d6a800d48e75bb4a98d2a588c44087 | 0264bd66f6e110beddb161dac6794b07af3293ac | refs/heads/master | 2021-06-24T23:52:29.460000 | 2017-09-12T08:07:22 | 2017-09-12T08:07:22 | 103,241,336 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.chengxiang.pay.model;
import com.chengxiang.pay.bean.ResponseParamsSlideShow;
import com.chengxiang.pay.bean.SlideImageBean;
import com.chengxiang.pay.framework.constant.Constant;
import com.chengxiang.pay.framework.encrypt.EncryptManager;
import com.chengxiang.pay.framework.encrypt.SignUtil;
import com.chengxiang.pay.framework.utils.ToastUtils;
import com.google.gson.Gson;
import com.orhanobut.logger.Logger;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import okhttp3.Call;
/**
* @author: LiuJinrui
* @email: liujinrui@qdcftx.com
* @time: 2017/8/7 16:19
* @description:
*/
public interface CommonPostModel {
/**
* 轮播图
*/
class PostSlideShow implements BaseModelUtils.SlideShow {
@Override
public void postSlideShow(String requestString, final CallBackUtils.SlideShowCallBack callBack) {
OkHttpUtils.post().url(Constant.MOBILE_FRONT + requestString).build().execute(new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
Logger.e("轮播图加载异常__" + e.toString());
callBack.OnNetError();
}
@Override
public void onResponse(String response, int id) {
Logger.i("轮播图信息返回成功__" + response);
ResponseParamsSlideShow info = new Gson().fromJson(response,
ResponseParamsSlideShow.class);
if (info.getRetCode().equals(Constant.RESPONSE_SUCCESS)) {
// 校验签名 同理 如果只校验公共参数则传空,否则传私有
// audit n.审计,查账;vt.审计,查账;旁听;vi.审计
if (SignUtil.verifyParams(EncryptManager.getEncryptManager(), info, null)) {
ArrayList<SlideImageBean> newList = info.getNewList();
callBack.slideShowResponse(newList);
} else {
ToastUtils.showLongToast("提现记录信息验签失败");
}
} else {
callBack.CodeError(info.getRetMsg());
}
}
});
}
}
}
| UTF-8 | Java | 2,410 | java | CommonPostModel.java | Java | [
{
"context": ".ArrayList;\n\nimport okhttp3.Call;\n\n/**\n * @author: LiuJinrui\n * @email: liujinrui@qdcftx.com\n * @time: 2017/8/",
"end": 595,
"score": 0.9998164176940918,
"start": 586,
"tag": "NAME",
"value": "LiuJinrui"
},
{
"context": "khttp3.Call;\n\n/**\n * @author: LiuJinrui... | null | [] | package com.chengxiang.pay.model;
import com.chengxiang.pay.bean.ResponseParamsSlideShow;
import com.chengxiang.pay.bean.SlideImageBean;
import com.chengxiang.pay.framework.constant.Constant;
import com.chengxiang.pay.framework.encrypt.EncryptManager;
import com.chengxiang.pay.framework.encrypt.SignUtil;
import com.chengxiang.pay.framework.utils.ToastUtils;
import com.google.gson.Gson;
import com.orhanobut.logger.Logger;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import okhttp3.Call;
/**
* @author: LiuJinrui
* @email: <EMAIL>
* @time: 2017/8/7 16:19
* @description:
*/
public interface CommonPostModel {
/**
* 轮播图
*/
class PostSlideShow implements BaseModelUtils.SlideShow {
@Override
public void postSlideShow(String requestString, final CallBackUtils.SlideShowCallBack callBack) {
OkHttpUtils.post().url(Constant.MOBILE_FRONT + requestString).build().execute(new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
Logger.e("轮播图加载异常__" + e.toString());
callBack.OnNetError();
}
@Override
public void onResponse(String response, int id) {
Logger.i("轮播图信息返回成功__" + response);
ResponseParamsSlideShow info = new Gson().fromJson(response,
ResponseParamsSlideShow.class);
if (info.getRetCode().equals(Constant.RESPONSE_SUCCESS)) {
// 校验签名 同理 如果只校验公共参数则传空,否则传私有
// audit n.审计,查账;vt.审计,查账;旁听;vi.审计
if (SignUtil.verifyParams(EncryptManager.getEncryptManager(), info, null)) {
ArrayList<SlideImageBean> newList = info.getNewList();
callBack.slideShowResponse(newList);
} else {
ToastUtils.showLongToast("提现记录信息验签失败");
}
} else {
callBack.CodeError(info.getRetMsg());
}
}
});
}
}
}
| 2,397 | 0.585677 | 0.580844 | 62 | 35.709679 | 28.639803 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.516129 | false | false | 13 |
c9b15f486186172b638dfdb36329c150bd2267dc | 37,391,985,298,530 | c03be46bae6e1077a1c56ce109e68e09642257d8 | /src/main/java/com/lh/service/ILeaveService.java | 3a9ead664afcc50baaad510476a60c1ade79b0dc | [] | no_license | 1364095124/Mytest | https://github.com/1364095124/Mytest | c519d1da34bc012e5c14258a634370853d46648a | fb445b3d36cd21e8151246c4cb5043837c709bde | refs/heads/master | 2020-04-26T09:22:30.551000 | 2019-04-23T07:33:07 | 2019-04-23T07:33:07 | 173,453,353 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lh.service;
import com.lh.model.LeaveForm;
import com.lh.model.Page;
import com.lh.model.ResultMap;
import com.lh.model.TaskList;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface ILeaveService {
void deploy(String name,String bpmn,String png,String key);
ResultMap<List<LeaveForm>> queryLeave(Page page, Integer limit);
ResultMap<List<LeaveForm>> queryTrashLeave(Page page,Integer limit);
String queryLeaveById(String leave_id);
String autoStartApply(LeaveForm leaveForm);
String addDeploy(MultipartFile file);
String save(LeaveForm leaveForm);
String startApply(String leave_id,String account,String department_Name,double sum);
ResultMap<List<TaskList>> getAllTaskList();
}
| UTF-8 | Java | 786 | java | ILeaveService.java | Java | [] | null | [] | package com.lh.service;
import com.lh.model.LeaveForm;
import com.lh.model.Page;
import com.lh.model.ResultMap;
import com.lh.model.TaskList;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface ILeaveService {
void deploy(String name,String bpmn,String png,String key);
ResultMap<List<LeaveForm>> queryLeave(Page page, Integer limit);
ResultMap<List<LeaveForm>> queryTrashLeave(Page page,Integer limit);
String queryLeaveById(String leave_id);
String autoStartApply(LeaveForm leaveForm);
String addDeploy(MultipartFile file);
String save(LeaveForm leaveForm);
String startApply(String leave_id,String account,String department_Name,double sum);
ResultMap<List<TaskList>> getAllTaskList();
}
| 786 | 0.765903 | 0.765903 | 33 | 22.818182 | 25.811031 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false | 13 |
6084ee548896306b60cdee90f1ed72f9457e2d03 | 35,716,948,069,742 | 23a48c58b6d1638e8a13ec81ce56de9fc40a2a7b | /src/topGoogleQuestions/Problem246_StrobogrammaticI.java | 0bd5a559ad15b4869c306e077dc99207e5ff7ca0 | [] | no_license | yyxd/leetcode | https://github.com/yyxd/leetcode | 6ddcb92e10dffeceeab2787f049af1395e7d910a | 31e8b24cbd64a95e67e3e6b8569756510143a29e | refs/heads/master | 2021-05-07T03:07:25.347000 | 2019-09-27T05:07:26 | 2019-09-27T05:07:26 | 110,630,457 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package topGoogleQuestions;
/**
* Created by HinTi on 2019/9/25.
* Goal:
*/
public class Problem246_StrobogrammaticI {
public boolean isStrobogrammatic(String num) {
int left = 0, right = num.length() - 1;
while (left <= right) {
char lch = num.charAt(left);
char rch = num.charAt(right);
if (lch == rch) {
if (lch != '1' && lch != '0' && lch != '8')
return false;
} else {
if (!(lch == '6' && rch == '9') && !(lch == '9' && rch == '6'))
return false;
}
left++;
right--;
}
return true;
}
} | UTF-8 | Java | 689 | java | Problem246_StrobogrammaticI.java | Java | [
{
"context": "package topGoogleQuestions;\n\n/**\n * Created by HinTi on 2019/9/25.\n * Goal:\n */\npublic class Problem24",
"end": 52,
"score": 0.7576068043708801,
"start": 47,
"tag": "NAME",
"value": "HinTi"
}
] | null | [] | package topGoogleQuestions;
/**
* Created by HinTi on 2019/9/25.
* Goal:
*/
public class Problem246_StrobogrammaticI {
public boolean isStrobogrammatic(String num) {
int left = 0, right = num.length() - 1;
while (left <= right) {
char lch = num.charAt(left);
char rch = num.charAt(right);
if (lch == rch) {
if (lch != '1' && lch != '0' && lch != '8')
return false;
} else {
if (!(lch == '6' && rch == '9') && !(lch == '9' && rch == '6'))
return false;
}
left++;
right--;
}
return true;
}
} | 689 | 0.422351 | 0.394775 | 25 | 26.6 | 19.497692 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 13 |
4125ef11b233cf3ca3dec88a468a8ec5f742d8d3 | 6,648,609,375,594 | 52c8132a975ca90a8c623d14e2da22352ce8d0c3 | /src/main/java/xyz/zaijushou/zhx/sys/entity/DataCaseSynergyDetailEntity.java | 7acacc1cdba763a2ee55c803679e763c7637f36b | [] | no_license | feiqi321/zxh | https://github.com/feiqi321/zxh | e2d80874592aef48ddd522e7ff7f96de3b68f37d | 65feff2129fb23ad2cba24cdc30c58e6c8b8915b | refs/heads/master | 2022-06-26T11:46:39.114000 | 2019-11-18T07:45:34 | 2019-11-18T07:45:34 | 166,340,929 | 0 | 1 | null | false | 2022-06-17T02:03:41 | 2019-01-18T03:57:08 | 2019-11-18T07:45:38 | 2022-06-17T02:03:40 | 3,339 | 0 | 0 | 4 | Java | false | false | package xyz.zaijushou.zhx.sys.entity;
import xyz.zaijushou.zhx.common.entity.CommonEntity;
/**
* Created by looyer on 2019/3/10.
*/
public class DataCaseSynergyDetailEntity extends CommonEntity {
private int caseId;
private int opType;
private int synergisticType;
private String synergisticResult;
private int synergisticUser;
private String applyContent;
private int applyer;
private String synergisticApplyStatus;
private String synergisticFinishStatus;
public int getCaseId() {
return caseId;
}
public void setCaseId(int caseId) {
this.caseId = caseId;
}
public int getSynergisticUser() {
return synergisticUser;
}
public void setSynergisticUser(int synergisticUser) {
this.synergisticUser = synergisticUser;
}
public int getOpType() {
return opType;
}
public void setOpType(int opType) {
this.opType = opType;
}
public int getSynergisticType() {
return synergisticType;
}
public void setSynergisticType(int synergisticType) {
this.synergisticType = synergisticType;
}
public String getSynergisticResult() {
return synergisticResult;
}
public void setSynergisticResult(String synergisticResult) {
this.synergisticResult = synergisticResult;
}
public String getApplyContent() {
return applyContent;
}
public void setApplyContent(String applyContent) {
this.applyContent = applyContent;
}
public int getApplyer() {
return applyer;
}
public void setApplyer(int applyer) {
this.applyer = applyer;
}
public String getSynergisticApplyStatus() {
return synergisticApplyStatus;
}
public void setSynergisticApplyStatus(String synergisticApplyStatus) {
this.synergisticApplyStatus = synergisticApplyStatus;
}
public String getSynergisticFinishStatus() {
return synergisticFinishStatus;
}
public void setSynergisticFinishStatus(String synergisticFinishStatus) {
this.synergisticFinishStatus = synergisticFinishStatus;
}
}
| UTF-8 | Java | 2,171 | java | DataCaseSynergyDetailEntity.java | Java | [
{
"context": "zhx.common.entity.CommonEntity;\n\n/**\n * Created by looyer on 2019/3/10.\n */\npublic class DataCaseSynergyDet",
"end": 117,
"score": 0.9996716380119324,
"start": 111,
"tag": "USERNAME",
"value": "looyer"
}
] | null | [] | package xyz.zaijushou.zhx.sys.entity;
import xyz.zaijushou.zhx.common.entity.CommonEntity;
/**
* Created by looyer on 2019/3/10.
*/
public class DataCaseSynergyDetailEntity extends CommonEntity {
private int caseId;
private int opType;
private int synergisticType;
private String synergisticResult;
private int synergisticUser;
private String applyContent;
private int applyer;
private String synergisticApplyStatus;
private String synergisticFinishStatus;
public int getCaseId() {
return caseId;
}
public void setCaseId(int caseId) {
this.caseId = caseId;
}
public int getSynergisticUser() {
return synergisticUser;
}
public void setSynergisticUser(int synergisticUser) {
this.synergisticUser = synergisticUser;
}
public int getOpType() {
return opType;
}
public void setOpType(int opType) {
this.opType = opType;
}
public int getSynergisticType() {
return synergisticType;
}
public void setSynergisticType(int synergisticType) {
this.synergisticType = synergisticType;
}
public String getSynergisticResult() {
return synergisticResult;
}
public void setSynergisticResult(String synergisticResult) {
this.synergisticResult = synergisticResult;
}
public String getApplyContent() {
return applyContent;
}
public void setApplyContent(String applyContent) {
this.applyContent = applyContent;
}
public int getApplyer() {
return applyer;
}
public void setApplyer(int applyer) {
this.applyer = applyer;
}
public String getSynergisticApplyStatus() {
return synergisticApplyStatus;
}
public void setSynergisticApplyStatus(String synergisticApplyStatus) {
this.synergisticApplyStatus = synergisticApplyStatus;
}
public String getSynergisticFinishStatus() {
return synergisticFinishStatus;
}
public void setSynergisticFinishStatus(String synergisticFinishStatus) {
this.synergisticFinishStatus = synergisticFinishStatus;
}
}
| 2,171 | 0.684477 | 0.681253 | 100 | 20.709999 | 21.455206 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.29 | false | false | 13 |
72a02478cef4a4f80c78067ae1de027b8ebad13c | 24,378,234,425,651 | afc1c37e6949ee68a2010270b6cc55b91cc95e45 | /src/com/app/laughing/LaughingService.java | 88e8caf9d1874e141b3778c63a167949352b26a4 | [] | no_license | Genxl/xlweixin | https://github.com/Genxl/xlweixin | 08726dd6fa2b4704dd61a3ad2b3d885faca5cfb2 | 0f0e4ae8465e2b48f83fddb643adefd2be06aaa9 | refs/heads/master | 2021-01-22T10:01:42.147000 | 2014-09-16T07:12:27 | 2014-09-16T07:12:27 | 19,139,779 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.laughing;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class LaughingService {
private static String httpRequest(String requestUrl){
StringBuffer buffer = new StringBuffer();
try {
// System.out.println("*****************"+requestUrl);
URL url = new URL(requestUrl);
HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection();
httpUrlConn.setDoInput(true);
httpUrlConn.setRequestMethod("GET");
httpUrlConn.connect();
// 将返回的输入流转换成字符串
InputStream inputStream = httpUrlConn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String str = null;
while ((str = bufferedReader.readLine()) != null) {
buffer.append(str);
}
bufferedReader.close();
inputStreamReader.close();
// 释放资源
inputStream.close();
inputStream = null;
httpUrlConn.disconnect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return buffer.toString();
}
/**
* 调用笑话API
*/
public String getLaugh(){
String queryUrl = "http://apix.sinaapp.com/joke/?appkey=trialuser";
String laugh = httpRequest(queryUrl);
laugh = laugh.replace("技术支持 方倍工作室", "")+"";
if(laugh.length()>6){
laugh = laugh.substring(1, laugh.length()-5)+"";
}
// System.out.println(laugh);
return laugh;
}
// public static void main(String args[]){
// LaughingService laugh = new LaughingService();
// laugh.getLaugh();
// }
}
| GB18030 | Java | 1,955 | java | LaughingService.java | Java | [
{
"context": " queryUrl = \"http://apix.sinaapp.com/joke/?appkey=trialuser\";\n String laugh = httpRequest(queryUrl",
"end": 1511,
"score": 0.8511191010475159,
"start": 1506,
"tag": "KEY",
"value": "trial"
}
] | null | [] | package com.app.laughing;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class LaughingService {
private static String httpRequest(String requestUrl){
StringBuffer buffer = new StringBuffer();
try {
// System.out.println("*****************"+requestUrl);
URL url = new URL(requestUrl);
HttpURLConnection httpUrlConn = (HttpURLConnection) url.openConnection();
httpUrlConn.setDoInput(true);
httpUrlConn.setRequestMethod("GET");
httpUrlConn.connect();
// 将返回的输入流转换成字符串
InputStream inputStream = httpUrlConn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String str = null;
while ((str = bufferedReader.readLine()) != null) {
buffer.append(str);
}
bufferedReader.close();
inputStreamReader.close();
// 释放资源
inputStream.close();
inputStream = null;
httpUrlConn.disconnect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return buffer.toString();
}
/**
* 调用笑话API
*/
public String getLaugh(){
String queryUrl = "http://apix.sinaapp.com/joke/?appkey=trialuser";
String laugh = httpRequest(queryUrl);
laugh = laugh.replace("技术支持 方倍工作室", "")+"";
if(laugh.length()>6){
laugh = laugh.substring(1, laugh.length()-5)+"";
}
// System.out.println(laugh);
return laugh;
}
// public static void main(String args[]){
// LaughingService laugh = new LaughingService();
// laugh.getLaugh();
// }
}
| 1,955 | 0.610554 | 0.608443 | 60 | 30.583334 | 22.792025 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.333333 | false | false | 13 |
6c8f1d0d418cdc12d49090d864b30664226e4c05 | 18,356,690,281,619 | 145307a7bbb72ab729656a157b660dbd1d2b3832 | /src/main/java/com/rdpgroupbd/apps/server/util/EMUtil.java | a3970b0568d6ea367929b80cb821c7fdd901f788 | [] | no_license | shahedhossain/RDPGXT | https://github.com/shahedhossain/RDPGXT | 0424dca322802e73f8701110af1da2b6bb856644 | 494d97019c0efe1577e1c0ae91e5ca19d0be690f | refs/heads/master | 2016-08-03T00:52:50.746000 | 2012-12-21T18:55:19 | 2012-12-21T18:55:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.rdpgroupbd.apps.server.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final public class EMUtil {
private static final Logger log = LoggerFactory.getLogger(EMUtil.class);
private static final String JPU = "ABC";
private EntityManagerFactory emf;
private EntityManager em;
private static EMUtil emu;
private EMUtil() {
emf = Persistence.createEntityManagerFactory(JPU);
em = emf.createEntityManager();
}
public static EMUtil getInstance() {
if (emu == null) {
emu = new EMUtil();
}
return emu;
}
public EntityManager getEntityManager() {
if (!em.isOpen()) {
emf = Persistence.createEntityManagerFactory(JPU);
em = emf.createEntityManager();
log.error("Unable to initialized Entity Manager!");
} else {
log.info("Entity Manager initialized ");
}
return em;
}
}
| UTF-8 | Java | 968 | java | EMUtil.java | Java | [] | null | [] | package com.rdpgroupbd.apps.server.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final public class EMUtil {
private static final Logger log = LoggerFactory.getLogger(EMUtil.class);
private static final String JPU = "ABC";
private EntityManagerFactory emf;
private EntityManager em;
private static EMUtil emu;
private EMUtil() {
emf = Persistence.createEntityManagerFactory(JPU);
em = emf.createEntityManager();
}
public static EMUtil getInstance() {
if (emu == null) {
emu = new EMUtil();
}
return emu;
}
public EntityManager getEntityManager() {
if (!em.isOpen()) {
emf = Persistence.createEntityManagerFactory(JPU);
em = emf.createEntityManager();
log.error("Unable to initialized Entity Manager!");
} else {
log.info("Entity Manager initialized ");
}
return em;
}
}
| 968 | 0.734504 | 0.732438 | 43 | 21.511627 | 19.48926 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.534884 | false | false | 13 |
d11603c4e77a7cf9221ce74916617c256ed7224c | 1,683,627,203,294 | 170fc772a3081bfa5fe4a5bdceee38ac341fc401 | /quizEEx_EJB/ejbModule/com/kiwi/entities/Quiz.java | e774f59b43ccd3f32e1ada2de2beb41bed4578ec | [] | no_license | IamKiwi/quizEEx | https://github.com/IamKiwi/quizEEx | b1d526473965ff75405200e89886038c15e87777 | 8125e122c499ebd6fefd9a5f6fc722e7530a6c9f | refs/heads/master | 2020-04-22T11:02:02.378000 | 2019-02-12T14:05:18 | 2019-02-12T14:05:18 | 170,325,514 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kiwi.entities;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the quizzes database table.
*
*/
@Entity
@Table(name="quizzes")
@NamedQuery(name="Quiz.findAll", query="SELECT q FROM Quiz q")
public class Quiz implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private int id;
private boolean active;
@Lob
private String category;
@Lob
private String name;
public Quiz() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public boolean getActive() {
return this.active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getCategory() {
return this.category;
}
public void setCategory(String category) {
this.category = category;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
} | UTF-8 | Java | 941 | java | Quiz.java | Java | [] | null | [] | package com.kiwi.entities;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the quizzes database table.
*
*/
@Entity
@Table(name="quizzes")
@NamedQuery(name="Quiz.findAll", query="SELECT q FROM Quiz q")
public class Quiz implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private int id;
private boolean active;
@Lob
private String category;
@Lob
private String name;
public Quiz() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public boolean getActive() {
return this.active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getCategory() {
return this.category;
}
public void setCategory(String category) {
this.category = category;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
} | 941 | 0.693943 | 0.69288 | 63 | 13.952381 | 15.756509 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.936508 | false | false | 13 |
2ab0db6ebc1c61978a4f426e48889f782aee445e | 12,541,304,520,064 | 58f0de7cba8a155c667aabeff25d01a97a67cb5a | /WebappHelp/src/webapp/help/utility/BrowserType.java | 49ede2f8e626c7b75316bda23f7a4d0e3d03d29e | [] | no_license | chaowang/webapp_2012fall | https://github.com/chaowang/webapp_2012fall | 2f75c6b38cb6de7d68af9a8b4dad3c7b79a0c679 | 8c3f4569031cbf0646671e2554465b7f0d8d972d | refs/heads/master | 2021-01-22T04:49:33.086000 | 2011-11-29T07:00:19 | 2011-11-29T07:00:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package webapp.help.utility;
public enum BrowserType {
Mobile,
Desktop
}
| UTF-8 | Java | 76 | java | BrowserType.java | Java | [] | null | [] | package webapp.help.utility;
public enum BrowserType {
Mobile,
Desktop
}
| 76 | 0.763158 | 0.763158 | 6 | 11.666667 | 10.964589 | 28 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 13 |
f638dfbaf57540e4e33cde991004da3c939df784 | 15,307,263,443,804 | 2cac80e1faea4469c1c4861876c41f6a213e611b | /app/src/main/java/lenovo/example/com/ilovenougat/adapters/ResultsAdapter.java | 9895a29d6aef4ade86ef79d92bd4986666a3bb1d | [] | no_license | abhi2448222/iLoveNougat | https://github.com/abhi2448222/iLoveNougat | 73fe291c359981da7041861887e9f392445879f4 | d96ff008e67c9a0bd2a55ce05838078f66fb7f4c | refs/heads/master | 2020-04-10T23:42:30.005000 | 2016-09-13T07:27:29 | 2016-09-13T07:27:29 | 68,085,274 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package lenovo.example.com.ilovenougat.adapters;
/**
* Created by Lenovo on 9/11/2016.
*/
import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
import lenovo.example.com.ilovenougat.R;
import lenovo.example.com.ilovenougat.model.Result;
public class ResultsAdapter extends RecyclerView.Adapter<ResultsAdapter.ResultsViewHolder> {
List<Result> resultList;
Context context;
ItemOnClickListener itemOnClickListener;
public static class ResultsViewHolder extends RecyclerView.ViewHolder {
public ImageView thumbnailImage;
public TextView price, percentOff, brand,productName;
public CardView container;
public ResultsViewHolder(View v) {
super(v);
thumbnailImage = (ImageView) v.findViewById(R.id.item_thumbnail);
productName = (TextView) v.findViewById(R.id.product_name);
price = (TextView) v.findViewById(R.id.price);
percentOff = (TextView) v.findViewById(R.id.percent_off);
brand = (TextView) v.findViewById(R.id.brand_name);
container = (CardView) v.findViewById(R.id.container);
}
}
public ResultsAdapter(List<Result> resultList, Context context) {
this.resultList = resultList;
this.context = context;
}
// Create new views (invoked by the layout manager)
@Override
public ResultsAdapter.ResultsViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.results_item, parent, false);
ResultsViewHolder vh = new ResultsViewHolder(v);
return vh;
}
//Displaying Product name, price, brand, percentage discount and thumbnail of the image in a cardView
@Override
public void onBindViewHolder(ResultsViewHolder holder, final int position) {
holder.productName.setText(Html.fromHtml(resultList.get(position).getProductName()));
holder.price.setText(String.valueOf(resultList.get(position).getPrice()));
holder.brand.setText(Html.fromHtml(String.valueOf(resultList.get(position).getBrandName())));
if(!resultList.get(position).getPercentOff().equals("0%")){
holder.percentOff.setText(resultList.get(position).getPercentOff() + " off");
}else{
holder.percentOff.setVisibility(View.GONE);
}
Picasso.with(context).load(resultList.get(position).getThumbnailImageUrl()).into(holder.thumbnailImage);
holder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemOnClickListener.onItemClick(resultList.get(position));
}
});
}
public void setItemOnClickListener(ItemOnClickListener itemOnClickListener) {
this.itemOnClickListener = itemOnClickListener;
}
@Override
public int getItemCount() {
return resultList.size();
}
public interface ItemOnClickListener{
void onItemClick(Result res);
}
}
| UTF-8 | Java | 3,440 | java | ResultsAdapter.java | Java | [
{
"context": "ample.com.ilovenougat.adapters;\n\n/**\n * Created by Lenovo on 9/11/2016.\n */\nimport android.content.Context;",
"end": 74,
"score": 0.8710706233978271,
"start": 68,
"tag": "USERNAME",
"value": "Lenovo"
}
] | null | [] | package lenovo.example.com.ilovenougat.adapters;
/**
* Created by Lenovo on 9/11/2016.
*/
import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
import lenovo.example.com.ilovenougat.R;
import lenovo.example.com.ilovenougat.model.Result;
public class ResultsAdapter extends RecyclerView.Adapter<ResultsAdapter.ResultsViewHolder> {
List<Result> resultList;
Context context;
ItemOnClickListener itemOnClickListener;
public static class ResultsViewHolder extends RecyclerView.ViewHolder {
public ImageView thumbnailImage;
public TextView price, percentOff, brand,productName;
public CardView container;
public ResultsViewHolder(View v) {
super(v);
thumbnailImage = (ImageView) v.findViewById(R.id.item_thumbnail);
productName = (TextView) v.findViewById(R.id.product_name);
price = (TextView) v.findViewById(R.id.price);
percentOff = (TextView) v.findViewById(R.id.percent_off);
brand = (TextView) v.findViewById(R.id.brand_name);
container = (CardView) v.findViewById(R.id.container);
}
}
public ResultsAdapter(List<Result> resultList, Context context) {
this.resultList = resultList;
this.context = context;
}
// Create new views (invoked by the layout manager)
@Override
public ResultsAdapter.ResultsViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.results_item, parent, false);
ResultsViewHolder vh = new ResultsViewHolder(v);
return vh;
}
//Displaying Product name, price, brand, percentage discount and thumbnail of the image in a cardView
@Override
public void onBindViewHolder(ResultsViewHolder holder, final int position) {
holder.productName.setText(Html.fromHtml(resultList.get(position).getProductName()));
holder.price.setText(String.valueOf(resultList.get(position).getPrice()));
holder.brand.setText(Html.fromHtml(String.valueOf(resultList.get(position).getBrandName())));
if(!resultList.get(position).getPercentOff().equals("0%")){
holder.percentOff.setText(resultList.get(position).getPercentOff() + " off");
}else{
holder.percentOff.setVisibility(View.GONE);
}
Picasso.with(context).load(resultList.get(position).getThumbnailImageUrl()).into(holder.thumbnailImage);
holder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemOnClickListener.onItemClick(resultList.get(position));
}
});
}
public void setItemOnClickListener(ItemOnClickListener itemOnClickListener) {
this.itemOnClickListener = itemOnClickListener;
}
@Override
public int getItemCount() {
return resultList.size();
}
public interface ItemOnClickListener{
void onItemClick(Result res);
}
}
| 3,440 | 0.682849 | 0.679942 | 100 | 33.400002 | 30.735973 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.54 | false | false | 13 |
82b9921b6c12b4911022e5a1ca8d87d3fb45db84 | 14,070,312,925,580 | 7db752b5f6ca6057f857ee92af99df83f05741e4 | /Widowmaker/src/com/bhrobotics/widowmaker/models/Compressor.java | 3fc898d8cbec12ddfd71651cc383538ea73c56eb | [
"MIT"
] | permissive | kern/mortorq | https://github.com/kern/mortorq | 9d10ceb9e2aab2717556b30bd26355504c29fe23 | 1a1c35b22b4b0cc178c1118d4b988d0e2c90f146 | refs/heads/master | 2016-09-09T20:19:47.523000 | 2010-03-05T19:15:18 | 2010-03-05T19:15:18 | 409,588 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bhrobotics.widowmaker.models;
import com.bhrobotics.morlib.Model;
public class Compressor implements Model {
private boolean manual = false;
private boolean sensor = false;
private boolean auto = true;
public void start() {}
public void stop() {
auto = false;
manual = false;
}
public void setManual(boolean _manual) { manual = _manual; }
public void setSensor(boolean _sensor) { sensor = _sensor; }
public void setAuto(boolean _auto) { auto = _auto; }
public boolean get() {
if(auto) { return !sensor; }
return manual;
}
} | UTF-8 | Java | 620 | java | Compressor.java | Java | [] | null | [] | package com.bhrobotics.widowmaker.models;
import com.bhrobotics.morlib.Model;
public class Compressor implements Model {
private boolean manual = false;
private boolean sensor = false;
private boolean auto = true;
public void start() {}
public void stop() {
auto = false;
manual = false;
}
public void setManual(boolean _manual) { manual = _manual; }
public void setSensor(boolean _sensor) { sensor = _sensor; }
public void setAuto(boolean _auto) { auto = _auto; }
public boolean get() {
if(auto) { return !sensor; }
return manual;
}
} | 620 | 0.633871 | 0.633871 | 24 | 24.875 | 19.755405 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 13 |
fb3810450bbd166adf1458ba4bc10798ed7749ee | 3,298,534,949,561 | 41f24d6043df6e7bfab90c750f51769149b10a66 | /gallery/app/src/main/java/com/example/gallery/recyclerview.java | b651a1e301197f38135f824db70be94a32507b62 | [] | no_license | dhara-31/dtDay9 | https://github.com/dhara-31/dtDay9 | 9224d2c0721c7159f5915932c2a6cf5a9d0489c1 | c582baa7a5d96bd00793501c253dcfb2f538027e | refs/heads/master | 2020-09-05T16:03:10.999000 | 2019-11-07T04:22:27 | 2019-11-07T04:22:27 | 220,150,720 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.gallery;
import android.view.View;
public interface recyclerview {
void onclick(View view,int position);
}
| UTF-8 | Java | 134 | java | recyclerview.java | Java | [] | null | [] | package com.example.gallery;
import android.view.View;
public interface recyclerview {
void onclick(View view,int position);
}
| 134 | 0.761194 | 0.761194 | 8 | 15.75 | 16.075991 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 13 |
9eb4c16eeb98ce13eab740504858f0a0960417f7 | 31,001,074,011,181 | dda0b7868f96b14da454579560710ef4735af02b | /src/main/java/secsort/SecGroup.java | 32341a8e815a5624d3e625400b8c8477db0e68fb | [] | no_license | Yanbuc/myhadoopcode | https://github.com/Yanbuc/myhadoopcode | 6b81939ed18790eb387f45fccb6a1ff6351a51f6 | 8e4dd4b3fc9824b8fe0037a5826ee48bb563c75b | refs/heads/master | 2022-08-31T10:42:26.016000 | 2019-10-11T14:03:57 | 2019-10-11T14:03:57 | 214,451,237 | 0 | 0 | null | false | 2022-07-01T17:42:39 | 2019-10-11T14:02:16 | 2019-10-11T14:05:45 | 2022-07-01T17:42:39 | 772 | 0 | 0 | 5 | Java | false | false | package secsort;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class SecGroup extends WritableComparator {
protected SecGroup(){
super(CombineKey.class,true);
}
@Override
public int compare(WritableComparable a, WritableComparable b) {
CombineKey one=(CombineKey) a;
CombineKey two=(CombineKey) b;
return one.getYear() == two.getYear() ? 0 : -1;
}
}
| UTF-8 | Java | 477 | java | SecGroup.java | Java | [] | null | [] | package secsort;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class SecGroup extends WritableComparator {
protected SecGroup(){
super(CombineKey.class,true);
}
@Override
public int compare(WritableComparable a, WritableComparable b) {
CombineKey one=(CombineKey) a;
CombineKey two=(CombineKey) b;
return one.getYear() == two.getYear() ? 0 : -1;
}
}
| 477 | 0.668763 | 0.66457 | 16 | 27.8125 | 21.720436 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5625 | false | false | 13 |
4cd88546ff87ad9fbcfb458a97a8b00b0edafaea | 31,001,074,009,723 | a3648eb3210541dac0fcb7cb46c6f3aecc120aa3 | /component/src/main/java/com/rongzhong/component/convert/OfficeToPdfSimple.java | d037a1b4e3ff3bdcbdfb65f9c48babe6d67b5efa | [] | no_license | pxieraly/demo | https://github.com/pxieraly/demo | 419d3d103fd66d51566619e263d729f38abd2a78 | e599f273d2e307865e88dd745560488d0d34fea8 | refs/heads/master | 2016-09-13T11:36:21.839000 | 2016-07-29T06:55:55 | 2016-07-29T06:55:55 | 64,457,335 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* OfficeToPdfSimpleImpl.java
* Copyright (c) 2011,融众网络技术有限公司(www.11186.com)
* All rights reserved.
* ---------------------------------------------------------------------
* 2011-11-8 Created
*/
package com.rongzhong.component.convert;
import java.io.File;
import java.net.ConnectException;
import org.apache.commons.lang.StringUtils;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.rongzhong.component.convert.exception.DocumentConvertException;
import com.rongzhong.component.logger.SimpleLogger;
/**
* office文档转pdf
*
* @author 杜晶
* @version 1.0 2011-11-8
* @since 1.0
*/
public class OfficeToPdfSimple {
private SimpleLogger logger = SimpleLogger.getLogger(OfficeToPdfSimple.class);
private static final String SUFFIX_PDF = ".pdf";
/**
*
* @param is
* @return
*/
public String officeToPdf(String filesrc) {
// 将文档写入临时文件
String pdfPath = StringUtils.substringBeforeLast(filesrc, ".") + SUFFIX_PDF;
try {
createPdf(filesrc, pdfPath);
} catch (DocumentConvertException e) {
logger.error("doc convert pdf has error", e);
return "";
}
return pdfPath;
}
/**
* office文档转pdf文档
*
* @param source
* 源文档路径
* @param dest
* 目标文档路径
* @throws DocumentConvertException
*/
private void convert(String source, String dest) throws DocumentConvertException {
File inputFile = new File(source);
File outputFile = new File(dest);
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
} catch (ConnectException e) {
logger.error("openoffice connet failed", e);
throw new DocumentConvertException("openoffice connet failed", e);
} finally {
if (connection != null) {
connection.disconnect();
connection = null;
}
}
}
/**
* 文档pdf转换并保存
*
* @param tempDocument
* 源文档的临时文档路径
* @param pdfPath
* 要转换的pdf文档路径
* @throws DocumentConvertException
*/
private void createPdf(String tempDocument, String pdfPath) throws DocumentConvertException {
convert(tempDocument, pdfPath);
}
}
| UTF-8 | Java | 2,696 | java | OfficeToPdfSimple.java | Java | [
{
"context": "eLogger;\r\n\r\n/**\r\n * office文档转pdf\r\n * \r\n * @author 杜晶\r\n * @version 1.0 2011-11-8\r\n * @since 1.0\r\n */\r\np",
"end": 846,
"score": 0.9995759725570679,
"start": 844,
"tag": "NAME",
"value": "杜晶"
}
] | null | [] | /*
* OfficeToPdfSimpleImpl.java
* Copyright (c) 2011,融众网络技术有限公司(www.11186.com)
* All rights reserved.
* ---------------------------------------------------------------------
* 2011-11-8 Created
*/
package com.rongzhong.component.convert;
import java.io.File;
import java.net.ConnectException;
import org.apache.commons.lang.StringUtils;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.rongzhong.component.convert.exception.DocumentConvertException;
import com.rongzhong.component.logger.SimpleLogger;
/**
* office文档转pdf
*
* @author 杜晶
* @version 1.0 2011-11-8
* @since 1.0
*/
public class OfficeToPdfSimple {
private SimpleLogger logger = SimpleLogger.getLogger(OfficeToPdfSimple.class);
private static final String SUFFIX_PDF = ".pdf";
/**
*
* @param is
* @return
*/
public String officeToPdf(String filesrc) {
// 将文档写入临时文件
String pdfPath = StringUtils.substringBeforeLast(filesrc, ".") + SUFFIX_PDF;
try {
createPdf(filesrc, pdfPath);
} catch (DocumentConvertException e) {
logger.error("doc convert pdf has error", e);
return "";
}
return pdfPath;
}
/**
* office文档转pdf文档
*
* @param source
* 源文档路径
* @param dest
* 目标文档路径
* @throws DocumentConvertException
*/
private void convert(String source, String dest) throws DocumentConvertException {
File inputFile = new File(source);
File outputFile = new File(dest);
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
} catch (ConnectException e) {
logger.error("openoffice connet failed", e);
throw new DocumentConvertException("openoffice connet failed", e);
} finally {
if (connection != null) {
connection.disconnect();
connection = null;
}
}
}
/**
* 文档pdf转换并保存
*
* @param tempDocument
* 源文档的临时文档路径
* @param pdfPath
* 要转换的pdf文档路径
* @throws DocumentConvertException
*/
private void createPdf(String tempDocument, String pdfPath) throws DocumentConvertException {
convert(tempDocument, pdfPath);
}
}
| 2,696 | 0.680436 | 0.668355 | 92 | 25.891304 | 25.468418 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.467391 | false | false | 13 |
7278a0d684c2702d123d4b761518f719152e3bd1 | 3,856,880,639,398 | a8abb43368f91a06d3c85d0e39b488f802b615bf | /java/com/anson/acode/view/OverscrollView.java | 7b45f3f8654600b750c3e8783e84d49413c6a915 | [] | no_license | ansondroider/acode | https://github.com/ansondroider/acode | 78e05dcad6d99c85ddcd4565a70ee52a97c59b06 | d6744749af6db840343a6d10345951ccf92febd9 | refs/heads/master | 2021-06-03T10:34:30.492000 | 2019-03-30T09:57:29 | 2019-03-30T09:57:29 | 42,907,384 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.anson.acode.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import com.anson.acode.R;
public class OverscrollView extends View {
String TAG = "OverscrollView";
public static final int over_none = 0x0000;
public static final int over_left = 0x0001;
public static final int over_top = 0x0010;
public static final int over_right =0x0100;
public static final int over_bottom=0x1000;
private final int DURATION = 200;
private int maxAlpha = 255;
private int minAlpha = 0;
private int alpha = 0;
private int overscrollFlags = 0;
Drawable overscroll_left, overscroll_top, overscroll_right, overscroll_bottom;
Handler h = new Handler(){
public void handleMessage(android.os.Message msg) {
moveStepByStep();
}
};
public OverscrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public OverscrollView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public OverscrollView(Context context) {
super(context);
init();
}
void init(){
overscroll_left = getResources().getDrawable(R.drawable.overscroll_left);
overscroll_top = getResources().getDrawable(R.drawable.overscroll_top);
overscroll_right = getResources().getDrawable(R.drawable.overscroll_right);
overscroll_bottom = getResources().getDrawable(R.drawable.overscroll_bottom);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if(width > 0 && height > 0){
overscroll_left.setBounds(0, 0, width/4, height);
overscroll_top.setBounds(0, 0, width, height/4);
overscroll_right.setBounds(width/4*3, 0, width, height);
overscroll_bottom.setBounds(0, height/4*3, width, height);
}
}
public void clear(){
overscrollFlags = 0;
alpha = 0;
}
public void setOverScroll(int direct, int distance){
alpha = distance;
alpha = alpha < minAlpha ? minAlpha : (alpha > maxAlpha ? maxAlpha :alpha);
overscrollFlags |= direct;
postInvalidate();
}
public void touchRelease(){
startClear();
}
@Override
protected void onDraw(Canvas canvas) {
//ALog.alog(TAG, "onDraw overscrollFlags = " + overscrollFlags);
if(canvas == null || overscrollFlags == 0)return;
if((over_left & overscrollFlags) > 0){
overscroll_left.setAlpha(alpha);
overscroll_left.draw(canvas);
}
if((over_right & overscrollFlags) > 0){
overscroll_right.setAlpha(alpha);
overscroll_right.draw(canvas);
}
if((over_top & overscrollFlags) > 0){
overscroll_top.setAlpha(alpha);
overscroll_top.draw(canvas);
}
if((over_bottom & overscrollFlags) > 0){
overscroll_bottom.setAlpha(alpha);
overscroll_bottom.draw(canvas);
}
}
int tranAlpha = 0;
long startTime = 0;
void startClear(){
startTime = System.currentTimeMillis();
tranAlpha = alpha;
h.sendEmptyMessageDelayed(0, 20);
}
void moveStepByStep(){
long curTime = System.currentTimeMillis();
int passTime = (int)(curTime - startTime);
if(passTime < DURATION){
alpha = maxAlpha - tranAlpha * passTime / DURATION;
h.sendEmptyMessageDelayed(0, 20);
postInvalidate();
}else{
alpha = 0;
postInvalidate();
clear();
}
}
}
| UTF-8 | Java | 3,492 | java | OverscrollView.java | Java | [] | null | [] | package com.anson.acode.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import com.anson.acode.R;
public class OverscrollView extends View {
String TAG = "OverscrollView";
public static final int over_none = 0x0000;
public static final int over_left = 0x0001;
public static final int over_top = 0x0010;
public static final int over_right =0x0100;
public static final int over_bottom=0x1000;
private final int DURATION = 200;
private int maxAlpha = 255;
private int minAlpha = 0;
private int alpha = 0;
private int overscrollFlags = 0;
Drawable overscroll_left, overscroll_top, overscroll_right, overscroll_bottom;
Handler h = new Handler(){
public void handleMessage(android.os.Message msg) {
moveStepByStep();
}
};
public OverscrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public OverscrollView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public OverscrollView(Context context) {
super(context);
init();
}
void init(){
overscroll_left = getResources().getDrawable(R.drawable.overscroll_left);
overscroll_top = getResources().getDrawable(R.drawable.overscroll_top);
overscroll_right = getResources().getDrawable(R.drawable.overscroll_right);
overscroll_bottom = getResources().getDrawable(R.drawable.overscroll_bottom);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if(width > 0 && height > 0){
overscroll_left.setBounds(0, 0, width/4, height);
overscroll_top.setBounds(0, 0, width, height/4);
overscroll_right.setBounds(width/4*3, 0, width, height);
overscroll_bottom.setBounds(0, height/4*3, width, height);
}
}
public void clear(){
overscrollFlags = 0;
alpha = 0;
}
public void setOverScroll(int direct, int distance){
alpha = distance;
alpha = alpha < minAlpha ? minAlpha : (alpha > maxAlpha ? maxAlpha :alpha);
overscrollFlags |= direct;
postInvalidate();
}
public void touchRelease(){
startClear();
}
@Override
protected void onDraw(Canvas canvas) {
//ALog.alog(TAG, "onDraw overscrollFlags = " + overscrollFlags);
if(canvas == null || overscrollFlags == 0)return;
if((over_left & overscrollFlags) > 0){
overscroll_left.setAlpha(alpha);
overscroll_left.draw(canvas);
}
if((over_right & overscrollFlags) > 0){
overscroll_right.setAlpha(alpha);
overscroll_right.draw(canvas);
}
if((over_top & overscrollFlags) > 0){
overscroll_top.setAlpha(alpha);
overscroll_top.draw(canvas);
}
if((over_bottom & overscrollFlags) > 0){
overscroll_bottom.setAlpha(alpha);
overscroll_bottom.draw(canvas);
}
}
int tranAlpha = 0;
long startTime = 0;
void startClear(){
startTime = System.currentTimeMillis();
tranAlpha = alpha;
h.sendEmptyMessageDelayed(0, 20);
}
void moveStepByStep(){
long curTime = System.currentTimeMillis();
int passTime = (int)(curTime - startTime);
if(passTime < DURATION){
alpha = maxAlpha - tranAlpha * passTime / DURATION;
h.sendEmptyMessageDelayed(0, 20);
postInvalidate();
}else{
alpha = 0;
postInvalidate();
clear();
}
}
}
| 3,492 | 0.715063 | 0.696735 | 131 | 25.656488 | 22.067823 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.267176 | false | false | 13 |
d59b202db93f2a04d9c18ac0dc6565f606c1e1f9 | 18,202,071,404,442 | e5b73019160a5697dff852e3d9fa5fa6abdbe681 | /JOOP.HW.L6.3/src/com/gmail/wildekatertz/SortShell.java | af46d0f3ddc25aa9de3874c4c3fcae151709b0e1 | [] | no_license | WildeKater/wk_java_oop | https://github.com/WildeKater/wk_java_oop | f5feb46907a76fd7988b740a401da8bd1cc6442a | d0c385ef8edc4da9859c01012e74900df28f770a | refs/heads/master | 2020-05-04T23:01:25.831000 | 2019-05-22T20:48:53 | 2019-05-22T20:48:53 | 179,530,679 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gmail.wildekatertz;
public class SortShell {
public static void sortShell(int[] array) {
for (int increment = array.length / 3; increment >= 1; increment = increment / 3) {
for (int startIndex = 0; startIndex < increment; startIndex++) {
insertSort(array, startIndex, increment);
}
}
}
private static void insertSort(int[] array, int startIndex, int increment) {
for (int i = startIndex; i < array.length; i = i + increment) {
for (int j = Math.min(i + increment, array.length - 1); j - increment >= 0; j = j - increment) {
if (array[j - increment] > array[j]) {
int temp = array[j];
array[j] = array[j - increment];
array[j - increment] = temp;
} else {
break;
}
}
}
}
}
| UTF-8 | Java | 748 | java | SortShell.java | Java | [
{
"context": "package com.gmail.wildekatertz;\n\npublic class SortShell {\n\n\tpublic static void s",
"end": 30,
"score": 0.9881480932235718,
"start": 18,
"tag": "USERNAME",
"value": "wildekatertz"
}
] | null | [] | package com.gmail.wildekatertz;
public class SortShell {
public static void sortShell(int[] array) {
for (int increment = array.length / 3; increment >= 1; increment = increment / 3) {
for (int startIndex = 0; startIndex < increment; startIndex++) {
insertSort(array, startIndex, increment);
}
}
}
private static void insertSort(int[] array, int startIndex, int increment) {
for (int i = startIndex; i < array.length; i = i + increment) {
for (int j = Math.min(i + increment, array.length - 1); j - increment >= 0; j = j - increment) {
if (array[j - increment] > array[j]) {
int temp = array[j];
array[j] = array[j - increment];
array[j - increment] = temp;
} else {
break;
}
}
}
}
}
| 748 | 0.613636 | 0.605615 | 27 | 26.703703 | 29.255978 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.925926 | false | false | 13 |
75fe64026fba0b42d7011f29c555039c6fa8557c | 22,754,736,773,907 | 52b19dcff5462cfdda698a9a360e3fa351374af3 | /src/main/java/com/github/cc3002/finalreality/model/weapon/AbstractWeapon.java | 8509c8542f2ac7325a0dadfe5df404771c050939 | [
"LicenseRef-scancode-unknown-license-reference",
"CC-BY-4.0",
"LicenseRef-scancode-public-domain"
] | permissive | camilabarca/final-reality-camilabarca | https://github.com/camilabarca/final-reality-camilabarca | 4033ae02283373a847d03dc48b9f51d61af468f5 | a4e23fb16729f24a4e933f3af37e37730dbf37d3 | refs/heads/master | 2023-02-08T20:48:58.948000 | 2020-12-30T19:09:28 | 2020-12-30T19:09:28 | 297,722,904 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.cc3002.finalreality.model.weapon;
import java.util.Objects;
/**
* An abstract class that holds the common behaviour of all the weapons
*
* @author Ignacio Slater Muñoz.
* @author Camila Labarca
*/
public abstract class AbstractWeapon implements IWeapon {
private final String name;
private final int damage;
private final int weight;
public AbstractWeapon(final String name, final int damage, final int weight) {
this.name = name;
this.damage = damage;
this.weight = weight;
}
/**
* Returns the weapon's name.
*/
public String getName() {
return name;
}
/**
* Returns the weapon's damage.
*/
public int getDamage() {
return damage;
}
/**
* Returns the weapon's weight.
*/
public int getWeight() {
return weight;
}
@Override
public int hashCode() {
return Objects.hash(getName(), getDamage(), getWeight());
}
}
| UTF-8 | Java | 923 | java | AbstractWeapon.java | Java | [
{
"context": " common behaviour of all the weapons\n *\n * @author Ignacio Slater Muñoz.\n * @author Camila Labarca\n */\npublic abstract cl",
"end": 191,
"score": 0.9998891353607178,
"start": 171,
"tag": "NAME",
"value": "Ignacio Slater Muñoz"
},
{
"context": "ons\n *\n * @author Ig... | null | [] | package com.github.cc3002.finalreality.model.weapon;
import java.util.Objects;
/**
* An abstract class that holds the common behaviour of all the weapons
*
* @author <NAME>.
* @author <NAME>
*/
public abstract class AbstractWeapon implements IWeapon {
private final String name;
private final int damage;
private final int weight;
public AbstractWeapon(final String name, final int damage, final int weight) {
this.name = name;
this.damage = damage;
this.weight = weight;
}
/**
* Returns the weapon's name.
*/
public String getName() {
return name;
}
/**
* Returns the weapon's damage.
*/
public int getDamage() {
return damage;
}
/**
* Returns the weapon's weight.
*/
public int getWeight() {
return weight;
}
@Override
public int hashCode() {
return Objects.hash(getName(), getDamage(), getWeight());
}
}
| 900 | 0.661605 | 0.657267 | 48 | 18.208334 | 19.629866 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
7aee93dfc23ad126de60c9157bb04f71774ab85d | 9,577,777,119,112 | 90809326608ae1b14be3edfe4f534c042fe5d586 | /app/src/main/java/brainwiz/gobrainwiz/ChangePasswordFragment.java | 82f60d4acddc55bfef16162185b31662b7592ac2 | [] | no_license | go2391/GoBrainWiz | https://github.com/go2391/GoBrainWiz | 77dcae1e5be414669f8b0e504c6f9286b356318f | 4ebc8e84ea415834ed3cb94cb94d3e85b5bc1ee4 | refs/heads/master | 2021-07-16T08:34:41.574000 | 2018-12-22T09:49:13 | 2018-12-22T09:49:13 | 145,028,599 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package brainwiz.gobrainwiz;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.HashMap;
import brainwiz.gobrainwiz.api.ApiCallback;
import brainwiz.gobrainwiz.api.RetrofitManager;
import brainwiz.gobrainwiz.api.model.BaseModel;
import brainwiz.gobrainwiz.api.model.LoginModel;
import brainwiz.gobrainwiz.api.model.RegistrationModel;
import brainwiz.gobrainwiz.databinding.FragmentChangePasswordBinding;
import brainwiz.gobrainwiz.utils.DDAlerts;
import brainwiz.gobrainwiz.utils.KeyBoardUtils;
import brainwiz.gobrainwiz.utils.NetWorkUtil;
import brainwiz.gobrainwiz.utils.SharedPrefUtils;
import retrofit2.Response;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.IS_LOGIN;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_EMAIL;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_ID;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_MOBILE;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_NAME;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_TOKEN;
public class ChangePasswordFragment extends BaseFragment {
private Context context;
private FragmentActivity activity;
private FragmentChangePasswordBinding bind;
private boolean isRegistration;
@Override
public void onAttach(Context context) {
this.context = context;
activity = getActivity();
super.onAttach(context);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_change_password, container, false);
bind = DataBindingUtil.bind(inflate);
initViews();
return inflate;
}
private void initViews() {
bind.confirm.setOnClickListener(onClickListener);
}
private final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.confirm:
if (verifyFileds()) {
changePassword();
}
break;
}
}
};
private boolean verifyFileds() {
if (isEmpty(bind.currentPassword)) {
DDAlerts.showToast(getActivity(), "enter current password.");
return false;
}
if (isEmpty(bind.password)) {
DDAlerts.showToast(getActivity(), "enter new password.");
return false;
}
if (isEmpty(bind.confirmPassword)) {
DDAlerts.showToast(getActivity(), "enter confirm password.");
return false;
}
if (bind.currentPassword.getText().toString().equals(bind.password.getText().toString())) {
DDAlerts.showToast(getActivity(), "current password and new password are matcheh. Please use different password.");
return false;
}
if (!bind.password.getText().toString().equals(bind.confirmPassword.getText().toString())) {
DDAlerts.showToast(getActivity(), "new password and confirm password are not matched ");
return false;
}
return true;
}
private void changePassword() {
if (!NetWorkUtil.isConnected(context)) {
DDAlerts.showNetworkAlert(activity);
return;
}
KeyBoardUtils.hideKeyboard(getActivity());
showProgress();
HashMap<String, String> hashMap = getBaseBodyMap();
hashMap.put("old_password", bind.currentPassword.getText().toString().trim());
hashMap.put("new_password", bind.password.getText().toString().trim());
RetrofitManager.getRestApiMethods().changePassword(hashMap).enqueue(new ApiCallback<BaseModel>(getActivity()) {
@Override
public void onApiResponse(Response<BaseModel> response, boolean isSuccess, String message) {
dismissProgress();
if (isSuccess) {
// if (response.body().getData().getMessage().equalsIgnoreCase("Password Updated")) {
DDAlerts.showToast(getActivity(), "Password changed successfully.");
getActivity().getSupportFragmentManager().popBackStack();
// activity.finish();
// startActivity(new Intent(activity, MainActivity.class));
} else {
DDAlerts.showResponseError(getActivity(), response.body());
}
// }
}
@Override
public void onApiFailure(boolean isSuccess, String message) {
dismissProgress();
}
});
}
}
| UTF-8 | Java | 5,076 | java | ChangePasswordFragment.java | Java | [] | null | [] | package brainwiz.gobrainwiz;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.HashMap;
import brainwiz.gobrainwiz.api.ApiCallback;
import brainwiz.gobrainwiz.api.RetrofitManager;
import brainwiz.gobrainwiz.api.model.BaseModel;
import brainwiz.gobrainwiz.api.model.LoginModel;
import brainwiz.gobrainwiz.api.model.RegistrationModel;
import brainwiz.gobrainwiz.databinding.FragmentChangePasswordBinding;
import brainwiz.gobrainwiz.utils.DDAlerts;
import brainwiz.gobrainwiz.utils.KeyBoardUtils;
import brainwiz.gobrainwiz.utils.NetWorkUtil;
import brainwiz.gobrainwiz.utils.SharedPrefUtils;
import retrofit2.Response;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.IS_LOGIN;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_EMAIL;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_ID;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_MOBILE;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_NAME;
import static brainwiz.gobrainwiz.utils.SharedPrefUtils.USER_TOKEN;
public class ChangePasswordFragment extends BaseFragment {
private Context context;
private FragmentActivity activity;
private FragmentChangePasswordBinding bind;
private boolean isRegistration;
@Override
public void onAttach(Context context) {
this.context = context;
activity = getActivity();
super.onAttach(context);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_change_password, container, false);
bind = DataBindingUtil.bind(inflate);
initViews();
return inflate;
}
private void initViews() {
bind.confirm.setOnClickListener(onClickListener);
}
private final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.confirm:
if (verifyFileds()) {
changePassword();
}
break;
}
}
};
private boolean verifyFileds() {
if (isEmpty(bind.currentPassword)) {
DDAlerts.showToast(getActivity(), "enter current password.");
return false;
}
if (isEmpty(bind.password)) {
DDAlerts.showToast(getActivity(), "enter new password.");
return false;
}
if (isEmpty(bind.confirmPassword)) {
DDAlerts.showToast(getActivity(), "enter confirm password.");
return false;
}
if (bind.currentPassword.getText().toString().equals(bind.password.getText().toString())) {
DDAlerts.showToast(getActivity(), "current password and new password are matcheh. Please use different password.");
return false;
}
if (!bind.password.getText().toString().equals(bind.confirmPassword.getText().toString())) {
DDAlerts.showToast(getActivity(), "new password and confirm password are not matched ");
return false;
}
return true;
}
private void changePassword() {
if (!NetWorkUtil.isConnected(context)) {
DDAlerts.showNetworkAlert(activity);
return;
}
KeyBoardUtils.hideKeyboard(getActivity());
showProgress();
HashMap<String, String> hashMap = getBaseBodyMap();
hashMap.put("old_password", bind.currentPassword.getText().toString().trim());
hashMap.put("new_password", bind.password.getText().toString().trim());
RetrofitManager.getRestApiMethods().changePassword(hashMap).enqueue(new ApiCallback<BaseModel>(getActivity()) {
@Override
public void onApiResponse(Response<BaseModel> response, boolean isSuccess, String message) {
dismissProgress();
if (isSuccess) {
// if (response.body().getData().getMessage().equalsIgnoreCase("Password Updated")) {
DDAlerts.showToast(getActivity(), "Password changed successfully.");
getActivity().getSupportFragmentManager().popBackStack();
// activity.finish();
// startActivity(new Intent(activity, MainActivity.class));
} else {
DDAlerts.showResponseError(getActivity(), response.body());
}
// }
}
@Override
public void onApiFailure(boolean isSuccess, String message) {
dismissProgress();
}
});
}
}
| 5,076 | 0.656619 | 0.656225 | 158 | 31.126583 | 30.757263 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.550633 | false | false | 13 |
19c0b52cf90d87216fd8e51a7e36e0289aebbc1a | 16,398,185,179,423 | cec3aeb009469585c7f40357227196dad8a0e4b3 | /src/main/java/moe/gensoukyo/mcgproject/common/item/cart/ItemGRM3BF.java | b8056064716a880956b9fd2747b58d64d7bc875f | [
"MIT"
] | permissive | SQwatermark/MCGProject | https://github.com/SQwatermark/MCGProject | 5177a583a0cc09caef2d57ff2224cbb507df2412 | ed6b7d2e38f4fab0b5ad85fc957c5cd3d72bc936 | refs/heads/master | 2021-07-15T02:17:21.550000 | 2020-10-15T02:46:36 | 2020-10-15T02:46:36 | 246,191,651 | 8 | 5 | MIT | false | 2020-09-03T04:30:09 | 2020-03-10T02:41:03 | 2020-08-31T13:31:02 | 2020-09-03T04:30:08 | 39,967 | 4 | 4 | 0 | Java | false | false | package moe.gensoukyo.mcgproject.common.item.cart;
import moe.gensoukyo.mcgproject.common.entity.cart.GRBogie;
import moe.gensoukyo.mcgproject.common.entity.cart.GRM3B;
import moe.gensoukyo.mcgproject.common.entity.cart.GRMotor;
import moe.gensoukyo.mcgproject.core.MCGProject;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class ItemGRM3BF extends AbsItemMetro {
final int length = 13, coupler = 4;
public ItemGRM3BF() {
super(GRM3B.class, MCGProject.ID + "." + "grm_3bf", "grm_3bf");
}
public void doSpawn(World world, double x, double y, double z, EntityPlayer player, EnumFacing facing) {
BlockPos pos = new BlockPos(0, 0, 0);
GRBogie bogieA = new GRBogie(world, x, y, z, length / 2.0F, coupler / 2.0F);
pos = pos.offset(facing, length / 2);
double v = (length / 2.0F) - (float) (length / 2);
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(v);
GRM3B carA = new GRM3B(world, x + (double)pos.getX() + vec.x, y + 1.0D + vec.y, z + (double)pos.getZ() + vec.z);
pos = pos.offset(facing, length / 2 + (int) (v * 2));
GRMotor bogieB = new GRMotor(world, x + (double)pos.getX(), y, z + (double)pos.getZ(), length / 2.0F, coupler / 2.0F);
bogieB.setIsCenter(true);
pos = pos.offset(facing, length / 2);
v = (length / 2.0F) - (float) (length / 2);
vec = new Vec3d(facing.getDirectionVec()).scale(v);
GRM3B carB = new GRM3B(world, x + (double)pos.getX() + vec.x, y + 1.0D + vec.y, z + (double)pos.getZ() + vec.z);
pos = pos.offset(facing, length / 2 + (int) (v * 2));
GRBogie bogieC = new GRBogie(world, x + (double)pos.getX(), y, z + (double)pos.getZ(), length / 2.0F, coupler / 2.0F);
Bogie.link(bogieA, bogieB); Bogie.link(bogieB, bogieC);
carA.setBogieA(bogieA).setBogieB(bogieB); carB.setBogieB(bogieB).setBogieA(bogieC);
world.spawnEntity(bogieA); world.spawnEntity(bogieB); world.spawnEntity(bogieC);
world.spawnEntity(carA); world.spawnEntity(carB);
}
}
| UTF-8 | Java | 2,213 | java | ItemGRM3BF.java | Java | [] | null | [] | package moe.gensoukyo.mcgproject.common.item.cart;
import moe.gensoukyo.mcgproject.common.entity.cart.GRBogie;
import moe.gensoukyo.mcgproject.common.entity.cart.GRM3B;
import moe.gensoukyo.mcgproject.common.entity.cart.GRMotor;
import moe.gensoukyo.mcgproject.core.MCGProject;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class ItemGRM3BF extends AbsItemMetro {
final int length = 13, coupler = 4;
public ItemGRM3BF() {
super(GRM3B.class, MCGProject.ID + "." + "grm_3bf", "grm_3bf");
}
public void doSpawn(World world, double x, double y, double z, EntityPlayer player, EnumFacing facing) {
BlockPos pos = new BlockPos(0, 0, 0);
GRBogie bogieA = new GRBogie(world, x, y, z, length / 2.0F, coupler / 2.0F);
pos = pos.offset(facing, length / 2);
double v = (length / 2.0F) - (float) (length / 2);
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(v);
GRM3B carA = new GRM3B(world, x + (double)pos.getX() + vec.x, y + 1.0D + vec.y, z + (double)pos.getZ() + vec.z);
pos = pos.offset(facing, length / 2 + (int) (v * 2));
GRMotor bogieB = new GRMotor(world, x + (double)pos.getX(), y, z + (double)pos.getZ(), length / 2.0F, coupler / 2.0F);
bogieB.setIsCenter(true);
pos = pos.offset(facing, length / 2);
v = (length / 2.0F) - (float) (length / 2);
vec = new Vec3d(facing.getDirectionVec()).scale(v);
GRM3B carB = new GRM3B(world, x + (double)pos.getX() + vec.x, y + 1.0D + vec.y, z + (double)pos.getZ() + vec.z);
pos = pos.offset(facing, length / 2 + (int) (v * 2));
GRBogie bogieC = new GRBogie(world, x + (double)pos.getX(), y, z + (double)pos.getZ(), length / 2.0F, coupler / 2.0F);
Bogie.link(bogieA, bogieB); Bogie.link(bogieB, bogieC);
carA.setBogieA(bogieA).setBogieB(bogieB); carB.setBogieB(bogieB).setBogieA(bogieC);
world.spawnEntity(bogieA); world.spawnEntity(bogieB); world.spawnEntity(bogieC);
world.spawnEntity(carA); world.spawnEntity(carB);
}
}
| 2,213 | 0.651152 | 0.629462 | 47 | 46.085106 | 36.632637 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.553192 | false | false | 13 |
a3898856b96923835349dfb62b93138f75fd70e9 | 14,319,420,967,827 | b00c34ce09bc732bd86792ae1c0564d9aced849f | /Cinema/src/Sala.java | ab5e15735eaf7661dd93d9cf5b77cacfb5328eda | [] | no_license | utcuj/laboratorliste-MPasca | https://github.com/utcuj/laboratorliste-MPasca | e1b0eedf8f8b4f2ab12e689a24bd3c74dc3f645f | 5c10913c6902790af42221abbe5d031d4ae001ba | refs/heads/main | 2023-01-30T09:58:44.780000 | 2020-12-15T11:05:10 | 2020-12-15T11:05:10 | 319,688,614 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.ArrayList;
import java.util.List;
public class Sala {
private int capacity;
private String id;
private List<Film> films = new ArrayList<>();
public Sala(String id, int capacity, List<Film> films) {
this.id = id;
this.capacity = capacity;
this.films = films;
}
public void addFilm(Film film) {
this.films.add(film);
}
public void removeFilm(Film film) {
this.films.remove(film);
}
public void searchByGenre(String genre) {
System.out.println("Genre: " + genre);
for(Film f: this.films) {
if(f.getGenre() == genre) {
System.out.println(f.getName());
}
}
}
public void printFilms() {
System.out.println(this.id);
for(Film f: this.films) {
System.out.println(f.toString());
}
}
}
| UTF-8 | Java | 754 | java | Sala.java | Java | [] | null | [] |
import java.util.ArrayList;
import java.util.List;
public class Sala {
private int capacity;
private String id;
private List<Film> films = new ArrayList<>();
public Sala(String id, int capacity, List<Film> films) {
this.id = id;
this.capacity = capacity;
this.films = films;
}
public void addFilm(Film film) {
this.films.add(film);
}
public void removeFilm(Film film) {
this.films.remove(film);
}
public void searchByGenre(String genre) {
System.out.println("Genre: " + genre);
for(Film f: this.films) {
if(f.getGenre() == genre) {
System.out.println(f.getName());
}
}
}
public void printFilms() {
System.out.println(this.id);
for(Film f: this.films) {
System.out.println(f.toString());
}
}
}
| 754 | 0.655172 | 0.655172 | 38 | 18.789474 | 15.691361 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.815789 | false | false | 13 |
5f78773368bb244e04fb1f299de0ba62266a94e7 | 26,010,321,994,969 | 8025b4821537c50f316900d3c2c1de7891a30059 | /lb2/src/main/java/com/example/lb2/AppProvider.java | e9e386288bcdcc2e31d55ac7e3a41fefbae0b397 | [] | no_license | m4ccim/ppAnd | https://github.com/m4ccim/ppAnd | 01deacfcb8130befdc89b90a59e021c1f4e3f080 | 8d17abb9fdf64820583e22a06c64fe6f48dc8f61 | refs/heads/master | 2020-12-01T19:17:52.903000 | 2019-12-29T11:23:52 | 2019-12-29T11:23:52 | 230,740,283 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.lb2;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class AppProvider extends ContentProvider {
static final String TABLE_NAME = "notes";
static final String CONTENT_AUTHORITY = "com.example.lb2";
static final Uri CONTENT_AUTHORITY_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd." + CONTENT_AUTHORITY + "." + TABLE_NAME;
static final String CONTENT_ITEM_TYPE= "vnd.android.cursor.item/vnd." + CONTENT_AUTHORITY + "." + TABLE_NAME;
public static class Columns{
public static final String COLUMN_ID = "_id";
private Columns(){
}
}
static final Uri CONTENT_URI = Uri.withAppendedPath(CONTENT_AUTHORITY_URI, TABLE_NAME);
// создает uri с помощью id
static Uri buildNoteUri(long taskId){
return ContentUris.withAppendedId(CONTENT_URI, taskId);
}
// получает id из uri
static long getNoteId(Uri uri){
return ContentUris.parseId(uri);
}
private DatabaseHelper mOpenHelper;
private static final UriMatcher sUriMatcher = buildUriMatcher();
public static final int NOTES = 100;
public static final int NOTES_ID = 101;
private static UriMatcher buildUriMatcher(){
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
// content://com.metanit.tasktimer.provider/NOTES
matcher.addURI(CONTENT_AUTHORITY, TABLE_NAME, NOTES);
// content://com.metanit.tasktimer.provider/NOTES/8
matcher.addURI(CONTENT_AUTHORITY, TABLE_NAME + "/#", NOTES_ID);
return matcher;
}
@Override
public boolean onCreate() {
mOpenHelper = DatabaseHelper.getInstance(getContext());
return true;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
final int match = sUriMatcher.match(uri);
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
switch(match){
case NOTES:
queryBuilder.setTables(TABLE_NAME);
break;
case NOTES_ID:
queryBuilder.setTables(TABLE_NAME);
long taskId = getNoteId(uri);
queryBuilder.appendWhere(Columns.COLUMN_ID + " = " + taskId);
break;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
return queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
final int match = sUriMatcher.match(uri);
switch(match){
case NOTES:
return CONTENT_TYPE;
case NOTES_ID:
return CONTENT_ITEM_TYPE;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db;
Uri returnUri;
long recordId;
switch(match){
case NOTES:
db = mOpenHelper.getWritableDatabase();
recordId = db.insert(TABLE_NAME, null, values);
if(recordId > 0){
returnUri = buildNoteUri(recordId);
}
else{
throw new android.database.SQLException("Failed to insert: " + uri.toString());
}
break;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
return returnUri;
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
String selectionCriteria = selection;
if(match != NOTES && match != NOTES_ID)
throw new IllegalArgumentException("Unknown URI: "+ uri);
if(match== NOTES_ID) {
long taskId = getNoteId(uri);
selectionCriteria = Columns.COLUMN_ID + " = " + taskId;
if ((selection != null) && (selection.length() > 0)) {
selectionCriteria += " AND (" + selection + ")";
}
}
return db.delete(TABLE_NAME, selectionCriteria, selectionArgs);
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
String selectionCriteria = selection;
if(match != NOTES && match != NOTES_ID)
throw new IllegalArgumentException("Unknown URI: "+ uri);
if(match== NOTES_ID) {
long taskId = getNoteId(uri);
selectionCriteria = Columns.COLUMN_ID + " = " + taskId;
if ((selection != null) && (selection.length() > 0)) {
selectionCriteria += " AND (" + selection + ")";
}
}
return db.update(TABLE_NAME, values, selectionCriteria, selectionArgs);
}
} | UTF-8 | Java | 5,855 | java | AppProvider.java | Java | [] | null | [] | package com.example.lb2;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class AppProvider extends ContentProvider {
static final String TABLE_NAME = "notes";
static final String CONTENT_AUTHORITY = "com.example.lb2";
static final Uri CONTENT_AUTHORITY_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd." + CONTENT_AUTHORITY + "." + TABLE_NAME;
static final String CONTENT_ITEM_TYPE= "vnd.android.cursor.item/vnd." + CONTENT_AUTHORITY + "." + TABLE_NAME;
public static class Columns{
public static final String COLUMN_ID = "_id";
private Columns(){
}
}
static final Uri CONTENT_URI = Uri.withAppendedPath(CONTENT_AUTHORITY_URI, TABLE_NAME);
// создает uri с помощью id
static Uri buildNoteUri(long taskId){
return ContentUris.withAppendedId(CONTENT_URI, taskId);
}
// получает id из uri
static long getNoteId(Uri uri){
return ContentUris.parseId(uri);
}
private DatabaseHelper mOpenHelper;
private static final UriMatcher sUriMatcher = buildUriMatcher();
public static final int NOTES = 100;
public static final int NOTES_ID = 101;
private static UriMatcher buildUriMatcher(){
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
// content://com.metanit.tasktimer.provider/NOTES
matcher.addURI(CONTENT_AUTHORITY, TABLE_NAME, NOTES);
// content://com.metanit.tasktimer.provider/NOTES/8
matcher.addURI(CONTENT_AUTHORITY, TABLE_NAME + "/#", NOTES_ID);
return matcher;
}
@Override
public boolean onCreate() {
mOpenHelper = DatabaseHelper.getInstance(getContext());
return true;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
final int match = sUriMatcher.match(uri);
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
switch(match){
case NOTES:
queryBuilder.setTables(TABLE_NAME);
break;
case NOTES_ID:
queryBuilder.setTables(TABLE_NAME);
long taskId = getNoteId(uri);
queryBuilder.appendWhere(Columns.COLUMN_ID + " = " + taskId);
break;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
return queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
final int match = sUriMatcher.match(uri);
switch(match){
case NOTES:
return CONTENT_TYPE;
case NOTES_ID:
return CONTENT_ITEM_TYPE;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db;
Uri returnUri;
long recordId;
switch(match){
case NOTES:
db = mOpenHelper.getWritableDatabase();
recordId = db.insert(TABLE_NAME, null, values);
if(recordId > 0){
returnUri = buildNoteUri(recordId);
}
else{
throw new android.database.SQLException("Failed to insert: " + uri.toString());
}
break;
default:
throw new IllegalArgumentException("Unknown URI: "+ uri);
}
return returnUri;
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
String selectionCriteria = selection;
if(match != NOTES && match != NOTES_ID)
throw new IllegalArgumentException("Unknown URI: "+ uri);
if(match== NOTES_ID) {
long taskId = getNoteId(uri);
selectionCriteria = Columns.COLUMN_ID + " = " + taskId;
if ((selection != null) && (selection.length() > 0)) {
selectionCriteria += " AND (" + selection + ")";
}
}
return db.delete(TABLE_NAME, selectionCriteria, selectionArgs);
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
final int match = sUriMatcher.match(uri);
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
String selectionCriteria = selection;
if(match != NOTES && match != NOTES_ID)
throw new IllegalArgumentException("Unknown URI: "+ uri);
if(match== NOTES_ID) {
long taskId = getNoteId(uri);
selectionCriteria = Columns.COLUMN_ID + " = " + taskId;
if ((selection != null) && (selection.length() > 0)) {
selectionCriteria += " AND (" + selection + ")";
}
}
return db.update(TABLE_NAME, values, selectionCriteria, selectionArgs);
}
} | 5,855 | 0.619897 | 0.617839 | 164 | 34.554878 | 30.203224 | 164 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615854 | false | false | 13 |
47a64c3ea1feb42c1188124a6ffebed758d39a5a | 12,421,045,468,710 | 1a5185ffd52a9741b3808fe9c0f79c74c2eef8a5 | /src/com/wangxin/dang/actions/product/HotProductAction.java | f688724f2e9d745502df032039ba34e0e89546e9 | [] | no_license | dyname/dangdang | https://github.com/dyname/dangdang | 6dc92156ab123ea7148e4b32c93cb704f299e69f | a2b9c98957f9d27cf5806c873e927ffd65ecf75d | refs/heads/master | 2016-09-03T07:09:13.556000 | 2014-04-23T15:17:08 | 2014-04-23T15:17:08 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wangxin.dang.actions.product;
import java.util.List;
import com.wangxin.dang.actions.BaseAction;
import com.wangxin.dang.pojos.Product;
import com.wangxin.dang.services.ProductService;
import com.wangxin.dang.services.impl.ProductServiceImpl;
public class HotProductAction extends BaseAction{
//input
private int hotSize;
//output
private List<Product> productList;
private ProductService service=new ProductServiceImpl();
public String execute(){
try {
productList=service.findHotProduct(hotSize);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "success";
}
public int getHotSize() {
return hotSize;
}
public void setHotSize(int hotSize) {
this.hotSize = hotSize;
}
public List<Product> getProductList() {
return productList;
}
public void setProductList(List<Product> productList) {
this.productList = productList;
}
}
| UTF-8 | Java | 980 | java | HotProductAction.java | Java | [] | null | [] | package com.wangxin.dang.actions.product;
import java.util.List;
import com.wangxin.dang.actions.BaseAction;
import com.wangxin.dang.pojos.Product;
import com.wangxin.dang.services.ProductService;
import com.wangxin.dang.services.impl.ProductServiceImpl;
public class HotProductAction extends BaseAction{
//input
private int hotSize;
//output
private List<Product> productList;
private ProductService service=new ProductServiceImpl();
public String execute(){
try {
productList=service.findHotProduct(hotSize);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "success";
}
public int getHotSize() {
return hotSize;
}
public void setHotSize(int hotSize) {
this.hotSize = hotSize;
}
public List<Product> getProductList() {
return productList;
}
public void setProductList(List<Product> productList) {
this.productList = productList;
}
}
| 980 | 0.710204 | 0.710204 | 47 | 18.851065 | 18.946711 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.297872 | false | false | 13 |
1df1724671abb512334726c74afd894fd7bbb255 | 16,277,926,097,114 | e90eac3efd9ee192cb5832a50a06f57995a819eb | /src/jp/ac/asojuku/asolearning/entity/TestcaseTableEntity.java | adc592c3582f7af86e6b5e9ac35766061d72be96 | [] | no_license | nishino-naoyuki/AsoLearning | https://github.com/nishino-naoyuki/AsoLearning | 66879b9a9e25dff93a71edf2bc3419c899e5908d | e6971e956dcfea2cc31b1becdf38a8e07543f8c4 | refs/heads/master | 2021-01-09T05:47:47.259000 | 2020-06-24T02:18:40 | 2020-06-24T02:18:40 | 80,833,845 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package jp.ac.asojuku.asolearning.entity;
import java.io.Serializable;
/**
* テストケーステーブル モデルクラス.
*
* @author generated by ERMaster
* @version $Id$
*/
public class TestcaseTableEntity implements Serializable {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
/** 課題テーブル. */
private TaskTblEntity taskTbl;
/** テストケースID. */
private Integer testcaseId;
/** 配点. */
private Integer allmostOfMarks;
/** 正解出力ファイル名. */
private String outputFileName;
/** 入力ファイル名. */
private String inputFileName;
/**
* コンストラクタ.
*/
public TestcaseTableEntity() {
}
/**
* 課題テーブル を設定します.
*
* @param taskTbl
* 課題テーブル
*/
public void setTaskTbl(TaskTblEntity taskTbl) {
this.taskTbl = taskTbl;
}
/**
* 課題テーブル を取得します.
*
* @return 課題テーブル
*/
public TaskTblEntity getTaskTbl() {
return this.taskTbl;
}
/**
* テストケースID を設定します.
*
* @param testcaseId
* テストケースID
*/
public void setTestcaseId(Integer testcaseId) {
this.testcaseId = testcaseId;
}
/**
* テストケースID を取得します.
*
* @return テストケースID
*/
public Integer getTestcaseId() {
return this.testcaseId;
}
/**
* 配点 を設定します.
*
* @param allmostOfMarks
* 配点
*/
public void setAllmostOfMarks(Integer allmostOfMarks) {
this.allmostOfMarks = allmostOfMarks;
}
/**
* 配点 を取得します.
*
* @return 配点
*/
public Integer getAllmostOfMarks() {
return this.allmostOfMarks;
}
/**
* 正解出力ファイル名 を設定します.
*
* @param outputFileName
* 正解出力ファイル名
*/
public void setOutputFileName(String outputFileName) {
this.outputFileName = outputFileName;
}
/**
* 正解出力ファイル名 を取得します.
*
* @return 正解出力ファイル名
*/
public String getOutputFileName() {
return this.outputFileName;
}
/**
* 入力ファイル名 を設定します.
*
* @param inputFileName
* 入力ファイル名
*/
public void setInputFileName(String inputFileName) {
this.inputFileName = inputFileName;
}
/**
* 入力ファイル名 を取得します.
*
* @return 入力ファイル名
*/
public String getInputFileName() {
return this.inputFileName;
}
}
| UTF-8 | Java | 2,671 | java | TestcaseTableEntity.java | Java | [
{
"context": "* テストケーステーブル モデルクラス.\r\n * \r\n * @author generated by ERMaster\r\n * @version $Id$\r\n */\r\npublic class TestcaseTabl",
"end": 142,
"score": 0.9984198808670044,
"start": 134,
"tag": "USERNAME",
"value": "ERMaster"
}
] | null | [] | package jp.ac.asojuku.asolearning.entity;
import java.io.Serializable;
/**
* テストケーステーブル モデルクラス.
*
* @author generated by ERMaster
* @version $Id$
*/
public class TestcaseTableEntity implements Serializable {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
/** 課題テーブル. */
private TaskTblEntity taskTbl;
/** テストケースID. */
private Integer testcaseId;
/** 配点. */
private Integer allmostOfMarks;
/** 正解出力ファイル名. */
private String outputFileName;
/** 入力ファイル名. */
private String inputFileName;
/**
* コンストラクタ.
*/
public TestcaseTableEntity() {
}
/**
* 課題テーブル を設定します.
*
* @param taskTbl
* 課題テーブル
*/
public void setTaskTbl(TaskTblEntity taskTbl) {
this.taskTbl = taskTbl;
}
/**
* 課題テーブル を取得します.
*
* @return 課題テーブル
*/
public TaskTblEntity getTaskTbl() {
return this.taskTbl;
}
/**
* テストケースID を設定します.
*
* @param testcaseId
* テストケースID
*/
public void setTestcaseId(Integer testcaseId) {
this.testcaseId = testcaseId;
}
/**
* テストケースID を取得します.
*
* @return テストケースID
*/
public Integer getTestcaseId() {
return this.testcaseId;
}
/**
* 配点 を設定します.
*
* @param allmostOfMarks
* 配点
*/
public void setAllmostOfMarks(Integer allmostOfMarks) {
this.allmostOfMarks = allmostOfMarks;
}
/**
* 配点 を取得します.
*
* @return 配点
*/
public Integer getAllmostOfMarks() {
return this.allmostOfMarks;
}
/**
* 正解出力ファイル名 を設定します.
*
* @param outputFileName
* 正解出力ファイル名
*/
public void setOutputFileName(String outputFileName) {
this.outputFileName = outputFileName;
}
/**
* 正解出力ファイル名 を取得します.
*
* @return 正解出力ファイル名
*/
public String getOutputFileName() {
return this.outputFileName;
}
/**
* 入力ファイル名 を設定します.
*
* @param inputFileName
* 入力ファイル名
*/
public void setInputFileName(String inputFileName) {
this.inputFileName = inputFileName;
}
/**
* 入力ファイル名 を取得します.
*
* @return 入力ファイル名
*/
public String getInputFileName() {
return this.inputFileName;
}
}
| 2,671 | 0.598639 | 0.598186 | 133 | 14.578947 | 14.853272 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.977444 | false | false | 13 |
5916672e098a828a99fac6a744549b83043df219 | 20,813,411,574,708 | 1ac90710711521e1abfb839f1b3febdb27fbb6cd | /app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java | 4e899f11c535c38f3dc4492994ffe85fe11b41e8 | [
"Apache-2.0"
] | permissive | nisanthchunduru/appsmith | https://github.com/nisanthchunduru/appsmith | f1926b62e63c75d1830421b51061a4bd0dea6b9d | 221857aeb56475edc7a3e784a283f83c98d8eeb5 | refs/heads/master | 2023-09-04T07:24:39.491000 | 2023-08-11T15:43:17 | 2023-08-11T15:43:17 | 296,965,395 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.appsmith.server.domains;
import com.appsmith.external.models.BaseDomain;
import com.appsmith.external.views.Views;
import com.appsmith.server.dtos.CustomJSLibApplicationDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.querydsl.core.annotations.QueryEntity;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.appsmith.server.constants.ResourceModes.EDIT;
import static com.appsmith.server.constants.ResourceModes.VIEW;
import static com.appsmith.server.helpers.DateUtils.ISO_FORMATTER;
@Getter
@Setter
@ToString
@NoArgsConstructor
@QueryEntity
@Document
public class Application extends BaseDomain {
@NotNull @JsonView(Views.Public.class)
String name;
// Organizations migrated to workspaces, kept the field as deprecated to support the old migration
@Deprecated
@JsonView(Views.Public.class)
String organizationId;
@JsonView(Views.Public.class)
String workspaceId;
/*
TODO: remove default values from application.
*/
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@Deprecated(forRemoval = true)
@JsonView(Views.Public.class)
Boolean isPublic = false;
@JsonView(Views.Public.class)
List<ApplicationPage> pages;
@JsonView(Views.Internal.class)
List<ApplicationPage> publishedPages;
@JsonView(Views.Internal.class)
@Transient
Boolean viewMode = false;
@Transient
@JsonView(Views.Public.class)
boolean appIsExample = false;
@Transient
@JsonView(Views.Public.class)
long unreadCommentThreads;
@JsonView(Views.Internal.class)
String clonedFromApplicationId;
@JsonView(Views.Internal.class)
ApplicationDetail unpublishedApplicationDetail;
@JsonView(Views.Internal.class)
ApplicationDetail publishedApplicationDetail;
@JsonView(Views.Public.class)
String color;
@JsonView(Views.Public.class)
String icon;
@JsonView(Views.Public.class)
private String slug;
@JsonView(Views.Internal.class)
AppLayout unpublishedAppLayout;
@JsonView(Views.Internal.class)
AppLayout publishedAppLayout;
@JsonView(Views.Public.class)
Set<CustomJSLibApplicationDTO> unpublishedCustomJSLibs;
@JsonView(Views.Public.class)
Set<CustomJSLibApplicationDTO> publishedCustomJSLibs;
@JsonView(Views.Public.class)
GitApplicationMetadata gitApplicationMetadata;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Instant lastDeployedAt; // when this application was last deployed
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Integer evaluationVersion;
/**
* applicationVersion will be used when we've a breaking change in application, and it's not possible to write a
* migration. User need to update the application manually.
* In such cases, we can use this field to determine whether we need to notify user about that breaking change
* so that they can update their application.
* Once updated, we should set applicationVersion to latest version as well.
*/
@JsonView(Views.Public.class)
Integer applicationVersion;
/**
* Changing name, change in pages, widgets and datasources will set lastEditedAt.
* Other activities e.g. changing policy will not change this property.
* We're adding JsonIgnore here because it'll be exposed as modifiedAt to keep it backward compatible
*/
@JsonView(Views.Internal.class)
Instant lastEditedAt;
@JsonView(Views.Public.class)
EmbedSetting embedSetting;
Boolean collapseInvisibleWidgets;
/**
* Earlier this was returning value of the updatedAt property in the base domain.
* As this property is modified by the framework when there is any change in domain,
* a new property lastEditedAt has been added to track the edit actions from users.
* This method exposes that property.
*
* @return updated time as a string
*/
@JsonProperty(value = "modifiedAt", access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
public String getLastUpdateTime() {
if (lastEditedAt != null) {
return ISO_FORMATTER.format(lastEditedAt);
}
return null;
}
@JsonView(Views.Public.class)
public String getLastDeployedAt() {
if (lastDeployedAt != null) {
return ISO_FORMATTER.format(lastDeployedAt);
}
return null;
}
@JsonView(Views.Public.class)
Boolean forkingEnabled;
// Field to convey if the application is updated by the user
@JsonView(Views.Public.class)
Boolean isManualUpdate;
// Field to convey if the application is modified from the DB migration
@Transient
@JsonView(Views.Public.class)
Boolean isAutoUpdate;
// To convey current schema version for client and server. This will be used to check if we run the migration
// between 2 commits if the application is connected to git
@JsonView(Views.Internal.class)
Integer clientSchemaVersion;
@JsonView(Views.Internal.class)
Integer serverSchemaVersion;
@JsonView(Views.Internal.class)
String publishedModeThemeId;
@JsonView(Views.Internal.class)
String editModeThemeId;
// TODO Temporary provision for exporting the application with datasource configuration for the sample/template apps
@JsonView(Views.Public.class)
Boolean exportWithConfiguration;
// forkWithConfiguration represents whether credentials are shared or not while forking an app
@JsonView(Views.Public.class)
Boolean forkWithConfiguration;
@JsonView(Views.Internal.class)
@Deprecated
String defaultPermissionGroup;
// This constructor is used during clone application. It only deeply copies selected fields. The rest are either
// initialized newly or is left up to the calling function to set.
public Application(Application application) {
super();
this.workspaceId = application.getWorkspaceId();
this.pages = new ArrayList<>();
this.publishedPages = new ArrayList<>();
this.clonedFromApplicationId = application.getId();
this.color = application.getColor();
this.icon = application.getIcon();
this.unpublishedAppLayout = application.getUnpublishedAppLayout() == null
? null
: new AppLayout(application.getUnpublishedAppLayout().type);
this.publishedAppLayout = application.getPublishedAppLayout() == null
? null
: new AppLayout(application.getPublishedAppLayout().type);
this.setUnpublishedApplicationDetail(new ApplicationDetail());
this.setPublishedApplicationDetail(new ApplicationDetail());
if (application.getUnpublishedApplicationDetail() == null) {
application.setUnpublishedApplicationDetail(new ApplicationDetail());
}
if (application.getPublishedApplicationDetail() == null) {
application.setPublishedApplicationDetail(new ApplicationDetail());
}
AppPositioning unpublishedAppPositioning =
application.getUnpublishedApplicationDetail().getAppPositioning() == null
? null
: new AppPositioning(
application.getUnpublishedApplicationDetail().getAppPositioning().type);
this.getUnpublishedApplicationDetail().setAppPositioning(unpublishedAppPositioning);
AppPositioning publishedAppPositioning =
application.getPublishedApplicationDetail().getAppPositioning() == null
? null
: new AppPositioning(
application.getPublishedApplicationDetail().getAppPositioning().type);
this.getPublishedApplicationDetail().setAppPositioning(publishedAppPositioning);
this.getUnpublishedApplicationDetail()
.setNavigationSetting(
application.getUnpublishedApplicationDetail().getNavigationSetting() == null
? null
: new NavigationSetting());
this.getPublishedApplicationDetail()
.setNavigationSetting(
application.getPublishedApplicationDetail().getNavigationSetting() == null
? null
: new NavigationSetting());
this.unpublishedCustomJSLibs = application.getUnpublishedCustomJSLibs();
this.collapseInvisibleWidgets = application.getCollapseInvisibleWidgets();
}
public void exportApplicationPages(final Map<String, String> pageIdToNameMap) {
for (ApplicationPage applicationPage : this.getPages()) {
applicationPage.setId(pageIdToNameMap.get(applicationPage.getId() + EDIT));
applicationPage.setDefaultPageId(null);
}
for (ApplicationPage applicationPage : this.getPublishedPages()) {
applicationPage.setId(pageIdToNameMap.get(applicationPage.getId() + VIEW));
applicationPage.setDefaultPageId(null);
}
}
@Override
public void sanitiseToExportDBObject() {
this.setWorkspaceId(null);
this.setOrganizationId(null);
this.setModifiedBy(null);
this.setCreatedBy(null);
this.setLastDeployedAt(null);
this.setLastEditedAt(null);
this.setGitApplicationMetadata(null);
this.setEditModeThemeId(null);
this.setPublishedModeThemeId(null);
this.setClientSchemaVersion(null);
this.setServerSchemaVersion(null);
this.setIsManualUpdate(false);
this.setDefaultPermissionGroup(null);
this.setPublishedCustomJSLibs(new HashSet<>());
this.setExportWithConfiguration(null);
this.setForkWithConfiguration(null);
this.setForkingEnabled(null);
super.sanitiseToExportDBObject();
}
public List<ApplicationPage> getPages() {
return Boolean.TRUE.equals(viewMode) ? publishedPages : pages;
}
public AppLayout getAppLayout() {
return Boolean.TRUE.equals(viewMode) ? publishedAppLayout : unpublishedAppLayout;
}
public void setAppLayout(AppLayout appLayout) {
if (Boolean.TRUE.equals(viewMode)) {
publishedAppLayout = appLayout;
} else {
unpublishedAppLayout = appLayout;
}
}
public ApplicationDetail getApplicationDetail() {
return Boolean.TRUE.equals(viewMode) ? publishedApplicationDetail : unpublishedApplicationDetail;
}
public void setApplicationDetail(ApplicationDetail applicationDetail) {
if (Boolean.TRUE.equals(viewMode)) {
publishedApplicationDetail = applicationDetail;
} else {
unpublishedApplicationDetail = applicationDetail;
}
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class AppLayout implements Serializable {
@JsonView(Views.Public.class)
Type type;
/**
* @deprecated The following field is deprecated and now removed, because it's needed in a migration. After the
* migration has been run, it may be removed (along with the migration or there'll be compile errors there).
*/
@JsonView(Views.Internal.class)
@Deprecated(forRemoval = true)
Integer width = null;
public AppLayout(Type type) {
this.type = type;
}
public enum Type {
DESKTOP,
TABLET_LARGE,
TABLET,
MOBILE,
FLUID,
}
}
/**
* EmbedSetting is used for embedding Appsmith apps on other platforms
*/
@Data
public static class EmbedSetting {
@JsonView(Views.Public.class)
private String height;
@JsonView(Views.Public.class)
private String width;
@JsonView(Views.Public.class)
private Boolean showNavigationBar;
}
/**
* NavigationSetting stores the navigation configuration for the app
*/
@Data
public static class NavigationSetting {
@JsonView(Views.Public.class)
private Boolean showNavbar;
@JsonView(Views.Public.class)
private String orientation;
@JsonView(Views.Public.class)
private String navStyle;
@JsonView(Views.Public.class)
private String position;
@JsonView(Views.Public.class)
private String itemStyle;
@JsonView(Views.Public.class)
private String colorStyle;
@JsonView(Views.Public.class)
private String logoAssetId;
@JsonView(Views.Public.class)
private String logoConfiguration;
@JsonView(Views.Public.class)
private Boolean showSignIn;
}
/**
* AppPositioning captures widget positioning Mode of the application
*/
@Data
@NoArgsConstructor
public static class AppPositioning {
@JsonView(Views.Public.class)
Type type;
public AppPositioning(Type type) {
this.type = type;
}
public enum Type {
FIXED,
AUTO
}
}
}
| UTF-8 | Java | 13,794 | java | Application.java | Java | [] | null | [] | package com.appsmith.server.domains;
import com.appsmith.external.models.BaseDomain;
import com.appsmith.external.views.Views;
import com.appsmith.server.dtos.CustomJSLibApplicationDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.querydsl.core.annotations.QueryEntity;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.appsmith.server.constants.ResourceModes.EDIT;
import static com.appsmith.server.constants.ResourceModes.VIEW;
import static com.appsmith.server.helpers.DateUtils.ISO_FORMATTER;
@Getter
@Setter
@ToString
@NoArgsConstructor
@QueryEntity
@Document
public class Application extends BaseDomain {
@NotNull @JsonView(Views.Public.class)
String name;
// Organizations migrated to workspaces, kept the field as deprecated to support the old migration
@Deprecated
@JsonView(Views.Public.class)
String organizationId;
@JsonView(Views.Public.class)
String workspaceId;
/*
TODO: remove default values from application.
*/
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@Deprecated(forRemoval = true)
@JsonView(Views.Public.class)
Boolean isPublic = false;
@JsonView(Views.Public.class)
List<ApplicationPage> pages;
@JsonView(Views.Internal.class)
List<ApplicationPage> publishedPages;
@JsonView(Views.Internal.class)
@Transient
Boolean viewMode = false;
@Transient
@JsonView(Views.Public.class)
boolean appIsExample = false;
@Transient
@JsonView(Views.Public.class)
long unreadCommentThreads;
@JsonView(Views.Internal.class)
String clonedFromApplicationId;
@JsonView(Views.Internal.class)
ApplicationDetail unpublishedApplicationDetail;
@JsonView(Views.Internal.class)
ApplicationDetail publishedApplicationDetail;
@JsonView(Views.Public.class)
String color;
@JsonView(Views.Public.class)
String icon;
@JsonView(Views.Public.class)
private String slug;
@JsonView(Views.Internal.class)
AppLayout unpublishedAppLayout;
@JsonView(Views.Internal.class)
AppLayout publishedAppLayout;
@JsonView(Views.Public.class)
Set<CustomJSLibApplicationDTO> unpublishedCustomJSLibs;
@JsonView(Views.Public.class)
Set<CustomJSLibApplicationDTO> publishedCustomJSLibs;
@JsonView(Views.Public.class)
GitApplicationMetadata gitApplicationMetadata;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Instant lastDeployedAt; // when this application was last deployed
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
Integer evaluationVersion;
/**
* applicationVersion will be used when we've a breaking change in application, and it's not possible to write a
* migration. User need to update the application manually.
* In such cases, we can use this field to determine whether we need to notify user about that breaking change
* so that they can update their application.
* Once updated, we should set applicationVersion to latest version as well.
*/
@JsonView(Views.Public.class)
Integer applicationVersion;
/**
* Changing name, change in pages, widgets and datasources will set lastEditedAt.
* Other activities e.g. changing policy will not change this property.
* We're adding JsonIgnore here because it'll be exposed as modifiedAt to keep it backward compatible
*/
@JsonView(Views.Internal.class)
Instant lastEditedAt;
@JsonView(Views.Public.class)
EmbedSetting embedSetting;
Boolean collapseInvisibleWidgets;
/**
* Earlier this was returning value of the updatedAt property in the base domain.
* As this property is modified by the framework when there is any change in domain,
* a new property lastEditedAt has been added to track the edit actions from users.
* This method exposes that property.
*
* @return updated time as a string
*/
@JsonProperty(value = "modifiedAt", access = JsonProperty.Access.READ_ONLY)
@JsonView(Views.Public.class)
public String getLastUpdateTime() {
if (lastEditedAt != null) {
return ISO_FORMATTER.format(lastEditedAt);
}
return null;
}
@JsonView(Views.Public.class)
public String getLastDeployedAt() {
if (lastDeployedAt != null) {
return ISO_FORMATTER.format(lastDeployedAt);
}
return null;
}
@JsonView(Views.Public.class)
Boolean forkingEnabled;
// Field to convey if the application is updated by the user
@JsonView(Views.Public.class)
Boolean isManualUpdate;
// Field to convey if the application is modified from the DB migration
@Transient
@JsonView(Views.Public.class)
Boolean isAutoUpdate;
// To convey current schema version for client and server. This will be used to check if we run the migration
// between 2 commits if the application is connected to git
@JsonView(Views.Internal.class)
Integer clientSchemaVersion;
@JsonView(Views.Internal.class)
Integer serverSchemaVersion;
@JsonView(Views.Internal.class)
String publishedModeThemeId;
@JsonView(Views.Internal.class)
String editModeThemeId;
// TODO Temporary provision for exporting the application with datasource configuration for the sample/template apps
@JsonView(Views.Public.class)
Boolean exportWithConfiguration;
// forkWithConfiguration represents whether credentials are shared or not while forking an app
@JsonView(Views.Public.class)
Boolean forkWithConfiguration;
@JsonView(Views.Internal.class)
@Deprecated
String defaultPermissionGroup;
// This constructor is used during clone application. It only deeply copies selected fields. The rest are either
// initialized newly or is left up to the calling function to set.
public Application(Application application) {
super();
this.workspaceId = application.getWorkspaceId();
this.pages = new ArrayList<>();
this.publishedPages = new ArrayList<>();
this.clonedFromApplicationId = application.getId();
this.color = application.getColor();
this.icon = application.getIcon();
this.unpublishedAppLayout = application.getUnpublishedAppLayout() == null
? null
: new AppLayout(application.getUnpublishedAppLayout().type);
this.publishedAppLayout = application.getPublishedAppLayout() == null
? null
: new AppLayout(application.getPublishedAppLayout().type);
this.setUnpublishedApplicationDetail(new ApplicationDetail());
this.setPublishedApplicationDetail(new ApplicationDetail());
if (application.getUnpublishedApplicationDetail() == null) {
application.setUnpublishedApplicationDetail(new ApplicationDetail());
}
if (application.getPublishedApplicationDetail() == null) {
application.setPublishedApplicationDetail(new ApplicationDetail());
}
AppPositioning unpublishedAppPositioning =
application.getUnpublishedApplicationDetail().getAppPositioning() == null
? null
: new AppPositioning(
application.getUnpublishedApplicationDetail().getAppPositioning().type);
this.getUnpublishedApplicationDetail().setAppPositioning(unpublishedAppPositioning);
AppPositioning publishedAppPositioning =
application.getPublishedApplicationDetail().getAppPositioning() == null
? null
: new AppPositioning(
application.getPublishedApplicationDetail().getAppPositioning().type);
this.getPublishedApplicationDetail().setAppPositioning(publishedAppPositioning);
this.getUnpublishedApplicationDetail()
.setNavigationSetting(
application.getUnpublishedApplicationDetail().getNavigationSetting() == null
? null
: new NavigationSetting());
this.getPublishedApplicationDetail()
.setNavigationSetting(
application.getPublishedApplicationDetail().getNavigationSetting() == null
? null
: new NavigationSetting());
this.unpublishedCustomJSLibs = application.getUnpublishedCustomJSLibs();
this.collapseInvisibleWidgets = application.getCollapseInvisibleWidgets();
}
public void exportApplicationPages(final Map<String, String> pageIdToNameMap) {
for (ApplicationPage applicationPage : this.getPages()) {
applicationPage.setId(pageIdToNameMap.get(applicationPage.getId() + EDIT));
applicationPage.setDefaultPageId(null);
}
for (ApplicationPage applicationPage : this.getPublishedPages()) {
applicationPage.setId(pageIdToNameMap.get(applicationPage.getId() + VIEW));
applicationPage.setDefaultPageId(null);
}
}
@Override
public void sanitiseToExportDBObject() {
this.setWorkspaceId(null);
this.setOrganizationId(null);
this.setModifiedBy(null);
this.setCreatedBy(null);
this.setLastDeployedAt(null);
this.setLastEditedAt(null);
this.setGitApplicationMetadata(null);
this.setEditModeThemeId(null);
this.setPublishedModeThemeId(null);
this.setClientSchemaVersion(null);
this.setServerSchemaVersion(null);
this.setIsManualUpdate(false);
this.setDefaultPermissionGroup(null);
this.setPublishedCustomJSLibs(new HashSet<>());
this.setExportWithConfiguration(null);
this.setForkWithConfiguration(null);
this.setForkingEnabled(null);
super.sanitiseToExportDBObject();
}
public List<ApplicationPage> getPages() {
return Boolean.TRUE.equals(viewMode) ? publishedPages : pages;
}
public AppLayout getAppLayout() {
return Boolean.TRUE.equals(viewMode) ? publishedAppLayout : unpublishedAppLayout;
}
public void setAppLayout(AppLayout appLayout) {
if (Boolean.TRUE.equals(viewMode)) {
publishedAppLayout = appLayout;
} else {
unpublishedAppLayout = appLayout;
}
}
public ApplicationDetail getApplicationDetail() {
return Boolean.TRUE.equals(viewMode) ? publishedApplicationDetail : unpublishedApplicationDetail;
}
public void setApplicationDetail(ApplicationDetail applicationDetail) {
if (Boolean.TRUE.equals(viewMode)) {
publishedApplicationDetail = applicationDetail;
} else {
unpublishedApplicationDetail = applicationDetail;
}
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class AppLayout implements Serializable {
@JsonView(Views.Public.class)
Type type;
/**
* @deprecated The following field is deprecated and now removed, because it's needed in a migration. After the
* migration has been run, it may be removed (along with the migration or there'll be compile errors there).
*/
@JsonView(Views.Internal.class)
@Deprecated(forRemoval = true)
Integer width = null;
public AppLayout(Type type) {
this.type = type;
}
public enum Type {
DESKTOP,
TABLET_LARGE,
TABLET,
MOBILE,
FLUID,
}
}
/**
* EmbedSetting is used for embedding Appsmith apps on other platforms
*/
@Data
public static class EmbedSetting {
@JsonView(Views.Public.class)
private String height;
@JsonView(Views.Public.class)
private String width;
@JsonView(Views.Public.class)
private Boolean showNavigationBar;
}
/**
* NavigationSetting stores the navigation configuration for the app
*/
@Data
public static class NavigationSetting {
@JsonView(Views.Public.class)
private Boolean showNavbar;
@JsonView(Views.Public.class)
private String orientation;
@JsonView(Views.Public.class)
private String navStyle;
@JsonView(Views.Public.class)
private String position;
@JsonView(Views.Public.class)
private String itemStyle;
@JsonView(Views.Public.class)
private String colorStyle;
@JsonView(Views.Public.class)
private String logoAssetId;
@JsonView(Views.Public.class)
private String logoConfiguration;
@JsonView(Views.Public.class)
private Boolean showSignIn;
}
/**
* AppPositioning captures widget positioning Mode of the application
*/
@Data
@NoArgsConstructor
public static class AppPositioning {
@JsonView(Views.Public.class)
Type type;
public AppPositioning(Type type) {
this.type = type;
}
public enum Type {
FIXED,
AUTO
}
}
}
| 13,794 | 0.682181 | 0.682108 | 409 | 32.726162 | 27.581013 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.366748 | false | false | 13 |
ffa146d866b2bd7a532eb9acd917535b03810988 | 15,719,580,360,126 | 9da7db5620474e5caf15dc8dcf81180722fd9b43 | /src/org/kyupi/misc/Pool.java | d3fa7b77571eebd8f470bf6f3c9b241aab6b9305 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | s-holst/kyupi | https://github.com/s-holst/kyupi | 2ab8f08c871badb01330bfd83b8b87b89b4f584b | bb74ac95d026c373ba110901875ab6f9cf9e5597 | refs/heads/master | 2021-01-13T17:27:43.513000 | 2018-11-24T02:02:38 | 2018-11-24T02:02:38 | 11,678,192 | 3 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2013 The KyuPI project contributors. See the COPYRIGHT.md file
* at the top-level directory of this distribution.
* This file is part of the KyuPI project. It is subject to the license terms
* in the LICENSE.md file found in the top-level directory of this distribution.
* No part of the KyuPI project, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE.md file.
*/
package org.kyupi.misc;
import java.util.LinkedList;
/**
* provides a way to re-use objects to reduce object creation and GC overheads.
*
* This class is used in the following way. Let Producer be a class, which wants
* to give give out re-usable objects of the class Value.
*
* The class Producer constructs a pool:
*
* <pre>
* Pool<Value> pool = new Pool<Value>() {
* public Value produce() {
* Value v = new Value(...);
* v.setPool(pool);
* return v;
* }
* };
* </pre>
*
* It then allocates objects by calling pool.alloc(). The pool will either
* return a previously freed object or calls produce implemented above.
*
* The class Value implements two methods:
*
* <pre>
* private Pool<Value> pool;
*
* public void setPool(Pool<Value> pool) {
* this.pool = pool;
* }
*
* public void free() {
* if (pool != null)
* pool.free(this);
* }
* </pre>
*
* The receiver of a Value instance returned by a method of Producer can call
* free as soon as the return value is not used anymore. This causes the object
* to be added to a pool, if one is available. If no pool is defined, free
* behaves transparently and normal garbage collection will kick in if
* necessary.
*
* @param <P>
*/
public abstract class Pool<P> {
LinkedList<P> pool = new LinkedList<P>();
public P alloc() {
if (pool.isEmpty())
return produce();
return pool.pop();
}
public void free(P pooled_object) {
pool.push(pooled_object);
}
public abstract P produce();
}
| UTF-8 | Java | 2,006 | java | Pool.java | Java | [] | null | [] | /*
* Copyright 2013 The KyuPI project contributors. See the COPYRIGHT.md file
* at the top-level directory of this distribution.
* This file is part of the KyuPI project. It is subject to the license terms
* in the LICENSE.md file found in the top-level directory of this distribution.
* No part of the KyuPI project, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE.md file.
*/
package org.kyupi.misc;
import java.util.LinkedList;
/**
* provides a way to re-use objects to reduce object creation and GC overheads.
*
* This class is used in the following way. Let Producer be a class, which wants
* to give give out re-usable objects of the class Value.
*
* The class Producer constructs a pool:
*
* <pre>
* Pool<Value> pool = new Pool<Value>() {
* public Value produce() {
* Value v = new Value(...);
* v.setPool(pool);
* return v;
* }
* };
* </pre>
*
* It then allocates objects by calling pool.alloc(). The pool will either
* return a previously freed object or calls produce implemented above.
*
* The class Value implements two methods:
*
* <pre>
* private Pool<Value> pool;
*
* public void setPool(Pool<Value> pool) {
* this.pool = pool;
* }
*
* public void free() {
* if (pool != null)
* pool.free(this);
* }
* </pre>
*
* The receiver of a Value instance returned by a method of Producer can call
* free as soon as the return value is not used anymore. This causes the object
* to be added to a pool, if one is available. If no pool is defined, free
* behaves transparently and normal garbage collection will kick in if
* necessary.
*
* @param <P>
*/
public abstract class Pool<P> {
LinkedList<P> pool = new LinkedList<P>();
public P alloc() {
if (pool.isEmpty())
return produce();
return pool.pop();
}
public void free(P pooled_object) {
pool.push(pooled_object);
}
public abstract P produce();
}
| 2,006 | 0.681954 | 0.67996 | 73 | 26.479452 | 27.121296 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.780822 | false | false | 13 |
20ef35eff2ce7460e89dd7cfc847ee9f3022bc9a | 22,170,621,235,649 | 54d878804ddc3c2178809aa0b6f55616e18d273d | /wx-public-platform/src/main/java/com/wx/platform/handle/event/GroupQrCodeEventHandle.java | b3e9e5a65c6e60ecc213731b9656603510105a16 | [] | no_license | Ken-Su/wechart | https://github.com/Ken-Su/wechart | b52d4f069a762097bf9ca012b56e60965d86c904 | 4ded268c2dbff5eea5a19ac0435c38c0a59dd9f8 | refs/heads/master | 2021-01-10T16:44:51.992000 | 2016-05-06T06:10:04 | 2016-05-06T06:10:04 | 44,937,611 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wx.platform.handle.event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.wx.platform.handle.EventHandle;
import com.wx.platform.handle.msg.ChatMessageHandle;
import com.wx.platform.message.BaseMsg;
import com.wx.platform.message.req.QrCodeEvent;
@Component
public class GroupQrCodeEventHandle implements EventHandle<QrCodeEvent> {
private static final Logger logger = LoggerFactory.getLogger(ChatMessageHandle.class);
@Override
public BaseMsg handle(QrCodeEvent event) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean beforeHandle(QrCodeEvent event) {
// logger.info(event.getEvent());
// logger.info(event.getEventKey());
// logger.info(event.getMsgType());
// logger.info(event.getTicket());
return false;
}
}
| UTF-8 | Java | 846 | java | GroupQrCodeEventHandle.java | Java | [] | null | [] | package com.wx.platform.handle.event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.wx.platform.handle.EventHandle;
import com.wx.platform.handle.msg.ChatMessageHandle;
import com.wx.platform.message.BaseMsg;
import com.wx.platform.message.req.QrCodeEvent;
@Component
public class GroupQrCodeEventHandle implements EventHandle<QrCodeEvent> {
private static final Logger logger = LoggerFactory.getLogger(ChatMessageHandle.class);
@Override
public BaseMsg handle(QrCodeEvent event) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean beforeHandle(QrCodeEvent event) {
// logger.info(event.getEvent());
// logger.info(event.getEventKey());
// logger.info(event.getMsgType());
// logger.info(event.getTicket());
return false;
}
}
| 846 | 0.781324 | 0.77896 | 32 | 25.4375 | 22.995838 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.125 | false | false | 13 |
5f853964b105d0c66baf968b6af9209f18a26db2 | 13,374,528,178,497 | e4015bb1a57841030ed2db5ca6512db0d04bfe58 | /app/src/main/java/com/example/rsj/DJIStationView/HttpUtils.java | 5410bd5a6c36fa583d20d2cec8a6bf25b98bee18 | [] | no_license | ZenZenDaMie/DJIStationView | https://github.com/ZenZenDaMie/DJIStationView | 2fd3512a89b962b61882f0c049ebfa4c1be0d4da | 35ba7e60dbdbbadd242a98901ca7ac5e8e1cb951 | refs/heads/master | 2020-03-22T01:34:38.679000 | 2018-07-06T08:09:02 | 2018-07-06T08:09:02 | 139,314,718 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.rsj.DJIStationView;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import okhttp3.Call;
/**
* Created by rsj on 2018/1/7.
*/
public class HttpUtils {
public static String url = "http://139.196.138.204/tp5/public/user/login"; //不可少,是你的请求地址
public static MiMiLoginListener miLoginListener; //登录
public interface MiMiLoginListener{
public void onLoginResult(int ret,Object msg);
}
public void onLoginResult(int ret,Object msg){
if(miLoginListener != null ){
miLoginListener.onLoginResult(ret,msg);
}
miLoginListener = null;
}
public static void postLogin(String phone_num,String passWord,final MiMiLoginListener listener){
miLoginListener = listener;
url=url+phone_num+"&password="+passWord;
OkHttpUtils
.get()
.url(url)
.addParams("name", phone_num)
.addParams("password",passWord)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
// Toast.makeText(LoginActivity.this,"连接错误,请查看网络连接", Toast.LENGTH_SHORT).show();
// ToastUtil.show("连接错误,请查看网络连接");
}
@Override
public void onResponse(String _response) {
listener.onLoginResult(1,_response);
}
});
}
} | UTF-8 | Java | 1,667 | java | HttpUtils.java | Java | [
{
"context": "gCallback;\nimport okhttp3.Call;\n\n/**\n * Created by rsj on 2018/1/7.\n */\n\npublic class HttpUtils {\n pu",
"end": 176,
"score": 0.9991136789321899,
"start": 173,
"tag": "USERNAME",
"value": "rsj"
},
{
"context": "ls {\n public static String url = \"http://139... | null | [] | package com.example.rsj.DJIStationView;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import okhttp3.Call;
/**
* Created by rsj on 2018/1/7.
*/
public class HttpUtils {
public static String url = "http://139.196.138.204/tp5/public/user/login"; //不可少,是你的请求地址
public static MiMiLoginListener miLoginListener; //登录
public interface MiMiLoginListener{
public void onLoginResult(int ret,Object msg);
}
public void onLoginResult(int ret,Object msg){
if(miLoginListener != null ){
miLoginListener.onLoginResult(ret,msg);
}
miLoginListener = null;
}
public static void postLogin(String phone_num,String passWord,final MiMiLoginListener listener){
miLoginListener = listener;
url=url+phone_num+"&password="+passWord;
OkHttpUtils
.get()
.url(url)
.addParams("name", phone_num)
.addParams("password",<PASSWORD>)
.build()
.execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
// Toast.makeText(LoginActivity.this,"连接错误,请查看网络连接", Toast.LENGTH_SHORT).show();
// ToastUtil.show("连接错误,请查看网络连接");
}
@Override
public void onResponse(String _response) {
listener.onLoginResult(1,_response);
}
});
}
} | 1,669 | 0.55995 | 0.546767 | 49 | 31.530613 | 27.078949 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.530612 | false | false | 13 |
97da000ac91cd84e3c036ed1622559e7d5eab246 | 19,052,474,943,510 | 9107c5b185dce76903e53153788868a630806759 | /Ex08_CustormList/src/Ex08_CustormList/org/Ex08_CustormListActivity.java | 58464df4e5027e8a0ae733fd7be44a38fa9bcec6 | [] | no_license | AirFit/android-examples | https://github.com/AirFit/android-examples | 9de82d778d8b3f88d9f4742bf49a1ec61a470ba5 | 1a402c42772333f2a612428cdf67d64141954f47 | refs/heads/master | 2021-01-17T17:12:18.751000 | 2014-10-30T04:38:43 | 2014-10-30T04:38:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Ex08_CustormList.org;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
public class Ex08_CustormListActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<MyItem> arrayItems = new ArrayList<MyItem>();
arrayItems.add(new MyItem(R.drawable.icon, "item4", "item22"));
arrayItems.add(new MyItem(R.drawable.icon, "item5", "item33"));
CustomAdater adapter = new CustomAdater(this, R.layout.itemlayout,
arrayItems);
ListView list = (ListView) this.findViewById(R.id.listview);
list.setAdapter(adapter);
}
} | UTF-8 | Java | 764 | java | Ex08_CustormListActivity.java | Java | [] | null | [] | package Ex08_CustormList.org;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
public class Ex08_CustormListActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<MyItem> arrayItems = new ArrayList<MyItem>();
arrayItems.add(new MyItem(R.drawable.icon, "item4", "item22"));
arrayItems.add(new MyItem(R.drawable.icon, "item5", "item33"));
CustomAdater adapter = new CustomAdater(this, R.layout.itemlayout,
arrayItems);
ListView list = (ListView) this.findViewById(R.id.listview);
list.setAdapter(adapter);
}
} | 764 | 0.756545 | 0.743455 | 27 | 27.333334 | 24.001543 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.592593 | false | false | 13 |
78d504f9a6c4663f5582dc563f07b75cebcea544 | 15,212,774,211,970 | 5ea625683fb2c1a4a9dd63d16885fdf18f8891e8 | /java_project/FirstJava/src/myproject/myProjectArrayTest/Student.java | bf185834e3c00493098a9e379b17790e86363bce | [] | no_license | KimYongMin2/MyBitcampjava205 | https://github.com/KimYongMin2/MyBitcampjava205 | e54824f3b03ba19cfe8a1cdbcd3527a9855d5938 | 0cdf2dd080d23f77f7579f796b53bb9687d40a69 | refs/heads/main | 2023-06-18T13:33:42.345000 | 2021-07-20T04:00:44 | 2021-07-20T04:00:44 | 370,247,323 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package myproject.myProjectArrayTest;
public class Student {
// 2. Student 클래스를 정의해봅시다.
// ① 학생이름, 국어점수, 영어점수, 수학점수를 저장하는 변수를 정의 합니다.
private String name;
private int kor;
private int eng;
private int math;
public Student(String name, int kor, int eng, int math) {
this.name = name;
this.kor = kor;
this.eng = eng;
this.math = math;
}
public Student() {
this("이름없음",0,0,0);
}
// ② 변수는 캡슐화를 합니다. getter/setter 메소드를 정의합니다.
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKor() {
return kor;
}
public void setKor(int kor) {
this.kor = kor;
}
public int getEng() {
return eng;
}
public void setEng(int eng) {
this.eng = eng;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
// ③ 총점과 평균을 구해 결과를 반환하는 메소드를 정의합니다.
int getSum() {
return this.kor + this.eng + this.math;
}
float getAvg() {
return getSum() / 3f;
}
} | UTF-8 | Java | 1,348 | java | Student.java | Java | [] | null | [] | package myproject.myProjectArrayTest;
public class Student {
// 2. Student 클래스를 정의해봅시다.
// ① 학생이름, 국어점수, 영어점수, 수학점수를 저장하는 변수를 정의 합니다.
private String name;
private int kor;
private int eng;
private int math;
public Student(String name, int kor, int eng, int math) {
this.name = name;
this.kor = kor;
this.eng = eng;
this.math = math;
}
public Student() {
this("이름없음",0,0,0);
}
// ② 변수는 캡슐화를 합니다. getter/setter 메소드를 정의합니다.
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKor() {
return kor;
}
public void setKor(int kor) {
this.kor = kor;
}
public int getEng() {
return eng;
}
public void setEng(int eng) {
this.eng = eng;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
// ③ 총점과 평균을 구해 결과를 반환하는 메소드를 정의합니다.
int getSum() {
return this.kor + this.eng + this.math;
}
float getAvg() {
return getSum() / 3f;
}
} | 1,348 | 0.536752 | 0.529915 | 65 | 17.015385 | 14.905334 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.507692 | false | false | 13 |
3fdb6de453401db45ce4839efda918a0c2044f09 | 27,221,502,788,459 | e7d6d56395d6ae2ecbca2779a0be99d062b4da26 | /src/main/java/sgo/datos/CompartimentoDao.java | 5b1e102b3238e68ea2a40979093a562cf9a94619 | [] | no_license | jesusmatosp/sgo-vp | https://github.com/jesusmatosp/sgo-vp | fbfa85d63905a8d60ed95a444a1ed4f9c89146e5 | 5266116b1535fc7adee6d0848029ed2b7e1ebe0d | refs/heads/master | 2020-04-25T06:47:21.957000 | 2019-06-05T20:26:27 | 2019-06-05T20:26:27 | 172,592,664 | 1 | 0 | null | false | 2020-10-13T12:07:09 | 2019-02-25T22:05:29 | 2019-06-05T20:27:32 | 2020-10-13T12:07:08 | 30,596 | 1 | 0 | 4 | Java | false | false | package sgo.datos;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import sgo.entidad.Compartimento;
import sgo.entidad.Contenido;
import sgo.entidad.ParametrosListar;
import sgo.entidad.RespuestaCompuesta;
import sgo.utilidades.Constante;
@Repository
public class CompartimentoDao {
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedJdbcTemplate;
public static final String NOMBRE_TABLA = Constante.ESQUEMA_APLICACION + "compartimento";
public static final String NOMBRE_VISTA = Constante.ESQUEMA_APLICACION + "v_compartimento";
public final static String NOMBRE_CAMPO_CLAVE = "id_compartimento";
public final static String CAMPO_NUMERO_COMPARTIMENTO="identificador";
public final static String NOMBRE_CAMPO_NUMERO_COMPARTIMENTO="identificador";
public final static String CAMPO_ALTURA_FLECHA="altura_flecha";
public final static String NOMBRE_CAMPO_ALTURA_FLECHA="alturaFlecha";
public final static String CAMPO_CISTERNA="id_cisterna";
public final static String NOMBRE_CAMPO_CISTERNA="idCisterna";
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}
public DataSource getDataSource(){
return this.jdbcTemplate.getDataSource();
}
public String mapearCampoOrdenamiento(String propiedad){
String campoOrdenamiento="";
try {
if (propiedad.equals("id")){
campoOrdenamiento="id_compartimento";
}
if (propiedad.equals(NOMBRE_CAMPO_NUMERO_COMPARTIMENTO)){
campoOrdenamiento=CAMPO_NUMERO_COMPARTIMENTO;
}
if (propiedad.equals("capacidadVolumetrica")){
campoOrdenamiento="capacidad_volumetrica";
}
if (propiedad.equals(NOMBRE_CAMPO_ALTURA_FLECHA)){
campoOrdenamiento=CAMPO_ALTURA_FLECHA;
}
if (propiedad.equals(NOMBRE_CAMPO_CISTERNA)){
campoOrdenamiento=CAMPO_CISTERNA;
}
//Campos de auditoria
}catch(Exception excepcion){
}
return campoOrdenamiento;
}
public RespuestaCompuesta recuperarRegistros(ParametrosListar argumentosListar) {
String sqlLimit = "";
int totalRegistros = 0, totalEncontrados = 0;
RespuestaCompuesta respuesta = new RespuestaCompuesta();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
List<Compartimento> listaRegistros = new ArrayList<Compartimento>();
List<Object> parametros = new ArrayList<Object>();
List<String> filtrosWhere = new ArrayList<String>();
String sqlWhere = "";
String sqlOrderBy="";
try {
if (argumentosListar.getPaginacion() == Constante.CON_PAGINACION) {
sqlLimit = Constante.SQL_LIMIT_CONFIGURADO;
parametros.add(argumentosListar.getInicioPaginacion());
parametros.add(argumentosListar.getRegistrosxPagina());
}
if (argumentosListar.getFiltroCisterna()>0) {
filtrosWhere.add(" t1." + CAMPO_CISTERNA + "=" + argumentosListar.getFiltroCisterna());
}
if (!filtrosWhere.isEmpty()) {
sqlWhere = " WHERE " + StringUtils.join(filtrosWhere,Constante.SQL_Y);
}
sqlOrderBy= " ORDER BY " + this.mapearCampoOrdenamiento(argumentosListar.getCampoOrdenamiento()) + " " + argumentosListar.getSentidoOrdenamiento();
StringBuilder consultaSQL = new StringBuilder();
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(sqlWhere);
consultaSQL.append(sqlOrderBy);
consultaSQL.append(sqlLimit);
listaRegistros = jdbcTemplate.query(consultaSQL.toString(),parametros.toArray(), new CompartimentoMapper());
totalRegistros = listaRegistros.size();
totalEncontrados =totalRegistros;
contenido.carga = listaRegistros;
respuesta.estado = true;
respuesta.contenido = contenido;
respuesta.contenido.totalRegistros = totalRegistros;
respuesta.contenido.totalEncontrados = totalEncontrados;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado = false;
respuesta.contenido=null;
} catch (Exception excepcionGenerica) {
excepcionGenerica.printStackTrace();
respuesta.error= Constante.EXCEPCION_GENERICA;
respuesta.contenido=null;
respuesta.estado = false;
}
return respuesta;
}
public RespuestaCompuesta recuperarRegistro(int ID){
StringBuilder consultaSQL= new StringBuilder();
List<Compartimento> listaRegistros=new ArrayList<Compartimento>();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
RespuestaCompuesta respuesta= new RespuestaCompuesta();
try {
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(" WHERE ");
consultaSQL.append(NOMBRE_CAMPO_CLAVE);
consultaSQL.append("=?");
listaRegistros= jdbcTemplate.query(consultaSQL.toString(),new Object[] {ID},new CompartimentoMapper());
contenido.totalRegistros=listaRegistros.size();
contenido.totalEncontrados=listaRegistros.size();
contenido.carga= listaRegistros;
respuesta.mensaje="OK";
respuesta.estado=true;
respuesta.contenido = contenido;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error = Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
respuesta.contenido=null;
}
return respuesta;
}
public RespuestaCompuesta guardarRegistro(Compartimento compartimento){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
StringBuilder consultaSQL= new StringBuilder();
KeyHolder claveGenerada = null;
int cantidadFilasAfectadas=0;
try {
consultaSQL.append("INSERT INTO ");
consultaSQL.append(NOMBRE_TABLA);
consultaSQL.append(" (identificador,capacidad_volumetrica,altura_flecha,id_cisterna,id_tracto) ");
consultaSQL.append(" VALUES (:Identificador,:CapacidadVolumetrica,:AlturaFlecha,:IdCisterna,:IdTracto) ");
MapSqlParameterSource listaParametros= new MapSqlParameterSource();
listaParametros.addValue("Identificador", compartimento.getIdentificador());
listaParametros.addValue("CapacidadVolumetrica", compartimento.getCapacidadVolumetrica());
listaParametros.addValue("AlturaFlecha", compartimento.getAlturaFlecha());
listaParametros.addValue("IdCisterna", compartimento.getIdCisterna());
listaParametros.addValue("IdTracto", compartimento.getIdTracto());
SqlParameterSource namedParameters= listaParametros;
/*Ejecuta la consulta y retorna las filas afectadas*/
claveGenerada = new GeneratedKeyHolder();
cantidadFilasAfectadas= namedJdbcTemplate.update(consultaSQL.toString(),namedParameters,claveGenerada,new String[] {NOMBRE_CAMPO_CLAVE});
if (cantidadFilasAfectadas>1){
respuesta.error=Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
respuesta.valor= claveGenerada.getKey().toString();
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error=Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta actualizarRegistro(Compartimento compartimento){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
StringBuilder consultaSQL= new StringBuilder();
int cantidadFilasAfectadas=0;
try {
consultaSQL.append("UPDATE ");
consultaSQL.append(NOMBRE_TABLA);
consultaSQL.append(" SET ");
consultaSQL.append("identificador=:Identificador,");
consultaSQL.append("capacidad_volumetrica=:CapacidadVolumetrica,");
consultaSQL.append("altura_flecha=:AlturaFlecha,");
consultaSQL.append("id_cisterna=:IdCisterna,");
consultaSQL.append("id_tracto=:IdTracto ");
// consultaSQL.append("actualizado_por=:ActualizadoPor,");
// consultaSQL.append("actualizado_el=:ActualizadoEl,");
// consultaSQL.append("ip_actualizacion=:IpActualizacion");
consultaSQL.append(" WHERE ");
consultaSQL.append(NOMBRE_CAMPO_CLAVE);
consultaSQL.append("=:Id");
MapSqlParameterSource listaParametros= new MapSqlParameterSource();
listaParametros.addValue("Identificador", compartimento.getIdentificador());
listaParametros.addValue("CapacidadVolumetrica", compartimento.getCapacidadVolumetrica());
listaParametros.addValue("AlturaFlecha", compartimento.getAlturaFlecha());
listaParametros.addValue("IdCisterna", compartimento.getIdCisterna());
listaParametros.addValue("IdTracto", compartimento.getIdTracto());
//Valores Auditoria
listaParametros.addValue("Id", compartimento.getId());
SqlParameterSource namedParameters= listaParametros;
/*Ejecuta la consulta y retorna las filas afectadas*/
cantidadFilasAfectadas= namedJdbcTemplate.update(consultaSQL.toString(),namedParameters);
if (cantidadFilasAfectadas>1){
respuesta.error= Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta eliminarRegistro(int idRegistro){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
int cantidadFilasAfectadas=0;
String consultaSQL="";
Object[] parametros = {idRegistro};
try {
consultaSQL="DELETE FROM " + NOMBRE_TABLA + " WHERE " + NOMBRE_CAMPO_CLAVE + "=?";
cantidadFilasAfectadas = jdbcTemplate.update(consultaSQL, parametros);
if (cantidadFilasAfectadas > 1){
respuesta.error= Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta eliminarRegistros(int idRegistro){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
int cantidadFilasAfectadas=0;
String consultaSQL="";
Object[] parametros = {idRegistro};
try {
consultaSQL="DELETE FROM " + NOMBRE_TABLA + " WHERE " + CAMPO_CISTERNA + "=?";
cantidadFilasAfectadas = jdbcTemplate.update(consultaSQL, parametros);
respuesta.estado=true;
respuesta.valor= String.valueOf(cantidadFilasAfectadas);
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta recuperarRegistroPorIdCisterna(int idCisterna){
StringBuilder consultaSQL= new StringBuilder();
List<Compartimento> listaRegistros=new ArrayList<Compartimento>();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
RespuestaCompuesta respuesta= new RespuestaCompuesta();
try {
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(" WHERE ");
consultaSQL.append(" t1.id_cisterna = ?");
listaRegistros= jdbcTemplate.query(consultaSQL.toString(),new Object[] {idCisterna},new CompartimentoMapper());
contenido.totalRegistros=listaRegistros.size();
contenido.totalEncontrados=listaRegistros.size();
contenido.carga= listaRegistros;
respuesta.mensaje="OK";
respuesta.estado=true;
respuesta.contenido = contenido;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error = Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
respuesta.contenido=null;
}
return respuesta;
}
} | UTF-8 | Java | 15,124 | java | CompartimentoDao.java | Java | [] | null | [] | package sgo.datos;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import sgo.entidad.Compartimento;
import sgo.entidad.Contenido;
import sgo.entidad.ParametrosListar;
import sgo.entidad.RespuestaCompuesta;
import sgo.utilidades.Constante;
@Repository
public class CompartimentoDao {
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedJdbcTemplate;
public static final String NOMBRE_TABLA = Constante.ESQUEMA_APLICACION + "compartimento";
public static final String NOMBRE_VISTA = Constante.ESQUEMA_APLICACION + "v_compartimento";
public final static String NOMBRE_CAMPO_CLAVE = "id_compartimento";
public final static String CAMPO_NUMERO_COMPARTIMENTO="identificador";
public final static String NOMBRE_CAMPO_NUMERO_COMPARTIMENTO="identificador";
public final static String CAMPO_ALTURA_FLECHA="altura_flecha";
public final static String NOMBRE_CAMPO_ALTURA_FLECHA="alturaFlecha";
public final static String CAMPO_CISTERNA="id_cisterna";
public final static String NOMBRE_CAMPO_CISTERNA="idCisterna";
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}
public DataSource getDataSource(){
return this.jdbcTemplate.getDataSource();
}
public String mapearCampoOrdenamiento(String propiedad){
String campoOrdenamiento="";
try {
if (propiedad.equals("id")){
campoOrdenamiento="id_compartimento";
}
if (propiedad.equals(NOMBRE_CAMPO_NUMERO_COMPARTIMENTO)){
campoOrdenamiento=CAMPO_NUMERO_COMPARTIMENTO;
}
if (propiedad.equals("capacidadVolumetrica")){
campoOrdenamiento="capacidad_volumetrica";
}
if (propiedad.equals(NOMBRE_CAMPO_ALTURA_FLECHA)){
campoOrdenamiento=CAMPO_ALTURA_FLECHA;
}
if (propiedad.equals(NOMBRE_CAMPO_CISTERNA)){
campoOrdenamiento=CAMPO_CISTERNA;
}
//Campos de auditoria
}catch(Exception excepcion){
}
return campoOrdenamiento;
}
public RespuestaCompuesta recuperarRegistros(ParametrosListar argumentosListar) {
String sqlLimit = "";
int totalRegistros = 0, totalEncontrados = 0;
RespuestaCompuesta respuesta = new RespuestaCompuesta();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
List<Compartimento> listaRegistros = new ArrayList<Compartimento>();
List<Object> parametros = new ArrayList<Object>();
List<String> filtrosWhere = new ArrayList<String>();
String sqlWhere = "";
String sqlOrderBy="";
try {
if (argumentosListar.getPaginacion() == Constante.CON_PAGINACION) {
sqlLimit = Constante.SQL_LIMIT_CONFIGURADO;
parametros.add(argumentosListar.getInicioPaginacion());
parametros.add(argumentosListar.getRegistrosxPagina());
}
if (argumentosListar.getFiltroCisterna()>0) {
filtrosWhere.add(" t1." + CAMPO_CISTERNA + "=" + argumentosListar.getFiltroCisterna());
}
if (!filtrosWhere.isEmpty()) {
sqlWhere = " WHERE " + StringUtils.join(filtrosWhere,Constante.SQL_Y);
}
sqlOrderBy= " ORDER BY " + this.mapearCampoOrdenamiento(argumentosListar.getCampoOrdenamiento()) + " " + argumentosListar.getSentidoOrdenamiento();
StringBuilder consultaSQL = new StringBuilder();
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(sqlWhere);
consultaSQL.append(sqlOrderBy);
consultaSQL.append(sqlLimit);
listaRegistros = jdbcTemplate.query(consultaSQL.toString(),parametros.toArray(), new CompartimentoMapper());
totalRegistros = listaRegistros.size();
totalEncontrados =totalRegistros;
contenido.carga = listaRegistros;
respuesta.estado = true;
respuesta.contenido = contenido;
respuesta.contenido.totalRegistros = totalRegistros;
respuesta.contenido.totalEncontrados = totalEncontrados;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado = false;
respuesta.contenido=null;
} catch (Exception excepcionGenerica) {
excepcionGenerica.printStackTrace();
respuesta.error= Constante.EXCEPCION_GENERICA;
respuesta.contenido=null;
respuesta.estado = false;
}
return respuesta;
}
public RespuestaCompuesta recuperarRegistro(int ID){
StringBuilder consultaSQL= new StringBuilder();
List<Compartimento> listaRegistros=new ArrayList<Compartimento>();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
RespuestaCompuesta respuesta= new RespuestaCompuesta();
try {
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(" WHERE ");
consultaSQL.append(NOMBRE_CAMPO_CLAVE);
consultaSQL.append("=?");
listaRegistros= jdbcTemplate.query(consultaSQL.toString(),new Object[] {ID},new CompartimentoMapper());
contenido.totalRegistros=listaRegistros.size();
contenido.totalEncontrados=listaRegistros.size();
contenido.carga= listaRegistros;
respuesta.mensaje="OK";
respuesta.estado=true;
respuesta.contenido = contenido;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error = Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
respuesta.contenido=null;
}
return respuesta;
}
public RespuestaCompuesta guardarRegistro(Compartimento compartimento){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
StringBuilder consultaSQL= new StringBuilder();
KeyHolder claveGenerada = null;
int cantidadFilasAfectadas=0;
try {
consultaSQL.append("INSERT INTO ");
consultaSQL.append(NOMBRE_TABLA);
consultaSQL.append(" (identificador,capacidad_volumetrica,altura_flecha,id_cisterna,id_tracto) ");
consultaSQL.append(" VALUES (:Identificador,:CapacidadVolumetrica,:AlturaFlecha,:IdCisterna,:IdTracto) ");
MapSqlParameterSource listaParametros= new MapSqlParameterSource();
listaParametros.addValue("Identificador", compartimento.getIdentificador());
listaParametros.addValue("CapacidadVolumetrica", compartimento.getCapacidadVolumetrica());
listaParametros.addValue("AlturaFlecha", compartimento.getAlturaFlecha());
listaParametros.addValue("IdCisterna", compartimento.getIdCisterna());
listaParametros.addValue("IdTracto", compartimento.getIdTracto());
SqlParameterSource namedParameters= listaParametros;
/*Ejecuta la consulta y retorna las filas afectadas*/
claveGenerada = new GeneratedKeyHolder();
cantidadFilasAfectadas= namedJdbcTemplate.update(consultaSQL.toString(),namedParameters,claveGenerada,new String[] {NOMBRE_CAMPO_CLAVE});
if (cantidadFilasAfectadas>1){
respuesta.error=Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
respuesta.valor= claveGenerada.getKey().toString();
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error=Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta actualizarRegistro(Compartimento compartimento){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
StringBuilder consultaSQL= new StringBuilder();
int cantidadFilasAfectadas=0;
try {
consultaSQL.append("UPDATE ");
consultaSQL.append(NOMBRE_TABLA);
consultaSQL.append(" SET ");
consultaSQL.append("identificador=:Identificador,");
consultaSQL.append("capacidad_volumetrica=:CapacidadVolumetrica,");
consultaSQL.append("altura_flecha=:AlturaFlecha,");
consultaSQL.append("id_cisterna=:IdCisterna,");
consultaSQL.append("id_tracto=:IdTracto ");
// consultaSQL.append("actualizado_por=:ActualizadoPor,");
// consultaSQL.append("actualizado_el=:ActualizadoEl,");
// consultaSQL.append("ip_actualizacion=:IpActualizacion");
consultaSQL.append(" WHERE ");
consultaSQL.append(NOMBRE_CAMPO_CLAVE);
consultaSQL.append("=:Id");
MapSqlParameterSource listaParametros= new MapSqlParameterSource();
listaParametros.addValue("Identificador", compartimento.getIdentificador());
listaParametros.addValue("CapacidadVolumetrica", compartimento.getCapacidadVolumetrica());
listaParametros.addValue("AlturaFlecha", compartimento.getAlturaFlecha());
listaParametros.addValue("IdCisterna", compartimento.getIdCisterna());
listaParametros.addValue("IdTracto", compartimento.getIdTracto());
//Valores Auditoria
listaParametros.addValue("Id", compartimento.getId());
SqlParameterSource namedParameters= listaParametros;
/*Ejecuta la consulta y retorna las filas afectadas*/
cantidadFilasAfectadas= namedJdbcTemplate.update(consultaSQL.toString(),namedParameters);
if (cantidadFilasAfectadas>1){
respuesta.error= Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta eliminarRegistro(int idRegistro){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
int cantidadFilasAfectadas=0;
String consultaSQL="";
Object[] parametros = {idRegistro};
try {
consultaSQL="DELETE FROM " + NOMBRE_TABLA + " WHERE " + NOMBRE_CAMPO_CLAVE + "=?";
cantidadFilasAfectadas = jdbcTemplate.update(consultaSQL, parametros);
if (cantidadFilasAfectadas > 1){
respuesta.error= Constante.EXCEPCION_CANTIDAD_REGISTROS_INCORRECTA;
respuesta.estado=false;
return respuesta;
}
respuesta.estado=true;
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta eliminarRegistros(int idRegistro){
RespuestaCompuesta respuesta = new RespuestaCompuesta();
int cantidadFilasAfectadas=0;
String consultaSQL="";
Object[] parametros = {idRegistro};
try {
consultaSQL="DELETE FROM " + NOMBRE_TABLA + " WHERE " + CAMPO_CISTERNA + "=?";
cantidadFilasAfectadas = jdbcTemplate.update(consultaSQL, parametros);
respuesta.estado=true;
respuesta.valor= String.valueOf(cantidadFilasAfectadas);
} catch (DataIntegrityViolationException excepcionIntegridadDatos){
excepcionIntegridadDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_INTEGRIDAD_DATOS;
respuesta.estado=false;
} catch (DataAccessException excepcionAccesoDatos){
excepcionAccesoDatos.printStackTrace();
respuesta.error= Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
}
return respuesta;
}
public RespuestaCompuesta recuperarRegistroPorIdCisterna(int idCisterna){
StringBuilder consultaSQL= new StringBuilder();
List<Compartimento> listaRegistros=new ArrayList<Compartimento>();
Contenido<Compartimento> contenido = new Contenido<Compartimento>();
RespuestaCompuesta respuesta= new RespuestaCompuesta();
try {
consultaSQL.append("SELECT ");
consultaSQL.append("t1.id_compartimento,");
consultaSQL.append("t1.identificador,");
consultaSQL.append("t1.capacidad_volumetrica,");
consultaSQL.append("t1.altura_flecha,");
consultaSQL.append("t1.id_cisterna,");
consultaSQL.append("t1.id_tracto");
consultaSQL.append(" FROM ");
consultaSQL.append(NOMBRE_VISTA);
consultaSQL.append(" t1 ");
consultaSQL.append(" WHERE ");
consultaSQL.append(" t1.id_cisterna = ?");
listaRegistros= jdbcTemplate.query(consultaSQL.toString(),new Object[] {idCisterna},new CompartimentoMapper());
contenido.totalRegistros=listaRegistros.size();
contenido.totalEncontrados=listaRegistros.size();
contenido.carga= listaRegistros;
respuesta.mensaje="OK";
respuesta.estado=true;
respuesta.contenido = contenido;
} catch (DataAccessException excepcionAccesoDatos) {
excepcionAccesoDatos.printStackTrace();
respuesta.error = Constante.EXCEPCION_ACCESO_DATOS;
respuesta.estado=false;
respuesta.contenido=null;
}
return respuesta;
}
} | 15,124 | 0.72018 | 0.717998 | 342 | 43.225147 | 25.868406 | 154 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.923977 | false | false | 13 |
96678f4dfb9accb9ece1e85c9cde5a5f1240fbeb | 23,287,312,683,196 | 0c84f9b6c7837223d4654f3c6f54ac565874498a | /DistSystems/HTCoursework/example/Dealing/DealOperations.java | 386cc7f29c2fad56ad03341189a9c52845072148 | [] | no_license | Chavyneebslod/Semester1 | https://github.com/Chavyneebslod/Semester1 | 1cd966c4784023306d13de16d587ab7b5bba2b1d | 3c5bdafa4bad446ca569f0e8b5e5e30ebf833b5d | refs/heads/master | 2021-01-18T14:22:12.770000 | 2011-02-25T19:25:53 | 2011-02-25T19:25:53 | 1,412,118 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Dealing;
/**
* Dealing/DealOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from dealing.idl
* Friday, 26 November 2010 16:43:44 o'clock GMT
*/
public interface DealOperations
{
void addBuy (Dealing.b b);
Dealing.b[] getBuys ();
} // interface DealOperations
| UTF-8 | Java | 312 | java | DealOperations.java | Java | [] | null | [] | package Dealing;
/**
* Dealing/DealOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from dealing.idl
* Friday, 26 November 2010 16:43:44 o'clock GMT
*/
public interface DealOperations
{
void addBuy (Dealing.b b);
Dealing.b[] getBuys ();
} // interface DealOperations
| 312 | 0.711538 | 0.666667 | 15 | 19.799999 | 18.94272 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 13 |
ab88682e5a5b4712a024fc518759e607e86babe9 | 28,132,035,832,109 | 92149490b4a84e6dc8c758fa2cb4013e4e269a4b | /src/main/java/stevekung/mods/moreplanets/util/debug/MorePlanetsCapabilityData.java | f521e297604863d2b95a44210f0fd490d9b4abae | [] | no_license | UROBBYU/MorePlanets | https://github.com/UROBBYU/MorePlanets | 06e59a55a3c095170f1f93c89ea0c378726cecd9 | 78a44333ab2b99f0b43cb81db389641851926593 | HEAD | 2019-03-18T22:39:49.455000 | 2018-03-01T13:29:26 | 2018-03-01T13:29:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package stevekung.mods.moreplanets.util.debug;
import net.minecraft.nbt.NBTTagCompound;
public interface MorePlanetsCapabilityData
{
public abstract void writeNBT(NBTTagCompound nbt);
public abstract void readNBT(NBTTagCompound nbt);
public void setStartCelestial(String object);
public String getStartCelestial();
} | UTF-8 | Java | 337 | java | MorePlanetsCapabilityData.java | Java | [
{
"context": "package stevekung.mods.moreplanets.util.debug;\n\nimport net.minecraf",
"end": 17,
"score": 0.9095659255981445,
"start": 8,
"tag": "USERNAME",
"value": "stevekung"
}
] | null | [] | package stevekung.mods.moreplanets.util.debug;
import net.minecraft.nbt.NBTTagCompound;
public interface MorePlanetsCapabilityData
{
public abstract void writeNBT(NBTTagCompound nbt);
public abstract void readNBT(NBTTagCompound nbt);
public void setStartCelestial(String object);
public String getStartCelestial();
} | 337 | 0.795252 | 0.795252 | 14 | 23.142857 | 23.228237 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 13 |
4d659f12e953c5fec3e796a90a0f538066f1429b | 29,437,705,910,108 | f222f641c27dfa54c6e3d3b55e0185e4940b92ae | /java/code/src/struct/adapter/main.java | 6ffc97326ac56564c2102303a19b7441ca8efa5a | [] | no_license | flipped0908/designPattern | https://github.com/flipped0908/designPattern | be6d0cdc85730e5a474fd28e8d72ba0b758b49d8 | ae0f51516ddc7e8820451f49ef6964c281904f0a | refs/heads/master | 2020-05-01T14:33:21.008000 | 2019-04-10T03:30:17 | 2019-04-10T03:30:17 | 177,523,474 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package src.struct.adapter;
public class main {
public static void main(String[] args) {
Captain captain = new Captain(new FishingBoatAdapter());
captain.row();
}
}
| UTF-8 | Java | 196 | java | main.java | Java | [] | null | [] | package src.struct.adapter;
public class main {
public static void main(String[] args) {
Captain captain = new Captain(new FishingBoatAdapter());
captain.row();
}
}
| 196 | 0.627551 | 0.627551 | 14 | 13 | 19.394403 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.214286 | false | false | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.